From kwrobot at kitware.com Sat Aug 1 00:01:08 2015 From: kwrobot at kitware.com (Kitware Robot) Date: Sat, 1 Aug 2015 00:01:08 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-660-g9432b14 Message-ID: <20150801040108.BA1EBB1105@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 9432b14e916421a727265f9a05dc1fbe6c6ec381 (commit) from 6c3d0e9a6bf88a03442acf1f0bc1ef1575779d46 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9432b14e916421a727265f9a05dc1fbe6c6ec381 commit 9432b14e916421a727265f9a05dc1fbe6c6ec381 Author: Kitware Robot AuthorDate: Sat Aug 1 00:01:06 2015 -0400 Commit: Kitware Robot CommitDate: Sat Aug 1 00:01:06 2015 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 34779a5..5d53072 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150731) +set(CMake_VERSION_PATCH 20150801) #set(CMake_VERSION_RC 1) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From steveire at gmail.com Sat Aug 1 01:07:14 2015 From: steveire at gmail.com (Stephen Kelly) Date: Sat, 1 Aug 2015 01:07:14 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1647-g383ae66 Message-ID: <20150801050714.3758FB113B@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 383ae666d2bfad26165c87c9edfebea52c82119e (commit) via e7db0856abb64c72187654d60ddb37b92c32a461 (commit) via 781beea3f7d6c8473d7b7090c76e2c7099d4968e (commit) via 0c62b16f28c7663d52d996edad4cf1b98813d0a1 (commit) via 81aef5efa638ad70264764af5a8790343b0d92cd (commit) via 4bba0342d18b9720fd2f256f6a1eca66719dcf7e (commit) via 7b9e4b50b82f3235775a2d016702905bd948373a (commit) via bb0e698f451ab24e63c485ff8398c71f8988590b (commit) via afb84b31e8277b2955284ad34708f58ea1db744f (commit) via baae0995abb15e6f5e2a4933ad34c1858a9042fd (commit) via cbb5037d0a246d998672da3e1b3fb517909ec5ae (commit) via 05bd71ce438bb92348f0948661ead92cbf09d982 (commit) via dd64a8b53b8e06979e28ffae61970037ce522f7a (commit) via ee0d75a5f81aadecb6d0b94b78c9f21bff5aba44 (commit) via 6e4e98de6e3bb604281e3f387ecee619c5f23709 (commit) via 938acba9e0f7fe6cc3a7eec5de4a10021a0aef05 (commit) via be205eb56d91414749b7a6073e14747e840d1aba (commit) via 1bd6d804a909be8884bf5dd234d8f6125c92d5a9 (commit) via d222009a0fe7bf9d060b3ce49e0e720046936f89 (commit) via 65e833dbf0b8372e719c6140cc1373e46e078ae8 (commit) via 1ce989a66c3aa97d1a8ca933123335d279671e83 (commit) via 2714f048b387b5387c248aa186b7892f4473055f (commit) via 544d3aa3038b565de500ef2f53f54b482c261296 (commit) via 5dc07198725d60d9cee3abf78f23ca9177a2fdd1 (commit) via 723f56e7c2848d587aae854410c86d3030508b9d (commit) via 82b706b70fbaa9b7469e03b3ef63ab8b66a49b5b (commit) via 2706b1fde45c27145805032aa0daa432b5f882b3 (commit) via 16a97e777828f96d2b6eee2106817fbd13f6c261 (commit) via 55e097ae0cc3b0a722ed56883c5f9ada772d5c09 (commit) via 65d9ff20a94bcd0439dfd8dd4a29e30bd1a49dd3 (commit) via a19a796b4f8c2eb2da33b2c23337596d1f109521 (commit) via 47c898cfc53430626eab7448c8657ecae15815d9 (commit) via 4af3f7ef11fd9118f259c5d9b05747c964ef620b (commit) via 29637d6c119ed98b28099023e3203ade09b6c6c9 (commit) via 3975e01b69b97fdcb887bb3607481a616e678a9a (commit) via 8c746162c33a1c207bf30a0261d35c8c7204898e (commit) from 967364dea4fb2a13bfe22f73d8343bccf15d3883 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=383ae666d2bfad26165c87c9edfebea52c82119e commit 383ae666d2bfad26165c87c9edfebea52c82119e Merge: 967364d e7db085 Author: Stephen Kelly AuthorDate: Sat Aug 1 01:07:08 2015 -0400 Commit: CMake Topic Stage CommitDate: Sat Aug 1 01:07:08 2015 -0400 Merge topic 'use-generator-target' into next e7db0856 cmGeneratorTarget: Move CompileInfoMap from cmTarget. 781beea3 cmGeneratorTarget: Move GetCompilePDBDirectory from cmTarget. 0c62b16f cmGeneratorTarget: Move GetOutputName from cmTarget. 81aef5ef cmComputeLinkDepends: Port to cmGeneratorTarget. 4bba0342 cmComputeLinkInformation: Port to cmGeneratorTarget. 7b9e4b50 cmGeneratorTarget: Move IsBundleOnApple from cmTarget. bb0e698f cmMakefileTargetGenerator: Add accessor for GeneratorTarget. afb84b31 cmGeneratorTarget: Move GetLinkClosure from cmTarget. baae0995 cmGeneratorTarget: Move GetLinkerLanguage from cmTarget. cbb5037d cmGeneratorTarget: Move GetFrameworkDirectory from cmTarget. 05bd71ce cmGeneratorTarget: Move GetFullNameInternal from cmTarget. dd64a8b5 cmGeneratorTarget: Move GetFullName from cmTarget. ee0d75a5 cmGeneratorTarget: Move GetAppBundleDirectory from cmTarget. 6e4e98de cmGeneratorTarget: Move GetInstallNameDir* from cmTarget. 938acba9 cmGeneratorTarget: Move GetMacContentDirectory from cmTarget. be205eb5 cmGeneratorTarget: Move GetFullNameComponents from cmTarget. ... http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e7db0856abb64c72187654d60ddb37b92c32a461 commit e7db0856abb64c72187654d60ddb37b92c32a461 Author: Stephen Kelly AuthorDate: Mon Oct 20 21:02:16 2014 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:04:26 2015 +0200 cmGeneratorTarget: Move CompileInfoMap from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index b8a0859..45812c7 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1356,6 +1356,46 @@ cmGeneratorTarget::GetMacContentDirectory(const std::string& config, return fpath; } + +//---------------------------------------------------------------------------- +cmGeneratorTarget::CompileInfo const* cmGeneratorTarget::GetCompileInfo( + const std::string& config) const +{ + // There is no compile information for imported targets. + if(this->IsImported()) + { + return 0; + } + + if(this->GetType() > cmTarget::OBJECT_LIBRARY) + { + std::string msg = "cmTarget::GetCompileInfo called for "; + msg += this->GetName(); + msg += " which has type "; + msg += cmTarget::GetTargetTypeName(this->Target->GetType()); + this->Makefile->IssueMessage(cmake::INTERNAL_ERROR, msg); + return 0; + } + + // Lookup/compute/cache the compile information for this configuration. + std::string config_upper; + if(!config.empty()) + { + config_upper = cmSystemTools::UpperCase(config); + } + CompileInfoMapType::const_iterator i = + this->CompileInfoMap.find(config_upper); + if(i == this->CompileInfoMap.end()) + { + CompileInfo info; + this->Target + ->ComputePDBOutputDir("COMPILE_PDB", config, info.CompilePdbDir); + CompileInfoMapType::value_type entry(config_upper, info); + i = this->CompileInfoMap.insert(entry).first; + } + return &i->second; +} + //---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetModuleDefinitionFile(const std::string& config) const @@ -1827,7 +1867,7 @@ void cmGeneratorTarget::TraceDependencies() std::string cmGeneratorTarget::GetCompilePDBDirectory(const std::string& config) const { - if(cmTarget::CompileInfo const* info = this->Target->GetCompileInfo(config)) + if(CompileInfo const* info = this->GetCompileInfo(config)) { return info->CompilePdbDir; } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index c291919..1d7a411 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -230,6 +230,16 @@ public: /** Whether this library has soname enabled and platform supports it. */ bool HasSOName(const std::string& config) const; + struct CompileInfo + { + std::string CompilePdbDir; + }; + + CompileInfo const* GetCompileInfo(const std::string& config) const; + + typedef std::map CompileInfoMapType; + mutable CompileInfoMapType CompileInfoMap; + /** Get the name of the compiler pdb file for the target. */ std::string GetCompilePDBName(const std::string& config="") const; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 9308113..1f8f07a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -126,9 +126,6 @@ public: typedef std::map ImportInfoMapType; ImportInfoMapType ImportInfoMap; - typedef std::map CompileInfoMapType; - CompileInfoMapType CompileInfoMap; - // Cache link implementation computation from each configuration. struct OptionalLinkImplementation: public cmTarget::LinkImplementation { @@ -2598,45 +2595,6 @@ cmTarget::OutputInfo const* cmTarget::GetOutputInfo( } //---------------------------------------------------------------------------- -cmTarget::CompileInfo const* cmTarget::GetCompileInfo( - const std::string& config) const -{ - // There is no compile information for imported targets. - if(this->IsImported()) - { - return 0; - } - - if(this->GetType() > cmTarget::OBJECT_LIBRARY) - { - std::string msg = "cmTarget::GetCompileInfo called for "; - msg += this->GetName(); - msg += " which has type "; - msg += cmTarget::GetTargetTypeName(this->GetType()); - this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg); - return 0; - } - - // Lookup/compute/cache the compile information for this configuration. - std::string config_upper; - if(!config.empty()) - { - config_upper = cmSystemTools::UpperCase(config); - } - typedef cmTargetInternals::CompileInfoMapType CompileInfoMapType; - CompileInfoMapType::const_iterator i = - this->Internal->CompileInfoMap.find(config_upper); - if(i == this->Internal->CompileInfoMap.end()) - { - CompileInfo info; - this->ComputePDBOutputDir("COMPILE_PDB", config, info.CompilePdbDir); - CompileInfoMapType::value_type entry(config_upper, info); - i = this->Internal->CompileInfoMap.insert(entry).first; - } - return &i->second; -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetDirectory(const std::string& config, bool implib) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 8689838..e3fbdfd 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -626,13 +626,6 @@ private: void ComputeImportInfo(std::string const& desired_config, ImportInfo& info) const; - // Cache target compile paths for each configuration. - struct CompileInfo - { - std::string CompilePdbDir; - }; - - CompileInfo const* GetCompileInfo(const std::string& config) const; LinkInterface const* GetImportLinkInterface(const std::string& config, cmTarget const* head, http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=781beea3f7d6c8473d7b7090c76e2c7099d4968e commit 781beea3f7d6c8473d7b7090c76e2c7099d4968e Author: Stephen Kelly AuthorDate: Mon Oct 20 20:52:54 2014 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:04:25 2015 +0200 cmGeneratorTarget: Move GetCompilePDBDirectory from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 7d7be5b..b8a0859 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -743,7 +743,7 @@ cmGeneratorTarget::GetCompilePDBName(const std::string& config) const std::string cmGeneratorTarget::GetCompilePDBPath(const std::string& config) const { - std::string dir = this->Target->GetCompilePDBDirectory(config); + std::string dir = this->GetCompilePDBDirectory(config); std::string name = this->GetCompilePDBName(config); if(dir.empty() && !name.empty()) { @@ -1824,6 +1824,16 @@ void cmGeneratorTarget::TraceDependencies() tracer.Trace(); } +std::string +cmGeneratorTarget::GetCompilePDBDirectory(const std::string& config) const +{ + if(cmTarget::CompileInfo const* info = this->Target->GetCompileInfo(config)) + { + return info->CompilePdbDir; + } + return ""; +} + //---------------------------------------------------------------------------- void cmGeneratorTarget::GetAppleArchs(const std::string& config, std::vector& archVec) const diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 31b3178..c291919 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -214,6 +214,12 @@ public: */ void TraceDependencies(); + /** Get the directory in which to place the target compiler .pdb file. + If the configuration name is given then the generator will add its + subdirectory for that configuration. Otherwise just the canonical + compiler pdb output directory is given. */ + std::string GetCompilePDBDirectory(const std::string& config = "") const; + /** Get sources that must be built before the given source. */ std::vector const* GetSourceDepends(cmSourceFile const* sf) const; diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index afe145a..ccb0974 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -130,7 +130,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) } std::string compilePdbOutputPath = - this->Target->GetCompilePDBDirectory(this->ConfigName); + this->GeneratorTarget->GetCompilePDBDirectory(this->ConfigName); cmSystemTools::MakeDirectory(compilePdbOutputPath.c_str()); std::string pdbOutputPath = this->Target->GetPDBDirectory(this->ConfigName); diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index bb0f9dd..2f995e8 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -311,7 +311,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules } std::string compilePdbOutputPath = - this->Target->GetCompilePDBDirectory(this->ConfigName); + this->GeneratorTarget->GetCompilePDBDirectory(this->ConfigName); cmSystemTools::MakeDirectory(compilePdbOutputPath.c_str()); std::string pdbOutputPath = this->Target->GetPDBDirectory(this->ConfigName); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 8b64bc4..9308113 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -69,12 +69,6 @@ struct cmTarget::OutputInfo }; //---------------------------------------------------------------------------- -struct cmTarget::CompileInfo -{ - std::string CompilePdbDir; -}; - -//---------------------------------------------------------------------------- class cmTargetInternals { public: @@ -2673,16 +2667,6 @@ std::string cmTarget::GetPDBDirectory(const std::string& config) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetCompilePDBDirectory(const std::string& config) const -{ - if(CompileInfo const* info = this->GetCompileInfo(config)) - { - return info->CompilePdbDir; - } - return ""; -} - -//---------------------------------------------------------------------------- const char* cmTarget::ImportedGetLocation(const std::string& config) const { static std::string location; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index a6f2465..8689838 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -334,12 +334,6 @@ public: pdb output directory is given. */ std::string GetPDBDirectory(const std::string& config) const; - /** Get the directory in which to place the target compiler .pdb file. - If the configuration name is given then the generator will add its - subdirectory for that configuration. Otherwise just the canonical - compiler pdb output directory is given. */ - std::string GetCompilePDBDirectory(const std::string& config = "") const; - const char* ImportedGetLocation(const std::string& config) const; /** Get the target major and minor version numbers interpreted from @@ -633,7 +627,11 @@ private: ImportInfo& info) const; // Cache target compile paths for each configuration. - struct CompileInfo; + struct CompileInfo + { + std::string CompilePdbDir; + }; + CompileInfo const* GetCompileInfo(const std::string& config) const; LinkInterface const* http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0c62b16f28c7663d52d996edad4cf1b98813d0a1 commit 0c62b16f28c7663d52d996edad4cf1b98813d0a1 Author: Stephen Kelly AuthorDate: Sat Aug 1 07:04:23 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:04:23 2015 +0200 cmGeneratorTarget: Move GetOutputName from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index d3067df..7d7be5b 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -267,6 +267,54 @@ const char *cmGeneratorTarget::GetProperty(const std::string& prop) const } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetOutputName(const std::string& config, + bool implib) const +{ + std::vector props; + std::string type = this->Target->GetOutputTargetType(implib); + std::string configUpper = cmSystemTools::UpperCase(config); + if(!type.empty() && !configUpper.empty()) + { + // _OUTPUT_NAME_ + props.push_back(type + "_OUTPUT_NAME_" + configUpper); + } + if(!type.empty()) + { + // _OUTPUT_NAME + props.push_back(type + "_OUTPUT_NAME"); + } + if(!configUpper.empty()) + { + // OUTPUT_NAME_ + props.push_back("OUTPUT_NAME_" + configUpper); + // _OUTPUT_NAME + props.push_back(configUpper + "_OUTPUT_NAME"); + } + // OUTPUT_NAME + props.push_back("OUTPUT_NAME"); + + std::string outName; + for(std::vector::const_iterator i = props.begin(); + i != props.end(); ++i) + { + if (const char* outNameProp = this->Target->GetProperty(*i)) + { + outName = outNameProp; + break; + } + } + + if (outName.empty()) + { + outName = this->GetName(); + } + + cmGeneratorExpression ge; + cmsys::auto_ptr cge = ge.Parse(outName); + return cge->Evaluate(this->Makefile, config); +} + +//---------------------------------------------------------------------------- std::vector const* cmGeneratorTarget::GetSourceDepends(cmSourceFile const* sf) const { @@ -922,7 +970,7 @@ std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config, bool contentOnly) const { std::string fpath; - fpath += this->Target->GetOutputName(config, false); + fpath += this->GetOutputName(config, false); fpath += "."; const char *ext = this->Target->GetProperty("BUNDLE_EXTENSION"); if (!ext) @@ -949,7 +997,7 @@ cmGeneratorTarget::GetFrameworkDirectory(const std::string& config, bool rootDir) const { std::string fpath; - fpath += this->Target->GetOutputName(config, false); + fpath += this->GetOutputName(config, false); fpath += ".framework"; if(!rootDir) { @@ -2247,7 +2295,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, std::string fw_prefix; if(this->Target->IsFrameworkOnApple()) { - fw_prefix = this->Target->GetOutputName(config, false); + fw_prefix = this->GetOutputName(config, false); fw_prefix += ".framework/"; targetPrefix = fw_prefix.c_str(); targetSuffix = 0; @@ -2265,7 +2313,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, outPrefix = targetPrefix?targetPrefix:""; // Append the target name or property-specified name. - outBase += this->Target->GetOutputName(config, implib); + outBase += this->GetOutputName(config, implib); // Append the per-configuration postfix. outBase += configPostfix?configPostfix:""; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index d10cd1d..31b3178 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -230,6 +230,9 @@ public: /** Get the path for the MSVC /Fd option for this target. */ std::string GetCompilePDBPath(const std::string& config="") const; + // Get the target base name. + std::string GetOutputName(const std::string& config, bool implib) const; + /** * Flags for a given source file as used in this target. Typically assigned * via SET_TARGET_PROPERTIES when the property is a list of source files. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e887ef3..8b64bc4 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3663,54 +3663,6 @@ bool cmTarget::UsesDefaultOutputDir(const std::string& config, } //---------------------------------------------------------------------------- -std::string cmTarget::GetOutputName(const std::string& config, - bool implib) const -{ - std::vector props; - std::string type = this->GetOutputTargetType(implib); - std::string configUpper = cmSystemTools::UpperCase(config); - if(!type.empty() && !configUpper.empty()) - { - // _OUTPUT_NAME_ - props.push_back(type + "_OUTPUT_NAME_" + configUpper); - } - if(!type.empty()) - { - // _OUTPUT_NAME - props.push_back(type + "_OUTPUT_NAME"); - } - if(!configUpper.empty()) - { - // OUTPUT_NAME_ - props.push_back("OUTPUT_NAME_" + configUpper); - // _OUTPUT_NAME - props.push_back(configUpper + "_OUTPUT_NAME"); - } - // OUTPUT_NAME - props.push_back("OUTPUT_NAME"); - - std::string outName; - for(std::vector::const_iterator i = props.begin(); - i != props.end(); ++i) - { - if (const char* outNameProp = this->GetProperty(*i)) - { - outName = outNameProp; - break; - } - } - - if (outName.empty()) - { - outName = this->GetName(); - } - - cmGeneratorExpression ge; - cmsys::auto_ptr cge = ge.Parse(outName); - return cge->Evaluate(this->Makefile, config); -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetFrameworkVersion() const { assert(this->GetType() != INTERFACE_LIBRARY); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e53afff..a6f2465 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -552,9 +552,6 @@ private: // Returns ARCHIVE, LIBRARY, or RUNTIME based on platform and type. const char* GetOutputTargetType(bool implib) const; - // Get the target base name. - std::string GetOutputName(const std::string& config, bool implib) const; - std::string GetFullNameImported(const std::string& config, bool implib) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=81aef5efa638ad70264764af5a8790343b0d92cd commit 81aef5efa638ad70264764af5a8790343b0d92cd Author: Stephen Kelly AuthorDate: Thu Jul 30 00:45:34 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:03:47 2015 +0200 cmComputeLinkDepends: Port to cmGeneratorTarget. diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index abd9877..8ba8847 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -173,18 +173,19 @@ items that we know the linker will re-use automatically (shared libs). //---------------------------------------------------------------------------- cmComputeLinkDepends -::cmComputeLinkDepends(cmTarget const* target, const std::string& config) +::cmComputeLinkDepends(const cmGeneratorTarget* target, + const std::string& config) { // Store context information. this->Target = target; - this->Makefile = this->Target->GetMakefile(); + this->Makefile = this->Target->Target->GetMakefile(); this->GlobalGenerator = this->Makefile->GetGlobalGenerator(); this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance(); // The configuration being linked. this->HasConfig = !config.empty(); this->Config = (this->HasConfig)? config : std::string(); - this->LinkType = this->Target->ComputeLinkType(this->Config); + this->LinkType = this->Target->Target->ComputeLinkType(this->Config); // Enable debug mode if requested. this->DebugMode = this->Makefile->IsOn("CMAKE_LINK_DEPENDS_DEBUG_MODE"); @@ -363,7 +364,7 @@ void cmComputeLinkDepends::FollowLinkEntry(BFSEntry const& qe) { // Follow the target dependencies. if(cmTarget::LinkInterface const* iface = - entry.Target->GetLinkInterface(this->Config, this->Target)) + entry.Target->GetLinkInterface(this->Config, this->Target->Target)) { const bool isIface = entry.Target->GetType() == cmTarget::INTERFACE_LIBRARY; @@ -461,7 +462,7 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep) if(entry.Target) { if(cmTarget::LinkInterface const* iface = - entry.Target->GetLinkInterface(this->Config, this->Target)) + entry.Target->GetLinkInterface(this->Config, this->Target->Target)) { // Follow public and private dependencies transitively. this->FollowSharedDeps(index, iface, true); @@ -552,7 +553,7 @@ void cmComputeLinkDepends::AddDirectLinkEntries() { // Add direct link dependencies in this configuration. cmTarget::LinkImplementation const* impl = - this->Target->GetLinkImplementation(this->Config); + this->Target->Target->GetLinkImplementation(this->Config); this->AddLinkEntries(-1, impl->Libraries); for(std::vector::const_iterator wi = impl->WrongConfigLibraries.begin(); @@ -634,7 +635,7 @@ cmTarget const* cmComputeLinkDepends::FindTargetToLink(int depender_index, const std::string& name) { // Look for a target in the scope of the depender. - cmTarget const* from = this->Target; + cmTarget const* from = this->Target->Target; if(depender_index >= 0) { if(cmTarget const* depender = this->EntryList[depender_index].Target) @@ -932,7 +933,7 @@ int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl) if(cmTarget const* target = this->EntryList[*ni].Target) { if(cmTarget::LinkInterface const* iface = - target->GetLinkInterface(this->Config, this->Target)) + target->GetLinkInterface(this->Config, this->Target->Target)) { if(iface->Multiplicity > count) { diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index 51a08c5..b925a4f 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -22,6 +22,7 @@ class cmComputeComponentGraph; class cmGlobalGenerator; class cmMakefile; +class cmGeneratorTarget; class cmTarget; class cmake; @@ -31,7 +32,8 @@ class cmake; class cmComputeLinkDepends { public: - cmComputeLinkDepends(cmTarget const* target, const std::string& config); + cmComputeLinkDepends(cmGeneratorTarget const* target, + const std::string& config); ~cmComputeLinkDepends(); // Basic information about each link item. @@ -57,7 +59,7 @@ public: private: // Context information. - cmTarget const* Target; + cmGeneratorTarget const* Target; cmMakefile* Makefile; cmGlobalGenerator const* GlobalGenerator; cmake* CMakeInstance; diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index fb89319..5cd0d54 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -497,7 +497,7 @@ bool cmComputeLinkInformation::Compute() } // Compute the ordered link line items. - cmComputeLinkDepends cld(this->Target->Target, this->Config); + cmComputeLinkDepends cld(this->Target, this->Config); cld.SetOldLinkDirMode(this->OldLinkDirMode); cmComputeLinkDepends::EntryVector const& linkEntries = cld.Compute(); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4bba0342d18b9720fd2f256f6a1eca66719dcf7e commit 4bba0342d18b9720fd2f256f6a1eca66719dcf7e Author: Stephen Kelly AuthorDate: Thu Jul 30 00:41:27 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:03:47 2015 +0200 cmComputeLinkInformation: Port to cmGeneratorTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index f03c04a..fb89319 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -242,11 +242,12 @@ because this need be done only for shared libraries without soname-s. //---------------------------------------------------------------------------- cmComputeLinkInformation -::cmComputeLinkInformation(cmTarget const* target, const std::string& config) +::cmComputeLinkInformation(const cmGeneratorTarget* target, + const std::string& config) { // Store context information. this->Target = target; - this->Makefile = this->Target->GetMakefile(); + this->Makefile = this->Target->Target->GetMakefile(); this->GlobalGenerator = this->Makefile->GetGlobalGenerator(); this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance(); @@ -259,17 +260,15 @@ cmComputeLinkInformation // Allocate internals. this->OrderLinkerSearchPath = - new cmOrderDirectories(this->GlobalGenerator, target, + new cmOrderDirectories(this->GlobalGenerator, target->Target, "linker search path"); this->OrderRuntimeSearchPath = - new cmOrderDirectories(this->GlobalGenerator, target, + new cmOrderDirectories(this->GlobalGenerator, target->Target, "runtime search path"); this->OrderDependentRPath = 0; - cmGeneratorTarget *gtgt = this->GlobalGenerator - ->GetGeneratorTarget(this->Target); // Get the language used for linking this target. - this->LinkLanguage = gtgt->GetLinkerLanguage(config); + this->LinkLanguage = this->Target->GetLinkerLanguage(config); if(this->LinkLanguage.empty()) { // The Compute method will do nothing, so skip the rest of the @@ -283,14 +282,14 @@ cmComputeLinkInformation // Check whether we should skip dependencies on shared library files. this->LinkDependsNoShared = - this->Target->GetPropertyAsBool("LINK_DEPENDS_NO_SHARED"); + this->Target->Target->GetPropertyAsBool("LINK_DEPENDS_NO_SHARED"); // On platforms without import libraries there may be a special flag // to use when creating a plugin (module) that obtains symbols from // the program that will load it. this->LoaderFlag = 0; if(!this->UseImportLibrary && - this->Target->GetType() == cmTarget::MODULE_LIBRARY) + this->Target->Target->GetType() == cmTarget::MODULE_LIBRARY) { std::string loader_flag_var = "CMAKE_SHARED_MODULE_LOADER_"; loader_flag_var += this->LinkLanguage; @@ -308,10 +307,10 @@ cmComputeLinkInformation // Get options needed to specify RPATHs. this->RuntimeUseChrpath = false; - if(this->Target->GetType() != cmTarget::STATIC_LIBRARY) + if(this->Target->Target->GetType() != cmTarget::STATIC_LIBRARY) { const char* tType = - ((this->Target->GetType() == cmTarget::EXECUTABLE)? + ((this->Target->Target->GetType() == cmTarget::EXECUTABLE)? "EXECUTABLE" : "SHARED_LIBRARY"); std::string rtVar = "CMAKE_"; rtVar += tType; @@ -325,7 +324,7 @@ cmComputeLinkInformation (this->Makefile-> GetSafeDefinition("CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH")); - this->RuntimeUseChrpath = gtgt->IsChrpathUsed(config); + this->RuntimeUseChrpath = this->Target->IsChrpathUsed(config); // Get options needed to help find dependent libraries. std::string rlVar = "CMAKE_"; @@ -371,15 +370,15 @@ cmComputeLinkInformation { this->SharedDependencyMode = SharedDepModeDir; this->OrderDependentRPath = - new cmOrderDirectories(this->GlobalGenerator, target, + new cmOrderDirectories(this->GlobalGenerator, target->Target, "dependent library path"); } // Add the search path entries requested by the user to path ordering. this->OrderLinkerSearchPath - ->AddUserDirectories(this->Target->GetLinkDirectories()); + ->AddUserDirectories(this->Target->Target->GetLinkDirectories()); this->OrderRuntimeSearchPath - ->AddUserDirectories(this->Target->GetLinkDirectories()); + ->AddUserDirectories(this->Target->Target->GetLinkDirectories()); // Set up the implicit link directories. this->LoadImplicitLinkInfo(); @@ -407,12 +406,13 @@ cmComputeLinkInformation // order to support such projects we need to add the directories // containing libraries linked with a full path to the -L path. this->OldLinkDirMode = - this->Target->GetPolicyStatusCMP0003() != cmPolicies::NEW; + this->Target->Target->GetPolicyStatusCMP0003() != cmPolicies::NEW; if(this->OldLinkDirMode) { // Construct a mask to not bother with this behavior for link // directories already specified by the user. - std::vector const& dirs = this->Target->GetLinkDirectories(); + std::vector const& dirs = + this->Target->Target->GetLinkDirectories(); this->OldLinkDirMask.insert(dirs.begin(), dirs.end()); } @@ -497,7 +497,7 @@ bool cmComputeLinkInformation::Compute() } // Compute the ordered link line items. - cmComputeLinkDepends cld(this->Target, this->Config); + cmComputeLinkDepends cld(this->Target->Target, this->Config); cld.SetOldLinkDirMode(this->OldLinkDirMode); cmComputeLinkDepends::EntryVector const& linkEntries = cld.Compute(); @@ -518,7 +518,8 @@ bool cmComputeLinkInformation::Compute() // Restore the target link type so the correct system runtime // libraries are found. - const char* lss = this->Target->GetProperty("LINK_SEARCH_END_STATIC"); + const char* lss = + this->Target->Target->GetProperty("LINK_SEARCH_END_STATIC"); if(cmSystemTools::IsOn(lss)) { this->SetCurrentLinkType(LinkStatic); @@ -571,7 +572,7 @@ bool cmComputeLinkInformation::Compute() "name." ; this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); } return true; @@ -580,12 +581,9 @@ bool cmComputeLinkInformation::Compute() //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddImplicitLinkInfo() { - cmGeneratorTarget *gtgt = this->Target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(this->Target); - // The link closure lists all languages whose implicit info is needed. - cmGeneratorTarget::LinkClosure const* lc=gtgt->GetLinkClosure(this->Config); + cmGeneratorTarget::LinkClosure const* lc = + this->Target->GetLinkClosure(this->Config); for(std::vector::const_iterator li = lc->Languages.begin(); li != lc->Languages.end(); ++li) { @@ -863,7 +861,8 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo() } // Lookup the starting link type from the target (linked statically?). - const char* lss = this->Target->GetProperty("LINK_SEARCH_START_STATIC"); + const char* lss = + this->Target->Target->GetProperty("LINK_SEARCH_START_STATIC"); this->StartLinkType = cmSystemTools::IsOn(lss)? LinkStatic : LinkShared; this->CurrentLinkType = this->StartLinkType; } @@ -1149,7 +1148,7 @@ void cmComputeLinkInformation::AddFullItem(std::string const& item) // Full path libraries should specify a valid library file name. // See documentation of CMP0008. std::string generator = this->GlobalGenerator->GetName(); - if(this->Target->GetPolicyStatusCMP0008() != cmPolicies::NEW && + if(this->Target->Target->GetPolicyStatusCMP0008() != cmPolicies::NEW && (generator.find("Visual Studio") != generator.npos || generator.find("Xcode") != generator.npos)) { @@ -1230,7 +1229,7 @@ bool cmComputeLinkInformation::CheckImplicitDirItem(std::string const& item) } // Check the policy for whether we should use the approach below. - switch (this->Target->GetPolicyStatusCMP0060()) + switch (this->Target->Target->GetPolicyStatusCMP0060()) { case cmPolicies::WARN: if (this->CMP0060Warn) @@ -1540,7 +1539,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item, this->OrderLinkerSearchPath->AddLinkLibrary(item); // Produce any needed message. - switch(this->Target->GetPolicyStatusCMP0008()) + switch(this->Target->Target->GetPolicyStatusCMP0008()) { case cmPolicies::WARN: { @@ -1557,7 +1556,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item, << " " << item << "\n" << "which is a full-path but not a valid library file name."; this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); } } case cmPolicies::OLD: @@ -1575,7 +1574,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item, << " " << item << "\n" << "which is a full-path but not a valid library file name."; this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); } break; } @@ -1592,7 +1591,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories() } // Enforce policy constraints. - switch(this->Target->GetPolicyStatusCMP0003()) + switch(this->Target->Target->GetPolicyStatusCMP0003()) { case cmPolicies::WARN: if(!this->CMakeInstance->GetState() @@ -1603,7 +1602,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories() std::ostringstream w; this->PrintLinkPolicyDiagnosis(w); this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); } case cmPolicies::OLD: // OLD behavior is to add the paths containing libraries with @@ -1619,7 +1618,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories() e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0003) << "\n"; this->PrintLinkPolicyDiagnosis(e); this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); return false; } } @@ -1923,23 +1922,24 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, // build tree. bool linking_for_install = (for_install || - this->Target->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")); + this->Target->Target->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")); bool use_install_rpath = - (outputRuntime && this->Target->HaveInstallTreeRPATH() && + (outputRuntime && this->Target->Target->HaveInstallTreeRPATH() && linking_for_install); bool use_build_rpath = - (outputRuntime && this->Target->HaveBuildTreeRPATH(this->Config) && + (outputRuntime && this->Target->Target->HaveBuildTreeRPATH(this->Config) && !linking_for_install); bool use_link_rpath = outputRuntime && linking_for_install && !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH") && - this->Target->GetPropertyAsBool("INSTALL_RPATH_USE_LINK_PATH"); + this->Target->Target->GetPropertyAsBool("INSTALL_RPATH_USE_LINK_PATH"); // Construct the RPATH. std::set emitted; if(use_install_rpath) { - const char* install_rpath = this->Target->GetProperty("INSTALL_RPATH"); + const char* install_rpath = + this->Target->Target->GetProperty("INSTALL_RPATH"); cmCLI_ExpandListUnique(install_rpath, runtimeDirs, emitted); } if(use_build_rpath || use_link_rpath) @@ -2011,12 +2011,8 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, // Add runtime paths required by the languages to always be // present. This is done even when skipping rpath support. { - cmGeneratorTarget *gtgt = this->Makefile - ->GetGlobalGenerator() - ->GetGeneratorTarget(this->Target); - cmGeneratorTarget::LinkClosure const* lc = - gtgt->GetLinkClosure(this->Config); + this->Target->GetLinkClosure(this->Config); for(std::vector::const_iterator li = lc->Languages.begin(); li != lc->Languages.end(); ++li) { diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index 2d7a5a5..8b83574 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -29,7 +29,8 @@ class cmOrderDirectories; class cmComputeLinkInformation { public: - cmComputeLinkInformation(cmTarget const* target, const std::string& config); + cmComputeLinkInformation(cmGeneratorTarget const* target, + const std::string& config); ~cmComputeLinkInformation(); bool Compute(); @@ -73,7 +74,7 @@ private: std::set SharedLibrariesLinked; // Context information. - cmTarget const* Target; + cmGeneratorTarget const* Target; cmMakefile* Makefile; cmGlobalGenerator* GlobalGenerator; cmake* CMakeInstance; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 2d2d4c1..d3067df 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3166,7 +3166,7 @@ cmGeneratorTarget::GetLinkInformation(const std::string& config) const { // Compute information for this configuration. cmComputeLinkInformation* info = - new cmComputeLinkInformation(this->Target, config); + new cmComputeLinkInformation(this, config); if(!info || !info->Compute()) { delete info; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7b9e4b50b82f3235775a2d016702905bd948373a commit 7b9e4b50b82f3235775a2d016702905bd948373a Author: Stephen Kelly AuthorDate: Tue Jul 28 23:16:43 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:03:47 2015 +0200 cmGeneratorTarget: Move IsBundleOnApple from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 6131d7e..2d2d4c1 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -910,6 +910,14 @@ cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, } //---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsBundleOnApple() const +{ + return this->Target->IsFrameworkOnApple() + || this->Target->IsAppBundleOnApple() + || this->Target->IsCFBundleOnApple(); +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config, bool contentOnly) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 4299053..d10cd1d 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -119,6 +119,10 @@ public: std::string GetAppBundleDirectory(const std::string& config, bool contentOnly) const; + /** Return whether this target is an executable Bundle, a framework + or CFBundle on Apple. */ + bool IsBundleOnApple() const; + /** Get the full name of the target according to the settings in its makefile. */ std::string GetFullName(const std::string& config="", diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index d38cf4c..0b3df90 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -313,7 +313,7 @@ cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator() (cmSourceFile const& source, const char* pkgloc) { // Skip OS X content when not building a Framework or Bundle. - if(!this->Generator->GetTarget()->IsBundleOnApple()) + if(!this->Generator->GetGeneratorTarget()->IsBundleOnApple()) { return; } diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 16e1f48..07efa16 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -742,7 +742,7 @@ cmNinjaTargetGenerator::MacOSXContentGeneratorType::operator()( cmSourceFile const& source, const char* pkgloc) { // Skip OS X content when not building a Framework or Bundle. - if(!this->Generator->GetTarget()->IsBundleOnApple()) + if(!this->Generator->GetGeneratorTarget()->IsBundleOnApple()) { return; } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 62aa12a..e887ef3 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -590,13 +590,6 @@ bool cmTarget::IsXCTestOnApple() const } //---------------------------------------------------------------------------- -bool cmTarget::IsBundleOnApple() const -{ - return this->IsFrameworkOnApple() || this->IsAppBundleOnApple() || - this->IsCFBundleOnApple(); -} - -//---------------------------------------------------------------------------- static bool processSources(cmTarget const* tgt, const std::vector &entries, std::vector &srcs, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 9a4915f..e53afff 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -424,10 +424,6 @@ public: /** Return whether this target is an executable Bundle on Apple. */ bool IsAppBundleOnApple() const; - /** Return whether this target is an executable Bundle, a framework - or CFBundle on Apple. */ - bool IsBundleOnApple() const; - /** Return the framework version string. Undefined if IsFrameworkOnApple returns false. */ std::string GetFrameworkVersion() const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bb0e698f451ab24e63c485ff8398c71f8988590b commit bb0e698f451ab24e63c485ff8398c71f8988590b Author: Stephen Kelly AuthorDate: Tue Jul 28 23:18:55 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:03:47 2015 +0200 cmMakefileTargetGenerator: Add accessor for GeneratorTarget. diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index b885672..fd4527b 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -53,6 +53,7 @@ public: { return this->ProgressFileNameFull; } cmTarget* GetTarget() { return this->Target;} + cmGeneratorTarget* GetGeneratorTarget() { return this->GeneratorTarget;} protected: http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=afb84b31e8277b2955284ad34708f58ea1db744f commit afb84b31e8277b2955284ad34708f58ea1db744f Author: Stephen Kelly AuthorDate: Wed Oct 10 21:43:28 2012 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:03:46 2015 +0200 cmGeneratorTarget: Move GetLinkClosure from cmTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 640e806..f03c04a 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -19,6 +19,7 @@ #include "cmOutputConverter.h" #include "cmMakefile.h" #include "cmTarget.h" +#include "cmGeneratorTarget.h" #include "cmake.h" #include "cmAlgorithms.h" @@ -579,8 +580,12 @@ bool cmComputeLinkInformation::Compute() //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddImplicitLinkInfo() { + cmGeneratorTarget *gtgt = this->Target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(this->Target); + // The link closure lists all languages whose implicit info is needed. - cmTarget::LinkClosure const* lc=this->Target->GetLinkClosure(this->Config); + cmGeneratorTarget::LinkClosure const* lc=gtgt->GetLinkClosure(this->Config); for(std::vector::const_iterator li = lc->Languages.begin(); li != lc->Languages.end(); ++li) { @@ -2006,8 +2011,12 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, // Add runtime paths required by the languages to always be // present. This is done even when skipping rpath support. { - cmTarget::LinkClosure const* lc = - this->Target->GetLinkClosure(this->Config); + cmGeneratorTarget *gtgt = this->Makefile + ->GetGlobalGenerator() + ->GetGeneratorTarget(this->Target); + + cmGeneratorTarget::LinkClosure const* lc = + gtgt->GetLinkClosure(this->Config); for(std::vector::const_iterator li = lc->Languages.begin(); li != lc->Languages.end(); ++li) { diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index 3afbb92..2d7a5a5 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -20,6 +20,7 @@ class cmake; class cmGlobalGenerator; class cmMakefile; class cmTarget; +class cmGeneratorTarget; class cmOrderDirectories; /** \class cmComputeLinkInformation diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 4de5e9c..6131d7e 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -27,6 +27,13 @@ #include #include "assert.h" +#if defined(CMAKE_BUILD_WITH_CMAKE) +#include +#define UNORDERED_SET cmsys::hash_set +#else +#define UNORDERED_SET std::set +#endif + //---------------------------------------------------------------------------- void reportBadObjLib(std::vector const& badObjLib, cmTarget *target, cmake *cm) @@ -1026,6 +1033,223 @@ std::string cmGeneratorTarget::GetInstallNameDirForInstallTree() const } //---------------------------------------------------------------------------- +class cmTargetCollectLinkLanguages +{ +public: + cmTargetCollectLinkLanguages(cmGeneratorTarget const* target, + const std::string& config, + UNORDERED_SET& languages, + cmTarget const* head): + Config(config), Languages(languages), HeadTarget(head), + Makefile(target->Target->GetMakefile()), Target(target) + { this->Visited.insert(target->Target); } + + void Visit(cmLinkItem const& item) + { + if(!item.Target) + { + if(item.find("::") != std::string::npos) + { + bool noMessage = false; + cmake::MessageType messageType = cmake::FATAL_ERROR; + std::stringstream e; + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0028)) + { + case cmPolicies::WARN: + { + e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0028) << "\n"; + messageType = cmake::AUTHOR_WARNING; + } + break; + case cmPolicies::OLD: + noMessage = true; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::NEW: + // Issue the fatal message. + break; + } + + if(!noMessage) + { + e << "Target \"" << this->Target->GetName() + << "\" links to target \"" << item + << "\" but the target was not found. Perhaps a find_package() " + "call is missing for an IMPORTED target, or an ALIAS target is " + "missing?"; + this->Makefile->GetCMakeInstance()->IssueMessage( + messageType, e.str(), this->Target->Target->GetBacktrace()); + } + } + return; + } + if(!this->Visited.insert(item.Target).second) + { + return; + } + + cmTarget::LinkInterface const* iface = + item.Target->GetLinkInterface(this->Config, this->HeadTarget); + if(!iface) { return; } + + for(std::vector::const_iterator + li = iface->Languages.begin(); li != iface->Languages.end(); ++li) + { + this->Languages.insert(*li); + } + + for(std::vector::const_iterator + li = iface->Libraries.begin(); li != iface->Libraries.end(); ++li) + { + this->Visit(*li); + } + } +private: + std::string Config; + UNORDERED_SET& Languages; + cmTarget const* HeadTarget; + cmMakefile* Makefile; + const cmGeneratorTarget* Target; + std::set Visited; +}; + +//---------------------------------------------------------------------------- +cmGeneratorTarget::LinkClosure const* +cmGeneratorTarget::GetLinkClosure(const std::string& config) const +{ + std::string key(cmSystemTools::UpperCase(config)); + LinkClosureMapType::iterator + i = this->LinkClosureMap.find(key); + if(i == this->LinkClosureMap.end()) + { + LinkClosure lc; + this->ComputeLinkClosure(config, lc); + LinkClosureMapType::value_type entry(key, lc); + i = this->LinkClosureMap.insert(entry).first; + } + return &i->second; +} + +//---------------------------------------------------------------------------- +class cmTargetSelectLinker +{ + int Preference; + cmGeneratorTarget const* Target; + cmMakefile* Makefile; + cmGlobalGenerator* GG; + std::set Preferred; +public: + cmTargetSelectLinker(cmGeneratorTarget const* target) + : Preference(0), Target(target) + { + this->Makefile = this->Target->Makefile; + this->GG = this->Makefile->GetLocalGenerator()->GetGlobalGenerator(); + } + void Consider(const char* lang) + { + int preference = this->GG->GetLinkerPreference(lang); + if(preference > this->Preference) + { + this->Preference = preference; + this->Preferred.clear(); + } + if(preference == this->Preference) + { + this->Preferred.insert(lang); + } + } + std::string Choose() + { + if(this->Preferred.empty()) + { + return ""; + } + else if(this->Preferred.size() > 1) + { + std::stringstream e; + e << "Target " << this->Target->GetName() + << " contains multiple languages with the highest linker preference" + << " (" << this->Preference << "):\n"; + for(std::set::const_iterator + li = this->Preferred.begin(); li != this->Preferred.end(); ++li) + { + e << " " << *li << "\n"; + } + e << "Set the LINKER_LANGUAGE property for this target."; + cmake* cm = this->Makefile->GetCMakeInstance(); + cm->IssueMessage(cmake::FATAL_ERROR, e.str(), + this->Target->Target->GetBacktrace()); + } + return *this->Preferred.begin(); + } +}; + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::ComputeLinkClosure(const std::string& config, + LinkClosure& lc) const +{ + // Get languages built in this target. + UNORDERED_SET languages; + cmTarget::LinkImplementation const* impl = + this->Target->GetLinkImplementation(config); + for(std::vector::const_iterator li = impl->Languages.begin(); + li != impl->Languages.end(); ++li) + { + languages.insert(*li); + } + + // Add interface languages from linked targets. + cmTargetCollectLinkLanguages cll(this, config, languages, this->Target); + for(std::vector::const_iterator li = impl->Libraries.begin(); + li != impl->Libraries.end(); ++li) + { + cll.Visit(*li); + } + + // Store the transitive closure of languages. + for(UNORDERED_SET::const_iterator li = languages.begin(); + li != languages.end(); ++li) + { + lc.Languages.push_back(*li); + } + + // Choose the language whose linker should be used. + if(this->GetProperty("HAS_CXX")) + { + lc.LinkerLanguage = "CXX"; + } + else if(const char* linkerLang = this->GetProperty("LINKER_LANGUAGE")) + { + lc.LinkerLanguage = linkerLang; + } + else + { + // Find the language with the highest preference value. + cmTargetSelectLinker tsl(this); + + // First select from the languages compiled directly in this target. + for(std::vector::const_iterator li = impl->Languages.begin(); + li != impl->Languages.end(); ++li) + { + tsl.Consider(li->c_str()); + } + + // Now consider languages that propagate from linked targets. + for(UNORDERED_SET::const_iterator sit = languages.begin(); + sit != languages.end(); ++sit) + { + std::string propagates = "CMAKE_"+*sit+"_LINKER_PREFERENCE_PROPAGATES"; + if(this->Makefile->IsOn(propagates)) + { + tsl.Consider(sit->c_str()); + } + } + + lc.LinkerLanguage = tsl.Choose(); + } +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, std::string& base, std::string& suffix, @@ -2058,7 +2282,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, std::string cmGeneratorTarget::GetLinkerLanguage(const std::string& config) const { - return this->Target->GetLinkClosure(config)->LinkerLanguage; + return this->GetLinkClosure(config)->LinkerLanguage; } //---------------------------------------------------------------------------- diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 2799371..4299053 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -165,6 +165,20 @@ public: std::string GetModuleDefinitionFile(const std::string& config) const; + /** Link information from the transitive closure of the link + implementation and the interfaces of its dependencies. */ + struct LinkClosure + { + // The preferred linker language. + std::string LinkerLanguage; + + // Languages whose runtime libraries must be linked. + std::vector Languages; + }; + + LinkClosure const* GetLinkClosure(const std::string& config) const; + void ComputeLinkClosure(const std::string& config, LinkClosure& lc) const; + /** Full path with trailing slash to the top-level directory holding object files for this target. Includes the build time config name placeholder if needed for the generator. */ @@ -300,6 +314,9 @@ private: std::string& outPrefix, std::string& outBase, std::string& outSuffix) const; + typedef std::map LinkClosureMapType; + mutable LinkClosureMapType LinkClosureMap; + struct CompatibleInterfacesBase { std::set PropsBool; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index c7118dc..62aa12a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -160,9 +160,6 @@ public: HeadToLinkImplementationMap> LinkImplMapType; LinkImplMapType LinkImplMap; - typedef std::map LinkClosureMapType; - LinkClosureMapType LinkClosureMap; - typedef std::map > SourceFilesMapType; SourceFilesMapType SourceFilesMap; @@ -511,7 +508,6 @@ void cmTarget::ClearLinkMaps() this->Internal->LinkImplMap.clear(); this->Internal->LinkInterfaceMap.clear(); this->Internal->LinkInterfaceUsageRequirementsOnlyMap.clear(); - this->Internal->LinkClosureMap.clear(); this->Internal->SourceFilesMap.clear(); } @@ -3136,223 +3132,6 @@ bool cmTarget::GetPropertyAsBool(const std::string& prop) const } //---------------------------------------------------------------------------- -class cmTargetCollectLinkLanguages -{ -public: - cmTargetCollectLinkLanguages(cmTarget const* target, - const std::string& config, - UNORDERED_SET& languages, - cmTarget const* head): - Config(config), Languages(languages), HeadTarget(head), - Makefile(target->GetMakefile()), Target(target) - { this->Visited.insert(target); } - - void Visit(cmLinkItem const& item) - { - if(!item.Target) - { - if(item.find("::") != std::string::npos) - { - bool noMessage = false; - cmake::MessageType messageType = cmake::FATAL_ERROR; - std::ostringstream e; - switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0028)) - { - case cmPolicies::WARN: - { - e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0028) << "\n"; - messageType = cmake::AUTHOR_WARNING; - } - break; - case cmPolicies::OLD: - noMessage = true; - case cmPolicies::REQUIRED_IF_USED: - case cmPolicies::REQUIRED_ALWAYS: - case cmPolicies::NEW: - // Issue the fatal message. - break; - } - - if(!noMessage) - { - e << "Target \"" << this->Target->GetName() - << "\" links to target \"" << item - << "\" but the target was not found. Perhaps a find_package() " - "call is missing for an IMPORTED target, or an ALIAS target is " - "missing?"; - this->Makefile->GetCMakeInstance()->IssueMessage(messageType, - e.str(), - this->Target->GetBacktrace()); - } - } - return; - } - if(!this->Visited.insert(item.Target).second) - { - return; - } - - cmTarget::LinkInterface const* iface = - item.Target->GetLinkInterface(this->Config, this->HeadTarget); - if(!iface) { return; } - - for(std::vector::const_iterator - li = iface->Languages.begin(); li != iface->Languages.end(); ++li) - { - this->Languages.insert(*li); - } - - for(std::vector::const_iterator - li = iface->Libraries.begin(); li != iface->Libraries.end(); ++li) - { - this->Visit(*li); - } - } -private: - std::string Config; - UNORDERED_SET& Languages; - cmTarget const* HeadTarget; - cmMakefile* Makefile; - const cmTarget* Target; - std::set Visited; -}; - -//---------------------------------------------------------------------------- -cmTarget::LinkClosure const* -cmTarget::GetLinkClosure(const std::string& config) const -{ - std::string key(cmSystemTools::UpperCase(config)); - cmTargetInternals::LinkClosureMapType::iterator - i = this->Internal->LinkClosureMap.find(key); - if(i == this->Internal->LinkClosureMap.end()) - { - LinkClosure lc; - this->ComputeLinkClosure(config, lc); - cmTargetInternals::LinkClosureMapType::value_type entry(key, lc); - i = this->Internal->LinkClosureMap.insert(entry).first; - } - return &i->second; -} - -//---------------------------------------------------------------------------- -class cmTargetSelectLinker -{ - int Preference; - cmTarget const* Target; - cmMakefile* Makefile; - cmGlobalGenerator* GG; - UNORDERED_SET Preferred; -public: - cmTargetSelectLinker(cmTarget const* target): Preference(0), Target(target) - { - this->Makefile = this->Target->GetMakefile(); - this->GG = this->Makefile->GetGlobalGenerator(); - } - void Consider(const std::string& lang) - { - int preference = this->GG->GetLinkerPreference(lang); - if(preference > this->Preference) - { - this->Preference = preference; - this->Preferred.clear(); - } - if(preference == this->Preference) - { - this->Preferred.insert(lang); - } - } - std::string Choose() - { - if(this->Preferred.empty()) - { - return ""; - } - else if(this->Preferred.size() > 1) - { - std::ostringstream e; - e << "Target " << this->Target->GetName() - << " contains multiple languages with the highest linker preference" - << " (" << this->Preference << "):\n"; - for(UNORDERED_SET::const_iterator - li = this->Preferred.begin(); li != this->Preferred.end(); ++li) - { - e << " " << *li << "\n"; - } - e << "Set the LINKER_LANGUAGE property for this target."; - cmake* cm = this->Makefile->GetCMakeInstance(); - cm->IssueMessage(cmake::FATAL_ERROR, e.str(), - this->Target->GetBacktrace()); - } - return *this->Preferred.begin(); - } -}; - -//---------------------------------------------------------------------------- -void cmTarget::ComputeLinkClosure(const std::string& config, - LinkClosure& lc) const -{ - // Get languages built in this target. - UNORDERED_SET languages; - LinkImplementation const* impl = this->GetLinkImplementation(config); - for(std::vector::const_iterator li = impl->Languages.begin(); - li != impl->Languages.end(); ++li) - { - languages.insert(*li); - } - - // Add interface languages from linked targets. - cmTargetCollectLinkLanguages cll(this, config, languages, this); - for(std::vector::const_iterator - li = impl->Libraries.begin(); - li != impl->Libraries.end(); ++li) - { - cll.Visit(*li); - } - - // Store the transitive closure of languages. - for(UNORDERED_SET::const_iterator li = languages.begin(); - li != languages.end(); ++li) - { - lc.Languages.push_back(*li); - } - - // Choose the language whose linker should be used. - if(this->GetProperty("HAS_CXX")) - { - lc.LinkerLanguage = "CXX"; - } - else if(const char* linkerLang = this->GetProperty("LINKER_LANGUAGE")) - { - lc.LinkerLanguage = linkerLang; - } - else - { - // Find the language with the highest preference value. - cmTargetSelectLinker tsl(this); - - // First select from the languages compiled directly in this target. - for(std::vector::const_iterator li = impl->Languages.begin(); - li != impl->Languages.end(); ++li) - { - tsl.Consider(*li); - } - - // Now consider languages that propagate from linked targets. - for(UNORDERED_SET::const_iterator sit = languages.begin(); - sit != languages.end(); ++sit) - { - std::string propagates = "CMAKE_"+*sit+"_LINKER_PREFERENCE_PROPAGATES"; - if(this->Makefile->IsOn(propagates)) - { - tsl.Consider(*sit); - } - } - - lc.LinkerLanguage = tsl.Choose(); - } -} - -//---------------------------------------------------------------------------- void cmTarget::ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index dea9bef..9a4915f 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -315,18 +315,6 @@ public: LinkImplementationLibraries const* GetLinkImplementationLibraries(const std::string& config) const; - /** Link information from the transitive closure of the link - implementation and the interfaces of its dependencies. */ - struct LinkClosure - { - // The preferred linker language. - std::string LinkerLanguage; - - // Languages whose runtime libraries must be linked. - std::vector Languages; - }; - LinkClosure const* GetLinkClosure(const std::string& config) const; - cmTarget const* FindTargetToLink(std::string const& name) const; /** Strip off leading and trailing whitespace from an item named in @@ -662,7 +650,6 @@ private: LinkImplementationLibraries const* GetLinkImplementationLibrariesInternal(const std::string& config, cmTarget const* head) const; - void ComputeLinkClosure(const std::string& config, LinkClosure& lc) const; void ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, cmTarget const* headTarget, http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=baae0995abb15e6f5e2a4933ad34c1858a9042fd commit baae0995abb15e6f5e2a4933ad34c1858a9042fd Author: Stephen Kelly AuthorDate: Sun Nov 3 16:33:25 2013 +0100 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:03:46 2015 +0200 cmGeneratorTarget: Move GetLinkerLanguage from cmTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index fee921c..640e806 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -265,8 +265,10 @@ cmComputeLinkInformation "runtime search path"); this->OrderDependentRPath = 0; + cmGeneratorTarget *gtgt = this->GlobalGenerator + ->GetGeneratorTarget(this->Target); // Get the language used for linking this target. - this->LinkLanguage = this->Target->GetLinkerLanguage(config); + this->LinkLanguage = gtgt->GetLinkerLanguage(config); if(this->LinkLanguage.empty()) { // The Compute method will do nothing, so skip the rest of the @@ -322,9 +324,6 @@ cmComputeLinkInformation (this->Makefile-> GetSafeDefinition("CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH")); - cmGeneratorTarget *gtgt = this->Target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(this->Target); this->RuntimeUseChrpath = gtgt->IsChrpathUsed(config); // Get options needed to help find dependent libraries. diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 49fc96b..a86c2bc 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -990,6 +990,9 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode assert(target); + cmGeneratorTarget* gtgt = + context->Makefile->GetGlobalGenerator()->GetGeneratorTarget(target); + if (propertyName == "LINKER_LANGUAGE") { if (target->LinkLanguagePropagatesToDependents() && @@ -1001,7 +1004,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode "link libraries for a static library"); return std::string(); } - return target->GetLinkerLanguage(context->Config); + return gtgt->GetLinkerLanguage(context->Config); } cmGeneratorExpressionDAGChecker dagChecker(context->Backtrace, @@ -1128,9 +1131,6 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode } } - cmGeneratorTarget* gtgt = - context->Makefile->GetGlobalGenerator()->GetGeneratorTarget(target); - if (!prop) { if (target->IsImported() @@ -1600,7 +1600,7 @@ struct TargetFilesystemArtifactResultCreator cmGeneratorExpressionContext *context, const GeneratorExpressionContent *content) { - std::string language = target->Target->GetLinkerLanguage(context->Config); + std::string language = target->GetLinkerLanguage(context->Config); std::string pdbSupportVar = "CMAKE_" + language + "_LINKER_SUPPORTS_PDB"; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 834a2e3..4de5e9c 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -709,8 +709,7 @@ bool cmGeneratorTarget::HasSOName(const std::string& config) const return ((this->GetType() == cmTarget::SHARED_LIBRARY || this->GetType() == cmTarget::MODULE_LIBRARY) && !this->GetPropertyAsBool("NO_SONAME") && - this->Makefile->GetSONameFlag( - this->Target->GetLinkerLanguage(config))); + this->Makefile->GetSONameFlag(this->GetLinkerLanguage(config))); } //---------------------------------------------------------------------------- @@ -752,7 +751,7 @@ cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const } // Check for rpath support on this platform. - std::string ll = this->Target->GetLinkerLanguage(config); + std::string ll = this->GetLinkerLanguage(config); if(!ll.empty()) { std::string flagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; @@ -823,7 +822,7 @@ bool cmGeneratorTarget::IsChrpathUsed(const std::string& config) const #if defined(CMAKE_USE_ELF_PARSER) // Enable if the rpath flag uses a separator and the target uses ELF // binaries. - std::string ll = this->Target->GetLinkerLanguage(config); + std::string ll = this->GetLinkerLanguage(config); if(!ll.empty()) { std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; @@ -1986,7 +1985,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, const char* suffixVar = this->Target->GetSuffixVariableInternal(implib); // Check for language-specific default prefix and suffix. - std::string ll = this->Target->GetLinkerLanguage(config); + std::string ll = this->GetLinkerLanguage(config); if(!ll.empty()) { if(!targetSuffix && suffixVar && *suffixVar) @@ -2056,6 +2055,13 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, //---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetLinkerLanguage(const std::string& config) const +{ + return this->Target->GetLinkClosure(config)->LinkerLanguage; +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetPDBName(const std::string& config) const { std::string prefix; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 372bbe1..2799371 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -258,6 +258,9 @@ public: /** Return true if builtin chrpath will work for this target */ bool IsChrpathUsed(const std::string& config) const; + ///! Return the preferred linker language for this target + std::string GetLinkerLanguage(const std::string& config = "") const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 7b0e153..5006828 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1376,7 +1376,8 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmTarget& cmtarget) return; } - std::string llang = cmtarget.GetLinkerLanguage("NOCONFIG"); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&cmtarget); + std::string llang = gtgt->GetLinkerLanguage("NOCONFIG"); if(llang.empty()) { return; } // If the language is compiled as a source trust Xcode to link with it. @@ -1824,7 +1825,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, AddCompileOptions(flags, &target, lang, configName); } - std::string llang = target.GetLinkerLanguage(configName); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); + std::string llang = gtgt->GetLinkerLanguage(configName); if(binary && llang.empty()) { cmSystemTools::Error @@ -1850,7 +1852,6 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, // Add the export symbol definition for shared library objects. this->AppendDefines(ppDefs, exportMacro); } - cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); std::vector targetDefines; target.GetCompileDefinitions(targetDefines, configName, "C"); this->AppendDefines(ppDefs, targetDefines); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 3ab501d..4ec77a1 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1353,7 +1353,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, linkFlags += this->Makefile->GetSafeDefinition(build); linkFlags += " "; } - std::string linkLanguage = target->Target->GetLinkerLanguage(buildType); + std::string linkLanguage = target->GetLinkerLanguage(buildType); if(linkLanguage.empty()) { cmSystemTools::Error diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 43e9ae4..a402c64 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1259,8 +1259,8 @@ void cmLocalVisualStudio6Generator extraLinkOptionsRelWithDebInfo += targetLinkFlags; } - - + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); // Get standard libraries for this language. if(targetBuilds) @@ -1269,10 +1269,10 @@ void cmLocalVisualStudio6Generator std::vector configs; target.GetMakefile()->GetConfigurations(configs); std::vector::const_iterator it = configs.begin(); - const std::string& linkLanguage = target.GetLinkerLanguage(*it); + const std::string& linkLanguage = gt->GetLinkerLanguage(*it); for ( ; it != configs.end(); ++it) { - const std::string& configLinkLanguage = target.GetLinkerLanguage(*it); + const std::string& configLinkLanguage = gt->GetLinkerLanguage(*it); if (configLinkLanguage != linkLanguage) { cmSystemTools::Error @@ -1702,10 +1702,10 @@ void cmLocalVisualStudio6Generator std::vector configs; target.GetMakefile()->GetConfigurations(configs); std::vector::const_iterator it = configs.begin(); - const std::string& linkLanguage = target.GetLinkerLanguage(*it); + const std::string& linkLanguage = gt->GetLinkerLanguage(*it); for ( ; it != configs.end(); ++it) { - const std::string& configLinkLanguage = target.GetLinkerLanguage(*it); + const std::string& configLinkLanguage = gt->GetLinkerLanguage(*it); if (configLinkLanguage != linkLanguage) { cmSystemTools::Error diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 5ecb144..0fb6bc0 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -664,6 +664,10 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, const char* configType = "10"; const char* projectType = 0; bool targetBuilds = true; + + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); + switch(target.GetType()) { case cmTarget::OBJECT_LIBRARY: @@ -696,7 +700,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, { const std::string& linkLanguage = (this->FortranProject? std::string("Fortran"): - target.GetLinkerLanguage(configName)); + gt->GetLinkerLanguage(configName)); if(linkLanguage.empty()) { cmSystemTools::Error @@ -758,8 +762,6 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, targetOptions.Parse(flags.c_str()); targetOptions.Parse(defineFlags.c_str()); targetOptions.ParseFinish(); - cmGeneratorTarget* gt = - this->GlobalGenerator->GetGeneratorTarget(&target); std::vector targetDefines; target.GetCompileDefinitions(targetDefines, configName, "CXX"); targetOptions.AddDefines(targetDefines); @@ -1637,7 +1639,7 @@ cmLocalVisualStudio7GeneratorFCInfo lg->GlobalGenerator->GetLanguageFromExtension (sf.GetExtension().c_str()); const std::string& sourceLang = lg->GetSourceFileLanguage(sf); - const std::string& linkLanguage = target.GetLinkerLanguage(i->c_str()); + const std::string& linkLanguage = gt->GetLinkerLanguage(i->c_str()); bool needForceLang = false; // source file does not match its extension language if(lang != sourceLang) diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 2fd77c9..afe145a 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -161,7 +161,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) // Get the language to use for linking this executable. std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); // Make sure we have a link language. if(linkLanguage.empty()) diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index b85b8a8..bb0f9dd 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -133,7 +133,7 @@ void cmMakefileLibraryTargetGenerator::WriteObjectLibraryRules() void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules() { std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_STATIC_LIBRARY"; @@ -159,7 +159,7 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink) return; } std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_SHARED_LIBRARY"; @@ -183,7 +183,7 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink) void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink) { std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_SHARED_MODULE"; @@ -206,7 +206,7 @@ void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink) void cmMakefileLibraryTargetGenerator::WriteFrameworkRules(bool relink) { std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_MACOSX_FRAMEWORK"; @@ -238,7 +238,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules // Get the language to use for linking this library. std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); // Make sure we have a link language. if(linkLanguage.empty()) diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index b94e151..d38cf4c 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1509,7 +1509,7 @@ std::string cmMakefileTargetGenerator::GetLinkRule( if(this->Target->HasImplibGNUtoMS()) { std::string ruleVar = "CMAKE_"; - ruleVar += this->Target->GetLinkerLanguage(this->ConfigName); + ruleVar += this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); ruleVar += "_GNUtoMS_RULE"; if(const char* rule = this->Makefile->GetDefinition(ruleVar)) { @@ -1663,7 +1663,8 @@ cmMakefileTargetGenerator { // Lookup the response file reference flag. std::string responseFlagVar = "CMAKE_"; - responseFlagVar += this->Target->GetLinkerLanguage(this->ConfigName); + responseFlagVar += this->GeneratorTarget + ->GetLinkerLanguage(this->ConfigName); responseFlagVar += "_RESPONSE_FILE_LINK_FLAG"; const char* responseFlag = this->Makefile->GetDefinition(responseFlagVar); @@ -1707,7 +1708,8 @@ cmMakefileTargetGenerator // Lookup the response file reference flag. std::string responseFlagVar = "CMAKE_"; - responseFlagVar += this->Target->GetLinkerLanguage(this->ConfigName); + responseFlagVar += this->GeneratorTarget + ->GetLinkerLanguage(this->ConfigName); responseFlagVar += "_RESPONSE_FILE_LINK_FLAG"; const char* responseFlag = this->Makefile->GetDefinition(responseFlagVar); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 1835841..b855bea 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -40,8 +40,7 @@ cmNinjaNormalTargetGenerator(cmGeneratorTarget* target) , TargetNamePDB() , TargetLinkLanguage("") { - this->TargetLinkLanguage = target->Target - ->GetLinkerLanguage(this->GetConfigName()); + this->TargetLinkLanguage = target->GetLinkerLanguage(this->GetConfigName()); if (target->GetType() == cmTarget::EXECUTABLE) this->GetGeneratorTarget()->GetExecutableNames(this->TargetNameOut, this->TargetNameReal, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 37b788d..c7118dc 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3218,12 +3218,6 @@ private: }; //---------------------------------------------------------------------------- -std::string cmTarget::GetLinkerLanguage(const std::string& config) const -{ - return this->GetLinkClosure(config)->LinkerLanguage; -} - -//---------------------------------------------------------------------------- cmTarget::LinkClosure const* cmTarget::GetLinkClosure(const std::string& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index d0cbc66..dea9bef 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -365,9 +365,6 @@ public: void GetTargetVersion(bool soversion, int& major, int& minor, int& patch) const; - ///! Return the preferred linker language for this target - std::string GetLinkerLanguage(const std::string& config = "") const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 2b33c2c..8a780b1 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1627,7 +1627,7 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( this->GlobalGenerator->GetLanguageFromExtension (sf.GetExtension().c_str()); std::string sourceLang = this->LocalGenerator->GetSourceFileLanguage(sf); - const std::string& linkLanguage = this->Target->GetLinkerLanguage(); + const std::string& linkLanguage = this->GeneratorTarget->GetLinkerLanguage(); bool needForceLang = false; // source file does not match its extension language if(lang != sourceLang) @@ -1891,10 +1891,40 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( this->Target->GetLinkerLanguage(configName.c_str()); if(linkLanguage.empty()) { - cmSystemTools::Error - ("CMake can not determine linker language for target: ", - this->Name.c_str()); - return false; + const std::string& linkLanguage = + this->GeneratorTarget->GetLinkerLanguage(configName.c_str()); + if(linkLanguage.empty()) + { + cmSystemTools::Error + ("CMake can not determine linker language for target: ", + this->Name.c_str()); + return false; + } + if(linkLanguage == "C" || linkLanguage == "CXX" + || linkLanguage == "Fortran") + { + std::string baseFlagVar = "CMAKE_"; + baseFlagVar += linkLanguage; + baseFlagVar += "_FLAGS"; + flags = this-> + Target->GetMakefile()->GetRequiredDefinition(baseFlagVar.c_str()); + std::string flagVar = baseFlagVar + std::string("_") + + cmSystemTools::UpperCase(configName); + flags += " "; + flags += this-> + Target->GetMakefile()->GetRequiredDefinition(flagVar.c_str()); + } + // set the correct language + if(linkLanguage == "C") + { + flags += " /TC "; + } + if(linkLanguage == "CXX") + { + flags += " /TP "; + } + this->LocalGenerator->AddCompileOptions(flags, this->Target, + linkLanguage, configName.c_str()); } if(linkLanguage == "C" || linkLanguage == "CXX" || linkLanguage == "Fortran") @@ -2371,7 +2401,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) Options& linkOptions = *pOptions; const std::string& linkLanguage = - this->Target->GetLinkerLanguage(config.c_str()); + this->GeneratorTarget->GetLinkerLanguage(config.c_str()); if(linkLanguage.empty()) { cmSystemTools::Error http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cbb5037d0a246d998672da3e1b3fb517909ec5ae commit cbb5037d0a246d998672da3e1b3fb517909ec5ae Author: Stephen Kelly AuthorDate: Tue Oct 9 01:22:42 2012 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:03:46 2015 +0200 cmGeneratorTarget: Move GetFrameworkDirectory from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 436e5dd..834a2e3 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -904,6 +904,48 @@ cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config, + bool contentOnly) const +{ + std::string fpath; + fpath += this->Target->GetOutputName(config, false); + fpath += "."; + const char *ext = this->Target->GetProperty("BUNDLE_EXTENSION"); + if (!ext) + { + if (this->Target->IsXCTestOnApple()) + { + ext = "xctest"; + } + else + { + ext = "bundle"; + } + } + fpath += ext; + fpath += "/Contents"; + if(!contentOnly) + fpath += "/MacOS"; + return fpath; +} + +//---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetFrameworkDirectory(const std::string& config, + bool rootDir) const +{ + std::string fpath; + fpath += this->Target->GetOutputName(config, false); + fpath += ".framework"; + if(!rootDir) + { + fpath += "/Versions/"; + fpath += this->Target->GetFrameworkVersion(); + } + return fpath; +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetFullName(const std::string& config, bool implib) const { @@ -1007,11 +1049,11 @@ cmGeneratorTarget::BuildMacContentDirectory(const std::string& base, } if(this->Target->IsFrameworkOnApple()) { - fpath += this->Target->GetFrameworkDirectory(config, contentOnly); + fpath += this->GetFrameworkDirectory(config, contentOnly); } if(this->Target->IsCFBundleOnApple()) { - fpath += this->Target->GetCFBundleDirectory(config, contentOnly); + fpath += this->GetCFBundleDirectory(config, contentOnly); } return fpath; } @@ -1982,7 +2024,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, if(this->Target->IsCFBundleOnApple()) { - fw_prefix = this->Target->GetCFBundleDirectory(config, false); + fw_prefix = this->GetCFBundleDirectory(config, false); fw_prefix += "/"; targetPrefix = fw_prefix.c_str(); targetSuffix = 0; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 8ccd6d0..372bbe1 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -124,6 +124,14 @@ public: std::string GetFullName(const std::string& config="", bool implib = false) const; + /** @return the Mac framework directory without the base. */ + std::string GetFrameworkDirectory(const std::string& config, + bool rootDir) const; + + /** @return the Mac CFBundle directory without the base */ + std::string GetCFBundleDirectory(const std::string& config, + bool contentOnly) const; + /** Return the install name directory for the target in the * build tree. For example: "\@rpath/", "\@loader_path/", * or "/full/path/to/library". */ diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 1d85d9c..4fe99e3 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -77,11 +77,11 @@ void cmOSXBundleGenerator::CreateFramework( // Compute the location of the top-level foo.framework directory. std::string contentdir = outpath + "/" + - this->GT->Target->GetFrameworkDirectory(this->ConfigName, true); + this->GT->GetFrameworkDirectory(this->ConfigName, true); contentdir += "/"; std::string newoutpath = outpath + "/" + - this->GT->Target->GetFrameworkDirectory(this->ConfigName, false); + this->GT->GetFrameworkDirectory(this->ConfigName, false); std::string frameworkVersion = this->GT->Target->GetFrameworkVersion(); @@ -172,14 +172,14 @@ void cmOSXBundleGenerator::CreateCFBundle(const std::string& targetName, // Compute bundle directory names. std::string out = root; out += "/"; - out += this->GT->Target->GetCFBundleDirectory(this->ConfigName, false); + out += this->GT->GetCFBundleDirectory(this->ConfigName, false); cmSystemTools::MakeDirectory(out.c_str()); this->Makefile->AddCMakeOutputFile(out); // Configure the Info.plist file. Note that it needs the executable name // to be set. std::string plist = root + "/" + - this->GT->Target->GetCFBundleDirectory(this->ConfigName, true); + this->GT->GetCFBundleDirectory(this->ConfigName, true); plist += "/Info.plist"; std::string name = cmSystemTools::GetFilenameName(targetName); this->LocalGenerator->GenerateAppleInfoPList(this->GT->Target, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index a5ff829..37b788d 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -5126,47 +5126,6 @@ std::string cmTarget::CheckCMP0004(std::string const& item) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetFrameworkDirectory(const std::string& config, - bool rootDir) const -{ - std::string fpath; - fpath += this->GetOutputName(config, false); - fpath += ".framework"; - if(!rootDir) - { - fpath += "/Versions/"; - fpath += this->GetFrameworkVersion(); - } - return fpath; -} - -//---------------------------------------------------------------------------- -std::string cmTarget::GetCFBundleDirectory(const std::string& config, - bool contentOnly) const -{ - std::string fpath; - fpath += this->GetOutputName(config, false); - fpath += "."; - const char *ext = this->GetProperty("BUNDLE_EXTENSION"); - if (!ext) - { - if (this->IsXCTestOnApple()) - { - ext = "xctest"; - } - else - { - ext = "bundle"; - } - } - fpath += ext; - fpath += "/Contents"; - if(!contentOnly) - fpath += "/MacOS"; - return fpath; -} - -//---------------------------------------------------------------------------- cmTargetInternalPointer::cmTargetInternalPointer() { this->Pointer = new cmTargetInternals; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e22d3af..d0cbc66 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -460,14 +460,6 @@ public: /** @return whether this target have a well defined output file name. */ bool HaveWellDefinedOutputFiles() const; - /** @return the Mac framework directory without the base. */ - std::string GetFrameworkDirectory(const std::string& config, - bool rootDir) const; - - /** @return the Mac CFBundle directory without the base */ - std::string GetCFBundleDirectory(const std::string& config, - bool contentOnly) const; - std::vector GetIncludeDirectories( const std::string& config, const std::string& language) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=05bd71ce438bb92348f0948661ead92cbf09d982 commit 05bd71ce438bb92348f0948661ead92cbf09d982 Author: Stephen Kelly AuthorDate: Tue Oct 9 19:01:39 2012 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:03:46 2015 +0200 cmGeneratorTarget: Move GetFullNameInternal from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index cdacfcb..436e5dd 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -663,7 +663,7 @@ cmGeneratorTarget::GetCompilePDBName(const std::string& config) const std::string prefix; std::string base; std::string suffix; - this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, false, prefix, base, suffix); // Check for a per-configuration output directory target property. std::string configUpper = cmSystemTools::UpperCase(config); @@ -905,6 +905,20 @@ cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, //---------------------------------------------------------------------------- std::string +cmGeneratorTarget::GetFullName(const std::string& config, bool implib) const +{ + if(this->Target->IsImported()) + { + return this->Target->GetFullNameImported(config, implib); + } + else + { + return this->GetFullNameInternal(config, implib); + } +} + +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetInstallNameDirForBuildTree( const std::string& config) const { @@ -977,7 +991,7 @@ void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, const std::string& config, bool implib) const { - this->Target->GetFullNameInternal(config, implib, prefix, base, suffix); + this->GetFullNameInternal(config, implib, prefix, base, suffix); } //---------------------------------------------------------------------------- @@ -1753,7 +1767,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, std::string prefix; std::string base; std::string suffix; - this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, false, prefix, base, suffix); // The library name. name = prefix+base+suffix; @@ -1782,7 +1796,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, if(this->GetType() == cmTarget::SHARED_LIBRARY || this->GetType() == cmTarget::MODULE_LIBRARY) { - impName = this->Target->GetFullNameInternal(config, true); + impName = this->GetFullNameInternal(config, true); } else { @@ -1828,7 +1842,7 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, std::string prefix; std::string base; std::string suffix; - this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, false, prefix, base, suffix); // The executable name. name = prefix+base+suffix; @@ -1849,19 +1863,163 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, #endif // The import library name. - impName = this->Target->GetFullNameInternal(config, true); + impName = this->GetFullNameInternal(config, true); // The program database file name. pdbName = this->GetPDBName(config); } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetFullNameInternal(const std::string& config, + bool implib) const +{ + std::string prefix; + std::string base; + std::string suffix; + this->GetFullNameInternal(config, implib, prefix, base, suffix); + return prefix+base+suffix; +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GetFullNameInternal(const std::string& config, + bool implib, + std::string& outPrefix, + std::string& outBase, + std::string& outSuffix) const +{ + // Use just the target name for non-main target types. + if(this->GetType() != cmTarget::STATIC_LIBRARY && + this->GetType() != cmTarget::SHARED_LIBRARY && + this->GetType() != cmTarget::MODULE_LIBRARY && + this->GetType() != cmTarget::EXECUTABLE) + { + outPrefix = ""; + outBase = this->GetName(); + outSuffix = ""; + return; + } + + // Return an empty name for the import library if this platform + // does not support import libraries. + if(implib && + !this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) + { + outPrefix = ""; + outBase = ""; + outSuffix = ""; + return; + } + + // The implib option is only allowed for shared libraries, module + // libraries, and executables. + if(this->GetType() != cmTarget::SHARED_LIBRARY && + this->GetType() != cmTarget::MODULE_LIBRARY && + this->GetType() != cmTarget::EXECUTABLE) + { + implib = false; + } + + // Compute the full name for main target types. + const char* targetPrefix = (implib + ? this->GetProperty("IMPORT_PREFIX") + : this->GetProperty("PREFIX")); + const char* targetSuffix = (implib + ? this->GetProperty("IMPORT_SUFFIX") + : this->GetProperty("SUFFIX")); + const char* configPostfix = 0; + if(!config.empty()) + { + std::string configProp = cmSystemTools::UpperCase(config); + configProp += "_POSTFIX"; + configPostfix = this->GetProperty(configProp); + // Mac application bundles and frameworks have no postfix. + if(configPostfix && + (this->Target->IsAppBundleOnApple() + || this->Target->IsFrameworkOnApple())) + { + configPostfix = 0; + } + } + const char* prefixVar = this->Target->GetPrefixVariableInternal(implib); + const char* suffixVar = this->Target->GetSuffixVariableInternal(implib); + + // Check for language-specific default prefix and suffix. + std::string ll = this->Target->GetLinkerLanguage(config); + if(!ll.empty()) + { + if(!targetSuffix && suffixVar && *suffixVar) + { + std::string langSuff = suffixVar + std::string("_") + ll; + targetSuffix = this->Makefile->GetDefinition(langSuff); + } + if(!targetPrefix && prefixVar && *prefixVar) + { + std::string langPrefix = prefixVar + std::string("_") + ll; + targetPrefix = this->Makefile->GetDefinition(langPrefix); + } + } + + // if there is no prefix on the target use the cmake definition + if(!targetPrefix && prefixVar) + { + targetPrefix = this->Makefile->GetSafeDefinition(prefixVar); + } + // if there is no suffix on the target use the cmake definition + if(!targetSuffix && suffixVar) + { + targetSuffix = this->Makefile->GetSafeDefinition(suffixVar); + } + + // frameworks have directory prefix but no suffix + std::string fw_prefix; + if(this->Target->IsFrameworkOnApple()) + { + fw_prefix = this->Target->GetOutputName(config, false); + fw_prefix += ".framework/"; + targetPrefix = fw_prefix.c_str(); + targetSuffix = 0; + } + + if(this->Target->IsCFBundleOnApple()) + { + fw_prefix = this->Target->GetCFBundleDirectory(config, false); + fw_prefix += "/"; + targetPrefix = fw_prefix.c_str(); + targetSuffix = 0; + } + + // Begin the final name with the prefix. + outPrefix = targetPrefix?targetPrefix:""; + + // Append the target name or property-specified name. + outBase += this->Target->GetOutputName(config, implib); + + // Append the per-configuration postfix. + outBase += configPostfix?configPostfix:""; + + // Name shared libraries with their version number on some platforms. + if(const char* soversion = this->GetProperty("SOVERSION")) + { + if(this->GetType() == cmTarget::SHARED_LIBRARY && !implib && + this->Makefile->IsOn("CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION")) + { + outBase += "-"; + outBase += soversion; + } + } + + // Append the suffix. + outSuffix = targetSuffix?targetSuffix:""; +} + + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetPDBName(const std::string& config) const { std::string prefix; std::string base; std::string suffix; - this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, false, prefix, base, suffix); std::vector props; std::string configUpper = diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index d0d6709..8ccd6d0 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -284,6 +284,11 @@ private: mutable std::map DebugCompatiblePropertiesDone; + std::string GetFullNameInternal(const std::string& config, bool implib) const; + void GetFullNameInternal(const std::string& config, bool implib, + std::string& outPrefix, std::string& outBase, + std::string& outSuffix) const; + struct CompatibleInterfacesBase { std::set PropsBool; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index c484417..a5ff829 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3612,148 +3612,6 @@ cmTarget::ImportedGetFullPath(const std::string& config, bool implib) const } //---------------------------------------------------------------------------- -std::string -cmTarget::GetFullNameInternal(const std::string& config, bool implib) const -{ - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, implib, prefix, base, suffix); - return prefix+base+suffix; -} - -//---------------------------------------------------------------------------- -void cmTarget::GetFullNameInternal(const std::string& config, - bool implib, - std::string& outPrefix, - std::string& outBase, - std::string& outSuffix) const -{ - // Use just the target name for non-main target types. - if(this->GetType() != cmTarget::STATIC_LIBRARY && - this->GetType() != cmTarget::SHARED_LIBRARY && - this->GetType() != cmTarget::MODULE_LIBRARY && - this->GetType() != cmTarget::EXECUTABLE) - { - outPrefix = ""; - outBase = this->GetName(); - outSuffix = ""; - return; - } - - // Return an empty name for the import library if this platform - // does not support import libraries. - if(implib && - !this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) - { - outPrefix = ""; - outBase = ""; - outSuffix = ""; - return; - } - - // The implib option is only allowed for shared libraries, module - // libraries, and executables. - if(this->GetType() != cmTarget::SHARED_LIBRARY && - this->GetType() != cmTarget::MODULE_LIBRARY && - this->GetType() != cmTarget::EXECUTABLE) - { - implib = false; - } - - // Compute the full name for main target types. - const char* targetPrefix = (implib - ? this->GetProperty("IMPORT_PREFIX") - : this->GetProperty("PREFIX")); - const char* targetSuffix = (implib - ? this->GetProperty("IMPORT_SUFFIX") - : this->GetProperty("SUFFIX")); - const char* configPostfix = 0; - if(!config.empty()) - { - std::string configProp = cmSystemTools::UpperCase(config); - configProp += "_POSTFIX"; - configPostfix = this->GetProperty(configProp); - // Mac application bundles and frameworks have no postfix. - if(configPostfix && - (this->IsAppBundleOnApple() || this->IsFrameworkOnApple())) - { - configPostfix = 0; - } - } - const char* prefixVar = this->GetPrefixVariableInternal(implib); - const char* suffixVar = this->GetSuffixVariableInternal(implib); - - // Check for language-specific default prefix and suffix. - std::string ll = this->GetLinkerLanguage(config); - if(!ll.empty()) - { - if(!targetSuffix && suffixVar && *suffixVar) - { - std::string langSuff = suffixVar + std::string("_") + ll; - targetSuffix = this->Makefile->GetDefinition(langSuff); - } - if(!targetPrefix && prefixVar && *prefixVar) - { - std::string langPrefix = prefixVar + std::string("_") + ll; - targetPrefix = this->Makefile->GetDefinition(langPrefix); - } - } - - // if there is no prefix on the target use the cmake definition - if(!targetPrefix && prefixVar) - { - targetPrefix = this->Makefile->GetSafeDefinition(prefixVar); - } - // if there is no suffix on the target use the cmake definition - if(!targetSuffix && suffixVar) - { - targetSuffix = this->Makefile->GetSafeDefinition(suffixVar); - } - - // frameworks have directory prefix but no suffix - std::string fw_prefix; - if(this->IsFrameworkOnApple()) - { - fw_prefix = this->GetOutputName(config, false); - fw_prefix += ".framework/"; - targetPrefix = fw_prefix.c_str(); - targetSuffix = 0; - } - - if(this->IsCFBundleOnApple()) - { - fw_prefix = this->GetCFBundleDirectory(config, false); - fw_prefix += "/"; - targetPrefix = fw_prefix.c_str(); - targetSuffix = 0; - } - - // Begin the final name with the prefix. - outPrefix = targetPrefix?targetPrefix:""; - - // Append the target name or property-specified name. - outBase += this->GetOutputName(config, implib); - - // Append the per-configuration postfix. - outBase += configPostfix?configPostfix:""; - - // Name shared libraries with their version number on some platforms. - if(const char* soversion = this->GetProperty("SOVERSION")) - { - if(this->GetType() == cmTarget::SHARED_LIBRARY && !implib && - this->Makefile->IsOn("CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION")) - { - outBase += "-"; - outBase += soversion; - } - } - - // Append the suffix. - outSuffix = targetSuffix?targetSuffix:""; -} - -//---------------------------------------------------------------------------- void cmTarget::ComputeVersionedName(std::string& vName, std::string const& prefix, std::string const& base, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 633e0ee..e22d3af 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -570,11 +570,6 @@ private: const char* GetSuffixVariableInternal(bool implib) const; const char* GetPrefixVariableInternal(bool implib) const; - std::string GetFullNameInternal(const std::string& config, - bool implib) const; - void GetFullNameInternal(const std::string& config, bool implib, - std::string& outPrefix, std::string& outBase, - std::string& outSuffix) const; // Use a makefile variable to set a default for the given property. // If the variable is not defined use the given default instead. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=dd64a8b53b8e06979e28ffae61970037ce522f7a commit dd64a8b53b8e06979e28ffae61970037ce522f7a Author: Stephen Kelly AuthorDate: Tue Oct 9 01:26:16 2012 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:03:46 2015 +0200 cmGeneratorTarget: Move GetFullName from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 0fdf646..cdacfcb 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -576,7 +576,7 @@ const char* cmGeneratorTarget::GetLocationForBuild() const } } location += "/"; - location += this->Target->GetFullName("", false); + location += this->GetFullName("", false); return location.c_str(); } @@ -896,7 +896,7 @@ std::string cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, bool contentOnly) const { - std::string fpath = this->Target->GetFullName(config, false); + std::string fpath = this->GetFullName(config, false); fpath += ".app/Contents"; if(!contentOnly) fpath += "/MacOS"; @@ -1655,7 +1655,7 @@ std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config, // Add the full name of the target. if(implib) { - fpath += this->Target->GetFullName(config, true); + fpath += this->GetFullName(config, true); } else if(realname) { @@ -1663,7 +1663,7 @@ std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config, } else { - fpath += this->Target->GetFullName(config, false); + fpath += this->GetFullName(config, false); } return fpath; } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index f0d8c60..d0d6709 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -119,6 +119,11 @@ public: std::string GetAppBundleDirectory(const std::string& config, bool contentOnly) const; + /** Get the full name of the target according to the settings in its + makefile. */ + std::string GetFullName(const std::string& config="", + bool implib = false) const; + /** Return the install name directory for the target in the * build tree. For example: "\@rpath/", "\@loader_path/", * or "/full/path/to/library". */ diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index d53ecde..7b0e153 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2742,7 +2742,8 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget, } else { - fullName = cmtarget.GetFullName(defConfig.c_str()); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&cmtarget); + fullName = gtgt->GetFullName(defConfig.c_str()); } fileRef->AddAttribute("path", this->CreateString(fullName.c_str())); fileRef->AddAttribute("refType", this->CreateString("0")); @@ -3688,7 +3689,7 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( std::string universalFile = universal; universalFile += *arch; universalFile += "/"; - universalFile += t->GetFullName(configName); + universalFile += gt->GetFullName(configName); makefileStream << "\t/bin/rm -f " << this->ConvertToRelativeForMake(universalFile.c_str()) diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 61d7847..43e9ae4 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1112,7 +1112,8 @@ void cmLocalVisualStudio6Generator // Compute the proper name to use to link this library. std::string lib; std::string libDebug; - cmTarget* tgt = this->GlobalGenerator->FindTarget(j->first.c_str()); + cmGeneratorTarget* tgt = + this->GlobalGenerator->FindGeneratorTarget(j->first.c_str()); if(tgt) { lib = cmSystemTools::GetFilenameWithoutExtension @@ -1328,11 +1329,11 @@ void cmLocalVisualStudio6Generator target.GetType() == cmTarget::SHARED_LIBRARY || target.GetType() == cmTarget::MODULE_LIBRARY) { - outputName = target.GetFullName(); - outputNameDebug = target.GetFullName("Debug"); - outputNameRelease = target.GetFullName("Release"); - outputNameMinSizeRel = target.GetFullName("MinSizeRel"); - outputNameRelWithDebInfo = target.GetFullName("RelWithDebInfo"); + outputName = gt->GetFullName(); + outputNameDebug = gt->GetFullName("Debug"); + outputNameRelease = gt->GetFullName("Release"); + outputNameMinSizeRel = gt->GetFullName("MinSizeRel"); + outputNameRelWithDebInfo = gt->GetFullName("RelWithDebInfo"); } else if(target.GetType() == cmTarget::OBJECT_LIBRARY) { @@ -1429,10 +1430,10 @@ void cmLocalVisualStudio6Generator fullPathImpRelease += "/"; fullPathImpMinSizeRel += "/"; fullPathImpRelWithDebInfo += "/"; - fullPathImpDebug += target.GetFullName("Debug", true); - fullPathImpRelease += target.GetFullName("Release", true); - fullPathImpMinSizeRel += target.GetFullName("MinSizeRel", true); - fullPathImpRelWithDebInfo += target.GetFullName("RelWithDebInfo", true); + fullPathImpDebug += gt->GetFullName("Debug", true); + fullPathImpRelease += gt->GetFullName("Release", true); + fullPathImpMinSizeRel += gt->GetFullName("MinSizeRel", true); + fullPathImpRelWithDebInfo += gt->GetFullName("RelWithDebInfo", true); targetImplibFlagDebug = "/implib:"; targetImplibFlagRelease = "/implib:"; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 724f575..5ecb144 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1074,6 +1074,9 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, this->ConvertToOutputFormat(this->ModuleDefinitionFile, SHELL); linkOptions.AddFlag("ModuleDefinitionFile", defFile.c_str()); } + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); + if (target.GetType() == cmTarget::SHARED_LIBRARY && this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) { @@ -1104,7 +1107,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, } case cmTarget::STATIC_LIBRARY: { - std::string targetNameFull = target.GetFullName(configName); + std::string targetNameFull = gt->GetFullName(configName); std::string libpath = target.GetDirectory(configName); libpath += "/"; libpath += targetNameFull; @@ -1148,8 +1151,6 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, targetNameImport, targetNamePDB, configName); // Compute the link library and directory information. - cmGeneratorTarget* gt = - this->GlobalGenerator->GetGeneratorTarget(&target); cmComputeLinkInformation* pcli = gt->GetLinkInformation(configName); if(!pcli) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e8ef770..c484417 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3587,20 +3587,6 @@ bool cmTarget::IsImportedSharedLibWithoutSOName( } //---------------------------------------------------------------------------- -std::string cmTarget::GetFullName(const std::string& config, - bool implib) const -{ - if(this->IsImported()) - { - return this->GetFullNameImported(config, implib); - } - else - { - return this->GetFullNameInternal(config, implib); - } -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetFullNameImported(const std::string& config, bool implib) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 4b804da..633e0ee 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -368,11 +368,6 @@ public: ///! Return the preferred linker language for this target std::string GetLinkerLanguage(const std::string& config = "") const; - /** Get the full name of the target according to the settings in its - makefile. */ - std::string GetFullName(const std::string& config="", - bool implib = false) const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 16edf3c..2b33c2c 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1774,7 +1774,7 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions() else { outDir = this->Target->GetDirectory(config->c_str()) + "/"; - targetNameFull = this->Target->GetFullName(config->c_str()); + targetNameFull = this->GeneratorTarget->GetFullName(config->c_str()); } this->ConvertToWindowsSlash(intermediateDir); this->ConvertToWindowsSlash(outDir); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ee0d75a5f81aadecb6d0b94b78c9f21bff5aba44 commit ee0d75a5f81aadecb6d0b94b78c9f21bff5aba44 Author: Stephen Kelly AuthorDate: Tue Jul 28 22:44:00 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:03:46 2015 +0200 cmGeneratorTarget: Move GetAppBundleDirectory from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 9848fb4..0fdf646 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -890,6 +890,19 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const } } + +//---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, + bool contentOnly) const +{ + std::string fpath = this->Target->GetFullName(config, false); + fpath += ".app/Contents"; + if(!contentOnly) + fpath += "/MacOS"; + return fpath; +} + //---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetInstallNameDirForBuildTree( @@ -969,6 +982,47 @@ void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, //---------------------------------------------------------------------------- std::string +cmGeneratorTarget::BuildMacContentDirectory(const std::string& base, + const std::string& config, + bool contentOnly) const +{ + std::string fpath = base; + if(this->Target->IsAppBundleOnApple()) + { + fpath += this->GetAppBundleDirectory(config, contentOnly); + } + if(this->Target->IsFrameworkOnApple()) + { + fpath += this->Target->GetFrameworkDirectory(config, contentOnly); + } + if(this->Target->IsCFBundleOnApple()) + { + fpath += this->Target->GetCFBundleDirectory(config, contentOnly); + } + return fpath; +} + +//---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetMacContentDirectory(const std::string& config, + bool implib) const +{ + // Start with the output directory for the target. + std::string fpath = this->Target->GetDirectory(config, implib); + fpath += "/"; + bool contentOnly = true; + if(this->Target->IsFrameworkOnApple()) + { + // additional files with a framework go into the version specific + // directory + contentOnly = false; + } + fpath = this->BuildMacContentDirectory(fpath, config, contentOnly); + return fpath; +} + +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetModuleDefinitionFile(const std::string& config) const { std::string data; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 6d084f7..f0d8c60 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -115,6 +115,10 @@ public: bool realname) const; std::string NormalGetRealName(const std::string& config) const; + /** @return the Mac App directory without the base */ + std::string GetAppBundleDirectory(const std::string& config, + bool contentOnly) const; + /** Return the install name directory for the target in the * build tree. For example: "\@rpath/", "\@loader_path/", * or "/full/path/to/library". */ diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 7df2f78..1d85d9c 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -47,7 +47,7 @@ void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName, // Compute bundle directory names. std::string out = outpath; out += "/"; - out += this->GT->Target->GetAppBundleDirectory(this->ConfigName, false); + out += this->GT->GetAppBundleDirectory(this->ConfigName, false); cmSystemTools::MakeDirectory(out.c_str()); this->Makefile->AddCMakeOutputFile(out); @@ -57,7 +57,7 @@ void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName, // to be set. std::string plist = outpath; plist += "/"; - plist += this->GT->Target->GetAppBundleDirectory(this->ConfigName, true); + plist += this->GT->GetAppBundleDirectory(this->ConfigName, true); plist += "/Info.plist"; this->LocalGenerator->GenerateAppleInfoPList(this->GT->Target, targetName, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index b49ad9b..e8ef770 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -5323,17 +5323,6 @@ std::string cmTarget::GetCFBundleDirectory(const std::string& config, } //---------------------------------------------------------------------------- -std::string cmTarget::GetAppBundleDirectory(const std::string& config, - bool contentOnly) const -{ - std::string fpath = this->GetFullName(config, false); - fpath += ".app/Contents"; - if(!contentOnly) - fpath += "/MacOS"; - return fpath; -} - -//---------------------------------------------------------------------------- cmTargetInternalPointer::cmTargetInternalPointer() { this->Pointer = new cmTargetInternals; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index c1c518f..4b804da 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -473,10 +473,6 @@ public: std::string GetCFBundleDirectory(const std::string& config, bool contentOnly) const; - /** @return the Mac App directory without the base */ - std::string GetAppBundleDirectory(const std::string& config, - bool contentOnly) const; - std::vector GetIncludeDirectories( const std::string& config, const std::string& language) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6e4e98de6e3bb604281e3f387ecee619c5f23709 commit 6e4e98de6e3bb604281e3f387ecee619c5f23709 Author: Stephen Kelly AuthorDate: Tue Oct 9 01:20:27 2012 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:03:45 2015 +0200 cmGeneratorTarget: Move GetInstallNameDir* from cmTarget. diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 6274c3f..fed0dbc 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -333,12 +333,12 @@ cmExportBuildFileGenerator } std::string -cmExportBuildFileGenerator::InstallNameDir(cmTarget* target, +cmExportBuildFileGenerator::InstallNameDir(cmGeneratorTarget* target, const std::string& config) { std::string install_name_dir; - cmMakefile* mf = target->GetMakefile(); + cmMakefile* mf = target->Target->GetMakefile(); if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { install_name_dir = diff --git a/Source/cmExportBuildFileGenerator.h b/Source/cmExportBuildFileGenerator.h index 4d8e062..ff3d2e1 100644 --- a/Source/cmExportBuildFileGenerator.h +++ b/Source/cmExportBuildFileGenerator.h @@ -71,7 +71,8 @@ protected: cmGeneratorTarget* target, ImportPropertyMap& properties); - std::string InstallNameDir(cmTarget* target, const std::string& config); + std::string InstallNameDir(cmGeneratorTarget* target, + const std::string& config); std::vector FindNamespaces(cmMakefile* mf, const std::string& name); diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index e3652c5..cae60b7 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -893,7 +893,7 @@ cmExportFileGenerator { if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { - value = this->InstallNameDir(target->Target, config); + value = this->InstallNameDir(target, config); } prop = "IMPORTED_SONAME"; value += target->GetSOName(config); diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index 4e54740..44f779b 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -200,7 +200,7 @@ private: virtual void ReplaceInstallPrefix(std::string &input); - virtual std::string InstallNameDir(cmTarget* target, + virtual std::string InstallNameDir(cmGeneratorTarget* target, const std::string& config) = 0; }; diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 23015e9..71875d5 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -546,12 +546,12 @@ cmExportInstallFileGenerator } std::string -cmExportInstallFileGenerator::InstallNameDir(cmTarget* target, +cmExportInstallFileGenerator::InstallNameDir(cmGeneratorTarget* target, const std::string&) { std::string install_name_dir; - cmMakefile* mf = target->GetMakefile(); + cmMakefile* mf = target->Target->GetMakefile(); if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { install_name_dir = diff --git a/Source/cmExportInstallFileGenerator.h b/Source/cmExportInstallFileGenerator.h index 6f86ac9..b06fee5 100644 --- a/Source/cmExportInstallFileGenerator.h +++ b/Source/cmExportInstallFileGenerator.h @@ -83,7 +83,8 @@ protected: std::set& importedLocations ); - std::string InstallNameDir(cmTarget* target, const std::string& config); + std::string InstallNameDir(cmGeneratorTarget* target, + const std::string& config); cmInstallExportGenerator* IEGen; diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx index 94831f8..ba66531 100644 --- a/Source/cmExportTryCompileFileGenerator.cxx +++ b/Source/cmExportTryCompileFileGenerator.cxx @@ -125,12 +125,12 @@ cmExportTryCompileFileGenerator::PopulateProperties(cmTarget const* target, } std::string -cmExportTryCompileFileGenerator::InstallNameDir(cmTarget* target, +cmExportTryCompileFileGenerator::InstallNameDir(cmGeneratorTarget* target, const std::string& config) { std::string install_name_dir; - cmMakefile* mf = target->GetMakefile(); + cmMakefile* mf = target->Target->GetMakefile(); if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { install_name_dir = diff --git a/Source/cmExportTryCompileFileGenerator.h b/Source/cmExportTryCompileFileGenerator.h index 749f3ef..8838eca 100644 --- a/Source/cmExportTryCompileFileGenerator.h +++ b/Source/cmExportTryCompileFileGenerator.h @@ -45,7 +45,7 @@ protected: ImportPropertyMap& properties, std::set &emitted); - std::string InstallNameDir(cmTarget* target, + std::string InstallNameDir(cmGeneratorTarget* target, const std::string& config); private: std::string FindTargets(const std::string& prop, cmTarget const* tgt, diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index daf55a7..9848fb4 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -891,6 +891,73 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const } //---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetInstallNameDirForBuildTree( + const std::string& config) const +{ + // If building directly for installation then the build tree install_name + // is the same as the install tree. + if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) + { + return this->GetInstallNameDirForInstallTree(); + } + + // Use the build tree directory for the target. + if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME") && + !this->Makefile->IsOn("CMAKE_SKIP_RPATH") && + !this->GetPropertyAsBool("SKIP_BUILD_RPATH")) + { + std::string dir; + if(this->Target->MacOSXRpathInstallNameDirDefault()) + { + dir = "@rpath"; + } + else + { + dir = this->Target->GetDirectory(config); + } + dir += "/"; + return dir; + } + else + { + return ""; + } +} + +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetInstallNameDirForInstallTree() const +{ + if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) + { + std::string dir; + const char* install_name_dir = this->GetProperty("INSTALL_NAME_DIR"); + + if(!this->Makefile->IsOn("CMAKE_SKIP_RPATH") && + !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH")) + { + if(install_name_dir && *install_name_dir) + { + dir = install_name_dir; + dir += "/"; + } + } + if(!install_name_dir) + { + if(this->Target->MacOSXRpathInstallNameDirDefault()) + { + dir = "@rpath/"; + } + } + return dir; + } + else + { + return ""; + } +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, std::string& base, std::string& suffix, diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 8fc1b44..6d084f7 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -115,6 +115,15 @@ public: bool realname) const; std::string NormalGetRealName(const std::string& config) const; + /** Return the install name directory for the target in the + * build tree. For example: "\@rpath/", "\@loader_path/", + * or "/full/path/to/library". */ + std::string GetInstallNameDirForBuildTree(const std::string& config) const; + + /** Return the install name directory for the target in the + * install tree. For example: "\@rpath/" or "\@loader_path/". */ + std::string GetInstallNameDirForInstallTree() const; + /** Get the soname of the target. Allowed only for a shared library. */ std::string GetSOName(const std::string& config) const; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 03f6d8f..d53ecde 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2331,7 +2331,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, if(target.GetType() == cmTarget::SHARED_LIBRARY) { // Get the install_name directory for the build tree. - install_name_dir = target.GetInstallNameDirForBuildTree(configName); + install_name_dir = gtgt->GetInstallNameDirForBuildTree(configName); // Xcode doesn't create the correct install_name in some cases. // That is, if the INSTALL_PATH is empty, or if we have versioning // of dylib libraries, we want to specify the install_name. diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 558d82f..60fadbe 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -576,11 +576,15 @@ cmInstallTargetGenerator continue; } + cmGeneratorTarget *gtgt = tgt->GetMakefile() + ->GetLocalGenerator() + ->GetGlobalGenerator() + ->GetGeneratorTarget(tgt); // If the build tree and install tree use different path // components of the install_name field then we need to create a // mapping to be applied after installation. - std::string for_build = tgt->GetInstallNameDirForBuildTree(config); - std::string for_install = tgt->GetInstallNameDirForInstallTree(); + std::string for_build = gtgt->GetInstallNameDirForBuildTree(config); + std::string for_install = gtgt->GetInstallNameDirForInstallTree(); if(for_build != for_install) { // The directory portions differ. Append the filename to @@ -605,9 +609,9 @@ cmInstallTargetGenerator if(this->Target->GetType() == cmTarget::SHARED_LIBRARY) { std::string for_build = - this->Target->Target->GetInstallNameDirForBuildTree(config); + this->Target->GetInstallNameDirForBuildTree(config); std::string for_install = - this->Target->Target->GetInstallNameDirForInstallTree(); + this->Target->GetInstallNameDirForInstallTree(); if(this->Target->Target->IsFrameworkOnApple() && for_install.empty()) { diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index a2fcbad..b85b8a8 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -666,7 +666,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules { // Get the install_name directory for the build tree. install_name_dir = - this->Target->GetInstallNameDirForBuildTree(this->ConfigName); + this->GeneratorTarget->GetInstallNameDirForBuildTree(this->ConfigName); // Set the rule variable replacement value. if(install_name_dir.empty()) diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index c80f485..1835841 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -537,7 +537,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() vars["SONAME"] = this->TargetNameSO; if (targetType == cmTarget::SHARED_LIBRARY) { - std::string install_dir = target.GetInstallNameDirForBuildTree(cfgName); + std::string install_dir = + this->GetGeneratorTarget()->GetInstallNameDirForBuildTree(cfgName); if (!install_dir.empty()) { vars["INSTALLNAME_DIR"] = localGen.Convert(install_dir, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 0f1d309..b49ad9b 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3846,73 +3846,6 @@ bool cmTarget::HaveInstallTreeRPATH() const } //---------------------------------------------------------------------------- -std::string cmTarget::GetInstallNameDirForBuildTree( - const std::string& config) const -{ - // If building directly for installation then the build tree install_name - // is the same as the install tree. - if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) - { - return GetInstallNameDirForInstallTree(); - } - - // Use the build tree directory for the target. - if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME") && - !this->Makefile->IsOn("CMAKE_SKIP_RPATH") && - !this->GetPropertyAsBool("SKIP_BUILD_RPATH")) - { - std::string dir; - bool macosx_rpath = this->MacOSXRpathInstallNameDirDefault(); - if(macosx_rpath) - { - dir = "@rpath"; - } - else - { - dir = this->GetDirectory(config); - } - dir += "/"; - return dir; - } - else - { - return ""; - } -} - -//---------------------------------------------------------------------------- -std::string cmTarget::GetInstallNameDirForInstallTree() const -{ - if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) - { - std::string dir; - const char* install_name_dir = this->GetProperty("INSTALL_NAME_DIR"); - - if(!this->Makefile->IsOn("CMAKE_SKIP_RPATH") && - !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH")) - { - if(install_name_dir && *install_name_dir) - { - dir = install_name_dir; - dir += "/"; - } - } - if(!install_name_dir) - { - if(this->MacOSXRpathInstallNameDirDefault()) - { - dir = "@rpath/"; - } - } - return dir; - } - else - { - return ""; - } -} - -//---------------------------------------------------------------------------- const char* cmTarget::GetOutputTargetType(bool implib) const { switch(this->GetType()) diff --git a/Source/cmTarget.h b/Source/cmTarget.h index d03ba3b..c1c518f 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -394,15 +394,6 @@ public: bool HaveBuildTreeRPATH(const std::string& config) const; bool HaveInstallTreeRPATH() const; - /** Return the install name directory for the target in the - * build tree. For example: "\@rpath/", "\@loader_path/", - * or "/full/path/to/library". */ - std::string GetInstallNameDirForBuildTree(const std::string& config) const; - - /** Return the install name directory for the target in the - * install tree. For example: "\@rpath/" or "\@loader_path/". */ - std::string GetInstallNameDirForInstallTree() const; - // Get the properties cmPropertyMap &GetProperties() const { return this->Properties; } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=938acba9e0f7fe6cc3a7eec5de4a10021a0aef05 commit 938acba9e0f7fe6cc3a7eec5de4a10021a0aef05 Author: Stephen Kelly AuthorDate: Tue Oct 9 01:13:20 2012 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:03:45 2015 +0200 cmGeneratorTarget: Move GetMacContentDirectory from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 4be034f..daf55a7 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -567,7 +567,7 @@ const char* cmGeneratorTarget::GetLocationForBuild() const if(this->Target->IsAppBundleOnApple()) { - std::string macdir = this->Target->BuildMacContentDirectory("", "", + std::string macdir = this->BuildMacContentDirectory("", "", false); if(!macdir.empty()) { @@ -1527,7 +1527,7 @@ std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config, fpath += "/"; if(this->Target->IsAppBundleOnApple()) { - fpath = this->Target->BuildMacContentDirectory(fpath, config, false); + fpath = this->BuildMacContentDirectory(fpath, config, false); fpath += "/"; } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index f96adad..8fc1b44 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -123,6 +123,15 @@ public: const std::string& config="", bool implib = false) const; + /** Append to @a base the mac content directory and return it. */ + std::string BuildMacContentDirectory(const std::string& base, + const std::string& config = "", + bool contentOnly = true) const; + + /** @return the mac content directory for this target. */ + std::string GetMacContentDirectory(const std::string& config = 0, + bool implib = false) const; + cmTarget* Target; cmMakefile* Makefile; cmLocalGenerator* LocalGenerator; diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 3bc0eb7..7df2f78 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -217,7 +217,7 @@ cmOSXBundleGenerator::InitMacOSXContentDirectory(const char* pkgloc) // Construct the full path to the content subdirectory. std::string macdir = - this->GT->Target->GetMacContentDirectory(this->ConfigName, + this->GT->GetMacContentDirectory(this->ConfigName, /*implib*/ false); macdir += "/"; macdir += pkgloc; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 0d9aa49..0f1d309 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -5401,45 +5401,6 @@ std::string cmTarget::GetAppBundleDirectory(const std::string& config, } //---------------------------------------------------------------------------- -std::string cmTarget::BuildMacContentDirectory(const std::string& base, - const std::string& config, - bool contentOnly) const -{ - std::string fpath = base; - if(this->IsAppBundleOnApple()) - { - fpath += this->GetAppBundleDirectory(config, contentOnly); - } - if(this->IsFrameworkOnApple()) - { - fpath += this->GetFrameworkDirectory(config, contentOnly); - } - if(this->IsCFBundleOnApple()) - { - fpath += this->GetCFBundleDirectory(config, contentOnly); - } - return fpath; -} - -//---------------------------------------------------------------------------- -std::string cmTarget::GetMacContentDirectory(const std::string& config, - bool implib) const -{ - // Start with the output directory for the target. - std::string fpath = this->GetDirectory(config, implib); - fpath += "/"; - bool contentOnly = true; - if(this->IsFrameworkOnApple()) - { - // additional files with a framework go into the version specific - // directory - contentOnly = false; - } - fpath = this->BuildMacContentDirectory(fpath, config, contentOnly); - return fpath; -} - -//---------------------------------------------------------------------------- cmTargetInternalPointer::cmTargetInternalPointer() { this->Pointer = new cmTargetInternals; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 9962fdb..d03ba3b 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -471,10 +471,6 @@ public: directory. */ bool UsesDefaultOutputDir(const std::string& config, bool implib) const; - /** @return the mac content directory for this target. */ - std::string GetMacContentDirectory(const std::string& config, - bool implib) const; - /** @return whether this target have a well defined output file name. */ bool HaveWellDefinedOutputFiles() const; @@ -615,10 +611,6 @@ private: std::string ImportedGetFullPath(const std::string& config, bool implib) const; - /** Append to @a base the mac content directory and return it. */ - std::string BuildMacContentDirectory(const std::string& base, - const std::string& config, - bool contentOnly) const; void GetSourceFiles(std::vector &files, const std::string& config) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=be205eb56d91414749b7a6073e14747e840d1aba commit be205eb56d91414749b7a6073e14747e840d1aba Author: Stephen Kelly AuthorDate: Tue Oct 9 00:40:34 2012 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:03:45 2015 +0200 cmGeneratorTarget: Move GetFullNameComponents from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 6481390..4be034f 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -891,6 +891,16 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const } //---------------------------------------------------------------------------- +void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, + std::string& base, + std::string& suffix, + const std::string& config, + bool implib) const +{ + this->Target->GetFullNameInternal(config, implib, prefix, base, suffix); +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetModuleDefinitionFile(const std::string& config) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 9ecbbbe..f96adad 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -118,6 +118,11 @@ public: /** Get the soname of the target. Allowed only for a shared library. */ std::string GetSOName(const std::string& config) const; + void GetFullNameComponents(std::string& prefix, + std::string& base, std::string& suffix, + const std::string& config="", + bool implib = false) const; + cmTarget* Target; cmMakefile* Makefile; cmLocalGenerator* LocalGenerator; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index d7ae36d..03f6d8f 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1940,7 +1940,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, std::string pnprefix; std::string pnbase; std::string pnsuffix; - target.GetFullNameComponents(pnprefix, pnbase, pnsuffix, configName); + gtgt->GetFullNameComponents(pnprefix, pnbase, pnsuffix, configName); const char* version = target.GetProperty("VERSION"); const char* soversion = target.GetProperty("SOVERSION"); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 2586b31..c80f485 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -569,7 +569,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() std::string prefix; std::string base; std::string suffix; - target.GetFullNameComponents(prefix, base, suffix); + this->GetGeneratorTarget()->GetFullNameComponents(prefix, base, suffix); std::string dbg_suffix = ".dbg"; // TODO: Where to document? if (mf->GetDefinition("CMAKE_DEBUG_SYMBOL_SUFFIX")) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1183fe4..0d9aa49 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3609,15 +3609,6 @@ cmTarget::GetFullNameImported(const std::string& config, bool implib) const } //---------------------------------------------------------------------------- -void cmTarget::GetFullNameComponents(std::string& prefix, std::string& base, - std::string& suffix, - const std::string& config, - bool implib) const -{ - this->GetFullNameInternal(config, implib, prefix, base, suffix); -} - -//---------------------------------------------------------------------------- std::string cmTarget::ImportedGetFullPath(const std::string& config, bool implib) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 1aef7b3..9962fdb 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -372,10 +372,6 @@ public: makefile. */ std::string GetFullName(const std::string& config="", bool implib = false) const; - void GetFullNameComponents(std::string& prefix, - std::string& base, std::string& suffix, - const std::string& config="", - bool implib = false) const; /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1bd6d804a909be8884bf5dd234d8f6125c92d5a9 commit 1bd6d804a909be8884bf5dd234d8f6125c92d5a9 Author: Stephen Kelly AuthorDate: Sun Nov 3 12:26:44 2013 +0100 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:03:45 2015 +0200 cmGeneratorTarget: Move IsChrPathUsed from cmTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 5aaa266..fee921c 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -321,7 +321,11 @@ cmComputeLinkInformation this->RuntimeAlways = (this->Makefile-> GetSafeDefinition("CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH")); - this->RuntimeUseChrpath = this->Target->IsChrpathUsed(config); + + cmGeneratorTarget *gtgt = this->Target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(this->Target); + this->RuntimeUseChrpath = gtgt->IsChrpathUsed(config); // Get options needed to help find dependent libraries. std::string rlVar = "CMAKE_"; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 505d01f..6481390 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -746,7 +746,7 @@ cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const } // If chrpath is going to be used no relinking is needed. - if(this->Target->IsChrpathUsed(config)) + if(this->IsChrpathUsed(config)) { return false; } @@ -779,6 +779,73 @@ cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const || this->Target->HaveInstallTreeRPATH(); } +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsChrpathUsed(const std::string& config) const +{ + // Only certain target types have an rpath. + if(!(this->GetType() == cmTarget::SHARED_LIBRARY || + this->GetType() == cmTarget::MODULE_LIBRARY || + this->GetType() == cmTarget::EXECUTABLE)) + { + return false; + } + + // If the target will not be installed we do not need to change its + // rpath. + if(!this->Target->GetHaveInstallRule()) + { + return false; + } + + // Skip chrpath if skipping rpath altogether. + if(this->Makefile->IsOn("CMAKE_SKIP_RPATH")) + { + return false; + } + + // Skip chrpath if it does not need to be changed at install time. + if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) + { + return false; + } + + // Allow the user to disable builtin chrpath explicitly. + if(this->Makefile->IsOn("CMAKE_NO_BUILTIN_CHRPATH")) + { + return false; + } + + if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) + { + return true; + } + +#if defined(CMAKE_USE_ELF_PARSER) + // Enable if the rpath flag uses a separator and the target uses ELF + // binaries. + std::string ll = this->Target->GetLinkerLanguage(config); + if(!ll.empty()) + { + std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; + sepVar += ll; + sepVar += "_FLAG_SEP"; + const char* sep = this->Makefile->GetDefinition(sepVar); + if(sep && *sep) + { + // TODO: Add ELF check to ABI detection and get rid of + // CMAKE_EXECUTABLE_FORMAT. + if(const char* fmt = + this->Makefile->GetDefinition("CMAKE_EXECUTABLE_FORMAT")) + { + return strcmp(fmt, "ELF") == 0; + } + } + } +#endif + static_cast(config); + return false; +} + //---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetSOName(const std::string& config) const diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index c9a2508..9ecbbbe 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -215,6 +215,9 @@ public: */ bool NeedRelinkBeforeInstall(const std::string& config) const; + /** Return true if builtin chrpath will work for this target */ + bool IsChrpathUsed(const std::string& config) const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 046a4bf..558d82f 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -656,11 +656,10 @@ cmInstallTargetGenerator std::string const& toDestDirPath) { // Skip the chrpath if the target does not need it. - if(this->ImportLibrary || !this->Target->Target->IsChrpathUsed(config)) + if(this->ImportLibrary || !this->Target->IsChrpathUsed(config)) { return; } - // Skip if on Apple if(this->Target->Target->GetMakefile() ->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) @@ -695,7 +694,7 @@ cmInstallTargetGenerator std::string const& toDestDirPath) { // Skip the chrpath if the target does not need it. - if(this->ImportLibrary || !this->Target->Target->IsChrpathUsed(config)) + if(this->ImportLibrary || !this->Target->IsChrpathUsed(config)) { return; } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 8dd62f9..1183fe4 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4314,73 +4314,6 @@ void cmTarget::GetLanguages(std::set& languages, } //---------------------------------------------------------------------------- -bool cmTarget::IsChrpathUsed(const std::string& config) const -{ - // Only certain target types have an rpath. - if(!(this->GetType() == cmTarget::SHARED_LIBRARY || - this->GetType() == cmTarget::MODULE_LIBRARY || - this->GetType() == cmTarget::EXECUTABLE)) - { - return false; - } - - // If the target will not be installed we do not need to change its - // rpath. - if(!this->GetHaveInstallRule()) - { - return false; - } - - // Skip chrpath if skipping rpath altogether. - if(this->Makefile->IsOn("CMAKE_SKIP_RPATH")) - { - return false; - } - - // Skip chrpath if it does not need to be changed at install time. - if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) - { - return false; - } - - // Allow the user to disable builtin chrpath explicitly. - if(this->Makefile->IsOn("CMAKE_NO_BUILTIN_CHRPATH")) - { - return false; - } - - if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) - { - return true; - } - -#if defined(CMAKE_USE_ELF_PARSER) - // Enable if the rpath flag uses a separator and the target uses ELF - // binaries. - std::string ll = this->GetLinkerLanguage(config); - if(!ll.empty()) - { - std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; - sepVar += ll; - sepVar += "_FLAG_SEP"; - const char* sep = this->Makefile->GetDefinition(sepVar); - if(sep && *sep) - { - // TODO: Add ELF check to ABI detection and get rid of - // CMAKE_EXECUTABLE_FORMAT. - if(const char* fmt = - this->Makefile->GetDefinition("CMAKE_EXECUTABLE_FORMAT")) - { - return strcmp(fmt, "ELF") == 0; - } - } - } -#endif - static_cast(config); - return false; -} - -//---------------------------------------------------------------------------- cmTarget::ImportInfo const* cmTarget::GetImportInfo(const std::string& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 11f715a..1aef7b3 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -398,9 +398,6 @@ public: bool HaveBuildTreeRPATH(const std::string& config) const; bool HaveInstallTreeRPATH() const; - /** Return true if builtin chrpath will work for this target */ - bool IsChrpathUsed(const std::string& config) const; - /** Return the install name directory for the target in the * build tree. For example: "\@rpath/", "\@loader_path/", * or "/full/path/to/library". */ http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d222009a0fe7bf9d060b3ce49e0e720046936f89 commit d222009a0fe7bf9d060b3ce49e0e720046936f89 Author: Stephen Kelly AuthorDate: Sun Nov 3 12:25:17 2013 +0100 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:03:45 2015 +0200 cmGeneratorTarget: Move NeedRelinkBeforeInstall from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index a29f4c9..505d01f 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -714,6 +714,73 @@ bool cmGeneratorTarget::HasSOName(const std::string& config) const } //---------------------------------------------------------------------------- +bool +cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const +{ + // Only executables and shared libraries can have an rpath and may + // need relinking. + if(this->GetType() != cmTarget::EXECUTABLE && + this->GetType() != cmTarget::SHARED_LIBRARY && + this->GetType() != cmTarget::MODULE_LIBRARY) + { + return false; + } + + // If there is no install location this target will not be installed + // and therefore does not need relinking. + if(!this->Target->GetHaveInstallRule()) + { + return false; + } + + // If skipping all rpaths completely then no relinking is needed. + if(this->Makefile->IsOn("CMAKE_SKIP_RPATH")) + { + return false; + } + + // If building with the install-tree rpath no relinking is needed. + if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) + { + return false; + } + + // If chrpath is going to be used no relinking is needed. + if(this->Target->IsChrpathUsed(config)) + { + return false; + } + + // Check for rpath support on this platform. + std::string ll = this->Target->GetLinkerLanguage(config); + if(!ll.empty()) + { + std::string flagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; + flagVar += ll; + flagVar += "_FLAG"; + if(!this->Makefile->IsSet(flagVar)) + { + // There is no rpath support on this platform so nothing needs + // relinking. + return false; + } + } + else + { + // No linker language is known. This error will be reported by + // other code. + return false; + } + + // If either a build or install tree rpath is set then the rpath + // will likely change between the build tree and install tree and + // this target must be relinked. + return this->Target->HaveBuildTreeRPATH(config) + || this->Target->HaveInstallTreeRPATH(); +} + + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetSOName(const std::string& config) const { if(this->Target->IsImported()) diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 441bbcf..c9a2508 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -210,6 +210,11 @@ public: std::string& realName, std::string& impName, std::string& pdbName, const std::string& config) const; + /** + * Compute whether this target must be relinked before installing. + */ + bool NeedRelinkBeforeInstall(const std::string& config) const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index edf2705..69747a4 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -482,7 +482,7 @@ cmGlobalUnixMakefileGenerator3 // Add this to the list of depends rules in this directory. if((!check_all || !gtarget->GetPropertyAsBool("EXCLUDE_FROM_ALL")) && (!check_relink || - gtarget->Target + gtarget ->NeedRelinkBeforeInstall(lg->GetConfigName()))) { std::string tname = lg->GetRelativeTargetDirectory(*gtarget->Target); @@ -691,7 +691,7 @@ cmGlobalUnixMakefileGenerator3 // Add a local name for the rule to relink the target before // installation. - if(gtarget->Target + if(gtarget ->NeedRelinkBeforeInstall(lg->GetConfigName())) { makeTargetName = lg->GetRelativeTargetDirectory(*gtarget->Target); @@ -876,7 +876,7 @@ cmGlobalUnixMakefileGenerator3 name, depends, commands, true); // Add rules to prepare the target for installation. - if(gtarget->Target + if(gtarget ->NeedRelinkBeforeInstall(lg->GetConfigName())) { localName = lg->GetRelativeTargetDirectory(*gtarget->Target); diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 62a3a9c..046a4bf 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -73,7 +73,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, { // Compute the build tree directory from which to copy the target. std::string fromDirConfig; - if(this->Target->Target->NeedRelinkBeforeInstall(config)) + if(this->Target->NeedRelinkBeforeInstall(config)) { fromDirConfig = this->Target->Target->GetMakefile()->GetCurrentBinaryDirectory(); diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 98bd0ab..ce370bc 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -486,8 +486,7 @@ void cmLocalUnixMakefileGenerator3 // Add a local name for the rule to relink the target before // installation. - if(t->second->Target - ->NeedRelinkBeforeInstall(this->ConfigName)) + if(t->second->NeedRelinkBeforeInstall(this->ConfigName)) { makeTargetName = this->GetRelativeTargetDirectory(*t->second->Target); makeTargetName += "/preinstall"; diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 31a78ad..2fd77c9 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -58,7 +58,7 @@ void cmMakefileExecutableTargetGenerator::WriteRuleFiles() // write the link rules this->WriteExecutableRule(false); - if(this->Target->NeedRelinkBeforeInstall(this->ConfigName)) + if(this->GeneratorTarget->NeedRelinkBeforeInstall(this->ConfigName)) { // Write rules to link an installable version of the target. this->WriteExecutableRule(true); diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 7d0dc49..a2fcbad 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -69,7 +69,7 @@ void cmMakefileLibraryTargetGenerator::WriteRuleFiles() break; case cmTarget::SHARED_LIBRARY: this->WriteSharedLibraryRules(false); - if(this->Target->NeedRelinkBeforeInstall(this->ConfigName)) + if(this->GeneratorTarget->NeedRelinkBeforeInstall(this->ConfigName)) { // Write rules to link an installable version of the target. this->WriteSharedLibraryRules(true); @@ -77,7 +77,7 @@ void cmMakefileLibraryTargetGenerator::WriteRuleFiles() break; case cmTarget::MODULE_LIBRARY: this->WriteModuleLibraryRules(false); - if(this->Target->NeedRelinkBeforeInstall(this->ConfigName)) + if(this->GeneratorTarget->NeedRelinkBeforeInstall(this->ConfigName)) { // Write rules to link an installable version of the target. this->WriteModuleLibraryRules(true); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1e7fb5a..8dd62f9 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3855,70 +3855,6 @@ bool cmTarget::HaveInstallTreeRPATH() const } //---------------------------------------------------------------------------- -bool cmTarget::NeedRelinkBeforeInstall(const std::string& config) const -{ - // Only executables and shared libraries can have an rpath and may - // need relinking. - if(this->TargetTypeValue != cmTarget::EXECUTABLE && - this->TargetTypeValue != cmTarget::SHARED_LIBRARY && - this->TargetTypeValue != cmTarget::MODULE_LIBRARY) - { - return false; - } - - // If there is no install location this target will not be installed - // and therefore does not need relinking. - if(!this->GetHaveInstallRule()) - { - return false; - } - - // If skipping all rpaths completely then no relinking is needed. - if(this->Makefile->IsOn("CMAKE_SKIP_RPATH")) - { - return false; - } - - // If building with the install-tree rpath no relinking is needed. - if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) - { - return false; - } - - // If chrpath is going to be used no relinking is needed. - if(this->IsChrpathUsed(config)) - { - return false; - } - - // Check for rpath support on this platform. - std::string ll = this->GetLinkerLanguage(config); - if(!ll.empty()) - { - std::string flagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; - flagVar += ll; - flagVar += "_FLAG"; - if(!this->Makefile->IsSet(flagVar)) - { - // There is no rpath support on this platform so nothing needs - // relinking. - return false; - } - } - else - { - // No linker language is known. This error will be reported by - // other code. - return false; - } - - // If either a build or install tree rpath is set then the rpath - // will likely change between the build tree and install tree and - // this target must be relinked. - return this->HaveBuildTreeRPATH(config) || this->HaveInstallTreeRPATH(); -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetInstallNameDirForBuildTree( const std::string& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 8c23372..11f715a 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -395,11 +395,6 @@ public: bool GetImplibGNUtoMS(std::string const& gnuName, std::string& out, const char* newExt = 0) const; - /** - * Compute whether this target must be relinked before installing. - */ - bool NeedRelinkBeforeInstall(const std::string& config) const; - bool HaveBuildTreeRPATH(const std::string& config) const; bool HaveInstallTreeRPATH() const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=65e833dbf0b8372e719c6140cc1373e46e078ae8 commit 65e833dbf0b8372e719c6140cc1373e46e078ae8 Author: Stephen Kelly AuthorDate: Tue Oct 9 18:59:12 2012 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:03:44 2015 +0200 cmGeneratorTarget: Move GetPDBName from cmTarget. diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index a20579b..49fc96b 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1625,7 +1625,7 @@ struct TargetFilesystemArtifactResultCreator std::string result = target->Target->GetPDBDirectory(context->Config); result += "/"; - result += target->Target->GetPDBName(context->Config); + result += target->GetPDBName(context->Config); return result; } }; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index a125e47..a29f4c9 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1525,7 +1525,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, } // The program database file name. - pdbName = this->Target->GetPDBName(config); + pdbName = this->GetPDBName(config); } //---------------------------------------------------------------------------- @@ -1587,7 +1587,39 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, impName = this->Target->GetFullNameInternal(config, true); // The program database file name. - pdbName = this->Target->GetPDBName(config); + pdbName = this->GetPDBName(config); +} + +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetPDBName(const std::string& config) const +{ + std::string prefix; + std::string base; + std::string suffix; + this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + + std::vector props; + std::string configUpper = + cmSystemTools::UpperCase(config); + if(!configUpper.empty()) + { + // PDB_NAME_ + props.push_back("PDB_NAME_" + configUpper); + } + + // PDB_NAME + props.push_back("PDB_NAME"); + + for(std::vector::const_iterator i = props.begin(); + i != props.end(); ++i) + { + if(const char* outName = this->GetProperty(*i)) + { + base = outName; + break; + } + } + return prefix+base+".pdb"; } bool cmStrictTargetComparison::operator()(cmTarget const* t1, diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 9cdfd00..441bbcf 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -160,6 +160,9 @@ public: std::vector const* GetSourceDepends(cmSourceFile const* sf) const; + /** Get the name of the pdb file for the target. */ + std::string GetPDBName(const std::string& config="") const; + /** Whether this library has soname enabled and platform supports it. */ bool HasSOName(const std::string& config) const; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index f9125fc..b94e151 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -548,7 +548,7 @@ cmMakefileTargetGenerator this->GeneratorTarget->GetFullPath(this->ConfigName, false, true); targetFullPathPDB = this->Target->GetPDBDirectory(this->ConfigName); targetFullPathPDB += "/"; - targetFullPathPDB += this->Target->GetPDBName(this->ConfigName); + targetFullPathPDB += this->GeneratorTarget->GetPDBName(this->ConfigName); } if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY) { diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index e61ba6f..16e1f48 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -273,7 +273,7 @@ bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(cmNinjaVars& vars) const { pdbPath = this->Target->GetPDBDirectory(this->GetConfigName()); pdbPath += "/"; - pdbPath += this->Target->GetPDBName(this->GetConfigName()); + pdbPath += this->GeneratorTarget->GetPDBName(this->GetConfigName()); } if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 188ad0f..1e7fb5a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3461,37 +3461,6 @@ const char* cmTarget::GetPrefixVariableInternal(bool implib) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetPDBName(const std::string& config) const -{ - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); - - std::vector props; - std::string configUpper = cmSystemTools::UpperCase(config); - if(!configUpper.empty()) - { - // PDB_NAME_ - props.push_back("PDB_NAME_" + configUpper); - } - - // PDB_NAME - props.push_back("PDB_NAME"); - - for(std::vector::const_iterator i = props.begin(); - i != props.end(); ++i) - { - if(const char* outName = this->GetProperty(*i)) - { - base = outName; - break; - } - } - return prefix+base+".pdb"; -} - -//---------------------------------------------------------------------------- bool cmTarget::HasMacOSXRpathInstallNameDir(const std::string& config) const { bool install_name_is_rpath = false; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 162033c..8c23372 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -377,9 +377,6 @@ public: const std::string& config="", bool implib = false) const; - /** Get the name of the pdb file for the target. */ - std::string GetPDBName(const std::string& config) const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1ce989a66c3aa97d1a8ca933123335d279671e83 commit 1ce989a66c3aa97d1a8ca933123335d279671e83 Author: Stephen Kelly AuthorDate: Mon Mar 10 17:52:04 2014 +0100 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:03:44 2015 +0200 cmGeneratorTarget: Move GetCompilePDBPath from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 2b3ebee..a125e47 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -657,6 +657,51 @@ void cmGeneratorTarget::GetSourceFiles(std::vector &files, } //---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetCompilePDBName(const std::string& config) const +{ + std::string prefix; + std::string base; + std::string suffix; + this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + + // Check for a per-configuration output directory target property. + std::string configUpper = cmSystemTools::UpperCase(config); + std::string configProp = "COMPILE_PDB_NAME_"; + configProp += configUpper; + const char* config_name = this->Target->GetProperty(configProp); + if(config_name && *config_name) + { + return prefix + config_name + ".pdb"; + } + + const char* name = this->Target->GetProperty("COMPILE_PDB_NAME"); + if(name && *name) + { + return prefix + name + ".pdb"; + } + + return ""; +} + +//---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetCompilePDBPath(const std::string& config) const +{ + std::string dir = this->Target->GetCompilePDBDirectory(config); + std::string name = this->GetCompilePDBName(config); + if(dir.empty() && !name.empty()) + { + dir = this->Target->GetPDBDirectory(config); + } + if(!dir.empty()) + { + dir += "/"; + } + return dir + name; +} + +//---------------------------------------------------------------------------- bool cmGeneratorTarget::HasSOName(const std::string& config) const { // soname is supported only for shared libraries and modules, diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 9254265..9cdfd00 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -163,6 +163,12 @@ public: /** Whether this library has soname enabled and platform supports it. */ bool HasSOName(const std::string& config) const; + /** Get the name of the compiler pdb file for the target. */ + std::string GetCompilePDBName(const std::string& config="") const; + + /** Get the path for the MSVC /Fd option for this target. */ + std::string GetCompilePDBPath(const std::string& config="") const; + /** * Flags for a given source file as used in this target. Typically assigned * via SET_TARGET_PROPERTIES when the property is a list of source files. diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 92ed917..724f575 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -881,7 +881,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, if(target.GetType() <= cmTarget::OBJECT_LIBRARY) { // Specify the compiler program database file if configured. - std::string pdb = target.GetCompilePDBPath(configName); + std::string pdb = gt->GetCompilePDBPath(configName); if(!pdb.empty()) { fout << "\t\t\t\tProgramDataBaseFileName=\"" diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index ac8cd29..f9125fc 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -553,7 +553,7 @@ cmMakefileTargetGenerator if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY) { targetFullPathCompilePDB = - this->Target->GetCompilePDBPath(this->ConfigName); + this->GeneratorTarget->GetCompilePDBPath(this->ConfigName); if(targetFullPathCompilePDB.empty()) { targetFullPathCompilePDB = this->Target->GetSupportDirectory() + "/"; diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index cf80424..e61ba6f 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -277,7 +277,8 @@ bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(cmNinjaVars& vars) const } if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY) { - compilePdbPath = this->Target->GetCompilePDBPath(this->GetConfigName()); + compilePdbPath = + this->GeneratorTarget->GetCompilePDBPath(this->GetConfigName()); if(compilePdbPath.empty()) { compilePdbPath = this->Target->GetSupportDirectory() + "/"; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e1b3e94..188ad0f 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3492,49 +3492,6 @@ std::string cmTarget::GetPDBName(const std::string& config) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetCompilePDBName(const std::string& config) const -{ - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); - - // Check for a per-configuration output directory target property. - std::string configUpper = cmSystemTools::UpperCase(config); - std::string configProp = "COMPILE_PDB_NAME_"; - configProp += configUpper; - const char* config_name = this->GetProperty(configProp); - if(config_name && *config_name) - { - return prefix + config_name + ".pdb"; - } - - const char* name = this->GetProperty("COMPILE_PDB_NAME"); - if(name && *name) - { - return prefix + name + ".pdb"; - } - - return ""; -} - -//---------------------------------------------------------------------------- -std::string cmTarget::GetCompilePDBPath(const std::string& config) const -{ - std::string dir = this->GetCompilePDBDirectory(config); - std::string name = this->GetCompilePDBName(config); - if(dir.empty() && !name.empty()) - { - dir = this->GetPDBDirectory(config); - } - if(!dir.empty()) - { - dir += "/"; - } - return dir + name; -} - -//---------------------------------------------------------------------------- bool cmTarget::HasMacOSXRpathInstallNameDir(const std::string& config) const { bool install_name_is_rpath = false; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e89a212..162033c 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -380,12 +380,6 @@ public: /** Get the name of the pdb file for the target. */ std::string GetPDBName(const std::string& config) const; - /** Get the name of the compiler pdb file for the target. */ - std::string GetCompilePDBName(const std::string& config="") const; - - /** Get the path for the MSVC /Fd option for this target. */ - std::string GetCompilePDBPath(const std::string& config="") const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 83775a5..16edf3c 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2026,7 +2026,8 @@ void cmVisualStudio10TargetGenerator::WriteClOptions( } // Specify the compiler program database file if configured. - std::string pdb = this->Target->GetCompilePDBPath(configName.c_str()); + std::string pdb = + this->GeneratorTarget->GetCompilePDBPath(configName.c_str()); if(!pdb.empty()) { this->ConvertToWindowsSlash(pdb); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2714f048b387b5387c248aa186b7892f4473055f commit 2714f048b387b5387c248aa186b7892f4473055f Author: Stephen Kelly AuthorDate: Mon Nov 18 17:01:00 2013 +0100 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:03:44 2015 +0200 cmGeneratorTarget: Move HasSOName from cmTarget. diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 8a2cf4b..e3652c5 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -889,7 +889,7 @@ cmExportFileGenerator { std::string prop; std::string value; - if(target->Target->HasSOName(config)) + if(target->HasSOName(config)) { if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 31c2df1..2b3ebee 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -657,6 +657,18 @@ void cmGeneratorTarget::GetSourceFiles(std::vector &files, } //---------------------------------------------------------------------------- +bool cmGeneratorTarget::HasSOName(const std::string& config) const +{ + // soname is supported only for shared libraries and modules, + // and then only when the platform supports an soname flag. + return ((this->GetType() == cmTarget::SHARED_LIBRARY || + this->GetType() == cmTarget::MODULE_LIBRARY) && + !this->GetPropertyAsBool("NO_SONAME") && + this->Makefile->GetSONameFlag( + this->Target->GetLinkerLanguage(config))); +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetSOName(const std::string& config) const { if(this->Target->IsImported()) @@ -1407,7 +1419,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, // Check for library version properties. const char* version = this->GetProperty("VERSION"); const char* soversion = this->GetProperty("SOVERSION"); - if(!this->Target->HasSOName(config) || + if(!this->HasSOName(config) || this->Target->IsFrameworkOnApple()) { // Versioning is supported only for shared libraries and modules, diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 7fb7c32..9254265 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -160,6 +160,9 @@ public: std::vector const* GetSourceDepends(cmSourceFile const* sf) const; + /** Whether this library has soname enabled and platform supports it. */ + bool HasSOName(const std::string& config) const; + /** * Flags for a given source file as used in this target. Typically assigned * via SET_TARGET_PROPERTIES when the property is a list of source files. diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index b44848c..d7ae36d 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1944,7 +1944,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, const char* version = target.GetProperty("VERSION"); const char* soversion = target.GetProperty("SOVERSION"); - if(!target.HasSOName(configName) || target.IsFrameworkOnApple()) + if(!gtgt->HasSOName(configName) || target.IsFrameworkOnApple()) { version = 0; soversion = 0; diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 26273ee..7d0dc49 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -653,7 +653,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules vars.Target = target.c_str(); vars.LinkLibraries = linkLibs.c_str(); vars.ObjectsQuoted = buildObjs.c_str(); - if (this->Target->HasSOName(this->ConfigName)) + if (this->GeneratorTarget->HasSOName(this->ConfigName)) { vars.SONameFlag = this->Makefile->GetSONameFlag(linkLanguage); vars.TargetSOName= targetNameSO.c_str(); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 5d86091..2586b31 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -531,7 +531,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() vars["LANGUAGE_COMPILE_FLAGS"] = t; } - if (target.HasSOName(cfgName)) + if (this->GetGeneratorTarget()->HasSOName(cfgName)) { vars["SONAME_FLAG"] = mf->GetSONameFlag(this->TargetLinkLanguage); vars["SONAME"] = this->TargetNameSO; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 60fe7e4..e1b3e94 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3535,17 +3535,6 @@ std::string cmTarget::GetCompilePDBPath(const std::string& config) const } //---------------------------------------------------------------------------- -bool cmTarget::HasSOName(const std::string& config) const -{ - // soname is supported only for shared libraries and modules, - // and then only when the platform supports an soname flag. - return ((this->GetType() == cmTarget::SHARED_LIBRARY || - this->GetType() == cmTarget::MODULE_LIBRARY) && - !this->GetPropertyAsBool("NO_SONAME") && - this->Makefile->GetSONameFlag(this->GetLinkerLanguage(config))); -} - -//---------------------------------------------------------------------------- bool cmTarget::HasMacOSXRpathInstallNameDir(const std::string& config) const { bool install_name_is_rpath = false; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 15dfb4a..e89a212 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -386,9 +386,6 @@ public: /** Get the path for the MSVC /Fd option for this target. */ std::string GetCompilePDBPath(const std::string& config="") const; - /** Whether this library has soname enabled and platform supports it. */ - bool HasSOName(const std::string& config) const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=544d3aa3038b565de500ef2f53f54b482c261296 commit 544d3aa3038b565de500ef2f53f54b482c261296 Author: Stephen Kelly AuthorDate: Tue Oct 9 18:48:18 2012 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:03:44 2015 +0200 cmGeneratorTarget: Move GetLibraryNames from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 6a693f1..31c2df1 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -693,8 +693,8 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const std::string realName; std::string impName; std::string pdbName; - this->Target->GetLibraryNames(name, soName, realName, - impName, pdbName, config); + this->GetLibraryNames(name, soName, realName, + impName, pdbName, config); return soName; } } @@ -1254,7 +1254,7 @@ void cmGeneratorTarget::GenerateTargetManifest( this->GetType() == cmTarget::SHARED_LIBRARY || this->GetType() == cmTarget::MODULE_LIBRARY) { - this->Target->GetLibraryNames(name, soName, realName, impName, pdbName, + this->GetLibraryNames(name, soName, realName, impName, pdbName, config); } else @@ -1378,13 +1378,100 @@ cmGeneratorTarget::NormalGetRealName(const std::string& config) const std::string realName; std::string impName; std::string pdbName; - this->Target->GetLibraryNames(name, soName, realName, - impName, pdbName, config); + this->GetLibraryNames(name, soName, realName, + impName, pdbName, config); return realName; } } //---------------------------------------------------------------------------- +void cmGeneratorTarget::GetLibraryNames(std::string& name, + std::string& soName, + std::string& realName, + std::string& impName, + std::string& pdbName, + const std::string& config) const +{ + // This should not be called for imported targets. + // TODO: Split cmTarget into a class hierarchy to get compile-time + // enforcement of the limited imported target API. + if(this->Target->IsImported()) + { + std::string msg = "GetLibraryNames called on imported target: "; + msg += this->GetName(); + this->LocalGenerator->IssueMessage(cmake::INTERNAL_ERROR, + msg); + return; + } + + // Check for library version properties. + const char* version = this->GetProperty("VERSION"); + const char* soversion = this->GetProperty("SOVERSION"); + if(!this->Target->HasSOName(config) || + this->Target->IsFrameworkOnApple()) + { + // Versioning is supported only for shared libraries and modules, + // and then only when the platform supports an soname flag. + version = 0; + soversion = 0; + } + if(version && !soversion) + { + // The soversion must be set if the library version is set. Use + // the library version as the soversion. + soversion = version; + } + if(!version && soversion) + { + // Use the soversion as the library version. + version = soversion; + } + + // Get the components of the library name. + std::string prefix; + std::string base; + std::string suffix; + this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + + // The library name. + name = prefix+base+suffix; + + if(this->Target->IsFrameworkOnApple()) + { + realName = prefix; + realName += "Versions/"; + realName += this->Target->GetFrameworkVersion(); + realName += "/"; + realName += base; + soName = realName; + } + else + { + // The library's soname. + this->Target->ComputeVersionedName(soName, prefix, base, suffix, + name, soversion); + + // The library's real name on disk. + this->Target->ComputeVersionedName(realName, prefix, base, suffix, + name, version); + } + + // The import library name. + if(this->GetType() == cmTarget::SHARED_LIBRARY || + this->GetType() == cmTarget::MODULE_LIBRARY) + { + impName = this->Target->GetFullNameInternal(config, true); + } + else + { + impName = ""; + } + + // The program database file name. + pdbName = this->Target->GetPDBName(config); +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetExecutableNames(std::string& name, std::string& realName, std::string& impName, @@ -1446,7 +1533,6 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, pdbName = this->Target->GetPDBName(config); } - bool cmStrictTargetComparison::operator()(cmTarget const* t1, cmTarget const* t2) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 49aa65b..7fb7c32 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -191,6 +191,13 @@ public: std::string& impName, std::string& pdbName, const std::string& config) const; + /** Get the names of the library needed to generate a build rule + that takes into account shared library version numbers. This + should be called only on a library target. */ + void GetLibraryNames(std::string& name, std::string& soName, + std::string& realName, std::string& impName, + std::string& pdbName, const std::string& config) const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 8335063..62a3a9c 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -185,7 +185,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - this->Target->Target->GetLibraryNames(targetName, targetNameSO, + this->Target->GetLibraryNames(targetName, targetNameSO, targetNameReal, targetNameImport, targetNamePDB, config); @@ -411,7 +411,7 @@ cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target, std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - target->GetLibraryNames(targetName, targetNameSO, targetNameReal, + gtgt->GetLibraryNames(targetName, targetNameSO, targetNameReal, targetNameImport, targetNamePDB, config); if(nameType == NameImplib) { diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 9717ed2..92ed917 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1144,7 +1144,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, std::string targetNameFull; std::string targetNameImport; std::string targetNamePDB; - target.GetLibraryNames(targetName, targetNameSO, targetNameFull, + gt->GetLibraryNames(targetName, targetNameSO, targetNameFull, targetNameImport, targetNamePDB, configName); // Compute the link library and directory information. diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 696dcc4..26273ee 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -28,7 +28,7 @@ cmMakefileLibraryTargetGenerator this->CustomCommandDriver = OnDepends; if (this->Target->GetType() != cmTarget::INTERFACE_LIBRARY) { - this->Target->GetLibraryNames( + this->GeneratorTarget->GetLibraryNames( this->TargetNameOut, this->TargetNameSO, this->TargetNameReal, this->TargetNameImport, this->TargetNamePDB, this->ConfigName); } @@ -266,7 +266,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - this->Target->GetLibraryNames( + this->GeneratorTarget->GetLibraryNames( targetName, targetNameSO, targetNameReal, targetNameImport, targetNamePDB, this->ConfigName); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 737510f..5d86091 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -49,7 +49,7 @@ cmNinjaNormalTargetGenerator(cmGeneratorTarget* target) this->TargetNamePDB, GetLocalGenerator()->GetConfigName()); else - target->Target->GetLibraryNames(this->TargetNameOut, + this->GetGeneratorTarget()->GetLibraryNames(this->TargetNameOut, this->TargetNameSO, this->TargetNameReal, this->TargetNameImport, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 22b76e9..60fe7e4 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3862,95 +3862,6 @@ void cmTarget::GetFullNameInternal(const std::string& config, } //---------------------------------------------------------------------------- -void cmTarget::GetLibraryNames(std::string& name, - std::string& soName, - std::string& realName, - std::string& impName, - std::string& pdbName, - const std::string& config) const -{ - // This should not be called for imported targets. - // TODO: Split cmTarget into a class hierarchy to get compile-time - // enforcement of the limited imported target API. - if(this->IsImported()) - { - std::string msg = "GetLibraryNames called on imported target: "; - msg += this->GetName(); - this->Makefile->IssueMessage(cmake::INTERNAL_ERROR, - msg); - return; - } - - assert(this->GetType() != INTERFACE_LIBRARY); - - // Check for library version properties. - const char* version = this->GetProperty("VERSION"); - const char* soversion = this->GetProperty("SOVERSION"); - if(!this->HasSOName(config) || - this->Makefile->IsOn("CMAKE_PLATFORM_NO_VERSIONED_SONAME") || - this->IsFrameworkOnApple()) - { - // Versioning is supported only for shared libraries and modules, - // and then only when the platform supports an soname flag. - version = 0; - soversion = 0; - } - if(version && !soversion) - { - // The soversion must be set if the library version is set. Use - // the library version as the soversion. - soversion = version; - } - if(!version && soversion) - { - // Use the soversion as the library version. - version = soversion; - } - - // Get the components of the library name. - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); - - // The library name. - name = prefix+base+suffix; - - if(this->IsFrameworkOnApple()) - { - realName = prefix; - realName += "Versions/"; - realName += this->GetFrameworkVersion(); - realName += "/"; - realName += base; - soName = realName; - } - else - { - // The library's soname. - this->ComputeVersionedName(soName, prefix, base, suffix, - name, soversion); - // The library's real name on disk. - this->ComputeVersionedName(realName, prefix, base, suffix, - name, version); - } - - // The import library name. - if(this->GetType() == cmTarget::SHARED_LIBRARY || - this->GetType() == cmTarget::MODULE_LIBRARY) - { - impName = this->GetFullNameInternal(config, true); - } - else - { - impName = ""; - } - - // The program database file name. - pdbName = this->GetPDBName(config); -} - -//---------------------------------------------------------------------------- void cmTarget::ComputeVersionedName(std::string& vName, std::string const& prefix, std::string const& base, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 714647c..15dfb4a 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -399,13 +399,6 @@ public: no soname at all. */ bool IsImportedSharedLibWithoutSOName(const std::string& config) const; - /** Get the names of the library needed to generate a build rule - that takes into account shared library version numbers. This - should be called only on a library target. */ - void GetLibraryNames(std::string& name, std::string& soName, - std::string& realName, std::string& impName, - std::string& pdbName, const std::string& config) const; - /** Does this target have a GNU implib to convert to MS format? */ bool HasImplibGNUtoMS() const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 1bb21ff..83775a5 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2477,7 +2477,8 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) } else { - this->Target->GetLibraryNames(targetName, targetNameSO, targetNameFull, + this->GeneratorTarget->GetLibraryNames(targetName, targetNameSO, + targetNameFull, targetNameImport, targetNamePDB, config.c_str()); } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5dc07198725d60d9cee3abf78f23ca9177a2fdd1 commit 5dc07198725d60d9cee3abf78f23ca9177a2fdd1 Author: Stephen Kelly AuthorDate: Tue Oct 9 18:40:45 2012 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:03:44 2015 +0200 cmGeneratorTarget: Move GetExecutableNames from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index f9f23a6..6a693f1 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1248,8 +1248,7 @@ void cmGeneratorTarget::GenerateTargetManifest( std::string pdbName; if(this->GetType() == cmTarget::EXECUTABLE) { - this->Target->GetExecutableNames(name, realName, impName, pdbName, - config); + this->GetExecutableNames(name, realName, impName, pdbName, config); } else if(this->GetType() == cmTarget::STATIC_LIBRARY || this->GetType() == cmTarget::SHARED_LIBRARY || @@ -1368,7 +1367,7 @@ cmGeneratorTarget::NormalGetRealName(const std::string& config) const std::string realName; std::string impName; std::string pdbName; - this->Target->GetExecutableNames(name, realName, impName, pdbName, config); + this->GetExecutableNames(name, realName, impName, pdbName, config); return realName; } else @@ -1385,6 +1384,69 @@ cmGeneratorTarget::NormalGetRealName(const std::string& config) const } } +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GetExecutableNames(std::string& name, + std::string& realName, + std::string& impName, + std::string& pdbName, + const std::string& config) const +{ + // This should not be called for imported targets. + // TODO: Split cmTarget into a class hierarchy to get compile-time + // enforcement of the limited imported target API. + if(this->Target->IsImported()) + { + std::string msg = + "GetExecutableNames called on imported target: "; + msg += this->GetName(); + this->LocalGenerator->IssueMessage(cmake::INTERNAL_ERROR, msg); + } + + // This versioning is supported only for executables and then only + // when the platform supports symbolic links. +#if defined(_WIN32) && !defined(__CYGWIN__) + const char* version = 0; +#else + // Check for executable version properties. + const char* version = this->GetProperty("VERSION"); + if(this->GetType() != cmTarget::EXECUTABLE || this->Makefile->IsOn("XCODE")) + { + version = 0; + } +#endif + + // Get the components of the executable name. + std::string prefix; + std::string base; + std::string suffix; + this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + + // The executable name. + name = prefix+base+suffix; + + // The executable's real name on disk. +#if defined(__CYGWIN__) + realName = prefix+base; +#else + realName = name; +#endif + if(version) + { + realName += "-"; + realName += version; + } +#if defined(__CYGWIN__) + realName += suffix; +#endif + + // The import library name. + impName = this->Target->GetFullNameInternal(config, true); + + // The program database file name. + pdbName = this->Target->GetPDBName(config); +} + + bool cmStrictTargetComparison::operator()(cmTarget const* t1, cmTarget const* t2) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 1303ee4..49aa65b 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -184,6 +184,12 @@ public: void GetAutoUicOptions(std::vector &result, const std::string& config) const; + /** Get the names of the executable needed to generate a build rule + that takes into account executable version numbers. This should + be called only on an executable target. */ + void GetExecutableNames(std::string& name, std::string& realName, + std::string& impName, std::string& pdbName, + const std::string& config) const; struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index c64f9a3..8335063 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -125,7 +125,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - this->Target->Target->GetExecutableNames(targetName, targetNameReal, + this->Target->GetExecutableNames(targetName, targetNameReal, targetNameImport, targetNamePDB, config); if(this->ImportLibrary) @@ -372,13 +372,16 @@ cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target, { std::string fname; // Compute the name of the library. + cmGeneratorTarget *gtgt = target->GetMakefile()->GetLocalGenerator() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); if(target->GetType() == cmTarget::EXECUTABLE) { std::string targetName; std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - target->GetExecutableNames(targetName, targetNameReal, + gtgt->GetExecutableNames(targetName, targetNameReal, targetNameImport, targetNamePDB, config); if(nameType == NameImplib) diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 5bd82ff..9717ed2 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1243,7 +1243,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, std::string targetNameFull; std::string targetNameImport; std::string targetNamePDB; - target.GetExecutableNames(targetName, targetNameFull, + gt->GetExecutableNames(targetName, targetNameFull, targetNameImport, targetNamePDB, configName); // Compute the link library and directory information. diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 416063f..31a78ad 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -25,7 +25,7 @@ cmMakefileExecutableTargetGenerator cmMakefileTargetGenerator(target) { this->CustomCommandDriver = OnDepends; - this->Target->GetExecutableNames( + this->GeneratorTarget->GetExecutableNames( this->TargetNameOut, this->TargetNameReal, this->TargetNameImport, this->TargetNamePDB, this->ConfigName); @@ -94,7 +94,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - this->Target->GetExecutableNames + this->GeneratorTarget->GetExecutableNames (targetName, targetNameReal, targetNameImport, targetNamePDB, this->ConfigName); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index c9fa7c0..737510f 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -43,7 +43,7 @@ cmNinjaNormalTargetGenerator(cmGeneratorTarget* target) this->TargetLinkLanguage = target->Target ->GetLinkerLanguage(this->GetConfigName()); if (target->GetType() == cmTarget::EXECUTABLE) - target->Target->GetExecutableNames(this->TargetNameOut, + this->GetGeneratorTarget()->GetExecutableNames(this->TargetNameOut, this->TargetNameReal, this->TargetNameImport, this->TargetNamePDB, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index ded5363..22b76e9 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3968,68 +3968,6 @@ void cmTarget::ComputeVersionedName(std::string& vName, } //---------------------------------------------------------------------------- -void cmTarget::GetExecutableNames(std::string& name, - std::string& realName, - std::string& impName, - std::string& pdbName, - const std::string& config) const -{ - // This should not be called for imported targets. - // TODO: Split cmTarget into a class hierarchy to get compile-time - // enforcement of the limited imported target API. - if(this->IsImported()) - { - std::string msg = - "GetExecutableNames called on imported target: "; - msg += this->GetName(); - this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg); - } - - // This versioning is supported only for executables and then only - // when the platform supports symbolic links. -#if defined(_WIN32) && !defined(__CYGWIN__) - const char* version = 0; -#else - // Check for executable version properties. - const char* version = this->GetProperty("VERSION"); - if(this->GetType() != cmTarget::EXECUTABLE || this->Makefile->IsOn("XCODE")) - { - version = 0; - } -#endif - - // Get the components of the executable name. - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); - - // The executable name. - name = prefix+base+suffix; - - // The executable's real name on disk. -#if defined(__CYGWIN__) - realName = prefix+base; -#else - realName = name; -#endif - if(version) - { - realName += "-"; - realName += version; - } -#if defined(__CYGWIN__) - realName += suffix; -#endif - - // The import library name. - impName = this->GetFullNameInternal(config, true); - - // The program database file name. - pdbName = this->GetPDBName(config); -} - -//---------------------------------------------------------------------------- bool cmTarget::HasImplibGNUtoMS() const { return this->HasImportLibrary() && this->GetPropertyAsBool("GNUtoMS"); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 925e7c6..714647c 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -406,14 +406,6 @@ public: std::string& realName, std::string& impName, std::string& pdbName, const std::string& config) const; - /** Get the names of the executable needed to generate a build rule - that takes into account executable version numbers. This should - be called only on an executable target. */ - void GetExecutableNames(std::string& name, std::string& realName, - std::string& impName, - std::string& pdbName, - const std::string& config) const; - /** Does this target have a GNU implib to convert to MS format? */ bool HasImplibGNUtoMS() const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index f3f291a..1bb21ff 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2471,7 +2471,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) std::string targetNamePDB; if(this->Target->GetType() == cmTarget::EXECUTABLE) { - this->Target->GetExecutableNames(targetName, targetNameFull, + this->GeneratorTarget->GetExecutableNames(targetName, targetNameFull, targetNameImport, targetNamePDB, config.c_str()); } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=723f56e7c2848d587aae854410c86d3030508b9d commit 723f56e7c2848d587aae854410c86d3030508b9d Author: Stephen Kelly AuthorDate: Mon Mar 10 20:34:59 2014 +0100 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:03:44 2015 +0200 cmGeneratorTarget: Move GetLinkImplementationClosure diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 521a5b7..f9f23a6 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -618,7 +618,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const std::string& dir, } std::vector const& deps = - this->Target->GetLinkImplementationClosure(config); + this->GetLinkImplementationClosure(config); for(std::vector::const_iterator li = deps.begin(), le = deps.end(); li != le; ++li) { @@ -775,6 +775,54 @@ void cmGeneratorTarget::GetAutoUicOptions(std::vector &result, } //---------------------------------------------------------------------------- +void processILibs(const std::string& config, + cmTarget const* headTarget, + cmLinkItem const& item, + std::vector& tgts, + std::set& emitted) +{ + if (item.Target && emitted.insert(item.Target).second) + { + tgts.push_back(item.Target); + if(cmTarget::LinkInterfaceLibraries const* iface = + item.Target->GetLinkInterfaceLibraries(config, headTarget, true)) + { + for(std::vector::const_iterator + it = iface->Libraries.begin(); + it != iface->Libraries.end(); ++it) + { + processILibs(config, headTarget, *it, tgts, emitted); + } + } + } +} + +//---------------------------------------------------------------------------- +const std::vector& +cmGeneratorTarget::GetLinkImplementationClosure( + const std::string& config) const +{ + LinkImplClosure& tgts = + this->LinkImplClosureMap[config]; + if(!tgts.Done) + { + tgts.Done = true; + std::set emitted; + + cmTarget::LinkImplementationLibraries const* impl + = this->Target->GetLinkImplementationLibraries(config); + + for(std::vector::const_iterator + it = impl->Libraries.begin(); + it != impl->Libraries.end(); ++it) + { + processILibs(config, this->Target, *it, tgts , emitted); + } + } + return tgts; +} + +//---------------------------------------------------------------------------- class cmTargetTraceDependencies { public: @@ -1455,7 +1503,7 @@ cmGeneratorTarget::GetCompatibleInterfaces(std::string const& config) const compat.PropsBool.insert("POSITION_INDEPENDENT_CODE"); compat.PropsString.insert("AUTOUIC_OPTIONS"); std::vector const& deps = - this->Target->GetLinkImplementationClosure(config); + this->GetLinkImplementationClosure(config); for(std::vector::const_iterator li = deps.begin(); li != deps.end(); ++li) { @@ -1954,7 +2002,7 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt, || (!impliedByUse && !explicitlySet)); std::vector const& deps = - tgt->Target->GetLinkImplementationClosure(config); + tgt->GetLinkImplementationClosure(config); if(deps.empty()) { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 8e68d39..1303ee4 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -245,6 +245,18 @@ private: cmGeneratorTarget(cmGeneratorTarget const&); void operator=(cmGeneratorTarget const&); + + struct LinkImplClosure: public std::vector + { + LinkImplClosure(): Done(false) {} + bool Done; + }; + mutable std::map LinkImplClosureMap; + +public: + std::vector const& + GetLinkImplementationClosure(const std::string& config) const; + }; struct cmStrictTargetComparison { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 968bd9d..ded5363 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -163,13 +163,6 @@ public: typedef std::map LinkClosureMapType; LinkClosureMapType LinkClosureMap; - struct LinkImplClosure: public std::vector - { - LinkImplClosure(): Done(false) {} - bool Done; - }; - std::map LinkImplClosureMap; - typedef std::map > SourceFilesMapType; SourceFilesMapType SourceFilesMap; @@ -5175,53 +5168,6 @@ cmTarget::GetImportLinkInterface(const std::string& config, } //---------------------------------------------------------------------------- -void processILibs(const std::string& config, - cmTarget const* headTarget, - cmLinkItem const& item, - std::vector& tgts, - std::set& emitted) -{ - if (item.Target && emitted.insert(item.Target).second) - { - tgts.push_back(item.Target); - if(cmTarget::LinkInterfaceLibraries const* iface = - item.Target->GetLinkInterfaceLibraries(config, headTarget, true)) - { - for(std::vector::const_iterator - it = iface->Libraries.begin(); - it != iface->Libraries.end(); ++it) - { - processILibs(config, headTarget, *it, tgts, emitted); - } - } - } -} - -//---------------------------------------------------------------------------- -std::vector const& -cmTarget::GetLinkImplementationClosure(const std::string& config) const -{ - cmTargetInternals::LinkImplClosure& tgts = - this->Internal->LinkImplClosureMap[config]; - if(!tgts.Done) - { - tgts.Done = true; - std::set emitted; - - cmTarget::LinkImplementationLibraries const* impl - = this->GetLinkImplementationLibraries(config); - - for(std::vector::const_iterator - it = impl->Libraries.begin(); - it != impl->Libraries.end(); ++it) - { - processILibs(config, this, *it, tgts , emitted); - } - } - return tgts; -} - -//---------------------------------------------------------------------------- void cmTargetInternals::ComputeLinkInterfaceLibraries( cmTarget const* thisTarget, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 85d9964..925e7c6 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -293,9 +293,6 @@ public: cmTarget const* headTarget, bool usage_requirements_only) const; - std::vector const& - GetLinkImplementationClosure(const std::string& config) const; - /** The link implementation specifies the direct library dependencies needed by the object files of the target. */ struct LinkImplementationLibraries http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=82b706b70fbaa9b7469e03b3ef63ab8b66a49b5b commit 82b706b70fbaa9b7469e03b3ef63ab8b66a49b5b Author: Stephen Kelly AuthorDate: Tue Jul 28 21:24:41 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:03:43 2015 +0200 cmGeneratorTarget: Move ReportPropertyOrigin from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index fe73fee..521a5b7 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1937,24 +1937,24 @@ std::pair consistentProperty(const char *lhs, //---------------------------------------------------------------------------- template -PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, +PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt, const std::string &p, const std::string& config, const char *defaultValue, CompatibleType t, PropertyType *) { - PropertyType propContent = getTypedProperty(tgt, p); - const bool explicitlySet = tgt->GetProperties() + PropertyType propContent = getTypedProperty(tgt->Target, p); + const bool explicitlySet = tgt->Target->GetProperties() .find(p) - != tgt->GetProperties().end(); + != tgt->Target->GetProperties().end(); const bool impliedByUse = - tgt->IsNullImpliedByLinkLibraries(p); + tgt->Target->IsNullImpliedByLinkLibraries(p); assert((impliedByUse ^ explicitlySet) || (!impliedByUse && !explicitlySet)); std::vector const& deps = - tgt->GetLinkImplementationClosure(config); + tgt->Target->GetLinkImplementationClosure(config); if(deps.empty()) { @@ -2125,7 +2125,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, bool cmGeneratorTarget::GetLinkInterfaceDependentBoolProperty( const std::string &p, const std::string& config) const { - return checkInterfacePropertyCompatibility(this->Target, p, config, + return checkInterfacePropertyCompatibility(this, p, config, "FALSE", BoolType, 0); } @@ -2135,7 +2135,7 @@ const char* cmGeneratorTarget::GetLinkInterfaceDependentStringProperty( const std::string &p, const std::string& config) const { - return checkInterfacePropertyCompatibility(this->Target, + return checkInterfacePropertyCompatibility(this, p, config, "empty", @@ -2147,7 +2147,7 @@ const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMinProperty( const std::string &p, const std::string& config) const { - return checkInterfacePropertyCompatibility(this->Target, + return checkInterfacePropertyCompatibility(this, p, config, "empty", @@ -2159,7 +2159,7 @@ const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMaxProperty( const std::string &p, const std::string& config) const { - return checkInterfacePropertyCompatibility(this->Target, + return checkInterfacePropertyCompatibility(this, p, config, "empty", @@ -2196,3 +2196,43 @@ cmGeneratorTarget::GetLinkInformation(const std::string& config) const } return i->second; } + +//---------------------------------------------------------------------------- +void +cmGeneratorTarget::ReportPropertyOrigin(const std::string &p, + const std::string &result, + const std::string &report, + const std::string &compatibilityType) const +{ + std::vector debugProperties; + const char *debugProp = this->Target->GetMakefile() + ->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); + if (debugProp) + { + cmSystemTools::ExpandListArgument(debugProp, debugProperties); + } + + bool debugOrigin = !this->DebugCompatiblePropertiesDone[p] + && std::find(debugProperties.begin(), + debugProperties.end(), + p) + != debugProperties.end(); + + if (this->Target->GetMakefile()->IsConfigured()) + { + this->DebugCompatiblePropertiesDone[p] = true; + } + if (!debugOrigin) + { + return; + } + + std::string areport = compatibilityType; + areport += std::string(" of property \"") + p + "\" for target \""; + areport += std::string(this->GetName()); + areport += "\" (result: \""; + areport += result; + areport += "\"):\n" + report; + + this->Makefile->GetCMakeInstance()->IssueMessage(cmake::LOG, areport); +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index d65b1ef..8e68d39 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -199,6 +199,11 @@ public: std::vector XamlSources; }; + void ReportPropertyOrigin(const std::string &p, + const std::string &result, + const std::string &report, + const std::string &compatibilityType) const; + private: friend class cmTargetTraceDependencies; struct SourceEntry { std::vector Depends; }; @@ -212,6 +217,8 @@ private: mutable bool SourceFileFlagsConstructed; mutable std::map SourceFlagsMap; + mutable std::map DebugCompatiblePropertiesDone; + struct CompatibleInterfacesBase { std::set PropsBool; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1fa62e7..968bd9d 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4537,46 +4537,6 @@ bool cmTarget::IsNullImpliedByLinkLibraries(const std::string &p) const //---------------------------------------------------------------------------- void -cmTarget::ReportPropertyOrigin(const std::string &p, - const std::string &result, - const std::string &report, - const std::string &compatibilityType) const -{ - std::vector debugProperties; - const char *debugProp = - this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); - if (debugProp) - { - cmSystemTools::ExpandListArgument(debugProp, debugProperties); - } - - bool debugOrigin = !this->DebugCompatiblePropertiesDone[p] - && std::find(debugProperties.begin(), - debugProperties.end(), - p) - != debugProperties.end(); - - if (this->Makefile->IsConfigured()) - { - this->DebugCompatiblePropertiesDone[p] = true; - } - if (!debugOrigin) - { - return; - } - - std::string areport = compatibilityType; - areport += std::string(" of property \"") + p + "\" for target \""; - areport += std::string(this->GetName()); - areport += "\" (result: \""; - areport += result; - areport += "\"):\n" + report; - - this->Makefile->GetCMakeInstance()->IssueMessage(cmake::LOG, areport); -} - -//---------------------------------------------------------------------------- -void cmTarget::GetObjectLibrariesCMP0026(std::vector& objlibs) const { // At configure-time, this method can be called as part of getting the diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 795753e..85d9964 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -565,11 +565,6 @@ public: bool LinkLanguagePropagatesToDependents() const { return this->TargetTypeValue == STATIC_LIBRARY; } - void ReportPropertyOrigin(const std::string &p, - const std::string &result, - const std::string &report, - const std::string &compatibilityType) const; - std::map const& GetMaxLanguageStandards() const { @@ -676,7 +671,6 @@ private: std::set Utilities; mutable std::set LinkImplicitNullProperties; std::map UtilityBacktraces; - mutable std::map DebugCompatiblePropertiesDone; mutable std::map MaxLanguageStandards; cmPolicies::PolicyMap PolicyMap; std::string Name; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2706b1fde45c27145805032aa0daa432b5f882b3 commit 2706b1fde45c27145805032aa0daa432b5f882b3 Author: Stephen Kelly AuthorDate: Tue Jul 28 21:15:44 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:03:43 2015 +0200 cmGeneratorTarget: Make CompatibleType enum private again. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index a9245c0..fe73fee 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1524,18 +1524,26 @@ bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty( return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0; } +enum CompatibleType +{ + BoolType, + StringType, + NumberMinType, + NumberMaxType +}; + template PropertyType getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, - cmTarget::CompatibleType, + CompatibleType, PropertyType *); template<> bool getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, - cmTarget::CompatibleType, bool *) + CompatibleType, bool *) { return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); } @@ -1544,19 +1552,19 @@ template<> const char * getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, - cmTarget::CompatibleType t, + CompatibleType t, const char **) { switch(t) { - case cmTarget::BoolType: + case BoolType: assert(0 && "String compatibility check function called for boolean"); return 0; - case cmTarget::StringType: + case StringType: return tgt->GetLinkInterfaceDependentStringProperty(prop, config); - case cmTarget::NumberMinType: + case NumberMinType: return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config); - case cmTarget::NumberMaxType: + case NumberMaxType: return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config); } assert(0 && "Unreachable!"); @@ -1570,7 +1578,7 @@ void checkPropertyConsistency(cmGeneratorTarget const* depender, const std::string& propName, std::set &emitted, const std::string& config, - cmTarget::CompatibleType t, + CompatibleType t, PropertyType *) { const char *prop = dependee->GetProperty(propName); @@ -1683,7 +1691,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( checkPropertyConsistency(this, li->Target, strBool, - emittedBools, config, cmTarget::BoolType, 0); + emittedBools, config, BoolType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; @@ -1691,7 +1699,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( checkPropertyConsistency(this, li->Target, strString, emittedStrings, config, - cmTarget::StringType, 0); + StringType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; @@ -1699,7 +1707,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( checkPropertyConsistency(this, li->Target, strNumMin, emittedMinNumbers, config, - cmTarget::NumberMinType, 0); + NumberMinType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; @@ -1707,7 +1715,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( checkPropertyConsistency(this, li->Target, strNumMax, emittedMaxNumbers, config, - cmTarget::NumberMaxType, 0); + NumberMaxType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; @@ -1760,17 +1768,17 @@ void cmGeneratorTarget::CheckPropertyCompatibility( } //---------------------------------------------------------------------------- -std::string compatibilityType(cmTarget::CompatibleType t) +std::string compatibilityType(CompatibleType t) { switch(t) { - case cmTarget::BoolType: + case BoolType: return "Boolean compatibility"; - case cmTarget::StringType: + case StringType: return "String compatibility"; - case cmTarget::NumberMaxType: + case NumberMaxType: return "Numeric maximum compatibility"; - case cmTarget::NumberMinType: + case NumberMinType: return "Numeric minimum compatibility"; } assert(0 && "Unreachable!"); @@ -1778,15 +1786,15 @@ std::string compatibilityType(cmTarget::CompatibleType t) } //---------------------------------------------------------------------------- -std::string compatibilityAgree(cmTarget::CompatibleType t, bool dominant) +std::string compatibilityAgree(CompatibleType t, bool dominant) { switch(t) { - case cmTarget::BoolType: - case cmTarget::StringType: + case BoolType: + case StringType: return dominant ? "(Disagree)\n" : "(Agree)\n"; - case cmTarget::NumberMaxType: - case cmTarget::NumberMinType: + case NumberMaxType: + case NumberMinType: return dominant ? "(Dominant)\n" : "(Ignored)\n"; } assert(0 && "Unreachable!"); @@ -1842,12 +1850,12 @@ const char* impliedValue(const char*) template std::pair consistentProperty(PropertyType lhs, PropertyType rhs, - cmTarget::CompatibleType t); + CompatibleType t); //---------------------------------------------------------------------------- template<> std::pair consistentProperty(bool lhs, bool rhs, - cmTarget::CompatibleType) + CompatibleType) { return std::make_pair(lhs == rhs, lhs); } @@ -1863,7 +1871,7 @@ std::pair consistentStringProperty(const char *lhs, //---------------------------------------------------------------------------- std::pair consistentNumberProperty(const char *lhs, const char *rhs, - cmTarget::CompatibleType t) + CompatibleType t) { char *pEnd; @@ -1881,7 +1889,7 @@ std::pair consistentNumberProperty(const char *lhs, return std::pair(false, null_ptr); } - if (t == cmTarget::NumberMaxType) + if (t == NumberMaxType) { return std::make_pair(true, std::max(lnum, rnum) == lnum ? lhs : rhs); } @@ -1895,7 +1903,7 @@ std::pair consistentNumberProperty(const char *lhs, template<> std::pair consistentProperty(const char *lhs, const char *rhs, - cmTarget::CompatibleType t) + CompatibleType t) { if (!lhs && !rhs) { @@ -1914,13 +1922,13 @@ std::pair consistentProperty(const char *lhs, switch(t) { - case cmTarget::BoolType: + case BoolType: assert(0 && "consistentProperty for strings called with BoolType"); return std::pair(false, null_ptr); - case cmTarget::StringType: + case StringType: return consistentStringProperty(lhs, rhs); - case cmTarget::NumberMinType: - case cmTarget::NumberMaxType: + case NumberMinType: + case NumberMaxType: return consistentNumberProperty(lhs, rhs, t); } assert(0 && "Unreachable!"); @@ -1933,7 +1941,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, const std::string &p, const std::string& config, const char *defaultValue, - cmTarget::CompatibleType t, + CompatibleType t, PropertyType *) { PropertyType propContent = getTypedProperty(tgt, p); @@ -2119,7 +2127,7 @@ bool cmGeneratorTarget::GetLinkInterfaceDependentBoolProperty( { return checkInterfacePropertyCompatibility(this->Target, p, config, "FALSE", - cmTarget::BoolType, 0); + BoolType, 0); } //---------------------------------------------------------------------------- @@ -2131,7 +2139,7 @@ const char* cmGeneratorTarget::GetLinkInterfaceDependentStringProperty( p, config, "empty", - cmTarget::StringType, 0); + StringType, 0); } //---------------------------------------------------------------------------- @@ -2143,7 +2151,7 @@ const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMinProperty( p, config, "empty", - cmTarget::NumberMinType, 0); + NumberMinType, 0); } //---------------------------------------------------------------------------- @@ -2155,7 +2163,7 @@ const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMaxProperty( p, config, "empty", - cmTarget::NumberMaxType, 0); + NumberMaxType, 0); } //---------------------------------------------------------------------------- diff --git a/Source/cmTarget.h b/Source/cmTarget.h index b544b0b..795753e 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -581,14 +581,6 @@ public: return this->LinkLibrariesForVS6;} #endif - enum CompatibleType - { - BoolType, - StringType, - NumberMinType, - NumberMaxType - }; - private: bool HandleLocationPropertyPolicy(cmMakefile* context) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=16a97e777828f96d2b6eee2106817fbd13f6c261 commit 16a97e777828f96d2b6eee2106817fbd13f6c261 Author: Stephen Kelly AuthorDate: Tue Jul 28 21:13:45 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:03:43 2015 +0200 cmGeneratorTarget: Move LinkInterfaceDependent methods from cmTarget. diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index c1641cc..a20579b 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1142,7 +1142,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode context->Config)) { context->HadContextSensitiveCondition = true; - return target->GetLinkInterfaceDependentBoolProperty( + return gtgt->GetLinkInterfaceDependentBoolProperty( propertyName, context->Config) ? "1" : "0"; } @@ -1151,7 +1151,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { context->HadContextSensitiveCondition = true; const char *propContent = - target->GetLinkInterfaceDependentStringProperty( + gtgt->GetLinkInterfaceDependentStringProperty( propertyName, context->Config); return propContent ? propContent : ""; @@ -1161,7 +1161,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { context->HadContextSensitiveCondition = true; const char *propContent = - target->GetLinkInterfaceDependentNumberMinProperty( + gtgt->GetLinkInterfaceDependentNumberMinProperty( propertyName, context->Config); return propContent ? propContent : ""; @@ -1171,7 +1171,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { context->HadContextSensitiveCondition = true; const char *propContent = - target->GetLinkInterfaceDependentNumberMaxProperty( + gtgt->GetLinkInterfaceDependentNumberMaxProperty( propertyName, context->Config); return propContent ? propContent : ""; @@ -1188,7 +1188,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { context->HadContextSensitiveCondition = true; const char *propContent = - target->GetLinkInterfaceDependentNumberMinProperty( + gtgt->GetLinkInterfaceDependentNumberMinProperty( propertyName, context->Config); return propContent ? propContent : ""; @@ -1198,7 +1198,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { context->HadContextSensitiveCondition = true; const char *propContent = - target->GetLinkInterfaceDependentNumberMaxProperty( + gtgt->GetLinkInterfaceDependentNumberMaxProperty( propertyName, context->Config); return propContent ? propContent : ""; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index a7b0349..a9245c0 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -24,6 +24,7 @@ #include +#include #include "assert.h" //---------------------------------------------------------------------------- @@ -753,8 +754,7 @@ void cmGeneratorTarget::GetAutoUicOptions(std::vector &result, const std::string& config) const { const char *prop - = this->Target-> - GetLinkInterfaceDependentStringProperty("AUTOUIC_OPTIONS", + = this->GetLinkInterfaceDependentStringProperty("AUTOUIC_OPTIONS", config); if (!prop) { @@ -1537,7 +1537,7 @@ bool getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& config, cmTarget::CompatibleType, bool *) { - return tgt->Target->GetLinkInterfaceDependentBoolProperty(prop, config); + return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); } template<> @@ -1553,13 +1553,11 @@ const char * getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, assert(0 && "String compatibility check function called for boolean"); return 0; case cmTarget::StringType: - return tgt->Target->GetLinkInterfaceDependentStringProperty(prop, config); + return tgt->GetLinkInterfaceDependentStringProperty(prop, config); case cmTarget::NumberMinType: - return tgt->Target - ->GetLinkInterfaceDependentNumberMinProperty(prop, config); + return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config); case cmTarget::NumberMaxType: - return tgt->Target - ->GetLinkInterfaceDependentNumberMaxProperty(prop, config); + return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config); } assert(0 && "Unreachable!"); return 0; @@ -1762,6 +1760,405 @@ void cmGeneratorTarget::CheckPropertyCompatibility( } //---------------------------------------------------------------------------- +std::string compatibilityType(cmTarget::CompatibleType t) +{ + switch(t) + { + case cmTarget::BoolType: + return "Boolean compatibility"; + case cmTarget::StringType: + return "String compatibility"; + case cmTarget::NumberMaxType: + return "Numeric maximum compatibility"; + case cmTarget::NumberMinType: + return "Numeric minimum compatibility"; + } + assert(0 && "Unreachable!"); + return ""; +} + +//---------------------------------------------------------------------------- +std::string compatibilityAgree(cmTarget::CompatibleType t, bool dominant) +{ + switch(t) + { + case cmTarget::BoolType: + case cmTarget::StringType: + return dominant ? "(Disagree)\n" : "(Agree)\n"; + case cmTarget::NumberMaxType: + case cmTarget::NumberMinType: + return dominant ? "(Dominant)\n" : "(Ignored)\n"; + } + assert(0 && "Unreachable!"); + return ""; +} + +//---------------------------------------------------------------------------- +template +PropertyType getTypedProperty(cmTarget const* tgt, const std::string& prop); + +//---------------------------------------------------------------------------- +template<> +bool getTypedProperty(cmTarget const* tgt, const std::string& prop) +{ + return tgt->GetPropertyAsBool(prop); +} + +//---------------------------------------------------------------------------- +template<> +const char *getTypedProperty(cmTarget const* tgt, + const std::string& prop) +{ + return tgt->GetProperty(prop); +} + +template +std::string valueAsString(PropertyType); +template<> +std::string valueAsString(bool value) +{ + return value ? "TRUE" : "FALSE"; +} +template<> +std::string valueAsString(const char* value) +{ + return value ? value : "(unset)"; +} + +template +PropertyType impliedValue(PropertyType); +template<> +bool impliedValue(bool) +{ + return false; +} +template<> +const char* impliedValue(const char*) +{ + return ""; +} + +//---------------------------------------------------------------------------- +template +std::pair consistentProperty(PropertyType lhs, + PropertyType rhs, + cmTarget::CompatibleType t); + +//---------------------------------------------------------------------------- +template<> +std::pair consistentProperty(bool lhs, bool rhs, + cmTarget::CompatibleType) +{ + return std::make_pair(lhs == rhs, lhs); +} + +//---------------------------------------------------------------------------- +std::pair consistentStringProperty(const char *lhs, + const char *rhs) +{ + const bool b = strcmp(lhs, rhs) == 0; + return std::make_pair(b, b ? lhs : 0); +} + +//---------------------------------------------------------------------------- +std::pair consistentNumberProperty(const char *lhs, + const char *rhs, + cmTarget::CompatibleType t) +{ + char *pEnd; + + const char* const null_ptr = 0; + + long lnum = strtol(lhs, &pEnd, 0); + if (pEnd == lhs || *pEnd != '\0' || errno == ERANGE) + { + return std::pair(false, null_ptr); + } + + long rnum = strtol(rhs, &pEnd, 0); + if (pEnd == rhs || *pEnd != '\0' || errno == ERANGE) + { + return std::pair(false, null_ptr); + } + + if (t == cmTarget::NumberMaxType) + { + return std::make_pair(true, std::max(lnum, rnum) == lnum ? lhs : rhs); + } + else + { + return std::make_pair(true, std::min(lnum, rnum) == lnum ? lhs : rhs); + } +} + +//---------------------------------------------------------------------------- +template<> +std::pair consistentProperty(const char *lhs, + const char *rhs, + cmTarget::CompatibleType t) +{ + if (!lhs && !rhs) + { + return std::make_pair(true, lhs); + } + if (!lhs) + { + return std::make_pair(true, rhs); + } + if (!rhs) + { + return std::make_pair(true, lhs); + } + + const char* const null_ptr = 0; + + switch(t) + { + case cmTarget::BoolType: + assert(0 && "consistentProperty for strings called with BoolType"); + return std::pair(false, null_ptr); + case cmTarget::StringType: + return consistentStringProperty(lhs, rhs); + case cmTarget::NumberMinType: + case cmTarget::NumberMaxType: + return consistentNumberProperty(lhs, rhs, t); + } + assert(0 && "Unreachable!"); + return std::pair(false, null_ptr); +} + +//---------------------------------------------------------------------------- +template +PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, + const std::string &p, + const std::string& config, + const char *defaultValue, + cmTarget::CompatibleType t, + PropertyType *) +{ + PropertyType propContent = getTypedProperty(tgt, p); + const bool explicitlySet = tgt->GetProperties() + .find(p) + != tgt->GetProperties().end(); + const bool impliedByUse = + tgt->IsNullImpliedByLinkLibraries(p); + assert((impliedByUse ^ explicitlySet) + || (!impliedByUse && !explicitlySet)); + + std::vector const& deps = + tgt->GetLinkImplementationClosure(config); + + if(deps.empty()) + { + return propContent; + } + bool propInitialized = explicitlySet; + + std::string report = " * Target \""; + report += tgt->GetName(); + if (explicitlySet) + { + report += "\" has property content \""; + report += valueAsString(propContent); + report += "\"\n"; + } + else if (impliedByUse) + { + report += "\" property is implied by use.\n"; + } + else + { + report += "\" property not set.\n"; + } + + std::string interfaceProperty = "INTERFACE_" + p; + for(std::vector::const_iterator li = + deps.begin(); + li != deps.end(); ++li) + { + // An error should be reported if one dependency + // has INTERFACE_POSITION_INDEPENDENT_CODE ON and the other + // has INTERFACE_POSITION_INDEPENDENT_CODE OFF, or if the + // target itself has a POSITION_INDEPENDENT_CODE which disagrees + // with a dependency. + + cmTarget const* theTarget = *li; + + const bool ifaceIsSet = theTarget->GetProperties() + .find(interfaceProperty) + != theTarget->GetProperties().end(); + PropertyType ifacePropContent = + getTypedProperty(theTarget, + interfaceProperty); + + std::string reportEntry; + if (ifaceIsSet) + { + reportEntry += " * Target \""; + reportEntry += theTarget->GetName(); + reportEntry += "\" property value \""; + reportEntry += valueAsString(ifacePropContent); + reportEntry += "\" "; + } + + if (explicitlySet) + { + if (ifaceIsSet) + { + std::pair consistent = + consistentProperty(propContent, + ifacePropContent, t); + report += reportEntry; + report += compatibilityAgree(t, propContent != consistent.second); + if (!consistent.first) + { + std::ostringstream e; + e << "Property " << p << " on target \"" + << tgt->GetName() << "\" does\nnot match the " + "INTERFACE_" << p << " property requirement\nof " + "dependency \"" << theTarget->GetName() << "\".\n"; + cmSystemTools::Error(e.str().c_str()); + break; + } + else + { + propContent = consistent.second; + continue; + } + } + else + { + // Explicitly set on target and not set in iface. Can't disagree. + continue; + } + } + else if (impliedByUse) + { + propContent = impliedValue(propContent); + + if (ifaceIsSet) + { + std::pair consistent = + consistentProperty(propContent, + ifacePropContent, t); + report += reportEntry; + report += compatibilityAgree(t, propContent != consistent.second); + if (!consistent.first) + { + std::ostringstream e; + e << "Property " << p << " on target \"" + << tgt->GetName() << "\" is\nimplied to be " << defaultValue + << " because it was used to determine the link libraries\n" + "already. The INTERFACE_" << p << " property on\ndependency \"" + << theTarget->GetName() << "\" is in conflict.\n"; + cmSystemTools::Error(e.str().c_str()); + break; + } + else + { + propContent = consistent.second; + continue; + } + } + else + { + // Implicitly set on target and not set in iface. Can't disagree. + continue; + } + } + else + { + if (ifaceIsSet) + { + if (propInitialized) + { + std::pair consistent = + consistentProperty(propContent, + ifacePropContent, t); + report += reportEntry; + report += compatibilityAgree(t, propContent != consistent.second); + if (!consistent.first) + { + std::ostringstream e; + e << "The INTERFACE_" << p << " property of \"" + << theTarget->GetName() << "\" does\nnot agree with the value " + "of " << p << " already determined\nfor \"" + << tgt->GetName() << "\".\n"; + cmSystemTools::Error(e.str().c_str()); + break; + } + else + { + propContent = consistent.second; + continue; + } + } + else + { + report += reportEntry + "(Interface set)\n"; + propContent = ifacePropContent; + propInitialized = true; + } + } + else + { + // Not set. Nothing to agree on. + continue; + } + } + } + + tgt->ReportPropertyOrigin(p, valueAsString(propContent), + report, compatibilityType(t)); + return propContent; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::GetLinkInterfaceDependentBoolProperty( + const std::string &p, const std::string& config) const +{ + return checkInterfacePropertyCompatibility(this->Target, p, config, + "FALSE", + cmTarget::BoolType, 0); +} + +//---------------------------------------------------------------------------- +const char* cmGeneratorTarget::GetLinkInterfaceDependentStringProperty( + const std::string &p, + const std::string& config) const +{ + return checkInterfacePropertyCompatibility(this->Target, + p, + config, + "empty", + cmTarget::StringType, 0); +} + +//---------------------------------------------------------------------------- +const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMinProperty( + const std::string &p, + const std::string& config) const +{ + return checkInterfacePropertyCompatibility(this->Target, + p, + config, + "empty", + cmTarget::NumberMinType, 0); +} + +//---------------------------------------------------------------------------- +const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMaxProperty( + const std::string &p, + const std::string& config) const +{ + return checkInterfacePropertyCompatibility(this->Target, + p, + config, + "empty", + cmTarget::NumberMaxType, 0); +} + +//---------------------------------------------------------------------------- cmComputeLinkInformation* cmGeneratorTarget::GetLinkInformation(const std::string& config) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index ae86e19..d65b1ef 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -96,6 +96,17 @@ public: bool IsLinkInterfaceDependentNumberMaxProperty(const std::string &p, const std::string& config) const; + bool GetLinkInterfaceDependentBoolProperty(const std::string &p, + const std::string& config) const; + + const char *GetLinkInterfaceDependentStringProperty(const std::string &p, + const std::string& config) const; + const char *GetLinkInterfaceDependentNumberMinProperty(const std::string &p, + const std::string& config) const; + const char *GetLinkInterfaceDependentNumberMaxProperty(const std::string &p, + const std::string& config) const; + + /** Get the full path to the target according to the settings in its makefile and the configuration type. */ std::string GetFullPath(const std::string& config="", bool implib = false, diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index eaf812f..3ab501d 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2059,7 +2059,9 @@ void cmLocalGenerator::AddCMP0018Flags(std::string &flags, return; } - if (target->GetLinkInterfaceDependentBoolProperty( + cmGeneratorTarget* gtgt = + this->GlobalGenerator->GetGeneratorTarget(target); + if (gtgt->GetLinkInterfaceDependentBoolProperty( "POSITION_INDEPENDENT_CODE", config)) { diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 1e05c34..30ddb59 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -547,8 +547,11 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target) { qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR"); } + cmGeneratorTarget *gtgt = target->GetMakefile()->GetLocalGenerator() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); if (const char *targetQtVersion = - target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", "")) + gtgt->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", "")) { qtVersion = targetQtVersion; } @@ -1150,6 +1153,9 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) std::string cmQtAutoGenerators::GetRccExecutable(cmTarget const* target) { + cmGeneratorTarget *gtgt = target->GetMakefile()->GetLocalGenerator() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); cmMakefile *makefile = target->GetMakefile(); const char *qtVersion = makefile->GetDefinition("_target_qt_version"); if (!qtVersion) @@ -1160,8 +1166,7 @@ std::string cmQtAutoGenerators::GetRccExecutable(cmTarget const* target) qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR"); } if (const char *targetQtVersion = - target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", - "")) + gtgt->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", "")) { qtVersion = targetQtVersion; } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index b165545..1fa62e7 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4536,141 +4536,6 @@ bool cmTarget::IsNullImpliedByLinkLibraries(const std::string &p) const } //---------------------------------------------------------------------------- -template -PropertyType getTypedProperty(cmTarget const* tgt, const std::string& prop); - -//---------------------------------------------------------------------------- -template<> -bool getTypedProperty(cmTarget const* tgt, const std::string& prop) -{ - return tgt->GetPropertyAsBool(prop); -} - -//---------------------------------------------------------------------------- -template<> -const char *getTypedProperty(cmTarget const* tgt, - const std::string& prop) -{ - return tgt->GetProperty(prop); -} - -//---------------------------------------------------------------------------- -template -std::pair consistentProperty(PropertyType lhs, - PropertyType rhs, - cmTarget::CompatibleType t); - -//---------------------------------------------------------------------------- -template<> -std::pair consistentProperty(bool lhs, bool rhs, - cmTarget::CompatibleType) -{ - return std::make_pair(lhs == rhs, lhs); -} - -//---------------------------------------------------------------------------- -std::pair consistentStringProperty(const char *lhs, - const char *rhs) -{ - const bool b = strcmp(lhs, rhs) == 0; - return std::make_pair(b, b ? lhs : 0); -} - -//---------------------------------------------------------------------------- -std::pair consistentNumberProperty(const char *lhs, - const char *rhs, - cmTarget::CompatibleType t) -{ - char *pEnd; - - const char* const null_ptr = 0; - - long lnum = strtol(lhs, &pEnd, 0); - if (pEnd == lhs || *pEnd != '\0' || errno == ERANGE) - { - return std::pair(false, null_ptr); - } - - long rnum = strtol(rhs, &pEnd, 0); - if (pEnd == rhs || *pEnd != '\0' || errno == ERANGE) - { - return std::pair(false, null_ptr); - } - - if (t == cmTarget::NumberMaxType) - { - return std::make_pair(true, std::max(lnum, rnum) == lnum ? lhs : rhs); - } - else - { - return std::make_pair(true, std::min(lnum, rnum) == lnum ? lhs : rhs); - } -} - -//---------------------------------------------------------------------------- -template<> -std::pair consistentProperty(const char *lhs, - const char *rhs, - cmTarget::CompatibleType t) -{ - if (!lhs && !rhs) - { - return std::make_pair(true, lhs); - } - if (!lhs) - { - return std::make_pair(true, rhs); - } - if (!rhs) - { - return std::make_pair(true, lhs); - } - - const char* const null_ptr = 0; - - switch(t) - { - case cmTarget::BoolType: - assert(0 && "consistentProperty for strings called with BoolType"); - return std::pair(false, null_ptr); - case cmTarget::StringType: - return consistentStringProperty(lhs, rhs); - case cmTarget::NumberMinType: - case cmTarget::NumberMaxType: - return consistentNumberProperty(lhs, rhs, t); - } - assert(0 && "Unreachable!"); - return std::pair(false, null_ptr); -} - -template -PropertyType impliedValue(PropertyType); -template<> -bool impliedValue(bool) -{ - return false; -} -template<> -const char* impliedValue(const char*) -{ - return ""; -} - - -template -std::string valueAsString(PropertyType); -template<> -std::string valueAsString(bool value) -{ - return value ? "TRUE" : "FALSE"; -} -template<> -std::string valueAsString(const char* value) -{ - return value ? value : "(unset)"; -} - -//---------------------------------------------------------------------------- void cmTarget::ReportPropertyOrigin(const std::string &p, const std::string &result, @@ -4711,270 +4576,6 @@ cmTarget::ReportPropertyOrigin(const std::string &p, } //---------------------------------------------------------------------------- -std::string compatibilityType(cmTarget::CompatibleType t) -{ - switch(t) - { - case cmTarget::BoolType: - return "Boolean compatibility"; - case cmTarget::StringType: - return "String compatibility"; - case cmTarget::NumberMaxType: - return "Numeric maximum compatibility"; - case cmTarget::NumberMinType: - return "Numeric minimum compatibility"; - } - assert(0 && "Unreachable!"); - return ""; -} - -//---------------------------------------------------------------------------- -std::string compatibilityAgree(cmTarget::CompatibleType t, bool dominant) -{ - switch(t) - { - case cmTarget::BoolType: - case cmTarget::StringType: - return dominant ? "(Disagree)\n" : "(Agree)\n"; - case cmTarget::NumberMaxType: - case cmTarget::NumberMinType: - return dominant ? "(Dominant)\n" : "(Ignored)\n"; - } - assert(0 && "Unreachable!"); - return ""; -} - -//---------------------------------------------------------------------------- -template -PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, - const std::string &p, - const std::string& config, - const char *defaultValue, - cmTarget::CompatibleType t, - PropertyType *) -{ - PropertyType propContent = getTypedProperty(tgt, p); - const bool explicitlySet = tgt->GetProperties() - .find(p) - != tgt->GetProperties().end(); - const bool impliedByUse = - tgt->IsNullImpliedByLinkLibraries(p); - assert((impliedByUse ^ explicitlySet) - || (!impliedByUse && !explicitlySet)); - - std::vector const& deps = - tgt->GetLinkImplementationClosure(config); - - if(deps.empty()) - { - return propContent; - } - bool propInitialized = explicitlySet; - - std::string report = " * Target \""; - report += tgt->GetName(); - if (explicitlySet) - { - report += "\" has property content \""; - report += valueAsString(propContent); - report += "\"\n"; - } - else if (impliedByUse) - { - report += "\" property is implied by use.\n"; - } - else - { - report += "\" property not set.\n"; - } - - std::string interfaceProperty = "INTERFACE_" + p; - for(std::vector::const_iterator li = - deps.begin(); - li != deps.end(); ++li) - { - // An error should be reported if one dependency - // has INTERFACE_POSITION_INDEPENDENT_CODE ON and the other - // has INTERFACE_POSITION_INDEPENDENT_CODE OFF, or if the - // target itself has a POSITION_INDEPENDENT_CODE which disagrees - // with a dependency. - - cmTarget const* theTarget = *li; - - const bool ifaceIsSet = theTarget->GetProperties() - .find(interfaceProperty) - != theTarget->GetProperties().end(); - PropertyType ifacePropContent = - getTypedProperty(theTarget, - interfaceProperty); - - std::string reportEntry; - if (ifaceIsSet) - { - reportEntry += " * Target \""; - reportEntry += theTarget->GetName(); - reportEntry += "\" property value \""; - reportEntry += valueAsString(ifacePropContent); - reportEntry += "\" "; - } - - if (explicitlySet) - { - if (ifaceIsSet) - { - std::pair consistent = - consistentProperty(propContent, - ifacePropContent, t); - report += reportEntry; - report += compatibilityAgree(t, propContent != consistent.second); - if (!consistent.first) - { - std::ostringstream e; - e << "Property " << p << " on target \"" - << tgt->GetName() << "\" does\nnot match the " - "INTERFACE_" << p << " property requirement\nof " - "dependency \"" << theTarget->GetName() << "\".\n"; - cmSystemTools::Error(e.str().c_str()); - break; - } - else - { - propContent = consistent.second; - continue; - } - } - else - { - // Explicitly set on target and not set in iface. Can't disagree. - continue; - } - } - else if (impliedByUse) - { - propContent = impliedValue(propContent); - - if (ifaceIsSet) - { - std::pair consistent = - consistentProperty(propContent, - ifacePropContent, t); - report += reportEntry; - report += compatibilityAgree(t, propContent != consistent.second); - if (!consistent.first) - { - std::ostringstream e; - e << "Property " << p << " on target \"" - << tgt->GetName() << "\" is\nimplied to be " << defaultValue - << " because it was used to determine the link libraries\n" - "already. The INTERFACE_" << p << " property on\ndependency \"" - << theTarget->GetName() << "\" is in conflict.\n"; - cmSystemTools::Error(e.str().c_str()); - break; - } - else - { - propContent = consistent.second; - continue; - } - } - else - { - // Implicitly set on target and not set in iface. Can't disagree. - continue; - } - } - else - { - if (ifaceIsSet) - { - if (propInitialized) - { - std::pair consistent = - consistentProperty(propContent, - ifacePropContent, t); - report += reportEntry; - report += compatibilityAgree(t, propContent != consistent.second); - if (!consistent.first) - { - std::ostringstream e; - e << "The INTERFACE_" << p << " property of \"" - << theTarget->GetName() << "\" does\nnot agree with the value " - "of " << p << " already determined\nfor \"" - << tgt->GetName() << "\".\n"; - cmSystemTools::Error(e.str().c_str()); - break; - } - else - { - propContent = consistent.second; - continue; - } - } - else - { - report += reportEntry + "(Interface set)\n"; - propContent = ifacePropContent; - propInitialized = true; - } - } - else - { - // Not set. Nothing to agree on. - continue; - } - } - } - - tgt->ReportPropertyOrigin(p, valueAsString(propContent), - report, compatibilityType(t)); - return propContent; -} - -//---------------------------------------------------------------------------- -bool cmTarget::GetLinkInterfaceDependentBoolProperty(const std::string &p, - const std::string& config) const -{ - return checkInterfacePropertyCompatibility(this, p, config, "FALSE", - BoolType, 0); -} - -//---------------------------------------------------------------------------- -const char * cmTarget::GetLinkInterfaceDependentStringProperty( - const std::string &p, - const std::string& config) const -{ - return checkInterfacePropertyCompatibility(this, - p, - config, - "empty", - StringType, 0); -} - -//---------------------------------------------------------------------------- -const char * cmTarget::GetLinkInterfaceDependentNumberMinProperty( - const std::string &p, - const std::string& config) const -{ - return checkInterfacePropertyCompatibility(this, - p, - config, - "empty", - NumberMinType, 0); -} - -//---------------------------------------------------------------------------- -const char * cmTarget::GetLinkInterfaceDependentNumberMaxProperty( - const std::string &p, - const std::string& config) const -{ - return checkInterfacePropertyCompatibility(this, - p, - config, - "empty", - NumberMaxType, 0); -} - -//---------------------------------------------------------------------------- void cmTarget::GetObjectLibrariesCMP0026(std::vector& objlibs) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 8af74ef..b544b0b 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -553,15 +553,6 @@ public: const std::string& config) const; bool IsNullImpliedByLinkLibraries(const std::string &p) const; - bool GetLinkInterfaceDependentBoolProperty(const std::string &p, - const std::string& config) const; - - const char *GetLinkInterfaceDependentStringProperty(const std::string &p, - const std::string& config) const; - const char *GetLinkInterfaceDependentNumberMinProperty(const std::string &p, - const std::string& config) const; - const char *GetLinkInterfaceDependentNumberMaxProperty(const std::string &p, - const std::string& config) const; std::string GetDebugGeneratorExpressions(const std::string &value, cmTarget::LinkLibraryType llt) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=55e097ae0cc3b0a722ed56883c5f9ada772d5c09 commit 55e097ae0cc3b0a722ed56883c5f9ada772d5c09 Author: Stephen Kelly AuthorDate: Tue Jul 28 21:02:27 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:03:43 2015 +0200 cmGeneratorTarget: Port internal API to cmGeneratorTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 1f3effb..a7b0349 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1525,23 +1525,23 @@ bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty( } template -PropertyType getLinkInterfaceDependentProperty(cmTarget const* tgt, +PropertyType getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, cmTarget::CompatibleType, PropertyType *); template<> -bool getLinkInterfaceDependentProperty(cmTarget const* tgt, +bool getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, cmTarget::CompatibleType, bool *) { - return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); + return tgt->Target->GetLinkInterfaceDependentBoolProperty(prop, config); } template<> -const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, +const char * getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, cmTarget::CompatibleType t, @@ -1553,11 +1553,13 @@ const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, assert(0 && "String compatibility check function called for boolean"); return 0; case cmTarget::StringType: - return tgt->GetLinkInterfaceDependentStringProperty(prop, config); + return tgt->Target->GetLinkInterfaceDependentStringProperty(prop, config); case cmTarget::NumberMinType: - return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config); + return tgt->Target + ->GetLinkInterfaceDependentNumberMinProperty(prop, config); case cmTarget::NumberMaxType: - return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config); + return tgt->Target + ->GetLinkInterfaceDependentNumberMaxProperty(prop, config); } assert(0 && "Unreachable!"); return 0; @@ -1565,7 +1567,7 @@ const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, //---------------------------------------------------------------------------- template -void checkPropertyConsistency(cmTarget const* depender, +void checkPropertyConsistency(cmGeneratorTarget const* depender, cmTarget const* dependee, const std::string& propName, std::set &emitted, @@ -1597,7 +1599,7 @@ void checkPropertyConsistency(cmTarget const* depender, << *pi << "\" listed in its " << propName << " property. " "This is not allowed. Only user-defined properties may appear " "listed in the " << propName << " property."; - depender->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, e.str()); + depender->GetLocalGenerator()->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } if(emitted.insert(*pi).second) @@ -1681,14 +1683,14 @@ void cmGeneratorTarget::CheckPropertyCompatibility( continue; } - checkPropertyConsistency(this->Target, li->Target, + checkPropertyConsistency(this, li->Target, strBool, emittedBools, config, cmTarget::BoolType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; } - checkPropertyConsistency(this->Target, li->Target, + checkPropertyConsistency(this, li->Target, strString, emittedStrings, config, cmTarget::StringType, 0); @@ -1696,7 +1698,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( { return; } - checkPropertyConsistency(this->Target, li->Target, + checkPropertyConsistency(this, li->Target, strNumMin, emittedMinNumbers, config, cmTarget::NumberMinType, 0); @@ -1704,7 +1706,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( { return; } - checkPropertyConsistency(this->Target, li->Target, + checkPropertyConsistency(this, li->Target, strNumMax, emittedMaxNumbers, config, cmTarget::NumberMaxType, 0); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=65d9ff20a94bcd0439dfd8dd4a29e30bd1a49dd3 commit 65d9ff20a94bcd0439dfd8dd4a29e30bd1a49dd3 Author: Stephen Kelly AuthorDate: Tue Jul 28 20:59:17 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:03:43 2015 +0200 cmGeneratorTarget: Move CheckPropertyCompatibility from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 845c052..1f3effb 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1524,6 +1524,240 @@ bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty( return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0; } +template +PropertyType getLinkInterfaceDependentProperty(cmTarget const* tgt, + const std::string& prop, + const std::string& config, + cmTarget::CompatibleType, + PropertyType *); + +template<> +bool getLinkInterfaceDependentProperty(cmTarget const* tgt, + const std::string& prop, + const std::string& config, + cmTarget::CompatibleType, bool *) +{ + return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); +} + +template<> +const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, + const std::string& prop, + const std::string& config, + cmTarget::CompatibleType t, + const char **) +{ + switch(t) + { + case cmTarget::BoolType: + assert(0 && "String compatibility check function called for boolean"); + return 0; + case cmTarget::StringType: + return tgt->GetLinkInterfaceDependentStringProperty(prop, config); + case cmTarget::NumberMinType: + return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config); + case cmTarget::NumberMaxType: + return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config); + } + assert(0 && "Unreachable!"); + return 0; +} + +//---------------------------------------------------------------------------- +template +void checkPropertyConsistency(cmTarget const* depender, + cmTarget const* dependee, + const std::string& propName, + std::set &emitted, + const std::string& config, + cmTarget::CompatibleType t, + PropertyType *) +{ + const char *prop = dependee->GetProperty(propName); + if (!prop) + { + return; + } + + std::vector props; + cmSystemTools::ExpandListArgument(prop, props); + std::string pdir = + dependee->GetMakefile()->GetRequiredDefinition("CMAKE_ROOT"); + pdir += "/Help/prop_tgt/"; + + for(std::vector::iterator pi = props.begin(); + pi != props.end(); ++pi) + { + std::string pname = cmSystemTools::HelpFileName(*pi); + std::string pfile = pdir + pname + ".rst"; + if(cmSystemTools::FileExists(pfile.c_str(), true)) + { + std::ostringstream e; + e << "Target \"" << dependee->GetName() << "\" has property \"" + << *pi << "\" listed in its " << propName << " property. " + "This is not allowed. Only user-defined properties may appear " + "listed in the " << propName << " property."; + depender->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, e.str()); + return; + } + if(emitted.insert(*pi).second) + { + getLinkInterfaceDependentProperty(depender, *pi, config, + t, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + } + } +} + +static std::string intersect(const std::set &s1, + const std::set &s2) +{ + std::set intersect; + std::set_intersection(s1.begin(),s1.end(), + s2.begin(),s2.end(), + std::inserter(intersect,intersect.begin())); + if (!intersect.empty()) + { + return *intersect.begin(); + } + return ""; +} + +static std::string intersect(const std::set &s1, + const std::set &s2, + const std::set &s3) +{ + std::string result; + result = intersect(s1, s2); + if (!result.empty()) + return result; + result = intersect(s1, s3); + if (!result.empty()) + return result; + return intersect(s2, s3); +} + +static std::string intersect(const std::set &s1, + const std::set &s2, + const std::set &s3, + const std::set &s4) +{ + std::string result; + result = intersect(s1, s2); + if (!result.empty()) + return result; + result = intersect(s1, s3); + if (!result.empty()) + return result; + result = intersect(s1, s4); + if (!result.empty()) + return result; + return intersect(s2, s3, s4); +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::CheckPropertyCompatibility( + cmComputeLinkInformation *info, const std::string& config) const +{ + const cmComputeLinkInformation::ItemVector &deps = info->GetItems(); + + std::set emittedBools; + static std::string strBool = "COMPATIBLE_INTERFACE_BOOL"; + std::set emittedStrings; + static std::string strString = "COMPATIBLE_INTERFACE_STRING"; + std::set emittedMinNumbers; + static std::string strNumMin = "COMPATIBLE_INTERFACE_NUMBER_MIN"; + std::set emittedMaxNumbers; + static std::string strNumMax = "COMPATIBLE_INTERFACE_NUMBER_MAX"; + + for(cmComputeLinkInformation::ItemVector::const_iterator li = + deps.begin(); li != deps.end(); ++li) + { + if (!li->Target) + { + continue; + } + + checkPropertyConsistency(this->Target, li->Target, + strBool, + emittedBools, config, cmTarget::BoolType, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + checkPropertyConsistency(this->Target, li->Target, + strString, + emittedStrings, config, + cmTarget::StringType, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + checkPropertyConsistency(this->Target, li->Target, + strNumMin, + emittedMinNumbers, config, + cmTarget::NumberMinType, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + checkPropertyConsistency(this->Target, li->Target, + strNumMax, + emittedMaxNumbers, config, + cmTarget::NumberMaxType, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + } + + std::string prop = intersect(emittedBools, + emittedStrings, + emittedMinNumbers, + emittedMaxNumbers); + + if (!prop.empty()) + { + // Use a sorted std::vector to keep the error message sorted. + std::vector props; + std::set::const_iterator i = emittedBools.find(prop); + if (i != emittedBools.end()) + { + props.push_back(strBool); + } + i = emittedStrings.find(prop); + if (i != emittedStrings.end()) + { + props.push_back(strString); + } + i = emittedMinNumbers.find(prop); + if (i != emittedMinNumbers.end()) + { + props.push_back(strNumMin); + } + i = emittedMaxNumbers.find(prop); + if (i != emittedMaxNumbers.end()) + { + props.push_back(strNumMax); + } + std::sort(props.begin(), props.end()); + + std::string propsString = cmJoin(cmMakeRange(props).retreat(1), ", "); + propsString += " and the " + props.back(); + + std::ostringstream e; + e << "Property \"" << prop << "\" appears in both the " + << propsString << + " property in the dependencies of target \"" << this->GetName() << + "\". This is not allowed. A property may only require compatibility " + "in a boolean interpretation, a numeric minimum, a numeric maximum or a " + "string interpretation, but not a mixture."; + this->LocalGenerator->IssueMessage(cmake::FATAL_ERROR, e.str()); + } +} //---------------------------------------------------------------------------- cmComputeLinkInformation* @@ -1550,7 +1784,7 @@ cmGeneratorTarget::GetLinkInformation(const std::string& config) const if (info) { - this->Target->CheckPropertyCompatibility(info, config); + this->CheckPropertyCompatibility(info, config); } } return i->second; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index e53f098..ae86e19 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -222,6 +222,9 @@ private: cmTargetLinkInformationMap; mutable cmTargetLinkInformationMap LinkInformation; + void CheckPropertyCompatibility(cmComputeLinkInformation *info, + const std::string& config) const; + cmGeneratorTarget(cmGeneratorTarget const&); void operator=(cmGeneratorTarget const&); }; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index d8904ea..b165545 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4554,23 +4554,16 @@ const char *getTypedProperty(cmTarget const* tgt, return tgt->GetProperty(prop); } -enum CompatibleType -{ - BoolType, - StringType, - NumberMinType, - NumberMaxType -}; - //---------------------------------------------------------------------------- template std::pair consistentProperty(PropertyType lhs, PropertyType rhs, - CompatibleType t); + cmTarget::CompatibleType t); //---------------------------------------------------------------------------- template<> -std::pair consistentProperty(bool lhs, bool rhs, CompatibleType) +std::pair consistentProperty(bool lhs, bool rhs, + cmTarget::CompatibleType) { return std::make_pair(lhs == rhs, lhs); } @@ -4585,8 +4578,8 @@ std::pair consistentStringProperty(const char *lhs, //---------------------------------------------------------------------------- std::pair consistentNumberProperty(const char *lhs, - const char *rhs, - CompatibleType t) + const char *rhs, + cmTarget::CompatibleType t) { char *pEnd; @@ -4604,7 +4597,7 @@ std::pair consistentNumberProperty(const char *lhs, return std::pair(false, null_ptr); } - if (t == NumberMaxType) + if (t == cmTarget::NumberMaxType) { return std::make_pair(true, std::max(lnum, rnum) == lnum ? lhs : rhs); } @@ -4618,7 +4611,7 @@ std::pair consistentNumberProperty(const char *lhs, template<> std::pair consistentProperty(const char *lhs, const char *rhs, - CompatibleType t) + cmTarget::CompatibleType t) { if (!lhs && !rhs) { @@ -4637,13 +4630,13 @@ std::pair consistentProperty(const char *lhs, switch(t) { - case BoolType: + case cmTarget::BoolType: assert(0 && "consistentProperty for strings called with BoolType"); return std::pair(false, null_ptr); - case StringType: + case cmTarget::StringType: return consistentStringProperty(lhs, rhs); - case NumberMinType: - case NumberMaxType: + case cmTarget::NumberMinType: + case cmTarget::NumberMaxType: return consistentNumberProperty(lhs, rhs, t); } assert(0 && "Unreachable!"); @@ -4718,17 +4711,17 @@ cmTarget::ReportPropertyOrigin(const std::string &p, } //---------------------------------------------------------------------------- -std::string compatibilityType(CompatibleType t) +std::string compatibilityType(cmTarget::CompatibleType t) { switch(t) { - case BoolType: + case cmTarget::BoolType: return "Boolean compatibility"; - case StringType: + case cmTarget::StringType: return "String compatibility"; - case NumberMaxType: + case cmTarget::NumberMaxType: return "Numeric maximum compatibility"; - case NumberMinType: + case cmTarget::NumberMinType: return "Numeric minimum compatibility"; } assert(0 && "Unreachable!"); @@ -4736,15 +4729,15 @@ std::string compatibilityType(CompatibleType t) } //---------------------------------------------------------------------------- -std::string compatibilityAgree(CompatibleType t, bool dominant) +std::string compatibilityAgree(cmTarget::CompatibleType t, bool dominant) { switch(t) { - case BoolType: - case StringType: + case cmTarget::BoolType: + case cmTarget::StringType: return dominant ? "(Disagree)\n" : "(Agree)\n"; - case NumberMaxType: - case NumberMinType: + case cmTarget::NumberMaxType: + case cmTarget::NumberMinType: return dominant ? "(Dominant)\n" : "(Ignored)\n"; } assert(0 && "Unreachable!"); @@ -4757,7 +4750,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, const std::string &p, const std::string& config, const char *defaultValue, - CompatibleType t, + cmTarget::CompatibleType t, PropertyType *) { PropertyType propContent = getTypedProperty(tgt, p); @@ -6224,240 +6217,6 @@ std::string cmTarget::CheckCMP0004(std::string const& item) const return lib; } -template -PropertyType getLinkInterfaceDependentProperty(cmTarget const* tgt, - const std::string& prop, - const std::string& config, - CompatibleType, - PropertyType *); - -template<> -bool getLinkInterfaceDependentProperty(cmTarget const* tgt, - const std::string& prop, - const std::string& config, - CompatibleType, bool *) -{ - return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); -} - -template<> -const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, - const std::string& prop, - const std::string& config, - CompatibleType t, - const char **) -{ - switch(t) - { - case BoolType: - assert(0 && "String compatibility check function called for boolean"); - return 0; - case StringType: - return tgt->GetLinkInterfaceDependentStringProperty(prop, config); - case NumberMinType: - return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config); - case NumberMaxType: - return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config); - } - assert(0 && "Unreachable!"); - return 0; -} - -//---------------------------------------------------------------------------- -template -void checkPropertyConsistency(cmTarget const* depender, - cmTarget const* dependee, - const std::string& propName, - std::set &emitted, - const std::string& config, - CompatibleType t, - PropertyType *) -{ - const char *prop = dependee->GetProperty(propName); - if (!prop) - { - return; - } - - std::vector props; - cmSystemTools::ExpandListArgument(prop, props); - std::string pdir = - dependee->GetMakefile()->GetRequiredDefinition("CMAKE_ROOT"); - pdir += "/Help/prop_tgt/"; - - for(std::vector::iterator pi = props.begin(); - pi != props.end(); ++pi) - { - std::string pname = cmSystemTools::HelpFileName(*pi); - std::string pfile = pdir + pname + ".rst"; - if(cmSystemTools::FileExists(pfile.c_str(), true)) - { - std::ostringstream e; - e << "Target \"" << dependee->GetName() << "\" has property \"" - << *pi << "\" listed in its " << propName << " property. " - "This is not allowed. Only user-defined properties may appear " - "listed in the " << propName << " property."; - depender->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, e.str()); - return; - } - if(emitted.insert(*pi).second) - { - getLinkInterfaceDependentProperty(depender, *pi, config, - t, 0); - if (cmSystemTools::GetErrorOccuredFlag()) - { - return; - } - } - } -} - -static std::string intersect(const std::set &s1, - const std::set &s2) -{ - std::set intersect; - std::set_intersection(s1.begin(),s1.end(), - s2.begin(),s2.end(), - std::inserter(intersect,intersect.begin())); - if (!intersect.empty()) - { - return *intersect.begin(); - } - return ""; -} -static std::string intersect(const std::set &s1, - const std::set &s2, - const std::set &s3) -{ - std::string result; - result = intersect(s1, s2); - if (!result.empty()) - return result; - result = intersect(s1, s3); - if (!result.empty()) - return result; - return intersect(s2, s3); -} -static std::string intersect(const std::set &s1, - const std::set &s2, - const std::set &s3, - const std::set &s4) -{ - std::string result; - result = intersect(s1, s2); - if (!result.empty()) - return result; - result = intersect(s1, s3); - if (!result.empty()) - return result; - result = intersect(s1, s4); - if (!result.empty()) - return result; - return intersect(s2, s3, s4); -} - -//---------------------------------------------------------------------------- -void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, - const std::string& config) const -{ - const cmComputeLinkInformation::ItemVector &deps = info->GetItems(); - - std::set emittedBools; - static std::string strBool = "COMPATIBLE_INTERFACE_BOOL"; - std::set emittedStrings; - static std::string strString = "COMPATIBLE_INTERFACE_STRING"; - std::set emittedMinNumbers; - static std::string strNumMin = "COMPATIBLE_INTERFACE_NUMBER_MIN"; - std::set emittedMaxNumbers; - static std::string strNumMax = "COMPATIBLE_INTERFACE_NUMBER_MAX"; - - for(cmComputeLinkInformation::ItemVector::const_iterator li = - deps.begin(); - li != deps.end(); ++li) - { - if (!li->Target) - { - continue; - } - - checkPropertyConsistency(this, li->Target, - strBool, - emittedBools, config, BoolType, 0); - if (cmSystemTools::GetErrorOccuredFlag()) - { - return; - } - checkPropertyConsistency(this, li->Target, - strString, - emittedStrings, config, - StringType, 0); - if (cmSystemTools::GetErrorOccuredFlag()) - { - return; - } - checkPropertyConsistency(this, li->Target, - strNumMin, - emittedMinNumbers, config, - NumberMinType, 0); - if (cmSystemTools::GetErrorOccuredFlag()) - { - return; - } - checkPropertyConsistency(this, li->Target, - strNumMax, - emittedMaxNumbers, config, - NumberMaxType, 0); - if (cmSystemTools::GetErrorOccuredFlag()) - { - return; - } - } - - std::string prop = intersect(emittedBools, - emittedStrings, - emittedMinNumbers, - emittedMaxNumbers); - - if (!prop.empty()) - { - // Use a sorted std::vector to keep the error message sorted. - std::vector props; - std::set::const_iterator i = emittedBools.find(prop); - if (i != emittedBools.end()) - { - props.push_back(strBool); - } - i = emittedStrings.find(prop); - if (i != emittedStrings.end()) - { - props.push_back(strString); - } - i = emittedMinNumbers.find(prop); - if (i != emittedMinNumbers.end()) - { - props.push_back(strNumMin); - } - i = emittedMaxNumbers.find(prop); - if (i != emittedMaxNumbers.end()) - { - props.push_back(strNumMax); - } - std::sort(props.begin(), props.end()); - - std::string propsString = cmJoin(cmMakeRange(props).retreat(1), ", "); - propsString += " and the " + props.back(); - - std::ostringstream e; - e << "Property \"" << prop << "\" appears in both the " - << propsString << - " property in the dependencies of target \"" << this->GetName() << - "\". This is not allowed. A property may only require compatibility " - "in a boolean interpretation, a numeric minimum, a numeric maximum or a " - "string interpretation, but not a mixture."; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); - } -} - //---------------------------------------------------------------------------- std::string cmTarget::GetFrameworkDirectory(const std::string& config, bool rootDir) const diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e3410aa..8af74ef 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -590,6 +590,14 @@ public: return this->LinkLibrariesForVS6;} #endif + enum CompatibleType + { + BoolType, + StringType, + NumberMinType, + NumberMaxType + }; + private: bool HandleLocationPropertyPolicy(cmMakefile* context) const; @@ -754,9 +762,6 @@ private: struct CompileInfo; CompileInfo const* GetCompileInfo(const std::string& config) const; - void CheckPropertyCompatibility(cmComputeLinkInformation *info, - const std::string& config) const; - LinkInterface const* GetImportLinkInterface(const std::string& config, cmTarget const* head, bool usage_requirements_only) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a19a796b4f8c2eb2da33b2c23337596d1f109521 commit a19a796b4f8c2eb2da33b2c23337596d1f109521 Author: Stephen Kelly AuthorDate: Thu Jun 13 21:56:07 2013 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:03:43 2015 +0200 cmGeneratorTarget: Move GetLinkInformation from cmTarget diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 26ca375..4840e89 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -276,7 +276,8 @@ std::string cmCommonTargetGenerator::GetFrameworkFlags(std::string const& l) std::string flags; const char* cfg = this->LocalGenerator->GetConfigName().c_str(); - if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(cfg)) + if(cmComputeLinkInformation* cli = + this->GeneratorTarget->GetLinkInformation(cfg)) { std::vector const& frameworks = cli->GetFrameworkPaths(); for(std::vector::const_iterator i = frameworks.begin(); @@ -384,7 +385,7 @@ cmCommonTargetGenerator::GetLinkedTargetDirectories() const std::vector dirs; std::set emitted; if (cmComputeLinkInformation* cli = - this->Target->GetLinkInformation(this->ConfigName)) + this->GeneratorTarget->GetLinkInformation(this->ConfigName)) { cmComputeLinkInformation::ItemVector const& items = cli->GetItems(); for(cmComputeLinkInformation::ItemVector::const_iterator diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index a5050ff..8a2cf4b 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -529,7 +529,7 @@ void getCompatibleInterfaceProperties(cmGeneratorTarget *target, std::set &ifaceProperties, const std::string& config) { - cmComputeLinkInformation *info = target->Target->GetLinkInformation(config); + cmComputeLinkInformation *info = target->GetLinkInformation(config); if (!info) { diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 3dbeff2..845c052 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -229,6 +229,12 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) this->GlobalGenerator = this->Makefile->GetGlobalGenerator(); } +cmGeneratorTarget::~cmGeneratorTarget() +{ + cmDeleteAll(this->LinkInformation); + this->LinkInformation.clear(); +} + cmLocalGenerator* cmGeneratorTarget::GetLocalGenerator() const { return this->LocalGenerator; @@ -1517,3 +1523,35 @@ bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty( } return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0; } + + +//---------------------------------------------------------------------------- +cmComputeLinkInformation* +cmGeneratorTarget::GetLinkInformation(const std::string& config) const +{ + // Lookup any existing information for this configuration. + std::string key(cmSystemTools::UpperCase(config)); + cmTargetLinkInformationMap::iterator + i = this->LinkInformation.find(key); + if(i == this->LinkInformation.end()) + { + // Compute information for this configuration. + cmComputeLinkInformation* info = + new cmComputeLinkInformation(this->Target, config); + if(!info || !info->Compute()) + { + delete info; + info = 0; + } + + // Store the information for this configuration. + cmTargetLinkInformationMap::value_type entry(key, info); + i = this->LinkInformation.insert(entry).first; + + if (info) + { + this->Target->CheckPropertyCompatibility(info, config); + } + } + return i->second; +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 3b32bf5..e53f098 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -20,11 +20,13 @@ class cmLocalGenerator; class cmMakefile; class cmSourceFile; class cmTarget; +class cmComputeLinkInformation; class cmGeneratorTarget { public: cmGeneratorTarget(cmTarget*, cmLocalGenerator* lg); + ~cmGeneratorTarget(); cmLocalGenerator* GetLocalGenerator() const; @@ -36,6 +38,9 @@ public: location is suitable for use as the LOCATION target property. */ const char* GetLocationForBuild() const; + cmComputeLinkInformation* + GetLinkInformation(const std::string& config) const; + int GetType() const; std::string GetName() const; const char *GetProperty(const std::string& prop) const; @@ -213,6 +218,10 @@ private: }; mutable std::map CompatibleInterfacesMap; + typedef std::map + cmTargetLinkInformationMap; + mutable cmTargetLinkInformationMap LinkInformation; + cmGeneratorTarget(cmGeneratorTarget const&); void operator=(cmGeneratorTarget const&); }; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 8cb59f8..b44848c 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2202,7 +2202,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, } } // Add framework search paths needed for linking. - if(cmComputeLinkInformation* cli = target.GetLinkInformation(configName)) + if(cmComputeLinkInformation* cli = gtgt->GetLinkInformation(configName)) { std::vector const& fwDirs = cli->GetFrameworkPaths(); for(std::vector::const_iterator fdi = fwDirs.begin(); @@ -2358,7 +2358,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, this->CreateString(install_name_dir.c_str())); // Create the LD_RUNPATH_SEARCH_PATHS - cmComputeLinkInformation* pcli = target.GetLinkInformation(configName); + cmComputeLinkInformation* pcli = gtgt->GetLinkInformation(configName); if(pcli) { std::string search_paths; @@ -2964,7 +2964,8 @@ void cmGlobalXCodeGenerator } // Compute the link library and directory information. - cmComputeLinkInformation* pcli = cmtarget->GetLinkInformation(configName); + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(cmtarget); + cmComputeLinkInformation* pcli = gtgt->GetLinkInformation(configName); if(!pcli) { continue; diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 01d4b77..c64f9a3 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -18,6 +18,7 @@ #include "cmMakefile.h" #include "cmGeneratorTarget.h" #include "cmake.h" +#include "cmGeneratorTarget.h" #include @@ -557,8 +558,7 @@ cmInstallTargetGenerator // Build a map of build-tree install_name to install-tree install_name for // shared libraries linked to this target. std::map install_name_remap; - if(cmComputeLinkInformation* cli = - this->Target->Target->GetLinkInformation(config)) + if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config)) { std::set const& sharedLibs = cli->GetSharedLibrariesLinked(); @@ -667,8 +667,7 @@ cmInstallTargetGenerator // Get the link information for this target. // It can provide the RPATH. - cmComputeLinkInformation* cli = - this->Target->Target->GetLinkInformation(config); + cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config); if(!cli) { return; @@ -700,8 +699,7 @@ cmInstallTargetGenerator // Get the link information for this target. // It can provide the RPATH. - cmComputeLinkInformation* cli = - this->Target->Target->GetLinkInformation(config); + cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config); if(!cli) { return; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 6b48a44..eaf812f 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1468,7 +1468,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, bool escapeAllowMakeVars = !forResponseFile; std::ostringstream fout; std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); - cmComputeLinkInformation* pcli = tgt.Target->GetLinkInformation(config); + cmComputeLinkInformation* pcli = tgt.GetLinkInformation(config); if(!pcli) { return; diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index cab5a47..61d7847 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1846,8 +1846,10 @@ void cmLocalVisualStudio6Generator const std::string extraOptions, std::string& options) { + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); // Compute the link information for this configuration. - cmComputeLinkInformation* pcli = target.GetLinkInformation(configName); + cmComputeLinkInformation* pcli = gt->GetLinkInformation(configName); if(!pcli) { return; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 572dbde..5bd82ff 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1148,7 +1148,9 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, targetNameImport, targetNamePDB, configName); // Compute the link library and directory information. - cmComputeLinkInformation* pcli = target.GetLinkInformation(configName); + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); + cmComputeLinkInformation* pcli = gt->GetLinkInformation(configName); if(!pcli) { return; @@ -1245,7 +1247,9 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, targetNameImport, targetNamePDB, configName); // Compute the link library and directory information. - cmComputeLinkInformation* pcli = target.GetLinkInformation(configName); + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); + cmComputeLinkInformation* pcli = gt->GetLinkInformation(configName); if(!pcli) { return; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 5edc0f5..ac8cd29 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1446,7 +1446,8 @@ void cmMakefileTargetGenerator // Loop over all library dependencies. const char* cfg = this->LocalGenerator->GetConfigName().c_str(); - if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(cfg)) + if(cmComputeLinkInformation* cli = + this->GeneratorTarget->GetLinkInformation(cfg)) { std::vector const& libDeps = cli->GetDepends(); depends.insert(depends.end(), libDeps.begin(), libDeps.end()); diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 4e4dc3f..cf80424 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -195,7 +195,7 @@ cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const return cmNinjaDeps(); cmComputeLinkInformation* cli = - this->Target->GetLinkInformation(this->GetConfigName()); + this->GeneratorTarget->GetLinkInformation(this->GetConfigName()); if(!cli) return cmNinjaDeps(); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 9c7e46a..d8904ea 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -520,8 +520,6 @@ void cmTarget::ClearLinkMaps() this->Internal->LinkInterfaceUsageRequirementsOnlyMap.clear(); this->Internal->LinkClosureMap.clear(); this->Internal->SourceFilesMap.clear(); - cmDeleteAll(this->LinkInformation); - this->LinkInformation.clear(); } //---------------------------------------------------------------------------- @@ -6461,37 +6459,6 @@ void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, } //---------------------------------------------------------------------------- -cmComputeLinkInformation* -cmTarget::GetLinkInformation(const std::string& config) const -{ - // Lookup any existing information for this configuration. - std::string key(cmSystemTools::UpperCase(config)); - cmTargetLinkInformationMap::iterator - i = this->LinkInformation.find(key); - if(i == this->LinkInformation.end()) - { - // Compute information for this configuration. - cmComputeLinkInformation* info = - new cmComputeLinkInformation(this, config); - if(!info || !info->Compute()) - { - delete info; - info = 0; - } - - // Store the information for this configuration. - cmTargetLinkInformationMap::value_type entry(key, info); - i = this->LinkInformation.insert(entry).first; - - if (info) - { - this->CheckPropertyCompatibility(info, config); - } - } - return i->second; -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetFrameworkDirectory(const std::string& config, bool rootDir) const { @@ -6583,26 +6550,6 @@ std::string cmTarget::GetMacContentDirectory(const std::string& config, } //---------------------------------------------------------------------------- -cmTargetLinkInformationMap -::cmTargetLinkInformationMap(cmTargetLinkInformationMap const& r): derived() -{ - // Ideally cmTarget instances should never be copied. However until - // we can make a sweep to remove that, this copy constructor avoids - // allowing the resources (LinkInformation) from getting copied. In - // the worst case this will lead to extra cmComputeLinkInformation - // instances. We also enforce in debug mode that the map be emptied - // when copied. - static_cast(r); - assert(r.empty()); -} - -//---------------------------------------------------------------------------- -cmTargetLinkInformationMap::~cmTargetLinkInformationMap() -{ - cmDeleteAll(*this); -} - -//---------------------------------------------------------------------------- cmTargetInternalPointer::cmTargetInternalPointer() { this->Pointer = new cmTargetInternals; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index df8cdc1..e3410aa 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -78,15 +78,6 @@ public: bool FromGenex; }; -struct cmTargetLinkInformationMap: - public std::map -{ - typedef std::map derived; - cmTargetLinkInformationMap() {} - cmTargetLinkInformationMap(cmTargetLinkInformationMap const& r); - ~cmTargetLinkInformationMap(); -}; - class cmTargetInternals; class cmTargetInternalPointer { @@ -454,9 +445,6 @@ public: * install tree. For example: "\@rpath/" or "\@loader_path/". */ std::string GetInstallNameDirForInstallTree() const; - cmComputeLinkInformation* - GetLinkInformation(const std::string& config) const; - // Get the properties cmPropertyMap &GetProperties() const { return this->Properties; } @@ -766,7 +754,6 @@ private: struct CompileInfo; CompileInfo const* GetCompileInfo(const std::string& config) const; - mutable cmTargetLinkInformationMap LinkInformation; void CheckPropertyCompatibility(cmComputeLinkInformation *info, const std::string& config) const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 71785e9..f3f291a 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2438,7 +2438,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) cmSystemTools::ExpandListArgument(libs, libVec); cmComputeLinkInformation* pcli = - this->Target->GetLinkInformation(config.c_str()); + this->GeneratorTarget->GetLinkInformation(config.c_str()); if(!pcli) { cmSystemTools::Error http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=47c898cfc53430626eab7448c8657ecae15815d9 commit 47c898cfc53430626eab7448c8657ecae15815d9 Author: Stephen Kelly AuthorDate: Mon Jul 27 22:51:04 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:03:42 2015 +0200 Export: Port more API to cmGeneratorTarget. diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 355fc00..6274c3f 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -27,6 +27,7 @@ cmExportBuildFileGenerator::cmExportBuildFileGenerator() //---------------------------------------------------------------------------- bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) { + std::vector allTargets; { std::string expectedTargets; std::string sep; @@ -68,7 +69,8 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) tei = this->Exports.begin(); tei != this->Exports.end(); ++tei) { - cmTarget* te = (*tei)->Target; + cmGeneratorTarget* gte = *tei; + cmTarget* te = gte->Target; this->GenerateImportTargetCode(os, te); te->AppendBuildInterfaceIncludes(); @@ -104,7 +106,7 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) cmGeneratorExpression::BuildInterface, properties, missingTargets); } - this->PopulateCompatibleInterfaceProperties(te, properties); + this->PopulateCompatibleInterfaceProperties(gte, properties); this->GenerateInterfaceProperties(te, os, properties); } diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 3aa2b65..a5050ff 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -525,15 +525,15 @@ void getPropertyContents(cmTarget const* tgt, const std::string& prop, } //---------------------------------------------------------------------------- -void getCompatibleInterfaceProperties(cmTarget *target, +void getCompatibleInterfaceProperties(cmGeneratorTarget *target, std::set &ifaceProperties, const std::string& config) { - cmComputeLinkInformation *info = target->GetLinkInformation(config); + cmComputeLinkInformation *info = target->Target->GetLinkInformation(config); if (!info) { - cmMakefile* mf = target->GetMakefile(); + cmMakefile* mf = target->Target->GetMakefile(); std::ostringstream e; e << "Exporting the target \"" << target->GetName() << "\" is not " "allowed since its linker language cannot be determined"; @@ -568,9 +568,10 @@ void getCompatibleInterfaceProperties(cmTarget *target, //---------------------------------------------------------------------------- void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( - cmTarget *target, + cmGeneratorTarget *gtarget, ImportPropertyMap &properties) { + cmTarget *target = gtarget->Target; this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_BOOL", target, properties); this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_STRING", @@ -591,7 +592,7 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( if (target->GetType() != cmTarget::INTERFACE_LIBRARY) { - getCompatibleInterfaceProperties(target, ifaceProperties, ""); + getCompatibleInterfaceProperties(gtarget, ifaceProperties, ""); std::vector configNames; target->GetMakefile()->GetConfigurations(configNames); @@ -599,7 +600,7 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( for (std::vector::const_iterator ci = configNames.begin(); ci != configNames.end(); ++ci) { - getCompatibleInterfaceProperties(target, ifaceProperties, *ci); + getCompatibleInterfaceProperties(gtarget, ifaceProperties, *ci); } } diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index 2f33200..4e54740 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -132,7 +132,7 @@ protected: std::vector &missingTargets); void PopulateInterfaceProperty(const std::string& propName, cmTarget *target, ImportPropertyMap &properties); - void PopulateCompatibleInterfaceProperties(cmTarget *target, + void PopulateCompatibleInterfaceProperties(cmGeneratorTarget *target, ImportPropertyMap &properties); void GenerateInterfaceProperties(cmTarget const* target, std::ostream& os, const ImportPropertyMap &properties); diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 1d75f43..23015e9 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -193,7 +193,11 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE", te, properties); - this->PopulateCompatibleInterfaceProperties(te, properties); + cmGeneratorTarget *gtgt = te->GetMakefile()->GetLocalGenerator() + ->GetGlobalGenerator() + ->GetGeneratorTarget(te); + + this->PopulateCompatibleInterfaceProperties(gtgt, properties); this->GenerateInterfaceProperties(te, os, properties); } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4af3f7ef11fd9118f259c5d9b05747c964ef620b commit 4af3f7ef11fd9118f259c5d9b05747c964ef620b Author: Stephen Kelly AuthorDate: Mon Jul 27 22:33:34 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:03:42 2015 +0200 cmGeneratorTarget: Move IsLinkInterfaceDependent* from cmTarget. diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index c0485db..c1641cc 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1128,6 +1128,9 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode } } + cmGeneratorTarget* gtgt = + context->Makefile->GetGlobalGenerator()->GetGeneratorTarget(target); + if (!prop) { if (target->IsImported() @@ -1135,16 +1138,16 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { return linkedTargetsContent; } - if (target->IsLinkInterfaceDependentBoolProperty(propertyName, - context->Config)) + if (gtgt->IsLinkInterfaceDependentBoolProperty(propertyName, + context->Config)) { context->HadContextSensitiveCondition = true; return target->GetLinkInterfaceDependentBoolProperty( propertyName, context->Config) ? "1" : "0"; } - if (target->IsLinkInterfaceDependentStringProperty(propertyName, - context->Config)) + if (gtgt->IsLinkInterfaceDependentStringProperty(propertyName, + context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = @@ -1153,8 +1156,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode context->Config); return propContent ? propContent : ""; } - if (target->IsLinkInterfaceDependentNumberMinProperty(propertyName, - context->Config)) + if (gtgt->IsLinkInterfaceDependentNumberMinProperty(propertyName, + context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = @@ -1163,8 +1166,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode context->Config); return propContent ? propContent : ""; } - if (target->IsLinkInterfaceDependentNumberMaxProperty(propertyName, - context->Config)) + if (gtgt->IsLinkInterfaceDependentNumberMaxProperty(propertyName, + context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = @@ -1180,8 +1183,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode if (!target->IsImported() && dagCheckerParent && !dagCheckerParent->EvaluatingLinkLibraries()) { - if (target->IsLinkInterfaceDependentNumberMinProperty(propertyName, - context->Config)) + if (gtgt->IsLinkInterfaceDependentNumberMinProperty(propertyName, + context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = @@ -1190,8 +1193,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode context->Config); return propContent ? propContent : ""; } - if (target->IsLinkInterfaceDependentNumberMaxProperty(propertyName, - context->Config)) + if (gtgt->IsLinkInterfaceDependentNumberMaxProperty(propertyName, + context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 95f6aaa..3dbeff2 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1436,3 +1436,84 @@ void cmGeneratorTarget::ConstructSourceFileFlags() const } } } + +//---------------------------------------------------------------------------- +const cmGeneratorTarget::CompatibleInterfacesBase& +cmGeneratorTarget::GetCompatibleInterfaces(std::string const& config) const +{ + cmGeneratorTarget::CompatibleInterfaces& compat = + this->CompatibleInterfacesMap[config]; + if(!compat.Done) + { + compat.Done = true; + compat.PropsBool.insert("POSITION_INDEPENDENT_CODE"); + compat.PropsString.insert("AUTOUIC_OPTIONS"); + std::vector const& deps = + this->Target->GetLinkImplementationClosure(config); + for(std::vector::const_iterator li = deps.begin(); + li != deps.end(); ++li) + { +#define CM_READ_COMPATIBLE_INTERFACE(X, x) \ + if(const char* prop = (*li)->GetProperty("COMPATIBLE_INTERFACE_" #X)) \ + { \ + std::vector props; \ + cmSystemTools::ExpandListArgument(prop, props); \ + compat.Props##x.insert(props.begin(), props.end()); \ + } + CM_READ_COMPATIBLE_INTERFACE(BOOL, Bool) + CM_READ_COMPATIBLE_INTERFACE(STRING, String) + CM_READ_COMPATIBLE_INTERFACE(NUMBER_MIN, NumberMin) + CM_READ_COMPATIBLE_INTERFACE(NUMBER_MAX, NumberMax) +#undef CM_READ_COMPATIBLE_INTERFACE + } + } + return compat; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsLinkInterfaceDependentBoolProperty( + const std::string &p, const std::string& config) const +{ + if (this->Target->GetType() == cmTarget::OBJECT_LIBRARY + || this->Target->GetType() == cmTarget::INTERFACE_LIBRARY) + { + return false; + } + return this->GetCompatibleInterfaces(config).PropsBool.count(p) > 0; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsLinkInterfaceDependentStringProperty( + const std::string &p, const std::string& config) const +{ + if (this->Target->GetType() == cmTarget::OBJECT_LIBRARY + || this->Target->GetType() == cmTarget::INTERFACE_LIBRARY) + { + return false; + } + return this->GetCompatibleInterfaces(config).PropsString.count(p) > 0; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMinProperty( + const std::string &p, const std::string& config) const +{ + if (this->Target->GetType() == cmTarget::OBJECT_LIBRARY + || this->Target->GetType() == cmTarget::INTERFACE_LIBRARY) + { + return false; + } + return this->GetCompatibleInterfaces(config).PropsNumberMin.count(p) > 0; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty( + const std::string &p, const std::string& config) const +{ + if (this->Target->GetType() == cmTarget::OBJECT_LIBRARY + || this->Target->GetType() == cmTarget::INTERFACE_LIBRARY) + { + return false; + } + return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0; +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 3e43711..3b32bf5 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -82,6 +82,15 @@ public: bool GetFeatureAsBool(const std::string& feature, const std::string& config) const; + bool IsLinkInterfaceDependentBoolProperty(const std::string &p, + const std::string& config) const; + bool IsLinkInterfaceDependentStringProperty(const std::string &p, + const std::string& config) const; + bool IsLinkInterfaceDependentNumberMinProperty(const std::string &p, + const std::string& config) const; + bool IsLinkInterfaceDependentNumberMaxProperty(const std::string &p, + const std::string& config) const; + /** Get the full path to the target according to the settings in its makefile and the configuration type. */ std::string GetFullPath(const std::string& config="", bool implib = false, @@ -187,6 +196,23 @@ private: mutable bool SourceFileFlagsConstructed; mutable std::map SourceFlagsMap; + struct CompatibleInterfacesBase + { + std::set PropsBool; + std::set PropsString; + std::set PropsNumberMax; + std::set PropsNumberMin; + }; + CompatibleInterfacesBase const& + GetCompatibleInterfaces(std::string const& config) const; + + struct CompatibleInterfaces: public CompatibleInterfacesBase + { + CompatibleInterfaces(): Done(false) {} + bool Done; + }; + mutable std::map CompatibleInterfacesMap; + cmGeneratorTarget(cmGeneratorTarget const&); void operator=(cmGeneratorTarget const&); }; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 3074f9b..9c7e46a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -170,13 +170,6 @@ public: }; std::map LinkImplClosureMap; - struct CompatibleInterfaces: public cmTarget::CompatibleInterfaces - { - CompatibleInterfaces(): Done(false) {} - bool Done; - }; - std::map CompatibleInterfacesMap; - typedef std::map > SourceFilesMapType; SourceFilesMapType SourceFilesMap; @@ -4991,54 +4984,6 @@ const char * cmTarget::GetLinkInterfaceDependentNumberMaxProperty( } //---------------------------------------------------------------------------- -bool cmTarget::IsLinkInterfaceDependentBoolProperty(const std::string &p, - const std::string& config) const -{ - if (this->TargetTypeValue == OBJECT_LIBRARY - || this->TargetTypeValue == INTERFACE_LIBRARY) - { - return false; - } - return this->GetCompatibleInterfaces(config).PropsBool.count(p) > 0; -} - -//---------------------------------------------------------------------------- -bool cmTarget::IsLinkInterfaceDependentStringProperty(const std::string &p, - const std::string& config) const -{ - if (this->TargetTypeValue == OBJECT_LIBRARY - || this->TargetTypeValue == INTERFACE_LIBRARY) - { - return false; - } - return this->GetCompatibleInterfaces(config).PropsString.count(p) > 0; -} - -//---------------------------------------------------------------------------- -bool cmTarget::IsLinkInterfaceDependentNumberMinProperty(const std::string &p, - const std::string& config) const -{ - if (this->TargetTypeValue == OBJECT_LIBRARY - || this->TargetTypeValue == INTERFACE_LIBRARY) - { - return false; - } - return this->GetCompatibleInterfaces(config).PropsNumberMin.count(p) > 0; -} - -//---------------------------------------------------------------------------- -bool cmTarget::IsLinkInterfaceDependentNumberMaxProperty(const std::string &p, - const std::string& config) const -{ - if (this->TargetTypeValue == OBJECT_LIBRARY - || this->TargetTypeValue == INTERFACE_LIBRARY) - { - return false; - } - return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0; -} - -//---------------------------------------------------------------------------- void cmTarget::GetObjectLibrariesCMP0026(std::vector& objlibs) const { @@ -5725,39 +5670,6 @@ cmTarget::GetLinkImplementationClosure(const std::string& config) const } //---------------------------------------------------------------------------- -cmTarget::CompatibleInterfaces const& -cmTarget::GetCompatibleInterfaces(std::string const& config) const -{ - cmTargetInternals::CompatibleInterfaces& compat = - this->Internal->CompatibleInterfacesMap[config]; - if(!compat.Done) - { - compat.Done = true; - compat.PropsBool.insert("POSITION_INDEPENDENT_CODE"); - compat.PropsString.insert("AUTOUIC_OPTIONS"); - std::vector const& deps = - this->GetLinkImplementationClosure(config); - for(std::vector::const_iterator li = deps.begin(); - li != deps.end(); ++li) - { -#define CM_READ_COMPATIBLE_INTERFACE(X, x) \ - if(const char* prop = (*li)->GetProperty("COMPATIBLE_INTERFACE_" #X)) \ - { \ - std::vector props; \ - cmSystemTools::ExpandListArgument(prop, props); \ - compat.Props##x.insert(props.begin(), props.end()); \ - } - CM_READ_COMPATIBLE_INTERFACE(BOOL, Bool) - CM_READ_COMPATIBLE_INTERFACE(STRING, String) - CM_READ_COMPATIBLE_INTERFACE(NUMBER_MIN, NumberMin) - CM_READ_COMPATIBLE_INTERFACE(NUMBER_MAX, NumberMax) -#undef CM_READ_COMPATIBLE_INTERFACE - } - } - return compat; -} - -//---------------------------------------------------------------------------- void cmTargetInternals::ComputeLinkInterfaceLibraries( cmTarget const* thisTarget, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index d5374a6..df8cdc1 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -305,16 +305,6 @@ public: std::vector const& GetLinkImplementationClosure(const std::string& config) const; - struct CompatibleInterfaces - { - std::set PropsBool; - std::set PropsString; - std::set PropsNumberMax; - std::set PropsNumberMin; - }; - CompatibleInterfaces const& - GetCompatibleInterfaces(std::string const& config) const; - /** The link implementation specifies the direct library dependencies needed by the object files of the target. */ struct LinkImplementationLibraries @@ -575,15 +565,6 @@ public: const std::string& config) const; bool IsNullImpliedByLinkLibraries(const std::string &p) const; - bool IsLinkInterfaceDependentBoolProperty(const std::string &p, - const std::string& config) const; - bool IsLinkInterfaceDependentStringProperty(const std::string &p, - const std::string& config) const; - bool IsLinkInterfaceDependentNumberMinProperty(const std::string &p, - const std::string& config) const; - bool IsLinkInterfaceDependentNumberMaxProperty(const std::string &p, - const std::string& config) const; - bool GetLinkInterfaceDependentBoolProperty(const std::string &p, const std::string& config) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=29637d6c119ed98b28099023e3203ade09b6c6c9 commit 29637d6c119ed98b28099023e3203ade09b6c6c9 Author: Stephen Kelly AuthorDate: Mon Dec 9 18:05:25 2013 +0100 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:03:42 2015 +0200 cmGeneratorTarget: Move GetAutoUicOptions from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index e17df9e..95f6aaa 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -743,6 +743,32 @@ cmGeneratorTarget::UseObjectLibraries(std::vector& objs, } //---------------------------------------------------------------------------- +void cmGeneratorTarget::GetAutoUicOptions(std::vector &result, + const std::string& config) const +{ + const char *prop + = this->Target-> + GetLinkInterfaceDependentStringProperty("AUTOUIC_OPTIONS", + config); + if (!prop) + { + return; + } + cmGeneratorExpression ge; + + cmGeneratorExpressionDAGChecker dagChecker( + this->GetName(), + "AUTOUIC_OPTIONS", 0, 0); + cmSystemTools::ExpandListArgument(ge.Parse(prop) + ->Evaluate(this->Makefile, + config, + false, + this->Target, + &dagChecker), + result); +} + +//---------------------------------------------------------------------------- class cmTargetTraceDependencies { public: diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 8e5c2ab..3e43711 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -156,6 +156,9 @@ public: SourceFileType Type; const char* MacFolder; // location inside Mac content folders }; + void GetAutoUicOptions(std::vector &result, + const std::string& config) const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; @@ -176,7 +179,6 @@ private: struct SourceEntry { std::vector Depends; }; typedef std::map SourceEntriesType; SourceEntriesType SourceEntries; - mutable std::map Objects; std::set ExplicitObjectName; mutable std::map > SystemIncludesCache; diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 1322dea..1e05c34 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -878,8 +878,11 @@ void cmQtAutoGenerators::MergeUicOptions(std::vector &opts, static void GetUicOpts(cmTarget const* target, const std::string& config, std::string &optString) { + cmGeneratorTarget *gtgt = target->GetMakefile()->GetLocalGenerator() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); std::vector opts; - target->GetAutoUicOptions(opts, config); + gtgt->GetAutoUicOptions(opts, config); optString = cmJoin(opts, ";"); } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 54f9cf0..3074f9b 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2236,31 +2236,6 @@ static void processCompileOptions(cmTarget const* tgt, } //---------------------------------------------------------------------------- -void cmTarget::GetAutoUicOptions(std::vector &result, - const std::string& config) const -{ - const char *prop - = this->GetLinkInterfaceDependentStringProperty("AUTOUIC_OPTIONS", - config); - if (!prop) - { - return; - } - cmGeneratorExpression ge; - - cmGeneratorExpressionDAGChecker dagChecker( - this->GetName(), - "AUTOUIC_OPTIONS", 0, 0); - cmSystemTools::ExpandListArgument(ge.Parse(prop) - ->Evaluate(this->Makefile, - config, - false, - this, - &dagChecker), - result); -} - -//---------------------------------------------------------------------------- void cmTarget::GetCompileOptions(std::vector &result, const std::string& config, const std::string& language) const diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 389f9cd..d5374a6 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -571,8 +571,6 @@ public: void GetCompileOptions(std::vector &result, const std::string& config, const std::string& language) const; - void GetAutoUicOptions(std::vector &result, - const std::string& config) const; void GetCompileFeatures(std::vector &features, const std::string& config) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3975e01b69b97fdcb887bb3607481a616e678a9a commit 3975e01b69b97fdcb887bb3607481a616e678a9a Author: Stephen Kelly AuthorDate: Tue Oct 9 00:37:37 2012 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:03:42 2015 +0200 cmGeneratorTarget: Move GetSOName from cmTarget.. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index e63b44f..5aaa266 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -756,15 +756,16 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, return; } + cmGeneratorTarget *gtgt = tgt->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(tgt); + // Get a full path to the dependent shared library. // Add it to the runtime path computation so that the target being // linked will be able to find it. std::string lib; if(tgt) { - cmGeneratorTarget *gtgt = tgt->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(tgt); lib = gtgt->GetFullPath(this->Config, this->UseImportLibrary); this->AddLibraryRuntimeInfo(lib, tgt); } @@ -792,7 +793,7 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, { if(tgt) { - std::string soName = tgt->GetSOName(this->Config); + std::string soName = gtgt->GetSOName(this->Config); const char* soname = soName.empty()? 0 : soName.c_str(); order->AddRuntimeLibrary(lib, soname); } @@ -1804,7 +1805,10 @@ cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath, // Try to get the soname of the library. Only files with this name // could possibly conflict. - std::string soName = target->GetSOName(this->Config); + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); + std::string soName = gtgt->GetSOName(this->Config); const char* soname = soName.empty()? 0 : soName.c_str(); // Include this library in the runtime path ordering. diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index a33cd59..3aa2b65 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -895,7 +895,7 @@ cmExportFileGenerator value = this->InstallNameDir(target->Target, config); } prop = "IMPORTED_SONAME"; - value += target->Target->GetSOName(config); + value += target->GetSOName(config); } else { diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index f3527ff..c0485db 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1584,7 +1584,7 @@ struct TargetFilesystemArtifactResultCreator } std::string result = target->Target->GetDirectory(context->Config); result += "/"; - result += target->Target->GetSOName(context->Config); + result += target->GetSOName(context->Config); return result; } }; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index bd57b3d..e17df9e 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -650,6 +650,49 @@ void cmGeneratorTarget::GetSourceFiles(std::vector &files, } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetSOName(const std::string& config) const +{ + if(this->Target->IsImported()) + { + // Lookup the imported soname. + if(cmTarget::ImportInfo const* info = this->Target->GetImportInfo(config)) + { + if(info->NoSOName) + { + // The imported library has no builtin soname so the name + // searched at runtime will be just the filename. + return cmSystemTools::GetFilenameName(info->Location); + } + else + { + // Use the soname given if any. + if(info->SOName.find("@rpath/") == 0) + { + return info->SOName.substr(6); + } + return info->SOName; + } + } + else + { + return ""; + } + } + else + { + // Compute the soname that will be built. + std::string name; + std::string soName; + std::string realName; + std::string impName; + std::string pdbName; + this->Target->GetLibraryNames(name, soName, realName, + impName, pdbName, config); + return soName; + } +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetModuleDefinitionFile(const std::string& config) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index a584c71..8e5c2ab 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -90,6 +90,9 @@ public: bool realname) const; std::string NormalGetRealName(const std::string& config) const; + /** Get the soname of the target. Allowed only for a shared library. */ + std::string GetSOName(const std::string& config) const; + cmTarget* Target; cmMakefile* Makefile; cmLocalGenerator* LocalGenerator; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 7dea107..8cb59f8 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2345,7 +2345,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, install_name += install_name_dir; install_name += "/"; } - install_name += target.GetSOName(configName); + install_name += gtgt->GetSOName(configName); if((realName != soName) || install_name_dir.empty()) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index cf33791..54f9cf0 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -69,21 +69,6 @@ struct cmTarget::OutputInfo }; //---------------------------------------------------------------------------- -struct cmTarget::ImportInfo -{ - ImportInfo(): NoSOName(false), Multiplicity(0) {} - bool NoSOName; - int Multiplicity; - std::string Location; - std::string SOName; - std::string ImportLibrary; - std::string Languages; - std::string Libraries; - std::string LibrariesProp; - std::string SharedDeps; -}; - -//---------------------------------------------------------------------------- struct cmTarget::CompileInfo { std::string CompilePdbDir; @@ -3602,48 +3587,6 @@ bool cmTarget::HasSOName(const std::string& config) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetSOName(const std::string& config) const -{ - if(this->IsImported()) - { - // Lookup the imported soname. - if(cmTarget::ImportInfo const* info = this->GetImportInfo(config)) - { - if(info->NoSOName) - { - // The imported library has no builtin soname so the name - // searched at runtime will be just the filename. - return cmSystemTools::GetFilenameName(info->Location); - } - else - { - // Use the soname given if any. - if(info->SOName.find("@rpath/") == 0) - { - return info->SOName.substr(6); - } - return info->SOName; - } - } - else - { - return ""; - } - } - else - { - // Compute the soname that will be built. - std::string name; - std::string soName; - std::string realName; - std::string impName; - std::string pdbName; - this->GetLibraryNames(name, soName, realName, impName, pdbName, config); - return soName; - } -} - -//---------------------------------------------------------------------------- bool cmTarget::HasMacOSXRpathInstallNameDir(const std::string& config) const { bool install_name_is_rpath = false; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index f567d50..389f9cd 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -411,9 +411,6 @@ public: /** Whether this library has soname enabled and platform supports it. */ bool HasSOName(const std::string& config) const; - /** Get the soname of the target. Allowed only for a shared library. */ - std::string GetSOName(const std::string& config) const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; @@ -768,7 +765,20 @@ private: std::string& out) const; // Cache import information from properties for each configuration. - struct ImportInfo; + struct ImportInfo + { + ImportInfo(): NoSOName(false), Multiplicity(0) {} + bool NoSOName; + int Multiplicity; + std::string Location; + std::string SOName; + std::string ImportLibrary; + std::string Languages; + std::string Libraries; + std::string LibrariesProp; + std::string SharedDeps; + }; + ImportInfo const* GetImportInfo(const std::string& config) const; void ComputeImportInfo(std::string const& desired_config, ImportInfo& info) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8c746162c33a1c207bf30a0261d35c8c7204898e commit 8c746162c33a1c207bf30a0261d35c8c7204898e Author: Stephen Kelly AuthorDate: Sat Aug 1 07:03:21 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:03:21 2015 +0200 cmGlobalNinjaGenerator: Simplify usage of API. diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index d24cce8..5bdd35f 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -911,9 +911,7 @@ cmGlobalNinjaGenerator case cmTarget::STATIC_LIBRARY: case cmTarget::MODULE_LIBRARY: { - cmGeneratorTarget *gtgt = target->GetMakefile()->GetLocalGenerator() - ->GetGlobalGenerator() - ->GetGeneratorTarget(target); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(target); outputs.push_back(ng->ConvertToNinjaPath( gtgt->GetFullPath(configName, false, realname))); break; ----------------------------------------------------------------------- Summary of changes: Source/cmCommonTargetGenerator.cxx | 5 +- Source/cmComputeLinkDepends.cxx | 17 +- Source/cmComputeLinkDepends.h | 6 +- Source/cmComputeLinkInformation.cxx | 84 +- Source/cmComputeLinkInformation.h | 6 +- Source/cmExportBuildFileGenerator.cxx | 10 +- Source/cmExportBuildFileGenerator.h | 3 +- Source/cmExportFileGenerator.cxx | 17 +- Source/cmExportFileGenerator.h | 4 +- Source/cmExportInstallFileGenerator.cxx | 10 +- Source/cmExportInstallFileGenerator.h | 3 +- Source/cmExportTryCompileFileGenerator.cxx | 4 +- Source/cmExportTryCompileFileGenerator.h | 2 +- Source/cmGeneratorExpressionNode.cxx | 47 +- Source/cmGeneratorTarget.cxx | 2957 ++++++++++++++++++++---- Source/cmGeneratorTarget.h | 196 +- Source/cmGlobalNinjaGenerator.cxx | 4 +- Source/cmGlobalUnixMakefileGenerator3.cxx | 6 +- Source/cmGlobalXCodeGenerator.cxx | 27 +- Source/cmInstallTargetGenerator.cxx | 40 +- Source/cmLocalGenerator.cxx | 8 +- Source/cmLocalUnixMakefileGenerator3.cxx | 3 +- Source/cmLocalVisualStudio6Generator.cxx | 37 +- Source/cmLocalVisualStudio7Generator.cxx | 27 +- Source/cmMakefileExecutableTargetGenerator.cxx | 10 +- Source/cmMakefileLibraryTargetGenerator.cxx | 24 +- Source/cmMakefileTargetGenerator.cxx | 17 +- Source/cmMakefileTargetGenerator.h | 1 + Source/cmNinjaNormalTargetGenerator.cxx | 14 +- Source/cmNinjaTargetGenerator.cxx | 9 +- Source/cmOSXBundleGenerator.cxx | 14 +- Source/cmQtAutoGenerators.cxx | 16 +- Source/cmTarget.cxx | 2095 +---------------- Source/cmTarget.h | 183 +- Source/cmVisualStudio10TargetGenerator.cxx | 54 +- 35 files changed, 3029 insertions(+), 2931 deletions(-) hooks/post-receive -- CMake From steveire at gmail.com Sat Aug 1 01:54:17 2015 From: steveire at gmail.com (Stephen Kelly) Date: Sat, 1 Aug 2015 01:54:17 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1657-g1aa0000 Message-ID: <20150801055417.ED080B0F20@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 1aa00000ee9cc3514467d66832d127aa955a99fb (commit) via adce5f39a42fa780c07e23c2a89d6ec47f66331c (commit) via 8572cce92cb678eba225161478fbb8dff3bc15ee (commit) via f95a1e6ebae47a3d2897d82f4485d1faf94bcb09 (commit) via 5fb814d7f968e10a6a02e2a78b7dccb7c34b026b (commit) via af0de01c6b3395fb1dba5d2ee0a94c19a9b464e9 (commit) via 6ae8b30bf4127011284a66541ed2116fcb45f007 (commit) via a5fc17b5098ee27fd7ae457ca6c5743bacc384a7 (commit) via 0a01e6c6e7bd428ca0ec99a00924b5b498c6e637 (commit) via f0005bb484bc2b85a169ef7816e33d8e2f16e109 (commit) from 383ae666d2bfad26165c87c9edfebea52c82119e (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1aa00000ee9cc3514467d66832d127aa955a99fb commit 1aa00000ee9cc3514467d66832d127aa955a99fb Merge: 383ae66 adce5f3 Author: Stephen Kelly AuthorDate: Sat Aug 1 01:54:15 2015 -0400 Commit: CMake Topic Stage CommitDate: Sat Aug 1 01:54:15 2015 -0400 Merge topic 'cmState-policies' into next adce5f39 cmState: Move PolicyState from cmMakefile. 8572cce9 cmState: Record the end position of each directory. f95a1e6e cmLinkedTree: Add Clear API. 5fb814d7 cmState: Add Type for policy scope. af0de01c cmState: Remove call stack parent tracking. 6ae8b30b cmMakefile: Move policy barriers inside cmState scopes. a5fc17b5 cmMakefile: Re-order policy entries and barriers. 0a01e6c6 cmState: Add Snapshot Type accessor. f0005bb4 Tests: Verify generate-time policy scope behavior. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=adce5f39a42fa780c07e23c2a89d6ec47f66331c commit adce5f39a42fa780c07e23c2a89d6ec47f66331c Author: Stephen Kelly AuthorDate: Sun Jul 26 13:04:09 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:53:35 2015 +0200 cmState: Move PolicyState from cmMakefile. Implement lexical scope checking in terms of the state stack instead of barriers. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 9fb3d06..a0a36ec 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -192,9 +192,6 @@ cmMakefile::cmMakefile(cmLocalGenerator* localGenerator) this->StateSnapshot = this->StateSnapshot.GetState() ->CreatePolicyScopeSnapshot(this->StateSnapshot); - // Protect the directory-level policies. - this->PushPolicyBarrier(); - // Enter a policy level for this directory. this->PushPolicy(); @@ -239,11 +236,6 @@ cmMakefile::~cmMakefile() cmDeleteAll(this->FinalPassCommands); cmDeleteAll(this->FunctionBlockers); this->FunctionBlockers.clear(); - if (this->PolicyStack.size() != 1) - { - cmSystemTools::Error("Internal CMake Error, Policy Stack has not been" - " popped properly"); - } } //---------------------------------------------------------------------------- @@ -479,7 +471,6 @@ cmMakefile::IncludeScope::IncludeScope(cmMakefile* mf, this->Makefile->ContextStack.back()->Name, this->Makefile->ContextStack.back()->Line, filenametoread); - this->Makefile->PushPolicyBarrier(); if(!this->NoPolicyScope) { // Check CMP0011 to determine the policy scope type. @@ -519,7 +510,8 @@ cmMakefile::IncludeScope::~IncludeScope() // one we pushed above. If the entry is empty, then the included // script did not set any policies that might affect the includer so // we do not need to enforce the policy. - if(this->CheckCMP0011 && this->Makefile->PolicyStack.back().IsEmpty()) + if(this->CheckCMP0011 + && !this->Makefile->StateSnapshot.HasDefinedPolicyCMP0011()) { this->CheckCMP0011 = false; } @@ -535,9 +527,6 @@ cmMakefile::IncludeScope::~IncludeScope() } } this->Makefile->PopPolicyBarrier(this->ReportError); - this->Makefile->StateSnapshot = - this->Makefile->GetState()->Pop(this->Makefile->StateSnapshot); - assert(this->Makefile->StateSnapshot.IsValid()); this->Makefile->PopFunctionBlockerBarrier(this->ReportError); } @@ -646,19 +635,12 @@ public: this->Makefile->StateSnapshot, name, line, filenametoread); assert(this->Makefile->StateSnapshot.IsValid()); - this->Makefile->PushPolicyBarrier(); - this->Makefile->PushFunctionBlockerBarrier(); } ~ListFileScope() { this->Makefile->PopPolicyBarrier(this->ReportError); - - this->Makefile->StateSnapshot = - this->Makefile->GetState()->Pop(this->Makefile->StateSnapshot); - assert(this->Makefile->StateSnapshot.IsValid()); - this->Makefile->PopFunctionBlockerBarrier(this->ReportError); } @@ -1630,7 +1612,6 @@ void cmMakefile::PushFunctionScope(std::string const& fileName, this->ContextStack.back()->Name, this->ContextStack.back()->Line, fileName); assert(this->StateSnapshot.IsValid()); - this->PushPolicyBarrier(); this->Internal->PushDefinitions(); @@ -1650,8 +1631,6 @@ void cmMakefile::PopFunctionScope(bool reportError) this->PopPolicy(); this->PopPolicyBarrier(reportError); - this->StateSnapshot = this->GetState()->Pop(this->StateSnapshot); - assert(this->StateSnapshot.IsValid()); this->PopFunctionBlockerBarrier(reportError); @@ -1675,7 +1654,6 @@ void cmMakefile::PushMacroScope(std::string const& fileName, this->ContextStack.back()->Name, this->ContextStack.back()->Line, fileName); assert(this->StateSnapshot.IsValid()); - this->PushPolicyBarrier(); this->PushFunctionBlockerBarrier(); @@ -1687,9 +1665,6 @@ void cmMakefile::PopMacroScope(bool reportError) this->PopPolicy(); this->PopPolicyBarrier(reportError); - this->StateSnapshot = this->GetState()->Pop(this->StateSnapshot); - assert(this->StateSnapshot.IsValid()); - this->PopFunctionBlockerBarrier(reportError); } @@ -1710,7 +1685,6 @@ public: this->Makefile->StateSnapshot.SetListFile(currentStart); this->Makefile->StateSnapshot = this->Makefile->StateSnapshot.GetState() ->CreatePolicyScopeSnapshot(this->Makefile->StateSnapshot); - this->Makefile->PushPolicyBarrier(); this->Makefile->PushFunctionBlockerBarrier(); this->GG = mf->GetGlobalGenerator(); @@ -1727,8 +1701,6 @@ public: { this->Makefile->PopFunctionBlockerBarrier(this->ReportError); this->Makefile->PopPolicyBarrier(this->ReportError); - this->Makefile->StateSnapshot = this->Makefile->StateSnapshot.GetState() - ->Pop(this->Makefile->StateSnapshot); #if defined(CMAKE_BUILD_WITH_CMAKE) this->GG->GetFileLockPool().PopFileScope(); #endif @@ -4759,30 +4731,7 @@ const char* cmMakefile::GetDefineFlagsCMP0059() const cmPolicies::PolicyStatus cmMakefile::GetPolicyStatus(cmPolicies::PolicyID id) const { - cmPolicies::PolicyStatus status = cmPolicies::GetPolicyStatus(id); - - if(status == cmPolicies::REQUIRED_ALWAYS || - status == cmPolicies::REQUIRED_IF_USED) - { - return status; - } - - cmLocalGenerator* lg = this->LocalGenerator; - while(lg) - { - cmMakefile const* mf = lg->GetMakefile(); - for(PolicyStackType::const_reverse_iterator psi = - mf->PolicyStack.rbegin(); psi != mf->PolicyStack.rend(); ++psi) - { - if(psi->IsDefined(id)) - { - status = psi->Get(id); - return status; - } - } - lg = lg->GetParent(); - } - return status; + return this->StateSnapshot.GetPolicy(id); } //---------------------------------------------------------------------------- @@ -4831,15 +4780,7 @@ bool cmMakefile::SetPolicy(cmPolicies::PolicyID id, return false; } - // Update the policy stack from the top to the top-most strong entry. - bool previous_was_weak = true; - for(PolicyStackType::reverse_iterator psi = this->PolicyStack.rbegin(); - previous_was_weak && psi != this->PolicyStack.rend(); ++psi) - { - psi->Set(id, status); - previous_was_weak = psi->Weak; - } - + this->StateSnapshot.SetPolicy(id, status); return true; } @@ -4850,7 +4791,6 @@ cmMakefile::PolicyPushPop::PolicyPushPop(cmMakefile* m, bool weak, { this->Makefile->StateSnapshot = this->Makefile->StateSnapshot.GetState() ->CreatePolicyScopeSnapshot(this->Makefile->StateSnapshot); - this->Makefile->PushPolicyBarrier(); this->Makefile->PushPolicy(weak, pm); } @@ -4859,25 +4799,18 @@ cmMakefile::PolicyPushPop::~PolicyPushPop() { this->Makefile->PopPolicy(); this->Makefile->PopPolicyBarrier(this->ReportError); - this->Makefile->StateSnapshot = this->Makefile->StateSnapshot.GetState() - ->Pop(this->Makefile->StateSnapshot); } //---------------------------------------------------------------------------- void cmMakefile::PushPolicy(bool weak, cmPolicies::PolicyMap const& pm) { - // Allocate a new stack entry. - this->PolicyStack.push_back(PolicyStackEntry(pm, weak)); + this->StateSnapshot.PushPolicy(pm, weak); } //---------------------------------------------------------------------------- void cmMakefile::PopPolicy() { - if(this->PolicyStack.size() > this->PolicyBarriers.back()) - { - this->PolicyStack.pop_back(); - } - else + if (!this->StateSnapshot.PopPolicy()) { this->IssueMessage(cmake::FATAL_ERROR, "cmake_policy POP without matching PUSH"); @@ -4885,17 +4818,9 @@ void cmMakefile::PopPolicy() } //---------------------------------------------------------------------------- -void cmMakefile::PushPolicyBarrier() -{ - this->PolicyBarriers.push_back(this->PolicyStack.size()); -} - -//---------------------------------------------------------------------------- void cmMakefile::PopPolicyBarrier(bool reportError) { - // Remove any extra entries pushed on the barrier. - PolicyStackType::size_type barrier = this->PolicyBarriers.back(); - while(this->PolicyStack.size() > barrier) + while (!this->StateSnapshot.CanPopPolicyScope()) { if(reportError) { @@ -4906,8 +4831,8 @@ void cmMakefile::PopPolicyBarrier(bool reportError) this->PopPolicy(); } - // Remove the barrier. - this->PolicyBarriers.pop_back(); + this->StateSnapshot = this->GetState()->Pop(this->StateSnapshot); + assert(this->StateSnapshot.IsValid()); } //---------------------------------------------------------------------------- diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 1e5c301..173914e 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -909,7 +909,6 @@ private: void PushPolicy(bool weak = false, cmPolicies::PolicyMap const& pm = cmPolicies::PolicyMap()); void PopPolicy(); - void PushPolicyBarrier(); void PopPolicyBarrier(bool reportError = true); friend class cmCMakePolicyCommand; class IncludeScope; @@ -919,18 +918,6 @@ private: class BuildsystemFileScope; friend class BuildsystemFileScope; - // stack of policy settings - struct PolicyStackEntry: public cmPolicies::PolicyMap - { - typedef cmPolicies::PolicyMap derived; - PolicyStackEntry(bool w = false): derived(), Weak(w) {} - PolicyStackEntry(derived const& d, bool w = false): derived(d), Weak(w) {} - PolicyStackEntry(PolicyStackEntry const& r): derived(r), Weak(r.Weak) {} - bool Weak; - }; - typedef std::vector PolicyStackType; - PolicyStackType PolicyStack; - std::vector PolicyBarriers; // CMP0053 == old cmake::MessageType ExpandVariablesInStringOld( diff --git a/Source/cmState.cxx b/Source/cmState.cxx index ea8d147..492a4d0 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -21,6 +21,9 @@ struct cmState::SnapshotDataType { cmState::PositionType DirectoryParent; + cmLinkedTree::iterator Policies; + cmLinkedTree::iterator PolicyRoot; + cmLinkedTree::iterator PolicyScope; cmState::SnapshotType SnapshotType; cmLinkedTree::iterator ExecutionListFile; cmLinkedTree::iterator @@ -32,6 +35,15 @@ struct cmState::SnapshotDataType std::vector::size_type CompileOptionsPosition; }; +struct cmState::PolicyStackEntry: public cmPolicies::PolicyMap +{ + typedef cmPolicies::PolicyMap derived; + PolicyStackEntry(bool w = false): derived(), Weak(w) {} + PolicyStackEntry(derived const& d, bool w): derived(d), Weak(w) {} + PolicyStackEntry(PolicyStackEntry const& r): derived(r), Weak(r.Weak) {} + bool Weak; +}; + struct cmState::BuildsystemDirectoryStateType { cmState::PositionType DirectoryEnd; @@ -256,6 +268,13 @@ cmState::Snapshot cmState::Reset() it->DirectoryEnd = pos; } + this->PolicyStack.Clear(); + pos->Policies = this->PolicyStack.Root(); + pos->PolicyRoot = this->PolicyStack.Root(); + pos->PolicyScope = this->PolicyStack.Root(); + assert(pos->Policies.IsValid()); + assert(pos->PolicyRoot.IsValid()); + this->DefineProperty ("RULE_LAUNCH_COMPILE", cmProperty::DIRECTORY, "", "", true); @@ -726,6 +745,11 @@ cmState::Snapshot cmState::CreateBaseSnapshot() pos->CompileDefinitionsPosition = 0; pos->CompileOptionsPosition = 0; pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->Policies = this->PolicyStack.Root(); + pos->PolicyRoot = this->PolicyStack.Root(); + pos->PolicyScope = this->PolicyStack.Root(); + assert(pos->Policies.IsValid()); + assert(pos->PolicyRoot.IsValid()); return cmState::Snapshot(this, pos); } @@ -747,6 +771,11 @@ cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot, this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile); pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->Policies = originSnapshot.Position->Policies; + pos->PolicyRoot = originSnapshot.Position->Policies; + pos->PolicyScope = originSnapshot.Position->Policies; + assert(pos->Policies.IsValid()); + assert(pos->PolicyRoot.IsValid()); return cmState::Snapshot(this, pos); } @@ -764,6 +793,7 @@ cmState::CreateFunctionCallSnapshot(cmState::Snapshot originSnapshot, pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile, fileName); pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->PolicyScope = originSnapshot.Position->Policies; return cmState::Snapshot(this, pos); } @@ -782,6 +812,7 @@ cmState::CreateMacroCallSnapshot(cmState::Snapshot originSnapshot, pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile, fileName); pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->PolicyScope = originSnapshot.Position->Policies; return cmState::Snapshot(this, pos); } @@ -799,6 +830,7 @@ cmState::CreateCallStackSnapshot(cmState::Snapshot originSnapshot, pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile, fileName); pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->PolicyScope = originSnapshot.Position->Policies; return cmState::Snapshot(this, pos); } @@ -816,15 +848,18 @@ cmState::CreateInlineListFileSnapshot(cmState::Snapshot originSnapshot, pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile, fileName); pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->PolicyScope = originSnapshot.Position->Policies; return cmState::Snapshot(this, pos); } -cmState::Snapshot cmState::CreatePolicyScopeSnapshot(cmState::Snapshot originSnapshot) +cmState::Snapshot +cmState::CreatePolicyScopeSnapshot(cmState::Snapshot originSnapshot) { PositionType pos = this->SnapshotData.Extend(originSnapshot.Position, *originSnapshot.Position); pos->SnapshotType = PolicyScopeType; pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->PolicyScope = originSnapshot.Position->Policies; return cmState::Snapshot(this, pos); } @@ -1004,6 +1039,90 @@ cmState::Snapshot cmState::Snapshot::GetCallStackParent() const return snapshot; } +void cmState::Snapshot::PushPolicy(cmPolicies::PolicyMap entry, bool weak) +{ + PositionType pos = this->Position; + pos->Policies = + this->State->PolicyStack.Extend(pos->Policies, + PolicyStackEntry(entry, weak)); +} + +bool cmState::Snapshot::PopPolicy() +{ + PositionType pos = this->Position; + if (pos->Policies == pos->PolicyScope) + { + return false; + } + ++pos->Policies; + return true; +} + +bool cmState::Snapshot::CanPopPolicyScope() +{ + PositionType pos = this->Position; + bool ok = (pos->Policies == pos->PolicyScope); + return ok; +} + +void cmState::Snapshot::SetPolicy(cmPolicies::PolicyID id, + cmPolicies::PolicyStatus status) +{ + // Update the policy stack from the top to the top-most strong entry. + bool previous_was_weak = true; + for(cmLinkedTree::iterator psi = this->Position->Policies; + previous_was_weak && psi != this->Position->PolicyRoot; ++psi) + { + psi->Set(id, status); + previous_was_weak = psi->Weak; + } +} + +cmPolicies::PolicyStatus +cmState::Snapshot::GetPolicy(cmPolicies::PolicyID id) const +{ + cmPolicies::PolicyStatus status = cmPolicies::GetPolicyStatus(id); + + if(status == cmPolicies::REQUIRED_ALWAYS || + status == cmPolicies::REQUIRED_IF_USED) + { + return status; + } + + cmLinkedTree::iterator dir = + this->Position->BuildSystemDirectory; + + while (true) + { + assert(dir.IsValid()); + cmLinkedTree::iterator leaf = + dir->DirectoryEnd->Policies; + cmLinkedTree::iterator root = + dir->DirectoryEnd->PolicyRoot; + for( ; leaf != root; ++leaf) + { + if(leaf->IsDefined(id)) + { + status = leaf->Get(id); + return status; + } + } + cmState::PositionType e = dir->DirectoryEnd; + cmState::PositionType p = e->DirectoryParent; + if (p == this->State->SnapshotData.Root()) + { + break; + } + dir = p->BuildSystemDirectory; + } + return status; +} + +bool cmState::Snapshot::HasDefinedPolicyCMP0011() +{ + return !this->Position->Policies->IsEmpty(); +} + static const std::string cmPropertySentinal = std::string(); template diff --git a/Source/cmState.h b/Source/cmState.h index 63b60ef..07aa2a5 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -17,6 +17,7 @@ #include "cmPropertyMap.h" #include "cmLinkedTree.h" #include "cmAlgorithms.h" +#include "cmPolicies.h" class cmake; class cmCommand; @@ -24,6 +25,7 @@ class cmCommand; class cmState { struct SnapshotDataType; + struct PolicyStackEntry; struct BuildsystemDirectoryStateType; typedef cmLinkedTree::iterator PositionType; friend class Snapshot; @@ -61,6 +63,13 @@ public: void InitializeFromParent(); + void SetPolicy(cmPolicies::PolicyID id, cmPolicies::PolicyStatus status); + cmPolicies::PolicyStatus GetPolicy(cmPolicies::PolicyID id) const; + bool HasDefinedPolicyCMP0011(); + void PushPolicy(cmPolicies::PolicyMap entry, bool weak); + bool PopPolicy(); + bool CanPopPolicyScope(); + cmState* GetState() const; Directory GetDirectory() const; @@ -257,6 +266,7 @@ private: cmLinkedTree ExecutionListFiles; + cmLinkedTree PolicyStack; cmLinkedTree SnapshotData; std::vector SourceDirectoryComponents; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8572cce92cb678eba225161478fbb8dff3bc15ee commit 8572cce92cb678eba225161478fbb8dff3bc15ee Author: Stephen Kelly AuthorDate: Sat Aug 1 07:20:26 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:39:56 2015 +0200 cmState: Record the end position of each directory. At generate time, variables and policies are determined from the end state of the cmMakefile. diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 68f5c18..ea8d147 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -34,6 +34,8 @@ struct cmState::SnapshotDataType struct cmState::BuildsystemDirectoryStateType { + cmState::PositionType DirectoryEnd; + std::string Location; std::string OutputLocation; @@ -239,6 +241,9 @@ cmState::Snapshot cmState::Reset() this->GlobalProperties.clear(); this->PropertyDefinitions.clear(); + PositionType pos = this->SnapshotData.Truncate(); + this->ExecutionListFiles.Truncate(); + { cmLinkedTree::iterator it = this->BuildsystemDirectory.Truncate(); @@ -248,9 +253,8 @@ cmState::Snapshot cmState::Reset() it->CompileDefinitionsBacktraces.clear(); it->CompileOptions.clear(); it->CompileOptionsBacktraces.clear(); + it->DirectoryEnd = pos; } - PositionType pos = this->SnapshotData.Truncate(); - this->ExecutionListFiles.Truncate(); this->DefineProperty ("RULE_LAUNCH_COMPILE", cmProperty::DIRECTORY, @@ -721,6 +725,7 @@ cmState::Snapshot cmState::CreateBaseSnapshot() pos->IncludeDirectoryPosition = 0; pos->CompileDefinitionsPosition = 0; pos->CompileOptionsPosition = 0; + pos->BuildSystemDirectory->DirectoryEnd = pos; return cmState::Snapshot(this, pos); } @@ -741,6 +746,7 @@ cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot, pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile); + pos->BuildSystemDirectory->DirectoryEnd = pos; return cmState::Snapshot(this, pos); } @@ -757,6 +763,7 @@ cmState::CreateFunctionCallSnapshot(cmState::Snapshot originSnapshot, pos->SnapshotType = FunctionCallType; pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile, fileName); + pos->BuildSystemDirectory->DirectoryEnd = pos; return cmState::Snapshot(this, pos); } @@ -774,6 +781,7 @@ cmState::CreateMacroCallSnapshot(cmState::Snapshot originSnapshot, pos->SnapshotType = MacroCallType; pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile, fileName); + pos->BuildSystemDirectory->DirectoryEnd = pos; return cmState::Snapshot(this, pos); } @@ -790,6 +798,7 @@ cmState::CreateCallStackSnapshot(cmState::Snapshot originSnapshot, pos->SnapshotType = CallStackType; pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile, fileName); + pos->BuildSystemDirectory->DirectoryEnd = pos; return cmState::Snapshot(this, pos); } @@ -806,6 +815,7 @@ cmState::CreateInlineListFileSnapshot(cmState::Snapshot originSnapshot, pos->SnapshotType = InlineListFileType; pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile, fileName); + pos->BuildSystemDirectory->DirectoryEnd = pos; return cmState::Snapshot(this, pos); } @@ -814,6 +824,7 @@ cmState::Snapshot cmState::CreatePolicyScopeSnapshot(cmState::Snapshot originSna PositionType pos = this->SnapshotData.Extend(originSnapshot.Position, *originSnapshot.Position); pos->SnapshotType = PolicyScopeType; + pos->BuildSystemDirectory->DirectoryEnd = pos; return cmState::Snapshot(this, pos); } @@ -828,6 +839,7 @@ cmState::Snapshot cmState::Pop(cmState::Snapshot originSnapshot) prevPos->BuildSystemDirectory->CompileDefinitions.size(); prevPos->CompileOptionsPosition = prevPos->BuildSystemDirectory->CompileOptions.size(); + prevPos->BuildSystemDirectory->DirectoryEnd = prevPos; return Snapshot(this, prevPos); } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f95a1e6ebae47a3d2897d82f4485d1faf94bcb09 commit f95a1e6ebae47a3d2897d82f4485d1faf94bcb09 Author: Stephen Kelly AuthorDate: Sun Jun 14 01:38:57 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:39:56 2015 +0200 cmLinkedTree: Add Clear API. diff --git a/Source/cmLinkedTree.h b/Source/cmLinkedTree.h index df00b30..3bcb940 100644 --- a/Source/cmLinkedTree.h +++ b/Source/cmLinkedTree.h @@ -155,6 +155,12 @@ public: return iterator(this, 1); } + void Clear() + { + this->UpPositions.clear(); + this->Data.clear(); + } + private: T& GetReference(PositionType pos) { http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5fb814d7f968e10a6a02e2a78b7dccb7c34b026b commit 5fb814d7f968e10a6a02e2a78b7dccb7c34b026b Author: Stephen Kelly AuthorDate: Sun Jul 26 12:56:10 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:39:56 2015 +0200 cmState: Add Type for policy scope. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 2c854dd..9fb3d06 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -189,6 +189,9 @@ cmMakefile::cmMakefile(cmLocalGenerator* localGenerator) this->cmAtVarRegex.compile("(@[A-Za-z_0-9/.+-]+@)"); this->cmNamedCurly.compile("^[A-Za-z0-9/_.+-]+{"); + this->StateSnapshot = this->StateSnapshot.GetState() + ->CreatePolicyScopeSnapshot(this->StateSnapshot); + // Protect the directory-level policies. this->PushPolicyBarrier(); @@ -1705,6 +1708,8 @@ public: this->Makefile->StateSnapshot.GetDirectory().GetCurrentSource(); currentStart += "/CMakeLists.txt"; this->Makefile->StateSnapshot.SetListFile(currentStart); + this->Makefile->StateSnapshot = this->Makefile->StateSnapshot.GetState() + ->CreatePolicyScopeSnapshot(this->Makefile->StateSnapshot); this->Makefile->PushPolicyBarrier(); this->Makefile->PushFunctionBlockerBarrier(); @@ -1722,6 +1727,8 @@ public: { this->Makefile->PopFunctionBlockerBarrier(this->ReportError); this->Makefile->PopPolicyBarrier(this->ReportError); + this->Makefile->StateSnapshot = this->Makefile->StateSnapshot.GetState() + ->Pop(this->Makefile->StateSnapshot); #if defined(CMAKE_BUILD_WITH_CMAKE) this->GG->GetFileLockPool().PopFileScope(); #endif @@ -4841,6 +4848,8 @@ cmMakefile::PolicyPushPop::PolicyPushPop(cmMakefile* m, bool weak, cmPolicies::PolicyMap const& pm): Makefile(m), ReportError(true) { + this->Makefile->StateSnapshot = this->Makefile->StateSnapshot.GetState() + ->CreatePolicyScopeSnapshot(this->Makefile->StateSnapshot); this->Makefile->PushPolicyBarrier(); this->Makefile->PushPolicy(weak, pm); } @@ -4850,6 +4859,8 @@ cmMakefile::PolicyPushPop::~PolicyPushPop() { this->Makefile->PopPolicy(); this->Makefile->PopPolicyBarrier(this->ReportError); + this->Makefile->StateSnapshot = this->Makefile->StateSnapshot.GetState() + ->Pop(this->Makefile->StateSnapshot); } //---------------------------------------------------------------------------- diff --git a/Source/cmState.cxx b/Source/cmState.cxx index a7df040..68f5c18 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -809,6 +809,14 @@ cmState::CreateInlineListFileSnapshot(cmState::Snapshot originSnapshot, return cmState::Snapshot(this, pos); } +cmState::Snapshot cmState::CreatePolicyScopeSnapshot(cmState::Snapshot originSnapshot) +{ + PositionType pos = this->SnapshotData.Extend(originSnapshot.Position, + *originSnapshot.Position); + pos->SnapshotType = PolicyScopeType; + return cmState::Snapshot(this, pos); +} + cmState::Snapshot cmState::Pop(cmState::Snapshot originSnapshot) { PositionType pos = originSnapshot.Position; @@ -959,13 +967,22 @@ cmState::Snapshot cmState::Snapshot::GetCallStackParent() const assert(this->Position != this->State->SnapshotData.Root()); Snapshot snapshot; - if (this->Position->SnapshotType == cmState::BuildsystemDirectoryType) + PositionType parentPos = this->Position; + while(parentPos->SnapshotType == cmState::PolicyScopeType) + { + ++parentPos; + } + if (parentPos->SnapshotType == cmState::BuildsystemDirectoryType) { return snapshot; } - PositionType parentPos = this->Position; ++parentPos; + while(parentPos->SnapshotType == cmState::PolicyScopeType) + { + ++parentPos; + } + if (parentPos == this->State->SnapshotData.Root()) { return snapshot; diff --git a/Source/cmState.h b/Source/cmState.h index 23fbc79..63b60ef 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -37,7 +37,8 @@ public: FunctionCallType, MacroCallType, CallStackType, - InlineListFileType + InlineListFileType, + PolicyScopeType }; class Directory; @@ -148,6 +149,7 @@ public: const std::string& entryPointCommand, long entryPointLine, std::string const& fileName); + Snapshot CreatePolicyScopeSnapshot(Snapshot originSnapshot); Snapshot Pop(Snapshot originSnapshot); enum CacheEntryType{ BOOL=0, PATH, FILEPATH, STRING, INTERNAL,STATIC, http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=af0de01c6b3395fb1dba5d2ee0a94c19a9b464e9 commit af0de01c6b3395fb1dba5d2ee0a94c19a9b464e9 Author: Stephen Kelly AuthorDate: Sat Aug 1 07:29:36 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:31:08 2015 +0200 cmState: Remove call stack parent tracking. This was added at a time when I thought the cmState would report errors, but that is not the direction it is going. The ordering of the stack of scopes is canonical and clients are required to maintain it. diff --git a/Source/cmState.cxx b/Source/cmState.cxx index a466471..a7df040 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -20,7 +20,6 @@ struct cmState::SnapshotDataType { - cmState::PositionType CallStackParent; cmState::PositionType DirectoryParent; cmState::SnapshotType SnapshotType; cmLinkedTree::iterator ExecutionListFile; @@ -732,7 +731,6 @@ cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot, { assert(originSnapshot.IsValid()); PositionType pos = this->SnapshotData.Extend(originSnapshot.Position); - pos->CallStackParent = originSnapshot.Position; pos->EntryPointLine = entryPointLine; pos->EntryPointCommand = entryPointCommand; pos->DirectoryParent = originSnapshot.Position; @@ -754,7 +752,6 @@ cmState::CreateFunctionCallSnapshot(cmState::Snapshot originSnapshot, { PositionType pos = this->SnapshotData.Extend(originSnapshot.Position, *originSnapshot.Position); - pos->CallStackParent = originSnapshot.Position; pos->EntryPointLine = entryPointLine; pos->EntryPointCommand = entryPointCommand; pos->SnapshotType = FunctionCallType; @@ -772,7 +769,6 @@ cmState::CreateMacroCallSnapshot(cmState::Snapshot originSnapshot, { PositionType pos = this->SnapshotData.Extend(originSnapshot.Position, *originSnapshot.Position); - pos->CallStackParent = originSnapshot.Position; pos->EntryPointLine = entryPointLine; pos->EntryPointCommand = entryPointCommand; pos->SnapshotType = MacroCallType; @@ -789,7 +785,6 @@ cmState::CreateCallStackSnapshot(cmState::Snapshot originSnapshot, { PositionType pos = this->SnapshotData.Extend(originSnapshot.Position, *originSnapshot.Position); - pos->CallStackParent = originSnapshot.Position; pos->EntryPointLine = entryPointLine; pos->EntryPointCommand = entryPointCommand; pos->SnapshotType = CallStackType; @@ -806,7 +801,6 @@ cmState::CreateInlineListFileSnapshot(cmState::Snapshot originSnapshot, { PositionType pos = this->SnapshotData.Extend(originSnapshot.Position, *originSnapshot.Position); - pos->CallStackParent = originSnapshot.Position; pos->EntryPointLine = entryPointLine; pos->EntryPointCommand = entryPointCommand; pos->SnapshotType = InlineListFileType; @@ -827,11 +821,7 @@ cmState::Snapshot cmState::Pop(cmState::Snapshot originSnapshot) prevPos->CompileOptionsPosition = prevPos->BuildSystemDirectory->CompileOptions.size(); - if (prevPos == this->SnapshotData.Root()) - { - return Snapshot(this, prevPos); - } - return Snapshot(this, originSnapshot.Position->CallStackParent); + return Snapshot(this, prevPos); } cmState::Snapshot::Snapshot(cmState* state) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6ae8b30bf4127011284a66541ed2116fcb45f007 commit 6ae8b30bf4127011284a66541ed2116fcb45f007 Author: Stephen Kelly AuthorDate: Tue Jul 28 08:09:49 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:18:34 2015 +0200 cmMakefile: Move policy barriers inside cmState scopes. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 16404cd..2c854dd 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -468,6 +468,14 @@ cmMakefile::IncludeScope::IncludeScope(cmMakefile* mf, Makefile(mf), NoPolicyScope(noPolicyScope), CheckCMP0011(false), ReportError(true) { + this->Makefile->PushFunctionBlockerBarrier(); + + this->Makefile->StateSnapshot = + this->Makefile->GetState()->CreateCallStackSnapshot( + this->Makefile->StateSnapshot, + this->Makefile->ContextStack.back()->Name, + this->Makefile->ContextStack.back()->Line, + filenametoread); this->Makefile->PushPolicyBarrier(); if(!this->NoPolicyScope) { @@ -497,27 +505,11 @@ cmMakefile::IncludeScope::IncludeScope(cmMakefile* mf, break; } } - - this->Makefile->PushFunctionBlockerBarrier(); - - this->Makefile->StateSnapshot = - this->Makefile->GetState()->CreateCallStackSnapshot( - this->Makefile->StateSnapshot, - this->Makefile->ContextStack.back()->Name, - this->Makefile->ContextStack.back()->Line, - filenametoread); } //---------------------------------------------------------------------------- cmMakefile::IncludeScope::~IncludeScope() { - this->Makefile->StateSnapshot = - this->Makefile->GetState()->Pop(this->Makefile->StateSnapshot); - assert(this->Makefile->StateSnapshot.IsValid()); - - this->Makefile->PopFunctionBlockerBarrier(this->ReportError); - // Enforce matching policy scopes inside the included file. - if(!this->NoPolicyScope) { // If we need to enforce policy CMP0011 then the top entry is the @@ -540,6 +532,11 @@ cmMakefile::IncludeScope::~IncludeScope() } } this->Makefile->PopPolicyBarrier(this->ReportError); + this->Makefile->StateSnapshot = + this->Makefile->GetState()->Pop(this->Makefile->StateSnapshot); + assert(this->Makefile->StateSnapshot.IsValid()); + + this->Makefile->PopFunctionBlockerBarrier(this->ReportError); } //---------------------------------------------------------------------------- @@ -634,8 +631,6 @@ public: ListFileScope(cmMakefile* mf, std::string const& filenametoread) : Makefile(mf), ReportError(true) { - this->Makefile->PushPolicyBarrier(); - long line = 0; std::string name; if (!this->Makefile->ContextStack.empty()) @@ -647,17 +642,21 @@ public: this->Makefile->GetState()->CreateInlineListFileSnapshot( this->Makefile->StateSnapshot, name, line, filenametoread); assert(this->Makefile->StateSnapshot.IsValid()); + + this->Makefile->PushPolicyBarrier(); + this->Makefile->PushFunctionBlockerBarrier(); } ~ListFileScope() { + this->Makefile->PopPolicyBarrier(this->ReportError); + this->Makefile->StateSnapshot = this->Makefile->GetState()->Pop(this->Makefile->StateSnapshot); assert(this->Makefile->StateSnapshot.IsValid()); this->Makefile->PopFunctionBlockerBarrier(this->ReportError); - this->Makefile->PopPolicyBarrier(this->ReportError); } void Quiet() { this->ReportError = false; } @@ -1628,6 +1627,7 @@ void cmMakefile::PushFunctionScope(std::string const& fileName, this->ContextStack.back()->Name, this->ContextStack.back()->Line, fileName); assert(this->StateSnapshot.IsValid()); + this->PushPolicyBarrier(); this->Internal->PushDefinitions(); @@ -1639,15 +1639,14 @@ void cmMakefile::PushFunctionScope(std::string const& fileName, this->PushFunctionBlockerBarrier(); - this->PushPolicyBarrier(); this->PushPolicy(true, pm); } void cmMakefile::PopFunctionScope(bool reportError) { this->PopPolicy(); - this->PopPolicyBarrier(reportError); + this->PopPolicyBarrier(reportError); this->StateSnapshot = this->GetState()->Pop(this->StateSnapshot); assert(this->StateSnapshot.IsValid()); @@ -1673,10 +1672,10 @@ void cmMakefile::PushMacroScope(std::string const& fileName, this->ContextStack.back()->Name, this->ContextStack.back()->Line, fileName); assert(this->StateSnapshot.IsValid()); + this->PushPolicyBarrier(); this->PushFunctionBlockerBarrier(); - this->PushPolicyBarrier(); this->PushPolicy(true, pm); } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a5fc17b5098ee27fd7ae457ca6c5743bacc384a7 commit a5fc17b5098ee27fd7ae457ca6c5743bacc384a7 Author: Stephen Kelly AuthorDate: Sun Jul 26 16:16:43 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:18:34 2015 +0200 cmMakefile: Re-order policy entries and barriers. Make the barriers surround the entries. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 4bdc9d5..16404cd 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -189,12 +189,12 @@ cmMakefile::cmMakefile(cmLocalGenerator* localGenerator) this->cmAtVarRegex.compile("(@[A-Za-z_0-9/.+-]+@)"); this->cmNamedCurly.compile("^[A-Za-z0-9/_.+-]+{"); - // Enter a policy level for this directory. - this->PushPolicy(); - // Protect the directory-level policies. this->PushPolicyBarrier(); + // Enter a policy level for this directory. + this->PushPolicy(); + // push empty loop block this->PushLoopBlockBarrier(); @@ -468,6 +468,7 @@ cmMakefile::IncludeScope::IncludeScope(cmMakefile* mf, Makefile(mf), NoPolicyScope(noPolicyScope), CheckCMP0011(false), ReportError(true) { + this->Makefile->PushPolicyBarrier(); if(!this->NoPolicyScope) { // Check CMP0011 to determine the policy scope type. @@ -497,8 +498,6 @@ cmMakefile::IncludeScope::IncludeScope(cmMakefile* mf, } } - // The included file cannot pop our policy scope. - this->Makefile->PushPolicyBarrier(); this->Makefile->PushFunctionBlockerBarrier(); this->Makefile->StateSnapshot = @@ -518,7 +517,6 @@ cmMakefile::IncludeScope::~IncludeScope() this->Makefile->PopFunctionBlockerBarrier(this->ReportError); // Enforce matching policy scopes inside the included file. - this->Makefile->PopPolicyBarrier(this->ReportError); if(!this->NoPolicyScope) { @@ -541,6 +539,7 @@ cmMakefile::IncludeScope::~IncludeScope() this->EnforceCMP0011(); } } + this->Makefile->PopPolicyBarrier(this->ReportError); } //---------------------------------------------------------------------------- @@ -1640,14 +1639,14 @@ void cmMakefile::PushFunctionScope(std::string const& fileName, this->PushFunctionBlockerBarrier(); - this->PushPolicy(true, pm); this->PushPolicyBarrier(); + this->PushPolicy(true, pm); } void cmMakefile::PopFunctionScope(bool reportError) { - this->PopPolicyBarrier(reportError); this->PopPolicy(); + this->PopPolicyBarrier(reportError); this->StateSnapshot = this->GetState()->Pop(this->StateSnapshot); assert(this->StateSnapshot.IsValid()); @@ -1677,14 +1676,14 @@ void cmMakefile::PushMacroScope(std::string const& fileName, this->PushFunctionBlockerBarrier(); - this->PushPolicy(true, pm); this->PushPolicyBarrier(); + this->PushPolicy(true, pm); } void cmMakefile::PopMacroScope(bool reportError) { - this->PopPolicyBarrier(reportError); this->PopPolicy(); + this->PopPolicyBarrier(reportError); this->StateSnapshot = this->GetState()->Pop(this->StateSnapshot); assert(this->StateSnapshot.IsValid()); @@ -4843,15 +4842,15 @@ cmMakefile::PolicyPushPop::PolicyPushPop(cmMakefile* m, bool weak, cmPolicies::PolicyMap const& pm): Makefile(m), ReportError(true) { - this->Makefile->PushPolicy(weak, pm); this->Makefile->PushPolicyBarrier(); + this->Makefile->PushPolicy(weak, pm); } //---------------------------------------------------------------------------- cmMakefile::PolicyPushPop::~PolicyPushPop() { - this->Makefile->PopPolicyBarrier(this->ReportError); this->Makefile->PopPolicy(); + this->Makefile->PopPolicyBarrier(this->ReportError); } //---------------------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0a01e6c6e7bd428ca0ec99a00924b5b498c6e637 commit 0a01e6c6e7bd428ca0ec99a00924b5b498c6e637 Author: Stephen Kelly AuthorDate: Sun Jul 26 12:54:16 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:18:34 2015 +0200 cmState: Add Snapshot Type accessor. diff --git a/Source/cmState.cxx b/Source/cmState.cxx index d8f8306..a466471 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -847,6 +847,11 @@ cmState::Snapshot::Snapshot(cmState* state, PositionType position) } +cmState::SnapshotType cmState::Snapshot::GetType() const +{ + return this->Position->SnapshotType; +} + const char* cmState::Directory::GetCurrentSource() const { return this->DirectoryState->Location.c_str(); diff --git a/Source/cmState.h b/Source/cmState.h index 0d5300f..23fbc79 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -56,6 +56,7 @@ public: bool IsValid() const; Snapshot GetBuildsystemDirectoryParent() const; Snapshot GetCallStackParent() const; + SnapshotType GetType() const; void InitializeFromParent(); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f0005bb484bc2b85a169ef7816e33d8e2f16e109 commit f0005bb484bc2b85a169ef7816e33d8e2f16e109 Author: Stephen Kelly AuthorDate: Sat Aug 1 07:16:40 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:18:21 2015 +0200 Tests: Verify generate-time policy scope behavior. If some day there are no policies checked through the makefile at generate time, this can be fixed. diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 607e799..c4579d7 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -145,6 +145,7 @@ add_RunCMake_test(TargetSources) add_RunCMake_test(find_dependency) add_RunCMake_test(CompileDefinitions) add_RunCMake_test(CompileFeatures) +add_RunCMake_test(PolicyScope) add_RunCMake_test(WriteCompilerDetectionHeader) if(NOT WIN32) add_RunCMake_test(PositionIndependentCode) diff --git a/Tests/RunCMake/PolicyScope/CMakeLists.txt b/Tests/RunCMake/PolicyScope/CMakeLists.txt new file mode 100644 index 0000000..667561e --- /dev/null +++ b/Tests/RunCMake/PolicyScope/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8.12) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE) diff --git a/Tests/RunCMake/PolicyScope/RunCMakeTest.cmake b/Tests/RunCMake/PolicyScope/RunCMakeTest.cmake new file mode 100644 index 0000000..d6c021f --- /dev/null +++ b/Tests/RunCMake/PolicyScope/RunCMakeTest.cmake @@ -0,0 +1,4 @@ +include(RunCMake) + +run_cmake(parent-dir-generate-time) +run_cmake(dir-in-macro-generate-time) diff --git a/Tests/RunCMake/PolicyScope/dir-in-macro-generate-time-result.txt b/Tests/RunCMake/PolicyScope/dir-in-macro-generate-time-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/PolicyScope/dir-in-macro-generate-time-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/PolicyScope/dir-in-macro-generate-time-stderr.txt b/Tests/RunCMake/PolicyScope/dir-in-macro-generate-time-stderr.txt new file mode 100644 index 0000000..d223f42 --- /dev/null +++ b/Tests/RunCMake/PolicyScope/dir-in-macro-generate-time-stderr.txt @@ -0,0 +1,5 @@ +CMake Warning \(dev\) at dir1/CMakeLists.txt:5 \(target_compile_definitions\): + Policy CMP0044 is not set: Case sensitive _COMPILER_ID generator + expressions. Run "cmake --help-policy CMP0044" for policy details. Use + the cmake_policy command to set the policy and suppress this warning. +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/PolicyScope/dir-in-macro-generate-time.cmake b/Tests/RunCMake/PolicyScope/dir-in-macro-generate-time.cmake new file mode 100644 index 0000000..04a7c2c --- /dev/null +++ b/Tests/RunCMake/PolicyScope/dir-in-macro-generate-time.cmake @@ -0,0 +1,2 @@ + +include(dir-in-macro-include.cmake) diff --git a/Tests/RunCMake/PolicyScope/dir-in-macro-include.cmake b/Tests/RunCMake/PolicyScope/dir-in-macro-include.cmake new file mode 100644 index 0000000..fd326f1 --- /dev/null +++ b/Tests/RunCMake/PolicyScope/dir-in-macro-include.cmake @@ -0,0 +1,6 @@ + +enable_language(CXX) + +# This does not affect dir1 despite being set before the add_subdirectory. +cmake_policy(SET CMP0044 NEW) +add_subdirectory(dir1) diff --git a/Tests/RunCMake/PolicyScope/dir1/CMakeLists.txt b/Tests/RunCMake/PolicyScope/dir1/CMakeLists.txt new file mode 100644 index 0000000..16bcb36 --- /dev/null +++ b/Tests/RunCMake/PolicyScope/dir1/CMakeLists.txt @@ -0,0 +1,5 @@ + + +add_library(foo STATIC foo.cpp) +string(TOLOWER ${CMAKE_CXX_COMPILER_ID} compiler_id) +target_compile_definitions(foo PRIVATE Foo=$) diff --git a/Tests/RunCMake/PolicyScope/dir1/foo.cpp b/Tests/RunCMake/PolicyScope/dir1/foo.cpp new file mode 100644 index 0000000..766b775 --- /dev/null +++ b/Tests/RunCMake/PolicyScope/dir1/foo.cpp @@ -0,0 +1,5 @@ + +int main() +{ + return 0; +} diff --git a/Tests/RunCMake/PolicyScope/parent-dir-generate-time-result.txt b/Tests/RunCMake/PolicyScope/parent-dir-generate-time-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/PolicyScope/parent-dir-generate-time-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/PolicyScope/parent-dir-generate-time.cmake b/Tests/RunCMake/PolicyScope/parent-dir-generate-time.cmake new file mode 100644 index 0000000..a0842f7 --- /dev/null +++ b/Tests/RunCMake/PolicyScope/parent-dir-generate-time.cmake @@ -0,0 +1,7 @@ + +enable_language(CXX) + +add_subdirectory(dir1) + +# This affects dir1 despite being set after the add_subdirectory. +cmake_policy(SET CMP0044 NEW) ----------------------------------------------------------------------- Summary of changes: Source/cmLinkedTree.h | 6 + Source/cmMakefile.cxx | 130 ++++----------- Source/cmMakefile.h | 13 -- Source/cmState.cxx | 173 ++++++++++++++++++-- Source/cmState.h | 15 +- Tests/RunCMake/CMakeLists.txt | 1 + .../RunCMake/{Ninja => PolicyScope}/CMakeLists.txt | 2 +- Tests/RunCMake/PolicyScope/RunCMakeTest.cmake | 4 + .../dir-in-macro-generate-time-result.txt} | 0 .../dir-in-macro-generate-time-stderr.txt} | 4 +- .../PolicyScope/dir-in-macro-generate-time.cmake | 2 + .../PolicyScope/dir-in-macro-include.cmake | 6 + Tests/RunCMake/PolicyScope/dir1/CMakeLists.txt | 5 + .../PolicyScope/dir1/foo.cpp} | 0 .../parent-dir-generate-time-result.txt} | 0 .../PolicyScope/parent-dir-generate-time.cmake | 7 + 16 files changed, 237 insertions(+), 131 deletions(-) copy Tests/RunCMake/{Ninja => PolicyScope}/CMakeLists.txt (66%) create mode 100644 Tests/RunCMake/PolicyScope/RunCMakeTest.cmake copy Tests/RunCMake/{CMP0022/CMP0022-WARN-empty-old-result.txt => PolicyScope/dir-in-macro-generate-time-result.txt} (100%) copy Tests/RunCMake/{GeneratorExpression/CMP0044-WARN-stderr.txt => PolicyScope/dir-in-macro-generate-time-stderr.txt} (69%) create mode 100644 Tests/RunCMake/PolicyScope/dir-in-macro-generate-time.cmake create mode 100644 Tests/RunCMake/PolicyScope/dir-in-macro-include.cmake create mode 100644 Tests/RunCMake/PolicyScope/dir1/CMakeLists.txt copy Tests/{CTestTestCycle/simple.cxx => RunCMake/PolicyScope/dir1/foo.cpp} (100%) copy Tests/RunCMake/{CMP0022/CMP0022-WARN-empty-old-result.txt => PolicyScope/parent-dir-generate-time-result.txt} (100%) create mode 100644 Tests/RunCMake/PolicyScope/parent-dir-generate-time.cmake hooks/post-receive -- CMake From steveire at gmail.com Sat Aug 1 02:00:13 2015 From: steveire at gmail.com (Stephen Kelly) Date: Sat, 1 Aug 2015 02:00:13 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1659-gdb70a1c Message-ID: <20150801060018.E2AA2B0FC7@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via db70a1c79decc497a0c42ee543d57dfc53ae8000 (commit) via 93f0c176d8abd604902c8ecafa41b4b4a1a9b12b (commit) from 1aa00000ee9cc3514467d66832d127aa955a99fb (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=db70a1c79decc497a0c42ee543d57dfc53ae8000 commit db70a1c79decc497a0c42ee543d57dfc53ae8000 Merge: 1aa0000 93f0c17 Author: Stephen Kelly AuthorDate: Sat Aug 1 02:00:12 2015 -0400 Commit: CMake Topic Stage CommitDate: Sat Aug 1 02:00:12 2015 -0400 Merge topic 'cmState-policies' into next 93f0c176 simplify http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=93f0c176d8abd604902c8ecafa41b4b4a1a9b12b commit 93f0c176d8abd604902c8ecafa41b4b4a1a9b12b Author: Stephen Kelly AuthorDate: Sat Aug 1 07:59:38 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 07:59:55 2015 +0200 simplify diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 492a4d0..f425861 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -1060,9 +1060,7 @@ bool cmState::Snapshot::PopPolicy() bool cmState::Snapshot::CanPopPolicyScope() { - PositionType pos = this->Position; - bool ok = (pos->Policies == pos->PolicyScope); - return ok; + return this->Position->Policies == this->Position->PolicyScope; } void cmState::Snapshot::SetPolicy(cmPolicies::PolicyID id, ----------------------------------------------------------------------- Summary of changes: Source/cmState.cxx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) hooks/post-receive -- CMake From steveire at gmail.com Sat Aug 1 02:00:38 2015 From: steveire at gmail.com (Stephen Kelly) Date: Sat, 1 Aug 2015 02:00:38 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1661-g0b2500e Message-ID: <20150801060054.3C3B9B0FD8@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 0b2500ebacc92ddddf00ea4adc2bc55a5bc0ced4 (commit) via 3492f289d900d8a785270455cdbdd0b49a6490a9 (commit) from db70a1c79decc497a0c42ee543d57dfc53ae8000 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0b2500ebacc92ddddf00ea4adc2bc55a5bc0ced4 commit 0b2500ebacc92ddddf00ea4adc2bc55a5bc0ced4 Merge: db70a1c 3492f28 Author: Stephen Kelly AuthorDate: Sat Aug 1 02:00:37 2015 -0400 Commit: CMake Topic Stage CommitDate: Sat Aug 1 02:00:37 2015 -0400 Merge topic 'cmState-policies' into next 3492f289 cmState: Move PolicyState from cmMakefile. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3492f289d900d8a785270455cdbdd0b49a6490a9 commit 3492f289d900d8a785270455cdbdd0b49a6490a9 Author: Stephen Kelly AuthorDate: Sun Jul 26 13:04:09 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 08:00:27 2015 +0200 cmState: Move PolicyState from cmMakefile. Implement lexical scope checking in terms of the state stack instead of barriers. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 9fb3d06..a0a36ec 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -192,9 +192,6 @@ cmMakefile::cmMakefile(cmLocalGenerator* localGenerator) this->StateSnapshot = this->StateSnapshot.GetState() ->CreatePolicyScopeSnapshot(this->StateSnapshot); - // Protect the directory-level policies. - this->PushPolicyBarrier(); - // Enter a policy level for this directory. this->PushPolicy(); @@ -239,11 +236,6 @@ cmMakefile::~cmMakefile() cmDeleteAll(this->FinalPassCommands); cmDeleteAll(this->FunctionBlockers); this->FunctionBlockers.clear(); - if (this->PolicyStack.size() != 1) - { - cmSystemTools::Error("Internal CMake Error, Policy Stack has not been" - " popped properly"); - } } //---------------------------------------------------------------------------- @@ -479,7 +471,6 @@ cmMakefile::IncludeScope::IncludeScope(cmMakefile* mf, this->Makefile->ContextStack.back()->Name, this->Makefile->ContextStack.back()->Line, filenametoread); - this->Makefile->PushPolicyBarrier(); if(!this->NoPolicyScope) { // Check CMP0011 to determine the policy scope type. @@ -519,7 +510,8 @@ cmMakefile::IncludeScope::~IncludeScope() // one we pushed above. If the entry is empty, then the included // script did not set any policies that might affect the includer so // we do not need to enforce the policy. - if(this->CheckCMP0011 && this->Makefile->PolicyStack.back().IsEmpty()) + if(this->CheckCMP0011 + && !this->Makefile->StateSnapshot.HasDefinedPolicyCMP0011()) { this->CheckCMP0011 = false; } @@ -535,9 +527,6 @@ cmMakefile::IncludeScope::~IncludeScope() } } this->Makefile->PopPolicyBarrier(this->ReportError); - this->Makefile->StateSnapshot = - this->Makefile->GetState()->Pop(this->Makefile->StateSnapshot); - assert(this->Makefile->StateSnapshot.IsValid()); this->Makefile->PopFunctionBlockerBarrier(this->ReportError); } @@ -646,19 +635,12 @@ public: this->Makefile->StateSnapshot, name, line, filenametoread); assert(this->Makefile->StateSnapshot.IsValid()); - this->Makefile->PushPolicyBarrier(); - this->Makefile->PushFunctionBlockerBarrier(); } ~ListFileScope() { this->Makefile->PopPolicyBarrier(this->ReportError); - - this->Makefile->StateSnapshot = - this->Makefile->GetState()->Pop(this->Makefile->StateSnapshot); - assert(this->Makefile->StateSnapshot.IsValid()); - this->Makefile->PopFunctionBlockerBarrier(this->ReportError); } @@ -1630,7 +1612,6 @@ void cmMakefile::PushFunctionScope(std::string const& fileName, this->ContextStack.back()->Name, this->ContextStack.back()->Line, fileName); assert(this->StateSnapshot.IsValid()); - this->PushPolicyBarrier(); this->Internal->PushDefinitions(); @@ -1650,8 +1631,6 @@ void cmMakefile::PopFunctionScope(bool reportError) this->PopPolicy(); this->PopPolicyBarrier(reportError); - this->StateSnapshot = this->GetState()->Pop(this->StateSnapshot); - assert(this->StateSnapshot.IsValid()); this->PopFunctionBlockerBarrier(reportError); @@ -1675,7 +1654,6 @@ void cmMakefile::PushMacroScope(std::string const& fileName, this->ContextStack.back()->Name, this->ContextStack.back()->Line, fileName); assert(this->StateSnapshot.IsValid()); - this->PushPolicyBarrier(); this->PushFunctionBlockerBarrier(); @@ -1687,9 +1665,6 @@ void cmMakefile::PopMacroScope(bool reportError) this->PopPolicy(); this->PopPolicyBarrier(reportError); - this->StateSnapshot = this->GetState()->Pop(this->StateSnapshot); - assert(this->StateSnapshot.IsValid()); - this->PopFunctionBlockerBarrier(reportError); } @@ -1710,7 +1685,6 @@ public: this->Makefile->StateSnapshot.SetListFile(currentStart); this->Makefile->StateSnapshot = this->Makefile->StateSnapshot.GetState() ->CreatePolicyScopeSnapshot(this->Makefile->StateSnapshot); - this->Makefile->PushPolicyBarrier(); this->Makefile->PushFunctionBlockerBarrier(); this->GG = mf->GetGlobalGenerator(); @@ -1727,8 +1701,6 @@ public: { this->Makefile->PopFunctionBlockerBarrier(this->ReportError); this->Makefile->PopPolicyBarrier(this->ReportError); - this->Makefile->StateSnapshot = this->Makefile->StateSnapshot.GetState() - ->Pop(this->Makefile->StateSnapshot); #if defined(CMAKE_BUILD_WITH_CMAKE) this->GG->GetFileLockPool().PopFileScope(); #endif @@ -4759,30 +4731,7 @@ const char* cmMakefile::GetDefineFlagsCMP0059() const cmPolicies::PolicyStatus cmMakefile::GetPolicyStatus(cmPolicies::PolicyID id) const { - cmPolicies::PolicyStatus status = cmPolicies::GetPolicyStatus(id); - - if(status == cmPolicies::REQUIRED_ALWAYS || - status == cmPolicies::REQUIRED_IF_USED) - { - return status; - } - - cmLocalGenerator* lg = this->LocalGenerator; - while(lg) - { - cmMakefile const* mf = lg->GetMakefile(); - for(PolicyStackType::const_reverse_iterator psi = - mf->PolicyStack.rbegin(); psi != mf->PolicyStack.rend(); ++psi) - { - if(psi->IsDefined(id)) - { - status = psi->Get(id); - return status; - } - } - lg = lg->GetParent(); - } - return status; + return this->StateSnapshot.GetPolicy(id); } //---------------------------------------------------------------------------- @@ -4831,15 +4780,7 @@ bool cmMakefile::SetPolicy(cmPolicies::PolicyID id, return false; } - // Update the policy stack from the top to the top-most strong entry. - bool previous_was_weak = true; - for(PolicyStackType::reverse_iterator psi = this->PolicyStack.rbegin(); - previous_was_weak && psi != this->PolicyStack.rend(); ++psi) - { - psi->Set(id, status); - previous_was_weak = psi->Weak; - } - + this->StateSnapshot.SetPolicy(id, status); return true; } @@ -4850,7 +4791,6 @@ cmMakefile::PolicyPushPop::PolicyPushPop(cmMakefile* m, bool weak, { this->Makefile->StateSnapshot = this->Makefile->StateSnapshot.GetState() ->CreatePolicyScopeSnapshot(this->Makefile->StateSnapshot); - this->Makefile->PushPolicyBarrier(); this->Makefile->PushPolicy(weak, pm); } @@ -4859,25 +4799,18 @@ cmMakefile::PolicyPushPop::~PolicyPushPop() { this->Makefile->PopPolicy(); this->Makefile->PopPolicyBarrier(this->ReportError); - this->Makefile->StateSnapshot = this->Makefile->StateSnapshot.GetState() - ->Pop(this->Makefile->StateSnapshot); } //---------------------------------------------------------------------------- void cmMakefile::PushPolicy(bool weak, cmPolicies::PolicyMap const& pm) { - // Allocate a new stack entry. - this->PolicyStack.push_back(PolicyStackEntry(pm, weak)); + this->StateSnapshot.PushPolicy(pm, weak); } //---------------------------------------------------------------------------- void cmMakefile::PopPolicy() { - if(this->PolicyStack.size() > this->PolicyBarriers.back()) - { - this->PolicyStack.pop_back(); - } - else + if (!this->StateSnapshot.PopPolicy()) { this->IssueMessage(cmake::FATAL_ERROR, "cmake_policy POP without matching PUSH"); @@ -4885,17 +4818,9 @@ void cmMakefile::PopPolicy() } //---------------------------------------------------------------------------- -void cmMakefile::PushPolicyBarrier() -{ - this->PolicyBarriers.push_back(this->PolicyStack.size()); -} - -//---------------------------------------------------------------------------- void cmMakefile::PopPolicyBarrier(bool reportError) { - // Remove any extra entries pushed on the barrier. - PolicyStackType::size_type barrier = this->PolicyBarriers.back(); - while(this->PolicyStack.size() > barrier) + while (!this->StateSnapshot.CanPopPolicyScope()) { if(reportError) { @@ -4906,8 +4831,8 @@ void cmMakefile::PopPolicyBarrier(bool reportError) this->PopPolicy(); } - // Remove the barrier. - this->PolicyBarriers.pop_back(); + this->StateSnapshot = this->GetState()->Pop(this->StateSnapshot); + assert(this->StateSnapshot.IsValid()); } //---------------------------------------------------------------------------- diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 1e5c301..173914e 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -909,7 +909,6 @@ private: void PushPolicy(bool weak = false, cmPolicies::PolicyMap const& pm = cmPolicies::PolicyMap()); void PopPolicy(); - void PushPolicyBarrier(); void PopPolicyBarrier(bool reportError = true); friend class cmCMakePolicyCommand; class IncludeScope; @@ -919,18 +918,6 @@ private: class BuildsystemFileScope; friend class BuildsystemFileScope; - // stack of policy settings - struct PolicyStackEntry: public cmPolicies::PolicyMap - { - typedef cmPolicies::PolicyMap derived; - PolicyStackEntry(bool w = false): derived(), Weak(w) {} - PolicyStackEntry(derived const& d, bool w = false): derived(d), Weak(w) {} - PolicyStackEntry(PolicyStackEntry const& r): derived(r), Weak(r.Weak) {} - bool Weak; - }; - typedef std::vector PolicyStackType; - PolicyStackType PolicyStack; - std::vector PolicyBarriers; // CMP0053 == old cmake::MessageType ExpandVariablesInStringOld( diff --git a/Source/cmState.cxx b/Source/cmState.cxx index ea8d147..f425861 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -21,6 +21,9 @@ struct cmState::SnapshotDataType { cmState::PositionType DirectoryParent; + cmLinkedTree::iterator Policies; + cmLinkedTree::iterator PolicyRoot; + cmLinkedTree::iterator PolicyScope; cmState::SnapshotType SnapshotType; cmLinkedTree::iterator ExecutionListFile; cmLinkedTree::iterator @@ -32,6 +35,15 @@ struct cmState::SnapshotDataType std::vector::size_type CompileOptionsPosition; }; +struct cmState::PolicyStackEntry: public cmPolicies::PolicyMap +{ + typedef cmPolicies::PolicyMap derived; + PolicyStackEntry(bool w = false): derived(), Weak(w) {} + PolicyStackEntry(derived const& d, bool w): derived(d), Weak(w) {} + PolicyStackEntry(PolicyStackEntry const& r): derived(r), Weak(r.Weak) {} + bool Weak; +}; + struct cmState::BuildsystemDirectoryStateType { cmState::PositionType DirectoryEnd; @@ -256,6 +268,13 @@ cmState::Snapshot cmState::Reset() it->DirectoryEnd = pos; } + this->PolicyStack.Clear(); + pos->Policies = this->PolicyStack.Root(); + pos->PolicyRoot = this->PolicyStack.Root(); + pos->PolicyScope = this->PolicyStack.Root(); + assert(pos->Policies.IsValid()); + assert(pos->PolicyRoot.IsValid()); + this->DefineProperty ("RULE_LAUNCH_COMPILE", cmProperty::DIRECTORY, "", "", true); @@ -726,6 +745,11 @@ cmState::Snapshot cmState::CreateBaseSnapshot() pos->CompileDefinitionsPosition = 0; pos->CompileOptionsPosition = 0; pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->Policies = this->PolicyStack.Root(); + pos->PolicyRoot = this->PolicyStack.Root(); + pos->PolicyScope = this->PolicyStack.Root(); + assert(pos->Policies.IsValid()); + assert(pos->PolicyRoot.IsValid()); return cmState::Snapshot(this, pos); } @@ -747,6 +771,11 @@ cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot, this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile); pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->Policies = originSnapshot.Position->Policies; + pos->PolicyRoot = originSnapshot.Position->Policies; + pos->PolicyScope = originSnapshot.Position->Policies; + assert(pos->Policies.IsValid()); + assert(pos->PolicyRoot.IsValid()); return cmState::Snapshot(this, pos); } @@ -764,6 +793,7 @@ cmState::CreateFunctionCallSnapshot(cmState::Snapshot originSnapshot, pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile, fileName); pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->PolicyScope = originSnapshot.Position->Policies; return cmState::Snapshot(this, pos); } @@ -782,6 +812,7 @@ cmState::CreateMacroCallSnapshot(cmState::Snapshot originSnapshot, pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile, fileName); pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->PolicyScope = originSnapshot.Position->Policies; return cmState::Snapshot(this, pos); } @@ -799,6 +830,7 @@ cmState::CreateCallStackSnapshot(cmState::Snapshot originSnapshot, pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile, fileName); pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->PolicyScope = originSnapshot.Position->Policies; return cmState::Snapshot(this, pos); } @@ -816,15 +848,18 @@ cmState::CreateInlineListFileSnapshot(cmState::Snapshot originSnapshot, pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile, fileName); pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->PolicyScope = originSnapshot.Position->Policies; return cmState::Snapshot(this, pos); } -cmState::Snapshot cmState::CreatePolicyScopeSnapshot(cmState::Snapshot originSnapshot) +cmState::Snapshot +cmState::CreatePolicyScopeSnapshot(cmState::Snapshot originSnapshot) { PositionType pos = this->SnapshotData.Extend(originSnapshot.Position, *originSnapshot.Position); pos->SnapshotType = PolicyScopeType; pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->PolicyScope = originSnapshot.Position->Policies; return cmState::Snapshot(this, pos); } @@ -1004,6 +1039,88 @@ cmState::Snapshot cmState::Snapshot::GetCallStackParent() const return snapshot; } +void cmState::Snapshot::PushPolicy(cmPolicies::PolicyMap entry, bool weak) +{ + PositionType pos = this->Position; + pos->Policies = + this->State->PolicyStack.Extend(pos->Policies, + PolicyStackEntry(entry, weak)); +} + +bool cmState::Snapshot::PopPolicy() +{ + PositionType pos = this->Position; + if (pos->Policies == pos->PolicyScope) + { + return false; + } + ++pos->Policies; + return true; +} + +bool cmState::Snapshot::CanPopPolicyScope() +{ + return this->Position->Policies == this->Position->PolicyScope; +} + +void cmState::Snapshot::SetPolicy(cmPolicies::PolicyID id, + cmPolicies::PolicyStatus status) +{ + // Update the policy stack from the top to the top-most strong entry. + bool previous_was_weak = true; + for(cmLinkedTree::iterator psi = this->Position->Policies; + previous_was_weak && psi != this->Position->PolicyRoot; ++psi) + { + psi->Set(id, status); + previous_was_weak = psi->Weak; + } +} + +cmPolicies::PolicyStatus +cmState::Snapshot::GetPolicy(cmPolicies::PolicyID id) const +{ + cmPolicies::PolicyStatus status = cmPolicies::GetPolicyStatus(id); + + if(status == cmPolicies::REQUIRED_ALWAYS || + status == cmPolicies::REQUIRED_IF_USED) + { + return status; + } + + cmLinkedTree::iterator dir = + this->Position->BuildSystemDirectory; + + while (true) + { + assert(dir.IsValid()); + cmLinkedTree::iterator leaf = + dir->DirectoryEnd->Policies; + cmLinkedTree::iterator root = + dir->DirectoryEnd->PolicyRoot; + for( ; leaf != root; ++leaf) + { + if(leaf->IsDefined(id)) + { + status = leaf->Get(id); + return status; + } + } + cmState::PositionType e = dir->DirectoryEnd; + cmState::PositionType p = e->DirectoryParent; + if (p == this->State->SnapshotData.Root()) + { + break; + } + dir = p->BuildSystemDirectory; + } + return status; +} + +bool cmState::Snapshot::HasDefinedPolicyCMP0011() +{ + return !this->Position->Policies->IsEmpty(); +} + static const std::string cmPropertySentinal = std::string(); template diff --git a/Source/cmState.h b/Source/cmState.h index 63b60ef..07aa2a5 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -17,6 +17,7 @@ #include "cmPropertyMap.h" #include "cmLinkedTree.h" #include "cmAlgorithms.h" +#include "cmPolicies.h" class cmake; class cmCommand; @@ -24,6 +25,7 @@ class cmCommand; class cmState { struct SnapshotDataType; + struct PolicyStackEntry; struct BuildsystemDirectoryStateType; typedef cmLinkedTree::iterator PositionType; friend class Snapshot; @@ -61,6 +63,13 @@ public: void InitializeFromParent(); + void SetPolicy(cmPolicies::PolicyID id, cmPolicies::PolicyStatus status); + cmPolicies::PolicyStatus GetPolicy(cmPolicies::PolicyID id) const; + bool HasDefinedPolicyCMP0011(); + void PushPolicy(cmPolicies::PolicyMap entry, bool weak); + bool PopPolicy(); + bool CanPopPolicyScope(); + cmState* GetState() const; Directory GetDirectory() const; @@ -257,6 +266,7 @@ private: cmLinkedTree ExecutionListFiles; + cmLinkedTree PolicyStack; cmLinkedTree SnapshotData; std::vector SourceDirectoryComponents; ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From steveire at gmail.com Sat Aug 1 02:18:40 2015 From: steveire at gmail.com (Stephen Kelly) Date: Sat, 1 Aug 2015 02:18:40 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1666-gb4bb775 Message-ID: <20150801061841.9827DB05C9@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via b4bb7753d5094346c64cb45cfb315d1e93f12dcb (commit) via e2d702941ae6ced5e094182d933d8d12721bc7ac (commit) via aba6d41ba00b9ecd397ed76bb97a4b1780c0a959 (commit) via 0815f476a47898cbb967ac684960a68dcc64ead7 (commit) via f6feed2c6d8fedb888a7b1fbb66d870c645c2251 (commit) from 0b2500ebacc92ddddf00ea4adc2bc55a5bc0ced4 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b4bb7753d5094346c64cb45cfb315d1e93f12dcb commit b4bb7753d5094346c64cb45cfb315d1e93f12dcb Merge: 0b2500e e2d7029 Author: Stephen Kelly AuthorDate: Sat Aug 1 02:18:37 2015 -0400 Commit: CMake Topic Stage CommitDate: Sat Aug 1 02:18:37 2015 -0400 Merge topic 'use-generator-target' into next e2d70294 cmMakefile: Remove unused method. aba6d41b Remove unneeded. 0815f476 cmGlobalGenerator: Base exclusion computation on cmGeneratorTarget. f6feed2c cmExportInstallFileGenerator: Simplify local generator access. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e2d702941ae6ced5e094182d933d8d12721bc7ac commit e2d702941ae6ced5e094182d933d8d12721bc7ac Author: Stephen Kelly AuthorDate: Sat Jun 6 14:27:52 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 08:17:57 2015 +0200 cmMakefile: Remove unused method. diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 1e5c301..00d4005 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -113,10 +113,6 @@ public: bool GetIsSourceFileTryCompile() const; - ///! Get the current makefile generator. - cmLocalGenerator* GetLocalGenerator() const - { return this->LocalGenerator;} - /** * Help enforce global target name uniqueness. */ http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=aba6d41ba00b9ecd397ed76bb97a4b1780c0a959 commit aba6d41ba00b9ecd397ed76bb97a4b1780c0a959 Author: Stephen Kelly AuthorDate: Sat Aug 1 08:17:27 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 08:17:57 2015 +0200 Remove unneeded. diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index f6d7168..d55be11 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -193,7 +193,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE", te, properties); - cmGeneratorTarget *gtgt = te->GetMakefile()->GetLocalGenerator() + cmGeneratorTarget *gtgt = te->GetMakefile() ->GetGlobalGenerator() ->GetGeneratorTarget(te); diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 45812c7..c831704 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1199,7 +1199,7 @@ public: : Preference(0), Target(target) { this->Makefile = this->Target->Makefile; - this->GG = this->Makefile->GetLocalGenerator()->GetGlobalGenerator(); + this->GG = this->Makefile->GetGlobalGenerator(); } void Consider(const char* lang) { diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 60fadbe..30cf175 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -372,7 +372,7 @@ cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target, { std::string fname; // Compute the name of the library. - cmGeneratorTarget *gtgt = target->GetMakefile()->GetLocalGenerator() + cmGeneratorTarget *gtgt = target->GetMakefile() ->GetGlobalGenerator() ->GetGeneratorTarget(target); if(target->GetType() == cmTarget::EXECUTABLE) @@ -577,7 +577,6 @@ cmInstallTargetGenerator } cmGeneratorTarget *gtgt = tgt->GetMakefile() - ->GetLocalGenerator() ->GetGlobalGenerator() ->GetGeneratorTarget(tgt); // If the build tree and install tree use different path diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 30ddb59..f1ba2f4 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -547,7 +547,7 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target) { qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR"); } - cmGeneratorTarget *gtgt = target->GetMakefile()->GetLocalGenerator() + cmGeneratorTarget *gtgt = target->GetMakefile() ->GetGlobalGenerator() ->GetGeneratorTarget(target); if (const char *targetQtVersion = @@ -881,7 +881,7 @@ void cmQtAutoGenerators::MergeUicOptions(std::vector &opts, static void GetUicOpts(cmTarget const* target, const std::string& config, std::string &optString) { - cmGeneratorTarget *gtgt = target->GetMakefile()->GetLocalGenerator() + cmGeneratorTarget *gtgt = target->GetMakefile() ->GetGlobalGenerator() ->GetGeneratorTarget(target); std::vector opts; @@ -1153,7 +1153,7 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) std::string cmQtAutoGenerators::GetRccExecutable(cmTarget const* target) { - cmGeneratorTarget *gtgt = target->GetMakefile()->GetLocalGenerator() + cmGeneratorTarget *gtgt = target->GetMakefile() ->GetGlobalGenerator() ->GetGeneratorTarget(target); cmMakefile *makefile = target->GetMakefile(); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0815f476a47898cbb967ac684960a68dcc64ead7 commit 0815f476a47898cbb967ac684960a68dcc64ead7 Author: Stephen Kelly AuthorDate: Sat Jun 6 14:09:35 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 08:13:48 2015 +0200 cmGlobalGenerator: Base exclusion computation on cmGeneratorTarget. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 1d6608b..b14949a 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2022,10 +2022,10 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, } bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, - cmTarget const& target) const + cmGeneratorTarget* target) const { - if(target.GetType() == cmTarget::INTERFACE_LIBRARY - || target.GetPropertyAsBool("EXCLUDE_FROM_ALL")) + if(target->GetType() == cmTarget::INTERFACE_LIBRARY + || target->Target->GetPropertyAsBool("EXCLUDE_FROM_ALL")) { // This target is excluded from its directory. return true; @@ -2034,7 +2034,7 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, { // This target is included in its directory. Check whether the // directory is excluded. - return this->IsExcluded(root, target.GetMakefile()->GetLocalGenerator()); + return this->IsExcluded(root, target->GetLocalGenerator()); } } @@ -2095,15 +2095,16 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap() { cmTarget const& target = t->second; + cmGeneratorTarget* gt = this->GetGeneratorTarget(&target); + // Consider the directory containing the target and all its // parents until something excludes the target. - for(cmLocalGenerator* clg = lg; clg && !this->IsExcluded(clg, target); + for(cmLocalGenerator* clg = lg; clg && !this->IsExcluded(clg, gt); clg = clg->GetParent()) { // This local generator includes the target. std::set& targetSet = this->LocalGeneratorToTargetMap[clg]; - cmGeneratorTarget* gt = this->GetGeneratorTarget(&target); targetSet.insert(gt); // Add dependencies of the included target. An excluded diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 9492372..3be76b6 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -398,7 +398,7 @@ protected: void FillProjectMap(); void CheckLocalGenerators(); bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen) const; - bool IsExcluded(cmLocalGenerator* root, cmTarget const& target) const; + bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) const; void FillLocalGeneratorToTargetMap(); void CreateDefaultGlobalTargets(cmTargets* targets); cmTarget CreateGlobalTarget(const std::string& name, const char* message, diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 2a749c1..47822b4 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -289,7 +289,7 @@ public: const std::vector& GetLocalGenerators() const { return LocalGenerators; } - bool IsExcluded(cmLocalGenerator* root, cmTarget& target) { + bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) { return cmGlobalGenerator::IsExcluded(root, target); } int GetRuleCmdLength(const std::string& name) { diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 69747a4..76d059ee 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -821,7 +821,7 @@ cmGlobalUnixMakefileGenerator3 localName, depends, commands, true); // add the all/all dependency - if(!this->IsExcluded(this->LocalGenerators[0], *gtarget->Target)) + if(!this->IsExcluded(this->LocalGenerators[0], gtarget)) { depends.clear(); depends.push_back(localName); @@ -889,7 +889,7 @@ cmGlobalUnixMakefileGenerator3 "Pre-install relink rule for target.", localName, depends, commands, true); - if(!this->IsExcluded(this->LocalGenerators[0], *gtarget->Target)) + if(!this->IsExcluded(this->LocalGenerators[0], gtarget)) { depends.clear(); depends.push_back(localName); diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 2f9d79a..c3131c3 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -111,17 +111,18 @@ bool cmGlobalVisualStudioGenerator::Compute() for(std::vector::iterator i = gen.begin(); i != gen.end(); ++i) { - cmTargets& targets = (*i)->GetMakefile()->GetTargets(); - for(cmTargets::iterator t = targets.begin(); + cmGeneratorTargetsType targets = + lg->GetMakefile()->GetGeneratorTargets(); + for(cmGeneratorTargetsType::iterator t = targets.begin(); t != targets.end(); ++t) { - if (t->second.GetType() == cmTarget::GLOBAL_TARGET) + if (t->second->GetType() == cmTarget::GLOBAL_TARGET) { continue; } if(!this->IsExcluded(gen[0], t->second)) { - allBuild->AddUtility(t->second.GetName()); + allBuild->AddUtility(t->second->GetName()); } } } diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 9889bd4..1822c97 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -90,7 +90,7 @@ void cmLocalNinjaGenerator::Generate() // Add the target to "all" if required. if (!this->GetGlobalNinjaGenerator()->IsExcluded( this->GetGlobalNinjaGenerator()->GetLocalGenerators()[0], - *t->second->Target)) + t->second)) this->GetGlobalNinjaGenerator()->AddDependencyToAll(t->second->Target); delete tg; } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f6feed2c6d8fedb888a7b1fbb66d870c645c2251 commit f6feed2c6d8fedb888a7b1fbb66d870c645c2251 Author: Stephen Kelly AuthorDate: Sat Aug 1 08:08:17 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 08:11:11 2015 +0200 cmExportInstallFileGenerator: Simplify local generator access. diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 71875d5..f6d7168 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -362,7 +362,7 @@ cmExportInstallFileGenerator if(!properties.empty()) { // Get the rest of the target details. - cmGeneratorTarget *gtgt = te->Target->GetMakefile()->GetLocalGenerator() + cmGeneratorTarget *gtgt = te->Target->GetMakefile() ->GetGlobalGenerator()->GetGeneratorTarget(te->Target); this->SetImportDetailProperties(config, suffix, gtgt, properties, missingTargets); ----------------------------------------------------------------------- Summary of changes: Source/cmExportInstallFileGenerator.cxx | 4 ++-- Source/cmGeneratorTarget.cxx | 2 +- Source/cmGlobalGenerator.cxx | 13 +++++++------ Source/cmGlobalGenerator.h | 2 +- Source/cmGlobalNinjaGenerator.h | 2 +- Source/cmGlobalUnixMakefileGenerator3.cxx | 4 ++-- Source/cmGlobalVisualStudioGenerator.cxx | 9 +++++---- Source/cmInstallTargetGenerator.cxx | 3 +-- Source/cmLocalNinjaGenerator.cxx | 2 +- Source/cmMakefile.h | 4 ---- Source/cmQtAutoGenerators.cxx | 6 +++--- 11 files changed, 24 insertions(+), 27 deletions(-) hooks/post-receive -- CMake From steveire at gmail.com Sat Aug 1 02:30:02 2015 From: steveire at gmail.com (Stephen Kelly) Date: Sat, 1 Aug 2015 02:30:02 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1704-g425a983 Message-ID: <20150801063004.66138B0A46@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 425a983649ec4f59b33a22b6f94cb91232ac872a (commit) via 8cf3ec5418a8f248feb6b5250d9131892531d34e (commit) via 61f8705cff754bcb0e4866c1007ccfd714a57307 (commit) via 3ef7f4e4545e27212046730feea1d181dfb3ef4b (commit) via 0f0a97cac1ed50a3296c06c8259845b9213c9ddd (commit) via 33f6436d739691e8578c87e98739bd26262e118f (commit) via 274f2fbf6e819cb92286ac3b580b406a6c6f7c34 (commit) via 5a1ce558bd6354b1656e147cecc3738ff3a2ed90 (commit) via dcee4eee037ad10207e1436d04ffc4efbcd3665c (commit) via 21ea08a634b72b31c64ed1c40f2b1335713622d4 (commit) via fe3594afe1630308526f579cdab7a087bdbf5290 (commit) via b8a1aff82bb487f75357f4881ed7696f2623a138 (commit) via 3302e8fd81a3fc200f1fb83891639e33ac5126f8 (commit) via 29f2ec1e8bd91bb14248f446890f3d510cfb6002 (commit) via f27459f23ffb233928261de8272da67aca7089cd (commit) via 307fa71eae9bb1fb5dcc09daa7a271c886330959 (commit) via 23c6a8a1f73e10e8bc02a72a9a0fa41445af7485 (commit) via 8461d3ef795535dbf18495328cabd54fb25fc5d3 (commit) via d726f0467fdb283af70ed0854a335b4dd8d3aaef (commit) via f9225c4b929932edfb603c2bf93b80ced99580fe (commit) via b0bd29f8e55562f2c14d8786c0e465be89d5fd48 (commit) via 1da265b05c7f23532992a7916772c1b139becc72 (commit) via 4295b84a31a1b97773912f3854fb2129cf4cd2a9 (commit) via 27458764cf805ff9108276bfe75d5734768004eb (commit) via 4a95d13b9c711498204bcffb9e7ec02e46460df5 (commit) via 83a1b62f4ee15f6bd906540b951da7b9a2ae15ac (commit) via 5a6ca0b81f7835f86abf9f1467b98247e4463edd (commit) via 549965f7207741ebac8125f28b22ec32de6aa0e6 (commit) via 587a99a5afd6f6f7d7442cb32ede860916073eed (commit) via 81442d2f2f5161f7b10bda7b5c7747832677160a (commit) via b31befa035f6b3294fea71ffdcf1fc889688ffb9 (commit) via 3553d2fdfc6203136ad240702e4c77bdc349416d (commit) via 28c2e75eae70dace83ec6d51b77622ba592a148e (commit) via 8bd6bdd2b6289196bb45103b50b7f41729938dc1 (commit) via cb73dc2b25fcea8e60853e13411f8013de09f6b9 (commit) via e9ac5066f92e4418c176d5563b22d7d469dfe93c (commit) via 427aa20814b97726b52efaef54905d0ed1aa4e2c (commit) via 22c1a69a9c472bd2530ddb2c0a5dae38465f2271 (commit) from b4bb7753d5094346c64cb45cfb315d1e93f12dcb (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=425a983649ec4f59b33a22b6f94cb91232ac872a commit 425a983649ec4f59b33a22b6f94cb91232ac872a Merge: b4bb775 8cf3ec5 Author: Stephen Kelly AuthorDate: Sat Aug 1 02:29:54 2015 -0400 Commit: CMake Topic Stage CommitDate: Sat Aug 1 02:29:54 2015 -0400 Merge topic 'use-generator-target' into next 8cf3ec54 cmMakefile: Remove unused method. 61f8705c cmGlobalGenerator: Base exclusion computation on cmGeneratorTarget. 3ef7f4e4 cmGeneratorTarget: Move CompileInfoMap from cmTarget. 0f0a97ca cmGeneratorTarget: Move GetCompilePDBDirectory from cmTarget. 33f6436d cmGeneratorTarget: Move GetOutputName from cmTarget. 274f2fbf cmComputeLinkDepends: Port to cmGeneratorTarget. 5a1ce558 cmComputeLinkInformation: Port to cmGeneratorTarget. dcee4eee cmGeneratorTarget: Move IsBundleOnApple from cmTarget. 21ea08a6 cmMakefileTargetGenerator: Add accessor for GeneratorTarget. fe3594af cmGeneratorTarget: Move GetLinkClosure from cmTarget. b8a1aff8 cmGeneratorTarget: Move GetLinkerLanguage from cmTarget. 3302e8fd cmGeneratorTarget: Move GetFrameworkDirectory from cmTarget. 29f2ec1e cmGeneratorTarget: Move GetFullNameInternal from cmTarget. f27459f2 cmGeneratorTarget: Move GetFullName from cmTarget. 307fa71e cmGeneratorTarget: Move GetAppBundleDirectory from cmTarget. 23c6a8a1 cmGeneratorTarget: Move GetInstallNameDir* from cmTarget. ... http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8cf3ec5418a8f248feb6b5250d9131892531d34e commit 8cf3ec5418a8f248feb6b5250d9131892531d34e Author: Stephen Kelly AuthorDate: Sat Jun 6 14:27:52 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 08:28:29 2015 +0200 cmMakefile: Remove unused method. diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 1e5c301..00d4005 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -113,10 +113,6 @@ public: bool GetIsSourceFileTryCompile() const; - ///! Get the current makefile generator. - cmLocalGenerator* GetLocalGenerator() const - { return this->LocalGenerator;} - /** * Help enforce global target name uniqueness. */ http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=61f8705cff754bcb0e4866c1007ccfd714a57307 commit 61f8705cff754bcb0e4866c1007ccfd714a57307 Author: Stephen Kelly AuthorDate: Sat Jun 6 14:09:35 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 08:28:29 2015 +0200 cmGlobalGenerator: Base exclusion computation on cmGeneratorTarget. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 1d6608b..b14949a 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2022,10 +2022,10 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, } bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, - cmTarget const& target) const + cmGeneratorTarget* target) const { - if(target.GetType() == cmTarget::INTERFACE_LIBRARY - || target.GetPropertyAsBool("EXCLUDE_FROM_ALL")) + if(target->GetType() == cmTarget::INTERFACE_LIBRARY + || target->Target->GetPropertyAsBool("EXCLUDE_FROM_ALL")) { // This target is excluded from its directory. return true; @@ -2034,7 +2034,7 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, { // This target is included in its directory. Check whether the // directory is excluded. - return this->IsExcluded(root, target.GetMakefile()->GetLocalGenerator()); + return this->IsExcluded(root, target->GetLocalGenerator()); } } @@ -2095,15 +2095,16 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap() { cmTarget const& target = t->second; + cmGeneratorTarget* gt = this->GetGeneratorTarget(&target); + // Consider the directory containing the target and all its // parents until something excludes the target. - for(cmLocalGenerator* clg = lg; clg && !this->IsExcluded(clg, target); + for(cmLocalGenerator* clg = lg; clg && !this->IsExcluded(clg, gt); clg = clg->GetParent()) { // This local generator includes the target. std::set& targetSet = this->LocalGeneratorToTargetMap[clg]; - cmGeneratorTarget* gt = this->GetGeneratorTarget(&target); targetSet.insert(gt); // Add dependencies of the included target. An excluded diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 9492372..3be76b6 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -398,7 +398,7 @@ protected: void FillProjectMap(); void CheckLocalGenerators(); bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen) const; - bool IsExcluded(cmLocalGenerator* root, cmTarget const& target) const; + bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) const; void FillLocalGeneratorToTargetMap(); void CreateDefaultGlobalTargets(cmTargets* targets); cmTarget CreateGlobalTarget(const std::string& name, const char* message, diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 2a749c1..47822b4 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -289,7 +289,7 @@ public: const std::vector& GetLocalGenerators() const { return LocalGenerators; } - bool IsExcluded(cmLocalGenerator* root, cmTarget& target) { + bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) { return cmGlobalGenerator::IsExcluded(root, target); } int GetRuleCmdLength(const std::string& name) { diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 69747a4..76d059ee 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -821,7 +821,7 @@ cmGlobalUnixMakefileGenerator3 localName, depends, commands, true); // add the all/all dependency - if(!this->IsExcluded(this->LocalGenerators[0], *gtarget->Target)) + if(!this->IsExcluded(this->LocalGenerators[0], gtarget)) { depends.clear(); depends.push_back(localName); @@ -889,7 +889,7 @@ cmGlobalUnixMakefileGenerator3 "Pre-install relink rule for target.", localName, depends, commands, true); - if(!this->IsExcluded(this->LocalGenerators[0], *gtarget->Target)) + if(!this->IsExcluded(this->LocalGenerators[0], gtarget)) { depends.clear(); depends.push_back(localName); diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 2f9d79a..c3131c3 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -111,17 +111,18 @@ bool cmGlobalVisualStudioGenerator::Compute() for(std::vector::iterator i = gen.begin(); i != gen.end(); ++i) { - cmTargets& targets = (*i)->GetMakefile()->GetTargets(); - for(cmTargets::iterator t = targets.begin(); + cmGeneratorTargetsType targets = + lg->GetMakefile()->GetGeneratorTargets(); + for(cmGeneratorTargetsType::iterator t = targets.begin(); t != targets.end(); ++t) { - if (t->second.GetType() == cmTarget::GLOBAL_TARGET) + if (t->second->GetType() == cmTarget::GLOBAL_TARGET) { continue; } if(!this->IsExcluded(gen[0], t->second)) { - allBuild->AddUtility(t->second.GetName()); + allBuild->AddUtility(t->second->GetName()); } } } diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 9889bd4..1822c97 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -90,7 +90,7 @@ void cmLocalNinjaGenerator::Generate() // Add the target to "all" if required. if (!this->GetGlobalNinjaGenerator()->IsExcluded( this->GetGlobalNinjaGenerator()->GetLocalGenerators()[0], - *t->second->Target)) + t->second)) this->GetGlobalNinjaGenerator()->AddDependencyToAll(t->second->Target); delete tg; } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3ef7f4e4545e27212046730feea1d181dfb3ef4b commit 3ef7f4e4545e27212046730feea1d181dfb3ef4b Author: Stephen Kelly AuthorDate: Mon Oct 20 21:02:16 2014 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 08:28:29 2015 +0200 cmGeneratorTarget: Move CompileInfoMap from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c6f248c..c831704 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1356,6 +1356,46 @@ cmGeneratorTarget::GetMacContentDirectory(const std::string& config, return fpath; } + +//---------------------------------------------------------------------------- +cmGeneratorTarget::CompileInfo const* cmGeneratorTarget::GetCompileInfo( + const std::string& config) const +{ + // There is no compile information for imported targets. + if(this->IsImported()) + { + return 0; + } + + if(this->GetType() > cmTarget::OBJECT_LIBRARY) + { + std::string msg = "cmTarget::GetCompileInfo called for "; + msg += this->GetName(); + msg += " which has type "; + msg += cmTarget::GetTargetTypeName(this->Target->GetType()); + this->Makefile->IssueMessage(cmake::INTERNAL_ERROR, msg); + return 0; + } + + // Lookup/compute/cache the compile information for this configuration. + std::string config_upper; + if(!config.empty()) + { + config_upper = cmSystemTools::UpperCase(config); + } + CompileInfoMapType::const_iterator i = + this->CompileInfoMap.find(config_upper); + if(i == this->CompileInfoMap.end()) + { + CompileInfo info; + this->Target + ->ComputePDBOutputDir("COMPILE_PDB", config, info.CompilePdbDir); + CompileInfoMapType::value_type entry(config_upper, info); + i = this->CompileInfoMap.insert(entry).first; + } + return &i->second; +} + //---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetModuleDefinitionFile(const std::string& config) const @@ -1827,7 +1867,7 @@ void cmGeneratorTarget::TraceDependencies() std::string cmGeneratorTarget::GetCompilePDBDirectory(const std::string& config) const { - if(cmTarget::CompileInfo const* info = this->Target->GetCompileInfo(config)) + if(CompileInfo const* info = this->GetCompileInfo(config)) { return info->CompilePdbDir; } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index c291919..1d7a411 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -230,6 +230,16 @@ public: /** Whether this library has soname enabled and platform supports it. */ bool HasSOName(const std::string& config) const; + struct CompileInfo + { + std::string CompilePdbDir; + }; + + CompileInfo const* GetCompileInfo(const std::string& config) const; + + typedef std::map CompileInfoMapType; + mutable CompileInfoMapType CompileInfoMap; + /** Get the name of the compiler pdb file for the target. */ std::string GetCompilePDBName(const std::string& config="") const; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 9308113..1f8f07a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -126,9 +126,6 @@ public: typedef std::map ImportInfoMapType; ImportInfoMapType ImportInfoMap; - typedef std::map CompileInfoMapType; - CompileInfoMapType CompileInfoMap; - // Cache link implementation computation from each configuration. struct OptionalLinkImplementation: public cmTarget::LinkImplementation { @@ -2598,45 +2595,6 @@ cmTarget::OutputInfo const* cmTarget::GetOutputInfo( } //---------------------------------------------------------------------------- -cmTarget::CompileInfo const* cmTarget::GetCompileInfo( - const std::string& config) const -{ - // There is no compile information for imported targets. - if(this->IsImported()) - { - return 0; - } - - if(this->GetType() > cmTarget::OBJECT_LIBRARY) - { - std::string msg = "cmTarget::GetCompileInfo called for "; - msg += this->GetName(); - msg += " which has type "; - msg += cmTarget::GetTargetTypeName(this->GetType()); - this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg); - return 0; - } - - // Lookup/compute/cache the compile information for this configuration. - std::string config_upper; - if(!config.empty()) - { - config_upper = cmSystemTools::UpperCase(config); - } - typedef cmTargetInternals::CompileInfoMapType CompileInfoMapType; - CompileInfoMapType::const_iterator i = - this->Internal->CompileInfoMap.find(config_upper); - if(i == this->Internal->CompileInfoMap.end()) - { - CompileInfo info; - this->ComputePDBOutputDir("COMPILE_PDB", config, info.CompilePdbDir); - CompileInfoMapType::value_type entry(config_upper, info); - i = this->Internal->CompileInfoMap.insert(entry).first; - } - return &i->second; -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetDirectory(const std::string& config, bool implib) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 8689838..e3fbdfd 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -626,13 +626,6 @@ private: void ComputeImportInfo(std::string const& desired_config, ImportInfo& info) const; - // Cache target compile paths for each configuration. - struct CompileInfo - { - std::string CompilePdbDir; - }; - - CompileInfo const* GetCompileInfo(const std::string& config) const; LinkInterface const* GetImportLinkInterface(const std::string& config, cmTarget const* head, http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0f0a97cac1ed50a3296c06c8259845b9213c9ddd commit 0f0a97cac1ed50a3296c06c8259845b9213c9ddd Author: Stephen Kelly AuthorDate: Mon Oct 20 20:52:54 2014 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 08:28:29 2015 +0200 cmGeneratorTarget: Move GetCompilePDBDirectory from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index aac941e..c6f248c 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -743,7 +743,7 @@ cmGeneratorTarget::GetCompilePDBName(const std::string& config) const std::string cmGeneratorTarget::GetCompilePDBPath(const std::string& config) const { - std::string dir = this->Target->GetCompilePDBDirectory(config); + std::string dir = this->GetCompilePDBDirectory(config); std::string name = this->GetCompilePDBName(config); if(dir.empty() && !name.empty()) { @@ -1824,6 +1824,16 @@ void cmGeneratorTarget::TraceDependencies() tracer.Trace(); } +std::string +cmGeneratorTarget::GetCompilePDBDirectory(const std::string& config) const +{ + if(cmTarget::CompileInfo const* info = this->Target->GetCompileInfo(config)) + { + return info->CompilePdbDir; + } + return ""; +} + //---------------------------------------------------------------------------- void cmGeneratorTarget::GetAppleArchs(const std::string& config, std::vector& archVec) const diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 31b3178..c291919 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -214,6 +214,12 @@ public: */ void TraceDependencies(); + /** Get the directory in which to place the target compiler .pdb file. + If the configuration name is given then the generator will add its + subdirectory for that configuration. Otherwise just the canonical + compiler pdb output directory is given. */ + std::string GetCompilePDBDirectory(const std::string& config = "") const; + /** Get sources that must be built before the given source. */ std::vector const* GetSourceDepends(cmSourceFile const* sf) const; diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index afe145a..ccb0974 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -130,7 +130,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) } std::string compilePdbOutputPath = - this->Target->GetCompilePDBDirectory(this->ConfigName); + this->GeneratorTarget->GetCompilePDBDirectory(this->ConfigName); cmSystemTools::MakeDirectory(compilePdbOutputPath.c_str()); std::string pdbOutputPath = this->Target->GetPDBDirectory(this->ConfigName); diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index bb0f9dd..2f995e8 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -311,7 +311,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules } std::string compilePdbOutputPath = - this->Target->GetCompilePDBDirectory(this->ConfigName); + this->GeneratorTarget->GetCompilePDBDirectory(this->ConfigName); cmSystemTools::MakeDirectory(compilePdbOutputPath.c_str()); std::string pdbOutputPath = this->Target->GetPDBDirectory(this->ConfigName); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 8b64bc4..9308113 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -69,12 +69,6 @@ struct cmTarget::OutputInfo }; //---------------------------------------------------------------------------- -struct cmTarget::CompileInfo -{ - std::string CompilePdbDir; -}; - -//---------------------------------------------------------------------------- class cmTargetInternals { public: @@ -2673,16 +2667,6 @@ std::string cmTarget::GetPDBDirectory(const std::string& config) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetCompilePDBDirectory(const std::string& config) const -{ - if(CompileInfo const* info = this->GetCompileInfo(config)) - { - return info->CompilePdbDir; - } - return ""; -} - -//---------------------------------------------------------------------------- const char* cmTarget::ImportedGetLocation(const std::string& config) const { static std::string location; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index a6f2465..8689838 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -334,12 +334,6 @@ public: pdb output directory is given. */ std::string GetPDBDirectory(const std::string& config) const; - /** Get the directory in which to place the target compiler .pdb file. - If the configuration name is given then the generator will add its - subdirectory for that configuration. Otherwise just the canonical - compiler pdb output directory is given. */ - std::string GetCompilePDBDirectory(const std::string& config = "") const; - const char* ImportedGetLocation(const std::string& config) const; /** Get the target major and minor version numbers interpreted from @@ -633,7 +627,11 @@ private: ImportInfo& info) const; // Cache target compile paths for each configuration. - struct CompileInfo; + struct CompileInfo + { + std::string CompilePdbDir; + }; + CompileInfo const* GetCompileInfo(const std::string& config) const; LinkInterface const* http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=33f6436d739691e8578c87e98739bd26262e118f commit 33f6436d739691e8578c87e98739bd26262e118f Author: Stephen Kelly AuthorDate: Sat Aug 1 07:04:23 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 08:28:29 2015 +0200 cmGeneratorTarget: Move GetOutputName from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 55e2922..aac941e 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -267,6 +267,54 @@ const char *cmGeneratorTarget::GetProperty(const std::string& prop) const } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetOutputName(const std::string& config, + bool implib) const +{ + std::vector props; + std::string type = this->Target->GetOutputTargetType(implib); + std::string configUpper = cmSystemTools::UpperCase(config); + if(!type.empty() && !configUpper.empty()) + { + // _OUTPUT_NAME_ + props.push_back(type + "_OUTPUT_NAME_" + configUpper); + } + if(!type.empty()) + { + // _OUTPUT_NAME + props.push_back(type + "_OUTPUT_NAME"); + } + if(!configUpper.empty()) + { + // OUTPUT_NAME_ + props.push_back("OUTPUT_NAME_" + configUpper); + // _OUTPUT_NAME + props.push_back(configUpper + "_OUTPUT_NAME"); + } + // OUTPUT_NAME + props.push_back("OUTPUT_NAME"); + + std::string outName; + for(std::vector::const_iterator i = props.begin(); + i != props.end(); ++i) + { + if (const char* outNameProp = this->Target->GetProperty(*i)) + { + outName = outNameProp; + break; + } + } + + if (outName.empty()) + { + outName = this->GetName(); + } + + cmGeneratorExpression ge; + cmsys::auto_ptr cge = ge.Parse(outName); + return cge->Evaluate(this->Makefile, config); +} + +//---------------------------------------------------------------------------- std::vector const* cmGeneratorTarget::GetSourceDepends(cmSourceFile const* sf) const { @@ -922,7 +970,7 @@ std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config, bool contentOnly) const { std::string fpath; - fpath += this->Target->GetOutputName(config, false); + fpath += this->GetOutputName(config, false); fpath += "."; const char *ext = this->Target->GetProperty("BUNDLE_EXTENSION"); if (!ext) @@ -949,7 +997,7 @@ cmGeneratorTarget::GetFrameworkDirectory(const std::string& config, bool rootDir) const { std::string fpath; - fpath += this->Target->GetOutputName(config, false); + fpath += this->GetOutputName(config, false); fpath += ".framework"; if(!rootDir) { @@ -2247,7 +2295,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, std::string fw_prefix; if(this->Target->IsFrameworkOnApple()) { - fw_prefix = this->Target->GetOutputName(config, false); + fw_prefix = this->GetOutputName(config, false); fw_prefix += ".framework/"; targetPrefix = fw_prefix.c_str(); targetSuffix = 0; @@ -2265,7 +2313,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, outPrefix = targetPrefix?targetPrefix:""; // Append the target name or property-specified name. - outBase += this->Target->GetOutputName(config, implib); + outBase += this->GetOutputName(config, implib); // Append the per-configuration postfix. outBase += configPostfix?configPostfix:""; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index d10cd1d..31b3178 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -230,6 +230,9 @@ public: /** Get the path for the MSVC /Fd option for this target. */ std::string GetCompilePDBPath(const std::string& config="") const; + // Get the target base name. + std::string GetOutputName(const std::string& config, bool implib) const; + /** * Flags for a given source file as used in this target. Typically assigned * via SET_TARGET_PROPERTIES when the property is a list of source files. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e887ef3..8b64bc4 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3663,54 +3663,6 @@ bool cmTarget::UsesDefaultOutputDir(const std::string& config, } //---------------------------------------------------------------------------- -std::string cmTarget::GetOutputName(const std::string& config, - bool implib) const -{ - std::vector props; - std::string type = this->GetOutputTargetType(implib); - std::string configUpper = cmSystemTools::UpperCase(config); - if(!type.empty() && !configUpper.empty()) - { - // _OUTPUT_NAME_ - props.push_back(type + "_OUTPUT_NAME_" + configUpper); - } - if(!type.empty()) - { - // _OUTPUT_NAME - props.push_back(type + "_OUTPUT_NAME"); - } - if(!configUpper.empty()) - { - // OUTPUT_NAME_ - props.push_back("OUTPUT_NAME_" + configUpper); - // _OUTPUT_NAME - props.push_back(configUpper + "_OUTPUT_NAME"); - } - // OUTPUT_NAME - props.push_back("OUTPUT_NAME"); - - std::string outName; - for(std::vector::const_iterator i = props.begin(); - i != props.end(); ++i) - { - if (const char* outNameProp = this->GetProperty(*i)) - { - outName = outNameProp; - break; - } - } - - if (outName.empty()) - { - outName = this->GetName(); - } - - cmGeneratorExpression ge; - cmsys::auto_ptr cge = ge.Parse(outName); - return cge->Evaluate(this->Makefile, config); -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetFrameworkVersion() const { assert(this->GetType() != INTERFACE_LIBRARY); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e53afff..a6f2465 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -552,9 +552,6 @@ private: // Returns ARCHIVE, LIBRARY, or RUNTIME based on platform and type. const char* GetOutputTargetType(bool implib) const; - // Get the target base name. - std::string GetOutputName(const std::string& config, bool implib) const; - std::string GetFullNameImported(const std::string& config, bool implib) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=274f2fbf6e819cb92286ac3b580b406a6c6f7c34 commit 274f2fbf6e819cb92286ac3b580b406a6c6f7c34 Author: Stephen Kelly AuthorDate: Thu Jul 30 00:45:34 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 08:28:28 2015 +0200 cmComputeLinkDepends: Port to cmGeneratorTarget. diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index abd9877..8ba8847 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -173,18 +173,19 @@ items that we know the linker will re-use automatically (shared libs). //---------------------------------------------------------------------------- cmComputeLinkDepends -::cmComputeLinkDepends(cmTarget const* target, const std::string& config) +::cmComputeLinkDepends(const cmGeneratorTarget* target, + const std::string& config) { // Store context information. this->Target = target; - this->Makefile = this->Target->GetMakefile(); + this->Makefile = this->Target->Target->GetMakefile(); this->GlobalGenerator = this->Makefile->GetGlobalGenerator(); this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance(); // The configuration being linked. this->HasConfig = !config.empty(); this->Config = (this->HasConfig)? config : std::string(); - this->LinkType = this->Target->ComputeLinkType(this->Config); + this->LinkType = this->Target->Target->ComputeLinkType(this->Config); // Enable debug mode if requested. this->DebugMode = this->Makefile->IsOn("CMAKE_LINK_DEPENDS_DEBUG_MODE"); @@ -363,7 +364,7 @@ void cmComputeLinkDepends::FollowLinkEntry(BFSEntry const& qe) { // Follow the target dependencies. if(cmTarget::LinkInterface const* iface = - entry.Target->GetLinkInterface(this->Config, this->Target)) + entry.Target->GetLinkInterface(this->Config, this->Target->Target)) { const bool isIface = entry.Target->GetType() == cmTarget::INTERFACE_LIBRARY; @@ -461,7 +462,7 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep) if(entry.Target) { if(cmTarget::LinkInterface const* iface = - entry.Target->GetLinkInterface(this->Config, this->Target)) + entry.Target->GetLinkInterface(this->Config, this->Target->Target)) { // Follow public and private dependencies transitively. this->FollowSharedDeps(index, iface, true); @@ -552,7 +553,7 @@ void cmComputeLinkDepends::AddDirectLinkEntries() { // Add direct link dependencies in this configuration. cmTarget::LinkImplementation const* impl = - this->Target->GetLinkImplementation(this->Config); + this->Target->Target->GetLinkImplementation(this->Config); this->AddLinkEntries(-1, impl->Libraries); for(std::vector::const_iterator wi = impl->WrongConfigLibraries.begin(); @@ -634,7 +635,7 @@ cmTarget const* cmComputeLinkDepends::FindTargetToLink(int depender_index, const std::string& name) { // Look for a target in the scope of the depender. - cmTarget const* from = this->Target; + cmTarget const* from = this->Target->Target; if(depender_index >= 0) { if(cmTarget const* depender = this->EntryList[depender_index].Target) @@ -932,7 +933,7 @@ int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl) if(cmTarget const* target = this->EntryList[*ni].Target) { if(cmTarget::LinkInterface const* iface = - target->GetLinkInterface(this->Config, this->Target)) + target->GetLinkInterface(this->Config, this->Target->Target)) { if(iface->Multiplicity > count) { diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index 51a08c5..b925a4f 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -22,6 +22,7 @@ class cmComputeComponentGraph; class cmGlobalGenerator; class cmMakefile; +class cmGeneratorTarget; class cmTarget; class cmake; @@ -31,7 +32,8 @@ class cmake; class cmComputeLinkDepends { public: - cmComputeLinkDepends(cmTarget const* target, const std::string& config); + cmComputeLinkDepends(cmGeneratorTarget const* target, + const std::string& config); ~cmComputeLinkDepends(); // Basic information about each link item. @@ -57,7 +59,7 @@ public: private: // Context information. - cmTarget const* Target; + cmGeneratorTarget const* Target; cmMakefile* Makefile; cmGlobalGenerator const* GlobalGenerator; cmake* CMakeInstance; diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index fb89319..5cd0d54 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -497,7 +497,7 @@ bool cmComputeLinkInformation::Compute() } // Compute the ordered link line items. - cmComputeLinkDepends cld(this->Target->Target, this->Config); + cmComputeLinkDepends cld(this->Target, this->Config); cld.SetOldLinkDirMode(this->OldLinkDirMode); cmComputeLinkDepends::EntryVector const& linkEntries = cld.Compute(); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5a1ce558bd6354b1656e147cecc3738ff3a2ed90 commit 5a1ce558bd6354b1656e147cecc3738ff3a2ed90 Author: Stephen Kelly AuthorDate: Thu Jul 30 00:41:27 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 08:28:28 2015 +0200 cmComputeLinkInformation: Port to cmGeneratorTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index f03c04a..fb89319 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -242,11 +242,12 @@ because this need be done only for shared libraries without soname-s. //---------------------------------------------------------------------------- cmComputeLinkInformation -::cmComputeLinkInformation(cmTarget const* target, const std::string& config) +::cmComputeLinkInformation(const cmGeneratorTarget* target, + const std::string& config) { // Store context information. this->Target = target; - this->Makefile = this->Target->GetMakefile(); + this->Makefile = this->Target->Target->GetMakefile(); this->GlobalGenerator = this->Makefile->GetGlobalGenerator(); this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance(); @@ -259,17 +260,15 @@ cmComputeLinkInformation // Allocate internals. this->OrderLinkerSearchPath = - new cmOrderDirectories(this->GlobalGenerator, target, + new cmOrderDirectories(this->GlobalGenerator, target->Target, "linker search path"); this->OrderRuntimeSearchPath = - new cmOrderDirectories(this->GlobalGenerator, target, + new cmOrderDirectories(this->GlobalGenerator, target->Target, "runtime search path"); this->OrderDependentRPath = 0; - cmGeneratorTarget *gtgt = this->GlobalGenerator - ->GetGeneratorTarget(this->Target); // Get the language used for linking this target. - this->LinkLanguage = gtgt->GetLinkerLanguage(config); + this->LinkLanguage = this->Target->GetLinkerLanguage(config); if(this->LinkLanguage.empty()) { // The Compute method will do nothing, so skip the rest of the @@ -283,14 +282,14 @@ cmComputeLinkInformation // Check whether we should skip dependencies on shared library files. this->LinkDependsNoShared = - this->Target->GetPropertyAsBool("LINK_DEPENDS_NO_SHARED"); + this->Target->Target->GetPropertyAsBool("LINK_DEPENDS_NO_SHARED"); // On platforms without import libraries there may be a special flag // to use when creating a plugin (module) that obtains symbols from // the program that will load it. this->LoaderFlag = 0; if(!this->UseImportLibrary && - this->Target->GetType() == cmTarget::MODULE_LIBRARY) + this->Target->Target->GetType() == cmTarget::MODULE_LIBRARY) { std::string loader_flag_var = "CMAKE_SHARED_MODULE_LOADER_"; loader_flag_var += this->LinkLanguage; @@ -308,10 +307,10 @@ cmComputeLinkInformation // Get options needed to specify RPATHs. this->RuntimeUseChrpath = false; - if(this->Target->GetType() != cmTarget::STATIC_LIBRARY) + if(this->Target->Target->GetType() != cmTarget::STATIC_LIBRARY) { const char* tType = - ((this->Target->GetType() == cmTarget::EXECUTABLE)? + ((this->Target->Target->GetType() == cmTarget::EXECUTABLE)? "EXECUTABLE" : "SHARED_LIBRARY"); std::string rtVar = "CMAKE_"; rtVar += tType; @@ -325,7 +324,7 @@ cmComputeLinkInformation (this->Makefile-> GetSafeDefinition("CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH")); - this->RuntimeUseChrpath = gtgt->IsChrpathUsed(config); + this->RuntimeUseChrpath = this->Target->IsChrpathUsed(config); // Get options needed to help find dependent libraries. std::string rlVar = "CMAKE_"; @@ -371,15 +370,15 @@ cmComputeLinkInformation { this->SharedDependencyMode = SharedDepModeDir; this->OrderDependentRPath = - new cmOrderDirectories(this->GlobalGenerator, target, + new cmOrderDirectories(this->GlobalGenerator, target->Target, "dependent library path"); } // Add the search path entries requested by the user to path ordering. this->OrderLinkerSearchPath - ->AddUserDirectories(this->Target->GetLinkDirectories()); + ->AddUserDirectories(this->Target->Target->GetLinkDirectories()); this->OrderRuntimeSearchPath - ->AddUserDirectories(this->Target->GetLinkDirectories()); + ->AddUserDirectories(this->Target->Target->GetLinkDirectories()); // Set up the implicit link directories. this->LoadImplicitLinkInfo(); @@ -407,12 +406,13 @@ cmComputeLinkInformation // order to support such projects we need to add the directories // containing libraries linked with a full path to the -L path. this->OldLinkDirMode = - this->Target->GetPolicyStatusCMP0003() != cmPolicies::NEW; + this->Target->Target->GetPolicyStatusCMP0003() != cmPolicies::NEW; if(this->OldLinkDirMode) { // Construct a mask to not bother with this behavior for link // directories already specified by the user. - std::vector const& dirs = this->Target->GetLinkDirectories(); + std::vector const& dirs = + this->Target->Target->GetLinkDirectories(); this->OldLinkDirMask.insert(dirs.begin(), dirs.end()); } @@ -497,7 +497,7 @@ bool cmComputeLinkInformation::Compute() } // Compute the ordered link line items. - cmComputeLinkDepends cld(this->Target, this->Config); + cmComputeLinkDepends cld(this->Target->Target, this->Config); cld.SetOldLinkDirMode(this->OldLinkDirMode); cmComputeLinkDepends::EntryVector const& linkEntries = cld.Compute(); @@ -518,7 +518,8 @@ bool cmComputeLinkInformation::Compute() // Restore the target link type so the correct system runtime // libraries are found. - const char* lss = this->Target->GetProperty("LINK_SEARCH_END_STATIC"); + const char* lss = + this->Target->Target->GetProperty("LINK_SEARCH_END_STATIC"); if(cmSystemTools::IsOn(lss)) { this->SetCurrentLinkType(LinkStatic); @@ -571,7 +572,7 @@ bool cmComputeLinkInformation::Compute() "name." ; this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); } return true; @@ -580,12 +581,9 @@ bool cmComputeLinkInformation::Compute() //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddImplicitLinkInfo() { - cmGeneratorTarget *gtgt = this->Target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(this->Target); - // The link closure lists all languages whose implicit info is needed. - cmGeneratorTarget::LinkClosure const* lc=gtgt->GetLinkClosure(this->Config); + cmGeneratorTarget::LinkClosure const* lc = + this->Target->GetLinkClosure(this->Config); for(std::vector::const_iterator li = lc->Languages.begin(); li != lc->Languages.end(); ++li) { @@ -863,7 +861,8 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo() } // Lookup the starting link type from the target (linked statically?). - const char* lss = this->Target->GetProperty("LINK_SEARCH_START_STATIC"); + const char* lss = + this->Target->Target->GetProperty("LINK_SEARCH_START_STATIC"); this->StartLinkType = cmSystemTools::IsOn(lss)? LinkStatic : LinkShared; this->CurrentLinkType = this->StartLinkType; } @@ -1149,7 +1148,7 @@ void cmComputeLinkInformation::AddFullItem(std::string const& item) // Full path libraries should specify a valid library file name. // See documentation of CMP0008. std::string generator = this->GlobalGenerator->GetName(); - if(this->Target->GetPolicyStatusCMP0008() != cmPolicies::NEW && + if(this->Target->Target->GetPolicyStatusCMP0008() != cmPolicies::NEW && (generator.find("Visual Studio") != generator.npos || generator.find("Xcode") != generator.npos)) { @@ -1230,7 +1229,7 @@ bool cmComputeLinkInformation::CheckImplicitDirItem(std::string const& item) } // Check the policy for whether we should use the approach below. - switch (this->Target->GetPolicyStatusCMP0060()) + switch (this->Target->Target->GetPolicyStatusCMP0060()) { case cmPolicies::WARN: if (this->CMP0060Warn) @@ -1540,7 +1539,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item, this->OrderLinkerSearchPath->AddLinkLibrary(item); // Produce any needed message. - switch(this->Target->GetPolicyStatusCMP0008()) + switch(this->Target->Target->GetPolicyStatusCMP0008()) { case cmPolicies::WARN: { @@ -1557,7 +1556,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item, << " " << item << "\n" << "which is a full-path but not a valid library file name."; this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); } } case cmPolicies::OLD: @@ -1575,7 +1574,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item, << " " << item << "\n" << "which is a full-path but not a valid library file name."; this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); } break; } @@ -1592,7 +1591,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories() } // Enforce policy constraints. - switch(this->Target->GetPolicyStatusCMP0003()) + switch(this->Target->Target->GetPolicyStatusCMP0003()) { case cmPolicies::WARN: if(!this->CMakeInstance->GetState() @@ -1603,7 +1602,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories() std::ostringstream w; this->PrintLinkPolicyDiagnosis(w); this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); } case cmPolicies::OLD: // OLD behavior is to add the paths containing libraries with @@ -1619,7 +1618,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories() e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0003) << "\n"; this->PrintLinkPolicyDiagnosis(e); this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); return false; } } @@ -1923,23 +1922,24 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, // build tree. bool linking_for_install = (for_install || - this->Target->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")); + this->Target->Target->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")); bool use_install_rpath = - (outputRuntime && this->Target->HaveInstallTreeRPATH() && + (outputRuntime && this->Target->Target->HaveInstallTreeRPATH() && linking_for_install); bool use_build_rpath = - (outputRuntime && this->Target->HaveBuildTreeRPATH(this->Config) && + (outputRuntime && this->Target->Target->HaveBuildTreeRPATH(this->Config) && !linking_for_install); bool use_link_rpath = outputRuntime && linking_for_install && !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH") && - this->Target->GetPropertyAsBool("INSTALL_RPATH_USE_LINK_PATH"); + this->Target->Target->GetPropertyAsBool("INSTALL_RPATH_USE_LINK_PATH"); // Construct the RPATH. std::set emitted; if(use_install_rpath) { - const char* install_rpath = this->Target->GetProperty("INSTALL_RPATH"); + const char* install_rpath = + this->Target->Target->GetProperty("INSTALL_RPATH"); cmCLI_ExpandListUnique(install_rpath, runtimeDirs, emitted); } if(use_build_rpath || use_link_rpath) @@ -2011,12 +2011,8 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, // Add runtime paths required by the languages to always be // present. This is done even when skipping rpath support. { - cmGeneratorTarget *gtgt = this->Makefile - ->GetGlobalGenerator() - ->GetGeneratorTarget(this->Target); - cmGeneratorTarget::LinkClosure const* lc = - gtgt->GetLinkClosure(this->Config); + this->Target->GetLinkClosure(this->Config); for(std::vector::const_iterator li = lc->Languages.begin(); li != lc->Languages.end(); ++li) { diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index 2d7a5a5..8b83574 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -29,7 +29,8 @@ class cmOrderDirectories; class cmComputeLinkInformation { public: - cmComputeLinkInformation(cmTarget const* target, const std::string& config); + cmComputeLinkInformation(cmGeneratorTarget const* target, + const std::string& config); ~cmComputeLinkInformation(); bool Compute(); @@ -73,7 +74,7 @@ private: std::set SharedLibrariesLinked; // Context information. - cmTarget const* Target; + cmGeneratorTarget const* Target; cmMakefile* Makefile; cmGlobalGenerator* GlobalGenerator; cmake* CMakeInstance; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c68c2b9..55e2922 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3166,7 +3166,7 @@ cmGeneratorTarget::GetLinkInformation(const std::string& config) const { // Compute information for this configuration. cmComputeLinkInformation* info = - new cmComputeLinkInformation(this->Target, config); + new cmComputeLinkInformation(this, config); if(!info || !info->Compute()) { delete info; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=dcee4eee037ad10207e1436d04ffc4efbcd3665c commit dcee4eee037ad10207e1436d04ffc4efbcd3665c Author: Stephen Kelly AuthorDate: Tue Jul 28 23:16:43 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 08:28:28 2015 +0200 cmGeneratorTarget: Move IsBundleOnApple from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c314372..c68c2b9 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -910,6 +910,14 @@ cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, } //---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsBundleOnApple() const +{ + return this->Target->IsFrameworkOnApple() + || this->Target->IsAppBundleOnApple() + || this->Target->IsCFBundleOnApple(); +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config, bool contentOnly) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 4299053..d10cd1d 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -119,6 +119,10 @@ public: std::string GetAppBundleDirectory(const std::string& config, bool contentOnly) const; + /** Return whether this target is an executable Bundle, a framework + or CFBundle on Apple. */ + bool IsBundleOnApple() const; + /** Get the full name of the target according to the settings in its makefile. */ std::string GetFullName(const std::string& config="", diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index d38cf4c..0b3df90 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -313,7 +313,7 @@ cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator() (cmSourceFile const& source, const char* pkgloc) { // Skip OS X content when not building a Framework or Bundle. - if(!this->Generator->GetTarget()->IsBundleOnApple()) + if(!this->Generator->GetGeneratorTarget()->IsBundleOnApple()) { return; } diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 16e1f48..07efa16 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -742,7 +742,7 @@ cmNinjaTargetGenerator::MacOSXContentGeneratorType::operator()( cmSourceFile const& source, const char* pkgloc) { // Skip OS X content when not building a Framework or Bundle. - if(!this->Generator->GetTarget()->IsBundleOnApple()) + if(!this->Generator->GetGeneratorTarget()->IsBundleOnApple()) { return; } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 62aa12a..e887ef3 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -590,13 +590,6 @@ bool cmTarget::IsXCTestOnApple() const } //---------------------------------------------------------------------------- -bool cmTarget::IsBundleOnApple() const -{ - return this->IsFrameworkOnApple() || this->IsAppBundleOnApple() || - this->IsCFBundleOnApple(); -} - -//---------------------------------------------------------------------------- static bool processSources(cmTarget const* tgt, const std::vector &entries, std::vector &srcs, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 9a4915f..e53afff 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -424,10 +424,6 @@ public: /** Return whether this target is an executable Bundle on Apple. */ bool IsAppBundleOnApple() const; - /** Return whether this target is an executable Bundle, a framework - or CFBundle on Apple. */ - bool IsBundleOnApple() const; - /** Return the framework version string. Undefined if IsFrameworkOnApple returns false. */ std::string GetFrameworkVersion() const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=21ea08a634b72b31c64ed1c40f2b1335713622d4 commit 21ea08a634b72b31c64ed1c40f2b1335713622d4 Author: Stephen Kelly AuthorDate: Tue Jul 28 23:18:55 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 08:28:28 2015 +0200 cmMakefileTargetGenerator: Add accessor for GeneratorTarget. diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index b885672..fd4527b 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -53,6 +53,7 @@ public: { return this->ProgressFileNameFull; } cmTarget* GetTarget() { return this->Target;} + cmGeneratorTarget* GetGeneratorTarget() { return this->GeneratorTarget;} protected: http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fe3594afe1630308526f579cdab7a087bdbf5290 commit fe3594afe1630308526f579cdab7a087bdbf5290 Author: Stephen Kelly AuthorDate: Wed Oct 10 21:43:28 2012 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 08:28:28 2015 +0200 cmGeneratorTarget: Move GetLinkClosure from cmTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 640e806..f03c04a 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -19,6 +19,7 @@ #include "cmOutputConverter.h" #include "cmMakefile.h" #include "cmTarget.h" +#include "cmGeneratorTarget.h" #include "cmake.h" #include "cmAlgorithms.h" @@ -579,8 +580,12 @@ bool cmComputeLinkInformation::Compute() //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddImplicitLinkInfo() { + cmGeneratorTarget *gtgt = this->Target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(this->Target); + // The link closure lists all languages whose implicit info is needed. - cmTarget::LinkClosure const* lc=this->Target->GetLinkClosure(this->Config); + cmGeneratorTarget::LinkClosure const* lc=gtgt->GetLinkClosure(this->Config); for(std::vector::const_iterator li = lc->Languages.begin(); li != lc->Languages.end(); ++li) { @@ -2006,8 +2011,12 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, // Add runtime paths required by the languages to always be // present. This is done even when skipping rpath support. { - cmTarget::LinkClosure const* lc = - this->Target->GetLinkClosure(this->Config); + cmGeneratorTarget *gtgt = this->Makefile + ->GetGlobalGenerator() + ->GetGeneratorTarget(this->Target); + + cmGeneratorTarget::LinkClosure const* lc = + gtgt->GetLinkClosure(this->Config); for(std::vector::const_iterator li = lc->Languages.begin(); li != lc->Languages.end(); ++li) { diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index 3afbb92..2d7a5a5 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -20,6 +20,7 @@ class cmake; class cmGlobalGenerator; class cmMakefile; class cmTarget; +class cmGeneratorTarget; class cmOrderDirectories; /** \class cmComputeLinkInformation diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 4de5e9c..c314372 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -27,6 +27,13 @@ #include #include "assert.h" +#if defined(CMAKE_BUILD_WITH_CMAKE) +#include +#define UNORDERED_SET cmsys::hash_set +#else +#define UNORDERED_SET std::set +#endif + //---------------------------------------------------------------------------- void reportBadObjLib(std::vector const& badObjLib, cmTarget *target, cmake *cm) @@ -1026,6 +1033,223 @@ std::string cmGeneratorTarget::GetInstallNameDirForInstallTree() const } //---------------------------------------------------------------------------- +class cmTargetCollectLinkLanguages +{ +public: + cmTargetCollectLinkLanguages(cmGeneratorTarget const* target, + const std::string& config, + UNORDERED_SET& languages, + cmTarget const* head): + Config(config), Languages(languages), HeadTarget(head), + Makefile(target->Target->GetMakefile()), Target(target) + { this->Visited.insert(target->Target); } + + void Visit(cmLinkItem const& item) + { + if(!item.Target) + { + if(item.find("::") != std::string::npos) + { + bool noMessage = false; + cmake::MessageType messageType = cmake::FATAL_ERROR; + std::stringstream e; + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0028)) + { + case cmPolicies::WARN: + { + e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0028) << "\n"; + messageType = cmake::AUTHOR_WARNING; + } + break; + case cmPolicies::OLD: + noMessage = true; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::NEW: + // Issue the fatal message. + break; + } + + if(!noMessage) + { + e << "Target \"" << this->Target->GetName() + << "\" links to target \"" << item + << "\" but the target was not found. Perhaps a find_package() " + "call is missing for an IMPORTED target, or an ALIAS target is " + "missing?"; + this->Makefile->GetCMakeInstance()->IssueMessage( + messageType, e.str(), this->Target->Target->GetBacktrace()); + } + } + return; + } + if(!this->Visited.insert(item.Target).second) + { + return; + } + + cmTarget::LinkInterface const* iface = + item.Target->GetLinkInterface(this->Config, this->HeadTarget); + if(!iface) { return; } + + for(std::vector::const_iterator + li = iface->Languages.begin(); li != iface->Languages.end(); ++li) + { + this->Languages.insert(*li); + } + + for(std::vector::const_iterator + li = iface->Libraries.begin(); li != iface->Libraries.end(); ++li) + { + this->Visit(*li); + } + } +private: + std::string Config; + UNORDERED_SET& Languages; + cmTarget const* HeadTarget; + cmMakefile* Makefile; + const cmGeneratorTarget* Target; + std::set Visited; +}; + +//---------------------------------------------------------------------------- +cmGeneratorTarget::LinkClosure const* +cmGeneratorTarget::GetLinkClosure(const std::string& config) const +{ + std::string key(cmSystemTools::UpperCase(config)); + LinkClosureMapType::iterator + i = this->LinkClosureMap.find(key); + if(i == this->LinkClosureMap.end()) + { + LinkClosure lc; + this->ComputeLinkClosure(config, lc); + LinkClosureMapType::value_type entry(key, lc); + i = this->LinkClosureMap.insert(entry).first; + } + return &i->second; +} + +//---------------------------------------------------------------------------- +class cmTargetSelectLinker +{ + int Preference; + cmGeneratorTarget const* Target; + cmMakefile* Makefile; + cmGlobalGenerator* GG; + std::set Preferred; +public: + cmTargetSelectLinker(cmGeneratorTarget const* target) + : Preference(0), Target(target) + { + this->Makefile = this->Target->Makefile; + this->GG = this->Makefile->GetGlobalGenerator(); + } + void Consider(const char* lang) + { + int preference = this->GG->GetLinkerPreference(lang); + if(preference > this->Preference) + { + this->Preference = preference; + this->Preferred.clear(); + } + if(preference == this->Preference) + { + this->Preferred.insert(lang); + } + } + std::string Choose() + { + if(this->Preferred.empty()) + { + return ""; + } + else if(this->Preferred.size() > 1) + { + std::stringstream e; + e << "Target " << this->Target->GetName() + << " contains multiple languages with the highest linker preference" + << " (" << this->Preference << "):\n"; + for(std::set::const_iterator + li = this->Preferred.begin(); li != this->Preferred.end(); ++li) + { + e << " " << *li << "\n"; + } + e << "Set the LINKER_LANGUAGE property for this target."; + cmake* cm = this->Makefile->GetCMakeInstance(); + cm->IssueMessage(cmake::FATAL_ERROR, e.str(), + this->Target->Target->GetBacktrace()); + } + return *this->Preferred.begin(); + } +}; + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::ComputeLinkClosure(const std::string& config, + LinkClosure& lc) const +{ + // Get languages built in this target. + UNORDERED_SET languages; + cmTarget::LinkImplementation const* impl = + this->Target->GetLinkImplementation(config); + for(std::vector::const_iterator li = impl->Languages.begin(); + li != impl->Languages.end(); ++li) + { + languages.insert(*li); + } + + // Add interface languages from linked targets. + cmTargetCollectLinkLanguages cll(this, config, languages, this->Target); + for(std::vector::const_iterator li = impl->Libraries.begin(); + li != impl->Libraries.end(); ++li) + { + cll.Visit(*li); + } + + // Store the transitive closure of languages. + for(UNORDERED_SET::const_iterator li = languages.begin(); + li != languages.end(); ++li) + { + lc.Languages.push_back(*li); + } + + // Choose the language whose linker should be used. + if(this->GetProperty("HAS_CXX")) + { + lc.LinkerLanguage = "CXX"; + } + else if(const char* linkerLang = this->GetProperty("LINKER_LANGUAGE")) + { + lc.LinkerLanguage = linkerLang; + } + else + { + // Find the language with the highest preference value. + cmTargetSelectLinker tsl(this); + + // First select from the languages compiled directly in this target. + for(std::vector::const_iterator li = impl->Languages.begin(); + li != impl->Languages.end(); ++li) + { + tsl.Consider(li->c_str()); + } + + // Now consider languages that propagate from linked targets. + for(UNORDERED_SET::const_iterator sit = languages.begin(); + sit != languages.end(); ++sit) + { + std::string propagates = "CMAKE_"+*sit+"_LINKER_PREFERENCE_PROPAGATES"; + if(this->Makefile->IsOn(propagates)) + { + tsl.Consider(sit->c_str()); + } + } + + lc.LinkerLanguage = tsl.Choose(); + } +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, std::string& base, std::string& suffix, @@ -2058,7 +2282,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, std::string cmGeneratorTarget::GetLinkerLanguage(const std::string& config) const { - return this->Target->GetLinkClosure(config)->LinkerLanguage; + return this->GetLinkClosure(config)->LinkerLanguage; } //---------------------------------------------------------------------------- diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 2799371..4299053 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -165,6 +165,20 @@ public: std::string GetModuleDefinitionFile(const std::string& config) const; + /** Link information from the transitive closure of the link + implementation and the interfaces of its dependencies. */ + struct LinkClosure + { + // The preferred linker language. + std::string LinkerLanguage; + + // Languages whose runtime libraries must be linked. + std::vector Languages; + }; + + LinkClosure const* GetLinkClosure(const std::string& config) const; + void ComputeLinkClosure(const std::string& config, LinkClosure& lc) const; + /** Full path with trailing slash to the top-level directory holding object files for this target. Includes the build time config name placeholder if needed for the generator. */ @@ -300,6 +314,9 @@ private: std::string& outPrefix, std::string& outBase, std::string& outSuffix) const; + typedef std::map LinkClosureMapType; + mutable LinkClosureMapType LinkClosureMap; + struct CompatibleInterfacesBase { std::set PropsBool; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index c7118dc..62aa12a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -160,9 +160,6 @@ public: HeadToLinkImplementationMap> LinkImplMapType; LinkImplMapType LinkImplMap; - typedef std::map LinkClosureMapType; - LinkClosureMapType LinkClosureMap; - typedef std::map > SourceFilesMapType; SourceFilesMapType SourceFilesMap; @@ -511,7 +508,6 @@ void cmTarget::ClearLinkMaps() this->Internal->LinkImplMap.clear(); this->Internal->LinkInterfaceMap.clear(); this->Internal->LinkInterfaceUsageRequirementsOnlyMap.clear(); - this->Internal->LinkClosureMap.clear(); this->Internal->SourceFilesMap.clear(); } @@ -3136,223 +3132,6 @@ bool cmTarget::GetPropertyAsBool(const std::string& prop) const } //---------------------------------------------------------------------------- -class cmTargetCollectLinkLanguages -{ -public: - cmTargetCollectLinkLanguages(cmTarget const* target, - const std::string& config, - UNORDERED_SET& languages, - cmTarget const* head): - Config(config), Languages(languages), HeadTarget(head), - Makefile(target->GetMakefile()), Target(target) - { this->Visited.insert(target); } - - void Visit(cmLinkItem const& item) - { - if(!item.Target) - { - if(item.find("::") != std::string::npos) - { - bool noMessage = false; - cmake::MessageType messageType = cmake::FATAL_ERROR; - std::ostringstream e; - switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0028)) - { - case cmPolicies::WARN: - { - e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0028) << "\n"; - messageType = cmake::AUTHOR_WARNING; - } - break; - case cmPolicies::OLD: - noMessage = true; - case cmPolicies::REQUIRED_IF_USED: - case cmPolicies::REQUIRED_ALWAYS: - case cmPolicies::NEW: - // Issue the fatal message. - break; - } - - if(!noMessage) - { - e << "Target \"" << this->Target->GetName() - << "\" links to target \"" << item - << "\" but the target was not found. Perhaps a find_package() " - "call is missing for an IMPORTED target, or an ALIAS target is " - "missing?"; - this->Makefile->GetCMakeInstance()->IssueMessage(messageType, - e.str(), - this->Target->GetBacktrace()); - } - } - return; - } - if(!this->Visited.insert(item.Target).second) - { - return; - } - - cmTarget::LinkInterface const* iface = - item.Target->GetLinkInterface(this->Config, this->HeadTarget); - if(!iface) { return; } - - for(std::vector::const_iterator - li = iface->Languages.begin(); li != iface->Languages.end(); ++li) - { - this->Languages.insert(*li); - } - - for(std::vector::const_iterator - li = iface->Libraries.begin(); li != iface->Libraries.end(); ++li) - { - this->Visit(*li); - } - } -private: - std::string Config; - UNORDERED_SET& Languages; - cmTarget const* HeadTarget; - cmMakefile* Makefile; - const cmTarget* Target; - std::set Visited; -}; - -//---------------------------------------------------------------------------- -cmTarget::LinkClosure const* -cmTarget::GetLinkClosure(const std::string& config) const -{ - std::string key(cmSystemTools::UpperCase(config)); - cmTargetInternals::LinkClosureMapType::iterator - i = this->Internal->LinkClosureMap.find(key); - if(i == this->Internal->LinkClosureMap.end()) - { - LinkClosure lc; - this->ComputeLinkClosure(config, lc); - cmTargetInternals::LinkClosureMapType::value_type entry(key, lc); - i = this->Internal->LinkClosureMap.insert(entry).first; - } - return &i->second; -} - -//---------------------------------------------------------------------------- -class cmTargetSelectLinker -{ - int Preference; - cmTarget const* Target; - cmMakefile* Makefile; - cmGlobalGenerator* GG; - UNORDERED_SET Preferred; -public: - cmTargetSelectLinker(cmTarget const* target): Preference(0), Target(target) - { - this->Makefile = this->Target->GetMakefile(); - this->GG = this->Makefile->GetGlobalGenerator(); - } - void Consider(const std::string& lang) - { - int preference = this->GG->GetLinkerPreference(lang); - if(preference > this->Preference) - { - this->Preference = preference; - this->Preferred.clear(); - } - if(preference == this->Preference) - { - this->Preferred.insert(lang); - } - } - std::string Choose() - { - if(this->Preferred.empty()) - { - return ""; - } - else if(this->Preferred.size() > 1) - { - std::ostringstream e; - e << "Target " << this->Target->GetName() - << " contains multiple languages with the highest linker preference" - << " (" << this->Preference << "):\n"; - for(UNORDERED_SET::const_iterator - li = this->Preferred.begin(); li != this->Preferred.end(); ++li) - { - e << " " << *li << "\n"; - } - e << "Set the LINKER_LANGUAGE property for this target."; - cmake* cm = this->Makefile->GetCMakeInstance(); - cm->IssueMessage(cmake::FATAL_ERROR, e.str(), - this->Target->GetBacktrace()); - } - return *this->Preferred.begin(); - } -}; - -//---------------------------------------------------------------------------- -void cmTarget::ComputeLinkClosure(const std::string& config, - LinkClosure& lc) const -{ - // Get languages built in this target. - UNORDERED_SET languages; - LinkImplementation const* impl = this->GetLinkImplementation(config); - for(std::vector::const_iterator li = impl->Languages.begin(); - li != impl->Languages.end(); ++li) - { - languages.insert(*li); - } - - // Add interface languages from linked targets. - cmTargetCollectLinkLanguages cll(this, config, languages, this); - for(std::vector::const_iterator - li = impl->Libraries.begin(); - li != impl->Libraries.end(); ++li) - { - cll.Visit(*li); - } - - // Store the transitive closure of languages. - for(UNORDERED_SET::const_iterator li = languages.begin(); - li != languages.end(); ++li) - { - lc.Languages.push_back(*li); - } - - // Choose the language whose linker should be used. - if(this->GetProperty("HAS_CXX")) - { - lc.LinkerLanguage = "CXX"; - } - else if(const char* linkerLang = this->GetProperty("LINKER_LANGUAGE")) - { - lc.LinkerLanguage = linkerLang; - } - else - { - // Find the language with the highest preference value. - cmTargetSelectLinker tsl(this); - - // First select from the languages compiled directly in this target. - for(std::vector::const_iterator li = impl->Languages.begin(); - li != impl->Languages.end(); ++li) - { - tsl.Consider(*li); - } - - // Now consider languages that propagate from linked targets. - for(UNORDERED_SET::const_iterator sit = languages.begin(); - sit != languages.end(); ++sit) - { - std::string propagates = "CMAKE_"+*sit+"_LINKER_PREFERENCE_PROPAGATES"; - if(this->Makefile->IsOn(propagates)) - { - tsl.Consider(*sit); - } - } - - lc.LinkerLanguage = tsl.Choose(); - } -} - -//---------------------------------------------------------------------------- void cmTarget::ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index dea9bef..9a4915f 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -315,18 +315,6 @@ public: LinkImplementationLibraries const* GetLinkImplementationLibraries(const std::string& config) const; - /** Link information from the transitive closure of the link - implementation and the interfaces of its dependencies. */ - struct LinkClosure - { - // The preferred linker language. - std::string LinkerLanguage; - - // Languages whose runtime libraries must be linked. - std::vector Languages; - }; - LinkClosure const* GetLinkClosure(const std::string& config) const; - cmTarget const* FindTargetToLink(std::string const& name) const; /** Strip off leading and trailing whitespace from an item named in @@ -662,7 +650,6 @@ private: LinkImplementationLibraries const* GetLinkImplementationLibrariesInternal(const std::string& config, cmTarget const* head) const; - void ComputeLinkClosure(const std::string& config, LinkClosure& lc) const; void ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, cmTarget const* headTarget, http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b8a1aff82bb487f75357f4881ed7696f2623a138 commit b8a1aff82bb487f75357f4881ed7696f2623a138 Author: Stephen Kelly AuthorDate: Sun Nov 3 16:33:25 2013 +0100 Commit: Stephen Kelly CommitDate: Sat Aug 1 08:28:27 2015 +0200 cmGeneratorTarget: Move GetLinkerLanguage from cmTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index fee921c..640e806 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -265,8 +265,10 @@ cmComputeLinkInformation "runtime search path"); this->OrderDependentRPath = 0; + cmGeneratorTarget *gtgt = this->GlobalGenerator + ->GetGeneratorTarget(this->Target); // Get the language used for linking this target. - this->LinkLanguage = this->Target->GetLinkerLanguage(config); + this->LinkLanguage = gtgt->GetLinkerLanguage(config); if(this->LinkLanguage.empty()) { // The Compute method will do nothing, so skip the rest of the @@ -322,9 +324,6 @@ cmComputeLinkInformation (this->Makefile-> GetSafeDefinition("CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH")); - cmGeneratorTarget *gtgt = this->Target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(this->Target); this->RuntimeUseChrpath = gtgt->IsChrpathUsed(config); // Get options needed to help find dependent libraries. diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 49fc96b..a86c2bc 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -990,6 +990,9 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode assert(target); + cmGeneratorTarget* gtgt = + context->Makefile->GetGlobalGenerator()->GetGeneratorTarget(target); + if (propertyName == "LINKER_LANGUAGE") { if (target->LinkLanguagePropagatesToDependents() && @@ -1001,7 +1004,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode "link libraries for a static library"); return std::string(); } - return target->GetLinkerLanguage(context->Config); + return gtgt->GetLinkerLanguage(context->Config); } cmGeneratorExpressionDAGChecker dagChecker(context->Backtrace, @@ -1128,9 +1131,6 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode } } - cmGeneratorTarget* gtgt = - context->Makefile->GetGlobalGenerator()->GetGeneratorTarget(target); - if (!prop) { if (target->IsImported() @@ -1600,7 +1600,7 @@ struct TargetFilesystemArtifactResultCreator cmGeneratorExpressionContext *context, const GeneratorExpressionContent *content) { - std::string language = target->Target->GetLinkerLanguage(context->Config); + std::string language = target->GetLinkerLanguage(context->Config); std::string pdbSupportVar = "CMAKE_" + language + "_LINKER_SUPPORTS_PDB"; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 834a2e3..4de5e9c 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -709,8 +709,7 @@ bool cmGeneratorTarget::HasSOName(const std::string& config) const return ((this->GetType() == cmTarget::SHARED_LIBRARY || this->GetType() == cmTarget::MODULE_LIBRARY) && !this->GetPropertyAsBool("NO_SONAME") && - this->Makefile->GetSONameFlag( - this->Target->GetLinkerLanguage(config))); + this->Makefile->GetSONameFlag(this->GetLinkerLanguage(config))); } //---------------------------------------------------------------------------- @@ -752,7 +751,7 @@ cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const } // Check for rpath support on this platform. - std::string ll = this->Target->GetLinkerLanguage(config); + std::string ll = this->GetLinkerLanguage(config); if(!ll.empty()) { std::string flagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; @@ -823,7 +822,7 @@ bool cmGeneratorTarget::IsChrpathUsed(const std::string& config) const #if defined(CMAKE_USE_ELF_PARSER) // Enable if the rpath flag uses a separator and the target uses ELF // binaries. - std::string ll = this->Target->GetLinkerLanguage(config); + std::string ll = this->GetLinkerLanguage(config); if(!ll.empty()) { std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; @@ -1986,7 +1985,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, const char* suffixVar = this->Target->GetSuffixVariableInternal(implib); // Check for language-specific default prefix and suffix. - std::string ll = this->Target->GetLinkerLanguage(config); + std::string ll = this->GetLinkerLanguage(config); if(!ll.empty()) { if(!targetSuffix && suffixVar && *suffixVar) @@ -2056,6 +2055,13 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, //---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetLinkerLanguage(const std::string& config) const +{ + return this->Target->GetLinkClosure(config)->LinkerLanguage; +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetPDBName(const std::string& config) const { std::string prefix; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 372bbe1..2799371 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -258,6 +258,9 @@ public: /** Return true if builtin chrpath will work for this target */ bool IsChrpathUsed(const std::string& config) const; + ///! Return the preferred linker language for this target + std::string GetLinkerLanguage(const std::string& config = "") const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 7b0e153..5006828 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1376,7 +1376,8 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmTarget& cmtarget) return; } - std::string llang = cmtarget.GetLinkerLanguage("NOCONFIG"); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&cmtarget); + std::string llang = gtgt->GetLinkerLanguage("NOCONFIG"); if(llang.empty()) { return; } // If the language is compiled as a source trust Xcode to link with it. @@ -1824,7 +1825,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, AddCompileOptions(flags, &target, lang, configName); } - std::string llang = target.GetLinkerLanguage(configName); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); + std::string llang = gtgt->GetLinkerLanguage(configName); if(binary && llang.empty()) { cmSystemTools::Error @@ -1850,7 +1852,6 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, // Add the export symbol definition for shared library objects. this->AppendDefines(ppDefs, exportMacro); } - cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); std::vector targetDefines; target.GetCompileDefinitions(targetDefines, configName, "C"); this->AppendDefines(ppDefs, targetDefines); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 3ab501d..4ec77a1 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1353,7 +1353,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, linkFlags += this->Makefile->GetSafeDefinition(build); linkFlags += " "; } - std::string linkLanguage = target->Target->GetLinkerLanguage(buildType); + std::string linkLanguage = target->GetLinkerLanguage(buildType); if(linkLanguage.empty()) { cmSystemTools::Error diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 43e9ae4..a402c64 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1259,8 +1259,8 @@ void cmLocalVisualStudio6Generator extraLinkOptionsRelWithDebInfo += targetLinkFlags; } - - + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); // Get standard libraries for this language. if(targetBuilds) @@ -1269,10 +1269,10 @@ void cmLocalVisualStudio6Generator std::vector configs; target.GetMakefile()->GetConfigurations(configs); std::vector::const_iterator it = configs.begin(); - const std::string& linkLanguage = target.GetLinkerLanguage(*it); + const std::string& linkLanguage = gt->GetLinkerLanguage(*it); for ( ; it != configs.end(); ++it) { - const std::string& configLinkLanguage = target.GetLinkerLanguage(*it); + const std::string& configLinkLanguage = gt->GetLinkerLanguage(*it); if (configLinkLanguage != linkLanguage) { cmSystemTools::Error @@ -1702,10 +1702,10 @@ void cmLocalVisualStudio6Generator std::vector configs; target.GetMakefile()->GetConfigurations(configs); std::vector::const_iterator it = configs.begin(); - const std::string& linkLanguage = target.GetLinkerLanguage(*it); + const std::string& linkLanguage = gt->GetLinkerLanguage(*it); for ( ; it != configs.end(); ++it) { - const std::string& configLinkLanguage = target.GetLinkerLanguage(*it); + const std::string& configLinkLanguage = gt->GetLinkerLanguage(*it); if (configLinkLanguage != linkLanguage) { cmSystemTools::Error diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 5ecb144..0fb6bc0 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -664,6 +664,10 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, const char* configType = "10"; const char* projectType = 0; bool targetBuilds = true; + + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); + switch(target.GetType()) { case cmTarget::OBJECT_LIBRARY: @@ -696,7 +700,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, { const std::string& linkLanguage = (this->FortranProject? std::string("Fortran"): - target.GetLinkerLanguage(configName)); + gt->GetLinkerLanguage(configName)); if(linkLanguage.empty()) { cmSystemTools::Error @@ -758,8 +762,6 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, targetOptions.Parse(flags.c_str()); targetOptions.Parse(defineFlags.c_str()); targetOptions.ParseFinish(); - cmGeneratorTarget* gt = - this->GlobalGenerator->GetGeneratorTarget(&target); std::vector targetDefines; target.GetCompileDefinitions(targetDefines, configName, "CXX"); targetOptions.AddDefines(targetDefines); @@ -1637,7 +1639,7 @@ cmLocalVisualStudio7GeneratorFCInfo lg->GlobalGenerator->GetLanguageFromExtension (sf.GetExtension().c_str()); const std::string& sourceLang = lg->GetSourceFileLanguage(sf); - const std::string& linkLanguage = target.GetLinkerLanguage(i->c_str()); + const std::string& linkLanguage = gt->GetLinkerLanguage(i->c_str()); bool needForceLang = false; // source file does not match its extension language if(lang != sourceLang) diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 2fd77c9..afe145a 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -161,7 +161,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) // Get the language to use for linking this executable. std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); // Make sure we have a link language. if(linkLanguage.empty()) diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index b85b8a8..bb0f9dd 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -133,7 +133,7 @@ void cmMakefileLibraryTargetGenerator::WriteObjectLibraryRules() void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules() { std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_STATIC_LIBRARY"; @@ -159,7 +159,7 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink) return; } std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_SHARED_LIBRARY"; @@ -183,7 +183,7 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink) void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink) { std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_SHARED_MODULE"; @@ -206,7 +206,7 @@ void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink) void cmMakefileLibraryTargetGenerator::WriteFrameworkRules(bool relink) { std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_MACOSX_FRAMEWORK"; @@ -238,7 +238,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules // Get the language to use for linking this library. std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); // Make sure we have a link language. if(linkLanguage.empty()) diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index b94e151..d38cf4c 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1509,7 +1509,7 @@ std::string cmMakefileTargetGenerator::GetLinkRule( if(this->Target->HasImplibGNUtoMS()) { std::string ruleVar = "CMAKE_"; - ruleVar += this->Target->GetLinkerLanguage(this->ConfigName); + ruleVar += this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); ruleVar += "_GNUtoMS_RULE"; if(const char* rule = this->Makefile->GetDefinition(ruleVar)) { @@ -1663,7 +1663,8 @@ cmMakefileTargetGenerator { // Lookup the response file reference flag. std::string responseFlagVar = "CMAKE_"; - responseFlagVar += this->Target->GetLinkerLanguage(this->ConfigName); + responseFlagVar += this->GeneratorTarget + ->GetLinkerLanguage(this->ConfigName); responseFlagVar += "_RESPONSE_FILE_LINK_FLAG"; const char* responseFlag = this->Makefile->GetDefinition(responseFlagVar); @@ -1707,7 +1708,8 @@ cmMakefileTargetGenerator // Lookup the response file reference flag. std::string responseFlagVar = "CMAKE_"; - responseFlagVar += this->Target->GetLinkerLanguage(this->ConfigName); + responseFlagVar += this->GeneratorTarget + ->GetLinkerLanguage(this->ConfigName); responseFlagVar += "_RESPONSE_FILE_LINK_FLAG"; const char* responseFlag = this->Makefile->GetDefinition(responseFlagVar); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 1835841..b855bea 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -40,8 +40,7 @@ cmNinjaNormalTargetGenerator(cmGeneratorTarget* target) , TargetNamePDB() , TargetLinkLanguage("") { - this->TargetLinkLanguage = target->Target - ->GetLinkerLanguage(this->GetConfigName()); + this->TargetLinkLanguage = target->GetLinkerLanguage(this->GetConfigName()); if (target->GetType() == cmTarget::EXECUTABLE) this->GetGeneratorTarget()->GetExecutableNames(this->TargetNameOut, this->TargetNameReal, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 37b788d..c7118dc 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3218,12 +3218,6 @@ private: }; //---------------------------------------------------------------------------- -std::string cmTarget::GetLinkerLanguage(const std::string& config) const -{ - return this->GetLinkClosure(config)->LinkerLanguage; -} - -//---------------------------------------------------------------------------- cmTarget::LinkClosure const* cmTarget::GetLinkClosure(const std::string& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index d0cbc66..dea9bef 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -365,9 +365,6 @@ public: void GetTargetVersion(bool soversion, int& major, int& minor, int& patch) const; - ///! Return the preferred linker language for this target - std::string GetLinkerLanguage(const std::string& config = "") const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 2b33c2c..8a780b1 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1627,7 +1627,7 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( this->GlobalGenerator->GetLanguageFromExtension (sf.GetExtension().c_str()); std::string sourceLang = this->LocalGenerator->GetSourceFileLanguage(sf); - const std::string& linkLanguage = this->Target->GetLinkerLanguage(); + const std::string& linkLanguage = this->GeneratorTarget->GetLinkerLanguage(); bool needForceLang = false; // source file does not match its extension language if(lang != sourceLang) @@ -1891,10 +1891,40 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( this->Target->GetLinkerLanguage(configName.c_str()); if(linkLanguage.empty()) { - cmSystemTools::Error - ("CMake can not determine linker language for target: ", - this->Name.c_str()); - return false; + const std::string& linkLanguage = + this->GeneratorTarget->GetLinkerLanguage(configName.c_str()); + if(linkLanguage.empty()) + { + cmSystemTools::Error + ("CMake can not determine linker language for target: ", + this->Name.c_str()); + return false; + } + if(linkLanguage == "C" || linkLanguage == "CXX" + || linkLanguage == "Fortran") + { + std::string baseFlagVar = "CMAKE_"; + baseFlagVar += linkLanguage; + baseFlagVar += "_FLAGS"; + flags = this-> + Target->GetMakefile()->GetRequiredDefinition(baseFlagVar.c_str()); + std::string flagVar = baseFlagVar + std::string("_") + + cmSystemTools::UpperCase(configName); + flags += " "; + flags += this-> + Target->GetMakefile()->GetRequiredDefinition(flagVar.c_str()); + } + // set the correct language + if(linkLanguage == "C") + { + flags += " /TC "; + } + if(linkLanguage == "CXX") + { + flags += " /TP "; + } + this->LocalGenerator->AddCompileOptions(flags, this->Target, + linkLanguage, configName.c_str()); } if(linkLanguage == "C" || linkLanguage == "CXX" || linkLanguage == "Fortran") @@ -2371,7 +2401,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) Options& linkOptions = *pOptions; const std::string& linkLanguage = - this->Target->GetLinkerLanguage(config.c_str()); + this->GeneratorTarget->GetLinkerLanguage(config.c_str()); if(linkLanguage.empty()) { cmSystemTools::Error http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3302e8fd81a3fc200f1fb83891639e33ac5126f8 commit 3302e8fd81a3fc200f1fb83891639e33ac5126f8 Author: Stephen Kelly AuthorDate: Tue Oct 9 01:22:42 2012 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 08:28:27 2015 +0200 cmGeneratorTarget: Move GetFrameworkDirectory from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 436e5dd..834a2e3 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -904,6 +904,48 @@ cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config, + bool contentOnly) const +{ + std::string fpath; + fpath += this->Target->GetOutputName(config, false); + fpath += "."; + const char *ext = this->Target->GetProperty("BUNDLE_EXTENSION"); + if (!ext) + { + if (this->Target->IsXCTestOnApple()) + { + ext = "xctest"; + } + else + { + ext = "bundle"; + } + } + fpath += ext; + fpath += "/Contents"; + if(!contentOnly) + fpath += "/MacOS"; + return fpath; +} + +//---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetFrameworkDirectory(const std::string& config, + bool rootDir) const +{ + std::string fpath; + fpath += this->Target->GetOutputName(config, false); + fpath += ".framework"; + if(!rootDir) + { + fpath += "/Versions/"; + fpath += this->Target->GetFrameworkVersion(); + } + return fpath; +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetFullName(const std::string& config, bool implib) const { @@ -1007,11 +1049,11 @@ cmGeneratorTarget::BuildMacContentDirectory(const std::string& base, } if(this->Target->IsFrameworkOnApple()) { - fpath += this->Target->GetFrameworkDirectory(config, contentOnly); + fpath += this->GetFrameworkDirectory(config, contentOnly); } if(this->Target->IsCFBundleOnApple()) { - fpath += this->Target->GetCFBundleDirectory(config, contentOnly); + fpath += this->GetCFBundleDirectory(config, contentOnly); } return fpath; } @@ -1982,7 +2024,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, if(this->Target->IsCFBundleOnApple()) { - fw_prefix = this->Target->GetCFBundleDirectory(config, false); + fw_prefix = this->GetCFBundleDirectory(config, false); fw_prefix += "/"; targetPrefix = fw_prefix.c_str(); targetSuffix = 0; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 8ccd6d0..372bbe1 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -124,6 +124,14 @@ public: std::string GetFullName(const std::string& config="", bool implib = false) const; + /** @return the Mac framework directory without the base. */ + std::string GetFrameworkDirectory(const std::string& config, + bool rootDir) const; + + /** @return the Mac CFBundle directory without the base */ + std::string GetCFBundleDirectory(const std::string& config, + bool contentOnly) const; + /** Return the install name directory for the target in the * build tree. For example: "\@rpath/", "\@loader_path/", * or "/full/path/to/library". */ diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 1d85d9c..4fe99e3 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -77,11 +77,11 @@ void cmOSXBundleGenerator::CreateFramework( // Compute the location of the top-level foo.framework directory. std::string contentdir = outpath + "/" + - this->GT->Target->GetFrameworkDirectory(this->ConfigName, true); + this->GT->GetFrameworkDirectory(this->ConfigName, true); contentdir += "/"; std::string newoutpath = outpath + "/" + - this->GT->Target->GetFrameworkDirectory(this->ConfigName, false); + this->GT->GetFrameworkDirectory(this->ConfigName, false); std::string frameworkVersion = this->GT->Target->GetFrameworkVersion(); @@ -172,14 +172,14 @@ void cmOSXBundleGenerator::CreateCFBundle(const std::string& targetName, // Compute bundle directory names. std::string out = root; out += "/"; - out += this->GT->Target->GetCFBundleDirectory(this->ConfigName, false); + out += this->GT->GetCFBundleDirectory(this->ConfigName, false); cmSystemTools::MakeDirectory(out.c_str()); this->Makefile->AddCMakeOutputFile(out); // Configure the Info.plist file. Note that it needs the executable name // to be set. std::string plist = root + "/" + - this->GT->Target->GetCFBundleDirectory(this->ConfigName, true); + this->GT->GetCFBundleDirectory(this->ConfigName, true); plist += "/Info.plist"; std::string name = cmSystemTools::GetFilenameName(targetName); this->LocalGenerator->GenerateAppleInfoPList(this->GT->Target, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index a5ff829..37b788d 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -5126,47 +5126,6 @@ std::string cmTarget::CheckCMP0004(std::string const& item) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetFrameworkDirectory(const std::string& config, - bool rootDir) const -{ - std::string fpath; - fpath += this->GetOutputName(config, false); - fpath += ".framework"; - if(!rootDir) - { - fpath += "/Versions/"; - fpath += this->GetFrameworkVersion(); - } - return fpath; -} - -//---------------------------------------------------------------------------- -std::string cmTarget::GetCFBundleDirectory(const std::string& config, - bool contentOnly) const -{ - std::string fpath; - fpath += this->GetOutputName(config, false); - fpath += "."; - const char *ext = this->GetProperty("BUNDLE_EXTENSION"); - if (!ext) - { - if (this->IsXCTestOnApple()) - { - ext = "xctest"; - } - else - { - ext = "bundle"; - } - } - fpath += ext; - fpath += "/Contents"; - if(!contentOnly) - fpath += "/MacOS"; - return fpath; -} - -//---------------------------------------------------------------------------- cmTargetInternalPointer::cmTargetInternalPointer() { this->Pointer = new cmTargetInternals; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e22d3af..d0cbc66 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -460,14 +460,6 @@ public: /** @return whether this target have a well defined output file name. */ bool HaveWellDefinedOutputFiles() const; - /** @return the Mac framework directory without the base. */ - std::string GetFrameworkDirectory(const std::string& config, - bool rootDir) const; - - /** @return the Mac CFBundle directory without the base */ - std::string GetCFBundleDirectory(const std::string& config, - bool contentOnly) const; - std::vector GetIncludeDirectories( const std::string& config, const std::string& language) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=29f2ec1e8bd91bb14248f446890f3d510cfb6002 commit 29f2ec1e8bd91bb14248f446890f3d510cfb6002 Author: Stephen Kelly AuthorDate: Tue Oct 9 19:01:39 2012 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 08:28:27 2015 +0200 cmGeneratorTarget: Move GetFullNameInternal from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index cdacfcb..436e5dd 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -663,7 +663,7 @@ cmGeneratorTarget::GetCompilePDBName(const std::string& config) const std::string prefix; std::string base; std::string suffix; - this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, false, prefix, base, suffix); // Check for a per-configuration output directory target property. std::string configUpper = cmSystemTools::UpperCase(config); @@ -905,6 +905,20 @@ cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, //---------------------------------------------------------------------------- std::string +cmGeneratorTarget::GetFullName(const std::string& config, bool implib) const +{ + if(this->Target->IsImported()) + { + return this->Target->GetFullNameImported(config, implib); + } + else + { + return this->GetFullNameInternal(config, implib); + } +} + +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetInstallNameDirForBuildTree( const std::string& config) const { @@ -977,7 +991,7 @@ void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, const std::string& config, bool implib) const { - this->Target->GetFullNameInternal(config, implib, prefix, base, suffix); + this->GetFullNameInternal(config, implib, prefix, base, suffix); } //---------------------------------------------------------------------------- @@ -1753,7 +1767,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, std::string prefix; std::string base; std::string suffix; - this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, false, prefix, base, suffix); // The library name. name = prefix+base+suffix; @@ -1782,7 +1796,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, if(this->GetType() == cmTarget::SHARED_LIBRARY || this->GetType() == cmTarget::MODULE_LIBRARY) { - impName = this->Target->GetFullNameInternal(config, true); + impName = this->GetFullNameInternal(config, true); } else { @@ -1828,7 +1842,7 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, std::string prefix; std::string base; std::string suffix; - this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, false, prefix, base, suffix); // The executable name. name = prefix+base+suffix; @@ -1849,19 +1863,163 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, #endif // The import library name. - impName = this->Target->GetFullNameInternal(config, true); + impName = this->GetFullNameInternal(config, true); // The program database file name. pdbName = this->GetPDBName(config); } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetFullNameInternal(const std::string& config, + bool implib) const +{ + std::string prefix; + std::string base; + std::string suffix; + this->GetFullNameInternal(config, implib, prefix, base, suffix); + return prefix+base+suffix; +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GetFullNameInternal(const std::string& config, + bool implib, + std::string& outPrefix, + std::string& outBase, + std::string& outSuffix) const +{ + // Use just the target name for non-main target types. + if(this->GetType() != cmTarget::STATIC_LIBRARY && + this->GetType() != cmTarget::SHARED_LIBRARY && + this->GetType() != cmTarget::MODULE_LIBRARY && + this->GetType() != cmTarget::EXECUTABLE) + { + outPrefix = ""; + outBase = this->GetName(); + outSuffix = ""; + return; + } + + // Return an empty name for the import library if this platform + // does not support import libraries. + if(implib && + !this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) + { + outPrefix = ""; + outBase = ""; + outSuffix = ""; + return; + } + + // The implib option is only allowed for shared libraries, module + // libraries, and executables. + if(this->GetType() != cmTarget::SHARED_LIBRARY && + this->GetType() != cmTarget::MODULE_LIBRARY && + this->GetType() != cmTarget::EXECUTABLE) + { + implib = false; + } + + // Compute the full name for main target types. + const char* targetPrefix = (implib + ? this->GetProperty("IMPORT_PREFIX") + : this->GetProperty("PREFIX")); + const char* targetSuffix = (implib + ? this->GetProperty("IMPORT_SUFFIX") + : this->GetProperty("SUFFIX")); + const char* configPostfix = 0; + if(!config.empty()) + { + std::string configProp = cmSystemTools::UpperCase(config); + configProp += "_POSTFIX"; + configPostfix = this->GetProperty(configProp); + // Mac application bundles and frameworks have no postfix. + if(configPostfix && + (this->Target->IsAppBundleOnApple() + || this->Target->IsFrameworkOnApple())) + { + configPostfix = 0; + } + } + const char* prefixVar = this->Target->GetPrefixVariableInternal(implib); + const char* suffixVar = this->Target->GetSuffixVariableInternal(implib); + + // Check for language-specific default prefix and suffix. + std::string ll = this->Target->GetLinkerLanguage(config); + if(!ll.empty()) + { + if(!targetSuffix && suffixVar && *suffixVar) + { + std::string langSuff = suffixVar + std::string("_") + ll; + targetSuffix = this->Makefile->GetDefinition(langSuff); + } + if(!targetPrefix && prefixVar && *prefixVar) + { + std::string langPrefix = prefixVar + std::string("_") + ll; + targetPrefix = this->Makefile->GetDefinition(langPrefix); + } + } + + // if there is no prefix on the target use the cmake definition + if(!targetPrefix && prefixVar) + { + targetPrefix = this->Makefile->GetSafeDefinition(prefixVar); + } + // if there is no suffix on the target use the cmake definition + if(!targetSuffix && suffixVar) + { + targetSuffix = this->Makefile->GetSafeDefinition(suffixVar); + } + + // frameworks have directory prefix but no suffix + std::string fw_prefix; + if(this->Target->IsFrameworkOnApple()) + { + fw_prefix = this->Target->GetOutputName(config, false); + fw_prefix += ".framework/"; + targetPrefix = fw_prefix.c_str(); + targetSuffix = 0; + } + + if(this->Target->IsCFBundleOnApple()) + { + fw_prefix = this->Target->GetCFBundleDirectory(config, false); + fw_prefix += "/"; + targetPrefix = fw_prefix.c_str(); + targetSuffix = 0; + } + + // Begin the final name with the prefix. + outPrefix = targetPrefix?targetPrefix:""; + + // Append the target name or property-specified name. + outBase += this->Target->GetOutputName(config, implib); + + // Append the per-configuration postfix. + outBase += configPostfix?configPostfix:""; + + // Name shared libraries with their version number on some platforms. + if(const char* soversion = this->GetProperty("SOVERSION")) + { + if(this->GetType() == cmTarget::SHARED_LIBRARY && !implib && + this->Makefile->IsOn("CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION")) + { + outBase += "-"; + outBase += soversion; + } + } + + // Append the suffix. + outSuffix = targetSuffix?targetSuffix:""; +} + + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetPDBName(const std::string& config) const { std::string prefix; std::string base; std::string suffix; - this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, false, prefix, base, suffix); std::vector props; std::string configUpper = diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index d0d6709..8ccd6d0 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -284,6 +284,11 @@ private: mutable std::map DebugCompatiblePropertiesDone; + std::string GetFullNameInternal(const std::string& config, bool implib) const; + void GetFullNameInternal(const std::string& config, bool implib, + std::string& outPrefix, std::string& outBase, + std::string& outSuffix) const; + struct CompatibleInterfacesBase { std::set PropsBool; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index c484417..a5ff829 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3612,148 +3612,6 @@ cmTarget::ImportedGetFullPath(const std::string& config, bool implib) const } //---------------------------------------------------------------------------- -std::string -cmTarget::GetFullNameInternal(const std::string& config, bool implib) const -{ - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, implib, prefix, base, suffix); - return prefix+base+suffix; -} - -//---------------------------------------------------------------------------- -void cmTarget::GetFullNameInternal(const std::string& config, - bool implib, - std::string& outPrefix, - std::string& outBase, - std::string& outSuffix) const -{ - // Use just the target name for non-main target types. - if(this->GetType() != cmTarget::STATIC_LIBRARY && - this->GetType() != cmTarget::SHARED_LIBRARY && - this->GetType() != cmTarget::MODULE_LIBRARY && - this->GetType() != cmTarget::EXECUTABLE) - { - outPrefix = ""; - outBase = this->GetName(); - outSuffix = ""; - return; - } - - // Return an empty name for the import library if this platform - // does not support import libraries. - if(implib && - !this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) - { - outPrefix = ""; - outBase = ""; - outSuffix = ""; - return; - } - - // The implib option is only allowed for shared libraries, module - // libraries, and executables. - if(this->GetType() != cmTarget::SHARED_LIBRARY && - this->GetType() != cmTarget::MODULE_LIBRARY && - this->GetType() != cmTarget::EXECUTABLE) - { - implib = false; - } - - // Compute the full name for main target types. - const char* targetPrefix = (implib - ? this->GetProperty("IMPORT_PREFIX") - : this->GetProperty("PREFIX")); - const char* targetSuffix = (implib - ? this->GetProperty("IMPORT_SUFFIX") - : this->GetProperty("SUFFIX")); - const char* configPostfix = 0; - if(!config.empty()) - { - std::string configProp = cmSystemTools::UpperCase(config); - configProp += "_POSTFIX"; - configPostfix = this->GetProperty(configProp); - // Mac application bundles and frameworks have no postfix. - if(configPostfix && - (this->IsAppBundleOnApple() || this->IsFrameworkOnApple())) - { - configPostfix = 0; - } - } - const char* prefixVar = this->GetPrefixVariableInternal(implib); - const char* suffixVar = this->GetSuffixVariableInternal(implib); - - // Check for language-specific default prefix and suffix. - std::string ll = this->GetLinkerLanguage(config); - if(!ll.empty()) - { - if(!targetSuffix && suffixVar && *suffixVar) - { - std::string langSuff = suffixVar + std::string("_") + ll; - targetSuffix = this->Makefile->GetDefinition(langSuff); - } - if(!targetPrefix && prefixVar && *prefixVar) - { - std::string langPrefix = prefixVar + std::string("_") + ll; - targetPrefix = this->Makefile->GetDefinition(langPrefix); - } - } - - // if there is no prefix on the target use the cmake definition - if(!targetPrefix && prefixVar) - { - targetPrefix = this->Makefile->GetSafeDefinition(prefixVar); - } - // if there is no suffix on the target use the cmake definition - if(!targetSuffix && suffixVar) - { - targetSuffix = this->Makefile->GetSafeDefinition(suffixVar); - } - - // frameworks have directory prefix but no suffix - std::string fw_prefix; - if(this->IsFrameworkOnApple()) - { - fw_prefix = this->GetOutputName(config, false); - fw_prefix += ".framework/"; - targetPrefix = fw_prefix.c_str(); - targetSuffix = 0; - } - - if(this->IsCFBundleOnApple()) - { - fw_prefix = this->GetCFBundleDirectory(config, false); - fw_prefix += "/"; - targetPrefix = fw_prefix.c_str(); - targetSuffix = 0; - } - - // Begin the final name with the prefix. - outPrefix = targetPrefix?targetPrefix:""; - - // Append the target name or property-specified name. - outBase += this->GetOutputName(config, implib); - - // Append the per-configuration postfix. - outBase += configPostfix?configPostfix:""; - - // Name shared libraries with their version number on some platforms. - if(const char* soversion = this->GetProperty("SOVERSION")) - { - if(this->GetType() == cmTarget::SHARED_LIBRARY && !implib && - this->Makefile->IsOn("CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION")) - { - outBase += "-"; - outBase += soversion; - } - } - - // Append the suffix. - outSuffix = targetSuffix?targetSuffix:""; -} - -//---------------------------------------------------------------------------- void cmTarget::ComputeVersionedName(std::string& vName, std::string const& prefix, std::string const& base, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 633e0ee..e22d3af 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -570,11 +570,6 @@ private: const char* GetSuffixVariableInternal(bool implib) const; const char* GetPrefixVariableInternal(bool implib) const; - std::string GetFullNameInternal(const std::string& config, - bool implib) const; - void GetFullNameInternal(const std::string& config, bool implib, - std::string& outPrefix, std::string& outBase, - std::string& outSuffix) const; // Use a makefile variable to set a default for the given property. // If the variable is not defined use the given default instead. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f27459f23ffb233928261de8272da67aca7089cd commit f27459f23ffb233928261de8272da67aca7089cd Author: Stephen Kelly AuthorDate: Tue Oct 9 01:26:16 2012 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 08:28:27 2015 +0200 cmGeneratorTarget: Move GetFullName from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 0fdf646..cdacfcb 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -576,7 +576,7 @@ const char* cmGeneratorTarget::GetLocationForBuild() const } } location += "/"; - location += this->Target->GetFullName("", false); + location += this->GetFullName("", false); return location.c_str(); } @@ -896,7 +896,7 @@ std::string cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, bool contentOnly) const { - std::string fpath = this->Target->GetFullName(config, false); + std::string fpath = this->GetFullName(config, false); fpath += ".app/Contents"; if(!contentOnly) fpath += "/MacOS"; @@ -1655,7 +1655,7 @@ std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config, // Add the full name of the target. if(implib) { - fpath += this->Target->GetFullName(config, true); + fpath += this->GetFullName(config, true); } else if(realname) { @@ -1663,7 +1663,7 @@ std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config, } else { - fpath += this->Target->GetFullName(config, false); + fpath += this->GetFullName(config, false); } return fpath; } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index f0d8c60..d0d6709 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -119,6 +119,11 @@ public: std::string GetAppBundleDirectory(const std::string& config, bool contentOnly) const; + /** Get the full name of the target according to the settings in its + makefile. */ + std::string GetFullName(const std::string& config="", + bool implib = false) const; + /** Return the install name directory for the target in the * build tree. For example: "\@rpath/", "\@loader_path/", * or "/full/path/to/library". */ diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index d53ecde..7b0e153 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2742,7 +2742,8 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget, } else { - fullName = cmtarget.GetFullName(defConfig.c_str()); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&cmtarget); + fullName = gtgt->GetFullName(defConfig.c_str()); } fileRef->AddAttribute("path", this->CreateString(fullName.c_str())); fileRef->AddAttribute("refType", this->CreateString("0")); @@ -3688,7 +3689,7 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( std::string universalFile = universal; universalFile += *arch; universalFile += "/"; - universalFile += t->GetFullName(configName); + universalFile += gt->GetFullName(configName); makefileStream << "\t/bin/rm -f " << this->ConvertToRelativeForMake(universalFile.c_str()) diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 61d7847..43e9ae4 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1112,7 +1112,8 @@ void cmLocalVisualStudio6Generator // Compute the proper name to use to link this library. std::string lib; std::string libDebug; - cmTarget* tgt = this->GlobalGenerator->FindTarget(j->first.c_str()); + cmGeneratorTarget* tgt = + this->GlobalGenerator->FindGeneratorTarget(j->first.c_str()); if(tgt) { lib = cmSystemTools::GetFilenameWithoutExtension @@ -1328,11 +1329,11 @@ void cmLocalVisualStudio6Generator target.GetType() == cmTarget::SHARED_LIBRARY || target.GetType() == cmTarget::MODULE_LIBRARY) { - outputName = target.GetFullName(); - outputNameDebug = target.GetFullName("Debug"); - outputNameRelease = target.GetFullName("Release"); - outputNameMinSizeRel = target.GetFullName("MinSizeRel"); - outputNameRelWithDebInfo = target.GetFullName("RelWithDebInfo"); + outputName = gt->GetFullName(); + outputNameDebug = gt->GetFullName("Debug"); + outputNameRelease = gt->GetFullName("Release"); + outputNameMinSizeRel = gt->GetFullName("MinSizeRel"); + outputNameRelWithDebInfo = gt->GetFullName("RelWithDebInfo"); } else if(target.GetType() == cmTarget::OBJECT_LIBRARY) { @@ -1429,10 +1430,10 @@ void cmLocalVisualStudio6Generator fullPathImpRelease += "/"; fullPathImpMinSizeRel += "/"; fullPathImpRelWithDebInfo += "/"; - fullPathImpDebug += target.GetFullName("Debug", true); - fullPathImpRelease += target.GetFullName("Release", true); - fullPathImpMinSizeRel += target.GetFullName("MinSizeRel", true); - fullPathImpRelWithDebInfo += target.GetFullName("RelWithDebInfo", true); + fullPathImpDebug += gt->GetFullName("Debug", true); + fullPathImpRelease += gt->GetFullName("Release", true); + fullPathImpMinSizeRel += gt->GetFullName("MinSizeRel", true); + fullPathImpRelWithDebInfo += gt->GetFullName("RelWithDebInfo", true); targetImplibFlagDebug = "/implib:"; targetImplibFlagRelease = "/implib:"; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 724f575..5ecb144 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1074,6 +1074,9 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, this->ConvertToOutputFormat(this->ModuleDefinitionFile, SHELL); linkOptions.AddFlag("ModuleDefinitionFile", defFile.c_str()); } + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); + if (target.GetType() == cmTarget::SHARED_LIBRARY && this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) { @@ -1104,7 +1107,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, } case cmTarget::STATIC_LIBRARY: { - std::string targetNameFull = target.GetFullName(configName); + std::string targetNameFull = gt->GetFullName(configName); std::string libpath = target.GetDirectory(configName); libpath += "/"; libpath += targetNameFull; @@ -1148,8 +1151,6 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, targetNameImport, targetNamePDB, configName); // Compute the link library and directory information. - cmGeneratorTarget* gt = - this->GlobalGenerator->GetGeneratorTarget(&target); cmComputeLinkInformation* pcli = gt->GetLinkInformation(configName); if(!pcli) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e8ef770..c484417 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3587,20 +3587,6 @@ bool cmTarget::IsImportedSharedLibWithoutSOName( } //---------------------------------------------------------------------------- -std::string cmTarget::GetFullName(const std::string& config, - bool implib) const -{ - if(this->IsImported()) - { - return this->GetFullNameImported(config, implib); - } - else - { - return this->GetFullNameInternal(config, implib); - } -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetFullNameImported(const std::string& config, bool implib) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 4b804da..633e0ee 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -368,11 +368,6 @@ public: ///! Return the preferred linker language for this target std::string GetLinkerLanguage(const std::string& config = "") const; - /** Get the full name of the target according to the settings in its - makefile. */ - std::string GetFullName(const std::string& config="", - bool implib = false) const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 16edf3c..2b33c2c 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1774,7 +1774,7 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions() else { outDir = this->Target->GetDirectory(config->c_str()) + "/"; - targetNameFull = this->Target->GetFullName(config->c_str()); + targetNameFull = this->GeneratorTarget->GetFullName(config->c_str()); } this->ConvertToWindowsSlash(intermediateDir); this->ConvertToWindowsSlash(outDir); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=307fa71eae9bb1fb5dcc09daa7a271c886330959 commit 307fa71eae9bb1fb5dcc09daa7a271c886330959 Author: Stephen Kelly AuthorDate: Tue Jul 28 22:44:00 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 08:28:27 2015 +0200 cmGeneratorTarget: Move GetAppBundleDirectory from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 9848fb4..0fdf646 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -890,6 +890,19 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const } } + +//---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, + bool contentOnly) const +{ + std::string fpath = this->Target->GetFullName(config, false); + fpath += ".app/Contents"; + if(!contentOnly) + fpath += "/MacOS"; + return fpath; +} + //---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetInstallNameDirForBuildTree( @@ -969,6 +982,47 @@ void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, //---------------------------------------------------------------------------- std::string +cmGeneratorTarget::BuildMacContentDirectory(const std::string& base, + const std::string& config, + bool contentOnly) const +{ + std::string fpath = base; + if(this->Target->IsAppBundleOnApple()) + { + fpath += this->GetAppBundleDirectory(config, contentOnly); + } + if(this->Target->IsFrameworkOnApple()) + { + fpath += this->Target->GetFrameworkDirectory(config, contentOnly); + } + if(this->Target->IsCFBundleOnApple()) + { + fpath += this->Target->GetCFBundleDirectory(config, contentOnly); + } + return fpath; +} + +//---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetMacContentDirectory(const std::string& config, + bool implib) const +{ + // Start with the output directory for the target. + std::string fpath = this->Target->GetDirectory(config, implib); + fpath += "/"; + bool contentOnly = true; + if(this->Target->IsFrameworkOnApple()) + { + // additional files with a framework go into the version specific + // directory + contentOnly = false; + } + fpath = this->BuildMacContentDirectory(fpath, config, contentOnly); + return fpath; +} + +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetModuleDefinitionFile(const std::string& config) const { std::string data; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 6d084f7..f0d8c60 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -115,6 +115,10 @@ public: bool realname) const; std::string NormalGetRealName(const std::string& config) const; + /** @return the Mac App directory without the base */ + std::string GetAppBundleDirectory(const std::string& config, + bool contentOnly) const; + /** Return the install name directory for the target in the * build tree. For example: "\@rpath/", "\@loader_path/", * or "/full/path/to/library". */ diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 7df2f78..1d85d9c 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -47,7 +47,7 @@ void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName, // Compute bundle directory names. std::string out = outpath; out += "/"; - out += this->GT->Target->GetAppBundleDirectory(this->ConfigName, false); + out += this->GT->GetAppBundleDirectory(this->ConfigName, false); cmSystemTools::MakeDirectory(out.c_str()); this->Makefile->AddCMakeOutputFile(out); @@ -57,7 +57,7 @@ void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName, // to be set. std::string plist = outpath; plist += "/"; - plist += this->GT->Target->GetAppBundleDirectory(this->ConfigName, true); + plist += this->GT->GetAppBundleDirectory(this->ConfigName, true); plist += "/Info.plist"; this->LocalGenerator->GenerateAppleInfoPList(this->GT->Target, targetName, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index b49ad9b..e8ef770 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -5323,17 +5323,6 @@ std::string cmTarget::GetCFBundleDirectory(const std::string& config, } //---------------------------------------------------------------------------- -std::string cmTarget::GetAppBundleDirectory(const std::string& config, - bool contentOnly) const -{ - std::string fpath = this->GetFullName(config, false); - fpath += ".app/Contents"; - if(!contentOnly) - fpath += "/MacOS"; - return fpath; -} - -//---------------------------------------------------------------------------- cmTargetInternalPointer::cmTargetInternalPointer() { this->Pointer = new cmTargetInternals; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index c1c518f..4b804da 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -473,10 +473,6 @@ public: std::string GetCFBundleDirectory(const std::string& config, bool contentOnly) const; - /** @return the Mac App directory without the base */ - std::string GetAppBundleDirectory(const std::string& config, - bool contentOnly) const; - std::vector GetIncludeDirectories( const std::string& config, const std::string& language) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=23c6a8a1f73e10e8bc02a72a9a0fa41445af7485 commit 23c6a8a1f73e10e8bc02a72a9a0fa41445af7485 Author: Stephen Kelly AuthorDate: Tue Oct 9 01:20:27 2012 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 08:28:26 2015 +0200 cmGeneratorTarget: Move GetInstallNameDir* from cmTarget. diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 6274c3f..fed0dbc 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -333,12 +333,12 @@ cmExportBuildFileGenerator } std::string -cmExportBuildFileGenerator::InstallNameDir(cmTarget* target, +cmExportBuildFileGenerator::InstallNameDir(cmGeneratorTarget* target, const std::string& config) { std::string install_name_dir; - cmMakefile* mf = target->GetMakefile(); + cmMakefile* mf = target->Target->GetMakefile(); if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { install_name_dir = diff --git a/Source/cmExportBuildFileGenerator.h b/Source/cmExportBuildFileGenerator.h index 4d8e062..ff3d2e1 100644 --- a/Source/cmExportBuildFileGenerator.h +++ b/Source/cmExportBuildFileGenerator.h @@ -71,7 +71,8 @@ protected: cmGeneratorTarget* target, ImportPropertyMap& properties); - std::string InstallNameDir(cmTarget* target, const std::string& config); + std::string InstallNameDir(cmGeneratorTarget* target, + const std::string& config); std::vector FindNamespaces(cmMakefile* mf, const std::string& name); diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index e3652c5..cae60b7 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -893,7 +893,7 @@ cmExportFileGenerator { if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { - value = this->InstallNameDir(target->Target, config); + value = this->InstallNameDir(target, config); } prop = "IMPORTED_SONAME"; value += target->GetSOName(config); diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index 4e54740..44f779b 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -200,7 +200,7 @@ private: virtual void ReplaceInstallPrefix(std::string &input); - virtual std::string InstallNameDir(cmTarget* target, + virtual std::string InstallNameDir(cmGeneratorTarget* target, const std::string& config) = 0; }; diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index b0bc686..d55be11 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -546,12 +546,12 @@ cmExportInstallFileGenerator } std::string -cmExportInstallFileGenerator::InstallNameDir(cmTarget* target, +cmExportInstallFileGenerator::InstallNameDir(cmGeneratorTarget* target, const std::string&) { std::string install_name_dir; - cmMakefile* mf = target->GetMakefile(); + cmMakefile* mf = target->Target->GetMakefile(); if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { install_name_dir = diff --git a/Source/cmExportInstallFileGenerator.h b/Source/cmExportInstallFileGenerator.h index 6f86ac9..b06fee5 100644 --- a/Source/cmExportInstallFileGenerator.h +++ b/Source/cmExportInstallFileGenerator.h @@ -83,7 +83,8 @@ protected: std::set& importedLocations ); - std::string InstallNameDir(cmTarget* target, const std::string& config); + std::string InstallNameDir(cmGeneratorTarget* target, + const std::string& config); cmInstallExportGenerator* IEGen; diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx index 94831f8..ba66531 100644 --- a/Source/cmExportTryCompileFileGenerator.cxx +++ b/Source/cmExportTryCompileFileGenerator.cxx @@ -125,12 +125,12 @@ cmExportTryCompileFileGenerator::PopulateProperties(cmTarget const* target, } std::string -cmExportTryCompileFileGenerator::InstallNameDir(cmTarget* target, +cmExportTryCompileFileGenerator::InstallNameDir(cmGeneratorTarget* target, const std::string& config) { std::string install_name_dir; - cmMakefile* mf = target->GetMakefile(); + cmMakefile* mf = target->Target->GetMakefile(); if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { install_name_dir = diff --git a/Source/cmExportTryCompileFileGenerator.h b/Source/cmExportTryCompileFileGenerator.h index 749f3ef..8838eca 100644 --- a/Source/cmExportTryCompileFileGenerator.h +++ b/Source/cmExportTryCompileFileGenerator.h @@ -45,7 +45,7 @@ protected: ImportPropertyMap& properties, std::set &emitted); - std::string InstallNameDir(cmTarget* target, + std::string InstallNameDir(cmGeneratorTarget* target, const std::string& config); private: std::string FindTargets(const std::string& prop, cmTarget const* tgt, diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index daf55a7..9848fb4 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -891,6 +891,73 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const } //---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetInstallNameDirForBuildTree( + const std::string& config) const +{ + // If building directly for installation then the build tree install_name + // is the same as the install tree. + if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) + { + return this->GetInstallNameDirForInstallTree(); + } + + // Use the build tree directory for the target. + if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME") && + !this->Makefile->IsOn("CMAKE_SKIP_RPATH") && + !this->GetPropertyAsBool("SKIP_BUILD_RPATH")) + { + std::string dir; + if(this->Target->MacOSXRpathInstallNameDirDefault()) + { + dir = "@rpath"; + } + else + { + dir = this->Target->GetDirectory(config); + } + dir += "/"; + return dir; + } + else + { + return ""; + } +} + +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetInstallNameDirForInstallTree() const +{ + if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) + { + std::string dir; + const char* install_name_dir = this->GetProperty("INSTALL_NAME_DIR"); + + if(!this->Makefile->IsOn("CMAKE_SKIP_RPATH") && + !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH")) + { + if(install_name_dir && *install_name_dir) + { + dir = install_name_dir; + dir += "/"; + } + } + if(!install_name_dir) + { + if(this->Target->MacOSXRpathInstallNameDirDefault()) + { + dir = "@rpath/"; + } + } + return dir; + } + else + { + return ""; + } +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, std::string& base, std::string& suffix, diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 8fc1b44..6d084f7 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -115,6 +115,15 @@ public: bool realname) const; std::string NormalGetRealName(const std::string& config) const; + /** Return the install name directory for the target in the + * build tree. For example: "\@rpath/", "\@loader_path/", + * or "/full/path/to/library". */ + std::string GetInstallNameDirForBuildTree(const std::string& config) const; + + /** Return the install name directory for the target in the + * install tree. For example: "\@rpath/" or "\@loader_path/". */ + std::string GetInstallNameDirForInstallTree() const; + /** Get the soname of the target. Allowed only for a shared library. */ std::string GetSOName(const std::string& config) const; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 03f6d8f..d53ecde 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2331,7 +2331,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, if(target.GetType() == cmTarget::SHARED_LIBRARY) { // Get the install_name directory for the build tree. - install_name_dir = target.GetInstallNameDirForBuildTree(configName); + install_name_dir = gtgt->GetInstallNameDirForBuildTree(configName); // Xcode doesn't create the correct install_name in some cases. // That is, if the INSTALL_PATH is empty, or if we have versioning // of dylib libraries, we want to specify the install_name. diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 24c1c49..30cf175 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -576,11 +576,14 @@ cmInstallTargetGenerator continue; } + cmGeneratorTarget *gtgt = tgt->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(tgt); // If the build tree and install tree use different path // components of the install_name field then we need to create a // mapping to be applied after installation. - std::string for_build = tgt->GetInstallNameDirForBuildTree(config); - std::string for_install = tgt->GetInstallNameDirForInstallTree(); + std::string for_build = gtgt->GetInstallNameDirForBuildTree(config); + std::string for_install = gtgt->GetInstallNameDirForInstallTree(); if(for_build != for_install) { // The directory portions differ. Append the filename to @@ -605,9 +608,9 @@ cmInstallTargetGenerator if(this->Target->GetType() == cmTarget::SHARED_LIBRARY) { std::string for_build = - this->Target->Target->GetInstallNameDirForBuildTree(config); + this->Target->GetInstallNameDirForBuildTree(config); std::string for_install = - this->Target->Target->GetInstallNameDirForInstallTree(); + this->Target->GetInstallNameDirForInstallTree(); if(this->Target->Target->IsFrameworkOnApple() && for_install.empty()) { diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index a2fcbad..b85b8a8 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -666,7 +666,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules { // Get the install_name directory for the build tree. install_name_dir = - this->Target->GetInstallNameDirForBuildTree(this->ConfigName); + this->GeneratorTarget->GetInstallNameDirForBuildTree(this->ConfigName); // Set the rule variable replacement value. if(install_name_dir.empty()) diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index c80f485..1835841 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -537,7 +537,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() vars["SONAME"] = this->TargetNameSO; if (targetType == cmTarget::SHARED_LIBRARY) { - std::string install_dir = target.GetInstallNameDirForBuildTree(cfgName); + std::string install_dir = + this->GetGeneratorTarget()->GetInstallNameDirForBuildTree(cfgName); if (!install_dir.empty()) { vars["INSTALLNAME_DIR"] = localGen.Convert(install_dir, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 0f1d309..b49ad9b 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3846,73 +3846,6 @@ bool cmTarget::HaveInstallTreeRPATH() const } //---------------------------------------------------------------------------- -std::string cmTarget::GetInstallNameDirForBuildTree( - const std::string& config) const -{ - // If building directly for installation then the build tree install_name - // is the same as the install tree. - if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) - { - return GetInstallNameDirForInstallTree(); - } - - // Use the build tree directory for the target. - if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME") && - !this->Makefile->IsOn("CMAKE_SKIP_RPATH") && - !this->GetPropertyAsBool("SKIP_BUILD_RPATH")) - { - std::string dir; - bool macosx_rpath = this->MacOSXRpathInstallNameDirDefault(); - if(macosx_rpath) - { - dir = "@rpath"; - } - else - { - dir = this->GetDirectory(config); - } - dir += "/"; - return dir; - } - else - { - return ""; - } -} - -//---------------------------------------------------------------------------- -std::string cmTarget::GetInstallNameDirForInstallTree() const -{ - if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) - { - std::string dir; - const char* install_name_dir = this->GetProperty("INSTALL_NAME_DIR"); - - if(!this->Makefile->IsOn("CMAKE_SKIP_RPATH") && - !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH")) - { - if(install_name_dir && *install_name_dir) - { - dir = install_name_dir; - dir += "/"; - } - } - if(!install_name_dir) - { - if(this->MacOSXRpathInstallNameDirDefault()) - { - dir = "@rpath/"; - } - } - return dir; - } - else - { - return ""; - } -} - -//---------------------------------------------------------------------------- const char* cmTarget::GetOutputTargetType(bool implib) const { switch(this->GetType()) diff --git a/Source/cmTarget.h b/Source/cmTarget.h index d03ba3b..c1c518f 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -394,15 +394,6 @@ public: bool HaveBuildTreeRPATH(const std::string& config) const; bool HaveInstallTreeRPATH() const; - /** Return the install name directory for the target in the - * build tree. For example: "\@rpath/", "\@loader_path/", - * or "/full/path/to/library". */ - std::string GetInstallNameDirForBuildTree(const std::string& config) const; - - /** Return the install name directory for the target in the - * install tree. For example: "\@rpath/" or "\@loader_path/". */ - std::string GetInstallNameDirForInstallTree() const; - // Get the properties cmPropertyMap &GetProperties() const { return this->Properties; } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8461d3ef795535dbf18495328cabd54fb25fc5d3 commit 8461d3ef795535dbf18495328cabd54fb25fc5d3 Author: Stephen Kelly AuthorDate: Tue Oct 9 01:13:20 2012 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 08:28:26 2015 +0200 cmGeneratorTarget: Move GetMacContentDirectory from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 4be034f..daf55a7 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -567,7 +567,7 @@ const char* cmGeneratorTarget::GetLocationForBuild() const if(this->Target->IsAppBundleOnApple()) { - std::string macdir = this->Target->BuildMacContentDirectory("", "", + std::string macdir = this->BuildMacContentDirectory("", "", false); if(!macdir.empty()) { @@ -1527,7 +1527,7 @@ std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config, fpath += "/"; if(this->Target->IsAppBundleOnApple()) { - fpath = this->Target->BuildMacContentDirectory(fpath, config, false); + fpath = this->BuildMacContentDirectory(fpath, config, false); fpath += "/"; } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index f96adad..8fc1b44 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -123,6 +123,15 @@ public: const std::string& config="", bool implib = false) const; + /** Append to @a base the mac content directory and return it. */ + std::string BuildMacContentDirectory(const std::string& base, + const std::string& config = "", + bool contentOnly = true) const; + + /** @return the mac content directory for this target. */ + std::string GetMacContentDirectory(const std::string& config = 0, + bool implib = false) const; + cmTarget* Target; cmMakefile* Makefile; cmLocalGenerator* LocalGenerator; diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 3bc0eb7..7df2f78 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -217,7 +217,7 @@ cmOSXBundleGenerator::InitMacOSXContentDirectory(const char* pkgloc) // Construct the full path to the content subdirectory. std::string macdir = - this->GT->Target->GetMacContentDirectory(this->ConfigName, + this->GT->GetMacContentDirectory(this->ConfigName, /*implib*/ false); macdir += "/"; macdir += pkgloc; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 0d9aa49..0f1d309 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -5401,45 +5401,6 @@ std::string cmTarget::GetAppBundleDirectory(const std::string& config, } //---------------------------------------------------------------------------- -std::string cmTarget::BuildMacContentDirectory(const std::string& base, - const std::string& config, - bool contentOnly) const -{ - std::string fpath = base; - if(this->IsAppBundleOnApple()) - { - fpath += this->GetAppBundleDirectory(config, contentOnly); - } - if(this->IsFrameworkOnApple()) - { - fpath += this->GetFrameworkDirectory(config, contentOnly); - } - if(this->IsCFBundleOnApple()) - { - fpath += this->GetCFBundleDirectory(config, contentOnly); - } - return fpath; -} - -//---------------------------------------------------------------------------- -std::string cmTarget::GetMacContentDirectory(const std::string& config, - bool implib) const -{ - // Start with the output directory for the target. - std::string fpath = this->GetDirectory(config, implib); - fpath += "/"; - bool contentOnly = true; - if(this->IsFrameworkOnApple()) - { - // additional files with a framework go into the version specific - // directory - contentOnly = false; - } - fpath = this->BuildMacContentDirectory(fpath, config, contentOnly); - return fpath; -} - -//---------------------------------------------------------------------------- cmTargetInternalPointer::cmTargetInternalPointer() { this->Pointer = new cmTargetInternals; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 9962fdb..d03ba3b 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -471,10 +471,6 @@ public: directory. */ bool UsesDefaultOutputDir(const std::string& config, bool implib) const; - /** @return the mac content directory for this target. */ - std::string GetMacContentDirectory(const std::string& config, - bool implib) const; - /** @return whether this target have a well defined output file name. */ bool HaveWellDefinedOutputFiles() const; @@ -615,10 +611,6 @@ private: std::string ImportedGetFullPath(const std::string& config, bool implib) const; - /** Append to @a base the mac content directory and return it. */ - std::string BuildMacContentDirectory(const std::string& base, - const std::string& config, - bool contentOnly) const; void GetSourceFiles(std::vector &files, const std::string& config) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d726f0467fdb283af70ed0854a335b4dd8d3aaef commit d726f0467fdb283af70ed0854a335b4dd8d3aaef Author: Stephen Kelly AuthorDate: Tue Oct 9 00:40:34 2012 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 08:28:26 2015 +0200 cmGeneratorTarget: Move GetFullNameComponents from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 6481390..4be034f 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -891,6 +891,16 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const } //---------------------------------------------------------------------------- +void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, + std::string& base, + std::string& suffix, + const std::string& config, + bool implib) const +{ + this->Target->GetFullNameInternal(config, implib, prefix, base, suffix); +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetModuleDefinitionFile(const std::string& config) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 9ecbbbe..f96adad 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -118,6 +118,11 @@ public: /** Get the soname of the target. Allowed only for a shared library. */ std::string GetSOName(const std::string& config) const; + void GetFullNameComponents(std::string& prefix, + std::string& base, std::string& suffix, + const std::string& config="", + bool implib = false) const; + cmTarget* Target; cmMakefile* Makefile; cmLocalGenerator* LocalGenerator; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index d7ae36d..03f6d8f 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1940,7 +1940,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, std::string pnprefix; std::string pnbase; std::string pnsuffix; - target.GetFullNameComponents(pnprefix, pnbase, pnsuffix, configName); + gtgt->GetFullNameComponents(pnprefix, pnbase, pnsuffix, configName); const char* version = target.GetProperty("VERSION"); const char* soversion = target.GetProperty("SOVERSION"); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 2586b31..c80f485 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -569,7 +569,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() std::string prefix; std::string base; std::string suffix; - target.GetFullNameComponents(prefix, base, suffix); + this->GetGeneratorTarget()->GetFullNameComponents(prefix, base, suffix); std::string dbg_suffix = ".dbg"; // TODO: Where to document? if (mf->GetDefinition("CMAKE_DEBUG_SYMBOL_SUFFIX")) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1183fe4..0d9aa49 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3609,15 +3609,6 @@ cmTarget::GetFullNameImported(const std::string& config, bool implib) const } //---------------------------------------------------------------------------- -void cmTarget::GetFullNameComponents(std::string& prefix, std::string& base, - std::string& suffix, - const std::string& config, - bool implib) const -{ - this->GetFullNameInternal(config, implib, prefix, base, suffix); -} - -//---------------------------------------------------------------------------- std::string cmTarget::ImportedGetFullPath(const std::string& config, bool implib) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 1aef7b3..9962fdb 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -372,10 +372,6 @@ public: makefile. */ std::string GetFullName(const std::string& config="", bool implib = false) const; - void GetFullNameComponents(std::string& prefix, - std::string& base, std::string& suffix, - const std::string& config="", - bool implib = false) const; /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f9225c4b929932edfb603c2bf93b80ced99580fe commit f9225c4b929932edfb603c2bf93b80ced99580fe Author: Stephen Kelly AuthorDate: Sun Nov 3 12:26:44 2013 +0100 Commit: Stephen Kelly CommitDate: Sat Aug 1 08:28:26 2015 +0200 cmGeneratorTarget: Move IsChrPathUsed from cmTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 5aaa266..fee921c 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -321,7 +321,11 @@ cmComputeLinkInformation this->RuntimeAlways = (this->Makefile-> GetSafeDefinition("CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH")); - this->RuntimeUseChrpath = this->Target->IsChrpathUsed(config); + + cmGeneratorTarget *gtgt = this->Target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(this->Target); + this->RuntimeUseChrpath = gtgt->IsChrpathUsed(config); // Get options needed to help find dependent libraries. std::string rlVar = "CMAKE_"; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 505d01f..6481390 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -746,7 +746,7 @@ cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const } // If chrpath is going to be used no relinking is needed. - if(this->Target->IsChrpathUsed(config)) + if(this->IsChrpathUsed(config)) { return false; } @@ -779,6 +779,73 @@ cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const || this->Target->HaveInstallTreeRPATH(); } +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsChrpathUsed(const std::string& config) const +{ + // Only certain target types have an rpath. + if(!(this->GetType() == cmTarget::SHARED_LIBRARY || + this->GetType() == cmTarget::MODULE_LIBRARY || + this->GetType() == cmTarget::EXECUTABLE)) + { + return false; + } + + // If the target will not be installed we do not need to change its + // rpath. + if(!this->Target->GetHaveInstallRule()) + { + return false; + } + + // Skip chrpath if skipping rpath altogether. + if(this->Makefile->IsOn("CMAKE_SKIP_RPATH")) + { + return false; + } + + // Skip chrpath if it does not need to be changed at install time. + if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) + { + return false; + } + + // Allow the user to disable builtin chrpath explicitly. + if(this->Makefile->IsOn("CMAKE_NO_BUILTIN_CHRPATH")) + { + return false; + } + + if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) + { + return true; + } + +#if defined(CMAKE_USE_ELF_PARSER) + // Enable if the rpath flag uses a separator and the target uses ELF + // binaries. + std::string ll = this->Target->GetLinkerLanguage(config); + if(!ll.empty()) + { + std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; + sepVar += ll; + sepVar += "_FLAG_SEP"; + const char* sep = this->Makefile->GetDefinition(sepVar); + if(sep && *sep) + { + // TODO: Add ELF check to ABI detection and get rid of + // CMAKE_EXECUTABLE_FORMAT. + if(const char* fmt = + this->Makefile->GetDefinition("CMAKE_EXECUTABLE_FORMAT")) + { + return strcmp(fmt, "ELF") == 0; + } + } + } +#endif + static_cast(config); + return false; +} + //---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetSOName(const std::string& config) const diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index c9a2508..9ecbbbe 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -215,6 +215,9 @@ public: */ bool NeedRelinkBeforeInstall(const std::string& config) const; + /** Return true if builtin chrpath will work for this target */ + bool IsChrpathUsed(const std::string& config) const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 7a7dcb4..24c1c49 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -656,11 +656,10 @@ cmInstallTargetGenerator std::string const& toDestDirPath) { // Skip the chrpath if the target does not need it. - if(this->ImportLibrary || !this->Target->Target->IsChrpathUsed(config)) + if(this->ImportLibrary || !this->Target->IsChrpathUsed(config)) { return; } - // Skip if on Apple if(this->Target->Target->GetMakefile() ->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) @@ -695,7 +694,7 @@ cmInstallTargetGenerator std::string const& toDestDirPath) { // Skip the chrpath if the target does not need it. - if(this->ImportLibrary || !this->Target->Target->IsChrpathUsed(config)) + if(this->ImportLibrary || !this->Target->IsChrpathUsed(config)) { return; } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 8dd62f9..1183fe4 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4314,73 +4314,6 @@ void cmTarget::GetLanguages(std::set& languages, } //---------------------------------------------------------------------------- -bool cmTarget::IsChrpathUsed(const std::string& config) const -{ - // Only certain target types have an rpath. - if(!(this->GetType() == cmTarget::SHARED_LIBRARY || - this->GetType() == cmTarget::MODULE_LIBRARY || - this->GetType() == cmTarget::EXECUTABLE)) - { - return false; - } - - // If the target will not be installed we do not need to change its - // rpath. - if(!this->GetHaveInstallRule()) - { - return false; - } - - // Skip chrpath if skipping rpath altogether. - if(this->Makefile->IsOn("CMAKE_SKIP_RPATH")) - { - return false; - } - - // Skip chrpath if it does not need to be changed at install time. - if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) - { - return false; - } - - // Allow the user to disable builtin chrpath explicitly. - if(this->Makefile->IsOn("CMAKE_NO_BUILTIN_CHRPATH")) - { - return false; - } - - if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) - { - return true; - } - -#if defined(CMAKE_USE_ELF_PARSER) - // Enable if the rpath flag uses a separator and the target uses ELF - // binaries. - std::string ll = this->GetLinkerLanguage(config); - if(!ll.empty()) - { - std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; - sepVar += ll; - sepVar += "_FLAG_SEP"; - const char* sep = this->Makefile->GetDefinition(sepVar); - if(sep && *sep) - { - // TODO: Add ELF check to ABI detection and get rid of - // CMAKE_EXECUTABLE_FORMAT. - if(const char* fmt = - this->Makefile->GetDefinition("CMAKE_EXECUTABLE_FORMAT")) - { - return strcmp(fmt, "ELF") == 0; - } - } - } -#endif - static_cast(config); - return false; -} - -//---------------------------------------------------------------------------- cmTarget::ImportInfo const* cmTarget::GetImportInfo(const std::string& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 11f715a..1aef7b3 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -398,9 +398,6 @@ public: bool HaveBuildTreeRPATH(const std::string& config) const; bool HaveInstallTreeRPATH() const; - /** Return true if builtin chrpath will work for this target */ - bool IsChrpathUsed(const std::string& config) const; - /** Return the install name directory for the target in the * build tree. For example: "\@rpath/", "\@loader_path/", * or "/full/path/to/library". */ http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b0bd29f8e55562f2c14d8786c0e465be89d5fd48 commit b0bd29f8e55562f2c14d8786c0e465be89d5fd48 Author: Stephen Kelly AuthorDate: Sun Nov 3 12:25:17 2013 +0100 Commit: Stephen Kelly CommitDate: Sat Aug 1 08:28:26 2015 +0200 cmGeneratorTarget: Move NeedRelinkBeforeInstall from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index a29f4c9..505d01f 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -714,6 +714,73 @@ bool cmGeneratorTarget::HasSOName(const std::string& config) const } //---------------------------------------------------------------------------- +bool +cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const +{ + // Only executables and shared libraries can have an rpath and may + // need relinking. + if(this->GetType() != cmTarget::EXECUTABLE && + this->GetType() != cmTarget::SHARED_LIBRARY && + this->GetType() != cmTarget::MODULE_LIBRARY) + { + return false; + } + + // If there is no install location this target will not be installed + // and therefore does not need relinking. + if(!this->Target->GetHaveInstallRule()) + { + return false; + } + + // If skipping all rpaths completely then no relinking is needed. + if(this->Makefile->IsOn("CMAKE_SKIP_RPATH")) + { + return false; + } + + // If building with the install-tree rpath no relinking is needed. + if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) + { + return false; + } + + // If chrpath is going to be used no relinking is needed. + if(this->Target->IsChrpathUsed(config)) + { + return false; + } + + // Check for rpath support on this platform. + std::string ll = this->Target->GetLinkerLanguage(config); + if(!ll.empty()) + { + std::string flagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; + flagVar += ll; + flagVar += "_FLAG"; + if(!this->Makefile->IsSet(flagVar)) + { + // There is no rpath support on this platform so nothing needs + // relinking. + return false; + } + } + else + { + // No linker language is known. This error will be reported by + // other code. + return false; + } + + // If either a build or install tree rpath is set then the rpath + // will likely change between the build tree and install tree and + // this target must be relinked. + return this->Target->HaveBuildTreeRPATH(config) + || this->Target->HaveInstallTreeRPATH(); +} + + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetSOName(const std::string& config) const { if(this->Target->IsImported()) diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 441bbcf..c9a2508 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -210,6 +210,11 @@ public: std::string& realName, std::string& impName, std::string& pdbName, const std::string& config) const; + /** + * Compute whether this target must be relinked before installing. + */ + bool NeedRelinkBeforeInstall(const std::string& config) const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index edf2705..69747a4 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -482,7 +482,7 @@ cmGlobalUnixMakefileGenerator3 // Add this to the list of depends rules in this directory. if((!check_all || !gtarget->GetPropertyAsBool("EXCLUDE_FROM_ALL")) && (!check_relink || - gtarget->Target + gtarget ->NeedRelinkBeforeInstall(lg->GetConfigName()))) { std::string tname = lg->GetRelativeTargetDirectory(*gtarget->Target); @@ -691,7 +691,7 @@ cmGlobalUnixMakefileGenerator3 // Add a local name for the rule to relink the target before // installation. - if(gtarget->Target + if(gtarget ->NeedRelinkBeforeInstall(lg->GetConfigName())) { makeTargetName = lg->GetRelativeTargetDirectory(*gtarget->Target); @@ -876,7 +876,7 @@ cmGlobalUnixMakefileGenerator3 name, depends, commands, true); // Add rules to prepare the target for installation. - if(gtarget->Target + if(gtarget ->NeedRelinkBeforeInstall(lg->GetConfigName())) { localName = lg->GetRelativeTargetDirectory(*gtarget->Target); diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index deabecf..7a7dcb4 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -73,7 +73,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, { // Compute the build tree directory from which to copy the target. std::string fromDirConfig; - if(this->Target->Target->NeedRelinkBeforeInstall(config)) + if(this->Target->NeedRelinkBeforeInstall(config)) { fromDirConfig = this->Target->Target->GetMakefile()->GetCurrentBinaryDirectory(); diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 98bd0ab..ce370bc 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -486,8 +486,7 @@ void cmLocalUnixMakefileGenerator3 // Add a local name for the rule to relink the target before // installation. - if(t->second->Target - ->NeedRelinkBeforeInstall(this->ConfigName)) + if(t->second->NeedRelinkBeforeInstall(this->ConfigName)) { makeTargetName = this->GetRelativeTargetDirectory(*t->second->Target); makeTargetName += "/preinstall"; diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 31a78ad..2fd77c9 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -58,7 +58,7 @@ void cmMakefileExecutableTargetGenerator::WriteRuleFiles() // write the link rules this->WriteExecutableRule(false); - if(this->Target->NeedRelinkBeforeInstall(this->ConfigName)) + if(this->GeneratorTarget->NeedRelinkBeforeInstall(this->ConfigName)) { // Write rules to link an installable version of the target. this->WriteExecutableRule(true); diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 7d0dc49..a2fcbad 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -69,7 +69,7 @@ void cmMakefileLibraryTargetGenerator::WriteRuleFiles() break; case cmTarget::SHARED_LIBRARY: this->WriteSharedLibraryRules(false); - if(this->Target->NeedRelinkBeforeInstall(this->ConfigName)) + if(this->GeneratorTarget->NeedRelinkBeforeInstall(this->ConfigName)) { // Write rules to link an installable version of the target. this->WriteSharedLibraryRules(true); @@ -77,7 +77,7 @@ void cmMakefileLibraryTargetGenerator::WriteRuleFiles() break; case cmTarget::MODULE_LIBRARY: this->WriteModuleLibraryRules(false); - if(this->Target->NeedRelinkBeforeInstall(this->ConfigName)) + if(this->GeneratorTarget->NeedRelinkBeforeInstall(this->ConfigName)) { // Write rules to link an installable version of the target. this->WriteModuleLibraryRules(true); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1e7fb5a..8dd62f9 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3855,70 +3855,6 @@ bool cmTarget::HaveInstallTreeRPATH() const } //---------------------------------------------------------------------------- -bool cmTarget::NeedRelinkBeforeInstall(const std::string& config) const -{ - // Only executables and shared libraries can have an rpath and may - // need relinking. - if(this->TargetTypeValue != cmTarget::EXECUTABLE && - this->TargetTypeValue != cmTarget::SHARED_LIBRARY && - this->TargetTypeValue != cmTarget::MODULE_LIBRARY) - { - return false; - } - - // If there is no install location this target will not be installed - // and therefore does not need relinking. - if(!this->GetHaveInstallRule()) - { - return false; - } - - // If skipping all rpaths completely then no relinking is needed. - if(this->Makefile->IsOn("CMAKE_SKIP_RPATH")) - { - return false; - } - - // If building with the install-tree rpath no relinking is needed. - if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) - { - return false; - } - - // If chrpath is going to be used no relinking is needed. - if(this->IsChrpathUsed(config)) - { - return false; - } - - // Check for rpath support on this platform. - std::string ll = this->GetLinkerLanguage(config); - if(!ll.empty()) - { - std::string flagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; - flagVar += ll; - flagVar += "_FLAG"; - if(!this->Makefile->IsSet(flagVar)) - { - // There is no rpath support on this platform so nothing needs - // relinking. - return false; - } - } - else - { - // No linker language is known. This error will be reported by - // other code. - return false; - } - - // If either a build or install tree rpath is set then the rpath - // will likely change between the build tree and install tree and - // this target must be relinked. - return this->HaveBuildTreeRPATH(config) || this->HaveInstallTreeRPATH(); -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetInstallNameDirForBuildTree( const std::string& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 8c23372..11f715a 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -395,11 +395,6 @@ public: bool GetImplibGNUtoMS(std::string const& gnuName, std::string& out, const char* newExt = 0) const; - /** - * Compute whether this target must be relinked before installing. - */ - bool NeedRelinkBeforeInstall(const std::string& config) const; - bool HaveBuildTreeRPATH(const std::string& config) const; bool HaveInstallTreeRPATH() const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1da265b05c7f23532992a7916772c1b139becc72 commit 1da265b05c7f23532992a7916772c1b139becc72 Author: Stephen Kelly AuthorDate: Tue Oct 9 18:59:12 2012 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 08:28:26 2015 +0200 cmGeneratorTarget: Move GetPDBName from cmTarget. diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index a20579b..49fc96b 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1625,7 +1625,7 @@ struct TargetFilesystemArtifactResultCreator std::string result = target->Target->GetPDBDirectory(context->Config); result += "/"; - result += target->Target->GetPDBName(context->Config); + result += target->GetPDBName(context->Config); return result; } }; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index a125e47..a29f4c9 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1525,7 +1525,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, } // The program database file name. - pdbName = this->Target->GetPDBName(config); + pdbName = this->GetPDBName(config); } //---------------------------------------------------------------------------- @@ -1587,7 +1587,39 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, impName = this->Target->GetFullNameInternal(config, true); // The program database file name. - pdbName = this->Target->GetPDBName(config); + pdbName = this->GetPDBName(config); +} + +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetPDBName(const std::string& config) const +{ + std::string prefix; + std::string base; + std::string suffix; + this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + + std::vector props; + std::string configUpper = + cmSystemTools::UpperCase(config); + if(!configUpper.empty()) + { + // PDB_NAME_ + props.push_back("PDB_NAME_" + configUpper); + } + + // PDB_NAME + props.push_back("PDB_NAME"); + + for(std::vector::const_iterator i = props.begin(); + i != props.end(); ++i) + { + if(const char* outName = this->GetProperty(*i)) + { + base = outName; + break; + } + } + return prefix+base+".pdb"; } bool cmStrictTargetComparison::operator()(cmTarget const* t1, diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 9cdfd00..441bbcf 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -160,6 +160,9 @@ public: std::vector const* GetSourceDepends(cmSourceFile const* sf) const; + /** Get the name of the pdb file for the target. */ + std::string GetPDBName(const std::string& config="") const; + /** Whether this library has soname enabled and platform supports it. */ bool HasSOName(const std::string& config) const; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index f9125fc..b94e151 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -548,7 +548,7 @@ cmMakefileTargetGenerator this->GeneratorTarget->GetFullPath(this->ConfigName, false, true); targetFullPathPDB = this->Target->GetPDBDirectory(this->ConfigName); targetFullPathPDB += "/"; - targetFullPathPDB += this->Target->GetPDBName(this->ConfigName); + targetFullPathPDB += this->GeneratorTarget->GetPDBName(this->ConfigName); } if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY) { diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index e61ba6f..16e1f48 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -273,7 +273,7 @@ bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(cmNinjaVars& vars) const { pdbPath = this->Target->GetPDBDirectory(this->GetConfigName()); pdbPath += "/"; - pdbPath += this->Target->GetPDBName(this->GetConfigName()); + pdbPath += this->GeneratorTarget->GetPDBName(this->GetConfigName()); } if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 188ad0f..1e7fb5a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3461,37 +3461,6 @@ const char* cmTarget::GetPrefixVariableInternal(bool implib) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetPDBName(const std::string& config) const -{ - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); - - std::vector props; - std::string configUpper = cmSystemTools::UpperCase(config); - if(!configUpper.empty()) - { - // PDB_NAME_ - props.push_back("PDB_NAME_" + configUpper); - } - - // PDB_NAME - props.push_back("PDB_NAME"); - - for(std::vector::const_iterator i = props.begin(); - i != props.end(); ++i) - { - if(const char* outName = this->GetProperty(*i)) - { - base = outName; - break; - } - } - return prefix+base+".pdb"; -} - -//---------------------------------------------------------------------------- bool cmTarget::HasMacOSXRpathInstallNameDir(const std::string& config) const { bool install_name_is_rpath = false; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 162033c..8c23372 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -377,9 +377,6 @@ public: const std::string& config="", bool implib = false) const; - /** Get the name of the pdb file for the target. */ - std::string GetPDBName(const std::string& config) const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4295b84a31a1b97773912f3854fb2129cf4cd2a9 commit 4295b84a31a1b97773912f3854fb2129cf4cd2a9 Author: Stephen Kelly AuthorDate: Mon Mar 10 17:52:04 2014 +0100 Commit: Stephen Kelly CommitDate: Sat Aug 1 08:28:25 2015 +0200 cmGeneratorTarget: Move GetCompilePDBPath from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 2b3ebee..a125e47 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -657,6 +657,51 @@ void cmGeneratorTarget::GetSourceFiles(std::vector &files, } //---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetCompilePDBName(const std::string& config) const +{ + std::string prefix; + std::string base; + std::string suffix; + this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + + // Check for a per-configuration output directory target property. + std::string configUpper = cmSystemTools::UpperCase(config); + std::string configProp = "COMPILE_PDB_NAME_"; + configProp += configUpper; + const char* config_name = this->Target->GetProperty(configProp); + if(config_name && *config_name) + { + return prefix + config_name + ".pdb"; + } + + const char* name = this->Target->GetProperty("COMPILE_PDB_NAME"); + if(name && *name) + { + return prefix + name + ".pdb"; + } + + return ""; +} + +//---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetCompilePDBPath(const std::string& config) const +{ + std::string dir = this->Target->GetCompilePDBDirectory(config); + std::string name = this->GetCompilePDBName(config); + if(dir.empty() && !name.empty()) + { + dir = this->Target->GetPDBDirectory(config); + } + if(!dir.empty()) + { + dir += "/"; + } + return dir + name; +} + +//---------------------------------------------------------------------------- bool cmGeneratorTarget::HasSOName(const std::string& config) const { // soname is supported only for shared libraries and modules, diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 9254265..9cdfd00 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -163,6 +163,12 @@ public: /** Whether this library has soname enabled and platform supports it. */ bool HasSOName(const std::string& config) const; + /** Get the name of the compiler pdb file for the target. */ + std::string GetCompilePDBName(const std::string& config="") const; + + /** Get the path for the MSVC /Fd option for this target. */ + std::string GetCompilePDBPath(const std::string& config="") const; + /** * Flags for a given source file as used in this target. Typically assigned * via SET_TARGET_PROPERTIES when the property is a list of source files. diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 92ed917..724f575 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -881,7 +881,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, if(target.GetType() <= cmTarget::OBJECT_LIBRARY) { // Specify the compiler program database file if configured. - std::string pdb = target.GetCompilePDBPath(configName); + std::string pdb = gt->GetCompilePDBPath(configName); if(!pdb.empty()) { fout << "\t\t\t\tProgramDataBaseFileName=\"" diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index ac8cd29..f9125fc 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -553,7 +553,7 @@ cmMakefileTargetGenerator if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY) { targetFullPathCompilePDB = - this->Target->GetCompilePDBPath(this->ConfigName); + this->GeneratorTarget->GetCompilePDBPath(this->ConfigName); if(targetFullPathCompilePDB.empty()) { targetFullPathCompilePDB = this->Target->GetSupportDirectory() + "/"; diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index cf80424..e61ba6f 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -277,7 +277,8 @@ bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(cmNinjaVars& vars) const } if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY) { - compilePdbPath = this->Target->GetCompilePDBPath(this->GetConfigName()); + compilePdbPath = + this->GeneratorTarget->GetCompilePDBPath(this->GetConfigName()); if(compilePdbPath.empty()) { compilePdbPath = this->Target->GetSupportDirectory() + "/"; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e1b3e94..188ad0f 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3492,49 +3492,6 @@ std::string cmTarget::GetPDBName(const std::string& config) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetCompilePDBName(const std::string& config) const -{ - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); - - // Check for a per-configuration output directory target property. - std::string configUpper = cmSystemTools::UpperCase(config); - std::string configProp = "COMPILE_PDB_NAME_"; - configProp += configUpper; - const char* config_name = this->GetProperty(configProp); - if(config_name && *config_name) - { - return prefix + config_name + ".pdb"; - } - - const char* name = this->GetProperty("COMPILE_PDB_NAME"); - if(name && *name) - { - return prefix + name + ".pdb"; - } - - return ""; -} - -//---------------------------------------------------------------------------- -std::string cmTarget::GetCompilePDBPath(const std::string& config) const -{ - std::string dir = this->GetCompilePDBDirectory(config); - std::string name = this->GetCompilePDBName(config); - if(dir.empty() && !name.empty()) - { - dir = this->GetPDBDirectory(config); - } - if(!dir.empty()) - { - dir += "/"; - } - return dir + name; -} - -//---------------------------------------------------------------------------- bool cmTarget::HasMacOSXRpathInstallNameDir(const std::string& config) const { bool install_name_is_rpath = false; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e89a212..162033c 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -380,12 +380,6 @@ public: /** Get the name of the pdb file for the target. */ std::string GetPDBName(const std::string& config) const; - /** Get the name of the compiler pdb file for the target. */ - std::string GetCompilePDBName(const std::string& config="") const; - - /** Get the path for the MSVC /Fd option for this target. */ - std::string GetCompilePDBPath(const std::string& config="") const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 83775a5..16edf3c 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2026,7 +2026,8 @@ void cmVisualStudio10TargetGenerator::WriteClOptions( } // Specify the compiler program database file if configured. - std::string pdb = this->Target->GetCompilePDBPath(configName.c_str()); + std::string pdb = + this->GeneratorTarget->GetCompilePDBPath(configName.c_str()); if(!pdb.empty()) { this->ConvertToWindowsSlash(pdb); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=27458764cf805ff9108276bfe75d5734768004eb commit 27458764cf805ff9108276bfe75d5734768004eb Author: Stephen Kelly AuthorDate: Mon Nov 18 17:01:00 2013 +0100 Commit: Stephen Kelly CommitDate: Sat Aug 1 08:28:25 2015 +0200 cmGeneratorTarget: Move HasSOName from cmTarget. diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 8a2cf4b..e3652c5 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -889,7 +889,7 @@ cmExportFileGenerator { std::string prop; std::string value; - if(target->Target->HasSOName(config)) + if(target->HasSOName(config)) { if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 31c2df1..2b3ebee 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -657,6 +657,18 @@ void cmGeneratorTarget::GetSourceFiles(std::vector &files, } //---------------------------------------------------------------------------- +bool cmGeneratorTarget::HasSOName(const std::string& config) const +{ + // soname is supported only for shared libraries and modules, + // and then only when the platform supports an soname flag. + return ((this->GetType() == cmTarget::SHARED_LIBRARY || + this->GetType() == cmTarget::MODULE_LIBRARY) && + !this->GetPropertyAsBool("NO_SONAME") && + this->Makefile->GetSONameFlag( + this->Target->GetLinkerLanguage(config))); +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetSOName(const std::string& config) const { if(this->Target->IsImported()) @@ -1407,7 +1419,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, // Check for library version properties. const char* version = this->GetProperty("VERSION"); const char* soversion = this->GetProperty("SOVERSION"); - if(!this->Target->HasSOName(config) || + if(!this->HasSOName(config) || this->Target->IsFrameworkOnApple()) { // Versioning is supported only for shared libraries and modules, diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 7fb7c32..9254265 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -160,6 +160,9 @@ public: std::vector const* GetSourceDepends(cmSourceFile const* sf) const; + /** Whether this library has soname enabled and platform supports it. */ + bool HasSOName(const std::string& config) const; + /** * Flags for a given source file as used in this target. Typically assigned * via SET_TARGET_PROPERTIES when the property is a list of source files. diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index b44848c..d7ae36d 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1944,7 +1944,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, const char* version = target.GetProperty("VERSION"); const char* soversion = target.GetProperty("SOVERSION"); - if(!target.HasSOName(configName) || target.IsFrameworkOnApple()) + if(!gtgt->HasSOName(configName) || target.IsFrameworkOnApple()) { version = 0; soversion = 0; diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 26273ee..7d0dc49 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -653,7 +653,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules vars.Target = target.c_str(); vars.LinkLibraries = linkLibs.c_str(); vars.ObjectsQuoted = buildObjs.c_str(); - if (this->Target->HasSOName(this->ConfigName)) + if (this->GeneratorTarget->HasSOName(this->ConfigName)) { vars.SONameFlag = this->Makefile->GetSONameFlag(linkLanguage); vars.TargetSOName= targetNameSO.c_str(); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 5d86091..2586b31 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -531,7 +531,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() vars["LANGUAGE_COMPILE_FLAGS"] = t; } - if (target.HasSOName(cfgName)) + if (this->GetGeneratorTarget()->HasSOName(cfgName)) { vars["SONAME_FLAG"] = mf->GetSONameFlag(this->TargetLinkLanguage); vars["SONAME"] = this->TargetNameSO; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 60fe7e4..e1b3e94 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3535,17 +3535,6 @@ std::string cmTarget::GetCompilePDBPath(const std::string& config) const } //---------------------------------------------------------------------------- -bool cmTarget::HasSOName(const std::string& config) const -{ - // soname is supported only for shared libraries and modules, - // and then only when the platform supports an soname flag. - return ((this->GetType() == cmTarget::SHARED_LIBRARY || - this->GetType() == cmTarget::MODULE_LIBRARY) && - !this->GetPropertyAsBool("NO_SONAME") && - this->Makefile->GetSONameFlag(this->GetLinkerLanguage(config))); -} - -//---------------------------------------------------------------------------- bool cmTarget::HasMacOSXRpathInstallNameDir(const std::string& config) const { bool install_name_is_rpath = false; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 15dfb4a..e89a212 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -386,9 +386,6 @@ public: /** Get the path for the MSVC /Fd option for this target. */ std::string GetCompilePDBPath(const std::string& config="") const; - /** Whether this library has soname enabled and platform supports it. */ - bool HasSOName(const std::string& config) const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4a95d13b9c711498204bcffb9e7ec02e46460df5 commit 4a95d13b9c711498204bcffb9e7ec02e46460df5 Author: Stephen Kelly AuthorDate: Tue Oct 9 18:48:18 2012 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 08:28:25 2015 +0200 cmGeneratorTarget: Move GetLibraryNames from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 6a693f1..31c2df1 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -693,8 +693,8 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const std::string realName; std::string impName; std::string pdbName; - this->Target->GetLibraryNames(name, soName, realName, - impName, pdbName, config); + this->GetLibraryNames(name, soName, realName, + impName, pdbName, config); return soName; } } @@ -1254,7 +1254,7 @@ void cmGeneratorTarget::GenerateTargetManifest( this->GetType() == cmTarget::SHARED_LIBRARY || this->GetType() == cmTarget::MODULE_LIBRARY) { - this->Target->GetLibraryNames(name, soName, realName, impName, pdbName, + this->GetLibraryNames(name, soName, realName, impName, pdbName, config); } else @@ -1378,13 +1378,100 @@ cmGeneratorTarget::NormalGetRealName(const std::string& config) const std::string realName; std::string impName; std::string pdbName; - this->Target->GetLibraryNames(name, soName, realName, - impName, pdbName, config); + this->GetLibraryNames(name, soName, realName, + impName, pdbName, config); return realName; } } //---------------------------------------------------------------------------- +void cmGeneratorTarget::GetLibraryNames(std::string& name, + std::string& soName, + std::string& realName, + std::string& impName, + std::string& pdbName, + const std::string& config) const +{ + // This should not be called for imported targets. + // TODO: Split cmTarget into a class hierarchy to get compile-time + // enforcement of the limited imported target API. + if(this->Target->IsImported()) + { + std::string msg = "GetLibraryNames called on imported target: "; + msg += this->GetName(); + this->LocalGenerator->IssueMessage(cmake::INTERNAL_ERROR, + msg); + return; + } + + // Check for library version properties. + const char* version = this->GetProperty("VERSION"); + const char* soversion = this->GetProperty("SOVERSION"); + if(!this->Target->HasSOName(config) || + this->Target->IsFrameworkOnApple()) + { + // Versioning is supported only for shared libraries and modules, + // and then only when the platform supports an soname flag. + version = 0; + soversion = 0; + } + if(version && !soversion) + { + // The soversion must be set if the library version is set. Use + // the library version as the soversion. + soversion = version; + } + if(!version && soversion) + { + // Use the soversion as the library version. + version = soversion; + } + + // Get the components of the library name. + std::string prefix; + std::string base; + std::string suffix; + this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + + // The library name. + name = prefix+base+suffix; + + if(this->Target->IsFrameworkOnApple()) + { + realName = prefix; + realName += "Versions/"; + realName += this->Target->GetFrameworkVersion(); + realName += "/"; + realName += base; + soName = realName; + } + else + { + // The library's soname. + this->Target->ComputeVersionedName(soName, prefix, base, suffix, + name, soversion); + + // The library's real name on disk. + this->Target->ComputeVersionedName(realName, prefix, base, suffix, + name, version); + } + + // The import library name. + if(this->GetType() == cmTarget::SHARED_LIBRARY || + this->GetType() == cmTarget::MODULE_LIBRARY) + { + impName = this->Target->GetFullNameInternal(config, true); + } + else + { + impName = ""; + } + + // The program database file name. + pdbName = this->Target->GetPDBName(config); +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetExecutableNames(std::string& name, std::string& realName, std::string& impName, @@ -1446,7 +1533,6 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, pdbName = this->Target->GetPDBName(config); } - bool cmStrictTargetComparison::operator()(cmTarget const* t1, cmTarget const* t2) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 49aa65b..7fb7c32 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -191,6 +191,13 @@ public: std::string& impName, std::string& pdbName, const std::string& config) const; + /** Get the names of the library needed to generate a build rule + that takes into account shared library version numbers. This + should be called only on a library target. */ + void GetLibraryNames(std::string& name, std::string& soName, + std::string& realName, std::string& impName, + std::string& pdbName, const std::string& config) const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index c872859..deabecf 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -185,7 +185,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - this->Target->Target->GetLibraryNames(targetName, targetNameSO, + this->Target->GetLibraryNames(targetName, targetNameSO, targetNameReal, targetNameImport, targetNamePDB, config); @@ -411,7 +411,7 @@ cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target, std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - target->GetLibraryNames(targetName, targetNameSO, targetNameReal, + gtgt->GetLibraryNames(targetName, targetNameSO, targetNameReal, targetNameImport, targetNamePDB, config); if(nameType == NameImplib) { diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 9717ed2..92ed917 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1144,7 +1144,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, std::string targetNameFull; std::string targetNameImport; std::string targetNamePDB; - target.GetLibraryNames(targetName, targetNameSO, targetNameFull, + gt->GetLibraryNames(targetName, targetNameSO, targetNameFull, targetNameImport, targetNamePDB, configName); // Compute the link library and directory information. diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 696dcc4..26273ee 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -28,7 +28,7 @@ cmMakefileLibraryTargetGenerator this->CustomCommandDriver = OnDepends; if (this->Target->GetType() != cmTarget::INTERFACE_LIBRARY) { - this->Target->GetLibraryNames( + this->GeneratorTarget->GetLibraryNames( this->TargetNameOut, this->TargetNameSO, this->TargetNameReal, this->TargetNameImport, this->TargetNamePDB, this->ConfigName); } @@ -266,7 +266,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - this->Target->GetLibraryNames( + this->GeneratorTarget->GetLibraryNames( targetName, targetNameSO, targetNameReal, targetNameImport, targetNamePDB, this->ConfigName); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 737510f..5d86091 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -49,7 +49,7 @@ cmNinjaNormalTargetGenerator(cmGeneratorTarget* target) this->TargetNamePDB, GetLocalGenerator()->GetConfigName()); else - target->Target->GetLibraryNames(this->TargetNameOut, + this->GetGeneratorTarget()->GetLibraryNames(this->TargetNameOut, this->TargetNameSO, this->TargetNameReal, this->TargetNameImport, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 22b76e9..60fe7e4 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3862,95 +3862,6 @@ void cmTarget::GetFullNameInternal(const std::string& config, } //---------------------------------------------------------------------------- -void cmTarget::GetLibraryNames(std::string& name, - std::string& soName, - std::string& realName, - std::string& impName, - std::string& pdbName, - const std::string& config) const -{ - // This should not be called for imported targets. - // TODO: Split cmTarget into a class hierarchy to get compile-time - // enforcement of the limited imported target API. - if(this->IsImported()) - { - std::string msg = "GetLibraryNames called on imported target: "; - msg += this->GetName(); - this->Makefile->IssueMessage(cmake::INTERNAL_ERROR, - msg); - return; - } - - assert(this->GetType() != INTERFACE_LIBRARY); - - // Check for library version properties. - const char* version = this->GetProperty("VERSION"); - const char* soversion = this->GetProperty("SOVERSION"); - if(!this->HasSOName(config) || - this->Makefile->IsOn("CMAKE_PLATFORM_NO_VERSIONED_SONAME") || - this->IsFrameworkOnApple()) - { - // Versioning is supported only for shared libraries and modules, - // and then only when the platform supports an soname flag. - version = 0; - soversion = 0; - } - if(version && !soversion) - { - // The soversion must be set if the library version is set. Use - // the library version as the soversion. - soversion = version; - } - if(!version && soversion) - { - // Use the soversion as the library version. - version = soversion; - } - - // Get the components of the library name. - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); - - // The library name. - name = prefix+base+suffix; - - if(this->IsFrameworkOnApple()) - { - realName = prefix; - realName += "Versions/"; - realName += this->GetFrameworkVersion(); - realName += "/"; - realName += base; - soName = realName; - } - else - { - // The library's soname. - this->ComputeVersionedName(soName, prefix, base, suffix, - name, soversion); - // The library's real name on disk. - this->ComputeVersionedName(realName, prefix, base, suffix, - name, version); - } - - // The import library name. - if(this->GetType() == cmTarget::SHARED_LIBRARY || - this->GetType() == cmTarget::MODULE_LIBRARY) - { - impName = this->GetFullNameInternal(config, true); - } - else - { - impName = ""; - } - - // The program database file name. - pdbName = this->GetPDBName(config); -} - -//---------------------------------------------------------------------------- void cmTarget::ComputeVersionedName(std::string& vName, std::string const& prefix, std::string const& base, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 714647c..15dfb4a 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -399,13 +399,6 @@ public: no soname at all. */ bool IsImportedSharedLibWithoutSOName(const std::string& config) const; - /** Get the names of the library needed to generate a build rule - that takes into account shared library version numbers. This - should be called only on a library target. */ - void GetLibraryNames(std::string& name, std::string& soName, - std::string& realName, std::string& impName, - std::string& pdbName, const std::string& config) const; - /** Does this target have a GNU implib to convert to MS format? */ bool HasImplibGNUtoMS() const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 1bb21ff..83775a5 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2477,7 +2477,8 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) } else { - this->Target->GetLibraryNames(targetName, targetNameSO, targetNameFull, + this->GeneratorTarget->GetLibraryNames(targetName, targetNameSO, + targetNameFull, targetNameImport, targetNamePDB, config.c_str()); } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=83a1b62f4ee15f6bd906540b951da7b9a2ae15ac commit 83a1b62f4ee15f6bd906540b951da7b9a2ae15ac Author: Stephen Kelly AuthorDate: Tue Oct 9 18:40:45 2012 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 08:28:25 2015 +0200 cmGeneratorTarget: Move GetExecutableNames from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index f9f23a6..6a693f1 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1248,8 +1248,7 @@ void cmGeneratorTarget::GenerateTargetManifest( std::string pdbName; if(this->GetType() == cmTarget::EXECUTABLE) { - this->Target->GetExecutableNames(name, realName, impName, pdbName, - config); + this->GetExecutableNames(name, realName, impName, pdbName, config); } else if(this->GetType() == cmTarget::STATIC_LIBRARY || this->GetType() == cmTarget::SHARED_LIBRARY || @@ -1368,7 +1367,7 @@ cmGeneratorTarget::NormalGetRealName(const std::string& config) const std::string realName; std::string impName; std::string pdbName; - this->Target->GetExecutableNames(name, realName, impName, pdbName, config); + this->GetExecutableNames(name, realName, impName, pdbName, config); return realName; } else @@ -1385,6 +1384,69 @@ cmGeneratorTarget::NormalGetRealName(const std::string& config) const } } +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GetExecutableNames(std::string& name, + std::string& realName, + std::string& impName, + std::string& pdbName, + const std::string& config) const +{ + // This should not be called for imported targets. + // TODO: Split cmTarget into a class hierarchy to get compile-time + // enforcement of the limited imported target API. + if(this->Target->IsImported()) + { + std::string msg = + "GetExecutableNames called on imported target: "; + msg += this->GetName(); + this->LocalGenerator->IssueMessage(cmake::INTERNAL_ERROR, msg); + } + + // This versioning is supported only for executables and then only + // when the platform supports symbolic links. +#if defined(_WIN32) && !defined(__CYGWIN__) + const char* version = 0; +#else + // Check for executable version properties. + const char* version = this->GetProperty("VERSION"); + if(this->GetType() != cmTarget::EXECUTABLE || this->Makefile->IsOn("XCODE")) + { + version = 0; + } +#endif + + // Get the components of the executable name. + std::string prefix; + std::string base; + std::string suffix; + this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + + // The executable name. + name = prefix+base+suffix; + + // The executable's real name on disk. +#if defined(__CYGWIN__) + realName = prefix+base; +#else + realName = name; +#endif + if(version) + { + realName += "-"; + realName += version; + } +#if defined(__CYGWIN__) + realName += suffix; +#endif + + // The import library name. + impName = this->Target->GetFullNameInternal(config, true); + + // The program database file name. + pdbName = this->Target->GetPDBName(config); +} + + bool cmStrictTargetComparison::operator()(cmTarget const* t1, cmTarget const* t2) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 1303ee4..49aa65b 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -184,6 +184,12 @@ public: void GetAutoUicOptions(std::vector &result, const std::string& config) const; + /** Get the names of the executable needed to generate a build rule + that takes into account executable version numbers. This should + be called only on an executable target. */ + void GetExecutableNames(std::string& name, std::string& realName, + std::string& impName, std::string& pdbName, + const std::string& config) const; struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index c64f9a3..c872859 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -125,7 +125,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - this->Target->Target->GetExecutableNames(targetName, targetNameReal, + this->Target->GetExecutableNames(targetName, targetNameReal, targetNameImport, targetNamePDB, config); if(this->ImportLibrary) @@ -372,13 +372,16 @@ cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target, { std::string fname; // Compute the name of the library. + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); if(target->GetType() == cmTarget::EXECUTABLE) { std::string targetName; std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - target->GetExecutableNames(targetName, targetNameReal, + gtgt->GetExecutableNames(targetName, targetNameReal, targetNameImport, targetNamePDB, config); if(nameType == NameImplib) diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 5bd82ff..9717ed2 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1243,7 +1243,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, std::string targetNameFull; std::string targetNameImport; std::string targetNamePDB; - target.GetExecutableNames(targetName, targetNameFull, + gt->GetExecutableNames(targetName, targetNameFull, targetNameImport, targetNamePDB, configName); // Compute the link library and directory information. diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 416063f..31a78ad 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -25,7 +25,7 @@ cmMakefileExecutableTargetGenerator cmMakefileTargetGenerator(target) { this->CustomCommandDriver = OnDepends; - this->Target->GetExecutableNames( + this->GeneratorTarget->GetExecutableNames( this->TargetNameOut, this->TargetNameReal, this->TargetNameImport, this->TargetNamePDB, this->ConfigName); @@ -94,7 +94,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - this->Target->GetExecutableNames + this->GeneratorTarget->GetExecutableNames (targetName, targetNameReal, targetNameImport, targetNamePDB, this->ConfigName); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index c9fa7c0..737510f 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -43,7 +43,7 @@ cmNinjaNormalTargetGenerator(cmGeneratorTarget* target) this->TargetLinkLanguage = target->Target ->GetLinkerLanguage(this->GetConfigName()); if (target->GetType() == cmTarget::EXECUTABLE) - target->Target->GetExecutableNames(this->TargetNameOut, + this->GetGeneratorTarget()->GetExecutableNames(this->TargetNameOut, this->TargetNameReal, this->TargetNameImport, this->TargetNamePDB, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index ded5363..22b76e9 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3968,68 +3968,6 @@ void cmTarget::ComputeVersionedName(std::string& vName, } //---------------------------------------------------------------------------- -void cmTarget::GetExecutableNames(std::string& name, - std::string& realName, - std::string& impName, - std::string& pdbName, - const std::string& config) const -{ - // This should not be called for imported targets. - // TODO: Split cmTarget into a class hierarchy to get compile-time - // enforcement of the limited imported target API. - if(this->IsImported()) - { - std::string msg = - "GetExecutableNames called on imported target: "; - msg += this->GetName(); - this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg); - } - - // This versioning is supported only for executables and then only - // when the platform supports symbolic links. -#if defined(_WIN32) && !defined(__CYGWIN__) - const char* version = 0; -#else - // Check for executable version properties. - const char* version = this->GetProperty("VERSION"); - if(this->GetType() != cmTarget::EXECUTABLE || this->Makefile->IsOn("XCODE")) - { - version = 0; - } -#endif - - // Get the components of the executable name. - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); - - // The executable name. - name = prefix+base+suffix; - - // The executable's real name on disk. -#if defined(__CYGWIN__) - realName = prefix+base; -#else - realName = name; -#endif - if(version) - { - realName += "-"; - realName += version; - } -#if defined(__CYGWIN__) - realName += suffix; -#endif - - // The import library name. - impName = this->GetFullNameInternal(config, true); - - // The program database file name. - pdbName = this->GetPDBName(config); -} - -//---------------------------------------------------------------------------- bool cmTarget::HasImplibGNUtoMS() const { return this->HasImportLibrary() && this->GetPropertyAsBool("GNUtoMS"); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 925e7c6..714647c 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -406,14 +406,6 @@ public: std::string& realName, std::string& impName, std::string& pdbName, const std::string& config) const; - /** Get the names of the executable needed to generate a build rule - that takes into account executable version numbers. This should - be called only on an executable target. */ - void GetExecutableNames(std::string& name, std::string& realName, - std::string& impName, - std::string& pdbName, - const std::string& config) const; - /** Does this target have a GNU implib to convert to MS format? */ bool HasImplibGNUtoMS() const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index f3f291a..1bb21ff 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2471,7 +2471,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) std::string targetNamePDB; if(this->Target->GetType() == cmTarget::EXECUTABLE) { - this->Target->GetExecutableNames(targetName, targetNameFull, + this->GeneratorTarget->GetExecutableNames(targetName, targetNameFull, targetNameImport, targetNamePDB, config.c_str()); } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5a6ca0b81f7835f86abf9f1467b98247e4463edd commit 5a6ca0b81f7835f86abf9f1467b98247e4463edd Author: Stephen Kelly AuthorDate: Mon Mar 10 20:34:59 2014 +0100 Commit: Stephen Kelly CommitDate: Sat Aug 1 08:28:25 2015 +0200 cmGeneratorTarget: Move GetLinkImplementationClosure diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 521a5b7..f9f23a6 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -618,7 +618,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const std::string& dir, } std::vector const& deps = - this->Target->GetLinkImplementationClosure(config); + this->GetLinkImplementationClosure(config); for(std::vector::const_iterator li = deps.begin(), le = deps.end(); li != le; ++li) { @@ -775,6 +775,54 @@ void cmGeneratorTarget::GetAutoUicOptions(std::vector &result, } //---------------------------------------------------------------------------- +void processILibs(const std::string& config, + cmTarget const* headTarget, + cmLinkItem const& item, + std::vector& tgts, + std::set& emitted) +{ + if (item.Target && emitted.insert(item.Target).second) + { + tgts.push_back(item.Target); + if(cmTarget::LinkInterfaceLibraries const* iface = + item.Target->GetLinkInterfaceLibraries(config, headTarget, true)) + { + for(std::vector::const_iterator + it = iface->Libraries.begin(); + it != iface->Libraries.end(); ++it) + { + processILibs(config, headTarget, *it, tgts, emitted); + } + } + } +} + +//---------------------------------------------------------------------------- +const std::vector& +cmGeneratorTarget::GetLinkImplementationClosure( + const std::string& config) const +{ + LinkImplClosure& tgts = + this->LinkImplClosureMap[config]; + if(!tgts.Done) + { + tgts.Done = true; + std::set emitted; + + cmTarget::LinkImplementationLibraries const* impl + = this->Target->GetLinkImplementationLibraries(config); + + for(std::vector::const_iterator + it = impl->Libraries.begin(); + it != impl->Libraries.end(); ++it) + { + processILibs(config, this->Target, *it, tgts , emitted); + } + } + return tgts; +} + +//---------------------------------------------------------------------------- class cmTargetTraceDependencies { public: @@ -1455,7 +1503,7 @@ cmGeneratorTarget::GetCompatibleInterfaces(std::string const& config) const compat.PropsBool.insert("POSITION_INDEPENDENT_CODE"); compat.PropsString.insert("AUTOUIC_OPTIONS"); std::vector const& deps = - this->Target->GetLinkImplementationClosure(config); + this->GetLinkImplementationClosure(config); for(std::vector::const_iterator li = deps.begin(); li != deps.end(); ++li) { @@ -1954,7 +2002,7 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt, || (!impliedByUse && !explicitlySet)); std::vector const& deps = - tgt->Target->GetLinkImplementationClosure(config); + tgt->GetLinkImplementationClosure(config); if(deps.empty()) { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 8e68d39..1303ee4 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -245,6 +245,18 @@ private: cmGeneratorTarget(cmGeneratorTarget const&); void operator=(cmGeneratorTarget const&); + + struct LinkImplClosure: public std::vector + { + LinkImplClosure(): Done(false) {} + bool Done; + }; + mutable std::map LinkImplClosureMap; + +public: + std::vector const& + GetLinkImplementationClosure(const std::string& config) const; + }; struct cmStrictTargetComparison { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 968bd9d..ded5363 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -163,13 +163,6 @@ public: typedef std::map LinkClosureMapType; LinkClosureMapType LinkClosureMap; - struct LinkImplClosure: public std::vector - { - LinkImplClosure(): Done(false) {} - bool Done; - }; - std::map LinkImplClosureMap; - typedef std::map > SourceFilesMapType; SourceFilesMapType SourceFilesMap; @@ -5175,53 +5168,6 @@ cmTarget::GetImportLinkInterface(const std::string& config, } //---------------------------------------------------------------------------- -void processILibs(const std::string& config, - cmTarget const* headTarget, - cmLinkItem const& item, - std::vector& tgts, - std::set& emitted) -{ - if (item.Target && emitted.insert(item.Target).second) - { - tgts.push_back(item.Target); - if(cmTarget::LinkInterfaceLibraries const* iface = - item.Target->GetLinkInterfaceLibraries(config, headTarget, true)) - { - for(std::vector::const_iterator - it = iface->Libraries.begin(); - it != iface->Libraries.end(); ++it) - { - processILibs(config, headTarget, *it, tgts, emitted); - } - } - } -} - -//---------------------------------------------------------------------------- -std::vector const& -cmTarget::GetLinkImplementationClosure(const std::string& config) const -{ - cmTargetInternals::LinkImplClosure& tgts = - this->Internal->LinkImplClosureMap[config]; - if(!tgts.Done) - { - tgts.Done = true; - std::set emitted; - - cmTarget::LinkImplementationLibraries const* impl - = this->GetLinkImplementationLibraries(config); - - for(std::vector::const_iterator - it = impl->Libraries.begin(); - it != impl->Libraries.end(); ++it) - { - processILibs(config, this, *it, tgts , emitted); - } - } - return tgts; -} - -//---------------------------------------------------------------------------- void cmTargetInternals::ComputeLinkInterfaceLibraries( cmTarget const* thisTarget, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 85d9964..925e7c6 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -293,9 +293,6 @@ public: cmTarget const* headTarget, bool usage_requirements_only) const; - std::vector const& - GetLinkImplementationClosure(const std::string& config) const; - /** The link implementation specifies the direct library dependencies needed by the object files of the target. */ struct LinkImplementationLibraries http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=549965f7207741ebac8125f28b22ec32de6aa0e6 commit 549965f7207741ebac8125f28b22ec32de6aa0e6 Author: Stephen Kelly AuthorDate: Tue Jul 28 21:24:41 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 08:28:24 2015 +0200 cmGeneratorTarget: Move ReportPropertyOrigin from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index fe73fee..521a5b7 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1937,24 +1937,24 @@ std::pair consistentProperty(const char *lhs, //---------------------------------------------------------------------------- template -PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, +PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt, const std::string &p, const std::string& config, const char *defaultValue, CompatibleType t, PropertyType *) { - PropertyType propContent = getTypedProperty(tgt, p); - const bool explicitlySet = tgt->GetProperties() + PropertyType propContent = getTypedProperty(tgt->Target, p); + const bool explicitlySet = tgt->Target->GetProperties() .find(p) - != tgt->GetProperties().end(); + != tgt->Target->GetProperties().end(); const bool impliedByUse = - tgt->IsNullImpliedByLinkLibraries(p); + tgt->Target->IsNullImpliedByLinkLibraries(p); assert((impliedByUse ^ explicitlySet) || (!impliedByUse && !explicitlySet)); std::vector const& deps = - tgt->GetLinkImplementationClosure(config); + tgt->Target->GetLinkImplementationClosure(config); if(deps.empty()) { @@ -2125,7 +2125,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, bool cmGeneratorTarget::GetLinkInterfaceDependentBoolProperty( const std::string &p, const std::string& config) const { - return checkInterfacePropertyCompatibility(this->Target, p, config, + return checkInterfacePropertyCompatibility(this, p, config, "FALSE", BoolType, 0); } @@ -2135,7 +2135,7 @@ const char* cmGeneratorTarget::GetLinkInterfaceDependentStringProperty( const std::string &p, const std::string& config) const { - return checkInterfacePropertyCompatibility(this->Target, + return checkInterfacePropertyCompatibility(this, p, config, "empty", @@ -2147,7 +2147,7 @@ const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMinProperty( const std::string &p, const std::string& config) const { - return checkInterfacePropertyCompatibility(this->Target, + return checkInterfacePropertyCompatibility(this, p, config, "empty", @@ -2159,7 +2159,7 @@ const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMaxProperty( const std::string &p, const std::string& config) const { - return checkInterfacePropertyCompatibility(this->Target, + return checkInterfacePropertyCompatibility(this, p, config, "empty", @@ -2196,3 +2196,43 @@ cmGeneratorTarget::GetLinkInformation(const std::string& config) const } return i->second; } + +//---------------------------------------------------------------------------- +void +cmGeneratorTarget::ReportPropertyOrigin(const std::string &p, + const std::string &result, + const std::string &report, + const std::string &compatibilityType) const +{ + std::vector debugProperties; + const char *debugProp = this->Target->GetMakefile() + ->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); + if (debugProp) + { + cmSystemTools::ExpandListArgument(debugProp, debugProperties); + } + + bool debugOrigin = !this->DebugCompatiblePropertiesDone[p] + && std::find(debugProperties.begin(), + debugProperties.end(), + p) + != debugProperties.end(); + + if (this->Target->GetMakefile()->IsConfigured()) + { + this->DebugCompatiblePropertiesDone[p] = true; + } + if (!debugOrigin) + { + return; + } + + std::string areport = compatibilityType; + areport += std::string(" of property \"") + p + "\" for target \""; + areport += std::string(this->GetName()); + areport += "\" (result: \""; + areport += result; + areport += "\"):\n" + report; + + this->Makefile->GetCMakeInstance()->IssueMessage(cmake::LOG, areport); +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index d65b1ef..8e68d39 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -199,6 +199,11 @@ public: std::vector XamlSources; }; + void ReportPropertyOrigin(const std::string &p, + const std::string &result, + const std::string &report, + const std::string &compatibilityType) const; + private: friend class cmTargetTraceDependencies; struct SourceEntry { std::vector Depends; }; @@ -212,6 +217,8 @@ private: mutable bool SourceFileFlagsConstructed; mutable std::map SourceFlagsMap; + mutable std::map DebugCompatiblePropertiesDone; + struct CompatibleInterfacesBase { std::set PropsBool; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1fa62e7..968bd9d 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4537,46 +4537,6 @@ bool cmTarget::IsNullImpliedByLinkLibraries(const std::string &p) const //---------------------------------------------------------------------------- void -cmTarget::ReportPropertyOrigin(const std::string &p, - const std::string &result, - const std::string &report, - const std::string &compatibilityType) const -{ - std::vector debugProperties; - const char *debugProp = - this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); - if (debugProp) - { - cmSystemTools::ExpandListArgument(debugProp, debugProperties); - } - - bool debugOrigin = !this->DebugCompatiblePropertiesDone[p] - && std::find(debugProperties.begin(), - debugProperties.end(), - p) - != debugProperties.end(); - - if (this->Makefile->IsConfigured()) - { - this->DebugCompatiblePropertiesDone[p] = true; - } - if (!debugOrigin) - { - return; - } - - std::string areport = compatibilityType; - areport += std::string(" of property \"") + p + "\" for target \""; - areport += std::string(this->GetName()); - areport += "\" (result: \""; - areport += result; - areport += "\"):\n" + report; - - this->Makefile->GetCMakeInstance()->IssueMessage(cmake::LOG, areport); -} - -//---------------------------------------------------------------------------- -void cmTarget::GetObjectLibrariesCMP0026(std::vector& objlibs) const { // At configure-time, this method can be called as part of getting the diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 795753e..85d9964 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -565,11 +565,6 @@ public: bool LinkLanguagePropagatesToDependents() const { return this->TargetTypeValue == STATIC_LIBRARY; } - void ReportPropertyOrigin(const std::string &p, - const std::string &result, - const std::string &report, - const std::string &compatibilityType) const; - std::map const& GetMaxLanguageStandards() const { @@ -676,7 +671,6 @@ private: std::set Utilities; mutable std::set LinkImplicitNullProperties; std::map UtilityBacktraces; - mutable std::map DebugCompatiblePropertiesDone; mutable std::map MaxLanguageStandards; cmPolicies::PolicyMap PolicyMap; std::string Name; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=587a99a5afd6f6f7d7442cb32ede860916073eed commit 587a99a5afd6f6f7d7442cb32ede860916073eed Author: Stephen Kelly AuthorDate: Tue Jul 28 21:15:44 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 08:28:24 2015 +0200 cmGeneratorTarget: Make CompatibleType enum private again. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index a9245c0..fe73fee 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1524,18 +1524,26 @@ bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty( return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0; } +enum CompatibleType +{ + BoolType, + StringType, + NumberMinType, + NumberMaxType +}; + template PropertyType getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, - cmTarget::CompatibleType, + CompatibleType, PropertyType *); template<> bool getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, - cmTarget::CompatibleType, bool *) + CompatibleType, bool *) { return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); } @@ -1544,19 +1552,19 @@ template<> const char * getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, - cmTarget::CompatibleType t, + CompatibleType t, const char **) { switch(t) { - case cmTarget::BoolType: + case BoolType: assert(0 && "String compatibility check function called for boolean"); return 0; - case cmTarget::StringType: + case StringType: return tgt->GetLinkInterfaceDependentStringProperty(prop, config); - case cmTarget::NumberMinType: + case NumberMinType: return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config); - case cmTarget::NumberMaxType: + case NumberMaxType: return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config); } assert(0 && "Unreachable!"); @@ -1570,7 +1578,7 @@ void checkPropertyConsistency(cmGeneratorTarget const* depender, const std::string& propName, std::set &emitted, const std::string& config, - cmTarget::CompatibleType t, + CompatibleType t, PropertyType *) { const char *prop = dependee->GetProperty(propName); @@ -1683,7 +1691,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( checkPropertyConsistency(this, li->Target, strBool, - emittedBools, config, cmTarget::BoolType, 0); + emittedBools, config, BoolType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; @@ -1691,7 +1699,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( checkPropertyConsistency(this, li->Target, strString, emittedStrings, config, - cmTarget::StringType, 0); + StringType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; @@ -1699,7 +1707,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( checkPropertyConsistency(this, li->Target, strNumMin, emittedMinNumbers, config, - cmTarget::NumberMinType, 0); + NumberMinType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; @@ -1707,7 +1715,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( checkPropertyConsistency(this, li->Target, strNumMax, emittedMaxNumbers, config, - cmTarget::NumberMaxType, 0); + NumberMaxType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; @@ -1760,17 +1768,17 @@ void cmGeneratorTarget::CheckPropertyCompatibility( } //---------------------------------------------------------------------------- -std::string compatibilityType(cmTarget::CompatibleType t) +std::string compatibilityType(CompatibleType t) { switch(t) { - case cmTarget::BoolType: + case BoolType: return "Boolean compatibility"; - case cmTarget::StringType: + case StringType: return "String compatibility"; - case cmTarget::NumberMaxType: + case NumberMaxType: return "Numeric maximum compatibility"; - case cmTarget::NumberMinType: + case NumberMinType: return "Numeric minimum compatibility"; } assert(0 && "Unreachable!"); @@ -1778,15 +1786,15 @@ std::string compatibilityType(cmTarget::CompatibleType t) } //---------------------------------------------------------------------------- -std::string compatibilityAgree(cmTarget::CompatibleType t, bool dominant) +std::string compatibilityAgree(CompatibleType t, bool dominant) { switch(t) { - case cmTarget::BoolType: - case cmTarget::StringType: + case BoolType: + case StringType: return dominant ? "(Disagree)\n" : "(Agree)\n"; - case cmTarget::NumberMaxType: - case cmTarget::NumberMinType: + case NumberMaxType: + case NumberMinType: return dominant ? "(Dominant)\n" : "(Ignored)\n"; } assert(0 && "Unreachable!"); @@ -1842,12 +1850,12 @@ const char* impliedValue(const char*) template std::pair consistentProperty(PropertyType lhs, PropertyType rhs, - cmTarget::CompatibleType t); + CompatibleType t); //---------------------------------------------------------------------------- template<> std::pair consistentProperty(bool lhs, bool rhs, - cmTarget::CompatibleType) + CompatibleType) { return std::make_pair(lhs == rhs, lhs); } @@ -1863,7 +1871,7 @@ std::pair consistentStringProperty(const char *lhs, //---------------------------------------------------------------------------- std::pair consistentNumberProperty(const char *lhs, const char *rhs, - cmTarget::CompatibleType t) + CompatibleType t) { char *pEnd; @@ -1881,7 +1889,7 @@ std::pair consistentNumberProperty(const char *lhs, return std::pair(false, null_ptr); } - if (t == cmTarget::NumberMaxType) + if (t == NumberMaxType) { return std::make_pair(true, std::max(lnum, rnum) == lnum ? lhs : rhs); } @@ -1895,7 +1903,7 @@ std::pair consistentNumberProperty(const char *lhs, template<> std::pair consistentProperty(const char *lhs, const char *rhs, - cmTarget::CompatibleType t) + CompatibleType t) { if (!lhs && !rhs) { @@ -1914,13 +1922,13 @@ std::pair consistentProperty(const char *lhs, switch(t) { - case cmTarget::BoolType: + case BoolType: assert(0 && "consistentProperty for strings called with BoolType"); return std::pair(false, null_ptr); - case cmTarget::StringType: + case StringType: return consistentStringProperty(lhs, rhs); - case cmTarget::NumberMinType: - case cmTarget::NumberMaxType: + case NumberMinType: + case NumberMaxType: return consistentNumberProperty(lhs, rhs, t); } assert(0 && "Unreachable!"); @@ -1933,7 +1941,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, const std::string &p, const std::string& config, const char *defaultValue, - cmTarget::CompatibleType t, + CompatibleType t, PropertyType *) { PropertyType propContent = getTypedProperty(tgt, p); @@ -2119,7 +2127,7 @@ bool cmGeneratorTarget::GetLinkInterfaceDependentBoolProperty( { return checkInterfacePropertyCompatibility(this->Target, p, config, "FALSE", - cmTarget::BoolType, 0); + BoolType, 0); } //---------------------------------------------------------------------------- @@ -2131,7 +2139,7 @@ const char* cmGeneratorTarget::GetLinkInterfaceDependentStringProperty( p, config, "empty", - cmTarget::StringType, 0); + StringType, 0); } //---------------------------------------------------------------------------- @@ -2143,7 +2151,7 @@ const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMinProperty( p, config, "empty", - cmTarget::NumberMinType, 0); + NumberMinType, 0); } //---------------------------------------------------------------------------- @@ -2155,7 +2163,7 @@ const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMaxProperty( p, config, "empty", - cmTarget::NumberMaxType, 0); + NumberMaxType, 0); } //---------------------------------------------------------------------------- diff --git a/Source/cmTarget.h b/Source/cmTarget.h index b544b0b..795753e 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -581,14 +581,6 @@ public: return this->LinkLibrariesForVS6;} #endif - enum CompatibleType - { - BoolType, - StringType, - NumberMinType, - NumberMaxType - }; - private: bool HandleLocationPropertyPolicy(cmMakefile* context) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=81442d2f2f5161f7b10bda7b5c7747832677160a commit 81442d2f2f5161f7b10bda7b5c7747832677160a Author: Stephen Kelly AuthorDate: Tue Jul 28 21:13:45 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 08:28:24 2015 +0200 cmGeneratorTarget: Move LinkInterfaceDependent methods from cmTarget. diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index c1641cc..a20579b 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1142,7 +1142,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode context->Config)) { context->HadContextSensitiveCondition = true; - return target->GetLinkInterfaceDependentBoolProperty( + return gtgt->GetLinkInterfaceDependentBoolProperty( propertyName, context->Config) ? "1" : "0"; } @@ -1151,7 +1151,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { context->HadContextSensitiveCondition = true; const char *propContent = - target->GetLinkInterfaceDependentStringProperty( + gtgt->GetLinkInterfaceDependentStringProperty( propertyName, context->Config); return propContent ? propContent : ""; @@ -1161,7 +1161,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { context->HadContextSensitiveCondition = true; const char *propContent = - target->GetLinkInterfaceDependentNumberMinProperty( + gtgt->GetLinkInterfaceDependentNumberMinProperty( propertyName, context->Config); return propContent ? propContent : ""; @@ -1171,7 +1171,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { context->HadContextSensitiveCondition = true; const char *propContent = - target->GetLinkInterfaceDependentNumberMaxProperty( + gtgt->GetLinkInterfaceDependentNumberMaxProperty( propertyName, context->Config); return propContent ? propContent : ""; @@ -1188,7 +1188,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { context->HadContextSensitiveCondition = true; const char *propContent = - target->GetLinkInterfaceDependentNumberMinProperty( + gtgt->GetLinkInterfaceDependentNumberMinProperty( propertyName, context->Config); return propContent ? propContent : ""; @@ -1198,7 +1198,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { context->HadContextSensitiveCondition = true; const char *propContent = - target->GetLinkInterfaceDependentNumberMaxProperty( + gtgt->GetLinkInterfaceDependentNumberMaxProperty( propertyName, context->Config); return propContent ? propContent : ""; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index a7b0349..a9245c0 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -24,6 +24,7 @@ #include +#include #include "assert.h" //---------------------------------------------------------------------------- @@ -753,8 +754,7 @@ void cmGeneratorTarget::GetAutoUicOptions(std::vector &result, const std::string& config) const { const char *prop - = this->Target-> - GetLinkInterfaceDependentStringProperty("AUTOUIC_OPTIONS", + = this->GetLinkInterfaceDependentStringProperty("AUTOUIC_OPTIONS", config); if (!prop) { @@ -1537,7 +1537,7 @@ bool getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& config, cmTarget::CompatibleType, bool *) { - return tgt->Target->GetLinkInterfaceDependentBoolProperty(prop, config); + return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); } template<> @@ -1553,13 +1553,11 @@ const char * getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, assert(0 && "String compatibility check function called for boolean"); return 0; case cmTarget::StringType: - return tgt->Target->GetLinkInterfaceDependentStringProperty(prop, config); + return tgt->GetLinkInterfaceDependentStringProperty(prop, config); case cmTarget::NumberMinType: - return tgt->Target - ->GetLinkInterfaceDependentNumberMinProperty(prop, config); + return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config); case cmTarget::NumberMaxType: - return tgt->Target - ->GetLinkInterfaceDependentNumberMaxProperty(prop, config); + return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config); } assert(0 && "Unreachable!"); return 0; @@ -1762,6 +1760,405 @@ void cmGeneratorTarget::CheckPropertyCompatibility( } //---------------------------------------------------------------------------- +std::string compatibilityType(cmTarget::CompatibleType t) +{ + switch(t) + { + case cmTarget::BoolType: + return "Boolean compatibility"; + case cmTarget::StringType: + return "String compatibility"; + case cmTarget::NumberMaxType: + return "Numeric maximum compatibility"; + case cmTarget::NumberMinType: + return "Numeric minimum compatibility"; + } + assert(0 && "Unreachable!"); + return ""; +} + +//---------------------------------------------------------------------------- +std::string compatibilityAgree(cmTarget::CompatibleType t, bool dominant) +{ + switch(t) + { + case cmTarget::BoolType: + case cmTarget::StringType: + return dominant ? "(Disagree)\n" : "(Agree)\n"; + case cmTarget::NumberMaxType: + case cmTarget::NumberMinType: + return dominant ? "(Dominant)\n" : "(Ignored)\n"; + } + assert(0 && "Unreachable!"); + return ""; +} + +//---------------------------------------------------------------------------- +template +PropertyType getTypedProperty(cmTarget const* tgt, const std::string& prop); + +//---------------------------------------------------------------------------- +template<> +bool getTypedProperty(cmTarget const* tgt, const std::string& prop) +{ + return tgt->GetPropertyAsBool(prop); +} + +//---------------------------------------------------------------------------- +template<> +const char *getTypedProperty(cmTarget const* tgt, + const std::string& prop) +{ + return tgt->GetProperty(prop); +} + +template +std::string valueAsString(PropertyType); +template<> +std::string valueAsString(bool value) +{ + return value ? "TRUE" : "FALSE"; +} +template<> +std::string valueAsString(const char* value) +{ + return value ? value : "(unset)"; +} + +template +PropertyType impliedValue(PropertyType); +template<> +bool impliedValue(bool) +{ + return false; +} +template<> +const char* impliedValue(const char*) +{ + return ""; +} + +//---------------------------------------------------------------------------- +template +std::pair consistentProperty(PropertyType lhs, + PropertyType rhs, + cmTarget::CompatibleType t); + +//---------------------------------------------------------------------------- +template<> +std::pair consistentProperty(bool lhs, bool rhs, + cmTarget::CompatibleType) +{ + return std::make_pair(lhs == rhs, lhs); +} + +//---------------------------------------------------------------------------- +std::pair consistentStringProperty(const char *lhs, + const char *rhs) +{ + const bool b = strcmp(lhs, rhs) == 0; + return std::make_pair(b, b ? lhs : 0); +} + +//---------------------------------------------------------------------------- +std::pair consistentNumberProperty(const char *lhs, + const char *rhs, + cmTarget::CompatibleType t) +{ + char *pEnd; + + const char* const null_ptr = 0; + + long lnum = strtol(lhs, &pEnd, 0); + if (pEnd == lhs || *pEnd != '\0' || errno == ERANGE) + { + return std::pair(false, null_ptr); + } + + long rnum = strtol(rhs, &pEnd, 0); + if (pEnd == rhs || *pEnd != '\0' || errno == ERANGE) + { + return std::pair(false, null_ptr); + } + + if (t == cmTarget::NumberMaxType) + { + return std::make_pair(true, std::max(lnum, rnum) == lnum ? lhs : rhs); + } + else + { + return std::make_pair(true, std::min(lnum, rnum) == lnum ? lhs : rhs); + } +} + +//---------------------------------------------------------------------------- +template<> +std::pair consistentProperty(const char *lhs, + const char *rhs, + cmTarget::CompatibleType t) +{ + if (!lhs && !rhs) + { + return std::make_pair(true, lhs); + } + if (!lhs) + { + return std::make_pair(true, rhs); + } + if (!rhs) + { + return std::make_pair(true, lhs); + } + + const char* const null_ptr = 0; + + switch(t) + { + case cmTarget::BoolType: + assert(0 && "consistentProperty for strings called with BoolType"); + return std::pair(false, null_ptr); + case cmTarget::StringType: + return consistentStringProperty(lhs, rhs); + case cmTarget::NumberMinType: + case cmTarget::NumberMaxType: + return consistentNumberProperty(lhs, rhs, t); + } + assert(0 && "Unreachable!"); + return std::pair(false, null_ptr); +} + +//---------------------------------------------------------------------------- +template +PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, + const std::string &p, + const std::string& config, + const char *defaultValue, + cmTarget::CompatibleType t, + PropertyType *) +{ + PropertyType propContent = getTypedProperty(tgt, p); + const bool explicitlySet = tgt->GetProperties() + .find(p) + != tgt->GetProperties().end(); + const bool impliedByUse = + tgt->IsNullImpliedByLinkLibraries(p); + assert((impliedByUse ^ explicitlySet) + || (!impliedByUse && !explicitlySet)); + + std::vector const& deps = + tgt->GetLinkImplementationClosure(config); + + if(deps.empty()) + { + return propContent; + } + bool propInitialized = explicitlySet; + + std::string report = " * Target \""; + report += tgt->GetName(); + if (explicitlySet) + { + report += "\" has property content \""; + report += valueAsString(propContent); + report += "\"\n"; + } + else if (impliedByUse) + { + report += "\" property is implied by use.\n"; + } + else + { + report += "\" property not set.\n"; + } + + std::string interfaceProperty = "INTERFACE_" + p; + for(std::vector::const_iterator li = + deps.begin(); + li != deps.end(); ++li) + { + // An error should be reported if one dependency + // has INTERFACE_POSITION_INDEPENDENT_CODE ON and the other + // has INTERFACE_POSITION_INDEPENDENT_CODE OFF, or if the + // target itself has a POSITION_INDEPENDENT_CODE which disagrees + // with a dependency. + + cmTarget const* theTarget = *li; + + const bool ifaceIsSet = theTarget->GetProperties() + .find(interfaceProperty) + != theTarget->GetProperties().end(); + PropertyType ifacePropContent = + getTypedProperty(theTarget, + interfaceProperty); + + std::string reportEntry; + if (ifaceIsSet) + { + reportEntry += " * Target \""; + reportEntry += theTarget->GetName(); + reportEntry += "\" property value \""; + reportEntry += valueAsString(ifacePropContent); + reportEntry += "\" "; + } + + if (explicitlySet) + { + if (ifaceIsSet) + { + std::pair consistent = + consistentProperty(propContent, + ifacePropContent, t); + report += reportEntry; + report += compatibilityAgree(t, propContent != consistent.second); + if (!consistent.first) + { + std::ostringstream e; + e << "Property " << p << " on target \"" + << tgt->GetName() << "\" does\nnot match the " + "INTERFACE_" << p << " property requirement\nof " + "dependency \"" << theTarget->GetName() << "\".\n"; + cmSystemTools::Error(e.str().c_str()); + break; + } + else + { + propContent = consistent.second; + continue; + } + } + else + { + // Explicitly set on target and not set in iface. Can't disagree. + continue; + } + } + else if (impliedByUse) + { + propContent = impliedValue(propContent); + + if (ifaceIsSet) + { + std::pair consistent = + consistentProperty(propContent, + ifacePropContent, t); + report += reportEntry; + report += compatibilityAgree(t, propContent != consistent.second); + if (!consistent.first) + { + std::ostringstream e; + e << "Property " << p << " on target \"" + << tgt->GetName() << "\" is\nimplied to be " << defaultValue + << " because it was used to determine the link libraries\n" + "already. The INTERFACE_" << p << " property on\ndependency \"" + << theTarget->GetName() << "\" is in conflict.\n"; + cmSystemTools::Error(e.str().c_str()); + break; + } + else + { + propContent = consistent.second; + continue; + } + } + else + { + // Implicitly set on target and not set in iface. Can't disagree. + continue; + } + } + else + { + if (ifaceIsSet) + { + if (propInitialized) + { + std::pair consistent = + consistentProperty(propContent, + ifacePropContent, t); + report += reportEntry; + report += compatibilityAgree(t, propContent != consistent.second); + if (!consistent.first) + { + std::ostringstream e; + e << "The INTERFACE_" << p << " property of \"" + << theTarget->GetName() << "\" does\nnot agree with the value " + "of " << p << " already determined\nfor \"" + << tgt->GetName() << "\".\n"; + cmSystemTools::Error(e.str().c_str()); + break; + } + else + { + propContent = consistent.second; + continue; + } + } + else + { + report += reportEntry + "(Interface set)\n"; + propContent = ifacePropContent; + propInitialized = true; + } + } + else + { + // Not set. Nothing to agree on. + continue; + } + } + } + + tgt->ReportPropertyOrigin(p, valueAsString(propContent), + report, compatibilityType(t)); + return propContent; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::GetLinkInterfaceDependentBoolProperty( + const std::string &p, const std::string& config) const +{ + return checkInterfacePropertyCompatibility(this->Target, p, config, + "FALSE", + cmTarget::BoolType, 0); +} + +//---------------------------------------------------------------------------- +const char* cmGeneratorTarget::GetLinkInterfaceDependentStringProperty( + const std::string &p, + const std::string& config) const +{ + return checkInterfacePropertyCompatibility(this->Target, + p, + config, + "empty", + cmTarget::StringType, 0); +} + +//---------------------------------------------------------------------------- +const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMinProperty( + const std::string &p, + const std::string& config) const +{ + return checkInterfacePropertyCompatibility(this->Target, + p, + config, + "empty", + cmTarget::NumberMinType, 0); +} + +//---------------------------------------------------------------------------- +const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMaxProperty( + const std::string &p, + const std::string& config) const +{ + return checkInterfacePropertyCompatibility(this->Target, + p, + config, + "empty", + cmTarget::NumberMaxType, 0); +} + +//---------------------------------------------------------------------------- cmComputeLinkInformation* cmGeneratorTarget::GetLinkInformation(const std::string& config) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index ae86e19..d65b1ef 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -96,6 +96,17 @@ public: bool IsLinkInterfaceDependentNumberMaxProperty(const std::string &p, const std::string& config) const; + bool GetLinkInterfaceDependentBoolProperty(const std::string &p, + const std::string& config) const; + + const char *GetLinkInterfaceDependentStringProperty(const std::string &p, + const std::string& config) const; + const char *GetLinkInterfaceDependentNumberMinProperty(const std::string &p, + const std::string& config) const; + const char *GetLinkInterfaceDependentNumberMaxProperty(const std::string &p, + const std::string& config) const; + + /** Get the full path to the target according to the settings in its makefile and the configuration type. */ std::string GetFullPath(const std::string& config="", bool implib = false, diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index eaf812f..3ab501d 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2059,7 +2059,9 @@ void cmLocalGenerator::AddCMP0018Flags(std::string &flags, return; } - if (target->GetLinkInterfaceDependentBoolProperty( + cmGeneratorTarget* gtgt = + this->GlobalGenerator->GetGeneratorTarget(target); + if (gtgt->GetLinkInterfaceDependentBoolProperty( "POSITION_INDEPENDENT_CODE", config)) { diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index a72b176..f1ba2f4 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -547,8 +547,11 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target) { qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR"); } + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); if (const char *targetQtVersion = - target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", "")) + gtgt->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", "")) { qtVersion = targetQtVersion; } @@ -1150,6 +1153,9 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) std::string cmQtAutoGenerators::GetRccExecutable(cmTarget const* target) { + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); cmMakefile *makefile = target->GetMakefile(); const char *qtVersion = makefile->GetDefinition("_target_qt_version"); if (!qtVersion) @@ -1160,8 +1166,7 @@ std::string cmQtAutoGenerators::GetRccExecutable(cmTarget const* target) qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR"); } if (const char *targetQtVersion = - target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", - "")) + gtgt->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", "")) { qtVersion = targetQtVersion; } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index b165545..1fa62e7 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4536,141 +4536,6 @@ bool cmTarget::IsNullImpliedByLinkLibraries(const std::string &p) const } //---------------------------------------------------------------------------- -template -PropertyType getTypedProperty(cmTarget const* tgt, const std::string& prop); - -//---------------------------------------------------------------------------- -template<> -bool getTypedProperty(cmTarget const* tgt, const std::string& prop) -{ - return tgt->GetPropertyAsBool(prop); -} - -//---------------------------------------------------------------------------- -template<> -const char *getTypedProperty(cmTarget const* tgt, - const std::string& prop) -{ - return tgt->GetProperty(prop); -} - -//---------------------------------------------------------------------------- -template -std::pair consistentProperty(PropertyType lhs, - PropertyType rhs, - cmTarget::CompatibleType t); - -//---------------------------------------------------------------------------- -template<> -std::pair consistentProperty(bool lhs, bool rhs, - cmTarget::CompatibleType) -{ - return std::make_pair(lhs == rhs, lhs); -} - -//---------------------------------------------------------------------------- -std::pair consistentStringProperty(const char *lhs, - const char *rhs) -{ - const bool b = strcmp(lhs, rhs) == 0; - return std::make_pair(b, b ? lhs : 0); -} - -//---------------------------------------------------------------------------- -std::pair consistentNumberProperty(const char *lhs, - const char *rhs, - cmTarget::CompatibleType t) -{ - char *pEnd; - - const char* const null_ptr = 0; - - long lnum = strtol(lhs, &pEnd, 0); - if (pEnd == lhs || *pEnd != '\0' || errno == ERANGE) - { - return std::pair(false, null_ptr); - } - - long rnum = strtol(rhs, &pEnd, 0); - if (pEnd == rhs || *pEnd != '\0' || errno == ERANGE) - { - return std::pair(false, null_ptr); - } - - if (t == cmTarget::NumberMaxType) - { - return std::make_pair(true, std::max(lnum, rnum) == lnum ? lhs : rhs); - } - else - { - return std::make_pair(true, std::min(lnum, rnum) == lnum ? lhs : rhs); - } -} - -//---------------------------------------------------------------------------- -template<> -std::pair consistentProperty(const char *lhs, - const char *rhs, - cmTarget::CompatibleType t) -{ - if (!lhs && !rhs) - { - return std::make_pair(true, lhs); - } - if (!lhs) - { - return std::make_pair(true, rhs); - } - if (!rhs) - { - return std::make_pair(true, lhs); - } - - const char* const null_ptr = 0; - - switch(t) - { - case cmTarget::BoolType: - assert(0 && "consistentProperty for strings called with BoolType"); - return std::pair(false, null_ptr); - case cmTarget::StringType: - return consistentStringProperty(lhs, rhs); - case cmTarget::NumberMinType: - case cmTarget::NumberMaxType: - return consistentNumberProperty(lhs, rhs, t); - } - assert(0 && "Unreachable!"); - return std::pair(false, null_ptr); -} - -template -PropertyType impliedValue(PropertyType); -template<> -bool impliedValue(bool) -{ - return false; -} -template<> -const char* impliedValue(const char*) -{ - return ""; -} - - -template -std::string valueAsString(PropertyType); -template<> -std::string valueAsString(bool value) -{ - return value ? "TRUE" : "FALSE"; -} -template<> -std::string valueAsString(const char* value) -{ - return value ? value : "(unset)"; -} - -//---------------------------------------------------------------------------- void cmTarget::ReportPropertyOrigin(const std::string &p, const std::string &result, @@ -4711,270 +4576,6 @@ cmTarget::ReportPropertyOrigin(const std::string &p, } //---------------------------------------------------------------------------- -std::string compatibilityType(cmTarget::CompatibleType t) -{ - switch(t) - { - case cmTarget::BoolType: - return "Boolean compatibility"; - case cmTarget::StringType: - return "String compatibility"; - case cmTarget::NumberMaxType: - return "Numeric maximum compatibility"; - case cmTarget::NumberMinType: - return "Numeric minimum compatibility"; - } - assert(0 && "Unreachable!"); - return ""; -} - -//---------------------------------------------------------------------------- -std::string compatibilityAgree(cmTarget::CompatibleType t, bool dominant) -{ - switch(t) - { - case cmTarget::BoolType: - case cmTarget::StringType: - return dominant ? "(Disagree)\n" : "(Agree)\n"; - case cmTarget::NumberMaxType: - case cmTarget::NumberMinType: - return dominant ? "(Dominant)\n" : "(Ignored)\n"; - } - assert(0 && "Unreachable!"); - return ""; -} - -//---------------------------------------------------------------------------- -template -PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, - const std::string &p, - const std::string& config, - const char *defaultValue, - cmTarget::CompatibleType t, - PropertyType *) -{ - PropertyType propContent = getTypedProperty(tgt, p); - const bool explicitlySet = tgt->GetProperties() - .find(p) - != tgt->GetProperties().end(); - const bool impliedByUse = - tgt->IsNullImpliedByLinkLibraries(p); - assert((impliedByUse ^ explicitlySet) - || (!impliedByUse && !explicitlySet)); - - std::vector const& deps = - tgt->GetLinkImplementationClosure(config); - - if(deps.empty()) - { - return propContent; - } - bool propInitialized = explicitlySet; - - std::string report = " * Target \""; - report += tgt->GetName(); - if (explicitlySet) - { - report += "\" has property content \""; - report += valueAsString(propContent); - report += "\"\n"; - } - else if (impliedByUse) - { - report += "\" property is implied by use.\n"; - } - else - { - report += "\" property not set.\n"; - } - - std::string interfaceProperty = "INTERFACE_" + p; - for(std::vector::const_iterator li = - deps.begin(); - li != deps.end(); ++li) - { - // An error should be reported if one dependency - // has INTERFACE_POSITION_INDEPENDENT_CODE ON and the other - // has INTERFACE_POSITION_INDEPENDENT_CODE OFF, or if the - // target itself has a POSITION_INDEPENDENT_CODE which disagrees - // with a dependency. - - cmTarget const* theTarget = *li; - - const bool ifaceIsSet = theTarget->GetProperties() - .find(interfaceProperty) - != theTarget->GetProperties().end(); - PropertyType ifacePropContent = - getTypedProperty(theTarget, - interfaceProperty); - - std::string reportEntry; - if (ifaceIsSet) - { - reportEntry += " * Target \""; - reportEntry += theTarget->GetName(); - reportEntry += "\" property value \""; - reportEntry += valueAsString(ifacePropContent); - reportEntry += "\" "; - } - - if (explicitlySet) - { - if (ifaceIsSet) - { - std::pair consistent = - consistentProperty(propContent, - ifacePropContent, t); - report += reportEntry; - report += compatibilityAgree(t, propContent != consistent.second); - if (!consistent.first) - { - std::ostringstream e; - e << "Property " << p << " on target \"" - << tgt->GetName() << "\" does\nnot match the " - "INTERFACE_" << p << " property requirement\nof " - "dependency \"" << theTarget->GetName() << "\".\n"; - cmSystemTools::Error(e.str().c_str()); - break; - } - else - { - propContent = consistent.second; - continue; - } - } - else - { - // Explicitly set on target and not set in iface. Can't disagree. - continue; - } - } - else if (impliedByUse) - { - propContent = impliedValue(propContent); - - if (ifaceIsSet) - { - std::pair consistent = - consistentProperty(propContent, - ifacePropContent, t); - report += reportEntry; - report += compatibilityAgree(t, propContent != consistent.second); - if (!consistent.first) - { - std::ostringstream e; - e << "Property " << p << " on target \"" - << tgt->GetName() << "\" is\nimplied to be " << defaultValue - << " because it was used to determine the link libraries\n" - "already. The INTERFACE_" << p << " property on\ndependency \"" - << theTarget->GetName() << "\" is in conflict.\n"; - cmSystemTools::Error(e.str().c_str()); - break; - } - else - { - propContent = consistent.second; - continue; - } - } - else - { - // Implicitly set on target and not set in iface. Can't disagree. - continue; - } - } - else - { - if (ifaceIsSet) - { - if (propInitialized) - { - std::pair consistent = - consistentProperty(propContent, - ifacePropContent, t); - report += reportEntry; - report += compatibilityAgree(t, propContent != consistent.second); - if (!consistent.first) - { - std::ostringstream e; - e << "The INTERFACE_" << p << " property of \"" - << theTarget->GetName() << "\" does\nnot agree with the value " - "of " << p << " already determined\nfor \"" - << tgt->GetName() << "\".\n"; - cmSystemTools::Error(e.str().c_str()); - break; - } - else - { - propContent = consistent.second; - continue; - } - } - else - { - report += reportEntry + "(Interface set)\n"; - propContent = ifacePropContent; - propInitialized = true; - } - } - else - { - // Not set. Nothing to agree on. - continue; - } - } - } - - tgt->ReportPropertyOrigin(p, valueAsString(propContent), - report, compatibilityType(t)); - return propContent; -} - -//---------------------------------------------------------------------------- -bool cmTarget::GetLinkInterfaceDependentBoolProperty(const std::string &p, - const std::string& config) const -{ - return checkInterfacePropertyCompatibility(this, p, config, "FALSE", - BoolType, 0); -} - -//---------------------------------------------------------------------------- -const char * cmTarget::GetLinkInterfaceDependentStringProperty( - const std::string &p, - const std::string& config) const -{ - return checkInterfacePropertyCompatibility(this, - p, - config, - "empty", - StringType, 0); -} - -//---------------------------------------------------------------------------- -const char * cmTarget::GetLinkInterfaceDependentNumberMinProperty( - const std::string &p, - const std::string& config) const -{ - return checkInterfacePropertyCompatibility(this, - p, - config, - "empty", - NumberMinType, 0); -} - -//---------------------------------------------------------------------------- -const char * cmTarget::GetLinkInterfaceDependentNumberMaxProperty( - const std::string &p, - const std::string& config) const -{ - return checkInterfacePropertyCompatibility(this, - p, - config, - "empty", - NumberMaxType, 0); -} - -//---------------------------------------------------------------------------- void cmTarget::GetObjectLibrariesCMP0026(std::vector& objlibs) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 8af74ef..b544b0b 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -553,15 +553,6 @@ public: const std::string& config) const; bool IsNullImpliedByLinkLibraries(const std::string &p) const; - bool GetLinkInterfaceDependentBoolProperty(const std::string &p, - const std::string& config) const; - - const char *GetLinkInterfaceDependentStringProperty(const std::string &p, - const std::string& config) const; - const char *GetLinkInterfaceDependentNumberMinProperty(const std::string &p, - const std::string& config) const; - const char *GetLinkInterfaceDependentNumberMaxProperty(const std::string &p, - const std::string& config) const; std::string GetDebugGeneratorExpressions(const std::string &value, cmTarget::LinkLibraryType llt) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b31befa035f6b3294fea71ffdcf1fc889688ffb9 commit b31befa035f6b3294fea71ffdcf1fc889688ffb9 Author: Stephen Kelly AuthorDate: Tue Jul 28 21:02:27 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 08:28:24 2015 +0200 cmGeneratorTarget: Port internal API to cmGeneratorTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 1f3effb..a7b0349 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1525,23 +1525,23 @@ bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty( } template -PropertyType getLinkInterfaceDependentProperty(cmTarget const* tgt, +PropertyType getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, cmTarget::CompatibleType, PropertyType *); template<> -bool getLinkInterfaceDependentProperty(cmTarget const* tgt, +bool getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, cmTarget::CompatibleType, bool *) { - return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); + return tgt->Target->GetLinkInterfaceDependentBoolProperty(prop, config); } template<> -const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, +const char * getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, cmTarget::CompatibleType t, @@ -1553,11 +1553,13 @@ const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, assert(0 && "String compatibility check function called for boolean"); return 0; case cmTarget::StringType: - return tgt->GetLinkInterfaceDependentStringProperty(prop, config); + return tgt->Target->GetLinkInterfaceDependentStringProperty(prop, config); case cmTarget::NumberMinType: - return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config); + return tgt->Target + ->GetLinkInterfaceDependentNumberMinProperty(prop, config); case cmTarget::NumberMaxType: - return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config); + return tgt->Target + ->GetLinkInterfaceDependentNumberMaxProperty(prop, config); } assert(0 && "Unreachable!"); return 0; @@ -1565,7 +1567,7 @@ const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, //---------------------------------------------------------------------------- template -void checkPropertyConsistency(cmTarget const* depender, +void checkPropertyConsistency(cmGeneratorTarget const* depender, cmTarget const* dependee, const std::string& propName, std::set &emitted, @@ -1597,7 +1599,7 @@ void checkPropertyConsistency(cmTarget const* depender, << *pi << "\" listed in its " << propName << " property. " "This is not allowed. Only user-defined properties may appear " "listed in the " << propName << " property."; - depender->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, e.str()); + depender->GetLocalGenerator()->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } if(emitted.insert(*pi).second) @@ -1681,14 +1683,14 @@ void cmGeneratorTarget::CheckPropertyCompatibility( continue; } - checkPropertyConsistency(this->Target, li->Target, + checkPropertyConsistency(this, li->Target, strBool, emittedBools, config, cmTarget::BoolType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; } - checkPropertyConsistency(this->Target, li->Target, + checkPropertyConsistency(this, li->Target, strString, emittedStrings, config, cmTarget::StringType, 0); @@ -1696,7 +1698,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( { return; } - checkPropertyConsistency(this->Target, li->Target, + checkPropertyConsistency(this, li->Target, strNumMin, emittedMinNumbers, config, cmTarget::NumberMinType, 0); @@ -1704,7 +1706,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( { return; } - checkPropertyConsistency(this->Target, li->Target, + checkPropertyConsistency(this, li->Target, strNumMax, emittedMaxNumbers, config, cmTarget::NumberMaxType, 0); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3553d2fdfc6203136ad240702e4c77bdc349416d commit 3553d2fdfc6203136ad240702e4c77bdc349416d Author: Stephen Kelly AuthorDate: Tue Jul 28 20:59:17 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 08:28:24 2015 +0200 cmGeneratorTarget: Move CheckPropertyCompatibility from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 845c052..1f3effb 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1524,6 +1524,240 @@ bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty( return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0; } +template +PropertyType getLinkInterfaceDependentProperty(cmTarget const* tgt, + const std::string& prop, + const std::string& config, + cmTarget::CompatibleType, + PropertyType *); + +template<> +bool getLinkInterfaceDependentProperty(cmTarget const* tgt, + const std::string& prop, + const std::string& config, + cmTarget::CompatibleType, bool *) +{ + return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); +} + +template<> +const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, + const std::string& prop, + const std::string& config, + cmTarget::CompatibleType t, + const char **) +{ + switch(t) + { + case cmTarget::BoolType: + assert(0 && "String compatibility check function called for boolean"); + return 0; + case cmTarget::StringType: + return tgt->GetLinkInterfaceDependentStringProperty(prop, config); + case cmTarget::NumberMinType: + return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config); + case cmTarget::NumberMaxType: + return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config); + } + assert(0 && "Unreachable!"); + return 0; +} + +//---------------------------------------------------------------------------- +template +void checkPropertyConsistency(cmTarget const* depender, + cmTarget const* dependee, + const std::string& propName, + std::set &emitted, + const std::string& config, + cmTarget::CompatibleType t, + PropertyType *) +{ + const char *prop = dependee->GetProperty(propName); + if (!prop) + { + return; + } + + std::vector props; + cmSystemTools::ExpandListArgument(prop, props); + std::string pdir = + dependee->GetMakefile()->GetRequiredDefinition("CMAKE_ROOT"); + pdir += "/Help/prop_tgt/"; + + for(std::vector::iterator pi = props.begin(); + pi != props.end(); ++pi) + { + std::string pname = cmSystemTools::HelpFileName(*pi); + std::string pfile = pdir + pname + ".rst"; + if(cmSystemTools::FileExists(pfile.c_str(), true)) + { + std::ostringstream e; + e << "Target \"" << dependee->GetName() << "\" has property \"" + << *pi << "\" listed in its " << propName << " property. " + "This is not allowed. Only user-defined properties may appear " + "listed in the " << propName << " property."; + depender->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, e.str()); + return; + } + if(emitted.insert(*pi).second) + { + getLinkInterfaceDependentProperty(depender, *pi, config, + t, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + } + } +} + +static std::string intersect(const std::set &s1, + const std::set &s2) +{ + std::set intersect; + std::set_intersection(s1.begin(),s1.end(), + s2.begin(),s2.end(), + std::inserter(intersect,intersect.begin())); + if (!intersect.empty()) + { + return *intersect.begin(); + } + return ""; +} + +static std::string intersect(const std::set &s1, + const std::set &s2, + const std::set &s3) +{ + std::string result; + result = intersect(s1, s2); + if (!result.empty()) + return result; + result = intersect(s1, s3); + if (!result.empty()) + return result; + return intersect(s2, s3); +} + +static std::string intersect(const std::set &s1, + const std::set &s2, + const std::set &s3, + const std::set &s4) +{ + std::string result; + result = intersect(s1, s2); + if (!result.empty()) + return result; + result = intersect(s1, s3); + if (!result.empty()) + return result; + result = intersect(s1, s4); + if (!result.empty()) + return result; + return intersect(s2, s3, s4); +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::CheckPropertyCompatibility( + cmComputeLinkInformation *info, const std::string& config) const +{ + const cmComputeLinkInformation::ItemVector &deps = info->GetItems(); + + std::set emittedBools; + static std::string strBool = "COMPATIBLE_INTERFACE_BOOL"; + std::set emittedStrings; + static std::string strString = "COMPATIBLE_INTERFACE_STRING"; + std::set emittedMinNumbers; + static std::string strNumMin = "COMPATIBLE_INTERFACE_NUMBER_MIN"; + std::set emittedMaxNumbers; + static std::string strNumMax = "COMPATIBLE_INTERFACE_NUMBER_MAX"; + + for(cmComputeLinkInformation::ItemVector::const_iterator li = + deps.begin(); li != deps.end(); ++li) + { + if (!li->Target) + { + continue; + } + + checkPropertyConsistency(this->Target, li->Target, + strBool, + emittedBools, config, cmTarget::BoolType, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + checkPropertyConsistency(this->Target, li->Target, + strString, + emittedStrings, config, + cmTarget::StringType, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + checkPropertyConsistency(this->Target, li->Target, + strNumMin, + emittedMinNumbers, config, + cmTarget::NumberMinType, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + checkPropertyConsistency(this->Target, li->Target, + strNumMax, + emittedMaxNumbers, config, + cmTarget::NumberMaxType, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + } + + std::string prop = intersect(emittedBools, + emittedStrings, + emittedMinNumbers, + emittedMaxNumbers); + + if (!prop.empty()) + { + // Use a sorted std::vector to keep the error message sorted. + std::vector props; + std::set::const_iterator i = emittedBools.find(prop); + if (i != emittedBools.end()) + { + props.push_back(strBool); + } + i = emittedStrings.find(prop); + if (i != emittedStrings.end()) + { + props.push_back(strString); + } + i = emittedMinNumbers.find(prop); + if (i != emittedMinNumbers.end()) + { + props.push_back(strNumMin); + } + i = emittedMaxNumbers.find(prop); + if (i != emittedMaxNumbers.end()) + { + props.push_back(strNumMax); + } + std::sort(props.begin(), props.end()); + + std::string propsString = cmJoin(cmMakeRange(props).retreat(1), ", "); + propsString += " and the " + props.back(); + + std::ostringstream e; + e << "Property \"" << prop << "\" appears in both the " + << propsString << + " property in the dependencies of target \"" << this->GetName() << + "\". This is not allowed. A property may only require compatibility " + "in a boolean interpretation, a numeric minimum, a numeric maximum or a " + "string interpretation, but not a mixture."; + this->LocalGenerator->IssueMessage(cmake::FATAL_ERROR, e.str()); + } +} //---------------------------------------------------------------------------- cmComputeLinkInformation* @@ -1550,7 +1784,7 @@ cmGeneratorTarget::GetLinkInformation(const std::string& config) const if (info) { - this->Target->CheckPropertyCompatibility(info, config); + this->CheckPropertyCompatibility(info, config); } } return i->second; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index e53f098..ae86e19 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -222,6 +222,9 @@ private: cmTargetLinkInformationMap; mutable cmTargetLinkInformationMap LinkInformation; + void CheckPropertyCompatibility(cmComputeLinkInformation *info, + const std::string& config) const; + cmGeneratorTarget(cmGeneratorTarget const&); void operator=(cmGeneratorTarget const&); }; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index d8904ea..b165545 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4554,23 +4554,16 @@ const char *getTypedProperty(cmTarget const* tgt, return tgt->GetProperty(prop); } -enum CompatibleType -{ - BoolType, - StringType, - NumberMinType, - NumberMaxType -}; - //---------------------------------------------------------------------------- template std::pair consistentProperty(PropertyType lhs, PropertyType rhs, - CompatibleType t); + cmTarget::CompatibleType t); //---------------------------------------------------------------------------- template<> -std::pair consistentProperty(bool lhs, bool rhs, CompatibleType) +std::pair consistentProperty(bool lhs, bool rhs, + cmTarget::CompatibleType) { return std::make_pair(lhs == rhs, lhs); } @@ -4585,8 +4578,8 @@ std::pair consistentStringProperty(const char *lhs, //---------------------------------------------------------------------------- std::pair consistentNumberProperty(const char *lhs, - const char *rhs, - CompatibleType t) + const char *rhs, + cmTarget::CompatibleType t) { char *pEnd; @@ -4604,7 +4597,7 @@ std::pair consistentNumberProperty(const char *lhs, return std::pair(false, null_ptr); } - if (t == NumberMaxType) + if (t == cmTarget::NumberMaxType) { return std::make_pair(true, std::max(lnum, rnum) == lnum ? lhs : rhs); } @@ -4618,7 +4611,7 @@ std::pair consistentNumberProperty(const char *lhs, template<> std::pair consistentProperty(const char *lhs, const char *rhs, - CompatibleType t) + cmTarget::CompatibleType t) { if (!lhs && !rhs) { @@ -4637,13 +4630,13 @@ std::pair consistentProperty(const char *lhs, switch(t) { - case BoolType: + case cmTarget::BoolType: assert(0 && "consistentProperty for strings called with BoolType"); return std::pair(false, null_ptr); - case StringType: + case cmTarget::StringType: return consistentStringProperty(lhs, rhs); - case NumberMinType: - case NumberMaxType: + case cmTarget::NumberMinType: + case cmTarget::NumberMaxType: return consistentNumberProperty(lhs, rhs, t); } assert(0 && "Unreachable!"); @@ -4718,17 +4711,17 @@ cmTarget::ReportPropertyOrigin(const std::string &p, } //---------------------------------------------------------------------------- -std::string compatibilityType(CompatibleType t) +std::string compatibilityType(cmTarget::CompatibleType t) { switch(t) { - case BoolType: + case cmTarget::BoolType: return "Boolean compatibility"; - case StringType: + case cmTarget::StringType: return "String compatibility"; - case NumberMaxType: + case cmTarget::NumberMaxType: return "Numeric maximum compatibility"; - case NumberMinType: + case cmTarget::NumberMinType: return "Numeric minimum compatibility"; } assert(0 && "Unreachable!"); @@ -4736,15 +4729,15 @@ std::string compatibilityType(CompatibleType t) } //---------------------------------------------------------------------------- -std::string compatibilityAgree(CompatibleType t, bool dominant) +std::string compatibilityAgree(cmTarget::CompatibleType t, bool dominant) { switch(t) { - case BoolType: - case StringType: + case cmTarget::BoolType: + case cmTarget::StringType: return dominant ? "(Disagree)\n" : "(Agree)\n"; - case NumberMaxType: - case NumberMinType: + case cmTarget::NumberMaxType: + case cmTarget::NumberMinType: return dominant ? "(Dominant)\n" : "(Ignored)\n"; } assert(0 && "Unreachable!"); @@ -4757,7 +4750,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, const std::string &p, const std::string& config, const char *defaultValue, - CompatibleType t, + cmTarget::CompatibleType t, PropertyType *) { PropertyType propContent = getTypedProperty(tgt, p); @@ -6224,240 +6217,6 @@ std::string cmTarget::CheckCMP0004(std::string const& item) const return lib; } -template -PropertyType getLinkInterfaceDependentProperty(cmTarget const* tgt, - const std::string& prop, - const std::string& config, - CompatibleType, - PropertyType *); - -template<> -bool getLinkInterfaceDependentProperty(cmTarget const* tgt, - const std::string& prop, - const std::string& config, - CompatibleType, bool *) -{ - return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); -} - -template<> -const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, - const std::string& prop, - const std::string& config, - CompatibleType t, - const char **) -{ - switch(t) - { - case BoolType: - assert(0 && "String compatibility check function called for boolean"); - return 0; - case StringType: - return tgt->GetLinkInterfaceDependentStringProperty(prop, config); - case NumberMinType: - return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config); - case NumberMaxType: - return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config); - } - assert(0 && "Unreachable!"); - return 0; -} - -//---------------------------------------------------------------------------- -template -void checkPropertyConsistency(cmTarget const* depender, - cmTarget const* dependee, - const std::string& propName, - std::set &emitted, - const std::string& config, - CompatibleType t, - PropertyType *) -{ - const char *prop = dependee->GetProperty(propName); - if (!prop) - { - return; - } - - std::vector props; - cmSystemTools::ExpandListArgument(prop, props); - std::string pdir = - dependee->GetMakefile()->GetRequiredDefinition("CMAKE_ROOT"); - pdir += "/Help/prop_tgt/"; - - for(std::vector::iterator pi = props.begin(); - pi != props.end(); ++pi) - { - std::string pname = cmSystemTools::HelpFileName(*pi); - std::string pfile = pdir + pname + ".rst"; - if(cmSystemTools::FileExists(pfile.c_str(), true)) - { - std::ostringstream e; - e << "Target \"" << dependee->GetName() << "\" has property \"" - << *pi << "\" listed in its " << propName << " property. " - "This is not allowed. Only user-defined properties may appear " - "listed in the " << propName << " property."; - depender->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, e.str()); - return; - } - if(emitted.insert(*pi).second) - { - getLinkInterfaceDependentProperty(depender, *pi, config, - t, 0); - if (cmSystemTools::GetErrorOccuredFlag()) - { - return; - } - } - } -} - -static std::string intersect(const std::set &s1, - const std::set &s2) -{ - std::set intersect; - std::set_intersection(s1.begin(),s1.end(), - s2.begin(),s2.end(), - std::inserter(intersect,intersect.begin())); - if (!intersect.empty()) - { - return *intersect.begin(); - } - return ""; -} -static std::string intersect(const std::set &s1, - const std::set &s2, - const std::set &s3) -{ - std::string result; - result = intersect(s1, s2); - if (!result.empty()) - return result; - result = intersect(s1, s3); - if (!result.empty()) - return result; - return intersect(s2, s3); -} -static std::string intersect(const std::set &s1, - const std::set &s2, - const std::set &s3, - const std::set &s4) -{ - std::string result; - result = intersect(s1, s2); - if (!result.empty()) - return result; - result = intersect(s1, s3); - if (!result.empty()) - return result; - result = intersect(s1, s4); - if (!result.empty()) - return result; - return intersect(s2, s3, s4); -} - -//---------------------------------------------------------------------------- -void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, - const std::string& config) const -{ - const cmComputeLinkInformation::ItemVector &deps = info->GetItems(); - - std::set emittedBools; - static std::string strBool = "COMPATIBLE_INTERFACE_BOOL"; - std::set emittedStrings; - static std::string strString = "COMPATIBLE_INTERFACE_STRING"; - std::set emittedMinNumbers; - static std::string strNumMin = "COMPATIBLE_INTERFACE_NUMBER_MIN"; - std::set emittedMaxNumbers; - static std::string strNumMax = "COMPATIBLE_INTERFACE_NUMBER_MAX"; - - for(cmComputeLinkInformation::ItemVector::const_iterator li = - deps.begin(); - li != deps.end(); ++li) - { - if (!li->Target) - { - continue; - } - - checkPropertyConsistency(this, li->Target, - strBool, - emittedBools, config, BoolType, 0); - if (cmSystemTools::GetErrorOccuredFlag()) - { - return; - } - checkPropertyConsistency(this, li->Target, - strString, - emittedStrings, config, - StringType, 0); - if (cmSystemTools::GetErrorOccuredFlag()) - { - return; - } - checkPropertyConsistency(this, li->Target, - strNumMin, - emittedMinNumbers, config, - NumberMinType, 0); - if (cmSystemTools::GetErrorOccuredFlag()) - { - return; - } - checkPropertyConsistency(this, li->Target, - strNumMax, - emittedMaxNumbers, config, - NumberMaxType, 0); - if (cmSystemTools::GetErrorOccuredFlag()) - { - return; - } - } - - std::string prop = intersect(emittedBools, - emittedStrings, - emittedMinNumbers, - emittedMaxNumbers); - - if (!prop.empty()) - { - // Use a sorted std::vector to keep the error message sorted. - std::vector props; - std::set::const_iterator i = emittedBools.find(prop); - if (i != emittedBools.end()) - { - props.push_back(strBool); - } - i = emittedStrings.find(prop); - if (i != emittedStrings.end()) - { - props.push_back(strString); - } - i = emittedMinNumbers.find(prop); - if (i != emittedMinNumbers.end()) - { - props.push_back(strNumMin); - } - i = emittedMaxNumbers.find(prop); - if (i != emittedMaxNumbers.end()) - { - props.push_back(strNumMax); - } - std::sort(props.begin(), props.end()); - - std::string propsString = cmJoin(cmMakeRange(props).retreat(1), ", "); - propsString += " and the " + props.back(); - - std::ostringstream e; - e << "Property \"" << prop << "\" appears in both the " - << propsString << - " property in the dependencies of target \"" << this->GetName() << - "\". This is not allowed. A property may only require compatibility " - "in a boolean interpretation, a numeric minimum, a numeric maximum or a " - "string interpretation, but not a mixture."; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); - } -} - //---------------------------------------------------------------------------- std::string cmTarget::GetFrameworkDirectory(const std::string& config, bool rootDir) const diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e3410aa..8af74ef 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -590,6 +590,14 @@ public: return this->LinkLibrariesForVS6;} #endif + enum CompatibleType + { + BoolType, + StringType, + NumberMinType, + NumberMaxType + }; + private: bool HandleLocationPropertyPolicy(cmMakefile* context) const; @@ -754,9 +762,6 @@ private: struct CompileInfo; CompileInfo const* GetCompileInfo(const std::string& config) const; - void CheckPropertyCompatibility(cmComputeLinkInformation *info, - const std::string& config) const; - LinkInterface const* GetImportLinkInterface(const std::string& config, cmTarget const* head, bool usage_requirements_only) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=28c2e75eae70dace83ec6d51b77622ba592a148e commit 28c2e75eae70dace83ec6d51b77622ba592a148e Author: Stephen Kelly AuthorDate: Thu Jun 13 21:56:07 2013 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 08:28:23 2015 +0200 cmGeneratorTarget: Move GetLinkInformation from cmTarget diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 26ca375..4840e89 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -276,7 +276,8 @@ std::string cmCommonTargetGenerator::GetFrameworkFlags(std::string const& l) std::string flags; const char* cfg = this->LocalGenerator->GetConfigName().c_str(); - if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(cfg)) + if(cmComputeLinkInformation* cli = + this->GeneratorTarget->GetLinkInformation(cfg)) { std::vector const& frameworks = cli->GetFrameworkPaths(); for(std::vector::const_iterator i = frameworks.begin(); @@ -384,7 +385,7 @@ cmCommonTargetGenerator::GetLinkedTargetDirectories() const std::vector dirs; std::set emitted; if (cmComputeLinkInformation* cli = - this->Target->GetLinkInformation(this->ConfigName)) + this->GeneratorTarget->GetLinkInformation(this->ConfigName)) { cmComputeLinkInformation::ItemVector const& items = cli->GetItems(); for(cmComputeLinkInformation::ItemVector::const_iterator diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index a5050ff..8a2cf4b 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -529,7 +529,7 @@ void getCompatibleInterfaceProperties(cmGeneratorTarget *target, std::set &ifaceProperties, const std::string& config) { - cmComputeLinkInformation *info = target->Target->GetLinkInformation(config); + cmComputeLinkInformation *info = target->GetLinkInformation(config); if (!info) { diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 3dbeff2..845c052 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -229,6 +229,12 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) this->GlobalGenerator = this->Makefile->GetGlobalGenerator(); } +cmGeneratorTarget::~cmGeneratorTarget() +{ + cmDeleteAll(this->LinkInformation); + this->LinkInformation.clear(); +} + cmLocalGenerator* cmGeneratorTarget::GetLocalGenerator() const { return this->LocalGenerator; @@ -1517,3 +1523,35 @@ bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty( } return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0; } + + +//---------------------------------------------------------------------------- +cmComputeLinkInformation* +cmGeneratorTarget::GetLinkInformation(const std::string& config) const +{ + // Lookup any existing information for this configuration. + std::string key(cmSystemTools::UpperCase(config)); + cmTargetLinkInformationMap::iterator + i = this->LinkInformation.find(key); + if(i == this->LinkInformation.end()) + { + // Compute information for this configuration. + cmComputeLinkInformation* info = + new cmComputeLinkInformation(this->Target, config); + if(!info || !info->Compute()) + { + delete info; + info = 0; + } + + // Store the information for this configuration. + cmTargetLinkInformationMap::value_type entry(key, info); + i = this->LinkInformation.insert(entry).first; + + if (info) + { + this->Target->CheckPropertyCompatibility(info, config); + } + } + return i->second; +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 3b32bf5..e53f098 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -20,11 +20,13 @@ class cmLocalGenerator; class cmMakefile; class cmSourceFile; class cmTarget; +class cmComputeLinkInformation; class cmGeneratorTarget { public: cmGeneratorTarget(cmTarget*, cmLocalGenerator* lg); + ~cmGeneratorTarget(); cmLocalGenerator* GetLocalGenerator() const; @@ -36,6 +38,9 @@ public: location is suitable for use as the LOCATION target property. */ const char* GetLocationForBuild() const; + cmComputeLinkInformation* + GetLinkInformation(const std::string& config) const; + int GetType() const; std::string GetName() const; const char *GetProperty(const std::string& prop) const; @@ -213,6 +218,10 @@ private: }; mutable std::map CompatibleInterfacesMap; + typedef std::map + cmTargetLinkInformationMap; + mutable cmTargetLinkInformationMap LinkInformation; + cmGeneratorTarget(cmGeneratorTarget const&); void operator=(cmGeneratorTarget const&); }; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 8cb59f8..b44848c 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2202,7 +2202,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, } } // Add framework search paths needed for linking. - if(cmComputeLinkInformation* cli = target.GetLinkInformation(configName)) + if(cmComputeLinkInformation* cli = gtgt->GetLinkInformation(configName)) { std::vector const& fwDirs = cli->GetFrameworkPaths(); for(std::vector::const_iterator fdi = fwDirs.begin(); @@ -2358,7 +2358,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, this->CreateString(install_name_dir.c_str())); // Create the LD_RUNPATH_SEARCH_PATHS - cmComputeLinkInformation* pcli = target.GetLinkInformation(configName); + cmComputeLinkInformation* pcli = gtgt->GetLinkInformation(configName); if(pcli) { std::string search_paths; @@ -2964,7 +2964,8 @@ void cmGlobalXCodeGenerator } // Compute the link library and directory information. - cmComputeLinkInformation* pcli = cmtarget->GetLinkInformation(configName); + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(cmtarget); + cmComputeLinkInformation* pcli = gtgt->GetLinkInformation(configName); if(!pcli) { continue; diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 01d4b77..c64f9a3 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -18,6 +18,7 @@ #include "cmMakefile.h" #include "cmGeneratorTarget.h" #include "cmake.h" +#include "cmGeneratorTarget.h" #include @@ -557,8 +558,7 @@ cmInstallTargetGenerator // Build a map of build-tree install_name to install-tree install_name for // shared libraries linked to this target. std::map install_name_remap; - if(cmComputeLinkInformation* cli = - this->Target->Target->GetLinkInformation(config)) + if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config)) { std::set const& sharedLibs = cli->GetSharedLibrariesLinked(); @@ -667,8 +667,7 @@ cmInstallTargetGenerator // Get the link information for this target. // It can provide the RPATH. - cmComputeLinkInformation* cli = - this->Target->Target->GetLinkInformation(config); + cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config); if(!cli) { return; @@ -700,8 +699,7 @@ cmInstallTargetGenerator // Get the link information for this target. // It can provide the RPATH. - cmComputeLinkInformation* cli = - this->Target->Target->GetLinkInformation(config); + cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config); if(!cli) { return; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 6b48a44..eaf812f 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1468,7 +1468,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, bool escapeAllowMakeVars = !forResponseFile; std::ostringstream fout; std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); - cmComputeLinkInformation* pcli = tgt.Target->GetLinkInformation(config); + cmComputeLinkInformation* pcli = tgt.GetLinkInformation(config); if(!pcli) { return; diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index cab5a47..61d7847 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1846,8 +1846,10 @@ void cmLocalVisualStudio6Generator const std::string extraOptions, std::string& options) { + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); // Compute the link information for this configuration. - cmComputeLinkInformation* pcli = target.GetLinkInformation(configName); + cmComputeLinkInformation* pcli = gt->GetLinkInformation(configName); if(!pcli) { return; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 572dbde..5bd82ff 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1148,7 +1148,9 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, targetNameImport, targetNamePDB, configName); // Compute the link library and directory information. - cmComputeLinkInformation* pcli = target.GetLinkInformation(configName); + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); + cmComputeLinkInformation* pcli = gt->GetLinkInformation(configName); if(!pcli) { return; @@ -1245,7 +1247,9 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, targetNameImport, targetNamePDB, configName); // Compute the link library and directory information. - cmComputeLinkInformation* pcli = target.GetLinkInformation(configName); + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); + cmComputeLinkInformation* pcli = gt->GetLinkInformation(configName); if(!pcli) { return; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 5edc0f5..ac8cd29 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1446,7 +1446,8 @@ void cmMakefileTargetGenerator // Loop over all library dependencies. const char* cfg = this->LocalGenerator->GetConfigName().c_str(); - if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(cfg)) + if(cmComputeLinkInformation* cli = + this->GeneratorTarget->GetLinkInformation(cfg)) { std::vector const& libDeps = cli->GetDepends(); depends.insert(depends.end(), libDeps.begin(), libDeps.end()); diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 4e4dc3f..cf80424 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -195,7 +195,7 @@ cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const return cmNinjaDeps(); cmComputeLinkInformation* cli = - this->Target->GetLinkInformation(this->GetConfigName()); + this->GeneratorTarget->GetLinkInformation(this->GetConfigName()); if(!cli) return cmNinjaDeps(); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 9c7e46a..d8904ea 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -520,8 +520,6 @@ void cmTarget::ClearLinkMaps() this->Internal->LinkInterfaceUsageRequirementsOnlyMap.clear(); this->Internal->LinkClosureMap.clear(); this->Internal->SourceFilesMap.clear(); - cmDeleteAll(this->LinkInformation); - this->LinkInformation.clear(); } //---------------------------------------------------------------------------- @@ -6461,37 +6459,6 @@ void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, } //---------------------------------------------------------------------------- -cmComputeLinkInformation* -cmTarget::GetLinkInformation(const std::string& config) const -{ - // Lookup any existing information for this configuration. - std::string key(cmSystemTools::UpperCase(config)); - cmTargetLinkInformationMap::iterator - i = this->LinkInformation.find(key); - if(i == this->LinkInformation.end()) - { - // Compute information for this configuration. - cmComputeLinkInformation* info = - new cmComputeLinkInformation(this, config); - if(!info || !info->Compute()) - { - delete info; - info = 0; - } - - // Store the information for this configuration. - cmTargetLinkInformationMap::value_type entry(key, info); - i = this->LinkInformation.insert(entry).first; - - if (info) - { - this->CheckPropertyCompatibility(info, config); - } - } - return i->second; -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetFrameworkDirectory(const std::string& config, bool rootDir) const { @@ -6583,26 +6550,6 @@ std::string cmTarget::GetMacContentDirectory(const std::string& config, } //---------------------------------------------------------------------------- -cmTargetLinkInformationMap -::cmTargetLinkInformationMap(cmTargetLinkInformationMap const& r): derived() -{ - // Ideally cmTarget instances should never be copied. However until - // we can make a sweep to remove that, this copy constructor avoids - // allowing the resources (LinkInformation) from getting copied. In - // the worst case this will lead to extra cmComputeLinkInformation - // instances. We also enforce in debug mode that the map be emptied - // when copied. - static_cast(r); - assert(r.empty()); -} - -//---------------------------------------------------------------------------- -cmTargetLinkInformationMap::~cmTargetLinkInformationMap() -{ - cmDeleteAll(*this); -} - -//---------------------------------------------------------------------------- cmTargetInternalPointer::cmTargetInternalPointer() { this->Pointer = new cmTargetInternals; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index df8cdc1..e3410aa 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -78,15 +78,6 @@ public: bool FromGenex; }; -struct cmTargetLinkInformationMap: - public std::map -{ - typedef std::map derived; - cmTargetLinkInformationMap() {} - cmTargetLinkInformationMap(cmTargetLinkInformationMap const& r); - ~cmTargetLinkInformationMap(); -}; - class cmTargetInternals; class cmTargetInternalPointer { @@ -454,9 +445,6 @@ public: * install tree. For example: "\@rpath/" or "\@loader_path/". */ std::string GetInstallNameDirForInstallTree() const; - cmComputeLinkInformation* - GetLinkInformation(const std::string& config) const; - // Get the properties cmPropertyMap &GetProperties() const { return this->Properties; } @@ -766,7 +754,6 @@ private: struct CompileInfo; CompileInfo const* GetCompileInfo(const std::string& config) const; - mutable cmTargetLinkInformationMap LinkInformation; void CheckPropertyCompatibility(cmComputeLinkInformation *info, const std::string& config) const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 71785e9..f3f291a 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2438,7 +2438,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) cmSystemTools::ExpandListArgument(libs, libVec); cmComputeLinkInformation* pcli = - this->Target->GetLinkInformation(config.c_str()); + this->GeneratorTarget->GetLinkInformation(config.c_str()); if(!pcli) { cmSystemTools::Error http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8bd6bdd2b6289196bb45103b50b7f41729938dc1 commit 8bd6bdd2b6289196bb45103b50b7f41729938dc1 Author: Stephen Kelly AuthorDate: Mon Jul 27 22:51:04 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 08:28:23 2015 +0200 Export: Port more API to cmGeneratorTarget. diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 355fc00..6274c3f 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -27,6 +27,7 @@ cmExportBuildFileGenerator::cmExportBuildFileGenerator() //---------------------------------------------------------------------------- bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) { + std::vector allTargets; { std::string expectedTargets; std::string sep; @@ -68,7 +69,8 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) tei = this->Exports.begin(); tei != this->Exports.end(); ++tei) { - cmTarget* te = (*tei)->Target; + cmGeneratorTarget* gte = *tei; + cmTarget* te = gte->Target; this->GenerateImportTargetCode(os, te); te->AppendBuildInterfaceIncludes(); @@ -104,7 +106,7 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) cmGeneratorExpression::BuildInterface, properties, missingTargets); } - this->PopulateCompatibleInterfaceProperties(te, properties); + this->PopulateCompatibleInterfaceProperties(gte, properties); this->GenerateInterfaceProperties(te, os, properties); } diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 3aa2b65..a5050ff 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -525,15 +525,15 @@ void getPropertyContents(cmTarget const* tgt, const std::string& prop, } //---------------------------------------------------------------------------- -void getCompatibleInterfaceProperties(cmTarget *target, +void getCompatibleInterfaceProperties(cmGeneratorTarget *target, std::set &ifaceProperties, const std::string& config) { - cmComputeLinkInformation *info = target->GetLinkInformation(config); + cmComputeLinkInformation *info = target->Target->GetLinkInformation(config); if (!info) { - cmMakefile* mf = target->GetMakefile(); + cmMakefile* mf = target->Target->GetMakefile(); std::ostringstream e; e << "Exporting the target \"" << target->GetName() << "\" is not " "allowed since its linker language cannot be determined"; @@ -568,9 +568,10 @@ void getCompatibleInterfaceProperties(cmTarget *target, //---------------------------------------------------------------------------- void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( - cmTarget *target, + cmGeneratorTarget *gtarget, ImportPropertyMap &properties) { + cmTarget *target = gtarget->Target; this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_BOOL", target, properties); this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_STRING", @@ -591,7 +592,7 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( if (target->GetType() != cmTarget::INTERFACE_LIBRARY) { - getCompatibleInterfaceProperties(target, ifaceProperties, ""); + getCompatibleInterfaceProperties(gtarget, ifaceProperties, ""); std::vector configNames; target->GetMakefile()->GetConfigurations(configNames); @@ -599,7 +600,7 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( for (std::vector::const_iterator ci = configNames.begin(); ci != configNames.end(); ++ci) { - getCompatibleInterfaceProperties(target, ifaceProperties, *ci); + getCompatibleInterfaceProperties(gtarget, ifaceProperties, *ci); } } diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index 2f33200..4e54740 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -132,7 +132,7 @@ protected: std::vector &missingTargets); void PopulateInterfaceProperty(const std::string& propName, cmTarget *target, ImportPropertyMap &properties); - void PopulateCompatibleInterfaceProperties(cmTarget *target, + void PopulateCompatibleInterfaceProperties(cmGeneratorTarget *target, ImportPropertyMap &properties); void GenerateInterfaceProperties(cmTarget const* target, std::ostream& os, const ImportPropertyMap &properties); diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index c88b7b2..b0bc686 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -193,7 +193,11 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE", te, properties); - this->PopulateCompatibleInterfaceProperties(te, properties); + cmGeneratorTarget *gtgt = te->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(te); + + this->PopulateCompatibleInterfaceProperties(gtgt, properties); this->GenerateInterfaceProperties(te, os, properties); } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cb73dc2b25fcea8e60853e13411f8013de09f6b9 commit cb73dc2b25fcea8e60853e13411f8013de09f6b9 Author: Stephen Kelly AuthorDate: Mon Jul 27 22:33:34 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 08:28:23 2015 +0200 cmGeneratorTarget: Move IsLinkInterfaceDependent* from cmTarget. diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index c0485db..c1641cc 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1128,6 +1128,9 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode } } + cmGeneratorTarget* gtgt = + context->Makefile->GetGlobalGenerator()->GetGeneratorTarget(target); + if (!prop) { if (target->IsImported() @@ -1135,16 +1138,16 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { return linkedTargetsContent; } - if (target->IsLinkInterfaceDependentBoolProperty(propertyName, - context->Config)) + if (gtgt->IsLinkInterfaceDependentBoolProperty(propertyName, + context->Config)) { context->HadContextSensitiveCondition = true; return target->GetLinkInterfaceDependentBoolProperty( propertyName, context->Config) ? "1" : "0"; } - if (target->IsLinkInterfaceDependentStringProperty(propertyName, - context->Config)) + if (gtgt->IsLinkInterfaceDependentStringProperty(propertyName, + context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = @@ -1153,8 +1156,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode context->Config); return propContent ? propContent : ""; } - if (target->IsLinkInterfaceDependentNumberMinProperty(propertyName, - context->Config)) + if (gtgt->IsLinkInterfaceDependentNumberMinProperty(propertyName, + context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = @@ -1163,8 +1166,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode context->Config); return propContent ? propContent : ""; } - if (target->IsLinkInterfaceDependentNumberMaxProperty(propertyName, - context->Config)) + if (gtgt->IsLinkInterfaceDependentNumberMaxProperty(propertyName, + context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = @@ -1180,8 +1183,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode if (!target->IsImported() && dagCheckerParent && !dagCheckerParent->EvaluatingLinkLibraries()) { - if (target->IsLinkInterfaceDependentNumberMinProperty(propertyName, - context->Config)) + if (gtgt->IsLinkInterfaceDependentNumberMinProperty(propertyName, + context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = @@ -1190,8 +1193,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode context->Config); return propContent ? propContent : ""; } - if (target->IsLinkInterfaceDependentNumberMaxProperty(propertyName, - context->Config)) + if (gtgt->IsLinkInterfaceDependentNumberMaxProperty(propertyName, + context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 95f6aaa..3dbeff2 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1436,3 +1436,84 @@ void cmGeneratorTarget::ConstructSourceFileFlags() const } } } + +//---------------------------------------------------------------------------- +const cmGeneratorTarget::CompatibleInterfacesBase& +cmGeneratorTarget::GetCompatibleInterfaces(std::string const& config) const +{ + cmGeneratorTarget::CompatibleInterfaces& compat = + this->CompatibleInterfacesMap[config]; + if(!compat.Done) + { + compat.Done = true; + compat.PropsBool.insert("POSITION_INDEPENDENT_CODE"); + compat.PropsString.insert("AUTOUIC_OPTIONS"); + std::vector const& deps = + this->Target->GetLinkImplementationClosure(config); + for(std::vector::const_iterator li = deps.begin(); + li != deps.end(); ++li) + { +#define CM_READ_COMPATIBLE_INTERFACE(X, x) \ + if(const char* prop = (*li)->GetProperty("COMPATIBLE_INTERFACE_" #X)) \ + { \ + std::vector props; \ + cmSystemTools::ExpandListArgument(prop, props); \ + compat.Props##x.insert(props.begin(), props.end()); \ + } + CM_READ_COMPATIBLE_INTERFACE(BOOL, Bool) + CM_READ_COMPATIBLE_INTERFACE(STRING, String) + CM_READ_COMPATIBLE_INTERFACE(NUMBER_MIN, NumberMin) + CM_READ_COMPATIBLE_INTERFACE(NUMBER_MAX, NumberMax) +#undef CM_READ_COMPATIBLE_INTERFACE + } + } + return compat; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsLinkInterfaceDependentBoolProperty( + const std::string &p, const std::string& config) const +{ + if (this->Target->GetType() == cmTarget::OBJECT_LIBRARY + || this->Target->GetType() == cmTarget::INTERFACE_LIBRARY) + { + return false; + } + return this->GetCompatibleInterfaces(config).PropsBool.count(p) > 0; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsLinkInterfaceDependentStringProperty( + const std::string &p, const std::string& config) const +{ + if (this->Target->GetType() == cmTarget::OBJECT_LIBRARY + || this->Target->GetType() == cmTarget::INTERFACE_LIBRARY) + { + return false; + } + return this->GetCompatibleInterfaces(config).PropsString.count(p) > 0; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMinProperty( + const std::string &p, const std::string& config) const +{ + if (this->Target->GetType() == cmTarget::OBJECT_LIBRARY + || this->Target->GetType() == cmTarget::INTERFACE_LIBRARY) + { + return false; + } + return this->GetCompatibleInterfaces(config).PropsNumberMin.count(p) > 0; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty( + const std::string &p, const std::string& config) const +{ + if (this->Target->GetType() == cmTarget::OBJECT_LIBRARY + || this->Target->GetType() == cmTarget::INTERFACE_LIBRARY) + { + return false; + } + return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0; +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 3e43711..3b32bf5 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -82,6 +82,15 @@ public: bool GetFeatureAsBool(const std::string& feature, const std::string& config) const; + bool IsLinkInterfaceDependentBoolProperty(const std::string &p, + const std::string& config) const; + bool IsLinkInterfaceDependentStringProperty(const std::string &p, + const std::string& config) const; + bool IsLinkInterfaceDependentNumberMinProperty(const std::string &p, + const std::string& config) const; + bool IsLinkInterfaceDependentNumberMaxProperty(const std::string &p, + const std::string& config) const; + /** Get the full path to the target according to the settings in its makefile and the configuration type. */ std::string GetFullPath(const std::string& config="", bool implib = false, @@ -187,6 +196,23 @@ private: mutable bool SourceFileFlagsConstructed; mutable std::map SourceFlagsMap; + struct CompatibleInterfacesBase + { + std::set PropsBool; + std::set PropsString; + std::set PropsNumberMax; + std::set PropsNumberMin; + }; + CompatibleInterfacesBase const& + GetCompatibleInterfaces(std::string const& config) const; + + struct CompatibleInterfaces: public CompatibleInterfacesBase + { + CompatibleInterfaces(): Done(false) {} + bool Done; + }; + mutable std::map CompatibleInterfacesMap; + cmGeneratorTarget(cmGeneratorTarget const&); void operator=(cmGeneratorTarget const&); }; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 3074f9b..9c7e46a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -170,13 +170,6 @@ public: }; std::map LinkImplClosureMap; - struct CompatibleInterfaces: public cmTarget::CompatibleInterfaces - { - CompatibleInterfaces(): Done(false) {} - bool Done; - }; - std::map CompatibleInterfacesMap; - typedef std::map > SourceFilesMapType; SourceFilesMapType SourceFilesMap; @@ -4991,54 +4984,6 @@ const char * cmTarget::GetLinkInterfaceDependentNumberMaxProperty( } //---------------------------------------------------------------------------- -bool cmTarget::IsLinkInterfaceDependentBoolProperty(const std::string &p, - const std::string& config) const -{ - if (this->TargetTypeValue == OBJECT_LIBRARY - || this->TargetTypeValue == INTERFACE_LIBRARY) - { - return false; - } - return this->GetCompatibleInterfaces(config).PropsBool.count(p) > 0; -} - -//---------------------------------------------------------------------------- -bool cmTarget::IsLinkInterfaceDependentStringProperty(const std::string &p, - const std::string& config) const -{ - if (this->TargetTypeValue == OBJECT_LIBRARY - || this->TargetTypeValue == INTERFACE_LIBRARY) - { - return false; - } - return this->GetCompatibleInterfaces(config).PropsString.count(p) > 0; -} - -//---------------------------------------------------------------------------- -bool cmTarget::IsLinkInterfaceDependentNumberMinProperty(const std::string &p, - const std::string& config) const -{ - if (this->TargetTypeValue == OBJECT_LIBRARY - || this->TargetTypeValue == INTERFACE_LIBRARY) - { - return false; - } - return this->GetCompatibleInterfaces(config).PropsNumberMin.count(p) > 0; -} - -//---------------------------------------------------------------------------- -bool cmTarget::IsLinkInterfaceDependentNumberMaxProperty(const std::string &p, - const std::string& config) const -{ - if (this->TargetTypeValue == OBJECT_LIBRARY - || this->TargetTypeValue == INTERFACE_LIBRARY) - { - return false; - } - return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0; -} - -//---------------------------------------------------------------------------- void cmTarget::GetObjectLibrariesCMP0026(std::vector& objlibs) const { @@ -5725,39 +5670,6 @@ cmTarget::GetLinkImplementationClosure(const std::string& config) const } //---------------------------------------------------------------------------- -cmTarget::CompatibleInterfaces const& -cmTarget::GetCompatibleInterfaces(std::string const& config) const -{ - cmTargetInternals::CompatibleInterfaces& compat = - this->Internal->CompatibleInterfacesMap[config]; - if(!compat.Done) - { - compat.Done = true; - compat.PropsBool.insert("POSITION_INDEPENDENT_CODE"); - compat.PropsString.insert("AUTOUIC_OPTIONS"); - std::vector const& deps = - this->GetLinkImplementationClosure(config); - for(std::vector::const_iterator li = deps.begin(); - li != deps.end(); ++li) - { -#define CM_READ_COMPATIBLE_INTERFACE(X, x) \ - if(const char* prop = (*li)->GetProperty("COMPATIBLE_INTERFACE_" #X)) \ - { \ - std::vector props; \ - cmSystemTools::ExpandListArgument(prop, props); \ - compat.Props##x.insert(props.begin(), props.end()); \ - } - CM_READ_COMPATIBLE_INTERFACE(BOOL, Bool) - CM_READ_COMPATIBLE_INTERFACE(STRING, String) - CM_READ_COMPATIBLE_INTERFACE(NUMBER_MIN, NumberMin) - CM_READ_COMPATIBLE_INTERFACE(NUMBER_MAX, NumberMax) -#undef CM_READ_COMPATIBLE_INTERFACE - } - } - return compat; -} - -//---------------------------------------------------------------------------- void cmTargetInternals::ComputeLinkInterfaceLibraries( cmTarget const* thisTarget, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index d5374a6..df8cdc1 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -305,16 +305,6 @@ public: std::vector const& GetLinkImplementationClosure(const std::string& config) const; - struct CompatibleInterfaces - { - std::set PropsBool; - std::set PropsString; - std::set PropsNumberMax; - std::set PropsNumberMin; - }; - CompatibleInterfaces const& - GetCompatibleInterfaces(std::string const& config) const; - /** The link implementation specifies the direct library dependencies needed by the object files of the target. */ struct LinkImplementationLibraries @@ -575,15 +565,6 @@ public: const std::string& config) const; bool IsNullImpliedByLinkLibraries(const std::string &p) const; - bool IsLinkInterfaceDependentBoolProperty(const std::string &p, - const std::string& config) const; - bool IsLinkInterfaceDependentStringProperty(const std::string &p, - const std::string& config) const; - bool IsLinkInterfaceDependentNumberMinProperty(const std::string &p, - const std::string& config) const; - bool IsLinkInterfaceDependentNumberMaxProperty(const std::string &p, - const std::string& config) const; - bool GetLinkInterfaceDependentBoolProperty(const std::string &p, const std::string& config) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e9ac5066f92e4418c176d5563b22d7d469dfe93c commit e9ac5066f92e4418c176d5563b22d7d469dfe93c Author: Stephen Kelly AuthorDate: Mon Dec 9 18:05:25 2013 +0100 Commit: Stephen Kelly CommitDate: Sat Aug 1 08:28:23 2015 +0200 cmGeneratorTarget: Move GetAutoUicOptions from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index e17df9e..95f6aaa 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -743,6 +743,32 @@ cmGeneratorTarget::UseObjectLibraries(std::vector& objs, } //---------------------------------------------------------------------------- +void cmGeneratorTarget::GetAutoUicOptions(std::vector &result, + const std::string& config) const +{ + const char *prop + = this->Target-> + GetLinkInterfaceDependentStringProperty("AUTOUIC_OPTIONS", + config); + if (!prop) + { + return; + } + cmGeneratorExpression ge; + + cmGeneratorExpressionDAGChecker dagChecker( + this->GetName(), + "AUTOUIC_OPTIONS", 0, 0); + cmSystemTools::ExpandListArgument(ge.Parse(prop) + ->Evaluate(this->Makefile, + config, + false, + this->Target, + &dagChecker), + result); +} + +//---------------------------------------------------------------------------- class cmTargetTraceDependencies { public: diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 8e5c2ab..3e43711 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -156,6 +156,9 @@ public: SourceFileType Type; const char* MacFolder; // location inside Mac content folders }; + void GetAutoUicOptions(std::vector &result, + const std::string& config) const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; @@ -176,7 +179,6 @@ private: struct SourceEntry { std::vector Depends; }; typedef std::map SourceEntriesType; SourceEntriesType SourceEntries; - mutable std::map Objects; std::set ExplicitObjectName; mutable std::map > SystemIncludesCache; diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 1322dea..a72b176 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -878,8 +878,11 @@ void cmQtAutoGenerators::MergeUicOptions(std::vector &opts, static void GetUicOpts(cmTarget const* target, const std::string& config, std::string &optString) { + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); std::vector opts; - target->GetAutoUicOptions(opts, config); + gtgt->GetAutoUicOptions(opts, config); optString = cmJoin(opts, ";"); } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 54f9cf0..3074f9b 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2236,31 +2236,6 @@ static void processCompileOptions(cmTarget const* tgt, } //---------------------------------------------------------------------------- -void cmTarget::GetAutoUicOptions(std::vector &result, - const std::string& config) const -{ - const char *prop - = this->GetLinkInterfaceDependentStringProperty("AUTOUIC_OPTIONS", - config); - if (!prop) - { - return; - } - cmGeneratorExpression ge; - - cmGeneratorExpressionDAGChecker dagChecker( - this->GetName(), - "AUTOUIC_OPTIONS", 0, 0); - cmSystemTools::ExpandListArgument(ge.Parse(prop) - ->Evaluate(this->Makefile, - config, - false, - this, - &dagChecker), - result); -} - -//---------------------------------------------------------------------------- void cmTarget::GetCompileOptions(std::vector &result, const std::string& config, const std::string& language) const diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 389f9cd..d5374a6 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -571,8 +571,6 @@ public: void GetCompileOptions(std::vector &result, const std::string& config, const std::string& language) const; - void GetAutoUicOptions(std::vector &result, - const std::string& config) const; void GetCompileFeatures(std::vector &features, const std::string& config) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=427aa20814b97726b52efaef54905d0ed1aa4e2c commit 427aa20814b97726b52efaef54905d0ed1aa4e2c Author: Stephen Kelly AuthorDate: Tue Oct 9 00:37:37 2012 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 08:28:23 2015 +0200 cmGeneratorTarget: Move GetSOName from cmTarget.. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index e63b44f..5aaa266 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -756,15 +756,16 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, return; } + cmGeneratorTarget *gtgt = tgt->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(tgt); + // Get a full path to the dependent shared library. // Add it to the runtime path computation so that the target being // linked will be able to find it. std::string lib; if(tgt) { - cmGeneratorTarget *gtgt = tgt->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(tgt); lib = gtgt->GetFullPath(this->Config, this->UseImportLibrary); this->AddLibraryRuntimeInfo(lib, tgt); } @@ -792,7 +793,7 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, { if(tgt) { - std::string soName = tgt->GetSOName(this->Config); + std::string soName = gtgt->GetSOName(this->Config); const char* soname = soName.empty()? 0 : soName.c_str(); order->AddRuntimeLibrary(lib, soname); } @@ -1804,7 +1805,10 @@ cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath, // Try to get the soname of the library. Only files with this name // could possibly conflict. - std::string soName = target->GetSOName(this->Config); + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); + std::string soName = gtgt->GetSOName(this->Config); const char* soname = soName.empty()? 0 : soName.c_str(); // Include this library in the runtime path ordering. diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index a33cd59..3aa2b65 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -895,7 +895,7 @@ cmExportFileGenerator value = this->InstallNameDir(target->Target, config); } prop = "IMPORTED_SONAME"; - value += target->Target->GetSOName(config); + value += target->GetSOName(config); } else { diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index f3527ff..c0485db 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1584,7 +1584,7 @@ struct TargetFilesystemArtifactResultCreator } std::string result = target->Target->GetDirectory(context->Config); result += "/"; - result += target->Target->GetSOName(context->Config); + result += target->GetSOName(context->Config); return result; } }; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index bd57b3d..e17df9e 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -650,6 +650,49 @@ void cmGeneratorTarget::GetSourceFiles(std::vector &files, } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetSOName(const std::string& config) const +{ + if(this->Target->IsImported()) + { + // Lookup the imported soname. + if(cmTarget::ImportInfo const* info = this->Target->GetImportInfo(config)) + { + if(info->NoSOName) + { + // The imported library has no builtin soname so the name + // searched at runtime will be just the filename. + return cmSystemTools::GetFilenameName(info->Location); + } + else + { + // Use the soname given if any. + if(info->SOName.find("@rpath/") == 0) + { + return info->SOName.substr(6); + } + return info->SOName; + } + } + else + { + return ""; + } + } + else + { + // Compute the soname that will be built. + std::string name; + std::string soName; + std::string realName; + std::string impName; + std::string pdbName; + this->Target->GetLibraryNames(name, soName, realName, + impName, pdbName, config); + return soName; + } +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetModuleDefinitionFile(const std::string& config) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index a584c71..8e5c2ab 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -90,6 +90,9 @@ public: bool realname) const; std::string NormalGetRealName(const std::string& config) const; + /** Get the soname of the target. Allowed only for a shared library. */ + std::string GetSOName(const std::string& config) const; + cmTarget* Target; cmMakefile* Makefile; cmLocalGenerator* LocalGenerator; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 7dea107..8cb59f8 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2345,7 +2345,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, install_name += install_name_dir; install_name += "/"; } - install_name += target.GetSOName(configName); + install_name += gtgt->GetSOName(configName); if((realName != soName) || install_name_dir.empty()) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index cf33791..54f9cf0 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -69,21 +69,6 @@ struct cmTarget::OutputInfo }; //---------------------------------------------------------------------------- -struct cmTarget::ImportInfo -{ - ImportInfo(): NoSOName(false), Multiplicity(0) {} - bool NoSOName; - int Multiplicity; - std::string Location; - std::string SOName; - std::string ImportLibrary; - std::string Languages; - std::string Libraries; - std::string LibrariesProp; - std::string SharedDeps; -}; - -//---------------------------------------------------------------------------- struct cmTarget::CompileInfo { std::string CompilePdbDir; @@ -3602,48 +3587,6 @@ bool cmTarget::HasSOName(const std::string& config) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetSOName(const std::string& config) const -{ - if(this->IsImported()) - { - // Lookup the imported soname. - if(cmTarget::ImportInfo const* info = this->GetImportInfo(config)) - { - if(info->NoSOName) - { - // The imported library has no builtin soname so the name - // searched at runtime will be just the filename. - return cmSystemTools::GetFilenameName(info->Location); - } - else - { - // Use the soname given if any. - if(info->SOName.find("@rpath/") == 0) - { - return info->SOName.substr(6); - } - return info->SOName; - } - } - else - { - return ""; - } - } - else - { - // Compute the soname that will be built. - std::string name; - std::string soName; - std::string realName; - std::string impName; - std::string pdbName; - this->GetLibraryNames(name, soName, realName, impName, pdbName, config); - return soName; - } -} - -//---------------------------------------------------------------------------- bool cmTarget::HasMacOSXRpathInstallNameDir(const std::string& config) const { bool install_name_is_rpath = false; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index f567d50..389f9cd 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -411,9 +411,6 @@ public: /** Whether this library has soname enabled and platform supports it. */ bool HasSOName(const std::string& config) const; - /** Get the soname of the target. Allowed only for a shared library. */ - std::string GetSOName(const std::string& config) const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; @@ -768,7 +765,20 @@ private: std::string& out) const; // Cache import information from properties for each configuration. - struct ImportInfo; + struct ImportInfo + { + ImportInfo(): NoSOName(false), Multiplicity(0) {} + bool NoSOName; + int Multiplicity; + std::string Location; + std::string SOName; + std::string ImportLibrary; + std::string Languages; + std::string Libraries; + std::string LibrariesProp; + std::string SharedDeps; + }; + ImportInfo const* GetImportInfo(const std::string& config) const; void ComputeImportInfo(std::string const& desired_config, ImportInfo& info) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=22c1a69a9c472bd2530ddb2c0a5dae38465f2271 commit 22c1a69a9c472bd2530ddb2c0a5dae38465f2271 Author: Stephen Kelly AuthorDate: Sat Aug 1 08:08:17 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 08:28:20 2015 +0200 cmExportInstallFileGenerator: Simplify local generator access. diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 1d75f43..c88b7b2 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -358,7 +358,7 @@ cmExportInstallFileGenerator if(!properties.empty()) { // Get the rest of the target details. - cmGeneratorTarget *gtgt = te->Target->GetMakefile()->GetLocalGenerator() + cmGeneratorTarget *gtgt = te->Target->GetMakefile() ->GetGlobalGenerator()->GetGeneratorTarget(te->Target); this->SetImportDetailProperties(config, suffix, gtgt, properties, missingTargets); ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From steveire at gmail.com Sat Aug 1 03:44:45 2015 From: steveire at gmail.com (Stephen Kelly) Date: Sat, 1 Aug 2015 03:44:45 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1709-gb3c1ffa Message-ID: <20150801074445.74883B0348@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via b3c1ffa8c5b38866434bb5db5e0c788684db83d5 (commit) via a45307477f84bfc58127f346c1f26bd917d6a4ea (commit) via 2f3c0dbac88f7f7a4cce62fd6ef64b048dfe10f2 (commit) via bef7a0f785b8192e11d26ae761d0ae7a2856d8a6 (commit) via 59a9f3c275a5f5f763d392802da3ff2ae4d1b8f5 (commit) from 425a983649ec4f59b33a22b6f94cb91232ac872a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b3c1ffa8c5b38866434bb5db5e0c788684db83d5 commit b3c1ffa8c5b38866434bb5db5e0c788684db83d5 Merge: 425a983 a453074 Author: Stephen Kelly AuthorDate: Sat Aug 1 03:44:44 2015 -0400 Commit: CMake Topic Stage CommitDate: Sat Aug 1 03:44:44 2015 -0400 Merge topic 'use-generator-target' into next a4530747 fixup! cmGeneratorTarget: Move GetLinkerLanguage from cmTarget. 2f3c0dba fixup! cmGeneratorTarget: Move GetFullName from cmTarget. bef7a0f7 fixup! cmGeneratorTarget: Move GetLinkerLanguage from cmTarget. 59a9f3c2 fixup! cmGeneratorTarget: Move GetFullName from cmTarget. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a45307477f84bfc58127f346c1f26bd917d6a4ea commit a45307477f84bfc58127f346c1f26bd917d6a4ea Author: Stephen Kelly AuthorDate: Sat Aug 1 09:38:06 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 09:38:06 2015 +0200 fixup! cmGeneratorTarget: Move GetLinkerLanguage from cmTarget. diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 390198d..80b8591 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1891,40 +1891,10 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( this->GeneratorTarget->GetLinkerLanguage(configName.c_str()); if(linkLanguage.empty()) { - const std::string& linkLanguage = - this->GeneratorTarget->GetLinkerLanguage(configName.c_str()); - if(linkLanguage.empty()) - { - cmSystemTools::Error - ("CMake can not determine linker language for target: ", - this->Name.c_str()); - return false; - } - if(linkLanguage == "C" || linkLanguage == "CXX" - || linkLanguage == "Fortran") - { - std::string baseFlagVar = "CMAKE_"; - baseFlagVar += linkLanguage; - baseFlagVar += "_FLAGS"; - flags = this-> - Target->GetMakefile()->GetRequiredDefinition(baseFlagVar.c_str()); - std::string flagVar = baseFlagVar + std::string("_") + - cmSystemTools::UpperCase(configName); - flags += " "; - flags += this-> - Target->GetMakefile()->GetRequiredDefinition(flagVar.c_str()); - } - // set the correct language - if(linkLanguage == "C") - { - flags += " /TC "; - } - if(linkLanguage == "CXX") - { - flags += " /TP "; - } - this->LocalGenerator->AddCompileOptions(flags, this->Target, - linkLanguage, configName.c_str()); + cmSystemTools::Error + ("CMake can not determine linker language for target: ", + this->Name.c_str()); + return false; } if(linkLanguage == "C" || linkLanguage == "CXX" || linkLanguage == "Fortran") http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2f3c0dbac88f7f7a4cce62fd6ef64b048dfe10f2 commit 2f3c0dbac88f7f7a4cce62fd6ef64b048dfe10f2 Author: Stephen Kelly AuthorDate: Sat Aug 1 09:35:55 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 09:35:55 2015 +0200 fixup! cmGeneratorTarget: Move GetFullName from cmTarget. diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index a402c64..e1fa7d4 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1112,8 +1112,8 @@ void cmLocalVisualStudio6Generator // Compute the proper name to use to link this library. std::string lib; std::string libDebug; - cmGeneratorTarget* tgt = - this->GlobalGenerator->FindGeneratorTarget(j->first.c_str()); + cmGeneratorTarget* tgt = this->GlobalGenerator->GetGeneratorTarget( + this->GlobalGenerator->FindTarget(j->first.c_str())); if(tgt) { lib = cmSystemTools::GetFilenameWithoutExtension http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bef7a0f785b8192e11d26ae761d0ae7a2856d8a6 commit bef7a0f785b8192e11d26ae761d0ae7a2856d8a6 Author: Stephen Kelly AuthorDate: Sat Aug 1 09:28:50 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 09:28:50 2015 +0200 fixup! cmGeneratorTarget: Move GetLinkerLanguage from cmTarget. diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index 2f9265a..1e57c33 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -128,7 +128,8 @@ void cmGhsMultiTargetGenerator::Generate() { config = "RELEASE"; } - const std::string language(this->Target->GetLinkerLanguage(config)); + const std::string language( + this->GeneratorTarget->GetLinkerLanguage(config)); config = cmSystemTools::UpperCase(config); this->DynamicDownload = this->DetermineIfDynamicDownload(config, language); if (this->DynamicDownload) diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 8a780b1..390198d 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1888,7 +1888,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( std::string flags; const std::string& linkLanguage = - this->Target->GetLinkerLanguage(configName.c_str()); + this->GeneratorTarget->GetLinkerLanguage(configName.c_str()); if(linkLanguage.empty()) { const std::string& linkLanguage = http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=59a9f3c275a5f5f763d392802da3ff2ae4d1b8f5 commit 59a9f3c275a5f5f763d392802da3ff2ae4d1b8f5 Author: Stephen Kelly AuthorDate: Sat Aug 1 09:26:44 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 09:26:44 2015 +0200 fixup! cmGeneratorTarget: Move GetFullName from cmTarget. diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 0fb6bc0..48b610b 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -805,7 +805,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, if (this->FortranProject) { // Intel Fortran >= 15.0 uses TargetName property. - std::string targetNameFull = target.GetFullName(configName); + std::string targetNameFull = gt->GetFullName(configName); std::string targetName = cmSystemTools::GetFilenameWithoutLastExtension(targetNameFull); std::string targetExt = ----------------------------------------------------------------------- Summary of changes: Source/cmGhsMultiTargetGenerator.cxx | 3 ++- Source/cmLocalVisualStudio6Generator.cxx | 4 +-- Source/cmLocalVisualStudio7Generator.cxx | 2 +- Source/cmVisualStudio10TargetGenerator.cxx | 40 ++++------------------------ 4 files changed, 10 insertions(+), 39 deletions(-) hooks/post-receive -- CMake From steveire at gmail.com Sat Aug 1 03:45:10 2015 From: steveire at gmail.com (Stephen Kelly) Date: Sat, 1 Aug 2015 03:45:10 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1727-g348c91d Message-ID: <20150801074510.6BD92B0399@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 348c91d7cced1089b349cf91eee7afaf967e45e6 (commit) via 478c0780ab0e6e922246e30a23a158a1be6ad3ac (commit) via 9519272851b2ec9cd0602e1d7414ccfc1ec30d3b (commit) via fb4089c62bc756a56f34986dfe106ca19a965d17 (commit) via 30d5da6572d3629ac0759dc03fe068301e92f0df (commit) via 19caafbc0c0a234ac110f229f7ecaa1d03e0fc23 (commit) via a2c60a99a2df41305c5c09724d17bf599cf8bd14 (commit) via 22b2c5560a6500c163fddc0e74197145a6cdf117 (commit) via a158d931d05fe3cea541494c01185a1c2cb7cc20 (commit) via 0cc640238b70edd09234a4eae5258651a6ae585a (commit) via 136ccd27b69beccd6d893fbaeb909f2915d41c48 (commit) via 3b36794bf535ae16c72cc3b363cc954ff680fed9 (commit) via 31b43bf4663f8612fa4e7ed01633deaa018961da (commit) via 9350e396795b07338169fda51189498b487fc324 (commit) via 627d9c0530e161807959550ddf3dae7cc1f605dd (commit) via d1f71f9c85a2cf86945baa1747de5c2756637070 (commit) via f39ec367a96d93f2a0117c7b61df30a54fbc3fc2 (commit) via 2a843615a947e0b8455b7da5fdd2ed7a609fb8f2 (commit) from b3c1ffa8c5b38866434bb5db5e0c788684db83d5 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=348c91d7cced1089b349cf91eee7afaf967e45e6 commit 348c91d7cced1089b349cf91eee7afaf967e45e6 Merge: b3c1ffa 478c078 Author: Stephen Kelly AuthorDate: Sat Aug 1 03:45:07 2015 -0400 Commit: CMake Topic Stage CommitDate: Sat Aug 1 03:45:07 2015 -0400 Merge topic 'use-generator-target' into next 478c0780 cmMakefile: Remove unused method. 95192728 cmGlobalGenerator: Base exclusion computation on cmGeneratorTarget. fb4089c6 cmGeneratorTarget: Move CompileInfoMap from cmTarget. 30d5da65 cmGeneratorTarget: Move GetCompilePDBDirectory from cmTarget. 19caafbc cmGeneratorTarget: Move GetOutputName from cmTarget. a2c60a99 cmComputeLinkDepends: Port to cmGeneratorTarget. 22b2c556 cmComputeLinkInformation: Port to cmGeneratorTarget. a158d931 cmGeneratorTarget: Move IsBundleOnApple from cmTarget. 0cc64023 cmMakefileTargetGenerator: Add accessor for GeneratorTarget. 136ccd27 cmGeneratorTarget: Move GetLinkClosure from cmTarget. 3b36794b cmGeneratorTarget: Move GetLinkerLanguage from cmTarget. 31b43bf4 cmGeneratorTarget: Move GetFrameworkDirectory from cmTarget. 9350e396 cmGeneratorTarget: Move GetFullNameInternal from cmTarget. 627d9c05 cmGeneratorTarget: Move GetFullName from cmTarget. d1f71f9c cmGeneratorTarget: Move GetAppBundleDirectory from cmTarget. f39ec367 cmGeneratorTarget: Move GetInstallNameDir* from cmTarget. ... http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=478c0780ab0e6e922246e30a23a158a1be6ad3ac commit 478c0780ab0e6e922246e30a23a158a1be6ad3ac Author: Stephen Kelly AuthorDate: Sat Jun 6 14:27:52 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 09:44:07 2015 +0200 cmMakefile: Remove unused method. diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 1e5c301..00d4005 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -113,10 +113,6 @@ public: bool GetIsSourceFileTryCompile() const; - ///! Get the current makefile generator. - cmLocalGenerator* GetLocalGenerator() const - { return this->LocalGenerator;} - /** * Help enforce global target name uniqueness. */ http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9519272851b2ec9cd0602e1d7414ccfc1ec30d3b commit 9519272851b2ec9cd0602e1d7414ccfc1ec30d3b Author: Stephen Kelly AuthorDate: Sat Jun 6 14:09:35 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 09:44:07 2015 +0200 cmGlobalGenerator: Base exclusion computation on cmGeneratorTarget. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 1d6608b..b14949a 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2022,10 +2022,10 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, } bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, - cmTarget const& target) const + cmGeneratorTarget* target) const { - if(target.GetType() == cmTarget::INTERFACE_LIBRARY - || target.GetPropertyAsBool("EXCLUDE_FROM_ALL")) + if(target->GetType() == cmTarget::INTERFACE_LIBRARY + || target->Target->GetPropertyAsBool("EXCLUDE_FROM_ALL")) { // This target is excluded from its directory. return true; @@ -2034,7 +2034,7 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, { // This target is included in its directory. Check whether the // directory is excluded. - return this->IsExcluded(root, target.GetMakefile()->GetLocalGenerator()); + return this->IsExcluded(root, target->GetLocalGenerator()); } } @@ -2095,15 +2095,16 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap() { cmTarget const& target = t->second; + cmGeneratorTarget* gt = this->GetGeneratorTarget(&target); + // Consider the directory containing the target and all its // parents until something excludes the target. - for(cmLocalGenerator* clg = lg; clg && !this->IsExcluded(clg, target); + for(cmLocalGenerator* clg = lg; clg && !this->IsExcluded(clg, gt); clg = clg->GetParent()) { // This local generator includes the target. std::set& targetSet = this->LocalGeneratorToTargetMap[clg]; - cmGeneratorTarget* gt = this->GetGeneratorTarget(&target); targetSet.insert(gt); // Add dependencies of the included target. An excluded diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 9492372..3be76b6 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -398,7 +398,7 @@ protected: void FillProjectMap(); void CheckLocalGenerators(); bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen) const; - bool IsExcluded(cmLocalGenerator* root, cmTarget const& target) const; + bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) const; void FillLocalGeneratorToTargetMap(); void CreateDefaultGlobalTargets(cmTargets* targets); cmTarget CreateGlobalTarget(const std::string& name, const char* message, diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 2a749c1..47822b4 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -289,7 +289,7 @@ public: const std::vector& GetLocalGenerators() const { return LocalGenerators; } - bool IsExcluded(cmLocalGenerator* root, cmTarget& target) { + bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) { return cmGlobalGenerator::IsExcluded(root, target); } int GetRuleCmdLength(const std::string& name) { diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 69747a4..76d059ee 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -821,7 +821,7 @@ cmGlobalUnixMakefileGenerator3 localName, depends, commands, true); // add the all/all dependency - if(!this->IsExcluded(this->LocalGenerators[0], *gtarget->Target)) + if(!this->IsExcluded(this->LocalGenerators[0], gtarget)) { depends.clear(); depends.push_back(localName); @@ -889,7 +889,7 @@ cmGlobalUnixMakefileGenerator3 "Pre-install relink rule for target.", localName, depends, commands, true); - if(!this->IsExcluded(this->LocalGenerators[0], *gtarget->Target)) + if(!this->IsExcluded(this->LocalGenerators[0], gtarget)) { depends.clear(); depends.push_back(localName); diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 2f9d79a..c3131c3 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -111,17 +111,18 @@ bool cmGlobalVisualStudioGenerator::Compute() for(std::vector::iterator i = gen.begin(); i != gen.end(); ++i) { - cmTargets& targets = (*i)->GetMakefile()->GetTargets(); - for(cmTargets::iterator t = targets.begin(); + cmGeneratorTargetsType targets = + lg->GetMakefile()->GetGeneratorTargets(); + for(cmGeneratorTargetsType::iterator t = targets.begin(); t != targets.end(); ++t) { - if (t->second.GetType() == cmTarget::GLOBAL_TARGET) + if (t->second->GetType() == cmTarget::GLOBAL_TARGET) { continue; } if(!this->IsExcluded(gen[0], t->second)) { - allBuild->AddUtility(t->second.GetName()); + allBuild->AddUtility(t->second->GetName()); } } } diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 9889bd4..1822c97 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -90,7 +90,7 @@ void cmLocalNinjaGenerator::Generate() // Add the target to "all" if required. if (!this->GetGlobalNinjaGenerator()->IsExcluded( this->GetGlobalNinjaGenerator()->GetLocalGenerators()[0], - *t->second->Target)) + t->second)) this->GetGlobalNinjaGenerator()->AddDependencyToAll(t->second->Target); delete tg; } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fb4089c62bc756a56f34986dfe106ca19a965d17 commit fb4089c62bc756a56f34986dfe106ca19a965d17 Author: Stephen Kelly AuthorDate: Mon Oct 20 21:02:16 2014 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 09:44:07 2015 +0200 cmGeneratorTarget: Move CompileInfoMap from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c6f248c..c831704 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1356,6 +1356,46 @@ cmGeneratorTarget::GetMacContentDirectory(const std::string& config, return fpath; } + +//---------------------------------------------------------------------------- +cmGeneratorTarget::CompileInfo const* cmGeneratorTarget::GetCompileInfo( + const std::string& config) const +{ + // There is no compile information for imported targets. + if(this->IsImported()) + { + return 0; + } + + if(this->GetType() > cmTarget::OBJECT_LIBRARY) + { + std::string msg = "cmTarget::GetCompileInfo called for "; + msg += this->GetName(); + msg += " which has type "; + msg += cmTarget::GetTargetTypeName(this->Target->GetType()); + this->Makefile->IssueMessage(cmake::INTERNAL_ERROR, msg); + return 0; + } + + // Lookup/compute/cache the compile information for this configuration. + std::string config_upper; + if(!config.empty()) + { + config_upper = cmSystemTools::UpperCase(config); + } + CompileInfoMapType::const_iterator i = + this->CompileInfoMap.find(config_upper); + if(i == this->CompileInfoMap.end()) + { + CompileInfo info; + this->Target + ->ComputePDBOutputDir("COMPILE_PDB", config, info.CompilePdbDir); + CompileInfoMapType::value_type entry(config_upper, info); + i = this->CompileInfoMap.insert(entry).first; + } + return &i->second; +} + //---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetModuleDefinitionFile(const std::string& config) const @@ -1827,7 +1867,7 @@ void cmGeneratorTarget::TraceDependencies() std::string cmGeneratorTarget::GetCompilePDBDirectory(const std::string& config) const { - if(cmTarget::CompileInfo const* info = this->Target->GetCompileInfo(config)) + if(CompileInfo const* info = this->GetCompileInfo(config)) { return info->CompilePdbDir; } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index c291919..1d7a411 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -230,6 +230,16 @@ public: /** Whether this library has soname enabled and platform supports it. */ bool HasSOName(const std::string& config) const; + struct CompileInfo + { + std::string CompilePdbDir; + }; + + CompileInfo const* GetCompileInfo(const std::string& config) const; + + typedef std::map CompileInfoMapType; + mutable CompileInfoMapType CompileInfoMap; + /** Get the name of the compiler pdb file for the target. */ std::string GetCompilePDBName(const std::string& config="") const; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 9308113..1f8f07a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -126,9 +126,6 @@ public: typedef std::map ImportInfoMapType; ImportInfoMapType ImportInfoMap; - typedef std::map CompileInfoMapType; - CompileInfoMapType CompileInfoMap; - // Cache link implementation computation from each configuration. struct OptionalLinkImplementation: public cmTarget::LinkImplementation { @@ -2598,45 +2595,6 @@ cmTarget::OutputInfo const* cmTarget::GetOutputInfo( } //---------------------------------------------------------------------------- -cmTarget::CompileInfo const* cmTarget::GetCompileInfo( - const std::string& config) const -{ - // There is no compile information for imported targets. - if(this->IsImported()) - { - return 0; - } - - if(this->GetType() > cmTarget::OBJECT_LIBRARY) - { - std::string msg = "cmTarget::GetCompileInfo called for "; - msg += this->GetName(); - msg += " which has type "; - msg += cmTarget::GetTargetTypeName(this->GetType()); - this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg); - return 0; - } - - // Lookup/compute/cache the compile information for this configuration. - std::string config_upper; - if(!config.empty()) - { - config_upper = cmSystemTools::UpperCase(config); - } - typedef cmTargetInternals::CompileInfoMapType CompileInfoMapType; - CompileInfoMapType::const_iterator i = - this->Internal->CompileInfoMap.find(config_upper); - if(i == this->Internal->CompileInfoMap.end()) - { - CompileInfo info; - this->ComputePDBOutputDir("COMPILE_PDB", config, info.CompilePdbDir); - CompileInfoMapType::value_type entry(config_upper, info); - i = this->Internal->CompileInfoMap.insert(entry).first; - } - return &i->second; -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetDirectory(const std::string& config, bool implib) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 8689838..e3fbdfd 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -626,13 +626,6 @@ private: void ComputeImportInfo(std::string const& desired_config, ImportInfo& info) const; - // Cache target compile paths for each configuration. - struct CompileInfo - { - std::string CompilePdbDir; - }; - - CompileInfo const* GetCompileInfo(const std::string& config) const; LinkInterface const* GetImportLinkInterface(const std::string& config, cmTarget const* head, http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=30d5da6572d3629ac0759dc03fe068301e92f0df commit 30d5da6572d3629ac0759dc03fe068301e92f0df Author: Stephen Kelly AuthorDate: Mon Oct 20 20:52:54 2014 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 09:44:07 2015 +0200 cmGeneratorTarget: Move GetCompilePDBDirectory from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index aac941e..c6f248c 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -743,7 +743,7 @@ cmGeneratorTarget::GetCompilePDBName(const std::string& config) const std::string cmGeneratorTarget::GetCompilePDBPath(const std::string& config) const { - std::string dir = this->Target->GetCompilePDBDirectory(config); + std::string dir = this->GetCompilePDBDirectory(config); std::string name = this->GetCompilePDBName(config); if(dir.empty() && !name.empty()) { @@ -1824,6 +1824,16 @@ void cmGeneratorTarget::TraceDependencies() tracer.Trace(); } +std::string +cmGeneratorTarget::GetCompilePDBDirectory(const std::string& config) const +{ + if(cmTarget::CompileInfo const* info = this->Target->GetCompileInfo(config)) + { + return info->CompilePdbDir; + } + return ""; +} + //---------------------------------------------------------------------------- void cmGeneratorTarget::GetAppleArchs(const std::string& config, std::vector& archVec) const diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 31b3178..c291919 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -214,6 +214,12 @@ public: */ void TraceDependencies(); + /** Get the directory in which to place the target compiler .pdb file. + If the configuration name is given then the generator will add its + subdirectory for that configuration. Otherwise just the canonical + compiler pdb output directory is given. */ + std::string GetCompilePDBDirectory(const std::string& config = "") const; + /** Get sources that must be built before the given source. */ std::vector const* GetSourceDepends(cmSourceFile const* sf) const; diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index afe145a..ccb0974 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -130,7 +130,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) } std::string compilePdbOutputPath = - this->Target->GetCompilePDBDirectory(this->ConfigName); + this->GeneratorTarget->GetCompilePDBDirectory(this->ConfigName); cmSystemTools::MakeDirectory(compilePdbOutputPath.c_str()); std::string pdbOutputPath = this->Target->GetPDBDirectory(this->ConfigName); diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index bb0f9dd..2f995e8 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -311,7 +311,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules } std::string compilePdbOutputPath = - this->Target->GetCompilePDBDirectory(this->ConfigName); + this->GeneratorTarget->GetCompilePDBDirectory(this->ConfigName); cmSystemTools::MakeDirectory(compilePdbOutputPath.c_str()); std::string pdbOutputPath = this->Target->GetPDBDirectory(this->ConfigName); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 8b64bc4..9308113 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -69,12 +69,6 @@ struct cmTarget::OutputInfo }; //---------------------------------------------------------------------------- -struct cmTarget::CompileInfo -{ - std::string CompilePdbDir; -}; - -//---------------------------------------------------------------------------- class cmTargetInternals { public: @@ -2673,16 +2667,6 @@ std::string cmTarget::GetPDBDirectory(const std::string& config) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetCompilePDBDirectory(const std::string& config) const -{ - if(CompileInfo const* info = this->GetCompileInfo(config)) - { - return info->CompilePdbDir; - } - return ""; -} - -//---------------------------------------------------------------------------- const char* cmTarget::ImportedGetLocation(const std::string& config) const { static std::string location; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index a6f2465..8689838 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -334,12 +334,6 @@ public: pdb output directory is given. */ std::string GetPDBDirectory(const std::string& config) const; - /** Get the directory in which to place the target compiler .pdb file. - If the configuration name is given then the generator will add its - subdirectory for that configuration. Otherwise just the canonical - compiler pdb output directory is given. */ - std::string GetCompilePDBDirectory(const std::string& config = "") const; - const char* ImportedGetLocation(const std::string& config) const; /** Get the target major and minor version numbers interpreted from @@ -633,7 +627,11 @@ private: ImportInfo& info) const; // Cache target compile paths for each configuration. - struct CompileInfo; + struct CompileInfo + { + std::string CompilePdbDir; + }; + CompileInfo const* GetCompileInfo(const std::string& config) const; LinkInterface const* http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=19caafbc0c0a234ac110f229f7ecaa1d03e0fc23 commit 19caafbc0c0a234ac110f229f7ecaa1d03e0fc23 Author: Stephen Kelly AuthorDate: Sat Aug 1 07:04:23 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 09:44:06 2015 +0200 cmGeneratorTarget: Move GetOutputName from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 55e2922..aac941e 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -267,6 +267,54 @@ const char *cmGeneratorTarget::GetProperty(const std::string& prop) const } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetOutputName(const std::string& config, + bool implib) const +{ + std::vector props; + std::string type = this->Target->GetOutputTargetType(implib); + std::string configUpper = cmSystemTools::UpperCase(config); + if(!type.empty() && !configUpper.empty()) + { + // _OUTPUT_NAME_ + props.push_back(type + "_OUTPUT_NAME_" + configUpper); + } + if(!type.empty()) + { + // _OUTPUT_NAME + props.push_back(type + "_OUTPUT_NAME"); + } + if(!configUpper.empty()) + { + // OUTPUT_NAME_ + props.push_back("OUTPUT_NAME_" + configUpper); + // _OUTPUT_NAME + props.push_back(configUpper + "_OUTPUT_NAME"); + } + // OUTPUT_NAME + props.push_back("OUTPUT_NAME"); + + std::string outName; + for(std::vector::const_iterator i = props.begin(); + i != props.end(); ++i) + { + if (const char* outNameProp = this->Target->GetProperty(*i)) + { + outName = outNameProp; + break; + } + } + + if (outName.empty()) + { + outName = this->GetName(); + } + + cmGeneratorExpression ge; + cmsys::auto_ptr cge = ge.Parse(outName); + return cge->Evaluate(this->Makefile, config); +} + +//---------------------------------------------------------------------------- std::vector const* cmGeneratorTarget::GetSourceDepends(cmSourceFile const* sf) const { @@ -922,7 +970,7 @@ std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config, bool contentOnly) const { std::string fpath; - fpath += this->Target->GetOutputName(config, false); + fpath += this->GetOutputName(config, false); fpath += "."; const char *ext = this->Target->GetProperty("BUNDLE_EXTENSION"); if (!ext) @@ -949,7 +997,7 @@ cmGeneratorTarget::GetFrameworkDirectory(const std::string& config, bool rootDir) const { std::string fpath; - fpath += this->Target->GetOutputName(config, false); + fpath += this->GetOutputName(config, false); fpath += ".framework"; if(!rootDir) { @@ -2247,7 +2295,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, std::string fw_prefix; if(this->Target->IsFrameworkOnApple()) { - fw_prefix = this->Target->GetOutputName(config, false); + fw_prefix = this->GetOutputName(config, false); fw_prefix += ".framework/"; targetPrefix = fw_prefix.c_str(); targetSuffix = 0; @@ -2265,7 +2313,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, outPrefix = targetPrefix?targetPrefix:""; // Append the target name or property-specified name. - outBase += this->Target->GetOutputName(config, implib); + outBase += this->GetOutputName(config, implib); // Append the per-configuration postfix. outBase += configPostfix?configPostfix:""; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index d10cd1d..31b3178 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -230,6 +230,9 @@ public: /** Get the path for the MSVC /Fd option for this target. */ std::string GetCompilePDBPath(const std::string& config="") const; + // Get the target base name. + std::string GetOutputName(const std::string& config, bool implib) const; + /** * Flags for a given source file as used in this target. Typically assigned * via SET_TARGET_PROPERTIES when the property is a list of source files. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e887ef3..8b64bc4 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3663,54 +3663,6 @@ bool cmTarget::UsesDefaultOutputDir(const std::string& config, } //---------------------------------------------------------------------------- -std::string cmTarget::GetOutputName(const std::string& config, - bool implib) const -{ - std::vector props; - std::string type = this->GetOutputTargetType(implib); - std::string configUpper = cmSystemTools::UpperCase(config); - if(!type.empty() && !configUpper.empty()) - { - // _OUTPUT_NAME_ - props.push_back(type + "_OUTPUT_NAME_" + configUpper); - } - if(!type.empty()) - { - // _OUTPUT_NAME - props.push_back(type + "_OUTPUT_NAME"); - } - if(!configUpper.empty()) - { - // OUTPUT_NAME_ - props.push_back("OUTPUT_NAME_" + configUpper); - // _OUTPUT_NAME - props.push_back(configUpper + "_OUTPUT_NAME"); - } - // OUTPUT_NAME - props.push_back("OUTPUT_NAME"); - - std::string outName; - for(std::vector::const_iterator i = props.begin(); - i != props.end(); ++i) - { - if (const char* outNameProp = this->GetProperty(*i)) - { - outName = outNameProp; - break; - } - } - - if (outName.empty()) - { - outName = this->GetName(); - } - - cmGeneratorExpression ge; - cmsys::auto_ptr cge = ge.Parse(outName); - return cge->Evaluate(this->Makefile, config); -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetFrameworkVersion() const { assert(this->GetType() != INTERFACE_LIBRARY); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e53afff..a6f2465 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -552,9 +552,6 @@ private: // Returns ARCHIVE, LIBRARY, or RUNTIME based on platform and type. const char* GetOutputTargetType(bool implib) const; - // Get the target base name. - std::string GetOutputName(const std::string& config, bool implib) const; - std::string GetFullNameImported(const std::string& config, bool implib) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a2c60a99a2df41305c5c09724d17bf599cf8bd14 commit a2c60a99a2df41305c5c09724d17bf599cf8bd14 Author: Stephen Kelly AuthorDate: Thu Jul 30 00:45:34 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 09:44:06 2015 +0200 cmComputeLinkDepends: Port to cmGeneratorTarget. diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index abd9877..8ba8847 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -173,18 +173,19 @@ items that we know the linker will re-use automatically (shared libs). //---------------------------------------------------------------------------- cmComputeLinkDepends -::cmComputeLinkDepends(cmTarget const* target, const std::string& config) +::cmComputeLinkDepends(const cmGeneratorTarget* target, + const std::string& config) { // Store context information. this->Target = target; - this->Makefile = this->Target->GetMakefile(); + this->Makefile = this->Target->Target->GetMakefile(); this->GlobalGenerator = this->Makefile->GetGlobalGenerator(); this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance(); // The configuration being linked. this->HasConfig = !config.empty(); this->Config = (this->HasConfig)? config : std::string(); - this->LinkType = this->Target->ComputeLinkType(this->Config); + this->LinkType = this->Target->Target->ComputeLinkType(this->Config); // Enable debug mode if requested. this->DebugMode = this->Makefile->IsOn("CMAKE_LINK_DEPENDS_DEBUG_MODE"); @@ -363,7 +364,7 @@ void cmComputeLinkDepends::FollowLinkEntry(BFSEntry const& qe) { // Follow the target dependencies. if(cmTarget::LinkInterface const* iface = - entry.Target->GetLinkInterface(this->Config, this->Target)) + entry.Target->GetLinkInterface(this->Config, this->Target->Target)) { const bool isIface = entry.Target->GetType() == cmTarget::INTERFACE_LIBRARY; @@ -461,7 +462,7 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep) if(entry.Target) { if(cmTarget::LinkInterface const* iface = - entry.Target->GetLinkInterface(this->Config, this->Target)) + entry.Target->GetLinkInterface(this->Config, this->Target->Target)) { // Follow public and private dependencies transitively. this->FollowSharedDeps(index, iface, true); @@ -552,7 +553,7 @@ void cmComputeLinkDepends::AddDirectLinkEntries() { // Add direct link dependencies in this configuration. cmTarget::LinkImplementation const* impl = - this->Target->GetLinkImplementation(this->Config); + this->Target->Target->GetLinkImplementation(this->Config); this->AddLinkEntries(-1, impl->Libraries); for(std::vector::const_iterator wi = impl->WrongConfigLibraries.begin(); @@ -634,7 +635,7 @@ cmTarget const* cmComputeLinkDepends::FindTargetToLink(int depender_index, const std::string& name) { // Look for a target in the scope of the depender. - cmTarget const* from = this->Target; + cmTarget const* from = this->Target->Target; if(depender_index >= 0) { if(cmTarget const* depender = this->EntryList[depender_index].Target) @@ -932,7 +933,7 @@ int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl) if(cmTarget const* target = this->EntryList[*ni].Target) { if(cmTarget::LinkInterface const* iface = - target->GetLinkInterface(this->Config, this->Target)) + target->GetLinkInterface(this->Config, this->Target->Target)) { if(iface->Multiplicity > count) { diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index 51a08c5..b925a4f 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -22,6 +22,7 @@ class cmComputeComponentGraph; class cmGlobalGenerator; class cmMakefile; +class cmGeneratorTarget; class cmTarget; class cmake; @@ -31,7 +32,8 @@ class cmake; class cmComputeLinkDepends { public: - cmComputeLinkDepends(cmTarget const* target, const std::string& config); + cmComputeLinkDepends(cmGeneratorTarget const* target, + const std::string& config); ~cmComputeLinkDepends(); // Basic information about each link item. @@ -57,7 +59,7 @@ public: private: // Context information. - cmTarget const* Target; + cmGeneratorTarget const* Target; cmMakefile* Makefile; cmGlobalGenerator const* GlobalGenerator; cmake* CMakeInstance; diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index fb89319..5cd0d54 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -497,7 +497,7 @@ bool cmComputeLinkInformation::Compute() } // Compute the ordered link line items. - cmComputeLinkDepends cld(this->Target->Target, this->Config); + cmComputeLinkDepends cld(this->Target, this->Config); cld.SetOldLinkDirMode(this->OldLinkDirMode); cmComputeLinkDepends::EntryVector const& linkEntries = cld.Compute(); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=22b2c5560a6500c163fddc0e74197145a6cdf117 commit 22b2c5560a6500c163fddc0e74197145a6cdf117 Author: Stephen Kelly AuthorDate: Thu Jul 30 00:41:27 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 09:44:06 2015 +0200 cmComputeLinkInformation: Port to cmGeneratorTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index f03c04a..fb89319 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -242,11 +242,12 @@ because this need be done only for shared libraries without soname-s. //---------------------------------------------------------------------------- cmComputeLinkInformation -::cmComputeLinkInformation(cmTarget const* target, const std::string& config) +::cmComputeLinkInformation(const cmGeneratorTarget* target, + const std::string& config) { // Store context information. this->Target = target; - this->Makefile = this->Target->GetMakefile(); + this->Makefile = this->Target->Target->GetMakefile(); this->GlobalGenerator = this->Makefile->GetGlobalGenerator(); this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance(); @@ -259,17 +260,15 @@ cmComputeLinkInformation // Allocate internals. this->OrderLinkerSearchPath = - new cmOrderDirectories(this->GlobalGenerator, target, + new cmOrderDirectories(this->GlobalGenerator, target->Target, "linker search path"); this->OrderRuntimeSearchPath = - new cmOrderDirectories(this->GlobalGenerator, target, + new cmOrderDirectories(this->GlobalGenerator, target->Target, "runtime search path"); this->OrderDependentRPath = 0; - cmGeneratorTarget *gtgt = this->GlobalGenerator - ->GetGeneratorTarget(this->Target); // Get the language used for linking this target. - this->LinkLanguage = gtgt->GetLinkerLanguage(config); + this->LinkLanguage = this->Target->GetLinkerLanguage(config); if(this->LinkLanguage.empty()) { // The Compute method will do nothing, so skip the rest of the @@ -283,14 +282,14 @@ cmComputeLinkInformation // Check whether we should skip dependencies on shared library files. this->LinkDependsNoShared = - this->Target->GetPropertyAsBool("LINK_DEPENDS_NO_SHARED"); + this->Target->Target->GetPropertyAsBool("LINK_DEPENDS_NO_SHARED"); // On platforms without import libraries there may be a special flag // to use when creating a plugin (module) that obtains symbols from // the program that will load it. this->LoaderFlag = 0; if(!this->UseImportLibrary && - this->Target->GetType() == cmTarget::MODULE_LIBRARY) + this->Target->Target->GetType() == cmTarget::MODULE_LIBRARY) { std::string loader_flag_var = "CMAKE_SHARED_MODULE_LOADER_"; loader_flag_var += this->LinkLanguage; @@ -308,10 +307,10 @@ cmComputeLinkInformation // Get options needed to specify RPATHs. this->RuntimeUseChrpath = false; - if(this->Target->GetType() != cmTarget::STATIC_LIBRARY) + if(this->Target->Target->GetType() != cmTarget::STATIC_LIBRARY) { const char* tType = - ((this->Target->GetType() == cmTarget::EXECUTABLE)? + ((this->Target->Target->GetType() == cmTarget::EXECUTABLE)? "EXECUTABLE" : "SHARED_LIBRARY"); std::string rtVar = "CMAKE_"; rtVar += tType; @@ -325,7 +324,7 @@ cmComputeLinkInformation (this->Makefile-> GetSafeDefinition("CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH")); - this->RuntimeUseChrpath = gtgt->IsChrpathUsed(config); + this->RuntimeUseChrpath = this->Target->IsChrpathUsed(config); // Get options needed to help find dependent libraries. std::string rlVar = "CMAKE_"; @@ -371,15 +370,15 @@ cmComputeLinkInformation { this->SharedDependencyMode = SharedDepModeDir; this->OrderDependentRPath = - new cmOrderDirectories(this->GlobalGenerator, target, + new cmOrderDirectories(this->GlobalGenerator, target->Target, "dependent library path"); } // Add the search path entries requested by the user to path ordering. this->OrderLinkerSearchPath - ->AddUserDirectories(this->Target->GetLinkDirectories()); + ->AddUserDirectories(this->Target->Target->GetLinkDirectories()); this->OrderRuntimeSearchPath - ->AddUserDirectories(this->Target->GetLinkDirectories()); + ->AddUserDirectories(this->Target->Target->GetLinkDirectories()); // Set up the implicit link directories. this->LoadImplicitLinkInfo(); @@ -407,12 +406,13 @@ cmComputeLinkInformation // order to support such projects we need to add the directories // containing libraries linked with a full path to the -L path. this->OldLinkDirMode = - this->Target->GetPolicyStatusCMP0003() != cmPolicies::NEW; + this->Target->Target->GetPolicyStatusCMP0003() != cmPolicies::NEW; if(this->OldLinkDirMode) { // Construct a mask to not bother with this behavior for link // directories already specified by the user. - std::vector const& dirs = this->Target->GetLinkDirectories(); + std::vector const& dirs = + this->Target->Target->GetLinkDirectories(); this->OldLinkDirMask.insert(dirs.begin(), dirs.end()); } @@ -497,7 +497,7 @@ bool cmComputeLinkInformation::Compute() } // Compute the ordered link line items. - cmComputeLinkDepends cld(this->Target, this->Config); + cmComputeLinkDepends cld(this->Target->Target, this->Config); cld.SetOldLinkDirMode(this->OldLinkDirMode); cmComputeLinkDepends::EntryVector const& linkEntries = cld.Compute(); @@ -518,7 +518,8 @@ bool cmComputeLinkInformation::Compute() // Restore the target link type so the correct system runtime // libraries are found. - const char* lss = this->Target->GetProperty("LINK_SEARCH_END_STATIC"); + const char* lss = + this->Target->Target->GetProperty("LINK_SEARCH_END_STATIC"); if(cmSystemTools::IsOn(lss)) { this->SetCurrentLinkType(LinkStatic); @@ -571,7 +572,7 @@ bool cmComputeLinkInformation::Compute() "name." ; this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); } return true; @@ -580,12 +581,9 @@ bool cmComputeLinkInformation::Compute() //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddImplicitLinkInfo() { - cmGeneratorTarget *gtgt = this->Target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(this->Target); - // The link closure lists all languages whose implicit info is needed. - cmGeneratorTarget::LinkClosure const* lc=gtgt->GetLinkClosure(this->Config); + cmGeneratorTarget::LinkClosure const* lc = + this->Target->GetLinkClosure(this->Config); for(std::vector::const_iterator li = lc->Languages.begin(); li != lc->Languages.end(); ++li) { @@ -863,7 +861,8 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo() } // Lookup the starting link type from the target (linked statically?). - const char* lss = this->Target->GetProperty("LINK_SEARCH_START_STATIC"); + const char* lss = + this->Target->Target->GetProperty("LINK_SEARCH_START_STATIC"); this->StartLinkType = cmSystemTools::IsOn(lss)? LinkStatic : LinkShared; this->CurrentLinkType = this->StartLinkType; } @@ -1149,7 +1148,7 @@ void cmComputeLinkInformation::AddFullItem(std::string const& item) // Full path libraries should specify a valid library file name. // See documentation of CMP0008. std::string generator = this->GlobalGenerator->GetName(); - if(this->Target->GetPolicyStatusCMP0008() != cmPolicies::NEW && + if(this->Target->Target->GetPolicyStatusCMP0008() != cmPolicies::NEW && (generator.find("Visual Studio") != generator.npos || generator.find("Xcode") != generator.npos)) { @@ -1230,7 +1229,7 @@ bool cmComputeLinkInformation::CheckImplicitDirItem(std::string const& item) } // Check the policy for whether we should use the approach below. - switch (this->Target->GetPolicyStatusCMP0060()) + switch (this->Target->Target->GetPolicyStatusCMP0060()) { case cmPolicies::WARN: if (this->CMP0060Warn) @@ -1540,7 +1539,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item, this->OrderLinkerSearchPath->AddLinkLibrary(item); // Produce any needed message. - switch(this->Target->GetPolicyStatusCMP0008()) + switch(this->Target->Target->GetPolicyStatusCMP0008()) { case cmPolicies::WARN: { @@ -1557,7 +1556,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item, << " " << item << "\n" << "which is a full-path but not a valid library file name."; this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); } } case cmPolicies::OLD: @@ -1575,7 +1574,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item, << " " << item << "\n" << "which is a full-path but not a valid library file name."; this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); } break; } @@ -1592,7 +1591,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories() } // Enforce policy constraints. - switch(this->Target->GetPolicyStatusCMP0003()) + switch(this->Target->Target->GetPolicyStatusCMP0003()) { case cmPolicies::WARN: if(!this->CMakeInstance->GetState() @@ -1603,7 +1602,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories() std::ostringstream w; this->PrintLinkPolicyDiagnosis(w); this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); } case cmPolicies::OLD: // OLD behavior is to add the paths containing libraries with @@ -1619,7 +1618,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories() e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0003) << "\n"; this->PrintLinkPolicyDiagnosis(e); this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); return false; } } @@ -1923,23 +1922,24 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, // build tree. bool linking_for_install = (for_install || - this->Target->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")); + this->Target->Target->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")); bool use_install_rpath = - (outputRuntime && this->Target->HaveInstallTreeRPATH() && + (outputRuntime && this->Target->Target->HaveInstallTreeRPATH() && linking_for_install); bool use_build_rpath = - (outputRuntime && this->Target->HaveBuildTreeRPATH(this->Config) && + (outputRuntime && this->Target->Target->HaveBuildTreeRPATH(this->Config) && !linking_for_install); bool use_link_rpath = outputRuntime && linking_for_install && !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH") && - this->Target->GetPropertyAsBool("INSTALL_RPATH_USE_LINK_PATH"); + this->Target->Target->GetPropertyAsBool("INSTALL_RPATH_USE_LINK_PATH"); // Construct the RPATH. std::set emitted; if(use_install_rpath) { - const char* install_rpath = this->Target->GetProperty("INSTALL_RPATH"); + const char* install_rpath = + this->Target->Target->GetProperty("INSTALL_RPATH"); cmCLI_ExpandListUnique(install_rpath, runtimeDirs, emitted); } if(use_build_rpath || use_link_rpath) @@ -2011,12 +2011,8 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, // Add runtime paths required by the languages to always be // present. This is done even when skipping rpath support. { - cmGeneratorTarget *gtgt = this->Makefile - ->GetGlobalGenerator() - ->GetGeneratorTarget(this->Target); - cmGeneratorTarget::LinkClosure const* lc = - gtgt->GetLinkClosure(this->Config); + this->Target->GetLinkClosure(this->Config); for(std::vector::const_iterator li = lc->Languages.begin(); li != lc->Languages.end(); ++li) { diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index 2d7a5a5..8b83574 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -29,7 +29,8 @@ class cmOrderDirectories; class cmComputeLinkInformation { public: - cmComputeLinkInformation(cmTarget const* target, const std::string& config); + cmComputeLinkInformation(cmGeneratorTarget const* target, + const std::string& config); ~cmComputeLinkInformation(); bool Compute(); @@ -73,7 +74,7 @@ private: std::set SharedLibrariesLinked; // Context information. - cmTarget const* Target; + cmGeneratorTarget const* Target; cmMakefile* Makefile; cmGlobalGenerator* GlobalGenerator; cmake* CMakeInstance; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c68c2b9..55e2922 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3166,7 +3166,7 @@ cmGeneratorTarget::GetLinkInformation(const std::string& config) const { // Compute information for this configuration. cmComputeLinkInformation* info = - new cmComputeLinkInformation(this->Target, config); + new cmComputeLinkInformation(this, config); if(!info || !info->Compute()) { delete info; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a158d931d05fe3cea541494c01185a1c2cb7cc20 commit a158d931d05fe3cea541494c01185a1c2cb7cc20 Author: Stephen Kelly AuthorDate: Tue Jul 28 23:16:43 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 09:44:06 2015 +0200 cmGeneratorTarget: Move IsBundleOnApple from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c314372..c68c2b9 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -910,6 +910,14 @@ cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, } //---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsBundleOnApple() const +{ + return this->Target->IsFrameworkOnApple() + || this->Target->IsAppBundleOnApple() + || this->Target->IsCFBundleOnApple(); +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config, bool contentOnly) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 4299053..d10cd1d 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -119,6 +119,10 @@ public: std::string GetAppBundleDirectory(const std::string& config, bool contentOnly) const; + /** Return whether this target is an executable Bundle, a framework + or CFBundle on Apple. */ + bool IsBundleOnApple() const; + /** Get the full name of the target according to the settings in its makefile. */ std::string GetFullName(const std::string& config="", diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index d38cf4c..0b3df90 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -313,7 +313,7 @@ cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator() (cmSourceFile const& source, const char* pkgloc) { // Skip OS X content when not building a Framework or Bundle. - if(!this->Generator->GetTarget()->IsBundleOnApple()) + if(!this->Generator->GetGeneratorTarget()->IsBundleOnApple()) { return; } diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 16e1f48..07efa16 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -742,7 +742,7 @@ cmNinjaTargetGenerator::MacOSXContentGeneratorType::operator()( cmSourceFile const& source, const char* pkgloc) { // Skip OS X content when not building a Framework or Bundle. - if(!this->Generator->GetTarget()->IsBundleOnApple()) + if(!this->Generator->GetGeneratorTarget()->IsBundleOnApple()) { return; } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 62aa12a..e887ef3 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -590,13 +590,6 @@ bool cmTarget::IsXCTestOnApple() const } //---------------------------------------------------------------------------- -bool cmTarget::IsBundleOnApple() const -{ - return this->IsFrameworkOnApple() || this->IsAppBundleOnApple() || - this->IsCFBundleOnApple(); -} - -//---------------------------------------------------------------------------- static bool processSources(cmTarget const* tgt, const std::vector &entries, std::vector &srcs, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 9a4915f..e53afff 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -424,10 +424,6 @@ public: /** Return whether this target is an executable Bundle on Apple. */ bool IsAppBundleOnApple() const; - /** Return whether this target is an executable Bundle, a framework - or CFBundle on Apple. */ - bool IsBundleOnApple() const; - /** Return the framework version string. Undefined if IsFrameworkOnApple returns false. */ std::string GetFrameworkVersion() const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0cc640238b70edd09234a4eae5258651a6ae585a commit 0cc640238b70edd09234a4eae5258651a6ae585a Author: Stephen Kelly AuthorDate: Tue Jul 28 23:18:55 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 09:44:06 2015 +0200 cmMakefileTargetGenerator: Add accessor for GeneratorTarget. diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index b885672..fd4527b 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -53,6 +53,7 @@ public: { return this->ProgressFileNameFull; } cmTarget* GetTarget() { return this->Target;} + cmGeneratorTarget* GetGeneratorTarget() { return this->GeneratorTarget;} protected: http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=136ccd27b69beccd6d893fbaeb909f2915d41c48 commit 136ccd27b69beccd6d893fbaeb909f2915d41c48 Author: Stephen Kelly AuthorDate: Wed Oct 10 21:43:28 2012 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 09:44:06 2015 +0200 cmGeneratorTarget: Move GetLinkClosure from cmTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 640e806..f03c04a 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -19,6 +19,7 @@ #include "cmOutputConverter.h" #include "cmMakefile.h" #include "cmTarget.h" +#include "cmGeneratorTarget.h" #include "cmake.h" #include "cmAlgorithms.h" @@ -579,8 +580,12 @@ bool cmComputeLinkInformation::Compute() //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddImplicitLinkInfo() { + cmGeneratorTarget *gtgt = this->Target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(this->Target); + // The link closure lists all languages whose implicit info is needed. - cmTarget::LinkClosure const* lc=this->Target->GetLinkClosure(this->Config); + cmGeneratorTarget::LinkClosure const* lc=gtgt->GetLinkClosure(this->Config); for(std::vector::const_iterator li = lc->Languages.begin(); li != lc->Languages.end(); ++li) { @@ -2006,8 +2011,12 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, // Add runtime paths required by the languages to always be // present. This is done even when skipping rpath support. { - cmTarget::LinkClosure const* lc = - this->Target->GetLinkClosure(this->Config); + cmGeneratorTarget *gtgt = this->Makefile + ->GetGlobalGenerator() + ->GetGeneratorTarget(this->Target); + + cmGeneratorTarget::LinkClosure const* lc = + gtgt->GetLinkClosure(this->Config); for(std::vector::const_iterator li = lc->Languages.begin(); li != lc->Languages.end(); ++li) { diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index 3afbb92..2d7a5a5 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -20,6 +20,7 @@ class cmake; class cmGlobalGenerator; class cmMakefile; class cmTarget; +class cmGeneratorTarget; class cmOrderDirectories; /** \class cmComputeLinkInformation diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 4de5e9c..c314372 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -27,6 +27,13 @@ #include #include "assert.h" +#if defined(CMAKE_BUILD_WITH_CMAKE) +#include +#define UNORDERED_SET cmsys::hash_set +#else +#define UNORDERED_SET std::set +#endif + //---------------------------------------------------------------------------- void reportBadObjLib(std::vector const& badObjLib, cmTarget *target, cmake *cm) @@ -1026,6 +1033,223 @@ std::string cmGeneratorTarget::GetInstallNameDirForInstallTree() const } //---------------------------------------------------------------------------- +class cmTargetCollectLinkLanguages +{ +public: + cmTargetCollectLinkLanguages(cmGeneratorTarget const* target, + const std::string& config, + UNORDERED_SET& languages, + cmTarget const* head): + Config(config), Languages(languages), HeadTarget(head), + Makefile(target->Target->GetMakefile()), Target(target) + { this->Visited.insert(target->Target); } + + void Visit(cmLinkItem const& item) + { + if(!item.Target) + { + if(item.find("::") != std::string::npos) + { + bool noMessage = false; + cmake::MessageType messageType = cmake::FATAL_ERROR; + std::stringstream e; + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0028)) + { + case cmPolicies::WARN: + { + e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0028) << "\n"; + messageType = cmake::AUTHOR_WARNING; + } + break; + case cmPolicies::OLD: + noMessage = true; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::NEW: + // Issue the fatal message. + break; + } + + if(!noMessage) + { + e << "Target \"" << this->Target->GetName() + << "\" links to target \"" << item + << "\" but the target was not found. Perhaps a find_package() " + "call is missing for an IMPORTED target, or an ALIAS target is " + "missing?"; + this->Makefile->GetCMakeInstance()->IssueMessage( + messageType, e.str(), this->Target->Target->GetBacktrace()); + } + } + return; + } + if(!this->Visited.insert(item.Target).second) + { + return; + } + + cmTarget::LinkInterface const* iface = + item.Target->GetLinkInterface(this->Config, this->HeadTarget); + if(!iface) { return; } + + for(std::vector::const_iterator + li = iface->Languages.begin(); li != iface->Languages.end(); ++li) + { + this->Languages.insert(*li); + } + + for(std::vector::const_iterator + li = iface->Libraries.begin(); li != iface->Libraries.end(); ++li) + { + this->Visit(*li); + } + } +private: + std::string Config; + UNORDERED_SET& Languages; + cmTarget const* HeadTarget; + cmMakefile* Makefile; + const cmGeneratorTarget* Target; + std::set Visited; +}; + +//---------------------------------------------------------------------------- +cmGeneratorTarget::LinkClosure const* +cmGeneratorTarget::GetLinkClosure(const std::string& config) const +{ + std::string key(cmSystemTools::UpperCase(config)); + LinkClosureMapType::iterator + i = this->LinkClosureMap.find(key); + if(i == this->LinkClosureMap.end()) + { + LinkClosure lc; + this->ComputeLinkClosure(config, lc); + LinkClosureMapType::value_type entry(key, lc); + i = this->LinkClosureMap.insert(entry).first; + } + return &i->second; +} + +//---------------------------------------------------------------------------- +class cmTargetSelectLinker +{ + int Preference; + cmGeneratorTarget const* Target; + cmMakefile* Makefile; + cmGlobalGenerator* GG; + std::set Preferred; +public: + cmTargetSelectLinker(cmGeneratorTarget const* target) + : Preference(0), Target(target) + { + this->Makefile = this->Target->Makefile; + this->GG = this->Makefile->GetGlobalGenerator(); + } + void Consider(const char* lang) + { + int preference = this->GG->GetLinkerPreference(lang); + if(preference > this->Preference) + { + this->Preference = preference; + this->Preferred.clear(); + } + if(preference == this->Preference) + { + this->Preferred.insert(lang); + } + } + std::string Choose() + { + if(this->Preferred.empty()) + { + return ""; + } + else if(this->Preferred.size() > 1) + { + std::stringstream e; + e << "Target " << this->Target->GetName() + << " contains multiple languages with the highest linker preference" + << " (" << this->Preference << "):\n"; + for(std::set::const_iterator + li = this->Preferred.begin(); li != this->Preferred.end(); ++li) + { + e << " " << *li << "\n"; + } + e << "Set the LINKER_LANGUAGE property for this target."; + cmake* cm = this->Makefile->GetCMakeInstance(); + cm->IssueMessage(cmake::FATAL_ERROR, e.str(), + this->Target->Target->GetBacktrace()); + } + return *this->Preferred.begin(); + } +}; + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::ComputeLinkClosure(const std::string& config, + LinkClosure& lc) const +{ + // Get languages built in this target. + UNORDERED_SET languages; + cmTarget::LinkImplementation const* impl = + this->Target->GetLinkImplementation(config); + for(std::vector::const_iterator li = impl->Languages.begin(); + li != impl->Languages.end(); ++li) + { + languages.insert(*li); + } + + // Add interface languages from linked targets. + cmTargetCollectLinkLanguages cll(this, config, languages, this->Target); + for(std::vector::const_iterator li = impl->Libraries.begin(); + li != impl->Libraries.end(); ++li) + { + cll.Visit(*li); + } + + // Store the transitive closure of languages. + for(UNORDERED_SET::const_iterator li = languages.begin(); + li != languages.end(); ++li) + { + lc.Languages.push_back(*li); + } + + // Choose the language whose linker should be used. + if(this->GetProperty("HAS_CXX")) + { + lc.LinkerLanguage = "CXX"; + } + else if(const char* linkerLang = this->GetProperty("LINKER_LANGUAGE")) + { + lc.LinkerLanguage = linkerLang; + } + else + { + // Find the language with the highest preference value. + cmTargetSelectLinker tsl(this); + + // First select from the languages compiled directly in this target. + for(std::vector::const_iterator li = impl->Languages.begin(); + li != impl->Languages.end(); ++li) + { + tsl.Consider(li->c_str()); + } + + // Now consider languages that propagate from linked targets. + for(UNORDERED_SET::const_iterator sit = languages.begin(); + sit != languages.end(); ++sit) + { + std::string propagates = "CMAKE_"+*sit+"_LINKER_PREFERENCE_PROPAGATES"; + if(this->Makefile->IsOn(propagates)) + { + tsl.Consider(sit->c_str()); + } + } + + lc.LinkerLanguage = tsl.Choose(); + } +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, std::string& base, std::string& suffix, @@ -2058,7 +2282,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, std::string cmGeneratorTarget::GetLinkerLanguage(const std::string& config) const { - return this->Target->GetLinkClosure(config)->LinkerLanguage; + return this->GetLinkClosure(config)->LinkerLanguage; } //---------------------------------------------------------------------------- diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 2799371..4299053 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -165,6 +165,20 @@ public: std::string GetModuleDefinitionFile(const std::string& config) const; + /** Link information from the transitive closure of the link + implementation and the interfaces of its dependencies. */ + struct LinkClosure + { + // The preferred linker language. + std::string LinkerLanguage; + + // Languages whose runtime libraries must be linked. + std::vector Languages; + }; + + LinkClosure const* GetLinkClosure(const std::string& config) const; + void ComputeLinkClosure(const std::string& config, LinkClosure& lc) const; + /** Full path with trailing slash to the top-level directory holding object files for this target. Includes the build time config name placeholder if needed for the generator. */ @@ -300,6 +314,9 @@ private: std::string& outPrefix, std::string& outBase, std::string& outSuffix) const; + typedef std::map LinkClosureMapType; + mutable LinkClosureMapType LinkClosureMap; + struct CompatibleInterfacesBase { std::set PropsBool; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index c7118dc..62aa12a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -160,9 +160,6 @@ public: HeadToLinkImplementationMap> LinkImplMapType; LinkImplMapType LinkImplMap; - typedef std::map LinkClosureMapType; - LinkClosureMapType LinkClosureMap; - typedef std::map > SourceFilesMapType; SourceFilesMapType SourceFilesMap; @@ -511,7 +508,6 @@ void cmTarget::ClearLinkMaps() this->Internal->LinkImplMap.clear(); this->Internal->LinkInterfaceMap.clear(); this->Internal->LinkInterfaceUsageRequirementsOnlyMap.clear(); - this->Internal->LinkClosureMap.clear(); this->Internal->SourceFilesMap.clear(); } @@ -3136,223 +3132,6 @@ bool cmTarget::GetPropertyAsBool(const std::string& prop) const } //---------------------------------------------------------------------------- -class cmTargetCollectLinkLanguages -{ -public: - cmTargetCollectLinkLanguages(cmTarget const* target, - const std::string& config, - UNORDERED_SET& languages, - cmTarget const* head): - Config(config), Languages(languages), HeadTarget(head), - Makefile(target->GetMakefile()), Target(target) - { this->Visited.insert(target); } - - void Visit(cmLinkItem const& item) - { - if(!item.Target) - { - if(item.find("::") != std::string::npos) - { - bool noMessage = false; - cmake::MessageType messageType = cmake::FATAL_ERROR; - std::ostringstream e; - switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0028)) - { - case cmPolicies::WARN: - { - e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0028) << "\n"; - messageType = cmake::AUTHOR_WARNING; - } - break; - case cmPolicies::OLD: - noMessage = true; - case cmPolicies::REQUIRED_IF_USED: - case cmPolicies::REQUIRED_ALWAYS: - case cmPolicies::NEW: - // Issue the fatal message. - break; - } - - if(!noMessage) - { - e << "Target \"" << this->Target->GetName() - << "\" links to target \"" << item - << "\" but the target was not found. Perhaps a find_package() " - "call is missing for an IMPORTED target, or an ALIAS target is " - "missing?"; - this->Makefile->GetCMakeInstance()->IssueMessage(messageType, - e.str(), - this->Target->GetBacktrace()); - } - } - return; - } - if(!this->Visited.insert(item.Target).second) - { - return; - } - - cmTarget::LinkInterface const* iface = - item.Target->GetLinkInterface(this->Config, this->HeadTarget); - if(!iface) { return; } - - for(std::vector::const_iterator - li = iface->Languages.begin(); li != iface->Languages.end(); ++li) - { - this->Languages.insert(*li); - } - - for(std::vector::const_iterator - li = iface->Libraries.begin(); li != iface->Libraries.end(); ++li) - { - this->Visit(*li); - } - } -private: - std::string Config; - UNORDERED_SET& Languages; - cmTarget const* HeadTarget; - cmMakefile* Makefile; - const cmTarget* Target; - std::set Visited; -}; - -//---------------------------------------------------------------------------- -cmTarget::LinkClosure const* -cmTarget::GetLinkClosure(const std::string& config) const -{ - std::string key(cmSystemTools::UpperCase(config)); - cmTargetInternals::LinkClosureMapType::iterator - i = this->Internal->LinkClosureMap.find(key); - if(i == this->Internal->LinkClosureMap.end()) - { - LinkClosure lc; - this->ComputeLinkClosure(config, lc); - cmTargetInternals::LinkClosureMapType::value_type entry(key, lc); - i = this->Internal->LinkClosureMap.insert(entry).first; - } - return &i->second; -} - -//---------------------------------------------------------------------------- -class cmTargetSelectLinker -{ - int Preference; - cmTarget const* Target; - cmMakefile* Makefile; - cmGlobalGenerator* GG; - UNORDERED_SET Preferred; -public: - cmTargetSelectLinker(cmTarget const* target): Preference(0), Target(target) - { - this->Makefile = this->Target->GetMakefile(); - this->GG = this->Makefile->GetGlobalGenerator(); - } - void Consider(const std::string& lang) - { - int preference = this->GG->GetLinkerPreference(lang); - if(preference > this->Preference) - { - this->Preference = preference; - this->Preferred.clear(); - } - if(preference == this->Preference) - { - this->Preferred.insert(lang); - } - } - std::string Choose() - { - if(this->Preferred.empty()) - { - return ""; - } - else if(this->Preferred.size() > 1) - { - std::ostringstream e; - e << "Target " << this->Target->GetName() - << " contains multiple languages with the highest linker preference" - << " (" << this->Preference << "):\n"; - for(UNORDERED_SET::const_iterator - li = this->Preferred.begin(); li != this->Preferred.end(); ++li) - { - e << " " << *li << "\n"; - } - e << "Set the LINKER_LANGUAGE property for this target."; - cmake* cm = this->Makefile->GetCMakeInstance(); - cm->IssueMessage(cmake::FATAL_ERROR, e.str(), - this->Target->GetBacktrace()); - } - return *this->Preferred.begin(); - } -}; - -//---------------------------------------------------------------------------- -void cmTarget::ComputeLinkClosure(const std::string& config, - LinkClosure& lc) const -{ - // Get languages built in this target. - UNORDERED_SET languages; - LinkImplementation const* impl = this->GetLinkImplementation(config); - for(std::vector::const_iterator li = impl->Languages.begin(); - li != impl->Languages.end(); ++li) - { - languages.insert(*li); - } - - // Add interface languages from linked targets. - cmTargetCollectLinkLanguages cll(this, config, languages, this); - for(std::vector::const_iterator - li = impl->Libraries.begin(); - li != impl->Libraries.end(); ++li) - { - cll.Visit(*li); - } - - // Store the transitive closure of languages. - for(UNORDERED_SET::const_iterator li = languages.begin(); - li != languages.end(); ++li) - { - lc.Languages.push_back(*li); - } - - // Choose the language whose linker should be used. - if(this->GetProperty("HAS_CXX")) - { - lc.LinkerLanguage = "CXX"; - } - else if(const char* linkerLang = this->GetProperty("LINKER_LANGUAGE")) - { - lc.LinkerLanguage = linkerLang; - } - else - { - // Find the language with the highest preference value. - cmTargetSelectLinker tsl(this); - - // First select from the languages compiled directly in this target. - for(std::vector::const_iterator li = impl->Languages.begin(); - li != impl->Languages.end(); ++li) - { - tsl.Consider(*li); - } - - // Now consider languages that propagate from linked targets. - for(UNORDERED_SET::const_iterator sit = languages.begin(); - sit != languages.end(); ++sit) - { - std::string propagates = "CMAKE_"+*sit+"_LINKER_PREFERENCE_PROPAGATES"; - if(this->Makefile->IsOn(propagates)) - { - tsl.Consider(*sit); - } - } - - lc.LinkerLanguage = tsl.Choose(); - } -} - -//---------------------------------------------------------------------------- void cmTarget::ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index dea9bef..9a4915f 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -315,18 +315,6 @@ public: LinkImplementationLibraries const* GetLinkImplementationLibraries(const std::string& config) const; - /** Link information from the transitive closure of the link - implementation and the interfaces of its dependencies. */ - struct LinkClosure - { - // The preferred linker language. - std::string LinkerLanguage; - - // Languages whose runtime libraries must be linked. - std::vector Languages; - }; - LinkClosure const* GetLinkClosure(const std::string& config) const; - cmTarget const* FindTargetToLink(std::string const& name) const; /** Strip off leading and trailing whitespace from an item named in @@ -662,7 +650,6 @@ private: LinkImplementationLibraries const* GetLinkImplementationLibrariesInternal(const std::string& config, cmTarget const* head) const; - void ComputeLinkClosure(const std::string& config, LinkClosure& lc) const; void ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, cmTarget const* headTarget, http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3b36794bf535ae16c72cc3b363cc954ff680fed9 commit 3b36794bf535ae16c72cc3b363cc954ff680fed9 Author: Stephen Kelly AuthorDate: Sun Nov 3 16:33:25 2013 +0100 Commit: Stephen Kelly CommitDate: Sat Aug 1 09:44:05 2015 +0200 cmGeneratorTarget: Move GetLinkerLanguage from cmTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index fee921c..640e806 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -265,8 +265,10 @@ cmComputeLinkInformation "runtime search path"); this->OrderDependentRPath = 0; + cmGeneratorTarget *gtgt = this->GlobalGenerator + ->GetGeneratorTarget(this->Target); // Get the language used for linking this target. - this->LinkLanguage = this->Target->GetLinkerLanguage(config); + this->LinkLanguage = gtgt->GetLinkerLanguage(config); if(this->LinkLanguage.empty()) { // The Compute method will do nothing, so skip the rest of the @@ -322,9 +324,6 @@ cmComputeLinkInformation (this->Makefile-> GetSafeDefinition("CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH")); - cmGeneratorTarget *gtgt = this->Target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(this->Target); this->RuntimeUseChrpath = gtgt->IsChrpathUsed(config); // Get options needed to help find dependent libraries. diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 49fc96b..a86c2bc 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -990,6 +990,9 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode assert(target); + cmGeneratorTarget* gtgt = + context->Makefile->GetGlobalGenerator()->GetGeneratorTarget(target); + if (propertyName == "LINKER_LANGUAGE") { if (target->LinkLanguagePropagatesToDependents() && @@ -1001,7 +1004,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode "link libraries for a static library"); return std::string(); } - return target->GetLinkerLanguage(context->Config); + return gtgt->GetLinkerLanguage(context->Config); } cmGeneratorExpressionDAGChecker dagChecker(context->Backtrace, @@ -1128,9 +1131,6 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode } } - cmGeneratorTarget* gtgt = - context->Makefile->GetGlobalGenerator()->GetGeneratorTarget(target); - if (!prop) { if (target->IsImported() @@ -1600,7 +1600,7 @@ struct TargetFilesystemArtifactResultCreator cmGeneratorExpressionContext *context, const GeneratorExpressionContent *content) { - std::string language = target->Target->GetLinkerLanguage(context->Config); + std::string language = target->GetLinkerLanguage(context->Config); std::string pdbSupportVar = "CMAKE_" + language + "_LINKER_SUPPORTS_PDB"; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 834a2e3..4de5e9c 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -709,8 +709,7 @@ bool cmGeneratorTarget::HasSOName(const std::string& config) const return ((this->GetType() == cmTarget::SHARED_LIBRARY || this->GetType() == cmTarget::MODULE_LIBRARY) && !this->GetPropertyAsBool("NO_SONAME") && - this->Makefile->GetSONameFlag( - this->Target->GetLinkerLanguage(config))); + this->Makefile->GetSONameFlag(this->GetLinkerLanguage(config))); } //---------------------------------------------------------------------------- @@ -752,7 +751,7 @@ cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const } // Check for rpath support on this platform. - std::string ll = this->Target->GetLinkerLanguage(config); + std::string ll = this->GetLinkerLanguage(config); if(!ll.empty()) { std::string flagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; @@ -823,7 +822,7 @@ bool cmGeneratorTarget::IsChrpathUsed(const std::string& config) const #if defined(CMAKE_USE_ELF_PARSER) // Enable if the rpath flag uses a separator and the target uses ELF // binaries. - std::string ll = this->Target->GetLinkerLanguage(config); + std::string ll = this->GetLinkerLanguage(config); if(!ll.empty()) { std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; @@ -1986,7 +1985,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, const char* suffixVar = this->Target->GetSuffixVariableInternal(implib); // Check for language-specific default prefix and suffix. - std::string ll = this->Target->GetLinkerLanguage(config); + std::string ll = this->GetLinkerLanguage(config); if(!ll.empty()) { if(!targetSuffix && suffixVar && *suffixVar) @@ -2056,6 +2055,13 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, //---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetLinkerLanguage(const std::string& config) const +{ + return this->Target->GetLinkClosure(config)->LinkerLanguage; +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetPDBName(const std::string& config) const { std::string prefix; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 372bbe1..2799371 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -258,6 +258,9 @@ public: /** Return true if builtin chrpath will work for this target */ bool IsChrpathUsed(const std::string& config) const; + ///! Return the preferred linker language for this target + std::string GetLinkerLanguage(const std::string& config = "") const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index 2f9265a..1e57c33 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -128,7 +128,8 @@ void cmGhsMultiTargetGenerator::Generate() { config = "RELEASE"; } - const std::string language(this->Target->GetLinkerLanguage(config)); + const std::string language( + this->GeneratorTarget->GetLinkerLanguage(config)); config = cmSystemTools::UpperCase(config); this->DynamicDownload = this->DetermineIfDynamicDownload(config, language); if (this->DynamicDownload) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 7b0e153..5006828 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1376,7 +1376,8 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmTarget& cmtarget) return; } - std::string llang = cmtarget.GetLinkerLanguage("NOCONFIG"); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&cmtarget); + std::string llang = gtgt->GetLinkerLanguage("NOCONFIG"); if(llang.empty()) { return; } // If the language is compiled as a source trust Xcode to link with it. @@ -1824,7 +1825,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, AddCompileOptions(flags, &target, lang, configName); } - std::string llang = target.GetLinkerLanguage(configName); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); + std::string llang = gtgt->GetLinkerLanguage(configName); if(binary && llang.empty()) { cmSystemTools::Error @@ -1850,7 +1852,6 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, // Add the export symbol definition for shared library objects. this->AppendDefines(ppDefs, exportMacro); } - cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); std::vector targetDefines; target.GetCompileDefinitions(targetDefines, configName, "C"); this->AppendDefines(ppDefs, targetDefines); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 3ab501d..4ec77a1 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1353,7 +1353,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, linkFlags += this->Makefile->GetSafeDefinition(build); linkFlags += " "; } - std::string linkLanguage = target->Target->GetLinkerLanguage(buildType); + std::string linkLanguage = target->GetLinkerLanguage(buildType); if(linkLanguage.empty()) { cmSystemTools::Error diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 94457bb..e1fa7d4 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1259,8 +1259,8 @@ void cmLocalVisualStudio6Generator extraLinkOptionsRelWithDebInfo += targetLinkFlags; } - - + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); // Get standard libraries for this language. if(targetBuilds) @@ -1269,10 +1269,10 @@ void cmLocalVisualStudio6Generator std::vector configs; target.GetMakefile()->GetConfigurations(configs); std::vector::const_iterator it = configs.begin(); - const std::string& linkLanguage = target.GetLinkerLanguage(*it); + const std::string& linkLanguage = gt->GetLinkerLanguage(*it); for ( ; it != configs.end(); ++it) { - const std::string& configLinkLanguage = target.GetLinkerLanguage(*it); + const std::string& configLinkLanguage = gt->GetLinkerLanguage(*it); if (configLinkLanguage != linkLanguage) { cmSystemTools::Error @@ -1702,10 +1702,10 @@ void cmLocalVisualStudio6Generator std::vector configs; target.GetMakefile()->GetConfigurations(configs); std::vector::const_iterator it = configs.begin(); - const std::string& linkLanguage = target.GetLinkerLanguage(*it); + const std::string& linkLanguage = gt->GetLinkerLanguage(*it); for ( ; it != configs.end(); ++it) { - const std::string& configLinkLanguage = target.GetLinkerLanguage(*it); + const std::string& configLinkLanguage = gt->GetLinkerLanguage(*it); if (configLinkLanguage != linkLanguage) { cmSystemTools::Error diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 99c6829..48b610b 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -664,6 +664,10 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, const char* configType = "10"; const char* projectType = 0; bool targetBuilds = true; + + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); + switch(target.GetType()) { case cmTarget::OBJECT_LIBRARY: @@ -696,7 +700,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, { const std::string& linkLanguage = (this->FortranProject? std::string("Fortran"): - target.GetLinkerLanguage(configName)); + gt->GetLinkerLanguage(configName)); if(linkLanguage.empty()) { cmSystemTools::Error @@ -758,8 +762,6 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, targetOptions.Parse(flags.c_str()); targetOptions.Parse(defineFlags.c_str()); targetOptions.ParseFinish(); - cmGeneratorTarget* gt = - this->GlobalGenerator->GetGeneratorTarget(&target); std::vector targetDefines; target.GetCompileDefinitions(targetDefines, configName, "CXX"); targetOptions.AddDefines(targetDefines); @@ -1637,7 +1639,7 @@ cmLocalVisualStudio7GeneratorFCInfo lg->GlobalGenerator->GetLanguageFromExtension (sf.GetExtension().c_str()); const std::string& sourceLang = lg->GetSourceFileLanguage(sf); - const std::string& linkLanguage = target.GetLinkerLanguage(i->c_str()); + const std::string& linkLanguage = gt->GetLinkerLanguage(i->c_str()); bool needForceLang = false; // source file does not match its extension language if(lang != sourceLang) diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 2fd77c9..afe145a 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -161,7 +161,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) // Get the language to use for linking this executable. std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); // Make sure we have a link language. if(linkLanguage.empty()) diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index b85b8a8..bb0f9dd 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -133,7 +133,7 @@ void cmMakefileLibraryTargetGenerator::WriteObjectLibraryRules() void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules() { std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_STATIC_LIBRARY"; @@ -159,7 +159,7 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink) return; } std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_SHARED_LIBRARY"; @@ -183,7 +183,7 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink) void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink) { std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_SHARED_MODULE"; @@ -206,7 +206,7 @@ void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink) void cmMakefileLibraryTargetGenerator::WriteFrameworkRules(bool relink) { std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_MACOSX_FRAMEWORK"; @@ -238,7 +238,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules // Get the language to use for linking this library. std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); // Make sure we have a link language. if(linkLanguage.empty()) diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index b94e151..d38cf4c 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1509,7 +1509,7 @@ std::string cmMakefileTargetGenerator::GetLinkRule( if(this->Target->HasImplibGNUtoMS()) { std::string ruleVar = "CMAKE_"; - ruleVar += this->Target->GetLinkerLanguage(this->ConfigName); + ruleVar += this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); ruleVar += "_GNUtoMS_RULE"; if(const char* rule = this->Makefile->GetDefinition(ruleVar)) { @@ -1663,7 +1663,8 @@ cmMakefileTargetGenerator { // Lookup the response file reference flag. std::string responseFlagVar = "CMAKE_"; - responseFlagVar += this->Target->GetLinkerLanguage(this->ConfigName); + responseFlagVar += this->GeneratorTarget + ->GetLinkerLanguage(this->ConfigName); responseFlagVar += "_RESPONSE_FILE_LINK_FLAG"; const char* responseFlag = this->Makefile->GetDefinition(responseFlagVar); @@ -1707,7 +1708,8 @@ cmMakefileTargetGenerator // Lookup the response file reference flag. std::string responseFlagVar = "CMAKE_"; - responseFlagVar += this->Target->GetLinkerLanguage(this->ConfigName); + responseFlagVar += this->GeneratorTarget + ->GetLinkerLanguage(this->ConfigName); responseFlagVar += "_RESPONSE_FILE_LINK_FLAG"; const char* responseFlag = this->Makefile->GetDefinition(responseFlagVar); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 1835841..b855bea 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -40,8 +40,7 @@ cmNinjaNormalTargetGenerator(cmGeneratorTarget* target) , TargetNamePDB() , TargetLinkLanguage("") { - this->TargetLinkLanguage = target->Target - ->GetLinkerLanguage(this->GetConfigName()); + this->TargetLinkLanguage = target->GetLinkerLanguage(this->GetConfigName()); if (target->GetType() == cmTarget::EXECUTABLE) this->GetGeneratorTarget()->GetExecutableNames(this->TargetNameOut, this->TargetNameReal, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 37b788d..c7118dc 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3218,12 +3218,6 @@ private: }; //---------------------------------------------------------------------------- -std::string cmTarget::GetLinkerLanguage(const std::string& config) const -{ - return this->GetLinkClosure(config)->LinkerLanguage; -} - -//---------------------------------------------------------------------------- cmTarget::LinkClosure const* cmTarget::GetLinkClosure(const std::string& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index d0cbc66..dea9bef 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -365,9 +365,6 @@ public: void GetTargetVersion(bool soversion, int& major, int& minor, int& patch) const; - ///! Return the preferred linker language for this target - std::string GetLinkerLanguage(const std::string& config = "") const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 2b33c2c..80b8591 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1627,7 +1627,7 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( this->GlobalGenerator->GetLanguageFromExtension (sf.GetExtension().c_str()); std::string sourceLang = this->LocalGenerator->GetSourceFileLanguage(sf); - const std::string& linkLanguage = this->Target->GetLinkerLanguage(); + const std::string& linkLanguage = this->GeneratorTarget->GetLinkerLanguage(); bool needForceLang = false; // source file does not match its extension language if(lang != sourceLang) @@ -1888,7 +1888,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( std::string flags; const std::string& linkLanguage = - this->Target->GetLinkerLanguage(configName.c_str()); + this->GeneratorTarget->GetLinkerLanguage(configName.c_str()); if(linkLanguage.empty()) { cmSystemTools::Error @@ -2371,7 +2371,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) Options& linkOptions = *pOptions; const std::string& linkLanguage = - this->Target->GetLinkerLanguage(config.c_str()); + this->GeneratorTarget->GetLinkerLanguage(config.c_str()); if(linkLanguage.empty()) { cmSystemTools::Error http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=31b43bf4663f8612fa4e7ed01633deaa018961da commit 31b43bf4663f8612fa4e7ed01633deaa018961da Author: Stephen Kelly AuthorDate: Tue Oct 9 01:22:42 2012 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 09:44:05 2015 +0200 cmGeneratorTarget: Move GetFrameworkDirectory from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 436e5dd..834a2e3 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -904,6 +904,48 @@ cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config, + bool contentOnly) const +{ + std::string fpath; + fpath += this->Target->GetOutputName(config, false); + fpath += "."; + const char *ext = this->Target->GetProperty("BUNDLE_EXTENSION"); + if (!ext) + { + if (this->Target->IsXCTestOnApple()) + { + ext = "xctest"; + } + else + { + ext = "bundle"; + } + } + fpath += ext; + fpath += "/Contents"; + if(!contentOnly) + fpath += "/MacOS"; + return fpath; +} + +//---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetFrameworkDirectory(const std::string& config, + bool rootDir) const +{ + std::string fpath; + fpath += this->Target->GetOutputName(config, false); + fpath += ".framework"; + if(!rootDir) + { + fpath += "/Versions/"; + fpath += this->Target->GetFrameworkVersion(); + } + return fpath; +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetFullName(const std::string& config, bool implib) const { @@ -1007,11 +1049,11 @@ cmGeneratorTarget::BuildMacContentDirectory(const std::string& base, } if(this->Target->IsFrameworkOnApple()) { - fpath += this->Target->GetFrameworkDirectory(config, contentOnly); + fpath += this->GetFrameworkDirectory(config, contentOnly); } if(this->Target->IsCFBundleOnApple()) { - fpath += this->Target->GetCFBundleDirectory(config, contentOnly); + fpath += this->GetCFBundleDirectory(config, contentOnly); } return fpath; } @@ -1982,7 +2024,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, if(this->Target->IsCFBundleOnApple()) { - fw_prefix = this->Target->GetCFBundleDirectory(config, false); + fw_prefix = this->GetCFBundleDirectory(config, false); fw_prefix += "/"; targetPrefix = fw_prefix.c_str(); targetSuffix = 0; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 8ccd6d0..372bbe1 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -124,6 +124,14 @@ public: std::string GetFullName(const std::string& config="", bool implib = false) const; + /** @return the Mac framework directory without the base. */ + std::string GetFrameworkDirectory(const std::string& config, + bool rootDir) const; + + /** @return the Mac CFBundle directory without the base */ + std::string GetCFBundleDirectory(const std::string& config, + bool contentOnly) const; + /** Return the install name directory for the target in the * build tree. For example: "\@rpath/", "\@loader_path/", * or "/full/path/to/library". */ diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 1d85d9c..4fe99e3 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -77,11 +77,11 @@ void cmOSXBundleGenerator::CreateFramework( // Compute the location of the top-level foo.framework directory. std::string contentdir = outpath + "/" + - this->GT->Target->GetFrameworkDirectory(this->ConfigName, true); + this->GT->GetFrameworkDirectory(this->ConfigName, true); contentdir += "/"; std::string newoutpath = outpath + "/" + - this->GT->Target->GetFrameworkDirectory(this->ConfigName, false); + this->GT->GetFrameworkDirectory(this->ConfigName, false); std::string frameworkVersion = this->GT->Target->GetFrameworkVersion(); @@ -172,14 +172,14 @@ void cmOSXBundleGenerator::CreateCFBundle(const std::string& targetName, // Compute bundle directory names. std::string out = root; out += "/"; - out += this->GT->Target->GetCFBundleDirectory(this->ConfigName, false); + out += this->GT->GetCFBundleDirectory(this->ConfigName, false); cmSystemTools::MakeDirectory(out.c_str()); this->Makefile->AddCMakeOutputFile(out); // Configure the Info.plist file. Note that it needs the executable name // to be set. std::string plist = root + "/" + - this->GT->Target->GetCFBundleDirectory(this->ConfigName, true); + this->GT->GetCFBundleDirectory(this->ConfigName, true); plist += "/Info.plist"; std::string name = cmSystemTools::GetFilenameName(targetName); this->LocalGenerator->GenerateAppleInfoPList(this->GT->Target, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index a5ff829..37b788d 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -5126,47 +5126,6 @@ std::string cmTarget::CheckCMP0004(std::string const& item) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetFrameworkDirectory(const std::string& config, - bool rootDir) const -{ - std::string fpath; - fpath += this->GetOutputName(config, false); - fpath += ".framework"; - if(!rootDir) - { - fpath += "/Versions/"; - fpath += this->GetFrameworkVersion(); - } - return fpath; -} - -//---------------------------------------------------------------------------- -std::string cmTarget::GetCFBundleDirectory(const std::string& config, - bool contentOnly) const -{ - std::string fpath; - fpath += this->GetOutputName(config, false); - fpath += "."; - const char *ext = this->GetProperty("BUNDLE_EXTENSION"); - if (!ext) - { - if (this->IsXCTestOnApple()) - { - ext = "xctest"; - } - else - { - ext = "bundle"; - } - } - fpath += ext; - fpath += "/Contents"; - if(!contentOnly) - fpath += "/MacOS"; - return fpath; -} - -//---------------------------------------------------------------------------- cmTargetInternalPointer::cmTargetInternalPointer() { this->Pointer = new cmTargetInternals; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e22d3af..d0cbc66 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -460,14 +460,6 @@ public: /** @return whether this target have a well defined output file name. */ bool HaveWellDefinedOutputFiles() const; - /** @return the Mac framework directory without the base. */ - std::string GetFrameworkDirectory(const std::string& config, - bool rootDir) const; - - /** @return the Mac CFBundle directory without the base */ - std::string GetCFBundleDirectory(const std::string& config, - bool contentOnly) const; - std::vector GetIncludeDirectories( const std::string& config, const std::string& language) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9350e396795b07338169fda51189498b487fc324 commit 9350e396795b07338169fda51189498b487fc324 Author: Stephen Kelly AuthorDate: Tue Oct 9 19:01:39 2012 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 09:44:05 2015 +0200 cmGeneratorTarget: Move GetFullNameInternal from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index cdacfcb..436e5dd 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -663,7 +663,7 @@ cmGeneratorTarget::GetCompilePDBName(const std::string& config) const std::string prefix; std::string base; std::string suffix; - this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, false, prefix, base, suffix); // Check for a per-configuration output directory target property. std::string configUpper = cmSystemTools::UpperCase(config); @@ -905,6 +905,20 @@ cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, //---------------------------------------------------------------------------- std::string +cmGeneratorTarget::GetFullName(const std::string& config, bool implib) const +{ + if(this->Target->IsImported()) + { + return this->Target->GetFullNameImported(config, implib); + } + else + { + return this->GetFullNameInternal(config, implib); + } +} + +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetInstallNameDirForBuildTree( const std::string& config) const { @@ -977,7 +991,7 @@ void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, const std::string& config, bool implib) const { - this->Target->GetFullNameInternal(config, implib, prefix, base, suffix); + this->GetFullNameInternal(config, implib, prefix, base, suffix); } //---------------------------------------------------------------------------- @@ -1753,7 +1767,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, std::string prefix; std::string base; std::string suffix; - this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, false, prefix, base, suffix); // The library name. name = prefix+base+suffix; @@ -1782,7 +1796,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, if(this->GetType() == cmTarget::SHARED_LIBRARY || this->GetType() == cmTarget::MODULE_LIBRARY) { - impName = this->Target->GetFullNameInternal(config, true); + impName = this->GetFullNameInternal(config, true); } else { @@ -1828,7 +1842,7 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, std::string prefix; std::string base; std::string suffix; - this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, false, prefix, base, suffix); // The executable name. name = prefix+base+suffix; @@ -1849,19 +1863,163 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, #endif // The import library name. - impName = this->Target->GetFullNameInternal(config, true); + impName = this->GetFullNameInternal(config, true); // The program database file name. pdbName = this->GetPDBName(config); } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetFullNameInternal(const std::string& config, + bool implib) const +{ + std::string prefix; + std::string base; + std::string suffix; + this->GetFullNameInternal(config, implib, prefix, base, suffix); + return prefix+base+suffix; +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GetFullNameInternal(const std::string& config, + bool implib, + std::string& outPrefix, + std::string& outBase, + std::string& outSuffix) const +{ + // Use just the target name for non-main target types. + if(this->GetType() != cmTarget::STATIC_LIBRARY && + this->GetType() != cmTarget::SHARED_LIBRARY && + this->GetType() != cmTarget::MODULE_LIBRARY && + this->GetType() != cmTarget::EXECUTABLE) + { + outPrefix = ""; + outBase = this->GetName(); + outSuffix = ""; + return; + } + + // Return an empty name for the import library if this platform + // does not support import libraries. + if(implib && + !this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) + { + outPrefix = ""; + outBase = ""; + outSuffix = ""; + return; + } + + // The implib option is only allowed for shared libraries, module + // libraries, and executables. + if(this->GetType() != cmTarget::SHARED_LIBRARY && + this->GetType() != cmTarget::MODULE_LIBRARY && + this->GetType() != cmTarget::EXECUTABLE) + { + implib = false; + } + + // Compute the full name for main target types. + const char* targetPrefix = (implib + ? this->GetProperty("IMPORT_PREFIX") + : this->GetProperty("PREFIX")); + const char* targetSuffix = (implib + ? this->GetProperty("IMPORT_SUFFIX") + : this->GetProperty("SUFFIX")); + const char* configPostfix = 0; + if(!config.empty()) + { + std::string configProp = cmSystemTools::UpperCase(config); + configProp += "_POSTFIX"; + configPostfix = this->GetProperty(configProp); + // Mac application bundles and frameworks have no postfix. + if(configPostfix && + (this->Target->IsAppBundleOnApple() + || this->Target->IsFrameworkOnApple())) + { + configPostfix = 0; + } + } + const char* prefixVar = this->Target->GetPrefixVariableInternal(implib); + const char* suffixVar = this->Target->GetSuffixVariableInternal(implib); + + // Check for language-specific default prefix and suffix. + std::string ll = this->Target->GetLinkerLanguage(config); + if(!ll.empty()) + { + if(!targetSuffix && suffixVar && *suffixVar) + { + std::string langSuff = suffixVar + std::string("_") + ll; + targetSuffix = this->Makefile->GetDefinition(langSuff); + } + if(!targetPrefix && prefixVar && *prefixVar) + { + std::string langPrefix = prefixVar + std::string("_") + ll; + targetPrefix = this->Makefile->GetDefinition(langPrefix); + } + } + + // if there is no prefix on the target use the cmake definition + if(!targetPrefix && prefixVar) + { + targetPrefix = this->Makefile->GetSafeDefinition(prefixVar); + } + // if there is no suffix on the target use the cmake definition + if(!targetSuffix && suffixVar) + { + targetSuffix = this->Makefile->GetSafeDefinition(suffixVar); + } + + // frameworks have directory prefix but no suffix + std::string fw_prefix; + if(this->Target->IsFrameworkOnApple()) + { + fw_prefix = this->Target->GetOutputName(config, false); + fw_prefix += ".framework/"; + targetPrefix = fw_prefix.c_str(); + targetSuffix = 0; + } + + if(this->Target->IsCFBundleOnApple()) + { + fw_prefix = this->Target->GetCFBundleDirectory(config, false); + fw_prefix += "/"; + targetPrefix = fw_prefix.c_str(); + targetSuffix = 0; + } + + // Begin the final name with the prefix. + outPrefix = targetPrefix?targetPrefix:""; + + // Append the target name or property-specified name. + outBase += this->Target->GetOutputName(config, implib); + + // Append the per-configuration postfix. + outBase += configPostfix?configPostfix:""; + + // Name shared libraries with their version number on some platforms. + if(const char* soversion = this->GetProperty("SOVERSION")) + { + if(this->GetType() == cmTarget::SHARED_LIBRARY && !implib && + this->Makefile->IsOn("CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION")) + { + outBase += "-"; + outBase += soversion; + } + } + + // Append the suffix. + outSuffix = targetSuffix?targetSuffix:""; +} + + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetPDBName(const std::string& config) const { std::string prefix; std::string base; std::string suffix; - this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, false, prefix, base, suffix); std::vector props; std::string configUpper = diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index d0d6709..8ccd6d0 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -284,6 +284,11 @@ private: mutable std::map DebugCompatiblePropertiesDone; + std::string GetFullNameInternal(const std::string& config, bool implib) const; + void GetFullNameInternal(const std::string& config, bool implib, + std::string& outPrefix, std::string& outBase, + std::string& outSuffix) const; + struct CompatibleInterfacesBase { std::set PropsBool; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index c484417..a5ff829 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3612,148 +3612,6 @@ cmTarget::ImportedGetFullPath(const std::string& config, bool implib) const } //---------------------------------------------------------------------------- -std::string -cmTarget::GetFullNameInternal(const std::string& config, bool implib) const -{ - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, implib, prefix, base, suffix); - return prefix+base+suffix; -} - -//---------------------------------------------------------------------------- -void cmTarget::GetFullNameInternal(const std::string& config, - bool implib, - std::string& outPrefix, - std::string& outBase, - std::string& outSuffix) const -{ - // Use just the target name for non-main target types. - if(this->GetType() != cmTarget::STATIC_LIBRARY && - this->GetType() != cmTarget::SHARED_LIBRARY && - this->GetType() != cmTarget::MODULE_LIBRARY && - this->GetType() != cmTarget::EXECUTABLE) - { - outPrefix = ""; - outBase = this->GetName(); - outSuffix = ""; - return; - } - - // Return an empty name for the import library if this platform - // does not support import libraries. - if(implib && - !this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) - { - outPrefix = ""; - outBase = ""; - outSuffix = ""; - return; - } - - // The implib option is only allowed for shared libraries, module - // libraries, and executables. - if(this->GetType() != cmTarget::SHARED_LIBRARY && - this->GetType() != cmTarget::MODULE_LIBRARY && - this->GetType() != cmTarget::EXECUTABLE) - { - implib = false; - } - - // Compute the full name for main target types. - const char* targetPrefix = (implib - ? this->GetProperty("IMPORT_PREFIX") - : this->GetProperty("PREFIX")); - const char* targetSuffix = (implib - ? this->GetProperty("IMPORT_SUFFIX") - : this->GetProperty("SUFFIX")); - const char* configPostfix = 0; - if(!config.empty()) - { - std::string configProp = cmSystemTools::UpperCase(config); - configProp += "_POSTFIX"; - configPostfix = this->GetProperty(configProp); - // Mac application bundles and frameworks have no postfix. - if(configPostfix && - (this->IsAppBundleOnApple() || this->IsFrameworkOnApple())) - { - configPostfix = 0; - } - } - const char* prefixVar = this->GetPrefixVariableInternal(implib); - const char* suffixVar = this->GetSuffixVariableInternal(implib); - - // Check for language-specific default prefix and suffix. - std::string ll = this->GetLinkerLanguage(config); - if(!ll.empty()) - { - if(!targetSuffix && suffixVar && *suffixVar) - { - std::string langSuff = suffixVar + std::string("_") + ll; - targetSuffix = this->Makefile->GetDefinition(langSuff); - } - if(!targetPrefix && prefixVar && *prefixVar) - { - std::string langPrefix = prefixVar + std::string("_") + ll; - targetPrefix = this->Makefile->GetDefinition(langPrefix); - } - } - - // if there is no prefix on the target use the cmake definition - if(!targetPrefix && prefixVar) - { - targetPrefix = this->Makefile->GetSafeDefinition(prefixVar); - } - // if there is no suffix on the target use the cmake definition - if(!targetSuffix && suffixVar) - { - targetSuffix = this->Makefile->GetSafeDefinition(suffixVar); - } - - // frameworks have directory prefix but no suffix - std::string fw_prefix; - if(this->IsFrameworkOnApple()) - { - fw_prefix = this->GetOutputName(config, false); - fw_prefix += ".framework/"; - targetPrefix = fw_prefix.c_str(); - targetSuffix = 0; - } - - if(this->IsCFBundleOnApple()) - { - fw_prefix = this->GetCFBundleDirectory(config, false); - fw_prefix += "/"; - targetPrefix = fw_prefix.c_str(); - targetSuffix = 0; - } - - // Begin the final name with the prefix. - outPrefix = targetPrefix?targetPrefix:""; - - // Append the target name or property-specified name. - outBase += this->GetOutputName(config, implib); - - // Append the per-configuration postfix. - outBase += configPostfix?configPostfix:""; - - // Name shared libraries with their version number on some platforms. - if(const char* soversion = this->GetProperty("SOVERSION")) - { - if(this->GetType() == cmTarget::SHARED_LIBRARY && !implib && - this->Makefile->IsOn("CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION")) - { - outBase += "-"; - outBase += soversion; - } - } - - // Append the suffix. - outSuffix = targetSuffix?targetSuffix:""; -} - -//---------------------------------------------------------------------------- void cmTarget::ComputeVersionedName(std::string& vName, std::string const& prefix, std::string const& base, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 633e0ee..e22d3af 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -570,11 +570,6 @@ private: const char* GetSuffixVariableInternal(bool implib) const; const char* GetPrefixVariableInternal(bool implib) const; - std::string GetFullNameInternal(const std::string& config, - bool implib) const; - void GetFullNameInternal(const std::string& config, bool implib, - std::string& outPrefix, std::string& outBase, - std::string& outSuffix) const; // Use a makefile variable to set a default for the given property. // If the variable is not defined use the given default instead. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=627d9c0530e161807959550ddf3dae7cc1f605dd commit 627d9c0530e161807959550ddf3dae7cc1f605dd Author: Stephen Kelly AuthorDate: Tue Oct 9 01:26:16 2012 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 09:44:05 2015 +0200 cmGeneratorTarget: Move GetFullName from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 0fdf646..cdacfcb 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -576,7 +576,7 @@ const char* cmGeneratorTarget::GetLocationForBuild() const } } location += "/"; - location += this->Target->GetFullName("", false); + location += this->GetFullName("", false); return location.c_str(); } @@ -896,7 +896,7 @@ std::string cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, bool contentOnly) const { - std::string fpath = this->Target->GetFullName(config, false); + std::string fpath = this->GetFullName(config, false); fpath += ".app/Contents"; if(!contentOnly) fpath += "/MacOS"; @@ -1655,7 +1655,7 @@ std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config, // Add the full name of the target. if(implib) { - fpath += this->Target->GetFullName(config, true); + fpath += this->GetFullName(config, true); } else if(realname) { @@ -1663,7 +1663,7 @@ std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config, } else { - fpath += this->Target->GetFullName(config, false); + fpath += this->GetFullName(config, false); } return fpath; } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index f0d8c60..d0d6709 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -119,6 +119,11 @@ public: std::string GetAppBundleDirectory(const std::string& config, bool contentOnly) const; + /** Get the full name of the target according to the settings in its + makefile. */ + std::string GetFullName(const std::string& config="", + bool implib = false) const; + /** Return the install name directory for the target in the * build tree. For example: "\@rpath/", "\@loader_path/", * or "/full/path/to/library". */ diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index d53ecde..7b0e153 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2742,7 +2742,8 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget, } else { - fullName = cmtarget.GetFullName(defConfig.c_str()); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&cmtarget); + fullName = gtgt->GetFullName(defConfig.c_str()); } fileRef->AddAttribute("path", this->CreateString(fullName.c_str())); fileRef->AddAttribute("refType", this->CreateString("0")); @@ -3688,7 +3689,7 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( std::string universalFile = universal; universalFile += *arch; universalFile += "/"; - universalFile += t->GetFullName(configName); + universalFile += gt->GetFullName(configName); makefileStream << "\t/bin/rm -f " << this->ConvertToRelativeForMake(universalFile.c_str()) diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 61d7847..94457bb 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1112,7 +1112,8 @@ void cmLocalVisualStudio6Generator // Compute the proper name to use to link this library. std::string lib; std::string libDebug; - cmTarget* tgt = this->GlobalGenerator->FindTarget(j->first.c_str()); + cmGeneratorTarget* tgt = this->GlobalGenerator->GetGeneratorTarget( + this->GlobalGenerator->FindTarget(j->first.c_str())); if(tgt) { lib = cmSystemTools::GetFilenameWithoutExtension @@ -1328,11 +1329,11 @@ void cmLocalVisualStudio6Generator target.GetType() == cmTarget::SHARED_LIBRARY || target.GetType() == cmTarget::MODULE_LIBRARY) { - outputName = target.GetFullName(); - outputNameDebug = target.GetFullName("Debug"); - outputNameRelease = target.GetFullName("Release"); - outputNameMinSizeRel = target.GetFullName("MinSizeRel"); - outputNameRelWithDebInfo = target.GetFullName("RelWithDebInfo"); + outputName = gt->GetFullName(); + outputNameDebug = gt->GetFullName("Debug"); + outputNameRelease = gt->GetFullName("Release"); + outputNameMinSizeRel = gt->GetFullName("MinSizeRel"); + outputNameRelWithDebInfo = gt->GetFullName("RelWithDebInfo"); } else if(target.GetType() == cmTarget::OBJECT_LIBRARY) { @@ -1429,10 +1430,10 @@ void cmLocalVisualStudio6Generator fullPathImpRelease += "/"; fullPathImpMinSizeRel += "/"; fullPathImpRelWithDebInfo += "/"; - fullPathImpDebug += target.GetFullName("Debug", true); - fullPathImpRelease += target.GetFullName("Release", true); - fullPathImpMinSizeRel += target.GetFullName("MinSizeRel", true); - fullPathImpRelWithDebInfo += target.GetFullName("RelWithDebInfo", true); + fullPathImpDebug += gt->GetFullName("Debug", true); + fullPathImpRelease += gt->GetFullName("Release", true); + fullPathImpMinSizeRel += gt->GetFullName("MinSizeRel", true); + fullPathImpRelWithDebInfo += gt->GetFullName("RelWithDebInfo", true); targetImplibFlagDebug = "/implib:"; targetImplibFlagRelease = "/implib:"; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 724f575..99c6829 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -803,7 +803,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, if (this->FortranProject) { // Intel Fortran >= 15.0 uses TargetName property. - std::string targetNameFull = target.GetFullName(configName); + std::string targetNameFull = gt->GetFullName(configName); std::string targetName = cmSystemTools::GetFilenameWithoutLastExtension(targetNameFull); std::string targetExt = @@ -1074,6 +1074,9 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, this->ConvertToOutputFormat(this->ModuleDefinitionFile, SHELL); linkOptions.AddFlag("ModuleDefinitionFile", defFile.c_str()); } + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); + if (target.GetType() == cmTarget::SHARED_LIBRARY && this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) { @@ -1104,7 +1107,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, } case cmTarget::STATIC_LIBRARY: { - std::string targetNameFull = target.GetFullName(configName); + std::string targetNameFull = gt->GetFullName(configName); std::string libpath = target.GetDirectory(configName); libpath += "/"; libpath += targetNameFull; @@ -1148,8 +1151,6 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, targetNameImport, targetNamePDB, configName); // Compute the link library and directory information. - cmGeneratorTarget* gt = - this->GlobalGenerator->GetGeneratorTarget(&target); cmComputeLinkInformation* pcli = gt->GetLinkInformation(configName); if(!pcli) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e8ef770..c484417 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3587,20 +3587,6 @@ bool cmTarget::IsImportedSharedLibWithoutSOName( } //---------------------------------------------------------------------------- -std::string cmTarget::GetFullName(const std::string& config, - bool implib) const -{ - if(this->IsImported()) - { - return this->GetFullNameImported(config, implib); - } - else - { - return this->GetFullNameInternal(config, implib); - } -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetFullNameImported(const std::string& config, bool implib) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 4b804da..633e0ee 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -368,11 +368,6 @@ public: ///! Return the preferred linker language for this target std::string GetLinkerLanguage(const std::string& config = "") const; - /** Get the full name of the target according to the settings in its - makefile. */ - std::string GetFullName(const std::string& config="", - bool implib = false) const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 16edf3c..2b33c2c 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1774,7 +1774,7 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions() else { outDir = this->Target->GetDirectory(config->c_str()) + "/"; - targetNameFull = this->Target->GetFullName(config->c_str()); + targetNameFull = this->GeneratorTarget->GetFullName(config->c_str()); } this->ConvertToWindowsSlash(intermediateDir); this->ConvertToWindowsSlash(outDir); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d1f71f9c85a2cf86945baa1747de5c2756637070 commit d1f71f9c85a2cf86945baa1747de5c2756637070 Author: Stephen Kelly AuthorDate: Tue Jul 28 22:44:00 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 09:44:02 2015 +0200 cmGeneratorTarget: Move GetAppBundleDirectory from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 2de3c77..0fdf646 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -890,6 +890,19 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const } } + +//---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, + bool contentOnly) const +{ + std::string fpath = this->Target->GetFullName(config, false); + fpath += ".app/Contents"; + if(!contentOnly) + fpath += "/MacOS"; + return fpath; +} + //---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetInstallNameDirForBuildTree( @@ -976,7 +989,7 @@ cmGeneratorTarget::BuildMacContentDirectory(const std::string& base, std::string fpath = base; if(this->Target->IsAppBundleOnApple()) { - fpath += this->Target->GetAppBundleDirectory(config, contentOnly); + fpath += this->GetAppBundleDirectory(config, contentOnly); } if(this->Target->IsFrameworkOnApple()) { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 6d084f7..f0d8c60 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -115,6 +115,10 @@ public: bool realname) const; std::string NormalGetRealName(const std::string& config) const; + /** @return the Mac App directory without the base */ + std::string GetAppBundleDirectory(const std::string& config, + bool contentOnly) const; + /** Return the install name directory for the target in the * build tree. For example: "\@rpath/", "\@loader_path/", * or "/full/path/to/library". */ diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 7df2f78..1d85d9c 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -47,7 +47,7 @@ void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName, // Compute bundle directory names. std::string out = outpath; out += "/"; - out += this->GT->Target->GetAppBundleDirectory(this->ConfigName, false); + out += this->GT->GetAppBundleDirectory(this->ConfigName, false); cmSystemTools::MakeDirectory(out.c_str()); this->Makefile->AddCMakeOutputFile(out); @@ -57,7 +57,7 @@ void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName, // to be set. std::string plist = outpath; plist += "/"; - plist += this->GT->Target->GetAppBundleDirectory(this->ConfigName, true); + plist += this->GT->GetAppBundleDirectory(this->ConfigName, true); plist += "/Info.plist"; this->LocalGenerator->GenerateAppleInfoPList(this->GT->Target, targetName, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index b49ad9b..e8ef770 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -5323,17 +5323,6 @@ std::string cmTarget::GetCFBundleDirectory(const std::string& config, } //---------------------------------------------------------------------------- -std::string cmTarget::GetAppBundleDirectory(const std::string& config, - bool contentOnly) const -{ - std::string fpath = this->GetFullName(config, false); - fpath += ".app/Contents"; - if(!contentOnly) - fpath += "/MacOS"; - return fpath; -} - -//---------------------------------------------------------------------------- cmTargetInternalPointer::cmTargetInternalPointer() { this->Pointer = new cmTargetInternals; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index c1c518f..4b804da 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -473,10 +473,6 @@ public: std::string GetCFBundleDirectory(const std::string& config, bool contentOnly) const; - /** @return the Mac App directory without the base */ - std::string GetAppBundleDirectory(const std::string& config, - bool contentOnly) const; - std::vector GetIncludeDirectories( const std::string& config, const std::string& language) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f39ec367a96d93f2a0117c7b61df30a54fbc3fc2 commit f39ec367a96d93f2a0117c7b61df30a54fbc3fc2 Author: Stephen Kelly AuthorDate: Tue Oct 9 01:20:27 2012 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 09:43:31 2015 +0200 cmGeneratorTarget: Move GetInstallNameDir* from cmTarget. diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 6274c3f..fed0dbc 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -333,12 +333,12 @@ cmExportBuildFileGenerator } std::string -cmExportBuildFileGenerator::InstallNameDir(cmTarget* target, +cmExportBuildFileGenerator::InstallNameDir(cmGeneratorTarget* target, const std::string& config) { std::string install_name_dir; - cmMakefile* mf = target->GetMakefile(); + cmMakefile* mf = target->Target->GetMakefile(); if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { install_name_dir = diff --git a/Source/cmExportBuildFileGenerator.h b/Source/cmExportBuildFileGenerator.h index 4d8e062..ff3d2e1 100644 --- a/Source/cmExportBuildFileGenerator.h +++ b/Source/cmExportBuildFileGenerator.h @@ -71,7 +71,8 @@ protected: cmGeneratorTarget* target, ImportPropertyMap& properties); - std::string InstallNameDir(cmTarget* target, const std::string& config); + std::string InstallNameDir(cmGeneratorTarget* target, + const std::string& config); std::vector FindNamespaces(cmMakefile* mf, const std::string& name); diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index e3652c5..cae60b7 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -893,7 +893,7 @@ cmExportFileGenerator { if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { - value = this->InstallNameDir(target->Target, config); + value = this->InstallNameDir(target, config); } prop = "IMPORTED_SONAME"; value += target->GetSOName(config); diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index 4e54740..44f779b 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -200,7 +200,7 @@ private: virtual void ReplaceInstallPrefix(std::string &input); - virtual std::string InstallNameDir(cmTarget* target, + virtual std::string InstallNameDir(cmGeneratorTarget* target, const std::string& config) = 0; }; diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index b0bc686..d55be11 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -546,12 +546,12 @@ cmExportInstallFileGenerator } std::string -cmExportInstallFileGenerator::InstallNameDir(cmTarget* target, +cmExportInstallFileGenerator::InstallNameDir(cmGeneratorTarget* target, const std::string&) { std::string install_name_dir; - cmMakefile* mf = target->GetMakefile(); + cmMakefile* mf = target->Target->GetMakefile(); if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { install_name_dir = diff --git a/Source/cmExportInstallFileGenerator.h b/Source/cmExportInstallFileGenerator.h index 6f86ac9..b06fee5 100644 --- a/Source/cmExportInstallFileGenerator.h +++ b/Source/cmExportInstallFileGenerator.h @@ -83,7 +83,8 @@ protected: std::set& importedLocations ); - std::string InstallNameDir(cmTarget* target, const std::string& config); + std::string InstallNameDir(cmGeneratorTarget* target, + const std::string& config); cmInstallExportGenerator* IEGen; diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx index 94831f8..ba66531 100644 --- a/Source/cmExportTryCompileFileGenerator.cxx +++ b/Source/cmExportTryCompileFileGenerator.cxx @@ -125,12 +125,12 @@ cmExportTryCompileFileGenerator::PopulateProperties(cmTarget const* target, } std::string -cmExportTryCompileFileGenerator::InstallNameDir(cmTarget* target, +cmExportTryCompileFileGenerator::InstallNameDir(cmGeneratorTarget* target, const std::string& config) { std::string install_name_dir; - cmMakefile* mf = target->GetMakefile(); + cmMakefile* mf = target->Target->GetMakefile(); if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { install_name_dir = diff --git a/Source/cmExportTryCompileFileGenerator.h b/Source/cmExportTryCompileFileGenerator.h index 749f3ef..8838eca 100644 --- a/Source/cmExportTryCompileFileGenerator.h +++ b/Source/cmExportTryCompileFileGenerator.h @@ -45,7 +45,7 @@ protected: ImportPropertyMap& properties, std::set &emitted); - std::string InstallNameDir(cmTarget* target, + std::string InstallNameDir(cmGeneratorTarget* target, const std::string& config); private: std::string FindTargets(const std::string& prop, cmTarget const* tgt, diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 45577e5..2de3c77 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -891,6 +891,73 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const } //---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetInstallNameDirForBuildTree( + const std::string& config) const +{ + // If building directly for installation then the build tree install_name + // is the same as the install tree. + if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) + { + return this->GetInstallNameDirForInstallTree(); + } + + // Use the build tree directory for the target. + if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME") && + !this->Makefile->IsOn("CMAKE_SKIP_RPATH") && + !this->GetPropertyAsBool("SKIP_BUILD_RPATH")) + { + std::string dir; + if(this->Target->MacOSXRpathInstallNameDirDefault()) + { + dir = "@rpath"; + } + else + { + dir = this->Target->GetDirectory(config); + } + dir += "/"; + return dir; + } + else + { + return ""; + } +} + +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetInstallNameDirForInstallTree() const +{ + if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) + { + std::string dir; + const char* install_name_dir = this->GetProperty("INSTALL_NAME_DIR"); + + if(!this->Makefile->IsOn("CMAKE_SKIP_RPATH") && + !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH")) + { + if(install_name_dir && *install_name_dir) + { + dir = install_name_dir; + dir += "/"; + } + } + if(!install_name_dir) + { + if(this->Target->MacOSXRpathInstallNameDirDefault()) + { + dir = "@rpath/"; + } + } + return dir; + } + else + { + return ""; + } +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, std::string& base, std::string& suffix, diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 8fc1b44..6d084f7 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -115,6 +115,15 @@ public: bool realname) const; std::string NormalGetRealName(const std::string& config) const; + /** Return the install name directory for the target in the + * build tree. For example: "\@rpath/", "\@loader_path/", + * or "/full/path/to/library". */ + std::string GetInstallNameDirForBuildTree(const std::string& config) const; + + /** Return the install name directory for the target in the + * install tree. For example: "\@rpath/" or "\@loader_path/". */ + std::string GetInstallNameDirForInstallTree() const; + /** Get the soname of the target. Allowed only for a shared library. */ std::string GetSOName(const std::string& config) const; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 03f6d8f..d53ecde 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2331,7 +2331,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, if(target.GetType() == cmTarget::SHARED_LIBRARY) { // Get the install_name directory for the build tree. - install_name_dir = target.GetInstallNameDirForBuildTree(configName); + install_name_dir = gtgt->GetInstallNameDirForBuildTree(configName); // Xcode doesn't create the correct install_name in some cases. // That is, if the INSTALL_PATH is empty, or if we have versioning // of dylib libraries, we want to specify the install_name. diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 24c1c49..30cf175 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -576,11 +576,14 @@ cmInstallTargetGenerator continue; } + cmGeneratorTarget *gtgt = tgt->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(tgt); // If the build tree and install tree use different path // components of the install_name field then we need to create a // mapping to be applied after installation. - std::string for_build = tgt->GetInstallNameDirForBuildTree(config); - std::string for_install = tgt->GetInstallNameDirForInstallTree(); + std::string for_build = gtgt->GetInstallNameDirForBuildTree(config); + std::string for_install = gtgt->GetInstallNameDirForInstallTree(); if(for_build != for_install) { // The directory portions differ. Append the filename to @@ -605,9 +608,9 @@ cmInstallTargetGenerator if(this->Target->GetType() == cmTarget::SHARED_LIBRARY) { std::string for_build = - this->Target->Target->GetInstallNameDirForBuildTree(config); + this->Target->GetInstallNameDirForBuildTree(config); std::string for_install = - this->Target->Target->GetInstallNameDirForInstallTree(); + this->Target->GetInstallNameDirForInstallTree(); if(this->Target->Target->IsFrameworkOnApple() && for_install.empty()) { diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index a2fcbad..b85b8a8 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -666,7 +666,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules { // Get the install_name directory for the build tree. install_name_dir = - this->Target->GetInstallNameDirForBuildTree(this->ConfigName); + this->GeneratorTarget->GetInstallNameDirForBuildTree(this->ConfigName); // Set the rule variable replacement value. if(install_name_dir.empty()) diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index c80f485..1835841 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -537,7 +537,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() vars["SONAME"] = this->TargetNameSO; if (targetType == cmTarget::SHARED_LIBRARY) { - std::string install_dir = target.GetInstallNameDirForBuildTree(cfgName); + std::string install_dir = + this->GetGeneratorTarget()->GetInstallNameDirForBuildTree(cfgName); if (!install_dir.empty()) { vars["INSTALLNAME_DIR"] = localGen.Convert(install_dir, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 0f1d309..b49ad9b 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3846,73 +3846,6 @@ bool cmTarget::HaveInstallTreeRPATH() const } //---------------------------------------------------------------------------- -std::string cmTarget::GetInstallNameDirForBuildTree( - const std::string& config) const -{ - // If building directly for installation then the build tree install_name - // is the same as the install tree. - if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) - { - return GetInstallNameDirForInstallTree(); - } - - // Use the build tree directory for the target. - if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME") && - !this->Makefile->IsOn("CMAKE_SKIP_RPATH") && - !this->GetPropertyAsBool("SKIP_BUILD_RPATH")) - { - std::string dir; - bool macosx_rpath = this->MacOSXRpathInstallNameDirDefault(); - if(macosx_rpath) - { - dir = "@rpath"; - } - else - { - dir = this->GetDirectory(config); - } - dir += "/"; - return dir; - } - else - { - return ""; - } -} - -//---------------------------------------------------------------------------- -std::string cmTarget::GetInstallNameDirForInstallTree() const -{ - if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) - { - std::string dir; - const char* install_name_dir = this->GetProperty("INSTALL_NAME_DIR"); - - if(!this->Makefile->IsOn("CMAKE_SKIP_RPATH") && - !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH")) - { - if(install_name_dir && *install_name_dir) - { - dir = install_name_dir; - dir += "/"; - } - } - if(!install_name_dir) - { - if(this->MacOSXRpathInstallNameDirDefault()) - { - dir = "@rpath/"; - } - } - return dir; - } - else - { - return ""; - } -} - -//---------------------------------------------------------------------------- const char* cmTarget::GetOutputTargetType(bool implib) const { switch(this->GetType()) diff --git a/Source/cmTarget.h b/Source/cmTarget.h index d03ba3b..c1c518f 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -394,15 +394,6 @@ public: bool HaveBuildTreeRPATH(const std::string& config) const; bool HaveInstallTreeRPATH() const; - /** Return the install name directory for the target in the - * build tree. For example: "\@rpath/", "\@loader_path/", - * or "/full/path/to/library". */ - std::string GetInstallNameDirForBuildTree(const std::string& config) const; - - /** Return the install name directory for the target in the - * install tree. For example: "\@rpath/" or "\@loader_path/". */ - std::string GetInstallNameDirForInstallTree() const; - // Get the properties cmPropertyMap &GetProperties() const { return this->Properties; } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2a843615a947e0b8455b7da5fdd2ed7a609fb8f2 commit 2a843615a947e0b8455b7da5fdd2ed7a609fb8f2 Author: Stephen Kelly AuthorDate: Tue Oct 9 01:13:20 2012 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 09:43:28 2015 +0200 cmGeneratorTarget: Move GetMacContentDirectory from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 4be034f..45577e5 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -567,7 +567,7 @@ const char* cmGeneratorTarget::GetLocationForBuild() const if(this->Target->IsAppBundleOnApple()) { - std::string macdir = this->Target->BuildMacContentDirectory("", "", + std::string macdir = this->BuildMacContentDirectory("", "", false); if(!macdir.empty()) { @@ -902,6 +902,47 @@ void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, //---------------------------------------------------------------------------- std::string +cmGeneratorTarget::BuildMacContentDirectory(const std::string& base, + const std::string& config, + bool contentOnly) const +{ + std::string fpath = base; + if(this->Target->IsAppBundleOnApple()) + { + fpath += this->Target->GetAppBundleDirectory(config, contentOnly); + } + if(this->Target->IsFrameworkOnApple()) + { + fpath += this->Target->GetFrameworkDirectory(config, contentOnly); + } + if(this->Target->IsCFBundleOnApple()) + { + fpath += this->Target->GetCFBundleDirectory(config, contentOnly); + } + return fpath; +} + +//---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetMacContentDirectory(const std::string& config, + bool implib) const +{ + // Start with the output directory for the target. + std::string fpath = this->Target->GetDirectory(config, implib); + fpath += "/"; + bool contentOnly = true; + if(this->Target->IsFrameworkOnApple()) + { + // additional files with a framework go into the version specific + // directory + contentOnly = false; + } + fpath = this->BuildMacContentDirectory(fpath, config, contentOnly); + return fpath; +} + +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetModuleDefinitionFile(const std::string& config) const { std::string data; @@ -1527,7 +1568,7 @@ std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config, fpath += "/"; if(this->Target->IsAppBundleOnApple()) { - fpath = this->Target->BuildMacContentDirectory(fpath, config, false); + fpath = this->BuildMacContentDirectory(fpath, config, false); fpath += "/"; } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index f96adad..8fc1b44 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -123,6 +123,15 @@ public: const std::string& config="", bool implib = false) const; + /** Append to @a base the mac content directory and return it. */ + std::string BuildMacContentDirectory(const std::string& base, + const std::string& config = "", + bool contentOnly = true) const; + + /** @return the mac content directory for this target. */ + std::string GetMacContentDirectory(const std::string& config = 0, + bool implib = false) const; + cmTarget* Target; cmMakefile* Makefile; cmLocalGenerator* LocalGenerator; diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 3bc0eb7..7df2f78 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -217,7 +217,7 @@ cmOSXBundleGenerator::InitMacOSXContentDirectory(const char* pkgloc) // Construct the full path to the content subdirectory. std::string macdir = - this->GT->Target->GetMacContentDirectory(this->ConfigName, + this->GT->GetMacContentDirectory(this->ConfigName, /*implib*/ false); macdir += "/"; macdir += pkgloc; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 0d9aa49..0f1d309 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -5401,45 +5401,6 @@ std::string cmTarget::GetAppBundleDirectory(const std::string& config, } //---------------------------------------------------------------------------- -std::string cmTarget::BuildMacContentDirectory(const std::string& base, - const std::string& config, - bool contentOnly) const -{ - std::string fpath = base; - if(this->IsAppBundleOnApple()) - { - fpath += this->GetAppBundleDirectory(config, contentOnly); - } - if(this->IsFrameworkOnApple()) - { - fpath += this->GetFrameworkDirectory(config, contentOnly); - } - if(this->IsCFBundleOnApple()) - { - fpath += this->GetCFBundleDirectory(config, contentOnly); - } - return fpath; -} - -//---------------------------------------------------------------------------- -std::string cmTarget::GetMacContentDirectory(const std::string& config, - bool implib) const -{ - // Start with the output directory for the target. - std::string fpath = this->GetDirectory(config, implib); - fpath += "/"; - bool contentOnly = true; - if(this->IsFrameworkOnApple()) - { - // additional files with a framework go into the version specific - // directory - contentOnly = false; - } - fpath = this->BuildMacContentDirectory(fpath, config, contentOnly); - return fpath; -} - -//---------------------------------------------------------------------------- cmTargetInternalPointer::cmTargetInternalPointer() { this->Pointer = new cmTargetInternals; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 9962fdb..d03ba3b 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -471,10 +471,6 @@ public: directory. */ bool UsesDefaultOutputDir(const std::string& config, bool implib) const; - /** @return the mac content directory for this target. */ - std::string GetMacContentDirectory(const std::string& config, - bool implib) const; - /** @return whether this target have a well defined output file name. */ bool HaveWellDefinedOutputFiles() const; @@ -615,10 +611,6 @@ private: std::string ImportedGetFullPath(const std::string& config, bool implib) const; - /** Append to @a base the mac content directory and return it. */ - std::string BuildMacContentDirectory(const std::string& base, - const std::string& config, - bool contentOnly) const; void GetSourceFiles(std::vector &files, const std::string& config) const; ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From steveire at gmail.com Sat Aug 1 03:50:38 2015 From: steveire at gmail.com (Stephen Kelly) Date: Sat, 1 Aug 2015 03:50:38 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1729-g245e10c Message-ID: <20150801075038.9AD54B0CF2@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 245e10c1674df5d8a7a0adce2660f1e934455a93 (commit) via aad914b0157e07ae75c7b95cd3056c6ee52249ca (commit) from 348c91d7cced1089b349cf91eee7afaf967e45e6 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=245e10c1674df5d8a7a0adce2660f1e934455a93 commit 245e10c1674df5d8a7a0adce2660f1e934455a93 Merge: 348c91d aad914b Author: Stephen Kelly AuthorDate: Sat Aug 1 03:50:38 2015 -0400 Commit: CMake Topic Stage CommitDate: Sat Aug 1 03:50:38 2015 -0400 Merge topic 'use-generator-target' into next aad914b0 cmOrderDirectories: Port to cmGeneratorTarget. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=aad914b0157e07ae75c7b95cd3056c6ee52249ca commit aad914b0157e07ae75c7b95cd3056c6ee52249ca Author: Stephen Kelly AuthorDate: Sat Aug 1 09:48:04 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 09:48:04 2015 +0200 cmOrderDirectories: Port to cmGeneratorTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 5cd0d54..e0c6e86 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -260,10 +260,10 @@ cmComputeLinkInformation // Allocate internals. this->OrderLinkerSearchPath = - new cmOrderDirectories(this->GlobalGenerator, target->Target, + new cmOrderDirectories(this->GlobalGenerator, target, "linker search path"); this->OrderRuntimeSearchPath = - new cmOrderDirectories(this->GlobalGenerator, target->Target, + new cmOrderDirectories(this->GlobalGenerator, target, "runtime search path"); this->OrderDependentRPath = 0; @@ -370,7 +370,7 @@ cmComputeLinkInformation { this->SharedDependencyMode = SharedDepModeDir; this->OrderDependentRPath = - new cmOrderDirectories(this->GlobalGenerator, target->Target, + new cmOrderDirectories(this->GlobalGenerator, target, "dependent library path"); } diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx index a612437..35ee127 100644 --- a/Source/cmOrderDirectories.cxx +++ b/Source/cmOrderDirectories.cxx @@ -280,7 +280,7 @@ bool cmOrderDirectoriesConstraintLibrary::FindConflict(std::string const& dir) //---------------------------------------------------------------------------- cmOrderDirectories::cmOrderDirectories(cmGlobalGenerator* gg, - cmTarget const* target, + const cmGeneratorTarget* target, const char* purpose) { this->GlobalGenerator = gg; @@ -554,7 +554,8 @@ void cmOrderDirectories::FindImplicitConflicts() << text << "Some of these libraries may not be found correctly."; this->GlobalGenerator->GetCMakeInstance() - ->IssueMessage(cmake::WARNING, w.str(), this->Target->GetBacktrace()); + ->IssueMessage(cmake::WARNING, w.str(), + this->Target->Target->GetBacktrace()); } //---------------------------------------------------------------------------- @@ -635,5 +636,6 @@ void cmOrderDirectories::DiagnoseCycle() } e << "Some of these libraries may not be found correctly."; this->GlobalGenerator->GetCMakeInstance() - ->IssueMessage(cmake::WARNING, e.str(), this->Target->GetBacktrace()); + ->IssueMessage(cmake::WARNING, e.str(), + this->Target->Target->GetBacktrace()); } diff --git a/Source/cmOrderDirectories.h b/Source/cmOrderDirectories.h index cb5a51f..211c786 100644 --- a/Source/cmOrderDirectories.h +++ b/Source/cmOrderDirectories.h @@ -19,7 +19,7 @@ class cmGlobalGenerator; class cmOrderDirectoriesConstraint; class cmOrderDirectoriesConstraintLibrary; -class cmTarget; +class cmGeneratorTarget; /** \class cmOrderDirectories * \brief Compute a safe runtime path order for a set of shared libraries. @@ -27,7 +27,7 @@ class cmTarget; class cmOrderDirectories { public: - cmOrderDirectories(cmGlobalGenerator* gg, cmTarget const* target, + cmOrderDirectories(cmGlobalGenerator* gg, cmGeneratorTarget const* target, const char* purpose); ~cmOrderDirectories(); void AddRuntimeLibrary(std::string const& fullPath, const char* soname = 0); @@ -41,7 +41,7 @@ public: std::vector const& GetOrderedDirectories(); private: cmGlobalGenerator* GlobalGenerator; - cmTarget const* Target; + cmGeneratorTarget const* Target; std::string Purpose; std::vector OrderedDirectories; ----------------------------------------------------------------------- Summary of changes: Source/cmComputeLinkInformation.cxx | 6 +++--- Source/cmOrderDirectories.cxx | 8 +++++--- Source/cmOrderDirectories.h | 6 +++--- 3 files changed, 11 insertions(+), 9 deletions(-) hooks/post-receive -- CMake From steveire at gmail.com Sat Aug 1 05:35:49 2015 From: steveire at gmail.com (Stephen Kelly) Date: Sat, 1 Aug 2015 05:35:49 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1731-g7a9a050 Message-ID: <20150801093549.8BDADB100B@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 7a9a0505fe3d187de146baa5bf7fa513376c8427 (commit) via 2879cd92a5eb965e03302eec44e212a4198c94bd (commit) from 245e10c1674df5d8a7a0adce2660f1e934455a93 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7a9a0505fe3d187de146baa5bf7fa513376c8427 commit 7a9a0505fe3d187de146baa5bf7fa513376c8427 Merge: 245e10c 2879cd9 Author: Stephen Kelly AuthorDate: Sat Aug 1 05:35:48 2015 -0400 Commit: CMake Topic Stage CommitDate: Sat Aug 1 05:35:48 2015 -0400 Merge topic 'use-generator-target' into next 2879cd92 fixup! cmGlobalGenerator: Base exclusion computation on cmGeneratorTarget. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2879cd92a5eb965e03302eec44e212a4198c94bd commit 2879cd92a5eb965e03302eec44e212a4198c94bd Author: Stephen Kelly AuthorDate: Sat Aug 1 11:35:28 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 11:35:28 2015 +0200 fixup! cmGlobalGenerator: Base exclusion computation on cmGeneratorTarget. diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index c3131c3..c06dfb3 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -112,7 +112,7 @@ bool cmGlobalVisualStudioGenerator::Compute() i != gen.end(); ++i) { cmGeneratorTargetsType targets = - lg->GetMakefile()->GetGeneratorTargets(); + (*i)->GetMakefile()->GetGeneratorTargets(); for(cmGeneratorTargetsType::iterator t = targets.begin(); t != targets.end(); ++t) { ----------------------------------------------------------------------- Summary of changes: Source/cmGlobalVisualStudioGenerator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From steveire at gmail.com Sat Aug 1 05:42:06 2015 From: steveire at gmail.com (Stephen Kelly) Date: Sat, 1 Aug 2015 05:42:06 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1735-g6d715db Message-ID: <20150801094206.0775FAFC5A@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 6d715db16259bce2236e7b4f592bcc05d24618be (commit) via 73ec307977649a0f010f51372e889b60214302ad (commit) via 0e23fad87886b633cfd5ba15f0a67e51401ab871 (commit) via 65b5eff92be74aec23d84bde226838613cc2ed7d (commit) from 7a9a0505fe3d187de146baa5bf7fa513376c8427 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6d715db16259bce2236e7b4f592bcc05d24618be commit 6d715db16259bce2236e7b4f592bcc05d24618be Merge: 7a9a050 73ec307 Author: Stephen Kelly AuthorDate: Sat Aug 1 05:42:05 2015 -0400 Commit: CMake Topic Stage CommitDate: Sat Aug 1 05:42:05 2015 -0400 Merge topic 'use-generator-target' into next 73ec3079 cmOrderDirectories: Port to cmGeneratorTarget. 0e23fad8 cmMakefile: Remove unused method. 65b5eff9 cmGlobalGenerator: Base exclusion computation on cmGeneratorTarget. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=73ec307977649a0f010f51372e889b60214302ad commit 73ec307977649a0f010f51372e889b60214302ad Author: Stephen Kelly AuthorDate: Sat Aug 1 09:48:04 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 11:35:59 2015 +0200 cmOrderDirectories: Port to cmGeneratorTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 5cd0d54..e0c6e86 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -260,10 +260,10 @@ cmComputeLinkInformation // Allocate internals. this->OrderLinkerSearchPath = - new cmOrderDirectories(this->GlobalGenerator, target->Target, + new cmOrderDirectories(this->GlobalGenerator, target, "linker search path"); this->OrderRuntimeSearchPath = - new cmOrderDirectories(this->GlobalGenerator, target->Target, + new cmOrderDirectories(this->GlobalGenerator, target, "runtime search path"); this->OrderDependentRPath = 0; @@ -370,7 +370,7 @@ cmComputeLinkInformation { this->SharedDependencyMode = SharedDepModeDir; this->OrderDependentRPath = - new cmOrderDirectories(this->GlobalGenerator, target->Target, + new cmOrderDirectories(this->GlobalGenerator, target, "dependent library path"); } diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx index a612437..35ee127 100644 --- a/Source/cmOrderDirectories.cxx +++ b/Source/cmOrderDirectories.cxx @@ -280,7 +280,7 @@ bool cmOrderDirectoriesConstraintLibrary::FindConflict(std::string const& dir) //---------------------------------------------------------------------------- cmOrderDirectories::cmOrderDirectories(cmGlobalGenerator* gg, - cmTarget const* target, + const cmGeneratorTarget* target, const char* purpose) { this->GlobalGenerator = gg; @@ -554,7 +554,8 @@ void cmOrderDirectories::FindImplicitConflicts() << text << "Some of these libraries may not be found correctly."; this->GlobalGenerator->GetCMakeInstance() - ->IssueMessage(cmake::WARNING, w.str(), this->Target->GetBacktrace()); + ->IssueMessage(cmake::WARNING, w.str(), + this->Target->Target->GetBacktrace()); } //---------------------------------------------------------------------------- @@ -635,5 +636,6 @@ void cmOrderDirectories::DiagnoseCycle() } e << "Some of these libraries may not be found correctly."; this->GlobalGenerator->GetCMakeInstance() - ->IssueMessage(cmake::WARNING, e.str(), this->Target->GetBacktrace()); + ->IssueMessage(cmake::WARNING, e.str(), + this->Target->Target->GetBacktrace()); } diff --git a/Source/cmOrderDirectories.h b/Source/cmOrderDirectories.h index cb5a51f..211c786 100644 --- a/Source/cmOrderDirectories.h +++ b/Source/cmOrderDirectories.h @@ -19,7 +19,7 @@ class cmGlobalGenerator; class cmOrderDirectoriesConstraint; class cmOrderDirectoriesConstraintLibrary; -class cmTarget; +class cmGeneratorTarget; /** \class cmOrderDirectories * \brief Compute a safe runtime path order for a set of shared libraries. @@ -27,7 +27,7 @@ class cmTarget; class cmOrderDirectories { public: - cmOrderDirectories(cmGlobalGenerator* gg, cmTarget const* target, + cmOrderDirectories(cmGlobalGenerator* gg, cmGeneratorTarget const* target, const char* purpose); ~cmOrderDirectories(); void AddRuntimeLibrary(std::string const& fullPath, const char* soname = 0); @@ -41,7 +41,7 @@ public: std::vector const& GetOrderedDirectories(); private: cmGlobalGenerator* GlobalGenerator; - cmTarget const* Target; + cmGeneratorTarget const* Target; std::string Purpose; std::vector OrderedDirectories; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0e23fad87886b633cfd5ba15f0a67e51401ab871 commit 0e23fad87886b633cfd5ba15f0a67e51401ab871 Author: Stephen Kelly AuthorDate: Sat Jun 6 14:27:52 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 11:35:59 2015 +0200 cmMakefile: Remove unused method. diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 1e5c301..00d4005 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -113,10 +113,6 @@ public: bool GetIsSourceFileTryCompile() const; - ///! Get the current makefile generator. - cmLocalGenerator* GetLocalGenerator() const - { return this->LocalGenerator;} - /** * Help enforce global target name uniqueness. */ http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=65b5eff92be74aec23d84bde226838613cc2ed7d commit 65b5eff92be74aec23d84bde226838613cc2ed7d Author: Stephen Kelly AuthorDate: Sat Jun 6 14:09:35 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 11:35:59 2015 +0200 cmGlobalGenerator: Base exclusion computation on cmGeneratorTarget. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 1d6608b..b14949a 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2022,10 +2022,10 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, } bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, - cmTarget const& target) const + cmGeneratorTarget* target) const { - if(target.GetType() == cmTarget::INTERFACE_LIBRARY - || target.GetPropertyAsBool("EXCLUDE_FROM_ALL")) + if(target->GetType() == cmTarget::INTERFACE_LIBRARY + || target->Target->GetPropertyAsBool("EXCLUDE_FROM_ALL")) { // This target is excluded from its directory. return true; @@ -2034,7 +2034,7 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, { // This target is included in its directory. Check whether the // directory is excluded. - return this->IsExcluded(root, target.GetMakefile()->GetLocalGenerator()); + return this->IsExcluded(root, target->GetLocalGenerator()); } } @@ -2095,15 +2095,16 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap() { cmTarget const& target = t->second; + cmGeneratorTarget* gt = this->GetGeneratorTarget(&target); + // Consider the directory containing the target and all its // parents until something excludes the target. - for(cmLocalGenerator* clg = lg; clg && !this->IsExcluded(clg, target); + for(cmLocalGenerator* clg = lg; clg && !this->IsExcluded(clg, gt); clg = clg->GetParent()) { // This local generator includes the target. std::set& targetSet = this->LocalGeneratorToTargetMap[clg]; - cmGeneratorTarget* gt = this->GetGeneratorTarget(&target); targetSet.insert(gt); // Add dependencies of the included target. An excluded diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 9492372..3be76b6 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -398,7 +398,7 @@ protected: void FillProjectMap(); void CheckLocalGenerators(); bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen) const; - bool IsExcluded(cmLocalGenerator* root, cmTarget const& target) const; + bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) const; void FillLocalGeneratorToTargetMap(); void CreateDefaultGlobalTargets(cmTargets* targets); cmTarget CreateGlobalTarget(const std::string& name, const char* message, diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 2a749c1..47822b4 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -289,7 +289,7 @@ public: const std::vector& GetLocalGenerators() const { return LocalGenerators; } - bool IsExcluded(cmLocalGenerator* root, cmTarget& target) { + bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) { return cmGlobalGenerator::IsExcluded(root, target); } int GetRuleCmdLength(const std::string& name) { diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 69747a4..76d059ee 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -821,7 +821,7 @@ cmGlobalUnixMakefileGenerator3 localName, depends, commands, true); // add the all/all dependency - if(!this->IsExcluded(this->LocalGenerators[0], *gtarget->Target)) + if(!this->IsExcluded(this->LocalGenerators[0], gtarget)) { depends.clear(); depends.push_back(localName); @@ -889,7 +889,7 @@ cmGlobalUnixMakefileGenerator3 "Pre-install relink rule for target.", localName, depends, commands, true); - if(!this->IsExcluded(this->LocalGenerators[0], *gtarget->Target)) + if(!this->IsExcluded(this->LocalGenerators[0], gtarget)) { depends.clear(); depends.push_back(localName); diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 2f9d79a..c06dfb3 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -111,17 +111,18 @@ bool cmGlobalVisualStudioGenerator::Compute() for(std::vector::iterator i = gen.begin(); i != gen.end(); ++i) { - cmTargets& targets = (*i)->GetMakefile()->GetTargets(); - for(cmTargets::iterator t = targets.begin(); + cmGeneratorTargetsType targets = + (*i)->GetMakefile()->GetGeneratorTargets(); + for(cmGeneratorTargetsType::iterator t = targets.begin(); t != targets.end(); ++t) { - if (t->second.GetType() == cmTarget::GLOBAL_TARGET) + if (t->second->GetType() == cmTarget::GLOBAL_TARGET) { continue; } if(!this->IsExcluded(gen[0], t->second)) { - allBuild->AddUtility(t->second.GetName()); + allBuild->AddUtility(t->second->GetName()); } } } diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 9889bd4..1822c97 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -90,7 +90,7 @@ void cmLocalNinjaGenerator::Generate() // Add the target to "all" if required. if (!this->GetGlobalNinjaGenerator()->IsExcluded( this->GetGlobalNinjaGenerator()->GetLocalGenerators()[0], - *t->second->Target)) + t->second)) this->GetGlobalNinjaGenerator()->AddDependencyToAll(t->second->Target); delete tg; } ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From steveire at gmail.com Sat Aug 1 07:17:08 2015 From: steveire at gmail.com (Stephen Kelly) Date: Sat, 1 Aug 2015 07:17:08 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1739-gf510c88 Message-ID: <20150801111709.D7708B091A@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via f510c88a6e2265dfd5492d9a966d2adae3a8c3f0 (commit) via 12c3f24827d2459154fcc9773b279f96c303e591 (commit) via 6c0e9ee276e9e35a970990baec09c0c2c85b3804 (commit) via 9432b14e916421a727265f9a05dc1fbe6c6ec381 (commit) from 6d715db16259bce2236e7b4f592bcc05d24618be (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f510c88a6e2265dfd5492d9a966d2adae3a8c3f0 commit f510c88a6e2265dfd5492d9a966d2adae3a8c3f0 Merge: 6d715db 12c3f24 Author: Stephen Kelly AuthorDate: Sat Aug 1 07:17:04 2015 -0400 Commit: CMake Topic Stage CommitDate: Sat Aug 1 07:17:04 2015 -0400 Merge topic 'refactor-evaluation-files' into next 12c3f248 cmGeneratorExpressionEvaluationFile: Require generator context. 6c0e9ee2 cmMakefile: Store EvaluationFiles. 9432b14e CMake Nightly Date Stamp diff --cc Source/cmMakefile.cxx index a0a36ec,3e8abbc..75cfe87 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@@ -235,7 -236,15 +236,10 @@@ cmMakefile::~cmMakefile( cmDeleteAll(this->ImportedTargetsOwned); cmDeleteAll(this->FinalPassCommands); cmDeleteAll(this->FunctionBlockers); + cmDeleteAll(this->EvaluationFiles); + this->EvaluationFiles.clear(); + this->FunctionBlockers.clear(); - if (this->PolicyStack.size() != 1) - { - cmSystemTools::Error("Internal CMake Error, Policy Stack has not been" - " popped properly"); - } } //---------------------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=12c3f24827d2459154fcc9773b279f96c303e591 commit 12c3f24827d2459154fcc9773b279f96c303e591 Author: Stephen Kelly AuthorDate: Sat Aug 1 12:19:32 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 13:07:11 2015 +0200 cmGeneratorExpressionEvaluationFile: Require generator context. Avoid storing a cmMakefile as a member, and evaluate in the context of a cmLocalGenerator instead. diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx index 92ff314..e4d9f10 100644 --- a/Source/cmGeneratorExpressionEvaluationFile.cxx +++ b/Source/cmGeneratorExpressionEvaluationFile.cxx @@ -25,19 +25,18 @@ cmGeneratorExpressionEvaluationFile::cmGeneratorExpressionEvaluationFile( const std::string &input, cmsys::auto_ptr outputFileExpr, - cmMakefile *makefile, cmsys::auto_ptr condition, bool inputIsContent) : Input(input), OutputFileExpr(outputFileExpr), - Makefile(makefile), Condition(condition), InputIsContent(inputIsContent) { } //---------------------------------------------------------------------------- -void cmGeneratorExpressionEvaluationFile::Generate(const std::string& config, +void cmGeneratorExpressionEvaluationFile::Generate(cmLocalGenerator* lg, + const std::string& config, const std::string& lang, cmCompiledGeneratorExpression* inputExpression, std::map &outputFiles, mode_t perm) @@ -45,7 +44,8 @@ void cmGeneratorExpressionEvaluationFile::Generate(const std::string& config, std::string rawCondition = this->Condition->GetInput(); if (!rawCondition.empty()) { - std::string condResult = this->Condition->Evaluate(this->Makefile, config, + std::string condResult = this->Condition->Evaluate(lg->GetMakefile(), + config, false, 0, 0, 0, lang); if (condResult == "0") { @@ -56,16 +56,17 @@ void cmGeneratorExpressionEvaluationFile::Generate(const std::string& config, std::ostringstream e; e << "Evaluation file condition \"" << rawCondition << "\" did " "not evaluate to valid content. Got \"" << condResult << "\"."; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); + lg->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } } const std::string outputFileName - = this->OutputFileExpr->Evaluate(this->Makefile, config, + = this->OutputFileExpr->Evaluate(lg->GetMakefile(), config, false, 0, 0, 0, lang); const std::string outputContent - = inputExpression->Evaluate(this->Makefile, config, + = inputExpression->Evaluate(lg->GetMakefile(), + config, false, 0, 0, 0, lang); std::map::iterator it @@ -81,11 +82,11 @@ void cmGeneratorExpressionEvaluationFile::Generate(const std::string& config, e << "Evaluation file to be written multiple times for different " "configurations or languages with different content:\n " << outputFileName; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); + lg->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } - this->Makefile->AddCMakeOutputFile(outputFileName.c_str()); + lg->GetMakefile()->AddCMakeOutputFile(outputFileName.c_str()); this->Files.push_back(outputFileName); outputFiles[outputFileName] = outputContent; @@ -100,18 +101,19 @@ void cmGeneratorExpressionEvaluationFile::Generate(const std::string& config, //---------------------------------------------------------------------------- void cmGeneratorExpressionEvaluationFile::CreateOutputFile( - std::string const& config) + cmLocalGenerator *lg, std::string const& config) { std::vector enabledLanguages; - cmGlobalGenerator *gg = this->Makefile->GetGlobalGenerator(); + cmGlobalGenerator *gg = lg->GetGlobalGenerator(); gg->GetEnabledLanguages(enabledLanguages); for(std::vector::const_iterator le = enabledLanguages.begin(); le != enabledLanguages.end(); ++le) { - std::string name = this->OutputFileExpr->Evaluate(this->Makefile, config, + std::string name = this->OutputFileExpr->Evaluate(lg->GetMakefile(), + config, false, 0, 0, 0, *le); - cmSourceFile* sf = this->Makefile->GetOrCreateSource(name); + cmSourceFile* sf = lg->GetMakefile()->GetOrCreateSource(name); sf->SetProperty("GENERATED", "1"); gg->SetFilenameTargetDepends(sf, @@ -120,7 +122,7 @@ void cmGeneratorExpressionEvaluationFile::CreateOutputFile( } //---------------------------------------------------------------------------- -void cmGeneratorExpressionEvaluationFile::Generate() +void cmGeneratorExpressionEvaluationFile::Generate(cmLocalGenerator *lg) { mode_t perm = 0; std::string inputContent; @@ -130,14 +132,14 @@ void cmGeneratorExpressionEvaluationFile::Generate() } else { - this->Makefile->AddCMakeDependFile(this->Input.c_str()); + lg->GetMakefile()->AddCMakeDependFile(this->Input.c_str()); cmSystemTools::GetPermissions(this->Input.c_str(), perm); cmsys::ifstream fin(this->Input.c_str()); if(!fin) { std::ostringstream e; e << "Evaluation file \"" << this->Input << "\" cannot be read."; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); + lg->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } @@ -159,7 +161,7 @@ void cmGeneratorExpressionEvaluationFile::Generate() std::map outputFiles; std::vector allConfigs; - this->Makefile->GetConfigurations(allConfigs); + lg->GetMakefile()->GetConfigurations(allConfigs); if (allConfigs.empty()) { @@ -167,7 +169,7 @@ void cmGeneratorExpressionEvaluationFile::Generate() } std::vector enabledLanguages; - cmGlobalGenerator *gg = this->Makefile->GetGlobalGenerator(); + cmGlobalGenerator *gg = lg->GetGlobalGenerator(); gg->GetEnabledLanguages(enabledLanguages); for(std::vector::const_iterator le = enabledLanguages.begin(); @@ -176,7 +178,7 @@ void cmGeneratorExpressionEvaluationFile::Generate() for(std::vector::const_iterator li = allConfigs.begin(); li != allConfigs.end(); ++li) { - this->Generate(*li, *le, inputExpression.get(), outputFiles, perm); + this->Generate(lg, *li, *le, inputExpression.get(), outputFiles, perm); if(cmSystemTools::GetFatalErrorOccured()) { return; diff --git a/Source/cmGeneratorExpressionEvaluationFile.h b/Source/cmGeneratorExpressionEvaluationFile.h index 5d8b54c..ad41274 100644 --- a/Source/cmGeneratorExpressionEvaluationFile.h +++ b/Source/cmGeneratorExpressionEvaluationFile.h @@ -18,31 +18,32 @@ #include "cmGeneratorExpression.h" +class cmLocalGenerator; + //---------------------------------------------------------------------------- class cmGeneratorExpressionEvaluationFile { public: cmGeneratorExpressionEvaluationFile(const std::string &input, cmsys::auto_ptr outputFileExpr, - cmMakefile *makefile, cmsys::auto_ptr condition, bool inputIsContent); - void Generate(); + void Generate(cmLocalGenerator* lg); std::vector GetFiles() const { return this->Files; } - void CreateOutputFile(std::string const& config); + void CreateOutputFile(cmLocalGenerator* lg, std::string const& config); private: - void Generate(const std::string& config, const std::string& lang, - cmCompiledGeneratorExpression* inputExpression, - std::map &outputFiles, mode_t perm); + void Generate(cmLocalGenerator* lg, const std::string& config, + const std::string& lang, + cmCompiledGeneratorExpression* inputExpression, + std::map &outputFiles, mode_t perm); private: const std::string Input; const cmsys::auto_ptr OutputFileExpr; - cmMakefile *Makefile; const cmsys::auto_ptr Condition; std::vector Files; const bool InputIsContent; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 7cc256a..ea0f658 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -220,7 +220,7 @@ void cmLocalGenerator::CreateEvaluationFileOutputs(std::string const& config) for(std::vector::const_iterator li = ef.begin(); li != ef.end(); ++li) { - (*li)->CreateOutputFile(config); + (*li)->CreateOutputFile(this, config); } } @@ -234,7 +234,7 @@ void cmLocalGenerator::ProcessEvaluationFiles( li != ef.end(); ++li) { - (*li)->Generate(); + (*li)->Generate(this); if (cmSystemTools::GetFatalErrorOccured()) { return; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 1407888..3e8abbc 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -788,7 +788,7 @@ void cmMakefile::AddEvaluationFile(const std::string& inputFile, { this->EvaluationFiles.push_back( new cmGeneratorExpressionEvaluationFile(inputFile, outputName, - this, condition, + condition, inputIsContent)); } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6c0e9ee276e9e35a970990baec09c0c2c85b3804 commit 6c0e9ee276e9e35a970990baec09c0c2c85b3804 Author: Stephen Kelly AuthorDate: Sat Aug 1 12:05:13 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 1 13:07:11 2015 +0200 cmMakefile: Store EvaluationFiles. Relieve the cmGlobalGenerator of this responsibility. Evaluate the generator expressions in the context of the cmLocalGenerator. diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 0daed66..87faf84 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -3573,11 +3573,8 @@ void cmFileCommand::AddEvaluationFile(const std::string &inputName, cmsys::auto_ptr conditionCge = conditionGe.Parse(condition); - this->Makefile->GetGlobalGenerator()->AddEvaluationFile(inputName, - outputCge, - this->Makefile, - conditionCge, - inputIsContent); + this->Makefile->AddEvaluationFile(inputName, outputCge, + conditionCge, inputIsContent); } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 1d6608b..d6d36d4 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -30,7 +30,6 @@ #include "cmGeneratedFileStream.h" #include "cmGeneratorTarget.h" #include "cmGeneratorExpression.h" -#include "cmGeneratorExpressionEvaluationFile.h" #include "cmExportBuildFileGenerator.h" #include "cmCPackPropertiesGenerator.h" #include "cmAlgorithms.h" @@ -1561,9 +1560,6 @@ void cmGlobalGenerator::ClearGeneratorMembers() cmDeleteAll(this->GeneratorTargets); this->GeneratorTargets.clear(); - cmDeleteAll(this->EvaluationFiles); - this->EvaluationFiles.clear(); - cmDeleteAll(this->BuildExportSets); this->BuildExportSets.clear(); @@ -3032,61 +3028,21 @@ cmGlobalGenerator::GetFilenameTargetDepends(cmSourceFile* sf) const { void cmGlobalGenerator::CreateEvaluationSourceFiles( std::string const& config) const { - for(std::vector::const_iterator - li = this->EvaluationFiles.begin(); - li != this->EvaluationFiles.end(); - ++li) + unsigned int i; + for (i = 0; i < this->LocalGenerators.size(); ++i) { - (*li)->CreateOutputFile(config); + this->LocalGenerators[i]->CreateEvaluationFileOutputs(config); } } //---------------------------------------------------------------------------- -void cmGlobalGenerator::AddEvaluationFile(const std::string &inputFile, - cmsys::auto_ptr outputExpr, - cmMakefile *makefile, - cmsys::auto_ptr condition, - bool inputIsContent) -{ - this->EvaluationFiles.push_back( - new cmGeneratorExpressionEvaluationFile(inputFile, outputExpr, - makefile, condition, - inputIsContent)); -} - -//---------------------------------------------------------------------------- void cmGlobalGenerator::ProcessEvaluationFiles() { std::vector generatedFiles; - for(std::vector::const_iterator - li = this->EvaluationFiles.begin(); - li != this->EvaluationFiles.end(); - ++li) + unsigned int i; + for (i = 0; i < this->LocalGenerators.size(); ++i) { - (*li)->Generate(); - if (cmSystemTools::GetFatalErrorOccured()) - { - return; - } - std::vector files = (*li)->GetFiles(); - std::sort(files.begin(), files.end()); - - std::vector intersection; - std::set_intersection(files.begin(), files.end(), - generatedFiles.begin(), generatedFiles.end(), - std::back_inserter(intersection)); - if (!intersection.empty()) - { - cmSystemTools::Error("Files to be generated by multiple different " - "commands: ", cmWrap('"', intersection, '"', " ").c_str()); - return; - } - - generatedFiles.insert(generatedFiles.end(), - files.begin(), files.end()); - std::vector::iterator newIt = - generatedFiles.end() - files.size(); - std::inplace_merge(generatedFiles.begin(), newIt, generatedFiles.end()); + this->LocalGenerators[i]->ProcessEvaluationFiles(generatedFiles); } } diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 9492372..3402fbc 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -34,7 +34,6 @@ class cmake; class cmGeneratorTarget; -class cmGeneratorExpressionEvaluationFile; class cmMakefile; class cmLocalGenerator; class cmExternalMakefileProjectGenerator; @@ -334,12 +333,6 @@ public: static std::string EscapeJSON(const std::string& s); - void AddEvaluationFile(const std::string &inputFile, - cmsys::auto_ptr outputName, - cmMakefile *makefile, - cmsys::auto_ptr condition, - bool inputIsContent); - void ProcessEvaluationFiles(); std::map& GetBuildExportSets() @@ -436,7 +429,6 @@ protected: TargetMap TotalTargets; TargetMap AliasTargets; TargetMap ImportedTargets; - std::vector EvaluationFiles; const char* GetPredefinedTargetsFolder(); virtual bool UseFolderProperty(); diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index d24cce8..cc7f78b 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -1055,23 +1055,21 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os) { knownDependencies.insert( ng->ConvertToNinjaPath( *j ) ); } - } - knownDependencies.insert( "CMakeCache.txt" ); - - for(std::vector::const_iterator - li = this->EvaluationFiles.begin(); - li != this->EvaluationFiles.end(); - ++li) - { - //get all the files created by generator expressions and convert them - //to ninja paths - std::vector files = (*li)->GetFiles(); - typedef std::vector::const_iterator vect_it; - for(vect_it j = files.begin(); j != files.end(); ++j) + std::vector const& ef = + (*i)->GetMakefile()->GetEvaluationFiles(); + for(std::vector::const_iterator + li = ef.begin(); li != ef.end(); ++li) { - knownDependencies.insert( ng->ConvertToNinjaPath( *j ) ); + //get all the files created by generator expressions and convert them + //to ninja paths + std::vector evaluationFiles = (*li)->GetFiles(); + for(vect_it j = evaluationFiles.begin(); j != evaluationFiles.end(); ++j) + { + knownDependencies.insert( ng->ConvertToNinjaPath( *j ) ); + } } } + knownDependencies.insert( "CMakeCache.txt" ); for(TargetAliasMap::const_iterator i= this->TargetAliases.begin(); i != this->TargetAliases.end(); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 6b48a44..7cc256a 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -16,6 +16,7 @@ #include "cmGlobalGenerator.h" #include "cmInstallGenerator.h" #include "cmInstallFilesGenerator.h" +#include "cmGeneratorExpressionEvaluationFile.h" #include "cmInstallScriptGenerator.h" #include "cmInstallTargetGenerator.h" #include "cmMakefile.h" @@ -212,6 +213,53 @@ void cmLocalGenerator::GenerateTestFiles() } } +void cmLocalGenerator::CreateEvaluationFileOutputs(std::string const& config) +{ + std::vector ef = + this->Makefile->GetEvaluationFiles(); + for(std::vector::const_iterator + li = ef.begin(); li != ef.end(); ++li) + { + (*li)->CreateOutputFile(config); + } +} + +void cmLocalGenerator::ProcessEvaluationFiles( + std::vector& generatedFiles) +{ + std::vector ef = + this->Makefile->GetEvaluationFiles(); + for(std::vector::const_iterator + li = ef.begin(); + li != ef.end(); + ++li) + { + (*li)->Generate(); + if (cmSystemTools::GetFatalErrorOccured()) + { + return; + } + std::vector files = (*li)->GetFiles(); + std::sort(files.begin(), files.end()); + + std::vector intersection; + std::set_intersection(files.begin(), files.end(), + generatedFiles.begin(), generatedFiles.end(), + std::back_inserter(intersection)); + if (!intersection.empty()) + { + cmSystemTools::Error("Files to be generated by multiple different " + "commands: ", cmWrap('"', intersection, '"', " ").c_str()); + return; + } + + generatedFiles.insert(generatedFiles.end(), files.begin(), files.end()); + std::vector::iterator newIt = + generatedFiles.end() - files.size(); + std::inplace_merge(generatedFiles.begin(), newIt, generatedFiles.end()); + } +} + //---------------------------------------------------------------------------- void cmLocalGenerator::GenerateInstallRules() { diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 2971574..1c18788 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -305,6 +305,8 @@ public: void IssueMessage(cmake::MessageType t, std::string const& text) const; + void CreateEvaluationFileOutputs(const std::string& config); + void ProcessEvaluationFiles(std::vector& generatedFiles); void ComputeObjectMaxPath(); protected: diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 4bdc9d5..1407888 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -21,6 +21,7 @@ #include "cmState.h" #include "cmOutputConverter.h" #include "cmFunctionBlocker.h" +#include "cmGeneratorExpressionEvaluationFile.h" #include "cmListFileCache.h" #include "cmCommandArgumentParserHelper.h" #include "cmGeneratorExpression.h" @@ -235,6 +236,9 @@ cmMakefile::~cmMakefile() cmDeleteAll(this->ImportedTargetsOwned); cmDeleteAll(this->FinalPassCommands); cmDeleteAll(this->FunctionBlockers); + cmDeleteAll(this->EvaluationFiles); + this->EvaluationFiles.clear(); + this->FunctionBlockers.clear(); if (this->PolicyStack.size() != 1) { @@ -777,6 +781,23 @@ void cmMakefile::EnforceDirectoryLevelRules() const } } +void cmMakefile::AddEvaluationFile(const std::string& inputFile, + cmsys::auto_ptr outputName, + cmsys::auto_ptr condition, + bool inputIsContent) +{ + this->EvaluationFiles.push_back( + new cmGeneratorExpressionEvaluationFile(inputFile, outputName, + this, condition, + inputIsContent)); +} + +std::vector +cmMakefile::GetEvaluationFiles() const +{ + return this->EvaluationFiles; +} + namespace { struct file_not_persistent diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 1e5c301..c16ab3d 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -52,6 +52,7 @@ class cmVariableWatch; class cmake; class cmMakefileCall; class cmCMakePolicyCommand; +class cmGeneratorExpressionEvaluationFile; /** \class cmMakefile * \brief Process the input CMakeLists.txt file. @@ -799,6 +800,12 @@ public: void EnforceDirectoryLevelRules() const; + void AddEvaluationFile(const std::string &inputFile, + cmsys::auto_ptr outputName, + cmsys::auto_ptr condition, + bool inputIsContent); + std::vector GetEvaluationFiles() const; + protected: // add link libraries and directories to the target void AddGlobalLinkInformation(const std::string& name, cmTarget& target); @@ -895,6 +902,8 @@ private: std::vector UnConfiguredDirectories; + std::vector EvaluationFiles; + cmPropertyMap Properties; std::vector ContextStack; ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- Source/cmFileCommand.cxx | 7 +-- Source/cmGeneratorExpressionEvaluationFile.cxx | 40 +++++++++-------- Source/cmGeneratorExpressionEvaluationFile.h | 15 ++++--- Source/cmGlobalGenerator.cxx | 56 +++--------------------- Source/cmGlobalGenerator.h | 8 ---- Source/cmGlobalNinjaGenerator.cxx | 26 +++++------ Source/cmLocalGenerator.cxx | 48 ++++++++++++++++++++ Source/cmLocalGenerator.h | 2 + Source/cmMakefile.cxx | 21 +++++++++ Source/cmMakefile.h | 9 ++++ 11 files changed, 130 insertions(+), 104 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Sun Aug 2 00:01:09 2015 From: kwrobot at kitware.com (Kitware Robot) Date: Sun, 2 Aug 2015 00:01:09 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-661-g614786c Message-ID: <20150802040109.91D01B1349@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 614786cc5c8cf6f504112a722aabf8dddc154d2c (commit) from 9432b14e916421a727265f9a05dc1fbe6c6ec381 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=614786cc5c8cf6f504112a722aabf8dddc154d2c commit 614786cc5c8cf6f504112a722aabf8dddc154d2c Author: Kitware Robot AuthorDate: Sun Aug 2 00:01:07 2015 -0400 Commit: Kitware Robot CommitDate: Sun Aug 2 00:01:07 2015 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 5d53072..8c496cd 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150801) +set(CMake_VERSION_PATCH 20150802) #set(CMake_VERSION_RC 1) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From steveire at gmail.com Sun Aug 2 02:57:32 2015 From: steveire at gmail.com (Stephen Kelly) Date: Sun, 2 Aug 2015 02:57:32 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1744-ge673ea3 Message-ID: <20150802065732.8F32BB0B56@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via e673ea37477d270aae309542366f1d93c246fa88 (commit) via 757a1f54085af4645ee1946329e24538162ac054 (commit) via 52dbe654dea7562564be9d880540e6bc706998ba (commit) via 65a5e0c671fc7d42525a6279aebf9a74de2c97a7 (commit) via 348354333a82ce98d733dc2ee939186c53c506f9 (commit) from f510c88a6e2265dfd5492d9a966d2adae3a8c3f0 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e673ea37477d270aae309542366f1d93c246fa88 commit e673ea37477d270aae309542366f1d93c246fa88 Merge: f510c88 757a1f5 Author: Stephen Kelly AuthorDate: Sun Aug 2 02:57:31 2015 -0400 Commit: CMake Topic Stage CommitDate: Sun Aug 2 02:57:31 2015 -0400 Merge topic 'cmState-policies' into next 757a1f54 cmState: Move PolicyState from cmMakefile. 52dbe654 cmState: Record the end position of each directory. 65a5e0c6 cmLinkedTree: Add Clear API. 34835433 cmState: Add Type for policy scope. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=757a1f54085af4645ee1946329e24538162ac054 commit 757a1f54085af4645ee1946329e24538162ac054 Author: Stephen Kelly AuthorDate: Sun Jul 26 13:04:09 2015 +0200 Commit: Stephen Kelly CommitDate: Sun Aug 2 08:56:57 2015 +0200 cmState: Move PolicyState from cmMakefile. Implement lexical scope checking in terms of the state stack instead of barriers. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 9fb3d06..a0a36ec 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -192,9 +192,6 @@ cmMakefile::cmMakefile(cmLocalGenerator* localGenerator) this->StateSnapshot = this->StateSnapshot.GetState() ->CreatePolicyScopeSnapshot(this->StateSnapshot); - // Protect the directory-level policies. - this->PushPolicyBarrier(); - // Enter a policy level for this directory. this->PushPolicy(); @@ -239,11 +236,6 @@ cmMakefile::~cmMakefile() cmDeleteAll(this->FinalPassCommands); cmDeleteAll(this->FunctionBlockers); this->FunctionBlockers.clear(); - if (this->PolicyStack.size() != 1) - { - cmSystemTools::Error("Internal CMake Error, Policy Stack has not been" - " popped properly"); - } } //---------------------------------------------------------------------------- @@ -479,7 +471,6 @@ cmMakefile::IncludeScope::IncludeScope(cmMakefile* mf, this->Makefile->ContextStack.back()->Name, this->Makefile->ContextStack.back()->Line, filenametoread); - this->Makefile->PushPolicyBarrier(); if(!this->NoPolicyScope) { // Check CMP0011 to determine the policy scope type. @@ -519,7 +510,8 @@ cmMakefile::IncludeScope::~IncludeScope() // one we pushed above. If the entry is empty, then the included // script did not set any policies that might affect the includer so // we do not need to enforce the policy. - if(this->CheckCMP0011 && this->Makefile->PolicyStack.back().IsEmpty()) + if(this->CheckCMP0011 + && !this->Makefile->StateSnapshot.HasDefinedPolicyCMP0011()) { this->CheckCMP0011 = false; } @@ -535,9 +527,6 @@ cmMakefile::IncludeScope::~IncludeScope() } } this->Makefile->PopPolicyBarrier(this->ReportError); - this->Makefile->StateSnapshot = - this->Makefile->GetState()->Pop(this->Makefile->StateSnapshot); - assert(this->Makefile->StateSnapshot.IsValid()); this->Makefile->PopFunctionBlockerBarrier(this->ReportError); } @@ -646,19 +635,12 @@ public: this->Makefile->StateSnapshot, name, line, filenametoread); assert(this->Makefile->StateSnapshot.IsValid()); - this->Makefile->PushPolicyBarrier(); - this->Makefile->PushFunctionBlockerBarrier(); } ~ListFileScope() { this->Makefile->PopPolicyBarrier(this->ReportError); - - this->Makefile->StateSnapshot = - this->Makefile->GetState()->Pop(this->Makefile->StateSnapshot); - assert(this->Makefile->StateSnapshot.IsValid()); - this->Makefile->PopFunctionBlockerBarrier(this->ReportError); } @@ -1630,7 +1612,6 @@ void cmMakefile::PushFunctionScope(std::string const& fileName, this->ContextStack.back()->Name, this->ContextStack.back()->Line, fileName); assert(this->StateSnapshot.IsValid()); - this->PushPolicyBarrier(); this->Internal->PushDefinitions(); @@ -1650,8 +1631,6 @@ void cmMakefile::PopFunctionScope(bool reportError) this->PopPolicy(); this->PopPolicyBarrier(reportError); - this->StateSnapshot = this->GetState()->Pop(this->StateSnapshot); - assert(this->StateSnapshot.IsValid()); this->PopFunctionBlockerBarrier(reportError); @@ -1675,7 +1654,6 @@ void cmMakefile::PushMacroScope(std::string const& fileName, this->ContextStack.back()->Name, this->ContextStack.back()->Line, fileName); assert(this->StateSnapshot.IsValid()); - this->PushPolicyBarrier(); this->PushFunctionBlockerBarrier(); @@ -1687,9 +1665,6 @@ void cmMakefile::PopMacroScope(bool reportError) this->PopPolicy(); this->PopPolicyBarrier(reportError); - this->StateSnapshot = this->GetState()->Pop(this->StateSnapshot); - assert(this->StateSnapshot.IsValid()); - this->PopFunctionBlockerBarrier(reportError); } @@ -1710,7 +1685,6 @@ public: this->Makefile->StateSnapshot.SetListFile(currentStart); this->Makefile->StateSnapshot = this->Makefile->StateSnapshot.GetState() ->CreatePolicyScopeSnapshot(this->Makefile->StateSnapshot); - this->Makefile->PushPolicyBarrier(); this->Makefile->PushFunctionBlockerBarrier(); this->GG = mf->GetGlobalGenerator(); @@ -1727,8 +1701,6 @@ public: { this->Makefile->PopFunctionBlockerBarrier(this->ReportError); this->Makefile->PopPolicyBarrier(this->ReportError); - this->Makefile->StateSnapshot = this->Makefile->StateSnapshot.GetState() - ->Pop(this->Makefile->StateSnapshot); #if defined(CMAKE_BUILD_WITH_CMAKE) this->GG->GetFileLockPool().PopFileScope(); #endif @@ -4759,30 +4731,7 @@ const char* cmMakefile::GetDefineFlagsCMP0059() const cmPolicies::PolicyStatus cmMakefile::GetPolicyStatus(cmPolicies::PolicyID id) const { - cmPolicies::PolicyStatus status = cmPolicies::GetPolicyStatus(id); - - if(status == cmPolicies::REQUIRED_ALWAYS || - status == cmPolicies::REQUIRED_IF_USED) - { - return status; - } - - cmLocalGenerator* lg = this->LocalGenerator; - while(lg) - { - cmMakefile const* mf = lg->GetMakefile(); - for(PolicyStackType::const_reverse_iterator psi = - mf->PolicyStack.rbegin(); psi != mf->PolicyStack.rend(); ++psi) - { - if(psi->IsDefined(id)) - { - status = psi->Get(id); - return status; - } - } - lg = lg->GetParent(); - } - return status; + return this->StateSnapshot.GetPolicy(id); } //---------------------------------------------------------------------------- @@ -4831,15 +4780,7 @@ bool cmMakefile::SetPolicy(cmPolicies::PolicyID id, return false; } - // Update the policy stack from the top to the top-most strong entry. - bool previous_was_weak = true; - for(PolicyStackType::reverse_iterator psi = this->PolicyStack.rbegin(); - previous_was_weak && psi != this->PolicyStack.rend(); ++psi) - { - psi->Set(id, status); - previous_was_weak = psi->Weak; - } - + this->StateSnapshot.SetPolicy(id, status); return true; } @@ -4850,7 +4791,6 @@ cmMakefile::PolicyPushPop::PolicyPushPop(cmMakefile* m, bool weak, { this->Makefile->StateSnapshot = this->Makefile->StateSnapshot.GetState() ->CreatePolicyScopeSnapshot(this->Makefile->StateSnapshot); - this->Makefile->PushPolicyBarrier(); this->Makefile->PushPolicy(weak, pm); } @@ -4859,25 +4799,18 @@ cmMakefile::PolicyPushPop::~PolicyPushPop() { this->Makefile->PopPolicy(); this->Makefile->PopPolicyBarrier(this->ReportError); - this->Makefile->StateSnapshot = this->Makefile->StateSnapshot.GetState() - ->Pop(this->Makefile->StateSnapshot); } //---------------------------------------------------------------------------- void cmMakefile::PushPolicy(bool weak, cmPolicies::PolicyMap const& pm) { - // Allocate a new stack entry. - this->PolicyStack.push_back(PolicyStackEntry(pm, weak)); + this->StateSnapshot.PushPolicy(pm, weak); } //---------------------------------------------------------------------------- void cmMakefile::PopPolicy() { - if(this->PolicyStack.size() > this->PolicyBarriers.back()) - { - this->PolicyStack.pop_back(); - } - else + if (!this->StateSnapshot.PopPolicy()) { this->IssueMessage(cmake::FATAL_ERROR, "cmake_policy POP without matching PUSH"); @@ -4885,17 +4818,9 @@ void cmMakefile::PopPolicy() } //---------------------------------------------------------------------------- -void cmMakefile::PushPolicyBarrier() -{ - this->PolicyBarriers.push_back(this->PolicyStack.size()); -} - -//---------------------------------------------------------------------------- void cmMakefile::PopPolicyBarrier(bool reportError) { - // Remove any extra entries pushed on the barrier. - PolicyStackType::size_type barrier = this->PolicyBarriers.back(); - while(this->PolicyStack.size() > barrier) + while (!this->StateSnapshot.CanPopPolicyScope()) { if(reportError) { @@ -4906,8 +4831,8 @@ void cmMakefile::PopPolicyBarrier(bool reportError) this->PopPolicy(); } - // Remove the barrier. - this->PolicyBarriers.pop_back(); + this->StateSnapshot = this->GetState()->Pop(this->StateSnapshot); + assert(this->StateSnapshot.IsValid()); } //---------------------------------------------------------------------------- diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 1e5c301..173914e 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -909,7 +909,6 @@ private: void PushPolicy(bool weak = false, cmPolicies::PolicyMap const& pm = cmPolicies::PolicyMap()); void PopPolicy(); - void PushPolicyBarrier(); void PopPolicyBarrier(bool reportError = true); friend class cmCMakePolicyCommand; class IncludeScope; @@ -919,18 +918,6 @@ private: class BuildsystemFileScope; friend class BuildsystemFileScope; - // stack of policy settings - struct PolicyStackEntry: public cmPolicies::PolicyMap - { - typedef cmPolicies::PolicyMap derived; - PolicyStackEntry(bool w = false): derived(), Weak(w) {} - PolicyStackEntry(derived const& d, bool w = false): derived(d), Weak(w) {} - PolicyStackEntry(PolicyStackEntry const& r): derived(r), Weak(r.Weak) {} - bool Weak; - }; - typedef std::vector PolicyStackType; - PolicyStackType PolicyStack; - std::vector PolicyBarriers; // CMP0053 == old cmake::MessageType ExpandVariablesInStringOld( diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 1d24ec6..f425861 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -21,6 +21,9 @@ struct cmState::SnapshotDataType { cmState::PositionType DirectoryParent; + cmLinkedTree::iterator Policies; + cmLinkedTree::iterator PolicyRoot; + cmLinkedTree::iterator PolicyScope; cmState::SnapshotType SnapshotType; cmLinkedTree::iterator ExecutionListFile; cmLinkedTree::iterator @@ -32,6 +35,15 @@ struct cmState::SnapshotDataType std::vector::size_type CompileOptionsPosition; }; +struct cmState::PolicyStackEntry: public cmPolicies::PolicyMap +{ + typedef cmPolicies::PolicyMap derived; + PolicyStackEntry(bool w = false): derived(), Weak(w) {} + PolicyStackEntry(derived const& d, bool w): derived(d), Weak(w) {} + PolicyStackEntry(PolicyStackEntry const& r): derived(r), Weak(r.Weak) {} + bool Weak; +}; + struct cmState::BuildsystemDirectoryStateType { cmState::PositionType DirectoryEnd; @@ -256,6 +268,13 @@ cmState::Snapshot cmState::Reset() it->DirectoryEnd = pos; } + this->PolicyStack.Clear(); + pos->Policies = this->PolicyStack.Root(); + pos->PolicyRoot = this->PolicyStack.Root(); + pos->PolicyScope = this->PolicyStack.Root(); + assert(pos->Policies.IsValid()); + assert(pos->PolicyRoot.IsValid()); + this->DefineProperty ("RULE_LAUNCH_COMPILE", cmProperty::DIRECTORY, "", "", true); @@ -726,6 +745,11 @@ cmState::Snapshot cmState::CreateBaseSnapshot() pos->CompileDefinitionsPosition = 0; pos->CompileOptionsPosition = 0; pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->Policies = this->PolicyStack.Root(); + pos->PolicyRoot = this->PolicyStack.Root(); + pos->PolicyScope = this->PolicyStack.Root(); + assert(pos->Policies.IsValid()); + assert(pos->PolicyRoot.IsValid()); return cmState::Snapshot(this, pos); } @@ -747,6 +771,11 @@ cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot, this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile); pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->Policies = originSnapshot.Position->Policies; + pos->PolicyRoot = originSnapshot.Position->Policies; + pos->PolicyScope = originSnapshot.Position->Policies; + assert(pos->Policies.IsValid()); + assert(pos->PolicyRoot.IsValid()); return cmState::Snapshot(this, pos); } @@ -764,6 +793,7 @@ cmState::CreateFunctionCallSnapshot(cmState::Snapshot originSnapshot, pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile, fileName); pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->PolicyScope = originSnapshot.Position->Policies; return cmState::Snapshot(this, pos); } @@ -782,6 +812,7 @@ cmState::CreateMacroCallSnapshot(cmState::Snapshot originSnapshot, pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile, fileName); pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->PolicyScope = originSnapshot.Position->Policies; return cmState::Snapshot(this, pos); } @@ -799,6 +830,7 @@ cmState::CreateCallStackSnapshot(cmState::Snapshot originSnapshot, pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile, fileName); pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->PolicyScope = originSnapshot.Position->Policies; return cmState::Snapshot(this, pos); } @@ -816,6 +848,7 @@ cmState::CreateInlineListFileSnapshot(cmState::Snapshot originSnapshot, pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile, fileName); pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->PolicyScope = originSnapshot.Position->Policies; return cmState::Snapshot(this, pos); } @@ -826,6 +859,7 @@ cmState::CreatePolicyScopeSnapshot(cmState::Snapshot originSnapshot) *originSnapshot.Position); pos->SnapshotType = PolicyScopeType; pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->PolicyScope = originSnapshot.Position->Policies; return cmState::Snapshot(this, pos); } @@ -1005,6 +1039,88 @@ cmState::Snapshot cmState::Snapshot::GetCallStackParent() const return snapshot; } +void cmState::Snapshot::PushPolicy(cmPolicies::PolicyMap entry, bool weak) +{ + PositionType pos = this->Position; + pos->Policies = + this->State->PolicyStack.Extend(pos->Policies, + PolicyStackEntry(entry, weak)); +} + +bool cmState::Snapshot::PopPolicy() +{ + PositionType pos = this->Position; + if (pos->Policies == pos->PolicyScope) + { + return false; + } + ++pos->Policies; + return true; +} + +bool cmState::Snapshot::CanPopPolicyScope() +{ + return this->Position->Policies == this->Position->PolicyScope; +} + +void cmState::Snapshot::SetPolicy(cmPolicies::PolicyID id, + cmPolicies::PolicyStatus status) +{ + // Update the policy stack from the top to the top-most strong entry. + bool previous_was_weak = true; + for(cmLinkedTree::iterator psi = this->Position->Policies; + previous_was_weak && psi != this->Position->PolicyRoot; ++psi) + { + psi->Set(id, status); + previous_was_weak = psi->Weak; + } +} + +cmPolicies::PolicyStatus +cmState::Snapshot::GetPolicy(cmPolicies::PolicyID id) const +{ + cmPolicies::PolicyStatus status = cmPolicies::GetPolicyStatus(id); + + if(status == cmPolicies::REQUIRED_ALWAYS || + status == cmPolicies::REQUIRED_IF_USED) + { + return status; + } + + cmLinkedTree::iterator dir = + this->Position->BuildSystemDirectory; + + while (true) + { + assert(dir.IsValid()); + cmLinkedTree::iterator leaf = + dir->DirectoryEnd->Policies; + cmLinkedTree::iterator root = + dir->DirectoryEnd->PolicyRoot; + for( ; leaf != root; ++leaf) + { + if(leaf->IsDefined(id)) + { + status = leaf->Get(id); + return status; + } + } + cmState::PositionType e = dir->DirectoryEnd; + cmState::PositionType p = e->DirectoryParent; + if (p == this->State->SnapshotData.Root()) + { + break; + } + dir = p->BuildSystemDirectory; + } + return status; +} + +bool cmState::Snapshot::HasDefinedPolicyCMP0011() +{ + return !this->Position->Policies->IsEmpty(); +} + static const std::string cmPropertySentinal = std::string(); template diff --git a/Source/cmState.h b/Source/cmState.h index 63b60ef..07aa2a5 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -17,6 +17,7 @@ #include "cmPropertyMap.h" #include "cmLinkedTree.h" #include "cmAlgorithms.h" +#include "cmPolicies.h" class cmake; class cmCommand; @@ -24,6 +25,7 @@ class cmCommand; class cmState { struct SnapshotDataType; + struct PolicyStackEntry; struct BuildsystemDirectoryStateType; typedef cmLinkedTree::iterator PositionType; friend class Snapshot; @@ -61,6 +63,13 @@ public: void InitializeFromParent(); + void SetPolicy(cmPolicies::PolicyID id, cmPolicies::PolicyStatus status); + cmPolicies::PolicyStatus GetPolicy(cmPolicies::PolicyID id) const; + bool HasDefinedPolicyCMP0011(); + void PushPolicy(cmPolicies::PolicyMap entry, bool weak); + bool PopPolicy(); + bool CanPopPolicyScope(); + cmState* GetState() const; Directory GetDirectory() const; @@ -257,6 +266,7 @@ private: cmLinkedTree ExecutionListFiles; + cmLinkedTree PolicyStack; cmLinkedTree SnapshotData; std::vector SourceDirectoryComponents; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=52dbe654dea7562564be9d880540e6bc706998ba commit 52dbe654dea7562564be9d880540e6bc706998ba Author: Stephen Kelly AuthorDate: Sat Aug 1 07:20:26 2015 +0200 Commit: Stephen Kelly CommitDate: Sun Aug 2 08:56:57 2015 +0200 cmState: Record the end position of each directory. At generate time, variables and policies are determined from the end state of the cmMakefile. diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 09446bb..1d24ec6 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -34,6 +34,8 @@ struct cmState::SnapshotDataType struct cmState::BuildsystemDirectoryStateType { + cmState::PositionType DirectoryEnd; + std::string Location; std::string OutputLocation; @@ -239,6 +241,9 @@ cmState::Snapshot cmState::Reset() this->GlobalProperties.clear(); this->PropertyDefinitions.clear(); + PositionType pos = this->SnapshotData.Truncate(); + this->ExecutionListFiles.Truncate(); + { cmLinkedTree::iterator it = this->BuildsystemDirectory.Truncate(); @@ -248,9 +253,8 @@ cmState::Snapshot cmState::Reset() it->CompileDefinitionsBacktraces.clear(); it->CompileOptions.clear(); it->CompileOptionsBacktraces.clear(); + it->DirectoryEnd = pos; } - PositionType pos = this->SnapshotData.Truncate(); - this->ExecutionListFiles.Truncate(); this->DefineProperty ("RULE_LAUNCH_COMPILE", cmProperty::DIRECTORY, @@ -721,6 +725,7 @@ cmState::Snapshot cmState::CreateBaseSnapshot() pos->IncludeDirectoryPosition = 0; pos->CompileDefinitionsPosition = 0; pos->CompileOptionsPosition = 0; + pos->BuildSystemDirectory->DirectoryEnd = pos; return cmState::Snapshot(this, pos); } @@ -741,6 +746,7 @@ cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot, pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile); + pos->BuildSystemDirectory->DirectoryEnd = pos; return cmState::Snapshot(this, pos); } @@ -757,6 +763,7 @@ cmState::CreateFunctionCallSnapshot(cmState::Snapshot originSnapshot, pos->SnapshotType = FunctionCallType; pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile, fileName); + pos->BuildSystemDirectory->DirectoryEnd = pos; return cmState::Snapshot(this, pos); } @@ -774,6 +781,7 @@ cmState::CreateMacroCallSnapshot(cmState::Snapshot originSnapshot, pos->SnapshotType = MacroCallType; pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile, fileName); + pos->BuildSystemDirectory->DirectoryEnd = pos; return cmState::Snapshot(this, pos); } @@ -790,6 +798,7 @@ cmState::CreateCallStackSnapshot(cmState::Snapshot originSnapshot, pos->SnapshotType = CallStackType; pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile, fileName); + pos->BuildSystemDirectory->DirectoryEnd = pos; return cmState::Snapshot(this, pos); } @@ -806,6 +815,7 @@ cmState::CreateInlineListFileSnapshot(cmState::Snapshot originSnapshot, pos->SnapshotType = InlineListFileType; pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile, fileName); + pos->BuildSystemDirectory->DirectoryEnd = pos; return cmState::Snapshot(this, pos); } @@ -815,6 +825,7 @@ cmState::CreatePolicyScopeSnapshot(cmState::Snapshot originSnapshot) PositionType pos = this->SnapshotData.Extend(originSnapshot.Position, *originSnapshot.Position); pos->SnapshotType = PolicyScopeType; + pos->BuildSystemDirectory->DirectoryEnd = pos; return cmState::Snapshot(this, pos); } @@ -829,6 +840,7 @@ cmState::Snapshot cmState::Pop(cmState::Snapshot originSnapshot) prevPos->BuildSystemDirectory->CompileDefinitions.size(); prevPos->CompileOptionsPosition = prevPos->BuildSystemDirectory->CompileOptions.size(); + prevPos->BuildSystemDirectory->DirectoryEnd = prevPos; return Snapshot(this, prevPos); } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=65a5e0c671fc7d42525a6279aebf9a74de2c97a7 commit 65a5e0c671fc7d42525a6279aebf9a74de2c97a7 Author: Stephen Kelly AuthorDate: Sun Jun 14 01:38:57 2015 +0200 Commit: Stephen Kelly CommitDate: Sun Aug 2 08:56:57 2015 +0200 cmLinkedTree: Add Clear API. diff --git a/Source/cmLinkedTree.h b/Source/cmLinkedTree.h index df00b30..3bcb940 100644 --- a/Source/cmLinkedTree.h +++ b/Source/cmLinkedTree.h @@ -155,6 +155,12 @@ public: return iterator(this, 1); } + void Clear() + { + this->UpPositions.clear(); + this->Data.clear(); + } + private: T& GetReference(PositionType pos) { http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=348354333a82ce98d733dc2ee939186c53c506f9 commit 348354333a82ce98d733dc2ee939186c53c506f9 Author: Stephen Kelly AuthorDate: Sun Jul 26 12:56:10 2015 +0200 Commit: Stephen Kelly CommitDate: Sun Aug 2 08:56:57 2015 +0200 cmState: Add Type for policy scope. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 2c854dd..9fb3d06 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -189,6 +189,9 @@ cmMakefile::cmMakefile(cmLocalGenerator* localGenerator) this->cmAtVarRegex.compile("(@[A-Za-z_0-9/.+-]+@)"); this->cmNamedCurly.compile("^[A-Za-z0-9/_.+-]+{"); + this->StateSnapshot = this->StateSnapshot.GetState() + ->CreatePolicyScopeSnapshot(this->StateSnapshot); + // Protect the directory-level policies. this->PushPolicyBarrier(); @@ -1705,6 +1708,8 @@ public: this->Makefile->StateSnapshot.GetDirectory().GetCurrentSource(); currentStart += "/CMakeLists.txt"; this->Makefile->StateSnapshot.SetListFile(currentStart); + this->Makefile->StateSnapshot = this->Makefile->StateSnapshot.GetState() + ->CreatePolicyScopeSnapshot(this->Makefile->StateSnapshot); this->Makefile->PushPolicyBarrier(); this->Makefile->PushFunctionBlockerBarrier(); @@ -1722,6 +1727,8 @@ public: { this->Makefile->PopFunctionBlockerBarrier(this->ReportError); this->Makefile->PopPolicyBarrier(this->ReportError); + this->Makefile->StateSnapshot = this->Makefile->StateSnapshot.GetState() + ->Pop(this->Makefile->StateSnapshot); #if defined(CMAKE_BUILD_WITH_CMAKE) this->GG->GetFileLockPool().PopFileScope(); #endif @@ -4841,6 +4848,8 @@ cmMakefile::PolicyPushPop::PolicyPushPop(cmMakefile* m, bool weak, cmPolicies::PolicyMap const& pm): Makefile(m), ReportError(true) { + this->Makefile->StateSnapshot = this->Makefile->StateSnapshot.GetState() + ->CreatePolicyScopeSnapshot(this->Makefile->StateSnapshot); this->Makefile->PushPolicyBarrier(); this->Makefile->PushPolicy(weak, pm); } @@ -4850,6 +4859,8 @@ cmMakefile::PolicyPushPop::~PolicyPushPop() { this->Makefile->PopPolicy(); this->Makefile->PopPolicyBarrier(this->ReportError); + this->Makefile->StateSnapshot = this->Makefile->StateSnapshot.GetState() + ->Pop(this->Makefile->StateSnapshot); } //---------------------------------------------------------------------------- diff --git a/Source/cmState.cxx b/Source/cmState.cxx index a7df040..09446bb 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -809,6 +809,15 @@ cmState::CreateInlineListFileSnapshot(cmState::Snapshot originSnapshot, return cmState::Snapshot(this, pos); } +cmState::Snapshot +cmState::CreatePolicyScopeSnapshot(cmState::Snapshot originSnapshot) +{ + PositionType pos = this->SnapshotData.Extend(originSnapshot.Position, + *originSnapshot.Position); + pos->SnapshotType = PolicyScopeType; + return cmState::Snapshot(this, pos); +} + cmState::Snapshot cmState::Pop(cmState::Snapshot originSnapshot) { PositionType pos = originSnapshot.Position; @@ -959,13 +968,22 @@ cmState::Snapshot cmState::Snapshot::GetCallStackParent() const assert(this->Position != this->State->SnapshotData.Root()); Snapshot snapshot; - if (this->Position->SnapshotType == cmState::BuildsystemDirectoryType) + PositionType parentPos = this->Position; + while(parentPos->SnapshotType == cmState::PolicyScopeType) + { + ++parentPos; + } + if (parentPos->SnapshotType == cmState::BuildsystemDirectoryType) { return snapshot; } - PositionType parentPos = this->Position; ++parentPos; + while(parentPos->SnapshotType == cmState::PolicyScopeType) + { + ++parentPos; + } + if (parentPos == this->State->SnapshotData.Root()) { return snapshot; diff --git a/Source/cmState.h b/Source/cmState.h index 23fbc79..63b60ef 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -37,7 +37,8 @@ public: FunctionCallType, MacroCallType, CallStackType, - InlineListFileType + InlineListFileType, + PolicyScopeType }; class Directory; @@ -148,6 +149,7 @@ public: const std::string& entryPointCommand, long entryPointLine, std::string const& fileName); + Snapshot CreatePolicyScopeSnapshot(Snapshot originSnapshot); Snapshot Pop(Snapshot originSnapshot); enum CacheEntryType{ BOOL=0, PATH, FILEPATH, STRING, INTERNAL,STATIC, ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From steveire at gmail.com Sun Aug 2 16:05:39 2015 From: steveire at gmail.com (Stephen Kelly) Date: Sun, 2 Aug 2015 16:05:39 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1746-g0482b6b Message-ID: <20150802200539.9D6D8B0F8B@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 0482b6b05eb3386880330ebbe0da534e88fed5cf (commit) via 03a5fe5ebc82e96f56d8d3aa7c4fff32799823a3 (commit) from e673ea37477d270aae309542366f1d93c246fa88 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0482b6b05eb3386880330ebbe0da534e88fed5cf commit 0482b6b05eb3386880330ebbe0da534e88fed5cf Merge: e673ea3 03a5fe5 Author: Stephen Kelly AuthorDate: Sun Aug 2 16:05:38 2015 -0400 Commit: CMake Topic Stage CommitDate: Sun Aug 2 16:05:38 2015 -0400 Merge topic 'use-generator-target' into next 03a5fe5e fixup! cmGeneratorTarget: Move GetFullName from cmTarget. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=03a5fe5ebc82e96f56d8d3aa7c4fff32799823a3 commit 03a5fe5ebc82e96f56d8d3aa7c4fff32799823a3 Author: Stephen Kelly AuthorDate: Sun Aug 2 22:01:38 2015 +0200 Commit: Stephen Kelly CommitDate: Sun Aug 2 22:01:38 2015 +0200 fixup! cmGeneratorTarget: Move GetFullName from cmTarget. diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 48b610b..a38a061 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1250,8 +1250,6 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, targetNameImport, targetNamePDB, configName); // Compute the link library and directory information. - cmGeneratorTarget* gt = - this->GlobalGenerator->GetGeneratorTarget(&target); cmComputeLinkInformation* pcli = gt->GetLinkInformation(configName); if(!pcli) { ----------------------------------------------------------------------- Summary of changes: Source/cmLocalVisualStudio7Generator.cxx | 2 -- 1 file changed, 2 deletions(-) hooks/post-receive -- CMake From steveire at gmail.com Sun Aug 2 16:07:07 2015 From: steveire at gmail.com (Stephen Kelly) Date: Sun, 2 Aug 2015 16:07:07 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1762-g6648c4d Message-ID: <20150802200707.3B2A4B0F9B@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 6648c4d2f8a390350e5361f4f7c5d1ee12911fae (commit) via 63ddd44c50cff1ec78513b97d1d7d45b3e2950fb (commit) via e7c376aa9c250e79918b3a01db301308912cb41a (commit) via 875f5a9449cf2ec596566c2e7496c93c34320009 (commit) via 756e89674e89efb180380a4b87141ca0e90e6191 (commit) via d96fe03397e73823846626446f1b9dbc11d7ed44 (commit) via 95e71fbe954c252fa8562507f52e2ada01ff160f (commit) via ebef362af12f7be46edfce4af9e93e124ece17e3 (commit) via 520d76306f8eca0b3b6792e6734deb7f893d23a2 (commit) via 57c42044578479ca3e734eb251728627dfcb8c9a (commit) via 83bfb2dfe55e77b9a3d0e655bd30aa23399c29e6 (commit) via 3bb7b1f045b47e4f83ed2c9e07cc9bfc4285be7c (commit) via fe5391eecaf19d2741cb25f6690dbc21c05aeae7 (commit) via c0497de1233b363afd983bc97af00b5d7fe27950 (commit) via 4031d184b53b6cff621e30663f80c7d86bee7aa8 (commit) via 7c8954af013c05f373c6753e17860dddd42eaee1 (commit) from 0482b6b05eb3386880330ebbe0da534e88fed5cf (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6648c4d2f8a390350e5361f4f7c5d1ee12911fae commit 6648c4d2f8a390350e5361f4f7c5d1ee12911fae Merge: 0482b6b 63ddd44 Author: Stephen Kelly AuthorDate: Sun Aug 2 16:07:04 2015 -0400 Commit: CMake Topic Stage CommitDate: Sun Aug 2 16:07:04 2015 -0400 Merge topic 'use-generator-target' into next 63ddd44c cmOrderDirectories: Port to cmGeneratorTarget. e7c376aa cmMakefile: Remove unused method. 875f5a94 cmGlobalGenerator: Base exclusion computation on cmGeneratorTarget. 756e8967 cmGeneratorTarget: Move CompileInfoMap from cmTarget. d96fe033 cmGeneratorTarget: Move GetCompilePDBDirectory from cmTarget. 95e71fbe cmGeneratorTarget: Move GetOutputName from cmTarget. ebef362a cmComputeLinkDepends: Port to cmGeneratorTarget. 520d7630 cmComputeLinkInformation: Port to cmGeneratorTarget. 57c42044 cmGeneratorTarget: Move IsBundleOnApple from cmTarget. 83bfb2df cmMakefileTargetGenerator: Add accessor for GeneratorTarget. 3bb7b1f0 cmGeneratorTarget: Move GetLinkClosure from cmTarget. fe5391ee cmGeneratorTarget: Move GetLinkerLanguage from cmTarget. c0497de1 cmGeneratorTarget: Move GetFrameworkDirectory from cmTarget. 4031d184 cmGeneratorTarget: Move GetFullNameInternal from cmTarget. 7c8954af cmGeneratorTarget: Move GetFullName from cmTarget. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=63ddd44c50cff1ec78513b97d1d7d45b3e2950fb commit 63ddd44c50cff1ec78513b97d1d7d45b3e2950fb Author: Stephen Kelly AuthorDate: Sat Aug 1 09:48:04 2015 +0200 Commit: Stephen Kelly CommitDate: Sun Aug 2 22:06:05 2015 +0200 cmOrderDirectories: Port to cmGeneratorTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 5cd0d54..e0c6e86 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -260,10 +260,10 @@ cmComputeLinkInformation // Allocate internals. this->OrderLinkerSearchPath = - new cmOrderDirectories(this->GlobalGenerator, target->Target, + new cmOrderDirectories(this->GlobalGenerator, target, "linker search path"); this->OrderRuntimeSearchPath = - new cmOrderDirectories(this->GlobalGenerator, target->Target, + new cmOrderDirectories(this->GlobalGenerator, target, "runtime search path"); this->OrderDependentRPath = 0; @@ -370,7 +370,7 @@ cmComputeLinkInformation { this->SharedDependencyMode = SharedDepModeDir; this->OrderDependentRPath = - new cmOrderDirectories(this->GlobalGenerator, target->Target, + new cmOrderDirectories(this->GlobalGenerator, target, "dependent library path"); } diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx index a612437..35ee127 100644 --- a/Source/cmOrderDirectories.cxx +++ b/Source/cmOrderDirectories.cxx @@ -280,7 +280,7 @@ bool cmOrderDirectoriesConstraintLibrary::FindConflict(std::string const& dir) //---------------------------------------------------------------------------- cmOrderDirectories::cmOrderDirectories(cmGlobalGenerator* gg, - cmTarget const* target, + const cmGeneratorTarget* target, const char* purpose) { this->GlobalGenerator = gg; @@ -554,7 +554,8 @@ void cmOrderDirectories::FindImplicitConflicts() << text << "Some of these libraries may not be found correctly."; this->GlobalGenerator->GetCMakeInstance() - ->IssueMessage(cmake::WARNING, w.str(), this->Target->GetBacktrace()); + ->IssueMessage(cmake::WARNING, w.str(), + this->Target->Target->GetBacktrace()); } //---------------------------------------------------------------------------- @@ -635,5 +636,6 @@ void cmOrderDirectories::DiagnoseCycle() } e << "Some of these libraries may not be found correctly."; this->GlobalGenerator->GetCMakeInstance() - ->IssueMessage(cmake::WARNING, e.str(), this->Target->GetBacktrace()); + ->IssueMessage(cmake::WARNING, e.str(), + this->Target->Target->GetBacktrace()); } diff --git a/Source/cmOrderDirectories.h b/Source/cmOrderDirectories.h index cb5a51f..211c786 100644 --- a/Source/cmOrderDirectories.h +++ b/Source/cmOrderDirectories.h @@ -19,7 +19,7 @@ class cmGlobalGenerator; class cmOrderDirectoriesConstraint; class cmOrderDirectoriesConstraintLibrary; -class cmTarget; +class cmGeneratorTarget; /** \class cmOrderDirectories * \brief Compute a safe runtime path order for a set of shared libraries. @@ -27,7 +27,7 @@ class cmTarget; class cmOrderDirectories { public: - cmOrderDirectories(cmGlobalGenerator* gg, cmTarget const* target, + cmOrderDirectories(cmGlobalGenerator* gg, cmGeneratorTarget const* target, const char* purpose); ~cmOrderDirectories(); void AddRuntimeLibrary(std::string const& fullPath, const char* soname = 0); @@ -41,7 +41,7 @@ public: std::vector const& GetOrderedDirectories(); private: cmGlobalGenerator* GlobalGenerator; - cmTarget const* Target; + cmGeneratorTarget const* Target; std::string Purpose; std::vector OrderedDirectories; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e7c376aa9c250e79918b3a01db301308912cb41a commit e7c376aa9c250e79918b3a01db301308912cb41a Author: Stephen Kelly AuthorDate: Sat Jun 6 14:27:52 2015 +0200 Commit: Stephen Kelly CommitDate: Sun Aug 2 22:06:05 2015 +0200 cmMakefile: Remove unused method. diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 1e5c301..00d4005 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -113,10 +113,6 @@ public: bool GetIsSourceFileTryCompile() const; - ///! Get the current makefile generator. - cmLocalGenerator* GetLocalGenerator() const - { return this->LocalGenerator;} - /** * Help enforce global target name uniqueness. */ http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=875f5a9449cf2ec596566c2e7496c93c34320009 commit 875f5a9449cf2ec596566c2e7496c93c34320009 Author: Stephen Kelly AuthorDate: Sat Jun 6 14:09:35 2015 +0200 Commit: Stephen Kelly CommitDate: Sun Aug 2 22:06:05 2015 +0200 cmGlobalGenerator: Base exclusion computation on cmGeneratorTarget. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 1d6608b..b14949a 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2022,10 +2022,10 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, } bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, - cmTarget const& target) const + cmGeneratorTarget* target) const { - if(target.GetType() == cmTarget::INTERFACE_LIBRARY - || target.GetPropertyAsBool("EXCLUDE_FROM_ALL")) + if(target->GetType() == cmTarget::INTERFACE_LIBRARY + || target->Target->GetPropertyAsBool("EXCLUDE_FROM_ALL")) { // This target is excluded from its directory. return true; @@ -2034,7 +2034,7 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, { // This target is included in its directory. Check whether the // directory is excluded. - return this->IsExcluded(root, target.GetMakefile()->GetLocalGenerator()); + return this->IsExcluded(root, target->GetLocalGenerator()); } } @@ -2095,15 +2095,16 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap() { cmTarget const& target = t->second; + cmGeneratorTarget* gt = this->GetGeneratorTarget(&target); + // Consider the directory containing the target and all its // parents until something excludes the target. - for(cmLocalGenerator* clg = lg; clg && !this->IsExcluded(clg, target); + for(cmLocalGenerator* clg = lg; clg && !this->IsExcluded(clg, gt); clg = clg->GetParent()) { // This local generator includes the target. std::set& targetSet = this->LocalGeneratorToTargetMap[clg]; - cmGeneratorTarget* gt = this->GetGeneratorTarget(&target); targetSet.insert(gt); // Add dependencies of the included target. An excluded diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 9492372..3be76b6 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -398,7 +398,7 @@ protected: void FillProjectMap(); void CheckLocalGenerators(); bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen) const; - bool IsExcluded(cmLocalGenerator* root, cmTarget const& target) const; + bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) const; void FillLocalGeneratorToTargetMap(); void CreateDefaultGlobalTargets(cmTargets* targets); cmTarget CreateGlobalTarget(const std::string& name, const char* message, diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 2a749c1..47822b4 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -289,7 +289,7 @@ public: const std::vector& GetLocalGenerators() const { return LocalGenerators; } - bool IsExcluded(cmLocalGenerator* root, cmTarget& target) { + bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) { return cmGlobalGenerator::IsExcluded(root, target); } int GetRuleCmdLength(const std::string& name) { diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 69747a4..76d059ee 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -821,7 +821,7 @@ cmGlobalUnixMakefileGenerator3 localName, depends, commands, true); // add the all/all dependency - if(!this->IsExcluded(this->LocalGenerators[0], *gtarget->Target)) + if(!this->IsExcluded(this->LocalGenerators[0], gtarget)) { depends.clear(); depends.push_back(localName); @@ -889,7 +889,7 @@ cmGlobalUnixMakefileGenerator3 "Pre-install relink rule for target.", localName, depends, commands, true); - if(!this->IsExcluded(this->LocalGenerators[0], *gtarget->Target)) + if(!this->IsExcluded(this->LocalGenerators[0], gtarget)) { depends.clear(); depends.push_back(localName); diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 2f9d79a..c06dfb3 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -111,17 +111,18 @@ bool cmGlobalVisualStudioGenerator::Compute() for(std::vector::iterator i = gen.begin(); i != gen.end(); ++i) { - cmTargets& targets = (*i)->GetMakefile()->GetTargets(); - for(cmTargets::iterator t = targets.begin(); + cmGeneratorTargetsType targets = + (*i)->GetMakefile()->GetGeneratorTargets(); + for(cmGeneratorTargetsType::iterator t = targets.begin(); t != targets.end(); ++t) { - if (t->second.GetType() == cmTarget::GLOBAL_TARGET) + if (t->second->GetType() == cmTarget::GLOBAL_TARGET) { continue; } if(!this->IsExcluded(gen[0], t->second)) { - allBuild->AddUtility(t->second.GetName()); + allBuild->AddUtility(t->second->GetName()); } } } diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 9889bd4..1822c97 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -90,7 +90,7 @@ void cmLocalNinjaGenerator::Generate() // Add the target to "all" if required. if (!this->GetGlobalNinjaGenerator()->IsExcluded( this->GetGlobalNinjaGenerator()->GetLocalGenerators()[0], - *t->second->Target)) + t->second)) this->GetGlobalNinjaGenerator()->AddDependencyToAll(t->second->Target); delete tg; } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=756e89674e89efb180380a4b87141ca0e90e6191 commit 756e89674e89efb180380a4b87141ca0e90e6191 Author: Stephen Kelly AuthorDate: Mon Oct 20 21:02:16 2014 +0200 Commit: Stephen Kelly CommitDate: Sun Aug 2 22:06:05 2015 +0200 cmGeneratorTarget: Move CompileInfoMap from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c6f248c..c831704 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1356,6 +1356,46 @@ cmGeneratorTarget::GetMacContentDirectory(const std::string& config, return fpath; } + +//---------------------------------------------------------------------------- +cmGeneratorTarget::CompileInfo const* cmGeneratorTarget::GetCompileInfo( + const std::string& config) const +{ + // There is no compile information for imported targets. + if(this->IsImported()) + { + return 0; + } + + if(this->GetType() > cmTarget::OBJECT_LIBRARY) + { + std::string msg = "cmTarget::GetCompileInfo called for "; + msg += this->GetName(); + msg += " which has type "; + msg += cmTarget::GetTargetTypeName(this->Target->GetType()); + this->Makefile->IssueMessage(cmake::INTERNAL_ERROR, msg); + return 0; + } + + // Lookup/compute/cache the compile information for this configuration. + std::string config_upper; + if(!config.empty()) + { + config_upper = cmSystemTools::UpperCase(config); + } + CompileInfoMapType::const_iterator i = + this->CompileInfoMap.find(config_upper); + if(i == this->CompileInfoMap.end()) + { + CompileInfo info; + this->Target + ->ComputePDBOutputDir("COMPILE_PDB", config, info.CompilePdbDir); + CompileInfoMapType::value_type entry(config_upper, info); + i = this->CompileInfoMap.insert(entry).first; + } + return &i->second; +} + //---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetModuleDefinitionFile(const std::string& config) const @@ -1827,7 +1867,7 @@ void cmGeneratorTarget::TraceDependencies() std::string cmGeneratorTarget::GetCompilePDBDirectory(const std::string& config) const { - if(cmTarget::CompileInfo const* info = this->Target->GetCompileInfo(config)) + if(CompileInfo const* info = this->GetCompileInfo(config)) { return info->CompilePdbDir; } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index c291919..1d7a411 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -230,6 +230,16 @@ public: /** Whether this library has soname enabled and platform supports it. */ bool HasSOName(const std::string& config) const; + struct CompileInfo + { + std::string CompilePdbDir; + }; + + CompileInfo const* GetCompileInfo(const std::string& config) const; + + typedef std::map CompileInfoMapType; + mutable CompileInfoMapType CompileInfoMap; + /** Get the name of the compiler pdb file for the target. */ std::string GetCompilePDBName(const std::string& config="") const; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 9308113..1f8f07a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -126,9 +126,6 @@ public: typedef std::map ImportInfoMapType; ImportInfoMapType ImportInfoMap; - typedef std::map CompileInfoMapType; - CompileInfoMapType CompileInfoMap; - // Cache link implementation computation from each configuration. struct OptionalLinkImplementation: public cmTarget::LinkImplementation { @@ -2598,45 +2595,6 @@ cmTarget::OutputInfo const* cmTarget::GetOutputInfo( } //---------------------------------------------------------------------------- -cmTarget::CompileInfo const* cmTarget::GetCompileInfo( - const std::string& config) const -{ - // There is no compile information for imported targets. - if(this->IsImported()) - { - return 0; - } - - if(this->GetType() > cmTarget::OBJECT_LIBRARY) - { - std::string msg = "cmTarget::GetCompileInfo called for "; - msg += this->GetName(); - msg += " which has type "; - msg += cmTarget::GetTargetTypeName(this->GetType()); - this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg); - return 0; - } - - // Lookup/compute/cache the compile information for this configuration. - std::string config_upper; - if(!config.empty()) - { - config_upper = cmSystemTools::UpperCase(config); - } - typedef cmTargetInternals::CompileInfoMapType CompileInfoMapType; - CompileInfoMapType::const_iterator i = - this->Internal->CompileInfoMap.find(config_upper); - if(i == this->Internal->CompileInfoMap.end()) - { - CompileInfo info; - this->ComputePDBOutputDir("COMPILE_PDB", config, info.CompilePdbDir); - CompileInfoMapType::value_type entry(config_upper, info); - i = this->Internal->CompileInfoMap.insert(entry).first; - } - return &i->second; -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetDirectory(const std::string& config, bool implib) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 8689838..e3fbdfd 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -626,13 +626,6 @@ private: void ComputeImportInfo(std::string const& desired_config, ImportInfo& info) const; - // Cache target compile paths for each configuration. - struct CompileInfo - { - std::string CompilePdbDir; - }; - - CompileInfo const* GetCompileInfo(const std::string& config) const; LinkInterface const* GetImportLinkInterface(const std::string& config, cmTarget const* head, http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d96fe03397e73823846626446f1b9dbc11d7ed44 commit d96fe03397e73823846626446f1b9dbc11d7ed44 Author: Stephen Kelly AuthorDate: Mon Oct 20 20:52:54 2014 +0200 Commit: Stephen Kelly CommitDate: Sun Aug 2 22:06:04 2015 +0200 cmGeneratorTarget: Move GetCompilePDBDirectory from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index aac941e..c6f248c 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -743,7 +743,7 @@ cmGeneratorTarget::GetCompilePDBName(const std::string& config) const std::string cmGeneratorTarget::GetCompilePDBPath(const std::string& config) const { - std::string dir = this->Target->GetCompilePDBDirectory(config); + std::string dir = this->GetCompilePDBDirectory(config); std::string name = this->GetCompilePDBName(config); if(dir.empty() && !name.empty()) { @@ -1824,6 +1824,16 @@ void cmGeneratorTarget::TraceDependencies() tracer.Trace(); } +std::string +cmGeneratorTarget::GetCompilePDBDirectory(const std::string& config) const +{ + if(cmTarget::CompileInfo const* info = this->Target->GetCompileInfo(config)) + { + return info->CompilePdbDir; + } + return ""; +} + //---------------------------------------------------------------------------- void cmGeneratorTarget::GetAppleArchs(const std::string& config, std::vector& archVec) const diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 31b3178..c291919 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -214,6 +214,12 @@ public: */ void TraceDependencies(); + /** Get the directory in which to place the target compiler .pdb file. + If the configuration name is given then the generator will add its + subdirectory for that configuration. Otherwise just the canonical + compiler pdb output directory is given. */ + std::string GetCompilePDBDirectory(const std::string& config = "") const; + /** Get sources that must be built before the given source. */ std::vector const* GetSourceDepends(cmSourceFile const* sf) const; diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index afe145a..ccb0974 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -130,7 +130,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) } std::string compilePdbOutputPath = - this->Target->GetCompilePDBDirectory(this->ConfigName); + this->GeneratorTarget->GetCompilePDBDirectory(this->ConfigName); cmSystemTools::MakeDirectory(compilePdbOutputPath.c_str()); std::string pdbOutputPath = this->Target->GetPDBDirectory(this->ConfigName); diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index bb0f9dd..2f995e8 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -311,7 +311,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules } std::string compilePdbOutputPath = - this->Target->GetCompilePDBDirectory(this->ConfigName); + this->GeneratorTarget->GetCompilePDBDirectory(this->ConfigName); cmSystemTools::MakeDirectory(compilePdbOutputPath.c_str()); std::string pdbOutputPath = this->Target->GetPDBDirectory(this->ConfigName); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 8b64bc4..9308113 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -69,12 +69,6 @@ struct cmTarget::OutputInfo }; //---------------------------------------------------------------------------- -struct cmTarget::CompileInfo -{ - std::string CompilePdbDir; -}; - -//---------------------------------------------------------------------------- class cmTargetInternals { public: @@ -2673,16 +2667,6 @@ std::string cmTarget::GetPDBDirectory(const std::string& config) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetCompilePDBDirectory(const std::string& config) const -{ - if(CompileInfo const* info = this->GetCompileInfo(config)) - { - return info->CompilePdbDir; - } - return ""; -} - -//---------------------------------------------------------------------------- const char* cmTarget::ImportedGetLocation(const std::string& config) const { static std::string location; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index a6f2465..8689838 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -334,12 +334,6 @@ public: pdb output directory is given. */ std::string GetPDBDirectory(const std::string& config) const; - /** Get the directory in which to place the target compiler .pdb file. - If the configuration name is given then the generator will add its - subdirectory for that configuration. Otherwise just the canonical - compiler pdb output directory is given. */ - std::string GetCompilePDBDirectory(const std::string& config = "") const; - const char* ImportedGetLocation(const std::string& config) const; /** Get the target major and minor version numbers interpreted from @@ -633,7 +627,11 @@ private: ImportInfo& info) const; // Cache target compile paths for each configuration. - struct CompileInfo; + struct CompileInfo + { + std::string CompilePdbDir; + }; + CompileInfo const* GetCompileInfo(const std::string& config) const; LinkInterface const* http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=95e71fbe954c252fa8562507f52e2ada01ff160f commit 95e71fbe954c252fa8562507f52e2ada01ff160f Author: Stephen Kelly AuthorDate: Sat Aug 1 07:04:23 2015 +0200 Commit: Stephen Kelly CommitDate: Sun Aug 2 22:06:04 2015 +0200 cmGeneratorTarget: Move GetOutputName from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 55e2922..aac941e 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -267,6 +267,54 @@ const char *cmGeneratorTarget::GetProperty(const std::string& prop) const } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetOutputName(const std::string& config, + bool implib) const +{ + std::vector props; + std::string type = this->Target->GetOutputTargetType(implib); + std::string configUpper = cmSystemTools::UpperCase(config); + if(!type.empty() && !configUpper.empty()) + { + // _OUTPUT_NAME_ + props.push_back(type + "_OUTPUT_NAME_" + configUpper); + } + if(!type.empty()) + { + // _OUTPUT_NAME + props.push_back(type + "_OUTPUT_NAME"); + } + if(!configUpper.empty()) + { + // OUTPUT_NAME_ + props.push_back("OUTPUT_NAME_" + configUpper); + // _OUTPUT_NAME + props.push_back(configUpper + "_OUTPUT_NAME"); + } + // OUTPUT_NAME + props.push_back("OUTPUT_NAME"); + + std::string outName; + for(std::vector::const_iterator i = props.begin(); + i != props.end(); ++i) + { + if (const char* outNameProp = this->Target->GetProperty(*i)) + { + outName = outNameProp; + break; + } + } + + if (outName.empty()) + { + outName = this->GetName(); + } + + cmGeneratorExpression ge; + cmsys::auto_ptr cge = ge.Parse(outName); + return cge->Evaluate(this->Makefile, config); +} + +//---------------------------------------------------------------------------- std::vector const* cmGeneratorTarget::GetSourceDepends(cmSourceFile const* sf) const { @@ -922,7 +970,7 @@ std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config, bool contentOnly) const { std::string fpath; - fpath += this->Target->GetOutputName(config, false); + fpath += this->GetOutputName(config, false); fpath += "."; const char *ext = this->Target->GetProperty("BUNDLE_EXTENSION"); if (!ext) @@ -949,7 +997,7 @@ cmGeneratorTarget::GetFrameworkDirectory(const std::string& config, bool rootDir) const { std::string fpath; - fpath += this->Target->GetOutputName(config, false); + fpath += this->GetOutputName(config, false); fpath += ".framework"; if(!rootDir) { @@ -2247,7 +2295,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, std::string fw_prefix; if(this->Target->IsFrameworkOnApple()) { - fw_prefix = this->Target->GetOutputName(config, false); + fw_prefix = this->GetOutputName(config, false); fw_prefix += ".framework/"; targetPrefix = fw_prefix.c_str(); targetSuffix = 0; @@ -2265,7 +2313,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, outPrefix = targetPrefix?targetPrefix:""; // Append the target name or property-specified name. - outBase += this->Target->GetOutputName(config, implib); + outBase += this->GetOutputName(config, implib); // Append the per-configuration postfix. outBase += configPostfix?configPostfix:""; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index d10cd1d..31b3178 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -230,6 +230,9 @@ public: /** Get the path for the MSVC /Fd option for this target. */ std::string GetCompilePDBPath(const std::string& config="") const; + // Get the target base name. + std::string GetOutputName(const std::string& config, bool implib) const; + /** * Flags for a given source file as used in this target. Typically assigned * via SET_TARGET_PROPERTIES when the property is a list of source files. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e887ef3..8b64bc4 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3663,54 +3663,6 @@ bool cmTarget::UsesDefaultOutputDir(const std::string& config, } //---------------------------------------------------------------------------- -std::string cmTarget::GetOutputName(const std::string& config, - bool implib) const -{ - std::vector props; - std::string type = this->GetOutputTargetType(implib); - std::string configUpper = cmSystemTools::UpperCase(config); - if(!type.empty() && !configUpper.empty()) - { - // _OUTPUT_NAME_ - props.push_back(type + "_OUTPUT_NAME_" + configUpper); - } - if(!type.empty()) - { - // _OUTPUT_NAME - props.push_back(type + "_OUTPUT_NAME"); - } - if(!configUpper.empty()) - { - // OUTPUT_NAME_ - props.push_back("OUTPUT_NAME_" + configUpper); - // _OUTPUT_NAME - props.push_back(configUpper + "_OUTPUT_NAME"); - } - // OUTPUT_NAME - props.push_back("OUTPUT_NAME"); - - std::string outName; - for(std::vector::const_iterator i = props.begin(); - i != props.end(); ++i) - { - if (const char* outNameProp = this->GetProperty(*i)) - { - outName = outNameProp; - break; - } - } - - if (outName.empty()) - { - outName = this->GetName(); - } - - cmGeneratorExpression ge; - cmsys::auto_ptr cge = ge.Parse(outName); - return cge->Evaluate(this->Makefile, config); -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetFrameworkVersion() const { assert(this->GetType() != INTERFACE_LIBRARY); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e53afff..a6f2465 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -552,9 +552,6 @@ private: // Returns ARCHIVE, LIBRARY, or RUNTIME based on platform and type. const char* GetOutputTargetType(bool implib) const; - // Get the target base name. - std::string GetOutputName(const std::string& config, bool implib) const; - std::string GetFullNameImported(const std::string& config, bool implib) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ebef362af12f7be46edfce4af9e93e124ece17e3 commit ebef362af12f7be46edfce4af9e93e124ece17e3 Author: Stephen Kelly AuthorDate: Thu Jul 30 00:45:34 2015 +0200 Commit: Stephen Kelly CommitDate: Sun Aug 2 22:06:04 2015 +0200 cmComputeLinkDepends: Port to cmGeneratorTarget. diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index abd9877..8ba8847 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -173,18 +173,19 @@ items that we know the linker will re-use automatically (shared libs). //---------------------------------------------------------------------------- cmComputeLinkDepends -::cmComputeLinkDepends(cmTarget const* target, const std::string& config) +::cmComputeLinkDepends(const cmGeneratorTarget* target, + const std::string& config) { // Store context information. this->Target = target; - this->Makefile = this->Target->GetMakefile(); + this->Makefile = this->Target->Target->GetMakefile(); this->GlobalGenerator = this->Makefile->GetGlobalGenerator(); this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance(); // The configuration being linked. this->HasConfig = !config.empty(); this->Config = (this->HasConfig)? config : std::string(); - this->LinkType = this->Target->ComputeLinkType(this->Config); + this->LinkType = this->Target->Target->ComputeLinkType(this->Config); // Enable debug mode if requested. this->DebugMode = this->Makefile->IsOn("CMAKE_LINK_DEPENDS_DEBUG_MODE"); @@ -363,7 +364,7 @@ void cmComputeLinkDepends::FollowLinkEntry(BFSEntry const& qe) { // Follow the target dependencies. if(cmTarget::LinkInterface const* iface = - entry.Target->GetLinkInterface(this->Config, this->Target)) + entry.Target->GetLinkInterface(this->Config, this->Target->Target)) { const bool isIface = entry.Target->GetType() == cmTarget::INTERFACE_LIBRARY; @@ -461,7 +462,7 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep) if(entry.Target) { if(cmTarget::LinkInterface const* iface = - entry.Target->GetLinkInterface(this->Config, this->Target)) + entry.Target->GetLinkInterface(this->Config, this->Target->Target)) { // Follow public and private dependencies transitively. this->FollowSharedDeps(index, iface, true); @@ -552,7 +553,7 @@ void cmComputeLinkDepends::AddDirectLinkEntries() { // Add direct link dependencies in this configuration. cmTarget::LinkImplementation const* impl = - this->Target->GetLinkImplementation(this->Config); + this->Target->Target->GetLinkImplementation(this->Config); this->AddLinkEntries(-1, impl->Libraries); for(std::vector::const_iterator wi = impl->WrongConfigLibraries.begin(); @@ -634,7 +635,7 @@ cmTarget const* cmComputeLinkDepends::FindTargetToLink(int depender_index, const std::string& name) { // Look for a target in the scope of the depender. - cmTarget const* from = this->Target; + cmTarget const* from = this->Target->Target; if(depender_index >= 0) { if(cmTarget const* depender = this->EntryList[depender_index].Target) @@ -932,7 +933,7 @@ int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl) if(cmTarget const* target = this->EntryList[*ni].Target) { if(cmTarget::LinkInterface const* iface = - target->GetLinkInterface(this->Config, this->Target)) + target->GetLinkInterface(this->Config, this->Target->Target)) { if(iface->Multiplicity > count) { diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index 51a08c5..b925a4f 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -22,6 +22,7 @@ class cmComputeComponentGraph; class cmGlobalGenerator; class cmMakefile; +class cmGeneratorTarget; class cmTarget; class cmake; @@ -31,7 +32,8 @@ class cmake; class cmComputeLinkDepends { public: - cmComputeLinkDepends(cmTarget const* target, const std::string& config); + cmComputeLinkDepends(cmGeneratorTarget const* target, + const std::string& config); ~cmComputeLinkDepends(); // Basic information about each link item. @@ -57,7 +59,7 @@ public: private: // Context information. - cmTarget const* Target; + cmGeneratorTarget const* Target; cmMakefile* Makefile; cmGlobalGenerator const* GlobalGenerator; cmake* CMakeInstance; diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index fb89319..5cd0d54 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -497,7 +497,7 @@ bool cmComputeLinkInformation::Compute() } // Compute the ordered link line items. - cmComputeLinkDepends cld(this->Target->Target, this->Config); + cmComputeLinkDepends cld(this->Target, this->Config); cld.SetOldLinkDirMode(this->OldLinkDirMode); cmComputeLinkDepends::EntryVector const& linkEntries = cld.Compute(); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=520d76306f8eca0b3b6792e6734deb7f893d23a2 commit 520d76306f8eca0b3b6792e6734deb7f893d23a2 Author: Stephen Kelly AuthorDate: Thu Jul 30 00:41:27 2015 +0200 Commit: Stephen Kelly CommitDate: Sun Aug 2 22:06:04 2015 +0200 cmComputeLinkInformation: Port to cmGeneratorTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index f03c04a..fb89319 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -242,11 +242,12 @@ because this need be done only for shared libraries without soname-s. //---------------------------------------------------------------------------- cmComputeLinkInformation -::cmComputeLinkInformation(cmTarget const* target, const std::string& config) +::cmComputeLinkInformation(const cmGeneratorTarget* target, + const std::string& config) { // Store context information. this->Target = target; - this->Makefile = this->Target->GetMakefile(); + this->Makefile = this->Target->Target->GetMakefile(); this->GlobalGenerator = this->Makefile->GetGlobalGenerator(); this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance(); @@ -259,17 +260,15 @@ cmComputeLinkInformation // Allocate internals. this->OrderLinkerSearchPath = - new cmOrderDirectories(this->GlobalGenerator, target, + new cmOrderDirectories(this->GlobalGenerator, target->Target, "linker search path"); this->OrderRuntimeSearchPath = - new cmOrderDirectories(this->GlobalGenerator, target, + new cmOrderDirectories(this->GlobalGenerator, target->Target, "runtime search path"); this->OrderDependentRPath = 0; - cmGeneratorTarget *gtgt = this->GlobalGenerator - ->GetGeneratorTarget(this->Target); // Get the language used for linking this target. - this->LinkLanguage = gtgt->GetLinkerLanguage(config); + this->LinkLanguage = this->Target->GetLinkerLanguage(config); if(this->LinkLanguage.empty()) { // The Compute method will do nothing, so skip the rest of the @@ -283,14 +282,14 @@ cmComputeLinkInformation // Check whether we should skip dependencies on shared library files. this->LinkDependsNoShared = - this->Target->GetPropertyAsBool("LINK_DEPENDS_NO_SHARED"); + this->Target->Target->GetPropertyAsBool("LINK_DEPENDS_NO_SHARED"); // On platforms without import libraries there may be a special flag // to use when creating a plugin (module) that obtains symbols from // the program that will load it. this->LoaderFlag = 0; if(!this->UseImportLibrary && - this->Target->GetType() == cmTarget::MODULE_LIBRARY) + this->Target->Target->GetType() == cmTarget::MODULE_LIBRARY) { std::string loader_flag_var = "CMAKE_SHARED_MODULE_LOADER_"; loader_flag_var += this->LinkLanguage; @@ -308,10 +307,10 @@ cmComputeLinkInformation // Get options needed to specify RPATHs. this->RuntimeUseChrpath = false; - if(this->Target->GetType() != cmTarget::STATIC_LIBRARY) + if(this->Target->Target->GetType() != cmTarget::STATIC_LIBRARY) { const char* tType = - ((this->Target->GetType() == cmTarget::EXECUTABLE)? + ((this->Target->Target->GetType() == cmTarget::EXECUTABLE)? "EXECUTABLE" : "SHARED_LIBRARY"); std::string rtVar = "CMAKE_"; rtVar += tType; @@ -325,7 +324,7 @@ cmComputeLinkInformation (this->Makefile-> GetSafeDefinition("CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH")); - this->RuntimeUseChrpath = gtgt->IsChrpathUsed(config); + this->RuntimeUseChrpath = this->Target->IsChrpathUsed(config); // Get options needed to help find dependent libraries. std::string rlVar = "CMAKE_"; @@ -371,15 +370,15 @@ cmComputeLinkInformation { this->SharedDependencyMode = SharedDepModeDir; this->OrderDependentRPath = - new cmOrderDirectories(this->GlobalGenerator, target, + new cmOrderDirectories(this->GlobalGenerator, target->Target, "dependent library path"); } // Add the search path entries requested by the user to path ordering. this->OrderLinkerSearchPath - ->AddUserDirectories(this->Target->GetLinkDirectories()); + ->AddUserDirectories(this->Target->Target->GetLinkDirectories()); this->OrderRuntimeSearchPath - ->AddUserDirectories(this->Target->GetLinkDirectories()); + ->AddUserDirectories(this->Target->Target->GetLinkDirectories()); // Set up the implicit link directories. this->LoadImplicitLinkInfo(); @@ -407,12 +406,13 @@ cmComputeLinkInformation // order to support such projects we need to add the directories // containing libraries linked with a full path to the -L path. this->OldLinkDirMode = - this->Target->GetPolicyStatusCMP0003() != cmPolicies::NEW; + this->Target->Target->GetPolicyStatusCMP0003() != cmPolicies::NEW; if(this->OldLinkDirMode) { // Construct a mask to not bother with this behavior for link // directories already specified by the user. - std::vector const& dirs = this->Target->GetLinkDirectories(); + std::vector const& dirs = + this->Target->Target->GetLinkDirectories(); this->OldLinkDirMask.insert(dirs.begin(), dirs.end()); } @@ -497,7 +497,7 @@ bool cmComputeLinkInformation::Compute() } // Compute the ordered link line items. - cmComputeLinkDepends cld(this->Target, this->Config); + cmComputeLinkDepends cld(this->Target->Target, this->Config); cld.SetOldLinkDirMode(this->OldLinkDirMode); cmComputeLinkDepends::EntryVector const& linkEntries = cld.Compute(); @@ -518,7 +518,8 @@ bool cmComputeLinkInformation::Compute() // Restore the target link type so the correct system runtime // libraries are found. - const char* lss = this->Target->GetProperty("LINK_SEARCH_END_STATIC"); + const char* lss = + this->Target->Target->GetProperty("LINK_SEARCH_END_STATIC"); if(cmSystemTools::IsOn(lss)) { this->SetCurrentLinkType(LinkStatic); @@ -571,7 +572,7 @@ bool cmComputeLinkInformation::Compute() "name." ; this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); } return true; @@ -580,12 +581,9 @@ bool cmComputeLinkInformation::Compute() //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddImplicitLinkInfo() { - cmGeneratorTarget *gtgt = this->Target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(this->Target); - // The link closure lists all languages whose implicit info is needed. - cmGeneratorTarget::LinkClosure const* lc=gtgt->GetLinkClosure(this->Config); + cmGeneratorTarget::LinkClosure const* lc = + this->Target->GetLinkClosure(this->Config); for(std::vector::const_iterator li = lc->Languages.begin(); li != lc->Languages.end(); ++li) { @@ -863,7 +861,8 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo() } // Lookup the starting link type from the target (linked statically?). - const char* lss = this->Target->GetProperty("LINK_SEARCH_START_STATIC"); + const char* lss = + this->Target->Target->GetProperty("LINK_SEARCH_START_STATIC"); this->StartLinkType = cmSystemTools::IsOn(lss)? LinkStatic : LinkShared; this->CurrentLinkType = this->StartLinkType; } @@ -1149,7 +1148,7 @@ void cmComputeLinkInformation::AddFullItem(std::string const& item) // Full path libraries should specify a valid library file name. // See documentation of CMP0008. std::string generator = this->GlobalGenerator->GetName(); - if(this->Target->GetPolicyStatusCMP0008() != cmPolicies::NEW && + if(this->Target->Target->GetPolicyStatusCMP0008() != cmPolicies::NEW && (generator.find("Visual Studio") != generator.npos || generator.find("Xcode") != generator.npos)) { @@ -1230,7 +1229,7 @@ bool cmComputeLinkInformation::CheckImplicitDirItem(std::string const& item) } // Check the policy for whether we should use the approach below. - switch (this->Target->GetPolicyStatusCMP0060()) + switch (this->Target->Target->GetPolicyStatusCMP0060()) { case cmPolicies::WARN: if (this->CMP0060Warn) @@ -1540,7 +1539,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item, this->OrderLinkerSearchPath->AddLinkLibrary(item); // Produce any needed message. - switch(this->Target->GetPolicyStatusCMP0008()) + switch(this->Target->Target->GetPolicyStatusCMP0008()) { case cmPolicies::WARN: { @@ -1557,7 +1556,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item, << " " << item << "\n" << "which is a full-path but not a valid library file name."; this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); } } case cmPolicies::OLD: @@ -1575,7 +1574,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item, << " " << item << "\n" << "which is a full-path but not a valid library file name."; this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); } break; } @@ -1592,7 +1591,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories() } // Enforce policy constraints. - switch(this->Target->GetPolicyStatusCMP0003()) + switch(this->Target->Target->GetPolicyStatusCMP0003()) { case cmPolicies::WARN: if(!this->CMakeInstance->GetState() @@ -1603,7 +1602,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories() std::ostringstream w; this->PrintLinkPolicyDiagnosis(w); this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); } case cmPolicies::OLD: // OLD behavior is to add the paths containing libraries with @@ -1619,7 +1618,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories() e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0003) << "\n"; this->PrintLinkPolicyDiagnosis(e); this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); return false; } } @@ -1923,23 +1922,24 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, // build tree. bool linking_for_install = (for_install || - this->Target->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")); + this->Target->Target->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")); bool use_install_rpath = - (outputRuntime && this->Target->HaveInstallTreeRPATH() && + (outputRuntime && this->Target->Target->HaveInstallTreeRPATH() && linking_for_install); bool use_build_rpath = - (outputRuntime && this->Target->HaveBuildTreeRPATH(this->Config) && + (outputRuntime && this->Target->Target->HaveBuildTreeRPATH(this->Config) && !linking_for_install); bool use_link_rpath = outputRuntime && linking_for_install && !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH") && - this->Target->GetPropertyAsBool("INSTALL_RPATH_USE_LINK_PATH"); + this->Target->Target->GetPropertyAsBool("INSTALL_RPATH_USE_LINK_PATH"); // Construct the RPATH. std::set emitted; if(use_install_rpath) { - const char* install_rpath = this->Target->GetProperty("INSTALL_RPATH"); + const char* install_rpath = + this->Target->Target->GetProperty("INSTALL_RPATH"); cmCLI_ExpandListUnique(install_rpath, runtimeDirs, emitted); } if(use_build_rpath || use_link_rpath) @@ -2011,12 +2011,8 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, // Add runtime paths required by the languages to always be // present. This is done even when skipping rpath support. { - cmGeneratorTarget *gtgt = this->Makefile - ->GetGlobalGenerator() - ->GetGeneratorTarget(this->Target); - cmGeneratorTarget::LinkClosure const* lc = - gtgt->GetLinkClosure(this->Config); + this->Target->GetLinkClosure(this->Config); for(std::vector::const_iterator li = lc->Languages.begin(); li != lc->Languages.end(); ++li) { diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index 2d7a5a5..8b83574 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -29,7 +29,8 @@ class cmOrderDirectories; class cmComputeLinkInformation { public: - cmComputeLinkInformation(cmTarget const* target, const std::string& config); + cmComputeLinkInformation(cmGeneratorTarget const* target, + const std::string& config); ~cmComputeLinkInformation(); bool Compute(); @@ -73,7 +74,7 @@ private: std::set SharedLibrariesLinked; // Context information. - cmTarget const* Target; + cmGeneratorTarget const* Target; cmMakefile* Makefile; cmGlobalGenerator* GlobalGenerator; cmake* CMakeInstance; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c68c2b9..55e2922 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3166,7 +3166,7 @@ cmGeneratorTarget::GetLinkInformation(const std::string& config) const { // Compute information for this configuration. cmComputeLinkInformation* info = - new cmComputeLinkInformation(this->Target, config); + new cmComputeLinkInformation(this, config); if(!info || !info->Compute()) { delete info; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=57c42044578479ca3e734eb251728627dfcb8c9a commit 57c42044578479ca3e734eb251728627dfcb8c9a Author: Stephen Kelly AuthorDate: Tue Jul 28 23:16:43 2015 +0200 Commit: Stephen Kelly CommitDate: Sun Aug 2 22:06:04 2015 +0200 cmGeneratorTarget: Move IsBundleOnApple from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c314372..c68c2b9 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -910,6 +910,14 @@ cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, } //---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsBundleOnApple() const +{ + return this->Target->IsFrameworkOnApple() + || this->Target->IsAppBundleOnApple() + || this->Target->IsCFBundleOnApple(); +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config, bool contentOnly) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 4299053..d10cd1d 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -119,6 +119,10 @@ public: std::string GetAppBundleDirectory(const std::string& config, bool contentOnly) const; + /** Return whether this target is an executable Bundle, a framework + or CFBundle on Apple. */ + bool IsBundleOnApple() const; + /** Get the full name of the target according to the settings in its makefile. */ std::string GetFullName(const std::string& config="", diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index d38cf4c..0b3df90 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -313,7 +313,7 @@ cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator() (cmSourceFile const& source, const char* pkgloc) { // Skip OS X content when not building a Framework or Bundle. - if(!this->Generator->GetTarget()->IsBundleOnApple()) + if(!this->Generator->GetGeneratorTarget()->IsBundleOnApple()) { return; } diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 16e1f48..07efa16 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -742,7 +742,7 @@ cmNinjaTargetGenerator::MacOSXContentGeneratorType::operator()( cmSourceFile const& source, const char* pkgloc) { // Skip OS X content when not building a Framework or Bundle. - if(!this->Generator->GetTarget()->IsBundleOnApple()) + if(!this->Generator->GetGeneratorTarget()->IsBundleOnApple()) { return; } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 62aa12a..e887ef3 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -590,13 +590,6 @@ bool cmTarget::IsXCTestOnApple() const } //---------------------------------------------------------------------------- -bool cmTarget::IsBundleOnApple() const -{ - return this->IsFrameworkOnApple() || this->IsAppBundleOnApple() || - this->IsCFBundleOnApple(); -} - -//---------------------------------------------------------------------------- static bool processSources(cmTarget const* tgt, const std::vector &entries, std::vector &srcs, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 9a4915f..e53afff 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -424,10 +424,6 @@ public: /** Return whether this target is an executable Bundle on Apple. */ bool IsAppBundleOnApple() const; - /** Return whether this target is an executable Bundle, a framework - or CFBundle on Apple. */ - bool IsBundleOnApple() const; - /** Return the framework version string. Undefined if IsFrameworkOnApple returns false. */ std::string GetFrameworkVersion() const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=83bfb2dfe55e77b9a3d0e655bd30aa23399c29e6 commit 83bfb2dfe55e77b9a3d0e655bd30aa23399c29e6 Author: Stephen Kelly AuthorDate: Tue Jul 28 23:18:55 2015 +0200 Commit: Stephen Kelly CommitDate: Sun Aug 2 22:06:03 2015 +0200 cmMakefileTargetGenerator: Add accessor for GeneratorTarget. diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index b885672..fd4527b 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -53,6 +53,7 @@ public: { return this->ProgressFileNameFull; } cmTarget* GetTarget() { return this->Target;} + cmGeneratorTarget* GetGeneratorTarget() { return this->GeneratorTarget;} protected: http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3bb7b1f045b47e4f83ed2c9e07cc9bfc4285be7c commit 3bb7b1f045b47e4f83ed2c9e07cc9bfc4285be7c Author: Stephen Kelly AuthorDate: Wed Oct 10 21:43:28 2012 +0200 Commit: Stephen Kelly CommitDate: Sun Aug 2 22:06:03 2015 +0200 cmGeneratorTarget: Move GetLinkClosure from cmTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 640e806..f03c04a 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -19,6 +19,7 @@ #include "cmOutputConverter.h" #include "cmMakefile.h" #include "cmTarget.h" +#include "cmGeneratorTarget.h" #include "cmake.h" #include "cmAlgorithms.h" @@ -579,8 +580,12 @@ bool cmComputeLinkInformation::Compute() //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddImplicitLinkInfo() { + cmGeneratorTarget *gtgt = this->Target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(this->Target); + // The link closure lists all languages whose implicit info is needed. - cmTarget::LinkClosure const* lc=this->Target->GetLinkClosure(this->Config); + cmGeneratorTarget::LinkClosure const* lc=gtgt->GetLinkClosure(this->Config); for(std::vector::const_iterator li = lc->Languages.begin(); li != lc->Languages.end(); ++li) { @@ -2006,8 +2011,12 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, // Add runtime paths required by the languages to always be // present. This is done even when skipping rpath support. { - cmTarget::LinkClosure const* lc = - this->Target->GetLinkClosure(this->Config); + cmGeneratorTarget *gtgt = this->Makefile + ->GetGlobalGenerator() + ->GetGeneratorTarget(this->Target); + + cmGeneratorTarget::LinkClosure const* lc = + gtgt->GetLinkClosure(this->Config); for(std::vector::const_iterator li = lc->Languages.begin(); li != lc->Languages.end(); ++li) { diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index 3afbb92..2d7a5a5 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -20,6 +20,7 @@ class cmake; class cmGlobalGenerator; class cmMakefile; class cmTarget; +class cmGeneratorTarget; class cmOrderDirectories; /** \class cmComputeLinkInformation diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 4de5e9c..c314372 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -27,6 +27,13 @@ #include #include "assert.h" +#if defined(CMAKE_BUILD_WITH_CMAKE) +#include +#define UNORDERED_SET cmsys::hash_set +#else +#define UNORDERED_SET std::set +#endif + //---------------------------------------------------------------------------- void reportBadObjLib(std::vector const& badObjLib, cmTarget *target, cmake *cm) @@ -1026,6 +1033,223 @@ std::string cmGeneratorTarget::GetInstallNameDirForInstallTree() const } //---------------------------------------------------------------------------- +class cmTargetCollectLinkLanguages +{ +public: + cmTargetCollectLinkLanguages(cmGeneratorTarget const* target, + const std::string& config, + UNORDERED_SET& languages, + cmTarget const* head): + Config(config), Languages(languages), HeadTarget(head), + Makefile(target->Target->GetMakefile()), Target(target) + { this->Visited.insert(target->Target); } + + void Visit(cmLinkItem const& item) + { + if(!item.Target) + { + if(item.find("::") != std::string::npos) + { + bool noMessage = false; + cmake::MessageType messageType = cmake::FATAL_ERROR; + std::stringstream e; + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0028)) + { + case cmPolicies::WARN: + { + e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0028) << "\n"; + messageType = cmake::AUTHOR_WARNING; + } + break; + case cmPolicies::OLD: + noMessage = true; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::NEW: + // Issue the fatal message. + break; + } + + if(!noMessage) + { + e << "Target \"" << this->Target->GetName() + << "\" links to target \"" << item + << "\" but the target was not found. Perhaps a find_package() " + "call is missing for an IMPORTED target, or an ALIAS target is " + "missing?"; + this->Makefile->GetCMakeInstance()->IssueMessage( + messageType, e.str(), this->Target->Target->GetBacktrace()); + } + } + return; + } + if(!this->Visited.insert(item.Target).second) + { + return; + } + + cmTarget::LinkInterface const* iface = + item.Target->GetLinkInterface(this->Config, this->HeadTarget); + if(!iface) { return; } + + for(std::vector::const_iterator + li = iface->Languages.begin(); li != iface->Languages.end(); ++li) + { + this->Languages.insert(*li); + } + + for(std::vector::const_iterator + li = iface->Libraries.begin(); li != iface->Libraries.end(); ++li) + { + this->Visit(*li); + } + } +private: + std::string Config; + UNORDERED_SET& Languages; + cmTarget const* HeadTarget; + cmMakefile* Makefile; + const cmGeneratorTarget* Target; + std::set Visited; +}; + +//---------------------------------------------------------------------------- +cmGeneratorTarget::LinkClosure const* +cmGeneratorTarget::GetLinkClosure(const std::string& config) const +{ + std::string key(cmSystemTools::UpperCase(config)); + LinkClosureMapType::iterator + i = this->LinkClosureMap.find(key); + if(i == this->LinkClosureMap.end()) + { + LinkClosure lc; + this->ComputeLinkClosure(config, lc); + LinkClosureMapType::value_type entry(key, lc); + i = this->LinkClosureMap.insert(entry).first; + } + return &i->second; +} + +//---------------------------------------------------------------------------- +class cmTargetSelectLinker +{ + int Preference; + cmGeneratorTarget const* Target; + cmMakefile* Makefile; + cmGlobalGenerator* GG; + std::set Preferred; +public: + cmTargetSelectLinker(cmGeneratorTarget const* target) + : Preference(0), Target(target) + { + this->Makefile = this->Target->Makefile; + this->GG = this->Makefile->GetGlobalGenerator(); + } + void Consider(const char* lang) + { + int preference = this->GG->GetLinkerPreference(lang); + if(preference > this->Preference) + { + this->Preference = preference; + this->Preferred.clear(); + } + if(preference == this->Preference) + { + this->Preferred.insert(lang); + } + } + std::string Choose() + { + if(this->Preferred.empty()) + { + return ""; + } + else if(this->Preferred.size() > 1) + { + std::stringstream e; + e << "Target " << this->Target->GetName() + << " contains multiple languages with the highest linker preference" + << " (" << this->Preference << "):\n"; + for(std::set::const_iterator + li = this->Preferred.begin(); li != this->Preferred.end(); ++li) + { + e << " " << *li << "\n"; + } + e << "Set the LINKER_LANGUAGE property for this target."; + cmake* cm = this->Makefile->GetCMakeInstance(); + cm->IssueMessage(cmake::FATAL_ERROR, e.str(), + this->Target->Target->GetBacktrace()); + } + return *this->Preferred.begin(); + } +}; + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::ComputeLinkClosure(const std::string& config, + LinkClosure& lc) const +{ + // Get languages built in this target. + UNORDERED_SET languages; + cmTarget::LinkImplementation const* impl = + this->Target->GetLinkImplementation(config); + for(std::vector::const_iterator li = impl->Languages.begin(); + li != impl->Languages.end(); ++li) + { + languages.insert(*li); + } + + // Add interface languages from linked targets. + cmTargetCollectLinkLanguages cll(this, config, languages, this->Target); + for(std::vector::const_iterator li = impl->Libraries.begin(); + li != impl->Libraries.end(); ++li) + { + cll.Visit(*li); + } + + // Store the transitive closure of languages. + for(UNORDERED_SET::const_iterator li = languages.begin(); + li != languages.end(); ++li) + { + lc.Languages.push_back(*li); + } + + // Choose the language whose linker should be used. + if(this->GetProperty("HAS_CXX")) + { + lc.LinkerLanguage = "CXX"; + } + else if(const char* linkerLang = this->GetProperty("LINKER_LANGUAGE")) + { + lc.LinkerLanguage = linkerLang; + } + else + { + // Find the language with the highest preference value. + cmTargetSelectLinker tsl(this); + + // First select from the languages compiled directly in this target. + for(std::vector::const_iterator li = impl->Languages.begin(); + li != impl->Languages.end(); ++li) + { + tsl.Consider(li->c_str()); + } + + // Now consider languages that propagate from linked targets. + for(UNORDERED_SET::const_iterator sit = languages.begin(); + sit != languages.end(); ++sit) + { + std::string propagates = "CMAKE_"+*sit+"_LINKER_PREFERENCE_PROPAGATES"; + if(this->Makefile->IsOn(propagates)) + { + tsl.Consider(sit->c_str()); + } + } + + lc.LinkerLanguage = tsl.Choose(); + } +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, std::string& base, std::string& suffix, @@ -2058,7 +2282,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, std::string cmGeneratorTarget::GetLinkerLanguage(const std::string& config) const { - return this->Target->GetLinkClosure(config)->LinkerLanguage; + return this->GetLinkClosure(config)->LinkerLanguage; } //---------------------------------------------------------------------------- diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 2799371..4299053 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -165,6 +165,20 @@ public: std::string GetModuleDefinitionFile(const std::string& config) const; + /** Link information from the transitive closure of the link + implementation and the interfaces of its dependencies. */ + struct LinkClosure + { + // The preferred linker language. + std::string LinkerLanguage; + + // Languages whose runtime libraries must be linked. + std::vector Languages; + }; + + LinkClosure const* GetLinkClosure(const std::string& config) const; + void ComputeLinkClosure(const std::string& config, LinkClosure& lc) const; + /** Full path with trailing slash to the top-level directory holding object files for this target. Includes the build time config name placeholder if needed for the generator. */ @@ -300,6 +314,9 @@ private: std::string& outPrefix, std::string& outBase, std::string& outSuffix) const; + typedef std::map LinkClosureMapType; + mutable LinkClosureMapType LinkClosureMap; + struct CompatibleInterfacesBase { std::set PropsBool; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index c7118dc..62aa12a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -160,9 +160,6 @@ public: HeadToLinkImplementationMap> LinkImplMapType; LinkImplMapType LinkImplMap; - typedef std::map LinkClosureMapType; - LinkClosureMapType LinkClosureMap; - typedef std::map > SourceFilesMapType; SourceFilesMapType SourceFilesMap; @@ -511,7 +508,6 @@ void cmTarget::ClearLinkMaps() this->Internal->LinkImplMap.clear(); this->Internal->LinkInterfaceMap.clear(); this->Internal->LinkInterfaceUsageRequirementsOnlyMap.clear(); - this->Internal->LinkClosureMap.clear(); this->Internal->SourceFilesMap.clear(); } @@ -3136,223 +3132,6 @@ bool cmTarget::GetPropertyAsBool(const std::string& prop) const } //---------------------------------------------------------------------------- -class cmTargetCollectLinkLanguages -{ -public: - cmTargetCollectLinkLanguages(cmTarget const* target, - const std::string& config, - UNORDERED_SET& languages, - cmTarget const* head): - Config(config), Languages(languages), HeadTarget(head), - Makefile(target->GetMakefile()), Target(target) - { this->Visited.insert(target); } - - void Visit(cmLinkItem const& item) - { - if(!item.Target) - { - if(item.find("::") != std::string::npos) - { - bool noMessage = false; - cmake::MessageType messageType = cmake::FATAL_ERROR; - std::ostringstream e; - switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0028)) - { - case cmPolicies::WARN: - { - e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0028) << "\n"; - messageType = cmake::AUTHOR_WARNING; - } - break; - case cmPolicies::OLD: - noMessage = true; - case cmPolicies::REQUIRED_IF_USED: - case cmPolicies::REQUIRED_ALWAYS: - case cmPolicies::NEW: - // Issue the fatal message. - break; - } - - if(!noMessage) - { - e << "Target \"" << this->Target->GetName() - << "\" links to target \"" << item - << "\" but the target was not found. Perhaps a find_package() " - "call is missing for an IMPORTED target, or an ALIAS target is " - "missing?"; - this->Makefile->GetCMakeInstance()->IssueMessage(messageType, - e.str(), - this->Target->GetBacktrace()); - } - } - return; - } - if(!this->Visited.insert(item.Target).second) - { - return; - } - - cmTarget::LinkInterface const* iface = - item.Target->GetLinkInterface(this->Config, this->HeadTarget); - if(!iface) { return; } - - for(std::vector::const_iterator - li = iface->Languages.begin(); li != iface->Languages.end(); ++li) - { - this->Languages.insert(*li); - } - - for(std::vector::const_iterator - li = iface->Libraries.begin(); li != iface->Libraries.end(); ++li) - { - this->Visit(*li); - } - } -private: - std::string Config; - UNORDERED_SET& Languages; - cmTarget const* HeadTarget; - cmMakefile* Makefile; - const cmTarget* Target; - std::set Visited; -}; - -//---------------------------------------------------------------------------- -cmTarget::LinkClosure const* -cmTarget::GetLinkClosure(const std::string& config) const -{ - std::string key(cmSystemTools::UpperCase(config)); - cmTargetInternals::LinkClosureMapType::iterator - i = this->Internal->LinkClosureMap.find(key); - if(i == this->Internal->LinkClosureMap.end()) - { - LinkClosure lc; - this->ComputeLinkClosure(config, lc); - cmTargetInternals::LinkClosureMapType::value_type entry(key, lc); - i = this->Internal->LinkClosureMap.insert(entry).first; - } - return &i->second; -} - -//---------------------------------------------------------------------------- -class cmTargetSelectLinker -{ - int Preference; - cmTarget const* Target; - cmMakefile* Makefile; - cmGlobalGenerator* GG; - UNORDERED_SET Preferred; -public: - cmTargetSelectLinker(cmTarget const* target): Preference(0), Target(target) - { - this->Makefile = this->Target->GetMakefile(); - this->GG = this->Makefile->GetGlobalGenerator(); - } - void Consider(const std::string& lang) - { - int preference = this->GG->GetLinkerPreference(lang); - if(preference > this->Preference) - { - this->Preference = preference; - this->Preferred.clear(); - } - if(preference == this->Preference) - { - this->Preferred.insert(lang); - } - } - std::string Choose() - { - if(this->Preferred.empty()) - { - return ""; - } - else if(this->Preferred.size() > 1) - { - std::ostringstream e; - e << "Target " << this->Target->GetName() - << " contains multiple languages with the highest linker preference" - << " (" << this->Preference << "):\n"; - for(UNORDERED_SET::const_iterator - li = this->Preferred.begin(); li != this->Preferred.end(); ++li) - { - e << " " << *li << "\n"; - } - e << "Set the LINKER_LANGUAGE property for this target."; - cmake* cm = this->Makefile->GetCMakeInstance(); - cm->IssueMessage(cmake::FATAL_ERROR, e.str(), - this->Target->GetBacktrace()); - } - return *this->Preferred.begin(); - } -}; - -//---------------------------------------------------------------------------- -void cmTarget::ComputeLinkClosure(const std::string& config, - LinkClosure& lc) const -{ - // Get languages built in this target. - UNORDERED_SET languages; - LinkImplementation const* impl = this->GetLinkImplementation(config); - for(std::vector::const_iterator li = impl->Languages.begin(); - li != impl->Languages.end(); ++li) - { - languages.insert(*li); - } - - // Add interface languages from linked targets. - cmTargetCollectLinkLanguages cll(this, config, languages, this); - for(std::vector::const_iterator - li = impl->Libraries.begin(); - li != impl->Libraries.end(); ++li) - { - cll.Visit(*li); - } - - // Store the transitive closure of languages. - for(UNORDERED_SET::const_iterator li = languages.begin(); - li != languages.end(); ++li) - { - lc.Languages.push_back(*li); - } - - // Choose the language whose linker should be used. - if(this->GetProperty("HAS_CXX")) - { - lc.LinkerLanguage = "CXX"; - } - else if(const char* linkerLang = this->GetProperty("LINKER_LANGUAGE")) - { - lc.LinkerLanguage = linkerLang; - } - else - { - // Find the language with the highest preference value. - cmTargetSelectLinker tsl(this); - - // First select from the languages compiled directly in this target. - for(std::vector::const_iterator li = impl->Languages.begin(); - li != impl->Languages.end(); ++li) - { - tsl.Consider(*li); - } - - // Now consider languages that propagate from linked targets. - for(UNORDERED_SET::const_iterator sit = languages.begin(); - sit != languages.end(); ++sit) - { - std::string propagates = "CMAKE_"+*sit+"_LINKER_PREFERENCE_PROPAGATES"; - if(this->Makefile->IsOn(propagates)) - { - tsl.Consider(*sit); - } - } - - lc.LinkerLanguage = tsl.Choose(); - } -} - -//---------------------------------------------------------------------------- void cmTarget::ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index dea9bef..9a4915f 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -315,18 +315,6 @@ public: LinkImplementationLibraries const* GetLinkImplementationLibraries(const std::string& config) const; - /** Link information from the transitive closure of the link - implementation and the interfaces of its dependencies. */ - struct LinkClosure - { - // The preferred linker language. - std::string LinkerLanguage; - - // Languages whose runtime libraries must be linked. - std::vector Languages; - }; - LinkClosure const* GetLinkClosure(const std::string& config) const; - cmTarget const* FindTargetToLink(std::string const& name) const; /** Strip off leading and trailing whitespace from an item named in @@ -662,7 +650,6 @@ private: LinkImplementationLibraries const* GetLinkImplementationLibrariesInternal(const std::string& config, cmTarget const* head) const; - void ComputeLinkClosure(const std::string& config, LinkClosure& lc) const; void ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, cmTarget const* headTarget, http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fe5391eecaf19d2741cb25f6690dbc21c05aeae7 commit fe5391eecaf19d2741cb25f6690dbc21c05aeae7 Author: Stephen Kelly AuthorDate: Sun Nov 3 16:33:25 2013 +0100 Commit: Stephen Kelly CommitDate: Sun Aug 2 22:06:03 2015 +0200 cmGeneratorTarget: Move GetLinkerLanguage from cmTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index fee921c..640e806 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -265,8 +265,10 @@ cmComputeLinkInformation "runtime search path"); this->OrderDependentRPath = 0; + cmGeneratorTarget *gtgt = this->GlobalGenerator + ->GetGeneratorTarget(this->Target); // Get the language used for linking this target. - this->LinkLanguage = this->Target->GetLinkerLanguage(config); + this->LinkLanguage = gtgt->GetLinkerLanguage(config); if(this->LinkLanguage.empty()) { // The Compute method will do nothing, so skip the rest of the @@ -322,9 +324,6 @@ cmComputeLinkInformation (this->Makefile-> GetSafeDefinition("CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH")); - cmGeneratorTarget *gtgt = this->Target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(this->Target); this->RuntimeUseChrpath = gtgt->IsChrpathUsed(config); // Get options needed to help find dependent libraries. diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 49fc96b..a86c2bc 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -990,6 +990,9 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode assert(target); + cmGeneratorTarget* gtgt = + context->Makefile->GetGlobalGenerator()->GetGeneratorTarget(target); + if (propertyName == "LINKER_LANGUAGE") { if (target->LinkLanguagePropagatesToDependents() && @@ -1001,7 +1004,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode "link libraries for a static library"); return std::string(); } - return target->GetLinkerLanguage(context->Config); + return gtgt->GetLinkerLanguage(context->Config); } cmGeneratorExpressionDAGChecker dagChecker(context->Backtrace, @@ -1128,9 +1131,6 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode } } - cmGeneratorTarget* gtgt = - context->Makefile->GetGlobalGenerator()->GetGeneratorTarget(target); - if (!prop) { if (target->IsImported() @@ -1600,7 +1600,7 @@ struct TargetFilesystemArtifactResultCreator cmGeneratorExpressionContext *context, const GeneratorExpressionContent *content) { - std::string language = target->Target->GetLinkerLanguage(context->Config); + std::string language = target->GetLinkerLanguage(context->Config); std::string pdbSupportVar = "CMAKE_" + language + "_LINKER_SUPPORTS_PDB"; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 834a2e3..4de5e9c 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -709,8 +709,7 @@ bool cmGeneratorTarget::HasSOName(const std::string& config) const return ((this->GetType() == cmTarget::SHARED_LIBRARY || this->GetType() == cmTarget::MODULE_LIBRARY) && !this->GetPropertyAsBool("NO_SONAME") && - this->Makefile->GetSONameFlag( - this->Target->GetLinkerLanguage(config))); + this->Makefile->GetSONameFlag(this->GetLinkerLanguage(config))); } //---------------------------------------------------------------------------- @@ -752,7 +751,7 @@ cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const } // Check for rpath support on this platform. - std::string ll = this->Target->GetLinkerLanguage(config); + std::string ll = this->GetLinkerLanguage(config); if(!ll.empty()) { std::string flagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; @@ -823,7 +822,7 @@ bool cmGeneratorTarget::IsChrpathUsed(const std::string& config) const #if defined(CMAKE_USE_ELF_PARSER) // Enable if the rpath flag uses a separator and the target uses ELF // binaries. - std::string ll = this->Target->GetLinkerLanguage(config); + std::string ll = this->GetLinkerLanguage(config); if(!ll.empty()) { std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; @@ -1986,7 +1985,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, const char* suffixVar = this->Target->GetSuffixVariableInternal(implib); // Check for language-specific default prefix and suffix. - std::string ll = this->Target->GetLinkerLanguage(config); + std::string ll = this->GetLinkerLanguage(config); if(!ll.empty()) { if(!targetSuffix && suffixVar && *suffixVar) @@ -2056,6 +2055,13 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, //---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetLinkerLanguage(const std::string& config) const +{ + return this->Target->GetLinkClosure(config)->LinkerLanguage; +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetPDBName(const std::string& config) const { std::string prefix; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 372bbe1..2799371 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -258,6 +258,9 @@ public: /** Return true if builtin chrpath will work for this target */ bool IsChrpathUsed(const std::string& config) const; + ///! Return the preferred linker language for this target + std::string GetLinkerLanguage(const std::string& config = "") const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index 2f9265a..1e57c33 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -128,7 +128,8 @@ void cmGhsMultiTargetGenerator::Generate() { config = "RELEASE"; } - const std::string language(this->Target->GetLinkerLanguage(config)); + const std::string language( + this->GeneratorTarget->GetLinkerLanguage(config)); config = cmSystemTools::UpperCase(config); this->DynamicDownload = this->DetermineIfDynamicDownload(config, language); if (this->DynamicDownload) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 7b0e153..5006828 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1376,7 +1376,8 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmTarget& cmtarget) return; } - std::string llang = cmtarget.GetLinkerLanguage("NOCONFIG"); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&cmtarget); + std::string llang = gtgt->GetLinkerLanguage("NOCONFIG"); if(llang.empty()) { return; } // If the language is compiled as a source trust Xcode to link with it. @@ -1824,7 +1825,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, AddCompileOptions(flags, &target, lang, configName); } - std::string llang = target.GetLinkerLanguage(configName); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); + std::string llang = gtgt->GetLinkerLanguage(configName); if(binary && llang.empty()) { cmSystemTools::Error @@ -1850,7 +1852,6 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, // Add the export symbol definition for shared library objects. this->AppendDefines(ppDefs, exportMacro); } - cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); std::vector targetDefines; target.GetCompileDefinitions(targetDefines, configName, "C"); this->AppendDefines(ppDefs, targetDefines); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 3ab501d..4ec77a1 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1353,7 +1353,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, linkFlags += this->Makefile->GetSafeDefinition(build); linkFlags += " "; } - std::string linkLanguage = target->Target->GetLinkerLanguage(buildType); + std::string linkLanguage = target->GetLinkerLanguage(buildType); if(linkLanguage.empty()) { cmSystemTools::Error diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 94457bb..e1fa7d4 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1259,8 +1259,8 @@ void cmLocalVisualStudio6Generator extraLinkOptionsRelWithDebInfo += targetLinkFlags; } - - + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); // Get standard libraries for this language. if(targetBuilds) @@ -1269,10 +1269,10 @@ void cmLocalVisualStudio6Generator std::vector configs; target.GetMakefile()->GetConfigurations(configs); std::vector::const_iterator it = configs.begin(); - const std::string& linkLanguage = target.GetLinkerLanguage(*it); + const std::string& linkLanguage = gt->GetLinkerLanguage(*it); for ( ; it != configs.end(); ++it) { - const std::string& configLinkLanguage = target.GetLinkerLanguage(*it); + const std::string& configLinkLanguage = gt->GetLinkerLanguage(*it); if (configLinkLanguage != linkLanguage) { cmSystemTools::Error @@ -1702,10 +1702,10 @@ void cmLocalVisualStudio6Generator std::vector configs; target.GetMakefile()->GetConfigurations(configs); std::vector::const_iterator it = configs.begin(); - const std::string& linkLanguage = target.GetLinkerLanguage(*it); + const std::string& linkLanguage = gt->GetLinkerLanguage(*it); for ( ; it != configs.end(); ++it) { - const std::string& configLinkLanguage = target.GetLinkerLanguage(*it); + const std::string& configLinkLanguage = gt->GetLinkerLanguage(*it); if (configLinkLanguage != linkLanguage) { cmSystemTools::Error diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 9f26712..a38a061 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -664,6 +664,10 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, const char* configType = "10"; const char* projectType = 0; bool targetBuilds = true; + + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); + switch(target.GetType()) { case cmTarget::OBJECT_LIBRARY: @@ -696,7 +700,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, { const std::string& linkLanguage = (this->FortranProject? std::string("Fortran"): - target.GetLinkerLanguage(configName)); + gt->GetLinkerLanguage(configName)); if(linkLanguage.empty()) { cmSystemTools::Error @@ -758,8 +762,6 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, targetOptions.Parse(flags.c_str()); targetOptions.Parse(defineFlags.c_str()); targetOptions.ParseFinish(); - cmGeneratorTarget* gt = - this->GlobalGenerator->GetGeneratorTarget(&target); std::vector targetDefines; target.GetCompileDefinitions(targetDefines, configName, "CXX"); targetOptions.AddDefines(targetDefines); @@ -1635,7 +1637,7 @@ cmLocalVisualStudio7GeneratorFCInfo lg->GlobalGenerator->GetLanguageFromExtension (sf.GetExtension().c_str()); const std::string& sourceLang = lg->GetSourceFileLanguage(sf); - const std::string& linkLanguage = target.GetLinkerLanguage(i->c_str()); + const std::string& linkLanguage = gt->GetLinkerLanguage(i->c_str()); bool needForceLang = false; // source file does not match its extension language if(lang != sourceLang) diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 2fd77c9..afe145a 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -161,7 +161,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) // Get the language to use for linking this executable. std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); // Make sure we have a link language. if(linkLanguage.empty()) diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index b85b8a8..bb0f9dd 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -133,7 +133,7 @@ void cmMakefileLibraryTargetGenerator::WriteObjectLibraryRules() void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules() { std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_STATIC_LIBRARY"; @@ -159,7 +159,7 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink) return; } std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_SHARED_LIBRARY"; @@ -183,7 +183,7 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink) void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink) { std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_SHARED_MODULE"; @@ -206,7 +206,7 @@ void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink) void cmMakefileLibraryTargetGenerator::WriteFrameworkRules(bool relink) { std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_MACOSX_FRAMEWORK"; @@ -238,7 +238,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules // Get the language to use for linking this library. std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); // Make sure we have a link language. if(linkLanguage.empty()) diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index b94e151..d38cf4c 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1509,7 +1509,7 @@ std::string cmMakefileTargetGenerator::GetLinkRule( if(this->Target->HasImplibGNUtoMS()) { std::string ruleVar = "CMAKE_"; - ruleVar += this->Target->GetLinkerLanguage(this->ConfigName); + ruleVar += this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); ruleVar += "_GNUtoMS_RULE"; if(const char* rule = this->Makefile->GetDefinition(ruleVar)) { @@ -1663,7 +1663,8 @@ cmMakefileTargetGenerator { // Lookup the response file reference flag. std::string responseFlagVar = "CMAKE_"; - responseFlagVar += this->Target->GetLinkerLanguage(this->ConfigName); + responseFlagVar += this->GeneratorTarget + ->GetLinkerLanguage(this->ConfigName); responseFlagVar += "_RESPONSE_FILE_LINK_FLAG"; const char* responseFlag = this->Makefile->GetDefinition(responseFlagVar); @@ -1707,7 +1708,8 @@ cmMakefileTargetGenerator // Lookup the response file reference flag. std::string responseFlagVar = "CMAKE_"; - responseFlagVar += this->Target->GetLinkerLanguage(this->ConfigName); + responseFlagVar += this->GeneratorTarget + ->GetLinkerLanguage(this->ConfigName); responseFlagVar += "_RESPONSE_FILE_LINK_FLAG"; const char* responseFlag = this->Makefile->GetDefinition(responseFlagVar); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 1835841..b855bea 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -40,8 +40,7 @@ cmNinjaNormalTargetGenerator(cmGeneratorTarget* target) , TargetNamePDB() , TargetLinkLanguage("") { - this->TargetLinkLanguage = target->Target - ->GetLinkerLanguage(this->GetConfigName()); + this->TargetLinkLanguage = target->GetLinkerLanguage(this->GetConfigName()); if (target->GetType() == cmTarget::EXECUTABLE) this->GetGeneratorTarget()->GetExecutableNames(this->TargetNameOut, this->TargetNameReal, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 37b788d..c7118dc 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3218,12 +3218,6 @@ private: }; //---------------------------------------------------------------------------- -std::string cmTarget::GetLinkerLanguage(const std::string& config) const -{ - return this->GetLinkClosure(config)->LinkerLanguage; -} - -//---------------------------------------------------------------------------- cmTarget::LinkClosure const* cmTarget::GetLinkClosure(const std::string& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index d0cbc66..dea9bef 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -365,9 +365,6 @@ public: void GetTargetVersion(bool soversion, int& major, int& minor, int& patch) const; - ///! Return the preferred linker language for this target - std::string GetLinkerLanguage(const std::string& config = "") const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 2b33c2c..80b8591 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1627,7 +1627,7 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( this->GlobalGenerator->GetLanguageFromExtension (sf.GetExtension().c_str()); std::string sourceLang = this->LocalGenerator->GetSourceFileLanguage(sf); - const std::string& linkLanguage = this->Target->GetLinkerLanguage(); + const std::string& linkLanguage = this->GeneratorTarget->GetLinkerLanguage(); bool needForceLang = false; // source file does not match its extension language if(lang != sourceLang) @@ -1888,7 +1888,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( std::string flags; const std::string& linkLanguage = - this->Target->GetLinkerLanguage(configName.c_str()); + this->GeneratorTarget->GetLinkerLanguage(configName.c_str()); if(linkLanguage.empty()) { cmSystemTools::Error @@ -2371,7 +2371,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) Options& linkOptions = *pOptions; const std::string& linkLanguage = - this->Target->GetLinkerLanguage(config.c_str()); + this->GeneratorTarget->GetLinkerLanguage(config.c_str()); if(linkLanguage.empty()) { cmSystemTools::Error http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c0497de1233b363afd983bc97af00b5d7fe27950 commit c0497de1233b363afd983bc97af00b5d7fe27950 Author: Stephen Kelly AuthorDate: Tue Oct 9 01:22:42 2012 +0200 Commit: Stephen Kelly CommitDate: Sun Aug 2 22:06:03 2015 +0200 cmGeneratorTarget: Move GetFrameworkDirectory from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 436e5dd..834a2e3 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -904,6 +904,48 @@ cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config, + bool contentOnly) const +{ + std::string fpath; + fpath += this->Target->GetOutputName(config, false); + fpath += "."; + const char *ext = this->Target->GetProperty("BUNDLE_EXTENSION"); + if (!ext) + { + if (this->Target->IsXCTestOnApple()) + { + ext = "xctest"; + } + else + { + ext = "bundle"; + } + } + fpath += ext; + fpath += "/Contents"; + if(!contentOnly) + fpath += "/MacOS"; + return fpath; +} + +//---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetFrameworkDirectory(const std::string& config, + bool rootDir) const +{ + std::string fpath; + fpath += this->Target->GetOutputName(config, false); + fpath += ".framework"; + if(!rootDir) + { + fpath += "/Versions/"; + fpath += this->Target->GetFrameworkVersion(); + } + return fpath; +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetFullName(const std::string& config, bool implib) const { @@ -1007,11 +1049,11 @@ cmGeneratorTarget::BuildMacContentDirectory(const std::string& base, } if(this->Target->IsFrameworkOnApple()) { - fpath += this->Target->GetFrameworkDirectory(config, contentOnly); + fpath += this->GetFrameworkDirectory(config, contentOnly); } if(this->Target->IsCFBundleOnApple()) { - fpath += this->Target->GetCFBundleDirectory(config, contentOnly); + fpath += this->GetCFBundleDirectory(config, contentOnly); } return fpath; } @@ -1982,7 +2024,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, if(this->Target->IsCFBundleOnApple()) { - fw_prefix = this->Target->GetCFBundleDirectory(config, false); + fw_prefix = this->GetCFBundleDirectory(config, false); fw_prefix += "/"; targetPrefix = fw_prefix.c_str(); targetSuffix = 0; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 8ccd6d0..372bbe1 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -124,6 +124,14 @@ public: std::string GetFullName(const std::string& config="", bool implib = false) const; + /** @return the Mac framework directory without the base. */ + std::string GetFrameworkDirectory(const std::string& config, + bool rootDir) const; + + /** @return the Mac CFBundle directory without the base */ + std::string GetCFBundleDirectory(const std::string& config, + bool contentOnly) const; + /** Return the install name directory for the target in the * build tree. For example: "\@rpath/", "\@loader_path/", * or "/full/path/to/library". */ diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 1d85d9c..4fe99e3 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -77,11 +77,11 @@ void cmOSXBundleGenerator::CreateFramework( // Compute the location of the top-level foo.framework directory. std::string contentdir = outpath + "/" + - this->GT->Target->GetFrameworkDirectory(this->ConfigName, true); + this->GT->GetFrameworkDirectory(this->ConfigName, true); contentdir += "/"; std::string newoutpath = outpath + "/" + - this->GT->Target->GetFrameworkDirectory(this->ConfigName, false); + this->GT->GetFrameworkDirectory(this->ConfigName, false); std::string frameworkVersion = this->GT->Target->GetFrameworkVersion(); @@ -172,14 +172,14 @@ void cmOSXBundleGenerator::CreateCFBundle(const std::string& targetName, // Compute bundle directory names. std::string out = root; out += "/"; - out += this->GT->Target->GetCFBundleDirectory(this->ConfigName, false); + out += this->GT->GetCFBundleDirectory(this->ConfigName, false); cmSystemTools::MakeDirectory(out.c_str()); this->Makefile->AddCMakeOutputFile(out); // Configure the Info.plist file. Note that it needs the executable name // to be set. std::string plist = root + "/" + - this->GT->Target->GetCFBundleDirectory(this->ConfigName, true); + this->GT->GetCFBundleDirectory(this->ConfigName, true); plist += "/Info.plist"; std::string name = cmSystemTools::GetFilenameName(targetName); this->LocalGenerator->GenerateAppleInfoPList(this->GT->Target, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index a5ff829..37b788d 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -5126,47 +5126,6 @@ std::string cmTarget::CheckCMP0004(std::string const& item) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetFrameworkDirectory(const std::string& config, - bool rootDir) const -{ - std::string fpath; - fpath += this->GetOutputName(config, false); - fpath += ".framework"; - if(!rootDir) - { - fpath += "/Versions/"; - fpath += this->GetFrameworkVersion(); - } - return fpath; -} - -//---------------------------------------------------------------------------- -std::string cmTarget::GetCFBundleDirectory(const std::string& config, - bool contentOnly) const -{ - std::string fpath; - fpath += this->GetOutputName(config, false); - fpath += "."; - const char *ext = this->GetProperty("BUNDLE_EXTENSION"); - if (!ext) - { - if (this->IsXCTestOnApple()) - { - ext = "xctest"; - } - else - { - ext = "bundle"; - } - } - fpath += ext; - fpath += "/Contents"; - if(!contentOnly) - fpath += "/MacOS"; - return fpath; -} - -//---------------------------------------------------------------------------- cmTargetInternalPointer::cmTargetInternalPointer() { this->Pointer = new cmTargetInternals; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e22d3af..d0cbc66 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -460,14 +460,6 @@ public: /** @return whether this target have a well defined output file name. */ bool HaveWellDefinedOutputFiles() const; - /** @return the Mac framework directory without the base. */ - std::string GetFrameworkDirectory(const std::string& config, - bool rootDir) const; - - /** @return the Mac CFBundle directory without the base */ - std::string GetCFBundleDirectory(const std::string& config, - bool contentOnly) const; - std::vector GetIncludeDirectories( const std::string& config, const std::string& language) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4031d184b53b6cff621e30663f80c7d86bee7aa8 commit 4031d184b53b6cff621e30663f80c7d86bee7aa8 Author: Stephen Kelly AuthorDate: Tue Oct 9 19:01:39 2012 +0200 Commit: Stephen Kelly CommitDate: Sun Aug 2 22:06:03 2015 +0200 cmGeneratorTarget: Move GetFullNameInternal from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index cdacfcb..436e5dd 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -663,7 +663,7 @@ cmGeneratorTarget::GetCompilePDBName(const std::string& config) const std::string prefix; std::string base; std::string suffix; - this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, false, prefix, base, suffix); // Check for a per-configuration output directory target property. std::string configUpper = cmSystemTools::UpperCase(config); @@ -905,6 +905,20 @@ cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, //---------------------------------------------------------------------------- std::string +cmGeneratorTarget::GetFullName(const std::string& config, bool implib) const +{ + if(this->Target->IsImported()) + { + return this->Target->GetFullNameImported(config, implib); + } + else + { + return this->GetFullNameInternal(config, implib); + } +} + +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetInstallNameDirForBuildTree( const std::string& config) const { @@ -977,7 +991,7 @@ void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, const std::string& config, bool implib) const { - this->Target->GetFullNameInternal(config, implib, prefix, base, suffix); + this->GetFullNameInternal(config, implib, prefix, base, suffix); } //---------------------------------------------------------------------------- @@ -1753,7 +1767,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, std::string prefix; std::string base; std::string suffix; - this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, false, prefix, base, suffix); // The library name. name = prefix+base+suffix; @@ -1782,7 +1796,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, if(this->GetType() == cmTarget::SHARED_LIBRARY || this->GetType() == cmTarget::MODULE_LIBRARY) { - impName = this->Target->GetFullNameInternal(config, true); + impName = this->GetFullNameInternal(config, true); } else { @@ -1828,7 +1842,7 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, std::string prefix; std::string base; std::string suffix; - this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, false, prefix, base, suffix); // The executable name. name = prefix+base+suffix; @@ -1849,19 +1863,163 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, #endif // The import library name. - impName = this->Target->GetFullNameInternal(config, true); + impName = this->GetFullNameInternal(config, true); // The program database file name. pdbName = this->GetPDBName(config); } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetFullNameInternal(const std::string& config, + bool implib) const +{ + std::string prefix; + std::string base; + std::string suffix; + this->GetFullNameInternal(config, implib, prefix, base, suffix); + return prefix+base+suffix; +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GetFullNameInternal(const std::string& config, + bool implib, + std::string& outPrefix, + std::string& outBase, + std::string& outSuffix) const +{ + // Use just the target name for non-main target types. + if(this->GetType() != cmTarget::STATIC_LIBRARY && + this->GetType() != cmTarget::SHARED_LIBRARY && + this->GetType() != cmTarget::MODULE_LIBRARY && + this->GetType() != cmTarget::EXECUTABLE) + { + outPrefix = ""; + outBase = this->GetName(); + outSuffix = ""; + return; + } + + // Return an empty name for the import library if this platform + // does not support import libraries. + if(implib && + !this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) + { + outPrefix = ""; + outBase = ""; + outSuffix = ""; + return; + } + + // The implib option is only allowed for shared libraries, module + // libraries, and executables. + if(this->GetType() != cmTarget::SHARED_LIBRARY && + this->GetType() != cmTarget::MODULE_LIBRARY && + this->GetType() != cmTarget::EXECUTABLE) + { + implib = false; + } + + // Compute the full name for main target types. + const char* targetPrefix = (implib + ? this->GetProperty("IMPORT_PREFIX") + : this->GetProperty("PREFIX")); + const char* targetSuffix = (implib + ? this->GetProperty("IMPORT_SUFFIX") + : this->GetProperty("SUFFIX")); + const char* configPostfix = 0; + if(!config.empty()) + { + std::string configProp = cmSystemTools::UpperCase(config); + configProp += "_POSTFIX"; + configPostfix = this->GetProperty(configProp); + // Mac application bundles and frameworks have no postfix. + if(configPostfix && + (this->Target->IsAppBundleOnApple() + || this->Target->IsFrameworkOnApple())) + { + configPostfix = 0; + } + } + const char* prefixVar = this->Target->GetPrefixVariableInternal(implib); + const char* suffixVar = this->Target->GetSuffixVariableInternal(implib); + + // Check for language-specific default prefix and suffix. + std::string ll = this->Target->GetLinkerLanguage(config); + if(!ll.empty()) + { + if(!targetSuffix && suffixVar && *suffixVar) + { + std::string langSuff = suffixVar + std::string("_") + ll; + targetSuffix = this->Makefile->GetDefinition(langSuff); + } + if(!targetPrefix && prefixVar && *prefixVar) + { + std::string langPrefix = prefixVar + std::string("_") + ll; + targetPrefix = this->Makefile->GetDefinition(langPrefix); + } + } + + // if there is no prefix on the target use the cmake definition + if(!targetPrefix && prefixVar) + { + targetPrefix = this->Makefile->GetSafeDefinition(prefixVar); + } + // if there is no suffix on the target use the cmake definition + if(!targetSuffix && suffixVar) + { + targetSuffix = this->Makefile->GetSafeDefinition(suffixVar); + } + + // frameworks have directory prefix but no suffix + std::string fw_prefix; + if(this->Target->IsFrameworkOnApple()) + { + fw_prefix = this->Target->GetOutputName(config, false); + fw_prefix += ".framework/"; + targetPrefix = fw_prefix.c_str(); + targetSuffix = 0; + } + + if(this->Target->IsCFBundleOnApple()) + { + fw_prefix = this->Target->GetCFBundleDirectory(config, false); + fw_prefix += "/"; + targetPrefix = fw_prefix.c_str(); + targetSuffix = 0; + } + + // Begin the final name with the prefix. + outPrefix = targetPrefix?targetPrefix:""; + + // Append the target name or property-specified name. + outBase += this->Target->GetOutputName(config, implib); + + // Append the per-configuration postfix. + outBase += configPostfix?configPostfix:""; + + // Name shared libraries with their version number on some platforms. + if(const char* soversion = this->GetProperty("SOVERSION")) + { + if(this->GetType() == cmTarget::SHARED_LIBRARY && !implib && + this->Makefile->IsOn("CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION")) + { + outBase += "-"; + outBase += soversion; + } + } + + // Append the suffix. + outSuffix = targetSuffix?targetSuffix:""; +} + + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetPDBName(const std::string& config) const { std::string prefix; std::string base; std::string suffix; - this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, false, prefix, base, suffix); std::vector props; std::string configUpper = diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index d0d6709..8ccd6d0 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -284,6 +284,11 @@ private: mutable std::map DebugCompatiblePropertiesDone; + std::string GetFullNameInternal(const std::string& config, bool implib) const; + void GetFullNameInternal(const std::string& config, bool implib, + std::string& outPrefix, std::string& outBase, + std::string& outSuffix) const; + struct CompatibleInterfacesBase { std::set PropsBool; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index c484417..a5ff829 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3612,148 +3612,6 @@ cmTarget::ImportedGetFullPath(const std::string& config, bool implib) const } //---------------------------------------------------------------------------- -std::string -cmTarget::GetFullNameInternal(const std::string& config, bool implib) const -{ - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, implib, prefix, base, suffix); - return prefix+base+suffix; -} - -//---------------------------------------------------------------------------- -void cmTarget::GetFullNameInternal(const std::string& config, - bool implib, - std::string& outPrefix, - std::string& outBase, - std::string& outSuffix) const -{ - // Use just the target name for non-main target types. - if(this->GetType() != cmTarget::STATIC_LIBRARY && - this->GetType() != cmTarget::SHARED_LIBRARY && - this->GetType() != cmTarget::MODULE_LIBRARY && - this->GetType() != cmTarget::EXECUTABLE) - { - outPrefix = ""; - outBase = this->GetName(); - outSuffix = ""; - return; - } - - // Return an empty name for the import library if this platform - // does not support import libraries. - if(implib && - !this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) - { - outPrefix = ""; - outBase = ""; - outSuffix = ""; - return; - } - - // The implib option is only allowed for shared libraries, module - // libraries, and executables. - if(this->GetType() != cmTarget::SHARED_LIBRARY && - this->GetType() != cmTarget::MODULE_LIBRARY && - this->GetType() != cmTarget::EXECUTABLE) - { - implib = false; - } - - // Compute the full name for main target types. - const char* targetPrefix = (implib - ? this->GetProperty("IMPORT_PREFIX") - : this->GetProperty("PREFIX")); - const char* targetSuffix = (implib - ? this->GetProperty("IMPORT_SUFFIX") - : this->GetProperty("SUFFIX")); - const char* configPostfix = 0; - if(!config.empty()) - { - std::string configProp = cmSystemTools::UpperCase(config); - configProp += "_POSTFIX"; - configPostfix = this->GetProperty(configProp); - // Mac application bundles and frameworks have no postfix. - if(configPostfix && - (this->IsAppBundleOnApple() || this->IsFrameworkOnApple())) - { - configPostfix = 0; - } - } - const char* prefixVar = this->GetPrefixVariableInternal(implib); - const char* suffixVar = this->GetSuffixVariableInternal(implib); - - // Check for language-specific default prefix and suffix. - std::string ll = this->GetLinkerLanguage(config); - if(!ll.empty()) - { - if(!targetSuffix && suffixVar && *suffixVar) - { - std::string langSuff = suffixVar + std::string("_") + ll; - targetSuffix = this->Makefile->GetDefinition(langSuff); - } - if(!targetPrefix && prefixVar && *prefixVar) - { - std::string langPrefix = prefixVar + std::string("_") + ll; - targetPrefix = this->Makefile->GetDefinition(langPrefix); - } - } - - // if there is no prefix on the target use the cmake definition - if(!targetPrefix && prefixVar) - { - targetPrefix = this->Makefile->GetSafeDefinition(prefixVar); - } - // if there is no suffix on the target use the cmake definition - if(!targetSuffix && suffixVar) - { - targetSuffix = this->Makefile->GetSafeDefinition(suffixVar); - } - - // frameworks have directory prefix but no suffix - std::string fw_prefix; - if(this->IsFrameworkOnApple()) - { - fw_prefix = this->GetOutputName(config, false); - fw_prefix += ".framework/"; - targetPrefix = fw_prefix.c_str(); - targetSuffix = 0; - } - - if(this->IsCFBundleOnApple()) - { - fw_prefix = this->GetCFBundleDirectory(config, false); - fw_prefix += "/"; - targetPrefix = fw_prefix.c_str(); - targetSuffix = 0; - } - - // Begin the final name with the prefix. - outPrefix = targetPrefix?targetPrefix:""; - - // Append the target name or property-specified name. - outBase += this->GetOutputName(config, implib); - - // Append the per-configuration postfix. - outBase += configPostfix?configPostfix:""; - - // Name shared libraries with their version number on some platforms. - if(const char* soversion = this->GetProperty("SOVERSION")) - { - if(this->GetType() == cmTarget::SHARED_LIBRARY && !implib && - this->Makefile->IsOn("CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION")) - { - outBase += "-"; - outBase += soversion; - } - } - - // Append the suffix. - outSuffix = targetSuffix?targetSuffix:""; -} - -//---------------------------------------------------------------------------- void cmTarget::ComputeVersionedName(std::string& vName, std::string const& prefix, std::string const& base, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 633e0ee..e22d3af 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -570,11 +570,6 @@ private: const char* GetSuffixVariableInternal(bool implib) const; const char* GetPrefixVariableInternal(bool implib) const; - std::string GetFullNameInternal(const std::string& config, - bool implib) const; - void GetFullNameInternal(const std::string& config, bool implib, - std::string& outPrefix, std::string& outBase, - std::string& outSuffix) const; // Use a makefile variable to set a default for the given property. // If the variable is not defined use the given default instead. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7c8954af013c05f373c6753e17860dddd42eaee1 commit 7c8954af013c05f373c6753e17860dddd42eaee1 Author: Stephen Kelly AuthorDate: Tue Oct 9 01:26:16 2012 +0200 Commit: Stephen Kelly CommitDate: Sun Aug 2 22:06:02 2015 +0200 cmGeneratorTarget: Move GetFullName from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 0fdf646..cdacfcb 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -576,7 +576,7 @@ const char* cmGeneratorTarget::GetLocationForBuild() const } } location += "/"; - location += this->Target->GetFullName("", false); + location += this->GetFullName("", false); return location.c_str(); } @@ -896,7 +896,7 @@ std::string cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, bool contentOnly) const { - std::string fpath = this->Target->GetFullName(config, false); + std::string fpath = this->GetFullName(config, false); fpath += ".app/Contents"; if(!contentOnly) fpath += "/MacOS"; @@ -1655,7 +1655,7 @@ std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config, // Add the full name of the target. if(implib) { - fpath += this->Target->GetFullName(config, true); + fpath += this->GetFullName(config, true); } else if(realname) { @@ -1663,7 +1663,7 @@ std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config, } else { - fpath += this->Target->GetFullName(config, false); + fpath += this->GetFullName(config, false); } return fpath; } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index f0d8c60..d0d6709 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -119,6 +119,11 @@ public: std::string GetAppBundleDirectory(const std::string& config, bool contentOnly) const; + /** Get the full name of the target according to the settings in its + makefile. */ + std::string GetFullName(const std::string& config="", + bool implib = false) const; + /** Return the install name directory for the target in the * build tree. For example: "\@rpath/", "\@loader_path/", * or "/full/path/to/library". */ diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index d53ecde..7b0e153 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2742,7 +2742,8 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget, } else { - fullName = cmtarget.GetFullName(defConfig.c_str()); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&cmtarget); + fullName = gtgt->GetFullName(defConfig.c_str()); } fileRef->AddAttribute("path", this->CreateString(fullName.c_str())); fileRef->AddAttribute("refType", this->CreateString("0")); @@ -3688,7 +3689,7 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( std::string universalFile = universal; universalFile += *arch; universalFile += "/"; - universalFile += t->GetFullName(configName); + universalFile += gt->GetFullName(configName); makefileStream << "\t/bin/rm -f " << this->ConvertToRelativeForMake(universalFile.c_str()) diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 61d7847..94457bb 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1112,7 +1112,8 @@ void cmLocalVisualStudio6Generator // Compute the proper name to use to link this library. std::string lib; std::string libDebug; - cmTarget* tgt = this->GlobalGenerator->FindTarget(j->first.c_str()); + cmGeneratorTarget* tgt = this->GlobalGenerator->GetGeneratorTarget( + this->GlobalGenerator->FindTarget(j->first.c_str())); if(tgt) { lib = cmSystemTools::GetFilenameWithoutExtension @@ -1328,11 +1329,11 @@ void cmLocalVisualStudio6Generator target.GetType() == cmTarget::SHARED_LIBRARY || target.GetType() == cmTarget::MODULE_LIBRARY) { - outputName = target.GetFullName(); - outputNameDebug = target.GetFullName("Debug"); - outputNameRelease = target.GetFullName("Release"); - outputNameMinSizeRel = target.GetFullName("MinSizeRel"); - outputNameRelWithDebInfo = target.GetFullName("RelWithDebInfo"); + outputName = gt->GetFullName(); + outputNameDebug = gt->GetFullName("Debug"); + outputNameRelease = gt->GetFullName("Release"); + outputNameMinSizeRel = gt->GetFullName("MinSizeRel"); + outputNameRelWithDebInfo = gt->GetFullName("RelWithDebInfo"); } else if(target.GetType() == cmTarget::OBJECT_LIBRARY) { @@ -1429,10 +1430,10 @@ void cmLocalVisualStudio6Generator fullPathImpRelease += "/"; fullPathImpMinSizeRel += "/"; fullPathImpRelWithDebInfo += "/"; - fullPathImpDebug += target.GetFullName("Debug", true); - fullPathImpRelease += target.GetFullName("Release", true); - fullPathImpMinSizeRel += target.GetFullName("MinSizeRel", true); - fullPathImpRelWithDebInfo += target.GetFullName("RelWithDebInfo", true); + fullPathImpDebug += gt->GetFullName("Debug", true); + fullPathImpRelease += gt->GetFullName("Release", true); + fullPathImpMinSizeRel += gt->GetFullName("MinSizeRel", true); + fullPathImpRelWithDebInfo += gt->GetFullName("RelWithDebInfo", true); targetImplibFlagDebug = "/implib:"; targetImplibFlagRelease = "/implib:"; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 724f575..9f26712 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -803,7 +803,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, if (this->FortranProject) { // Intel Fortran >= 15.0 uses TargetName property. - std::string targetNameFull = target.GetFullName(configName); + std::string targetNameFull = gt->GetFullName(configName); std::string targetName = cmSystemTools::GetFilenameWithoutLastExtension(targetNameFull); std::string targetExt = @@ -1074,6 +1074,9 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, this->ConvertToOutputFormat(this->ModuleDefinitionFile, SHELL); linkOptions.AddFlag("ModuleDefinitionFile", defFile.c_str()); } + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); + if (target.GetType() == cmTarget::SHARED_LIBRARY && this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) { @@ -1104,7 +1107,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, } case cmTarget::STATIC_LIBRARY: { - std::string targetNameFull = target.GetFullName(configName); + std::string targetNameFull = gt->GetFullName(configName); std::string libpath = target.GetDirectory(configName); libpath += "/"; libpath += targetNameFull; @@ -1148,8 +1151,6 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, targetNameImport, targetNamePDB, configName); // Compute the link library and directory information. - cmGeneratorTarget* gt = - this->GlobalGenerator->GetGeneratorTarget(&target); cmComputeLinkInformation* pcli = gt->GetLinkInformation(configName); if(!pcli) { @@ -1247,8 +1248,6 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, targetNameImport, targetNamePDB, configName); // Compute the link library and directory information. - cmGeneratorTarget* gt = - this->GlobalGenerator->GetGeneratorTarget(&target); cmComputeLinkInformation* pcli = gt->GetLinkInformation(configName); if(!pcli) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e8ef770..c484417 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3587,20 +3587,6 @@ bool cmTarget::IsImportedSharedLibWithoutSOName( } //---------------------------------------------------------------------------- -std::string cmTarget::GetFullName(const std::string& config, - bool implib) const -{ - if(this->IsImported()) - { - return this->GetFullNameImported(config, implib); - } - else - { - return this->GetFullNameInternal(config, implib); - } -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetFullNameImported(const std::string& config, bool implib) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 4b804da..633e0ee 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -368,11 +368,6 @@ public: ///! Return the preferred linker language for this target std::string GetLinkerLanguage(const std::string& config = "") const; - /** Get the full name of the target according to the settings in its - makefile. */ - std::string GetFullName(const std::string& config="", - bool implib = false) const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 16edf3c..2b33c2c 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1774,7 +1774,7 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions() else { outDir = this->Target->GetDirectory(config->c_str()) + "/"; - targetNameFull = this->Target->GetFullName(config->c_str()); + targetNameFull = this->GeneratorTarget->GetFullName(config->c_str()); } this->ConvertToWindowsSlash(intermediateDir); this->ConvertToWindowsSlash(outDir); ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From kwrobot at kitware.com Mon Aug 3 00:01:07 2015 From: kwrobot at kitware.com (Kitware Robot) Date: Mon, 3 Aug 2015 00:01:07 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-662-gebacce3 Message-ID: <20150803040107.CEB8CB07A3@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via ebacce3f0b0cef6116e91d408d591ff67285c420 (commit) from 614786cc5c8cf6f504112a722aabf8dddc154d2c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ebacce3f0b0cef6116e91d408d591ff67285c420 commit ebacce3f0b0cef6116e91d408d591ff67285c420 Author: Kitware Robot AuthorDate: Mon Aug 3 00:01:05 2015 -0400 Commit: Kitware Robot CommitDate: Mon Aug 3 00:01:05 2015 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 8c496cd..368ff0c 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150802) +set(CMake_VERSION_PATCH 20150803) #set(CMake_VERSION_RC 1) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From steveire at gmail.com Mon Aug 3 03:13:49 2015 From: steveire at gmail.com (Stephen Kelly) Date: Mon, 3 Aug 2015 03:13:49 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1764-gfde8e00 Message-ID: <20150803071349.BE436AFF61@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via fde8e00e2c7ab16e09b2716b4c661b2c299bac6b (commit) via 9b59c178718b7cf1c007d758f59d603ad2856627 (commit) from 6648c4d2f8a390350e5361f4f7c5d1ee12911fae (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fde8e00e2c7ab16e09b2716b4c661b2c299bac6b commit fde8e00e2c7ab16e09b2716b4c661b2c299bac6b Merge: 6648c4d 9b59c17 Author: Stephen Kelly AuthorDate: Mon Aug 3 03:13:48 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 3 03:13:48 2015 -0400 Merge topic 'use-generator-target' into next 9b59c178 Fix width. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9b59c178718b7cf1c007d758f59d603ad2856627 commit 9b59c178718b7cf1c007d758f59d603ad2856627 Author: Stephen Kelly AuthorDate: Mon Aug 3 09:13:16 2015 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 3 09:13:16 2015 +0200 Fix width. diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 1d7a411..68e7a8a 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -332,7 +332,8 @@ private: mutable std::map DebugCompatiblePropertiesDone; - std::string GetFullNameInternal(const std::string& config, bool implib) const; + std::string GetFullNameInternal(const std::string& config, + bool implib) const; void GetFullNameInternal(const std::string& config, bool implib, std::string& outPrefix, std::string& outBase, std::string& outSuffix) const; ----------------------------------------------------------------------- Summary of changes: Source/cmGeneratorTarget.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) hooks/post-receive -- CMake From steveire at gmail.com Mon Aug 3 03:17:56 2015 From: steveire at gmail.com (Stephen Kelly) Date: Mon, 3 Aug 2015 03:17:56 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1779-g1f652e5 Message-ID: <20150803071756.04978B0BBC@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 1f652e5949b2309bfc1bd102d21092117ff069b0 (commit) via 77abc4d7ff48dfae64a698c3627d43d08c8dccdd (commit) via 3513808281430af404f390d881b6a9b5447d960f (commit) via e341befa19cbd538ea804dc519caa10930ef7dad (commit) via da967933e0e81bc065ccb53a7a4ab69302f42371 (commit) via 4fbbae36ecfc5f281256da93e02539b88fe92d15 (commit) via a324ef1b3f9041eea32fa45991896c8dec0c8541 (commit) via 2c76fc32078d21454c0cb4d4ddf0c771adad9e0a (commit) via 5c5ab106dd68ebd3105a877c325b94892504a0a2 (commit) via b952bb3f9be968de54032135237c67bbc0dd0a70 (commit) via 6daea501377f8347c5b081f03fdd22cfdb76f538 (commit) via 798a5ac620ee63abc5d61b6db6f65db1b34a3605 (commit) via 05a79e3349482f58ccd70f87ac7b852d451b1abd (commit) via 8fcae6727a7355bf01a77250f2c5fe0df8fda82a (commit) via a12e80dd27edd9499f1a252549254866b2dcb827 (commit) from fde8e00e2c7ab16e09b2716b4c661b2c299bac6b (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1f652e5949b2309bfc1bd102d21092117ff069b0 commit 1f652e5949b2309bfc1bd102d21092117ff069b0 Merge: fde8e00 77abc4d Author: Stephen Kelly AuthorDate: Mon Aug 3 03:17:53 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 3 03:17:53 2015 -0400 Merge topic 'use-generator-target' into next 77abc4d7 cmOrderDirectories: Port to cmGeneratorTarget. 35138082 cmMakefile: Remove unused method. e341befa cmGlobalGenerator: Base exclusion computation on cmGeneratorTarget. da967933 cmGeneratorTarget: Move CompileInfoMap from cmTarget. 4fbbae36 cmGeneratorTarget: Move GetCompilePDBDirectory from cmTarget. a324ef1b cmGeneratorTarget: Move GetOutputName from cmTarget. 2c76fc32 cmComputeLinkDepends: Port to cmGeneratorTarget. 5c5ab106 cmComputeLinkInformation: Port to cmGeneratorTarget. b952bb3f cmGeneratorTarget: Move IsBundleOnApple from cmTarget. 6daea501 cmMakefileTargetGenerator: Add accessor for GeneratorTarget. 798a5ac6 cmGeneratorTarget: Move GetLinkClosure from cmTarget. 05a79e33 cmGeneratorTarget: Move GetLinkerLanguage from cmTarget. 8fcae672 cmGeneratorTarget: Move GetFrameworkDirectory from cmTarget. a12e80dd cmGeneratorTarget: Move GetFullNameInternal from cmTarget. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=77abc4d7ff48dfae64a698c3627d43d08c8dccdd commit 77abc4d7ff48dfae64a698c3627d43d08c8dccdd Author: Stephen Kelly AuthorDate: Sat Aug 1 09:48:04 2015 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 3 09:14:17 2015 +0200 cmOrderDirectories: Port to cmGeneratorTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 5cd0d54..e0c6e86 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -260,10 +260,10 @@ cmComputeLinkInformation // Allocate internals. this->OrderLinkerSearchPath = - new cmOrderDirectories(this->GlobalGenerator, target->Target, + new cmOrderDirectories(this->GlobalGenerator, target, "linker search path"); this->OrderRuntimeSearchPath = - new cmOrderDirectories(this->GlobalGenerator, target->Target, + new cmOrderDirectories(this->GlobalGenerator, target, "runtime search path"); this->OrderDependentRPath = 0; @@ -370,7 +370,7 @@ cmComputeLinkInformation { this->SharedDependencyMode = SharedDepModeDir; this->OrderDependentRPath = - new cmOrderDirectories(this->GlobalGenerator, target->Target, + new cmOrderDirectories(this->GlobalGenerator, target, "dependent library path"); } diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx index a612437..35ee127 100644 --- a/Source/cmOrderDirectories.cxx +++ b/Source/cmOrderDirectories.cxx @@ -280,7 +280,7 @@ bool cmOrderDirectoriesConstraintLibrary::FindConflict(std::string const& dir) //---------------------------------------------------------------------------- cmOrderDirectories::cmOrderDirectories(cmGlobalGenerator* gg, - cmTarget const* target, + const cmGeneratorTarget* target, const char* purpose) { this->GlobalGenerator = gg; @@ -554,7 +554,8 @@ void cmOrderDirectories::FindImplicitConflicts() << text << "Some of these libraries may not be found correctly."; this->GlobalGenerator->GetCMakeInstance() - ->IssueMessage(cmake::WARNING, w.str(), this->Target->GetBacktrace()); + ->IssueMessage(cmake::WARNING, w.str(), + this->Target->Target->GetBacktrace()); } //---------------------------------------------------------------------------- @@ -635,5 +636,6 @@ void cmOrderDirectories::DiagnoseCycle() } e << "Some of these libraries may not be found correctly."; this->GlobalGenerator->GetCMakeInstance() - ->IssueMessage(cmake::WARNING, e.str(), this->Target->GetBacktrace()); + ->IssueMessage(cmake::WARNING, e.str(), + this->Target->Target->GetBacktrace()); } diff --git a/Source/cmOrderDirectories.h b/Source/cmOrderDirectories.h index cb5a51f..211c786 100644 --- a/Source/cmOrderDirectories.h +++ b/Source/cmOrderDirectories.h @@ -19,7 +19,7 @@ class cmGlobalGenerator; class cmOrderDirectoriesConstraint; class cmOrderDirectoriesConstraintLibrary; -class cmTarget; +class cmGeneratorTarget; /** \class cmOrderDirectories * \brief Compute a safe runtime path order for a set of shared libraries. @@ -27,7 +27,7 @@ class cmTarget; class cmOrderDirectories { public: - cmOrderDirectories(cmGlobalGenerator* gg, cmTarget const* target, + cmOrderDirectories(cmGlobalGenerator* gg, cmGeneratorTarget const* target, const char* purpose); ~cmOrderDirectories(); void AddRuntimeLibrary(std::string const& fullPath, const char* soname = 0); @@ -41,7 +41,7 @@ public: std::vector const& GetOrderedDirectories(); private: cmGlobalGenerator* GlobalGenerator; - cmTarget const* Target; + cmGeneratorTarget const* Target; std::string Purpose; std::vector OrderedDirectories; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3513808281430af404f390d881b6a9b5447d960f commit 3513808281430af404f390d881b6a9b5447d960f Author: Stephen Kelly AuthorDate: Sat Jun 6 14:27:52 2015 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 3 09:14:17 2015 +0200 cmMakefile: Remove unused method. diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 1e5c301..00d4005 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -113,10 +113,6 @@ public: bool GetIsSourceFileTryCompile() const; - ///! Get the current makefile generator. - cmLocalGenerator* GetLocalGenerator() const - { return this->LocalGenerator;} - /** * Help enforce global target name uniqueness. */ http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e341befa19cbd538ea804dc519caa10930ef7dad commit e341befa19cbd538ea804dc519caa10930ef7dad Author: Stephen Kelly AuthorDate: Sat Jun 6 14:09:35 2015 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 3 09:14:17 2015 +0200 cmGlobalGenerator: Base exclusion computation on cmGeneratorTarget. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 1d6608b..b14949a 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2022,10 +2022,10 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, } bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, - cmTarget const& target) const + cmGeneratorTarget* target) const { - if(target.GetType() == cmTarget::INTERFACE_LIBRARY - || target.GetPropertyAsBool("EXCLUDE_FROM_ALL")) + if(target->GetType() == cmTarget::INTERFACE_LIBRARY + || target->Target->GetPropertyAsBool("EXCLUDE_FROM_ALL")) { // This target is excluded from its directory. return true; @@ -2034,7 +2034,7 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, { // This target is included in its directory. Check whether the // directory is excluded. - return this->IsExcluded(root, target.GetMakefile()->GetLocalGenerator()); + return this->IsExcluded(root, target->GetLocalGenerator()); } } @@ -2095,15 +2095,16 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap() { cmTarget const& target = t->second; + cmGeneratorTarget* gt = this->GetGeneratorTarget(&target); + // Consider the directory containing the target and all its // parents until something excludes the target. - for(cmLocalGenerator* clg = lg; clg && !this->IsExcluded(clg, target); + for(cmLocalGenerator* clg = lg; clg && !this->IsExcluded(clg, gt); clg = clg->GetParent()) { // This local generator includes the target. std::set& targetSet = this->LocalGeneratorToTargetMap[clg]; - cmGeneratorTarget* gt = this->GetGeneratorTarget(&target); targetSet.insert(gt); // Add dependencies of the included target. An excluded diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 9492372..3be76b6 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -398,7 +398,7 @@ protected: void FillProjectMap(); void CheckLocalGenerators(); bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen) const; - bool IsExcluded(cmLocalGenerator* root, cmTarget const& target) const; + bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) const; void FillLocalGeneratorToTargetMap(); void CreateDefaultGlobalTargets(cmTargets* targets); cmTarget CreateGlobalTarget(const std::string& name, const char* message, diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 2a749c1..47822b4 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -289,7 +289,7 @@ public: const std::vector& GetLocalGenerators() const { return LocalGenerators; } - bool IsExcluded(cmLocalGenerator* root, cmTarget& target) { + bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) { return cmGlobalGenerator::IsExcluded(root, target); } int GetRuleCmdLength(const std::string& name) { diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 69747a4..76d059ee 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -821,7 +821,7 @@ cmGlobalUnixMakefileGenerator3 localName, depends, commands, true); // add the all/all dependency - if(!this->IsExcluded(this->LocalGenerators[0], *gtarget->Target)) + if(!this->IsExcluded(this->LocalGenerators[0], gtarget)) { depends.clear(); depends.push_back(localName); @@ -889,7 +889,7 @@ cmGlobalUnixMakefileGenerator3 "Pre-install relink rule for target.", localName, depends, commands, true); - if(!this->IsExcluded(this->LocalGenerators[0], *gtarget->Target)) + if(!this->IsExcluded(this->LocalGenerators[0], gtarget)) { depends.clear(); depends.push_back(localName); diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 2f9d79a..c06dfb3 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -111,17 +111,18 @@ bool cmGlobalVisualStudioGenerator::Compute() for(std::vector::iterator i = gen.begin(); i != gen.end(); ++i) { - cmTargets& targets = (*i)->GetMakefile()->GetTargets(); - for(cmTargets::iterator t = targets.begin(); + cmGeneratorTargetsType targets = + (*i)->GetMakefile()->GetGeneratorTargets(); + for(cmGeneratorTargetsType::iterator t = targets.begin(); t != targets.end(); ++t) { - if (t->second.GetType() == cmTarget::GLOBAL_TARGET) + if (t->second->GetType() == cmTarget::GLOBAL_TARGET) { continue; } if(!this->IsExcluded(gen[0], t->second)) { - allBuild->AddUtility(t->second.GetName()); + allBuild->AddUtility(t->second->GetName()); } } } diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 9889bd4..1822c97 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -90,7 +90,7 @@ void cmLocalNinjaGenerator::Generate() // Add the target to "all" if required. if (!this->GetGlobalNinjaGenerator()->IsExcluded( this->GetGlobalNinjaGenerator()->GetLocalGenerators()[0], - *t->second->Target)) + t->second)) this->GetGlobalNinjaGenerator()->AddDependencyToAll(t->second->Target); delete tg; } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=da967933e0e81bc065ccb53a7a4ab69302f42371 commit da967933e0e81bc065ccb53a7a4ab69302f42371 Author: Stephen Kelly AuthorDate: Mon Oct 20 21:02:16 2014 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 3 09:14:16 2015 +0200 cmGeneratorTarget: Move CompileInfoMap from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c6f248c..c831704 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1356,6 +1356,46 @@ cmGeneratorTarget::GetMacContentDirectory(const std::string& config, return fpath; } + +//---------------------------------------------------------------------------- +cmGeneratorTarget::CompileInfo const* cmGeneratorTarget::GetCompileInfo( + const std::string& config) const +{ + // There is no compile information for imported targets. + if(this->IsImported()) + { + return 0; + } + + if(this->GetType() > cmTarget::OBJECT_LIBRARY) + { + std::string msg = "cmTarget::GetCompileInfo called for "; + msg += this->GetName(); + msg += " which has type "; + msg += cmTarget::GetTargetTypeName(this->Target->GetType()); + this->Makefile->IssueMessage(cmake::INTERNAL_ERROR, msg); + return 0; + } + + // Lookup/compute/cache the compile information for this configuration. + std::string config_upper; + if(!config.empty()) + { + config_upper = cmSystemTools::UpperCase(config); + } + CompileInfoMapType::const_iterator i = + this->CompileInfoMap.find(config_upper); + if(i == this->CompileInfoMap.end()) + { + CompileInfo info; + this->Target + ->ComputePDBOutputDir("COMPILE_PDB", config, info.CompilePdbDir); + CompileInfoMapType::value_type entry(config_upper, info); + i = this->CompileInfoMap.insert(entry).first; + } + return &i->second; +} + //---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetModuleDefinitionFile(const std::string& config) const @@ -1827,7 +1867,7 @@ void cmGeneratorTarget::TraceDependencies() std::string cmGeneratorTarget::GetCompilePDBDirectory(const std::string& config) const { - if(cmTarget::CompileInfo const* info = this->Target->GetCompileInfo(config)) + if(CompileInfo const* info = this->GetCompileInfo(config)) { return info->CompilePdbDir; } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 3dbbca1..68e7a8a 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -230,6 +230,16 @@ public: /** Whether this library has soname enabled and platform supports it. */ bool HasSOName(const std::string& config) const; + struct CompileInfo + { + std::string CompilePdbDir; + }; + + CompileInfo const* GetCompileInfo(const std::string& config) const; + + typedef std::map CompileInfoMapType; + mutable CompileInfoMapType CompileInfoMap; + /** Get the name of the compiler pdb file for the target. */ std::string GetCompilePDBName(const std::string& config="") const; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 9308113..1f8f07a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -126,9 +126,6 @@ public: typedef std::map ImportInfoMapType; ImportInfoMapType ImportInfoMap; - typedef std::map CompileInfoMapType; - CompileInfoMapType CompileInfoMap; - // Cache link implementation computation from each configuration. struct OptionalLinkImplementation: public cmTarget::LinkImplementation { @@ -2598,45 +2595,6 @@ cmTarget::OutputInfo const* cmTarget::GetOutputInfo( } //---------------------------------------------------------------------------- -cmTarget::CompileInfo const* cmTarget::GetCompileInfo( - const std::string& config) const -{ - // There is no compile information for imported targets. - if(this->IsImported()) - { - return 0; - } - - if(this->GetType() > cmTarget::OBJECT_LIBRARY) - { - std::string msg = "cmTarget::GetCompileInfo called for "; - msg += this->GetName(); - msg += " which has type "; - msg += cmTarget::GetTargetTypeName(this->GetType()); - this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg); - return 0; - } - - // Lookup/compute/cache the compile information for this configuration. - std::string config_upper; - if(!config.empty()) - { - config_upper = cmSystemTools::UpperCase(config); - } - typedef cmTargetInternals::CompileInfoMapType CompileInfoMapType; - CompileInfoMapType::const_iterator i = - this->Internal->CompileInfoMap.find(config_upper); - if(i == this->Internal->CompileInfoMap.end()) - { - CompileInfo info; - this->ComputePDBOutputDir("COMPILE_PDB", config, info.CompilePdbDir); - CompileInfoMapType::value_type entry(config_upper, info); - i = this->Internal->CompileInfoMap.insert(entry).first; - } - return &i->second; -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetDirectory(const std::string& config, bool implib) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 8689838..e3fbdfd 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -626,13 +626,6 @@ private: void ComputeImportInfo(std::string const& desired_config, ImportInfo& info) const; - // Cache target compile paths for each configuration. - struct CompileInfo - { - std::string CompilePdbDir; - }; - - CompileInfo const* GetCompileInfo(const std::string& config) const; LinkInterface const* GetImportLinkInterface(const std::string& config, cmTarget const* head, http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4fbbae36ecfc5f281256da93e02539b88fe92d15 commit 4fbbae36ecfc5f281256da93e02539b88fe92d15 Author: Stephen Kelly AuthorDate: Mon Oct 20 20:52:54 2014 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 3 09:14:16 2015 +0200 cmGeneratorTarget: Move GetCompilePDBDirectory from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index aac941e..c6f248c 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -743,7 +743,7 @@ cmGeneratorTarget::GetCompilePDBName(const std::string& config) const std::string cmGeneratorTarget::GetCompilePDBPath(const std::string& config) const { - std::string dir = this->Target->GetCompilePDBDirectory(config); + std::string dir = this->GetCompilePDBDirectory(config); std::string name = this->GetCompilePDBName(config); if(dir.empty() && !name.empty()) { @@ -1824,6 +1824,16 @@ void cmGeneratorTarget::TraceDependencies() tracer.Trace(); } +std::string +cmGeneratorTarget::GetCompilePDBDirectory(const std::string& config) const +{ + if(cmTarget::CompileInfo const* info = this->Target->GetCompileInfo(config)) + { + return info->CompilePdbDir; + } + return ""; +} + //---------------------------------------------------------------------------- void cmGeneratorTarget::GetAppleArchs(const std::string& config, std::vector& archVec) const diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 52ab6c0..3dbbca1 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -214,6 +214,12 @@ public: */ void TraceDependencies(); + /** Get the directory in which to place the target compiler .pdb file. + If the configuration name is given then the generator will add its + subdirectory for that configuration. Otherwise just the canonical + compiler pdb output directory is given. */ + std::string GetCompilePDBDirectory(const std::string& config = "") const; + /** Get sources that must be built before the given source. */ std::vector const* GetSourceDepends(cmSourceFile const* sf) const; diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index afe145a..ccb0974 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -130,7 +130,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) } std::string compilePdbOutputPath = - this->Target->GetCompilePDBDirectory(this->ConfigName); + this->GeneratorTarget->GetCompilePDBDirectory(this->ConfigName); cmSystemTools::MakeDirectory(compilePdbOutputPath.c_str()); std::string pdbOutputPath = this->Target->GetPDBDirectory(this->ConfigName); diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index bb0f9dd..2f995e8 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -311,7 +311,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules } std::string compilePdbOutputPath = - this->Target->GetCompilePDBDirectory(this->ConfigName); + this->GeneratorTarget->GetCompilePDBDirectory(this->ConfigName); cmSystemTools::MakeDirectory(compilePdbOutputPath.c_str()); std::string pdbOutputPath = this->Target->GetPDBDirectory(this->ConfigName); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 8b64bc4..9308113 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -69,12 +69,6 @@ struct cmTarget::OutputInfo }; //---------------------------------------------------------------------------- -struct cmTarget::CompileInfo -{ - std::string CompilePdbDir; -}; - -//---------------------------------------------------------------------------- class cmTargetInternals { public: @@ -2673,16 +2667,6 @@ std::string cmTarget::GetPDBDirectory(const std::string& config) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetCompilePDBDirectory(const std::string& config) const -{ - if(CompileInfo const* info = this->GetCompileInfo(config)) - { - return info->CompilePdbDir; - } - return ""; -} - -//---------------------------------------------------------------------------- const char* cmTarget::ImportedGetLocation(const std::string& config) const { static std::string location; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index a6f2465..8689838 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -334,12 +334,6 @@ public: pdb output directory is given. */ std::string GetPDBDirectory(const std::string& config) const; - /** Get the directory in which to place the target compiler .pdb file. - If the configuration name is given then the generator will add its - subdirectory for that configuration. Otherwise just the canonical - compiler pdb output directory is given. */ - std::string GetCompilePDBDirectory(const std::string& config = "") const; - const char* ImportedGetLocation(const std::string& config) const; /** Get the target major and minor version numbers interpreted from @@ -633,7 +627,11 @@ private: ImportInfo& info) const; // Cache target compile paths for each configuration. - struct CompileInfo; + struct CompileInfo + { + std::string CompilePdbDir; + }; + CompileInfo const* GetCompileInfo(const std::string& config) const; LinkInterface const* http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a324ef1b3f9041eea32fa45991896c8dec0c8541 commit a324ef1b3f9041eea32fa45991896c8dec0c8541 Author: Stephen Kelly AuthorDate: Sat Aug 1 07:04:23 2015 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 3 09:14:16 2015 +0200 cmGeneratorTarget: Move GetOutputName from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 55e2922..aac941e 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -267,6 +267,54 @@ const char *cmGeneratorTarget::GetProperty(const std::string& prop) const } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetOutputName(const std::string& config, + bool implib) const +{ + std::vector props; + std::string type = this->Target->GetOutputTargetType(implib); + std::string configUpper = cmSystemTools::UpperCase(config); + if(!type.empty() && !configUpper.empty()) + { + // _OUTPUT_NAME_ + props.push_back(type + "_OUTPUT_NAME_" + configUpper); + } + if(!type.empty()) + { + // _OUTPUT_NAME + props.push_back(type + "_OUTPUT_NAME"); + } + if(!configUpper.empty()) + { + // OUTPUT_NAME_ + props.push_back("OUTPUT_NAME_" + configUpper); + // _OUTPUT_NAME + props.push_back(configUpper + "_OUTPUT_NAME"); + } + // OUTPUT_NAME + props.push_back("OUTPUT_NAME"); + + std::string outName; + for(std::vector::const_iterator i = props.begin(); + i != props.end(); ++i) + { + if (const char* outNameProp = this->Target->GetProperty(*i)) + { + outName = outNameProp; + break; + } + } + + if (outName.empty()) + { + outName = this->GetName(); + } + + cmGeneratorExpression ge; + cmsys::auto_ptr cge = ge.Parse(outName); + return cge->Evaluate(this->Makefile, config); +} + +//---------------------------------------------------------------------------- std::vector const* cmGeneratorTarget::GetSourceDepends(cmSourceFile const* sf) const { @@ -922,7 +970,7 @@ std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config, bool contentOnly) const { std::string fpath; - fpath += this->Target->GetOutputName(config, false); + fpath += this->GetOutputName(config, false); fpath += "."; const char *ext = this->Target->GetProperty("BUNDLE_EXTENSION"); if (!ext) @@ -949,7 +997,7 @@ cmGeneratorTarget::GetFrameworkDirectory(const std::string& config, bool rootDir) const { std::string fpath; - fpath += this->Target->GetOutputName(config, false); + fpath += this->GetOutputName(config, false); fpath += ".framework"; if(!rootDir) { @@ -2247,7 +2295,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, std::string fw_prefix; if(this->Target->IsFrameworkOnApple()) { - fw_prefix = this->Target->GetOutputName(config, false); + fw_prefix = this->GetOutputName(config, false); fw_prefix += ".framework/"; targetPrefix = fw_prefix.c_str(); targetSuffix = 0; @@ -2265,7 +2313,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, outPrefix = targetPrefix?targetPrefix:""; // Append the target name or property-specified name. - outBase += this->Target->GetOutputName(config, implib); + outBase += this->GetOutputName(config, implib); // Append the per-configuration postfix. outBase += configPostfix?configPostfix:""; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 21e0900..52ab6c0 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -230,6 +230,9 @@ public: /** Get the path for the MSVC /Fd option for this target. */ std::string GetCompilePDBPath(const std::string& config="") const; + // Get the target base name. + std::string GetOutputName(const std::string& config, bool implib) const; + /** * Flags for a given source file as used in this target. Typically assigned * via SET_TARGET_PROPERTIES when the property is a list of source files. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e887ef3..8b64bc4 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3663,54 +3663,6 @@ bool cmTarget::UsesDefaultOutputDir(const std::string& config, } //---------------------------------------------------------------------------- -std::string cmTarget::GetOutputName(const std::string& config, - bool implib) const -{ - std::vector props; - std::string type = this->GetOutputTargetType(implib); - std::string configUpper = cmSystemTools::UpperCase(config); - if(!type.empty() && !configUpper.empty()) - { - // _OUTPUT_NAME_ - props.push_back(type + "_OUTPUT_NAME_" + configUpper); - } - if(!type.empty()) - { - // _OUTPUT_NAME - props.push_back(type + "_OUTPUT_NAME"); - } - if(!configUpper.empty()) - { - // OUTPUT_NAME_ - props.push_back("OUTPUT_NAME_" + configUpper); - // _OUTPUT_NAME - props.push_back(configUpper + "_OUTPUT_NAME"); - } - // OUTPUT_NAME - props.push_back("OUTPUT_NAME"); - - std::string outName; - for(std::vector::const_iterator i = props.begin(); - i != props.end(); ++i) - { - if (const char* outNameProp = this->GetProperty(*i)) - { - outName = outNameProp; - break; - } - } - - if (outName.empty()) - { - outName = this->GetName(); - } - - cmGeneratorExpression ge; - cmsys::auto_ptr cge = ge.Parse(outName); - return cge->Evaluate(this->Makefile, config); -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetFrameworkVersion() const { assert(this->GetType() != INTERFACE_LIBRARY); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e53afff..a6f2465 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -552,9 +552,6 @@ private: // Returns ARCHIVE, LIBRARY, or RUNTIME based on platform and type. const char* GetOutputTargetType(bool implib) const; - // Get the target base name. - std::string GetOutputName(const std::string& config, bool implib) const; - std::string GetFullNameImported(const std::string& config, bool implib) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2c76fc32078d21454c0cb4d4ddf0c771adad9e0a commit 2c76fc32078d21454c0cb4d4ddf0c771adad9e0a Author: Stephen Kelly AuthorDate: Thu Jul 30 00:45:34 2015 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 3 09:14:16 2015 +0200 cmComputeLinkDepends: Port to cmGeneratorTarget. diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index abd9877..8ba8847 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -173,18 +173,19 @@ items that we know the linker will re-use automatically (shared libs). //---------------------------------------------------------------------------- cmComputeLinkDepends -::cmComputeLinkDepends(cmTarget const* target, const std::string& config) +::cmComputeLinkDepends(const cmGeneratorTarget* target, + const std::string& config) { // Store context information. this->Target = target; - this->Makefile = this->Target->GetMakefile(); + this->Makefile = this->Target->Target->GetMakefile(); this->GlobalGenerator = this->Makefile->GetGlobalGenerator(); this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance(); // The configuration being linked. this->HasConfig = !config.empty(); this->Config = (this->HasConfig)? config : std::string(); - this->LinkType = this->Target->ComputeLinkType(this->Config); + this->LinkType = this->Target->Target->ComputeLinkType(this->Config); // Enable debug mode if requested. this->DebugMode = this->Makefile->IsOn("CMAKE_LINK_DEPENDS_DEBUG_MODE"); @@ -363,7 +364,7 @@ void cmComputeLinkDepends::FollowLinkEntry(BFSEntry const& qe) { // Follow the target dependencies. if(cmTarget::LinkInterface const* iface = - entry.Target->GetLinkInterface(this->Config, this->Target)) + entry.Target->GetLinkInterface(this->Config, this->Target->Target)) { const bool isIface = entry.Target->GetType() == cmTarget::INTERFACE_LIBRARY; @@ -461,7 +462,7 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep) if(entry.Target) { if(cmTarget::LinkInterface const* iface = - entry.Target->GetLinkInterface(this->Config, this->Target)) + entry.Target->GetLinkInterface(this->Config, this->Target->Target)) { // Follow public and private dependencies transitively. this->FollowSharedDeps(index, iface, true); @@ -552,7 +553,7 @@ void cmComputeLinkDepends::AddDirectLinkEntries() { // Add direct link dependencies in this configuration. cmTarget::LinkImplementation const* impl = - this->Target->GetLinkImplementation(this->Config); + this->Target->Target->GetLinkImplementation(this->Config); this->AddLinkEntries(-1, impl->Libraries); for(std::vector::const_iterator wi = impl->WrongConfigLibraries.begin(); @@ -634,7 +635,7 @@ cmTarget const* cmComputeLinkDepends::FindTargetToLink(int depender_index, const std::string& name) { // Look for a target in the scope of the depender. - cmTarget const* from = this->Target; + cmTarget const* from = this->Target->Target; if(depender_index >= 0) { if(cmTarget const* depender = this->EntryList[depender_index].Target) @@ -932,7 +933,7 @@ int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl) if(cmTarget const* target = this->EntryList[*ni].Target) { if(cmTarget::LinkInterface const* iface = - target->GetLinkInterface(this->Config, this->Target)) + target->GetLinkInterface(this->Config, this->Target->Target)) { if(iface->Multiplicity > count) { diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index 51a08c5..b925a4f 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -22,6 +22,7 @@ class cmComputeComponentGraph; class cmGlobalGenerator; class cmMakefile; +class cmGeneratorTarget; class cmTarget; class cmake; @@ -31,7 +32,8 @@ class cmake; class cmComputeLinkDepends { public: - cmComputeLinkDepends(cmTarget const* target, const std::string& config); + cmComputeLinkDepends(cmGeneratorTarget const* target, + const std::string& config); ~cmComputeLinkDepends(); // Basic information about each link item. @@ -57,7 +59,7 @@ public: private: // Context information. - cmTarget const* Target; + cmGeneratorTarget const* Target; cmMakefile* Makefile; cmGlobalGenerator const* GlobalGenerator; cmake* CMakeInstance; diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index fb89319..5cd0d54 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -497,7 +497,7 @@ bool cmComputeLinkInformation::Compute() } // Compute the ordered link line items. - cmComputeLinkDepends cld(this->Target->Target, this->Config); + cmComputeLinkDepends cld(this->Target, this->Config); cld.SetOldLinkDirMode(this->OldLinkDirMode); cmComputeLinkDepends::EntryVector const& linkEntries = cld.Compute(); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5c5ab106dd68ebd3105a877c325b94892504a0a2 commit 5c5ab106dd68ebd3105a877c325b94892504a0a2 Author: Stephen Kelly AuthorDate: Thu Jul 30 00:41:27 2015 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 3 09:14:16 2015 +0200 cmComputeLinkInformation: Port to cmGeneratorTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index f03c04a..fb89319 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -242,11 +242,12 @@ because this need be done only for shared libraries without soname-s. //---------------------------------------------------------------------------- cmComputeLinkInformation -::cmComputeLinkInformation(cmTarget const* target, const std::string& config) +::cmComputeLinkInformation(const cmGeneratorTarget* target, + const std::string& config) { // Store context information. this->Target = target; - this->Makefile = this->Target->GetMakefile(); + this->Makefile = this->Target->Target->GetMakefile(); this->GlobalGenerator = this->Makefile->GetGlobalGenerator(); this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance(); @@ -259,17 +260,15 @@ cmComputeLinkInformation // Allocate internals. this->OrderLinkerSearchPath = - new cmOrderDirectories(this->GlobalGenerator, target, + new cmOrderDirectories(this->GlobalGenerator, target->Target, "linker search path"); this->OrderRuntimeSearchPath = - new cmOrderDirectories(this->GlobalGenerator, target, + new cmOrderDirectories(this->GlobalGenerator, target->Target, "runtime search path"); this->OrderDependentRPath = 0; - cmGeneratorTarget *gtgt = this->GlobalGenerator - ->GetGeneratorTarget(this->Target); // Get the language used for linking this target. - this->LinkLanguage = gtgt->GetLinkerLanguage(config); + this->LinkLanguage = this->Target->GetLinkerLanguage(config); if(this->LinkLanguage.empty()) { // The Compute method will do nothing, so skip the rest of the @@ -283,14 +282,14 @@ cmComputeLinkInformation // Check whether we should skip dependencies on shared library files. this->LinkDependsNoShared = - this->Target->GetPropertyAsBool("LINK_DEPENDS_NO_SHARED"); + this->Target->Target->GetPropertyAsBool("LINK_DEPENDS_NO_SHARED"); // On platforms without import libraries there may be a special flag // to use when creating a plugin (module) that obtains symbols from // the program that will load it. this->LoaderFlag = 0; if(!this->UseImportLibrary && - this->Target->GetType() == cmTarget::MODULE_LIBRARY) + this->Target->Target->GetType() == cmTarget::MODULE_LIBRARY) { std::string loader_flag_var = "CMAKE_SHARED_MODULE_LOADER_"; loader_flag_var += this->LinkLanguage; @@ -308,10 +307,10 @@ cmComputeLinkInformation // Get options needed to specify RPATHs. this->RuntimeUseChrpath = false; - if(this->Target->GetType() != cmTarget::STATIC_LIBRARY) + if(this->Target->Target->GetType() != cmTarget::STATIC_LIBRARY) { const char* tType = - ((this->Target->GetType() == cmTarget::EXECUTABLE)? + ((this->Target->Target->GetType() == cmTarget::EXECUTABLE)? "EXECUTABLE" : "SHARED_LIBRARY"); std::string rtVar = "CMAKE_"; rtVar += tType; @@ -325,7 +324,7 @@ cmComputeLinkInformation (this->Makefile-> GetSafeDefinition("CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH")); - this->RuntimeUseChrpath = gtgt->IsChrpathUsed(config); + this->RuntimeUseChrpath = this->Target->IsChrpathUsed(config); // Get options needed to help find dependent libraries. std::string rlVar = "CMAKE_"; @@ -371,15 +370,15 @@ cmComputeLinkInformation { this->SharedDependencyMode = SharedDepModeDir; this->OrderDependentRPath = - new cmOrderDirectories(this->GlobalGenerator, target, + new cmOrderDirectories(this->GlobalGenerator, target->Target, "dependent library path"); } // Add the search path entries requested by the user to path ordering. this->OrderLinkerSearchPath - ->AddUserDirectories(this->Target->GetLinkDirectories()); + ->AddUserDirectories(this->Target->Target->GetLinkDirectories()); this->OrderRuntimeSearchPath - ->AddUserDirectories(this->Target->GetLinkDirectories()); + ->AddUserDirectories(this->Target->Target->GetLinkDirectories()); // Set up the implicit link directories. this->LoadImplicitLinkInfo(); @@ -407,12 +406,13 @@ cmComputeLinkInformation // order to support such projects we need to add the directories // containing libraries linked with a full path to the -L path. this->OldLinkDirMode = - this->Target->GetPolicyStatusCMP0003() != cmPolicies::NEW; + this->Target->Target->GetPolicyStatusCMP0003() != cmPolicies::NEW; if(this->OldLinkDirMode) { // Construct a mask to not bother with this behavior for link // directories already specified by the user. - std::vector const& dirs = this->Target->GetLinkDirectories(); + std::vector const& dirs = + this->Target->Target->GetLinkDirectories(); this->OldLinkDirMask.insert(dirs.begin(), dirs.end()); } @@ -497,7 +497,7 @@ bool cmComputeLinkInformation::Compute() } // Compute the ordered link line items. - cmComputeLinkDepends cld(this->Target, this->Config); + cmComputeLinkDepends cld(this->Target->Target, this->Config); cld.SetOldLinkDirMode(this->OldLinkDirMode); cmComputeLinkDepends::EntryVector const& linkEntries = cld.Compute(); @@ -518,7 +518,8 @@ bool cmComputeLinkInformation::Compute() // Restore the target link type so the correct system runtime // libraries are found. - const char* lss = this->Target->GetProperty("LINK_SEARCH_END_STATIC"); + const char* lss = + this->Target->Target->GetProperty("LINK_SEARCH_END_STATIC"); if(cmSystemTools::IsOn(lss)) { this->SetCurrentLinkType(LinkStatic); @@ -571,7 +572,7 @@ bool cmComputeLinkInformation::Compute() "name." ; this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); } return true; @@ -580,12 +581,9 @@ bool cmComputeLinkInformation::Compute() //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddImplicitLinkInfo() { - cmGeneratorTarget *gtgt = this->Target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(this->Target); - // The link closure lists all languages whose implicit info is needed. - cmGeneratorTarget::LinkClosure const* lc=gtgt->GetLinkClosure(this->Config); + cmGeneratorTarget::LinkClosure const* lc = + this->Target->GetLinkClosure(this->Config); for(std::vector::const_iterator li = lc->Languages.begin(); li != lc->Languages.end(); ++li) { @@ -863,7 +861,8 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo() } // Lookup the starting link type from the target (linked statically?). - const char* lss = this->Target->GetProperty("LINK_SEARCH_START_STATIC"); + const char* lss = + this->Target->Target->GetProperty("LINK_SEARCH_START_STATIC"); this->StartLinkType = cmSystemTools::IsOn(lss)? LinkStatic : LinkShared; this->CurrentLinkType = this->StartLinkType; } @@ -1149,7 +1148,7 @@ void cmComputeLinkInformation::AddFullItem(std::string const& item) // Full path libraries should specify a valid library file name. // See documentation of CMP0008. std::string generator = this->GlobalGenerator->GetName(); - if(this->Target->GetPolicyStatusCMP0008() != cmPolicies::NEW && + if(this->Target->Target->GetPolicyStatusCMP0008() != cmPolicies::NEW && (generator.find("Visual Studio") != generator.npos || generator.find("Xcode") != generator.npos)) { @@ -1230,7 +1229,7 @@ bool cmComputeLinkInformation::CheckImplicitDirItem(std::string const& item) } // Check the policy for whether we should use the approach below. - switch (this->Target->GetPolicyStatusCMP0060()) + switch (this->Target->Target->GetPolicyStatusCMP0060()) { case cmPolicies::WARN: if (this->CMP0060Warn) @@ -1540,7 +1539,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item, this->OrderLinkerSearchPath->AddLinkLibrary(item); // Produce any needed message. - switch(this->Target->GetPolicyStatusCMP0008()) + switch(this->Target->Target->GetPolicyStatusCMP0008()) { case cmPolicies::WARN: { @@ -1557,7 +1556,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item, << " " << item << "\n" << "which is a full-path but not a valid library file name."; this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); } } case cmPolicies::OLD: @@ -1575,7 +1574,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item, << " " << item << "\n" << "which is a full-path but not a valid library file name."; this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); } break; } @@ -1592,7 +1591,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories() } // Enforce policy constraints. - switch(this->Target->GetPolicyStatusCMP0003()) + switch(this->Target->Target->GetPolicyStatusCMP0003()) { case cmPolicies::WARN: if(!this->CMakeInstance->GetState() @@ -1603,7 +1602,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories() std::ostringstream w; this->PrintLinkPolicyDiagnosis(w); this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); } case cmPolicies::OLD: // OLD behavior is to add the paths containing libraries with @@ -1619,7 +1618,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories() e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0003) << "\n"; this->PrintLinkPolicyDiagnosis(e); this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); return false; } } @@ -1923,23 +1922,24 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, // build tree. bool linking_for_install = (for_install || - this->Target->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")); + this->Target->Target->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")); bool use_install_rpath = - (outputRuntime && this->Target->HaveInstallTreeRPATH() && + (outputRuntime && this->Target->Target->HaveInstallTreeRPATH() && linking_for_install); bool use_build_rpath = - (outputRuntime && this->Target->HaveBuildTreeRPATH(this->Config) && + (outputRuntime && this->Target->Target->HaveBuildTreeRPATH(this->Config) && !linking_for_install); bool use_link_rpath = outputRuntime && linking_for_install && !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH") && - this->Target->GetPropertyAsBool("INSTALL_RPATH_USE_LINK_PATH"); + this->Target->Target->GetPropertyAsBool("INSTALL_RPATH_USE_LINK_PATH"); // Construct the RPATH. std::set emitted; if(use_install_rpath) { - const char* install_rpath = this->Target->GetProperty("INSTALL_RPATH"); + const char* install_rpath = + this->Target->Target->GetProperty("INSTALL_RPATH"); cmCLI_ExpandListUnique(install_rpath, runtimeDirs, emitted); } if(use_build_rpath || use_link_rpath) @@ -2011,12 +2011,8 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, // Add runtime paths required by the languages to always be // present. This is done even when skipping rpath support. { - cmGeneratorTarget *gtgt = this->Makefile - ->GetGlobalGenerator() - ->GetGeneratorTarget(this->Target); - cmGeneratorTarget::LinkClosure const* lc = - gtgt->GetLinkClosure(this->Config); + this->Target->GetLinkClosure(this->Config); for(std::vector::const_iterator li = lc->Languages.begin(); li != lc->Languages.end(); ++li) { diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index 2d7a5a5..8b83574 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -29,7 +29,8 @@ class cmOrderDirectories; class cmComputeLinkInformation { public: - cmComputeLinkInformation(cmTarget const* target, const std::string& config); + cmComputeLinkInformation(cmGeneratorTarget const* target, + const std::string& config); ~cmComputeLinkInformation(); bool Compute(); @@ -73,7 +74,7 @@ private: std::set SharedLibrariesLinked; // Context information. - cmTarget const* Target; + cmGeneratorTarget const* Target; cmMakefile* Makefile; cmGlobalGenerator* GlobalGenerator; cmake* CMakeInstance; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c68c2b9..55e2922 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3166,7 +3166,7 @@ cmGeneratorTarget::GetLinkInformation(const std::string& config) const { // Compute information for this configuration. cmComputeLinkInformation* info = - new cmComputeLinkInformation(this->Target, config); + new cmComputeLinkInformation(this, config); if(!info || !info->Compute()) { delete info; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b952bb3f9be968de54032135237c67bbc0dd0a70 commit b952bb3f9be968de54032135237c67bbc0dd0a70 Author: Stephen Kelly AuthorDate: Tue Jul 28 23:16:43 2015 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 3 09:14:15 2015 +0200 cmGeneratorTarget: Move IsBundleOnApple from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c314372..c68c2b9 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -910,6 +910,14 @@ cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, } //---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsBundleOnApple() const +{ + return this->Target->IsFrameworkOnApple() + || this->Target->IsAppBundleOnApple() + || this->Target->IsCFBundleOnApple(); +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config, bool contentOnly) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index a1193a6..21e0900 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -119,6 +119,10 @@ public: std::string GetAppBundleDirectory(const std::string& config, bool contentOnly) const; + /** Return whether this target is an executable Bundle, a framework + or CFBundle on Apple. */ + bool IsBundleOnApple() const; + /** Get the full name of the target according to the settings in its makefile. */ std::string GetFullName(const std::string& config="", diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index d38cf4c..0b3df90 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -313,7 +313,7 @@ cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator() (cmSourceFile const& source, const char* pkgloc) { // Skip OS X content when not building a Framework or Bundle. - if(!this->Generator->GetTarget()->IsBundleOnApple()) + if(!this->Generator->GetGeneratorTarget()->IsBundleOnApple()) { return; } diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 16e1f48..07efa16 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -742,7 +742,7 @@ cmNinjaTargetGenerator::MacOSXContentGeneratorType::operator()( cmSourceFile const& source, const char* pkgloc) { // Skip OS X content when not building a Framework or Bundle. - if(!this->Generator->GetTarget()->IsBundleOnApple()) + if(!this->Generator->GetGeneratorTarget()->IsBundleOnApple()) { return; } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 62aa12a..e887ef3 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -590,13 +590,6 @@ bool cmTarget::IsXCTestOnApple() const } //---------------------------------------------------------------------------- -bool cmTarget::IsBundleOnApple() const -{ - return this->IsFrameworkOnApple() || this->IsAppBundleOnApple() || - this->IsCFBundleOnApple(); -} - -//---------------------------------------------------------------------------- static bool processSources(cmTarget const* tgt, const std::vector &entries, std::vector &srcs, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 9a4915f..e53afff 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -424,10 +424,6 @@ public: /** Return whether this target is an executable Bundle on Apple. */ bool IsAppBundleOnApple() const; - /** Return whether this target is an executable Bundle, a framework - or CFBundle on Apple. */ - bool IsBundleOnApple() const; - /** Return the framework version string. Undefined if IsFrameworkOnApple returns false. */ std::string GetFrameworkVersion() const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6daea501377f8347c5b081f03fdd22cfdb76f538 commit 6daea501377f8347c5b081f03fdd22cfdb76f538 Author: Stephen Kelly AuthorDate: Tue Jul 28 23:18:55 2015 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 3 09:14:15 2015 +0200 cmMakefileTargetGenerator: Add accessor for GeneratorTarget. diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index b885672..fd4527b 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -53,6 +53,7 @@ public: { return this->ProgressFileNameFull; } cmTarget* GetTarget() { return this->Target;} + cmGeneratorTarget* GetGeneratorTarget() { return this->GeneratorTarget;} protected: http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=798a5ac620ee63abc5d61b6db6f65db1b34a3605 commit 798a5ac620ee63abc5d61b6db6f65db1b34a3605 Author: Stephen Kelly AuthorDate: Wed Oct 10 21:43:28 2012 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 3 09:14:15 2015 +0200 cmGeneratorTarget: Move GetLinkClosure from cmTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 640e806..f03c04a 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -19,6 +19,7 @@ #include "cmOutputConverter.h" #include "cmMakefile.h" #include "cmTarget.h" +#include "cmGeneratorTarget.h" #include "cmake.h" #include "cmAlgorithms.h" @@ -579,8 +580,12 @@ bool cmComputeLinkInformation::Compute() //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddImplicitLinkInfo() { + cmGeneratorTarget *gtgt = this->Target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(this->Target); + // The link closure lists all languages whose implicit info is needed. - cmTarget::LinkClosure const* lc=this->Target->GetLinkClosure(this->Config); + cmGeneratorTarget::LinkClosure const* lc=gtgt->GetLinkClosure(this->Config); for(std::vector::const_iterator li = lc->Languages.begin(); li != lc->Languages.end(); ++li) { @@ -2006,8 +2011,12 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, // Add runtime paths required by the languages to always be // present. This is done even when skipping rpath support. { - cmTarget::LinkClosure const* lc = - this->Target->GetLinkClosure(this->Config); + cmGeneratorTarget *gtgt = this->Makefile + ->GetGlobalGenerator() + ->GetGeneratorTarget(this->Target); + + cmGeneratorTarget::LinkClosure const* lc = + gtgt->GetLinkClosure(this->Config); for(std::vector::const_iterator li = lc->Languages.begin(); li != lc->Languages.end(); ++li) { diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index 3afbb92..2d7a5a5 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -20,6 +20,7 @@ class cmake; class cmGlobalGenerator; class cmMakefile; class cmTarget; +class cmGeneratorTarget; class cmOrderDirectories; /** \class cmComputeLinkInformation diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 4de5e9c..c314372 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -27,6 +27,13 @@ #include #include "assert.h" +#if defined(CMAKE_BUILD_WITH_CMAKE) +#include +#define UNORDERED_SET cmsys::hash_set +#else +#define UNORDERED_SET std::set +#endif + //---------------------------------------------------------------------------- void reportBadObjLib(std::vector const& badObjLib, cmTarget *target, cmake *cm) @@ -1026,6 +1033,223 @@ std::string cmGeneratorTarget::GetInstallNameDirForInstallTree() const } //---------------------------------------------------------------------------- +class cmTargetCollectLinkLanguages +{ +public: + cmTargetCollectLinkLanguages(cmGeneratorTarget const* target, + const std::string& config, + UNORDERED_SET& languages, + cmTarget const* head): + Config(config), Languages(languages), HeadTarget(head), + Makefile(target->Target->GetMakefile()), Target(target) + { this->Visited.insert(target->Target); } + + void Visit(cmLinkItem const& item) + { + if(!item.Target) + { + if(item.find("::") != std::string::npos) + { + bool noMessage = false; + cmake::MessageType messageType = cmake::FATAL_ERROR; + std::stringstream e; + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0028)) + { + case cmPolicies::WARN: + { + e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0028) << "\n"; + messageType = cmake::AUTHOR_WARNING; + } + break; + case cmPolicies::OLD: + noMessage = true; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::NEW: + // Issue the fatal message. + break; + } + + if(!noMessage) + { + e << "Target \"" << this->Target->GetName() + << "\" links to target \"" << item + << "\" but the target was not found. Perhaps a find_package() " + "call is missing for an IMPORTED target, or an ALIAS target is " + "missing?"; + this->Makefile->GetCMakeInstance()->IssueMessage( + messageType, e.str(), this->Target->Target->GetBacktrace()); + } + } + return; + } + if(!this->Visited.insert(item.Target).second) + { + return; + } + + cmTarget::LinkInterface const* iface = + item.Target->GetLinkInterface(this->Config, this->HeadTarget); + if(!iface) { return; } + + for(std::vector::const_iterator + li = iface->Languages.begin(); li != iface->Languages.end(); ++li) + { + this->Languages.insert(*li); + } + + for(std::vector::const_iterator + li = iface->Libraries.begin(); li != iface->Libraries.end(); ++li) + { + this->Visit(*li); + } + } +private: + std::string Config; + UNORDERED_SET& Languages; + cmTarget const* HeadTarget; + cmMakefile* Makefile; + const cmGeneratorTarget* Target; + std::set Visited; +}; + +//---------------------------------------------------------------------------- +cmGeneratorTarget::LinkClosure const* +cmGeneratorTarget::GetLinkClosure(const std::string& config) const +{ + std::string key(cmSystemTools::UpperCase(config)); + LinkClosureMapType::iterator + i = this->LinkClosureMap.find(key); + if(i == this->LinkClosureMap.end()) + { + LinkClosure lc; + this->ComputeLinkClosure(config, lc); + LinkClosureMapType::value_type entry(key, lc); + i = this->LinkClosureMap.insert(entry).first; + } + return &i->second; +} + +//---------------------------------------------------------------------------- +class cmTargetSelectLinker +{ + int Preference; + cmGeneratorTarget const* Target; + cmMakefile* Makefile; + cmGlobalGenerator* GG; + std::set Preferred; +public: + cmTargetSelectLinker(cmGeneratorTarget const* target) + : Preference(0), Target(target) + { + this->Makefile = this->Target->Makefile; + this->GG = this->Makefile->GetGlobalGenerator(); + } + void Consider(const char* lang) + { + int preference = this->GG->GetLinkerPreference(lang); + if(preference > this->Preference) + { + this->Preference = preference; + this->Preferred.clear(); + } + if(preference == this->Preference) + { + this->Preferred.insert(lang); + } + } + std::string Choose() + { + if(this->Preferred.empty()) + { + return ""; + } + else if(this->Preferred.size() > 1) + { + std::stringstream e; + e << "Target " << this->Target->GetName() + << " contains multiple languages with the highest linker preference" + << " (" << this->Preference << "):\n"; + for(std::set::const_iterator + li = this->Preferred.begin(); li != this->Preferred.end(); ++li) + { + e << " " << *li << "\n"; + } + e << "Set the LINKER_LANGUAGE property for this target."; + cmake* cm = this->Makefile->GetCMakeInstance(); + cm->IssueMessage(cmake::FATAL_ERROR, e.str(), + this->Target->Target->GetBacktrace()); + } + return *this->Preferred.begin(); + } +}; + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::ComputeLinkClosure(const std::string& config, + LinkClosure& lc) const +{ + // Get languages built in this target. + UNORDERED_SET languages; + cmTarget::LinkImplementation const* impl = + this->Target->GetLinkImplementation(config); + for(std::vector::const_iterator li = impl->Languages.begin(); + li != impl->Languages.end(); ++li) + { + languages.insert(*li); + } + + // Add interface languages from linked targets. + cmTargetCollectLinkLanguages cll(this, config, languages, this->Target); + for(std::vector::const_iterator li = impl->Libraries.begin(); + li != impl->Libraries.end(); ++li) + { + cll.Visit(*li); + } + + // Store the transitive closure of languages. + for(UNORDERED_SET::const_iterator li = languages.begin(); + li != languages.end(); ++li) + { + lc.Languages.push_back(*li); + } + + // Choose the language whose linker should be used. + if(this->GetProperty("HAS_CXX")) + { + lc.LinkerLanguage = "CXX"; + } + else if(const char* linkerLang = this->GetProperty("LINKER_LANGUAGE")) + { + lc.LinkerLanguage = linkerLang; + } + else + { + // Find the language with the highest preference value. + cmTargetSelectLinker tsl(this); + + // First select from the languages compiled directly in this target. + for(std::vector::const_iterator li = impl->Languages.begin(); + li != impl->Languages.end(); ++li) + { + tsl.Consider(li->c_str()); + } + + // Now consider languages that propagate from linked targets. + for(UNORDERED_SET::const_iterator sit = languages.begin(); + sit != languages.end(); ++sit) + { + std::string propagates = "CMAKE_"+*sit+"_LINKER_PREFERENCE_PROPAGATES"; + if(this->Makefile->IsOn(propagates)) + { + tsl.Consider(sit->c_str()); + } + } + + lc.LinkerLanguage = tsl.Choose(); + } +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, std::string& base, std::string& suffix, @@ -2058,7 +2282,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, std::string cmGeneratorTarget::GetLinkerLanguage(const std::string& config) const { - return this->Target->GetLinkClosure(config)->LinkerLanguage; + return this->GetLinkClosure(config)->LinkerLanguage; } //---------------------------------------------------------------------------- diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 41fb848..a1193a6 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -165,6 +165,20 @@ public: std::string GetModuleDefinitionFile(const std::string& config) const; + /** Link information from the transitive closure of the link + implementation and the interfaces of its dependencies. */ + struct LinkClosure + { + // The preferred linker language. + std::string LinkerLanguage; + + // Languages whose runtime libraries must be linked. + std::vector Languages; + }; + + LinkClosure const* GetLinkClosure(const std::string& config) const; + void ComputeLinkClosure(const std::string& config, LinkClosure& lc) const; + /** Full path with trailing slash to the top-level directory holding object files for this target. Includes the build time config name placeholder if needed for the generator. */ @@ -301,6 +315,9 @@ private: std::string& outPrefix, std::string& outBase, std::string& outSuffix) const; + typedef std::map LinkClosureMapType; + mutable LinkClosureMapType LinkClosureMap; + struct CompatibleInterfacesBase { std::set PropsBool; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index c7118dc..62aa12a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -160,9 +160,6 @@ public: HeadToLinkImplementationMap> LinkImplMapType; LinkImplMapType LinkImplMap; - typedef std::map LinkClosureMapType; - LinkClosureMapType LinkClosureMap; - typedef std::map > SourceFilesMapType; SourceFilesMapType SourceFilesMap; @@ -511,7 +508,6 @@ void cmTarget::ClearLinkMaps() this->Internal->LinkImplMap.clear(); this->Internal->LinkInterfaceMap.clear(); this->Internal->LinkInterfaceUsageRequirementsOnlyMap.clear(); - this->Internal->LinkClosureMap.clear(); this->Internal->SourceFilesMap.clear(); } @@ -3136,223 +3132,6 @@ bool cmTarget::GetPropertyAsBool(const std::string& prop) const } //---------------------------------------------------------------------------- -class cmTargetCollectLinkLanguages -{ -public: - cmTargetCollectLinkLanguages(cmTarget const* target, - const std::string& config, - UNORDERED_SET& languages, - cmTarget const* head): - Config(config), Languages(languages), HeadTarget(head), - Makefile(target->GetMakefile()), Target(target) - { this->Visited.insert(target); } - - void Visit(cmLinkItem const& item) - { - if(!item.Target) - { - if(item.find("::") != std::string::npos) - { - bool noMessage = false; - cmake::MessageType messageType = cmake::FATAL_ERROR; - std::ostringstream e; - switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0028)) - { - case cmPolicies::WARN: - { - e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0028) << "\n"; - messageType = cmake::AUTHOR_WARNING; - } - break; - case cmPolicies::OLD: - noMessage = true; - case cmPolicies::REQUIRED_IF_USED: - case cmPolicies::REQUIRED_ALWAYS: - case cmPolicies::NEW: - // Issue the fatal message. - break; - } - - if(!noMessage) - { - e << "Target \"" << this->Target->GetName() - << "\" links to target \"" << item - << "\" but the target was not found. Perhaps a find_package() " - "call is missing for an IMPORTED target, or an ALIAS target is " - "missing?"; - this->Makefile->GetCMakeInstance()->IssueMessage(messageType, - e.str(), - this->Target->GetBacktrace()); - } - } - return; - } - if(!this->Visited.insert(item.Target).second) - { - return; - } - - cmTarget::LinkInterface const* iface = - item.Target->GetLinkInterface(this->Config, this->HeadTarget); - if(!iface) { return; } - - for(std::vector::const_iterator - li = iface->Languages.begin(); li != iface->Languages.end(); ++li) - { - this->Languages.insert(*li); - } - - for(std::vector::const_iterator - li = iface->Libraries.begin(); li != iface->Libraries.end(); ++li) - { - this->Visit(*li); - } - } -private: - std::string Config; - UNORDERED_SET& Languages; - cmTarget const* HeadTarget; - cmMakefile* Makefile; - const cmTarget* Target; - std::set Visited; -}; - -//---------------------------------------------------------------------------- -cmTarget::LinkClosure const* -cmTarget::GetLinkClosure(const std::string& config) const -{ - std::string key(cmSystemTools::UpperCase(config)); - cmTargetInternals::LinkClosureMapType::iterator - i = this->Internal->LinkClosureMap.find(key); - if(i == this->Internal->LinkClosureMap.end()) - { - LinkClosure lc; - this->ComputeLinkClosure(config, lc); - cmTargetInternals::LinkClosureMapType::value_type entry(key, lc); - i = this->Internal->LinkClosureMap.insert(entry).first; - } - return &i->second; -} - -//---------------------------------------------------------------------------- -class cmTargetSelectLinker -{ - int Preference; - cmTarget const* Target; - cmMakefile* Makefile; - cmGlobalGenerator* GG; - UNORDERED_SET Preferred; -public: - cmTargetSelectLinker(cmTarget const* target): Preference(0), Target(target) - { - this->Makefile = this->Target->GetMakefile(); - this->GG = this->Makefile->GetGlobalGenerator(); - } - void Consider(const std::string& lang) - { - int preference = this->GG->GetLinkerPreference(lang); - if(preference > this->Preference) - { - this->Preference = preference; - this->Preferred.clear(); - } - if(preference == this->Preference) - { - this->Preferred.insert(lang); - } - } - std::string Choose() - { - if(this->Preferred.empty()) - { - return ""; - } - else if(this->Preferred.size() > 1) - { - std::ostringstream e; - e << "Target " << this->Target->GetName() - << " contains multiple languages with the highest linker preference" - << " (" << this->Preference << "):\n"; - for(UNORDERED_SET::const_iterator - li = this->Preferred.begin(); li != this->Preferred.end(); ++li) - { - e << " " << *li << "\n"; - } - e << "Set the LINKER_LANGUAGE property for this target."; - cmake* cm = this->Makefile->GetCMakeInstance(); - cm->IssueMessage(cmake::FATAL_ERROR, e.str(), - this->Target->GetBacktrace()); - } - return *this->Preferred.begin(); - } -}; - -//---------------------------------------------------------------------------- -void cmTarget::ComputeLinkClosure(const std::string& config, - LinkClosure& lc) const -{ - // Get languages built in this target. - UNORDERED_SET languages; - LinkImplementation const* impl = this->GetLinkImplementation(config); - for(std::vector::const_iterator li = impl->Languages.begin(); - li != impl->Languages.end(); ++li) - { - languages.insert(*li); - } - - // Add interface languages from linked targets. - cmTargetCollectLinkLanguages cll(this, config, languages, this); - for(std::vector::const_iterator - li = impl->Libraries.begin(); - li != impl->Libraries.end(); ++li) - { - cll.Visit(*li); - } - - // Store the transitive closure of languages. - for(UNORDERED_SET::const_iterator li = languages.begin(); - li != languages.end(); ++li) - { - lc.Languages.push_back(*li); - } - - // Choose the language whose linker should be used. - if(this->GetProperty("HAS_CXX")) - { - lc.LinkerLanguage = "CXX"; - } - else if(const char* linkerLang = this->GetProperty("LINKER_LANGUAGE")) - { - lc.LinkerLanguage = linkerLang; - } - else - { - // Find the language with the highest preference value. - cmTargetSelectLinker tsl(this); - - // First select from the languages compiled directly in this target. - for(std::vector::const_iterator li = impl->Languages.begin(); - li != impl->Languages.end(); ++li) - { - tsl.Consider(*li); - } - - // Now consider languages that propagate from linked targets. - for(UNORDERED_SET::const_iterator sit = languages.begin(); - sit != languages.end(); ++sit) - { - std::string propagates = "CMAKE_"+*sit+"_LINKER_PREFERENCE_PROPAGATES"; - if(this->Makefile->IsOn(propagates)) - { - tsl.Consider(*sit); - } - } - - lc.LinkerLanguage = tsl.Choose(); - } -} - -//---------------------------------------------------------------------------- void cmTarget::ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index dea9bef..9a4915f 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -315,18 +315,6 @@ public: LinkImplementationLibraries const* GetLinkImplementationLibraries(const std::string& config) const; - /** Link information from the transitive closure of the link - implementation and the interfaces of its dependencies. */ - struct LinkClosure - { - // The preferred linker language. - std::string LinkerLanguage; - - // Languages whose runtime libraries must be linked. - std::vector Languages; - }; - LinkClosure const* GetLinkClosure(const std::string& config) const; - cmTarget const* FindTargetToLink(std::string const& name) const; /** Strip off leading and trailing whitespace from an item named in @@ -662,7 +650,6 @@ private: LinkImplementationLibraries const* GetLinkImplementationLibrariesInternal(const std::string& config, cmTarget const* head) const; - void ComputeLinkClosure(const std::string& config, LinkClosure& lc) const; void ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, cmTarget const* headTarget, http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=05a79e3349482f58ccd70f87ac7b852d451b1abd commit 05a79e3349482f58ccd70f87ac7b852d451b1abd Author: Stephen Kelly AuthorDate: Sun Nov 3 16:33:25 2013 +0100 Commit: Stephen Kelly CommitDate: Mon Aug 3 09:14:15 2015 +0200 cmGeneratorTarget: Move GetLinkerLanguage from cmTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index fee921c..640e806 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -265,8 +265,10 @@ cmComputeLinkInformation "runtime search path"); this->OrderDependentRPath = 0; + cmGeneratorTarget *gtgt = this->GlobalGenerator + ->GetGeneratorTarget(this->Target); // Get the language used for linking this target. - this->LinkLanguage = this->Target->GetLinkerLanguage(config); + this->LinkLanguage = gtgt->GetLinkerLanguage(config); if(this->LinkLanguage.empty()) { // The Compute method will do nothing, so skip the rest of the @@ -322,9 +324,6 @@ cmComputeLinkInformation (this->Makefile-> GetSafeDefinition("CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH")); - cmGeneratorTarget *gtgt = this->Target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(this->Target); this->RuntimeUseChrpath = gtgt->IsChrpathUsed(config); // Get options needed to help find dependent libraries. diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 49fc96b..a86c2bc 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -990,6 +990,9 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode assert(target); + cmGeneratorTarget* gtgt = + context->Makefile->GetGlobalGenerator()->GetGeneratorTarget(target); + if (propertyName == "LINKER_LANGUAGE") { if (target->LinkLanguagePropagatesToDependents() && @@ -1001,7 +1004,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode "link libraries for a static library"); return std::string(); } - return target->GetLinkerLanguage(context->Config); + return gtgt->GetLinkerLanguage(context->Config); } cmGeneratorExpressionDAGChecker dagChecker(context->Backtrace, @@ -1128,9 +1131,6 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode } } - cmGeneratorTarget* gtgt = - context->Makefile->GetGlobalGenerator()->GetGeneratorTarget(target); - if (!prop) { if (target->IsImported() @@ -1600,7 +1600,7 @@ struct TargetFilesystemArtifactResultCreator cmGeneratorExpressionContext *context, const GeneratorExpressionContent *content) { - std::string language = target->Target->GetLinkerLanguage(context->Config); + std::string language = target->GetLinkerLanguage(context->Config); std::string pdbSupportVar = "CMAKE_" + language + "_LINKER_SUPPORTS_PDB"; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 834a2e3..4de5e9c 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -709,8 +709,7 @@ bool cmGeneratorTarget::HasSOName(const std::string& config) const return ((this->GetType() == cmTarget::SHARED_LIBRARY || this->GetType() == cmTarget::MODULE_LIBRARY) && !this->GetPropertyAsBool("NO_SONAME") && - this->Makefile->GetSONameFlag( - this->Target->GetLinkerLanguage(config))); + this->Makefile->GetSONameFlag(this->GetLinkerLanguage(config))); } //---------------------------------------------------------------------------- @@ -752,7 +751,7 @@ cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const } // Check for rpath support on this platform. - std::string ll = this->Target->GetLinkerLanguage(config); + std::string ll = this->GetLinkerLanguage(config); if(!ll.empty()) { std::string flagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; @@ -823,7 +822,7 @@ bool cmGeneratorTarget::IsChrpathUsed(const std::string& config) const #if defined(CMAKE_USE_ELF_PARSER) // Enable if the rpath flag uses a separator and the target uses ELF // binaries. - std::string ll = this->Target->GetLinkerLanguage(config); + std::string ll = this->GetLinkerLanguage(config); if(!ll.empty()) { std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; @@ -1986,7 +1985,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, const char* suffixVar = this->Target->GetSuffixVariableInternal(implib); // Check for language-specific default prefix and suffix. - std::string ll = this->Target->GetLinkerLanguage(config); + std::string ll = this->GetLinkerLanguage(config); if(!ll.empty()) { if(!targetSuffix && suffixVar && *suffixVar) @@ -2056,6 +2055,13 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, //---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetLinkerLanguage(const std::string& config) const +{ + return this->Target->GetLinkClosure(config)->LinkerLanguage; +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetPDBName(const std::string& config) const { std::string prefix; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 7ee4fc5..41fb848 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -258,6 +258,9 @@ public: /** Return true if builtin chrpath will work for this target */ bool IsChrpathUsed(const std::string& config) const; + ///! Return the preferred linker language for this target + std::string GetLinkerLanguage(const std::string& config = "") const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index 2f9265a..1e57c33 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -128,7 +128,8 @@ void cmGhsMultiTargetGenerator::Generate() { config = "RELEASE"; } - const std::string language(this->Target->GetLinkerLanguage(config)); + const std::string language( + this->GeneratorTarget->GetLinkerLanguage(config)); config = cmSystemTools::UpperCase(config); this->DynamicDownload = this->DetermineIfDynamicDownload(config, language); if (this->DynamicDownload) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 7b0e153..5006828 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1376,7 +1376,8 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmTarget& cmtarget) return; } - std::string llang = cmtarget.GetLinkerLanguage("NOCONFIG"); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&cmtarget); + std::string llang = gtgt->GetLinkerLanguage("NOCONFIG"); if(llang.empty()) { return; } // If the language is compiled as a source trust Xcode to link with it. @@ -1824,7 +1825,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, AddCompileOptions(flags, &target, lang, configName); } - std::string llang = target.GetLinkerLanguage(configName); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); + std::string llang = gtgt->GetLinkerLanguage(configName); if(binary && llang.empty()) { cmSystemTools::Error @@ -1850,7 +1852,6 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, // Add the export symbol definition for shared library objects. this->AppendDefines(ppDefs, exportMacro); } - cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); std::vector targetDefines; target.GetCompileDefinitions(targetDefines, configName, "C"); this->AppendDefines(ppDefs, targetDefines); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 3ab501d..4ec77a1 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1353,7 +1353,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, linkFlags += this->Makefile->GetSafeDefinition(build); linkFlags += " "; } - std::string linkLanguage = target->Target->GetLinkerLanguage(buildType); + std::string linkLanguage = target->GetLinkerLanguage(buildType); if(linkLanguage.empty()) { cmSystemTools::Error diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 94457bb..e1fa7d4 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1259,8 +1259,8 @@ void cmLocalVisualStudio6Generator extraLinkOptionsRelWithDebInfo += targetLinkFlags; } - - + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); // Get standard libraries for this language. if(targetBuilds) @@ -1269,10 +1269,10 @@ void cmLocalVisualStudio6Generator std::vector configs; target.GetMakefile()->GetConfigurations(configs); std::vector::const_iterator it = configs.begin(); - const std::string& linkLanguage = target.GetLinkerLanguage(*it); + const std::string& linkLanguage = gt->GetLinkerLanguage(*it); for ( ; it != configs.end(); ++it) { - const std::string& configLinkLanguage = target.GetLinkerLanguage(*it); + const std::string& configLinkLanguage = gt->GetLinkerLanguage(*it); if (configLinkLanguage != linkLanguage) { cmSystemTools::Error @@ -1702,10 +1702,10 @@ void cmLocalVisualStudio6Generator std::vector configs; target.GetMakefile()->GetConfigurations(configs); std::vector::const_iterator it = configs.begin(); - const std::string& linkLanguage = target.GetLinkerLanguage(*it); + const std::string& linkLanguage = gt->GetLinkerLanguage(*it); for ( ; it != configs.end(); ++it) { - const std::string& configLinkLanguage = target.GetLinkerLanguage(*it); + const std::string& configLinkLanguage = gt->GetLinkerLanguage(*it); if (configLinkLanguage != linkLanguage) { cmSystemTools::Error diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 9f26712..a38a061 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -664,6 +664,10 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, const char* configType = "10"; const char* projectType = 0; bool targetBuilds = true; + + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); + switch(target.GetType()) { case cmTarget::OBJECT_LIBRARY: @@ -696,7 +700,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, { const std::string& linkLanguage = (this->FortranProject? std::string("Fortran"): - target.GetLinkerLanguage(configName)); + gt->GetLinkerLanguage(configName)); if(linkLanguage.empty()) { cmSystemTools::Error @@ -758,8 +762,6 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, targetOptions.Parse(flags.c_str()); targetOptions.Parse(defineFlags.c_str()); targetOptions.ParseFinish(); - cmGeneratorTarget* gt = - this->GlobalGenerator->GetGeneratorTarget(&target); std::vector targetDefines; target.GetCompileDefinitions(targetDefines, configName, "CXX"); targetOptions.AddDefines(targetDefines); @@ -1635,7 +1637,7 @@ cmLocalVisualStudio7GeneratorFCInfo lg->GlobalGenerator->GetLanguageFromExtension (sf.GetExtension().c_str()); const std::string& sourceLang = lg->GetSourceFileLanguage(sf); - const std::string& linkLanguage = target.GetLinkerLanguage(i->c_str()); + const std::string& linkLanguage = gt->GetLinkerLanguage(i->c_str()); bool needForceLang = false; // source file does not match its extension language if(lang != sourceLang) diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 2fd77c9..afe145a 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -161,7 +161,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) // Get the language to use for linking this executable. std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); // Make sure we have a link language. if(linkLanguage.empty()) diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index b85b8a8..bb0f9dd 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -133,7 +133,7 @@ void cmMakefileLibraryTargetGenerator::WriteObjectLibraryRules() void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules() { std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_STATIC_LIBRARY"; @@ -159,7 +159,7 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink) return; } std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_SHARED_LIBRARY"; @@ -183,7 +183,7 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink) void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink) { std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_SHARED_MODULE"; @@ -206,7 +206,7 @@ void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink) void cmMakefileLibraryTargetGenerator::WriteFrameworkRules(bool relink) { std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_MACOSX_FRAMEWORK"; @@ -238,7 +238,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules // Get the language to use for linking this library. std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); // Make sure we have a link language. if(linkLanguage.empty()) diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index b94e151..d38cf4c 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1509,7 +1509,7 @@ std::string cmMakefileTargetGenerator::GetLinkRule( if(this->Target->HasImplibGNUtoMS()) { std::string ruleVar = "CMAKE_"; - ruleVar += this->Target->GetLinkerLanguage(this->ConfigName); + ruleVar += this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); ruleVar += "_GNUtoMS_RULE"; if(const char* rule = this->Makefile->GetDefinition(ruleVar)) { @@ -1663,7 +1663,8 @@ cmMakefileTargetGenerator { // Lookup the response file reference flag. std::string responseFlagVar = "CMAKE_"; - responseFlagVar += this->Target->GetLinkerLanguage(this->ConfigName); + responseFlagVar += this->GeneratorTarget + ->GetLinkerLanguage(this->ConfigName); responseFlagVar += "_RESPONSE_FILE_LINK_FLAG"; const char* responseFlag = this->Makefile->GetDefinition(responseFlagVar); @@ -1707,7 +1708,8 @@ cmMakefileTargetGenerator // Lookup the response file reference flag. std::string responseFlagVar = "CMAKE_"; - responseFlagVar += this->Target->GetLinkerLanguage(this->ConfigName); + responseFlagVar += this->GeneratorTarget + ->GetLinkerLanguage(this->ConfigName); responseFlagVar += "_RESPONSE_FILE_LINK_FLAG"; const char* responseFlag = this->Makefile->GetDefinition(responseFlagVar); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 1835841..b855bea 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -40,8 +40,7 @@ cmNinjaNormalTargetGenerator(cmGeneratorTarget* target) , TargetNamePDB() , TargetLinkLanguage("") { - this->TargetLinkLanguage = target->Target - ->GetLinkerLanguage(this->GetConfigName()); + this->TargetLinkLanguage = target->GetLinkerLanguage(this->GetConfigName()); if (target->GetType() == cmTarget::EXECUTABLE) this->GetGeneratorTarget()->GetExecutableNames(this->TargetNameOut, this->TargetNameReal, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 37b788d..c7118dc 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3218,12 +3218,6 @@ private: }; //---------------------------------------------------------------------------- -std::string cmTarget::GetLinkerLanguage(const std::string& config) const -{ - return this->GetLinkClosure(config)->LinkerLanguage; -} - -//---------------------------------------------------------------------------- cmTarget::LinkClosure const* cmTarget::GetLinkClosure(const std::string& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index d0cbc66..dea9bef 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -365,9 +365,6 @@ public: void GetTargetVersion(bool soversion, int& major, int& minor, int& patch) const; - ///! Return the preferred linker language for this target - std::string GetLinkerLanguage(const std::string& config = "") const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 2b33c2c..80b8591 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1627,7 +1627,7 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( this->GlobalGenerator->GetLanguageFromExtension (sf.GetExtension().c_str()); std::string sourceLang = this->LocalGenerator->GetSourceFileLanguage(sf); - const std::string& linkLanguage = this->Target->GetLinkerLanguage(); + const std::string& linkLanguage = this->GeneratorTarget->GetLinkerLanguage(); bool needForceLang = false; // source file does not match its extension language if(lang != sourceLang) @@ -1888,7 +1888,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( std::string flags; const std::string& linkLanguage = - this->Target->GetLinkerLanguage(configName.c_str()); + this->GeneratorTarget->GetLinkerLanguage(configName.c_str()); if(linkLanguage.empty()) { cmSystemTools::Error @@ -2371,7 +2371,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) Options& linkOptions = *pOptions; const std::string& linkLanguage = - this->Target->GetLinkerLanguage(config.c_str()); + this->GeneratorTarget->GetLinkerLanguage(config.c_str()); if(linkLanguage.empty()) { cmSystemTools::Error http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8fcae6727a7355bf01a77250f2c5fe0df8fda82a commit 8fcae6727a7355bf01a77250f2c5fe0df8fda82a Author: Stephen Kelly AuthorDate: Tue Oct 9 01:22:42 2012 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 3 09:14:14 2015 +0200 cmGeneratorTarget: Move GetFrameworkDirectory from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 436e5dd..834a2e3 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -904,6 +904,48 @@ cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config, + bool contentOnly) const +{ + std::string fpath; + fpath += this->Target->GetOutputName(config, false); + fpath += "."; + const char *ext = this->Target->GetProperty("BUNDLE_EXTENSION"); + if (!ext) + { + if (this->Target->IsXCTestOnApple()) + { + ext = "xctest"; + } + else + { + ext = "bundle"; + } + } + fpath += ext; + fpath += "/Contents"; + if(!contentOnly) + fpath += "/MacOS"; + return fpath; +} + +//---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetFrameworkDirectory(const std::string& config, + bool rootDir) const +{ + std::string fpath; + fpath += this->Target->GetOutputName(config, false); + fpath += ".framework"; + if(!rootDir) + { + fpath += "/Versions/"; + fpath += this->Target->GetFrameworkVersion(); + } + return fpath; +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetFullName(const std::string& config, bool implib) const { @@ -1007,11 +1049,11 @@ cmGeneratorTarget::BuildMacContentDirectory(const std::string& base, } if(this->Target->IsFrameworkOnApple()) { - fpath += this->Target->GetFrameworkDirectory(config, contentOnly); + fpath += this->GetFrameworkDirectory(config, contentOnly); } if(this->Target->IsCFBundleOnApple()) { - fpath += this->Target->GetCFBundleDirectory(config, contentOnly); + fpath += this->GetCFBundleDirectory(config, contentOnly); } return fpath; } @@ -1982,7 +2024,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, if(this->Target->IsCFBundleOnApple()) { - fw_prefix = this->Target->GetCFBundleDirectory(config, false); + fw_prefix = this->GetCFBundleDirectory(config, false); fw_prefix += "/"; targetPrefix = fw_prefix.c_str(); targetSuffix = 0; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 1dfdbb3..7ee4fc5 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -124,6 +124,14 @@ public: std::string GetFullName(const std::string& config="", bool implib = false) const; + /** @return the Mac framework directory without the base. */ + std::string GetFrameworkDirectory(const std::string& config, + bool rootDir) const; + + /** @return the Mac CFBundle directory without the base */ + std::string GetCFBundleDirectory(const std::string& config, + bool contentOnly) const; + /** Return the install name directory for the target in the * build tree. For example: "\@rpath/", "\@loader_path/", * or "/full/path/to/library". */ diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 1d85d9c..4fe99e3 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -77,11 +77,11 @@ void cmOSXBundleGenerator::CreateFramework( // Compute the location of the top-level foo.framework directory. std::string contentdir = outpath + "/" + - this->GT->Target->GetFrameworkDirectory(this->ConfigName, true); + this->GT->GetFrameworkDirectory(this->ConfigName, true); contentdir += "/"; std::string newoutpath = outpath + "/" + - this->GT->Target->GetFrameworkDirectory(this->ConfigName, false); + this->GT->GetFrameworkDirectory(this->ConfigName, false); std::string frameworkVersion = this->GT->Target->GetFrameworkVersion(); @@ -172,14 +172,14 @@ void cmOSXBundleGenerator::CreateCFBundle(const std::string& targetName, // Compute bundle directory names. std::string out = root; out += "/"; - out += this->GT->Target->GetCFBundleDirectory(this->ConfigName, false); + out += this->GT->GetCFBundleDirectory(this->ConfigName, false); cmSystemTools::MakeDirectory(out.c_str()); this->Makefile->AddCMakeOutputFile(out); // Configure the Info.plist file. Note that it needs the executable name // to be set. std::string plist = root + "/" + - this->GT->Target->GetCFBundleDirectory(this->ConfigName, true); + this->GT->GetCFBundleDirectory(this->ConfigName, true); plist += "/Info.plist"; std::string name = cmSystemTools::GetFilenameName(targetName); this->LocalGenerator->GenerateAppleInfoPList(this->GT->Target, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index a5ff829..37b788d 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -5126,47 +5126,6 @@ std::string cmTarget::CheckCMP0004(std::string const& item) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetFrameworkDirectory(const std::string& config, - bool rootDir) const -{ - std::string fpath; - fpath += this->GetOutputName(config, false); - fpath += ".framework"; - if(!rootDir) - { - fpath += "/Versions/"; - fpath += this->GetFrameworkVersion(); - } - return fpath; -} - -//---------------------------------------------------------------------------- -std::string cmTarget::GetCFBundleDirectory(const std::string& config, - bool contentOnly) const -{ - std::string fpath; - fpath += this->GetOutputName(config, false); - fpath += "."; - const char *ext = this->GetProperty("BUNDLE_EXTENSION"); - if (!ext) - { - if (this->IsXCTestOnApple()) - { - ext = "xctest"; - } - else - { - ext = "bundle"; - } - } - fpath += ext; - fpath += "/Contents"; - if(!contentOnly) - fpath += "/MacOS"; - return fpath; -} - -//---------------------------------------------------------------------------- cmTargetInternalPointer::cmTargetInternalPointer() { this->Pointer = new cmTargetInternals; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e22d3af..d0cbc66 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -460,14 +460,6 @@ public: /** @return whether this target have a well defined output file name. */ bool HaveWellDefinedOutputFiles() const; - /** @return the Mac framework directory without the base. */ - std::string GetFrameworkDirectory(const std::string& config, - bool rootDir) const; - - /** @return the Mac CFBundle directory without the base */ - std::string GetCFBundleDirectory(const std::string& config, - bool contentOnly) const; - std::vector GetIncludeDirectories( const std::string& config, const std::string& language) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a12e80dd27edd9499f1a252549254866b2dcb827 commit a12e80dd27edd9499f1a252549254866b2dcb827 Author: Stephen Kelly AuthorDate: Tue Oct 9 19:01:39 2012 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 3 09:14:14 2015 +0200 cmGeneratorTarget: Move GetFullNameInternal from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index cdacfcb..436e5dd 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -663,7 +663,7 @@ cmGeneratorTarget::GetCompilePDBName(const std::string& config) const std::string prefix; std::string base; std::string suffix; - this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, false, prefix, base, suffix); // Check for a per-configuration output directory target property. std::string configUpper = cmSystemTools::UpperCase(config); @@ -905,6 +905,20 @@ cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, //---------------------------------------------------------------------------- std::string +cmGeneratorTarget::GetFullName(const std::string& config, bool implib) const +{ + if(this->Target->IsImported()) + { + return this->Target->GetFullNameImported(config, implib); + } + else + { + return this->GetFullNameInternal(config, implib); + } +} + +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetInstallNameDirForBuildTree( const std::string& config) const { @@ -977,7 +991,7 @@ void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, const std::string& config, bool implib) const { - this->Target->GetFullNameInternal(config, implib, prefix, base, suffix); + this->GetFullNameInternal(config, implib, prefix, base, suffix); } //---------------------------------------------------------------------------- @@ -1753,7 +1767,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, std::string prefix; std::string base; std::string suffix; - this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, false, prefix, base, suffix); // The library name. name = prefix+base+suffix; @@ -1782,7 +1796,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, if(this->GetType() == cmTarget::SHARED_LIBRARY || this->GetType() == cmTarget::MODULE_LIBRARY) { - impName = this->Target->GetFullNameInternal(config, true); + impName = this->GetFullNameInternal(config, true); } else { @@ -1828,7 +1842,7 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, std::string prefix; std::string base; std::string suffix; - this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, false, prefix, base, suffix); // The executable name. name = prefix+base+suffix; @@ -1849,19 +1863,163 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, #endif // The import library name. - impName = this->Target->GetFullNameInternal(config, true); + impName = this->GetFullNameInternal(config, true); // The program database file name. pdbName = this->GetPDBName(config); } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetFullNameInternal(const std::string& config, + bool implib) const +{ + std::string prefix; + std::string base; + std::string suffix; + this->GetFullNameInternal(config, implib, prefix, base, suffix); + return prefix+base+suffix; +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GetFullNameInternal(const std::string& config, + bool implib, + std::string& outPrefix, + std::string& outBase, + std::string& outSuffix) const +{ + // Use just the target name for non-main target types. + if(this->GetType() != cmTarget::STATIC_LIBRARY && + this->GetType() != cmTarget::SHARED_LIBRARY && + this->GetType() != cmTarget::MODULE_LIBRARY && + this->GetType() != cmTarget::EXECUTABLE) + { + outPrefix = ""; + outBase = this->GetName(); + outSuffix = ""; + return; + } + + // Return an empty name for the import library if this platform + // does not support import libraries. + if(implib && + !this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) + { + outPrefix = ""; + outBase = ""; + outSuffix = ""; + return; + } + + // The implib option is only allowed for shared libraries, module + // libraries, and executables. + if(this->GetType() != cmTarget::SHARED_LIBRARY && + this->GetType() != cmTarget::MODULE_LIBRARY && + this->GetType() != cmTarget::EXECUTABLE) + { + implib = false; + } + + // Compute the full name for main target types. + const char* targetPrefix = (implib + ? this->GetProperty("IMPORT_PREFIX") + : this->GetProperty("PREFIX")); + const char* targetSuffix = (implib + ? this->GetProperty("IMPORT_SUFFIX") + : this->GetProperty("SUFFIX")); + const char* configPostfix = 0; + if(!config.empty()) + { + std::string configProp = cmSystemTools::UpperCase(config); + configProp += "_POSTFIX"; + configPostfix = this->GetProperty(configProp); + // Mac application bundles and frameworks have no postfix. + if(configPostfix && + (this->Target->IsAppBundleOnApple() + || this->Target->IsFrameworkOnApple())) + { + configPostfix = 0; + } + } + const char* prefixVar = this->Target->GetPrefixVariableInternal(implib); + const char* suffixVar = this->Target->GetSuffixVariableInternal(implib); + + // Check for language-specific default prefix and suffix. + std::string ll = this->Target->GetLinkerLanguage(config); + if(!ll.empty()) + { + if(!targetSuffix && suffixVar && *suffixVar) + { + std::string langSuff = suffixVar + std::string("_") + ll; + targetSuffix = this->Makefile->GetDefinition(langSuff); + } + if(!targetPrefix && prefixVar && *prefixVar) + { + std::string langPrefix = prefixVar + std::string("_") + ll; + targetPrefix = this->Makefile->GetDefinition(langPrefix); + } + } + + // if there is no prefix on the target use the cmake definition + if(!targetPrefix && prefixVar) + { + targetPrefix = this->Makefile->GetSafeDefinition(prefixVar); + } + // if there is no suffix on the target use the cmake definition + if(!targetSuffix && suffixVar) + { + targetSuffix = this->Makefile->GetSafeDefinition(suffixVar); + } + + // frameworks have directory prefix but no suffix + std::string fw_prefix; + if(this->Target->IsFrameworkOnApple()) + { + fw_prefix = this->Target->GetOutputName(config, false); + fw_prefix += ".framework/"; + targetPrefix = fw_prefix.c_str(); + targetSuffix = 0; + } + + if(this->Target->IsCFBundleOnApple()) + { + fw_prefix = this->Target->GetCFBundleDirectory(config, false); + fw_prefix += "/"; + targetPrefix = fw_prefix.c_str(); + targetSuffix = 0; + } + + // Begin the final name with the prefix. + outPrefix = targetPrefix?targetPrefix:""; + + // Append the target name or property-specified name. + outBase += this->Target->GetOutputName(config, implib); + + // Append the per-configuration postfix. + outBase += configPostfix?configPostfix:""; + + // Name shared libraries with their version number on some platforms. + if(const char* soversion = this->GetProperty("SOVERSION")) + { + if(this->GetType() == cmTarget::SHARED_LIBRARY && !implib && + this->Makefile->IsOn("CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION")) + { + outBase += "-"; + outBase += soversion; + } + } + + // Append the suffix. + outSuffix = targetSuffix?targetSuffix:""; +} + + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetPDBName(const std::string& config) const { std::string prefix; std::string base; std::string suffix; - this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, false, prefix, base, suffix); std::vector props; std::string configUpper = diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index d0d6709..1dfdbb3 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -284,6 +284,12 @@ private: mutable std::map DebugCompatiblePropertiesDone; + std::string GetFullNameInternal(const std::string& config, + bool implib) const; + void GetFullNameInternal(const std::string& config, bool implib, + std::string& outPrefix, std::string& outBase, + std::string& outSuffix) const; + struct CompatibleInterfacesBase { std::set PropsBool; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index c484417..a5ff829 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3612,148 +3612,6 @@ cmTarget::ImportedGetFullPath(const std::string& config, bool implib) const } //---------------------------------------------------------------------------- -std::string -cmTarget::GetFullNameInternal(const std::string& config, bool implib) const -{ - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, implib, prefix, base, suffix); - return prefix+base+suffix; -} - -//---------------------------------------------------------------------------- -void cmTarget::GetFullNameInternal(const std::string& config, - bool implib, - std::string& outPrefix, - std::string& outBase, - std::string& outSuffix) const -{ - // Use just the target name for non-main target types. - if(this->GetType() != cmTarget::STATIC_LIBRARY && - this->GetType() != cmTarget::SHARED_LIBRARY && - this->GetType() != cmTarget::MODULE_LIBRARY && - this->GetType() != cmTarget::EXECUTABLE) - { - outPrefix = ""; - outBase = this->GetName(); - outSuffix = ""; - return; - } - - // Return an empty name for the import library if this platform - // does not support import libraries. - if(implib && - !this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) - { - outPrefix = ""; - outBase = ""; - outSuffix = ""; - return; - } - - // The implib option is only allowed for shared libraries, module - // libraries, and executables. - if(this->GetType() != cmTarget::SHARED_LIBRARY && - this->GetType() != cmTarget::MODULE_LIBRARY && - this->GetType() != cmTarget::EXECUTABLE) - { - implib = false; - } - - // Compute the full name for main target types. - const char* targetPrefix = (implib - ? this->GetProperty("IMPORT_PREFIX") - : this->GetProperty("PREFIX")); - const char* targetSuffix = (implib - ? this->GetProperty("IMPORT_SUFFIX") - : this->GetProperty("SUFFIX")); - const char* configPostfix = 0; - if(!config.empty()) - { - std::string configProp = cmSystemTools::UpperCase(config); - configProp += "_POSTFIX"; - configPostfix = this->GetProperty(configProp); - // Mac application bundles and frameworks have no postfix. - if(configPostfix && - (this->IsAppBundleOnApple() || this->IsFrameworkOnApple())) - { - configPostfix = 0; - } - } - const char* prefixVar = this->GetPrefixVariableInternal(implib); - const char* suffixVar = this->GetSuffixVariableInternal(implib); - - // Check for language-specific default prefix and suffix. - std::string ll = this->GetLinkerLanguage(config); - if(!ll.empty()) - { - if(!targetSuffix && suffixVar && *suffixVar) - { - std::string langSuff = suffixVar + std::string("_") + ll; - targetSuffix = this->Makefile->GetDefinition(langSuff); - } - if(!targetPrefix && prefixVar && *prefixVar) - { - std::string langPrefix = prefixVar + std::string("_") + ll; - targetPrefix = this->Makefile->GetDefinition(langPrefix); - } - } - - // if there is no prefix on the target use the cmake definition - if(!targetPrefix && prefixVar) - { - targetPrefix = this->Makefile->GetSafeDefinition(prefixVar); - } - // if there is no suffix on the target use the cmake definition - if(!targetSuffix && suffixVar) - { - targetSuffix = this->Makefile->GetSafeDefinition(suffixVar); - } - - // frameworks have directory prefix but no suffix - std::string fw_prefix; - if(this->IsFrameworkOnApple()) - { - fw_prefix = this->GetOutputName(config, false); - fw_prefix += ".framework/"; - targetPrefix = fw_prefix.c_str(); - targetSuffix = 0; - } - - if(this->IsCFBundleOnApple()) - { - fw_prefix = this->GetCFBundleDirectory(config, false); - fw_prefix += "/"; - targetPrefix = fw_prefix.c_str(); - targetSuffix = 0; - } - - // Begin the final name with the prefix. - outPrefix = targetPrefix?targetPrefix:""; - - // Append the target name or property-specified name. - outBase += this->GetOutputName(config, implib); - - // Append the per-configuration postfix. - outBase += configPostfix?configPostfix:""; - - // Name shared libraries with their version number on some platforms. - if(const char* soversion = this->GetProperty("SOVERSION")) - { - if(this->GetType() == cmTarget::SHARED_LIBRARY && !implib && - this->Makefile->IsOn("CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION")) - { - outBase += "-"; - outBase += soversion; - } - } - - // Append the suffix. - outSuffix = targetSuffix?targetSuffix:""; -} - -//---------------------------------------------------------------------------- void cmTarget::ComputeVersionedName(std::string& vName, std::string const& prefix, std::string const& base, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 633e0ee..e22d3af 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -570,11 +570,6 @@ private: const char* GetSuffixVariableInternal(bool implib) const; const char* GetPrefixVariableInternal(bool implib) const; - std::string GetFullNameInternal(const std::string& config, - bool implib) const; - void GetFullNameInternal(const std::string& config, bool implib, - std::string& outPrefix, std::string& outBase, - std::string& outSuffix) const; // Use a makefile variable to set a default for the given property. // If the variable is not defined use the given default instead. ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 3 09:11:27 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 3 Aug 2015 09:11:27 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-667-g5c02ae4 Message-ID: <20150803131127.76B95AFEE0@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 5c02ae4ac9dec3a275d3965ccdcfdb564686dc79 (commit) via da98b89612d59906bd938d58a9072b3ce68864de (commit) via 129640f279259e51fbb0e81a5bec2ec2dfac543e (commit) via d0915bc86f294707411ae525e70fa20965f1aeec (commit) via 1feafc643b1c50fd0fa8171a4170065ca39d4d4c (commit) from ebacce3f0b0cef6116e91d408d591ff67285c420 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5c02ae4ac9dec3a275d3965ccdcfdb564686dc79 commit 5c02ae4ac9dec3a275d3965ccdcfdb564686dc79 Merge: ebacce3 da98b89 Author: Brad King AuthorDate: Mon Aug 3 09:11:25 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 3 09:11:25 2015 -0400 Merge topic 'update-kwsys' da98b896 Tests: In CTestTest2 skip the kwsys.testProcess-10 test that leaks 129640f2 CTestCustom: Ignore kwsys.testProcess-10 for MemCheck as KWSys does d0915bc8 Merge branch 'upstream-kwsys' into update-kwsys 1feafc64 KWSys 2015-07-30 (f63febb7) ----------------------------------------------------------------------- Summary of changes: CTestCustom.cmake.in | 4 + Source/kwsys/CMakeLists.txt | 6 +- Source/kwsys/CTestCustom.cmake.in | 15 ++ Source/kwsys/Process.h.in | 131 ++++++----- Source/kwsys/ProcessUNIX.c | 357 ++++++++++++++++++++++++---- Source/kwsys/ProcessWin32.c | 462 ++++++++++++++++++++++++++++++++----- Source/kwsys/testProcess.c | 267 +++++++++++++++++---- Tests/CTestTest2/test.cmake.in | 13 +- 8 files changed, 1051 insertions(+), 204 deletions(-) create mode 100644 Source/kwsys/CTestCustom.cmake.in hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 3 09:11:29 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 3 Aug 2015 09:11:29 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-669-gdb519ca Message-ID: <20150803131129.BA69EAFFD6@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via db519cae57122dc6584226aac951674b49301efc (commit) via f7a9ed7e90cd2661b279d0bcd44d43620b8eeda1 (commit) from 5c02ae4ac9dec3a275d3965ccdcfdb564686dc79 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=db519cae57122dc6584226aac951674b49301efc commit db519cae57122dc6584226aac951674b49301efc Merge: 5c02ae4 f7a9ed7 Author: Brad King AuthorDate: Mon Aug 3 09:11:28 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 3 09:11:28 2015 -0400 Merge topic 'fix-xcode-quoting' f7a9ed7e Xcode: Quote strings containing a tilde (#15672) ----------------------------------------------------------------------- Summary of changes: Source/cmXCodeObject.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 3 09:11:32 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 3 Aug 2015 09:11:32 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-671-g25ec835 Message-ID: <20150803131132.1D97BB0229@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 25ec835571741d5339fb653e06e79896d72f8e8a (commit) via d4736d53cd61f2cbbb36bec682663b74b01dddce (commit) from db519cae57122dc6584226aac951674b49301efc (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=25ec835571741d5339fb653e06e79896d72f8e8a commit 25ec835571741d5339fb653e06e79896d72f8e8a Merge: db519ca d4736d5 Author: Brad King AuthorDate: Mon Aug 3 09:11:30 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 3 09:11:30 2015 -0400 Merge topic 'fix-windows-version-detection' d4736d53 Windows: Fix CMAKE_HOST_SYSTEM_VERSION on Windows >= 8.1 (#15674) ----------------------------------------------------------------------- Summary of changes: Source/cmGlobalGenerator.cxx | 56 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 10 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 3 09:11:34 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 3 Aug 2015 09:11:34 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-673-g6508cc5 Message-ID: <20150803131134.1E356B0159@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 6508cc5355d74a148e9a8d7feca99d60b9748168 (commit) via 1c46b6aed0db88c97189713f291164f98df780a9 (commit) from 25ec835571741d5339fb653e06e79896d72f8e8a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6508cc5355d74a148e9a8d7feca99d60b9748168 commit 6508cc5355d74a148e9a8d7feca99d60b9748168 Merge: 25ec835 1c46b6a Author: Brad King AuthorDate: Mon Aug 3 09:11:32 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 3 09:11:32 2015 -0400 Merge topic 'FindMPI-drop-GetPrerequisites' 1c46b6ae FindMPI: Drop unnecessary and incorrect use of GetPrerequisites ----------------------------------------------------------------------- Summary of changes: Modules/FindMPI.cmake | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 3 09:11:35 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 3 Aug 2015 09:11:35 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-676-g94d53d1 Message-ID: <20150803131135.F11DCB0246@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 94d53d1664b1e792e8088880cfd206e8e81ff625 (commit) via 5d0a8b1abc3f8a6d8d23772251b4ef2758d2def6 (commit) via afb674ab46a7d6ff3d1801315f3d852bdba79d0c (commit) from 6508cc5355d74a148e9a8d7feca99d60b9748168 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=94d53d1664b1e792e8088880cfd206e8e81ff625 commit 94d53d1664b1e792e8088880cfd206e8e81ff625 Merge: 6508cc5 5d0a8b1 Author: Brad King AuthorDate: Mon Aug 3 09:11:34 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 3 09:11:34 2015 -0400 Merge topic 'GetPrerequisites-updates' 5d0a8b1a GetPrerequisites: Optionally filter "objdump" output for speed afb674ab GetPrerequisites: Add error checks for execute_process() calls ----------------------------------------------------------------------- Summary of changes: Modules/GetPrerequisites.cmake | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 3 09:13:17 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 3 Aug 2015 09:13:17 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1781-gbbfd6cb Message-ID: <20150803131317.3F01AB0587@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via bbfd6cbd9f339015c1cefa27773953f69b6d3c68 (commit) via 632cb7761c2b69224dda45151ff7ff9bf3ebbce8 (commit) from 1f652e5949b2309bfc1bd102d21092117ff069b0 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bbfd6cbd9f339015c1cefa27773953f69b6d3c68 commit bbfd6cbd9f339015c1cefa27773953f69b6d3c68 Merge: 1f652e5 632cb77 Author: Brad King AuthorDate: Mon Aug 3 09:13:16 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 3 09:13:16 2015 -0400 Merge topic 'cpack-rpm-documentation-fixes' into next 632cb776 Revert topic 'cpack-rpm-documentation-fixes' http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=632cb7761c2b69224dda45151ff7ff9bf3ebbce8 commit 632cb7761c2b69224dda45151ff7ff9bf3ebbce8 Author: Brad King AuthorDate: Mon Aug 3 09:12:57 2015 -0400 Commit: Brad King CommitDate: Mon Aug 3 09:12:57 2015 -0400 Revert topic 'cpack-rpm-documentation-fixes' It will be restored once unrelated errors in its tests are fixed. diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake index 7c1db14..cb77fb8 100644 --- a/Modules/CPackRPM.cmake +++ b/Modules/CPackRPM.cmake @@ -95,7 +95,6 @@ # * Default : CPACK_PACKAGE_VENDOR if set or "unknown" # # .. variable:: CPACK_RPM_PACKAGE_URL -# CPACK_RPM__PACKAGE_URL # # The projects URL. # @@ -124,55 +123,7 @@ # compression whereas older cannot use such RPM. Using this one can enforce # compression type to be used. Possible value are: lzma, xz, bzip2 and gzip. # -# .. variable:: CPACK_RPM_PACKAGE_AUTOREQ -# CPACK_RPM__PACKAGE_AUTOREQ -# -# RPM spec autoreq field. -# -# * Mandatory : NO -# * Default : - -# -# May be used to enable (1, yes) or disable (0, no) automatic shared libraries -# dependency detection. Dependencies are added to requires list. -# -# .. note:: -# -# By defalut automatic dependency detection is enabled by rpm generator. -# -# .. variable:: CPACK_RPM_PACKAGE_AUTOPROV -# CPACK_RPM__PACKAGE_AUTOPROV -# -# RPM spec autoprov field. -# -# * Mandatory : NO -# * Default : - -# -# May be used to enable (1, yes) or disable (0, no) automatic listing of shared -# libraries that are provided by the package. Shared libraries are added to -# provides list. -# -# .. note:: -# -# By defalut automatic provides detection is enabled by rpm generator. -# -# .. variable:: CPACK_RPM_PACKAGE_AUTOREQPROV -# CPACK_RPM__PACKAGE_AUTOREQPROV -# -# RPM spec autoreqprov field. -# -# * Mandatory : NO -# * Default : - -# -# Variable enables/disables autoreq and autoprov at the same time. -# See :variable:`CPACK_RPM_PACKAGE_AUTOREQ` and :variable:`CPACK_RPM_PACKAGE_AUTOPROV` -# for more details. -# -# .. note:: -# -# By defalut automatic detection feature is enabled by rpm. -# # .. variable:: CPACK_RPM_PACKAGE_REQUIRES -# CPACK_RPM__PACKAGE_REQUIRES # # RPM spec requires field. # @@ -188,25 +139,7 @@ # # rpm -qp --requires file.rpm # -# .. variable:: CPACK_RPM_PACKAGE_CONFLICTS -# CPACK_RPM__PACKAGE_CONFLICTS -# -# RPM spec conflicts field. -# -# * Mandatory : NO -# * Default : - -# -# May be used to set negative RPM dependencies (conflicts). Note that you must enclose -# the complete requires string between quotes, for example:: -# -# set(CPACK_RPM_PACKAGE_CONFLICTS "libxml2") -# -# The conflicting package list of an RPM file could be printed with:: -# -# rpm -qp --conflicts file.rpm -# # .. variable:: CPACK_RPM_PACKAGE_REQUIRES_PRE -# CPACK_RPM__PACKAGE_REQUIRES_PRE # # RPM spec requires(pre) field. # @@ -219,7 +152,6 @@ # set(CPACK_RPM_PACKAGE_REQUIRES_PRE "shadow-utils, initscripts") # # .. variable:: CPACK_RPM_PACKAGE_REQUIRES_POST -# CPACK_RPM__PACKAGE_REQUIRES_POST # # RPM spec requires(post) field. # @@ -233,7 +165,6 @@ # # # .. variable:: CPACK_RPM_PACKAGE_REQUIRES_POSTUN -# CPACK_RPM__PACKAGE_REQUIRES_POSTUN # # RPM spec requires(postun) field. # @@ -247,7 +178,6 @@ # # # .. variable:: CPACK_RPM_PACKAGE_REQUIRES_PREUN -# CPACK_RPM__PACKAGE_REQUIRES_PREUN # # RPM spec requires(preun) field. # @@ -260,7 +190,6 @@ # set(CPACK_RPM_PACKAGE_REQUIRES_PREUN "shadow-utils, initscripts") # # .. variable:: CPACK_RPM_PACKAGE_SUGGESTS -# CPACK_RPM__PACKAGE_SUGGESTS # # RPM spec suggest field. # @@ -271,7 +200,6 @@ # enclose the complete requires string between quotes. # # .. variable:: CPACK_RPM_PACKAGE_PROVIDES -# CPACK_RPM__PACKAGE_PROVIDES # # RPM spec provides field. # @@ -284,7 +212,6 @@ # rpm -qp --provides file.rpm # # .. variable:: CPACK_RPM_PACKAGE_OBSOLETES -# CPACK_RPM__PACKAGE_OBSOLETES # # RPM spec obsoletes field. # diff --git a/Tests/RunCMake/CPack/CMakeLists.txt b/Tests/RunCMake/CPack/CMakeLists.txt index 46f1367..7905706 100644 --- a/Tests/RunCMake/CPack/CMakeLists.txt +++ b/Tests/RunCMake/CPack/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.1 FATAL_ERROR) -project(${RunCMake_TEST} CXX) +project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) # include test generator specifics diff --git a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake deleted file mode 100644 index 577a560..0000000 --- a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake +++ /dev/null @@ -1,13 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "5") -set(EXPECTED_FILE_1 "dependencies*-applications.deb") -set(EXPECTED_FILE_CONTENT_1 "^.*/usr/foo${whitespaces_}.*/usr/foo/test_prog$") -set(EXPECTED_FILE_2 "dependencies*-applications_auto.deb") -set(EXPECTED_FILE_CONTENT_2 "^.*/usr/foo_auto${whitespaces_}.*/usr/foo_auto/test_prog$") -set(EXPECTED_FILE_3 "dependencies*-headers.deb") -set(EXPECTED_FILE_CONTENT_3 "^.*/usr/bar${whitespaces_}.*/usr/bar/CMakeLists.txt$") -set(EXPECTED_FILE_4 "dependencies*-libs.deb") -set(EXPECTED_FILE_CONTENT_4 "^.*/usr/bas${whitespaces_}.*/usr/bas/libtest_lib.so$") -set(EXPECTED_FILE_5 "dependencies*-libs_auto.deb") -set(EXPECTED_FILE_CONTENT_5 "^.*/usr/bas_auto${whitespaces_}.*/usr/bas_auto/libtest_lib.so$") diff --git a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-VerifyResult.cmake b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-VerifyResult.cmake deleted file mode 100644 index 44c862d..0000000 --- a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-VerifyResult.cmake +++ /dev/null @@ -1,15 +0,0 @@ -function(checkDepends_ FILE REGEX) - set(whitespaces_ "[\t\n\r ]*") - - getPackageInfo("${FILE}" "FILE_INFO_") - if(NOT FILE_INFO_ MATCHES "${REGEX}") - message(FATAL_ERROR "Unexpected dependencies in '${FILE}'; file info: '${FILE_INFO_}'") - endif() -endfunction() - -checkDepends_("${FOUND_FILE_1}" ".*Depends${whitespaces_}:${whitespaces_}depend-application, depend-application-b.*") -# use wildcard as we are using dependency auto detection -checkDepends_("${FOUND_FILE_2}" ".*Depends${whitespaces_}:${whitespaces_}.*depend-application, depend-application-b.*") -checkDepends_("${FOUND_FILE_3}" ".*Depends${whitespaces_}:${whitespaces_}depend-headers.*") -checkDepends_("${FOUND_FILE_4}" ".*Depends${whitespaces_}:${whitespaces_}depend-default, depend-default-b.*") -checkDepends_("${FOUND_FILE_5}" ".*Depends${whitespaces_}:${whitespaces_}depend-default, depend-default-b.*") diff --git a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-specifics.cmake b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-specifics.cmake deleted file mode 100644 index 9e09428..0000000 --- a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-specifics.cmake +++ /dev/null @@ -1,15 +0,0 @@ -set(CPACK_PACKAGE_CONTACT "someone") -set(CPACK_DEB_COMPONENT_INSTALL "ON") - -# false by default -set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS FALSE) -# FIXME can not be tested as libraries first have to be part of a package in order -# to determine their dependencies and we can not be certain if there will be any -set(CPACK_DEBIAN_APPLICATIONS_AUTO_PACKAGE_SHLIBDEPS TRUE) - -set(CPACK_DEBIAN_PACKAGE_DEPENDS "depend-default, depend-default-b") -set(CPACK_DEBIAN_APPLICATIONS_PACKAGE_DEPENDS "depend-application, depend-application-b") -set(CPACK_DEBIAN_APPLICATIONS_AUTO_PACKAGE_DEPENDS "depend-application, depend-application-b") -set(CPACK_DEBIAN_HEADERS_PACKAGE_DEPENDS "depend-headers") - -# TODO add other dependency tests once CPackDeb supports them diff --git a/Tests/RunCMake/CPack/DEB/Helpers.cmake b/Tests/RunCMake/CPack/DEB/Helpers.cmake index a204a3c..45c85c3 100644 --- a/Tests/RunCMake/CPack/DEB/Helpers.cmake +++ b/Tests/RunCMake/CPack/DEB/Helpers.cmake @@ -26,13 +26,3 @@ function(verifyDebControl FILE PREFIX VERIFY_FILES) endif() endforeach() endfunction() - -function(getPackageInfo FILE RESULT_VAR) - execute_process(COMMAND ${DPKG_EXECUTABLE} -I ${FILE} - WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" - OUTPUT_VARIABLE package_info_ - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - - set(${RESULT_VAR} "${package_info_}" PARENT_SCOPE) -endfunction() diff --git a/Tests/RunCMake/CPack/DEPENDENCIES.cmake b/Tests/RunCMake/CPack/DEPENDENCIES.cmake deleted file mode 100644 index 0aef925..0000000 --- a/Tests/RunCMake/CPack/DEPENDENCIES.cmake +++ /dev/null @@ -1,18 +0,0 @@ -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.hpp" - "int test_lib();") -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp" - "#include \"test_lib.hpp\"\nint test_lib() {return 0;}") -add_library(test_lib SHARED "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp") - -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp" - "#include \"test_lib.hpp\"\nint main() {return test_lib();}") -add_executable(test_prog "${CMAKE_CURRENT_BINARY_DIR}/main.cpp") -target_link_libraries(test_prog test_lib) - -install(TARGETS test_prog DESTINATION foo COMPONENT applications) -install(TARGETS test_prog DESTINATION foo_auto COMPONENT applications_auto) -install(FILES CMakeLists.txt DESTINATION bar COMPONENT headers) -install(TARGETS test_lib DESTINATION bas COMPONENT libs) -install(TARGETS test_lib DESTINATION bas_auto COMPONENT libs_auto) - -set(CPACK_PACKAGE_NAME "dependencies") diff --git a/Tests/RunCMake/CPack/RPM/DEPENDENCIES-ExpectedFiles.cmake b/Tests/RunCMake/CPack/RPM/DEPENDENCIES-ExpectedFiles.cmake deleted file mode 100644 index cf85dab..0000000 --- a/Tests/RunCMake/CPack/RPM/DEPENDENCIES-ExpectedFiles.cmake +++ /dev/null @@ -1,13 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "5") -set(EXPECTED_FILE_1 "dependencies*-applications.rpm") -set(EXPECTED_FILE_CONTENT_1 "^/usr/foo${whitespaces_}/usr/foo/test_prog$") -set(EXPECTED_FILE_2 "dependencies*-applications_auto.rpm") -set(EXPECTED_FILE_CONTENT_2 "^/usr/foo_auto${whitespaces_}/usr/foo_auto/test_prog$") -set(EXPECTED_FILE_3 "dependencies*-headers.rpm") -set(EXPECTED_FILE_CONTENT_3 "^/usr/bar${whitespaces_}/usr/bar/CMakeLists.txt$") -set(EXPECTED_FILE_4 "dependencies*-libs.rpm") -set(EXPECTED_FILE_CONTENT_4 "^/usr/bas${whitespaces_}/usr/bas/libtest_lib.so$") -set(EXPECTED_FILE_5 "dependencies*-libs_auto.rpm") -set(EXPECTED_FILE_CONTENT_5 "^/usr/bas_auto${whitespaces_}/usr/bas_auto/libtest_lib.so$") diff --git a/Tests/RunCMake/CPack/RPM/DEPENDENCIES-VerifyResult.cmake b/Tests/RunCMake/CPack/RPM/DEPENDENCIES-VerifyResult.cmake deleted file mode 100644 index fec8889..0000000 --- a/Tests/RunCMake/CPack/RPM/DEPENDENCIES-VerifyResult.cmake +++ /dev/null @@ -1,45 +0,0 @@ -function(checkDependencies_ FILE TYPE COMPARE_LIST) - set(whitespaces_ "[\t\n\r ]*") - - execute_process(COMMAND ${RPM_EXECUTABLE} -qp --${TYPE} ${FILE} - WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" - OUTPUT_VARIABLE FILE_DEPENDENCIES_ - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - - string(REPLACE "\n" ";" FILE_DEPENDENCIES_LIST_ "${FILE_DEPENDENCIES_}") - - foreach(COMPARE_REGEX_ IN LISTS COMPARE_LIST) - unset(FOUND_) - - foreach(COMPARE_ IN LISTS FILE_DEPENDENCIES_LIST_) - if(COMPARE_ MATCHES "${COMPARE_REGEX_}") - set(FOUND_ true) - break() - endif() - endforeach() - - if(NOT FOUND_) - message(FATAL_ERROR "Missing dependencies in '${FILE}'; check type: '${TYPE}'; file info: '${FILE_DEPENDENCIES_}'; missing: '${COMPARE_REGEX_}'") - endif() - endforeach() -endfunction() - -# TODO add tests for what should not be present in lists -checkDependencies_("${FOUND_FILE_1}" "requires" "depend-application;depend-application-b") -checkDependencies_("${FOUND_FILE_2}" "requires" "depend-application;depend-application-b;libtest_lib\\.so.*") -checkDependencies_("${FOUND_FILE_3}" "requires" "depend-headers") -checkDependencies_("${FOUND_FILE_4}" "requires" "depend-default;depend-default-b") -checkDependencies_("${FOUND_FILE_5}" "requires" "depend-default;depend-default-b") - -checkDependencies_("${FOUND_FILE_1}" "conflicts" "conflict-application;conflict-application-b") -checkDependencies_("${FOUND_FILE_2}" "conflicts" "conflict-application;conflict-application-b") -checkDependencies_("${FOUND_FILE_3}" "conflicts" "conflict-headers") -checkDependencies_("${FOUND_FILE_4}" "conflicts" "conflict-default;conflict-default-b") -checkDependencies_("${FOUND_FILE_5}" "conflicts" "conflict-default;conflict-default-b") - -checkDependencies_("${FOUND_FILE_1}" "provides" "provided-default;provided-default-b") -checkDependencies_("${FOUND_FILE_2}" "provides" "provided-default;provided-default-b") -checkDependencies_("${FOUND_FILE_3}" "provides" "provided-default;provided-default-b") -checkDependencies_("${FOUND_FILE_4}" "provides" "provided-lib") -checkDependencies_("${FOUND_FILE_5}" "provides" "provided-lib_auto;provided-lib_auto-b") diff --git a/Tests/RunCMake/CPack/RPM/DEPENDENCIES-specifics.cmake b/Tests/RunCMake/CPack/RPM/DEPENDENCIES-specifics.cmake deleted file mode 100644 index 2cdfece..0000000 --- a/Tests/RunCMake/CPack/RPM/DEPENDENCIES-specifics.cmake +++ /dev/null @@ -1,22 +0,0 @@ -set(CPACK_RPM_COMPONENT_INSTALL "ON") - -# FIXME auto autoprov is not tested at the moment as Ubuntu 15.04 rpmbuild -# does not use them correctly: https://bugs.launchpad.net/rpm/+bug/1475755 -set(CPACK_RPM_PACKAGE_AUTOREQ "no") -set(CPACK_RPM_PACKAGE_AUTOPROV "no") -set(CPACK_RPM_applications_auto_PACKAGE_AUTOREQPROV "yes") -set(CPACK_RPM_libs_auto_PACKAGE_AUTOREQPROV "yes") - -set(CPACK_RPM_PACKAGE_REQUIRES "depend-default, depend-default-b") -set(CPACK_RPM_applications_PACKAGE_REQUIRES "depend-application, depend-application-b") -set(CPACK_RPM_applications_auto_PACKAGE_REQUIRES "depend-application, depend-application-b") -set(CPACK_RPM_headers_PACKAGE_REQUIRES "depend-headers") - -set(CPACK_RPM_PACKAGE_CONFLICTS "conflict-default, conflict-default-b") -set(CPACK_RPM_applications_PACKAGE_CONFLICTS "conflict-application, conflict-application-b") -set(CPACK_RPM_applications_auto_PACKAGE_CONFLICTS "conflict-application, conflict-application-b") -set(CPACK_RPM_headers_PACKAGE_CONFLICTS "conflict-headers") - -set(CPACK_RPM_PACKAGE_PROVIDES "provided-default, provided-default-b") -set(CPACK_RPM_libs_PACKAGE_PROVIDES "provided-lib") -set(CPACK_RPM_libs_auto_PACKAGE_PROVIDES "provided-lib_auto, provided-lib_auto-b") diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake index 3e5714d..97ef238 100644 --- a/Tests/RunCMake/CPack/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake @@ -7,4 +7,3 @@ include("${RunCMake_SOURCE_DIR}/CPackTestHelpers.cmake") run_cpack_test(MINIMAL "RPM;DEB" false) run_cpack_test(PARTIALLY_RELOCATABLE_WARNING "RPM" false) run_cpack_test(DEB_EXTRA "DEB" false) -run_cpack_test(DEPENDENCIES "RPM;DEB" true) diff --git a/Tests/RunCMake/CPack/VerifyResult.cmake b/Tests/RunCMake/CPack/VerifyResult.cmake index 96efa9e..e059d9c 100644 --- a/Tests/RunCMake/CPack/VerifyResult.cmake +++ b/Tests/RunCMake/CPack/VerifyResult.cmake @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION ${CMAKE_VERSION} FATAL_ERROR) +cmake_minimum_required(VERSION 3.1 FATAL_ERROR) include("${config_file}") include("${src_dir}/${GENERATOR_TYPE}/Helpers.cmake") ----------------------------------------------------------------------- Summary of changes: Modules/CPackRPM.cmake | 73 -------------------- Tests/RunCMake/CPack/CMakeLists.txt | 2 +- .../CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake | 13 ---- .../CPack/DEB/DEPENDENCIES-VerifyResult.cmake | 15 ---- .../CPack/DEB/DEPENDENCIES-specifics.cmake | 15 ---- Tests/RunCMake/CPack/DEB/Helpers.cmake | 10 --- Tests/RunCMake/CPack/DEPENDENCIES.cmake | 18 ----- .../CPack/RPM/DEPENDENCIES-ExpectedFiles.cmake | 13 ---- .../CPack/RPM/DEPENDENCIES-VerifyResult.cmake | 45 ------------ .../CPack/RPM/DEPENDENCIES-specifics.cmake | 22 ------ Tests/RunCMake/CPack/RunCMakeTest.cmake | 1 - Tests/RunCMake/CPack/VerifyResult.cmake | 2 +- 12 files changed, 2 insertions(+), 227 deletions(-) delete mode 100644 Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake delete mode 100644 Tests/RunCMake/CPack/DEB/DEPENDENCIES-VerifyResult.cmake delete mode 100644 Tests/RunCMake/CPack/DEB/DEPENDENCIES-specifics.cmake delete mode 100644 Tests/RunCMake/CPack/DEPENDENCIES.cmake delete mode 100644 Tests/RunCMake/CPack/RPM/DEPENDENCIES-ExpectedFiles.cmake delete mode 100644 Tests/RunCMake/CPack/RPM/DEPENDENCIES-VerifyResult.cmake delete mode 100644 Tests/RunCMake/CPack/RPM/DEPENDENCIES-specifics.cmake hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 3 09:17:00 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 3 Aug 2015 09:17:00 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1790-gcb7e276 Message-ID: <20150803131700.B773EB0B0A@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via cb7e276d6a39ebf79ddb060532f7c11066784a5b (commit) via 302edf850e34b008b921e40e756b81d9fde5d1ad (commit) via 94d53d1664b1e792e8088880cfd206e8e81ff625 (commit) via 6508cc5355d74a148e9a8d7feca99d60b9748168 (commit) via 25ec835571741d5339fb653e06e79896d72f8e8a (commit) via db519cae57122dc6584226aac951674b49301efc (commit) via 5c02ae4ac9dec3a275d3965ccdcfdb564686dc79 (commit) via ebacce3f0b0cef6116e91d408d591ff67285c420 (commit) via 614786cc5c8cf6f504112a722aabf8dddc154d2c (commit) from bbfd6cbd9f339015c1cefa27773953f69b6d3c68 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cb7e276d6a39ebf79ddb060532f7c11066784a5b commit cb7e276d6a39ebf79ddb060532f7c11066784a5b Merge: 302edf8 94d53d1 Author: Brad King AuthorDate: Mon Aug 3 09:16:41 2015 -0400 Commit: Brad King CommitDate: Mon Aug 3 09:16:41 2015 -0400 Merge branch 'master' into next http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=302edf850e34b008b921e40e756b81d9fde5d1ad commit 302edf850e34b008b921e40e756b81d9fde5d1ad Merge: bbfd6cb ebacce3 Author: Brad King AuthorDate: Mon Aug 3 09:16:35 2015 -0400 Commit: Brad King CommitDate: Mon Aug 3 09:16:35 2015 -0400 Merge branch 'master' into next ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 3 09:25:02 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 3 Aug 2015 09:25:02 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1793-g2b5ca8e Message-ID: <20150803132502.72DF9B0E6B@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 2b5ca8ec591cb9e7c3f7415c022662293773ebda (commit) via 14e49ed15615e7f2bcb58aa4540683250006f5c7 (commit) via 623dcc85a447b9ce0f09cffa8cd296cd8a51ad9d (commit) from cb7e276d6a39ebf79ddb060532f7c11066784a5b (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2b5ca8ec591cb9e7c3f7415c022662293773ebda commit 2b5ca8ec591cb9e7c3f7415c022662293773ebda Merge: cb7e276 14e49ed Author: Brad King AuthorDate: Mon Aug 3 09:25:01 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 3 09:25:01 2015 -0400 Merge topic 'if-test' into next 14e49ed1 if: Add "TEST " condition 623dcc85 ExternalProject: Avoid if() auto-dereference of a "TEST" variable http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=14e49ed15615e7f2bcb58aa4540683250006f5c7 commit 14e49ed15615e7f2bcb58aa4540683250006f5c7 Author: Matt McCormick AuthorDate: Mon Dec 29 20:47:48 2014 -0500 Commit: Brad King CommitDate: Mon Aug 3 09:22:25 2015 -0400 if: Add "TEST " condition if(TEST TestNameThatExists) will return true if a test with the name TestNameThatExists has been added with add_test. The syntax is similar to if(TARGET TargetName). Since use of "TEST" as an argument to if() could previously be interpreted as a non-keyword argument, add policy CMP0064 to treat it as a keyword as NEW behavior. diff --git a/Help/command/if.rst b/Help/command/if.rst index 396becf..2465bde 100644 --- a/Help/command/if.rst +++ b/Help/command/if.rst @@ -71,6 +71,10 @@ Possible expressions are: created by the :command:`add_executable`, :command:`add_library`, or :command:`add_custom_target` commands. +``if(TEST test-name)`` + True if the given name is an existing test name created by the + :command:`add_test` command. + ``if(EXISTS path-to-file-or-directory)`` True if the named file or directory exists. Behavior is well-defined only for full paths. diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst index 0a313cd..590f10d 100644 --- a/Help/manual/cmake-policies.7.rst +++ b/Help/manual/cmake-policies.7.rst @@ -121,3 +121,4 @@ All Policies /policy/CMP0061 /policy/CMP0062 /policy/CMP0063 + /policy/CMP0064 diff --git a/Help/policy/CMP0064.rst b/Help/policy/CMP0064.rst new file mode 100644 index 0000000..e9a061b --- /dev/null +++ b/Help/policy/CMP0064.rst @@ -0,0 +1,17 @@ +CMP0064 +------- + +Recognize ``TEST`` as a operator for the :command:`if` command. + +The ``TEST`` operator was added to the :command:`if` command to determine if a +given test name was created by the :command:`add_test` command. + +The ``OLD`` behavior for this policy is to ignore the ``TEST`` operator. +The ``NEW`` behavior is to interpret the ``TEST`` operator. + +This policy was introduced in CMake version 3.4. CMake version +|release| warns when the policy is not set and uses ``OLD`` behavior. Use +the :command:`cmake_policy()` command to set it to ``OLD`` or ``NEW`` +explicitly. + +.. include:: DEPRECATED.txt diff --git a/Help/release/dev/if-TEST.rst b/Help/release/dev/if-TEST.rst new file mode 100644 index 0000000..05bf71c --- /dev/null +++ b/Help/release/dev/if-TEST.rst @@ -0,0 +1,5 @@ +if-TEST +------- + +* Add a new TEST operator to if() that evaluates to true + if a given test name has been defined. diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx index 420bfdf..7874803 100644 --- a/Source/cmConditionEvaluator.cxx +++ b/Source/cmConditionEvaluator.cxx @@ -16,7 +16,8 @@ cmConditionEvaluator::cmConditionEvaluator(cmMakefile& makefile): Makefile(makefile), Policy12Status(makefile.GetPolicyStatus(cmPolicies::CMP0012)), Policy54Status(makefile.GetPolicyStatus(cmPolicies::CMP0054)), - Policy57Status(makefile.GetPolicyStatus(cmPolicies::CMP0057)) + Policy57Status(makefile.GetPolicyStatus(cmPolicies::CMP0057)), + Policy64Status(makefile.GetPolicyStatus(cmPolicies::CMP0064)) { } @@ -493,6 +494,29 @@ bool cmConditionEvaluator::HandleLevel1(cmArgumentList &newArgs, this->Makefile.FindTargetToUse(argP1->GetValue())?true:false, reducible, arg, newArgs, argP1, argP2); } + // does a test exist + if(this->Policy64Status != cmPolicies::OLD && + this->Policy64Status != cmPolicies::WARN) + { + if (this->IsKeyword("TEST", *arg) && argP1 != newArgs.end()) + { + const cmTest* haveTest = this->Makefile.GetTest(argP1->c_str()); + this->HandlePredicate( + haveTest?true:false, + reducible, arg, newArgs, argP1, argP2); + } + } + else if(this->Policy64Status == cmPolicies::WARN && + this->IsKeyword("TEST", *arg)) + { + std::ostringstream e; + e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0064) << "\n"; + e << "TEST will be interpreted as an operator " + "when the policy is set to NEW. " + "Since the policy is not set the OLD behavior will be used."; + + this->Makefile.IssueMessage(cmake::AUTHOR_WARNING, e.str()); + } // is a variable defined if (this->IsKeyword("DEFINED", *arg) && argP1 != newArgs.end()) { diff --git a/Source/cmConditionEvaluator.h b/Source/cmConditionEvaluator.h index c923d76..c4e2d11 100644 --- a/Source/cmConditionEvaluator.h +++ b/Source/cmConditionEvaluator.h @@ -94,6 +94,7 @@ private: cmPolicies::PolicyStatus Policy12Status; cmPolicies::PolicyStatus Policy54Status; cmPolicies::PolicyStatus Policy57Status; + cmPolicies::PolicyStatus Policy64Status; }; #endif diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index b783701..a791b89 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -217,6 +217,9 @@ class cmPolicy; 3, 3, 0, cmPolicies::WARN) \ SELECT(POLICY, CMP0063, \ "Honor visibility properties for all target types.", \ + 3, 3, 0, cmPolicies::WARN) \ + SELECT(POLICY, CMP0064, \ + "Support new TEST if() operator.", \ 3, 3, 0, cmPolicies::WARN) #define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1) diff --git a/Tests/RunCMake/CMP0064/CMP0064-NEW.cmake b/Tests/RunCMake/CMP0064/CMP0064-NEW.cmake new file mode 100644 index 0000000..cdf50e9 --- /dev/null +++ b/Tests/RunCMake/CMP0064/CMP0064-NEW.cmake @@ -0,0 +1,5 @@ +cmake_policy(SET CMP0064 NEW) + +if(NOT TEST TestThatDoesNotExist) + message(STATUS "if NOT TestThatDoesNotExist is true") +endif() diff --git a/Tests/RunCMake/CMP0064/CMP0064-OLD.cmake b/Tests/RunCMake/CMP0064/CMP0064-OLD.cmake new file mode 100644 index 0000000..bffd3f3 --- /dev/null +++ b/Tests/RunCMake/CMP0064/CMP0064-OLD.cmake @@ -0,0 +1,7 @@ +cmake_policy(SET CMP0064 OLD) + +if(TEST) + message(FATAL_ERROR "TEST was not recognized to be undefined") +else() + message(STATUS "TEST was treated as a variable") +endif() diff --git a/Tests/RunCMake/CMP0064/CMP0064-WARN.cmake b/Tests/RunCMake/CMP0064/CMP0064-WARN.cmake new file mode 100644 index 0000000..bffd3f3 --- /dev/null +++ b/Tests/RunCMake/CMP0064/CMP0064-WARN.cmake @@ -0,0 +1,7 @@ +cmake_policy(SET CMP0064 OLD) + +if(TEST) + message(FATAL_ERROR "TEST was not recognized to be undefined") +else() + message(STATUS "TEST was treated as a variable") +endif() diff --git a/Tests/RunCMake/CMP0064/CMakeLists.txt b/Tests/RunCMake/CMP0064/CMakeLists.txt new file mode 100644 index 0000000..74b3ff8 --- /dev/null +++ b/Tests/RunCMake/CMP0064/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.3) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMP0064/RunCMakeTest.cmake b/Tests/RunCMake/CMP0064/RunCMakeTest.cmake new file mode 100644 index 0000000..26e0a91 --- /dev/null +++ b/Tests/RunCMake/CMP0064/RunCMakeTest.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +run_cmake(CMP0064-OLD) +run_cmake(CMP0064-WARN) +run_cmake(CMP0064-NEW) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 607e799..20d47b2 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -103,6 +103,7 @@ add_RunCMake_test(CMP0055) add_RunCMake_test(CMP0057) add_RunCMake_test(CMP0059) add_RunCMake_test(CMP0060) +add_RunCMake_test(CMP0064) if(CMAKE_GENERATOR MATCHES "Make") add_RunCMake_test(Make) endif() diff --git a/Tests/RunCMake/if/RunCMakeTest.cmake b/Tests/RunCMake/if/RunCMakeTest.cmake index 2c0c4d7..3f4d2a2 100644 --- a/Tests/RunCMake/if/RunCMakeTest.cmake +++ b/Tests/RunCMake/if/RunCMakeTest.cmake @@ -4,3 +4,6 @@ run_cmake(InvalidArgument1) run_cmake(IsDirectory) run_cmake(IsDirectoryLong) run_cmake(elseif-message) + +run_cmake(TestNameThatExists) +run_cmake(TestNameThatDoesNotExist) diff --git a/Tests/RunCMake/if/TestNameThatDoesNotExist-stdout.txt b/Tests/RunCMake/if/TestNameThatDoesNotExist-stdout.txt new file mode 100644 index 0000000..8874ca8 --- /dev/null +++ b/Tests/RunCMake/if/TestNameThatDoesNotExist-stdout.txt @@ -0,0 +1 @@ +TestThatDoesNotExist is false diff --git a/Tests/RunCMake/if/TestNameThatDoesNotExist.cmake b/Tests/RunCMake/if/TestNameThatDoesNotExist.cmake new file mode 100644 index 0000000..74bc8b0 --- /dev/null +++ b/Tests/RunCMake/if/TestNameThatDoesNotExist.cmake @@ -0,0 +1,6 @@ +cmake_policy(SET CMP0064 NEW) +if(TEST TestThatDoesNotExist) + message(FATAL_ERROR "if TestThatDoesNotExist is true") +else() + message(STATUS "if TestThatDoesNotExist is false") +endif() diff --git a/Tests/RunCMake/if/TestNameThatExists-stdout.txt b/Tests/RunCMake/if/TestNameThatExists-stdout.txt new file mode 100644 index 0000000..54911bc --- /dev/null +++ b/Tests/RunCMake/if/TestNameThatExists-stdout.txt @@ -0,0 +1 @@ +TestThatExists is true diff --git a/Tests/RunCMake/if/TestNameThatExists.cmake b/Tests/RunCMake/if/TestNameThatExists.cmake new file mode 100644 index 0000000..65c2b46 --- /dev/null +++ b/Tests/RunCMake/if/TestNameThatExists.cmake @@ -0,0 +1,7 @@ +cmake_policy(SET CMP0064 NEW) +add_test(NAME TestThatExists COMMAND ${CMAKE_COMMAND} -E echo "A CMake Test") +if(TEST TestThatExists) + message(STATUS "if TestThatExists is true") +else() + message(FATAL_ERROR "if TestThatExists is false") +endif() http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=623dcc85a447b9ce0f09cffa8cd296cd8a51ad9d commit 623dcc85a447b9ce0f09cffa8cd296cd8a51ad9d Author: Matt McCormick AuthorDate: Wed Jul 29 14:46:40 2015 -0400 Commit: Brad King CommitDate: Mon Aug 3 09:21:39 2015 -0400 ExternalProject: Avoid if() auto-dereference of a "TEST" variable Exposed by CMP0054 warnings. diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index f6844be..fdb146a 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -1211,7 +1211,7 @@ function(_ep_get_build_command name step cmd_var) if(step STREQUAL "INSTALL") set(args install) endif() - if(step STREQUAL "TEST") + if("x${step}x" STREQUAL "xTESTx") set(args test) endif() else() @@ -1230,7 +1230,7 @@ function(_ep_get_build_command name step cmd_var) list(APPEND args --target install) endif() # But for "TEST" drive the project with corresponding "ctest". - if(step STREQUAL "TEST") + if("x${step}x" STREQUAL "xTESTx") string(REGEX REPLACE "^(.*/)cmake([^/]*)$" "\\1ctest\\2" cmd "${cmd}") set(args "") endif() @@ -1246,7 +1246,7 @@ function(_ep_get_build_command name step cmd_var) if(step STREQUAL "INSTALL") set(args install) endif() - if(step STREQUAL "TEST") + if("x${step}x" STREQUAL "xTESTx") set(args test) endif() endif() ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 3 09:25:12 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 3 Aug 2015 09:25:12 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-679-g7ac2b12 Message-ID: <20150803132512.2FA11B0E75@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 7ac2b1256b09044b86c6bd926cc239133beab088 (commit) via 14e49ed15615e7f2bcb58aa4540683250006f5c7 (commit) via 623dcc85a447b9ce0f09cffa8cd296cd8a51ad9d (commit) from 94d53d1664b1e792e8088880cfd206e8e81ff625 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7ac2b1256b09044b86c6bd926cc239133beab088 commit 7ac2b1256b09044b86c6bd926cc239133beab088 Merge: 94d53d1 14e49ed Author: Brad King AuthorDate: Mon Aug 3 09:25:10 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 3 09:25:10 2015 -0400 Merge topic 'if-test' 14e49ed1 if: Add "TEST " condition 623dcc85 ExternalProject: Avoid if() auto-dereference of a "TEST" variable ----------------------------------------------------------------------- Summary of changes: Help/command/if.rst | 4 +++ Help/manual/cmake-policies.7.rst | 1 + Help/policy/CMP0064.rst | 17 +++++++++++++ Help/release/dev/if-TEST.rst | 5 ++++ Modules/ExternalProject.cmake | 6 ++--- Source/cmConditionEvaluator.cxx | 26 +++++++++++++++++++- Source/cmConditionEvaluator.h | 1 + Source/cmPolicies.h | 3 +++ Tests/RunCMake/CMP0064/CMP0064-NEW.cmake | 5 ++++ Tests/RunCMake/CMP0064/CMP0064-OLD.cmake | 7 ++++++ Tests/RunCMake/CMP0064/CMP0064-WARN.cmake | 7 ++++++ .../{CompileDefinitions => CMP0064}/CMakeLists.txt | 0 Tests/RunCMake/CMP0064/RunCMakeTest.cmake | 5 ++++ Tests/RunCMake/CMakeLists.txt | 1 + Tests/RunCMake/if/RunCMakeTest.cmake | 3 +++ .../if/TestNameThatDoesNotExist-stdout.txt | 1 + Tests/RunCMake/if/TestNameThatDoesNotExist.cmake | 6 +++++ Tests/RunCMake/if/TestNameThatExists-stdout.txt | 1 + Tests/RunCMake/if/TestNameThatExists.cmake | 7 ++++++ 19 files changed, 102 insertions(+), 4 deletions(-) create mode 100644 Help/policy/CMP0064.rst create mode 100644 Help/release/dev/if-TEST.rst create mode 100644 Tests/RunCMake/CMP0064/CMP0064-NEW.cmake create mode 100644 Tests/RunCMake/CMP0064/CMP0064-OLD.cmake create mode 100644 Tests/RunCMake/CMP0064/CMP0064-WARN.cmake copy Tests/RunCMake/{CompileDefinitions => CMP0064}/CMakeLists.txt (100%) create mode 100644 Tests/RunCMake/CMP0064/RunCMakeTest.cmake create mode 100644 Tests/RunCMake/if/TestNameThatDoesNotExist-stdout.txt create mode 100644 Tests/RunCMake/if/TestNameThatDoesNotExist.cmake create mode 100644 Tests/RunCMake/if/TestNameThatExists-stdout.txt create mode 100644 Tests/RunCMake/if/TestNameThatExists.cmake hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 3 09:25:29 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 3 Aug 2015 09:25:29 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1795-g1e7713c Message-ID: <20150803132529.1502CB0E79@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 1e7713c82c352d6f69a4add9614611d4e3b6f0de (commit) via 7ac2b1256b09044b86c6bd926cc239133beab088 (commit) from 2b5ca8ec591cb9e7c3f7415c022662293773ebda (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1e7713c82c352d6f69a4add9614611d4e3b6f0de commit 1e7713c82c352d6f69a4add9614611d4e3b6f0de Merge: 2b5ca8e 7ac2b12 Author: Brad King AuthorDate: Mon Aug 3 09:25:21 2015 -0400 Commit: Brad King CommitDate: Mon Aug 3 09:25:21 2015 -0400 Merge branch 'master' into next ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 3 10:21:07 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 3 Aug 2015 10:21:07 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1797-g8b0fd7f Message-ID: <20150803142107.091C6B0B3C@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 8b0fd7f79a86971233d8561ed9fc8cc2d6df9372 (commit) via 975426ceb339cf7a17f57ffba2757bb368669f93 (commit) from 1e7713c82c352d6f69a4add9614611d4e3b6f0de (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8b0fd7f79a86971233d8561ed9fc8cc2d6df9372 commit 8b0fd7f79a86971233d8561ed9fc8cc2d6df9372 Merge: 1e7713c 975426c Author: Brad King AuthorDate: Mon Aug 3 10:21:06 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 3 10:21:06 2015 -0400 Merge topic 'cmake-W-options' into next 975426ce cmake: Do not treat developer warnings as errors by default in scripts http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=975426ceb339cf7a17f57ffba2757bb368669f93 commit 975426ceb339cf7a17f57ffba2757bb368669f93 Author: Brad King AuthorDate: Mon Aug 3 10:00:42 2015 -0400 Commit: Brad King CommitDate: Mon Aug 3 10:03:27 2015 -0400 cmake: Do not treat developer warnings as errors by default in scripts The logic in commit c96fe0b4 (cmake: Add -W options to control deprecation warnings and errors, 2015-07-28) accidentally enables errors on warnings by default in scripts because there is no initialization of CMAKE_SUPPRESS_DEVELOPER_ERRORS to TRUE. Rename internal CMAKE_SUPPRESS_DEVELOPER_ERRORS cache entry to CMAKE_ERROR_DEVELOPER_WARNINGS. Fix the logic in the message() command to treat AUTHOR_WARNING as an error only if the option is explicitly enabled. diff --git a/Source/cmMessageCommand.cxx b/Source/cmMessageCommand.cxx index e09ba75..467555f 100644 --- a/Source/cmMessageCommand.cxx +++ b/Source/cmMessageCommand.cxx @@ -43,7 +43,7 @@ bool cmMessageCommand } else if (*i == "AUTHOR_WARNING") { - if (!this->Makefile->IsOn("CMAKE_SUPPRESS_DEVELOPER_ERRORS")) + if (this->Makefile->IsOn("CMAKE_ERROR_DEVELOPER_WARNINGS")) { fatal = true; type = cmake::AUTHOR_ERROR; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 6832141..e28f385 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1289,7 +1289,7 @@ int cmake::Configure() " the author of the CMakeLists.txt files.", cmState::INTERNAL); this->CacheManager-> - AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_ERRORS", "TRUE", + AddCacheEntry("CMAKE_ERROR_DEVELOPER_WARNINGS", "FALSE", "Suppress errors that are meant for" " the author of the CMakeLists.txt files.", cmState::INTERNAL); @@ -1328,7 +1328,7 @@ int cmake::Configure() else if (warningLevel == ERROR_LEVEL) { this->CacheManager-> - AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_ERRORS", "FALSE", + AddCacheEntry("CMAKE_ERROR_DEVELOPER_WARNINGS", "TRUE", "Suppress errors that are meant for" " the author of the CMakeLists.txt files.", cmState::INTERNAL); @@ -1676,11 +1676,11 @@ int cmake::Run(const std::vector& args, bool noconfigure) } // don't turn dev warnings into errors by default, if no value has been - // specified for the flag, enable it - if (!this->State->GetCacheEntryValue("CMAKE_SUPPRESS_DEVELOPER_ERRORS")) + // specified for the flag, disable it + if (!this->State->GetCacheEntryValue("CMAKE_ERROR_DEVELOPER_WARNINGS")) { this->CacheManager-> - AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_ERRORS", "TRUE", + AddCacheEntry("CMAKE_ERROR_DEVELOPER_WARNINGS", "FALSE", "Suppress errors that are meant for" " the author of the CMakeLists.txt files.", cmState::INTERNAL); ----------------------------------------------------------------------- Summary of changes: Source/cmMessageCommand.cxx | 2 +- Source/cmake.cxx | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 3 10:26:09 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 3 Aug 2015 10:26:09 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1799-g940f14e Message-ID: <20150803142609.52E52B0DB5@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 940f14edf440b4a58ed4f22468ae9bf474b46629 (commit) via d951f5429a116e6174f9cdb983945cb01cf37553 (commit) from 8b0fd7f79a86971233d8561ed9fc8cc2d6df9372 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=940f14edf440b4a58ed4f22468ae9bf474b46629 commit 940f14edf440b4a58ed4f22468ae9bf474b46629 Merge: 8b0fd7f d951f54 Author: Brad King AuthorDate: Mon Aug 3 10:26:08 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 3 10:26:08 2015 -0400 Merge topic 'doc-ninja-rule-launchers' into next d951f542 Help: Refine RULE_LAUNCH_{COMPILE,CUSTOM,LINK} global property docs http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d951f5429a116e6174f9cdb983945cb01cf37553 commit d951f5429a116e6174f9cdb983945cb01cf37553 Author: Brad King AuthorDate: Mon Aug 3 10:19:49 2015 -0400 Commit: Brad King CommitDate: Mon Aug 3 10:25:53 2015 -0400 Help: Refine RULE_LAUNCH_{COMPILE,CUSTOM,LINK} global property docs Link to the generators that implement these properties. Explain in more detail why other generators ignore them. diff --git a/Help/prop_gbl/RULE_LAUNCH_COMPILE.rst b/Help/prop_gbl/RULE_LAUNCH_COMPILE.rst index 980843b..e0df878 100644 --- a/Help/prop_gbl/RULE_LAUNCH_COMPILE.rst +++ b/Help/prop_gbl/RULE_LAUNCH_COMPILE.rst @@ -3,7 +3,9 @@ RULE_LAUNCH_COMPILE Specify a launcher for compile rules. -Makefile generators prefix compiler commands with the given launcher -command line. This is intended to allow launchers to intercept build -problems with high granularity. Non-Makefile generators currently -ignore this property. +:ref:`Makefile Generators` and the :generator:`Ninja` generator prefix +compiler commands with the given launcher command line. +This is intended to allow launchers to intercept build problems +with high granularity. Other generators ignore this property +because their underlying build systems provide no hook to wrap +individual commands with a launcher. diff --git a/Help/prop_gbl/RULE_LAUNCH_CUSTOM.rst b/Help/prop_gbl/RULE_LAUNCH_CUSTOM.rst index 9d4a25c..b20c59b 100644 --- a/Help/prop_gbl/RULE_LAUNCH_CUSTOM.rst +++ b/Help/prop_gbl/RULE_LAUNCH_CUSTOM.rst @@ -3,7 +3,9 @@ RULE_LAUNCH_CUSTOM Specify a launcher for custom rules. -Makefile generators prefix custom commands with the given launcher -command line. This is intended to allow launchers to intercept build -problems with high granularity. Non-Makefile generators currently -ignore this property. +:ref:`Makefile Generators` and the :generator:`Ninja` generator prefix +custom commands with the given launcher command line. +This is intended to allow launchers to intercept build problems +with high granularity. Other generators ignore this property +because their underlying build systems provide no hook to wrap +individual commands with a launcher. diff --git a/Help/prop_gbl/RULE_LAUNCH_LINK.rst b/Help/prop_gbl/RULE_LAUNCH_LINK.rst index 191f1d5..567bb68 100644 --- a/Help/prop_gbl/RULE_LAUNCH_LINK.rst +++ b/Help/prop_gbl/RULE_LAUNCH_LINK.rst @@ -3,7 +3,9 @@ RULE_LAUNCH_LINK Specify a launcher for link rules. -Makefile generators prefix link and archive commands with the given -launcher command line. This is intended to allow launchers to -intercept build problems with high granularity. Non-Makefile -generators currently ignore this property. +:ref:`Makefile Generators` and the :generator:`Ninja` generator prefix +link and archive commands with the given launcher command line. +This is intended to allow launchers to intercept build problems +with high granularity. Other generators ignore this property +because their underlying build systems provide no hook to wrap +individual commands with a launcher. ----------------------------------------------------------------------- Summary of changes: Help/prop_gbl/RULE_LAUNCH_COMPILE.rst | 10 ++++++---- Help/prop_gbl/RULE_LAUNCH_CUSTOM.rst | 10 ++++++---- Help/prop_gbl/RULE_LAUNCH_LINK.rst | 10 ++++++---- 3 files changed, 18 insertions(+), 12 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 3 13:37:29 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 3 Aug 2015 13:37:29 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1802-ge540a54 Message-ID: <20150803173729.BFE35B10EF@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via e540a5464bda433d5850908065e73261b9c4fea1 (commit) via 3da431379bae33374edd7c62c6f4261b4e3a663f (commit) via 9a59ae5c198f7c413bcaf29f1ab107a265677b95 (commit) from 940f14edf440b4a58ed4f22468ae9bf474b46629 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e540a5464bda433d5850908065e73261b9c4fea1 commit e540a5464bda433d5850908065e73261b9c4fea1 Merge: 940f14e 3da4313 Author: Brad King AuthorDate: Mon Aug 3 13:37:28 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 3 13:37:28 2015 -0400 Merge topic 'update-kwsys' into next 3da43137 Merge branch 'upstream-kwsys' into update-kwsys 9a59ae5c KWSys 2015-08-03 (dad68c33) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3da431379bae33374edd7c62c6f4261b4e3a663f commit 3da431379bae33374edd7c62c6f4261b4e3a663f Merge: 7ac2b12 9a59ae5 Author: Brad King AuthorDate: Mon Aug 3 13:17:54 2015 -0400 Commit: Brad King CommitDate: Mon Aug 3 13:17:54 2015 -0400 Merge branch 'upstream-kwsys' into update-kwsys http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9a59ae5c198f7c413bcaf29f1ab107a265677b95 commit 9a59ae5c198f7c413bcaf29f1ab107a265677b95 Author: KWSys Robot AuthorDate: Mon Aug 3 13:14:14 2015 -0400 Commit: Brad King CommitDate: Mon Aug 3 13:17:50 2015 -0400 KWSys 2015-08-03 (dad68c33) Extract upstream KWSys using the following shell commands. $ git archive --prefix=upstream-kwsys/ dad68c33 | tar x $ git shortlog --no-merges --abbrev=8 --format='%h %s' f63febb7..dad68c33 James Johnston (1): dad68c33 Encoding: Fix undefined behavior if out of memory. Jean-Christophe Fillion-Robin (2): e5c23738 SystemTools: Fix DetectFileType failure on missing file 6d83c113 SystemTools: Fix DetectFileType failure on directory Sebastian Schuberth (1): 4db8e69f SystemTools: Implement FileIsSymlink on Windows diff --git a/EncodingC.c b/EncodingC.c index ba2cec2..32b9bff 100644 --- a/EncodingC.c +++ b/EncodingC.c @@ -45,8 +45,11 @@ wchar_t* kwsysEncoding_DupToWide(const char* str) if(length > 0) { ret = (wchar_t*)malloc((length)*sizeof(wchar_t)); - ret[0] = 0; - kwsysEncoding_mbstowcs(ret, str, length); + if(ret) + { + ret[0] = 0; + kwsysEncoding_mbstowcs(ret, str, length); + } } return ret; } @@ -72,8 +75,11 @@ char* kwsysEncoding_DupToNarrow(const wchar_t* str) if(length > 0) { ret = (char*)malloc(length); - ret[0] = 0; - kwsysEncoding_wcstombs(ret, str, length); + if(ret) + { + ret[0] = 0; + kwsysEncoding_wcstombs(ret, str, length); + } } return ret; } diff --git a/SystemTools.cxx b/SystemTools.cxx index 3452259..0714344 100644 --- a/SystemTools.cxx +++ b/SystemTools.cxx @@ -3198,8 +3198,16 @@ bool SystemTools::FileIsDirectory(const kwsys_stl::string& inName) bool SystemTools::FileIsSymlink(const kwsys_stl::string& name) { #if defined( _WIN32 ) - (void)name; - return false; + DWORD attr = GetFileAttributesW( + SystemTools::ConvertToWindowsExtendedPath(name).c_str()); + if (attr != INVALID_FILE_ATTRIBUTES) + { + return (attr & FILE_ATTRIBUTE_REPARSE_POINT) != 0; + } + else + { + return false; + } #else struct stat fs; if(lstat(name.c_str(), &fs) == 0) @@ -4230,6 +4238,11 @@ SystemTools::DetectFileType(const char *filename, return SystemTools::FileTypeUnknown; } + if (SystemTools::FileIsDirectory(filename)) + { + return SystemTools::FileTypeUnknown; + } + FILE *fp = Fopen(filename, "rb"); if (!fp) { @@ -4243,6 +4256,7 @@ SystemTools::DetectFileType(const char *filename, fclose(fp); if (read_length == 0) { + delete [] buffer; return SystemTools::FileTypeUnknown; } diff --git a/testSystemTools.cxx b/testSystemTools.cxx index 15d8eab..7b5c025 100644 --- a/testSystemTools.cxx +++ b/testSystemTools.cxx @@ -98,6 +98,10 @@ static bool CheckEscapeChars(kwsys_stl::string input, static bool CheckFileOperations() { bool res = true; + const kwsys_stl::string testNonExistingFile(TEST_SYSTEMTOOLS_SOURCE_DIR + "/testSystemToolsNonExistingFile"); + const kwsys_stl::string testDotFile(TEST_SYSTEMTOOLS_SOURCE_DIR + "/."); const kwsys_stl::string testBinFile(TEST_SYSTEMTOOLS_SOURCE_DIR "/testSystemTools.bin"); const kwsys_stl::string testTxtFile(TEST_SYSTEMTOOLS_SOURCE_DIR @@ -106,6 +110,24 @@ static bool CheckFileOperations() "/testSystemToolsNewDir"); const kwsys_stl::string testNewFile(testNewDir + "/testNewFile.txt"); + if (kwsys::SystemTools::DetectFileType(testNonExistingFile.c_str()) != + kwsys::SystemTools::FileTypeUnknown) + { + kwsys_ios::cerr + << "Problem with DetectFileType - failed to detect type of: " + << testNonExistingFile << kwsys_ios::endl; + res = false; + } + + if (kwsys::SystemTools::DetectFileType(testDotFile.c_str()) != + kwsys::SystemTools::FileTypeUnknown) + { + kwsys_ios::cerr + << "Problem with DetectFileType - failed to detect type of: " + << testDotFile << kwsys_ios::endl; + res = false; + } + if (kwsys::SystemTools::DetectFileType(testBinFile.c_str()) != kwsys::SystemTools::FileTypeBinary) { ----------------------------------------------------------------------- Summary of changes: Source/kwsys/EncodingC.c | 14 ++++++++++---- Source/kwsys/SystemTools.cxx | 18 ++++++++++++++++-- Source/kwsys/testSystemTools.cxx | 22 ++++++++++++++++++++++ 3 files changed, 48 insertions(+), 6 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 3 15:10:50 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 3 Aug 2015 15:10:50 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1806-g1341adc Message-ID: <20150803191050.138271DA7@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 1341adc5d45a5273c1e36904a2957e151fdaa1c9 (commit) via 8f8d824d2b7c8ed4ff911e223141a45eebb5569e (commit) via 244e93644116719d208a7e55606ba267225e362f (commit) via 7e49926499c76e427441eed29277c176eb779194 (commit) from e540a5464bda433d5850908065e73261b9c4fea1 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1341adc5d45a5273c1e36904a2957e151fdaa1c9 commit 1341adc5d45a5273c1e36904a2957e151fdaa1c9 Merge: e540a54 8f8d824 Author: Brad King AuthorDate: Mon Aug 3 15:10:48 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 3 15:10:48 2015 -0400 Merge topic 'java-updates' into next 8f8d824d UseJava: Teach install_jar new DESTINATION and COMPONENT options 244e9364 UseJava: Teach add_jar to support file syntax for sources 7e499264 FindJava: Add support for idlj and jarsigner tools http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8f8d824d2b7c8ed4ff911e223141a45eebb5569e commit 8f8d824d2b7c8ed4ff911e223141a45eebb5569e Author: Marc Chevrier AuthorDate: Thu Jul 30 11:19:24 2015 +0200 Commit: Brad King CommitDate: Mon Aug 3 14:59:44 2015 -0400 UseJava: Teach install_jar new DESTINATION and COMPONENT options diff --git a/Help/release/dev/java-updates.rst b/Help/release/dev/java-updates.rst index 2e5e184..b777807 100644 --- a/Help/release/dev/java-updates.rst +++ b/Help/release/dev/java-updates.rst @@ -7,3 +7,7 @@ java-updates * The :module:`UseJava` module ``add_jar`` function learned to support response files (e.g. ``@srcs.txt``) for source specification. + +* The :module:`UseJava` module ``install_jar`` function learned + new ``DESTINATION`` and ``COMPONENT`` options to specify + the corresponding :command:`install` command options. diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake index 0add8d2..c61591d 100644 --- a/Modules/UseJava.cmake +++ b/Modules/UseJava.cmake @@ -211,14 +211,16 @@ # # :: # -# install_jar(TARGET_NAME DESTINATION) +# install_jar(target_name destination) +# install_jar(target_name DESTINATION destination [COMPONENT component]) # # This command installs the TARGET_NAME files to the given DESTINATION. # It should be called in the same scope as add_jar() or it will fail. # # :: # -# install_jni_symlink(TARGET_NAME DESTINATION) +# install_jni_symlink(target_name destination) +# install_jni_symlink(target_name DESTINATION destination [COMPONENT component]) # # This command installs the TARGET_NAME JNI symlinks to the given # DESTINATION. It should be called in the same scope as add_jar() or it @@ -629,7 +631,26 @@ function(add_jar _TARGET_NAME) endfunction() -function(INSTALL_JAR _TARGET_NAME _DESTINATION) +function(INSTALL_JAR _TARGET_NAME) + if (ARGC EQUAL 2) + set (_DESTINATION ${ARGV1}) + else() + cmake_parse_arguments(_install_jar + "" + "DESTINATION;COMPONENT" + "" + ${ARGN}) + if (_install_jar_DESTINATION) + set (_DESTINATION ${_install_jar_DESTINATION}) + else() + message(SEND_ERROR "install_jar: ${_TARGET_NAME}: DESTINATION must be specified.") + endif() + + if (_install_jar_COMPONENT) + set (_COMPONENT COMPONENT ${_install_jar_COMPONENT}) + endif() + endif() + get_property(__FILES TARGET ${_TARGET_NAME} @@ -643,13 +664,33 @@ function(INSTALL_JAR _TARGET_NAME _DESTINATION) ${__FILES} DESTINATION ${_DESTINATION} + ${_COMPONENT} ) else () - message(SEND_ERROR "The target ${_TARGET_NAME} is not known in this scope.") + message(SEND_ERROR "install_jar: The target ${_TARGET_NAME} is not known in this scope.") endif () endfunction() -function(INSTALL_JNI_SYMLINK _TARGET_NAME _DESTINATION) +function(INSTALL_JNI_SYMLINK _TARGET_NAME) + if (ARGC EQUAL 2) + set (_DESTINATION ${ARGV1}) + else() + cmake_parse_arguments(_install_jni_symlink + "" + "DESTINATION;COMPONENT" + "" + ${ARGN}) + if (_install_jni_symlink_DESTINATION) + set (_DESTINATION ${_install_jni_symlink_DESTINATION}) + else() + message(SEND_ERROR "install_jni_symlink: ${_TARGET_NAME}: DESTINATION must be specified.") + endif() + + if (_install_jni_symlink_COMPONENT) + set (_COMPONENT COMPONENT ${_install_jni_symlink_COMPONENT}) + endif() + endif() + get_property(__SYMLINK TARGET ${_TARGET_NAME} @@ -663,9 +704,10 @@ function(INSTALL_JNI_SYMLINK _TARGET_NAME _DESTINATION) ${__SYMLINK} DESTINATION ${_DESTINATION} + ${_COMPONENT} ) else () - message(SEND_ERROR "The target ${_TARGET_NAME} is not known in this scope.") + message(SEND_ERROR "install_jni_symlink: The target ${_TARGET_NAME} is not known in this scope.") endif () endfunction() http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=244e93644116719d208a7e55606ba267225e362f commit 244e93644116719d208a7e55606ba267225e362f Author: Marc Chevrier AuthorDate: Thu Jul 30 11:17:04 2015 +0200 Commit: Brad King CommitDate: Mon Aug 3 14:59:24 2015 -0400 UseJava: Teach add_jar to support file syntax for sources diff --git a/Help/release/dev/java-updates.rst b/Help/release/dev/java-updates.rst index 94998eb..2e5e184 100644 --- a/Help/release/dev/java-updates.rst +++ b/Help/release/dev/java-updates.rst @@ -3,3 +3,7 @@ java-updates * The :module:`FindJava` module learned to optionally find the ``idlj`` and ``jarsigner`` tools. + +* The :module:`UseJava` module ``add_jar`` function learned + to support response files (e.g. ``@srcs.txt``) for source + specification. diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake index 5eb0ca8..0add8d2 100644 --- a/Modules/UseJava.cmake +++ b/Modules/UseJava.cmake @@ -21,7 +21,8 @@ # # This command creates a .jar. It compiles the given # source files (source) and adds the given resource files (resource) to -# the jar file. If only resource files are given then just a jar file +# the jar file. Source files can be java files or listing files +# (prefixed by '@'). If only resource files are given then just a jar file # is created. The list of include jars are added to the classpath when # compiling the java sources and also to the dependencies of the target. # INCLUDE_JARS also accepts other target names created by add_jar. For @@ -423,6 +424,7 @@ function(add_jar _TARGET_NAME) set(_JAVA_CLASS_FILES) set(_JAVA_COMPILE_FILES) + set(_JAVA_COMPILE_FILELISTS) set(_JAVA_DEPENDS) set(_JAVA_COMPILE_DEPENDS) set(_JAVA_RESOURCE_FILES) @@ -433,7 +435,11 @@ function(add_jar _TARGET_NAME) get_filename_component(_JAVA_PATH ${_JAVA_SOURCE_FILE} PATH) get_filename_component(_JAVA_FULL ${_JAVA_SOURCE_FILE} ABSOLUTE) - if (_JAVA_EXT MATCHES ".java") + if (_JAVA_SOURCE_FILE MATCHES "^@(.+)$") + get_filename_component(_JAVA_FULL ${CMAKE_MATCH_1} ABSOLUTE) + list(APPEND _JAVA_COMPILE_FILELISTS ${_JAVA_FULL}) + + elseif (_JAVA_EXT MATCHES ".java") file(RELATIVE_PATH _JAVA_REL_BINARY_PATH ${_add_jar_OUTPUT_DIR} ${_JAVA_FULL}) file(RELATIVE_PATH _JAVA_REL_SOURCE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${_JAVA_FULL}) string(LENGTH ${_JAVA_REL_BINARY_PATH} _BIN_LEN) @@ -492,11 +498,21 @@ function(add_jar _TARGET_NAME) file(WRITE ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist "") endif() - if (_JAVA_COMPILE_FILES) - # Create the list of files to compile. - set(_JAVA_SOURCES_FILE ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_sources) - string(REPLACE ";" "\"\n\"" _JAVA_COMPILE_STRING "\"${_JAVA_COMPILE_FILES}\"") - file(WRITE ${_JAVA_SOURCES_FILE} ${_JAVA_COMPILE_STRING}) + if (_JAVA_COMPILE_FILES OR _JAVA_COMPILE_FILELISTS) + set (_JAVA_SOURCES_FILELISTS) + + if (_JAVA_COMPILE_FILES) + # Create the list of files to compile. + set(_JAVA_SOURCES_FILE ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_sources) + string(REPLACE ";" "\"\n\"" _JAVA_COMPILE_STRING "\"${_JAVA_COMPILE_FILES}\"") + file(WRITE ${_JAVA_SOURCES_FILE} ${_JAVA_COMPILE_STRING}) + list (APPEND _JAVA_SOURCES_FILELISTS "@${_JAVA_SOURCES_FILE}") + endif() + if (_JAVA_COMPILE_FILELISTS) + foreach (_JAVA_FILELIST IN LISTS _JAVA_COMPILE_FILELISTS) + list (APPEND _JAVA_SOURCES_FILELISTS "@${_JAVA_FILELIST}") + endforeach() + endif() # Compile the java files and create a list of class files add_custom_command( @@ -506,9 +522,9 @@ function(add_jar _TARGET_NAME) ${CMAKE_JAVA_COMPILE_FLAGS} -classpath "${CMAKE_JAVA_INCLUDE_PATH_FINAL}" -d ${CMAKE_JAVA_CLASS_OUTPUT_PATH} - @${_JAVA_SOURCES_FILE} + ${_JAVA_SOURCES_FILELISTS} COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_compiled_${_TARGET_NAME} - DEPENDS ${_JAVA_COMPILE_FILES} ${_JAVA_COMPILE_DEPENDS} + DEPENDS ${_JAVA_COMPILE_FILES} ${_JAVA_COMPILE_FILELISTS} ${_JAVA_COMPILE_DEPENDS} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMENT "Building Java objects for ${_TARGET_NAME}.jar" ) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index d95a5f4..bc8373b 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -3008,16 +3008,28 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release if(JNI_H AND EXISTS "${JNI_H}") # in case jni.h is a broken symlink file(READ "${JNI_H}" JNI_FILE) if("${JNI_FILE}" MATCHES "JDK1_2") - add_test(Java ${CMAKE_CTEST_COMMAND} + add_test(Java.Jar ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/Java" "${CMake_BINARY_DIR}/Tests/Java" ${build_generator_args} --build-project hello + --build-target hello --build-two-config --build-run-dir "${CMake_BINARY_DIR}/Tests/Java/" --build-options ${build_options} --test-command ${JAVA_RUNTIME} -classpath hello.jar HelloWorld) + add_test(Java.JarSourceList ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/Java" + "${CMake_BINARY_DIR}/Tests/Java" + ${build_generator_args} + --build-project hello + --build-target hello2 + --build-two-config + --build-run-dir "${CMake_BINARY_DIR}/Tests/Java/" + --build-options ${build_options} + --test-command ${JAVA_RUNTIME} -classpath hello2.jar HelloWorld) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Java") endif() endif() diff --git a/Tests/Java/CMakeLists.txt b/Tests/Java/CMakeLists.txt index 6a69a24..e1bcf3c 100644 --- a/Tests/Java/CMakeLists.txt +++ b/Tests/Java/CMakeLists.txt @@ -7,3 +7,7 @@ find_package(Java COMPONENTS Development) include (UseJava) add_jar(hello A.java HelloWorld.java) + +# use listing file to specify sources +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/java_fileslist "A.java\nHelloWorld.java\n") +add_jar(hello2 @${CMAKE_CURRENT_BINARY_DIR}/java_fileslist) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7e49926499c76e427441eed29277c176eb779194 commit 7e49926499c76e427441eed29277c176eb779194 Author: Marc Chevrier AuthorDate: Fri Jul 31 10:00:43 2015 +0200 Commit: Brad King CommitDate: Mon Aug 3 14:58:55 2015 -0400 FindJava: Add support for idlj and jarsigner tools diff --git a/Help/release/dev/java-updates.rst b/Help/release/dev/java-updates.rst new file mode 100644 index 0000000..94998eb --- /dev/null +++ b/Help/release/dev/java-updates.rst @@ -0,0 +1,5 @@ +java-updates +------------ + +* The :module:`FindJava` module learned to optionally find + the ``idlj`` and ``jarsigner`` tools. diff --git a/Modules/FindJava.cmake b/Modules/FindJava.cmake index 9e43174..9f87997 100644 --- a/Modules/FindJava.cmake +++ b/Modules/FindJava.cmake @@ -8,21 +8,34 @@ # include files and libraries are. The caller may set variable JAVA_HOME # to specify a Java installation prefix explicitly. # +# +# Specify one or more of the following components as you call this find module. See example below. +# +# :: +# +# Runtime = User just want to execute some Java byte-compiled +# Development = Development tools (java, javac, javah and javadoc), includes Runtime component +# IdlJ = idl compiler for Java +# JarSigner = signer tool for jar +# +# # This module sets the following result variables: # # :: # -# Java_JAVA_EXECUTABLE = the full path to the Java runtime -# Java_JAVAC_EXECUTABLE = the full path to the Java compiler -# Java_JAVAH_EXECUTABLE = the full path to the Java header generator -# Java_JAVADOC_EXECUTABLE = the full path to the Java documention generator -# Java_JAR_EXECUTABLE = the full path to the Java archiver -# Java_VERSION_STRING = Version of java found, eg. 1.6.0_12 -# Java_VERSION_MAJOR = The major version of the package found. -# Java_VERSION_MINOR = The minor version of the package found. -# Java_VERSION_PATCH = The patch version of the package found. -# Java_VERSION_TWEAK = The tweak version of the package found (after '_') -# Java_VERSION = This is set to: $major.$minor.$patch(.$tweak) +# Java_JAVA_EXECUTABLE = the full path to the Java runtime +# Java_JAVAC_EXECUTABLE = the full path to the Java compiler +# Java_JAVAH_EXECUTABLE = the full path to the Java header generator +# Java_JAVADOC_EXECUTABLE = the full path to the Java documention generator +# Java_IDLJ_EXECUTABLE = the full path to the Java idl compiler +# Java_JAR_EXECUTABLE = the full path to the Java archiver +# Java_JARSIGNER_EXECUTABLE = the full path to the Java jar signer +# Java_VERSION_STRING = Version of java found, eg. 1.6.0_12 +# Java_VERSION_MAJOR = The major version of the package found. +# Java_VERSION_MINOR = The minor version of the package found. +# Java_VERSION_PATCH = The patch version of the package found. +# Java_VERSION_TWEAK = The tweak version of the package found (after '_') +# Java_VERSION = This is set to: $major.$minor.$patch(.$tweak) # # # @@ -184,28 +197,61 @@ find_program(Java_JAVADOC_EXECUTABLE PATHS ${_JAVA_PATHS} ) +find_program(Java_IDLJ_EXECUTABLE + NAMES idlj + HINTS ${_JAVA_HINTS} + PATHS ${_JAVA_PATHS} +) + +find_program(Java_JARSIGNER_EXECUTABLE + NAMES jarsigner + HINTS ${_JAVA_HINTS} + PATHS ${_JAVA_PATHS} +) + include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) if(Java_FIND_COMPONENTS) + set(_JAVA_REQUIRED_VARS) foreach(component ${Java_FIND_COMPONENTS}) # User just want to execute some Java byte-compiled - if(component STREQUAL "Runtime") - find_package_handle_standard_args(Java - REQUIRED_VARS Java_JAVA_EXECUTABLE - VERSION_VAR Java_VERSION - ) + If(component STREQUAL "Runtime") + list(APPEND _JAVA_REQUIRED_VARS Java_JAVA_EXECUTABLE) + if(Java_JAVA_EXECUTABLE) + set(Java_Runtime_FOUND TRUE) + endif() elseif(component STREQUAL "Development") - find_package_handle_standard_args(Java - REQUIRED_VARS Java_JAVA_EXECUTABLE Java_JAR_EXECUTABLE Java_JAVAC_EXECUTABLE - Java_JAVAH_EXECUTABLE Java_JAVADOC_EXECUTABLE - VERSION_VAR Java_VERSION - ) + list(APPEND _JAVA_REQUIRED_VARS Java_JAVA_EXECUTABLE Java_JAVAC_EXECUTABLE + Java_JAVAH_EXECUTABLE Java_JAVADOC_EXECUTABLE) + if(Java_JAVA_EXECUTABLE AND Java_JAVAC_EXECUTABLE + AND Java_JAVAH_EXECUTABLE AND Java_JAVADOC_EXECUTABLE) + set(Java_Development_FOUND TRUE) + endif() + elseif(component STREQUAL "IdlJ") + list(APPEND _JAVA_REQUIRED_VARS Java_IDLJ_EXECUTABLE) + if(Java_IdlJ_EXECUTABLE) + set(Java_Extra_FOUND TRUE) + endif() + elseif(component STREQUAL "JarSigner") + list(APPEND _JAVA_REQUIRED_VARS Java_JARSIGNER_EXECUTABLE) + if(Java_IDLJ_EXECUTABLE) + set(Java_JarSigner_FOUND TRUE) + endif() else() message(FATAL_ERROR "Comp: ${component} is not handled") endif() - set(Java_${component}_FOUND TRUE) endforeach() + list (REMOVE_DUPLICATES _JAVA_REQUIRED_VARS) + find_package_handle_standard_args(Java + REQUIRED_VARS ${_JAVA_REQUIRED_VARS} HANDLE_COMPONENTS + VERSION_VAR Java_VERSION + ) + if(Java_FOUND) + foreach(component ${Java_FIND_COMPONENTS}) + set(Java_${component}_FOUND TRUE) + endforeach() + endif() else() - # Check for everything + # Check for Development find_package_handle_standard_args(Java REQUIRED_VARS Java_JAVA_EXECUTABLE Java_JAR_EXECUTABLE Java_JAVAC_EXECUTABLE Java_JAVAH_EXECUTABLE Java_JAVADOC_EXECUTABLE @@ -220,6 +266,8 @@ mark_as_advanced( Java_JAVAC_EXECUTABLE Java_JAVAH_EXECUTABLE Java_JAVADOC_EXECUTABLE + Java_IDLJ_EXECUTABLE + Java_JARSIGNER_EXECUTABLE ) # LEGACY ----------------------------------------------------------------------- Summary of changes: Help/release/dev/java-updates.rst | 13 +++++ Modules/FindJava.cmake | 94 ++++++++++++++++++++++++++++--------- Modules/UseJava.cmake | 88 ++++++++++++++++++++++++++++------ Tests/CMakeLists.txt | 14 +++++- Tests/Java/CMakeLists.txt | 4 ++ 5 files changed, 174 insertions(+), 39 deletions(-) create mode 100644 Help/release/dev/java-updates.rst hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 3 16:42:11 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 3 Aug 2015 16:42:11 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1808-g910b102 Message-ID: <20150803204211.0E4B88C5ED@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 910b10207f43694f66036569b5604b023d39ab03 (commit) via 354bbd881d3e46aa40e2a566967174682c0521b2 (commit) from 1341adc5d45a5273c1e36904a2957e151fdaa1c9 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=910b10207f43694f66036569b5604b023d39ab03 commit 910b10207f43694f66036569b5604b023d39ab03 Merge: 1341adc 354bbd8 Author: Brad King AuthorDate: Mon Aug 3 16:42:10 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 3 16:42:10 2015 -0400 Merge topic 'use-generator-target' into next 354bbd88 fixup! cmGeneratorTarget: Move GetFullName from cmTarget. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=354bbd881d3e46aa40e2a566967174682c0521b2 commit 354bbd881d3e46aa40e2a566967174682c0521b2 Author: Brad King AuthorDate: Mon Aug 3 16:40:57 2015 -0400 Commit: Brad King CommitDate: Mon Aug 3 16:40:57 2015 -0400 fixup! cmGeneratorTarget: Move GetFullName from cmTarget. diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index e1fa7d4..29e1034 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1112,14 +1112,15 @@ void cmLocalVisualStudio6Generator // Compute the proper name to use to link this library. std::string lib; std::string libDebug; - cmGeneratorTarget* tgt = this->GlobalGenerator->GetGeneratorTarget( - this->GlobalGenerator->FindTarget(j->first.c_str())); + cmTarget* tgt = this->GlobalGenerator->FindTarget(j->first.c_str()); if(tgt) { + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(tgt); lib = cmSystemTools::GetFilenameWithoutExtension - (tgt->GetFullName().c_str()); + (gt->GetFullName().c_str()); libDebug = cmSystemTools::GetFilenameWithoutExtension - (tgt->GetFullName("Debug").c_str()); + (gt->GetFullName("Debug").c_str()); lib += ".lib"; libDebug += ".lib"; } ----------------------------------------------------------------------- Summary of changes: Source/cmLocalVisualStudio6Generator.cxx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 3 16:43:00 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 3 Aug 2015 16:43:00 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1841-g3c77f9c Message-ID: <20150803204300.3E297A9783@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 3c77f9ca3a67d5c94251154a391991b8b2146be5 (commit) via 1071024a6036cb74f7f6c55c05e715ce58a322f9 (commit) via 968e1ca548746ff92770c11ec5e524af548f4419 (commit) via ffc27b83b4f3a31c1c38cdc7edc8a6d37ed1977d (commit) via 7c451647fdf53736196b68c493315275348edb05 (commit) via c0d4cf3dc6cba3e6e71556ac48573826a4d52c17 (commit) via f6ce58e7952ec8cf8fda391de3b398d64736b50d (commit) via 2a8606e92535835e91a2b0ac00104a663f31f6a4 (commit) via ac39bd910e3e2f606b722e2495373a58efedde59 (commit) via 44288bd6da0141a91e7afb3cfd3664f8b4c6084c (commit) via 90016ac72a2151ac28ad5ae6baa38b65a11a38ff (commit) via 15556c7db7df7f59f1010ea3f86ccb35f36b10e0 (commit) via fe3a255a93ca247460915aeabdb905217355b788 (commit) via d5d7ae969c778663d4da0c5f18b5826b128ff7d2 (commit) via 53ba657602648ac20b6710c46daa043807dc8c2a (commit) via 1950f478ffcf738794485180c165dedbc744dbf6 (commit) via 5a827c6ab7ac480fb5c0bd2a5643c22fd0ddabc9 (commit) via e69c5efa1d6929522c47c68fab6a245664769e53 (commit) via d3a63396fbe3a43857a37edb88e08d00802e9adb (commit) via 47fd39fe1260259d088704c323e119d075f314af (commit) via 3bd4785affc66f194847fc5effdaa78e40087fb0 (commit) via 02beed7e24a93e6d684415ba1773d33bd9df50cf (commit) via 38b76360744534506296bde467e3fadb13a2eea9 (commit) via a3ae53efa53aea6e705948173e92d716d8710700 (commit) via 6b9a9d3dd66c4de66cf0d35f1d3e5f810b4a2a8e (commit) via a393b45f3953d13da0585a8c01721c85639dd487 (commit) via 64688437a69269725b7f73ced318252e5ee090a1 (commit) via ff84e914b247dc3c692086323aed69f0a8942d2e (commit) via c71fd71080f2c3d78ee82980c2306cd345cb6d06 (commit) via 16a84de3ade279d8eb8e56c88efc85eba200098a (commit) via 5d414a138f9e5d1d3a2054d289961aa5c66693a7 (commit) via 4b0e72cf72e52b09be07fde986b9fc3431c2124e (commit) via e699c0d6f9e8937c6d78b7da13ddc657492b7810 (commit) from 910b10207f43694f66036569b5604b023d39ab03 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3c77f9ca3a67d5c94251154a391991b8b2146be5 commit 3c77f9ca3a67d5c94251154a391991b8b2146be5 Merge: 910b102 1071024 Author: Brad King AuthorDate: Mon Aug 3 16:42:55 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 3 16:42:55 2015 -0400 Merge topic 'use-generator-target' into next 1071024a cmOrderDirectories: Port to cmGeneratorTarget. 968e1ca5 cmMakefile: Remove unused method. ffc27b83 cmGlobalGenerator: Base exclusion computation on cmGeneratorTarget. 7c451647 cmGeneratorTarget: Move CompileInfoMap from cmTarget. c0d4cf3d cmGeneratorTarget: Move GetCompilePDBDirectory from cmTarget. f6ce58e7 cmGeneratorTarget: Move GetOutputName from cmTarget. 2a8606e9 cmComputeLinkDepends: Port to cmGeneratorTarget. ac39bd91 cmComputeLinkInformation: Port to cmGeneratorTarget. 44288bd6 cmGeneratorTarget: Move IsBundleOnApple from cmTarget. 90016ac7 cmMakefileTargetGenerator: Add accessor for GeneratorTarget. 15556c7d cmGeneratorTarget: Move GetLinkClosure from cmTarget. fe3a255a cmGeneratorTarget: Move GetLinkerLanguage from cmTarget. d5d7ae96 cmGeneratorTarget: Move GetFrameworkDirectory from cmTarget. 53ba6576 cmGeneratorTarget: Move GetFullName from cmTarget. 1950f478 cmGeneratorTarget: Move GetAppBundleDirectory from cmTarget. 5a827c6a cmGeneratorTarget: Move GetInstallNameDir* from cmTarget. ... http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1071024a6036cb74f7f6c55c05e715ce58a322f9 commit 1071024a6036cb74f7f6c55c05e715ce58a322f9 Author: Stephen Kelly AuthorDate: Sat Aug 1 09:48:04 2015 +0200 Commit: Brad King CommitDate: Mon Aug 3 16:39:56 2015 -0400 cmOrderDirectories: Port to cmGeneratorTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 5cd0d54..e0c6e86 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -260,10 +260,10 @@ cmComputeLinkInformation // Allocate internals. this->OrderLinkerSearchPath = - new cmOrderDirectories(this->GlobalGenerator, target->Target, + new cmOrderDirectories(this->GlobalGenerator, target, "linker search path"); this->OrderRuntimeSearchPath = - new cmOrderDirectories(this->GlobalGenerator, target->Target, + new cmOrderDirectories(this->GlobalGenerator, target, "runtime search path"); this->OrderDependentRPath = 0; @@ -370,7 +370,7 @@ cmComputeLinkInformation { this->SharedDependencyMode = SharedDepModeDir; this->OrderDependentRPath = - new cmOrderDirectories(this->GlobalGenerator, target->Target, + new cmOrderDirectories(this->GlobalGenerator, target, "dependent library path"); } diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx index a612437..35ee127 100644 --- a/Source/cmOrderDirectories.cxx +++ b/Source/cmOrderDirectories.cxx @@ -280,7 +280,7 @@ bool cmOrderDirectoriesConstraintLibrary::FindConflict(std::string const& dir) //---------------------------------------------------------------------------- cmOrderDirectories::cmOrderDirectories(cmGlobalGenerator* gg, - cmTarget const* target, + const cmGeneratorTarget* target, const char* purpose) { this->GlobalGenerator = gg; @@ -554,7 +554,8 @@ void cmOrderDirectories::FindImplicitConflicts() << text << "Some of these libraries may not be found correctly."; this->GlobalGenerator->GetCMakeInstance() - ->IssueMessage(cmake::WARNING, w.str(), this->Target->GetBacktrace()); + ->IssueMessage(cmake::WARNING, w.str(), + this->Target->Target->GetBacktrace()); } //---------------------------------------------------------------------------- @@ -635,5 +636,6 @@ void cmOrderDirectories::DiagnoseCycle() } e << "Some of these libraries may not be found correctly."; this->GlobalGenerator->GetCMakeInstance() - ->IssueMessage(cmake::WARNING, e.str(), this->Target->GetBacktrace()); + ->IssueMessage(cmake::WARNING, e.str(), + this->Target->Target->GetBacktrace()); } diff --git a/Source/cmOrderDirectories.h b/Source/cmOrderDirectories.h index cb5a51f..211c786 100644 --- a/Source/cmOrderDirectories.h +++ b/Source/cmOrderDirectories.h @@ -19,7 +19,7 @@ class cmGlobalGenerator; class cmOrderDirectoriesConstraint; class cmOrderDirectoriesConstraintLibrary; -class cmTarget; +class cmGeneratorTarget; /** \class cmOrderDirectories * \brief Compute a safe runtime path order for a set of shared libraries. @@ -27,7 +27,7 @@ class cmTarget; class cmOrderDirectories { public: - cmOrderDirectories(cmGlobalGenerator* gg, cmTarget const* target, + cmOrderDirectories(cmGlobalGenerator* gg, cmGeneratorTarget const* target, const char* purpose); ~cmOrderDirectories(); void AddRuntimeLibrary(std::string const& fullPath, const char* soname = 0); @@ -41,7 +41,7 @@ public: std::vector const& GetOrderedDirectories(); private: cmGlobalGenerator* GlobalGenerator; - cmTarget const* Target; + cmGeneratorTarget const* Target; std::string Purpose; std::vector OrderedDirectories; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=968e1ca548746ff92770c11ec5e524af548f4419 commit 968e1ca548746ff92770c11ec5e524af548f4419 Author: Stephen Kelly AuthorDate: Sat Jun 6 14:27:52 2015 +0200 Commit: Brad King CommitDate: Mon Aug 3 16:39:54 2015 -0400 cmMakefile: Remove unused method. diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 1e5c301..00d4005 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -113,10 +113,6 @@ public: bool GetIsSourceFileTryCompile() const; - ///! Get the current makefile generator. - cmLocalGenerator* GetLocalGenerator() const - { return this->LocalGenerator;} - /** * Help enforce global target name uniqueness. */ http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ffc27b83b4f3a31c1c38cdc7edc8a6d37ed1977d commit ffc27b83b4f3a31c1c38cdc7edc8a6d37ed1977d Author: Stephen Kelly AuthorDate: Sat Jun 6 14:09:35 2015 +0200 Commit: Brad King CommitDate: Mon Aug 3 16:39:52 2015 -0400 cmGlobalGenerator: Base exclusion computation on cmGeneratorTarget. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 1d6608b..b14949a 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2022,10 +2022,10 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, } bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, - cmTarget const& target) const + cmGeneratorTarget* target) const { - if(target.GetType() == cmTarget::INTERFACE_LIBRARY - || target.GetPropertyAsBool("EXCLUDE_FROM_ALL")) + if(target->GetType() == cmTarget::INTERFACE_LIBRARY + || target->Target->GetPropertyAsBool("EXCLUDE_FROM_ALL")) { // This target is excluded from its directory. return true; @@ -2034,7 +2034,7 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, { // This target is included in its directory. Check whether the // directory is excluded. - return this->IsExcluded(root, target.GetMakefile()->GetLocalGenerator()); + return this->IsExcluded(root, target->GetLocalGenerator()); } } @@ -2095,15 +2095,16 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap() { cmTarget const& target = t->second; + cmGeneratorTarget* gt = this->GetGeneratorTarget(&target); + // Consider the directory containing the target and all its // parents until something excludes the target. - for(cmLocalGenerator* clg = lg; clg && !this->IsExcluded(clg, target); + for(cmLocalGenerator* clg = lg; clg && !this->IsExcluded(clg, gt); clg = clg->GetParent()) { // This local generator includes the target. std::set& targetSet = this->LocalGeneratorToTargetMap[clg]; - cmGeneratorTarget* gt = this->GetGeneratorTarget(&target); targetSet.insert(gt); // Add dependencies of the included target. An excluded diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 9492372..3be76b6 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -398,7 +398,7 @@ protected: void FillProjectMap(); void CheckLocalGenerators(); bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen) const; - bool IsExcluded(cmLocalGenerator* root, cmTarget const& target) const; + bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) const; void FillLocalGeneratorToTargetMap(); void CreateDefaultGlobalTargets(cmTargets* targets); cmTarget CreateGlobalTarget(const std::string& name, const char* message, diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 2a749c1..47822b4 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -289,7 +289,7 @@ public: const std::vector& GetLocalGenerators() const { return LocalGenerators; } - bool IsExcluded(cmLocalGenerator* root, cmTarget& target) { + bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) { return cmGlobalGenerator::IsExcluded(root, target); } int GetRuleCmdLength(const std::string& name) { diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 69747a4..76d059ee 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -821,7 +821,7 @@ cmGlobalUnixMakefileGenerator3 localName, depends, commands, true); // add the all/all dependency - if(!this->IsExcluded(this->LocalGenerators[0], *gtarget->Target)) + if(!this->IsExcluded(this->LocalGenerators[0], gtarget)) { depends.clear(); depends.push_back(localName); @@ -889,7 +889,7 @@ cmGlobalUnixMakefileGenerator3 "Pre-install relink rule for target.", localName, depends, commands, true); - if(!this->IsExcluded(this->LocalGenerators[0], *gtarget->Target)) + if(!this->IsExcluded(this->LocalGenerators[0], gtarget)) { depends.clear(); depends.push_back(localName); diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 2f9d79a..c06dfb3 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -111,17 +111,18 @@ bool cmGlobalVisualStudioGenerator::Compute() for(std::vector::iterator i = gen.begin(); i != gen.end(); ++i) { - cmTargets& targets = (*i)->GetMakefile()->GetTargets(); - for(cmTargets::iterator t = targets.begin(); + cmGeneratorTargetsType targets = + (*i)->GetMakefile()->GetGeneratorTargets(); + for(cmGeneratorTargetsType::iterator t = targets.begin(); t != targets.end(); ++t) { - if (t->second.GetType() == cmTarget::GLOBAL_TARGET) + if (t->second->GetType() == cmTarget::GLOBAL_TARGET) { continue; } if(!this->IsExcluded(gen[0], t->second)) { - allBuild->AddUtility(t->second.GetName()); + allBuild->AddUtility(t->second->GetName()); } } } diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 9889bd4..1822c97 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -90,7 +90,7 @@ void cmLocalNinjaGenerator::Generate() // Add the target to "all" if required. if (!this->GetGlobalNinjaGenerator()->IsExcluded( this->GetGlobalNinjaGenerator()->GetLocalGenerators()[0], - *t->second->Target)) + t->second)) this->GetGlobalNinjaGenerator()->AddDependencyToAll(t->second->Target); delete tg; } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7c451647fdf53736196b68c493315275348edb05 commit 7c451647fdf53736196b68c493315275348edb05 Author: Stephen Kelly AuthorDate: Mon Oct 20 21:02:16 2014 +0200 Commit: Brad King CommitDate: Mon Aug 3 16:39:50 2015 -0400 cmGeneratorTarget: Move CompileInfoMap from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c6f248c..c831704 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1356,6 +1356,46 @@ cmGeneratorTarget::GetMacContentDirectory(const std::string& config, return fpath; } + +//---------------------------------------------------------------------------- +cmGeneratorTarget::CompileInfo const* cmGeneratorTarget::GetCompileInfo( + const std::string& config) const +{ + // There is no compile information for imported targets. + if(this->IsImported()) + { + return 0; + } + + if(this->GetType() > cmTarget::OBJECT_LIBRARY) + { + std::string msg = "cmTarget::GetCompileInfo called for "; + msg += this->GetName(); + msg += " which has type "; + msg += cmTarget::GetTargetTypeName(this->Target->GetType()); + this->Makefile->IssueMessage(cmake::INTERNAL_ERROR, msg); + return 0; + } + + // Lookup/compute/cache the compile information for this configuration. + std::string config_upper; + if(!config.empty()) + { + config_upper = cmSystemTools::UpperCase(config); + } + CompileInfoMapType::const_iterator i = + this->CompileInfoMap.find(config_upper); + if(i == this->CompileInfoMap.end()) + { + CompileInfo info; + this->Target + ->ComputePDBOutputDir("COMPILE_PDB", config, info.CompilePdbDir); + CompileInfoMapType::value_type entry(config_upper, info); + i = this->CompileInfoMap.insert(entry).first; + } + return &i->second; +} + //---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetModuleDefinitionFile(const std::string& config) const @@ -1827,7 +1867,7 @@ void cmGeneratorTarget::TraceDependencies() std::string cmGeneratorTarget::GetCompilePDBDirectory(const std::string& config) const { - if(cmTarget::CompileInfo const* info = this->Target->GetCompileInfo(config)) + if(CompileInfo const* info = this->GetCompileInfo(config)) { return info->CompilePdbDir; } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 3dbbca1..68e7a8a 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -230,6 +230,16 @@ public: /** Whether this library has soname enabled and platform supports it. */ bool HasSOName(const std::string& config) const; + struct CompileInfo + { + std::string CompilePdbDir; + }; + + CompileInfo const* GetCompileInfo(const std::string& config) const; + + typedef std::map CompileInfoMapType; + mutable CompileInfoMapType CompileInfoMap; + /** Get the name of the compiler pdb file for the target. */ std::string GetCompilePDBName(const std::string& config="") const; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 9308113..1f8f07a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -126,9 +126,6 @@ public: typedef std::map ImportInfoMapType; ImportInfoMapType ImportInfoMap; - typedef std::map CompileInfoMapType; - CompileInfoMapType CompileInfoMap; - // Cache link implementation computation from each configuration. struct OptionalLinkImplementation: public cmTarget::LinkImplementation { @@ -2598,45 +2595,6 @@ cmTarget::OutputInfo const* cmTarget::GetOutputInfo( } //---------------------------------------------------------------------------- -cmTarget::CompileInfo const* cmTarget::GetCompileInfo( - const std::string& config) const -{ - // There is no compile information for imported targets. - if(this->IsImported()) - { - return 0; - } - - if(this->GetType() > cmTarget::OBJECT_LIBRARY) - { - std::string msg = "cmTarget::GetCompileInfo called for "; - msg += this->GetName(); - msg += " which has type "; - msg += cmTarget::GetTargetTypeName(this->GetType()); - this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg); - return 0; - } - - // Lookup/compute/cache the compile information for this configuration. - std::string config_upper; - if(!config.empty()) - { - config_upper = cmSystemTools::UpperCase(config); - } - typedef cmTargetInternals::CompileInfoMapType CompileInfoMapType; - CompileInfoMapType::const_iterator i = - this->Internal->CompileInfoMap.find(config_upper); - if(i == this->Internal->CompileInfoMap.end()) - { - CompileInfo info; - this->ComputePDBOutputDir("COMPILE_PDB", config, info.CompilePdbDir); - CompileInfoMapType::value_type entry(config_upper, info); - i = this->Internal->CompileInfoMap.insert(entry).first; - } - return &i->second; -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetDirectory(const std::string& config, bool implib) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 8689838..e3fbdfd 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -626,13 +626,6 @@ private: void ComputeImportInfo(std::string const& desired_config, ImportInfo& info) const; - // Cache target compile paths for each configuration. - struct CompileInfo - { - std::string CompilePdbDir; - }; - - CompileInfo const* GetCompileInfo(const std::string& config) const; LinkInterface const* GetImportLinkInterface(const std::string& config, cmTarget const* head, http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c0d4cf3dc6cba3e6e71556ac48573826a4d52c17 commit c0d4cf3dc6cba3e6e71556ac48573826a4d52c17 Author: Stephen Kelly AuthorDate: Mon Oct 20 20:52:54 2014 +0200 Commit: Brad King CommitDate: Mon Aug 3 16:39:49 2015 -0400 cmGeneratorTarget: Move GetCompilePDBDirectory from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index aac941e..c6f248c 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -743,7 +743,7 @@ cmGeneratorTarget::GetCompilePDBName(const std::string& config) const std::string cmGeneratorTarget::GetCompilePDBPath(const std::string& config) const { - std::string dir = this->Target->GetCompilePDBDirectory(config); + std::string dir = this->GetCompilePDBDirectory(config); std::string name = this->GetCompilePDBName(config); if(dir.empty() && !name.empty()) { @@ -1824,6 +1824,16 @@ void cmGeneratorTarget::TraceDependencies() tracer.Trace(); } +std::string +cmGeneratorTarget::GetCompilePDBDirectory(const std::string& config) const +{ + if(cmTarget::CompileInfo const* info = this->Target->GetCompileInfo(config)) + { + return info->CompilePdbDir; + } + return ""; +} + //---------------------------------------------------------------------------- void cmGeneratorTarget::GetAppleArchs(const std::string& config, std::vector& archVec) const diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 52ab6c0..3dbbca1 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -214,6 +214,12 @@ public: */ void TraceDependencies(); + /** Get the directory in which to place the target compiler .pdb file. + If the configuration name is given then the generator will add its + subdirectory for that configuration. Otherwise just the canonical + compiler pdb output directory is given. */ + std::string GetCompilePDBDirectory(const std::string& config = "") const; + /** Get sources that must be built before the given source. */ std::vector const* GetSourceDepends(cmSourceFile const* sf) const; diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index afe145a..ccb0974 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -130,7 +130,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) } std::string compilePdbOutputPath = - this->Target->GetCompilePDBDirectory(this->ConfigName); + this->GeneratorTarget->GetCompilePDBDirectory(this->ConfigName); cmSystemTools::MakeDirectory(compilePdbOutputPath.c_str()); std::string pdbOutputPath = this->Target->GetPDBDirectory(this->ConfigName); diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index bb0f9dd..2f995e8 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -311,7 +311,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules } std::string compilePdbOutputPath = - this->Target->GetCompilePDBDirectory(this->ConfigName); + this->GeneratorTarget->GetCompilePDBDirectory(this->ConfigName); cmSystemTools::MakeDirectory(compilePdbOutputPath.c_str()); std::string pdbOutputPath = this->Target->GetPDBDirectory(this->ConfigName); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 8b64bc4..9308113 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -69,12 +69,6 @@ struct cmTarget::OutputInfo }; //---------------------------------------------------------------------------- -struct cmTarget::CompileInfo -{ - std::string CompilePdbDir; -}; - -//---------------------------------------------------------------------------- class cmTargetInternals { public: @@ -2673,16 +2667,6 @@ std::string cmTarget::GetPDBDirectory(const std::string& config) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetCompilePDBDirectory(const std::string& config) const -{ - if(CompileInfo const* info = this->GetCompileInfo(config)) - { - return info->CompilePdbDir; - } - return ""; -} - -//---------------------------------------------------------------------------- const char* cmTarget::ImportedGetLocation(const std::string& config) const { static std::string location; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index a6f2465..8689838 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -334,12 +334,6 @@ public: pdb output directory is given. */ std::string GetPDBDirectory(const std::string& config) const; - /** Get the directory in which to place the target compiler .pdb file. - If the configuration name is given then the generator will add its - subdirectory for that configuration. Otherwise just the canonical - compiler pdb output directory is given. */ - std::string GetCompilePDBDirectory(const std::string& config = "") const; - const char* ImportedGetLocation(const std::string& config) const; /** Get the target major and minor version numbers interpreted from @@ -633,7 +627,11 @@ private: ImportInfo& info) const; // Cache target compile paths for each configuration. - struct CompileInfo; + struct CompileInfo + { + std::string CompilePdbDir; + }; + CompileInfo const* GetCompileInfo(const std::string& config) const; LinkInterface const* http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f6ce58e7952ec8cf8fda391de3b398d64736b50d commit f6ce58e7952ec8cf8fda391de3b398d64736b50d Author: Stephen Kelly AuthorDate: Sat Aug 1 07:04:23 2015 +0200 Commit: Brad King CommitDate: Mon Aug 3 16:39:47 2015 -0400 cmGeneratorTarget: Move GetOutputName from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 55e2922..aac941e 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -267,6 +267,54 @@ const char *cmGeneratorTarget::GetProperty(const std::string& prop) const } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetOutputName(const std::string& config, + bool implib) const +{ + std::vector props; + std::string type = this->Target->GetOutputTargetType(implib); + std::string configUpper = cmSystemTools::UpperCase(config); + if(!type.empty() && !configUpper.empty()) + { + // _OUTPUT_NAME_ + props.push_back(type + "_OUTPUT_NAME_" + configUpper); + } + if(!type.empty()) + { + // _OUTPUT_NAME + props.push_back(type + "_OUTPUT_NAME"); + } + if(!configUpper.empty()) + { + // OUTPUT_NAME_ + props.push_back("OUTPUT_NAME_" + configUpper); + // _OUTPUT_NAME + props.push_back(configUpper + "_OUTPUT_NAME"); + } + // OUTPUT_NAME + props.push_back("OUTPUT_NAME"); + + std::string outName; + for(std::vector::const_iterator i = props.begin(); + i != props.end(); ++i) + { + if (const char* outNameProp = this->Target->GetProperty(*i)) + { + outName = outNameProp; + break; + } + } + + if (outName.empty()) + { + outName = this->GetName(); + } + + cmGeneratorExpression ge; + cmsys::auto_ptr cge = ge.Parse(outName); + return cge->Evaluate(this->Makefile, config); +} + +//---------------------------------------------------------------------------- std::vector const* cmGeneratorTarget::GetSourceDepends(cmSourceFile const* sf) const { @@ -922,7 +970,7 @@ std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config, bool contentOnly) const { std::string fpath; - fpath += this->Target->GetOutputName(config, false); + fpath += this->GetOutputName(config, false); fpath += "."; const char *ext = this->Target->GetProperty("BUNDLE_EXTENSION"); if (!ext) @@ -949,7 +997,7 @@ cmGeneratorTarget::GetFrameworkDirectory(const std::string& config, bool rootDir) const { std::string fpath; - fpath += this->Target->GetOutputName(config, false); + fpath += this->GetOutputName(config, false); fpath += ".framework"; if(!rootDir) { @@ -2247,7 +2295,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, std::string fw_prefix; if(this->Target->IsFrameworkOnApple()) { - fw_prefix = this->Target->GetOutputName(config, false); + fw_prefix = this->GetOutputName(config, false); fw_prefix += ".framework/"; targetPrefix = fw_prefix.c_str(); targetSuffix = 0; @@ -2265,7 +2313,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, outPrefix = targetPrefix?targetPrefix:""; // Append the target name or property-specified name. - outBase += this->Target->GetOutputName(config, implib); + outBase += this->GetOutputName(config, implib); // Append the per-configuration postfix. outBase += configPostfix?configPostfix:""; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 21e0900..52ab6c0 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -230,6 +230,9 @@ public: /** Get the path for the MSVC /Fd option for this target. */ std::string GetCompilePDBPath(const std::string& config="") const; + // Get the target base name. + std::string GetOutputName(const std::string& config, bool implib) const; + /** * Flags for a given source file as used in this target. Typically assigned * via SET_TARGET_PROPERTIES when the property is a list of source files. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e887ef3..8b64bc4 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3663,54 +3663,6 @@ bool cmTarget::UsesDefaultOutputDir(const std::string& config, } //---------------------------------------------------------------------------- -std::string cmTarget::GetOutputName(const std::string& config, - bool implib) const -{ - std::vector props; - std::string type = this->GetOutputTargetType(implib); - std::string configUpper = cmSystemTools::UpperCase(config); - if(!type.empty() && !configUpper.empty()) - { - // _OUTPUT_NAME_ - props.push_back(type + "_OUTPUT_NAME_" + configUpper); - } - if(!type.empty()) - { - // _OUTPUT_NAME - props.push_back(type + "_OUTPUT_NAME"); - } - if(!configUpper.empty()) - { - // OUTPUT_NAME_ - props.push_back("OUTPUT_NAME_" + configUpper); - // _OUTPUT_NAME - props.push_back(configUpper + "_OUTPUT_NAME"); - } - // OUTPUT_NAME - props.push_back("OUTPUT_NAME"); - - std::string outName; - for(std::vector::const_iterator i = props.begin(); - i != props.end(); ++i) - { - if (const char* outNameProp = this->GetProperty(*i)) - { - outName = outNameProp; - break; - } - } - - if (outName.empty()) - { - outName = this->GetName(); - } - - cmGeneratorExpression ge; - cmsys::auto_ptr cge = ge.Parse(outName); - return cge->Evaluate(this->Makefile, config); -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetFrameworkVersion() const { assert(this->GetType() != INTERFACE_LIBRARY); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e53afff..a6f2465 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -552,9 +552,6 @@ private: // Returns ARCHIVE, LIBRARY, or RUNTIME based on platform and type. const char* GetOutputTargetType(bool implib) const; - // Get the target base name. - std::string GetOutputName(const std::string& config, bool implib) const; - std::string GetFullNameImported(const std::string& config, bool implib) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2a8606e92535835e91a2b0ac00104a663f31f6a4 commit 2a8606e92535835e91a2b0ac00104a663f31f6a4 Author: Stephen Kelly AuthorDate: Thu Jul 30 00:45:34 2015 +0200 Commit: Brad King CommitDate: Mon Aug 3 16:39:45 2015 -0400 cmComputeLinkDepends: Port to cmGeneratorTarget. diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index abd9877..8ba8847 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -173,18 +173,19 @@ items that we know the linker will re-use automatically (shared libs). //---------------------------------------------------------------------------- cmComputeLinkDepends -::cmComputeLinkDepends(cmTarget const* target, const std::string& config) +::cmComputeLinkDepends(const cmGeneratorTarget* target, + const std::string& config) { // Store context information. this->Target = target; - this->Makefile = this->Target->GetMakefile(); + this->Makefile = this->Target->Target->GetMakefile(); this->GlobalGenerator = this->Makefile->GetGlobalGenerator(); this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance(); // The configuration being linked. this->HasConfig = !config.empty(); this->Config = (this->HasConfig)? config : std::string(); - this->LinkType = this->Target->ComputeLinkType(this->Config); + this->LinkType = this->Target->Target->ComputeLinkType(this->Config); // Enable debug mode if requested. this->DebugMode = this->Makefile->IsOn("CMAKE_LINK_DEPENDS_DEBUG_MODE"); @@ -363,7 +364,7 @@ void cmComputeLinkDepends::FollowLinkEntry(BFSEntry const& qe) { // Follow the target dependencies. if(cmTarget::LinkInterface const* iface = - entry.Target->GetLinkInterface(this->Config, this->Target)) + entry.Target->GetLinkInterface(this->Config, this->Target->Target)) { const bool isIface = entry.Target->GetType() == cmTarget::INTERFACE_LIBRARY; @@ -461,7 +462,7 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep) if(entry.Target) { if(cmTarget::LinkInterface const* iface = - entry.Target->GetLinkInterface(this->Config, this->Target)) + entry.Target->GetLinkInterface(this->Config, this->Target->Target)) { // Follow public and private dependencies transitively. this->FollowSharedDeps(index, iface, true); @@ -552,7 +553,7 @@ void cmComputeLinkDepends::AddDirectLinkEntries() { // Add direct link dependencies in this configuration. cmTarget::LinkImplementation const* impl = - this->Target->GetLinkImplementation(this->Config); + this->Target->Target->GetLinkImplementation(this->Config); this->AddLinkEntries(-1, impl->Libraries); for(std::vector::const_iterator wi = impl->WrongConfigLibraries.begin(); @@ -634,7 +635,7 @@ cmTarget const* cmComputeLinkDepends::FindTargetToLink(int depender_index, const std::string& name) { // Look for a target in the scope of the depender. - cmTarget const* from = this->Target; + cmTarget const* from = this->Target->Target; if(depender_index >= 0) { if(cmTarget const* depender = this->EntryList[depender_index].Target) @@ -932,7 +933,7 @@ int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl) if(cmTarget const* target = this->EntryList[*ni].Target) { if(cmTarget::LinkInterface const* iface = - target->GetLinkInterface(this->Config, this->Target)) + target->GetLinkInterface(this->Config, this->Target->Target)) { if(iface->Multiplicity > count) { diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index 51a08c5..b925a4f 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -22,6 +22,7 @@ class cmComputeComponentGraph; class cmGlobalGenerator; class cmMakefile; +class cmGeneratorTarget; class cmTarget; class cmake; @@ -31,7 +32,8 @@ class cmake; class cmComputeLinkDepends { public: - cmComputeLinkDepends(cmTarget const* target, const std::string& config); + cmComputeLinkDepends(cmGeneratorTarget const* target, + const std::string& config); ~cmComputeLinkDepends(); // Basic information about each link item. @@ -57,7 +59,7 @@ public: private: // Context information. - cmTarget const* Target; + cmGeneratorTarget const* Target; cmMakefile* Makefile; cmGlobalGenerator const* GlobalGenerator; cmake* CMakeInstance; diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index fb89319..5cd0d54 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -497,7 +497,7 @@ bool cmComputeLinkInformation::Compute() } // Compute the ordered link line items. - cmComputeLinkDepends cld(this->Target->Target, this->Config); + cmComputeLinkDepends cld(this->Target, this->Config); cld.SetOldLinkDirMode(this->OldLinkDirMode); cmComputeLinkDepends::EntryVector const& linkEntries = cld.Compute(); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ac39bd910e3e2f606b722e2495373a58efedde59 commit ac39bd910e3e2f606b722e2495373a58efedde59 Author: Stephen Kelly AuthorDate: Thu Jul 30 00:41:27 2015 +0200 Commit: Brad King CommitDate: Mon Aug 3 16:39:43 2015 -0400 cmComputeLinkInformation: Port to cmGeneratorTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index f03c04a..fb89319 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -242,11 +242,12 @@ because this need be done only for shared libraries without soname-s. //---------------------------------------------------------------------------- cmComputeLinkInformation -::cmComputeLinkInformation(cmTarget const* target, const std::string& config) +::cmComputeLinkInformation(const cmGeneratorTarget* target, + const std::string& config) { // Store context information. this->Target = target; - this->Makefile = this->Target->GetMakefile(); + this->Makefile = this->Target->Target->GetMakefile(); this->GlobalGenerator = this->Makefile->GetGlobalGenerator(); this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance(); @@ -259,17 +260,15 @@ cmComputeLinkInformation // Allocate internals. this->OrderLinkerSearchPath = - new cmOrderDirectories(this->GlobalGenerator, target, + new cmOrderDirectories(this->GlobalGenerator, target->Target, "linker search path"); this->OrderRuntimeSearchPath = - new cmOrderDirectories(this->GlobalGenerator, target, + new cmOrderDirectories(this->GlobalGenerator, target->Target, "runtime search path"); this->OrderDependentRPath = 0; - cmGeneratorTarget *gtgt = this->GlobalGenerator - ->GetGeneratorTarget(this->Target); // Get the language used for linking this target. - this->LinkLanguage = gtgt->GetLinkerLanguage(config); + this->LinkLanguage = this->Target->GetLinkerLanguage(config); if(this->LinkLanguage.empty()) { // The Compute method will do nothing, so skip the rest of the @@ -283,14 +282,14 @@ cmComputeLinkInformation // Check whether we should skip dependencies on shared library files. this->LinkDependsNoShared = - this->Target->GetPropertyAsBool("LINK_DEPENDS_NO_SHARED"); + this->Target->Target->GetPropertyAsBool("LINK_DEPENDS_NO_SHARED"); // On platforms without import libraries there may be a special flag // to use when creating a plugin (module) that obtains symbols from // the program that will load it. this->LoaderFlag = 0; if(!this->UseImportLibrary && - this->Target->GetType() == cmTarget::MODULE_LIBRARY) + this->Target->Target->GetType() == cmTarget::MODULE_LIBRARY) { std::string loader_flag_var = "CMAKE_SHARED_MODULE_LOADER_"; loader_flag_var += this->LinkLanguage; @@ -308,10 +307,10 @@ cmComputeLinkInformation // Get options needed to specify RPATHs. this->RuntimeUseChrpath = false; - if(this->Target->GetType() != cmTarget::STATIC_LIBRARY) + if(this->Target->Target->GetType() != cmTarget::STATIC_LIBRARY) { const char* tType = - ((this->Target->GetType() == cmTarget::EXECUTABLE)? + ((this->Target->Target->GetType() == cmTarget::EXECUTABLE)? "EXECUTABLE" : "SHARED_LIBRARY"); std::string rtVar = "CMAKE_"; rtVar += tType; @@ -325,7 +324,7 @@ cmComputeLinkInformation (this->Makefile-> GetSafeDefinition("CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH")); - this->RuntimeUseChrpath = gtgt->IsChrpathUsed(config); + this->RuntimeUseChrpath = this->Target->IsChrpathUsed(config); // Get options needed to help find dependent libraries. std::string rlVar = "CMAKE_"; @@ -371,15 +370,15 @@ cmComputeLinkInformation { this->SharedDependencyMode = SharedDepModeDir; this->OrderDependentRPath = - new cmOrderDirectories(this->GlobalGenerator, target, + new cmOrderDirectories(this->GlobalGenerator, target->Target, "dependent library path"); } // Add the search path entries requested by the user to path ordering. this->OrderLinkerSearchPath - ->AddUserDirectories(this->Target->GetLinkDirectories()); + ->AddUserDirectories(this->Target->Target->GetLinkDirectories()); this->OrderRuntimeSearchPath - ->AddUserDirectories(this->Target->GetLinkDirectories()); + ->AddUserDirectories(this->Target->Target->GetLinkDirectories()); // Set up the implicit link directories. this->LoadImplicitLinkInfo(); @@ -407,12 +406,13 @@ cmComputeLinkInformation // order to support such projects we need to add the directories // containing libraries linked with a full path to the -L path. this->OldLinkDirMode = - this->Target->GetPolicyStatusCMP0003() != cmPolicies::NEW; + this->Target->Target->GetPolicyStatusCMP0003() != cmPolicies::NEW; if(this->OldLinkDirMode) { // Construct a mask to not bother with this behavior for link // directories already specified by the user. - std::vector const& dirs = this->Target->GetLinkDirectories(); + std::vector const& dirs = + this->Target->Target->GetLinkDirectories(); this->OldLinkDirMask.insert(dirs.begin(), dirs.end()); } @@ -497,7 +497,7 @@ bool cmComputeLinkInformation::Compute() } // Compute the ordered link line items. - cmComputeLinkDepends cld(this->Target, this->Config); + cmComputeLinkDepends cld(this->Target->Target, this->Config); cld.SetOldLinkDirMode(this->OldLinkDirMode); cmComputeLinkDepends::EntryVector const& linkEntries = cld.Compute(); @@ -518,7 +518,8 @@ bool cmComputeLinkInformation::Compute() // Restore the target link type so the correct system runtime // libraries are found. - const char* lss = this->Target->GetProperty("LINK_SEARCH_END_STATIC"); + const char* lss = + this->Target->Target->GetProperty("LINK_SEARCH_END_STATIC"); if(cmSystemTools::IsOn(lss)) { this->SetCurrentLinkType(LinkStatic); @@ -571,7 +572,7 @@ bool cmComputeLinkInformation::Compute() "name." ; this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); } return true; @@ -580,12 +581,9 @@ bool cmComputeLinkInformation::Compute() //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddImplicitLinkInfo() { - cmGeneratorTarget *gtgt = this->Target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(this->Target); - // The link closure lists all languages whose implicit info is needed. - cmGeneratorTarget::LinkClosure const* lc=gtgt->GetLinkClosure(this->Config); + cmGeneratorTarget::LinkClosure const* lc = + this->Target->GetLinkClosure(this->Config); for(std::vector::const_iterator li = lc->Languages.begin(); li != lc->Languages.end(); ++li) { @@ -863,7 +861,8 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo() } // Lookup the starting link type from the target (linked statically?). - const char* lss = this->Target->GetProperty("LINK_SEARCH_START_STATIC"); + const char* lss = + this->Target->Target->GetProperty("LINK_SEARCH_START_STATIC"); this->StartLinkType = cmSystemTools::IsOn(lss)? LinkStatic : LinkShared; this->CurrentLinkType = this->StartLinkType; } @@ -1149,7 +1148,7 @@ void cmComputeLinkInformation::AddFullItem(std::string const& item) // Full path libraries should specify a valid library file name. // See documentation of CMP0008. std::string generator = this->GlobalGenerator->GetName(); - if(this->Target->GetPolicyStatusCMP0008() != cmPolicies::NEW && + if(this->Target->Target->GetPolicyStatusCMP0008() != cmPolicies::NEW && (generator.find("Visual Studio") != generator.npos || generator.find("Xcode") != generator.npos)) { @@ -1230,7 +1229,7 @@ bool cmComputeLinkInformation::CheckImplicitDirItem(std::string const& item) } // Check the policy for whether we should use the approach below. - switch (this->Target->GetPolicyStatusCMP0060()) + switch (this->Target->Target->GetPolicyStatusCMP0060()) { case cmPolicies::WARN: if (this->CMP0060Warn) @@ -1540,7 +1539,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item, this->OrderLinkerSearchPath->AddLinkLibrary(item); // Produce any needed message. - switch(this->Target->GetPolicyStatusCMP0008()) + switch(this->Target->Target->GetPolicyStatusCMP0008()) { case cmPolicies::WARN: { @@ -1557,7 +1556,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item, << " " << item << "\n" << "which is a full-path but not a valid library file name."; this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); } } case cmPolicies::OLD: @@ -1575,7 +1574,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item, << " " << item << "\n" << "which is a full-path but not a valid library file name."; this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); } break; } @@ -1592,7 +1591,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories() } // Enforce policy constraints. - switch(this->Target->GetPolicyStatusCMP0003()) + switch(this->Target->Target->GetPolicyStatusCMP0003()) { case cmPolicies::WARN: if(!this->CMakeInstance->GetState() @@ -1603,7 +1602,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories() std::ostringstream w; this->PrintLinkPolicyDiagnosis(w); this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); } case cmPolicies::OLD: // OLD behavior is to add the paths containing libraries with @@ -1619,7 +1618,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories() e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0003) << "\n"; this->PrintLinkPolicyDiagnosis(e); this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); return false; } } @@ -1923,23 +1922,24 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, // build tree. bool linking_for_install = (for_install || - this->Target->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")); + this->Target->Target->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")); bool use_install_rpath = - (outputRuntime && this->Target->HaveInstallTreeRPATH() && + (outputRuntime && this->Target->Target->HaveInstallTreeRPATH() && linking_for_install); bool use_build_rpath = - (outputRuntime && this->Target->HaveBuildTreeRPATH(this->Config) && + (outputRuntime && this->Target->Target->HaveBuildTreeRPATH(this->Config) && !linking_for_install); bool use_link_rpath = outputRuntime && linking_for_install && !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH") && - this->Target->GetPropertyAsBool("INSTALL_RPATH_USE_LINK_PATH"); + this->Target->Target->GetPropertyAsBool("INSTALL_RPATH_USE_LINK_PATH"); // Construct the RPATH. std::set emitted; if(use_install_rpath) { - const char* install_rpath = this->Target->GetProperty("INSTALL_RPATH"); + const char* install_rpath = + this->Target->Target->GetProperty("INSTALL_RPATH"); cmCLI_ExpandListUnique(install_rpath, runtimeDirs, emitted); } if(use_build_rpath || use_link_rpath) @@ -2011,12 +2011,8 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, // Add runtime paths required by the languages to always be // present. This is done even when skipping rpath support. { - cmGeneratorTarget *gtgt = this->Makefile - ->GetGlobalGenerator() - ->GetGeneratorTarget(this->Target); - cmGeneratorTarget::LinkClosure const* lc = - gtgt->GetLinkClosure(this->Config); + this->Target->GetLinkClosure(this->Config); for(std::vector::const_iterator li = lc->Languages.begin(); li != lc->Languages.end(); ++li) { diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index 2d7a5a5..8b83574 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -29,7 +29,8 @@ class cmOrderDirectories; class cmComputeLinkInformation { public: - cmComputeLinkInformation(cmTarget const* target, const std::string& config); + cmComputeLinkInformation(cmGeneratorTarget const* target, + const std::string& config); ~cmComputeLinkInformation(); bool Compute(); @@ -73,7 +74,7 @@ private: std::set SharedLibrariesLinked; // Context information. - cmTarget const* Target; + cmGeneratorTarget const* Target; cmMakefile* Makefile; cmGlobalGenerator* GlobalGenerator; cmake* CMakeInstance; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c68c2b9..55e2922 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3166,7 +3166,7 @@ cmGeneratorTarget::GetLinkInformation(const std::string& config) const { // Compute information for this configuration. cmComputeLinkInformation* info = - new cmComputeLinkInformation(this->Target, config); + new cmComputeLinkInformation(this, config); if(!info || !info->Compute()) { delete info; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=44288bd6da0141a91e7afb3cfd3664f8b4c6084c commit 44288bd6da0141a91e7afb3cfd3664f8b4c6084c Author: Stephen Kelly AuthorDate: Tue Jul 28 23:16:43 2015 +0200 Commit: Brad King CommitDate: Mon Aug 3 16:39:42 2015 -0400 cmGeneratorTarget: Move IsBundleOnApple from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c314372..c68c2b9 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -910,6 +910,14 @@ cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, } //---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsBundleOnApple() const +{ + return this->Target->IsFrameworkOnApple() + || this->Target->IsAppBundleOnApple() + || this->Target->IsCFBundleOnApple(); +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config, bool contentOnly) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index a1193a6..21e0900 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -119,6 +119,10 @@ public: std::string GetAppBundleDirectory(const std::string& config, bool contentOnly) const; + /** Return whether this target is an executable Bundle, a framework + or CFBundle on Apple. */ + bool IsBundleOnApple() const; + /** Get the full name of the target according to the settings in its makefile. */ std::string GetFullName(const std::string& config="", diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index d38cf4c..0b3df90 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -313,7 +313,7 @@ cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator() (cmSourceFile const& source, const char* pkgloc) { // Skip OS X content when not building a Framework or Bundle. - if(!this->Generator->GetTarget()->IsBundleOnApple()) + if(!this->Generator->GetGeneratorTarget()->IsBundleOnApple()) { return; } diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 16e1f48..07efa16 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -742,7 +742,7 @@ cmNinjaTargetGenerator::MacOSXContentGeneratorType::operator()( cmSourceFile const& source, const char* pkgloc) { // Skip OS X content when not building a Framework or Bundle. - if(!this->Generator->GetTarget()->IsBundleOnApple()) + if(!this->Generator->GetGeneratorTarget()->IsBundleOnApple()) { return; } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 62aa12a..e887ef3 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -590,13 +590,6 @@ bool cmTarget::IsXCTestOnApple() const } //---------------------------------------------------------------------------- -bool cmTarget::IsBundleOnApple() const -{ - return this->IsFrameworkOnApple() || this->IsAppBundleOnApple() || - this->IsCFBundleOnApple(); -} - -//---------------------------------------------------------------------------- static bool processSources(cmTarget const* tgt, const std::vector &entries, std::vector &srcs, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 9a4915f..e53afff 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -424,10 +424,6 @@ public: /** Return whether this target is an executable Bundle on Apple. */ bool IsAppBundleOnApple() const; - /** Return whether this target is an executable Bundle, a framework - or CFBundle on Apple. */ - bool IsBundleOnApple() const; - /** Return the framework version string. Undefined if IsFrameworkOnApple returns false. */ std::string GetFrameworkVersion() const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=90016ac72a2151ac28ad5ae6baa38b65a11a38ff commit 90016ac72a2151ac28ad5ae6baa38b65a11a38ff Author: Stephen Kelly AuthorDate: Tue Jul 28 23:18:55 2015 +0200 Commit: Brad King CommitDate: Mon Aug 3 16:39:40 2015 -0400 cmMakefileTargetGenerator: Add accessor for GeneratorTarget. diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index b885672..fd4527b 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -53,6 +53,7 @@ public: { return this->ProgressFileNameFull; } cmTarget* GetTarget() { return this->Target;} + cmGeneratorTarget* GetGeneratorTarget() { return this->GeneratorTarget;} protected: http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=15556c7db7df7f59f1010ea3f86ccb35f36b10e0 commit 15556c7db7df7f59f1010ea3f86ccb35f36b10e0 Author: Stephen Kelly AuthorDate: Wed Oct 10 21:43:28 2012 +0200 Commit: Brad King CommitDate: Mon Aug 3 16:39:38 2015 -0400 cmGeneratorTarget: Move GetLinkClosure from cmTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 640e806..f03c04a 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -19,6 +19,7 @@ #include "cmOutputConverter.h" #include "cmMakefile.h" #include "cmTarget.h" +#include "cmGeneratorTarget.h" #include "cmake.h" #include "cmAlgorithms.h" @@ -579,8 +580,12 @@ bool cmComputeLinkInformation::Compute() //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddImplicitLinkInfo() { + cmGeneratorTarget *gtgt = this->Target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(this->Target); + // The link closure lists all languages whose implicit info is needed. - cmTarget::LinkClosure const* lc=this->Target->GetLinkClosure(this->Config); + cmGeneratorTarget::LinkClosure const* lc=gtgt->GetLinkClosure(this->Config); for(std::vector::const_iterator li = lc->Languages.begin(); li != lc->Languages.end(); ++li) { @@ -2006,8 +2011,12 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, // Add runtime paths required by the languages to always be // present. This is done even when skipping rpath support. { - cmTarget::LinkClosure const* lc = - this->Target->GetLinkClosure(this->Config); + cmGeneratorTarget *gtgt = this->Makefile + ->GetGlobalGenerator() + ->GetGeneratorTarget(this->Target); + + cmGeneratorTarget::LinkClosure const* lc = + gtgt->GetLinkClosure(this->Config); for(std::vector::const_iterator li = lc->Languages.begin(); li != lc->Languages.end(); ++li) { diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index 3afbb92..2d7a5a5 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -20,6 +20,7 @@ class cmake; class cmGlobalGenerator; class cmMakefile; class cmTarget; +class cmGeneratorTarget; class cmOrderDirectories; /** \class cmComputeLinkInformation diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 4de5e9c..c314372 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -27,6 +27,13 @@ #include #include "assert.h" +#if defined(CMAKE_BUILD_WITH_CMAKE) +#include +#define UNORDERED_SET cmsys::hash_set +#else +#define UNORDERED_SET std::set +#endif + //---------------------------------------------------------------------------- void reportBadObjLib(std::vector const& badObjLib, cmTarget *target, cmake *cm) @@ -1026,6 +1033,223 @@ std::string cmGeneratorTarget::GetInstallNameDirForInstallTree() const } //---------------------------------------------------------------------------- +class cmTargetCollectLinkLanguages +{ +public: + cmTargetCollectLinkLanguages(cmGeneratorTarget const* target, + const std::string& config, + UNORDERED_SET& languages, + cmTarget const* head): + Config(config), Languages(languages), HeadTarget(head), + Makefile(target->Target->GetMakefile()), Target(target) + { this->Visited.insert(target->Target); } + + void Visit(cmLinkItem const& item) + { + if(!item.Target) + { + if(item.find("::") != std::string::npos) + { + bool noMessage = false; + cmake::MessageType messageType = cmake::FATAL_ERROR; + std::stringstream e; + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0028)) + { + case cmPolicies::WARN: + { + e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0028) << "\n"; + messageType = cmake::AUTHOR_WARNING; + } + break; + case cmPolicies::OLD: + noMessage = true; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::NEW: + // Issue the fatal message. + break; + } + + if(!noMessage) + { + e << "Target \"" << this->Target->GetName() + << "\" links to target \"" << item + << "\" but the target was not found. Perhaps a find_package() " + "call is missing for an IMPORTED target, or an ALIAS target is " + "missing?"; + this->Makefile->GetCMakeInstance()->IssueMessage( + messageType, e.str(), this->Target->Target->GetBacktrace()); + } + } + return; + } + if(!this->Visited.insert(item.Target).second) + { + return; + } + + cmTarget::LinkInterface const* iface = + item.Target->GetLinkInterface(this->Config, this->HeadTarget); + if(!iface) { return; } + + for(std::vector::const_iterator + li = iface->Languages.begin(); li != iface->Languages.end(); ++li) + { + this->Languages.insert(*li); + } + + for(std::vector::const_iterator + li = iface->Libraries.begin(); li != iface->Libraries.end(); ++li) + { + this->Visit(*li); + } + } +private: + std::string Config; + UNORDERED_SET& Languages; + cmTarget const* HeadTarget; + cmMakefile* Makefile; + const cmGeneratorTarget* Target; + std::set Visited; +}; + +//---------------------------------------------------------------------------- +cmGeneratorTarget::LinkClosure const* +cmGeneratorTarget::GetLinkClosure(const std::string& config) const +{ + std::string key(cmSystemTools::UpperCase(config)); + LinkClosureMapType::iterator + i = this->LinkClosureMap.find(key); + if(i == this->LinkClosureMap.end()) + { + LinkClosure lc; + this->ComputeLinkClosure(config, lc); + LinkClosureMapType::value_type entry(key, lc); + i = this->LinkClosureMap.insert(entry).first; + } + return &i->second; +} + +//---------------------------------------------------------------------------- +class cmTargetSelectLinker +{ + int Preference; + cmGeneratorTarget const* Target; + cmMakefile* Makefile; + cmGlobalGenerator* GG; + std::set Preferred; +public: + cmTargetSelectLinker(cmGeneratorTarget const* target) + : Preference(0), Target(target) + { + this->Makefile = this->Target->Makefile; + this->GG = this->Makefile->GetGlobalGenerator(); + } + void Consider(const char* lang) + { + int preference = this->GG->GetLinkerPreference(lang); + if(preference > this->Preference) + { + this->Preference = preference; + this->Preferred.clear(); + } + if(preference == this->Preference) + { + this->Preferred.insert(lang); + } + } + std::string Choose() + { + if(this->Preferred.empty()) + { + return ""; + } + else if(this->Preferred.size() > 1) + { + std::stringstream e; + e << "Target " << this->Target->GetName() + << " contains multiple languages with the highest linker preference" + << " (" << this->Preference << "):\n"; + for(std::set::const_iterator + li = this->Preferred.begin(); li != this->Preferred.end(); ++li) + { + e << " " << *li << "\n"; + } + e << "Set the LINKER_LANGUAGE property for this target."; + cmake* cm = this->Makefile->GetCMakeInstance(); + cm->IssueMessage(cmake::FATAL_ERROR, e.str(), + this->Target->Target->GetBacktrace()); + } + return *this->Preferred.begin(); + } +}; + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::ComputeLinkClosure(const std::string& config, + LinkClosure& lc) const +{ + // Get languages built in this target. + UNORDERED_SET languages; + cmTarget::LinkImplementation const* impl = + this->Target->GetLinkImplementation(config); + for(std::vector::const_iterator li = impl->Languages.begin(); + li != impl->Languages.end(); ++li) + { + languages.insert(*li); + } + + // Add interface languages from linked targets. + cmTargetCollectLinkLanguages cll(this, config, languages, this->Target); + for(std::vector::const_iterator li = impl->Libraries.begin(); + li != impl->Libraries.end(); ++li) + { + cll.Visit(*li); + } + + // Store the transitive closure of languages. + for(UNORDERED_SET::const_iterator li = languages.begin(); + li != languages.end(); ++li) + { + lc.Languages.push_back(*li); + } + + // Choose the language whose linker should be used. + if(this->GetProperty("HAS_CXX")) + { + lc.LinkerLanguage = "CXX"; + } + else if(const char* linkerLang = this->GetProperty("LINKER_LANGUAGE")) + { + lc.LinkerLanguage = linkerLang; + } + else + { + // Find the language with the highest preference value. + cmTargetSelectLinker tsl(this); + + // First select from the languages compiled directly in this target. + for(std::vector::const_iterator li = impl->Languages.begin(); + li != impl->Languages.end(); ++li) + { + tsl.Consider(li->c_str()); + } + + // Now consider languages that propagate from linked targets. + for(UNORDERED_SET::const_iterator sit = languages.begin(); + sit != languages.end(); ++sit) + { + std::string propagates = "CMAKE_"+*sit+"_LINKER_PREFERENCE_PROPAGATES"; + if(this->Makefile->IsOn(propagates)) + { + tsl.Consider(sit->c_str()); + } + } + + lc.LinkerLanguage = tsl.Choose(); + } +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, std::string& base, std::string& suffix, @@ -2058,7 +2282,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, std::string cmGeneratorTarget::GetLinkerLanguage(const std::string& config) const { - return this->Target->GetLinkClosure(config)->LinkerLanguage; + return this->GetLinkClosure(config)->LinkerLanguage; } //---------------------------------------------------------------------------- diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 41fb848..a1193a6 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -165,6 +165,20 @@ public: std::string GetModuleDefinitionFile(const std::string& config) const; + /** Link information from the transitive closure of the link + implementation and the interfaces of its dependencies. */ + struct LinkClosure + { + // The preferred linker language. + std::string LinkerLanguage; + + // Languages whose runtime libraries must be linked. + std::vector Languages; + }; + + LinkClosure const* GetLinkClosure(const std::string& config) const; + void ComputeLinkClosure(const std::string& config, LinkClosure& lc) const; + /** Full path with trailing slash to the top-level directory holding object files for this target. Includes the build time config name placeholder if needed for the generator. */ @@ -301,6 +315,9 @@ private: std::string& outPrefix, std::string& outBase, std::string& outSuffix) const; + typedef std::map LinkClosureMapType; + mutable LinkClosureMapType LinkClosureMap; + struct CompatibleInterfacesBase { std::set PropsBool; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index c7118dc..62aa12a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -160,9 +160,6 @@ public: HeadToLinkImplementationMap> LinkImplMapType; LinkImplMapType LinkImplMap; - typedef std::map LinkClosureMapType; - LinkClosureMapType LinkClosureMap; - typedef std::map > SourceFilesMapType; SourceFilesMapType SourceFilesMap; @@ -511,7 +508,6 @@ void cmTarget::ClearLinkMaps() this->Internal->LinkImplMap.clear(); this->Internal->LinkInterfaceMap.clear(); this->Internal->LinkInterfaceUsageRequirementsOnlyMap.clear(); - this->Internal->LinkClosureMap.clear(); this->Internal->SourceFilesMap.clear(); } @@ -3136,223 +3132,6 @@ bool cmTarget::GetPropertyAsBool(const std::string& prop) const } //---------------------------------------------------------------------------- -class cmTargetCollectLinkLanguages -{ -public: - cmTargetCollectLinkLanguages(cmTarget const* target, - const std::string& config, - UNORDERED_SET& languages, - cmTarget const* head): - Config(config), Languages(languages), HeadTarget(head), - Makefile(target->GetMakefile()), Target(target) - { this->Visited.insert(target); } - - void Visit(cmLinkItem const& item) - { - if(!item.Target) - { - if(item.find("::") != std::string::npos) - { - bool noMessage = false; - cmake::MessageType messageType = cmake::FATAL_ERROR; - std::ostringstream e; - switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0028)) - { - case cmPolicies::WARN: - { - e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0028) << "\n"; - messageType = cmake::AUTHOR_WARNING; - } - break; - case cmPolicies::OLD: - noMessage = true; - case cmPolicies::REQUIRED_IF_USED: - case cmPolicies::REQUIRED_ALWAYS: - case cmPolicies::NEW: - // Issue the fatal message. - break; - } - - if(!noMessage) - { - e << "Target \"" << this->Target->GetName() - << "\" links to target \"" << item - << "\" but the target was not found. Perhaps a find_package() " - "call is missing for an IMPORTED target, or an ALIAS target is " - "missing?"; - this->Makefile->GetCMakeInstance()->IssueMessage(messageType, - e.str(), - this->Target->GetBacktrace()); - } - } - return; - } - if(!this->Visited.insert(item.Target).second) - { - return; - } - - cmTarget::LinkInterface const* iface = - item.Target->GetLinkInterface(this->Config, this->HeadTarget); - if(!iface) { return; } - - for(std::vector::const_iterator - li = iface->Languages.begin(); li != iface->Languages.end(); ++li) - { - this->Languages.insert(*li); - } - - for(std::vector::const_iterator - li = iface->Libraries.begin(); li != iface->Libraries.end(); ++li) - { - this->Visit(*li); - } - } -private: - std::string Config; - UNORDERED_SET& Languages; - cmTarget const* HeadTarget; - cmMakefile* Makefile; - const cmTarget* Target; - std::set Visited; -}; - -//---------------------------------------------------------------------------- -cmTarget::LinkClosure const* -cmTarget::GetLinkClosure(const std::string& config) const -{ - std::string key(cmSystemTools::UpperCase(config)); - cmTargetInternals::LinkClosureMapType::iterator - i = this->Internal->LinkClosureMap.find(key); - if(i == this->Internal->LinkClosureMap.end()) - { - LinkClosure lc; - this->ComputeLinkClosure(config, lc); - cmTargetInternals::LinkClosureMapType::value_type entry(key, lc); - i = this->Internal->LinkClosureMap.insert(entry).first; - } - return &i->second; -} - -//---------------------------------------------------------------------------- -class cmTargetSelectLinker -{ - int Preference; - cmTarget const* Target; - cmMakefile* Makefile; - cmGlobalGenerator* GG; - UNORDERED_SET Preferred; -public: - cmTargetSelectLinker(cmTarget const* target): Preference(0), Target(target) - { - this->Makefile = this->Target->GetMakefile(); - this->GG = this->Makefile->GetGlobalGenerator(); - } - void Consider(const std::string& lang) - { - int preference = this->GG->GetLinkerPreference(lang); - if(preference > this->Preference) - { - this->Preference = preference; - this->Preferred.clear(); - } - if(preference == this->Preference) - { - this->Preferred.insert(lang); - } - } - std::string Choose() - { - if(this->Preferred.empty()) - { - return ""; - } - else if(this->Preferred.size() > 1) - { - std::ostringstream e; - e << "Target " << this->Target->GetName() - << " contains multiple languages with the highest linker preference" - << " (" << this->Preference << "):\n"; - for(UNORDERED_SET::const_iterator - li = this->Preferred.begin(); li != this->Preferred.end(); ++li) - { - e << " " << *li << "\n"; - } - e << "Set the LINKER_LANGUAGE property for this target."; - cmake* cm = this->Makefile->GetCMakeInstance(); - cm->IssueMessage(cmake::FATAL_ERROR, e.str(), - this->Target->GetBacktrace()); - } - return *this->Preferred.begin(); - } -}; - -//---------------------------------------------------------------------------- -void cmTarget::ComputeLinkClosure(const std::string& config, - LinkClosure& lc) const -{ - // Get languages built in this target. - UNORDERED_SET languages; - LinkImplementation const* impl = this->GetLinkImplementation(config); - for(std::vector::const_iterator li = impl->Languages.begin(); - li != impl->Languages.end(); ++li) - { - languages.insert(*li); - } - - // Add interface languages from linked targets. - cmTargetCollectLinkLanguages cll(this, config, languages, this); - for(std::vector::const_iterator - li = impl->Libraries.begin(); - li != impl->Libraries.end(); ++li) - { - cll.Visit(*li); - } - - // Store the transitive closure of languages. - for(UNORDERED_SET::const_iterator li = languages.begin(); - li != languages.end(); ++li) - { - lc.Languages.push_back(*li); - } - - // Choose the language whose linker should be used. - if(this->GetProperty("HAS_CXX")) - { - lc.LinkerLanguage = "CXX"; - } - else if(const char* linkerLang = this->GetProperty("LINKER_LANGUAGE")) - { - lc.LinkerLanguage = linkerLang; - } - else - { - // Find the language with the highest preference value. - cmTargetSelectLinker tsl(this); - - // First select from the languages compiled directly in this target. - for(std::vector::const_iterator li = impl->Languages.begin(); - li != impl->Languages.end(); ++li) - { - tsl.Consider(*li); - } - - // Now consider languages that propagate from linked targets. - for(UNORDERED_SET::const_iterator sit = languages.begin(); - sit != languages.end(); ++sit) - { - std::string propagates = "CMAKE_"+*sit+"_LINKER_PREFERENCE_PROPAGATES"; - if(this->Makefile->IsOn(propagates)) - { - tsl.Consider(*sit); - } - } - - lc.LinkerLanguage = tsl.Choose(); - } -} - -//---------------------------------------------------------------------------- void cmTarget::ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index dea9bef..9a4915f 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -315,18 +315,6 @@ public: LinkImplementationLibraries const* GetLinkImplementationLibraries(const std::string& config) const; - /** Link information from the transitive closure of the link - implementation and the interfaces of its dependencies. */ - struct LinkClosure - { - // The preferred linker language. - std::string LinkerLanguage; - - // Languages whose runtime libraries must be linked. - std::vector Languages; - }; - LinkClosure const* GetLinkClosure(const std::string& config) const; - cmTarget const* FindTargetToLink(std::string const& name) const; /** Strip off leading and trailing whitespace from an item named in @@ -662,7 +650,6 @@ private: LinkImplementationLibraries const* GetLinkImplementationLibrariesInternal(const std::string& config, cmTarget const* head) const; - void ComputeLinkClosure(const std::string& config, LinkClosure& lc) const; void ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, cmTarget const* headTarget, http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fe3a255a93ca247460915aeabdb905217355b788 commit fe3a255a93ca247460915aeabdb905217355b788 Author: Stephen Kelly AuthorDate: Sun Nov 3 16:33:25 2013 +0100 Commit: Brad King CommitDate: Mon Aug 3 16:39:36 2015 -0400 cmGeneratorTarget: Move GetLinkerLanguage from cmTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index fee921c..640e806 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -265,8 +265,10 @@ cmComputeLinkInformation "runtime search path"); this->OrderDependentRPath = 0; + cmGeneratorTarget *gtgt = this->GlobalGenerator + ->GetGeneratorTarget(this->Target); // Get the language used for linking this target. - this->LinkLanguage = this->Target->GetLinkerLanguage(config); + this->LinkLanguage = gtgt->GetLinkerLanguage(config); if(this->LinkLanguage.empty()) { // The Compute method will do nothing, so skip the rest of the @@ -322,9 +324,6 @@ cmComputeLinkInformation (this->Makefile-> GetSafeDefinition("CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH")); - cmGeneratorTarget *gtgt = this->Target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(this->Target); this->RuntimeUseChrpath = gtgt->IsChrpathUsed(config); // Get options needed to help find dependent libraries. diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 49fc96b..a86c2bc 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -990,6 +990,9 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode assert(target); + cmGeneratorTarget* gtgt = + context->Makefile->GetGlobalGenerator()->GetGeneratorTarget(target); + if (propertyName == "LINKER_LANGUAGE") { if (target->LinkLanguagePropagatesToDependents() && @@ -1001,7 +1004,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode "link libraries for a static library"); return std::string(); } - return target->GetLinkerLanguage(context->Config); + return gtgt->GetLinkerLanguage(context->Config); } cmGeneratorExpressionDAGChecker dagChecker(context->Backtrace, @@ -1128,9 +1131,6 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode } } - cmGeneratorTarget* gtgt = - context->Makefile->GetGlobalGenerator()->GetGeneratorTarget(target); - if (!prop) { if (target->IsImported() @@ -1600,7 +1600,7 @@ struct TargetFilesystemArtifactResultCreator cmGeneratorExpressionContext *context, const GeneratorExpressionContent *content) { - std::string language = target->Target->GetLinkerLanguage(context->Config); + std::string language = target->GetLinkerLanguage(context->Config); std::string pdbSupportVar = "CMAKE_" + language + "_LINKER_SUPPORTS_PDB"; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 834a2e3..4de5e9c 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -709,8 +709,7 @@ bool cmGeneratorTarget::HasSOName(const std::string& config) const return ((this->GetType() == cmTarget::SHARED_LIBRARY || this->GetType() == cmTarget::MODULE_LIBRARY) && !this->GetPropertyAsBool("NO_SONAME") && - this->Makefile->GetSONameFlag( - this->Target->GetLinkerLanguage(config))); + this->Makefile->GetSONameFlag(this->GetLinkerLanguage(config))); } //---------------------------------------------------------------------------- @@ -752,7 +751,7 @@ cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const } // Check for rpath support on this platform. - std::string ll = this->Target->GetLinkerLanguage(config); + std::string ll = this->GetLinkerLanguage(config); if(!ll.empty()) { std::string flagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; @@ -823,7 +822,7 @@ bool cmGeneratorTarget::IsChrpathUsed(const std::string& config) const #if defined(CMAKE_USE_ELF_PARSER) // Enable if the rpath flag uses a separator and the target uses ELF // binaries. - std::string ll = this->Target->GetLinkerLanguage(config); + std::string ll = this->GetLinkerLanguage(config); if(!ll.empty()) { std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; @@ -1986,7 +1985,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, const char* suffixVar = this->Target->GetSuffixVariableInternal(implib); // Check for language-specific default prefix and suffix. - std::string ll = this->Target->GetLinkerLanguage(config); + std::string ll = this->GetLinkerLanguage(config); if(!ll.empty()) { if(!targetSuffix && suffixVar && *suffixVar) @@ -2056,6 +2055,13 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, //---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetLinkerLanguage(const std::string& config) const +{ + return this->Target->GetLinkClosure(config)->LinkerLanguage; +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetPDBName(const std::string& config) const { std::string prefix; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 7ee4fc5..41fb848 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -258,6 +258,9 @@ public: /** Return true if builtin chrpath will work for this target */ bool IsChrpathUsed(const std::string& config) const; + ///! Return the preferred linker language for this target + std::string GetLinkerLanguage(const std::string& config = "") const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index 2f9265a..1e57c33 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -128,7 +128,8 @@ void cmGhsMultiTargetGenerator::Generate() { config = "RELEASE"; } - const std::string language(this->Target->GetLinkerLanguage(config)); + const std::string language( + this->GeneratorTarget->GetLinkerLanguage(config)); config = cmSystemTools::UpperCase(config); this->DynamicDownload = this->DetermineIfDynamicDownload(config, language); if (this->DynamicDownload) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 7b0e153..5006828 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1376,7 +1376,8 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmTarget& cmtarget) return; } - std::string llang = cmtarget.GetLinkerLanguage("NOCONFIG"); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&cmtarget); + std::string llang = gtgt->GetLinkerLanguage("NOCONFIG"); if(llang.empty()) { return; } // If the language is compiled as a source trust Xcode to link with it. @@ -1824,7 +1825,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, AddCompileOptions(flags, &target, lang, configName); } - std::string llang = target.GetLinkerLanguage(configName); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); + std::string llang = gtgt->GetLinkerLanguage(configName); if(binary && llang.empty()) { cmSystemTools::Error @@ -1850,7 +1852,6 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, // Add the export symbol definition for shared library objects. this->AppendDefines(ppDefs, exportMacro); } - cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); std::vector targetDefines; target.GetCompileDefinitions(targetDefines, configName, "C"); this->AppendDefines(ppDefs, targetDefines); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 3ab501d..4ec77a1 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1353,7 +1353,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, linkFlags += this->Makefile->GetSafeDefinition(build); linkFlags += " "; } - std::string linkLanguage = target->Target->GetLinkerLanguage(buildType); + std::string linkLanguage = target->GetLinkerLanguage(buildType); if(linkLanguage.empty()) { cmSystemTools::Error diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 014d3be..29e1034 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1270,10 +1270,10 @@ void cmLocalVisualStudio6Generator std::vector configs; target.GetMakefile()->GetConfigurations(configs); std::vector::const_iterator it = configs.begin(); - const std::string& linkLanguage = target.GetLinkerLanguage(*it); + const std::string& linkLanguage = gt->GetLinkerLanguage(*it); for ( ; it != configs.end(); ++it) { - const std::string& configLinkLanguage = target.GetLinkerLanguage(*it); + const std::string& configLinkLanguage = gt->GetLinkerLanguage(*it); if (configLinkLanguage != linkLanguage) { cmSystemTools::Error @@ -1703,10 +1703,10 @@ void cmLocalVisualStudio6Generator std::vector configs; target.GetMakefile()->GetConfigurations(configs); std::vector::const_iterator it = configs.begin(); - const std::string& linkLanguage = target.GetLinkerLanguage(*it); + const std::string& linkLanguage = gt->GetLinkerLanguage(*it); for ( ; it != configs.end(); ++it) { - const std::string& configLinkLanguage = target.GetLinkerLanguage(*it); + const std::string& configLinkLanguage = gt->GetLinkerLanguage(*it); if (configLinkLanguage != linkLanguage) { cmSystemTools::Error diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 9f26712..a38a061 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -664,6 +664,10 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, const char* configType = "10"; const char* projectType = 0; bool targetBuilds = true; + + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); + switch(target.GetType()) { case cmTarget::OBJECT_LIBRARY: @@ -696,7 +700,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, { const std::string& linkLanguage = (this->FortranProject? std::string("Fortran"): - target.GetLinkerLanguage(configName)); + gt->GetLinkerLanguage(configName)); if(linkLanguage.empty()) { cmSystemTools::Error @@ -758,8 +762,6 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, targetOptions.Parse(flags.c_str()); targetOptions.Parse(defineFlags.c_str()); targetOptions.ParseFinish(); - cmGeneratorTarget* gt = - this->GlobalGenerator->GetGeneratorTarget(&target); std::vector targetDefines; target.GetCompileDefinitions(targetDefines, configName, "CXX"); targetOptions.AddDefines(targetDefines); @@ -1635,7 +1637,7 @@ cmLocalVisualStudio7GeneratorFCInfo lg->GlobalGenerator->GetLanguageFromExtension (sf.GetExtension().c_str()); const std::string& sourceLang = lg->GetSourceFileLanguage(sf); - const std::string& linkLanguage = target.GetLinkerLanguage(i->c_str()); + const std::string& linkLanguage = gt->GetLinkerLanguage(i->c_str()); bool needForceLang = false; // source file does not match its extension language if(lang != sourceLang) diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 2fd77c9..afe145a 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -161,7 +161,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) // Get the language to use for linking this executable. std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); // Make sure we have a link language. if(linkLanguage.empty()) diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index b85b8a8..bb0f9dd 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -133,7 +133,7 @@ void cmMakefileLibraryTargetGenerator::WriteObjectLibraryRules() void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules() { std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_STATIC_LIBRARY"; @@ -159,7 +159,7 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink) return; } std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_SHARED_LIBRARY"; @@ -183,7 +183,7 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink) void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink) { std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_SHARED_MODULE"; @@ -206,7 +206,7 @@ void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink) void cmMakefileLibraryTargetGenerator::WriteFrameworkRules(bool relink) { std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_MACOSX_FRAMEWORK"; @@ -238,7 +238,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules // Get the language to use for linking this library. std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); // Make sure we have a link language. if(linkLanguage.empty()) diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index b94e151..d38cf4c 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1509,7 +1509,7 @@ std::string cmMakefileTargetGenerator::GetLinkRule( if(this->Target->HasImplibGNUtoMS()) { std::string ruleVar = "CMAKE_"; - ruleVar += this->Target->GetLinkerLanguage(this->ConfigName); + ruleVar += this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); ruleVar += "_GNUtoMS_RULE"; if(const char* rule = this->Makefile->GetDefinition(ruleVar)) { @@ -1663,7 +1663,8 @@ cmMakefileTargetGenerator { // Lookup the response file reference flag. std::string responseFlagVar = "CMAKE_"; - responseFlagVar += this->Target->GetLinkerLanguage(this->ConfigName); + responseFlagVar += this->GeneratorTarget + ->GetLinkerLanguage(this->ConfigName); responseFlagVar += "_RESPONSE_FILE_LINK_FLAG"; const char* responseFlag = this->Makefile->GetDefinition(responseFlagVar); @@ -1707,7 +1708,8 @@ cmMakefileTargetGenerator // Lookup the response file reference flag. std::string responseFlagVar = "CMAKE_"; - responseFlagVar += this->Target->GetLinkerLanguage(this->ConfigName); + responseFlagVar += this->GeneratorTarget + ->GetLinkerLanguage(this->ConfigName); responseFlagVar += "_RESPONSE_FILE_LINK_FLAG"; const char* responseFlag = this->Makefile->GetDefinition(responseFlagVar); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 1835841..b855bea 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -40,8 +40,7 @@ cmNinjaNormalTargetGenerator(cmGeneratorTarget* target) , TargetNamePDB() , TargetLinkLanguage("") { - this->TargetLinkLanguage = target->Target - ->GetLinkerLanguage(this->GetConfigName()); + this->TargetLinkLanguage = target->GetLinkerLanguage(this->GetConfigName()); if (target->GetType() == cmTarget::EXECUTABLE) this->GetGeneratorTarget()->GetExecutableNames(this->TargetNameOut, this->TargetNameReal, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 37b788d..c7118dc 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3218,12 +3218,6 @@ private: }; //---------------------------------------------------------------------------- -std::string cmTarget::GetLinkerLanguage(const std::string& config) const -{ - return this->GetLinkClosure(config)->LinkerLanguage; -} - -//---------------------------------------------------------------------------- cmTarget::LinkClosure const* cmTarget::GetLinkClosure(const std::string& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index d0cbc66..dea9bef 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -365,9 +365,6 @@ public: void GetTargetVersion(bool soversion, int& major, int& minor, int& patch) const; - ///! Return the preferred linker language for this target - std::string GetLinkerLanguage(const std::string& config = "") const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 2b33c2c..80b8591 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1627,7 +1627,7 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( this->GlobalGenerator->GetLanguageFromExtension (sf.GetExtension().c_str()); std::string sourceLang = this->LocalGenerator->GetSourceFileLanguage(sf); - const std::string& linkLanguage = this->Target->GetLinkerLanguage(); + const std::string& linkLanguage = this->GeneratorTarget->GetLinkerLanguage(); bool needForceLang = false; // source file does not match its extension language if(lang != sourceLang) @@ -1888,7 +1888,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( std::string flags; const std::string& linkLanguage = - this->Target->GetLinkerLanguage(configName.c_str()); + this->GeneratorTarget->GetLinkerLanguage(configName.c_str()); if(linkLanguage.empty()) { cmSystemTools::Error @@ -2371,7 +2371,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) Options& linkOptions = *pOptions; const std::string& linkLanguage = - this->Target->GetLinkerLanguage(config.c_str()); + this->GeneratorTarget->GetLinkerLanguage(config.c_str()); if(linkLanguage.empty()) { cmSystemTools::Error http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d5d7ae969c778663d4da0c5f18b5826b128ff7d2 commit d5d7ae969c778663d4da0c5f18b5826b128ff7d2 Author: Stephen Kelly AuthorDate: Tue Oct 9 01:22:42 2012 +0200 Commit: Brad King CommitDate: Mon Aug 3 16:39:34 2015 -0400 cmGeneratorTarget: Move GetFrameworkDirectory from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 436e5dd..834a2e3 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -904,6 +904,48 @@ cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config, + bool contentOnly) const +{ + std::string fpath; + fpath += this->Target->GetOutputName(config, false); + fpath += "."; + const char *ext = this->Target->GetProperty("BUNDLE_EXTENSION"); + if (!ext) + { + if (this->Target->IsXCTestOnApple()) + { + ext = "xctest"; + } + else + { + ext = "bundle"; + } + } + fpath += ext; + fpath += "/Contents"; + if(!contentOnly) + fpath += "/MacOS"; + return fpath; +} + +//---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetFrameworkDirectory(const std::string& config, + bool rootDir) const +{ + std::string fpath; + fpath += this->Target->GetOutputName(config, false); + fpath += ".framework"; + if(!rootDir) + { + fpath += "/Versions/"; + fpath += this->Target->GetFrameworkVersion(); + } + return fpath; +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetFullName(const std::string& config, bool implib) const { @@ -1007,11 +1049,11 @@ cmGeneratorTarget::BuildMacContentDirectory(const std::string& base, } if(this->Target->IsFrameworkOnApple()) { - fpath += this->Target->GetFrameworkDirectory(config, contentOnly); + fpath += this->GetFrameworkDirectory(config, contentOnly); } if(this->Target->IsCFBundleOnApple()) { - fpath += this->Target->GetCFBundleDirectory(config, contentOnly); + fpath += this->GetCFBundleDirectory(config, contentOnly); } return fpath; } @@ -1982,7 +2024,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, if(this->Target->IsCFBundleOnApple()) { - fw_prefix = this->Target->GetCFBundleDirectory(config, false); + fw_prefix = this->GetCFBundleDirectory(config, false); fw_prefix += "/"; targetPrefix = fw_prefix.c_str(); targetSuffix = 0; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 1dfdbb3..7ee4fc5 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -124,6 +124,14 @@ public: std::string GetFullName(const std::string& config="", bool implib = false) const; + /** @return the Mac framework directory without the base. */ + std::string GetFrameworkDirectory(const std::string& config, + bool rootDir) const; + + /** @return the Mac CFBundle directory without the base */ + std::string GetCFBundleDirectory(const std::string& config, + bool contentOnly) const; + /** Return the install name directory for the target in the * build tree. For example: "\@rpath/", "\@loader_path/", * or "/full/path/to/library". */ diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 1d85d9c..4fe99e3 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -77,11 +77,11 @@ void cmOSXBundleGenerator::CreateFramework( // Compute the location of the top-level foo.framework directory. std::string contentdir = outpath + "/" + - this->GT->Target->GetFrameworkDirectory(this->ConfigName, true); + this->GT->GetFrameworkDirectory(this->ConfigName, true); contentdir += "/"; std::string newoutpath = outpath + "/" + - this->GT->Target->GetFrameworkDirectory(this->ConfigName, false); + this->GT->GetFrameworkDirectory(this->ConfigName, false); std::string frameworkVersion = this->GT->Target->GetFrameworkVersion(); @@ -172,14 +172,14 @@ void cmOSXBundleGenerator::CreateCFBundle(const std::string& targetName, // Compute bundle directory names. std::string out = root; out += "/"; - out += this->GT->Target->GetCFBundleDirectory(this->ConfigName, false); + out += this->GT->GetCFBundleDirectory(this->ConfigName, false); cmSystemTools::MakeDirectory(out.c_str()); this->Makefile->AddCMakeOutputFile(out); // Configure the Info.plist file. Note that it needs the executable name // to be set. std::string plist = root + "/" + - this->GT->Target->GetCFBundleDirectory(this->ConfigName, true); + this->GT->GetCFBundleDirectory(this->ConfigName, true); plist += "/Info.plist"; std::string name = cmSystemTools::GetFilenameName(targetName); this->LocalGenerator->GenerateAppleInfoPList(this->GT->Target, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index a5ff829..37b788d 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -5126,47 +5126,6 @@ std::string cmTarget::CheckCMP0004(std::string const& item) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetFrameworkDirectory(const std::string& config, - bool rootDir) const -{ - std::string fpath; - fpath += this->GetOutputName(config, false); - fpath += ".framework"; - if(!rootDir) - { - fpath += "/Versions/"; - fpath += this->GetFrameworkVersion(); - } - return fpath; -} - -//---------------------------------------------------------------------------- -std::string cmTarget::GetCFBundleDirectory(const std::string& config, - bool contentOnly) const -{ - std::string fpath; - fpath += this->GetOutputName(config, false); - fpath += "."; - const char *ext = this->GetProperty("BUNDLE_EXTENSION"); - if (!ext) - { - if (this->IsXCTestOnApple()) - { - ext = "xctest"; - } - else - { - ext = "bundle"; - } - } - fpath += ext; - fpath += "/Contents"; - if(!contentOnly) - fpath += "/MacOS"; - return fpath; -} - -//---------------------------------------------------------------------------- cmTargetInternalPointer::cmTargetInternalPointer() { this->Pointer = new cmTargetInternals; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e22d3af..d0cbc66 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -460,14 +460,6 @@ public: /** @return whether this target have a well defined output file name. */ bool HaveWellDefinedOutputFiles() const; - /** @return the Mac framework directory without the base. */ - std::string GetFrameworkDirectory(const std::string& config, - bool rootDir) const; - - /** @return the Mac CFBundle directory without the base */ - std::string GetCFBundleDirectory(const std::string& config, - bool contentOnly) const; - std::vector GetIncludeDirectories( const std::string& config, const std::string& language) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=53ba657602648ac20b6710c46daa043807dc8c2a commit 53ba657602648ac20b6710c46daa043807dc8c2a Author: Stephen Kelly AuthorDate: Tue Oct 9 01:26:16 2012 +0200 Commit: Brad King CommitDate: Mon Aug 3 16:39:09 2015 -0400 cmGeneratorTarget: Move GetFullName from cmTarget. Bring GetFullNameInternal with it. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 0fdf646..436e5dd 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -576,7 +576,7 @@ const char* cmGeneratorTarget::GetLocationForBuild() const } } location += "/"; - location += this->Target->GetFullName("", false); + location += this->GetFullName("", false); return location.c_str(); } @@ -663,7 +663,7 @@ cmGeneratorTarget::GetCompilePDBName(const std::string& config) const std::string prefix; std::string base; std::string suffix; - this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, false, prefix, base, suffix); // Check for a per-configuration output directory target property. std::string configUpper = cmSystemTools::UpperCase(config); @@ -896,7 +896,7 @@ std::string cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, bool contentOnly) const { - std::string fpath = this->Target->GetFullName(config, false); + std::string fpath = this->GetFullName(config, false); fpath += ".app/Contents"; if(!contentOnly) fpath += "/MacOS"; @@ -905,6 +905,20 @@ cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, //---------------------------------------------------------------------------- std::string +cmGeneratorTarget::GetFullName(const std::string& config, bool implib) const +{ + if(this->Target->IsImported()) + { + return this->Target->GetFullNameImported(config, implib); + } + else + { + return this->GetFullNameInternal(config, implib); + } +} + +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetInstallNameDirForBuildTree( const std::string& config) const { @@ -977,7 +991,7 @@ void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, const std::string& config, bool implib) const { - this->Target->GetFullNameInternal(config, implib, prefix, base, suffix); + this->GetFullNameInternal(config, implib, prefix, base, suffix); } //---------------------------------------------------------------------------- @@ -1655,7 +1669,7 @@ std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config, // Add the full name of the target. if(implib) { - fpath += this->Target->GetFullName(config, true); + fpath += this->GetFullName(config, true); } else if(realname) { @@ -1663,7 +1677,7 @@ std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config, } else { - fpath += this->Target->GetFullName(config, false); + fpath += this->GetFullName(config, false); } return fpath; } @@ -1753,7 +1767,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, std::string prefix; std::string base; std::string suffix; - this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, false, prefix, base, suffix); // The library name. name = prefix+base+suffix; @@ -1782,7 +1796,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, if(this->GetType() == cmTarget::SHARED_LIBRARY || this->GetType() == cmTarget::MODULE_LIBRARY) { - impName = this->Target->GetFullNameInternal(config, true); + impName = this->GetFullNameInternal(config, true); } else { @@ -1828,7 +1842,7 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, std::string prefix; std::string base; std::string suffix; - this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, false, prefix, base, suffix); // The executable name. name = prefix+base+suffix; @@ -1849,19 +1863,163 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, #endif // The import library name. - impName = this->Target->GetFullNameInternal(config, true); + impName = this->GetFullNameInternal(config, true); // The program database file name. pdbName = this->GetPDBName(config); } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetFullNameInternal(const std::string& config, + bool implib) const +{ + std::string prefix; + std::string base; + std::string suffix; + this->GetFullNameInternal(config, implib, prefix, base, suffix); + return prefix+base+suffix; +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GetFullNameInternal(const std::string& config, + bool implib, + std::string& outPrefix, + std::string& outBase, + std::string& outSuffix) const +{ + // Use just the target name for non-main target types. + if(this->GetType() != cmTarget::STATIC_LIBRARY && + this->GetType() != cmTarget::SHARED_LIBRARY && + this->GetType() != cmTarget::MODULE_LIBRARY && + this->GetType() != cmTarget::EXECUTABLE) + { + outPrefix = ""; + outBase = this->GetName(); + outSuffix = ""; + return; + } + + // Return an empty name for the import library if this platform + // does not support import libraries. + if(implib && + !this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) + { + outPrefix = ""; + outBase = ""; + outSuffix = ""; + return; + } + + // The implib option is only allowed for shared libraries, module + // libraries, and executables. + if(this->GetType() != cmTarget::SHARED_LIBRARY && + this->GetType() != cmTarget::MODULE_LIBRARY && + this->GetType() != cmTarget::EXECUTABLE) + { + implib = false; + } + + // Compute the full name for main target types. + const char* targetPrefix = (implib + ? this->GetProperty("IMPORT_PREFIX") + : this->GetProperty("PREFIX")); + const char* targetSuffix = (implib + ? this->GetProperty("IMPORT_SUFFIX") + : this->GetProperty("SUFFIX")); + const char* configPostfix = 0; + if(!config.empty()) + { + std::string configProp = cmSystemTools::UpperCase(config); + configProp += "_POSTFIX"; + configPostfix = this->GetProperty(configProp); + // Mac application bundles and frameworks have no postfix. + if(configPostfix && + (this->Target->IsAppBundleOnApple() + || this->Target->IsFrameworkOnApple())) + { + configPostfix = 0; + } + } + const char* prefixVar = this->Target->GetPrefixVariableInternal(implib); + const char* suffixVar = this->Target->GetSuffixVariableInternal(implib); + + // Check for language-specific default prefix and suffix. + std::string ll = this->Target->GetLinkerLanguage(config); + if(!ll.empty()) + { + if(!targetSuffix && suffixVar && *suffixVar) + { + std::string langSuff = suffixVar + std::string("_") + ll; + targetSuffix = this->Makefile->GetDefinition(langSuff); + } + if(!targetPrefix && prefixVar && *prefixVar) + { + std::string langPrefix = prefixVar + std::string("_") + ll; + targetPrefix = this->Makefile->GetDefinition(langPrefix); + } + } + + // if there is no prefix on the target use the cmake definition + if(!targetPrefix && prefixVar) + { + targetPrefix = this->Makefile->GetSafeDefinition(prefixVar); + } + // if there is no suffix on the target use the cmake definition + if(!targetSuffix && suffixVar) + { + targetSuffix = this->Makefile->GetSafeDefinition(suffixVar); + } + + // frameworks have directory prefix but no suffix + std::string fw_prefix; + if(this->Target->IsFrameworkOnApple()) + { + fw_prefix = this->Target->GetOutputName(config, false); + fw_prefix += ".framework/"; + targetPrefix = fw_prefix.c_str(); + targetSuffix = 0; + } + + if(this->Target->IsCFBundleOnApple()) + { + fw_prefix = this->Target->GetCFBundleDirectory(config, false); + fw_prefix += "/"; + targetPrefix = fw_prefix.c_str(); + targetSuffix = 0; + } + + // Begin the final name with the prefix. + outPrefix = targetPrefix?targetPrefix:""; + + // Append the target name or property-specified name. + outBase += this->Target->GetOutputName(config, implib); + + // Append the per-configuration postfix. + outBase += configPostfix?configPostfix:""; + + // Name shared libraries with their version number on some platforms. + if(const char* soversion = this->GetProperty("SOVERSION")) + { + if(this->GetType() == cmTarget::SHARED_LIBRARY && !implib && + this->Makefile->IsOn("CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION")) + { + outBase += "-"; + outBase += soversion; + } + } + + // Append the suffix. + outSuffix = targetSuffix?targetSuffix:""; +} + + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetPDBName(const std::string& config) const { std::string prefix; std::string base; std::string suffix; - this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, false, prefix, base, suffix); std::vector props; std::string configUpper = diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index f0d8c60..1dfdbb3 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -119,6 +119,11 @@ public: std::string GetAppBundleDirectory(const std::string& config, bool contentOnly) const; + /** Get the full name of the target according to the settings in its + makefile. */ + std::string GetFullName(const std::string& config="", + bool implib = false) const; + /** Return the install name directory for the target in the * build tree. For example: "\@rpath/", "\@loader_path/", * or "/full/path/to/library". */ @@ -279,6 +284,12 @@ private: mutable std::map DebugCompatiblePropertiesDone; + std::string GetFullNameInternal(const std::string& config, + bool implib) const; + void GetFullNameInternal(const std::string& config, bool implib, + std::string& outPrefix, std::string& outBase, + std::string& outSuffix) const; + struct CompatibleInterfacesBase { std::set PropsBool; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index d53ecde..7b0e153 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2742,7 +2742,8 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget, } else { - fullName = cmtarget.GetFullName(defConfig.c_str()); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&cmtarget); + fullName = gtgt->GetFullName(defConfig.c_str()); } fileRef->AddAttribute("path", this->CreateString(fullName.c_str())); fileRef->AddAttribute("refType", this->CreateString("0")); @@ -3688,7 +3689,7 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( std::string universalFile = universal; universalFile += *arch; universalFile += "/"; - universalFile += t->GetFullName(configName); + universalFile += gt->GetFullName(configName); makefileStream << "\t/bin/rm -f " << this->ConvertToRelativeForMake(universalFile.c_str()) diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 61d7847..014d3be 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1115,10 +1115,12 @@ void cmLocalVisualStudio6Generator cmTarget* tgt = this->GlobalGenerator->FindTarget(j->first.c_str()); if(tgt) { + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(tgt); lib = cmSystemTools::GetFilenameWithoutExtension - (tgt->GetFullName().c_str()); + (gt->GetFullName().c_str()); libDebug = cmSystemTools::GetFilenameWithoutExtension - (tgt->GetFullName("Debug").c_str()); + (gt->GetFullName("Debug").c_str()); lib += ".lib"; libDebug += ".lib"; } @@ -1258,8 +1260,8 @@ void cmLocalVisualStudio6Generator extraLinkOptionsRelWithDebInfo += targetLinkFlags; } - - + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); // Get standard libraries for this language. if(targetBuilds) @@ -1328,11 +1330,11 @@ void cmLocalVisualStudio6Generator target.GetType() == cmTarget::SHARED_LIBRARY || target.GetType() == cmTarget::MODULE_LIBRARY) { - outputName = target.GetFullName(); - outputNameDebug = target.GetFullName("Debug"); - outputNameRelease = target.GetFullName("Release"); - outputNameMinSizeRel = target.GetFullName("MinSizeRel"); - outputNameRelWithDebInfo = target.GetFullName("RelWithDebInfo"); + outputName = gt->GetFullName(); + outputNameDebug = gt->GetFullName("Debug"); + outputNameRelease = gt->GetFullName("Release"); + outputNameMinSizeRel = gt->GetFullName("MinSizeRel"); + outputNameRelWithDebInfo = gt->GetFullName("RelWithDebInfo"); } else if(target.GetType() == cmTarget::OBJECT_LIBRARY) { @@ -1429,10 +1431,10 @@ void cmLocalVisualStudio6Generator fullPathImpRelease += "/"; fullPathImpMinSizeRel += "/"; fullPathImpRelWithDebInfo += "/"; - fullPathImpDebug += target.GetFullName("Debug", true); - fullPathImpRelease += target.GetFullName("Release", true); - fullPathImpMinSizeRel += target.GetFullName("MinSizeRel", true); - fullPathImpRelWithDebInfo += target.GetFullName("RelWithDebInfo", true); + fullPathImpDebug += gt->GetFullName("Debug", true); + fullPathImpRelease += gt->GetFullName("Release", true); + fullPathImpMinSizeRel += gt->GetFullName("MinSizeRel", true); + fullPathImpRelWithDebInfo += gt->GetFullName("RelWithDebInfo", true); targetImplibFlagDebug = "/implib:"; targetImplibFlagRelease = "/implib:"; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 799bac6..9f26712 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -803,7 +803,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, if (this->FortranProject) { // Intel Fortran >= 15.0 uses TargetName property. - std::string targetNameFull = target.GetFullName(configName); + std::string targetNameFull = gt->GetFullName(configName); std::string targetName = cmSystemTools::GetFilenameWithoutLastExtension(targetNameFull); std::string targetExt = @@ -1107,7 +1107,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, } case cmTarget::STATIC_LIBRARY: { - std::string targetNameFull = target.GetFullName(configName); + std::string targetNameFull = gt->GetFullName(configName); std::string libpath = target.GetDirectory(configName); libpath += "/"; libpath += targetNameFull; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e8ef770..a5ff829 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3587,20 +3587,6 @@ bool cmTarget::IsImportedSharedLibWithoutSOName( } //---------------------------------------------------------------------------- -std::string cmTarget::GetFullName(const std::string& config, - bool implib) const -{ - if(this->IsImported()) - { - return this->GetFullNameImported(config, implib); - } - else - { - return this->GetFullNameInternal(config, implib); - } -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetFullNameImported(const std::string& config, bool implib) const { @@ -3626,148 +3612,6 @@ cmTarget::ImportedGetFullPath(const std::string& config, bool implib) const } //---------------------------------------------------------------------------- -std::string -cmTarget::GetFullNameInternal(const std::string& config, bool implib) const -{ - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, implib, prefix, base, suffix); - return prefix+base+suffix; -} - -//---------------------------------------------------------------------------- -void cmTarget::GetFullNameInternal(const std::string& config, - bool implib, - std::string& outPrefix, - std::string& outBase, - std::string& outSuffix) const -{ - // Use just the target name for non-main target types. - if(this->GetType() != cmTarget::STATIC_LIBRARY && - this->GetType() != cmTarget::SHARED_LIBRARY && - this->GetType() != cmTarget::MODULE_LIBRARY && - this->GetType() != cmTarget::EXECUTABLE) - { - outPrefix = ""; - outBase = this->GetName(); - outSuffix = ""; - return; - } - - // Return an empty name for the import library if this platform - // does not support import libraries. - if(implib && - !this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) - { - outPrefix = ""; - outBase = ""; - outSuffix = ""; - return; - } - - // The implib option is only allowed for shared libraries, module - // libraries, and executables. - if(this->GetType() != cmTarget::SHARED_LIBRARY && - this->GetType() != cmTarget::MODULE_LIBRARY && - this->GetType() != cmTarget::EXECUTABLE) - { - implib = false; - } - - // Compute the full name for main target types. - const char* targetPrefix = (implib - ? this->GetProperty("IMPORT_PREFIX") - : this->GetProperty("PREFIX")); - const char* targetSuffix = (implib - ? this->GetProperty("IMPORT_SUFFIX") - : this->GetProperty("SUFFIX")); - const char* configPostfix = 0; - if(!config.empty()) - { - std::string configProp = cmSystemTools::UpperCase(config); - configProp += "_POSTFIX"; - configPostfix = this->GetProperty(configProp); - // Mac application bundles and frameworks have no postfix. - if(configPostfix && - (this->IsAppBundleOnApple() || this->IsFrameworkOnApple())) - { - configPostfix = 0; - } - } - const char* prefixVar = this->GetPrefixVariableInternal(implib); - const char* suffixVar = this->GetSuffixVariableInternal(implib); - - // Check for language-specific default prefix and suffix. - std::string ll = this->GetLinkerLanguage(config); - if(!ll.empty()) - { - if(!targetSuffix && suffixVar && *suffixVar) - { - std::string langSuff = suffixVar + std::string("_") + ll; - targetSuffix = this->Makefile->GetDefinition(langSuff); - } - if(!targetPrefix && prefixVar && *prefixVar) - { - std::string langPrefix = prefixVar + std::string("_") + ll; - targetPrefix = this->Makefile->GetDefinition(langPrefix); - } - } - - // if there is no prefix on the target use the cmake definition - if(!targetPrefix && prefixVar) - { - targetPrefix = this->Makefile->GetSafeDefinition(prefixVar); - } - // if there is no suffix on the target use the cmake definition - if(!targetSuffix && suffixVar) - { - targetSuffix = this->Makefile->GetSafeDefinition(suffixVar); - } - - // frameworks have directory prefix but no suffix - std::string fw_prefix; - if(this->IsFrameworkOnApple()) - { - fw_prefix = this->GetOutputName(config, false); - fw_prefix += ".framework/"; - targetPrefix = fw_prefix.c_str(); - targetSuffix = 0; - } - - if(this->IsCFBundleOnApple()) - { - fw_prefix = this->GetCFBundleDirectory(config, false); - fw_prefix += "/"; - targetPrefix = fw_prefix.c_str(); - targetSuffix = 0; - } - - // Begin the final name with the prefix. - outPrefix = targetPrefix?targetPrefix:""; - - // Append the target name or property-specified name. - outBase += this->GetOutputName(config, implib); - - // Append the per-configuration postfix. - outBase += configPostfix?configPostfix:""; - - // Name shared libraries with their version number on some platforms. - if(const char* soversion = this->GetProperty("SOVERSION")) - { - if(this->GetType() == cmTarget::SHARED_LIBRARY && !implib && - this->Makefile->IsOn("CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION")) - { - outBase += "-"; - outBase += soversion; - } - } - - // Append the suffix. - outSuffix = targetSuffix?targetSuffix:""; -} - -//---------------------------------------------------------------------------- void cmTarget::ComputeVersionedName(std::string& vName, std::string const& prefix, std::string const& base, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 4b804da..e22d3af 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -368,11 +368,6 @@ public: ///! Return the preferred linker language for this target std::string GetLinkerLanguage(const std::string& config = "") const; - /** Get the full name of the target according to the settings in its - makefile. */ - std::string GetFullName(const std::string& config="", - bool implib = false) const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; @@ -575,11 +570,6 @@ private: const char* GetSuffixVariableInternal(bool implib) const; const char* GetPrefixVariableInternal(bool implib) const; - std::string GetFullNameInternal(const std::string& config, - bool implib) const; - void GetFullNameInternal(const std::string& config, bool implib, - std::string& outPrefix, std::string& outBase, - std::string& outSuffix) const; // Use a makefile variable to set a default for the given property. // If the variable is not defined use the given default instead. diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 16edf3c..2b33c2c 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1774,7 +1774,7 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions() else { outDir = this->Target->GetDirectory(config->c_str()) + "/"; - targetNameFull = this->Target->GetFullName(config->c_str()); + targetNameFull = this->GeneratorTarget->GetFullName(config->c_str()); } this->ConvertToWindowsSlash(intermediateDir); this->ConvertToWindowsSlash(outDir); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1950f478ffcf738794485180c165dedbc744dbf6 commit 1950f478ffcf738794485180c165dedbc744dbf6 Author: Stephen Kelly AuthorDate: Tue Jul 28 22:44:00 2015 +0200 Commit: Brad King CommitDate: Mon Aug 3 15:58:12 2015 -0400 cmGeneratorTarget: Move GetAppBundleDirectory from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 2de3c77..0fdf646 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -890,6 +890,19 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const } } + +//---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, + bool contentOnly) const +{ + std::string fpath = this->Target->GetFullName(config, false); + fpath += ".app/Contents"; + if(!contentOnly) + fpath += "/MacOS"; + return fpath; +} + //---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetInstallNameDirForBuildTree( @@ -976,7 +989,7 @@ cmGeneratorTarget::BuildMacContentDirectory(const std::string& base, std::string fpath = base; if(this->Target->IsAppBundleOnApple()) { - fpath += this->Target->GetAppBundleDirectory(config, contentOnly); + fpath += this->GetAppBundleDirectory(config, contentOnly); } if(this->Target->IsFrameworkOnApple()) { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 6d084f7..f0d8c60 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -115,6 +115,10 @@ public: bool realname) const; std::string NormalGetRealName(const std::string& config) const; + /** @return the Mac App directory without the base */ + std::string GetAppBundleDirectory(const std::string& config, + bool contentOnly) const; + /** Return the install name directory for the target in the * build tree. For example: "\@rpath/", "\@loader_path/", * or "/full/path/to/library". */ diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 7df2f78..1d85d9c 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -47,7 +47,7 @@ void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName, // Compute bundle directory names. std::string out = outpath; out += "/"; - out += this->GT->Target->GetAppBundleDirectory(this->ConfigName, false); + out += this->GT->GetAppBundleDirectory(this->ConfigName, false); cmSystemTools::MakeDirectory(out.c_str()); this->Makefile->AddCMakeOutputFile(out); @@ -57,7 +57,7 @@ void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName, // to be set. std::string plist = outpath; plist += "/"; - plist += this->GT->Target->GetAppBundleDirectory(this->ConfigName, true); + plist += this->GT->GetAppBundleDirectory(this->ConfigName, true); plist += "/Info.plist"; this->LocalGenerator->GenerateAppleInfoPList(this->GT->Target, targetName, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index b49ad9b..e8ef770 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -5323,17 +5323,6 @@ std::string cmTarget::GetCFBundleDirectory(const std::string& config, } //---------------------------------------------------------------------------- -std::string cmTarget::GetAppBundleDirectory(const std::string& config, - bool contentOnly) const -{ - std::string fpath = this->GetFullName(config, false); - fpath += ".app/Contents"; - if(!contentOnly) - fpath += "/MacOS"; - return fpath; -} - -//---------------------------------------------------------------------------- cmTargetInternalPointer::cmTargetInternalPointer() { this->Pointer = new cmTargetInternals; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index c1c518f..4b804da 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -473,10 +473,6 @@ public: std::string GetCFBundleDirectory(const std::string& config, bool contentOnly) const; - /** @return the Mac App directory without the base */ - std::string GetAppBundleDirectory(const std::string& config, - bool contentOnly) const; - std::vector GetIncludeDirectories( const std::string& config, const std::string& language) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5a827c6ab7ac480fb5c0bd2a5643c22fd0ddabc9 commit 5a827c6ab7ac480fb5c0bd2a5643c22fd0ddabc9 Author: Stephen Kelly AuthorDate: Tue Oct 9 01:20:27 2012 +0200 Commit: Brad King CommitDate: Mon Aug 3 15:55:50 2015 -0400 cmGeneratorTarget: Move GetInstallNameDir* from cmTarget. diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 6274c3f..fed0dbc 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -333,12 +333,12 @@ cmExportBuildFileGenerator } std::string -cmExportBuildFileGenerator::InstallNameDir(cmTarget* target, +cmExportBuildFileGenerator::InstallNameDir(cmGeneratorTarget* target, const std::string& config) { std::string install_name_dir; - cmMakefile* mf = target->GetMakefile(); + cmMakefile* mf = target->Target->GetMakefile(); if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { install_name_dir = diff --git a/Source/cmExportBuildFileGenerator.h b/Source/cmExportBuildFileGenerator.h index 4d8e062..ff3d2e1 100644 --- a/Source/cmExportBuildFileGenerator.h +++ b/Source/cmExportBuildFileGenerator.h @@ -71,7 +71,8 @@ protected: cmGeneratorTarget* target, ImportPropertyMap& properties); - std::string InstallNameDir(cmTarget* target, const std::string& config); + std::string InstallNameDir(cmGeneratorTarget* target, + const std::string& config); std::vector FindNamespaces(cmMakefile* mf, const std::string& name); diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index e3652c5..cae60b7 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -893,7 +893,7 @@ cmExportFileGenerator { if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { - value = this->InstallNameDir(target->Target, config); + value = this->InstallNameDir(target, config); } prop = "IMPORTED_SONAME"; value += target->GetSOName(config); diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index 4e54740..44f779b 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -200,7 +200,7 @@ private: virtual void ReplaceInstallPrefix(std::string &input); - virtual std::string InstallNameDir(cmTarget* target, + virtual std::string InstallNameDir(cmGeneratorTarget* target, const std::string& config) = 0; }; diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index b0bc686..d55be11 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -546,12 +546,12 @@ cmExportInstallFileGenerator } std::string -cmExportInstallFileGenerator::InstallNameDir(cmTarget* target, +cmExportInstallFileGenerator::InstallNameDir(cmGeneratorTarget* target, const std::string&) { std::string install_name_dir; - cmMakefile* mf = target->GetMakefile(); + cmMakefile* mf = target->Target->GetMakefile(); if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { install_name_dir = diff --git a/Source/cmExportInstallFileGenerator.h b/Source/cmExportInstallFileGenerator.h index 6f86ac9..b06fee5 100644 --- a/Source/cmExportInstallFileGenerator.h +++ b/Source/cmExportInstallFileGenerator.h @@ -83,7 +83,8 @@ protected: std::set& importedLocations ); - std::string InstallNameDir(cmTarget* target, const std::string& config); + std::string InstallNameDir(cmGeneratorTarget* target, + const std::string& config); cmInstallExportGenerator* IEGen; diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx index 94831f8..ba66531 100644 --- a/Source/cmExportTryCompileFileGenerator.cxx +++ b/Source/cmExportTryCompileFileGenerator.cxx @@ -125,12 +125,12 @@ cmExportTryCompileFileGenerator::PopulateProperties(cmTarget const* target, } std::string -cmExportTryCompileFileGenerator::InstallNameDir(cmTarget* target, +cmExportTryCompileFileGenerator::InstallNameDir(cmGeneratorTarget* target, const std::string& config) { std::string install_name_dir; - cmMakefile* mf = target->GetMakefile(); + cmMakefile* mf = target->Target->GetMakefile(); if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { install_name_dir = diff --git a/Source/cmExportTryCompileFileGenerator.h b/Source/cmExportTryCompileFileGenerator.h index 749f3ef..8838eca 100644 --- a/Source/cmExportTryCompileFileGenerator.h +++ b/Source/cmExportTryCompileFileGenerator.h @@ -45,7 +45,7 @@ protected: ImportPropertyMap& properties, std::set &emitted); - std::string InstallNameDir(cmTarget* target, + std::string InstallNameDir(cmGeneratorTarget* target, const std::string& config); private: std::string FindTargets(const std::string& prop, cmTarget const* tgt, diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 45577e5..2de3c77 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -891,6 +891,73 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const } //---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetInstallNameDirForBuildTree( + const std::string& config) const +{ + // If building directly for installation then the build tree install_name + // is the same as the install tree. + if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) + { + return this->GetInstallNameDirForInstallTree(); + } + + // Use the build tree directory for the target. + if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME") && + !this->Makefile->IsOn("CMAKE_SKIP_RPATH") && + !this->GetPropertyAsBool("SKIP_BUILD_RPATH")) + { + std::string dir; + if(this->Target->MacOSXRpathInstallNameDirDefault()) + { + dir = "@rpath"; + } + else + { + dir = this->Target->GetDirectory(config); + } + dir += "/"; + return dir; + } + else + { + return ""; + } +} + +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetInstallNameDirForInstallTree() const +{ + if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) + { + std::string dir; + const char* install_name_dir = this->GetProperty("INSTALL_NAME_DIR"); + + if(!this->Makefile->IsOn("CMAKE_SKIP_RPATH") && + !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH")) + { + if(install_name_dir && *install_name_dir) + { + dir = install_name_dir; + dir += "/"; + } + } + if(!install_name_dir) + { + if(this->Target->MacOSXRpathInstallNameDirDefault()) + { + dir = "@rpath/"; + } + } + return dir; + } + else + { + return ""; + } +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, std::string& base, std::string& suffix, diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 8fc1b44..6d084f7 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -115,6 +115,15 @@ public: bool realname) const; std::string NormalGetRealName(const std::string& config) const; + /** Return the install name directory for the target in the + * build tree. For example: "\@rpath/", "\@loader_path/", + * or "/full/path/to/library". */ + std::string GetInstallNameDirForBuildTree(const std::string& config) const; + + /** Return the install name directory for the target in the + * install tree. For example: "\@rpath/" or "\@loader_path/". */ + std::string GetInstallNameDirForInstallTree() const; + /** Get the soname of the target. Allowed only for a shared library. */ std::string GetSOName(const std::string& config) const; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 03f6d8f..d53ecde 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2331,7 +2331,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, if(target.GetType() == cmTarget::SHARED_LIBRARY) { // Get the install_name directory for the build tree. - install_name_dir = target.GetInstallNameDirForBuildTree(configName); + install_name_dir = gtgt->GetInstallNameDirForBuildTree(configName); // Xcode doesn't create the correct install_name in some cases. // That is, if the INSTALL_PATH is empty, or if we have versioning // of dylib libraries, we want to specify the install_name. diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 24c1c49..30cf175 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -576,11 +576,14 @@ cmInstallTargetGenerator continue; } + cmGeneratorTarget *gtgt = tgt->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(tgt); // If the build tree and install tree use different path // components of the install_name field then we need to create a // mapping to be applied after installation. - std::string for_build = tgt->GetInstallNameDirForBuildTree(config); - std::string for_install = tgt->GetInstallNameDirForInstallTree(); + std::string for_build = gtgt->GetInstallNameDirForBuildTree(config); + std::string for_install = gtgt->GetInstallNameDirForInstallTree(); if(for_build != for_install) { // The directory portions differ. Append the filename to @@ -605,9 +608,9 @@ cmInstallTargetGenerator if(this->Target->GetType() == cmTarget::SHARED_LIBRARY) { std::string for_build = - this->Target->Target->GetInstallNameDirForBuildTree(config); + this->Target->GetInstallNameDirForBuildTree(config); std::string for_install = - this->Target->Target->GetInstallNameDirForInstallTree(); + this->Target->GetInstallNameDirForInstallTree(); if(this->Target->Target->IsFrameworkOnApple() && for_install.empty()) { diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index a2fcbad..b85b8a8 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -666,7 +666,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules { // Get the install_name directory for the build tree. install_name_dir = - this->Target->GetInstallNameDirForBuildTree(this->ConfigName); + this->GeneratorTarget->GetInstallNameDirForBuildTree(this->ConfigName); // Set the rule variable replacement value. if(install_name_dir.empty()) diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index c80f485..1835841 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -537,7 +537,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() vars["SONAME"] = this->TargetNameSO; if (targetType == cmTarget::SHARED_LIBRARY) { - std::string install_dir = target.GetInstallNameDirForBuildTree(cfgName); + std::string install_dir = + this->GetGeneratorTarget()->GetInstallNameDirForBuildTree(cfgName); if (!install_dir.empty()) { vars["INSTALLNAME_DIR"] = localGen.Convert(install_dir, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 0f1d309..b49ad9b 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3846,73 +3846,6 @@ bool cmTarget::HaveInstallTreeRPATH() const } //---------------------------------------------------------------------------- -std::string cmTarget::GetInstallNameDirForBuildTree( - const std::string& config) const -{ - // If building directly for installation then the build tree install_name - // is the same as the install tree. - if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) - { - return GetInstallNameDirForInstallTree(); - } - - // Use the build tree directory for the target. - if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME") && - !this->Makefile->IsOn("CMAKE_SKIP_RPATH") && - !this->GetPropertyAsBool("SKIP_BUILD_RPATH")) - { - std::string dir; - bool macosx_rpath = this->MacOSXRpathInstallNameDirDefault(); - if(macosx_rpath) - { - dir = "@rpath"; - } - else - { - dir = this->GetDirectory(config); - } - dir += "/"; - return dir; - } - else - { - return ""; - } -} - -//---------------------------------------------------------------------------- -std::string cmTarget::GetInstallNameDirForInstallTree() const -{ - if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) - { - std::string dir; - const char* install_name_dir = this->GetProperty("INSTALL_NAME_DIR"); - - if(!this->Makefile->IsOn("CMAKE_SKIP_RPATH") && - !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH")) - { - if(install_name_dir && *install_name_dir) - { - dir = install_name_dir; - dir += "/"; - } - } - if(!install_name_dir) - { - if(this->MacOSXRpathInstallNameDirDefault()) - { - dir = "@rpath/"; - } - } - return dir; - } - else - { - return ""; - } -} - -//---------------------------------------------------------------------------- const char* cmTarget::GetOutputTargetType(bool implib) const { switch(this->GetType()) diff --git a/Source/cmTarget.h b/Source/cmTarget.h index d03ba3b..c1c518f 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -394,15 +394,6 @@ public: bool HaveBuildTreeRPATH(const std::string& config) const; bool HaveInstallTreeRPATH() const; - /** Return the install name directory for the target in the - * build tree. For example: "\@rpath/", "\@loader_path/", - * or "/full/path/to/library". */ - std::string GetInstallNameDirForBuildTree(const std::string& config) const; - - /** Return the install name directory for the target in the - * install tree. For example: "\@rpath/" or "\@loader_path/". */ - std::string GetInstallNameDirForInstallTree() const; - // Get the properties cmPropertyMap &GetProperties() const { return this->Properties; } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e69c5efa1d6929522c47c68fab6a245664769e53 commit e69c5efa1d6929522c47c68fab6a245664769e53 Author: Stephen Kelly AuthorDate: Tue Oct 9 01:13:20 2012 +0200 Commit: Brad King CommitDate: Mon Aug 3 15:54:38 2015 -0400 cmGeneratorTarget: Move GetMacContentDirectory from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 4be034f..45577e5 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -567,7 +567,7 @@ const char* cmGeneratorTarget::GetLocationForBuild() const if(this->Target->IsAppBundleOnApple()) { - std::string macdir = this->Target->BuildMacContentDirectory("", "", + std::string macdir = this->BuildMacContentDirectory("", "", false); if(!macdir.empty()) { @@ -902,6 +902,47 @@ void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, //---------------------------------------------------------------------------- std::string +cmGeneratorTarget::BuildMacContentDirectory(const std::string& base, + const std::string& config, + bool contentOnly) const +{ + std::string fpath = base; + if(this->Target->IsAppBundleOnApple()) + { + fpath += this->Target->GetAppBundleDirectory(config, contentOnly); + } + if(this->Target->IsFrameworkOnApple()) + { + fpath += this->Target->GetFrameworkDirectory(config, contentOnly); + } + if(this->Target->IsCFBundleOnApple()) + { + fpath += this->Target->GetCFBundleDirectory(config, contentOnly); + } + return fpath; +} + +//---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetMacContentDirectory(const std::string& config, + bool implib) const +{ + // Start with the output directory for the target. + std::string fpath = this->Target->GetDirectory(config, implib); + fpath += "/"; + bool contentOnly = true; + if(this->Target->IsFrameworkOnApple()) + { + // additional files with a framework go into the version specific + // directory + contentOnly = false; + } + fpath = this->BuildMacContentDirectory(fpath, config, contentOnly); + return fpath; +} + +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetModuleDefinitionFile(const std::string& config) const { std::string data; @@ -1527,7 +1568,7 @@ std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config, fpath += "/"; if(this->Target->IsAppBundleOnApple()) { - fpath = this->Target->BuildMacContentDirectory(fpath, config, false); + fpath = this->BuildMacContentDirectory(fpath, config, false); fpath += "/"; } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index f96adad..8fc1b44 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -123,6 +123,15 @@ public: const std::string& config="", bool implib = false) const; + /** Append to @a base the mac content directory and return it. */ + std::string BuildMacContentDirectory(const std::string& base, + const std::string& config = "", + bool contentOnly = true) const; + + /** @return the mac content directory for this target. */ + std::string GetMacContentDirectory(const std::string& config = 0, + bool implib = false) const; + cmTarget* Target; cmMakefile* Makefile; cmLocalGenerator* LocalGenerator; diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 3bc0eb7..7df2f78 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -217,7 +217,7 @@ cmOSXBundleGenerator::InitMacOSXContentDirectory(const char* pkgloc) // Construct the full path to the content subdirectory. std::string macdir = - this->GT->Target->GetMacContentDirectory(this->ConfigName, + this->GT->GetMacContentDirectory(this->ConfigName, /*implib*/ false); macdir += "/"; macdir += pkgloc; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 0d9aa49..0f1d309 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -5401,45 +5401,6 @@ std::string cmTarget::GetAppBundleDirectory(const std::string& config, } //---------------------------------------------------------------------------- -std::string cmTarget::BuildMacContentDirectory(const std::string& base, - const std::string& config, - bool contentOnly) const -{ - std::string fpath = base; - if(this->IsAppBundleOnApple()) - { - fpath += this->GetAppBundleDirectory(config, contentOnly); - } - if(this->IsFrameworkOnApple()) - { - fpath += this->GetFrameworkDirectory(config, contentOnly); - } - if(this->IsCFBundleOnApple()) - { - fpath += this->GetCFBundleDirectory(config, contentOnly); - } - return fpath; -} - -//---------------------------------------------------------------------------- -std::string cmTarget::GetMacContentDirectory(const std::string& config, - bool implib) const -{ - // Start with the output directory for the target. - std::string fpath = this->GetDirectory(config, implib); - fpath += "/"; - bool contentOnly = true; - if(this->IsFrameworkOnApple()) - { - // additional files with a framework go into the version specific - // directory - contentOnly = false; - } - fpath = this->BuildMacContentDirectory(fpath, config, contentOnly); - return fpath; -} - -//---------------------------------------------------------------------------- cmTargetInternalPointer::cmTargetInternalPointer() { this->Pointer = new cmTargetInternals; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 9962fdb..d03ba3b 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -471,10 +471,6 @@ public: directory. */ bool UsesDefaultOutputDir(const std::string& config, bool implib) const; - /** @return the mac content directory for this target. */ - std::string GetMacContentDirectory(const std::string& config, - bool implib) const; - /** @return whether this target have a well defined output file name. */ bool HaveWellDefinedOutputFiles() const; @@ -615,10 +611,6 @@ private: std::string ImportedGetFullPath(const std::string& config, bool implib) const; - /** Append to @a base the mac content directory and return it. */ - std::string BuildMacContentDirectory(const std::string& base, - const std::string& config, - bool contentOnly) const; void GetSourceFiles(std::vector &files, const std::string& config) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d3a63396fbe3a43857a37edb88e08d00802e9adb commit d3a63396fbe3a43857a37edb88e08d00802e9adb Author: Stephen Kelly AuthorDate: Tue Oct 9 00:40:34 2012 +0200 Commit: Brad King CommitDate: Mon Aug 3 15:53:37 2015 -0400 cmGeneratorTarget: Move GetFullNameComponents from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 6481390..4be034f 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -891,6 +891,16 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const } //---------------------------------------------------------------------------- +void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, + std::string& base, + std::string& suffix, + const std::string& config, + bool implib) const +{ + this->Target->GetFullNameInternal(config, implib, prefix, base, suffix); +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetModuleDefinitionFile(const std::string& config) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 9ecbbbe..f96adad 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -118,6 +118,11 @@ public: /** Get the soname of the target. Allowed only for a shared library. */ std::string GetSOName(const std::string& config) const; + void GetFullNameComponents(std::string& prefix, + std::string& base, std::string& suffix, + const std::string& config="", + bool implib = false) const; + cmTarget* Target; cmMakefile* Makefile; cmLocalGenerator* LocalGenerator; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index d7ae36d..03f6d8f 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1940,7 +1940,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, std::string pnprefix; std::string pnbase; std::string pnsuffix; - target.GetFullNameComponents(pnprefix, pnbase, pnsuffix, configName); + gtgt->GetFullNameComponents(pnprefix, pnbase, pnsuffix, configName); const char* version = target.GetProperty("VERSION"); const char* soversion = target.GetProperty("SOVERSION"); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 2586b31..c80f485 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -569,7 +569,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() std::string prefix; std::string base; std::string suffix; - target.GetFullNameComponents(prefix, base, suffix); + this->GetGeneratorTarget()->GetFullNameComponents(prefix, base, suffix); std::string dbg_suffix = ".dbg"; // TODO: Where to document? if (mf->GetDefinition("CMAKE_DEBUG_SYMBOL_SUFFIX")) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1183fe4..0d9aa49 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3609,15 +3609,6 @@ cmTarget::GetFullNameImported(const std::string& config, bool implib) const } //---------------------------------------------------------------------------- -void cmTarget::GetFullNameComponents(std::string& prefix, std::string& base, - std::string& suffix, - const std::string& config, - bool implib) const -{ - this->GetFullNameInternal(config, implib, prefix, base, suffix); -} - -//---------------------------------------------------------------------------- std::string cmTarget::ImportedGetFullPath(const std::string& config, bool implib) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 1aef7b3..9962fdb 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -372,10 +372,6 @@ public: makefile. */ std::string GetFullName(const std::string& config="", bool implib = false) const; - void GetFullNameComponents(std::string& prefix, - std::string& base, std::string& suffix, - const std::string& config="", - bool implib = false) const; /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=47fd39fe1260259d088704c323e119d075f314af commit 47fd39fe1260259d088704c323e119d075f314af Author: Stephen Kelly AuthorDate: Sun Nov 3 12:26:44 2013 +0100 Commit: Brad King CommitDate: Mon Aug 3 15:52:35 2015 -0400 cmGeneratorTarget: Move IsChrPathUsed from cmTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 5aaa266..fee921c 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -321,7 +321,11 @@ cmComputeLinkInformation this->RuntimeAlways = (this->Makefile-> GetSafeDefinition("CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH")); - this->RuntimeUseChrpath = this->Target->IsChrpathUsed(config); + + cmGeneratorTarget *gtgt = this->Target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(this->Target); + this->RuntimeUseChrpath = gtgt->IsChrpathUsed(config); // Get options needed to help find dependent libraries. std::string rlVar = "CMAKE_"; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 505d01f..6481390 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -746,7 +746,7 @@ cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const } // If chrpath is going to be used no relinking is needed. - if(this->Target->IsChrpathUsed(config)) + if(this->IsChrpathUsed(config)) { return false; } @@ -779,6 +779,73 @@ cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const || this->Target->HaveInstallTreeRPATH(); } +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsChrpathUsed(const std::string& config) const +{ + // Only certain target types have an rpath. + if(!(this->GetType() == cmTarget::SHARED_LIBRARY || + this->GetType() == cmTarget::MODULE_LIBRARY || + this->GetType() == cmTarget::EXECUTABLE)) + { + return false; + } + + // If the target will not be installed we do not need to change its + // rpath. + if(!this->Target->GetHaveInstallRule()) + { + return false; + } + + // Skip chrpath if skipping rpath altogether. + if(this->Makefile->IsOn("CMAKE_SKIP_RPATH")) + { + return false; + } + + // Skip chrpath if it does not need to be changed at install time. + if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) + { + return false; + } + + // Allow the user to disable builtin chrpath explicitly. + if(this->Makefile->IsOn("CMAKE_NO_BUILTIN_CHRPATH")) + { + return false; + } + + if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) + { + return true; + } + +#if defined(CMAKE_USE_ELF_PARSER) + // Enable if the rpath flag uses a separator and the target uses ELF + // binaries. + std::string ll = this->Target->GetLinkerLanguage(config); + if(!ll.empty()) + { + std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; + sepVar += ll; + sepVar += "_FLAG_SEP"; + const char* sep = this->Makefile->GetDefinition(sepVar); + if(sep && *sep) + { + // TODO: Add ELF check to ABI detection and get rid of + // CMAKE_EXECUTABLE_FORMAT. + if(const char* fmt = + this->Makefile->GetDefinition("CMAKE_EXECUTABLE_FORMAT")) + { + return strcmp(fmt, "ELF") == 0; + } + } + } +#endif + static_cast(config); + return false; +} + //---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetSOName(const std::string& config) const diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index c9a2508..9ecbbbe 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -215,6 +215,9 @@ public: */ bool NeedRelinkBeforeInstall(const std::string& config) const; + /** Return true if builtin chrpath will work for this target */ + bool IsChrpathUsed(const std::string& config) const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 7a7dcb4..24c1c49 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -656,11 +656,10 @@ cmInstallTargetGenerator std::string const& toDestDirPath) { // Skip the chrpath if the target does not need it. - if(this->ImportLibrary || !this->Target->Target->IsChrpathUsed(config)) + if(this->ImportLibrary || !this->Target->IsChrpathUsed(config)) { return; } - // Skip if on Apple if(this->Target->Target->GetMakefile() ->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) @@ -695,7 +694,7 @@ cmInstallTargetGenerator std::string const& toDestDirPath) { // Skip the chrpath if the target does not need it. - if(this->ImportLibrary || !this->Target->Target->IsChrpathUsed(config)) + if(this->ImportLibrary || !this->Target->IsChrpathUsed(config)) { return; } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 8dd62f9..1183fe4 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4314,73 +4314,6 @@ void cmTarget::GetLanguages(std::set& languages, } //---------------------------------------------------------------------------- -bool cmTarget::IsChrpathUsed(const std::string& config) const -{ - // Only certain target types have an rpath. - if(!(this->GetType() == cmTarget::SHARED_LIBRARY || - this->GetType() == cmTarget::MODULE_LIBRARY || - this->GetType() == cmTarget::EXECUTABLE)) - { - return false; - } - - // If the target will not be installed we do not need to change its - // rpath. - if(!this->GetHaveInstallRule()) - { - return false; - } - - // Skip chrpath if skipping rpath altogether. - if(this->Makefile->IsOn("CMAKE_SKIP_RPATH")) - { - return false; - } - - // Skip chrpath if it does not need to be changed at install time. - if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) - { - return false; - } - - // Allow the user to disable builtin chrpath explicitly. - if(this->Makefile->IsOn("CMAKE_NO_BUILTIN_CHRPATH")) - { - return false; - } - - if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) - { - return true; - } - -#if defined(CMAKE_USE_ELF_PARSER) - // Enable if the rpath flag uses a separator and the target uses ELF - // binaries. - std::string ll = this->GetLinkerLanguage(config); - if(!ll.empty()) - { - std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; - sepVar += ll; - sepVar += "_FLAG_SEP"; - const char* sep = this->Makefile->GetDefinition(sepVar); - if(sep && *sep) - { - // TODO: Add ELF check to ABI detection and get rid of - // CMAKE_EXECUTABLE_FORMAT. - if(const char* fmt = - this->Makefile->GetDefinition("CMAKE_EXECUTABLE_FORMAT")) - { - return strcmp(fmt, "ELF") == 0; - } - } - } -#endif - static_cast(config); - return false; -} - -//---------------------------------------------------------------------------- cmTarget::ImportInfo const* cmTarget::GetImportInfo(const std::string& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 11f715a..1aef7b3 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -398,9 +398,6 @@ public: bool HaveBuildTreeRPATH(const std::string& config) const; bool HaveInstallTreeRPATH() const; - /** Return true if builtin chrpath will work for this target */ - bool IsChrpathUsed(const std::string& config) const; - /** Return the install name directory for the target in the * build tree. For example: "\@rpath/", "\@loader_path/", * or "/full/path/to/library". */ http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3bd4785affc66f194847fc5effdaa78e40087fb0 commit 3bd4785affc66f194847fc5effdaa78e40087fb0 Author: Stephen Kelly AuthorDate: Sun Nov 3 12:25:17 2013 +0100 Commit: Brad King CommitDate: Mon Aug 3 15:46:53 2015 -0400 cmGeneratorTarget: Move NeedRelinkBeforeInstall from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index a29f4c9..505d01f 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -714,6 +714,73 @@ bool cmGeneratorTarget::HasSOName(const std::string& config) const } //---------------------------------------------------------------------------- +bool +cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const +{ + // Only executables and shared libraries can have an rpath and may + // need relinking. + if(this->GetType() != cmTarget::EXECUTABLE && + this->GetType() != cmTarget::SHARED_LIBRARY && + this->GetType() != cmTarget::MODULE_LIBRARY) + { + return false; + } + + // If there is no install location this target will not be installed + // and therefore does not need relinking. + if(!this->Target->GetHaveInstallRule()) + { + return false; + } + + // If skipping all rpaths completely then no relinking is needed. + if(this->Makefile->IsOn("CMAKE_SKIP_RPATH")) + { + return false; + } + + // If building with the install-tree rpath no relinking is needed. + if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) + { + return false; + } + + // If chrpath is going to be used no relinking is needed. + if(this->Target->IsChrpathUsed(config)) + { + return false; + } + + // Check for rpath support on this platform. + std::string ll = this->Target->GetLinkerLanguage(config); + if(!ll.empty()) + { + std::string flagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; + flagVar += ll; + flagVar += "_FLAG"; + if(!this->Makefile->IsSet(flagVar)) + { + // There is no rpath support on this platform so nothing needs + // relinking. + return false; + } + } + else + { + // No linker language is known. This error will be reported by + // other code. + return false; + } + + // If either a build or install tree rpath is set then the rpath + // will likely change between the build tree and install tree and + // this target must be relinked. + return this->Target->HaveBuildTreeRPATH(config) + || this->Target->HaveInstallTreeRPATH(); +} + + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetSOName(const std::string& config) const { if(this->Target->IsImported()) diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 441bbcf..c9a2508 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -210,6 +210,11 @@ public: std::string& realName, std::string& impName, std::string& pdbName, const std::string& config) const; + /** + * Compute whether this target must be relinked before installing. + */ + bool NeedRelinkBeforeInstall(const std::string& config) const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index edf2705..69747a4 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -482,7 +482,7 @@ cmGlobalUnixMakefileGenerator3 // Add this to the list of depends rules in this directory. if((!check_all || !gtarget->GetPropertyAsBool("EXCLUDE_FROM_ALL")) && (!check_relink || - gtarget->Target + gtarget ->NeedRelinkBeforeInstall(lg->GetConfigName()))) { std::string tname = lg->GetRelativeTargetDirectory(*gtarget->Target); @@ -691,7 +691,7 @@ cmGlobalUnixMakefileGenerator3 // Add a local name for the rule to relink the target before // installation. - if(gtarget->Target + if(gtarget ->NeedRelinkBeforeInstall(lg->GetConfigName())) { makeTargetName = lg->GetRelativeTargetDirectory(*gtarget->Target); @@ -876,7 +876,7 @@ cmGlobalUnixMakefileGenerator3 name, depends, commands, true); // Add rules to prepare the target for installation. - if(gtarget->Target + if(gtarget ->NeedRelinkBeforeInstall(lg->GetConfigName())) { localName = lg->GetRelativeTargetDirectory(*gtarget->Target); diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index deabecf..7a7dcb4 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -73,7 +73,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, { // Compute the build tree directory from which to copy the target. std::string fromDirConfig; - if(this->Target->Target->NeedRelinkBeforeInstall(config)) + if(this->Target->NeedRelinkBeforeInstall(config)) { fromDirConfig = this->Target->Target->GetMakefile()->GetCurrentBinaryDirectory(); diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 98bd0ab..ce370bc 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -486,8 +486,7 @@ void cmLocalUnixMakefileGenerator3 // Add a local name for the rule to relink the target before // installation. - if(t->second->Target - ->NeedRelinkBeforeInstall(this->ConfigName)) + if(t->second->NeedRelinkBeforeInstall(this->ConfigName)) { makeTargetName = this->GetRelativeTargetDirectory(*t->second->Target); makeTargetName += "/preinstall"; diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 31a78ad..2fd77c9 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -58,7 +58,7 @@ void cmMakefileExecutableTargetGenerator::WriteRuleFiles() // write the link rules this->WriteExecutableRule(false); - if(this->Target->NeedRelinkBeforeInstall(this->ConfigName)) + if(this->GeneratorTarget->NeedRelinkBeforeInstall(this->ConfigName)) { // Write rules to link an installable version of the target. this->WriteExecutableRule(true); diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 7d0dc49..a2fcbad 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -69,7 +69,7 @@ void cmMakefileLibraryTargetGenerator::WriteRuleFiles() break; case cmTarget::SHARED_LIBRARY: this->WriteSharedLibraryRules(false); - if(this->Target->NeedRelinkBeforeInstall(this->ConfigName)) + if(this->GeneratorTarget->NeedRelinkBeforeInstall(this->ConfigName)) { // Write rules to link an installable version of the target. this->WriteSharedLibraryRules(true); @@ -77,7 +77,7 @@ void cmMakefileLibraryTargetGenerator::WriteRuleFiles() break; case cmTarget::MODULE_LIBRARY: this->WriteModuleLibraryRules(false); - if(this->Target->NeedRelinkBeforeInstall(this->ConfigName)) + if(this->GeneratorTarget->NeedRelinkBeforeInstall(this->ConfigName)) { // Write rules to link an installable version of the target. this->WriteModuleLibraryRules(true); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1e7fb5a..8dd62f9 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3855,70 +3855,6 @@ bool cmTarget::HaveInstallTreeRPATH() const } //---------------------------------------------------------------------------- -bool cmTarget::NeedRelinkBeforeInstall(const std::string& config) const -{ - // Only executables and shared libraries can have an rpath and may - // need relinking. - if(this->TargetTypeValue != cmTarget::EXECUTABLE && - this->TargetTypeValue != cmTarget::SHARED_LIBRARY && - this->TargetTypeValue != cmTarget::MODULE_LIBRARY) - { - return false; - } - - // If there is no install location this target will not be installed - // and therefore does not need relinking. - if(!this->GetHaveInstallRule()) - { - return false; - } - - // If skipping all rpaths completely then no relinking is needed. - if(this->Makefile->IsOn("CMAKE_SKIP_RPATH")) - { - return false; - } - - // If building with the install-tree rpath no relinking is needed. - if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) - { - return false; - } - - // If chrpath is going to be used no relinking is needed. - if(this->IsChrpathUsed(config)) - { - return false; - } - - // Check for rpath support on this platform. - std::string ll = this->GetLinkerLanguage(config); - if(!ll.empty()) - { - std::string flagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; - flagVar += ll; - flagVar += "_FLAG"; - if(!this->Makefile->IsSet(flagVar)) - { - // There is no rpath support on this platform so nothing needs - // relinking. - return false; - } - } - else - { - // No linker language is known. This error will be reported by - // other code. - return false; - } - - // If either a build or install tree rpath is set then the rpath - // will likely change between the build tree and install tree and - // this target must be relinked. - return this->HaveBuildTreeRPATH(config) || this->HaveInstallTreeRPATH(); -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetInstallNameDirForBuildTree( const std::string& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 8c23372..11f715a 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -395,11 +395,6 @@ public: bool GetImplibGNUtoMS(std::string const& gnuName, std::string& out, const char* newExt = 0) const; - /** - * Compute whether this target must be relinked before installing. - */ - bool NeedRelinkBeforeInstall(const std::string& config) const; - bool HaveBuildTreeRPATH(const std::string& config) const; bool HaveInstallTreeRPATH() const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=02beed7e24a93e6d684415ba1773d33bd9df50cf commit 02beed7e24a93e6d684415ba1773d33bd9df50cf Author: Stephen Kelly AuthorDate: Tue Oct 9 18:59:12 2012 +0200 Commit: Brad King CommitDate: Mon Aug 3 15:45:54 2015 -0400 cmGeneratorTarget: Move GetPDBName from cmTarget. diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index a20579b..49fc96b 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1625,7 +1625,7 @@ struct TargetFilesystemArtifactResultCreator std::string result = target->Target->GetPDBDirectory(context->Config); result += "/"; - result += target->Target->GetPDBName(context->Config); + result += target->GetPDBName(context->Config); return result; } }; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index a125e47..a29f4c9 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1525,7 +1525,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, } // The program database file name. - pdbName = this->Target->GetPDBName(config); + pdbName = this->GetPDBName(config); } //---------------------------------------------------------------------------- @@ -1587,7 +1587,39 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, impName = this->Target->GetFullNameInternal(config, true); // The program database file name. - pdbName = this->Target->GetPDBName(config); + pdbName = this->GetPDBName(config); +} + +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetPDBName(const std::string& config) const +{ + std::string prefix; + std::string base; + std::string suffix; + this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + + std::vector props; + std::string configUpper = + cmSystemTools::UpperCase(config); + if(!configUpper.empty()) + { + // PDB_NAME_ + props.push_back("PDB_NAME_" + configUpper); + } + + // PDB_NAME + props.push_back("PDB_NAME"); + + for(std::vector::const_iterator i = props.begin(); + i != props.end(); ++i) + { + if(const char* outName = this->GetProperty(*i)) + { + base = outName; + break; + } + } + return prefix+base+".pdb"; } bool cmStrictTargetComparison::operator()(cmTarget const* t1, diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 9cdfd00..441bbcf 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -160,6 +160,9 @@ public: std::vector const* GetSourceDepends(cmSourceFile const* sf) const; + /** Get the name of the pdb file for the target. */ + std::string GetPDBName(const std::string& config="") const; + /** Whether this library has soname enabled and platform supports it. */ bool HasSOName(const std::string& config) const; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index f9125fc..b94e151 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -548,7 +548,7 @@ cmMakefileTargetGenerator this->GeneratorTarget->GetFullPath(this->ConfigName, false, true); targetFullPathPDB = this->Target->GetPDBDirectory(this->ConfigName); targetFullPathPDB += "/"; - targetFullPathPDB += this->Target->GetPDBName(this->ConfigName); + targetFullPathPDB += this->GeneratorTarget->GetPDBName(this->ConfigName); } if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY) { diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index e61ba6f..16e1f48 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -273,7 +273,7 @@ bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(cmNinjaVars& vars) const { pdbPath = this->Target->GetPDBDirectory(this->GetConfigName()); pdbPath += "/"; - pdbPath += this->Target->GetPDBName(this->GetConfigName()); + pdbPath += this->GeneratorTarget->GetPDBName(this->GetConfigName()); } if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 188ad0f..1e7fb5a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3461,37 +3461,6 @@ const char* cmTarget::GetPrefixVariableInternal(bool implib) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetPDBName(const std::string& config) const -{ - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); - - std::vector props; - std::string configUpper = cmSystemTools::UpperCase(config); - if(!configUpper.empty()) - { - // PDB_NAME_ - props.push_back("PDB_NAME_" + configUpper); - } - - // PDB_NAME - props.push_back("PDB_NAME"); - - for(std::vector::const_iterator i = props.begin(); - i != props.end(); ++i) - { - if(const char* outName = this->GetProperty(*i)) - { - base = outName; - break; - } - } - return prefix+base+".pdb"; -} - -//---------------------------------------------------------------------------- bool cmTarget::HasMacOSXRpathInstallNameDir(const std::string& config) const { bool install_name_is_rpath = false; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 162033c..8c23372 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -377,9 +377,6 @@ public: const std::string& config="", bool implib = false) const; - /** Get the name of the pdb file for the target. */ - std::string GetPDBName(const std::string& config) const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=38b76360744534506296bde467e3fadb13a2eea9 commit 38b76360744534506296bde467e3fadb13a2eea9 Author: Stephen Kelly AuthorDate: Mon Mar 10 17:52:04 2014 +0100 Commit: Brad King CommitDate: Mon Aug 3 15:44:50 2015 -0400 cmGeneratorTarget: Move GetCompilePDBPath from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 2b3ebee..a125e47 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -657,6 +657,51 @@ void cmGeneratorTarget::GetSourceFiles(std::vector &files, } //---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetCompilePDBName(const std::string& config) const +{ + std::string prefix; + std::string base; + std::string suffix; + this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + + // Check for a per-configuration output directory target property. + std::string configUpper = cmSystemTools::UpperCase(config); + std::string configProp = "COMPILE_PDB_NAME_"; + configProp += configUpper; + const char* config_name = this->Target->GetProperty(configProp); + if(config_name && *config_name) + { + return prefix + config_name + ".pdb"; + } + + const char* name = this->Target->GetProperty("COMPILE_PDB_NAME"); + if(name && *name) + { + return prefix + name + ".pdb"; + } + + return ""; +} + +//---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetCompilePDBPath(const std::string& config) const +{ + std::string dir = this->Target->GetCompilePDBDirectory(config); + std::string name = this->GetCompilePDBName(config); + if(dir.empty() && !name.empty()) + { + dir = this->Target->GetPDBDirectory(config); + } + if(!dir.empty()) + { + dir += "/"; + } + return dir + name; +} + +//---------------------------------------------------------------------------- bool cmGeneratorTarget::HasSOName(const std::string& config) const { // soname is supported only for shared libraries and modules, diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 9254265..9cdfd00 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -163,6 +163,12 @@ public: /** Whether this library has soname enabled and platform supports it. */ bool HasSOName(const std::string& config) const; + /** Get the name of the compiler pdb file for the target. */ + std::string GetCompilePDBName(const std::string& config="") const; + + /** Get the path for the MSVC /Fd option for this target. */ + std::string GetCompilePDBPath(const std::string& config="") const; + /** * Flags for a given source file as used in this target. Typically assigned * via SET_TARGET_PROPERTIES when the property is a list of source files. diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index dd4cd33..799bac6 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -881,7 +881,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, if(target.GetType() <= cmTarget::OBJECT_LIBRARY) { // Specify the compiler program database file if configured. - std::string pdb = target.GetCompilePDBPath(configName); + std::string pdb = gt->GetCompilePDBPath(configName); if(!pdb.empty()) { fout << "\t\t\t\tProgramDataBaseFileName=\"" diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index ac8cd29..f9125fc 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -553,7 +553,7 @@ cmMakefileTargetGenerator if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY) { targetFullPathCompilePDB = - this->Target->GetCompilePDBPath(this->ConfigName); + this->GeneratorTarget->GetCompilePDBPath(this->ConfigName); if(targetFullPathCompilePDB.empty()) { targetFullPathCompilePDB = this->Target->GetSupportDirectory() + "/"; diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index cf80424..e61ba6f 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -277,7 +277,8 @@ bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(cmNinjaVars& vars) const } if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY) { - compilePdbPath = this->Target->GetCompilePDBPath(this->GetConfigName()); + compilePdbPath = + this->GeneratorTarget->GetCompilePDBPath(this->GetConfigName()); if(compilePdbPath.empty()) { compilePdbPath = this->Target->GetSupportDirectory() + "/"; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e1b3e94..188ad0f 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3492,49 +3492,6 @@ std::string cmTarget::GetPDBName(const std::string& config) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetCompilePDBName(const std::string& config) const -{ - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); - - // Check for a per-configuration output directory target property. - std::string configUpper = cmSystemTools::UpperCase(config); - std::string configProp = "COMPILE_PDB_NAME_"; - configProp += configUpper; - const char* config_name = this->GetProperty(configProp); - if(config_name && *config_name) - { - return prefix + config_name + ".pdb"; - } - - const char* name = this->GetProperty("COMPILE_PDB_NAME"); - if(name && *name) - { - return prefix + name + ".pdb"; - } - - return ""; -} - -//---------------------------------------------------------------------------- -std::string cmTarget::GetCompilePDBPath(const std::string& config) const -{ - std::string dir = this->GetCompilePDBDirectory(config); - std::string name = this->GetCompilePDBName(config); - if(dir.empty() && !name.empty()) - { - dir = this->GetPDBDirectory(config); - } - if(!dir.empty()) - { - dir += "/"; - } - return dir + name; -} - -//---------------------------------------------------------------------------- bool cmTarget::HasMacOSXRpathInstallNameDir(const std::string& config) const { bool install_name_is_rpath = false; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e89a212..162033c 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -380,12 +380,6 @@ public: /** Get the name of the pdb file for the target. */ std::string GetPDBName(const std::string& config) const; - /** Get the name of the compiler pdb file for the target. */ - std::string GetCompilePDBName(const std::string& config="") const; - - /** Get the path for the MSVC /Fd option for this target. */ - std::string GetCompilePDBPath(const std::string& config="") const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 83775a5..16edf3c 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2026,7 +2026,8 @@ void cmVisualStudio10TargetGenerator::WriteClOptions( } // Specify the compiler program database file if configured. - std::string pdb = this->Target->GetCompilePDBPath(configName.c_str()); + std::string pdb = + this->GeneratorTarget->GetCompilePDBPath(configName.c_str()); if(!pdb.empty()) { this->ConvertToWindowsSlash(pdb); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a3ae53efa53aea6e705948173e92d716d8710700 commit a3ae53efa53aea6e705948173e92d716d8710700 Author: Stephen Kelly AuthorDate: Mon Nov 18 17:01:00 2013 +0100 Commit: Brad King CommitDate: Mon Aug 3 15:42:24 2015 -0400 cmGeneratorTarget: Move HasSOName from cmTarget. diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 8a2cf4b..e3652c5 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -889,7 +889,7 @@ cmExportFileGenerator { std::string prop; std::string value; - if(target->Target->HasSOName(config)) + if(target->HasSOName(config)) { if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 31c2df1..2b3ebee 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -657,6 +657,18 @@ void cmGeneratorTarget::GetSourceFiles(std::vector &files, } //---------------------------------------------------------------------------- +bool cmGeneratorTarget::HasSOName(const std::string& config) const +{ + // soname is supported only for shared libraries and modules, + // and then only when the platform supports an soname flag. + return ((this->GetType() == cmTarget::SHARED_LIBRARY || + this->GetType() == cmTarget::MODULE_LIBRARY) && + !this->GetPropertyAsBool("NO_SONAME") && + this->Makefile->GetSONameFlag( + this->Target->GetLinkerLanguage(config))); +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetSOName(const std::string& config) const { if(this->Target->IsImported()) @@ -1407,7 +1419,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, // Check for library version properties. const char* version = this->GetProperty("VERSION"); const char* soversion = this->GetProperty("SOVERSION"); - if(!this->Target->HasSOName(config) || + if(!this->HasSOName(config) || this->Target->IsFrameworkOnApple()) { // Versioning is supported only for shared libraries and modules, diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 7fb7c32..9254265 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -160,6 +160,9 @@ public: std::vector const* GetSourceDepends(cmSourceFile const* sf) const; + /** Whether this library has soname enabled and platform supports it. */ + bool HasSOName(const std::string& config) const; + /** * Flags for a given source file as used in this target. Typically assigned * via SET_TARGET_PROPERTIES when the property is a list of source files. diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index b44848c..d7ae36d 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1944,7 +1944,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, const char* version = target.GetProperty("VERSION"); const char* soversion = target.GetProperty("SOVERSION"); - if(!target.HasSOName(configName) || target.IsFrameworkOnApple()) + if(!gtgt->HasSOName(configName) || target.IsFrameworkOnApple()) { version = 0; soversion = 0; diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 26273ee..7d0dc49 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -653,7 +653,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules vars.Target = target.c_str(); vars.LinkLibraries = linkLibs.c_str(); vars.ObjectsQuoted = buildObjs.c_str(); - if (this->Target->HasSOName(this->ConfigName)) + if (this->GeneratorTarget->HasSOName(this->ConfigName)) { vars.SONameFlag = this->Makefile->GetSONameFlag(linkLanguage); vars.TargetSOName= targetNameSO.c_str(); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 5d86091..2586b31 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -531,7 +531,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() vars["LANGUAGE_COMPILE_FLAGS"] = t; } - if (target.HasSOName(cfgName)) + if (this->GetGeneratorTarget()->HasSOName(cfgName)) { vars["SONAME_FLAG"] = mf->GetSONameFlag(this->TargetLinkLanguage); vars["SONAME"] = this->TargetNameSO; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 60fe7e4..e1b3e94 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3535,17 +3535,6 @@ std::string cmTarget::GetCompilePDBPath(const std::string& config) const } //---------------------------------------------------------------------------- -bool cmTarget::HasSOName(const std::string& config) const -{ - // soname is supported only for shared libraries and modules, - // and then only when the platform supports an soname flag. - return ((this->GetType() == cmTarget::SHARED_LIBRARY || - this->GetType() == cmTarget::MODULE_LIBRARY) && - !this->GetPropertyAsBool("NO_SONAME") && - this->Makefile->GetSONameFlag(this->GetLinkerLanguage(config))); -} - -//---------------------------------------------------------------------------- bool cmTarget::HasMacOSXRpathInstallNameDir(const std::string& config) const { bool install_name_is_rpath = false; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 15dfb4a..e89a212 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -386,9 +386,6 @@ public: /** Get the path for the MSVC /Fd option for this target. */ std::string GetCompilePDBPath(const std::string& config="") const; - /** Whether this library has soname enabled and platform supports it. */ - bool HasSOName(const std::string& config) const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6b9a9d3dd66c4de66cf0d35f1d3e5f810b4a2a8e commit 6b9a9d3dd66c4de66cf0d35f1d3e5f810b4a2a8e Author: Stephen Kelly AuthorDate: Tue Oct 9 18:48:18 2012 +0200 Commit: Brad King CommitDate: Mon Aug 3 15:36:52 2015 -0400 cmGeneratorTarget: Move GetLibraryNames from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 6a693f1..31c2df1 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -693,8 +693,8 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const std::string realName; std::string impName; std::string pdbName; - this->Target->GetLibraryNames(name, soName, realName, - impName, pdbName, config); + this->GetLibraryNames(name, soName, realName, + impName, pdbName, config); return soName; } } @@ -1254,7 +1254,7 @@ void cmGeneratorTarget::GenerateTargetManifest( this->GetType() == cmTarget::SHARED_LIBRARY || this->GetType() == cmTarget::MODULE_LIBRARY) { - this->Target->GetLibraryNames(name, soName, realName, impName, pdbName, + this->GetLibraryNames(name, soName, realName, impName, pdbName, config); } else @@ -1378,13 +1378,100 @@ cmGeneratorTarget::NormalGetRealName(const std::string& config) const std::string realName; std::string impName; std::string pdbName; - this->Target->GetLibraryNames(name, soName, realName, - impName, pdbName, config); + this->GetLibraryNames(name, soName, realName, + impName, pdbName, config); return realName; } } //---------------------------------------------------------------------------- +void cmGeneratorTarget::GetLibraryNames(std::string& name, + std::string& soName, + std::string& realName, + std::string& impName, + std::string& pdbName, + const std::string& config) const +{ + // This should not be called for imported targets. + // TODO: Split cmTarget into a class hierarchy to get compile-time + // enforcement of the limited imported target API. + if(this->Target->IsImported()) + { + std::string msg = "GetLibraryNames called on imported target: "; + msg += this->GetName(); + this->LocalGenerator->IssueMessage(cmake::INTERNAL_ERROR, + msg); + return; + } + + // Check for library version properties. + const char* version = this->GetProperty("VERSION"); + const char* soversion = this->GetProperty("SOVERSION"); + if(!this->Target->HasSOName(config) || + this->Target->IsFrameworkOnApple()) + { + // Versioning is supported only for shared libraries and modules, + // and then only when the platform supports an soname flag. + version = 0; + soversion = 0; + } + if(version && !soversion) + { + // The soversion must be set if the library version is set. Use + // the library version as the soversion. + soversion = version; + } + if(!version && soversion) + { + // Use the soversion as the library version. + version = soversion; + } + + // Get the components of the library name. + std::string prefix; + std::string base; + std::string suffix; + this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + + // The library name. + name = prefix+base+suffix; + + if(this->Target->IsFrameworkOnApple()) + { + realName = prefix; + realName += "Versions/"; + realName += this->Target->GetFrameworkVersion(); + realName += "/"; + realName += base; + soName = realName; + } + else + { + // The library's soname. + this->Target->ComputeVersionedName(soName, prefix, base, suffix, + name, soversion); + + // The library's real name on disk. + this->Target->ComputeVersionedName(realName, prefix, base, suffix, + name, version); + } + + // The import library name. + if(this->GetType() == cmTarget::SHARED_LIBRARY || + this->GetType() == cmTarget::MODULE_LIBRARY) + { + impName = this->Target->GetFullNameInternal(config, true); + } + else + { + impName = ""; + } + + // The program database file name. + pdbName = this->Target->GetPDBName(config); +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetExecutableNames(std::string& name, std::string& realName, std::string& impName, @@ -1446,7 +1533,6 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, pdbName = this->Target->GetPDBName(config); } - bool cmStrictTargetComparison::operator()(cmTarget const* t1, cmTarget const* t2) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 49aa65b..7fb7c32 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -191,6 +191,13 @@ public: std::string& impName, std::string& pdbName, const std::string& config) const; + /** Get the names of the library needed to generate a build rule + that takes into account shared library version numbers. This + should be called only on a library target. */ + void GetLibraryNames(std::string& name, std::string& soName, + std::string& realName, std::string& impName, + std::string& pdbName, const std::string& config) const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index c872859..deabecf 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -185,7 +185,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - this->Target->Target->GetLibraryNames(targetName, targetNameSO, + this->Target->GetLibraryNames(targetName, targetNameSO, targetNameReal, targetNameImport, targetNamePDB, config); @@ -411,7 +411,7 @@ cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target, std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - target->GetLibraryNames(targetName, targetNameSO, targetNameReal, + gtgt->GetLibraryNames(targetName, targetNameSO, targetNameReal, targetNameImport, targetNamePDB, config); if(nameType == NameImplib) { diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index daac331..dd4cd33 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1147,7 +1147,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, std::string targetNameFull; std::string targetNameImport; std::string targetNamePDB; - target.GetLibraryNames(targetName, targetNameSO, targetNameFull, + gt->GetLibraryNames(targetName, targetNameSO, targetNameFull, targetNameImport, targetNamePDB, configName); // Compute the link library and directory information. diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 696dcc4..26273ee 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -28,7 +28,7 @@ cmMakefileLibraryTargetGenerator this->CustomCommandDriver = OnDepends; if (this->Target->GetType() != cmTarget::INTERFACE_LIBRARY) { - this->Target->GetLibraryNames( + this->GeneratorTarget->GetLibraryNames( this->TargetNameOut, this->TargetNameSO, this->TargetNameReal, this->TargetNameImport, this->TargetNamePDB, this->ConfigName); } @@ -266,7 +266,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - this->Target->GetLibraryNames( + this->GeneratorTarget->GetLibraryNames( targetName, targetNameSO, targetNameReal, targetNameImport, targetNamePDB, this->ConfigName); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 737510f..5d86091 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -49,7 +49,7 @@ cmNinjaNormalTargetGenerator(cmGeneratorTarget* target) this->TargetNamePDB, GetLocalGenerator()->GetConfigName()); else - target->Target->GetLibraryNames(this->TargetNameOut, + this->GetGeneratorTarget()->GetLibraryNames(this->TargetNameOut, this->TargetNameSO, this->TargetNameReal, this->TargetNameImport, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 22b76e9..60fe7e4 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3862,95 +3862,6 @@ void cmTarget::GetFullNameInternal(const std::string& config, } //---------------------------------------------------------------------------- -void cmTarget::GetLibraryNames(std::string& name, - std::string& soName, - std::string& realName, - std::string& impName, - std::string& pdbName, - const std::string& config) const -{ - // This should not be called for imported targets. - // TODO: Split cmTarget into a class hierarchy to get compile-time - // enforcement of the limited imported target API. - if(this->IsImported()) - { - std::string msg = "GetLibraryNames called on imported target: "; - msg += this->GetName(); - this->Makefile->IssueMessage(cmake::INTERNAL_ERROR, - msg); - return; - } - - assert(this->GetType() != INTERFACE_LIBRARY); - - // Check for library version properties. - const char* version = this->GetProperty("VERSION"); - const char* soversion = this->GetProperty("SOVERSION"); - if(!this->HasSOName(config) || - this->Makefile->IsOn("CMAKE_PLATFORM_NO_VERSIONED_SONAME") || - this->IsFrameworkOnApple()) - { - // Versioning is supported only for shared libraries and modules, - // and then only when the platform supports an soname flag. - version = 0; - soversion = 0; - } - if(version && !soversion) - { - // The soversion must be set if the library version is set. Use - // the library version as the soversion. - soversion = version; - } - if(!version && soversion) - { - // Use the soversion as the library version. - version = soversion; - } - - // Get the components of the library name. - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); - - // The library name. - name = prefix+base+suffix; - - if(this->IsFrameworkOnApple()) - { - realName = prefix; - realName += "Versions/"; - realName += this->GetFrameworkVersion(); - realName += "/"; - realName += base; - soName = realName; - } - else - { - // The library's soname. - this->ComputeVersionedName(soName, prefix, base, suffix, - name, soversion); - // The library's real name on disk. - this->ComputeVersionedName(realName, prefix, base, suffix, - name, version); - } - - // The import library name. - if(this->GetType() == cmTarget::SHARED_LIBRARY || - this->GetType() == cmTarget::MODULE_LIBRARY) - { - impName = this->GetFullNameInternal(config, true); - } - else - { - impName = ""; - } - - // The program database file name. - pdbName = this->GetPDBName(config); -} - -//---------------------------------------------------------------------------- void cmTarget::ComputeVersionedName(std::string& vName, std::string const& prefix, std::string const& base, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 714647c..15dfb4a 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -399,13 +399,6 @@ public: no soname at all. */ bool IsImportedSharedLibWithoutSOName(const std::string& config) const; - /** Get the names of the library needed to generate a build rule - that takes into account shared library version numbers. This - should be called only on a library target. */ - void GetLibraryNames(std::string& name, std::string& soName, - std::string& realName, std::string& impName, - std::string& pdbName, const std::string& config) const; - /** Does this target have a GNU implib to convert to MS format? */ bool HasImplibGNUtoMS() const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 1bb21ff..83775a5 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2477,7 +2477,8 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) } else { - this->Target->GetLibraryNames(targetName, targetNameSO, targetNameFull, + this->GeneratorTarget->GetLibraryNames(targetName, targetNameSO, + targetNameFull, targetNameImport, targetNamePDB, config.c_str()); } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a393b45f3953d13da0585a8c01721c85639dd487 commit a393b45f3953d13da0585a8c01721c85639dd487 Author: Stephen Kelly AuthorDate: Tue Oct 9 18:40:45 2012 +0200 Commit: Brad King CommitDate: Mon Aug 3 15:34:39 2015 -0400 cmGeneratorTarget: Move GetExecutableNames from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index f9f23a6..6a693f1 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1248,8 +1248,7 @@ void cmGeneratorTarget::GenerateTargetManifest( std::string pdbName; if(this->GetType() == cmTarget::EXECUTABLE) { - this->Target->GetExecutableNames(name, realName, impName, pdbName, - config); + this->GetExecutableNames(name, realName, impName, pdbName, config); } else if(this->GetType() == cmTarget::STATIC_LIBRARY || this->GetType() == cmTarget::SHARED_LIBRARY || @@ -1368,7 +1367,7 @@ cmGeneratorTarget::NormalGetRealName(const std::string& config) const std::string realName; std::string impName; std::string pdbName; - this->Target->GetExecutableNames(name, realName, impName, pdbName, config); + this->GetExecutableNames(name, realName, impName, pdbName, config); return realName; } else @@ -1385,6 +1384,69 @@ cmGeneratorTarget::NormalGetRealName(const std::string& config) const } } +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GetExecutableNames(std::string& name, + std::string& realName, + std::string& impName, + std::string& pdbName, + const std::string& config) const +{ + // This should not be called for imported targets. + // TODO: Split cmTarget into a class hierarchy to get compile-time + // enforcement of the limited imported target API. + if(this->Target->IsImported()) + { + std::string msg = + "GetExecutableNames called on imported target: "; + msg += this->GetName(); + this->LocalGenerator->IssueMessage(cmake::INTERNAL_ERROR, msg); + } + + // This versioning is supported only for executables and then only + // when the platform supports symbolic links. +#if defined(_WIN32) && !defined(__CYGWIN__) + const char* version = 0; +#else + // Check for executable version properties. + const char* version = this->GetProperty("VERSION"); + if(this->GetType() != cmTarget::EXECUTABLE || this->Makefile->IsOn("XCODE")) + { + version = 0; + } +#endif + + // Get the components of the executable name. + std::string prefix; + std::string base; + std::string suffix; + this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + + // The executable name. + name = prefix+base+suffix; + + // The executable's real name on disk. +#if defined(__CYGWIN__) + realName = prefix+base; +#else + realName = name; +#endif + if(version) + { + realName += "-"; + realName += version; + } +#if defined(__CYGWIN__) + realName += suffix; +#endif + + // The import library name. + impName = this->Target->GetFullNameInternal(config, true); + + // The program database file name. + pdbName = this->Target->GetPDBName(config); +} + + bool cmStrictTargetComparison::operator()(cmTarget const* t1, cmTarget const* t2) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 1303ee4..49aa65b 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -184,6 +184,12 @@ public: void GetAutoUicOptions(std::vector &result, const std::string& config) const; + /** Get the names of the executable needed to generate a build rule + that takes into account executable version numbers. This should + be called only on an executable target. */ + void GetExecutableNames(std::string& name, std::string& realName, + std::string& impName, std::string& pdbName, + const std::string& config) const; struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index c64f9a3..c872859 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -125,7 +125,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - this->Target->Target->GetExecutableNames(targetName, targetNameReal, + this->Target->GetExecutableNames(targetName, targetNameReal, targetNameImport, targetNamePDB, config); if(this->ImportLibrary) @@ -372,13 +372,16 @@ cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target, { std::string fname; // Compute the name of the library. + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); if(target->GetType() == cmTarget::EXECUTABLE) { std::string targetName; std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - target->GetExecutableNames(targetName, targetNameReal, + gtgt->GetExecutableNames(targetName, targetNameReal, targetNameImport, targetNamePDB, config); if(nameType == NameImplib) diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 37e08dd..daac331 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1244,7 +1244,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, std::string targetNameFull; std::string targetNameImport; std::string targetNamePDB; - target.GetExecutableNames(targetName, targetNameFull, + gt->GetExecutableNames(targetName, targetNameFull, targetNameImport, targetNamePDB, configName); // Compute the link library and directory information. diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 416063f..31a78ad 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -25,7 +25,7 @@ cmMakefileExecutableTargetGenerator cmMakefileTargetGenerator(target) { this->CustomCommandDriver = OnDepends; - this->Target->GetExecutableNames( + this->GeneratorTarget->GetExecutableNames( this->TargetNameOut, this->TargetNameReal, this->TargetNameImport, this->TargetNamePDB, this->ConfigName); @@ -94,7 +94,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - this->Target->GetExecutableNames + this->GeneratorTarget->GetExecutableNames (targetName, targetNameReal, targetNameImport, targetNamePDB, this->ConfigName); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index c9fa7c0..737510f 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -43,7 +43,7 @@ cmNinjaNormalTargetGenerator(cmGeneratorTarget* target) this->TargetLinkLanguage = target->Target ->GetLinkerLanguage(this->GetConfigName()); if (target->GetType() == cmTarget::EXECUTABLE) - target->Target->GetExecutableNames(this->TargetNameOut, + this->GetGeneratorTarget()->GetExecutableNames(this->TargetNameOut, this->TargetNameReal, this->TargetNameImport, this->TargetNamePDB, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index ded5363..22b76e9 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3968,68 +3968,6 @@ void cmTarget::ComputeVersionedName(std::string& vName, } //---------------------------------------------------------------------------- -void cmTarget::GetExecutableNames(std::string& name, - std::string& realName, - std::string& impName, - std::string& pdbName, - const std::string& config) const -{ - // This should not be called for imported targets. - // TODO: Split cmTarget into a class hierarchy to get compile-time - // enforcement of the limited imported target API. - if(this->IsImported()) - { - std::string msg = - "GetExecutableNames called on imported target: "; - msg += this->GetName(); - this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg); - } - - // This versioning is supported only for executables and then only - // when the platform supports symbolic links. -#if defined(_WIN32) && !defined(__CYGWIN__) - const char* version = 0; -#else - // Check for executable version properties. - const char* version = this->GetProperty("VERSION"); - if(this->GetType() != cmTarget::EXECUTABLE || this->Makefile->IsOn("XCODE")) - { - version = 0; - } -#endif - - // Get the components of the executable name. - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); - - // The executable name. - name = prefix+base+suffix; - - // The executable's real name on disk. -#if defined(__CYGWIN__) - realName = prefix+base; -#else - realName = name; -#endif - if(version) - { - realName += "-"; - realName += version; - } -#if defined(__CYGWIN__) - realName += suffix; -#endif - - // The import library name. - impName = this->GetFullNameInternal(config, true); - - // The program database file name. - pdbName = this->GetPDBName(config); -} - -//---------------------------------------------------------------------------- bool cmTarget::HasImplibGNUtoMS() const { return this->HasImportLibrary() && this->GetPropertyAsBool("GNUtoMS"); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 925e7c6..714647c 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -406,14 +406,6 @@ public: std::string& realName, std::string& impName, std::string& pdbName, const std::string& config) const; - /** Get the names of the executable needed to generate a build rule - that takes into account executable version numbers. This should - be called only on an executable target. */ - void GetExecutableNames(std::string& name, std::string& realName, - std::string& impName, - std::string& pdbName, - const std::string& config) const; - /** Does this target have a GNU implib to convert to MS format? */ bool HasImplibGNUtoMS() const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index f3f291a..1bb21ff 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2471,7 +2471,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) std::string targetNamePDB; if(this->Target->GetType() == cmTarget::EXECUTABLE) { - this->Target->GetExecutableNames(targetName, targetNameFull, + this->GeneratorTarget->GetExecutableNames(targetName, targetNameFull, targetNameImport, targetNamePDB, config.c_str()); } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=64688437a69269725b7f73ced318252e5ee090a1 commit 64688437a69269725b7f73ced318252e5ee090a1 Author: Stephen Kelly AuthorDate: Mon Mar 10 20:34:59 2014 +0100 Commit: Brad King CommitDate: Mon Aug 3 15:33:39 2015 -0400 cmGeneratorTarget: Move GetLinkImplementationClosure diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 521a5b7..f9f23a6 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -618,7 +618,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const std::string& dir, } std::vector const& deps = - this->Target->GetLinkImplementationClosure(config); + this->GetLinkImplementationClosure(config); for(std::vector::const_iterator li = deps.begin(), le = deps.end(); li != le; ++li) { @@ -775,6 +775,54 @@ void cmGeneratorTarget::GetAutoUicOptions(std::vector &result, } //---------------------------------------------------------------------------- +void processILibs(const std::string& config, + cmTarget const* headTarget, + cmLinkItem const& item, + std::vector& tgts, + std::set& emitted) +{ + if (item.Target && emitted.insert(item.Target).second) + { + tgts.push_back(item.Target); + if(cmTarget::LinkInterfaceLibraries const* iface = + item.Target->GetLinkInterfaceLibraries(config, headTarget, true)) + { + for(std::vector::const_iterator + it = iface->Libraries.begin(); + it != iface->Libraries.end(); ++it) + { + processILibs(config, headTarget, *it, tgts, emitted); + } + } + } +} + +//---------------------------------------------------------------------------- +const std::vector& +cmGeneratorTarget::GetLinkImplementationClosure( + const std::string& config) const +{ + LinkImplClosure& tgts = + this->LinkImplClosureMap[config]; + if(!tgts.Done) + { + tgts.Done = true; + std::set emitted; + + cmTarget::LinkImplementationLibraries const* impl + = this->Target->GetLinkImplementationLibraries(config); + + for(std::vector::const_iterator + it = impl->Libraries.begin(); + it != impl->Libraries.end(); ++it) + { + processILibs(config, this->Target, *it, tgts , emitted); + } + } + return tgts; +} + +//---------------------------------------------------------------------------- class cmTargetTraceDependencies { public: @@ -1455,7 +1503,7 @@ cmGeneratorTarget::GetCompatibleInterfaces(std::string const& config) const compat.PropsBool.insert("POSITION_INDEPENDENT_CODE"); compat.PropsString.insert("AUTOUIC_OPTIONS"); std::vector const& deps = - this->Target->GetLinkImplementationClosure(config); + this->GetLinkImplementationClosure(config); for(std::vector::const_iterator li = deps.begin(); li != deps.end(); ++li) { @@ -1954,7 +2002,7 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt, || (!impliedByUse && !explicitlySet)); std::vector const& deps = - tgt->Target->GetLinkImplementationClosure(config); + tgt->GetLinkImplementationClosure(config); if(deps.empty()) { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 8e68d39..1303ee4 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -245,6 +245,18 @@ private: cmGeneratorTarget(cmGeneratorTarget const&); void operator=(cmGeneratorTarget const&); + + struct LinkImplClosure: public std::vector + { + LinkImplClosure(): Done(false) {} + bool Done; + }; + mutable std::map LinkImplClosureMap; + +public: + std::vector const& + GetLinkImplementationClosure(const std::string& config) const; + }; struct cmStrictTargetComparison { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 968bd9d..ded5363 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -163,13 +163,6 @@ public: typedef std::map LinkClosureMapType; LinkClosureMapType LinkClosureMap; - struct LinkImplClosure: public std::vector - { - LinkImplClosure(): Done(false) {} - bool Done; - }; - std::map LinkImplClosureMap; - typedef std::map > SourceFilesMapType; SourceFilesMapType SourceFilesMap; @@ -5175,53 +5168,6 @@ cmTarget::GetImportLinkInterface(const std::string& config, } //---------------------------------------------------------------------------- -void processILibs(const std::string& config, - cmTarget const* headTarget, - cmLinkItem const& item, - std::vector& tgts, - std::set& emitted) -{ - if (item.Target && emitted.insert(item.Target).second) - { - tgts.push_back(item.Target); - if(cmTarget::LinkInterfaceLibraries const* iface = - item.Target->GetLinkInterfaceLibraries(config, headTarget, true)) - { - for(std::vector::const_iterator - it = iface->Libraries.begin(); - it != iface->Libraries.end(); ++it) - { - processILibs(config, headTarget, *it, tgts, emitted); - } - } - } -} - -//---------------------------------------------------------------------------- -std::vector const& -cmTarget::GetLinkImplementationClosure(const std::string& config) const -{ - cmTargetInternals::LinkImplClosure& tgts = - this->Internal->LinkImplClosureMap[config]; - if(!tgts.Done) - { - tgts.Done = true; - std::set emitted; - - cmTarget::LinkImplementationLibraries const* impl - = this->GetLinkImplementationLibraries(config); - - for(std::vector::const_iterator - it = impl->Libraries.begin(); - it != impl->Libraries.end(); ++it) - { - processILibs(config, this, *it, tgts , emitted); - } - } - return tgts; -} - -//---------------------------------------------------------------------------- void cmTargetInternals::ComputeLinkInterfaceLibraries( cmTarget const* thisTarget, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 85d9964..925e7c6 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -293,9 +293,6 @@ public: cmTarget const* headTarget, bool usage_requirements_only) const; - std::vector const& - GetLinkImplementationClosure(const std::string& config) const; - /** The link implementation specifies the direct library dependencies needed by the object files of the target. */ struct LinkImplementationLibraries http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ff84e914b247dc3c692086323aed69f0a8942d2e commit ff84e914b247dc3c692086323aed69f0a8942d2e Author: Stephen Kelly AuthorDate: Tue Jul 28 21:24:41 2015 +0200 Commit: Brad King CommitDate: Mon Aug 3 15:32:13 2015 -0400 cmGeneratorTarget: Move ReportPropertyOrigin from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index fe73fee..521a5b7 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1937,24 +1937,24 @@ std::pair consistentProperty(const char *lhs, //---------------------------------------------------------------------------- template -PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, +PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt, const std::string &p, const std::string& config, const char *defaultValue, CompatibleType t, PropertyType *) { - PropertyType propContent = getTypedProperty(tgt, p); - const bool explicitlySet = tgt->GetProperties() + PropertyType propContent = getTypedProperty(tgt->Target, p); + const bool explicitlySet = tgt->Target->GetProperties() .find(p) - != tgt->GetProperties().end(); + != tgt->Target->GetProperties().end(); const bool impliedByUse = - tgt->IsNullImpliedByLinkLibraries(p); + tgt->Target->IsNullImpliedByLinkLibraries(p); assert((impliedByUse ^ explicitlySet) || (!impliedByUse && !explicitlySet)); std::vector const& deps = - tgt->GetLinkImplementationClosure(config); + tgt->Target->GetLinkImplementationClosure(config); if(deps.empty()) { @@ -2125,7 +2125,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, bool cmGeneratorTarget::GetLinkInterfaceDependentBoolProperty( const std::string &p, const std::string& config) const { - return checkInterfacePropertyCompatibility(this->Target, p, config, + return checkInterfacePropertyCompatibility(this, p, config, "FALSE", BoolType, 0); } @@ -2135,7 +2135,7 @@ const char* cmGeneratorTarget::GetLinkInterfaceDependentStringProperty( const std::string &p, const std::string& config) const { - return checkInterfacePropertyCompatibility(this->Target, + return checkInterfacePropertyCompatibility(this, p, config, "empty", @@ -2147,7 +2147,7 @@ const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMinProperty( const std::string &p, const std::string& config) const { - return checkInterfacePropertyCompatibility(this->Target, + return checkInterfacePropertyCompatibility(this, p, config, "empty", @@ -2159,7 +2159,7 @@ const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMaxProperty( const std::string &p, const std::string& config) const { - return checkInterfacePropertyCompatibility(this->Target, + return checkInterfacePropertyCompatibility(this, p, config, "empty", @@ -2196,3 +2196,43 @@ cmGeneratorTarget::GetLinkInformation(const std::string& config) const } return i->second; } + +//---------------------------------------------------------------------------- +void +cmGeneratorTarget::ReportPropertyOrigin(const std::string &p, + const std::string &result, + const std::string &report, + const std::string &compatibilityType) const +{ + std::vector debugProperties; + const char *debugProp = this->Target->GetMakefile() + ->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); + if (debugProp) + { + cmSystemTools::ExpandListArgument(debugProp, debugProperties); + } + + bool debugOrigin = !this->DebugCompatiblePropertiesDone[p] + && std::find(debugProperties.begin(), + debugProperties.end(), + p) + != debugProperties.end(); + + if (this->Target->GetMakefile()->IsConfigured()) + { + this->DebugCompatiblePropertiesDone[p] = true; + } + if (!debugOrigin) + { + return; + } + + std::string areport = compatibilityType; + areport += std::string(" of property \"") + p + "\" for target \""; + areport += std::string(this->GetName()); + areport += "\" (result: \""; + areport += result; + areport += "\"):\n" + report; + + this->Makefile->GetCMakeInstance()->IssueMessage(cmake::LOG, areport); +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index d65b1ef..8e68d39 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -199,6 +199,11 @@ public: std::vector XamlSources; }; + void ReportPropertyOrigin(const std::string &p, + const std::string &result, + const std::string &report, + const std::string &compatibilityType) const; + private: friend class cmTargetTraceDependencies; struct SourceEntry { std::vector Depends; }; @@ -212,6 +217,8 @@ private: mutable bool SourceFileFlagsConstructed; mutable std::map SourceFlagsMap; + mutable std::map DebugCompatiblePropertiesDone; + struct CompatibleInterfacesBase { std::set PropsBool; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1fa62e7..968bd9d 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4537,46 +4537,6 @@ bool cmTarget::IsNullImpliedByLinkLibraries(const std::string &p) const //---------------------------------------------------------------------------- void -cmTarget::ReportPropertyOrigin(const std::string &p, - const std::string &result, - const std::string &report, - const std::string &compatibilityType) const -{ - std::vector debugProperties; - const char *debugProp = - this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); - if (debugProp) - { - cmSystemTools::ExpandListArgument(debugProp, debugProperties); - } - - bool debugOrigin = !this->DebugCompatiblePropertiesDone[p] - && std::find(debugProperties.begin(), - debugProperties.end(), - p) - != debugProperties.end(); - - if (this->Makefile->IsConfigured()) - { - this->DebugCompatiblePropertiesDone[p] = true; - } - if (!debugOrigin) - { - return; - } - - std::string areport = compatibilityType; - areport += std::string(" of property \"") + p + "\" for target \""; - areport += std::string(this->GetName()); - areport += "\" (result: \""; - areport += result; - areport += "\"):\n" + report; - - this->Makefile->GetCMakeInstance()->IssueMessage(cmake::LOG, areport); -} - -//---------------------------------------------------------------------------- -void cmTarget::GetObjectLibrariesCMP0026(std::vector& objlibs) const { // At configure-time, this method can be called as part of getting the diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 795753e..85d9964 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -565,11 +565,6 @@ public: bool LinkLanguagePropagatesToDependents() const { return this->TargetTypeValue == STATIC_LIBRARY; } - void ReportPropertyOrigin(const std::string &p, - const std::string &result, - const std::string &report, - const std::string &compatibilityType) const; - std::map const& GetMaxLanguageStandards() const { @@ -676,7 +671,6 @@ private: std::set Utilities; mutable std::set LinkImplicitNullProperties; std::map UtilityBacktraces; - mutable std::map DebugCompatiblePropertiesDone; mutable std::map MaxLanguageStandards; cmPolicies::PolicyMap PolicyMap; std::string Name; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c71fd71080f2c3d78ee82980c2306cd345cb6d06 commit c71fd71080f2c3d78ee82980c2306cd345cb6d06 Author: Stephen Kelly AuthorDate: Tue Jul 28 21:15:44 2015 +0200 Commit: Brad King CommitDate: Mon Aug 3 15:31:08 2015 -0400 cmGeneratorTarget: Make CompatibleType enum private again. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index a9245c0..fe73fee 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1524,18 +1524,26 @@ bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty( return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0; } +enum CompatibleType +{ + BoolType, + StringType, + NumberMinType, + NumberMaxType +}; + template PropertyType getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, - cmTarget::CompatibleType, + CompatibleType, PropertyType *); template<> bool getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, - cmTarget::CompatibleType, bool *) + CompatibleType, bool *) { return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); } @@ -1544,19 +1552,19 @@ template<> const char * getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, - cmTarget::CompatibleType t, + CompatibleType t, const char **) { switch(t) { - case cmTarget::BoolType: + case BoolType: assert(0 && "String compatibility check function called for boolean"); return 0; - case cmTarget::StringType: + case StringType: return tgt->GetLinkInterfaceDependentStringProperty(prop, config); - case cmTarget::NumberMinType: + case NumberMinType: return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config); - case cmTarget::NumberMaxType: + case NumberMaxType: return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config); } assert(0 && "Unreachable!"); @@ -1570,7 +1578,7 @@ void checkPropertyConsistency(cmGeneratorTarget const* depender, const std::string& propName, std::set &emitted, const std::string& config, - cmTarget::CompatibleType t, + CompatibleType t, PropertyType *) { const char *prop = dependee->GetProperty(propName); @@ -1683,7 +1691,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( checkPropertyConsistency(this, li->Target, strBool, - emittedBools, config, cmTarget::BoolType, 0); + emittedBools, config, BoolType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; @@ -1691,7 +1699,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( checkPropertyConsistency(this, li->Target, strString, emittedStrings, config, - cmTarget::StringType, 0); + StringType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; @@ -1699,7 +1707,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( checkPropertyConsistency(this, li->Target, strNumMin, emittedMinNumbers, config, - cmTarget::NumberMinType, 0); + NumberMinType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; @@ -1707,7 +1715,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( checkPropertyConsistency(this, li->Target, strNumMax, emittedMaxNumbers, config, - cmTarget::NumberMaxType, 0); + NumberMaxType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; @@ -1760,17 +1768,17 @@ void cmGeneratorTarget::CheckPropertyCompatibility( } //---------------------------------------------------------------------------- -std::string compatibilityType(cmTarget::CompatibleType t) +std::string compatibilityType(CompatibleType t) { switch(t) { - case cmTarget::BoolType: + case BoolType: return "Boolean compatibility"; - case cmTarget::StringType: + case StringType: return "String compatibility"; - case cmTarget::NumberMaxType: + case NumberMaxType: return "Numeric maximum compatibility"; - case cmTarget::NumberMinType: + case NumberMinType: return "Numeric minimum compatibility"; } assert(0 && "Unreachable!"); @@ -1778,15 +1786,15 @@ std::string compatibilityType(cmTarget::CompatibleType t) } //---------------------------------------------------------------------------- -std::string compatibilityAgree(cmTarget::CompatibleType t, bool dominant) +std::string compatibilityAgree(CompatibleType t, bool dominant) { switch(t) { - case cmTarget::BoolType: - case cmTarget::StringType: + case BoolType: + case StringType: return dominant ? "(Disagree)\n" : "(Agree)\n"; - case cmTarget::NumberMaxType: - case cmTarget::NumberMinType: + case NumberMaxType: + case NumberMinType: return dominant ? "(Dominant)\n" : "(Ignored)\n"; } assert(0 && "Unreachable!"); @@ -1842,12 +1850,12 @@ const char* impliedValue(const char*) template std::pair consistentProperty(PropertyType lhs, PropertyType rhs, - cmTarget::CompatibleType t); + CompatibleType t); //---------------------------------------------------------------------------- template<> std::pair consistentProperty(bool lhs, bool rhs, - cmTarget::CompatibleType) + CompatibleType) { return std::make_pair(lhs == rhs, lhs); } @@ -1863,7 +1871,7 @@ std::pair consistentStringProperty(const char *lhs, //---------------------------------------------------------------------------- std::pair consistentNumberProperty(const char *lhs, const char *rhs, - cmTarget::CompatibleType t) + CompatibleType t) { char *pEnd; @@ -1881,7 +1889,7 @@ std::pair consistentNumberProperty(const char *lhs, return std::pair(false, null_ptr); } - if (t == cmTarget::NumberMaxType) + if (t == NumberMaxType) { return std::make_pair(true, std::max(lnum, rnum) == lnum ? lhs : rhs); } @@ -1895,7 +1903,7 @@ std::pair consistentNumberProperty(const char *lhs, template<> std::pair consistentProperty(const char *lhs, const char *rhs, - cmTarget::CompatibleType t) + CompatibleType t) { if (!lhs && !rhs) { @@ -1914,13 +1922,13 @@ std::pair consistentProperty(const char *lhs, switch(t) { - case cmTarget::BoolType: + case BoolType: assert(0 && "consistentProperty for strings called with BoolType"); return std::pair(false, null_ptr); - case cmTarget::StringType: + case StringType: return consistentStringProperty(lhs, rhs); - case cmTarget::NumberMinType: - case cmTarget::NumberMaxType: + case NumberMinType: + case NumberMaxType: return consistentNumberProperty(lhs, rhs, t); } assert(0 && "Unreachable!"); @@ -1933,7 +1941,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, const std::string &p, const std::string& config, const char *defaultValue, - cmTarget::CompatibleType t, + CompatibleType t, PropertyType *) { PropertyType propContent = getTypedProperty(tgt, p); @@ -2119,7 +2127,7 @@ bool cmGeneratorTarget::GetLinkInterfaceDependentBoolProperty( { return checkInterfacePropertyCompatibility(this->Target, p, config, "FALSE", - cmTarget::BoolType, 0); + BoolType, 0); } //---------------------------------------------------------------------------- @@ -2131,7 +2139,7 @@ const char* cmGeneratorTarget::GetLinkInterfaceDependentStringProperty( p, config, "empty", - cmTarget::StringType, 0); + StringType, 0); } //---------------------------------------------------------------------------- @@ -2143,7 +2151,7 @@ const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMinProperty( p, config, "empty", - cmTarget::NumberMinType, 0); + NumberMinType, 0); } //---------------------------------------------------------------------------- @@ -2155,7 +2163,7 @@ const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMaxProperty( p, config, "empty", - cmTarget::NumberMaxType, 0); + NumberMaxType, 0); } //---------------------------------------------------------------------------- diff --git a/Source/cmTarget.h b/Source/cmTarget.h index b544b0b..795753e 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -581,14 +581,6 @@ public: return this->LinkLibrariesForVS6;} #endif - enum CompatibleType - { - BoolType, - StringType, - NumberMinType, - NumberMaxType - }; - private: bool HandleLocationPropertyPolicy(cmMakefile* context) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=16a84de3ade279d8eb8e56c88efc85eba200098a commit 16a84de3ade279d8eb8e56c88efc85eba200098a Author: Stephen Kelly AuthorDate: Tue Jul 28 21:13:45 2015 +0200 Commit: Brad King CommitDate: Mon Aug 3 15:09:12 2015 -0400 cmGeneratorTarget: Move LinkInterfaceDependent methods from cmTarget. diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index c1641cc..a20579b 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1142,7 +1142,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode context->Config)) { context->HadContextSensitiveCondition = true; - return target->GetLinkInterfaceDependentBoolProperty( + return gtgt->GetLinkInterfaceDependentBoolProperty( propertyName, context->Config) ? "1" : "0"; } @@ -1151,7 +1151,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { context->HadContextSensitiveCondition = true; const char *propContent = - target->GetLinkInterfaceDependentStringProperty( + gtgt->GetLinkInterfaceDependentStringProperty( propertyName, context->Config); return propContent ? propContent : ""; @@ -1161,7 +1161,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { context->HadContextSensitiveCondition = true; const char *propContent = - target->GetLinkInterfaceDependentNumberMinProperty( + gtgt->GetLinkInterfaceDependentNumberMinProperty( propertyName, context->Config); return propContent ? propContent : ""; @@ -1171,7 +1171,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { context->HadContextSensitiveCondition = true; const char *propContent = - target->GetLinkInterfaceDependentNumberMaxProperty( + gtgt->GetLinkInterfaceDependentNumberMaxProperty( propertyName, context->Config); return propContent ? propContent : ""; @@ -1188,7 +1188,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { context->HadContextSensitiveCondition = true; const char *propContent = - target->GetLinkInterfaceDependentNumberMinProperty( + gtgt->GetLinkInterfaceDependentNumberMinProperty( propertyName, context->Config); return propContent ? propContent : ""; @@ -1198,7 +1198,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { context->HadContextSensitiveCondition = true; const char *propContent = - target->GetLinkInterfaceDependentNumberMaxProperty( + gtgt->GetLinkInterfaceDependentNumberMaxProperty( propertyName, context->Config); return propContent ? propContent : ""; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index a7b0349..a9245c0 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -24,6 +24,7 @@ #include +#include #include "assert.h" //---------------------------------------------------------------------------- @@ -753,8 +754,7 @@ void cmGeneratorTarget::GetAutoUicOptions(std::vector &result, const std::string& config) const { const char *prop - = this->Target-> - GetLinkInterfaceDependentStringProperty("AUTOUIC_OPTIONS", + = this->GetLinkInterfaceDependentStringProperty("AUTOUIC_OPTIONS", config); if (!prop) { @@ -1537,7 +1537,7 @@ bool getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& config, cmTarget::CompatibleType, bool *) { - return tgt->Target->GetLinkInterfaceDependentBoolProperty(prop, config); + return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); } template<> @@ -1553,13 +1553,11 @@ const char * getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, assert(0 && "String compatibility check function called for boolean"); return 0; case cmTarget::StringType: - return tgt->Target->GetLinkInterfaceDependentStringProperty(prop, config); + return tgt->GetLinkInterfaceDependentStringProperty(prop, config); case cmTarget::NumberMinType: - return tgt->Target - ->GetLinkInterfaceDependentNumberMinProperty(prop, config); + return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config); case cmTarget::NumberMaxType: - return tgt->Target - ->GetLinkInterfaceDependentNumberMaxProperty(prop, config); + return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config); } assert(0 && "Unreachable!"); return 0; @@ -1762,6 +1760,405 @@ void cmGeneratorTarget::CheckPropertyCompatibility( } //---------------------------------------------------------------------------- +std::string compatibilityType(cmTarget::CompatibleType t) +{ + switch(t) + { + case cmTarget::BoolType: + return "Boolean compatibility"; + case cmTarget::StringType: + return "String compatibility"; + case cmTarget::NumberMaxType: + return "Numeric maximum compatibility"; + case cmTarget::NumberMinType: + return "Numeric minimum compatibility"; + } + assert(0 && "Unreachable!"); + return ""; +} + +//---------------------------------------------------------------------------- +std::string compatibilityAgree(cmTarget::CompatibleType t, bool dominant) +{ + switch(t) + { + case cmTarget::BoolType: + case cmTarget::StringType: + return dominant ? "(Disagree)\n" : "(Agree)\n"; + case cmTarget::NumberMaxType: + case cmTarget::NumberMinType: + return dominant ? "(Dominant)\n" : "(Ignored)\n"; + } + assert(0 && "Unreachable!"); + return ""; +} + +//---------------------------------------------------------------------------- +template +PropertyType getTypedProperty(cmTarget const* tgt, const std::string& prop); + +//---------------------------------------------------------------------------- +template<> +bool getTypedProperty(cmTarget const* tgt, const std::string& prop) +{ + return tgt->GetPropertyAsBool(prop); +} + +//---------------------------------------------------------------------------- +template<> +const char *getTypedProperty(cmTarget const* tgt, + const std::string& prop) +{ + return tgt->GetProperty(prop); +} + +template +std::string valueAsString(PropertyType); +template<> +std::string valueAsString(bool value) +{ + return value ? "TRUE" : "FALSE"; +} +template<> +std::string valueAsString(const char* value) +{ + return value ? value : "(unset)"; +} + +template +PropertyType impliedValue(PropertyType); +template<> +bool impliedValue(bool) +{ + return false; +} +template<> +const char* impliedValue(const char*) +{ + return ""; +} + +//---------------------------------------------------------------------------- +template +std::pair consistentProperty(PropertyType lhs, + PropertyType rhs, + cmTarget::CompatibleType t); + +//---------------------------------------------------------------------------- +template<> +std::pair consistentProperty(bool lhs, bool rhs, + cmTarget::CompatibleType) +{ + return std::make_pair(lhs == rhs, lhs); +} + +//---------------------------------------------------------------------------- +std::pair consistentStringProperty(const char *lhs, + const char *rhs) +{ + const bool b = strcmp(lhs, rhs) == 0; + return std::make_pair(b, b ? lhs : 0); +} + +//---------------------------------------------------------------------------- +std::pair consistentNumberProperty(const char *lhs, + const char *rhs, + cmTarget::CompatibleType t) +{ + char *pEnd; + + const char* const null_ptr = 0; + + long lnum = strtol(lhs, &pEnd, 0); + if (pEnd == lhs || *pEnd != '\0' || errno == ERANGE) + { + return std::pair(false, null_ptr); + } + + long rnum = strtol(rhs, &pEnd, 0); + if (pEnd == rhs || *pEnd != '\0' || errno == ERANGE) + { + return std::pair(false, null_ptr); + } + + if (t == cmTarget::NumberMaxType) + { + return std::make_pair(true, std::max(lnum, rnum) == lnum ? lhs : rhs); + } + else + { + return std::make_pair(true, std::min(lnum, rnum) == lnum ? lhs : rhs); + } +} + +//---------------------------------------------------------------------------- +template<> +std::pair consistentProperty(const char *lhs, + const char *rhs, + cmTarget::CompatibleType t) +{ + if (!lhs && !rhs) + { + return std::make_pair(true, lhs); + } + if (!lhs) + { + return std::make_pair(true, rhs); + } + if (!rhs) + { + return std::make_pair(true, lhs); + } + + const char* const null_ptr = 0; + + switch(t) + { + case cmTarget::BoolType: + assert(0 && "consistentProperty for strings called with BoolType"); + return std::pair(false, null_ptr); + case cmTarget::StringType: + return consistentStringProperty(lhs, rhs); + case cmTarget::NumberMinType: + case cmTarget::NumberMaxType: + return consistentNumberProperty(lhs, rhs, t); + } + assert(0 && "Unreachable!"); + return std::pair(false, null_ptr); +} + +//---------------------------------------------------------------------------- +template +PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, + const std::string &p, + const std::string& config, + const char *defaultValue, + cmTarget::CompatibleType t, + PropertyType *) +{ + PropertyType propContent = getTypedProperty(tgt, p); + const bool explicitlySet = tgt->GetProperties() + .find(p) + != tgt->GetProperties().end(); + const bool impliedByUse = + tgt->IsNullImpliedByLinkLibraries(p); + assert((impliedByUse ^ explicitlySet) + || (!impliedByUse && !explicitlySet)); + + std::vector const& deps = + tgt->GetLinkImplementationClosure(config); + + if(deps.empty()) + { + return propContent; + } + bool propInitialized = explicitlySet; + + std::string report = " * Target \""; + report += tgt->GetName(); + if (explicitlySet) + { + report += "\" has property content \""; + report += valueAsString(propContent); + report += "\"\n"; + } + else if (impliedByUse) + { + report += "\" property is implied by use.\n"; + } + else + { + report += "\" property not set.\n"; + } + + std::string interfaceProperty = "INTERFACE_" + p; + for(std::vector::const_iterator li = + deps.begin(); + li != deps.end(); ++li) + { + // An error should be reported if one dependency + // has INTERFACE_POSITION_INDEPENDENT_CODE ON and the other + // has INTERFACE_POSITION_INDEPENDENT_CODE OFF, or if the + // target itself has a POSITION_INDEPENDENT_CODE which disagrees + // with a dependency. + + cmTarget const* theTarget = *li; + + const bool ifaceIsSet = theTarget->GetProperties() + .find(interfaceProperty) + != theTarget->GetProperties().end(); + PropertyType ifacePropContent = + getTypedProperty(theTarget, + interfaceProperty); + + std::string reportEntry; + if (ifaceIsSet) + { + reportEntry += " * Target \""; + reportEntry += theTarget->GetName(); + reportEntry += "\" property value \""; + reportEntry += valueAsString(ifacePropContent); + reportEntry += "\" "; + } + + if (explicitlySet) + { + if (ifaceIsSet) + { + std::pair consistent = + consistentProperty(propContent, + ifacePropContent, t); + report += reportEntry; + report += compatibilityAgree(t, propContent != consistent.second); + if (!consistent.first) + { + std::ostringstream e; + e << "Property " << p << " on target \"" + << tgt->GetName() << "\" does\nnot match the " + "INTERFACE_" << p << " property requirement\nof " + "dependency \"" << theTarget->GetName() << "\".\n"; + cmSystemTools::Error(e.str().c_str()); + break; + } + else + { + propContent = consistent.second; + continue; + } + } + else + { + // Explicitly set on target and not set in iface. Can't disagree. + continue; + } + } + else if (impliedByUse) + { + propContent = impliedValue(propContent); + + if (ifaceIsSet) + { + std::pair consistent = + consistentProperty(propContent, + ifacePropContent, t); + report += reportEntry; + report += compatibilityAgree(t, propContent != consistent.second); + if (!consistent.first) + { + std::ostringstream e; + e << "Property " << p << " on target \"" + << tgt->GetName() << "\" is\nimplied to be " << defaultValue + << " because it was used to determine the link libraries\n" + "already. The INTERFACE_" << p << " property on\ndependency \"" + << theTarget->GetName() << "\" is in conflict.\n"; + cmSystemTools::Error(e.str().c_str()); + break; + } + else + { + propContent = consistent.second; + continue; + } + } + else + { + // Implicitly set on target and not set in iface. Can't disagree. + continue; + } + } + else + { + if (ifaceIsSet) + { + if (propInitialized) + { + std::pair consistent = + consistentProperty(propContent, + ifacePropContent, t); + report += reportEntry; + report += compatibilityAgree(t, propContent != consistent.second); + if (!consistent.first) + { + std::ostringstream e; + e << "The INTERFACE_" << p << " property of \"" + << theTarget->GetName() << "\" does\nnot agree with the value " + "of " << p << " already determined\nfor \"" + << tgt->GetName() << "\".\n"; + cmSystemTools::Error(e.str().c_str()); + break; + } + else + { + propContent = consistent.second; + continue; + } + } + else + { + report += reportEntry + "(Interface set)\n"; + propContent = ifacePropContent; + propInitialized = true; + } + } + else + { + // Not set. Nothing to agree on. + continue; + } + } + } + + tgt->ReportPropertyOrigin(p, valueAsString(propContent), + report, compatibilityType(t)); + return propContent; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::GetLinkInterfaceDependentBoolProperty( + const std::string &p, const std::string& config) const +{ + return checkInterfacePropertyCompatibility(this->Target, p, config, + "FALSE", + cmTarget::BoolType, 0); +} + +//---------------------------------------------------------------------------- +const char* cmGeneratorTarget::GetLinkInterfaceDependentStringProperty( + const std::string &p, + const std::string& config) const +{ + return checkInterfacePropertyCompatibility(this->Target, + p, + config, + "empty", + cmTarget::StringType, 0); +} + +//---------------------------------------------------------------------------- +const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMinProperty( + const std::string &p, + const std::string& config) const +{ + return checkInterfacePropertyCompatibility(this->Target, + p, + config, + "empty", + cmTarget::NumberMinType, 0); +} + +//---------------------------------------------------------------------------- +const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMaxProperty( + const std::string &p, + const std::string& config) const +{ + return checkInterfacePropertyCompatibility(this->Target, + p, + config, + "empty", + cmTarget::NumberMaxType, 0); +} + +//---------------------------------------------------------------------------- cmComputeLinkInformation* cmGeneratorTarget::GetLinkInformation(const std::string& config) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index ae86e19..d65b1ef 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -96,6 +96,17 @@ public: bool IsLinkInterfaceDependentNumberMaxProperty(const std::string &p, const std::string& config) const; + bool GetLinkInterfaceDependentBoolProperty(const std::string &p, + const std::string& config) const; + + const char *GetLinkInterfaceDependentStringProperty(const std::string &p, + const std::string& config) const; + const char *GetLinkInterfaceDependentNumberMinProperty(const std::string &p, + const std::string& config) const; + const char *GetLinkInterfaceDependentNumberMaxProperty(const std::string &p, + const std::string& config) const; + + /** Get the full path to the target according to the settings in its makefile and the configuration type. */ std::string GetFullPath(const std::string& config="", bool implib = false, diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index eaf812f..3ab501d 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2059,7 +2059,9 @@ void cmLocalGenerator::AddCMP0018Flags(std::string &flags, return; } - if (target->GetLinkInterfaceDependentBoolProperty( + cmGeneratorTarget* gtgt = + this->GlobalGenerator->GetGeneratorTarget(target); + if (gtgt->GetLinkInterfaceDependentBoolProperty( "POSITION_INDEPENDENT_CODE", config)) { diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index a72b176..f1ba2f4 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -547,8 +547,11 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target) { qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR"); } + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); if (const char *targetQtVersion = - target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", "")) + gtgt->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", "")) { qtVersion = targetQtVersion; } @@ -1150,6 +1153,9 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) std::string cmQtAutoGenerators::GetRccExecutable(cmTarget const* target) { + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); cmMakefile *makefile = target->GetMakefile(); const char *qtVersion = makefile->GetDefinition("_target_qt_version"); if (!qtVersion) @@ -1160,8 +1166,7 @@ std::string cmQtAutoGenerators::GetRccExecutable(cmTarget const* target) qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR"); } if (const char *targetQtVersion = - target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", - "")) + gtgt->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", "")) { qtVersion = targetQtVersion; } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index b165545..1fa62e7 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4536,141 +4536,6 @@ bool cmTarget::IsNullImpliedByLinkLibraries(const std::string &p) const } //---------------------------------------------------------------------------- -template -PropertyType getTypedProperty(cmTarget const* tgt, const std::string& prop); - -//---------------------------------------------------------------------------- -template<> -bool getTypedProperty(cmTarget const* tgt, const std::string& prop) -{ - return tgt->GetPropertyAsBool(prop); -} - -//---------------------------------------------------------------------------- -template<> -const char *getTypedProperty(cmTarget const* tgt, - const std::string& prop) -{ - return tgt->GetProperty(prop); -} - -//---------------------------------------------------------------------------- -template -std::pair consistentProperty(PropertyType lhs, - PropertyType rhs, - cmTarget::CompatibleType t); - -//---------------------------------------------------------------------------- -template<> -std::pair consistentProperty(bool lhs, bool rhs, - cmTarget::CompatibleType) -{ - return std::make_pair(lhs == rhs, lhs); -} - -//---------------------------------------------------------------------------- -std::pair consistentStringProperty(const char *lhs, - const char *rhs) -{ - const bool b = strcmp(lhs, rhs) == 0; - return std::make_pair(b, b ? lhs : 0); -} - -//---------------------------------------------------------------------------- -std::pair consistentNumberProperty(const char *lhs, - const char *rhs, - cmTarget::CompatibleType t) -{ - char *pEnd; - - const char* const null_ptr = 0; - - long lnum = strtol(lhs, &pEnd, 0); - if (pEnd == lhs || *pEnd != '\0' || errno == ERANGE) - { - return std::pair(false, null_ptr); - } - - long rnum = strtol(rhs, &pEnd, 0); - if (pEnd == rhs || *pEnd != '\0' || errno == ERANGE) - { - return std::pair(false, null_ptr); - } - - if (t == cmTarget::NumberMaxType) - { - return std::make_pair(true, std::max(lnum, rnum) == lnum ? lhs : rhs); - } - else - { - return std::make_pair(true, std::min(lnum, rnum) == lnum ? lhs : rhs); - } -} - -//---------------------------------------------------------------------------- -template<> -std::pair consistentProperty(const char *lhs, - const char *rhs, - cmTarget::CompatibleType t) -{ - if (!lhs && !rhs) - { - return std::make_pair(true, lhs); - } - if (!lhs) - { - return std::make_pair(true, rhs); - } - if (!rhs) - { - return std::make_pair(true, lhs); - } - - const char* const null_ptr = 0; - - switch(t) - { - case cmTarget::BoolType: - assert(0 && "consistentProperty for strings called with BoolType"); - return std::pair(false, null_ptr); - case cmTarget::StringType: - return consistentStringProperty(lhs, rhs); - case cmTarget::NumberMinType: - case cmTarget::NumberMaxType: - return consistentNumberProperty(lhs, rhs, t); - } - assert(0 && "Unreachable!"); - return std::pair(false, null_ptr); -} - -template -PropertyType impliedValue(PropertyType); -template<> -bool impliedValue(bool) -{ - return false; -} -template<> -const char* impliedValue(const char*) -{ - return ""; -} - - -template -std::string valueAsString(PropertyType); -template<> -std::string valueAsString(bool value) -{ - return value ? "TRUE" : "FALSE"; -} -template<> -std::string valueAsString(const char* value) -{ - return value ? value : "(unset)"; -} - -//---------------------------------------------------------------------------- void cmTarget::ReportPropertyOrigin(const std::string &p, const std::string &result, @@ -4711,270 +4576,6 @@ cmTarget::ReportPropertyOrigin(const std::string &p, } //---------------------------------------------------------------------------- -std::string compatibilityType(cmTarget::CompatibleType t) -{ - switch(t) - { - case cmTarget::BoolType: - return "Boolean compatibility"; - case cmTarget::StringType: - return "String compatibility"; - case cmTarget::NumberMaxType: - return "Numeric maximum compatibility"; - case cmTarget::NumberMinType: - return "Numeric minimum compatibility"; - } - assert(0 && "Unreachable!"); - return ""; -} - -//---------------------------------------------------------------------------- -std::string compatibilityAgree(cmTarget::CompatibleType t, bool dominant) -{ - switch(t) - { - case cmTarget::BoolType: - case cmTarget::StringType: - return dominant ? "(Disagree)\n" : "(Agree)\n"; - case cmTarget::NumberMaxType: - case cmTarget::NumberMinType: - return dominant ? "(Dominant)\n" : "(Ignored)\n"; - } - assert(0 && "Unreachable!"); - return ""; -} - -//---------------------------------------------------------------------------- -template -PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, - const std::string &p, - const std::string& config, - const char *defaultValue, - cmTarget::CompatibleType t, - PropertyType *) -{ - PropertyType propContent = getTypedProperty(tgt, p); - const bool explicitlySet = tgt->GetProperties() - .find(p) - != tgt->GetProperties().end(); - const bool impliedByUse = - tgt->IsNullImpliedByLinkLibraries(p); - assert((impliedByUse ^ explicitlySet) - || (!impliedByUse && !explicitlySet)); - - std::vector const& deps = - tgt->GetLinkImplementationClosure(config); - - if(deps.empty()) - { - return propContent; - } - bool propInitialized = explicitlySet; - - std::string report = " * Target \""; - report += tgt->GetName(); - if (explicitlySet) - { - report += "\" has property content \""; - report += valueAsString(propContent); - report += "\"\n"; - } - else if (impliedByUse) - { - report += "\" property is implied by use.\n"; - } - else - { - report += "\" property not set.\n"; - } - - std::string interfaceProperty = "INTERFACE_" + p; - for(std::vector::const_iterator li = - deps.begin(); - li != deps.end(); ++li) - { - // An error should be reported if one dependency - // has INTERFACE_POSITION_INDEPENDENT_CODE ON and the other - // has INTERFACE_POSITION_INDEPENDENT_CODE OFF, or if the - // target itself has a POSITION_INDEPENDENT_CODE which disagrees - // with a dependency. - - cmTarget const* theTarget = *li; - - const bool ifaceIsSet = theTarget->GetProperties() - .find(interfaceProperty) - != theTarget->GetProperties().end(); - PropertyType ifacePropContent = - getTypedProperty(theTarget, - interfaceProperty); - - std::string reportEntry; - if (ifaceIsSet) - { - reportEntry += " * Target \""; - reportEntry += theTarget->GetName(); - reportEntry += "\" property value \""; - reportEntry += valueAsString(ifacePropContent); - reportEntry += "\" "; - } - - if (explicitlySet) - { - if (ifaceIsSet) - { - std::pair consistent = - consistentProperty(propContent, - ifacePropContent, t); - report += reportEntry; - report += compatibilityAgree(t, propContent != consistent.second); - if (!consistent.first) - { - std::ostringstream e; - e << "Property " << p << " on target \"" - << tgt->GetName() << "\" does\nnot match the " - "INTERFACE_" << p << " property requirement\nof " - "dependency \"" << theTarget->GetName() << "\".\n"; - cmSystemTools::Error(e.str().c_str()); - break; - } - else - { - propContent = consistent.second; - continue; - } - } - else - { - // Explicitly set on target and not set in iface. Can't disagree. - continue; - } - } - else if (impliedByUse) - { - propContent = impliedValue(propContent); - - if (ifaceIsSet) - { - std::pair consistent = - consistentProperty(propContent, - ifacePropContent, t); - report += reportEntry; - report += compatibilityAgree(t, propContent != consistent.second); - if (!consistent.first) - { - std::ostringstream e; - e << "Property " << p << " on target \"" - << tgt->GetName() << "\" is\nimplied to be " << defaultValue - << " because it was used to determine the link libraries\n" - "already. The INTERFACE_" << p << " property on\ndependency \"" - << theTarget->GetName() << "\" is in conflict.\n"; - cmSystemTools::Error(e.str().c_str()); - break; - } - else - { - propContent = consistent.second; - continue; - } - } - else - { - // Implicitly set on target and not set in iface. Can't disagree. - continue; - } - } - else - { - if (ifaceIsSet) - { - if (propInitialized) - { - std::pair consistent = - consistentProperty(propContent, - ifacePropContent, t); - report += reportEntry; - report += compatibilityAgree(t, propContent != consistent.second); - if (!consistent.first) - { - std::ostringstream e; - e << "The INTERFACE_" << p << " property of \"" - << theTarget->GetName() << "\" does\nnot agree with the value " - "of " << p << " already determined\nfor \"" - << tgt->GetName() << "\".\n"; - cmSystemTools::Error(e.str().c_str()); - break; - } - else - { - propContent = consistent.second; - continue; - } - } - else - { - report += reportEntry + "(Interface set)\n"; - propContent = ifacePropContent; - propInitialized = true; - } - } - else - { - // Not set. Nothing to agree on. - continue; - } - } - } - - tgt->ReportPropertyOrigin(p, valueAsString(propContent), - report, compatibilityType(t)); - return propContent; -} - -//---------------------------------------------------------------------------- -bool cmTarget::GetLinkInterfaceDependentBoolProperty(const std::string &p, - const std::string& config) const -{ - return checkInterfacePropertyCompatibility(this, p, config, "FALSE", - BoolType, 0); -} - -//---------------------------------------------------------------------------- -const char * cmTarget::GetLinkInterfaceDependentStringProperty( - const std::string &p, - const std::string& config) const -{ - return checkInterfacePropertyCompatibility(this, - p, - config, - "empty", - StringType, 0); -} - -//---------------------------------------------------------------------------- -const char * cmTarget::GetLinkInterfaceDependentNumberMinProperty( - const std::string &p, - const std::string& config) const -{ - return checkInterfacePropertyCompatibility(this, - p, - config, - "empty", - NumberMinType, 0); -} - -//---------------------------------------------------------------------------- -const char * cmTarget::GetLinkInterfaceDependentNumberMaxProperty( - const std::string &p, - const std::string& config) const -{ - return checkInterfacePropertyCompatibility(this, - p, - config, - "empty", - NumberMaxType, 0); -} - -//---------------------------------------------------------------------------- void cmTarget::GetObjectLibrariesCMP0026(std::vector& objlibs) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 8af74ef..b544b0b 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -553,15 +553,6 @@ public: const std::string& config) const; bool IsNullImpliedByLinkLibraries(const std::string &p) const; - bool GetLinkInterfaceDependentBoolProperty(const std::string &p, - const std::string& config) const; - - const char *GetLinkInterfaceDependentStringProperty(const std::string &p, - const std::string& config) const; - const char *GetLinkInterfaceDependentNumberMinProperty(const std::string &p, - const std::string& config) const; - const char *GetLinkInterfaceDependentNumberMaxProperty(const std::string &p, - const std::string& config) const; std::string GetDebugGeneratorExpressions(const std::string &value, cmTarget::LinkLibraryType llt) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5d414a138f9e5d1d3a2054d289961aa5c66693a7 commit 5d414a138f9e5d1d3a2054d289961aa5c66693a7 Author: Stephen Kelly AuthorDate: Tue Jul 28 21:02:27 2015 +0200 Commit: Brad King CommitDate: Mon Aug 3 15:08:55 2015 -0400 cmGeneratorTarget: Port internal API to cmGeneratorTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 1f3effb..a7b0349 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1525,23 +1525,23 @@ bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty( } template -PropertyType getLinkInterfaceDependentProperty(cmTarget const* tgt, +PropertyType getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, cmTarget::CompatibleType, PropertyType *); template<> -bool getLinkInterfaceDependentProperty(cmTarget const* tgt, +bool getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, cmTarget::CompatibleType, bool *) { - return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); + return tgt->Target->GetLinkInterfaceDependentBoolProperty(prop, config); } template<> -const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, +const char * getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, cmTarget::CompatibleType t, @@ -1553,11 +1553,13 @@ const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, assert(0 && "String compatibility check function called for boolean"); return 0; case cmTarget::StringType: - return tgt->GetLinkInterfaceDependentStringProperty(prop, config); + return tgt->Target->GetLinkInterfaceDependentStringProperty(prop, config); case cmTarget::NumberMinType: - return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config); + return tgt->Target + ->GetLinkInterfaceDependentNumberMinProperty(prop, config); case cmTarget::NumberMaxType: - return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config); + return tgt->Target + ->GetLinkInterfaceDependentNumberMaxProperty(prop, config); } assert(0 && "Unreachable!"); return 0; @@ -1565,7 +1567,7 @@ const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, //---------------------------------------------------------------------------- template -void checkPropertyConsistency(cmTarget const* depender, +void checkPropertyConsistency(cmGeneratorTarget const* depender, cmTarget const* dependee, const std::string& propName, std::set &emitted, @@ -1597,7 +1599,7 @@ void checkPropertyConsistency(cmTarget const* depender, << *pi << "\" listed in its " << propName << " property. " "This is not allowed. Only user-defined properties may appear " "listed in the " << propName << " property."; - depender->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, e.str()); + depender->GetLocalGenerator()->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } if(emitted.insert(*pi).second) @@ -1681,14 +1683,14 @@ void cmGeneratorTarget::CheckPropertyCompatibility( continue; } - checkPropertyConsistency(this->Target, li->Target, + checkPropertyConsistency(this, li->Target, strBool, emittedBools, config, cmTarget::BoolType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; } - checkPropertyConsistency(this->Target, li->Target, + checkPropertyConsistency(this, li->Target, strString, emittedStrings, config, cmTarget::StringType, 0); @@ -1696,7 +1698,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( { return; } - checkPropertyConsistency(this->Target, li->Target, + checkPropertyConsistency(this, li->Target, strNumMin, emittedMinNumbers, config, cmTarget::NumberMinType, 0); @@ -1704,7 +1706,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( { return; } - checkPropertyConsistency(this->Target, li->Target, + checkPropertyConsistency(this, li->Target, strNumMax, emittedMaxNumbers, config, cmTarget::NumberMaxType, 0); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4b0e72cf72e52b09be07fde986b9fc3431c2124e commit 4b0e72cf72e52b09be07fde986b9fc3431c2124e Author: Stephen Kelly AuthorDate: Tue Jul 28 20:59:17 2015 +0200 Commit: Brad King CommitDate: Mon Aug 3 14:51:38 2015 -0400 cmGeneratorTarget: Move CheckPropertyCompatibility from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 845c052..1f3effb 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1524,6 +1524,240 @@ bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty( return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0; } +template +PropertyType getLinkInterfaceDependentProperty(cmTarget const* tgt, + const std::string& prop, + const std::string& config, + cmTarget::CompatibleType, + PropertyType *); + +template<> +bool getLinkInterfaceDependentProperty(cmTarget const* tgt, + const std::string& prop, + const std::string& config, + cmTarget::CompatibleType, bool *) +{ + return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); +} + +template<> +const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, + const std::string& prop, + const std::string& config, + cmTarget::CompatibleType t, + const char **) +{ + switch(t) + { + case cmTarget::BoolType: + assert(0 && "String compatibility check function called for boolean"); + return 0; + case cmTarget::StringType: + return tgt->GetLinkInterfaceDependentStringProperty(prop, config); + case cmTarget::NumberMinType: + return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config); + case cmTarget::NumberMaxType: + return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config); + } + assert(0 && "Unreachable!"); + return 0; +} + +//---------------------------------------------------------------------------- +template +void checkPropertyConsistency(cmTarget const* depender, + cmTarget const* dependee, + const std::string& propName, + std::set &emitted, + const std::string& config, + cmTarget::CompatibleType t, + PropertyType *) +{ + const char *prop = dependee->GetProperty(propName); + if (!prop) + { + return; + } + + std::vector props; + cmSystemTools::ExpandListArgument(prop, props); + std::string pdir = + dependee->GetMakefile()->GetRequiredDefinition("CMAKE_ROOT"); + pdir += "/Help/prop_tgt/"; + + for(std::vector::iterator pi = props.begin(); + pi != props.end(); ++pi) + { + std::string pname = cmSystemTools::HelpFileName(*pi); + std::string pfile = pdir + pname + ".rst"; + if(cmSystemTools::FileExists(pfile.c_str(), true)) + { + std::ostringstream e; + e << "Target \"" << dependee->GetName() << "\" has property \"" + << *pi << "\" listed in its " << propName << " property. " + "This is not allowed. Only user-defined properties may appear " + "listed in the " << propName << " property."; + depender->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, e.str()); + return; + } + if(emitted.insert(*pi).second) + { + getLinkInterfaceDependentProperty(depender, *pi, config, + t, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + } + } +} + +static std::string intersect(const std::set &s1, + const std::set &s2) +{ + std::set intersect; + std::set_intersection(s1.begin(),s1.end(), + s2.begin(),s2.end(), + std::inserter(intersect,intersect.begin())); + if (!intersect.empty()) + { + return *intersect.begin(); + } + return ""; +} + +static std::string intersect(const std::set &s1, + const std::set &s2, + const std::set &s3) +{ + std::string result; + result = intersect(s1, s2); + if (!result.empty()) + return result; + result = intersect(s1, s3); + if (!result.empty()) + return result; + return intersect(s2, s3); +} + +static std::string intersect(const std::set &s1, + const std::set &s2, + const std::set &s3, + const std::set &s4) +{ + std::string result; + result = intersect(s1, s2); + if (!result.empty()) + return result; + result = intersect(s1, s3); + if (!result.empty()) + return result; + result = intersect(s1, s4); + if (!result.empty()) + return result; + return intersect(s2, s3, s4); +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::CheckPropertyCompatibility( + cmComputeLinkInformation *info, const std::string& config) const +{ + const cmComputeLinkInformation::ItemVector &deps = info->GetItems(); + + std::set emittedBools; + static std::string strBool = "COMPATIBLE_INTERFACE_BOOL"; + std::set emittedStrings; + static std::string strString = "COMPATIBLE_INTERFACE_STRING"; + std::set emittedMinNumbers; + static std::string strNumMin = "COMPATIBLE_INTERFACE_NUMBER_MIN"; + std::set emittedMaxNumbers; + static std::string strNumMax = "COMPATIBLE_INTERFACE_NUMBER_MAX"; + + for(cmComputeLinkInformation::ItemVector::const_iterator li = + deps.begin(); li != deps.end(); ++li) + { + if (!li->Target) + { + continue; + } + + checkPropertyConsistency(this->Target, li->Target, + strBool, + emittedBools, config, cmTarget::BoolType, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + checkPropertyConsistency(this->Target, li->Target, + strString, + emittedStrings, config, + cmTarget::StringType, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + checkPropertyConsistency(this->Target, li->Target, + strNumMin, + emittedMinNumbers, config, + cmTarget::NumberMinType, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + checkPropertyConsistency(this->Target, li->Target, + strNumMax, + emittedMaxNumbers, config, + cmTarget::NumberMaxType, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + } + + std::string prop = intersect(emittedBools, + emittedStrings, + emittedMinNumbers, + emittedMaxNumbers); + + if (!prop.empty()) + { + // Use a sorted std::vector to keep the error message sorted. + std::vector props; + std::set::const_iterator i = emittedBools.find(prop); + if (i != emittedBools.end()) + { + props.push_back(strBool); + } + i = emittedStrings.find(prop); + if (i != emittedStrings.end()) + { + props.push_back(strString); + } + i = emittedMinNumbers.find(prop); + if (i != emittedMinNumbers.end()) + { + props.push_back(strNumMin); + } + i = emittedMaxNumbers.find(prop); + if (i != emittedMaxNumbers.end()) + { + props.push_back(strNumMax); + } + std::sort(props.begin(), props.end()); + + std::string propsString = cmJoin(cmMakeRange(props).retreat(1), ", "); + propsString += " and the " + props.back(); + + std::ostringstream e; + e << "Property \"" << prop << "\" appears in both the " + << propsString << + " property in the dependencies of target \"" << this->GetName() << + "\". This is not allowed. A property may only require compatibility " + "in a boolean interpretation, a numeric minimum, a numeric maximum or a " + "string interpretation, but not a mixture."; + this->LocalGenerator->IssueMessage(cmake::FATAL_ERROR, e.str()); + } +} //---------------------------------------------------------------------------- cmComputeLinkInformation* @@ -1550,7 +1784,7 @@ cmGeneratorTarget::GetLinkInformation(const std::string& config) const if (info) { - this->Target->CheckPropertyCompatibility(info, config); + this->CheckPropertyCompatibility(info, config); } } return i->second; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index e53f098..ae86e19 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -222,6 +222,9 @@ private: cmTargetLinkInformationMap; mutable cmTargetLinkInformationMap LinkInformation; + void CheckPropertyCompatibility(cmComputeLinkInformation *info, + const std::string& config) const; + cmGeneratorTarget(cmGeneratorTarget const&); void operator=(cmGeneratorTarget const&); }; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index d8904ea..b165545 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4554,23 +4554,16 @@ const char *getTypedProperty(cmTarget const* tgt, return tgt->GetProperty(prop); } -enum CompatibleType -{ - BoolType, - StringType, - NumberMinType, - NumberMaxType -}; - //---------------------------------------------------------------------------- template std::pair consistentProperty(PropertyType lhs, PropertyType rhs, - CompatibleType t); + cmTarget::CompatibleType t); //---------------------------------------------------------------------------- template<> -std::pair consistentProperty(bool lhs, bool rhs, CompatibleType) +std::pair consistentProperty(bool lhs, bool rhs, + cmTarget::CompatibleType) { return std::make_pair(lhs == rhs, lhs); } @@ -4585,8 +4578,8 @@ std::pair consistentStringProperty(const char *lhs, //---------------------------------------------------------------------------- std::pair consistentNumberProperty(const char *lhs, - const char *rhs, - CompatibleType t) + const char *rhs, + cmTarget::CompatibleType t) { char *pEnd; @@ -4604,7 +4597,7 @@ std::pair consistentNumberProperty(const char *lhs, return std::pair(false, null_ptr); } - if (t == NumberMaxType) + if (t == cmTarget::NumberMaxType) { return std::make_pair(true, std::max(lnum, rnum) == lnum ? lhs : rhs); } @@ -4618,7 +4611,7 @@ std::pair consistentNumberProperty(const char *lhs, template<> std::pair consistentProperty(const char *lhs, const char *rhs, - CompatibleType t) + cmTarget::CompatibleType t) { if (!lhs && !rhs) { @@ -4637,13 +4630,13 @@ std::pair consistentProperty(const char *lhs, switch(t) { - case BoolType: + case cmTarget::BoolType: assert(0 && "consistentProperty for strings called with BoolType"); return std::pair(false, null_ptr); - case StringType: + case cmTarget::StringType: return consistentStringProperty(lhs, rhs); - case NumberMinType: - case NumberMaxType: + case cmTarget::NumberMinType: + case cmTarget::NumberMaxType: return consistentNumberProperty(lhs, rhs, t); } assert(0 && "Unreachable!"); @@ -4718,17 +4711,17 @@ cmTarget::ReportPropertyOrigin(const std::string &p, } //---------------------------------------------------------------------------- -std::string compatibilityType(CompatibleType t) +std::string compatibilityType(cmTarget::CompatibleType t) { switch(t) { - case BoolType: + case cmTarget::BoolType: return "Boolean compatibility"; - case StringType: + case cmTarget::StringType: return "String compatibility"; - case NumberMaxType: + case cmTarget::NumberMaxType: return "Numeric maximum compatibility"; - case NumberMinType: + case cmTarget::NumberMinType: return "Numeric minimum compatibility"; } assert(0 && "Unreachable!"); @@ -4736,15 +4729,15 @@ std::string compatibilityType(CompatibleType t) } //---------------------------------------------------------------------------- -std::string compatibilityAgree(CompatibleType t, bool dominant) +std::string compatibilityAgree(cmTarget::CompatibleType t, bool dominant) { switch(t) { - case BoolType: - case StringType: + case cmTarget::BoolType: + case cmTarget::StringType: return dominant ? "(Disagree)\n" : "(Agree)\n"; - case NumberMaxType: - case NumberMinType: + case cmTarget::NumberMaxType: + case cmTarget::NumberMinType: return dominant ? "(Dominant)\n" : "(Ignored)\n"; } assert(0 && "Unreachable!"); @@ -4757,7 +4750,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, const std::string &p, const std::string& config, const char *defaultValue, - CompatibleType t, + cmTarget::CompatibleType t, PropertyType *) { PropertyType propContent = getTypedProperty(tgt, p); @@ -6224,240 +6217,6 @@ std::string cmTarget::CheckCMP0004(std::string const& item) const return lib; } -template -PropertyType getLinkInterfaceDependentProperty(cmTarget const* tgt, - const std::string& prop, - const std::string& config, - CompatibleType, - PropertyType *); - -template<> -bool getLinkInterfaceDependentProperty(cmTarget const* tgt, - const std::string& prop, - const std::string& config, - CompatibleType, bool *) -{ - return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); -} - -template<> -const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, - const std::string& prop, - const std::string& config, - CompatibleType t, - const char **) -{ - switch(t) - { - case BoolType: - assert(0 && "String compatibility check function called for boolean"); - return 0; - case StringType: - return tgt->GetLinkInterfaceDependentStringProperty(prop, config); - case NumberMinType: - return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config); - case NumberMaxType: - return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config); - } - assert(0 && "Unreachable!"); - return 0; -} - -//---------------------------------------------------------------------------- -template -void checkPropertyConsistency(cmTarget const* depender, - cmTarget const* dependee, - const std::string& propName, - std::set &emitted, - const std::string& config, - CompatibleType t, - PropertyType *) -{ - const char *prop = dependee->GetProperty(propName); - if (!prop) - { - return; - } - - std::vector props; - cmSystemTools::ExpandListArgument(prop, props); - std::string pdir = - dependee->GetMakefile()->GetRequiredDefinition("CMAKE_ROOT"); - pdir += "/Help/prop_tgt/"; - - for(std::vector::iterator pi = props.begin(); - pi != props.end(); ++pi) - { - std::string pname = cmSystemTools::HelpFileName(*pi); - std::string pfile = pdir + pname + ".rst"; - if(cmSystemTools::FileExists(pfile.c_str(), true)) - { - std::ostringstream e; - e << "Target \"" << dependee->GetName() << "\" has property \"" - << *pi << "\" listed in its " << propName << " property. " - "This is not allowed. Only user-defined properties may appear " - "listed in the " << propName << " property."; - depender->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, e.str()); - return; - } - if(emitted.insert(*pi).second) - { - getLinkInterfaceDependentProperty(depender, *pi, config, - t, 0); - if (cmSystemTools::GetErrorOccuredFlag()) - { - return; - } - } - } -} - -static std::string intersect(const std::set &s1, - const std::set &s2) -{ - std::set intersect; - std::set_intersection(s1.begin(),s1.end(), - s2.begin(),s2.end(), - std::inserter(intersect,intersect.begin())); - if (!intersect.empty()) - { - return *intersect.begin(); - } - return ""; -} -static std::string intersect(const std::set &s1, - const std::set &s2, - const std::set &s3) -{ - std::string result; - result = intersect(s1, s2); - if (!result.empty()) - return result; - result = intersect(s1, s3); - if (!result.empty()) - return result; - return intersect(s2, s3); -} -static std::string intersect(const std::set &s1, - const std::set &s2, - const std::set &s3, - const std::set &s4) -{ - std::string result; - result = intersect(s1, s2); - if (!result.empty()) - return result; - result = intersect(s1, s3); - if (!result.empty()) - return result; - result = intersect(s1, s4); - if (!result.empty()) - return result; - return intersect(s2, s3, s4); -} - -//---------------------------------------------------------------------------- -void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, - const std::string& config) const -{ - const cmComputeLinkInformation::ItemVector &deps = info->GetItems(); - - std::set emittedBools; - static std::string strBool = "COMPATIBLE_INTERFACE_BOOL"; - std::set emittedStrings; - static std::string strString = "COMPATIBLE_INTERFACE_STRING"; - std::set emittedMinNumbers; - static std::string strNumMin = "COMPATIBLE_INTERFACE_NUMBER_MIN"; - std::set emittedMaxNumbers; - static std::string strNumMax = "COMPATIBLE_INTERFACE_NUMBER_MAX"; - - for(cmComputeLinkInformation::ItemVector::const_iterator li = - deps.begin(); - li != deps.end(); ++li) - { - if (!li->Target) - { - continue; - } - - checkPropertyConsistency(this, li->Target, - strBool, - emittedBools, config, BoolType, 0); - if (cmSystemTools::GetErrorOccuredFlag()) - { - return; - } - checkPropertyConsistency(this, li->Target, - strString, - emittedStrings, config, - StringType, 0); - if (cmSystemTools::GetErrorOccuredFlag()) - { - return; - } - checkPropertyConsistency(this, li->Target, - strNumMin, - emittedMinNumbers, config, - NumberMinType, 0); - if (cmSystemTools::GetErrorOccuredFlag()) - { - return; - } - checkPropertyConsistency(this, li->Target, - strNumMax, - emittedMaxNumbers, config, - NumberMaxType, 0); - if (cmSystemTools::GetErrorOccuredFlag()) - { - return; - } - } - - std::string prop = intersect(emittedBools, - emittedStrings, - emittedMinNumbers, - emittedMaxNumbers); - - if (!prop.empty()) - { - // Use a sorted std::vector to keep the error message sorted. - std::vector props; - std::set::const_iterator i = emittedBools.find(prop); - if (i != emittedBools.end()) - { - props.push_back(strBool); - } - i = emittedStrings.find(prop); - if (i != emittedStrings.end()) - { - props.push_back(strString); - } - i = emittedMinNumbers.find(prop); - if (i != emittedMinNumbers.end()) - { - props.push_back(strNumMin); - } - i = emittedMaxNumbers.find(prop); - if (i != emittedMaxNumbers.end()) - { - props.push_back(strNumMax); - } - std::sort(props.begin(), props.end()); - - std::string propsString = cmJoin(cmMakeRange(props).retreat(1), ", "); - propsString += " and the " + props.back(); - - std::ostringstream e; - e << "Property \"" << prop << "\" appears in both the " - << propsString << - " property in the dependencies of target \"" << this->GetName() << - "\". This is not allowed. A property may only require compatibility " - "in a boolean interpretation, a numeric minimum, a numeric maximum or a " - "string interpretation, but not a mixture."; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); - } -} - //---------------------------------------------------------------------------- std::string cmTarget::GetFrameworkDirectory(const std::string& config, bool rootDir) const diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e3410aa..8af74ef 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -590,6 +590,14 @@ public: return this->LinkLibrariesForVS6;} #endif + enum CompatibleType + { + BoolType, + StringType, + NumberMinType, + NumberMaxType + }; + private: bool HandleLocationPropertyPolicy(cmMakefile* context) const; @@ -754,9 +762,6 @@ private: struct CompileInfo; CompileInfo const* GetCompileInfo(const std::string& config) const; - void CheckPropertyCompatibility(cmComputeLinkInformation *info, - const std::string& config) const; - LinkInterface const* GetImportLinkInterface(const std::string& config, cmTarget const* head, bool usage_requirements_only) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e699c0d6f9e8937c6d78b7da13ddc657492b7810 commit e699c0d6f9e8937c6d78b7da13ddc657492b7810 Author: Stephen Kelly AuthorDate: Thu Jun 13 21:56:07 2013 +0200 Commit: Brad King CommitDate: Mon Aug 3 14:43:04 2015 -0400 cmGeneratorTarget: Move GetLinkInformation from cmTarget diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 26ca375..4840e89 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -276,7 +276,8 @@ std::string cmCommonTargetGenerator::GetFrameworkFlags(std::string const& l) std::string flags; const char* cfg = this->LocalGenerator->GetConfigName().c_str(); - if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(cfg)) + if(cmComputeLinkInformation* cli = + this->GeneratorTarget->GetLinkInformation(cfg)) { std::vector const& frameworks = cli->GetFrameworkPaths(); for(std::vector::const_iterator i = frameworks.begin(); @@ -384,7 +385,7 @@ cmCommonTargetGenerator::GetLinkedTargetDirectories() const std::vector dirs; std::set emitted; if (cmComputeLinkInformation* cli = - this->Target->GetLinkInformation(this->ConfigName)) + this->GeneratorTarget->GetLinkInformation(this->ConfigName)) { cmComputeLinkInformation::ItemVector const& items = cli->GetItems(); for(cmComputeLinkInformation::ItemVector::const_iterator diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index a5050ff..8a2cf4b 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -529,7 +529,7 @@ void getCompatibleInterfaceProperties(cmGeneratorTarget *target, std::set &ifaceProperties, const std::string& config) { - cmComputeLinkInformation *info = target->Target->GetLinkInformation(config); + cmComputeLinkInformation *info = target->GetLinkInformation(config); if (!info) { diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 3dbeff2..845c052 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -229,6 +229,12 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) this->GlobalGenerator = this->Makefile->GetGlobalGenerator(); } +cmGeneratorTarget::~cmGeneratorTarget() +{ + cmDeleteAll(this->LinkInformation); + this->LinkInformation.clear(); +} + cmLocalGenerator* cmGeneratorTarget::GetLocalGenerator() const { return this->LocalGenerator; @@ -1517,3 +1523,35 @@ bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty( } return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0; } + + +//---------------------------------------------------------------------------- +cmComputeLinkInformation* +cmGeneratorTarget::GetLinkInformation(const std::string& config) const +{ + // Lookup any existing information for this configuration. + std::string key(cmSystemTools::UpperCase(config)); + cmTargetLinkInformationMap::iterator + i = this->LinkInformation.find(key); + if(i == this->LinkInformation.end()) + { + // Compute information for this configuration. + cmComputeLinkInformation* info = + new cmComputeLinkInformation(this->Target, config); + if(!info || !info->Compute()) + { + delete info; + info = 0; + } + + // Store the information for this configuration. + cmTargetLinkInformationMap::value_type entry(key, info); + i = this->LinkInformation.insert(entry).first; + + if (info) + { + this->Target->CheckPropertyCompatibility(info, config); + } + } + return i->second; +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 3b32bf5..e53f098 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -20,11 +20,13 @@ class cmLocalGenerator; class cmMakefile; class cmSourceFile; class cmTarget; +class cmComputeLinkInformation; class cmGeneratorTarget { public: cmGeneratorTarget(cmTarget*, cmLocalGenerator* lg); + ~cmGeneratorTarget(); cmLocalGenerator* GetLocalGenerator() const; @@ -36,6 +38,9 @@ public: location is suitable for use as the LOCATION target property. */ const char* GetLocationForBuild() const; + cmComputeLinkInformation* + GetLinkInformation(const std::string& config) const; + int GetType() const; std::string GetName() const; const char *GetProperty(const std::string& prop) const; @@ -213,6 +218,10 @@ private: }; mutable std::map CompatibleInterfacesMap; + typedef std::map + cmTargetLinkInformationMap; + mutable cmTargetLinkInformationMap LinkInformation; + cmGeneratorTarget(cmGeneratorTarget const&); void operator=(cmGeneratorTarget const&); }; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 8cb59f8..b44848c 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2202,7 +2202,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, } } // Add framework search paths needed for linking. - if(cmComputeLinkInformation* cli = target.GetLinkInformation(configName)) + if(cmComputeLinkInformation* cli = gtgt->GetLinkInformation(configName)) { std::vector const& fwDirs = cli->GetFrameworkPaths(); for(std::vector::const_iterator fdi = fwDirs.begin(); @@ -2358,7 +2358,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, this->CreateString(install_name_dir.c_str())); // Create the LD_RUNPATH_SEARCH_PATHS - cmComputeLinkInformation* pcli = target.GetLinkInformation(configName); + cmComputeLinkInformation* pcli = gtgt->GetLinkInformation(configName); if(pcli) { std::string search_paths; @@ -2964,7 +2964,8 @@ void cmGlobalXCodeGenerator } // Compute the link library and directory information. - cmComputeLinkInformation* pcli = cmtarget->GetLinkInformation(configName); + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(cmtarget); + cmComputeLinkInformation* pcli = gtgt->GetLinkInformation(configName); if(!pcli) { continue; diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 01d4b77..c64f9a3 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -18,6 +18,7 @@ #include "cmMakefile.h" #include "cmGeneratorTarget.h" #include "cmake.h" +#include "cmGeneratorTarget.h" #include @@ -557,8 +558,7 @@ cmInstallTargetGenerator // Build a map of build-tree install_name to install-tree install_name for // shared libraries linked to this target. std::map install_name_remap; - if(cmComputeLinkInformation* cli = - this->Target->Target->GetLinkInformation(config)) + if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config)) { std::set const& sharedLibs = cli->GetSharedLibrariesLinked(); @@ -667,8 +667,7 @@ cmInstallTargetGenerator // Get the link information for this target. // It can provide the RPATH. - cmComputeLinkInformation* cli = - this->Target->Target->GetLinkInformation(config); + cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config); if(!cli) { return; @@ -700,8 +699,7 @@ cmInstallTargetGenerator // Get the link information for this target. // It can provide the RPATH. - cmComputeLinkInformation* cli = - this->Target->Target->GetLinkInformation(config); + cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config); if(!cli) { return; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 6b48a44..eaf812f 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1468,7 +1468,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, bool escapeAllowMakeVars = !forResponseFile; std::ostringstream fout; std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); - cmComputeLinkInformation* pcli = tgt.Target->GetLinkInformation(config); + cmComputeLinkInformation* pcli = tgt.GetLinkInformation(config); if(!pcli) { return; diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index cab5a47..61d7847 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1846,8 +1846,10 @@ void cmLocalVisualStudio6Generator const std::string extraOptions, std::string& options) { + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); // Compute the link information for this configuration. - cmComputeLinkInformation* pcli = target.GetLinkInformation(configName); + cmComputeLinkInformation* pcli = gt->GetLinkInformation(configName); if(!pcli) { return; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 572dbde..37e08dd 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1074,6 +1074,9 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, this->ConvertToOutputFormat(this->ModuleDefinitionFile, SHELL); linkOptions.AddFlag("ModuleDefinitionFile", defFile.c_str()); } + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); + if (target.GetType() == cmTarget::SHARED_LIBRARY && this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) { @@ -1148,7 +1151,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, targetNameImport, targetNamePDB, configName); // Compute the link library and directory information. - cmComputeLinkInformation* pcli = target.GetLinkInformation(configName); + cmComputeLinkInformation* pcli = gt->GetLinkInformation(configName); if(!pcli) { return; @@ -1245,7 +1248,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, targetNameImport, targetNamePDB, configName); // Compute the link library and directory information. - cmComputeLinkInformation* pcli = target.GetLinkInformation(configName); + cmComputeLinkInformation* pcli = gt->GetLinkInformation(configName); if(!pcli) { return; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 5edc0f5..ac8cd29 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1446,7 +1446,8 @@ void cmMakefileTargetGenerator // Loop over all library dependencies. const char* cfg = this->LocalGenerator->GetConfigName().c_str(); - if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(cfg)) + if(cmComputeLinkInformation* cli = + this->GeneratorTarget->GetLinkInformation(cfg)) { std::vector const& libDeps = cli->GetDepends(); depends.insert(depends.end(), libDeps.begin(), libDeps.end()); diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 4e4dc3f..cf80424 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -195,7 +195,7 @@ cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const return cmNinjaDeps(); cmComputeLinkInformation* cli = - this->Target->GetLinkInformation(this->GetConfigName()); + this->GeneratorTarget->GetLinkInformation(this->GetConfigName()); if(!cli) return cmNinjaDeps(); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 9c7e46a..d8904ea 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -520,8 +520,6 @@ void cmTarget::ClearLinkMaps() this->Internal->LinkInterfaceUsageRequirementsOnlyMap.clear(); this->Internal->LinkClosureMap.clear(); this->Internal->SourceFilesMap.clear(); - cmDeleteAll(this->LinkInformation); - this->LinkInformation.clear(); } //---------------------------------------------------------------------------- @@ -6461,37 +6459,6 @@ void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, } //---------------------------------------------------------------------------- -cmComputeLinkInformation* -cmTarget::GetLinkInformation(const std::string& config) const -{ - // Lookup any existing information for this configuration. - std::string key(cmSystemTools::UpperCase(config)); - cmTargetLinkInformationMap::iterator - i = this->LinkInformation.find(key); - if(i == this->LinkInformation.end()) - { - // Compute information for this configuration. - cmComputeLinkInformation* info = - new cmComputeLinkInformation(this, config); - if(!info || !info->Compute()) - { - delete info; - info = 0; - } - - // Store the information for this configuration. - cmTargetLinkInformationMap::value_type entry(key, info); - i = this->LinkInformation.insert(entry).first; - - if (info) - { - this->CheckPropertyCompatibility(info, config); - } - } - return i->second; -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetFrameworkDirectory(const std::string& config, bool rootDir) const { @@ -6583,26 +6550,6 @@ std::string cmTarget::GetMacContentDirectory(const std::string& config, } //---------------------------------------------------------------------------- -cmTargetLinkInformationMap -::cmTargetLinkInformationMap(cmTargetLinkInformationMap const& r): derived() -{ - // Ideally cmTarget instances should never be copied. However until - // we can make a sweep to remove that, this copy constructor avoids - // allowing the resources (LinkInformation) from getting copied. In - // the worst case this will lead to extra cmComputeLinkInformation - // instances. We also enforce in debug mode that the map be emptied - // when copied. - static_cast(r); - assert(r.empty()); -} - -//---------------------------------------------------------------------------- -cmTargetLinkInformationMap::~cmTargetLinkInformationMap() -{ - cmDeleteAll(*this); -} - -//---------------------------------------------------------------------------- cmTargetInternalPointer::cmTargetInternalPointer() { this->Pointer = new cmTargetInternals; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index df8cdc1..e3410aa 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -78,15 +78,6 @@ public: bool FromGenex; }; -struct cmTargetLinkInformationMap: - public std::map -{ - typedef std::map derived; - cmTargetLinkInformationMap() {} - cmTargetLinkInformationMap(cmTargetLinkInformationMap const& r); - ~cmTargetLinkInformationMap(); -}; - class cmTargetInternals; class cmTargetInternalPointer { @@ -454,9 +445,6 @@ public: * install tree. For example: "\@rpath/" or "\@loader_path/". */ std::string GetInstallNameDirForInstallTree() const; - cmComputeLinkInformation* - GetLinkInformation(const std::string& config) const; - // Get the properties cmPropertyMap &GetProperties() const { return this->Properties; } @@ -766,7 +754,6 @@ private: struct CompileInfo; CompileInfo const* GetCompileInfo(const std::string& config) const; - mutable cmTargetLinkInformationMap LinkInformation; void CheckPropertyCompatibility(cmComputeLinkInformation *info, const std::string& config) const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 71785e9..f3f291a 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2438,7 +2438,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) cmSystemTools::ExpandListArgument(libs, libVec); cmComputeLinkInformation* pcli = - this->Target->GetLinkInformation(config.c_str()); + this->GeneratorTarget->GetLinkInformation(config.c_str()); if(!pcli) { cmSystemTools::Error ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From kwrobot at kitware.com Tue Aug 4 00:01:08 2015 From: kwrobot at kitware.com (Kitware Robot) Date: Tue, 4 Aug 2015 00:01:08 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-680-g331e791 Message-ID: <20150804040108.EB14EB1305@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 331e791a3e18d8335960c0161d30dbe04e3a6fe5 (commit) from 7ac2b1256b09044b86c6bd926cc239133beab088 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=331e791a3e18d8335960c0161d30dbe04e3a6fe5 commit 331e791a3e18d8335960c0161d30dbe04e3a6fe5 Author: Kitware Robot AuthorDate: Tue Aug 4 00:01:07 2015 -0400 Commit: Kitware Robot CommitDate: Tue Aug 4 00:01:07 2015 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 368ff0c..9a7ae8b 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150803) +set(CMake_VERSION_PATCH 20150804) #set(CMake_VERSION_RC 1) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Tue Aug 4 09:15:09 2015 From: brad.king at kitware.com (Brad King) Date: Tue, 4 Aug 2015 09:15:09 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-682-g4a1173f Message-ID: <20150804131509.E7007B0245@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 4a1173fda09afe8fd861b45b77d83260cec688df (commit) via 975426ceb339cf7a17f57ffba2757bb368669f93 (commit) from 331e791a3e18d8335960c0161d30dbe04e3a6fe5 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4a1173fda09afe8fd861b45b77d83260cec688df commit 4a1173fda09afe8fd861b45b77d83260cec688df Merge: 331e791 975426c Author: Brad King AuthorDate: Tue Aug 4 09:15:08 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 4 09:15:08 2015 -0400 Merge topic 'cmake-W-options' 975426ce cmake: Do not treat developer warnings as errors by default in scripts ----------------------------------------------------------------------- Summary of changes: Source/cmMessageCommand.cxx | 2 +- Source/cmake.cxx | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Tue Aug 4 09:15:11 2015 From: brad.king at kitware.com (Brad King) Date: Tue, 4 Aug 2015 09:15:11 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-684-g258470b Message-ID: <20150804131511.E57EFB02B9@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 258470bd367552994ba61b8746e04d1514ac34a6 (commit) via d951f5429a116e6174f9cdb983945cb01cf37553 (commit) from 4a1173fda09afe8fd861b45b77d83260cec688df (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=258470bd367552994ba61b8746e04d1514ac34a6 commit 258470bd367552994ba61b8746e04d1514ac34a6 Merge: 4a1173f d951f54 Author: Brad King AuthorDate: Tue Aug 4 09:15:10 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 4 09:15:10 2015 -0400 Merge topic 'doc-ninja-rule-launchers' d951f542 Help: Refine RULE_LAUNCH_{COMPILE,CUSTOM,LINK} global property docs ----------------------------------------------------------------------- Summary of changes: Help/prop_gbl/RULE_LAUNCH_COMPILE.rst | 10 ++++++---- Help/prop_gbl/RULE_LAUNCH_CUSTOM.rst | 10 ++++++---- Help/prop_gbl/RULE_LAUNCH_LINK.rst | 10 ++++++---- 3 files changed, 18 insertions(+), 12 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Tue Aug 4 09:15:13 2015 From: brad.king at kitware.com (Brad King) Date: Tue, 4 Aug 2015 09:15:13 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-687-g87b869c Message-ID: <20150804131513.EF768B0278@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 87b869c1da77f673f6397eff48b09cfb5f44f5f9 (commit) via 3da431379bae33374edd7c62c6f4261b4e3a663f (commit) via 9a59ae5c198f7c413bcaf29f1ab107a265677b95 (commit) from 258470bd367552994ba61b8746e04d1514ac34a6 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=87b869c1da77f673f6397eff48b09cfb5f44f5f9 commit 87b869c1da77f673f6397eff48b09cfb5f44f5f9 Merge: 258470b 3da4313 Author: Brad King AuthorDate: Tue Aug 4 09:15:12 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 4 09:15:12 2015 -0400 Merge topic 'update-kwsys' 3da43137 Merge branch 'upstream-kwsys' into update-kwsys 9a59ae5c KWSys 2015-08-03 (dad68c33) ----------------------------------------------------------------------- Summary of changes: Source/kwsys/EncodingC.c | 14 ++++++++++---- Source/kwsys/SystemTools.cxx | 18 ++++++++++++++++-- Source/kwsys/testSystemTools.cxx | 22 ++++++++++++++++++++++ 3 files changed, 48 insertions(+), 6 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Tue Aug 4 09:15:28 2015 From: brad.king at kitware.com (Brad King) Date: Tue, 4 Aug 2015 09:15:28 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1846-g176546c Message-ID: <20150804131528.622C8B0278@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 176546cf838362e249598060cedf57d1365940f4 (commit) via 87b869c1da77f673f6397eff48b09cfb5f44f5f9 (commit) via 258470bd367552994ba61b8746e04d1514ac34a6 (commit) via 4a1173fda09afe8fd861b45b77d83260cec688df (commit) via 331e791a3e18d8335960c0161d30dbe04e3a6fe5 (commit) from 3c77f9ca3a67d5c94251154a391991b8b2146be5 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=176546cf838362e249598060cedf57d1365940f4 commit 176546cf838362e249598060cedf57d1365940f4 Merge: 3c77f9c 87b869c Author: Brad King AuthorDate: Tue Aug 4 09:15:21 2015 -0400 Commit: Brad King CommitDate: Tue Aug 4 09:15:21 2015 -0400 Merge branch 'master' into next ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Tue Aug 4 09:49:05 2015 From: brad.king at kitware.com (Brad King) Date: Tue, 4 Aug 2015 09:49:05 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1849-gc783951 Message-ID: <20150804134905.75F35B0AF5@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via c783951c1fa1f6508145a845b0a00b2d1b17eeb0 (commit) via 133ea6a940d698a75c118c5d3e7350c472f6e8fb (commit) via 5cc55b9331b7b8844c331657ac60c3293dce9fc3 (commit) from 176546cf838362e249598060cedf57d1365940f4 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c783951c1fa1f6508145a845b0a00b2d1b17eeb0 commit c783951c1fa1f6508145a845b0a00b2d1b17eeb0 Merge: 176546c 133ea6a Author: Brad King AuthorDate: Tue Aug 4 09:49:04 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 4 09:49:04 2015 -0400 Merge topic 'use-generator-target' into next 133ea6a9 Revert "cmGlobalGenerator: Base exclusion computation on cmGeneratorTarget." 5cc55b93 Revert "cmMakefile: Remove unused method." http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=133ea6a940d698a75c118c5d3e7350c472f6e8fb commit 133ea6a940d698a75c118c5d3e7350c472f6e8fb Author: Brad King AuthorDate: Tue Aug 4 09:32:42 2015 -0400 Commit: Brad King CommitDate: Tue Aug 4 09:33:33 2015 -0400 Revert "cmGlobalGenerator: Base exclusion computation on cmGeneratorTarget." This reverts commit ffc27b83b4f3a31c1c38cdc7edc8a6d37ed1977d. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index b14949a..1d6608b 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2022,10 +2022,10 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, } bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, - cmGeneratorTarget* target) const + cmTarget const& target) const { - if(target->GetType() == cmTarget::INTERFACE_LIBRARY - || target->Target->GetPropertyAsBool("EXCLUDE_FROM_ALL")) + if(target.GetType() == cmTarget::INTERFACE_LIBRARY + || target.GetPropertyAsBool("EXCLUDE_FROM_ALL")) { // This target is excluded from its directory. return true; @@ -2034,7 +2034,7 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, { // This target is included in its directory. Check whether the // directory is excluded. - return this->IsExcluded(root, target->GetLocalGenerator()); + return this->IsExcluded(root, target.GetMakefile()->GetLocalGenerator()); } } @@ -2095,16 +2095,15 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap() { cmTarget const& target = t->second; - cmGeneratorTarget* gt = this->GetGeneratorTarget(&target); - // Consider the directory containing the target and all its // parents until something excludes the target. - for(cmLocalGenerator* clg = lg; clg && !this->IsExcluded(clg, gt); + for(cmLocalGenerator* clg = lg; clg && !this->IsExcluded(clg, target); clg = clg->GetParent()) { // This local generator includes the target. std::set& targetSet = this->LocalGeneratorToTargetMap[clg]; + cmGeneratorTarget* gt = this->GetGeneratorTarget(&target); targetSet.insert(gt); // Add dependencies of the included target. An excluded diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 3be76b6..9492372 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -398,7 +398,7 @@ protected: void FillProjectMap(); void CheckLocalGenerators(); bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen) const; - bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) const; + bool IsExcluded(cmLocalGenerator* root, cmTarget const& target) const; void FillLocalGeneratorToTargetMap(); void CreateDefaultGlobalTargets(cmTargets* targets); cmTarget CreateGlobalTarget(const std::string& name, const char* message, diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 47822b4..2a749c1 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -289,7 +289,7 @@ public: const std::vector& GetLocalGenerators() const { return LocalGenerators; } - bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) { + bool IsExcluded(cmLocalGenerator* root, cmTarget& target) { return cmGlobalGenerator::IsExcluded(root, target); } int GetRuleCmdLength(const std::string& name) { diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 76d059ee..69747a4 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -821,7 +821,7 @@ cmGlobalUnixMakefileGenerator3 localName, depends, commands, true); // add the all/all dependency - if(!this->IsExcluded(this->LocalGenerators[0], gtarget)) + if(!this->IsExcluded(this->LocalGenerators[0], *gtarget->Target)) { depends.clear(); depends.push_back(localName); @@ -889,7 +889,7 @@ cmGlobalUnixMakefileGenerator3 "Pre-install relink rule for target.", localName, depends, commands, true); - if(!this->IsExcluded(this->LocalGenerators[0], gtarget)) + if(!this->IsExcluded(this->LocalGenerators[0], *gtarget->Target)) { depends.clear(); depends.push_back(localName); diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index c06dfb3..2f9d79a 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -111,18 +111,17 @@ bool cmGlobalVisualStudioGenerator::Compute() for(std::vector::iterator i = gen.begin(); i != gen.end(); ++i) { - cmGeneratorTargetsType targets = - (*i)->GetMakefile()->GetGeneratorTargets(); - for(cmGeneratorTargetsType::iterator t = targets.begin(); + cmTargets& targets = (*i)->GetMakefile()->GetTargets(); + for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t) { - if (t->second->GetType() == cmTarget::GLOBAL_TARGET) + if (t->second.GetType() == cmTarget::GLOBAL_TARGET) { continue; } if(!this->IsExcluded(gen[0], t->second)) { - allBuild->AddUtility(t->second->GetName()); + allBuild->AddUtility(t->second.GetName()); } } } diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 1822c97..9889bd4 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -90,7 +90,7 @@ void cmLocalNinjaGenerator::Generate() // Add the target to "all" if required. if (!this->GetGlobalNinjaGenerator()->IsExcluded( this->GetGlobalNinjaGenerator()->GetLocalGenerators()[0], - t->second)) + *t->second->Target)) this->GetGlobalNinjaGenerator()->AddDependencyToAll(t->second->Target); delete tg; } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5cc55b9331b7b8844c331657ac60c3293dce9fc3 commit 5cc55b9331b7b8844c331657ac60c3293dce9fc3 Author: Brad King AuthorDate: Tue Aug 4 09:33:19 2015 -0400 Commit: Brad King CommitDate: Tue Aug 4 09:33:31 2015 -0400 Revert "cmMakefile: Remove unused method." This reverts commit 968e1ca548746ff92770c11ec5e524af548f4419. diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 00d4005..1e5c301 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -113,6 +113,10 @@ public: bool GetIsSourceFileTryCompile() const; + ///! Get the current makefile generator. + cmLocalGenerator* GetLocalGenerator() const + { return this->LocalGenerator;} + /** * Help enforce global target name uniqueness. */ ----------------------------------------------------------------------- Summary of changes: Source/cmGlobalGenerator.cxx | 13 ++++++------- Source/cmGlobalGenerator.h | 2 +- Source/cmGlobalNinjaGenerator.h | 2 +- Source/cmGlobalUnixMakefileGenerator3.cxx | 4 ++-- Source/cmGlobalVisualStudioGenerator.cxx | 9 ++++----- Source/cmLocalNinjaGenerator.cxx | 2 +- Source/cmMakefile.h | 4 ++++ 7 files changed, 19 insertions(+), 17 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Tue Aug 4 11:19:17 2015 From: brad.king at kitware.com (Brad King) Date: Tue, 4 Aug 2015 11:19:17 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1851-g97b5cdd Message-ID: <20150804151917.9AAA0B0597@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 97b5cddf8e80efbca9ecfe324aed94e27225618c (commit) via cfd751f140d546810fc2fa718f00a069e18ea1fd (commit) from c783951c1fa1f6508145a845b0a00b2d1b17eeb0 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=97b5cddf8e80efbca9ecfe324aed94e27225618c commit 97b5cddf8e80efbca9ecfe324aed94e27225618c Merge: c783951 cfd751f Author: Brad King AuthorDate: Tue Aug 4 11:19:16 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 4 11:19:16 2015 -0400 Merge topic 'java-updates' into next cfd751f1 Revise topic 'java-updates' http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cfd751f140d546810fc2fa718f00a069e18ea1fd commit cfd751f140d546810fc2fa718f00a069e18ea1fd Author: Brad King AuthorDate: Tue Aug 4 11:18:23 2015 -0400 Commit: Brad King CommitDate: Tue Aug 4 11:18:23 2015 -0400 Revise topic 'java-updates' diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index bc8373b..5781a9e 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -3011,26 +3011,27 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release add_test(Java.Jar ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/Java" - "${CMake_BINARY_DIR}/Tests/Java" + "${CMake_BINARY_DIR}/Tests/JavaJar" ${build_generator_args} --build-project hello --build-target hello --build-two-config - --build-run-dir "${CMake_BINARY_DIR}/Tests/Java/" + --build-run-dir "${CMake_BINARY_DIR}/Tests/JavaJar/" --build-options ${build_options} --test-command ${JAVA_RUNTIME} -classpath hello.jar HelloWorld) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJar") add_test(Java.JarSourceList ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/Java" - "${CMake_BINARY_DIR}/Tests/Java" + "${CMake_BINARY_DIR}/Tests/JavaJarSourceList" ${build_generator_args} --build-project hello --build-target hello2 --build-two-config - --build-run-dir "${CMake_BINARY_DIR}/Tests/Java/" + --build-run-dir "${CMake_BINARY_DIR}/Tests/JavaJarSourceList/" --build-options ${build_options} --test-command ${JAVA_RUNTIME} -classpath hello2.jar HelloWorld) - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Java") + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJarSourceList") endif() endif() endif() ----------------------------------------------------------------------- Summary of changes: Tests/CMakeLists.txt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Tue Aug 4 11:20:58 2015 From: brad.king at kitware.com (Brad King) Date: Tue, 4 Aug 2015 11:20:58 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1855-ga62d22e Message-ID: <20150804152058.1E342B0958@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via a62d22ed4cf8be3e53718add6be1c4dd7db2922e (commit) via cc23f0e9d38fe3f880ada549af4e552fc13fc655 (commit) via 3d287de4ea99718ffe2ac6b855c2786d67946be2 (commit) via e72806fb30dd9162aa1b05cb478ae51d1ecd27fa (commit) from 97b5cddf8e80efbca9ecfe324aed94e27225618c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a62d22ed4cf8be3e53718add6be1c4dd7db2922e commit a62d22ed4cf8be3e53718add6be1c4dd7db2922e Merge: 97b5cdd cc23f0e Author: Brad King AuthorDate: Tue Aug 4 11:20:57 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 4 11:20:57 2015 -0400 Merge topic 'java-updates' into next cc23f0e9 UseJava: Teach install_jar new DESTINATION and COMPONENT options 3d287de4 UseJava: Teach add_jar to support file syntax for sources e72806fb FindJava: Add support for idlj and jarsigner tools http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cc23f0e9d38fe3f880ada549af4e552fc13fc655 commit cc23f0e9d38fe3f880ada549af4e552fc13fc655 Author: Marc Chevrier AuthorDate: Thu Jul 30 11:19:24 2015 +0200 Commit: Brad King CommitDate: Tue Aug 4 11:19:44 2015 -0400 UseJava: Teach install_jar new DESTINATION and COMPONENT options diff --git a/Help/release/dev/java-updates.rst b/Help/release/dev/java-updates.rst index 2e5e184..b777807 100644 --- a/Help/release/dev/java-updates.rst +++ b/Help/release/dev/java-updates.rst @@ -7,3 +7,7 @@ java-updates * The :module:`UseJava` module ``add_jar`` function learned to support response files (e.g. ``@srcs.txt``) for source specification. + +* The :module:`UseJava` module ``install_jar`` function learned + new ``DESTINATION`` and ``COMPONENT`` options to specify + the corresponding :command:`install` command options. diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake index 0add8d2..c61591d 100644 --- a/Modules/UseJava.cmake +++ b/Modules/UseJava.cmake @@ -211,14 +211,16 @@ # # :: # -# install_jar(TARGET_NAME DESTINATION) +# install_jar(target_name destination) +# install_jar(target_name DESTINATION destination [COMPONENT component]) # # This command installs the TARGET_NAME files to the given DESTINATION. # It should be called in the same scope as add_jar() or it will fail. # # :: # -# install_jni_symlink(TARGET_NAME DESTINATION) +# install_jni_symlink(target_name destination) +# install_jni_symlink(target_name DESTINATION destination [COMPONENT component]) # # This command installs the TARGET_NAME JNI symlinks to the given # DESTINATION. It should be called in the same scope as add_jar() or it @@ -629,7 +631,26 @@ function(add_jar _TARGET_NAME) endfunction() -function(INSTALL_JAR _TARGET_NAME _DESTINATION) +function(INSTALL_JAR _TARGET_NAME) + if (ARGC EQUAL 2) + set (_DESTINATION ${ARGV1}) + else() + cmake_parse_arguments(_install_jar + "" + "DESTINATION;COMPONENT" + "" + ${ARGN}) + if (_install_jar_DESTINATION) + set (_DESTINATION ${_install_jar_DESTINATION}) + else() + message(SEND_ERROR "install_jar: ${_TARGET_NAME}: DESTINATION must be specified.") + endif() + + if (_install_jar_COMPONENT) + set (_COMPONENT COMPONENT ${_install_jar_COMPONENT}) + endif() + endif() + get_property(__FILES TARGET ${_TARGET_NAME} @@ -643,13 +664,33 @@ function(INSTALL_JAR _TARGET_NAME _DESTINATION) ${__FILES} DESTINATION ${_DESTINATION} + ${_COMPONENT} ) else () - message(SEND_ERROR "The target ${_TARGET_NAME} is not known in this scope.") + message(SEND_ERROR "install_jar: The target ${_TARGET_NAME} is not known in this scope.") endif () endfunction() -function(INSTALL_JNI_SYMLINK _TARGET_NAME _DESTINATION) +function(INSTALL_JNI_SYMLINK _TARGET_NAME) + if (ARGC EQUAL 2) + set (_DESTINATION ${ARGV1}) + else() + cmake_parse_arguments(_install_jni_symlink + "" + "DESTINATION;COMPONENT" + "" + ${ARGN}) + if (_install_jni_symlink_DESTINATION) + set (_DESTINATION ${_install_jni_symlink_DESTINATION}) + else() + message(SEND_ERROR "install_jni_symlink: ${_TARGET_NAME}: DESTINATION must be specified.") + endif() + + if (_install_jni_symlink_COMPONENT) + set (_COMPONENT COMPONENT ${_install_jni_symlink_COMPONENT}) + endif() + endif() + get_property(__SYMLINK TARGET ${_TARGET_NAME} @@ -663,9 +704,10 @@ function(INSTALL_JNI_SYMLINK _TARGET_NAME _DESTINATION) ${__SYMLINK} DESTINATION ${_DESTINATION} + ${_COMPONENT} ) else () - message(SEND_ERROR "The target ${_TARGET_NAME} is not known in this scope.") + message(SEND_ERROR "install_jni_symlink: The target ${_TARGET_NAME} is not known in this scope.") endif () endfunction() http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3d287de4ea99718ffe2ac6b855c2786d67946be2 commit 3d287de4ea99718ffe2ac6b855c2786d67946be2 Author: Marc Chevrier AuthorDate: Thu Jul 30 11:17:04 2015 +0200 Commit: Brad King CommitDate: Tue Aug 4 11:19:43 2015 -0400 UseJava: Teach add_jar to support file syntax for sources diff --git a/Help/release/dev/java-updates.rst b/Help/release/dev/java-updates.rst index 94998eb..2e5e184 100644 --- a/Help/release/dev/java-updates.rst +++ b/Help/release/dev/java-updates.rst @@ -3,3 +3,7 @@ java-updates * The :module:`FindJava` module learned to optionally find the ``idlj`` and ``jarsigner`` tools. + +* The :module:`UseJava` module ``add_jar`` function learned + to support response files (e.g. ``@srcs.txt``) for source + specification. diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake index 5eb0ca8..0add8d2 100644 --- a/Modules/UseJava.cmake +++ b/Modules/UseJava.cmake @@ -21,7 +21,8 @@ # # This command creates a .jar. It compiles the given # source files (source) and adds the given resource files (resource) to -# the jar file. If only resource files are given then just a jar file +# the jar file. Source files can be java files or listing files +# (prefixed by '@'). If only resource files are given then just a jar file # is created. The list of include jars are added to the classpath when # compiling the java sources and also to the dependencies of the target. # INCLUDE_JARS also accepts other target names created by add_jar. For @@ -423,6 +424,7 @@ function(add_jar _TARGET_NAME) set(_JAVA_CLASS_FILES) set(_JAVA_COMPILE_FILES) + set(_JAVA_COMPILE_FILELISTS) set(_JAVA_DEPENDS) set(_JAVA_COMPILE_DEPENDS) set(_JAVA_RESOURCE_FILES) @@ -433,7 +435,11 @@ function(add_jar _TARGET_NAME) get_filename_component(_JAVA_PATH ${_JAVA_SOURCE_FILE} PATH) get_filename_component(_JAVA_FULL ${_JAVA_SOURCE_FILE} ABSOLUTE) - if (_JAVA_EXT MATCHES ".java") + if (_JAVA_SOURCE_FILE MATCHES "^@(.+)$") + get_filename_component(_JAVA_FULL ${CMAKE_MATCH_1} ABSOLUTE) + list(APPEND _JAVA_COMPILE_FILELISTS ${_JAVA_FULL}) + + elseif (_JAVA_EXT MATCHES ".java") file(RELATIVE_PATH _JAVA_REL_BINARY_PATH ${_add_jar_OUTPUT_DIR} ${_JAVA_FULL}) file(RELATIVE_PATH _JAVA_REL_SOURCE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${_JAVA_FULL}) string(LENGTH ${_JAVA_REL_BINARY_PATH} _BIN_LEN) @@ -492,11 +498,21 @@ function(add_jar _TARGET_NAME) file(WRITE ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist "") endif() - if (_JAVA_COMPILE_FILES) - # Create the list of files to compile. - set(_JAVA_SOURCES_FILE ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_sources) - string(REPLACE ";" "\"\n\"" _JAVA_COMPILE_STRING "\"${_JAVA_COMPILE_FILES}\"") - file(WRITE ${_JAVA_SOURCES_FILE} ${_JAVA_COMPILE_STRING}) + if (_JAVA_COMPILE_FILES OR _JAVA_COMPILE_FILELISTS) + set (_JAVA_SOURCES_FILELISTS) + + if (_JAVA_COMPILE_FILES) + # Create the list of files to compile. + set(_JAVA_SOURCES_FILE ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_sources) + string(REPLACE ";" "\"\n\"" _JAVA_COMPILE_STRING "\"${_JAVA_COMPILE_FILES}\"") + file(WRITE ${_JAVA_SOURCES_FILE} ${_JAVA_COMPILE_STRING}) + list (APPEND _JAVA_SOURCES_FILELISTS "@${_JAVA_SOURCES_FILE}") + endif() + if (_JAVA_COMPILE_FILELISTS) + foreach (_JAVA_FILELIST IN LISTS _JAVA_COMPILE_FILELISTS) + list (APPEND _JAVA_SOURCES_FILELISTS "@${_JAVA_FILELIST}") + endforeach() + endif() # Compile the java files and create a list of class files add_custom_command( @@ -506,9 +522,9 @@ function(add_jar _TARGET_NAME) ${CMAKE_JAVA_COMPILE_FLAGS} -classpath "${CMAKE_JAVA_INCLUDE_PATH_FINAL}" -d ${CMAKE_JAVA_CLASS_OUTPUT_PATH} - @${_JAVA_SOURCES_FILE} + ${_JAVA_SOURCES_FILELISTS} COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_compiled_${_TARGET_NAME} - DEPENDS ${_JAVA_COMPILE_FILES} ${_JAVA_COMPILE_DEPENDS} + DEPENDS ${_JAVA_COMPILE_FILES} ${_JAVA_COMPILE_FILELISTS} ${_JAVA_COMPILE_DEPENDS} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMENT "Building Java objects for ${_TARGET_NAME}.jar" ) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index d95a5f4..5781a9e 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -3008,17 +3008,30 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release if(JNI_H AND EXISTS "${JNI_H}") # in case jni.h is a broken symlink file(READ "${JNI_H}" JNI_FILE) if("${JNI_FILE}" MATCHES "JDK1_2") - add_test(Java ${CMAKE_CTEST_COMMAND} + add_test(Java.Jar ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/Java" - "${CMake_BINARY_DIR}/Tests/Java" + "${CMake_BINARY_DIR}/Tests/JavaJar" ${build_generator_args} --build-project hello + --build-target hello --build-two-config - --build-run-dir "${CMake_BINARY_DIR}/Tests/Java/" + --build-run-dir "${CMake_BINARY_DIR}/Tests/JavaJar/" --build-options ${build_options} --test-command ${JAVA_RUNTIME} -classpath hello.jar HelloWorld) - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Java") + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJar") + add_test(Java.JarSourceList ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/Java" + "${CMake_BINARY_DIR}/Tests/JavaJarSourceList" + ${build_generator_args} + --build-project hello + --build-target hello2 + --build-two-config + --build-run-dir "${CMake_BINARY_DIR}/Tests/JavaJarSourceList/" + --build-options ${build_options} + --test-command ${JAVA_RUNTIME} -classpath hello2.jar HelloWorld) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJarSourceList") endif() endif() endif() diff --git a/Tests/Java/CMakeLists.txt b/Tests/Java/CMakeLists.txt index 6a69a24..e1bcf3c 100644 --- a/Tests/Java/CMakeLists.txt +++ b/Tests/Java/CMakeLists.txt @@ -7,3 +7,7 @@ find_package(Java COMPONENTS Development) include (UseJava) add_jar(hello A.java HelloWorld.java) + +# use listing file to specify sources +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/java_fileslist "A.java\nHelloWorld.java\n") +add_jar(hello2 @${CMAKE_CURRENT_BINARY_DIR}/java_fileslist) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e72806fb30dd9162aa1b05cb478ae51d1ecd27fa commit e72806fb30dd9162aa1b05cb478ae51d1ecd27fa Author: Marc Chevrier AuthorDate: Fri Jul 31 10:00:43 2015 +0200 Commit: Brad King CommitDate: Tue Aug 4 11:19:40 2015 -0400 FindJava: Add support for idlj and jarsigner tools diff --git a/Help/release/dev/java-updates.rst b/Help/release/dev/java-updates.rst new file mode 100644 index 0000000..94998eb --- /dev/null +++ b/Help/release/dev/java-updates.rst @@ -0,0 +1,5 @@ +java-updates +------------ + +* The :module:`FindJava` module learned to optionally find + the ``idlj`` and ``jarsigner`` tools. diff --git a/Modules/FindJava.cmake b/Modules/FindJava.cmake index 9e43174..9f87997 100644 --- a/Modules/FindJava.cmake +++ b/Modules/FindJava.cmake @@ -8,21 +8,34 @@ # include files and libraries are. The caller may set variable JAVA_HOME # to specify a Java installation prefix explicitly. # +# +# Specify one or more of the following components as you call this find module. See example below. +# +# :: +# +# Runtime = User just want to execute some Java byte-compiled +# Development = Development tools (java, javac, javah and javadoc), includes Runtime component +# IdlJ = idl compiler for Java +# JarSigner = signer tool for jar +# +# # This module sets the following result variables: # # :: # -# Java_JAVA_EXECUTABLE = the full path to the Java runtime -# Java_JAVAC_EXECUTABLE = the full path to the Java compiler -# Java_JAVAH_EXECUTABLE = the full path to the Java header generator -# Java_JAVADOC_EXECUTABLE = the full path to the Java documention generator -# Java_JAR_EXECUTABLE = the full path to the Java archiver -# Java_VERSION_STRING = Version of java found, eg. 1.6.0_12 -# Java_VERSION_MAJOR = The major version of the package found. -# Java_VERSION_MINOR = The minor version of the package found. -# Java_VERSION_PATCH = The patch version of the package found. -# Java_VERSION_TWEAK = The tweak version of the package found (after '_') -# Java_VERSION = This is set to: $major.$minor.$patch(.$tweak) +# Java_JAVA_EXECUTABLE = the full path to the Java runtime +# Java_JAVAC_EXECUTABLE = the full path to the Java compiler +# Java_JAVAH_EXECUTABLE = the full path to the Java header generator +# Java_JAVADOC_EXECUTABLE = the full path to the Java documention generator +# Java_IDLJ_EXECUTABLE = the full path to the Java idl compiler +# Java_JAR_EXECUTABLE = the full path to the Java archiver +# Java_JARSIGNER_EXECUTABLE = the full path to the Java jar signer +# Java_VERSION_STRING = Version of java found, eg. 1.6.0_12 +# Java_VERSION_MAJOR = The major version of the package found. +# Java_VERSION_MINOR = The minor version of the package found. +# Java_VERSION_PATCH = The patch version of the package found. +# Java_VERSION_TWEAK = The tweak version of the package found (after '_') +# Java_VERSION = This is set to: $major.$minor.$patch(.$tweak) # # # @@ -184,28 +197,61 @@ find_program(Java_JAVADOC_EXECUTABLE PATHS ${_JAVA_PATHS} ) +find_program(Java_IDLJ_EXECUTABLE + NAMES idlj + HINTS ${_JAVA_HINTS} + PATHS ${_JAVA_PATHS} +) + +find_program(Java_JARSIGNER_EXECUTABLE + NAMES jarsigner + HINTS ${_JAVA_HINTS} + PATHS ${_JAVA_PATHS} +) + include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) if(Java_FIND_COMPONENTS) + set(_JAVA_REQUIRED_VARS) foreach(component ${Java_FIND_COMPONENTS}) # User just want to execute some Java byte-compiled - if(component STREQUAL "Runtime") - find_package_handle_standard_args(Java - REQUIRED_VARS Java_JAVA_EXECUTABLE - VERSION_VAR Java_VERSION - ) + If(component STREQUAL "Runtime") + list(APPEND _JAVA_REQUIRED_VARS Java_JAVA_EXECUTABLE) + if(Java_JAVA_EXECUTABLE) + set(Java_Runtime_FOUND TRUE) + endif() elseif(component STREQUAL "Development") - find_package_handle_standard_args(Java - REQUIRED_VARS Java_JAVA_EXECUTABLE Java_JAR_EXECUTABLE Java_JAVAC_EXECUTABLE - Java_JAVAH_EXECUTABLE Java_JAVADOC_EXECUTABLE - VERSION_VAR Java_VERSION - ) + list(APPEND _JAVA_REQUIRED_VARS Java_JAVA_EXECUTABLE Java_JAVAC_EXECUTABLE + Java_JAVAH_EXECUTABLE Java_JAVADOC_EXECUTABLE) + if(Java_JAVA_EXECUTABLE AND Java_JAVAC_EXECUTABLE + AND Java_JAVAH_EXECUTABLE AND Java_JAVADOC_EXECUTABLE) + set(Java_Development_FOUND TRUE) + endif() + elseif(component STREQUAL "IdlJ") + list(APPEND _JAVA_REQUIRED_VARS Java_IDLJ_EXECUTABLE) + if(Java_IdlJ_EXECUTABLE) + set(Java_Extra_FOUND TRUE) + endif() + elseif(component STREQUAL "JarSigner") + list(APPEND _JAVA_REQUIRED_VARS Java_JARSIGNER_EXECUTABLE) + if(Java_IDLJ_EXECUTABLE) + set(Java_JarSigner_FOUND TRUE) + endif() else() message(FATAL_ERROR "Comp: ${component} is not handled") endif() - set(Java_${component}_FOUND TRUE) endforeach() + list (REMOVE_DUPLICATES _JAVA_REQUIRED_VARS) + find_package_handle_standard_args(Java + REQUIRED_VARS ${_JAVA_REQUIRED_VARS} HANDLE_COMPONENTS + VERSION_VAR Java_VERSION + ) + if(Java_FOUND) + foreach(component ${Java_FIND_COMPONENTS}) + set(Java_${component}_FOUND TRUE) + endforeach() + endif() else() - # Check for everything + # Check for Development find_package_handle_standard_args(Java REQUIRED_VARS Java_JAVA_EXECUTABLE Java_JAR_EXECUTABLE Java_JAVAC_EXECUTABLE Java_JAVAH_EXECUTABLE Java_JAVADOC_EXECUTABLE @@ -220,6 +266,8 @@ mark_as_advanced( Java_JAVAC_EXECUTABLE Java_JAVAH_EXECUTABLE Java_JAVADOC_EXECUTABLE + Java_IDLJ_EXECUTABLE + Java_JARSIGNER_EXECUTABLE ) # LEGACY ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From steveire at gmail.com Tue Aug 4 13:20:37 2015 From: steveire at gmail.com (Stephen Kelly) Date: Tue, 4 Aug 2015 13:20:37 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1892-ge12067e Message-ID: <20150804172037.B3494B0305@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via e12067e28975b01aca849ee1d55656d3ba23c694 (commit) via 3760cc890b0a13b4cf31dda77047e92b3ac2ea19 (commit) via fc28823e87b86b5aed3ec355889a352ca171994e (commit) via db3100f7ab4b844070f6cdbd8fa61eb90f404166 (commit) via 8a89793258af88c11d63c3426fe07f6aee66f963 (commit) via 47f6495f520447e66eda98bdb9fc622f651e164d (commit) via 9c840669c250dd37348be973b63b7e29ce0f6363 (commit) via 86a622bb3bde32bce5e660747b9811356c84e42d (commit) via 23642b4e767611e283f33f0ae3a1bf0bdd8b0017 (commit) via f2b1f037358d7298ca302f5b5a676bd03ad77604 (commit) via db6e978ee79797f6899a7a965cc105a945f99caa (commit) via de2d705c0e0c4e0de910cc5f3874fc898d455634 (commit) via 9f4b3c8e60590576dbad108cd6a739679301ed3e (commit) via 49b4dc1ec857ceeccd63c3a7f5d8bb5167a16f41 (commit) via cd7c204cef7bf52e49aa20cfa669d9db5ddcb08f (commit) via f7a6b821224f5d54f8b255a2d547f51d434d2a34 (commit) via 41a64c59c6276e247d801248dc5be21ded76cc0d (commit) via 4bd1cd9a5c80bdf858777450ecdbdd71f80ad83e (commit) via 82c377564b26a346e6a75c71956d2633f7463ef2 (commit) via a8b2a0e500424abed91cb06a58baef8e5c26dd77 (commit) via 381788822634315ca6f5be46cebdf9e2a80aeba3 (commit) via 6d031d2891ab567ae6d868bb5959b877bbf225ab (commit) via 77d8a8b8ac2177e4a193fa602a76483ce99319d2 (commit) via 3f9edf779b2363f10ac6acaa915a55ccb872b347 (commit) via ec2f478af178d35606a3b4024879df1121e5bf20 (commit) via 452ec942b08a83390736cc9b50f6006adef38bde (commit) via 50c11c585e9b2a8050c31a6b7179379fa2472b23 (commit) via 3009936bba98cbe03514c60567ab104a2b22a526 (commit) via 2c5b01bc544299e6461ffb04e004e39dedb03b0c (commit) via 7580640aec82a7a175c3f9054df4a44233ecbd7c (commit) via 25053a1b5691b774e4fe800f4bca97aeecbc9547 (commit) via 9ab2eb2d622ad18cb027ada68ba95d4b5817ac30 (commit) via 11bce89dc927b7928dafb24989d437f03bd41f54 (commit) via f0a5a551cc64a0d6188f9a6ee1969348eb6e80c7 (commit) via 4085e2bde2a87b9526b2fdc2dfd4bd9329c367fd (commit) via 1aa13f2b58e477095f76d28a8d9bb1b83a9dd1f5 (commit) via 1ab59f688f647abe1bc0b5e7a187ec0bac988e0f (commit) from a62d22ed4cf8be3e53718add6be1c4dd7db2922e (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e12067e28975b01aca849ee1d55656d3ba23c694 commit e12067e28975b01aca849ee1d55656d3ba23c694 Merge: a62d22e 3760cc8 Author: Stephen Kelly AuthorDate: Tue Aug 4 13:20:32 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 4 13:20:32 2015 -0400 Merge topic 'use-generator-target' into next 3760cc89 cmOrderDirectories: Port to cmGeneratorTarget. fc28823e cmGeneratorTarget: Move CompileInfoMap from cmTarget. db3100f7 cmGeneratorTarget: Move GetCompilePDBDirectory from cmTarget. 8a897932 cmGeneratorTarget: Move GetOutputName from cmTarget. 47f6495f cmComputeLinkDepends: Port to cmGeneratorTarget. 9c840669 cmComputeLinkInformation: Port to cmGeneratorTarget. 86a622bb cmGeneratorTarget: Move IsBundleOnApple from cmTarget. 23642b4e cmMakefileTargetGenerator: Add accessor for GeneratorTarget. f2b1f037 cmGeneratorTarget: Move GetLinkClosure from cmTarget. db6e978e cmGeneratorTarget: Move GetLinkerLanguage from cmTarget. de2d705c cmGeneratorTarget: Move GetFrameworkDirectory from cmTarget. 9f4b3c8e cmGeneratorTarget: Move GetFullName from cmTarget. 49b4dc1e cmGeneratorTarget: Move GetAppBundleDirectory from cmTarget. cd7c204c cmGeneratorTarget: Move GetInstallNameDir* from cmTarget. f7a6b821 cmGeneratorTarget: Move GetMacContentDirectory from cmTarget. 41a64c59 cmGeneratorTarget: Move GetFullNameComponents from cmTarget. ... http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3760cc890b0a13b4cf31dda77047e92b3ac2ea19 commit 3760cc890b0a13b4cf31dda77047e92b3ac2ea19 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:51 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 4 19:19:51 2015 +0200 cmOrderDirectories: Port to cmGeneratorTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 5cd0d54..e0c6e86 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -260,10 +260,10 @@ cmComputeLinkInformation // Allocate internals. this->OrderLinkerSearchPath = - new cmOrderDirectories(this->GlobalGenerator, target->Target, + new cmOrderDirectories(this->GlobalGenerator, target, "linker search path"); this->OrderRuntimeSearchPath = - new cmOrderDirectories(this->GlobalGenerator, target->Target, + new cmOrderDirectories(this->GlobalGenerator, target, "runtime search path"); this->OrderDependentRPath = 0; @@ -370,7 +370,7 @@ cmComputeLinkInformation { this->SharedDependencyMode = SharedDepModeDir; this->OrderDependentRPath = - new cmOrderDirectories(this->GlobalGenerator, target->Target, + new cmOrderDirectories(this->GlobalGenerator, target, "dependent library path"); } diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx index a612437..35ee127 100644 --- a/Source/cmOrderDirectories.cxx +++ b/Source/cmOrderDirectories.cxx @@ -280,7 +280,7 @@ bool cmOrderDirectoriesConstraintLibrary::FindConflict(std::string const& dir) //---------------------------------------------------------------------------- cmOrderDirectories::cmOrderDirectories(cmGlobalGenerator* gg, - cmTarget const* target, + const cmGeneratorTarget* target, const char* purpose) { this->GlobalGenerator = gg; @@ -554,7 +554,8 @@ void cmOrderDirectories::FindImplicitConflicts() << text << "Some of these libraries may not be found correctly."; this->GlobalGenerator->GetCMakeInstance() - ->IssueMessage(cmake::WARNING, w.str(), this->Target->GetBacktrace()); + ->IssueMessage(cmake::WARNING, w.str(), + this->Target->Target->GetBacktrace()); } //---------------------------------------------------------------------------- @@ -635,5 +636,6 @@ void cmOrderDirectories::DiagnoseCycle() } e << "Some of these libraries may not be found correctly."; this->GlobalGenerator->GetCMakeInstance() - ->IssueMessage(cmake::WARNING, e.str(), this->Target->GetBacktrace()); + ->IssueMessage(cmake::WARNING, e.str(), + this->Target->Target->GetBacktrace()); } diff --git a/Source/cmOrderDirectories.h b/Source/cmOrderDirectories.h index cb5a51f..211c786 100644 --- a/Source/cmOrderDirectories.h +++ b/Source/cmOrderDirectories.h @@ -19,7 +19,7 @@ class cmGlobalGenerator; class cmOrderDirectoriesConstraint; class cmOrderDirectoriesConstraintLibrary; -class cmTarget; +class cmGeneratorTarget; /** \class cmOrderDirectories * \brief Compute a safe runtime path order for a set of shared libraries. @@ -27,7 +27,7 @@ class cmTarget; class cmOrderDirectories { public: - cmOrderDirectories(cmGlobalGenerator* gg, cmTarget const* target, + cmOrderDirectories(cmGlobalGenerator* gg, cmGeneratorTarget const* target, const char* purpose); ~cmOrderDirectories(); void AddRuntimeLibrary(std::string const& fullPath, const char* soname = 0); @@ -41,7 +41,7 @@ public: std::vector const& GetOrderedDirectories(); private: cmGlobalGenerator* GlobalGenerator; - cmTarget const* Target; + cmGeneratorTarget const* Target; std::string Purpose; std::vector OrderedDirectories; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fc28823e87b86b5aed3ec355889a352ca171994e commit fc28823e87b86b5aed3ec355889a352ca171994e Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:51 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 4 19:19:51 2015 +0200 cmGeneratorTarget: Move CompileInfoMap from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c6f248c..c831704 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1356,6 +1356,46 @@ cmGeneratorTarget::GetMacContentDirectory(const std::string& config, return fpath; } + +//---------------------------------------------------------------------------- +cmGeneratorTarget::CompileInfo const* cmGeneratorTarget::GetCompileInfo( + const std::string& config) const +{ + // There is no compile information for imported targets. + if(this->IsImported()) + { + return 0; + } + + if(this->GetType() > cmTarget::OBJECT_LIBRARY) + { + std::string msg = "cmTarget::GetCompileInfo called for "; + msg += this->GetName(); + msg += " which has type "; + msg += cmTarget::GetTargetTypeName(this->Target->GetType()); + this->Makefile->IssueMessage(cmake::INTERNAL_ERROR, msg); + return 0; + } + + // Lookup/compute/cache the compile information for this configuration. + std::string config_upper; + if(!config.empty()) + { + config_upper = cmSystemTools::UpperCase(config); + } + CompileInfoMapType::const_iterator i = + this->CompileInfoMap.find(config_upper); + if(i == this->CompileInfoMap.end()) + { + CompileInfo info; + this->Target + ->ComputePDBOutputDir("COMPILE_PDB", config, info.CompilePdbDir); + CompileInfoMapType::value_type entry(config_upper, info); + i = this->CompileInfoMap.insert(entry).first; + } + return &i->second; +} + //---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetModuleDefinitionFile(const std::string& config) const @@ -1827,7 +1867,7 @@ void cmGeneratorTarget::TraceDependencies() std::string cmGeneratorTarget::GetCompilePDBDirectory(const std::string& config) const { - if(cmTarget::CompileInfo const* info = this->Target->GetCompileInfo(config)) + if(CompileInfo const* info = this->GetCompileInfo(config)) { return info->CompilePdbDir; } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 3dbbca1..68e7a8a 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -230,6 +230,16 @@ public: /** Whether this library has soname enabled and platform supports it. */ bool HasSOName(const std::string& config) const; + struct CompileInfo + { + std::string CompilePdbDir; + }; + + CompileInfo const* GetCompileInfo(const std::string& config) const; + + typedef std::map CompileInfoMapType; + mutable CompileInfoMapType CompileInfoMap; + /** Get the name of the compiler pdb file for the target. */ std::string GetCompilePDBName(const std::string& config="") const; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 9308113..1f8f07a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -126,9 +126,6 @@ public: typedef std::map ImportInfoMapType; ImportInfoMapType ImportInfoMap; - typedef std::map CompileInfoMapType; - CompileInfoMapType CompileInfoMap; - // Cache link implementation computation from each configuration. struct OptionalLinkImplementation: public cmTarget::LinkImplementation { @@ -2598,45 +2595,6 @@ cmTarget::OutputInfo const* cmTarget::GetOutputInfo( } //---------------------------------------------------------------------------- -cmTarget::CompileInfo const* cmTarget::GetCompileInfo( - const std::string& config) const -{ - // There is no compile information for imported targets. - if(this->IsImported()) - { - return 0; - } - - if(this->GetType() > cmTarget::OBJECT_LIBRARY) - { - std::string msg = "cmTarget::GetCompileInfo called for "; - msg += this->GetName(); - msg += " which has type "; - msg += cmTarget::GetTargetTypeName(this->GetType()); - this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg); - return 0; - } - - // Lookup/compute/cache the compile information for this configuration. - std::string config_upper; - if(!config.empty()) - { - config_upper = cmSystemTools::UpperCase(config); - } - typedef cmTargetInternals::CompileInfoMapType CompileInfoMapType; - CompileInfoMapType::const_iterator i = - this->Internal->CompileInfoMap.find(config_upper); - if(i == this->Internal->CompileInfoMap.end()) - { - CompileInfo info; - this->ComputePDBOutputDir("COMPILE_PDB", config, info.CompilePdbDir); - CompileInfoMapType::value_type entry(config_upper, info); - i = this->Internal->CompileInfoMap.insert(entry).first; - } - return &i->second; -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetDirectory(const std::string& config, bool implib) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 8689838..e3fbdfd 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -626,13 +626,6 @@ private: void ComputeImportInfo(std::string const& desired_config, ImportInfo& info) const; - // Cache target compile paths for each configuration. - struct CompileInfo - { - std::string CompilePdbDir; - }; - - CompileInfo const* GetCompileInfo(const std::string& config) const; LinkInterface const* GetImportLinkInterface(const std::string& config, cmTarget const* head, http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=db3100f7ab4b844070f6cdbd8fa61eb90f404166 commit db3100f7ab4b844070f6cdbd8fa61eb90f404166 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:51 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 4 19:19:51 2015 +0200 cmGeneratorTarget: Move GetCompilePDBDirectory from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index aac941e..c6f248c 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -743,7 +743,7 @@ cmGeneratorTarget::GetCompilePDBName(const std::string& config) const std::string cmGeneratorTarget::GetCompilePDBPath(const std::string& config) const { - std::string dir = this->Target->GetCompilePDBDirectory(config); + std::string dir = this->GetCompilePDBDirectory(config); std::string name = this->GetCompilePDBName(config); if(dir.empty() && !name.empty()) { @@ -1824,6 +1824,16 @@ void cmGeneratorTarget::TraceDependencies() tracer.Trace(); } +std::string +cmGeneratorTarget::GetCompilePDBDirectory(const std::string& config) const +{ + if(cmTarget::CompileInfo const* info = this->Target->GetCompileInfo(config)) + { + return info->CompilePdbDir; + } + return ""; +} + //---------------------------------------------------------------------------- void cmGeneratorTarget::GetAppleArchs(const std::string& config, std::vector& archVec) const diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 52ab6c0..3dbbca1 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -214,6 +214,12 @@ public: */ void TraceDependencies(); + /** Get the directory in which to place the target compiler .pdb file. + If the configuration name is given then the generator will add its + subdirectory for that configuration. Otherwise just the canonical + compiler pdb output directory is given. */ + std::string GetCompilePDBDirectory(const std::string& config = "") const; + /** Get sources that must be built before the given source. */ std::vector const* GetSourceDepends(cmSourceFile const* sf) const; diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index afe145a..ccb0974 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -130,7 +130,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) } std::string compilePdbOutputPath = - this->Target->GetCompilePDBDirectory(this->ConfigName); + this->GeneratorTarget->GetCompilePDBDirectory(this->ConfigName); cmSystemTools::MakeDirectory(compilePdbOutputPath.c_str()); std::string pdbOutputPath = this->Target->GetPDBDirectory(this->ConfigName); diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index bb0f9dd..2f995e8 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -311,7 +311,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules } std::string compilePdbOutputPath = - this->Target->GetCompilePDBDirectory(this->ConfigName); + this->GeneratorTarget->GetCompilePDBDirectory(this->ConfigName); cmSystemTools::MakeDirectory(compilePdbOutputPath.c_str()); std::string pdbOutputPath = this->Target->GetPDBDirectory(this->ConfigName); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 8b64bc4..9308113 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -69,12 +69,6 @@ struct cmTarget::OutputInfo }; //---------------------------------------------------------------------------- -struct cmTarget::CompileInfo -{ - std::string CompilePdbDir; -}; - -//---------------------------------------------------------------------------- class cmTargetInternals { public: @@ -2673,16 +2667,6 @@ std::string cmTarget::GetPDBDirectory(const std::string& config) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetCompilePDBDirectory(const std::string& config) const -{ - if(CompileInfo const* info = this->GetCompileInfo(config)) - { - return info->CompilePdbDir; - } - return ""; -} - -//---------------------------------------------------------------------------- const char* cmTarget::ImportedGetLocation(const std::string& config) const { static std::string location; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index a6f2465..8689838 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -334,12 +334,6 @@ public: pdb output directory is given. */ std::string GetPDBDirectory(const std::string& config) const; - /** Get the directory in which to place the target compiler .pdb file. - If the configuration name is given then the generator will add its - subdirectory for that configuration. Otherwise just the canonical - compiler pdb output directory is given. */ - std::string GetCompilePDBDirectory(const std::string& config = "") const; - const char* ImportedGetLocation(const std::string& config) const; /** Get the target major and minor version numbers interpreted from @@ -633,7 +627,11 @@ private: ImportInfo& info) const; // Cache target compile paths for each configuration. - struct CompileInfo; + struct CompileInfo + { + std::string CompilePdbDir; + }; + CompileInfo const* GetCompileInfo(const std::string& config) const; LinkInterface const* http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8a89793258af88c11d63c3426fe07f6aee66f963 commit 8a89793258af88c11d63c3426fe07f6aee66f963 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:50 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 4 19:19:50 2015 +0200 cmGeneratorTarget: Move GetOutputName from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 55e2922..aac941e 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -267,6 +267,54 @@ const char *cmGeneratorTarget::GetProperty(const std::string& prop) const } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetOutputName(const std::string& config, + bool implib) const +{ + std::vector props; + std::string type = this->Target->GetOutputTargetType(implib); + std::string configUpper = cmSystemTools::UpperCase(config); + if(!type.empty() && !configUpper.empty()) + { + // _OUTPUT_NAME_ + props.push_back(type + "_OUTPUT_NAME_" + configUpper); + } + if(!type.empty()) + { + // _OUTPUT_NAME + props.push_back(type + "_OUTPUT_NAME"); + } + if(!configUpper.empty()) + { + // OUTPUT_NAME_ + props.push_back("OUTPUT_NAME_" + configUpper); + // _OUTPUT_NAME + props.push_back(configUpper + "_OUTPUT_NAME"); + } + // OUTPUT_NAME + props.push_back("OUTPUT_NAME"); + + std::string outName; + for(std::vector::const_iterator i = props.begin(); + i != props.end(); ++i) + { + if (const char* outNameProp = this->Target->GetProperty(*i)) + { + outName = outNameProp; + break; + } + } + + if (outName.empty()) + { + outName = this->GetName(); + } + + cmGeneratorExpression ge; + cmsys::auto_ptr cge = ge.Parse(outName); + return cge->Evaluate(this->Makefile, config); +} + +//---------------------------------------------------------------------------- std::vector const* cmGeneratorTarget::GetSourceDepends(cmSourceFile const* sf) const { @@ -922,7 +970,7 @@ std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config, bool contentOnly) const { std::string fpath; - fpath += this->Target->GetOutputName(config, false); + fpath += this->GetOutputName(config, false); fpath += "."; const char *ext = this->Target->GetProperty("BUNDLE_EXTENSION"); if (!ext) @@ -949,7 +997,7 @@ cmGeneratorTarget::GetFrameworkDirectory(const std::string& config, bool rootDir) const { std::string fpath; - fpath += this->Target->GetOutputName(config, false); + fpath += this->GetOutputName(config, false); fpath += ".framework"; if(!rootDir) { @@ -2247,7 +2295,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, std::string fw_prefix; if(this->Target->IsFrameworkOnApple()) { - fw_prefix = this->Target->GetOutputName(config, false); + fw_prefix = this->GetOutputName(config, false); fw_prefix += ".framework/"; targetPrefix = fw_prefix.c_str(); targetSuffix = 0; @@ -2265,7 +2313,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, outPrefix = targetPrefix?targetPrefix:""; // Append the target name or property-specified name. - outBase += this->Target->GetOutputName(config, implib); + outBase += this->GetOutputName(config, implib); // Append the per-configuration postfix. outBase += configPostfix?configPostfix:""; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 21e0900..52ab6c0 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -230,6 +230,9 @@ public: /** Get the path for the MSVC /Fd option for this target. */ std::string GetCompilePDBPath(const std::string& config="") const; + // Get the target base name. + std::string GetOutputName(const std::string& config, bool implib) const; + /** * Flags for a given source file as used in this target. Typically assigned * via SET_TARGET_PROPERTIES when the property is a list of source files. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e887ef3..8b64bc4 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3663,54 +3663,6 @@ bool cmTarget::UsesDefaultOutputDir(const std::string& config, } //---------------------------------------------------------------------------- -std::string cmTarget::GetOutputName(const std::string& config, - bool implib) const -{ - std::vector props; - std::string type = this->GetOutputTargetType(implib); - std::string configUpper = cmSystemTools::UpperCase(config); - if(!type.empty() && !configUpper.empty()) - { - // _OUTPUT_NAME_ - props.push_back(type + "_OUTPUT_NAME_" + configUpper); - } - if(!type.empty()) - { - // _OUTPUT_NAME - props.push_back(type + "_OUTPUT_NAME"); - } - if(!configUpper.empty()) - { - // OUTPUT_NAME_ - props.push_back("OUTPUT_NAME_" + configUpper); - // _OUTPUT_NAME - props.push_back(configUpper + "_OUTPUT_NAME"); - } - // OUTPUT_NAME - props.push_back("OUTPUT_NAME"); - - std::string outName; - for(std::vector::const_iterator i = props.begin(); - i != props.end(); ++i) - { - if (const char* outNameProp = this->GetProperty(*i)) - { - outName = outNameProp; - break; - } - } - - if (outName.empty()) - { - outName = this->GetName(); - } - - cmGeneratorExpression ge; - cmsys::auto_ptr cge = ge.Parse(outName); - return cge->Evaluate(this->Makefile, config); -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetFrameworkVersion() const { assert(this->GetType() != INTERFACE_LIBRARY); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e53afff..a6f2465 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -552,9 +552,6 @@ private: // Returns ARCHIVE, LIBRARY, or RUNTIME based on platform and type. const char* GetOutputTargetType(bool implib) const; - // Get the target base name. - std::string GetOutputName(const std::string& config, bool implib) const; - std::string GetFullNameImported(const std::string& config, bool implib) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=47f6495f520447e66eda98bdb9fc622f651e164d commit 47f6495f520447e66eda98bdb9fc622f651e164d Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:50 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 4 19:19:50 2015 +0200 cmComputeLinkDepends: Port to cmGeneratorTarget. diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index abd9877..8ba8847 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -173,18 +173,19 @@ items that we know the linker will re-use automatically (shared libs). //---------------------------------------------------------------------------- cmComputeLinkDepends -::cmComputeLinkDepends(cmTarget const* target, const std::string& config) +::cmComputeLinkDepends(const cmGeneratorTarget* target, + const std::string& config) { // Store context information. this->Target = target; - this->Makefile = this->Target->GetMakefile(); + this->Makefile = this->Target->Target->GetMakefile(); this->GlobalGenerator = this->Makefile->GetGlobalGenerator(); this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance(); // The configuration being linked. this->HasConfig = !config.empty(); this->Config = (this->HasConfig)? config : std::string(); - this->LinkType = this->Target->ComputeLinkType(this->Config); + this->LinkType = this->Target->Target->ComputeLinkType(this->Config); // Enable debug mode if requested. this->DebugMode = this->Makefile->IsOn("CMAKE_LINK_DEPENDS_DEBUG_MODE"); @@ -363,7 +364,7 @@ void cmComputeLinkDepends::FollowLinkEntry(BFSEntry const& qe) { // Follow the target dependencies. if(cmTarget::LinkInterface const* iface = - entry.Target->GetLinkInterface(this->Config, this->Target)) + entry.Target->GetLinkInterface(this->Config, this->Target->Target)) { const bool isIface = entry.Target->GetType() == cmTarget::INTERFACE_LIBRARY; @@ -461,7 +462,7 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep) if(entry.Target) { if(cmTarget::LinkInterface const* iface = - entry.Target->GetLinkInterface(this->Config, this->Target)) + entry.Target->GetLinkInterface(this->Config, this->Target->Target)) { // Follow public and private dependencies transitively. this->FollowSharedDeps(index, iface, true); @@ -552,7 +553,7 @@ void cmComputeLinkDepends::AddDirectLinkEntries() { // Add direct link dependencies in this configuration. cmTarget::LinkImplementation const* impl = - this->Target->GetLinkImplementation(this->Config); + this->Target->Target->GetLinkImplementation(this->Config); this->AddLinkEntries(-1, impl->Libraries); for(std::vector::const_iterator wi = impl->WrongConfigLibraries.begin(); @@ -634,7 +635,7 @@ cmTarget const* cmComputeLinkDepends::FindTargetToLink(int depender_index, const std::string& name) { // Look for a target in the scope of the depender. - cmTarget const* from = this->Target; + cmTarget const* from = this->Target->Target; if(depender_index >= 0) { if(cmTarget const* depender = this->EntryList[depender_index].Target) @@ -932,7 +933,7 @@ int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl) if(cmTarget const* target = this->EntryList[*ni].Target) { if(cmTarget::LinkInterface const* iface = - target->GetLinkInterface(this->Config, this->Target)) + target->GetLinkInterface(this->Config, this->Target->Target)) { if(iface->Multiplicity > count) { diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index 51a08c5..b925a4f 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -22,6 +22,7 @@ class cmComputeComponentGraph; class cmGlobalGenerator; class cmMakefile; +class cmGeneratorTarget; class cmTarget; class cmake; @@ -31,7 +32,8 @@ class cmake; class cmComputeLinkDepends { public: - cmComputeLinkDepends(cmTarget const* target, const std::string& config); + cmComputeLinkDepends(cmGeneratorTarget const* target, + const std::string& config); ~cmComputeLinkDepends(); // Basic information about each link item. @@ -57,7 +59,7 @@ public: private: // Context information. - cmTarget const* Target; + cmGeneratorTarget const* Target; cmMakefile* Makefile; cmGlobalGenerator const* GlobalGenerator; cmake* CMakeInstance; diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index fb89319..5cd0d54 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -497,7 +497,7 @@ bool cmComputeLinkInformation::Compute() } // Compute the ordered link line items. - cmComputeLinkDepends cld(this->Target->Target, this->Config); + cmComputeLinkDepends cld(this->Target, this->Config); cld.SetOldLinkDirMode(this->OldLinkDirMode); cmComputeLinkDepends::EntryVector const& linkEntries = cld.Compute(); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9c840669c250dd37348be973b63b7e29ce0f6363 commit 9c840669c250dd37348be973b63b7e29ce0f6363 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:50 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 4 19:19:50 2015 +0200 cmComputeLinkInformation: Port to cmGeneratorTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index f03c04a..fb89319 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -242,11 +242,12 @@ because this need be done only for shared libraries without soname-s. //---------------------------------------------------------------------------- cmComputeLinkInformation -::cmComputeLinkInformation(cmTarget const* target, const std::string& config) +::cmComputeLinkInformation(const cmGeneratorTarget* target, + const std::string& config) { // Store context information. this->Target = target; - this->Makefile = this->Target->GetMakefile(); + this->Makefile = this->Target->Target->GetMakefile(); this->GlobalGenerator = this->Makefile->GetGlobalGenerator(); this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance(); @@ -259,17 +260,15 @@ cmComputeLinkInformation // Allocate internals. this->OrderLinkerSearchPath = - new cmOrderDirectories(this->GlobalGenerator, target, + new cmOrderDirectories(this->GlobalGenerator, target->Target, "linker search path"); this->OrderRuntimeSearchPath = - new cmOrderDirectories(this->GlobalGenerator, target, + new cmOrderDirectories(this->GlobalGenerator, target->Target, "runtime search path"); this->OrderDependentRPath = 0; - cmGeneratorTarget *gtgt = this->GlobalGenerator - ->GetGeneratorTarget(this->Target); // Get the language used for linking this target. - this->LinkLanguage = gtgt->GetLinkerLanguage(config); + this->LinkLanguage = this->Target->GetLinkerLanguage(config); if(this->LinkLanguage.empty()) { // The Compute method will do nothing, so skip the rest of the @@ -283,14 +282,14 @@ cmComputeLinkInformation // Check whether we should skip dependencies on shared library files. this->LinkDependsNoShared = - this->Target->GetPropertyAsBool("LINK_DEPENDS_NO_SHARED"); + this->Target->Target->GetPropertyAsBool("LINK_DEPENDS_NO_SHARED"); // On platforms without import libraries there may be a special flag // to use when creating a plugin (module) that obtains symbols from // the program that will load it. this->LoaderFlag = 0; if(!this->UseImportLibrary && - this->Target->GetType() == cmTarget::MODULE_LIBRARY) + this->Target->Target->GetType() == cmTarget::MODULE_LIBRARY) { std::string loader_flag_var = "CMAKE_SHARED_MODULE_LOADER_"; loader_flag_var += this->LinkLanguage; @@ -308,10 +307,10 @@ cmComputeLinkInformation // Get options needed to specify RPATHs. this->RuntimeUseChrpath = false; - if(this->Target->GetType() != cmTarget::STATIC_LIBRARY) + if(this->Target->Target->GetType() != cmTarget::STATIC_LIBRARY) { const char* tType = - ((this->Target->GetType() == cmTarget::EXECUTABLE)? + ((this->Target->Target->GetType() == cmTarget::EXECUTABLE)? "EXECUTABLE" : "SHARED_LIBRARY"); std::string rtVar = "CMAKE_"; rtVar += tType; @@ -325,7 +324,7 @@ cmComputeLinkInformation (this->Makefile-> GetSafeDefinition("CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH")); - this->RuntimeUseChrpath = gtgt->IsChrpathUsed(config); + this->RuntimeUseChrpath = this->Target->IsChrpathUsed(config); // Get options needed to help find dependent libraries. std::string rlVar = "CMAKE_"; @@ -371,15 +370,15 @@ cmComputeLinkInformation { this->SharedDependencyMode = SharedDepModeDir; this->OrderDependentRPath = - new cmOrderDirectories(this->GlobalGenerator, target, + new cmOrderDirectories(this->GlobalGenerator, target->Target, "dependent library path"); } // Add the search path entries requested by the user to path ordering. this->OrderLinkerSearchPath - ->AddUserDirectories(this->Target->GetLinkDirectories()); + ->AddUserDirectories(this->Target->Target->GetLinkDirectories()); this->OrderRuntimeSearchPath - ->AddUserDirectories(this->Target->GetLinkDirectories()); + ->AddUserDirectories(this->Target->Target->GetLinkDirectories()); // Set up the implicit link directories. this->LoadImplicitLinkInfo(); @@ -407,12 +406,13 @@ cmComputeLinkInformation // order to support such projects we need to add the directories // containing libraries linked with a full path to the -L path. this->OldLinkDirMode = - this->Target->GetPolicyStatusCMP0003() != cmPolicies::NEW; + this->Target->Target->GetPolicyStatusCMP0003() != cmPolicies::NEW; if(this->OldLinkDirMode) { // Construct a mask to not bother with this behavior for link // directories already specified by the user. - std::vector const& dirs = this->Target->GetLinkDirectories(); + std::vector const& dirs = + this->Target->Target->GetLinkDirectories(); this->OldLinkDirMask.insert(dirs.begin(), dirs.end()); } @@ -497,7 +497,7 @@ bool cmComputeLinkInformation::Compute() } // Compute the ordered link line items. - cmComputeLinkDepends cld(this->Target, this->Config); + cmComputeLinkDepends cld(this->Target->Target, this->Config); cld.SetOldLinkDirMode(this->OldLinkDirMode); cmComputeLinkDepends::EntryVector const& linkEntries = cld.Compute(); @@ -518,7 +518,8 @@ bool cmComputeLinkInformation::Compute() // Restore the target link type so the correct system runtime // libraries are found. - const char* lss = this->Target->GetProperty("LINK_SEARCH_END_STATIC"); + const char* lss = + this->Target->Target->GetProperty("LINK_SEARCH_END_STATIC"); if(cmSystemTools::IsOn(lss)) { this->SetCurrentLinkType(LinkStatic); @@ -571,7 +572,7 @@ bool cmComputeLinkInformation::Compute() "name." ; this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); } return true; @@ -580,12 +581,9 @@ bool cmComputeLinkInformation::Compute() //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddImplicitLinkInfo() { - cmGeneratorTarget *gtgt = this->Target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(this->Target); - // The link closure lists all languages whose implicit info is needed. - cmGeneratorTarget::LinkClosure const* lc=gtgt->GetLinkClosure(this->Config); + cmGeneratorTarget::LinkClosure const* lc = + this->Target->GetLinkClosure(this->Config); for(std::vector::const_iterator li = lc->Languages.begin(); li != lc->Languages.end(); ++li) { @@ -863,7 +861,8 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo() } // Lookup the starting link type from the target (linked statically?). - const char* lss = this->Target->GetProperty("LINK_SEARCH_START_STATIC"); + const char* lss = + this->Target->Target->GetProperty("LINK_SEARCH_START_STATIC"); this->StartLinkType = cmSystemTools::IsOn(lss)? LinkStatic : LinkShared; this->CurrentLinkType = this->StartLinkType; } @@ -1149,7 +1148,7 @@ void cmComputeLinkInformation::AddFullItem(std::string const& item) // Full path libraries should specify a valid library file name. // See documentation of CMP0008. std::string generator = this->GlobalGenerator->GetName(); - if(this->Target->GetPolicyStatusCMP0008() != cmPolicies::NEW && + if(this->Target->Target->GetPolicyStatusCMP0008() != cmPolicies::NEW && (generator.find("Visual Studio") != generator.npos || generator.find("Xcode") != generator.npos)) { @@ -1230,7 +1229,7 @@ bool cmComputeLinkInformation::CheckImplicitDirItem(std::string const& item) } // Check the policy for whether we should use the approach below. - switch (this->Target->GetPolicyStatusCMP0060()) + switch (this->Target->Target->GetPolicyStatusCMP0060()) { case cmPolicies::WARN: if (this->CMP0060Warn) @@ -1540,7 +1539,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item, this->OrderLinkerSearchPath->AddLinkLibrary(item); // Produce any needed message. - switch(this->Target->GetPolicyStatusCMP0008()) + switch(this->Target->Target->GetPolicyStatusCMP0008()) { case cmPolicies::WARN: { @@ -1557,7 +1556,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item, << " " << item << "\n" << "which is a full-path but not a valid library file name."; this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); } } case cmPolicies::OLD: @@ -1575,7 +1574,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item, << " " << item << "\n" << "which is a full-path but not a valid library file name."; this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); } break; } @@ -1592,7 +1591,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories() } // Enforce policy constraints. - switch(this->Target->GetPolicyStatusCMP0003()) + switch(this->Target->Target->GetPolicyStatusCMP0003()) { case cmPolicies::WARN: if(!this->CMakeInstance->GetState() @@ -1603,7 +1602,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories() std::ostringstream w; this->PrintLinkPolicyDiagnosis(w); this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); } case cmPolicies::OLD: // OLD behavior is to add the paths containing libraries with @@ -1619,7 +1618,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories() e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0003) << "\n"; this->PrintLinkPolicyDiagnosis(e); this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); return false; } } @@ -1923,23 +1922,24 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, // build tree. bool linking_for_install = (for_install || - this->Target->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")); + this->Target->Target->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")); bool use_install_rpath = - (outputRuntime && this->Target->HaveInstallTreeRPATH() && + (outputRuntime && this->Target->Target->HaveInstallTreeRPATH() && linking_for_install); bool use_build_rpath = - (outputRuntime && this->Target->HaveBuildTreeRPATH(this->Config) && + (outputRuntime && this->Target->Target->HaveBuildTreeRPATH(this->Config) && !linking_for_install); bool use_link_rpath = outputRuntime && linking_for_install && !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH") && - this->Target->GetPropertyAsBool("INSTALL_RPATH_USE_LINK_PATH"); + this->Target->Target->GetPropertyAsBool("INSTALL_RPATH_USE_LINK_PATH"); // Construct the RPATH. std::set emitted; if(use_install_rpath) { - const char* install_rpath = this->Target->GetProperty("INSTALL_RPATH"); + const char* install_rpath = + this->Target->Target->GetProperty("INSTALL_RPATH"); cmCLI_ExpandListUnique(install_rpath, runtimeDirs, emitted); } if(use_build_rpath || use_link_rpath) @@ -2011,12 +2011,8 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, // Add runtime paths required by the languages to always be // present. This is done even when skipping rpath support. { - cmGeneratorTarget *gtgt = this->Makefile - ->GetGlobalGenerator() - ->GetGeneratorTarget(this->Target); - cmGeneratorTarget::LinkClosure const* lc = - gtgt->GetLinkClosure(this->Config); + this->Target->GetLinkClosure(this->Config); for(std::vector::const_iterator li = lc->Languages.begin(); li != lc->Languages.end(); ++li) { diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index 2d7a5a5..8b83574 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -29,7 +29,8 @@ class cmOrderDirectories; class cmComputeLinkInformation { public: - cmComputeLinkInformation(cmTarget const* target, const std::string& config); + cmComputeLinkInformation(cmGeneratorTarget const* target, + const std::string& config); ~cmComputeLinkInformation(); bool Compute(); @@ -73,7 +74,7 @@ private: std::set SharedLibrariesLinked; // Context information. - cmTarget const* Target; + cmGeneratorTarget const* Target; cmMakefile* Makefile; cmGlobalGenerator* GlobalGenerator; cmake* CMakeInstance; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c68c2b9..55e2922 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3166,7 +3166,7 @@ cmGeneratorTarget::GetLinkInformation(const std::string& config) const { // Compute information for this configuration. cmComputeLinkInformation* info = - new cmComputeLinkInformation(this->Target, config); + new cmComputeLinkInformation(this, config); if(!info || !info->Compute()) { delete info; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=86a622bb3bde32bce5e660747b9811356c84e42d commit 86a622bb3bde32bce5e660747b9811356c84e42d Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:49 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 4 19:19:49 2015 +0200 cmGeneratorTarget: Move IsBundleOnApple from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c314372..c68c2b9 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -910,6 +910,14 @@ cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, } //---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsBundleOnApple() const +{ + return this->Target->IsFrameworkOnApple() + || this->Target->IsAppBundleOnApple() + || this->Target->IsCFBundleOnApple(); +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config, bool contentOnly) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index a1193a6..21e0900 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -119,6 +119,10 @@ public: std::string GetAppBundleDirectory(const std::string& config, bool contentOnly) const; + /** Return whether this target is an executable Bundle, a framework + or CFBundle on Apple. */ + bool IsBundleOnApple() const; + /** Get the full name of the target according to the settings in its makefile. */ std::string GetFullName(const std::string& config="", diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index d38cf4c..0b3df90 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -313,7 +313,7 @@ cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator() (cmSourceFile const& source, const char* pkgloc) { // Skip OS X content when not building a Framework or Bundle. - if(!this->Generator->GetTarget()->IsBundleOnApple()) + if(!this->Generator->GetGeneratorTarget()->IsBundleOnApple()) { return; } diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 16e1f48..07efa16 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -742,7 +742,7 @@ cmNinjaTargetGenerator::MacOSXContentGeneratorType::operator()( cmSourceFile const& source, const char* pkgloc) { // Skip OS X content when not building a Framework or Bundle. - if(!this->Generator->GetTarget()->IsBundleOnApple()) + if(!this->Generator->GetGeneratorTarget()->IsBundleOnApple()) { return; } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 62aa12a..e887ef3 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -590,13 +590,6 @@ bool cmTarget::IsXCTestOnApple() const } //---------------------------------------------------------------------------- -bool cmTarget::IsBundleOnApple() const -{ - return this->IsFrameworkOnApple() || this->IsAppBundleOnApple() || - this->IsCFBundleOnApple(); -} - -//---------------------------------------------------------------------------- static bool processSources(cmTarget const* tgt, const std::vector &entries, std::vector &srcs, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 9a4915f..e53afff 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -424,10 +424,6 @@ public: /** Return whether this target is an executable Bundle on Apple. */ bool IsAppBundleOnApple() const; - /** Return whether this target is an executable Bundle, a framework - or CFBundle on Apple. */ - bool IsBundleOnApple() const; - /** Return the framework version string. Undefined if IsFrameworkOnApple returns false. */ std::string GetFrameworkVersion() const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=23642b4e767611e283f33f0ae3a1bf0bdd8b0017 commit 23642b4e767611e283f33f0ae3a1bf0bdd8b0017 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:49 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 4 19:19:49 2015 +0200 cmMakefileTargetGenerator: Add accessor for GeneratorTarget. diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index b885672..fd4527b 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -53,6 +53,7 @@ public: { return this->ProgressFileNameFull; } cmTarget* GetTarget() { return this->Target;} + cmGeneratorTarget* GetGeneratorTarget() { return this->GeneratorTarget;} protected: http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f2b1f037358d7298ca302f5b5a676bd03ad77604 commit f2b1f037358d7298ca302f5b5a676bd03ad77604 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:49 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 4 19:19:49 2015 +0200 cmGeneratorTarget: Move GetLinkClosure from cmTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 640e806..f03c04a 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -19,6 +19,7 @@ #include "cmOutputConverter.h" #include "cmMakefile.h" #include "cmTarget.h" +#include "cmGeneratorTarget.h" #include "cmake.h" #include "cmAlgorithms.h" @@ -579,8 +580,12 @@ bool cmComputeLinkInformation::Compute() //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddImplicitLinkInfo() { + cmGeneratorTarget *gtgt = this->Target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(this->Target); + // The link closure lists all languages whose implicit info is needed. - cmTarget::LinkClosure const* lc=this->Target->GetLinkClosure(this->Config); + cmGeneratorTarget::LinkClosure const* lc=gtgt->GetLinkClosure(this->Config); for(std::vector::const_iterator li = lc->Languages.begin(); li != lc->Languages.end(); ++li) { @@ -2006,8 +2011,12 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, // Add runtime paths required by the languages to always be // present. This is done even when skipping rpath support. { - cmTarget::LinkClosure const* lc = - this->Target->GetLinkClosure(this->Config); + cmGeneratorTarget *gtgt = this->Makefile + ->GetGlobalGenerator() + ->GetGeneratorTarget(this->Target); + + cmGeneratorTarget::LinkClosure const* lc = + gtgt->GetLinkClosure(this->Config); for(std::vector::const_iterator li = lc->Languages.begin(); li != lc->Languages.end(); ++li) { diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index 3afbb92..2d7a5a5 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -20,6 +20,7 @@ class cmake; class cmGlobalGenerator; class cmMakefile; class cmTarget; +class cmGeneratorTarget; class cmOrderDirectories; /** \class cmComputeLinkInformation diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 4de5e9c..c314372 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -27,6 +27,13 @@ #include #include "assert.h" +#if defined(CMAKE_BUILD_WITH_CMAKE) +#include +#define UNORDERED_SET cmsys::hash_set +#else +#define UNORDERED_SET std::set +#endif + //---------------------------------------------------------------------------- void reportBadObjLib(std::vector const& badObjLib, cmTarget *target, cmake *cm) @@ -1026,6 +1033,223 @@ std::string cmGeneratorTarget::GetInstallNameDirForInstallTree() const } //---------------------------------------------------------------------------- +class cmTargetCollectLinkLanguages +{ +public: + cmTargetCollectLinkLanguages(cmGeneratorTarget const* target, + const std::string& config, + UNORDERED_SET& languages, + cmTarget const* head): + Config(config), Languages(languages), HeadTarget(head), + Makefile(target->Target->GetMakefile()), Target(target) + { this->Visited.insert(target->Target); } + + void Visit(cmLinkItem const& item) + { + if(!item.Target) + { + if(item.find("::") != std::string::npos) + { + bool noMessage = false; + cmake::MessageType messageType = cmake::FATAL_ERROR; + std::stringstream e; + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0028)) + { + case cmPolicies::WARN: + { + e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0028) << "\n"; + messageType = cmake::AUTHOR_WARNING; + } + break; + case cmPolicies::OLD: + noMessage = true; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::NEW: + // Issue the fatal message. + break; + } + + if(!noMessage) + { + e << "Target \"" << this->Target->GetName() + << "\" links to target \"" << item + << "\" but the target was not found. Perhaps a find_package() " + "call is missing for an IMPORTED target, or an ALIAS target is " + "missing?"; + this->Makefile->GetCMakeInstance()->IssueMessage( + messageType, e.str(), this->Target->Target->GetBacktrace()); + } + } + return; + } + if(!this->Visited.insert(item.Target).second) + { + return; + } + + cmTarget::LinkInterface const* iface = + item.Target->GetLinkInterface(this->Config, this->HeadTarget); + if(!iface) { return; } + + for(std::vector::const_iterator + li = iface->Languages.begin(); li != iface->Languages.end(); ++li) + { + this->Languages.insert(*li); + } + + for(std::vector::const_iterator + li = iface->Libraries.begin(); li != iface->Libraries.end(); ++li) + { + this->Visit(*li); + } + } +private: + std::string Config; + UNORDERED_SET& Languages; + cmTarget const* HeadTarget; + cmMakefile* Makefile; + const cmGeneratorTarget* Target; + std::set Visited; +}; + +//---------------------------------------------------------------------------- +cmGeneratorTarget::LinkClosure const* +cmGeneratorTarget::GetLinkClosure(const std::string& config) const +{ + std::string key(cmSystemTools::UpperCase(config)); + LinkClosureMapType::iterator + i = this->LinkClosureMap.find(key); + if(i == this->LinkClosureMap.end()) + { + LinkClosure lc; + this->ComputeLinkClosure(config, lc); + LinkClosureMapType::value_type entry(key, lc); + i = this->LinkClosureMap.insert(entry).first; + } + return &i->second; +} + +//---------------------------------------------------------------------------- +class cmTargetSelectLinker +{ + int Preference; + cmGeneratorTarget const* Target; + cmMakefile* Makefile; + cmGlobalGenerator* GG; + std::set Preferred; +public: + cmTargetSelectLinker(cmGeneratorTarget const* target) + : Preference(0), Target(target) + { + this->Makefile = this->Target->Makefile; + this->GG = this->Makefile->GetGlobalGenerator(); + } + void Consider(const char* lang) + { + int preference = this->GG->GetLinkerPreference(lang); + if(preference > this->Preference) + { + this->Preference = preference; + this->Preferred.clear(); + } + if(preference == this->Preference) + { + this->Preferred.insert(lang); + } + } + std::string Choose() + { + if(this->Preferred.empty()) + { + return ""; + } + else if(this->Preferred.size() > 1) + { + std::stringstream e; + e << "Target " << this->Target->GetName() + << " contains multiple languages with the highest linker preference" + << " (" << this->Preference << "):\n"; + for(std::set::const_iterator + li = this->Preferred.begin(); li != this->Preferred.end(); ++li) + { + e << " " << *li << "\n"; + } + e << "Set the LINKER_LANGUAGE property for this target."; + cmake* cm = this->Makefile->GetCMakeInstance(); + cm->IssueMessage(cmake::FATAL_ERROR, e.str(), + this->Target->Target->GetBacktrace()); + } + return *this->Preferred.begin(); + } +}; + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::ComputeLinkClosure(const std::string& config, + LinkClosure& lc) const +{ + // Get languages built in this target. + UNORDERED_SET languages; + cmTarget::LinkImplementation const* impl = + this->Target->GetLinkImplementation(config); + for(std::vector::const_iterator li = impl->Languages.begin(); + li != impl->Languages.end(); ++li) + { + languages.insert(*li); + } + + // Add interface languages from linked targets. + cmTargetCollectLinkLanguages cll(this, config, languages, this->Target); + for(std::vector::const_iterator li = impl->Libraries.begin(); + li != impl->Libraries.end(); ++li) + { + cll.Visit(*li); + } + + // Store the transitive closure of languages. + for(UNORDERED_SET::const_iterator li = languages.begin(); + li != languages.end(); ++li) + { + lc.Languages.push_back(*li); + } + + // Choose the language whose linker should be used. + if(this->GetProperty("HAS_CXX")) + { + lc.LinkerLanguage = "CXX"; + } + else if(const char* linkerLang = this->GetProperty("LINKER_LANGUAGE")) + { + lc.LinkerLanguage = linkerLang; + } + else + { + // Find the language with the highest preference value. + cmTargetSelectLinker tsl(this); + + // First select from the languages compiled directly in this target. + for(std::vector::const_iterator li = impl->Languages.begin(); + li != impl->Languages.end(); ++li) + { + tsl.Consider(li->c_str()); + } + + // Now consider languages that propagate from linked targets. + for(UNORDERED_SET::const_iterator sit = languages.begin(); + sit != languages.end(); ++sit) + { + std::string propagates = "CMAKE_"+*sit+"_LINKER_PREFERENCE_PROPAGATES"; + if(this->Makefile->IsOn(propagates)) + { + tsl.Consider(sit->c_str()); + } + } + + lc.LinkerLanguage = tsl.Choose(); + } +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, std::string& base, std::string& suffix, @@ -2058,7 +2282,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, std::string cmGeneratorTarget::GetLinkerLanguage(const std::string& config) const { - return this->Target->GetLinkClosure(config)->LinkerLanguage; + return this->GetLinkClosure(config)->LinkerLanguage; } //---------------------------------------------------------------------------- diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 41fb848..a1193a6 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -165,6 +165,20 @@ public: std::string GetModuleDefinitionFile(const std::string& config) const; + /** Link information from the transitive closure of the link + implementation and the interfaces of its dependencies. */ + struct LinkClosure + { + // The preferred linker language. + std::string LinkerLanguage; + + // Languages whose runtime libraries must be linked. + std::vector Languages; + }; + + LinkClosure const* GetLinkClosure(const std::string& config) const; + void ComputeLinkClosure(const std::string& config, LinkClosure& lc) const; + /** Full path with trailing slash to the top-level directory holding object files for this target. Includes the build time config name placeholder if needed for the generator. */ @@ -301,6 +315,9 @@ private: std::string& outPrefix, std::string& outBase, std::string& outSuffix) const; + typedef std::map LinkClosureMapType; + mutable LinkClosureMapType LinkClosureMap; + struct CompatibleInterfacesBase { std::set PropsBool; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index c7118dc..62aa12a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -160,9 +160,6 @@ public: HeadToLinkImplementationMap> LinkImplMapType; LinkImplMapType LinkImplMap; - typedef std::map LinkClosureMapType; - LinkClosureMapType LinkClosureMap; - typedef std::map > SourceFilesMapType; SourceFilesMapType SourceFilesMap; @@ -511,7 +508,6 @@ void cmTarget::ClearLinkMaps() this->Internal->LinkImplMap.clear(); this->Internal->LinkInterfaceMap.clear(); this->Internal->LinkInterfaceUsageRequirementsOnlyMap.clear(); - this->Internal->LinkClosureMap.clear(); this->Internal->SourceFilesMap.clear(); } @@ -3136,223 +3132,6 @@ bool cmTarget::GetPropertyAsBool(const std::string& prop) const } //---------------------------------------------------------------------------- -class cmTargetCollectLinkLanguages -{ -public: - cmTargetCollectLinkLanguages(cmTarget const* target, - const std::string& config, - UNORDERED_SET& languages, - cmTarget const* head): - Config(config), Languages(languages), HeadTarget(head), - Makefile(target->GetMakefile()), Target(target) - { this->Visited.insert(target); } - - void Visit(cmLinkItem const& item) - { - if(!item.Target) - { - if(item.find("::") != std::string::npos) - { - bool noMessage = false; - cmake::MessageType messageType = cmake::FATAL_ERROR; - std::ostringstream e; - switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0028)) - { - case cmPolicies::WARN: - { - e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0028) << "\n"; - messageType = cmake::AUTHOR_WARNING; - } - break; - case cmPolicies::OLD: - noMessage = true; - case cmPolicies::REQUIRED_IF_USED: - case cmPolicies::REQUIRED_ALWAYS: - case cmPolicies::NEW: - // Issue the fatal message. - break; - } - - if(!noMessage) - { - e << "Target \"" << this->Target->GetName() - << "\" links to target \"" << item - << "\" but the target was not found. Perhaps a find_package() " - "call is missing for an IMPORTED target, or an ALIAS target is " - "missing?"; - this->Makefile->GetCMakeInstance()->IssueMessage(messageType, - e.str(), - this->Target->GetBacktrace()); - } - } - return; - } - if(!this->Visited.insert(item.Target).second) - { - return; - } - - cmTarget::LinkInterface const* iface = - item.Target->GetLinkInterface(this->Config, this->HeadTarget); - if(!iface) { return; } - - for(std::vector::const_iterator - li = iface->Languages.begin(); li != iface->Languages.end(); ++li) - { - this->Languages.insert(*li); - } - - for(std::vector::const_iterator - li = iface->Libraries.begin(); li != iface->Libraries.end(); ++li) - { - this->Visit(*li); - } - } -private: - std::string Config; - UNORDERED_SET& Languages; - cmTarget const* HeadTarget; - cmMakefile* Makefile; - const cmTarget* Target; - std::set Visited; -}; - -//---------------------------------------------------------------------------- -cmTarget::LinkClosure const* -cmTarget::GetLinkClosure(const std::string& config) const -{ - std::string key(cmSystemTools::UpperCase(config)); - cmTargetInternals::LinkClosureMapType::iterator - i = this->Internal->LinkClosureMap.find(key); - if(i == this->Internal->LinkClosureMap.end()) - { - LinkClosure lc; - this->ComputeLinkClosure(config, lc); - cmTargetInternals::LinkClosureMapType::value_type entry(key, lc); - i = this->Internal->LinkClosureMap.insert(entry).first; - } - return &i->second; -} - -//---------------------------------------------------------------------------- -class cmTargetSelectLinker -{ - int Preference; - cmTarget const* Target; - cmMakefile* Makefile; - cmGlobalGenerator* GG; - UNORDERED_SET Preferred; -public: - cmTargetSelectLinker(cmTarget const* target): Preference(0), Target(target) - { - this->Makefile = this->Target->GetMakefile(); - this->GG = this->Makefile->GetGlobalGenerator(); - } - void Consider(const std::string& lang) - { - int preference = this->GG->GetLinkerPreference(lang); - if(preference > this->Preference) - { - this->Preference = preference; - this->Preferred.clear(); - } - if(preference == this->Preference) - { - this->Preferred.insert(lang); - } - } - std::string Choose() - { - if(this->Preferred.empty()) - { - return ""; - } - else if(this->Preferred.size() > 1) - { - std::ostringstream e; - e << "Target " << this->Target->GetName() - << " contains multiple languages with the highest linker preference" - << " (" << this->Preference << "):\n"; - for(UNORDERED_SET::const_iterator - li = this->Preferred.begin(); li != this->Preferred.end(); ++li) - { - e << " " << *li << "\n"; - } - e << "Set the LINKER_LANGUAGE property for this target."; - cmake* cm = this->Makefile->GetCMakeInstance(); - cm->IssueMessage(cmake::FATAL_ERROR, e.str(), - this->Target->GetBacktrace()); - } - return *this->Preferred.begin(); - } -}; - -//---------------------------------------------------------------------------- -void cmTarget::ComputeLinkClosure(const std::string& config, - LinkClosure& lc) const -{ - // Get languages built in this target. - UNORDERED_SET languages; - LinkImplementation const* impl = this->GetLinkImplementation(config); - for(std::vector::const_iterator li = impl->Languages.begin(); - li != impl->Languages.end(); ++li) - { - languages.insert(*li); - } - - // Add interface languages from linked targets. - cmTargetCollectLinkLanguages cll(this, config, languages, this); - for(std::vector::const_iterator - li = impl->Libraries.begin(); - li != impl->Libraries.end(); ++li) - { - cll.Visit(*li); - } - - // Store the transitive closure of languages. - for(UNORDERED_SET::const_iterator li = languages.begin(); - li != languages.end(); ++li) - { - lc.Languages.push_back(*li); - } - - // Choose the language whose linker should be used. - if(this->GetProperty("HAS_CXX")) - { - lc.LinkerLanguage = "CXX"; - } - else if(const char* linkerLang = this->GetProperty("LINKER_LANGUAGE")) - { - lc.LinkerLanguage = linkerLang; - } - else - { - // Find the language with the highest preference value. - cmTargetSelectLinker tsl(this); - - // First select from the languages compiled directly in this target. - for(std::vector::const_iterator li = impl->Languages.begin(); - li != impl->Languages.end(); ++li) - { - tsl.Consider(*li); - } - - // Now consider languages that propagate from linked targets. - for(UNORDERED_SET::const_iterator sit = languages.begin(); - sit != languages.end(); ++sit) - { - std::string propagates = "CMAKE_"+*sit+"_LINKER_PREFERENCE_PROPAGATES"; - if(this->Makefile->IsOn(propagates)) - { - tsl.Consider(*sit); - } - } - - lc.LinkerLanguage = tsl.Choose(); - } -} - -//---------------------------------------------------------------------------- void cmTarget::ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index dea9bef..9a4915f 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -315,18 +315,6 @@ public: LinkImplementationLibraries const* GetLinkImplementationLibraries(const std::string& config) const; - /** Link information from the transitive closure of the link - implementation and the interfaces of its dependencies. */ - struct LinkClosure - { - // The preferred linker language. - std::string LinkerLanguage; - - // Languages whose runtime libraries must be linked. - std::vector Languages; - }; - LinkClosure const* GetLinkClosure(const std::string& config) const; - cmTarget const* FindTargetToLink(std::string const& name) const; /** Strip off leading and trailing whitespace from an item named in @@ -662,7 +650,6 @@ private: LinkImplementationLibraries const* GetLinkImplementationLibrariesInternal(const std::string& config, cmTarget const* head) const; - void ComputeLinkClosure(const std::string& config, LinkClosure& lc) const; void ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, cmTarget const* headTarget, http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=db6e978ee79797f6899a7a965cc105a945f99caa commit db6e978ee79797f6899a7a965cc105a945f99caa Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:49 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 4 19:19:49 2015 +0200 cmGeneratorTarget: Move GetLinkerLanguage from cmTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index fee921c..640e806 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -265,8 +265,10 @@ cmComputeLinkInformation "runtime search path"); this->OrderDependentRPath = 0; + cmGeneratorTarget *gtgt = this->GlobalGenerator + ->GetGeneratorTarget(this->Target); // Get the language used for linking this target. - this->LinkLanguage = this->Target->GetLinkerLanguage(config); + this->LinkLanguage = gtgt->GetLinkerLanguage(config); if(this->LinkLanguage.empty()) { // The Compute method will do nothing, so skip the rest of the @@ -322,9 +324,6 @@ cmComputeLinkInformation (this->Makefile-> GetSafeDefinition("CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH")); - cmGeneratorTarget *gtgt = this->Target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(this->Target); this->RuntimeUseChrpath = gtgt->IsChrpathUsed(config); // Get options needed to help find dependent libraries. diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 49fc96b..a86c2bc 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -990,6 +990,9 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode assert(target); + cmGeneratorTarget* gtgt = + context->Makefile->GetGlobalGenerator()->GetGeneratorTarget(target); + if (propertyName == "LINKER_LANGUAGE") { if (target->LinkLanguagePropagatesToDependents() && @@ -1001,7 +1004,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode "link libraries for a static library"); return std::string(); } - return target->GetLinkerLanguage(context->Config); + return gtgt->GetLinkerLanguage(context->Config); } cmGeneratorExpressionDAGChecker dagChecker(context->Backtrace, @@ -1128,9 +1131,6 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode } } - cmGeneratorTarget* gtgt = - context->Makefile->GetGlobalGenerator()->GetGeneratorTarget(target); - if (!prop) { if (target->IsImported() @@ -1600,7 +1600,7 @@ struct TargetFilesystemArtifactResultCreator cmGeneratorExpressionContext *context, const GeneratorExpressionContent *content) { - std::string language = target->Target->GetLinkerLanguage(context->Config); + std::string language = target->GetLinkerLanguage(context->Config); std::string pdbSupportVar = "CMAKE_" + language + "_LINKER_SUPPORTS_PDB"; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 834a2e3..4de5e9c 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -709,8 +709,7 @@ bool cmGeneratorTarget::HasSOName(const std::string& config) const return ((this->GetType() == cmTarget::SHARED_LIBRARY || this->GetType() == cmTarget::MODULE_LIBRARY) && !this->GetPropertyAsBool("NO_SONAME") && - this->Makefile->GetSONameFlag( - this->Target->GetLinkerLanguage(config))); + this->Makefile->GetSONameFlag(this->GetLinkerLanguage(config))); } //---------------------------------------------------------------------------- @@ -752,7 +751,7 @@ cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const } // Check for rpath support on this platform. - std::string ll = this->Target->GetLinkerLanguage(config); + std::string ll = this->GetLinkerLanguage(config); if(!ll.empty()) { std::string flagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; @@ -823,7 +822,7 @@ bool cmGeneratorTarget::IsChrpathUsed(const std::string& config) const #if defined(CMAKE_USE_ELF_PARSER) // Enable if the rpath flag uses a separator and the target uses ELF // binaries. - std::string ll = this->Target->GetLinkerLanguage(config); + std::string ll = this->GetLinkerLanguage(config); if(!ll.empty()) { std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; @@ -1986,7 +1985,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, const char* suffixVar = this->Target->GetSuffixVariableInternal(implib); // Check for language-specific default prefix and suffix. - std::string ll = this->Target->GetLinkerLanguage(config); + std::string ll = this->GetLinkerLanguage(config); if(!ll.empty()) { if(!targetSuffix && suffixVar && *suffixVar) @@ -2056,6 +2055,13 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, //---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetLinkerLanguage(const std::string& config) const +{ + return this->Target->GetLinkClosure(config)->LinkerLanguage; +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetPDBName(const std::string& config) const { std::string prefix; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 7ee4fc5..41fb848 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -258,6 +258,9 @@ public: /** Return true if builtin chrpath will work for this target */ bool IsChrpathUsed(const std::string& config) const; + ///! Return the preferred linker language for this target + std::string GetLinkerLanguage(const std::string& config = "") const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index 2f9265a..1e57c33 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -128,7 +128,8 @@ void cmGhsMultiTargetGenerator::Generate() { config = "RELEASE"; } - const std::string language(this->Target->GetLinkerLanguage(config)); + const std::string language( + this->GeneratorTarget->GetLinkerLanguage(config)); config = cmSystemTools::UpperCase(config); this->DynamicDownload = this->DetermineIfDynamicDownload(config, language); if (this->DynamicDownload) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 7b0e153..5006828 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1376,7 +1376,8 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmTarget& cmtarget) return; } - std::string llang = cmtarget.GetLinkerLanguage("NOCONFIG"); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&cmtarget); + std::string llang = gtgt->GetLinkerLanguage("NOCONFIG"); if(llang.empty()) { return; } // If the language is compiled as a source trust Xcode to link with it. @@ -1824,7 +1825,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, AddCompileOptions(flags, &target, lang, configName); } - std::string llang = target.GetLinkerLanguage(configName); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); + std::string llang = gtgt->GetLinkerLanguage(configName); if(binary && llang.empty()) { cmSystemTools::Error @@ -1850,7 +1852,6 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, // Add the export symbol definition for shared library objects. this->AppendDefines(ppDefs, exportMacro); } - cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); std::vector targetDefines; target.GetCompileDefinitions(targetDefines, configName, "C"); this->AppendDefines(ppDefs, targetDefines); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 3ab501d..4ec77a1 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1353,7 +1353,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, linkFlags += this->Makefile->GetSafeDefinition(build); linkFlags += " "; } - std::string linkLanguage = target->Target->GetLinkerLanguage(buildType); + std::string linkLanguage = target->GetLinkerLanguage(buildType); if(linkLanguage.empty()) { cmSystemTools::Error diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 014d3be..29e1034 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1270,10 +1270,10 @@ void cmLocalVisualStudio6Generator std::vector configs; target.GetMakefile()->GetConfigurations(configs); std::vector::const_iterator it = configs.begin(); - const std::string& linkLanguage = target.GetLinkerLanguage(*it); + const std::string& linkLanguage = gt->GetLinkerLanguage(*it); for ( ; it != configs.end(); ++it) { - const std::string& configLinkLanguage = target.GetLinkerLanguage(*it); + const std::string& configLinkLanguage = gt->GetLinkerLanguage(*it); if (configLinkLanguage != linkLanguage) { cmSystemTools::Error @@ -1703,10 +1703,10 @@ void cmLocalVisualStudio6Generator std::vector configs; target.GetMakefile()->GetConfigurations(configs); std::vector::const_iterator it = configs.begin(); - const std::string& linkLanguage = target.GetLinkerLanguage(*it); + const std::string& linkLanguage = gt->GetLinkerLanguage(*it); for ( ; it != configs.end(); ++it) { - const std::string& configLinkLanguage = target.GetLinkerLanguage(*it); + const std::string& configLinkLanguage = gt->GetLinkerLanguage(*it); if (configLinkLanguage != linkLanguage) { cmSystemTools::Error diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 9f26712..a38a061 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -664,6 +664,10 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, const char* configType = "10"; const char* projectType = 0; bool targetBuilds = true; + + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); + switch(target.GetType()) { case cmTarget::OBJECT_LIBRARY: @@ -696,7 +700,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, { const std::string& linkLanguage = (this->FortranProject? std::string("Fortran"): - target.GetLinkerLanguage(configName)); + gt->GetLinkerLanguage(configName)); if(linkLanguage.empty()) { cmSystemTools::Error @@ -758,8 +762,6 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, targetOptions.Parse(flags.c_str()); targetOptions.Parse(defineFlags.c_str()); targetOptions.ParseFinish(); - cmGeneratorTarget* gt = - this->GlobalGenerator->GetGeneratorTarget(&target); std::vector targetDefines; target.GetCompileDefinitions(targetDefines, configName, "CXX"); targetOptions.AddDefines(targetDefines); @@ -1635,7 +1637,7 @@ cmLocalVisualStudio7GeneratorFCInfo lg->GlobalGenerator->GetLanguageFromExtension (sf.GetExtension().c_str()); const std::string& sourceLang = lg->GetSourceFileLanguage(sf); - const std::string& linkLanguage = target.GetLinkerLanguage(i->c_str()); + const std::string& linkLanguage = gt->GetLinkerLanguage(i->c_str()); bool needForceLang = false; // source file does not match its extension language if(lang != sourceLang) diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 2fd77c9..afe145a 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -161,7 +161,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) // Get the language to use for linking this executable. std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); // Make sure we have a link language. if(linkLanguage.empty()) diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index b85b8a8..bb0f9dd 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -133,7 +133,7 @@ void cmMakefileLibraryTargetGenerator::WriteObjectLibraryRules() void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules() { std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_STATIC_LIBRARY"; @@ -159,7 +159,7 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink) return; } std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_SHARED_LIBRARY"; @@ -183,7 +183,7 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink) void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink) { std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_SHARED_MODULE"; @@ -206,7 +206,7 @@ void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink) void cmMakefileLibraryTargetGenerator::WriteFrameworkRules(bool relink) { std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_MACOSX_FRAMEWORK"; @@ -238,7 +238,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules // Get the language to use for linking this library. std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); // Make sure we have a link language. if(linkLanguage.empty()) diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index b94e151..d38cf4c 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1509,7 +1509,7 @@ std::string cmMakefileTargetGenerator::GetLinkRule( if(this->Target->HasImplibGNUtoMS()) { std::string ruleVar = "CMAKE_"; - ruleVar += this->Target->GetLinkerLanguage(this->ConfigName); + ruleVar += this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); ruleVar += "_GNUtoMS_RULE"; if(const char* rule = this->Makefile->GetDefinition(ruleVar)) { @@ -1663,7 +1663,8 @@ cmMakefileTargetGenerator { // Lookup the response file reference flag. std::string responseFlagVar = "CMAKE_"; - responseFlagVar += this->Target->GetLinkerLanguage(this->ConfigName); + responseFlagVar += this->GeneratorTarget + ->GetLinkerLanguage(this->ConfigName); responseFlagVar += "_RESPONSE_FILE_LINK_FLAG"; const char* responseFlag = this->Makefile->GetDefinition(responseFlagVar); @@ -1707,7 +1708,8 @@ cmMakefileTargetGenerator // Lookup the response file reference flag. std::string responseFlagVar = "CMAKE_"; - responseFlagVar += this->Target->GetLinkerLanguage(this->ConfigName); + responseFlagVar += this->GeneratorTarget + ->GetLinkerLanguage(this->ConfigName); responseFlagVar += "_RESPONSE_FILE_LINK_FLAG"; const char* responseFlag = this->Makefile->GetDefinition(responseFlagVar); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 1835841..b855bea 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -40,8 +40,7 @@ cmNinjaNormalTargetGenerator(cmGeneratorTarget* target) , TargetNamePDB() , TargetLinkLanguage("") { - this->TargetLinkLanguage = target->Target - ->GetLinkerLanguage(this->GetConfigName()); + this->TargetLinkLanguage = target->GetLinkerLanguage(this->GetConfigName()); if (target->GetType() == cmTarget::EXECUTABLE) this->GetGeneratorTarget()->GetExecutableNames(this->TargetNameOut, this->TargetNameReal, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 37b788d..c7118dc 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3218,12 +3218,6 @@ private: }; //---------------------------------------------------------------------------- -std::string cmTarget::GetLinkerLanguage(const std::string& config) const -{ - return this->GetLinkClosure(config)->LinkerLanguage; -} - -//---------------------------------------------------------------------------- cmTarget::LinkClosure const* cmTarget::GetLinkClosure(const std::string& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index d0cbc66..dea9bef 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -365,9 +365,6 @@ public: void GetTargetVersion(bool soversion, int& major, int& minor, int& patch) const; - ///! Return the preferred linker language for this target - std::string GetLinkerLanguage(const std::string& config = "") const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 2b33c2c..80b8591 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1627,7 +1627,7 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( this->GlobalGenerator->GetLanguageFromExtension (sf.GetExtension().c_str()); std::string sourceLang = this->LocalGenerator->GetSourceFileLanguage(sf); - const std::string& linkLanguage = this->Target->GetLinkerLanguage(); + const std::string& linkLanguage = this->GeneratorTarget->GetLinkerLanguage(); bool needForceLang = false; // source file does not match its extension language if(lang != sourceLang) @@ -1888,7 +1888,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( std::string flags; const std::string& linkLanguage = - this->Target->GetLinkerLanguage(configName.c_str()); + this->GeneratorTarget->GetLinkerLanguage(configName.c_str()); if(linkLanguage.empty()) { cmSystemTools::Error @@ -2371,7 +2371,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) Options& linkOptions = *pOptions; const std::string& linkLanguage = - this->Target->GetLinkerLanguage(config.c_str()); + this->GeneratorTarget->GetLinkerLanguage(config.c_str()); if(linkLanguage.empty()) { cmSystemTools::Error http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=de2d705c0e0c4e0de910cc5f3874fc898d455634 commit de2d705c0e0c4e0de910cc5f3874fc898d455634 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:48 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 4 19:19:48 2015 +0200 cmGeneratorTarget: Move GetFrameworkDirectory from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 436e5dd..834a2e3 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -904,6 +904,48 @@ cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config, + bool contentOnly) const +{ + std::string fpath; + fpath += this->Target->GetOutputName(config, false); + fpath += "."; + const char *ext = this->Target->GetProperty("BUNDLE_EXTENSION"); + if (!ext) + { + if (this->Target->IsXCTestOnApple()) + { + ext = "xctest"; + } + else + { + ext = "bundle"; + } + } + fpath += ext; + fpath += "/Contents"; + if(!contentOnly) + fpath += "/MacOS"; + return fpath; +} + +//---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetFrameworkDirectory(const std::string& config, + bool rootDir) const +{ + std::string fpath; + fpath += this->Target->GetOutputName(config, false); + fpath += ".framework"; + if(!rootDir) + { + fpath += "/Versions/"; + fpath += this->Target->GetFrameworkVersion(); + } + return fpath; +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetFullName(const std::string& config, bool implib) const { @@ -1007,11 +1049,11 @@ cmGeneratorTarget::BuildMacContentDirectory(const std::string& base, } if(this->Target->IsFrameworkOnApple()) { - fpath += this->Target->GetFrameworkDirectory(config, contentOnly); + fpath += this->GetFrameworkDirectory(config, contentOnly); } if(this->Target->IsCFBundleOnApple()) { - fpath += this->Target->GetCFBundleDirectory(config, contentOnly); + fpath += this->GetCFBundleDirectory(config, contentOnly); } return fpath; } @@ -1982,7 +2024,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, if(this->Target->IsCFBundleOnApple()) { - fw_prefix = this->Target->GetCFBundleDirectory(config, false); + fw_prefix = this->GetCFBundleDirectory(config, false); fw_prefix += "/"; targetPrefix = fw_prefix.c_str(); targetSuffix = 0; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 1dfdbb3..7ee4fc5 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -124,6 +124,14 @@ public: std::string GetFullName(const std::string& config="", bool implib = false) const; + /** @return the Mac framework directory without the base. */ + std::string GetFrameworkDirectory(const std::string& config, + bool rootDir) const; + + /** @return the Mac CFBundle directory without the base */ + std::string GetCFBundleDirectory(const std::string& config, + bool contentOnly) const; + /** Return the install name directory for the target in the * build tree. For example: "\@rpath/", "\@loader_path/", * or "/full/path/to/library". */ diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 1d85d9c..4fe99e3 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -77,11 +77,11 @@ void cmOSXBundleGenerator::CreateFramework( // Compute the location of the top-level foo.framework directory. std::string contentdir = outpath + "/" + - this->GT->Target->GetFrameworkDirectory(this->ConfigName, true); + this->GT->GetFrameworkDirectory(this->ConfigName, true); contentdir += "/"; std::string newoutpath = outpath + "/" + - this->GT->Target->GetFrameworkDirectory(this->ConfigName, false); + this->GT->GetFrameworkDirectory(this->ConfigName, false); std::string frameworkVersion = this->GT->Target->GetFrameworkVersion(); @@ -172,14 +172,14 @@ void cmOSXBundleGenerator::CreateCFBundle(const std::string& targetName, // Compute bundle directory names. std::string out = root; out += "/"; - out += this->GT->Target->GetCFBundleDirectory(this->ConfigName, false); + out += this->GT->GetCFBundleDirectory(this->ConfigName, false); cmSystemTools::MakeDirectory(out.c_str()); this->Makefile->AddCMakeOutputFile(out); // Configure the Info.plist file. Note that it needs the executable name // to be set. std::string plist = root + "/" + - this->GT->Target->GetCFBundleDirectory(this->ConfigName, true); + this->GT->GetCFBundleDirectory(this->ConfigName, true); plist += "/Info.plist"; std::string name = cmSystemTools::GetFilenameName(targetName); this->LocalGenerator->GenerateAppleInfoPList(this->GT->Target, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index a5ff829..37b788d 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -5126,47 +5126,6 @@ std::string cmTarget::CheckCMP0004(std::string const& item) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetFrameworkDirectory(const std::string& config, - bool rootDir) const -{ - std::string fpath; - fpath += this->GetOutputName(config, false); - fpath += ".framework"; - if(!rootDir) - { - fpath += "/Versions/"; - fpath += this->GetFrameworkVersion(); - } - return fpath; -} - -//---------------------------------------------------------------------------- -std::string cmTarget::GetCFBundleDirectory(const std::string& config, - bool contentOnly) const -{ - std::string fpath; - fpath += this->GetOutputName(config, false); - fpath += "."; - const char *ext = this->GetProperty("BUNDLE_EXTENSION"); - if (!ext) - { - if (this->IsXCTestOnApple()) - { - ext = "xctest"; - } - else - { - ext = "bundle"; - } - } - fpath += ext; - fpath += "/Contents"; - if(!contentOnly) - fpath += "/MacOS"; - return fpath; -} - -//---------------------------------------------------------------------------- cmTargetInternalPointer::cmTargetInternalPointer() { this->Pointer = new cmTargetInternals; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e22d3af..d0cbc66 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -460,14 +460,6 @@ public: /** @return whether this target have a well defined output file name. */ bool HaveWellDefinedOutputFiles() const; - /** @return the Mac framework directory without the base. */ - std::string GetFrameworkDirectory(const std::string& config, - bool rootDir) const; - - /** @return the Mac CFBundle directory without the base */ - std::string GetCFBundleDirectory(const std::string& config, - bool contentOnly) const; - std::vector GetIncludeDirectories( const std::string& config, const std::string& language) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9f4b3c8e60590576dbad108cd6a739679301ed3e commit 9f4b3c8e60590576dbad108cd6a739679301ed3e Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:48 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 4 19:19:48 2015 +0200 cmGeneratorTarget: Move GetFullName from cmTarget. Bring GetFullNameInternal with it. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 0fdf646..436e5dd 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -576,7 +576,7 @@ const char* cmGeneratorTarget::GetLocationForBuild() const } } location += "/"; - location += this->Target->GetFullName("", false); + location += this->GetFullName("", false); return location.c_str(); } @@ -663,7 +663,7 @@ cmGeneratorTarget::GetCompilePDBName(const std::string& config) const std::string prefix; std::string base; std::string suffix; - this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, false, prefix, base, suffix); // Check for a per-configuration output directory target property. std::string configUpper = cmSystemTools::UpperCase(config); @@ -896,7 +896,7 @@ std::string cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, bool contentOnly) const { - std::string fpath = this->Target->GetFullName(config, false); + std::string fpath = this->GetFullName(config, false); fpath += ".app/Contents"; if(!contentOnly) fpath += "/MacOS"; @@ -905,6 +905,20 @@ cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, //---------------------------------------------------------------------------- std::string +cmGeneratorTarget::GetFullName(const std::string& config, bool implib) const +{ + if(this->Target->IsImported()) + { + return this->Target->GetFullNameImported(config, implib); + } + else + { + return this->GetFullNameInternal(config, implib); + } +} + +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetInstallNameDirForBuildTree( const std::string& config) const { @@ -977,7 +991,7 @@ void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, const std::string& config, bool implib) const { - this->Target->GetFullNameInternal(config, implib, prefix, base, suffix); + this->GetFullNameInternal(config, implib, prefix, base, suffix); } //---------------------------------------------------------------------------- @@ -1655,7 +1669,7 @@ std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config, // Add the full name of the target. if(implib) { - fpath += this->Target->GetFullName(config, true); + fpath += this->GetFullName(config, true); } else if(realname) { @@ -1663,7 +1677,7 @@ std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config, } else { - fpath += this->Target->GetFullName(config, false); + fpath += this->GetFullName(config, false); } return fpath; } @@ -1753,7 +1767,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, std::string prefix; std::string base; std::string suffix; - this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, false, prefix, base, suffix); // The library name. name = prefix+base+suffix; @@ -1782,7 +1796,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, if(this->GetType() == cmTarget::SHARED_LIBRARY || this->GetType() == cmTarget::MODULE_LIBRARY) { - impName = this->Target->GetFullNameInternal(config, true); + impName = this->GetFullNameInternal(config, true); } else { @@ -1828,7 +1842,7 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, std::string prefix; std::string base; std::string suffix; - this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, false, prefix, base, suffix); // The executable name. name = prefix+base+suffix; @@ -1849,19 +1863,163 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, #endif // The import library name. - impName = this->Target->GetFullNameInternal(config, true); + impName = this->GetFullNameInternal(config, true); // The program database file name. pdbName = this->GetPDBName(config); } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetFullNameInternal(const std::string& config, + bool implib) const +{ + std::string prefix; + std::string base; + std::string suffix; + this->GetFullNameInternal(config, implib, prefix, base, suffix); + return prefix+base+suffix; +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GetFullNameInternal(const std::string& config, + bool implib, + std::string& outPrefix, + std::string& outBase, + std::string& outSuffix) const +{ + // Use just the target name for non-main target types. + if(this->GetType() != cmTarget::STATIC_LIBRARY && + this->GetType() != cmTarget::SHARED_LIBRARY && + this->GetType() != cmTarget::MODULE_LIBRARY && + this->GetType() != cmTarget::EXECUTABLE) + { + outPrefix = ""; + outBase = this->GetName(); + outSuffix = ""; + return; + } + + // Return an empty name for the import library if this platform + // does not support import libraries. + if(implib && + !this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) + { + outPrefix = ""; + outBase = ""; + outSuffix = ""; + return; + } + + // The implib option is only allowed for shared libraries, module + // libraries, and executables. + if(this->GetType() != cmTarget::SHARED_LIBRARY && + this->GetType() != cmTarget::MODULE_LIBRARY && + this->GetType() != cmTarget::EXECUTABLE) + { + implib = false; + } + + // Compute the full name for main target types. + const char* targetPrefix = (implib + ? this->GetProperty("IMPORT_PREFIX") + : this->GetProperty("PREFIX")); + const char* targetSuffix = (implib + ? this->GetProperty("IMPORT_SUFFIX") + : this->GetProperty("SUFFIX")); + const char* configPostfix = 0; + if(!config.empty()) + { + std::string configProp = cmSystemTools::UpperCase(config); + configProp += "_POSTFIX"; + configPostfix = this->GetProperty(configProp); + // Mac application bundles and frameworks have no postfix. + if(configPostfix && + (this->Target->IsAppBundleOnApple() + || this->Target->IsFrameworkOnApple())) + { + configPostfix = 0; + } + } + const char* prefixVar = this->Target->GetPrefixVariableInternal(implib); + const char* suffixVar = this->Target->GetSuffixVariableInternal(implib); + + // Check for language-specific default prefix and suffix. + std::string ll = this->Target->GetLinkerLanguage(config); + if(!ll.empty()) + { + if(!targetSuffix && suffixVar && *suffixVar) + { + std::string langSuff = suffixVar + std::string("_") + ll; + targetSuffix = this->Makefile->GetDefinition(langSuff); + } + if(!targetPrefix && prefixVar && *prefixVar) + { + std::string langPrefix = prefixVar + std::string("_") + ll; + targetPrefix = this->Makefile->GetDefinition(langPrefix); + } + } + + // if there is no prefix on the target use the cmake definition + if(!targetPrefix && prefixVar) + { + targetPrefix = this->Makefile->GetSafeDefinition(prefixVar); + } + // if there is no suffix on the target use the cmake definition + if(!targetSuffix && suffixVar) + { + targetSuffix = this->Makefile->GetSafeDefinition(suffixVar); + } + + // frameworks have directory prefix but no suffix + std::string fw_prefix; + if(this->Target->IsFrameworkOnApple()) + { + fw_prefix = this->Target->GetOutputName(config, false); + fw_prefix += ".framework/"; + targetPrefix = fw_prefix.c_str(); + targetSuffix = 0; + } + + if(this->Target->IsCFBundleOnApple()) + { + fw_prefix = this->Target->GetCFBundleDirectory(config, false); + fw_prefix += "/"; + targetPrefix = fw_prefix.c_str(); + targetSuffix = 0; + } + + // Begin the final name with the prefix. + outPrefix = targetPrefix?targetPrefix:""; + + // Append the target name or property-specified name. + outBase += this->Target->GetOutputName(config, implib); + + // Append the per-configuration postfix. + outBase += configPostfix?configPostfix:""; + + // Name shared libraries with their version number on some platforms. + if(const char* soversion = this->GetProperty("SOVERSION")) + { + if(this->GetType() == cmTarget::SHARED_LIBRARY && !implib && + this->Makefile->IsOn("CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION")) + { + outBase += "-"; + outBase += soversion; + } + } + + // Append the suffix. + outSuffix = targetSuffix?targetSuffix:""; +} + + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetPDBName(const std::string& config) const { std::string prefix; std::string base; std::string suffix; - this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, false, prefix, base, suffix); std::vector props; std::string configUpper = diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index f0d8c60..1dfdbb3 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -119,6 +119,11 @@ public: std::string GetAppBundleDirectory(const std::string& config, bool contentOnly) const; + /** Get the full name of the target according to the settings in its + makefile. */ + std::string GetFullName(const std::string& config="", + bool implib = false) const; + /** Return the install name directory for the target in the * build tree. For example: "\@rpath/", "\@loader_path/", * or "/full/path/to/library". */ @@ -279,6 +284,12 @@ private: mutable std::map DebugCompatiblePropertiesDone; + std::string GetFullNameInternal(const std::string& config, + bool implib) const; + void GetFullNameInternal(const std::string& config, bool implib, + std::string& outPrefix, std::string& outBase, + std::string& outSuffix) const; + struct CompatibleInterfacesBase { std::set PropsBool; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index d53ecde..7b0e153 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2742,7 +2742,8 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget, } else { - fullName = cmtarget.GetFullName(defConfig.c_str()); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&cmtarget); + fullName = gtgt->GetFullName(defConfig.c_str()); } fileRef->AddAttribute("path", this->CreateString(fullName.c_str())); fileRef->AddAttribute("refType", this->CreateString("0")); @@ -3688,7 +3689,7 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( std::string universalFile = universal; universalFile += *arch; universalFile += "/"; - universalFile += t->GetFullName(configName); + universalFile += gt->GetFullName(configName); makefileStream << "\t/bin/rm -f " << this->ConvertToRelativeForMake(universalFile.c_str()) diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 61d7847..014d3be 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1115,10 +1115,12 @@ void cmLocalVisualStudio6Generator cmTarget* tgt = this->GlobalGenerator->FindTarget(j->first.c_str()); if(tgt) { + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(tgt); lib = cmSystemTools::GetFilenameWithoutExtension - (tgt->GetFullName().c_str()); + (gt->GetFullName().c_str()); libDebug = cmSystemTools::GetFilenameWithoutExtension - (tgt->GetFullName("Debug").c_str()); + (gt->GetFullName("Debug").c_str()); lib += ".lib"; libDebug += ".lib"; } @@ -1258,8 +1260,8 @@ void cmLocalVisualStudio6Generator extraLinkOptionsRelWithDebInfo += targetLinkFlags; } - - + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); // Get standard libraries for this language. if(targetBuilds) @@ -1328,11 +1330,11 @@ void cmLocalVisualStudio6Generator target.GetType() == cmTarget::SHARED_LIBRARY || target.GetType() == cmTarget::MODULE_LIBRARY) { - outputName = target.GetFullName(); - outputNameDebug = target.GetFullName("Debug"); - outputNameRelease = target.GetFullName("Release"); - outputNameMinSizeRel = target.GetFullName("MinSizeRel"); - outputNameRelWithDebInfo = target.GetFullName("RelWithDebInfo"); + outputName = gt->GetFullName(); + outputNameDebug = gt->GetFullName("Debug"); + outputNameRelease = gt->GetFullName("Release"); + outputNameMinSizeRel = gt->GetFullName("MinSizeRel"); + outputNameRelWithDebInfo = gt->GetFullName("RelWithDebInfo"); } else if(target.GetType() == cmTarget::OBJECT_LIBRARY) { @@ -1429,10 +1431,10 @@ void cmLocalVisualStudio6Generator fullPathImpRelease += "/"; fullPathImpMinSizeRel += "/"; fullPathImpRelWithDebInfo += "/"; - fullPathImpDebug += target.GetFullName("Debug", true); - fullPathImpRelease += target.GetFullName("Release", true); - fullPathImpMinSizeRel += target.GetFullName("MinSizeRel", true); - fullPathImpRelWithDebInfo += target.GetFullName("RelWithDebInfo", true); + fullPathImpDebug += gt->GetFullName("Debug", true); + fullPathImpRelease += gt->GetFullName("Release", true); + fullPathImpMinSizeRel += gt->GetFullName("MinSizeRel", true); + fullPathImpRelWithDebInfo += gt->GetFullName("RelWithDebInfo", true); targetImplibFlagDebug = "/implib:"; targetImplibFlagRelease = "/implib:"; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 799bac6..9f26712 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -803,7 +803,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, if (this->FortranProject) { // Intel Fortran >= 15.0 uses TargetName property. - std::string targetNameFull = target.GetFullName(configName); + std::string targetNameFull = gt->GetFullName(configName); std::string targetName = cmSystemTools::GetFilenameWithoutLastExtension(targetNameFull); std::string targetExt = @@ -1107,7 +1107,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, } case cmTarget::STATIC_LIBRARY: { - std::string targetNameFull = target.GetFullName(configName); + std::string targetNameFull = gt->GetFullName(configName); std::string libpath = target.GetDirectory(configName); libpath += "/"; libpath += targetNameFull; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e8ef770..a5ff829 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3587,20 +3587,6 @@ bool cmTarget::IsImportedSharedLibWithoutSOName( } //---------------------------------------------------------------------------- -std::string cmTarget::GetFullName(const std::string& config, - bool implib) const -{ - if(this->IsImported()) - { - return this->GetFullNameImported(config, implib); - } - else - { - return this->GetFullNameInternal(config, implib); - } -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetFullNameImported(const std::string& config, bool implib) const { @@ -3626,148 +3612,6 @@ cmTarget::ImportedGetFullPath(const std::string& config, bool implib) const } //---------------------------------------------------------------------------- -std::string -cmTarget::GetFullNameInternal(const std::string& config, bool implib) const -{ - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, implib, prefix, base, suffix); - return prefix+base+suffix; -} - -//---------------------------------------------------------------------------- -void cmTarget::GetFullNameInternal(const std::string& config, - bool implib, - std::string& outPrefix, - std::string& outBase, - std::string& outSuffix) const -{ - // Use just the target name for non-main target types. - if(this->GetType() != cmTarget::STATIC_LIBRARY && - this->GetType() != cmTarget::SHARED_LIBRARY && - this->GetType() != cmTarget::MODULE_LIBRARY && - this->GetType() != cmTarget::EXECUTABLE) - { - outPrefix = ""; - outBase = this->GetName(); - outSuffix = ""; - return; - } - - // Return an empty name for the import library if this platform - // does not support import libraries. - if(implib && - !this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) - { - outPrefix = ""; - outBase = ""; - outSuffix = ""; - return; - } - - // The implib option is only allowed for shared libraries, module - // libraries, and executables. - if(this->GetType() != cmTarget::SHARED_LIBRARY && - this->GetType() != cmTarget::MODULE_LIBRARY && - this->GetType() != cmTarget::EXECUTABLE) - { - implib = false; - } - - // Compute the full name for main target types. - const char* targetPrefix = (implib - ? this->GetProperty("IMPORT_PREFIX") - : this->GetProperty("PREFIX")); - const char* targetSuffix = (implib - ? this->GetProperty("IMPORT_SUFFIX") - : this->GetProperty("SUFFIX")); - const char* configPostfix = 0; - if(!config.empty()) - { - std::string configProp = cmSystemTools::UpperCase(config); - configProp += "_POSTFIX"; - configPostfix = this->GetProperty(configProp); - // Mac application bundles and frameworks have no postfix. - if(configPostfix && - (this->IsAppBundleOnApple() || this->IsFrameworkOnApple())) - { - configPostfix = 0; - } - } - const char* prefixVar = this->GetPrefixVariableInternal(implib); - const char* suffixVar = this->GetSuffixVariableInternal(implib); - - // Check for language-specific default prefix and suffix. - std::string ll = this->GetLinkerLanguage(config); - if(!ll.empty()) - { - if(!targetSuffix && suffixVar && *suffixVar) - { - std::string langSuff = suffixVar + std::string("_") + ll; - targetSuffix = this->Makefile->GetDefinition(langSuff); - } - if(!targetPrefix && prefixVar && *prefixVar) - { - std::string langPrefix = prefixVar + std::string("_") + ll; - targetPrefix = this->Makefile->GetDefinition(langPrefix); - } - } - - // if there is no prefix on the target use the cmake definition - if(!targetPrefix && prefixVar) - { - targetPrefix = this->Makefile->GetSafeDefinition(prefixVar); - } - // if there is no suffix on the target use the cmake definition - if(!targetSuffix && suffixVar) - { - targetSuffix = this->Makefile->GetSafeDefinition(suffixVar); - } - - // frameworks have directory prefix but no suffix - std::string fw_prefix; - if(this->IsFrameworkOnApple()) - { - fw_prefix = this->GetOutputName(config, false); - fw_prefix += ".framework/"; - targetPrefix = fw_prefix.c_str(); - targetSuffix = 0; - } - - if(this->IsCFBundleOnApple()) - { - fw_prefix = this->GetCFBundleDirectory(config, false); - fw_prefix += "/"; - targetPrefix = fw_prefix.c_str(); - targetSuffix = 0; - } - - // Begin the final name with the prefix. - outPrefix = targetPrefix?targetPrefix:""; - - // Append the target name or property-specified name. - outBase += this->GetOutputName(config, implib); - - // Append the per-configuration postfix. - outBase += configPostfix?configPostfix:""; - - // Name shared libraries with their version number on some platforms. - if(const char* soversion = this->GetProperty("SOVERSION")) - { - if(this->GetType() == cmTarget::SHARED_LIBRARY && !implib && - this->Makefile->IsOn("CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION")) - { - outBase += "-"; - outBase += soversion; - } - } - - // Append the suffix. - outSuffix = targetSuffix?targetSuffix:""; -} - -//---------------------------------------------------------------------------- void cmTarget::ComputeVersionedName(std::string& vName, std::string const& prefix, std::string const& base, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 4b804da..e22d3af 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -368,11 +368,6 @@ public: ///! Return the preferred linker language for this target std::string GetLinkerLanguage(const std::string& config = "") const; - /** Get the full name of the target according to the settings in its - makefile. */ - std::string GetFullName(const std::string& config="", - bool implib = false) const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; @@ -575,11 +570,6 @@ private: const char* GetSuffixVariableInternal(bool implib) const; const char* GetPrefixVariableInternal(bool implib) const; - std::string GetFullNameInternal(const std::string& config, - bool implib) const; - void GetFullNameInternal(const std::string& config, bool implib, - std::string& outPrefix, std::string& outBase, - std::string& outSuffix) const; // Use a makefile variable to set a default for the given property. // If the variable is not defined use the given default instead. diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 16edf3c..2b33c2c 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1774,7 +1774,7 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions() else { outDir = this->Target->GetDirectory(config->c_str()) + "/"; - targetNameFull = this->Target->GetFullName(config->c_str()); + targetNameFull = this->GeneratorTarget->GetFullName(config->c_str()); } this->ConvertToWindowsSlash(intermediateDir); this->ConvertToWindowsSlash(outDir); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=49b4dc1ec857ceeccd63c3a7f5d8bb5167a16f41 commit 49b4dc1ec857ceeccd63c3a7f5d8bb5167a16f41 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:48 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 4 19:19:48 2015 +0200 cmGeneratorTarget: Move GetAppBundleDirectory from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 2de3c77..0fdf646 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -890,6 +890,19 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const } } + +//---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, + bool contentOnly) const +{ + std::string fpath = this->Target->GetFullName(config, false); + fpath += ".app/Contents"; + if(!contentOnly) + fpath += "/MacOS"; + return fpath; +} + //---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetInstallNameDirForBuildTree( @@ -976,7 +989,7 @@ cmGeneratorTarget::BuildMacContentDirectory(const std::string& base, std::string fpath = base; if(this->Target->IsAppBundleOnApple()) { - fpath += this->Target->GetAppBundleDirectory(config, contentOnly); + fpath += this->GetAppBundleDirectory(config, contentOnly); } if(this->Target->IsFrameworkOnApple()) { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 6d084f7..f0d8c60 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -115,6 +115,10 @@ public: bool realname) const; std::string NormalGetRealName(const std::string& config) const; + /** @return the Mac App directory without the base */ + std::string GetAppBundleDirectory(const std::string& config, + bool contentOnly) const; + /** Return the install name directory for the target in the * build tree. For example: "\@rpath/", "\@loader_path/", * or "/full/path/to/library". */ diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 7df2f78..1d85d9c 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -47,7 +47,7 @@ void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName, // Compute bundle directory names. std::string out = outpath; out += "/"; - out += this->GT->Target->GetAppBundleDirectory(this->ConfigName, false); + out += this->GT->GetAppBundleDirectory(this->ConfigName, false); cmSystemTools::MakeDirectory(out.c_str()); this->Makefile->AddCMakeOutputFile(out); @@ -57,7 +57,7 @@ void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName, // to be set. std::string plist = outpath; plist += "/"; - plist += this->GT->Target->GetAppBundleDirectory(this->ConfigName, true); + plist += this->GT->GetAppBundleDirectory(this->ConfigName, true); plist += "/Info.plist"; this->LocalGenerator->GenerateAppleInfoPList(this->GT->Target, targetName, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index b49ad9b..e8ef770 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -5323,17 +5323,6 @@ std::string cmTarget::GetCFBundleDirectory(const std::string& config, } //---------------------------------------------------------------------------- -std::string cmTarget::GetAppBundleDirectory(const std::string& config, - bool contentOnly) const -{ - std::string fpath = this->GetFullName(config, false); - fpath += ".app/Contents"; - if(!contentOnly) - fpath += "/MacOS"; - return fpath; -} - -//---------------------------------------------------------------------------- cmTargetInternalPointer::cmTargetInternalPointer() { this->Pointer = new cmTargetInternals; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index c1c518f..4b804da 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -473,10 +473,6 @@ public: std::string GetCFBundleDirectory(const std::string& config, bool contentOnly) const; - /** @return the Mac App directory without the base */ - std::string GetAppBundleDirectory(const std::string& config, - bool contentOnly) const; - std::vector GetIncludeDirectories( const std::string& config, const std::string& language) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cd7c204cef7bf52e49aa20cfa669d9db5ddcb08f commit cd7c204cef7bf52e49aa20cfa669d9db5ddcb08f Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:47 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 4 19:19:47 2015 +0200 cmGeneratorTarget: Move GetInstallNameDir* from cmTarget. diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 6274c3f..fed0dbc 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -333,12 +333,12 @@ cmExportBuildFileGenerator } std::string -cmExportBuildFileGenerator::InstallNameDir(cmTarget* target, +cmExportBuildFileGenerator::InstallNameDir(cmGeneratorTarget* target, const std::string& config) { std::string install_name_dir; - cmMakefile* mf = target->GetMakefile(); + cmMakefile* mf = target->Target->GetMakefile(); if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { install_name_dir = diff --git a/Source/cmExportBuildFileGenerator.h b/Source/cmExportBuildFileGenerator.h index 4d8e062..ff3d2e1 100644 --- a/Source/cmExportBuildFileGenerator.h +++ b/Source/cmExportBuildFileGenerator.h @@ -71,7 +71,8 @@ protected: cmGeneratorTarget* target, ImportPropertyMap& properties); - std::string InstallNameDir(cmTarget* target, const std::string& config); + std::string InstallNameDir(cmGeneratorTarget* target, + const std::string& config); std::vector FindNamespaces(cmMakefile* mf, const std::string& name); diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index e3652c5..cae60b7 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -893,7 +893,7 @@ cmExportFileGenerator { if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { - value = this->InstallNameDir(target->Target, config); + value = this->InstallNameDir(target, config); } prop = "IMPORTED_SONAME"; value += target->GetSOName(config); diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index 4e54740..44f779b 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -200,7 +200,7 @@ private: virtual void ReplaceInstallPrefix(std::string &input); - virtual std::string InstallNameDir(cmTarget* target, + virtual std::string InstallNameDir(cmGeneratorTarget* target, const std::string& config) = 0; }; diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index b0bc686..d55be11 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -546,12 +546,12 @@ cmExportInstallFileGenerator } std::string -cmExportInstallFileGenerator::InstallNameDir(cmTarget* target, +cmExportInstallFileGenerator::InstallNameDir(cmGeneratorTarget* target, const std::string&) { std::string install_name_dir; - cmMakefile* mf = target->GetMakefile(); + cmMakefile* mf = target->Target->GetMakefile(); if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { install_name_dir = diff --git a/Source/cmExportInstallFileGenerator.h b/Source/cmExportInstallFileGenerator.h index 6f86ac9..b06fee5 100644 --- a/Source/cmExportInstallFileGenerator.h +++ b/Source/cmExportInstallFileGenerator.h @@ -83,7 +83,8 @@ protected: std::set& importedLocations ); - std::string InstallNameDir(cmTarget* target, const std::string& config); + std::string InstallNameDir(cmGeneratorTarget* target, + const std::string& config); cmInstallExportGenerator* IEGen; diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx index 94831f8..ba66531 100644 --- a/Source/cmExportTryCompileFileGenerator.cxx +++ b/Source/cmExportTryCompileFileGenerator.cxx @@ -125,12 +125,12 @@ cmExportTryCompileFileGenerator::PopulateProperties(cmTarget const* target, } std::string -cmExportTryCompileFileGenerator::InstallNameDir(cmTarget* target, +cmExportTryCompileFileGenerator::InstallNameDir(cmGeneratorTarget* target, const std::string& config) { std::string install_name_dir; - cmMakefile* mf = target->GetMakefile(); + cmMakefile* mf = target->Target->GetMakefile(); if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { install_name_dir = diff --git a/Source/cmExportTryCompileFileGenerator.h b/Source/cmExportTryCompileFileGenerator.h index 749f3ef..8838eca 100644 --- a/Source/cmExportTryCompileFileGenerator.h +++ b/Source/cmExportTryCompileFileGenerator.h @@ -45,7 +45,7 @@ protected: ImportPropertyMap& properties, std::set &emitted); - std::string InstallNameDir(cmTarget* target, + std::string InstallNameDir(cmGeneratorTarget* target, const std::string& config); private: std::string FindTargets(const std::string& prop, cmTarget const* tgt, diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 45577e5..2de3c77 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -891,6 +891,73 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const } //---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetInstallNameDirForBuildTree( + const std::string& config) const +{ + // If building directly for installation then the build tree install_name + // is the same as the install tree. + if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) + { + return this->GetInstallNameDirForInstallTree(); + } + + // Use the build tree directory for the target. + if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME") && + !this->Makefile->IsOn("CMAKE_SKIP_RPATH") && + !this->GetPropertyAsBool("SKIP_BUILD_RPATH")) + { + std::string dir; + if(this->Target->MacOSXRpathInstallNameDirDefault()) + { + dir = "@rpath"; + } + else + { + dir = this->Target->GetDirectory(config); + } + dir += "/"; + return dir; + } + else + { + return ""; + } +} + +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetInstallNameDirForInstallTree() const +{ + if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) + { + std::string dir; + const char* install_name_dir = this->GetProperty("INSTALL_NAME_DIR"); + + if(!this->Makefile->IsOn("CMAKE_SKIP_RPATH") && + !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH")) + { + if(install_name_dir && *install_name_dir) + { + dir = install_name_dir; + dir += "/"; + } + } + if(!install_name_dir) + { + if(this->Target->MacOSXRpathInstallNameDirDefault()) + { + dir = "@rpath/"; + } + } + return dir; + } + else + { + return ""; + } +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, std::string& base, std::string& suffix, diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 8fc1b44..6d084f7 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -115,6 +115,15 @@ public: bool realname) const; std::string NormalGetRealName(const std::string& config) const; + /** Return the install name directory for the target in the + * build tree. For example: "\@rpath/", "\@loader_path/", + * or "/full/path/to/library". */ + std::string GetInstallNameDirForBuildTree(const std::string& config) const; + + /** Return the install name directory for the target in the + * install tree. For example: "\@rpath/" or "\@loader_path/". */ + std::string GetInstallNameDirForInstallTree() const; + /** Get the soname of the target. Allowed only for a shared library. */ std::string GetSOName(const std::string& config) const; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 03f6d8f..d53ecde 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2331,7 +2331,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, if(target.GetType() == cmTarget::SHARED_LIBRARY) { // Get the install_name directory for the build tree. - install_name_dir = target.GetInstallNameDirForBuildTree(configName); + install_name_dir = gtgt->GetInstallNameDirForBuildTree(configName); // Xcode doesn't create the correct install_name in some cases. // That is, if the INSTALL_PATH is empty, or if we have versioning // of dylib libraries, we want to specify the install_name. diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 24c1c49..30cf175 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -576,11 +576,14 @@ cmInstallTargetGenerator continue; } + cmGeneratorTarget *gtgt = tgt->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(tgt); // If the build tree and install tree use different path // components of the install_name field then we need to create a // mapping to be applied after installation. - std::string for_build = tgt->GetInstallNameDirForBuildTree(config); - std::string for_install = tgt->GetInstallNameDirForInstallTree(); + std::string for_build = gtgt->GetInstallNameDirForBuildTree(config); + std::string for_install = gtgt->GetInstallNameDirForInstallTree(); if(for_build != for_install) { // The directory portions differ. Append the filename to @@ -605,9 +608,9 @@ cmInstallTargetGenerator if(this->Target->GetType() == cmTarget::SHARED_LIBRARY) { std::string for_build = - this->Target->Target->GetInstallNameDirForBuildTree(config); + this->Target->GetInstallNameDirForBuildTree(config); std::string for_install = - this->Target->Target->GetInstallNameDirForInstallTree(); + this->Target->GetInstallNameDirForInstallTree(); if(this->Target->Target->IsFrameworkOnApple() && for_install.empty()) { diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index a2fcbad..b85b8a8 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -666,7 +666,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules { // Get the install_name directory for the build tree. install_name_dir = - this->Target->GetInstallNameDirForBuildTree(this->ConfigName); + this->GeneratorTarget->GetInstallNameDirForBuildTree(this->ConfigName); // Set the rule variable replacement value. if(install_name_dir.empty()) diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index c80f485..1835841 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -537,7 +537,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() vars["SONAME"] = this->TargetNameSO; if (targetType == cmTarget::SHARED_LIBRARY) { - std::string install_dir = target.GetInstallNameDirForBuildTree(cfgName); + std::string install_dir = + this->GetGeneratorTarget()->GetInstallNameDirForBuildTree(cfgName); if (!install_dir.empty()) { vars["INSTALLNAME_DIR"] = localGen.Convert(install_dir, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 0f1d309..b49ad9b 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3846,73 +3846,6 @@ bool cmTarget::HaveInstallTreeRPATH() const } //---------------------------------------------------------------------------- -std::string cmTarget::GetInstallNameDirForBuildTree( - const std::string& config) const -{ - // If building directly for installation then the build tree install_name - // is the same as the install tree. - if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) - { - return GetInstallNameDirForInstallTree(); - } - - // Use the build tree directory for the target. - if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME") && - !this->Makefile->IsOn("CMAKE_SKIP_RPATH") && - !this->GetPropertyAsBool("SKIP_BUILD_RPATH")) - { - std::string dir; - bool macosx_rpath = this->MacOSXRpathInstallNameDirDefault(); - if(macosx_rpath) - { - dir = "@rpath"; - } - else - { - dir = this->GetDirectory(config); - } - dir += "/"; - return dir; - } - else - { - return ""; - } -} - -//---------------------------------------------------------------------------- -std::string cmTarget::GetInstallNameDirForInstallTree() const -{ - if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) - { - std::string dir; - const char* install_name_dir = this->GetProperty("INSTALL_NAME_DIR"); - - if(!this->Makefile->IsOn("CMAKE_SKIP_RPATH") && - !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH")) - { - if(install_name_dir && *install_name_dir) - { - dir = install_name_dir; - dir += "/"; - } - } - if(!install_name_dir) - { - if(this->MacOSXRpathInstallNameDirDefault()) - { - dir = "@rpath/"; - } - } - return dir; - } - else - { - return ""; - } -} - -//---------------------------------------------------------------------------- const char* cmTarget::GetOutputTargetType(bool implib) const { switch(this->GetType()) diff --git a/Source/cmTarget.h b/Source/cmTarget.h index d03ba3b..c1c518f 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -394,15 +394,6 @@ public: bool HaveBuildTreeRPATH(const std::string& config) const; bool HaveInstallTreeRPATH() const; - /** Return the install name directory for the target in the - * build tree. For example: "\@rpath/", "\@loader_path/", - * or "/full/path/to/library". */ - std::string GetInstallNameDirForBuildTree(const std::string& config) const; - - /** Return the install name directory for the target in the - * install tree. For example: "\@rpath/" or "\@loader_path/". */ - std::string GetInstallNameDirForInstallTree() const; - // Get the properties cmPropertyMap &GetProperties() const { return this->Properties; } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f7a6b821224f5d54f8b255a2d547f51d434d2a34 commit f7a6b821224f5d54f8b255a2d547f51d434d2a34 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:47 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 4 19:19:47 2015 +0200 cmGeneratorTarget: Move GetMacContentDirectory from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 4be034f..45577e5 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -567,7 +567,7 @@ const char* cmGeneratorTarget::GetLocationForBuild() const if(this->Target->IsAppBundleOnApple()) { - std::string macdir = this->Target->BuildMacContentDirectory("", "", + std::string macdir = this->BuildMacContentDirectory("", "", false); if(!macdir.empty()) { @@ -902,6 +902,47 @@ void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, //---------------------------------------------------------------------------- std::string +cmGeneratorTarget::BuildMacContentDirectory(const std::string& base, + const std::string& config, + bool contentOnly) const +{ + std::string fpath = base; + if(this->Target->IsAppBundleOnApple()) + { + fpath += this->Target->GetAppBundleDirectory(config, contentOnly); + } + if(this->Target->IsFrameworkOnApple()) + { + fpath += this->Target->GetFrameworkDirectory(config, contentOnly); + } + if(this->Target->IsCFBundleOnApple()) + { + fpath += this->Target->GetCFBundleDirectory(config, contentOnly); + } + return fpath; +} + +//---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetMacContentDirectory(const std::string& config, + bool implib) const +{ + // Start with the output directory for the target. + std::string fpath = this->Target->GetDirectory(config, implib); + fpath += "/"; + bool contentOnly = true; + if(this->Target->IsFrameworkOnApple()) + { + // additional files with a framework go into the version specific + // directory + contentOnly = false; + } + fpath = this->BuildMacContentDirectory(fpath, config, contentOnly); + return fpath; +} + +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetModuleDefinitionFile(const std::string& config) const { std::string data; @@ -1527,7 +1568,7 @@ std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config, fpath += "/"; if(this->Target->IsAppBundleOnApple()) { - fpath = this->Target->BuildMacContentDirectory(fpath, config, false); + fpath = this->BuildMacContentDirectory(fpath, config, false); fpath += "/"; } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index f96adad..8fc1b44 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -123,6 +123,15 @@ public: const std::string& config="", bool implib = false) const; + /** Append to @a base the mac content directory and return it. */ + std::string BuildMacContentDirectory(const std::string& base, + const std::string& config = "", + bool contentOnly = true) const; + + /** @return the mac content directory for this target. */ + std::string GetMacContentDirectory(const std::string& config = 0, + bool implib = false) const; + cmTarget* Target; cmMakefile* Makefile; cmLocalGenerator* LocalGenerator; diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 3bc0eb7..7df2f78 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -217,7 +217,7 @@ cmOSXBundleGenerator::InitMacOSXContentDirectory(const char* pkgloc) // Construct the full path to the content subdirectory. std::string macdir = - this->GT->Target->GetMacContentDirectory(this->ConfigName, + this->GT->GetMacContentDirectory(this->ConfigName, /*implib*/ false); macdir += "/"; macdir += pkgloc; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 0d9aa49..0f1d309 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -5401,45 +5401,6 @@ std::string cmTarget::GetAppBundleDirectory(const std::string& config, } //---------------------------------------------------------------------------- -std::string cmTarget::BuildMacContentDirectory(const std::string& base, - const std::string& config, - bool contentOnly) const -{ - std::string fpath = base; - if(this->IsAppBundleOnApple()) - { - fpath += this->GetAppBundleDirectory(config, contentOnly); - } - if(this->IsFrameworkOnApple()) - { - fpath += this->GetFrameworkDirectory(config, contentOnly); - } - if(this->IsCFBundleOnApple()) - { - fpath += this->GetCFBundleDirectory(config, contentOnly); - } - return fpath; -} - -//---------------------------------------------------------------------------- -std::string cmTarget::GetMacContentDirectory(const std::string& config, - bool implib) const -{ - // Start with the output directory for the target. - std::string fpath = this->GetDirectory(config, implib); - fpath += "/"; - bool contentOnly = true; - if(this->IsFrameworkOnApple()) - { - // additional files with a framework go into the version specific - // directory - contentOnly = false; - } - fpath = this->BuildMacContentDirectory(fpath, config, contentOnly); - return fpath; -} - -//---------------------------------------------------------------------------- cmTargetInternalPointer::cmTargetInternalPointer() { this->Pointer = new cmTargetInternals; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 9962fdb..d03ba3b 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -471,10 +471,6 @@ public: directory. */ bool UsesDefaultOutputDir(const std::string& config, bool implib) const; - /** @return the mac content directory for this target. */ - std::string GetMacContentDirectory(const std::string& config, - bool implib) const; - /** @return whether this target have a well defined output file name. */ bool HaveWellDefinedOutputFiles() const; @@ -615,10 +611,6 @@ private: std::string ImportedGetFullPath(const std::string& config, bool implib) const; - /** Append to @a base the mac content directory and return it. */ - std::string BuildMacContentDirectory(const std::string& base, - const std::string& config, - bool contentOnly) const; void GetSourceFiles(std::vector &files, const std::string& config) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=41a64c59c6276e247d801248dc5be21ded76cc0d commit 41a64c59c6276e247d801248dc5be21ded76cc0d Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:47 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 4 19:19:47 2015 +0200 cmGeneratorTarget: Move GetFullNameComponents from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 6481390..4be034f 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -891,6 +891,16 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const } //---------------------------------------------------------------------------- +void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, + std::string& base, + std::string& suffix, + const std::string& config, + bool implib) const +{ + this->Target->GetFullNameInternal(config, implib, prefix, base, suffix); +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetModuleDefinitionFile(const std::string& config) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 9ecbbbe..f96adad 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -118,6 +118,11 @@ public: /** Get the soname of the target. Allowed only for a shared library. */ std::string GetSOName(const std::string& config) const; + void GetFullNameComponents(std::string& prefix, + std::string& base, std::string& suffix, + const std::string& config="", + bool implib = false) const; + cmTarget* Target; cmMakefile* Makefile; cmLocalGenerator* LocalGenerator; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index d7ae36d..03f6d8f 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1940,7 +1940,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, std::string pnprefix; std::string pnbase; std::string pnsuffix; - target.GetFullNameComponents(pnprefix, pnbase, pnsuffix, configName); + gtgt->GetFullNameComponents(pnprefix, pnbase, pnsuffix, configName); const char* version = target.GetProperty("VERSION"); const char* soversion = target.GetProperty("SOVERSION"); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 2586b31..c80f485 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -569,7 +569,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() std::string prefix; std::string base; std::string suffix; - target.GetFullNameComponents(prefix, base, suffix); + this->GetGeneratorTarget()->GetFullNameComponents(prefix, base, suffix); std::string dbg_suffix = ".dbg"; // TODO: Where to document? if (mf->GetDefinition("CMAKE_DEBUG_SYMBOL_SUFFIX")) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1183fe4..0d9aa49 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3609,15 +3609,6 @@ cmTarget::GetFullNameImported(const std::string& config, bool implib) const } //---------------------------------------------------------------------------- -void cmTarget::GetFullNameComponents(std::string& prefix, std::string& base, - std::string& suffix, - const std::string& config, - bool implib) const -{ - this->GetFullNameInternal(config, implib, prefix, base, suffix); -} - -//---------------------------------------------------------------------------- std::string cmTarget::ImportedGetFullPath(const std::string& config, bool implib) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 1aef7b3..9962fdb 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -372,10 +372,6 @@ public: makefile. */ std::string GetFullName(const std::string& config="", bool implib = false) const; - void GetFullNameComponents(std::string& prefix, - std::string& base, std::string& suffix, - const std::string& config="", - bool implib = false) const; /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4bd1cd9a5c80bdf858777450ecdbdd71f80ad83e commit 4bd1cd9a5c80bdf858777450ecdbdd71f80ad83e Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:46 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 4 19:19:46 2015 +0200 cmGeneratorTarget: Move IsChrPathUsed from cmTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 5aaa266..fee921c 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -321,7 +321,11 @@ cmComputeLinkInformation this->RuntimeAlways = (this->Makefile-> GetSafeDefinition("CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH")); - this->RuntimeUseChrpath = this->Target->IsChrpathUsed(config); + + cmGeneratorTarget *gtgt = this->Target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(this->Target); + this->RuntimeUseChrpath = gtgt->IsChrpathUsed(config); // Get options needed to help find dependent libraries. std::string rlVar = "CMAKE_"; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 505d01f..6481390 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -746,7 +746,7 @@ cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const } // If chrpath is going to be used no relinking is needed. - if(this->Target->IsChrpathUsed(config)) + if(this->IsChrpathUsed(config)) { return false; } @@ -779,6 +779,73 @@ cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const || this->Target->HaveInstallTreeRPATH(); } +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsChrpathUsed(const std::string& config) const +{ + // Only certain target types have an rpath. + if(!(this->GetType() == cmTarget::SHARED_LIBRARY || + this->GetType() == cmTarget::MODULE_LIBRARY || + this->GetType() == cmTarget::EXECUTABLE)) + { + return false; + } + + // If the target will not be installed we do not need to change its + // rpath. + if(!this->Target->GetHaveInstallRule()) + { + return false; + } + + // Skip chrpath if skipping rpath altogether. + if(this->Makefile->IsOn("CMAKE_SKIP_RPATH")) + { + return false; + } + + // Skip chrpath if it does not need to be changed at install time. + if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) + { + return false; + } + + // Allow the user to disable builtin chrpath explicitly. + if(this->Makefile->IsOn("CMAKE_NO_BUILTIN_CHRPATH")) + { + return false; + } + + if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) + { + return true; + } + +#if defined(CMAKE_USE_ELF_PARSER) + // Enable if the rpath flag uses a separator and the target uses ELF + // binaries. + std::string ll = this->Target->GetLinkerLanguage(config); + if(!ll.empty()) + { + std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; + sepVar += ll; + sepVar += "_FLAG_SEP"; + const char* sep = this->Makefile->GetDefinition(sepVar); + if(sep && *sep) + { + // TODO: Add ELF check to ABI detection and get rid of + // CMAKE_EXECUTABLE_FORMAT. + if(const char* fmt = + this->Makefile->GetDefinition("CMAKE_EXECUTABLE_FORMAT")) + { + return strcmp(fmt, "ELF") == 0; + } + } + } +#endif + static_cast(config); + return false; +} + //---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetSOName(const std::string& config) const diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index c9a2508..9ecbbbe 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -215,6 +215,9 @@ public: */ bool NeedRelinkBeforeInstall(const std::string& config) const; + /** Return true if builtin chrpath will work for this target */ + bool IsChrpathUsed(const std::string& config) const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 7a7dcb4..24c1c49 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -656,11 +656,10 @@ cmInstallTargetGenerator std::string const& toDestDirPath) { // Skip the chrpath if the target does not need it. - if(this->ImportLibrary || !this->Target->Target->IsChrpathUsed(config)) + if(this->ImportLibrary || !this->Target->IsChrpathUsed(config)) { return; } - // Skip if on Apple if(this->Target->Target->GetMakefile() ->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) @@ -695,7 +694,7 @@ cmInstallTargetGenerator std::string const& toDestDirPath) { // Skip the chrpath if the target does not need it. - if(this->ImportLibrary || !this->Target->Target->IsChrpathUsed(config)) + if(this->ImportLibrary || !this->Target->IsChrpathUsed(config)) { return; } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 8dd62f9..1183fe4 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4314,73 +4314,6 @@ void cmTarget::GetLanguages(std::set& languages, } //---------------------------------------------------------------------------- -bool cmTarget::IsChrpathUsed(const std::string& config) const -{ - // Only certain target types have an rpath. - if(!(this->GetType() == cmTarget::SHARED_LIBRARY || - this->GetType() == cmTarget::MODULE_LIBRARY || - this->GetType() == cmTarget::EXECUTABLE)) - { - return false; - } - - // If the target will not be installed we do not need to change its - // rpath. - if(!this->GetHaveInstallRule()) - { - return false; - } - - // Skip chrpath if skipping rpath altogether. - if(this->Makefile->IsOn("CMAKE_SKIP_RPATH")) - { - return false; - } - - // Skip chrpath if it does not need to be changed at install time. - if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) - { - return false; - } - - // Allow the user to disable builtin chrpath explicitly. - if(this->Makefile->IsOn("CMAKE_NO_BUILTIN_CHRPATH")) - { - return false; - } - - if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) - { - return true; - } - -#if defined(CMAKE_USE_ELF_PARSER) - // Enable if the rpath flag uses a separator and the target uses ELF - // binaries. - std::string ll = this->GetLinkerLanguage(config); - if(!ll.empty()) - { - std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; - sepVar += ll; - sepVar += "_FLAG_SEP"; - const char* sep = this->Makefile->GetDefinition(sepVar); - if(sep && *sep) - { - // TODO: Add ELF check to ABI detection and get rid of - // CMAKE_EXECUTABLE_FORMAT. - if(const char* fmt = - this->Makefile->GetDefinition("CMAKE_EXECUTABLE_FORMAT")) - { - return strcmp(fmt, "ELF") == 0; - } - } - } -#endif - static_cast(config); - return false; -} - -//---------------------------------------------------------------------------- cmTarget::ImportInfo const* cmTarget::GetImportInfo(const std::string& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 11f715a..1aef7b3 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -398,9 +398,6 @@ public: bool HaveBuildTreeRPATH(const std::string& config) const; bool HaveInstallTreeRPATH() const; - /** Return true if builtin chrpath will work for this target */ - bool IsChrpathUsed(const std::string& config) const; - /** Return the install name directory for the target in the * build tree. For example: "\@rpath/", "\@loader_path/", * or "/full/path/to/library". */ http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=82c377564b26a346e6a75c71956d2633f7463ef2 commit 82c377564b26a346e6a75c71956d2633f7463ef2 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:46 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 4 19:19:46 2015 +0200 cmGeneratorTarget: Move NeedRelinkBeforeInstall from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index a29f4c9..505d01f 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -714,6 +714,73 @@ bool cmGeneratorTarget::HasSOName(const std::string& config) const } //---------------------------------------------------------------------------- +bool +cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const +{ + // Only executables and shared libraries can have an rpath and may + // need relinking. + if(this->GetType() != cmTarget::EXECUTABLE && + this->GetType() != cmTarget::SHARED_LIBRARY && + this->GetType() != cmTarget::MODULE_LIBRARY) + { + return false; + } + + // If there is no install location this target will not be installed + // and therefore does not need relinking. + if(!this->Target->GetHaveInstallRule()) + { + return false; + } + + // If skipping all rpaths completely then no relinking is needed. + if(this->Makefile->IsOn("CMAKE_SKIP_RPATH")) + { + return false; + } + + // If building with the install-tree rpath no relinking is needed. + if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) + { + return false; + } + + // If chrpath is going to be used no relinking is needed. + if(this->Target->IsChrpathUsed(config)) + { + return false; + } + + // Check for rpath support on this platform. + std::string ll = this->Target->GetLinkerLanguage(config); + if(!ll.empty()) + { + std::string flagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; + flagVar += ll; + flagVar += "_FLAG"; + if(!this->Makefile->IsSet(flagVar)) + { + // There is no rpath support on this platform so nothing needs + // relinking. + return false; + } + } + else + { + // No linker language is known. This error will be reported by + // other code. + return false; + } + + // If either a build or install tree rpath is set then the rpath + // will likely change between the build tree and install tree and + // this target must be relinked. + return this->Target->HaveBuildTreeRPATH(config) + || this->Target->HaveInstallTreeRPATH(); +} + + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetSOName(const std::string& config) const { if(this->Target->IsImported()) diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 441bbcf..c9a2508 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -210,6 +210,11 @@ public: std::string& realName, std::string& impName, std::string& pdbName, const std::string& config) const; + /** + * Compute whether this target must be relinked before installing. + */ + bool NeedRelinkBeforeInstall(const std::string& config) const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index edf2705..69747a4 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -482,7 +482,7 @@ cmGlobalUnixMakefileGenerator3 // Add this to the list of depends rules in this directory. if((!check_all || !gtarget->GetPropertyAsBool("EXCLUDE_FROM_ALL")) && (!check_relink || - gtarget->Target + gtarget ->NeedRelinkBeforeInstall(lg->GetConfigName()))) { std::string tname = lg->GetRelativeTargetDirectory(*gtarget->Target); @@ -691,7 +691,7 @@ cmGlobalUnixMakefileGenerator3 // Add a local name for the rule to relink the target before // installation. - if(gtarget->Target + if(gtarget ->NeedRelinkBeforeInstall(lg->GetConfigName())) { makeTargetName = lg->GetRelativeTargetDirectory(*gtarget->Target); @@ -876,7 +876,7 @@ cmGlobalUnixMakefileGenerator3 name, depends, commands, true); // Add rules to prepare the target for installation. - if(gtarget->Target + if(gtarget ->NeedRelinkBeforeInstall(lg->GetConfigName())) { localName = lg->GetRelativeTargetDirectory(*gtarget->Target); diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index deabecf..7a7dcb4 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -73,7 +73,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, { // Compute the build tree directory from which to copy the target. std::string fromDirConfig; - if(this->Target->Target->NeedRelinkBeforeInstall(config)) + if(this->Target->NeedRelinkBeforeInstall(config)) { fromDirConfig = this->Target->Target->GetMakefile()->GetCurrentBinaryDirectory(); diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 98bd0ab..ce370bc 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -486,8 +486,7 @@ void cmLocalUnixMakefileGenerator3 // Add a local name for the rule to relink the target before // installation. - if(t->second->Target - ->NeedRelinkBeforeInstall(this->ConfigName)) + if(t->second->NeedRelinkBeforeInstall(this->ConfigName)) { makeTargetName = this->GetRelativeTargetDirectory(*t->second->Target); makeTargetName += "/preinstall"; diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 31a78ad..2fd77c9 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -58,7 +58,7 @@ void cmMakefileExecutableTargetGenerator::WriteRuleFiles() // write the link rules this->WriteExecutableRule(false); - if(this->Target->NeedRelinkBeforeInstall(this->ConfigName)) + if(this->GeneratorTarget->NeedRelinkBeforeInstall(this->ConfigName)) { // Write rules to link an installable version of the target. this->WriteExecutableRule(true); diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 7d0dc49..a2fcbad 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -69,7 +69,7 @@ void cmMakefileLibraryTargetGenerator::WriteRuleFiles() break; case cmTarget::SHARED_LIBRARY: this->WriteSharedLibraryRules(false); - if(this->Target->NeedRelinkBeforeInstall(this->ConfigName)) + if(this->GeneratorTarget->NeedRelinkBeforeInstall(this->ConfigName)) { // Write rules to link an installable version of the target. this->WriteSharedLibraryRules(true); @@ -77,7 +77,7 @@ void cmMakefileLibraryTargetGenerator::WriteRuleFiles() break; case cmTarget::MODULE_LIBRARY: this->WriteModuleLibraryRules(false); - if(this->Target->NeedRelinkBeforeInstall(this->ConfigName)) + if(this->GeneratorTarget->NeedRelinkBeforeInstall(this->ConfigName)) { // Write rules to link an installable version of the target. this->WriteModuleLibraryRules(true); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1e7fb5a..8dd62f9 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3855,70 +3855,6 @@ bool cmTarget::HaveInstallTreeRPATH() const } //---------------------------------------------------------------------------- -bool cmTarget::NeedRelinkBeforeInstall(const std::string& config) const -{ - // Only executables and shared libraries can have an rpath and may - // need relinking. - if(this->TargetTypeValue != cmTarget::EXECUTABLE && - this->TargetTypeValue != cmTarget::SHARED_LIBRARY && - this->TargetTypeValue != cmTarget::MODULE_LIBRARY) - { - return false; - } - - // If there is no install location this target will not be installed - // and therefore does not need relinking. - if(!this->GetHaveInstallRule()) - { - return false; - } - - // If skipping all rpaths completely then no relinking is needed. - if(this->Makefile->IsOn("CMAKE_SKIP_RPATH")) - { - return false; - } - - // If building with the install-tree rpath no relinking is needed. - if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) - { - return false; - } - - // If chrpath is going to be used no relinking is needed. - if(this->IsChrpathUsed(config)) - { - return false; - } - - // Check for rpath support on this platform. - std::string ll = this->GetLinkerLanguage(config); - if(!ll.empty()) - { - std::string flagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; - flagVar += ll; - flagVar += "_FLAG"; - if(!this->Makefile->IsSet(flagVar)) - { - // There is no rpath support on this platform so nothing needs - // relinking. - return false; - } - } - else - { - // No linker language is known. This error will be reported by - // other code. - return false; - } - - // If either a build or install tree rpath is set then the rpath - // will likely change between the build tree and install tree and - // this target must be relinked. - return this->HaveBuildTreeRPATH(config) || this->HaveInstallTreeRPATH(); -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetInstallNameDirForBuildTree( const std::string& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 8c23372..11f715a 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -395,11 +395,6 @@ public: bool GetImplibGNUtoMS(std::string const& gnuName, std::string& out, const char* newExt = 0) const; - /** - * Compute whether this target must be relinked before installing. - */ - bool NeedRelinkBeforeInstall(const std::string& config) const; - bool HaveBuildTreeRPATH(const std::string& config) const; bool HaveInstallTreeRPATH() const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a8b2a0e500424abed91cb06a58baef8e5c26dd77 commit a8b2a0e500424abed91cb06a58baef8e5c26dd77 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:46 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 4 19:19:46 2015 +0200 cmGeneratorTarget: Move GetPDBName from cmTarget. diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index a20579b..49fc96b 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1625,7 +1625,7 @@ struct TargetFilesystemArtifactResultCreator std::string result = target->Target->GetPDBDirectory(context->Config); result += "/"; - result += target->Target->GetPDBName(context->Config); + result += target->GetPDBName(context->Config); return result; } }; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index a125e47..a29f4c9 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1525,7 +1525,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, } // The program database file name. - pdbName = this->Target->GetPDBName(config); + pdbName = this->GetPDBName(config); } //---------------------------------------------------------------------------- @@ -1587,7 +1587,39 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, impName = this->Target->GetFullNameInternal(config, true); // The program database file name. - pdbName = this->Target->GetPDBName(config); + pdbName = this->GetPDBName(config); +} + +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetPDBName(const std::string& config) const +{ + std::string prefix; + std::string base; + std::string suffix; + this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + + std::vector props; + std::string configUpper = + cmSystemTools::UpperCase(config); + if(!configUpper.empty()) + { + // PDB_NAME_ + props.push_back("PDB_NAME_" + configUpper); + } + + // PDB_NAME + props.push_back("PDB_NAME"); + + for(std::vector::const_iterator i = props.begin(); + i != props.end(); ++i) + { + if(const char* outName = this->GetProperty(*i)) + { + base = outName; + break; + } + } + return prefix+base+".pdb"; } bool cmStrictTargetComparison::operator()(cmTarget const* t1, diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 9cdfd00..441bbcf 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -160,6 +160,9 @@ public: std::vector const* GetSourceDepends(cmSourceFile const* sf) const; + /** Get the name of the pdb file for the target. */ + std::string GetPDBName(const std::string& config="") const; + /** Whether this library has soname enabled and platform supports it. */ bool HasSOName(const std::string& config) const; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index f9125fc..b94e151 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -548,7 +548,7 @@ cmMakefileTargetGenerator this->GeneratorTarget->GetFullPath(this->ConfigName, false, true); targetFullPathPDB = this->Target->GetPDBDirectory(this->ConfigName); targetFullPathPDB += "/"; - targetFullPathPDB += this->Target->GetPDBName(this->ConfigName); + targetFullPathPDB += this->GeneratorTarget->GetPDBName(this->ConfigName); } if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY) { diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index e61ba6f..16e1f48 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -273,7 +273,7 @@ bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(cmNinjaVars& vars) const { pdbPath = this->Target->GetPDBDirectory(this->GetConfigName()); pdbPath += "/"; - pdbPath += this->Target->GetPDBName(this->GetConfigName()); + pdbPath += this->GeneratorTarget->GetPDBName(this->GetConfigName()); } if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 188ad0f..1e7fb5a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3461,37 +3461,6 @@ const char* cmTarget::GetPrefixVariableInternal(bool implib) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetPDBName(const std::string& config) const -{ - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); - - std::vector props; - std::string configUpper = cmSystemTools::UpperCase(config); - if(!configUpper.empty()) - { - // PDB_NAME_ - props.push_back("PDB_NAME_" + configUpper); - } - - // PDB_NAME - props.push_back("PDB_NAME"); - - for(std::vector::const_iterator i = props.begin(); - i != props.end(); ++i) - { - if(const char* outName = this->GetProperty(*i)) - { - base = outName; - break; - } - } - return prefix+base+".pdb"; -} - -//---------------------------------------------------------------------------- bool cmTarget::HasMacOSXRpathInstallNameDir(const std::string& config) const { bool install_name_is_rpath = false; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 162033c..8c23372 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -377,9 +377,6 @@ public: const std::string& config="", bool implib = false) const; - /** Get the name of the pdb file for the target. */ - std::string GetPDBName(const std::string& config) const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=381788822634315ca6f5be46cebdf9e2a80aeba3 commit 381788822634315ca6f5be46cebdf9e2a80aeba3 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:45 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 4 19:19:45 2015 +0200 cmGeneratorTarget: Move GetCompilePDBPath from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 2b3ebee..a125e47 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -657,6 +657,51 @@ void cmGeneratorTarget::GetSourceFiles(std::vector &files, } //---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetCompilePDBName(const std::string& config) const +{ + std::string prefix; + std::string base; + std::string suffix; + this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + + // Check for a per-configuration output directory target property. + std::string configUpper = cmSystemTools::UpperCase(config); + std::string configProp = "COMPILE_PDB_NAME_"; + configProp += configUpper; + const char* config_name = this->Target->GetProperty(configProp); + if(config_name && *config_name) + { + return prefix + config_name + ".pdb"; + } + + const char* name = this->Target->GetProperty("COMPILE_PDB_NAME"); + if(name && *name) + { + return prefix + name + ".pdb"; + } + + return ""; +} + +//---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetCompilePDBPath(const std::string& config) const +{ + std::string dir = this->Target->GetCompilePDBDirectory(config); + std::string name = this->GetCompilePDBName(config); + if(dir.empty() && !name.empty()) + { + dir = this->Target->GetPDBDirectory(config); + } + if(!dir.empty()) + { + dir += "/"; + } + return dir + name; +} + +//---------------------------------------------------------------------------- bool cmGeneratorTarget::HasSOName(const std::string& config) const { // soname is supported only for shared libraries and modules, diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 9254265..9cdfd00 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -163,6 +163,12 @@ public: /** Whether this library has soname enabled and platform supports it. */ bool HasSOName(const std::string& config) const; + /** Get the name of the compiler pdb file for the target. */ + std::string GetCompilePDBName(const std::string& config="") const; + + /** Get the path for the MSVC /Fd option for this target. */ + std::string GetCompilePDBPath(const std::string& config="") const; + /** * Flags for a given source file as used in this target. Typically assigned * via SET_TARGET_PROPERTIES when the property is a list of source files. diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index dd4cd33..799bac6 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -881,7 +881,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, if(target.GetType() <= cmTarget::OBJECT_LIBRARY) { // Specify the compiler program database file if configured. - std::string pdb = target.GetCompilePDBPath(configName); + std::string pdb = gt->GetCompilePDBPath(configName); if(!pdb.empty()) { fout << "\t\t\t\tProgramDataBaseFileName=\"" diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index ac8cd29..f9125fc 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -553,7 +553,7 @@ cmMakefileTargetGenerator if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY) { targetFullPathCompilePDB = - this->Target->GetCompilePDBPath(this->ConfigName); + this->GeneratorTarget->GetCompilePDBPath(this->ConfigName); if(targetFullPathCompilePDB.empty()) { targetFullPathCompilePDB = this->Target->GetSupportDirectory() + "/"; diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index cf80424..e61ba6f 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -277,7 +277,8 @@ bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(cmNinjaVars& vars) const } if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY) { - compilePdbPath = this->Target->GetCompilePDBPath(this->GetConfigName()); + compilePdbPath = + this->GeneratorTarget->GetCompilePDBPath(this->GetConfigName()); if(compilePdbPath.empty()) { compilePdbPath = this->Target->GetSupportDirectory() + "/"; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e1b3e94..188ad0f 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3492,49 +3492,6 @@ std::string cmTarget::GetPDBName(const std::string& config) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetCompilePDBName(const std::string& config) const -{ - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); - - // Check for a per-configuration output directory target property. - std::string configUpper = cmSystemTools::UpperCase(config); - std::string configProp = "COMPILE_PDB_NAME_"; - configProp += configUpper; - const char* config_name = this->GetProperty(configProp); - if(config_name && *config_name) - { - return prefix + config_name + ".pdb"; - } - - const char* name = this->GetProperty("COMPILE_PDB_NAME"); - if(name && *name) - { - return prefix + name + ".pdb"; - } - - return ""; -} - -//---------------------------------------------------------------------------- -std::string cmTarget::GetCompilePDBPath(const std::string& config) const -{ - std::string dir = this->GetCompilePDBDirectory(config); - std::string name = this->GetCompilePDBName(config); - if(dir.empty() && !name.empty()) - { - dir = this->GetPDBDirectory(config); - } - if(!dir.empty()) - { - dir += "/"; - } - return dir + name; -} - -//---------------------------------------------------------------------------- bool cmTarget::HasMacOSXRpathInstallNameDir(const std::string& config) const { bool install_name_is_rpath = false; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e89a212..162033c 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -380,12 +380,6 @@ public: /** Get the name of the pdb file for the target. */ std::string GetPDBName(const std::string& config) const; - /** Get the name of the compiler pdb file for the target. */ - std::string GetCompilePDBName(const std::string& config="") const; - - /** Get the path for the MSVC /Fd option for this target. */ - std::string GetCompilePDBPath(const std::string& config="") const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 83775a5..16edf3c 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2026,7 +2026,8 @@ void cmVisualStudio10TargetGenerator::WriteClOptions( } // Specify the compiler program database file if configured. - std::string pdb = this->Target->GetCompilePDBPath(configName.c_str()); + std::string pdb = + this->GeneratorTarget->GetCompilePDBPath(configName.c_str()); if(!pdb.empty()) { this->ConvertToWindowsSlash(pdb); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6d031d2891ab567ae6d868bb5959b877bbf225ab commit 6d031d2891ab567ae6d868bb5959b877bbf225ab Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:45 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 4 19:19:45 2015 +0200 cmGeneratorTarget: Move HasSOName from cmTarget. diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 8a2cf4b..e3652c5 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -889,7 +889,7 @@ cmExportFileGenerator { std::string prop; std::string value; - if(target->Target->HasSOName(config)) + if(target->HasSOName(config)) { if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 31c2df1..2b3ebee 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -657,6 +657,18 @@ void cmGeneratorTarget::GetSourceFiles(std::vector &files, } //---------------------------------------------------------------------------- +bool cmGeneratorTarget::HasSOName(const std::string& config) const +{ + // soname is supported only for shared libraries and modules, + // and then only when the platform supports an soname flag. + return ((this->GetType() == cmTarget::SHARED_LIBRARY || + this->GetType() == cmTarget::MODULE_LIBRARY) && + !this->GetPropertyAsBool("NO_SONAME") && + this->Makefile->GetSONameFlag( + this->Target->GetLinkerLanguage(config))); +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetSOName(const std::string& config) const { if(this->Target->IsImported()) @@ -1407,7 +1419,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, // Check for library version properties. const char* version = this->GetProperty("VERSION"); const char* soversion = this->GetProperty("SOVERSION"); - if(!this->Target->HasSOName(config) || + if(!this->HasSOName(config) || this->Target->IsFrameworkOnApple()) { // Versioning is supported only for shared libraries and modules, diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 7fb7c32..9254265 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -160,6 +160,9 @@ public: std::vector const* GetSourceDepends(cmSourceFile const* sf) const; + /** Whether this library has soname enabled and platform supports it. */ + bool HasSOName(const std::string& config) const; + /** * Flags for a given source file as used in this target. Typically assigned * via SET_TARGET_PROPERTIES when the property is a list of source files. diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index b44848c..d7ae36d 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1944,7 +1944,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, const char* version = target.GetProperty("VERSION"); const char* soversion = target.GetProperty("SOVERSION"); - if(!target.HasSOName(configName) || target.IsFrameworkOnApple()) + if(!gtgt->HasSOName(configName) || target.IsFrameworkOnApple()) { version = 0; soversion = 0; diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 26273ee..7d0dc49 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -653,7 +653,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules vars.Target = target.c_str(); vars.LinkLibraries = linkLibs.c_str(); vars.ObjectsQuoted = buildObjs.c_str(); - if (this->Target->HasSOName(this->ConfigName)) + if (this->GeneratorTarget->HasSOName(this->ConfigName)) { vars.SONameFlag = this->Makefile->GetSONameFlag(linkLanguage); vars.TargetSOName= targetNameSO.c_str(); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 5d86091..2586b31 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -531,7 +531,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() vars["LANGUAGE_COMPILE_FLAGS"] = t; } - if (target.HasSOName(cfgName)) + if (this->GetGeneratorTarget()->HasSOName(cfgName)) { vars["SONAME_FLAG"] = mf->GetSONameFlag(this->TargetLinkLanguage); vars["SONAME"] = this->TargetNameSO; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 60fe7e4..e1b3e94 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3535,17 +3535,6 @@ std::string cmTarget::GetCompilePDBPath(const std::string& config) const } //---------------------------------------------------------------------------- -bool cmTarget::HasSOName(const std::string& config) const -{ - // soname is supported only for shared libraries and modules, - // and then only when the platform supports an soname flag. - return ((this->GetType() == cmTarget::SHARED_LIBRARY || - this->GetType() == cmTarget::MODULE_LIBRARY) && - !this->GetPropertyAsBool("NO_SONAME") && - this->Makefile->GetSONameFlag(this->GetLinkerLanguage(config))); -} - -//---------------------------------------------------------------------------- bool cmTarget::HasMacOSXRpathInstallNameDir(const std::string& config) const { bool install_name_is_rpath = false; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 15dfb4a..e89a212 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -386,9 +386,6 @@ public: /** Get the path for the MSVC /Fd option for this target. */ std::string GetCompilePDBPath(const std::string& config="") const; - /** Whether this library has soname enabled and platform supports it. */ - bool HasSOName(const std::string& config) const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=77d8a8b8ac2177e4a193fa602a76483ce99319d2 commit 77d8a8b8ac2177e4a193fa602a76483ce99319d2 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:45 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 4 19:19:45 2015 +0200 cmGeneratorTarget: Move GetLibraryNames from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 6a693f1..31c2df1 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -693,8 +693,8 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const std::string realName; std::string impName; std::string pdbName; - this->Target->GetLibraryNames(name, soName, realName, - impName, pdbName, config); + this->GetLibraryNames(name, soName, realName, + impName, pdbName, config); return soName; } } @@ -1254,7 +1254,7 @@ void cmGeneratorTarget::GenerateTargetManifest( this->GetType() == cmTarget::SHARED_LIBRARY || this->GetType() == cmTarget::MODULE_LIBRARY) { - this->Target->GetLibraryNames(name, soName, realName, impName, pdbName, + this->GetLibraryNames(name, soName, realName, impName, pdbName, config); } else @@ -1378,13 +1378,100 @@ cmGeneratorTarget::NormalGetRealName(const std::string& config) const std::string realName; std::string impName; std::string pdbName; - this->Target->GetLibraryNames(name, soName, realName, - impName, pdbName, config); + this->GetLibraryNames(name, soName, realName, + impName, pdbName, config); return realName; } } //---------------------------------------------------------------------------- +void cmGeneratorTarget::GetLibraryNames(std::string& name, + std::string& soName, + std::string& realName, + std::string& impName, + std::string& pdbName, + const std::string& config) const +{ + // This should not be called for imported targets. + // TODO: Split cmTarget into a class hierarchy to get compile-time + // enforcement of the limited imported target API. + if(this->Target->IsImported()) + { + std::string msg = "GetLibraryNames called on imported target: "; + msg += this->GetName(); + this->LocalGenerator->IssueMessage(cmake::INTERNAL_ERROR, + msg); + return; + } + + // Check for library version properties. + const char* version = this->GetProperty("VERSION"); + const char* soversion = this->GetProperty("SOVERSION"); + if(!this->Target->HasSOName(config) || + this->Target->IsFrameworkOnApple()) + { + // Versioning is supported only for shared libraries and modules, + // and then only when the platform supports an soname flag. + version = 0; + soversion = 0; + } + if(version && !soversion) + { + // The soversion must be set if the library version is set. Use + // the library version as the soversion. + soversion = version; + } + if(!version && soversion) + { + // Use the soversion as the library version. + version = soversion; + } + + // Get the components of the library name. + std::string prefix; + std::string base; + std::string suffix; + this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + + // The library name. + name = prefix+base+suffix; + + if(this->Target->IsFrameworkOnApple()) + { + realName = prefix; + realName += "Versions/"; + realName += this->Target->GetFrameworkVersion(); + realName += "/"; + realName += base; + soName = realName; + } + else + { + // The library's soname. + this->Target->ComputeVersionedName(soName, prefix, base, suffix, + name, soversion); + + // The library's real name on disk. + this->Target->ComputeVersionedName(realName, prefix, base, suffix, + name, version); + } + + // The import library name. + if(this->GetType() == cmTarget::SHARED_LIBRARY || + this->GetType() == cmTarget::MODULE_LIBRARY) + { + impName = this->Target->GetFullNameInternal(config, true); + } + else + { + impName = ""; + } + + // The program database file name. + pdbName = this->Target->GetPDBName(config); +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetExecutableNames(std::string& name, std::string& realName, std::string& impName, @@ -1446,7 +1533,6 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, pdbName = this->Target->GetPDBName(config); } - bool cmStrictTargetComparison::operator()(cmTarget const* t1, cmTarget const* t2) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 49aa65b..7fb7c32 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -191,6 +191,13 @@ public: std::string& impName, std::string& pdbName, const std::string& config) const; + /** Get the names of the library needed to generate a build rule + that takes into account shared library version numbers. This + should be called only on a library target. */ + void GetLibraryNames(std::string& name, std::string& soName, + std::string& realName, std::string& impName, + std::string& pdbName, const std::string& config) const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index c872859..deabecf 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -185,7 +185,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - this->Target->Target->GetLibraryNames(targetName, targetNameSO, + this->Target->GetLibraryNames(targetName, targetNameSO, targetNameReal, targetNameImport, targetNamePDB, config); @@ -411,7 +411,7 @@ cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target, std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - target->GetLibraryNames(targetName, targetNameSO, targetNameReal, + gtgt->GetLibraryNames(targetName, targetNameSO, targetNameReal, targetNameImport, targetNamePDB, config); if(nameType == NameImplib) { diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index daac331..dd4cd33 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1147,7 +1147,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, std::string targetNameFull; std::string targetNameImport; std::string targetNamePDB; - target.GetLibraryNames(targetName, targetNameSO, targetNameFull, + gt->GetLibraryNames(targetName, targetNameSO, targetNameFull, targetNameImport, targetNamePDB, configName); // Compute the link library and directory information. diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 696dcc4..26273ee 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -28,7 +28,7 @@ cmMakefileLibraryTargetGenerator this->CustomCommandDriver = OnDepends; if (this->Target->GetType() != cmTarget::INTERFACE_LIBRARY) { - this->Target->GetLibraryNames( + this->GeneratorTarget->GetLibraryNames( this->TargetNameOut, this->TargetNameSO, this->TargetNameReal, this->TargetNameImport, this->TargetNamePDB, this->ConfigName); } @@ -266,7 +266,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - this->Target->GetLibraryNames( + this->GeneratorTarget->GetLibraryNames( targetName, targetNameSO, targetNameReal, targetNameImport, targetNamePDB, this->ConfigName); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 737510f..5d86091 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -49,7 +49,7 @@ cmNinjaNormalTargetGenerator(cmGeneratorTarget* target) this->TargetNamePDB, GetLocalGenerator()->GetConfigName()); else - target->Target->GetLibraryNames(this->TargetNameOut, + this->GetGeneratorTarget()->GetLibraryNames(this->TargetNameOut, this->TargetNameSO, this->TargetNameReal, this->TargetNameImport, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 22b76e9..60fe7e4 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3862,95 +3862,6 @@ void cmTarget::GetFullNameInternal(const std::string& config, } //---------------------------------------------------------------------------- -void cmTarget::GetLibraryNames(std::string& name, - std::string& soName, - std::string& realName, - std::string& impName, - std::string& pdbName, - const std::string& config) const -{ - // This should not be called for imported targets. - // TODO: Split cmTarget into a class hierarchy to get compile-time - // enforcement of the limited imported target API. - if(this->IsImported()) - { - std::string msg = "GetLibraryNames called on imported target: "; - msg += this->GetName(); - this->Makefile->IssueMessage(cmake::INTERNAL_ERROR, - msg); - return; - } - - assert(this->GetType() != INTERFACE_LIBRARY); - - // Check for library version properties. - const char* version = this->GetProperty("VERSION"); - const char* soversion = this->GetProperty("SOVERSION"); - if(!this->HasSOName(config) || - this->Makefile->IsOn("CMAKE_PLATFORM_NO_VERSIONED_SONAME") || - this->IsFrameworkOnApple()) - { - // Versioning is supported only for shared libraries and modules, - // and then only when the platform supports an soname flag. - version = 0; - soversion = 0; - } - if(version && !soversion) - { - // The soversion must be set if the library version is set. Use - // the library version as the soversion. - soversion = version; - } - if(!version && soversion) - { - // Use the soversion as the library version. - version = soversion; - } - - // Get the components of the library name. - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); - - // The library name. - name = prefix+base+suffix; - - if(this->IsFrameworkOnApple()) - { - realName = prefix; - realName += "Versions/"; - realName += this->GetFrameworkVersion(); - realName += "/"; - realName += base; - soName = realName; - } - else - { - // The library's soname. - this->ComputeVersionedName(soName, prefix, base, suffix, - name, soversion); - // The library's real name on disk. - this->ComputeVersionedName(realName, prefix, base, suffix, - name, version); - } - - // The import library name. - if(this->GetType() == cmTarget::SHARED_LIBRARY || - this->GetType() == cmTarget::MODULE_LIBRARY) - { - impName = this->GetFullNameInternal(config, true); - } - else - { - impName = ""; - } - - // The program database file name. - pdbName = this->GetPDBName(config); -} - -//---------------------------------------------------------------------------- void cmTarget::ComputeVersionedName(std::string& vName, std::string const& prefix, std::string const& base, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 714647c..15dfb4a 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -399,13 +399,6 @@ public: no soname at all. */ bool IsImportedSharedLibWithoutSOName(const std::string& config) const; - /** Get the names of the library needed to generate a build rule - that takes into account shared library version numbers. This - should be called only on a library target. */ - void GetLibraryNames(std::string& name, std::string& soName, - std::string& realName, std::string& impName, - std::string& pdbName, const std::string& config) const; - /** Does this target have a GNU implib to convert to MS format? */ bool HasImplibGNUtoMS() const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 1bb21ff..83775a5 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2477,7 +2477,8 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) } else { - this->Target->GetLibraryNames(targetName, targetNameSO, targetNameFull, + this->GeneratorTarget->GetLibraryNames(targetName, targetNameSO, + targetNameFull, targetNameImport, targetNamePDB, config.c_str()); } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3f9edf779b2363f10ac6acaa915a55ccb872b347 commit 3f9edf779b2363f10ac6acaa915a55ccb872b347 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:44 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 4 19:19:44 2015 +0200 cmGeneratorTarget: Move GetExecutableNames from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index f9f23a6..6a693f1 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1248,8 +1248,7 @@ void cmGeneratorTarget::GenerateTargetManifest( std::string pdbName; if(this->GetType() == cmTarget::EXECUTABLE) { - this->Target->GetExecutableNames(name, realName, impName, pdbName, - config); + this->GetExecutableNames(name, realName, impName, pdbName, config); } else if(this->GetType() == cmTarget::STATIC_LIBRARY || this->GetType() == cmTarget::SHARED_LIBRARY || @@ -1368,7 +1367,7 @@ cmGeneratorTarget::NormalGetRealName(const std::string& config) const std::string realName; std::string impName; std::string pdbName; - this->Target->GetExecutableNames(name, realName, impName, pdbName, config); + this->GetExecutableNames(name, realName, impName, pdbName, config); return realName; } else @@ -1385,6 +1384,69 @@ cmGeneratorTarget::NormalGetRealName(const std::string& config) const } } +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GetExecutableNames(std::string& name, + std::string& realName, + std::string& impName, + std::string& pdbName, + const std::string& config) const +{ + // This should not be called for imported targets. + // TODO: Split cmTarget into a class hierarchy to get compile-time + // enforcement of the limited imported target API. + if(this->Target->IsImported()) + { + std::string msg = + "GetExecutableNames called on imported target: "; + msg += this->GetName(); + this->LocalGenerator->IssueMessage(cmake::INTERNAL_ERROR, msg); + } + + // This versioning is supported only for executables and then only + // when the platform supports symbolic links. +#if defined(_WIN32) && !defined(__CYGWIN__) + const char* version = 0; +#else + // Check for executable version properties. + const char* version = this->GetProperty("VERSION"); + if(this->GetType() != cmTarget::EXECUTABLE || this->Makefile->IsOn("XCODE")) + { + version = 0; + } +#endif + + // Get the components of the executable name. + std::string prefix; + std::string base; + std::string suffix; + this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + + // The executable name. + name = prefix+base+suffix; + + // The executable's real name on disk. +#if defined(__CYGWIN__) + realName = prefix+base; +#else + realName = name; +#endif + if(version) + { + realName += "-"; + realName += version; + } +#if defined(__CYGWIN__) + realName += suffix; +#endif + + // The import library name. + impName = this->Target->GetFullNameInternal(config, true); + + // The program database file name. + pdbName = this->Target->GetPDBName(config); +} + + bool cmStrictTargetComparison::operator()(cmTarget const* t1, cmTarget const* t2) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 1303ee4..49aa65b 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -184,6 +184,12 @@ public: void GetAutoUicOptions(std::vector &result, const std::string& config) const; + /** Get the names of the executable needed to generate a build rule + that takes into account executable version numbers. This should + be called only on an executable target. */ + void GetExecutableNames(std::string& name, std::string& realName, + std::string& impName, std::string& pdbName, + const std::string& config) const; struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index c64f9a3..c872859 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -125,7 +125,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - this->Target->Target->GetExecutableNames(targetName, targetNameReal, + this->Target->GetExecutableNames(targetName, targetNameReal, targetNameImport, targetNamePDB, config); if(this->ImportLibrary) @@ -372,13 +372,16 @@ cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target, { std::string fname; // Compute the name of the library. + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); if(target->GetType() == cmTarget::EXECUTABLE) { std::string targetName; std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - target->GetExecutableNames(targetName, targetNameReal, + gtgt->GetExecutableNames(targetName, targetNameReal, targetNameImport, targetNamePDB, config); if(nameType == NameImplib) diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 37e08dd..daac331 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1244,7 +1244,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, std::string targetNameFull; std::string targetNameImport; std::string targetNamePDB; - target.GetExecutableNames(targetName, targetNameFull, + gt->GetExecutableNames(targetName, targetNameFull, targetNameImport, targetNamePDB, configName); // Compute the link library and directory information. diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 416063f..31a78ad 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -25,7 +25,7 @@ cmMakefileExecutableTargetGenerator cmMakefileTargetGenerator(target) { this->CustomCommandDriver = OnDepends; - this->Target->GetExecutableNames( + this->GeneratorTarget->GetExecutableNames( this->TargetNameOut, this->TargetNameReal, this->TargetNameImport, this->TargetNamePDB, this->ConfigName); @@ -94,7 +94,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - this->Target->GetExecutableNames + this->GeneratorTarget->GetExecutableNames (targetName, targetNameReal, targetNameImport, targetNamePDB, this->ConfigName); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index c9fa7c0..737510f 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -43,7 +43,7 @@ cmNinjaNormalTargetGenerator(cmGeneratorTarget* target) this->TargetLinkLanguage = target->Target ->GetLinkerLanguage(this->GetConfigName()); if (target->GetType() == cmTarget::EXECUTABLE) - target->Target->GetExecutableNames(this->TargetNameOut, + this->GetGeneratorTarget()->GetExecutableNames(this->TargetNameOut, this->TargetNameReal, this->TargetNameImport, this->TargetNamePDB, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index ded5363..22b76e9 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3968,68 +3968,6 @@ void cmTarget::ComputeVersionedName(std::string& vName, } //---------------------------------------------------------------------------- -void cmTarget::GetExecutableNames(std::string& name, - std::string& realName, - std::string& impName, - std::string& pdbName, - const std::string& config) const -{ - // This should not be called for imported targets. - // TODO: Split cmTarget into a class hierarchy to get compile-time - // enforcement of the limited imported target API. - if(this->IsImported()) - { - std::string msg = - "GetExecutableNames called on imported target: "; - msg += this->GetName(); - this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg); - } - - // This versioning is supported only for executables and then only - // when the platform supports symbolic links. -#if defined(_WIN32) && !defined(__CYGWIN__) - const char* version = 0; -#else - // Check for executable version properties. - const char* version = this->GetProperty("VERSION"); - if(this->GetType() != cmTarget::EXECUTABLE || this->Makefile->IsOn("XCODE")) - { - version = 0; - } -#endif - - // Get the components of the executable name. - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); - - // The executable name. - name = prefix+base+suffix; - - // The executable's real name on disk. -#if defined(__CYGWIN__) - realName = prefix+base; -#else - realName = name; -#endif - if(version) - { - realName += "-"; - realName += version; - } -#if defined(__CYGWIN__) - realName += suffix; -#endif - - // The import library name. - impName = this->GetFullNameInternal(config, true); - - // The program database file name. - pdbName = this->GetPDBName(config); -} - -//---------------------------------------------------------------------------- bool cmTarget::HasImplibGNUtoMS() const { return this->HasImportLibrary() && this->GetPropertyAsBool("GNUtoMS"); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 925e7c6..714647c 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -406,14 +406,6 @@ public: std::string& realName, std::string& impName, std::string& pdbName, const std::string& config) const; - /** Get the names of the executable needed to generate a build rule - that takes into account executable version numbers. This should - be called only on an executable target. */ - void GetExecutableNames(std::string& name, std::string& realName, - std::string& impName, - std::string& pdbName, - const std::string& config) const; - /** Does this target have a GNU implib to convert to MS format? */ bool HasImplibGNUtoMS() const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index f3f291a..1bb21ff 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2471,7 +2471,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) std::string targetNamePDB; if(this->Target->GetType() == cmTarget::EXECUTABLE) { - this->Target->GetExecutableNames(targetName, targetNameFull, + this->GeneratorTarget->GetExecutableNames(targetName, targetNameFull, targetNameImport, targetNamePDB, config.c_str()); } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ec2f478af178d35606a3b4024879df1121e5bf20 commit ec2f478af178d35606a3b4024879df1121e5bf20 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:44 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 4 19:19:44 2015 +0200 cmGeneratorTarget: Move GetLinkImplementationClosure diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 521a5b7..f9f23a6 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -618,7 +618,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const std::string& dir, } std::vector const& deps = - this->Target->GetLinkImplementationClosure(config); + this->GetLinkImplementationClosure(config); for(std::vector::const_iterator li = deps.begin(), le = deps.end(); li != le; ++li) { @@ -775,6 +775,54 @@ void cmGeneratorTarget::GetAutoUicOptions(std::vector &result, } //---------------------------------------------------------------------------- +void processILibs(const std::string& config, + cmTarget const* headTarget, + cmLinkItem const& item, + std::vector& tgts, + std::set& emitted) +{ + if (item.Target && emitted.insert(item.Target).second) + { + tgts.push_back(item.Target); + if(cmTarget::LinkInterfaceLibraries const* iface = + item.Target->GetLinkInterfaceLibraries(config, headTarget, true)) + { + for(std::vector::const_iterator + it = iface->Libraries.begin(); + it != iface->Libraries.end(); ++it) + { + processILibs(config, headTarget, *it, tgts, emitted); + } + } + } +} + +//---------------------------------------------------------------------------- +const std::vector& +cmGeneratorTarget::GetLinkImplementationClosure( + const std::string& config) const +{ + LinkImplClosure& tgts = + this->LinkImplClosureMap[config]; + if(!tgts.Done) + { + tgts.Done = true; + std::set emitted; + + cmTarget::LinkImplementationLibraries const* impl + = this->Target->GetLinkImplementationLibraries(config); + + for(std::vector::const_iterator + it = impl->Libraries.begin(); + it != impl->Libraries.end(); ++it) + { + processILibs(config, this->Target, *it, tgts , emitted); + } + } + return tgts; +} + +//---------------------------------------------------------------------------- class cmTargetTraceDependencies { public: @@ -1455,7 +1503,7 @@ cmGeneratorTarget::GetCompatibleInterfaces(std::string const& config) const compat.PropsBool.insert("POSITION_INDEPENDENT_CODE"); compat.PropsString.insert("AUTOUIC_OPTIONS"); std::vector const& deps = - this->Target->GetLinkImplementationClosure(config); + this->GetLinkImplementationClosure(config); for(std::vector::const_iterator li = deps.begin(); li != deps.end(); ++li) { @@ -1954,7 +2002,7 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt, || (!impliedByUse && !explicitlySet)); std::vector const& deps = - tgt->Target->GetLinkImplementationClosure(config); + tgt->GetLinkImplementationClosure(config); if(deps.empty()) { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 8e68d39..1303ee4 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -245,6 +245,18 @@ private: cmGeneratorTarget(cmGeneratorTarget const&); void operator=(cmGeneratorTarget const&); + + struct LinkImplClosure: public std::vector + { + LinkImplClosure(): Done(false) {} + bool Done; + }; + mutable std::map LinkImplClosureMap; + +public: + std::vector const& + GetLinkImplementationClosure(const std::string& config) const; + }; struct cmStrictTargetComparison { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 968bd9d..ded5363 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -163,13 +163,6 @@ public: typedef std::map LinkClosureMapType; LinkClosureMapType LinkClosureMap; - struct LinkImplClosure: public std::vector - { - LinkImplClosure(): Done(false) {} - bool Done; - }; - std::map LinkImplClosureMap; - typedef std::map > SourceFilesMapType; SourceFilesMapType SourceFilesMap; @@ -5175,53 +5168,6 @@ cmTarget::GetImportLinkInterface(const std::string& config, } //---------------------------------------------------------------------------- -void processILibs(const std::string& config, - cmTarget const* headTarget, - cmLinkItem const& item, - std::vector& tgts, - std::set& emitted) -{ - if (item.Target && emitted.insert(item.Target).second) - { - tgts.push_back(item.Target); - if(cmTarget::LinkInterfaceLibraries const* iface = - item.Target->GetLinkInterfaceLibraries(config, headTarget, true)) - { - for(std::vector::const_iterator - it = iface->Libraries.begin(); - it != iface->Libraries.end(); ++it) - { - processILibs(config, headTarget, *it, tgts, emitted); - } - } - } -} - -//---------------------------------------------------------------------------- -std::vector const& -cmTarget::GetLinkImplementationClosure(const std::string& config) const -{ - cmTargetInternals::LinkImplClosure& tgts = - this->Internal->LinkImplClosureMap[config]; - if(!tgts.Done) - { - tgts.Done = true; - std::set emitted; - - cmTarget::LinkImplementationLibraries const* impl - = this->GetLinkImplementationLibraries(config); - - for(std::vector::const_iterator - it = impl->Libraries.begin(); - it != impl->Libraries.end(); ++it) - { - processILibs(config, this, *it, tgts , emitted); - } - } - return tgts; -} - -//---------------------------------------------------------------------------- void cmTargetInternals::ComputeLinkInterfaceLibraries( cmTarget const* thisTarget, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 85d9964..925e7c6 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -293,9 +293,6 @@ public: cmTarget const* headTarget, bool usage_requirements_only) const; - std::vector const& - GetLinkImplementationClosure(const std::string& config) const; - /** The link implementation specifies the direct library dependencies needed by the object files of the target. */ struct LinkImplementationLibraries http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=452ec942b08a83390736cc9b50f6006adef38bde commit 452ec942b08a83390736cc9b50f6006adef38bde Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:44 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 4 19:19:44 2015 +0200 cmGeneratorTarget: Move ReportPropertyOrigin from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index fe73fee..521a5b7 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1937,24 +1937,24 @@ std::pair consistentProperty(const char *lhs, //---------------------------------------------------------------------------- template -PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, +PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt, const std::string &p, const std::string& config, const char *defaultValue, CompatibleType t, PropertyType *) { - PropertyType propContent = getTypedProperty(tgt, p); - const bool explicitlySet = tgt->GetProperties() + PropertyType propContent = getTypedProperty(tgt->Target, p); + const bool explicitlySet = tgt->Target->GetProperties() .find(p) - != tgt->GetProperties().end(); + != tgt->Target->GetProperties().end(); const bool impliedByUse = - tgt->IsNullImpliedByLinkLibraries(p); + tgt->Target->IsNullImpliedByLinkLibraries(p); assert((impliedByUse ^ explicitlySet) || (!impliedByUse && !explicitlySet)); std::vector const& deps = - tgt->GetLinkImplementationClosure(config); + tgt->Target->GetLinkImplementationClosure(config); if(deps.empty()) { @@ -2125,7 +2125,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, bool cmGeneratorTarget::GetLinkInterfaceDependentBoolProperty( const std::string &p, const std::string& config) const { - return checkInterfacePropertyCompatibility(this->Target, p, config, + return checkInterfacePropertyCompatibility(this, p, config, "FALSE", BoolType, 0); } @@ -2135,7 +2135,7 @@ const char* cmGeneratorTarget::GetLinkInterfaceDependentStringProperty( const std::string &p, const std::string& config) const { - return checkInterfacePropertyCompatibility(this->Target, + return checkInterfacePropertyCompatibility(this, p, config, "empty", @@ -2147,7 +2147,7 @@ const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMinProperty( const std::string &p, const std::string& config) const { - return checkInterfacePropertyCompatibility(this->Target, + return checkInterfacePropertyCompatibility(this, p, config, "empty", @@ -2159,7 +2159,7 @@ const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMaxProperty( const std::string &p, const std::string& config) const { - return checkInterfacePropertyCompatibility(this->Target, + return checkInterfacePropertyCompatibility(this, p, config, "empty", @@ -2196,3 +2196,43 @@ cmGeneratorTarget::GetLinkInformation(const std::string& config) const } return i->second; } + +//---------------------------------------------------------------------------- +void +cmGeneratorTarget::ReportPropertyOrigin(const std::string &p, + const std::string &result, + const std::string &report, + const std::string &compatibilityType) const +{ + std::vector debugProperties; + const char *debugProp = this->Target->GetMakefile() + ->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); + if (debugProp) + { + cmSystemTools::ExpandListArgument(debugProp, debugProperties); + } + + bool debugOrigin = !this->DebugCompatiblePropertiesDone[p] + && std::find(debugProperties.begin(), + debugProperties.end(), + p) + != debugProperties.end(); + + if (this->Target->GetMakefile()->IsConfigured()) + { + this->DebugCompatiblePropertiesDone[p] = true; + } + if (!debugOrigin) + { + return; + } + + std::string areport = compatibilityType; + areport += std::string(" of property \"") + p + "\" for target \""; + areport += std::string(this->GetName()); + areport += "\" (result: \""; + areport += result; + areport += "\"):\n" + report; + + this->Makefile->GetCMakeInstance()->IssueMessage(cmake::LOG, areport); +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index d65b1ef..8e68d39 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -199,6 +199,11 @@ public: std::vector XamlSources; }; + void ReportPropertyOrigin(const std::string &p, + const std::string &result, + const std::string &report, + const std::string &compatibilityType) const; + private: friend class cmTargetTraceDependencies; struct SourceEntry { std::vector Depends; }; @@ -212,6 +217,8 @@ private: mutable bool SourceFileFlagsConstructed; mutable std::map SourceFlagsMap; + mutable std::map DebugCompatiblePropertiesDone; + struct CompatibleInterfacesBase { std::set PropsBool; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1fa62e7..968bd9d 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4537,46 +4537,6 @@ bool cmTarget::IsNullImpliedByLinkLibraries(const std::string &p) const //---------------------------------------------------------------------------- void -cmTarget::ReportPropertyOrigin(const std::string &p, - const std::string &result, - const std::string &report, - const std::string &compatibilityType) const -{ - std::vector debugProperties; - const char *debugProp = - this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); - if (debugProp) - { - cmSystemTools::ExpandListArgument(debugProp, debugProperties); - } - - bool debugOrigin = !this->DebugCompatiblePropertiesDone[p] - && std::find(debugProperties.begin(), - debugProperties.end(), - p) - != debugProperties.end(); - - if (this->Makefile->IsConfigured()) - { - this->DebugCompatiblePropertiesDone[p] = true; - } - if (!debugOrigin) - { - return; - } - - std::string areport = compatibilityType; - areport += std::string(" of property \"") + p + "\" for target \""; - areport += std::string(this->GetName()); - areport += "\" (result: \""; - areport += result; - areport += "\"):\n" + report; - - this->Makefile->GetCMakeInstance()->IssueMessage(cmake::LOG, areport); -} - -//---------------------------------------------------------------------------- -void cmTarget::GetObjectLibrariesCMP0026(std::vector& objlibs) const { // At configure-time, this method can be called as part of getting the diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 795753e..85d9964 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -565,11 +565,6 @@ public: bool LinkLanguagePropagatesToDependents() const { return this->TargetTypeValue == STATIC_LIBRARY; } - void ReportPropertyOrigin(const std::string &p, - const std::string &result, - const std::string &report, - const std::string &compatibilityType) const; - std::map const& GetMaxLanguageStandards() const { @@ -676,7 +671,6 @@ private: std::set Utilities; mutable std::set LinkImplicitNullProperties; std::map UtilityBacktraces; - mutable std::map DebugCompatiblePropertiesDone; mutable std::map MaxLanguageStandards; cmPolicies::PolicyMap PolicyMap; std::string Name; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=50c11c585e9b2a8050c31a6b7179379fa2472b23 commit 50c11c585e9b2a8050c31a6b7179379fa2472b23 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:43 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 4 19:19:43 2015 +0200 cmGeneratorTarget: Make CompatibleType enum private again. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index a9245c0..fe73fee 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1524,18 +1524,26 @@ bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty( return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0; } +enum CompatibleType +{ + BoolType, + StringType, + NumberMinType, + NumberMaxType +}; + template PropertyType getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, - cmTarget::CompatibleType, + CompatibleType, PropertyType *); template<> bool getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, - cmTarget::CompatibleType, bool *) + CompatibleType, bool *) { return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); } @@ -1544,19 +1552,19 @@ template<> const char * getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, - cmTarget::CompatibleType t, + CompatibleType t, const char **) { switch(t) { - case cmTarget::BoolType: + case BoolType: assert(0 && "String compatibility check function called for boolean"); return 0; - case cmTarget::StringType: + case StringType: return tgt->GetLinkInterfaceDependentStringProperty(prop, config); - case cmTarget::NumberMinType: + case NumberMinType: return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config); - case cmTarget::NumberMaxType: + case NumberMaxType: return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config); } assert(0 && "Unreachable!"); @@ -1570,7 +1578,7 @@ void checkPropertyConsistency(cmGeneratorTarget const* depender, const std::string& propName, std::set &emitted, const std::string& config, - cmTarget::CompatibleType t, + CompatibleType t, PropertyType *) { const char *prop = dependee->GetProperty(propName); @@ -1683,7 +1691,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( checkPropertyConsistency(this, li->Target, strBool, - emittedBools, config, cmTarget::BoolType, 0); + emittedBools, config, BoolType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; @@ -1691,7 +1699,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( checkPropertyConsistency(this, li->Target, strString, emittedStrings, config, - cmTarget::StringType, 0); + StringType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; @@ -1699,7 +1707,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( checkPropertyConsistency(this, li->Target, strNumMin, emittedMinNumbers, config, - cmTarget::NumberMinType, 0); + NumberMinType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; @@ -1707,7 +1715,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( checkPropertyConsistency(this, li->Target, strNumMax, emittedMaxNumbers, config, - cmTarget::NumberMaxType, 0); + NumberMaxType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; @@ -1760,17 +1768,17 @@ void cmGeneratorTarget::CheckPropertyCompatibility( } //---------------------------------------------------------------------------- -std::string compatibilityType(cmTarget::CompatibleType t) +std::string compatibilityType(CompatibleType t) { switch(t) { - case cmTarget::BoolType: + case BoolType: return "Boolean compatibility"; - case cmTarget::StringType: + case StringType: return "String compatibility"; - case cmTarget::NumberMaxType: + case NumberMaxType: return "Numeric maximum compatibility"; - case cmTarget::NumberMinType: + case NumberMinType: return "Numeric minimum compatibility"; } assert(0 && "Unreachable!"); @@ -1778,15 +1786,15 @@ std::string compatibilityType(cmTarget::CompatibleType t) } //---------------------------------------------------------------------------- -std::string compatibilityAgree(cmTarget::CompatibleType t, bool dominant) +std::string compatibilityAgree(CompatibleType t, bool dominant) { switch(t) { - case cmTarget::BoolType: - case cmTarget::StringType: + case BoolType: + case StringType: return dominant ? "(Disagree)\n" : "(Agree)\n"; - case cmTarget::NumberMaxType: - case cmTarget::NumberMinType: + case NumberMaxType: + case NumberMinType: return dominant ? "(Dominant)\n" : "(Ignored)\n"; } assert(0 && "Unreachable!"); @@ -1842,12 +1850,12 @@ const char* impliedValue(const char*) template std::pair consistentProperty(PropertyType lhs, PropertyType rhs, - cmTarget::CompatibleType t); + CompatibleType t); //---------------------------------------------------------------------------- template<> std::pair consistentProperty(bool lhs, bool rhs, - cmTarget::CompatibleType) + CompatibleType) { return std::make_pair(lhs == rhs, lhs); } @@ -1863,7 +1871,7 @@ std::pair consistentStringProperty(const char *lhs, //---------------------------------------------------------------------------- std::pair consistentNumberProperty(const char *lhs, const char *rhs, - cmTarget::CompatibleType t) + CompatibleType t) { char *pEnd; @@ -1881,7 +1889,7 @@ std::pair consistentNumberProperty(const char *lhs, return std::pair(false, null_ptr); } - if (t == cmTarget::NumberMaxType) + if (t == NumberMaxType) { return std::make_pair(true, std::max(lnum, rnum) == lnum ? lhs : rhs); } @@ -1895,7 +1903,7 @@ std::pair consistentNumberProperty(const char *lhs, template<> std::pair consistentProperty(const char *lhs, const char *rhs, - cmTarget::CompatibleType t) + CompatibleType t) { if (!lhs && !rhs) { @@ -1914,13 +1922,13 @@ std::pair consistentProperty(const char *lhs, switch(t) { - case cmTarget::BoolType: + case BoolType: assert(0 && "consistentProperty for strings called with BoolType"); return std::pair(false, null_ptr); - case cmTarget::StringType: + case StringType: return consistentStringProperty(lhs, rhs); - case cmTarget::NumberMinType: - case cmTarget::NumberMaxType: + case NumberMinType: + case NumberMaxType: return consistentNumberProperty(lhs, rhs, t); } assert(0 && "Unreachable!"); @@ -1933,7 +1941,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, const std::string &p, const std::string& config, const char *defaultValue, - cmTarget::CompatibleType t, + CompatibleType t, PropertyType *) { PropertyType propContent = getTypedProperty(tgt, p); @@ -2119,7 +2127,7 @@ bool cmGeneratorTarget::GetLinkInterfaceDependentBoolProperty( { return checkInterfacePropertyCompatibility(this->Target, p, config, "FALSE", - cmTarget::BoolType, 0); + BoolType, 0); } //---------------------------------------------------------------------------- @@ -2131,7 +2139,7 @@ const char* cmGeneratorTarget::GetLinkInterfaceDependentStringProperty( p, config, "empty", - cmTarget::StringType, 0); + StringType, 0); } //---------------------------------------------------------------------------- @@ -2143,7 +2151,7 @@ const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMinProperty( p, config, "empty", - cmTarget::NumberMinType, 0); + NumberMinType, 0); } //---------------------------------------------------------------------------- @@ -2155,7 +2163,7 @@ const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMaxProperty( p, config, "empty", - cmTarget::NumberMaxType, 0); + NumberMaxType, 0); } //---------------------------------------------------------------------------- diff --git a/Source/cmTarget.h b/Source/cmTarget.h index b544b0b..795753e 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -581,14 +581,6 @@ public: return this->LinkLibrariesForVS6;} #endif - enum CompatibleType - { - BoolType, - StringType, - NumberMinType, - NumberMaxType - }; - private: bool HandleLocationPropertyPolicy(cmMakefile* context) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3009936bba98cbe03514c60567ab104a2b22a526 commit 3009936bba98cbe03514c60567ab104a2b22a526 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:43 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 4 19:19:43 2015 +0200 cmGeneratorTarget: Move LinkInterfaceDependent methods from cmTarget. diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index c1641cc..a20579b 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1142,7 +1142,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode context->Config)) { context->HadContextSensitiveCondition = true; - return target->GetLinkInterfaceDependentBoolProperty( + return gtgt->GetLinkInterfaceDependentBoolProperty( propertyName, context->Config) ? "1" : "0"; } @@ -1151,7 +1151,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { context->HadContextSensitiveCondition = true; const char *propContent = - target->GetLinkInterfaceDependentStringProperty( + gtgt->GetLinkInterfaceDependentStringProperty( propertyName, context->Config); return propContent ? propContent : ""; @@ -1161,7 +1161,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { context->HadContextSensitiveCondition = true; const char *propContent = - target->GetLinkInterfaceDependentNumberMinProperty( + gtgt->GetLinkInterfaceDependentNumberMinProperty( propertyName, context->Config); return propContent ? propContent : ""; @@ -1171,7 +1171,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { context->HadContextSensitiveCondition = true; const char *propContent = - target->GetLinkInterfaceDependentNumberMaxProperty( + gtgt->GetLinkInterfaceDependentNumberMaxProperty( propertyName, context->Config); return propContent ? propContent : ""; @@ -1188,7 +1188,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { context->HadContextSensitiveCondition = true; const char *propContent = - target->GetLinkInterfaceDependentNumberMinProperty( + gtgt->GetLinkInterfaceDependentNumberMinProperty( propertyName, context->Config); return propContent ? propContent : ""; @@ -1198,7 +1198,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { context->HadContextSensitiveCondition = true; const char *propContent = - target->GetLinkInterfaceDependentNumberMaxProperty( + gtgt->GetLinkInterfaceDependentNumberMaxProperty( propertyName, context->Config); return propContent ? propContent : ""; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index a7b0349..a9245c0 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -24,6 +24,7 @@ #include +#include #include "assert.h" //---------------------------------------------------------------------------- @@ -753,8 +754,7 @@ void cmGeneratorTarget::GetAutoUicOptions(std::vector &result, const std::string& config) const { const char *prop - = this->Target-> - GetLinkInterfaceDependentStringProperty("AUTOUIC_OPTIONS", + = this->GetLinkInterfaceDependentStringProperty("AUTOUIC_OPTIONS", config); if (!prop) { @@ -1537,7 +1537,7 @@ bool getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& config, cmTarget::CompatibleType, bool *) { - return tgt->Target->GetLinkInterfaceDependentBoolProperty(prop, config); + return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); } template<> @@ -1553,13 +1553,11 @@ const char * getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, assert(0 && "String compatibility check function called for boolean"); return 0; case cmTarget::StringType: - return tgt->Target->GetLinkInterfaceDependentStringProperty(prop, config); + return tgt->GetLinkInterfaceDependentStringProperty(prop, config); case cmTarget::NumberMinType: - return tgt->Target - ->GetLinkInterfaceDependentNumberMinProperty(prop, config); + return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config); case cmTarget::NumberMaxType: - return tgt->Target - ->GetLinkInterfaceDependentNumberMaxProperty(prop, config); + return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config); } assert(0 && "Unreachable!"); return 0; @@ -1762,6 +1760,405 @@ void cmGeneratorTarget::CheckPropertyCompatibility( } //---------------------------------------------------------------------------- +std::string compatibilityType(cmTarget::CompatibleType t) +{ + switch(t) + { + case cmTarget::BoolType: + return "Boolean compatibility"; + case cmTarget::StringType: + return "String compatibility"; + case cmTarget::NumberMaxType: + return "Numeric maximum compatibility"; + case cmTarget::NumberMinType: + return "Numeric minimum compatibility"; + } + assert(0 && "Unreachable!"); + return ""; +} + +//---------------------------------------------------------------------------- +std::string compatibilityAgree(cmTarget::CompatibleType t, bool dominant) +{ + switch(t) + { + case cmTarget::BoolType: + case cmTarget::StringType: + return dominant ? "(Disagree)\n" : "(Agree)\n"; + case cmTarget::NumberMaxType: + case cmTarget::NumberMinType: + return dominant ? "(Dominant)\n" : "(Ignored)\n"; + } + assert(0 && "Unreachable!"); + return ""; +} + +//---------------------------------------------------------------------------- +template +PropertyType getTypedProperty(cmTarget const* tgt, const std::string& prop); + +//---------------------------------------------------------------------------- +template<> +bool getTypedProperty(cmTarget const* tgt, const std::string& prop) +{ + return tgt->GetPropertyAsBool(prop); +} + +//---------------------------------------------------------------------------- +template<> +const char *getTypedProperty(cmTarget const* tgt, + const std::string& prop) +{ + return tgt->GetProperty(prop); +} + +template +std::string valueAsString(PropertyType); +template<> +std::string valueAsString(bool value) +{ + return value ? "TRUE" : "FALSE"; +} +template<> +std::string valueAsString(const char* value) +{ + return value ? value : "(unset)"; +} + +template +PropertyType impliedValue(PropertyType); +template<> +bool impliedValue(bool) +{ + return false; +} +template<> +const char* impliedValue(const char*) +{ + return ""; +} + +//---------------------------------------------------------------------------- +template +std::pair consistentProperty(PropertyType lhs, + PropertyType rhs, + cmTarget::CompatibleType t); + +//---------------------------------------------------------------------------- +template<> +std::pair consistentProperty(bool lhs, bool rhs, + cmTarget::CompatibleType) +{ + return std::make_pair(lhs == rhs, lhs); +} + +//---------------------------------------------------------------------------- +std::pair consistentStringProperty(const char *lhs, + const char *rhs) +{ + const bool b = strcmp(lhs, rhs) == 0; + return std::make_pair(b, b ? lhs : 0); +} + +//---------------------------------------------------------------------------- +std::pair consistentNumberProperty(const char *lhs, + const char *rhs, + cmTarget::CompatibleType t) +{ + char *pEnd; + + const char* const null_ptr = 0; + + long lnum = strtol(lhs, &pEnd, 0); + if (pEnd == lhs || *pEnd != '\0' || errno == ERANGE) + { + return std::pair(false, null_ptr); + } + + long rnum = strtol(rhs, &pEnd, 0); + if (pEnd == rhs || *pEnd != '\0' || errno == ERANGE) + { + return std::pair(false, null_ptr); + } + + if (t == cmTarget::NumberMaxType) + { + return std::make_pair(true, std::max(lnum, rnum) == lnum ? lhs : rhs); + } + else + { + return std::make_pair(true, std::min(lnum, rnum) == lnum ? lhs : rhs); + } +} + +//---------------------------------------------------------------------------- +template<> +std::pair consistentProperty(const char *lhs, + const char *rhs, + cmTarget::CompatibleType t) +{ + if (!lhs && !rhs) + { + return std::make_pair(true, lhs); + } + if (!lhs) + { + return std::make_pair(true, rhs); + } + if (!rhs) + { + return std::make_pair(true, lhs); + } + + const char* const null_ptr = 0; + + switch(t) + { + case cmTarget::BoolType: + assert(0 && "consistentProperty for strings called with BoolType"); + return std::pair(false, null_ptr); + case cmTarget::StringType: + return consistentStringProperty(lhs, rhs); + case cmTarget::NumberMinType: + case cmTarget::NumberMaxType: + return consistentNumberProperty(lhs, rhs, t); + } + assert(0 && "Unreachable!"); + return std::pair(false, null_ptr); +} + +//---------------------------------------------------------------------------- +template +PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, + const std::string &p, + const std::string& config, + const char *defaultValue, + cmTarget::CompatibleType t, + PropertyType *) +{ + PropertyType propContent = getTypedProperty(tgt, p); + const bool explicitlySet = tgt->GetProperties() + .find(p) + != tgt->GetProperties().end(); + const bool impliedByUse = + tgt->IsNullImpliedByLinkLibraries(p); + assert((impliedByUse ^ explicitlySet) + || (!impliedByUse && !explicitlySet)); + + std::vector const& deps = + tgt->GetLinkImplementationClosure(config); + + if(deps.empty()) + { + return propContent; + } + bool propInitialized = explicitlySet; + + std::string report = " * Target \""; + report += tgt->GetName(); + if (explicitlySet) + { + report += "\" has property content \""; + report += valueAsString(propContent); + report += "\"\n"; + } + else if (impliedByUse) + { + report += "\" property is implied by use.\n"; + } + else + { + report += "\" property not set.\n"; + } + + std::string interfaceProperty = "INTERFACE_" + p; + for(std::vector::const_iterator li = + deps.begin(); + li != deps.end(); ++li) + { + // An error should be reported if one dependency + // has INTERFACE_POSITION_INDEPENDENT_CODE ON and the other + // has INTERFACE_POSITION_INDEPENDENT_CODE OFF, or if the + // target itself has a POSITION_INDEPENDENT_CODE which disagrees + // with a dependency. + + cmTarget const* theTarget = *li; + + const bool ifaceIsSet = theTarget->GetProperties() + .find(interfaceProperty) + != theTarget->GetProperties().end(); + PropertyType ifacePropContent = + getTypedProperty(theTarget, + interfaceProperty); + + std::string reportEntry; + if (ifaceIsSet) + { + reportEntry += " * Target \""; + reportEntry += theTarget->GetName(); + reportEntry += "\" property value \""; + reportEntry += valueAsString(ifacePropContent); + reportEntry += "\" "; + } + + if (explicitlySet) + { + if (ifaceIsSet) + { + std::pair consistent = + consistentProperty(propContent, + ifacePropContent, t); + report += reportEntry; + report += compatibilityAgree(t, propContent != consistent.second); + if (!consistent.first) + { + std::ostringstream e; + e << "Property " << p << " on target \"" + << tgt->GetName() << "\" does\nnot match the " + "INTERFACE_" << p << " property requirement\nof " + "dependency \"" << theTarget->GetName() << "\".\n"; + cmSystemTools::Error(e.str().c_str()); + break; + } + else + { + propContent = consistent.second; + continue; + } + } + else + { + // Explicitly set on target and not set in iface. Can't disagree. + continue; + } + } + else if (impliedByUse) + { + propContent = impliedValue(propContent); + + if (ifaceIsSet) + { + std::pair consistent = + consistentProperty(propContent, + ifacePropContent, t); + report += reportEntry; + report += compatibilityAgree(t, propContent != consistent.second); + if (!consistent.first) + { + std::ostringstream e; + e << "Property " << p << " on target \"" + << tgt->GetName() << "\" is\nimplied to be " << defaultValue + << " because it was used to determine the link libraries\n" + "already. The INTERFACE_" << p << " property on\ndependency \"" + << theTarget->GetName() << "\" is in conflict.\n"; + cmSystemTools::Error(e.str().c_str()); + break; + } + else + { + propContent = consistent.second; + continue; + } + } + else + { + // Implicitly set on target and not set in iface. Can't disagree. + continue; + } + } + else + { + if (ifaceIsSet) + { + if (propInitialized) + { + std::pair consistent = + consistentProperty(propContent, + ifacePropContent, t); + report += reportEntry; + report += compatibilityAgree(t, propContent != consistent.second); + if (!consistent.first) + { + std::ostringstream e; + e << "The INTERFACE_" << p << " property of \"" + << theTarget->GetName() << "\" does\nnot agree with the value " + "of " << p << " already determined\nfor \"" + << tgt->GetName() << "\".\n"; + cmSystemTools::Error(e.str().c_str()); + break; + } + else + { + propContent = consistent.second; + continue; + } + } + else + { + report += reportEntry + "(Interface set)\n"; + propContent = ifacePropContent; + propInitialized = true; + } + } + else + { + // Not set. Nothing to agree on. + continue; + } + } + } + + tgt->ReportPropertyOrigin(p, valueAsString(propContent), + report, compatibilityType(t)); + return propContent; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::GetLinkInterfaceDependentBoolProperty( + const std::string &p, const std::string& config) const +{ + return checkInterfacePropertyCompatibility(this->Target, p, config, + "FALSE", + cmTarget::BoolType, 0); +} + +//---------------------------------------------------------------------------- +const char* cmGeneratorTarget::GetLinkInterfaceDependentStringProperty( + const std::string &p, + const std::string& config) const +{ + return checkInterfacePropertyCompatibility(this->Target, + p, + config, + "empty", + cmTarget::StringType, 0); +} + +//---------------------------------------------------------------------------- +const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMinProperty( + const std::string &p, + const std::string& config) const +{ + return checkInterfacePropertyCompatibility(this->Target, + p, + config, + "empty", + cmTarget::NumberMinType, 0); +} + +//---------------------------------------------------------------------------- +const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMaxProperty( + const std::string &p, + const std::string& config) const +{ + return checkInterfacePropertyCompatibility(this->Target, + p, + config, + "empty", + cmTarget::NumberMaxType, 0); +} + +//---------------------------------------------------------------------------- cmComputeLinkInformation* cmGeneratorTarget::GetLinkInformation(const std::string& config) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index ae86e19..d65b1ef 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -96,6 +96,17 @@ public: bool IsLinkInterfaceDependentNumberMaxProperty(const std::string &p, const std::string& config) const; + bool GetLinkInterfaceDependentBoolProperty(const std::string &p, + const std::string& config) const; + + const char *GetLinkInterfaceDependentStringProperty(const std::string &p, + const std::string& config) const; + const char *GetLinkInterfaceDependentNumberMinProperty(const std::string &p, + const std::string& config) const; + const char *GetLinkInterfaceDependentNumberMaxProperty(const std::string &p, + const std::string& config) const; + + /** Get the full path to the target according to the settings in its makefile and the configuration type. */ std::string GetFullPath(const std::string& config="", bool implib = false, diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index eaf812f..3ab501d 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2059,7 +2059,9 @@ void cmLocalGenerator::AddCMP0018Flags(std::string &flags, return; } - if (target->GetLinkInterfaceDependentBoolProperty( + cmGeneratorTarget* gtgt = + this->GlobalGenerator->GetGeneratorTarget(target); + if (gtgt->GetLinkInterfaceDependentBoolProperty( "POSITION_INDEPENDENT_CODE", config)) { diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index a72b176..f1ba2f4 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -547,8 +547,11 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target) { qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR"); } + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); if (const char *targetQtVersion = - target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", "")) + gtgt->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", "")) { qtVersion = targetQtVersion; } @@ -1150,6 +1153,9 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) std::string cmQtAutoGenerators::GetRccExecutable(cmTarget const* target) { + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); cmMakefile *makefile = target->GetMakefile(); const char *qtVersion = makefile->GetDefinition("_target_qt_version"); if (!qtVersion) @@ -1160,8 +1166,7 @@ std::string cmQtAutoGenerators::GetRccExecutable(cmTarget const* target) qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR"); } if (const char *targetQtVersion = - target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", - "")) + gtgt->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", "")) { qtVersion = targetQtVersion; } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index b165545..1fa62e7 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4536,141 +4536,6 @@ bool cmTarget::IsNullImpliedByLinkLibraries(const std::string &p) const } //---------------------------------------------------------------------------- -template -PropertyType getTypedProperty(cmTarget const* tgt, const std::string& prop); - -//---------------------------------------------------------------------------- -template<> -bool getTypedProperty(cmTarget const* tgt, const std::string& prop) -{ - return tgt->GetPropertyAsBool(prop); -} - -//---------------------------------------------------------------------------- -template<> -const char *getTypedProperty(cmTarget const* tgt, - const std::string& prop) -{ - return tgt->GetProperty(prop); -} - -//---------------------------------------------------------------------------- -template -std::pair consistentProperty(PropertyType lhs, - PropertyType rhs, - cmTarget::CompatibleType t); - -//---------------------------------------------------------------------------- -template<> -std::pair consistentProperty(bool lhs, bool rhs, - cmTarget::CompatibleType) -{ - return std::make_pair(lhs == rhs, lhs); -} - -//---------------------------------------------------------------------------- -std::pair consistentStringProperty(const char *lhs, - const char *rhs) -{ - const bool b = strcmp(lhs, rhs) == 0; - return std::make_pair(b, b ? lhs : 0); -} - -//---------------------------------------------------------------------------- -std::pair consistentNumberProperty(const char *lhs, - const char *rhs, - cmTarget::CompatibleType t) -{ - char *pEnd; - - const char* const null_ptr = 0; - - long lnum = strtol(lhs, &pEnd, 0); - if (pEnd == lhs || *pEnd != '\0' || errno == ERANGE) - { - return std::pair(false, null_ptr); - } - - long rnum = strtol(rhs, &pEnd, 0); - if (pEnd == rhs || *pEnd != '\0' || errno == ERANGE) - { - return std::pair(false, null_ptr); - } - - if (t == cmTarget::NumberMaxType) - { - return std::make_pair(true, std::max(lnum, rnum) == lnum ? lhs : rhs); - } - else - { - return std::make_pair(true, std::min(lnum, rnum) == lnum ? lhs : rhs); - } -} - -//---------------------------------------------------------------------------- -template<> -std::pair consistentProperty(const char *lhs, - const char *rhs, - cmTarget::CompatibleType t) -{ - if (!lhs && !rhs) - { - return std::make_pair(true, lhs); - } - if (!lhs) - { - return std::make_pair(true, rhs); - } - if (!rhs) - { - return std::make_pair(true, lhs); - } - - const char* const null_ptr = 0; - - switch(t) - { - case cmTarget::BoolType: - assert(0 && "consistentProperty for strings called with BoolType"); - return std::pair(false, null_ptr); - case cmTarget::StringType: - return consistentStringProperty(lhs, rhs); - case cmTarget::NumberMinType: - case cmTarget::NumberMaxType: - return consistentNumberProperty(lhs, rhs, t); - } - assert(0 && "Unreachable!"); - return std::pair(false, null_ptr); -} - -template -PropertyType impliedValue(PropertyType); -template<> -bool impliedValue(bool) -{ - return false; -} -template<> -const char* impliedValue(const char*) -{ - return ""; -} - - -template -std::string valueAsString(PropertyType); -template<> -std::string valueAsString(bool value) -{ - return value ? "TRUE" : "FALSE"; -} -template<> -std::string valueAsString(const char* value) -{ - return value ? value : "(unset)"; -} - -//---------------------------------------------------------------------------- void cmTarget::ReportPropertyOrigin(const std::string &p, const std::string &result, @@ -4711,270 +4576,6 @@ cmTarget::ReportPropertyOrigin(const std::string &p, } //---------------------------------------------------------------------------- -std::string compatibilityType(cmTarget::CompatibleType t) -{ - switch(t) - { - case cmTarget::BoolType: - return "Boolean compatibility"; - case cmTarget::StringType: - return "String compatibility"; - case cmTarget::NumberMaxType: - return "Numeric maximum compatibility"; - case cmTarget::NumberMinType: - return "Numeric minimum compatibility"; - } - assert(0 && "Unreachable!"); - return ""; -} - -//---------------------------------------------------------------------------- -std::string compatibilityAgree(cmTarget::CompatibleType t, bool dominant) -{ - switch(t) - { - case cmTarget::BoolType: - case cmTarget::StringType: - return dominant ? "(Disagree)\n" : "(Agree)\n"; - case cmTarget::NumberMaxType: - case cmTarget::NumberMinType: - return dominant ? "(Dominant)\n" : "(Ignored)\n"; - } - assert(0 && "Unreachable!"); - return ""; -} - -//---------------------------------------------------------------------------- -template -PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, - const std::string &p, - const std::string& config, - const char *defaultValue, - cmTarget::CompatibleType t, - PropertyType *) -{ - PropertyType propContent = getTypedProperty(tgt, p); - const bool explicitlySet = tgt->GetProperties() - .find(p) - != tgt->GetProperties().end(); - const bool impliedByUse = - tgt->IsNullImpliedByLinkLibraries(p); - assert((impliedByUse ^ explicitlySet) - || (!impliedByUse && !explicitlySet)); - - std::vector const& deps = - tgt->GetLinkImplementationClosure(config); - - if(deps.empty()) - { - return propContent; - } - bool propInitialized = explicitlySet; - - std::string report = " * Target \""; - report += tgt->GetName(); - if (explicitlySet) - { - report += "\" has property content \""; - report += valueAsString(propContent); - report += "\"\n"; - } - else if (impliedByUse) - { - report += "\" property is implied by use.\n"; - } - else - { - report += "\" property not set.\n"; - } - - std::string interfaceProperty = "INTERFACE_" + p; - for(std::vector::const_iterator li = - deps.begin(); - li != deps.end(); ++li) - { - // An error should be reported if one dependency - // has INTERFACE_POSITION_INDEPENDENT_CODE ON and the other - // has INTERFACE_POSITION_INDEPENDENT_CODE OFF, or if the - // target itself has a POSITION_INDEPENDENT_CODE which disagrees - // with a dependency. - - cmTarget const* theTarget = *li; - - const bool ifaceIsSet = theTarget->GetProperties() - .find(interfaceProperty) - != theTarget->GetProperties().end(); - PropertyType ifacePropContent = - getTypedProperty(theTarget, - interfaceProperty); - - std::string reportEntry; - if (ifaceIsSet) - { - reportEntry += " * Target \""; - reportEntry += theTarget->GetName(); - reportEntry += "\" property value \""; - reportEntry += valueAsString(ifacePropContent); - reportEntry += "\" "; - } - - if (explicitlySet) - { - if (ifaceIsSet) - { - std::pair consistent = - consistentProperty(propContent, - ifacePropContent, t); - report += reportEntry; - report += compatibilityAgree(t, propContent != consistent.second); - if (!consistent.first) - { - std::ostringstream e; - e << "Property " << p << " on target \"" - << tgt->GetName() << "\" does\nnot match the " - "INTERFACE_" << p << " property requirement\nof " - "dependency \"" << theTarget->GetName() << "\".\n"; - cmSystemTools::Error(e.str().c_str()); - break; - } - else - { - propContent = consistent.second; - continue; - } - } - else - { - // Explicitly set on target and not set in iface. Can't disagree. - continue; - } - } - else if (impliedByUse) - { - propContent = impliedValue(propContent); - - if (ifaceIsSet) - { - std::pair consistent = - consistentProperty(propContent, - ifacePropContent, t); - report += reportEntry; - report += compatibilityAgree(t, propContent != consistent.second); - if (!consistent.first) - { - std::ostringstream e; - e << "Property " << p << " on target \"" - << tgt->GetName() << "\" is\nimplied to be " << defaultValue - << " because it was used to determine the link libraries\n" - "already. The INTERFACE_" << p << " property on\ndependency \"" - << theTarget->GetName() << "\" is in conflict.\n"; - cmSystemTools::Error(e.str().c_str()); - break; - } - else - { - propContent = consistent.second; - continue; - } - } - else - { - // Implicitly set on target and not set in iface. Can't disagree. - continue; - } - } - else - { - if (ifaceIsSet) - { - if (propInitialized) - { - std::pair consistent = - consistentProperty(propContent, - ifacePropContent, t); - report += reportEntry; - report += compatibilityAgree(t, propContent != consistent.second); - if (!consistent.first) - { - std::ostringstream e; - e << "The INTERFACE_" << p << " property of \"" - << theTarget->GetName() << "\" does\nnot agree with the value " - "of " << p << " already determined\nfor \"" - << tgt->GetName() << "\".\n"; - cmSystemTools::Error(e.str().c_str()); - break; - } - else - { - propContent = consistent.second; - continue; - } - } - else - { - report += reportEntry + "(Interface set)\n"; - propContent = ifacePropContent; - propInitialized = true; - } - } - else - { - // Not set. Nothing to agree on. - continue; - } - } - } - - tgt->ReportPropertyOrigin(p, valueAsString(propContent), - report, compatibilityType(t)); - return propContent; -} - -//---------------------------------------------------------------------------- -bool cmTarget::GetLinkInterfaceDependentBoolProperty(const std::string &p, - const std::string& config) const -{ - return checkInterfacePropertyCompatibility(this, p, config, "FALSE", - BoolType, 0); -} - -//---------------------------------------------------------------------------- -const char * cmTarget::GetLinkInterfaceDependentStringProperty( - const std::string &p, - const std::string& config) const -{ - return checkInterfacePropertyCompatibility(this, - p, - config, - "empty", - StringType, 0); -} - -//---------------------------------------------------------------------------- -const char * cmTarget::GetLinkInterfaceDependentNumberMinProperty( - const std::string &p, - const std::string& config) const -{ - return checkInterfacePropertyCompatibility(this, - p, - config, - "empty", - NumberMinType, 0); -} - -//---------------------------------------------------------------------------- -const char * cmTarget::GetLinkInterfaceDependentNumberMaxProperty( - const std::string &p, - const std::string& config) const -{ - return checkInterfacePropertyCompatibility(this, - p, - config, - "empty", - NumberMaxType, 0); -} - -//---------------------------------------------------------------------------- void cmTarget::GetObjectLibrariesCMP0026(std::vector& objlibs) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 8af74ef..b544b0b 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -553,15 +553,6 @@ public: const std::string& config) const; bool IsNullImpliedByLinkLibraries(const std::string &p) const; - bool GetLinkInterfaceDependentBoolProperty(const std::string &p, - const std::string& config) const; - - const char *GetLinkInterfaceDependentStringProperty(const std::string &p, - const std::string& config) const; - const char *GetLinkInterfaceDependentNumberMinProperty(const std::string &p, - const std::string& config) const; - const char *GetLinkInterfaceDependentNumberMaxProperty(const std::string &p, - const std::string& config) const; std::string GetDebugGeneratorExpressions(const std::string &value, cmTarget::LinkLibraryType llt) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2c5b01bc544299e6461ffb04e004e39dedb03b0c commit 2c5b01bc544299e6461ffb04e004e39dedb03b0c Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:43 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 4 19:19:43 2015 +0200 cmGeneratorTarget: Port internal API to cmGeneratorTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 1f3effb..a7b0349 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1525,23 +1525,23 @@ bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty( } template -PropertyType getLinkInterfaceDependentProperty(cmTarget const* tgt, +PropertyType getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, cmTarget::CompatibleType, PropertyType *); template<> -bool getLinkInterfaceDependentProperty(cmTarget const* tgt, +bool getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, cmTarget::CompatibleType, bool *) { - return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); + return tgt->Target->GetLinkInterfaceDependentBoolProperty(prop, config); } template<> -const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, +const char * getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, cmTarget::CompatibleType t, @@ -1553,11 +1553,13 @@ const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, assert(0 && "String compatibility check function called for boolean"); return 0; case cmTarget::StringType: - return tgt->GetLinkInterfaceDependentStringProperty(prop, config); + return tgt->Target->GetLinkInterfaceDependentStringProperty(prop, config); case cmTarget::NumberMinType: - return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config); + return tgt->Target + ->GetLinkInterfaceDependentNumberMinProperty(prop, config); case cmTarget::NumberMaxType: - return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config); + return tgt->Target + ->GetLinkInterfaceDependentNumberMaxProperty(prop, config); } assert(0 && "Unreachable!"); return 0; @@ -1565,7 +1567,7 @@ const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, //---------------------------------------------------------------------------- template -void checkPropertyConsistency(cmTarget const* depender, +void checkPropertyConsistency(cmGeneratorTarget const* depender, cmTarget const* dependee, const std::string& propName, std::set &emitted, @@ -1597,7 +1599,7 @@ void checkPropertyConsistency(cmTarget const* depender, << *pi << "\" listed in its " << propName << " property. " "This is not allowed. Only user-defined properties may appear " "listed in the " << propName << " property."; - depender->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, e.str()); + depender->GetLocalGenerator()->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } if(emitted.insert(*pi).second) @@ -1681,14 +1683,14 @@ void cmGeneratorTarget::CheckPropertyCompatibility( continue; } - checkPropertyConsistency(this->Target, li->Target, + checkPropertyConsistency(this, li->Target, strBool, emittedBools, config, cmTarget::BoolType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; } - checkPropertyConsistency(this->Target, li->Target, + checkPropertyConsistency(this, li->Target, strString, emittedStrings, config, cmTarget::StringType, 0); @@ -1696,7 +1698,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( { return; } - checkPropertyConsistency(this->Target, li->Target, + checkPropertyConsistency(this, li->Target, strNumMin, emittedMinNumbers, config, cmTarget::NumberMinType, 0); @@ -1704,7 +1706,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( { return; } - checkPropertyConsistency(this->Target, li->Target, + checkPropertyConsistency(this, li->Target, strNumMax, emittedMaxNumbers, config, cmTarget::NumberMaxType, 0); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7580640aec82a7a175c3f9054df4a44233ecbd7c commit 7580640aec82a7a175c3f9054df4a44233ecbd7c Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:43 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 4 19:19:43 2015 +0200 cmGeneratorTarget: Move CheckPropertyCompatibility from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 845c052..1f3effb 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1524,6 +1524,240 @@ bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty( return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0; } +template +PropertyType getLinkInterfaceDependentProperty(cmTarget const* tgt, + const std::string& prop, + const std::string& config, + cmTarget::CompatibleType, + PropertyType *); + +template<> +bool getLinkInterfaceDependentProperty(cmTarget const* tgt, + const std::string& prop, + const std::string& config, + cmTarget::CompatibleType, bool *) +{ + return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); +} + +template<> +const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, + const std::string& prop, + const std::string& config, + cmTarget::CompatibleType t, + const char **) +{ + switch(t) + { + case cmTarget::BoolType: + assert(0 && "String compatibility check function called for boolean"); + return 0; + case cmTarget::StringType: + return tgt->GetLinkInterfaceDependentStringProperty(prop, config); + case cmTarget::NumberMinType: + return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config); + case cmTarget::NumberMaxType: + return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config); + } + assert(0 && "Unreachable!"); + return 0; +} + +//---------------------------------------------------------------------------- +template +void checkPropertyConsistency(cmTarget const* depender, + cmTarget const* dependee, + const std::string& propName, + std::set &emitted, + const std::string& config, + cmTarget::CompatibleType t, + PropertyType *) +{ + const char *prop = dependee->GetProperty(propName); + if (!prop) + { + return; + } + + std::vector props; + cmSystemTools::ExpandListArgument(prop, props); + std::string pdir = + dependee->GetMakefile()->GetRequiredDefinition("CMAKE_ROOT"); + pdir += "/Help/prop_tgt/"; + + for(std::vector::iterator pi = props.begin(); + pi != props.end(); ++pi) + { + std::string pname = cmSystemTools::HelpFileName(*pi); + std::string pfile = pdir + pname + ".rst"; + if(cmSystemTools::FileExists(pfile.c_str(), true)) + { + std::ostringstream e; + e << "Target \"" << dependee->GetName() << "\" has property \"" + << *pi << "\" listed in its " << propName << " property. " + "This is not allowed. Only user-defined properties may appear " + "listed in the " << propName << " property."; + depender->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, e.str()); + return; + } + if(emitted.insert(*pi).second) + { + getLinkInterfaceDependentProperty(depender, *pi, config, + t, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + } + } +} + +static std::string intersect(const std::set &s1, + const std::set &s2) +{ + std::set intersect; + std::set_intersection(s1.begin(),s1.end(), + s2.begin(),s2.end(), + std::inserter(intersect,intersect.begin())); + if (!intersect.empty()) + { + return *intersect.begin(); + } + return ""; +} + +static std::string intersect(const std::set &s1, + const std::set &s2, + const std::set &s3) +{ + std::string result; + result = intersect(s1, s2); + if (!result.empty()) + return result; + result = intersect(s1, s3); + if (!result.empty()) + return result; + return intersect(s2, s3); +} + +static std::string intersect(const std::set &s1, + const std::set &s2, + const std::set &s3, + const std::set &s4) +{ + std::string result; + result = intersect(s1, s2); + if (!result.empty()) + return result; + result = intersect(s1, s3); + if (!result.empty()) + return result; + result = intersect(s1, s4); + if (!result.empty()) + return result; + return intersect(s2, s3, s4); +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::CheckPropertyCompatibility( + cmComputeLinkInformation *info, const std::string& config) const +{ + const cmComputeLinkInformation::ItemVector &deps = info->GetItems(); + + std::set emittedBools; + static std::string strBool = "COMPATIBLE_INTERFACE_BOOL"; + std::set emittedStrings; + static std::string strString = "COMPATIBLE_INTERFACE_STRING"; + std::set emittedMinNumbers; + static std::string strNumMin = "COMPATIBLE_INTERFACE_NUMBER_MIN"; + std::set emittedMaxNumbers; + static std::string strNumMax = "COMPATIBLE_INTERFACE_NUMBER_MAX"; + + for(cmComputeLinkInformation::ItemVector::const_iterator li = + deps.begin(); li != deps.end(); ++li) + { + if (!li->Target) + { + continue; + } + + checkPropertyConsistency(this->Target, li->Target, + strBool, + emittedBools, config, cmTarget::BoolType, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + checkPropertyConsistency(this->Target, li->Target, + strString, + emittedStrings, config, + cmTarget::StringType, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + checkPropertyConsistency(this->Target, li->Target, + strNumMin, + emittedMinNumbers, config, + cmTarget::NumberMinType, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + checkPropertyConsistency(this->Target, li->Target, + strNumMax, + emittedMaxNumbers, config, + cmTarget::NumberMaxType, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + } + + std::string prop = intersect(emittedBools, + emittedStrings, + emittedMinNumbers, + emittedMaxNumbers); + + if (!prop.empty()) + { + // Use a sorted std::vector to keep the error message sorted. + std::vector props; + std::set::const_iterator i = emittedBools.find(prop); + if (i != emittedBools.end()) + { + props.push_back(strBool); + } + i = emittedStrings.find(prop); + if (i != emittedStrings.end()) + { + props.push_back(strString); + } + i = emittedMinNumbers.find(prop); + if (i != emittedMinNumbers.end()) + { + props.push_back(strNumMin); + } + i = emittedMaxNumbers.find(prop); + if (i != emittedMaxNumbers.end()) + { + props.push_back(strNumMax); + } + std::sort(props.begin(), props.end()); + + std::string propsString = cmJoin(cmMakeRange(props).retreat(1), ", "); + propsString += " and the " + props.back(); + + std::ostringstream e; + e << "Property \"" << prop << "\" appears in both the " + << propsString << + " property in the dependencies of target \"" << this->GetName() << + "\". This is not allowed. A property may only require compatibility " + "in a boolean interpretation, a numeric minimum, a numeric maximum or a " + "string interpretation, but not a mixture."; + this->LocalGenerator->IssueMessage(cmake::FATAL_ERROR, e.str()); + } +} //---------------------------------------------------------------------------- cmComputeLinkInformation* @@ -1550,7 +1784,7 @@ cmGeneratorTarget::GetLinkInformation(const std::string& config) const if (info) { - this->Target->CheckPropertyCompatibility(info, config); + this->CheckPropertyCompatibility(info, config); } } return i->second; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index e53f098..ae86e19 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -222,6 +222,9 @@ private: cmTargetLinkInformationMap; mutable cmTargetLinkInformationMap LinkInformation; + void CheckPropertyCompatibility(cmComputeLinkInformation *info, + const std::string& config) const; + cmGeneratorTarget(cmGeneratorTarget const&); void operator=(cmGeneratorTarget const&); }; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index d8904ea..b165545 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4554,23 +4554,16 @@ const char *getTypedProperty(cmTarget const* tgt, return tgt->GetProperty(prop); } -enum CompatibleType -{ - BoolType, - StringType, - NumberMinType, - NumberMaxType -}; - //---------------------------------------------------------------------------- template std::pair consistentProperty(PropertyType lhs, PropertyType rhs, - CompatibleType t); + cmTarget::CompatibleType t); //---------------------------------------------------------------------------- template<> -std::pair consistentProperty(bool lhs, bool rhs, CompatibleType) +std::pair consistentProperty(bool lhs, bool rhs, + cmTarget::CompatibleType) { return std::make_pair(lhs == rhs, lhs); } @@ -4585,8 +4578,8 @@ std::pair consistentStringProperty(const char *lhs, //---------------------------------------------------------------------------- std::pair consistentNumberProperty(const char *lhs, - const char *rhs, - CompatibleType t) + const char *rhs, + cmTarget::CompatibleType t) { char *pEnd; @@ -4604,7 +4597,7 @@ std::pair consistentNumberProperty(const char *lhs, return std::pair(false, null_ptr); } - if (t == NumberMaxType) + if (t == cmTarget::NumberMaxType) { return std::make_pair(true, std::max(lnum, rnum) == lnum ? lhs : rhs); } @@ -4618,7 +4611,7 @@ std::pair consistentNumberProperty(const char *lhs, template<> std::pair consistentProperty(const char *lhs, const char *rhs, - CompatibleType t) + cmTarget::CompatibleType t) { if (!lhs && !rhs) { @@ -4637,13 +4630,13 @@ std::pair consistentProperty(const char *lhs, switch(t) { - case BoolType: + case cmTarget::BoolType: assert(0 && "consistentProperty for strings called with BoolType"); return std::pair(false, null_ptr); - case StringType: + case cmTarget::StringType: return consistentStringProperty(lhs, rhs); - case NumberMinType: - case NumberMaxType: + case cmTarget::NumberMinType: + case cmTarget::NumberMaxType: return consistentNumberProperty(lhs, rhs, t); } assert(0 && "Unreachable!"); @@ -4718,17 +4711,17 @@ cmTarget::ReportPropertyOrigin(const std::string &p, } //---------------------------------------------------------------------------- -std::string compatibilityType(CompatibleType t) +std::string compatibilityType(cmTarget::CompatibleType t) { switch(t) { - case BoolType: + case cmTarget::BoolType: return "Boolean compatibility"; - case StringType: + case cmTarget::StringType: return "String compatibility"; - case NumberMaxType: + case cmTarget::NumberMaxType: return "Numeric maximum compatibility"; - case NumberMinType: + case cmTarget::NumberMinType: return "Numeric minimum compatibility"; } assert(0 && "Unreachable!"); @@ -4736,15 +4729,15 @@ std::string compatibilityType(CompatibleType t) } //---------------------------------------------------------------------------- -std::string compatibilityAgree(CompatibleType t, bool dominant) +std::string compatibilityAgree(cmTarget::CompatibleType t, bool dominant) { switch(t) { - case BoolType: - case StringType: + case cmTarget::BoolType: + case cmTarget::StringType: return dominant ? "(Disagree)\n" : "(Agree)\n"; - case NumberMaxType: - case NumberMinType: + case cmTarget::NumberMaxType: + case cmTarget::NumberMinType: return dominant ? "(Dominant)\n" : "(Ignored)\n"; } assert(0 && "Unreachable!"); @@ -4757,7 +4750,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, const std::string &p, const std::string& config, const char *defaultValue, - CompatibleType t, + cmTarget::CompatibleType t, PropertyType *) { PropertyType propContent = getTypedProperty(tgt, p); @@ -6224,240 +6217,6 @@ std::string cmTarget::CheckCMP0004(std::string const& item) const return lib; } -template -PropertyType getLinkInterfaceDependentProperty(cmTarget const* tgt, - const std::string& prop, - const std::string& config, - CompatibleType, - PropertyType *); - -template<> -bool getLinkInterfaceDependentProperty(cmTarget const* tgt, - const std::string& prop, - const std::string& config, - CompatibleType, bool *) -{ - return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); -} - -template<> -const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, - const std::string& prop, - const std::string& config, - CompatibleType t, - const char **) -{ - switch(t) - { - case BoolType: - assert(0 && "String compatibility check function called for boolean"); - return 0; - case StringType: - return tgt->GetLinkInterfaceDependentStringProperty(prop, config); - case NumberMinType: - return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config); - case NumberMaxType: - return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config); - } - assert(0 && "Unreachable!"); - return 0; -} - -//---------------------------------------------------------------------------- -template -void checkPropertyConsistency(cmTarget const* depender, - cmTarget const* dependee, - const std::string& propName, - std::set &emitted, - const std::string& config, - CompatibleType t, - PropertyType *) -{ - const char *prop = dependee->GetProperty(propName); - if (!prop) - { - return; - } - - std::vector props; - cmSystemTools::ExpandListArgument(prop, props); - std::string pdir = - dependee->GetMakefile()->GetRequiredDefinition("CMAKE_ROOT"); - pdir += "/Help/prop_tgt/"; - - for(std::vector::iterator pi = props.begin(); - pi != props.end(); ++pi) - { - std::string pname = cmSystemTools::HelpFileName(*pi); - std::string pfile = pdir + pname + ".rst"; - if(cmSystemTools::FileExists(pfile.c_str(), true)) - { - std::ostringstream e; - e << "Target \"" << dependee->GetName() << "\" has property \"" - << *pi << "\" listed in its " << propName << " property. " - "This is not allowed. Only user-defined properties may appear " - "listed in the " << propName << " property."; - depender->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, e.str()); - return; - } - if(emitted.insert(*pi).second) - { - getLinkInterfaceDependentProperty(depender, *pi, config, - t, 0); - if (cmSystemTools::GetErrorOccuredFlag()) - { - return; - } - } - } -} - -static std::string intersect(const std::set &s1, - const std::set &s2) -{ - std::set intersect; - std::set_intersection(s1.begin(),s1.end(), - s2.begin(),s2.end(), - std::inserter(intersect,intersect.begin())); - if (!intersect.empty()) - { - return *intersect.begin(); - } - return ""; -} -static std::string intersect(const std::set &s1, - const std::set &s2, - const std::set &s3) -{ - std::string result; - result = intersect(s1, s2); - if (!result.empty()) - return result; - result = intersect(s1, s3); - if (!result.empty()) - return result; - return intersect(s2, s3); -} -static std::string intersect(const std::set &s1, - const std::set &s2, - const std::set &s3, - const std::set &s4) -{ - std::string result; - result = intersect(s1, s2); - if (!result.empty()) - return result; - result = intersect(s1, s3); - if (!result.empty()) - return result; - result = intersect(s1, s4); - if (!result.empty()) - return result; - return intersect(s2, s3, s4); -} - -//---------------------------------------------------------------------------- -void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, - const std::string& config) const -{ - const cmComputeLinkInformation::ItemVector &deps = info->GetItems(); - - std::set emittedBools; - static std::string strBool = "COMPATIBLE_INTERFACE_BOOL"; - std::set emittedStrings; - static std::string strString = "COMPATIBLE_INTERFACE_STRING"; - std::set emittedMinNumbers; - static std::string strNumMin = "COMPATIBLE_INTERFACE_NUMBER_MIN"; - std::set emittedMaxNumbers; - static std::string strNumMax = "COMPATIBLE_INTERFACE_NUMBER_MAX"; - - for(cmComputeLinkInformation::ItemVector::const_iterator li = - deps.begin(); - li != deps.end(); ++li) - { - if (!li->Target) - { - continue; - } - - checkPropertyConsistency(this, li->Target, - strBool, - emittedBools, config, BoolType, 0); - if (cmSystemTools::GetErrorOccuredFlag()) - { - return; - } - checkPropertyConsistency(this, li->Target, - strString, - emittedStrings, config, - StringType, 0); - if (cmSystemTools::GetErrorOccuredFlag()) - { - return; - } - checkPropertyConsistency(this, li->Target, - strNumMin, - emittedMinNumbers, config, - NumberMinType, 0); - if (cmSystemTools::GetErrorOccuredFlag()) - { - return; - } - checkPropertyConsistency(this, li->Target, - strNumMax, - emittedMaxNumbers, config, - NumberMaxType, 0); - if (cmSystemTools::GetErrorOccuredFlag()) - { - return; - } - } - - std::string prop = intersect(emittedBools, - emittedStrings, - emittedMinNumbers, - emittedMaxNumbers); - - if (!prop.empty()) - { - // Use a sorted std::vector to keep the error message sorted. - std::vector props; - std::set::const_iterator i = emittedBools.find(prop); - if (i != emittedBools.end()) - { - props.push_back(strBool); - } - i = emittedStrings.find(prop); - if (i != emittedStrings.end()) - { - props.push_back(strString); - } - i = emittedMinNumbers.find(prop); - if (i != emittedMinNumbers.end()) - { - props.push_back(strNumMin); - } - i = emittedMaxNumbers.find(prop); - if (i != emittedMaxNumbers.end()) - { - props.push_back(strNumMax); - } - std::sort(props.begin(), props.end()); - - std::string propsString = cmJoin(cmMakeRange(props).retreat(1), ", "); - propsString += " and the " + props.back(); - - std::ostringstream e; - e << "Property \"" << prop << "\" appears in both the " - << propsString << - " property in the dependencies of target \"" << this->GetName() << - "\". This is not allowed. A property may only require compatibility " - "in a boolean interpretation, a numeric minimum, a numeric maximum or a " - "string interpretation, but not a mixture."; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); - } -} - //---------------------------------------------------------------------------- std::string cmTarget::GetFrameworkDirectory(const std::string& config, bool rootDir) const diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e3410aa..8af74ef 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -590,6 +590,14 @@ public: return this->LinkLibrariesForVS6;} #endif + enum CompatibleType + { + BoolType, + StringType, + NumberMinType, + NumberMaxType + }; + private: bool HandleLocationPropertyPolicy(cmMakefile* context) const; @@ -754,9 +762,6 @@ private: struct CompileInfo; CompileInfo const* GetCompileInfo(const std::string& config) const; - void CheckPropertyCompatibility(cmComputeLinkInformation *info, - const std::string& config) const; - LinkInterface const* GetImportLinkInterface(const std::string& config, cmTarget const* head, bool usage_requirements_only) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=25053a1b5691b774e4fe800f4bca97aeecbc9547 commit 25053a1b5691b774e4fe800f4bca97aeecbc9547 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:42 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 4 19:19:42 2015 +0200 cmGeneratorTarget: Move GetLinkInformation from cmTarget diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 26ca375..4840e89 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -276,7 +276,8 @@ std::string cmCommonTargetGenerator::GetFrameworkFlags(std::string const& l) std::string flags; const char* cfg = this->LocalGenerator->GetConfigName().c_str(); - if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(cfg)) + if(cmComputeLinkInformation* cli = + this->GeneratorTarget->GetLinkInformation(cfg)) { std::vector const& frameworks = cli->GetFrameworkPaths(); for(std::vector::const_iterator i = frameworks.begin(); @@ -384,7 +385,7 @@ cmCommonTargetGenerator::GetLinkedTargetDirectories() const std::vector dirs; std::set emitted; if (cmComputeLinkInformation* cli = - this->Target->GetLinkInformation(this->ConfigName)) + this->GeneratorTarget->GetLinkInformation(this->ConfigName)) { cmComputeLinkInformation::ItemVector const& items = cli->GetItems(); for(cmComputeLinkInformation::ItemVector::const_iterator diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index a5050ff..8a2cf4b 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -529,7 +529,7 @@ void getCompatibleInterfaceProperties(cmGeneratorTarget *target, std::set &ifaceProperties, const std::string& config) { - cmComputeLinkInformation *info = target->Target->GetLinkInformation(config); + cmComputeLinkInformation *info = target->GetLinkInformation(config); if (!info) { diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 3dbeff2..845c052 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -229,6 +229,12 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) this->GlobalGenerator = this->Makefile->GetGlobalGenerator(); } +cmGeneratorTarget::~cmGeneratorTarget() +{ + cmDeleteAll(this->LinkInformation); + this->LinkInformation.clear(); +} + cmLocalGenerator* cmGeneratorTarget::GetLocalGenerator() const { return this->LocalGenerator; @@ -1517,3 +1523,35 @@ bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty( } return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0; } + + +//---------------------------------------------------------------------------- +cmComputeLinkInformation* +cmGeneratorTarget::GetLinkInformation(const std::string& config) const +{ + // Lookup any existing information for this configuration. + std::string key(cmSystemTools::UpperCase(config)); + cmTargetLinkInformationMap::iterator + i = this->LinkInformation.find(key); + if(i == this->LinkInformation.end()) + { + // Compute information for this configuration. + cmComputeLinkInformation* info = + new cmComputeLinkInformation(this->Target, config); + if(!info || !info->Compute()) + { + delete info; + info = 0; + } + + // Store the information for this configuration. + cmTargetLinkInformationMap::value_type entry(key, info); + i = this->LinkInformation.insert(entry).first; + + if (info) + { + this->Target->CheckPropertyCompatibility(info, config); + } + } + return i->second; +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 3b32bf5..e53f098 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -20,11 +20,13 @@ class cmLocalGenerator; class cmMakefile; class cmSourceFile; class cmTarget; +class cmComputeLinkInformation; class cmGeneratorTarget { public: cmGeneratorTarget(cmTarget*, cmLocalGenerator* lg); + ~cmGeneratorTarget(); cmLocalGenerator* GetLocalGenerator() const; @@ -36,6 +38,9 @@ public: location is suitable for use as the LOCATION target property. */ const char* GetLocationForBuild() const; + cmComputeLinkInformation* + GetLinkInformation(const std::string& config) const; + int GetType() const; std::string GetName() const; const char *GetProperty(const std::string& prop) const; @@ -213,6 +218,10 @@ private: }; mutable std::map CompatibleInterfacesMap; + typedef std::map + cmTargetLinkInformationMap; + mutable cmTargetLinkInformationMap LinkInformation; + cmGeneratorTarget(cmGeneratorTarget const&); void operator=(cmGeneratorTarget const&); }; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 8cb59f8..b44848c 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2202,7 +2202,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, } } // Add framework search paths needed for linking. - if(cmComputeLinkInformation* cli = target.GetLinkInformation(configName)) + if(cmComputeLinkInformation* cli = gtgt->GetLinkInformation(configName)) { std::vector const& fwDirs = cli->GetFrameworkPaths(); for(std::vector::const_iterator fdi = fwDirs.begin(); @@ -2358,7 +2358,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, this->CreateString(install_name_dir.c_str())); // Create the LD_RUNPATH_SEARCH_PATHS - cmComputeLinkInformation* pcli = target.GetLinkInformation(configName); + cmComputeLinkInformation* pcli = gtgt->GetLinkInformation(configName); if(pcli) { std::string search_paths; @@ -2964,7 +2964,8 @@ void cmGlobalXCodeGenerator } // Compute the link library and directory information. - cmComputeLinkInformation* pcli = cmtarget->GetLinkInformation(configName); + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(cmtarget); + cmComputeLinkInformation* pcli = gtgt->GetLinkInformation(configName); if(!pcli) { continue; diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 01d4b77..c64f9a3 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -18,6 +18,7 @@ #include "cmMakefile.h" #include "cmGeneratorTarget.h" #include "cmake.h" +#include "cmGeneratorTarget.h" #include @@ -557,8 +558,7 @@ cmInstallTargetGenerator // Build a map of build-tree install_name to install-tree install_name for // shared libraries linked to this target. std::map install_name_remap; - if(cmComputeLinkInformation* cli = - this->Target->Target->GetLinkInformation(config)) + if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config)) { std::set const& sharedLibs = cli->GetSharedLibrariesLinked(); @@ -667,8 +667,7 @@ cmInstallTargetGenerator // Get the link information for this target. // It can provide the RPATH. - cmComputeLinkInformation* cli = - this->Target->Target->GetLinkInformation(config); + cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config); if(!cli) { return; @@ -700,8 +699,7 @@ cmInstallTargetGenerator // Get the link information for this target. // It can provide the RPATH. - cmComputeLinkInformation* cli = - this->Target->Target->GetLinkInformation(config); + cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config); if(!cli) { return; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 6b48a44..eaf812f 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1468,7 +1468,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, bool escapeAllowMakeVars = !forResponseFile; std::ostringstream fout; std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); - cmComputeLinkInformation* pcli = tgt.Target->GetLinkInformation(config); + cmComputeLinkInformation* pcli = tgt.GetLinkInformation(config); if(!pcli) { return; diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index cab5a47..61d7847 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1846,8 +1846,10 @@ void cmLocalVisualStudio6Generator const std::string extraOptions, std::string& options) { + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); // Compute the link information for this configuration. - cmComputeLinkInformation* pcli = target.GetLinkInformation(configName); + cmComputeLinkInformation* pcli = gt->GetLinkInformation(configName); if(!pcli) { return; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 572dbde..37e08dd 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1074,6 +1074,9 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, this->ConvertToOutputFormat(this->ModuleDefinitionFile, SHELL); linkOptions.AddFlag("ModuleDefinitionFile", defFile.c_str()); } + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); + if (target.GetType() == cmTarget::SHARED_LIBRARY && this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) { @@ -1148,7 +1151,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, targetNameImport, targetNamePDB, configName); // Compute the link library and directory information. - cmComputeLinkInformation* pcli = target.GetLinkInformation(configName); + cmComputeLinkInformation* pcli = gt->GetLinkInformation(configName); if(!pcli) { return; @@ -1245,7 +1248,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, targetNameImport, targetNamePDB, configName); // Compute the link library and directory information. - cmComputeLinkInformation* pcli = target.GetLinkInformation(configName); + cmComputeLinkInformation* pcli = gt->GetLinkInformation(configName); if(!pcli) { return; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 5edc0f5..ac8cd29 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1446,7 +1446,8 @@ void cmMakefileTargetGenerator // Loop over all library dependencies. const char* cfg = this->LocalGenerator->GetConfigName().c_str(); - if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(cfg)) + if(cmComputeLinkInformation* cli = + this->GeneratorTarget->GetLinkInformation(cfg)) { std::vector const& libDeps = cli->GetDepends(); depends.insert(depends.end(), libDeps.begin(), libDeps.end()); diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 4e4dc3f..cf80424 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -195,7 +195,7 @@ cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const return cmNinjaDeps(); cmComputeLinkInformation* cli = - this->Target->GetLinkInformation(this->GetConfigName()); + this->GeneratorTarget->GetLinkInformation(this->GetConfigName()); if(!cli) return cmNinjaDeps(); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 9c7e46a..d8904ea 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -520,8 +520,6 @@ void cmTarget::ClearLinkMaps() this->Internal->LinkInterfaceUsageRequirementsOnlyMap.clear(); this->Internal->LinkClosureMap.clear(); this->Internal->SourceFilesMap.clear(); - cmDeleteAll(this->LinkInformation); - this->LinkInformation.clear(); } //---------------------------------------------------------------------------- @@ -6461,37 +6459,6 @@ void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, } //---------------------------------------------------------------------------- -cmComputeLinkInformation* -cmTarget::GetLinkInformation(const std::string& config) const -{ - // Lookup any existing information for this configuration. - std::string key(cmSystemTools::UpperCase(config)); - cmTargetLinkInformationMap::iterator - i = this->LinkInformation.find(key); - if(i == this->LinkInformation.end()) - { - // Compute information for this configuration. - cmComputeLinkInformation* info = - new cmComputeLinkInformation(this, config); - if(!info || !info->Compute()) - { - delete info; - info = 0; - } - - // Store the information for this configuration. - cmTargetLinkInformationMap::value_type entry(key, info); - i = this->LinkInformation.insert(entry).first; - - if (info) - { - this->CheckPropertyCompatibility(info, config); - } - } - return i->second; -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetFrameworkDirectory(const std::string& config, bool rootDir) const { @@ -6583,26 +6550,6 @@ std::string cmTarget::GetMacContentDirectory(const std::string& config, } //---------------------------------------------------------------------------- -cmTargetLinkInformationMap -::cmTargetLinkInformationMap(cmTargetLinkInformationMap const& r): derived() -{ - // Ideally cmTarget instances should never be copied. However until - // we can make a sweep to remove that, this copy constructor avoids - // allowing the resources (LinkInformation) from getting copied. In - // the worst case this will lead to extra cmComputeLinkInformation - // instances. We also enforce in debug mode that the map be emptied - // when copied. - static_cast(r); - assert(r.empty()); -} - -//---------------------------------------------------------------------------- -cmTargetLinkInformationMap::~cmTargetLinkInformationMap() -{ - cmDeleteAll(*this); -} - -//---------------------------------------------------------------------------- cmTargetInternalPointer::cmTargetInternalPointer() { this->Pointer = new cmTargetInternals; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index df8cdc1..e3410aa 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -78,15 +78,6 @@ public: bool FromGenex; }; -struct cmTargetLinkInformationMap: - public std::map -{ - typedef std::map derived; - cmTargetLinkInformationMap() {} - cmTargetLinkInformationMap(cmTargetLinkInformationMap const& r); - ~cmTargetLinkInformationMap(); -}; - class cmTargetInternals; class cmTargetInternalPointer { @@ -454,9 +445,6 @@ public: * install tree. For example: "\@rpath/" or "\@loader_path/". */ std::string GetInstallNameDirForInstallTree() const; - cmComputeLinkInformation* - GetLinkInformation(const std::string& config) const; - // Get the properties cmPropertyMap &GetProperties() const { return this->Properties; } @@ -766,7 +754,6 @@ private: struct CompileInfo; CompileInfo const* GetCompileInfo(const std::string& config) const; - mutable cmTargetLinkInformationMap LinkInformation; void CheckPropertyCompatibility(cmComputeLinkInformation *info, const std::string& config) const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 71785e9..f3f291a 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2438,7 +2438,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) cmSystemTools::ExpandListArgument(libs, libVec); cmComputeLinkInformation* pcli = - this->Target->GetLinkInformation(config.c_str()); + this->GeneratorTarget->GetLinkInformation(config.c_str()); if(!pcli) { cmSystemTools::Error http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9ab2eb2d622ad18cb027ada68ba95d4b5817ac30 commit 9ab2eb2d622ad18cb027ada68ba95d4b5817ac30 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:42 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 4 19:19:42 2015 +0200 Export: Port more API to cmGeneratorTarget. diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 355fc00..6274c3f 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -27,6 +27,7 @@ cmExportBuildFileGenerator::cmExportBuildFileGenerator() //---------------------------------------------------------------------------- bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) { + std::vector allTargets; { std::string expectedTargets; std::string sep; @@ -68,7 +69,8 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) tei = this->Exports.begin(); tei != this->Exports.end(); ++tei) { - cmTarget* te = (*tei)->Target; + cmGeneratorTarget* gte = *tei; + cmTarget* te = gte->Target; this->GenerateImportTargetCode(os, te); te->AppendBuildInterfaceIncludes(); @@ -104,7 +106,7 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) cmGeneratorExpression::BuildInterface, properties, missingTargets); } - this->PopulateCompatibleInterfaceProperties(te, properties); + this->PopulateCompatibleInterfaceProperties(gte, properties); this->GenerateInterfaceProperties(te, os, properties); } diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 3aa2b65..a5050ff 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -525,15 +525,15 @@ void getPropertyContents(cmTarget const* tgt, const std::string& prop, } //---------------------------------------------------------------------------- -void getCompatibleInterfaceProperties(cmTarget *target, +void getCompatibleInterfaceProperties(cmGeneratorTarget *target, std::set &ifaceProperties, const std::string& config) { - cmComputeLinkInformation *info = target->GetLinkInformation(config); + cmComputeLinkInformation *info = target->Target->GetLinkInformation(config); if (!info) { - cmMakefile* mf = target->GetMakefile(); + cmMakefile* mf = target->Target->GetMakefile(); std::ostringstream e; e << "Exporting the target \"" << target->GetName() << "\" is not " "allowed since its linker language cannot be determined"; @@ -568,9 +568,10 @@ void getCompatibleInterfaceProperties(cmTarget *target, //---------------------------------------------------------------------------- void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( - cmTarget *target, + cmGeneratorTarget *gtarget, ImportPropertyMap &properties) { + cmTarget *target = gtarget->Target; this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_BOOL", target, properties); this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_STRING", @@ -591,7 +592,7 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( if (target->GetType() != cmTarget::INTERFACE_LIBRARY) { - getCompatibleInterfaceProperties(target, ifaceProperties, ""); + getCompatibleInterfaceProperties(gtarget, ifaceProperties, ""); std::vector configNames; target->GetMakefile()->GetConfigurations(configNames); @@ -599,7 +600,7 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( for (std::vector::const_iterator ci = configNames.begin(); ci != configNames.end(); ++ci) { - getCompatibleInterfaceProperties(target, ifaceProperties, *ci); + getCompatibleInterfaceProperties(gtarget, ifaceProperties, *ci); } } diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index 2f33200..4e54740 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -132,7 +132,7 @@ protected: std::vector &missingTargets); void PopulateInterfaceProperty(const std::string& propName, cmTarget *target, ImportPropertyMap &properties); - void PopulateCompatibleInterfaceProperties(cmTarget *target, + void PopulateCompatibleInterfaceProperties(cmGeneratorTarget *target, ImportPropertyMap &properties); void GenerateInterfaceProperties(cmTarget const* target, std::ostream& os, const ImportPropertyMap &properties); diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index c88b7b2..b0bc686 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -193,7 +193,11 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE", te, properties); - this->PopulateCompatibleInterfaceProperties(te, properties); + cmGeneratorTarget *gtgt = te->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(te); + + this->PopulateCompatibleInterfaceProperties(gtgt, properties); this->GenerateInterfaceProperties(te, os, properties); } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=11bce89dc927b7928dafb24989d437f03bd41f54 commit 11bce89dc927b7928dafb24989d437f03bd41f54 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:42 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 4 19:19:42 2015 +0200 cmGeneratorTarget: Move IsLinkInterfaceDependent* from cmTarget. diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index c0485db..c1641cc 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1128,6 +1128,9 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode } } + cmGeneratorTarget* gtgt = + context->Makefile->GetGlobalGenerator()->GetGeneratorTarget(target); + if (!prop) { if (target->IsImported() @@ -1135,16 +1138,16 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { return linkedTargetsContent; } - if (target->IsLinkInterfaceDependentBoolProperty(propertyName, - context->Config)) + if (gtgt->IsLinkInterfaceDependentBoolProperty(propertyName, + context->Config)) { context->HadContextSensitiveCondition = true; return target->GetLinkInterfaceDependentBoolProperty( propertyName, context->Config) ? "1" : "0"; } - if (target->IsLinkInterfaceDependentStringProperty(propertyName, - context->Config)) + if (gtgt->IsLinkInterfaceDependentStringProperty(propertyName, + context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = @@ -1153,8 +1156,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode context->Config); return propContent ? propContent : ""; } - if (target->IsLinkInterfaceDependentNumberMinProperty(propertyName, - context->Config)) + if (gtgt->IsLinkInterfaceDependentNumberMinProperty(propertyName, + context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = @@ -1163,8 +1166,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode context->Config); return propContent ? propContent : ""; } - if (target->IsLinkInterfaceDependentNumberMaxProperty(propertyName, - context->Config)) + if (gtgt->IsLinkInterfaceDependentNumberMaxProperty(propertyName, + context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = @@ -1180,8 +1183,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode if (!target->IsImported() && dagCheckerParent && !dagCheckerParent->EvaluatingLinkLibraries()) { - if (target->IsLinkInterfaceDependentNumberMinProperty(propertyName, - context->Config)) + if (gtgt->IsLinkInterfaceDependentNumberMinProperty(propertyName, + context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = @@ -1190,8 +1193,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode context->Config); return propContent ? propContent : ""; } - if (target->IsLinkInterfaceDependentNumberMaxProperty(propertyName, - context->Config)) + if (gtgt->IsLinkInterfaceDependentNumberMaxProperty(propertyName, + context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 95f6aaa..3dbeff2 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1436,3 +1436,84 @@ void cmGeneratorTarget::ConstructSourceFileFlags() const } } } + +//---------------------------------------------------------------------------- +const cmGeneratorTarget::CompatibleInterfacesBase& +cmGeneratorTarget::GetCompatibleInterfaces(std::string const& config) const +{ + cmGeneratorTarget::CompatibleInterfaces& compat = + this->CompatibleInterfacesMap[config]; + if(!compat.Done) + { + compat.Done = true; + compat.PropsBool.insert("POSITION_INDEPENDENT_CODE"); + compat.PropsString.insert("AUTOUIC_OPTIONS"); + std::vector const& deps = + this->Target->GetLinkImplementationClosure(config); + for(std::vector::const_iterator li = deps.begin(); + li != deps.end(); ++li) + { +#define CM_READ_COMPATIBLE_INTERFACE(X, x) \ + if(const char* prop = (*li)->GetProperty("COMPATIBLE_INTERFACE_" #X)) \ + { \ + std::vector props; \ + cmSystemTools::ExpandListArgument(prop, props); \ + compat.Props##x.insert(props.begin(), props.end()); \ + } + CM_READ_COMPATIBLE_INTERFACE(BOOL, Bool) + CM_READ_COMPATIBLE_INTERFACE(STRING, String) + CM_READ_COMPATIBLE_INTERFACE(NUMBER_MIN, NumberMin) + CM_READ_COMPATIBLE_INTERFACE(NUMBER_MAX, NumberMax) +#undef CM_READ_COMPATIBLE_INTERFACE + } + } + return compat; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsLinkInterfaceDependentBoolProperty( + const std::string &p, const std::string& config) const +{ + if (this->Target->GetType() == cmTarget::OBJECT_LIBRARY + || this->Target->GetType() == cmTarget::INTERFACE_LIBRARY) + { + return false; + } + return this->GetCompatibleInterfaces(config).PropsBool.count(p) > 0; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsLinkInterfaceDependentStringProperty( + const std::string &p, const std::string& config) const +{ + if (this->Target->GetType() == cmTarget::OBJECT_LIBRARY + || this->Target->GetType() == cmTarget::INTERFACE_LIBRARY) + { + return false; + } + return this->GetCompatibleInterfaces(config).PropsString.count(p) > 0; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMinProperty( + const std::string &p, const std::string& config) const +{ + if (this->Target->GetType() == cmTarget::OBJECT_LIBRARY + || this->Target->GetType() == cmTarget::INTERFACE_LIBRARY) + { + return false; + } + return this->GetCompatibleInterfaces(config).PropsNumberMin.count(p) > 0; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty( + const std::string &p, const std::string& config) const +{ + if (this->Target->GetType() == cmTarget::OBJECT_LIBRARY + || this->Target->GetType() == cmTarget::INTERFACE_LIBRARY) + { + return false; + } + return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0; +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 3e43711..3b32bf5 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -82,6 +82,15 @@ public: bool GetFeatureAsBool(const std::string& feature, const std::string& config) const; + bool IsLinkInterfaceDependentBoolProperty(const std::string &p, + const std::string& config) const; + bool IsLinkInterfaceDependentStringProperty(const std::string &p, + const std::string& config) const; + bool IsLinkInterfaceDependentNumberMinProperty(const std::string &p, + const std::string& config) const; + bool IsLinkInterfaceDependentNumberMaxProperty(const std::string &p, + const std::string& config) const; + /** Get the full path to the target according to the settings in its makefile and the configuration type. */ std::string GetFullPath(const std::string& config="", bool implib = false, @@ -187,6 +196,23 @@ private: mutable bool SourceFileFlagsConstructed; mutable std::map SourceFlagsMap; + struct CompatibleInterfacesBase + { + std::set PropsBool; + std::set PropsString; + std::set PropsNumberMax; + std::set PropsNumberMin; + }; + CompatibleInterfacesBase const& + GetCompatibleInterfaces(std::string const& config) const; + + struct CompatibleInterfaces: public CompatibleInterfacesBase + { + CompatibleInterfaces(): Done(false) {} + bool Done; + }; + mutable std::map CompatibleInterfacesMap; + cmGeneratorTarget(cmGeneratorTarget const&); void operator=(cmGeneratorTarget const&); }; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 3074f9b..9c7e46a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -170,13 +170,6 @@ public: }; std::map LinkImplClosureMap; - struct CompatibleInterfaces: public cmTarget::CompatibleInterfaces - { - CompatibleInterfaces(): Done(false) {} - bool Done; - }; - std::map CompatibleInterfacesMap; - typedef std::map > SourceFilesMapType; SourceFilesMapType SourceFilesMap; @@ -4991,54 +4984,6 @@ const char * cmTarget::GetLinkInterfaceDependentNumberMaxProperty( } //---------------------------------------------------------------------------- -bool cmTarget::IsLinkInterfaceDependentBoolProperty(const std::string &p, - const std::string& config) const -{ - if (this->TargetTypeValue == OBJECT_LIBRARY - || this->TargetTypeValue == INTERFACE_LIBRARY) - { - return false; - } - return this->GetCompatibleInterfaces(config).PropsBool.count(p) > 0; -} - -//---------------------------------------------------------------------------- -bool cmTarget::IsLinkInterfaceDependentStringProperty(const std::string &p, - const std::string& config) const -{ - if (this->TargetTypeValue == OBJECT_LIBRARY - || this->TargetTypeValue == INTERFACE_LIBRARY) - { - return false; - } - return this->GetCompatibleInterfaces(config).PropsString.count(p) > 0; -} - -//---------------------------------------------------------------------------- -bool cmTarget::IsLinkInterfaceDependentNumberMinProperty(const std::string &p, - const std::string& config) const -{ - if (this->TargetTypeValue == OBJECT_LIBRARY - || this->TargetTypeValue == INTERFACE_LIBRARY) - { - return false; - } - return this->GetCompatibleInterfaces(config).PropsNumberMin.count(p) > 0; -} - -//---------------------------------------------------------------------------- -bool cmTarget::IsLinkInterfaceDependentNumberMaxProperty(const std::string &p, - const std::string& config) const -{ - if (this->TargetTypeValue == OBJECT_LIBRARY - || this->TargetTypeValue == INTERFACE_LIBRARY) - { - return false; - } - return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0; -} - -//---------------------------------------------------------------------------- void cmTarget::GetObjectLibrariesCMP0026(std::vector& objlibs) const { @@ -5725,39 +5670,6 @@ cmTarget::GetLinkImplementationClosure(const std::string& config) const } //---------------------------------------------------------------------------- -cmTarget::CompatibleInterfaces const& -cmTarget::GetCompatibleInterfaces(std::string const& config) const -{ - cmTargetInternals::CompatibleInterfaces& compat = - this->Internal->CompatibleInterfacesMap[config]; - if(!compat.Done) - { - compat.Done = true; - compat.PropsBool.insert("POSITION_INDEPENDENT_CODE"); - compat.PropsString.insert("AUTOUIC_OPTIONS"); - std::vector const& deps = - this->GetLinkImplementationClosure(config); - for(std::vector::const_iterator li = deps.begin(); - li != deps.end(); ++li) - { -#define CM_READ_COMPATIBLE_INTERFACE(X, x) \ - if(const char* prop = (*li)->GetProperty("COMPATIBLE_INTERFACE_" #X)) \ - { \ - std::vector props; \ - cmSystemTools::ExpandListArgument(prop, props); \ - compat.Props##x.insert(props.begin(), props.end()); \ - } - CM_READ_COMPATIBLE_INTERFACE(BOOL, Bool) - CM_READ_COMPATIBLE_INTERFACE(STRING, String) - CM_READ_COMPATIBLE_INTERFACE(NUMBER_MIN, NumberMin) - CM_READ_COMPATIBLE_INTERFACE(NUMBER_MAX, NumberMax) -#undef CM_READ_COMPATIBLE_INTERFACE - } - } - return compat; -} - -//---------------------------------------------------------------------------- void cmTargetInternals::ComputeLinkInterfaceLibraries( cmTarget const* thisTarget, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index d5374a6..df8cdc1 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -305,16 +305,6 @@ public: std::vector const& GetLinkImplementationClosure(const std::string& config) const; - struct CompatibleInterfaces - { - std::set PropsBool; - std::set PropsString; - std::set PropsNumberMax; - std::set PropsNumberMin; - }; - CompatibleInterfaces const& - GetCompatibleInterfaces(std::string const& config) const; - /** The link implementation specifies the direct library dependencies needed by the object files of the target. */ struct LinkImplementationLibraries @@ -575,15 +565,6 @@ public: const std::string& config) const; bool IsNullImpliedByLinkLibraries(const std::string &p) const; - bool IsLinkInterfaceDependentBoolProperty(const std::string &p, - const std::string& config) const; - bool IsLinkInterfaceDependentStringProperty(const std::string &p, - const std::string& config) const; - bool IsLinkInterfaceDependentNumberMinProperty(const std::string &p, - const std::string& config) const; - bool IsLinkInterfaceDependentNumberMaxProperty(const std::string &p, - const std::string& config) const; - bool GetLinkInterfaceDependentBoolProperty(const std::string &p, const std::string& config) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f0a5a551cc64a0d6188f9a6ee1969348eb6e80c7 commit f0a5a551cc64a0d6188f9a6ee1969348eb6e80c7 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:41 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 4 19:19:41 2015 +0200 cmGeneratorTarget: Move GetAutoUicOptions from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index e17df9e..95f6aaa 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -743,6 +743,32 @@ cmGeneratorTarget::UseObjectLibraries(std::vector& objs, } //---------------------------------------------------------------------------- +void cmGeneratorTarget::GetAutoUicOptions(std::vector &result, + const std::string& config) const +{ + const char *prop + = this->Target-> + GetLinkInterfaceDependentStringProperty("AUTOUIC_OPTIONS", + config); + if (!prop) + { + return; + } + cmGeneratorExpression ge; + + cmGeneratorExpressionDAGChecker dagChecker( + this->GetName(), + "AUTOUIC_OPTIONS", 0, 0); + cmSystemTools::ExpandListArgument(ge.Parse(prop) + ->Evaluate(this->Makefile, + config, + false, + this->Target, + &dagChecker), + result); +} + +//---------------------------------------------------------------------------- class cmTargetTraceDependencies { public: diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 8e5c2ab..3e43711 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -156,6 +156,9 @@ public: SourceFileType Type; const char* MacFolder; // location inside Mac content folders }; + void GetAutoUicOptions(std::vector &result, + const std::string& config) const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; @@ -176,7 +179,6 @@ private: struct SourceEntry { std::vector Depends; }; typedef std::map SourceEntriesType; SourceEntriesType SourceEntries; - mutable std::map Objects; std::set ExplicitObjectName; mutable std::map > SystemIncludesCache; diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 1322dea..a72b176 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -878,8 +878,11 @@ void cmQtAutoGenerators::MergeUicOptions(std::vector &opts, static void GetUicOpts(cmTarget const* target, const std::string& config, std::string &optString) { + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); std::vector opts; - target->GetAutoUicOptions(opts, config); + gtgt->GetAutoUicOptions(opts, config); optString = cmJoin(opts, ";"); } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 54f9cf0..3074f9b 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2236,31 +2236,6 @@ static void processCompileOptions(cmTarget const* tgt, } //---------------------------------------------------------------------------- -void cmTarget::GetAutoUicOptions(std::vector &result, - const std::string& config) const -{ - const char *prop - = this->GetLinkInterfaceDependentStringProperty("AUTOUIC_OPTIONS", - config); - if (!prop) - { - return; - } - cmGeneratorExpression ge; - - cmGeneratorExpressionDAGChecker dagChecker( - this->GetName(), - "AUTOUIC_OPTIONS", 0, 0); - cmSystemTools::ExpandListArgument(ge.Parse(prop) - ->Evaluate(this->Makefile, - config, - false, - this, - &dagChecker), - result); -} - -//---------------------------------------------------------------------------- void cmTarget::GetCompileOptions(std::vector &result, const std::string& config, const std::string& language) const diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 389f9cd..d5374a6 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -571,8 +571,6 @@ public: void GetCompileOptions(std::vector &result, const std::string& config, const std::string& language) const; - void GetAutoUicOptions(std::vector &result, - const std::string& config) const; void GetCompileFeatures(std::vector &features, const std::string& config) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4085e2bde2a87b9526b2fdc2dfd4bd9329c367fd commit 4085e2bde2a87b9526b2fdc2dfd4bd9329c367fd Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:41 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 4 19:19:41 2015 +0200 cmGeneratorTarget: Move GetSOName from cmTarget.. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index e63b44f..5aaa266 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -756,15 +756,16 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, return; } + cmGeneratorTarget *gtgt = tgt->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(tgt); + // Get a full path to the dependent shared library. // Add it to the runtime path computation so that the target being // linked will be able to find it. std::string lib; if(tgt) { - cmGeneratorTarget *gtgt = tgt->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(tgt); lib = gtgt->GetFullPath(this->Config, this->UseImportLibrary); this->AddLibraryRuntimeInfo(lib, tgt); } @@ -792,7 +793,7 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, { if(tgt) { - std::string soName = tgt->GetSOName(this->Config); + std::string soName = gtgt->GetSOName(this->Config); const char* soname = soName.empty()? 0 : soName.c_str(); order->AddRuntimeLibrary(lib, soname); } @@ -1804,7 +1805,10 @@ cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath, // Try to get the soname of the library. Only files with this name // could possibly conflict. - std::string soName = target->GetSOName(this->Config); + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); + std::string soName = gtgt->GetSOName(this->Config); const char* soname = soName.empty()? 0 : soName.c_str(); // Include this library in the runtime path ordering. diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index a33cd59..3aa2b65 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -895,7 +895,7 @@ cmExportFileGenerator value = this->InstallNameDir(target->Target, config); } prop = "IMPORTED_SONAME"; - value += target->Target->GetSOName(config); + value += target->GetSOName(config); } else { diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index f3527ff..c0485db 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1584,7 +1584,7 @@ struct TargetFilesystemArtifactResultCreator } std::string result = target->Target->GetDirectory(context->Config); result += "/"; - result += target->Target->GetSOName(context->Config); + result += target->GetSOName(context->Config); return result; } }; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index bd57b3d..e17df9e 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -650,6 +650,49 @@ void cmGeneratorTarget::GetSourceFiles(std::vector &files, } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetSOName(const std::string& config) const +{ + if(this->Target->IsImported()) + { + // Lookup the imported soname. + if(cmTarget::ImportInfo const* info = this->Target->GetImportInfo(config)) + { + if(info->NoSOName) + { + // The imported library has no builtin soname so the name + // searched at runtime will be just the filename. + return cmSystemTools::GetFilenameName(info->Location); + } + else + { + // Use the soname given if any. + if(info->SOName.find("@rpath/") == 0) + { + return info->SOName.substr(6); + } + return info->SOName; + } + } + else + { + return ""; + } + } + else + { + // Compute the soname that will be built. + std::string name; + std::string soName; + std::string realName; + std::string impName; + std::string pdbName; + this->Target->GetLibraryNames(name, soName, realName, + impName, pdbName, config); + return soName; + } +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetModuleDefinitionFile(const std::string& config) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index a584c71..8e5c2ab 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -90,6 +90,9 @@ public: bool realname) const; std::string NormalGetRealName(const std::string& config) const; + /** Get the soname of the target. Allowed only for a shared library. */ + std::string GetSOName(const std::string& config) const; + cmTarget* Target; cmMakefile* Makefile; cmLocalGenerator* LocalGenerator; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 7dea107..8cb59f8 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2345,7 +2345,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, install_name += install_name_dir; install_name += "/"; } - install_name += target.GetSOName(configName); + install_name += gtgt->GetSOName(configName); if((realName != soName) || install_name_dir.empty()) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index cf33791..54f9cf0 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -69,21 +69,6 @@ struct cmTarget::OutputInfo }; //---------------------------------------------------------------------------- -struct cmTarget::ImportInfo -{ - ImportInfo(): NoSOName(false), Multiplicity(0) {} - bool NoSOName; - int Multiplicity; - std::string Location; - std::string SOName; - std::string ImportLibrary; - std::string Languages; - std::string Libraries; - std::string LibrariesProp; - std::string SharedDeps; -}; - -//---------------------------------------------------------------------------- struct cmTarget::CompileInfo { std::string CompilePdbDir; @@ -3602,48 +3587,6 @@ bool cmTarget::HasSOName(const std::string& config) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetSOName(const std::string& config) const -{ - if(this->IsImported()) - { - // Lookup the imported soname. - if(cmTarget::ImportInfo const* info = this->GetImportInfo(config)) - { - if(info->NoSOName) - { - // The imported library has no builtin soname so the name - // searched at runtime will be just the filename. - return cmSystemTools::GetFilenameName(info->Location); - } - else - { - // Use the soname given if any. - if(info->SOName.find("@rpath/") == 0) - { - return info->SOName.substr(6); - } - return info->SOName; - } - } - else - { - return ""; - } - } - else - { - // Compute the soname that will be built. - std::string name; - std::string soName; - std::string realName; - std::string impName; - std::string pdbName; - this->GetLibraryNames(name, soName, realName, impName, pdbName, config); - return soName; - } -} - -//---------------------------------------------------------------------------- bool cmTarget::HasMacOSXRpathInstallNameDir(const std::string& config) const { bool install_name_is_rpath = false; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index f567d50..389f9cd 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -411,9 +411,6 @@ public: /** Whether this library has soname enabled and platform supports it. */ bool HasSOName(const std::string& config) const; - /** Get the soname of the target. Allowed only for a shared library. */ - std::string GetSOName(const std::string& config) const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; @@ -768,7 +765,20 @@ private: std::string& out) const; // Cache import information from properties for each configuration. - struct ImportInfo; + struct ImportInfo + { + ImportInfo(): NoSOName(false), Multiplicity(0) {} + bool NoSOName; + int Multiplicity; + std::string Location; + std::string SOName; + std::string ImportLibrary; + std::string Languages; + std::string Libraries; + std::string LibrariesProp; + std::string SharedDeps; + }; + ImportInfo const* GetImportInfo(const std::string& config) const; void ComputeImportInfo(std::string const& desired_config, ImportInfo& info) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1aa13f2b58e477095f76d28a8d9bb1b83a9dd1f5 commit 1aa13f2b58e477095f76d28a8d9bb1b83a9dd1f5 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:41 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 4 19:19:41 2015 +0200 cmExportInstallFileGenerator: Simplify local generator access. diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 1d75f43..c88b7b2 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -358,7 +358,7 @@ cmExportInstallFileGenerator if(!properties.empty()) { // Get the rest of the target details. - cmGeneratorTarget *gtgt = te->Target->GetMakefile()->GetLocalGenerator() + cmGeneratorTarget *gtgt = te->Target->GetMakefile() ->GetGlobalGenerator()->GetGeneratorTarget(te->Target); this->SetImportDetailProperties(config, suffix, gtgt, properties, missingTargets); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1ab59f688f647abe1bc0b5e7a187ec0bac988e0f commit 1ab59f688f647abe1bc0b5e7a187ec0bac988e0f Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:40 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 4 19:19:40 2015 +0200 cmGlobalNinjaGenerator: Simplify usage of API. diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index d24cce8..5bdd35f 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -911,9 +911,7 @@ cmGlobalNinjaGenerator case cmTarget::STATIC_LIBRARY: case cmTarget::MODULE_LIBRARY: { - cmGeneratorTarget *gtgt = target->GetMakefile()->GetLocalGenerator() - ->GetGlobalGenerator() - ->GetGeneratorTarget(target); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(target); outputs.push_back(ng->ConvertToNinjaPath( gtgt->GetFullPath(configName, false, realname))); break; ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From gjasny at googlemail.com Tue Aug 4 16:47:09 2015 From: gjasny at googlemail.com (Gregor Jasny) Date: Tue, 4 Aug 2015 16:47:09 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1895-gc06c74f Message-ID: <20150804204709.D0C4FB102C@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via c06c74f32f5318789bd72ddb41cec9759d6a9339 (commit) via adecd54b8a3e357489c2492898a5594217e4db29 (commit) via c635339b0039d677100f7212ed02d8f0dc3f492d (commit) from e12067e28975b01aca849ee1d55656d3ba23c694 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c06c74f32f5318789bd72ddb41cec9759d6a9339 commit c06c74f32f5318789bd72ddb41cec9759d6a9339 Merge: e12067e adecd54 Author: Gregor Jasny AuthorDate: Tue Aug 4 16:47:05 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 4 16:47:05 2015 -0400 Merge topic 'fix-xcode-quoting' into next adecd54b Xcode: Invert quoting logic to whitelist of characters c635339b Xcode: quote more characters http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=adecd54b8a3e357489c2492898a5594217e4db29 commit adecd54b8a3e357489c2492898a5594217e4db29 Author: Gregor Jasny AuthorDate: Sun Aug 2 00:06:49 2015 +0200 Commit: Gregor Jasny CommitDate: Sun Aug 2 00:16:39 2015 +0200 Xcode: Invert quoting logic to whitelist of characters The problem with the list of characters which triggers quoting is that it does not with UTF-8 characters which are not in the 7 bit table. Therefore the quoting decision is reversed: Do not quote if all characters found in the string are in the whitelist. diff --git a/Source/cmXCodeObject.cxx b/Source/cmXCodeObject.cxx index 4041d26..c59c360 100644 --- a/Source/cmXCodeObject.cxx +++ b/Source/cmXCodeObject.cxx @@ -243,7 +243,11 @@ void cmXCodeObject::PrintString(std::ostream& os,std::string String) bool needQuote = (String.empty() || String.find("//") != String.npos || - String.find_first_of(" <>+-*=@[](){},~|;!?':&#%^\"\\`") != String.npos); + String.find_first_not_of( + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789" + "$_./") != String.npos); const char* quote = needQuote? "\"" : ""; // Print the string, quoted and escaped as necessary. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c635339b0039d677100f7212ed02d8f0dc3f492d commit c635339b0039d677100f7212ed02d8f0dc3f492d Author: Gregor Jasny AuthorDate: Sat Aug 1 22:30:15 2015 +0200 Commit: Gregor Jasny CommitDate: Sun Aug 2 00:16:31 2015 +0200 Xcode: quote more characters diff --git a/Source/cmXCodeObject.cxx b/Source/cmXCodeObject.cxx index ba6e395..4041d26 100644 --- a/Source/cmXCodeObject.cxx +++ b/Source/cmXCodeObject.cxx @@ -243,7 +243,7 @@ void cmXCodeObject::PrintString(std::ostream& os,std::string String) bool needQuote = (String.empty() || String.find("//") != String.npos || - String.find_first_of(" <>+-*=@[](){},~") != String.npos); + String.find_first_of(" <>+-*=@[](){},~|;!?':&#%^\"\\`") != String.npos); const char* quote = needQuote? "\"" : ""; // Print the string, quoted and escaped as necessary. ----------------------------------------------------------------------- Summary of changes: Source/cmXCodeObject.cxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) hooks/post-receive -- CMake From domen.vrankar at gmail.com Tue Aug 4 16:51:07 2015 From: domen.vrankar at gmail.com (Domen Vrankar) Date: Tue, 4 Aug 2015 16:51:07 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1902-gd5b5aac Message-ID: <20150804205107.AE59BB10D1@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via d5b5aac6c174e169fcd12391011e3d2c22ef961e (commit) via 59a722f73a98fcc6695d62dcc9069bfbcaadff46 (commit) via 5b3c3d5e14c22ec7a96f5514bfff6d1b1e2232bc (commit) via ea7051f5c47d4618279e084ddac1627a973e1140 (commit) via fcc510ba32975dfc6257ac5998aeba58cda3088a (commit) via e26f53a88b2fd16fc54513adfbb8eaab26dd102f (commit) via 64aacb24b65e5496b4148437ed96363ae06e8200 (commit) from c06c74f32f5318789bd72ddb41cec9759d6a9339 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d5b5aac6c174e169fcd12391011e3d2c22ef961e commit d5b5aac6c174e169fcd12391011e3d2c22ef961e Merge: c06c74f 59a722f Author: Domen Vrankar AuthorDate: Tue Aug 4 16:51:06 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 4 16:51:06 2015 -0400 Merge topic 'cpack-rpm-documentation-fixes' into next 59a722f7 RunCMake/CPack dependencies tests 5b3c3d5e RunCMake/CPack bumped verify result cmake version ea7051f5 RunCMake/CPack_DEB getPackageInfo helper function fcc510ba RunCMake/CPack enable CXX e26f53a8 CPack/RPM: missing PACKAGE_CONFLICTS documentation 64aacb24 CPack/RPM: undocumented variables http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=59a722f73a98fcc6695d62dcc9069bfbcaadff46 commit 59a722f73a98fcc6695d62dcc9069bfbcaadff46 Author: Domen Vrankar AuthorDate: Wed Jul 29 23:39:11 2015 +0200 Commit: Domen Vrankar CommitDate: Tue Aug 4 22:49:13 2015 +0200 RunCMake/CPack dependencies tests Tests for RPM and DEB package test for currently supported dependency features (requires, provides, conflicts, ...) diff --git a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake new file mode 100644 index 0000000..577a560 --- /dev/null +++ b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake @@ -0,0 +1,13 @@ +set(whitespaces_ "[\t\n\r ]*") + +set(EXPECTED_FILES_COUNT "5") +set(EXPECTED_FILE_1 "dependencies*-applications.deb") +set(EXPECTED_FILE_CONTENT_1 "^.*/usr/foo${whitespaces_}.*/usr/foo/test_prog$") +set(EXPECTED_FILE_2 "dependencies*-applications_auto.deb") +set(EXPECTED_FILE_CONTENT_2 "^.*/usr/foo_auto${whitespaces_}.*/usr/foo_auto/test_prog$") +set(EXPECTED_FILE_3 "dependencies*-headers.deb") +set(EXPECTED_FILE_CONTENT_3 "^.*/usr/bar${whitespaces_}.*/usr/bar/CMakeLists.txt$") +set(EXPECTED_FILE_4 "dependencies*-libs.deb") +set(EXPECTED_FILE_CONTENT_4 "^.*/usr/bas${whitespaces_}.*/usr/bas/libtest_lib.so$") +set(EXPECTED_FILE_5 "dependencies*-libs_auto.deb") +set(EXPECTED_FILE_CONTENT_5 "^.*/usr/bas_auto${whitespaces_}.*/usr/bas_auto/libtest_lib.so$") diff --git a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-VerifyResult.cmake b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-VerifyResult.cmake new file mode 100644 index 0000000..44c862d --- /dev/null +++ b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-VerifyResult.cmake @@ -0,0 +1,15 @@ +function(checkDepends_ FILE REGEX) + set(whitespaces_ "[\t\n\r ]*") + + getPackageInfo("${FILE}" "FILE_INFO_") + if(NOT FILE_INFO_ MATCHES "${REGEX}") + message(FATAL_ERROR "Unexpected dependencies in '${FILE}'; file info: '${FILE_INFO_}'") + endif() +endfunction() + +checkDepends_("${FOUND_FILE_1}" ".*Depends${whitespaces_}:${whitespaces_}depend-application, depend-application-b.*") +# use wildcard as we are using dependency auto detection +checkDepends_("${FOUND_FILE_2}" ".*Depends${whitespaces_}:${whitespaces_}.*depend-application, depend-application-b.*") +checkDepends_("${FOUND_FILE_3}" ".*Depends${whitespaces_}:${whitespaces_}depend-headers.*") +checkDepends_("${FOUND_FILE_4}" ".*Depends${whitespaces_}:${whitespaces_}depend-default, depend-default-b.*") +checkDepends_("${FOUND_FILE_5}" ".*Depends${whitespaces_}:${whitespaces_}depend-default, depend-default-b.*") diff --git a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-specifics.cmake b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-specifics.cmake new file mode 100644 index 0000000..9e09428 --- /dev/null +++ b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-specifics.cmake @@ -0,0 +1,15 @@ +set(CPACK_PACKAGE_CONTACT "someone") +set(CPACK_DEB_COMPONENT_INSTALL "ON") + +# false by default +set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS FALSE) +# FIXME can not be tested as libraries first have to be part of a package in order +# to determine their dependencies and we can not be certain if there will be any +set(CPACK_DEBIAN_APPLICATIONS_AUTO_PACKAGE_SHLIBDEPS TRUE) + +set(CPACK_DEBIAN_PACKAGE_DEPENDS "depend-default, depend-default-b") +set(CPACK_DEBIAN_APPLICATIONS_PACKAGE_DEPENDS "depend-application, depend-application-b") +set(CPACK_DEBIAN_APPLICATIONS_AUTO_PACKAGE_DEPENDS "depend-application, depend-application-b") +set(CPACK_DEBIAN_HEADERS_PACKAGE_DEPENDS "depend-headers") + +# TODO add other dependency tests once CPackDeb supports them diff --git a/Tests/RunCMake/CPack/DEPENDENCIES.cmake b/Tests/RunCMake/CPack/DEPENDENCIES.cmake new file mode 100644 index 0000000..0aef925 --- /dev/null +++ b/Tests/RunCMake/CPack/DEPENDENCIES.cmake @@ -0,0 +1,18 @@ +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.hpp" + "int test_lib();") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp" + "#include \"test_lib.hpp\"\nint test_lib() {return 0;}") +add_library(test_lib SHARED "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp") + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp" + "#include \"test_lib.hpp\"\nint main() {return test_lib();}") +add_executable(test_prog "${CMAKE_CURRENT_BINARY_DIR}/main.cpp") +target_link_libraries(test_prog test_lib) + +install(TARGETS test_prog DESTINATION foo COMPONENT applications) +install(TARGETS test_prog DESTINATION foo_auto COMPONENT applications_auto) +install(FILES CMakeLists.txt DESTINATION bar COMPONENT headers) +install(TARGETS test_lib DESTINATION bas COMPONENT libs) +install(TARGETS test_lib DESTINATION bas_auto COMPONENT libs_auto) + +set(CPACK_PACKAGE_NAME "dependencies") diff --git a/Tests/RunCMake/CPack/RPM/DEPENDENCIES-ExpectedFiles.cmake b/Tests/RunCMake/CPack/RPM/DEPENDENCIES-ExpectedFiles.cmake new file mode 100644 index 0000000..cf85dab --- /dev/null +++ b/Tests/RunCMake/CPack/RPM/DEPENDENCIES-ExpectedFiles.cmake @@ -0,0 +1,13 @@ +set(whitespaces_ "[\t\n\r ]*") + +set(EXPECTED_FILES_COUNT "5") +set(EXPECTED_FILE_1 "dependencies*-applications.rpm") +set(EXPECTED_FILE_CONTENT_1 "^/usr/foo${whitespaces_}/usr/foo/test_prog$") +set(EXPECTED_FILE_2 "dependencies*-applications_auto.rpm") +set(EXPECTED_FILE_CONTENT_2 "^/usr/foo_auto${whitespaces_}/usr/foo_auto/test_prog$") +set(EXPECTED_FILE_3 "dependencies*-headers.rpm") +set(EXPECTED_FILE_CONTENT_3 "^/usr/bar${whitespaces_}/usr/bar/CMakeLists.txt$") +set(EXPECTED_FILE_4 "dependencies*-libs.rpm") +set(EXPECTED_FILE_CONTENT_4 "^/usr/bas${whitespaces_}/usr/bas/libtest_lib.so$") +set(EXPECTED_FILE_5 "dependencies*-libs_auto.rpm") +set(EXPECTED_FILE_CONTENT_5 "^/usr/bas_auto${whitespaces_}/usr/bas_auto/libtest_lib.so$") diff --git a/Tests/RunCMake/CPack/RPM/DEPENDENCIES-VerifyResult.cmake b/Tests/RunCMake/CPack/RPM/DEPENDENCIES-VerifyResult.cmake new file mode 100644 index 0000000..fec8889 --- /dev/null +++ b/Tests/RunCMake/CPack/RPM/DEPENDENCIES-VerifyResult.cmake @@ -0,0 +1,45 @@ +function(checkDependencies_ FILE TYPE COMPARE_LIST) + set(whitespaces_ "[\t\n\r ]*") + + execute_process(COMMAND ${RPM_EXECUTABLE} -qp --${TYPE} ${FILE} + WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" + OUTPUT_VARIABLE FILE_DEPENDENCIES_ + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + + string(REPLACE "\n" ";" FILE_DEPENDENCIES_LIST_ "${FILE_DEPENDENCIES_}") + + foreach(COMPARE_REGEX_ IN LISTS COMPARE_LIST) + unset(FOUND_) + + foreach(COMPARE_ IN LISTS FILE_DEPENDENCIES_LIST_) + if(COMPARE_ MATCHES "${COMPARE_REGEX_}") + set(FOUND_ true) + break() + endif() + endforeach() + + if(NOT FOUND_) + message(FATAL_ERROR "Missing dependencies in '${FILE}'; check type: '${TYPE}'; file info: '${FILE_DEPENDENCIES_}'; missing: '${COMPARE_REGEX_}'") + endif() + endforeach() +endfunction() + +# TODO add tests for what should not be present in lists +checkDependencies_("${FOUND_FILE_1}" "requires" "depend-application;depend-application-b") +checkDependencies_("${FOUND_FILE_2}" "requires" "depend-application;depend-application-b;libtest_lib\\.so.*") +checkDependencies_("${FOUND_FILE_3}" "requires" "depend-headers") +checkDependencies_("${FOUND_FILE_4}" "requires" "depend-default;depend-default-b") +checkDependencies_("${FOUND_FILE_5}" "requires" "depend-default;depend-default-b") + +checkDependencies_("${FOUND_FILE_1}" "conflicts" "conflict-application;conflict-application-b") +checkDependencies_("${FOUND_FILE_2}" "conflicts" "conflict-application;conflict-application-b") +checkDependencies_("${FOUND_FILE_3}" "conflicts" "conflict-headers") +checkDependencies_("${FOUND_FILE_4}" "conflicts" "conflict-default;conflict-default-b") +checkDependencies_("${FOUND_FILE_5}" "conflicts" "conflict-default;conflict-default-b") + +checkDependencies_("${FOUND_FILE_1}" "provides" "provided-default;provided-default-b") +checkDependencies_("${FOUND_FILE_2}" "provides" "provided-default;provided-default-b") +checkDependencies_("${FOUND_FILE_3}" "provides" "provided-default;provided-default-b") +checkDependencies_("${FOUND_FILE_4}" "provides" "provided-lib") +checkDependencies_("${FOUND_FILE_5}" "provides" "provided-lib_auto;provided-lib_auto-b") diff --git a/Tests/RunCMake/CPack/RPM/DEPENDENCIES-specifics.cmake b/Tests/RunCMake/CPack/RPM/DEPENDENCIES-specifics.cmake new file mode 100644 index 0000000..2cdfece --- /dev/null +++ b/Tests/RunCMake/CPack/RPM/DEPENDENCIES-specifics.cmake @@ -0,0 +1,22 @@ +set(CPACK_RPM_COMPONENT_INSTALL "ON") + +# FIXME auto autoprov is not tested at the moment as Ubuntu 15.04 rpmbuild +# does not use them correctly: https://bugs.launchpad.net/rpm/+bug/1475755 +set(CPACK_RPM_PACKAGE_AUTOREQ "no") +set(CPACK_RPM_PACKAGE_AUTOPROV "no") +set(CPACK_RPM_applications_auto_PACKAGE_AUTOREQPROV "yes") +set(CPACK_RPM_libs_auto_PACKAGE_AUTOREQPROV "yes") + +set(CPACK_RPM_PACKAGE_REQUIRES "depend-default, depend-default-b") +set(CPACK_RPM_applications_PACKAGE_REQUIRES "depend-application, depend-application-b") +set(CPACK_RPM_applications_auto_PACKAGE_REQUIRES "depend-application, depend-application-b") +set(CPACK_RPM_headers_PACKAGE_REQUIRES "depend-headers") + +set(CPACK_RPM_PACKAGE_CONFLICTS "conflict-default, conflict-default-b") +set(CPACK_RPM_applications_PACKAGE_CONFLICTS "conflict-application, conflict-application-b") +set(CPACK_RPM_applications_auto_PACKAGE_CONFLICTS "conflict-application, conflict-application-b") +set(CPACK_RPM_headers_PACKAGE_CONFLICTS "conflict-headers") + +set(CPACK_RPM_PACKAGE_PROVIDES "provided-default, provided-default-b") +set(CPACK_RPM_libs_PACKAGE_PROVIDES "provided-lib") +set(CPACK_RPM_libs_auto_PACKAGE_PROVIDES "provided-lib_auto, provided-lib_auto-b") diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake index 97ef238..3e5714d 100644 --- a/Tests/RunCMake/CPack/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake @@ -7,3 +7,4 @@ include("${RunCMake_SOURCE_DIR}/CPackTestHelpers.cmake") run_cpack_test(MINIMAL "RPM;DEB" false) run_cpack_test(PARTIALLY_RELOCATABLE_WARNING "RPM" false) run_cpack_test(DEB_EXTRA "DEB" false) +run_cpack_test(DEPENDENCIES "RPM;DEB" true) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5b3c3d5e14c22ec7a96f5514bfff6d1b1e2232bc commit 5b3c3d5e14c22ec7a96f5514bfff6d1b1e2232bc Author: Domen Vrankar AuthorDate: Wed Jul 29 23:36:11 2015 +0200 Commit: Domen Vrankar CommitDate: Tue Aug 4 22:49:13 2015 +0200 RunCMake/CPack bumped verify result cmake version Bumped version to current cmake version so that we always use latest policies diff --git a/Tests/RunCMake/CPack/VerifyResult.cmake b/Tests/RunCMake/CPack/VerifyResult.cmake index e059d9c..96efa9e 100644 --- a/Tests/RunCMake/CPack/VerifyResult.cmake +++ b/Tests/RunCMake/CPack/VerifyResult.cmake @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1 FATAL_ERROR) +cmake_minimum_required(VERSION ${CMAKE_VERSION} FATAL_ERROR) include("${config_file}") include("${src_dir}/${GENERATOR_TYPE}/Helpers.cmake") http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ea7051f5c47d4618279e084ddac1627a973e1140 commit ea7051f5c47d4618279e084ddac1627a973e1140 Author: Domen Vrankar AuthorDate: Wed Jul 29 23:34:17 2015 +0200 Commit: Domen Vrankar CommitDate: Tue Aug 4 22:49:13 2015 +0200 RunCMake/CPack_DEB getPackageInfo helper function getPackageInfo helper function returns package info for provided deb package file diff --git a/Tests/RunCMake/CPack/DEB/Helpers.cmake b/Tests/RunCMake/CPack/DEB/Helpers.cmake index 45c85c3..a204a3c 100644 --- a/Tests/RunCMake/CPack/DEB/Helpers.cmake +++ b/Tests/RunCMake/CPack/DEB/Helpers.cmake @@ -26,3 +26,13 @@ function(verifyDebControl FILE PREFIX VERIFY_FILES) endif() endforeach() endfunction() + +function(getPackageInfo FILE RESULT_VAR) + execute_process(COMMAND ${DPKG_EXECUTABLE} -I ${FILE} + WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" + OUTPUT_VARIABLE package_info_ + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + + set(${RESULT_VAR} "${package_info_}" PARENT_SCOPE) +endfunction() http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fcc510ba32975dfc6257ac5998aeba58cda3088a commit fcc510ba32975dfc6257ac5998aeba58cda3088a Author: Domen Vrankar AuthorDate: Wed Jul 29 23:32:13 2015 +0200 Commit: Domen Vrankar CommitDate: Tue Aug 4 22:49:13 2015 +0200 RunCMake/CPack enable CXX Enable CXX language for CPack tests so that they may compile binaries if needed diff --git a/Tests/RunCMake/CPack/CMakeLists.txt b/Tests/RunCMake/CPack/CMakeLists.txt index 7905706..46f1367 100644 --- a/Tests/RunCMake/CPack/CMakeLists.txt +++ b/Tests/RunCMake/CPack/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.1 FATAL_ERROR) -project(${RunCMake_TEST} NONE) +project(${RunCMake_TEST} CXX) include(${RunCMake_TEST}.cmake) # include test generator specifics http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e26f53a88b2fd16fc54513adfbb8eaab26dd102f commit e26f53a88b2fd16fc54513adfbb8eaab26dd102f Author: Frank-Christian Otto AuthorDate: Fri Jul 17 17:11:37 2015 +0200 Commit: Domen Vrankar CommitDate: Tue Aug 4 22:49:13 2015 +0200 CPack/RPM: missing PACKAGE_CONFLICTS documentation diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake index f442731..7c1db14 100644 --- a/Modules/CPackRPM.cmake +++ b/Modules/CPackRPM.cmake @@ -188,6 +188,23 @@ # # rpm -qp --requires file.rpm # +# .. variable:: CPACK_RPM_PACKAGE_CONFLICTS +# CPACK_RPM__PACKAGE_CONFLICTS +# +# RPM spec conflicts field. +# +# * Mandatory : NO +# * Default : - +# +# May be used to set negative RPM dependencies (conflicts). Note that you must enclose +# the complete requires string between quotes, for example:: +# +# set(CPACK_RPM_PACKAGE_CONFLICTS "libxml2") +# +# The conflicting package list of an RPM file could be printed with:: +# +# rpm -qp --conflicts file.rpm +# # .. variable:: CPACK_RPM_PACKAGE_REQUIRES_PRE # CPACK_RPM__PACKAGE_REQUIRES_PRE # http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=64aacb24b65e5496b4148437ed96363ae06e8200 commit 64aacb24b65e5496b4148437ed96363ae06e8200 Author: Domen Vrankar AuthorDate: Thu Jul 16 22:48:27 2015 +0200 Commit: Domen Vrankar CommitDate: Tue Aug 4 22:49:12 2015 +0200 CPack/RPM: undocumented variables Some CPack/RPM variables were undocumented even though they are implemented in code for quite a while now. diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake index cb77fb8..f442731 100644 --- a/Modules/CPackRPM.cmake +++ b/Modules/CPackRPM.cmake @@ -95,6 +95,7 @@ # * Default : CPACK_PACKAGE_VENDOR if set or "unknown" # # .. variable:: CPACK_RPM_PACKAGE_URL +# CPACK_RPM__PACKAGE_URL # # The projects URL. # @@ -123,7 +124,55 @@ # compression whereas older cannot use such RPM. Using this one can enforce # compression type to be used. Possible value are: lzma, xz, bzip2 and gzip. # +# .. variable:: CPACK_RPM_PACKAGE_AUTOREQ +# CPACK_RPM__PACKAGE_AUTOREQ +# +# RPM spec autoreq field. +# +# * Mandatory : NO +# * Default : - +# +# May be used to enable (1, yes) or disable (0, no) automatic shared libraries +# dependency detection. Dependencies are added to requires list. +# +# .. note:: +# +# By defalut automatic dependency detection is enabled by rpm generator. +# +# .. variable:: CPACK_RPM_PACKAGE_AUTOPROV +# CPACK_RPM__PACKAGE_AUTOPROV +# +# RPM spec autoprov field. +# +# * Mandatory : NO +# * Default : - +# +# May be used to enable (1, yes) or disable (0, no) automatic listing of shared +# libraries that are provided by the package. Shared libraries are added to +# provides list. +# +# .. note:: +# +# By defalut automatic provides detection is enabled by rpm generator. +# +# .. variable:: CPACK_RPM_PACKAGE_AUTOREQPROV +# CPACK_RPM__PACKAGE_AUTOREQPROV +# +# RPM spec autoreqprov field. +# +# * Mandatory : NO +# * Default : - +# +# Variable enables/disables autoreq and autoprov at the same time. +# See :variable:`CPACK_RPM_PACKAGE_AUTOREQ` and :variable:`CPACK_RPM_PACKAGE_AUTOPROV` +# for more details. +# +# .. note:: +# +# By defalut automatic detection feature is enabled by rpm. +# # .. variable:: CPACK_RPM_PACKAGE_REQUIRES +# CPACK_RPM__PACKAGE_REQUIRES # # RPM spec requires field. # @@ -140,6 +189,7 @@ # rpm -qp --requires file.rpm # # .. variable:: CPACK_RPM_PACKAGE_REQUIRES_PRE +# CPACK_RPM__PACKAGE_REQUIRES_PRE # # RPM spec requires(pre) field. # @@ -152,6 +202,7 @@ # set(CPACK_RPM_PACKAGE_REQUIRES_PRE "shadow-utils, initscripts") # # .. variable:: CPACK_RPM_PACKAGE_REQUIRES_POST +# CPACK_RPM__PACKAGE_REQUIRES_POST # # RPM spec requires(post) field. # @@ -165,6 +216,7 @@ # # # .. variable:: CPACK_RPM_PACKAGE_REQUIRES_POSTUN +# CPACK_RPM__PACKAGE_REQUIRES_POSTUN # # RPM spec requires(postun) field. # @@ -178,6 +230,7 @@ # # # .. variable:: CPACK_RPM_PACKAGE_REQUIRES_PREUN +# CPACK_RPM__PACKAGE_REQUIRES_PREUN # # RPM spec requires(preun) field. # @@ -190,6 +243,7 @@ # set(CPACK_RPM_PACKAGE_REQUIRES_PREUN "shadow-utils, initscripts") # # .. variable:: CPACK_RPM_PACKAGE_SUGGESTS +# CPACK_RPM__PACKAGE_SUGGESTS # # RPM spec suggest field. # @@ -200,6 +254,7 @@ # enclose the complete requires string between quotes. # # .. variable:: CPACK_RPM_PACKAGE_PROVIDES +# CPACK_RPM__PACKAGE_PROVIDES # # RPM spec provides field. # @@ -212,6 +267,7 @@ # rpm -qp --provides file.rpm # # .. variable:: CPACK_RPM_PACKAGE_OBSOLETES +# CPACK_RPM__PACKAGE_OBSOLETES # # RPM spec obsoletes field. # ----------------------------------------------------------------------- Summary of changes: Modules/CPackRPM.cmake | 73 ++++++++++++++++++++ Tests/RunCMake/CPack/CMakeLists.txt | 2 +- .../CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake | 13 ++++ .../CPack/DEB/DEPENDENCIES-VerifyResult.cmake | 15 ++++ .../CPack/DEB/DEPENDENCIES-specifics.cmake | 15 ++++ Tests/RunCMake/CPack/DEB/Helpers.cmake | 10 +++ Tests/RunCMake/CPack/DEPENDENCIES.cmake | 18 +++++ .../CPack/RPM/DEPENDENCIES-ExpectedFiles.cmake | 13 ++++ .../CPack/RPM/DEPENDENCIES-VerifyResult.cmake | 45 ++++++++++++ .../CPack/RPM/DEPENDENCIES-specifics.cmake | 22 ++++++ Tests/RunCMake/CPack/RunCMakeTest.cmake | 1 + Tests/RunCMake/CPack/VerifyResult.cmake | 2 +- 12 files changed, 227 insertions(+), 2 deletions(-) create mode 100644 Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake create mode 100644 Tests/RunCMake/CPack/DEB/DEPENDENCIES-VerifyResult.cmake create mode 100644 Tests/RunCMake/CPack/DEB/DEPENDENCIES-specifics.cmake create mode 100644 Tests/RunCMake/CPack/DEPENDENCIES.cmake create mode 100644 Tests/RunCMake/CPack/RPM/DEPENDENCIES-ExpectedFiles.cmake create mode 100644 Tests/RunCMake/CPack/RPM/DEPENDENCIES-VerifyResult.cmake create mode 100644 Tests/RunCMake/CPack/RPM/DEPENDENCIES-specifics.cmake hooks/post-receive -- CMake From kwrobot at kitware.com Wed Aug 5 00:01:09 2015 From: kwrobot at kitware.com (Kitware Robot) Date: Wed, 5 Aug 2015 00:01:09 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-688-ga15b69c Message-ID: <20150805040109.851CFB10C3@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via a15b69cbc75f475601f41c516330c679915676e4 (commit) from 87b869c1da77f673f6397eff48b09cfb5f44f5f9 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a15b69cbc75f475601f41c516330c679915676e4 commit a15b69cbc75f475601f41c516330c679915676e4 Author: Kitware Robot AuthorDate: Wed Aug 5 00:01:06 2015 -0400 Commit: Kitware Robot CommitDate: Wed Aug 5 00:01:06 2015 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 9a7ae8b..a9dfae0 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150804) +set(CMake_VERSION_PATCH 20150805) #set(CMake_VERSION_RC 1) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Wed Aug 5 08:07:25 2015 From: brad.king at kitware.com (Brad King) Date: Wed, 5 Aug 2015 08:07:25 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1904-g1e0d21e Message-ID: <20150805120725.C20B6B14A0@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 1e0d21e449ca1baed38683acb052f46e26526d73 (commit) via c4d2f64f3c9dea3a5fcd8af5bb389db00ccd64df (commit) from d5b5aac6c174e169fcd12391011e3d2c22ef961e (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1e0d21e449ca1baed38683acb052f46e26526d73 commit 1e0d21e449ca1baed38683acb052f46e26526d73 Merge: d5b5aac c4d2f64 Author: Brad King AuthorDate: Wed Aug 5 08:07:24 2015 -0400 Commit: CMake Topic Stage CommitDate: Wed Aug 5 08:07:24 2015 -0400 Merge topic 'fix-missing-subdir-error' into next c4d2f64f add_subdirectory: Fix error message on missing CMakeLists.txt (#15680) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c4d2f64f3c9dea3a5fcd8af5bb389db00ccd64df commit c4d2f64f3c9dea3a5fcd8af5bb389db00ccd64df Author: Brad King AuthorDate: Tue Aug 4 16:39:31 2015 -0400 Commit: Brad King CommitDate: Tue Aug 4 16:40:13 2015 -0400 add_subdirectory: Fix error message on missing CMakeLists.txt (#15680) Refactoring in commit v3.3.0-rc1~76^2 (cmMakefile: Handle CMP0014 before configuring the generator, 2015-05-14) accidentally left the file name "/CMakeLists.txt" in the error message. Remove it and add a test case. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index ee6c1da..bdc55f2 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1564,8 +1564,8 @@ void cmMakefile::ConfigureSubDirectory(cmLocalGenerator *lg2) cmSystemTools::Message(msg.c_str()); } - currentStart += "/CMakeLists.txt"; - if(!cmSystemTools::FileExists(currentStart.c_str(), true)) + std::string const currentStartFile = currentStart + "/CMakeLists.txt"; + if (!cmSystemTools::FileExists(currentStartFile, true)) { // The file is missing. Check policy CMP0014. std::ostringstream e; diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 81029cd..4e7c7b3 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -118,6 +118,7 @@ add_RunCMake_test(Syntax) add_RunCMake_test(add_custom_command) add_RunCMake_test(add_custom_target) add_RunCMake_test(add_dependencies) +add_RunCMake_test(add_subdirectory) add_RunCMake_test(build_command) add_RunCMake_test(execute_process) add_RunCMake_test(export) diff --git a/Tests/RunCMake/add_subdirectory/CMakeLists.txt b/Tests/RunCMake/add_subdirectory/CMakeLists.txt new file mode 100644 index 0000000..18dfd26 --- /dev/null +++ b/Tests/RunCMake/add_subdirectory/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.2) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/add_subdirectory/DoesNotExist-result.txt b/Tests/RunCMake/add_subdirectory/DoesNotExist-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/add_subdirectory/DoesNotExist-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/add_subdirectory/DoesNotExist-stderr.txt b/Tests/RunCMake/add_subdirectory/DoesNotExist-stderr.txt new file mode 100644 index 0000000..369a956 --- /dev/null +++ b/Tests/RunCMake/add_subdirectory/DoesNotExist-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error at DoesNotExist.cmake:1 \(add_subdirectory\): + add_subdirectory given source "DoesNotExist" which is not an existing + directory. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/add_subdirectory/DoesNotExist.cmake b/Tests/RunCMake/add_subdirectory/DoesNotExist.cmake new file mode 100644 index 0000000..fe2945c --- /dev/null +++ b/Tests/RunCMake/add_subdirectory/DoesNotExist.cmake @@ -0,0 +1 @@ +add_subdirectory(DoesNotExist) diff --git a/Tests/RunCMake/add_subdirectory/Missing-result.txt b/Tests/RunCMake/add_subdirectory/Missing-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/add_subdirectory/Missing-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/add_subdirectory/Missing-stderr.txt b/Tests/RunCMake/add_subdirectory/Missing-stderr.txt new file mode 100644 index 0000000..aba0675 --- /dev/null +++ b/Tests/RunCMake/add_subdirectory/Missing-stderr.txt @@ -0,0 +1,8 @@ +^CMake Error at Missing.cmake:1 \(add_subdirectory\): + The source directory + + .*/Tests/RunCMake/add_subdirectory/Missing + + does not contain a CMakeLists.txt file. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/add_subdirectory/Missing.cmake b/Tests/RunCMake/add_subdirectory/Missing.cmake new file mode 100644 index 0000000..0e68927 --- /dev/null +++ b/Tests/RunCMake/add_subdirectory/Missing.cmake @@ -0,0 +1 @@ +add_subdirectory(Missing) diff --git a/Tests/RunCMake/add_subdirectory/Missing/Missing.txt b/Tests/RunCMake/add_subdirectory/Missing/Missing.txt new file mode 100644 index 0000000..e69de29 diff --git a/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake b/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake new file mode 100644 index 0000000..a3ddec8 --- /dev/null +++ b/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake @@ -0,0 +1,4 @@ +include(RunCMake) + +run_cmake(DoesNotExist) +run_cmake(Missing) ----------------------------------------------------------------------- Summary of changes: Source/cmMakefile.cxx | 4 ++-- Tests/RunCMake/CMakeLists.txt | 1 + .../{AutoExportDll => add_subdirectory}/CMakeLists.txt | 0 .../DoesNotExist-result.txt} | 0 Tests/RunCMake/add_subdirectory/DoesNotExist-stderr.txt | 5 +++++ Tests/RunCMake/add_subdirectory/DoesNotExist.cmake | 1 + .../Missing-result.txt} | 0 Tests/RunCMake/add_subdirectory/Missing-stderr.txt | 8 ++++++++ Tests/RunCMake/add_subdirectory/Missing.cmake | 1 + .../RunCMake/add_subdirectory/Missing/Missing.txt | 0 Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake | 4 ++++ 11 files changed, 22 insertions(+), 2 deletions(-) copy Tests/RunCMake/{AutoExportDll => add_subdirectory}/CMakeLists.txt (100%) copy Tests/RunCMake/{CMP0004/CMP0004-NEW-result.txt => add_subdirectory/DoesNotExist-result.txt} (100%) create mode 100644 Tests/RunCMake/add_subdirectory/DoesNotExist-stderr.txt create mode 100644 Tests/RunCMake/add_subdirectory/DoesNotExist.cmake copy Tests/RunCMake/{CMP0004/CMP0004-NEW-result.txt => add_subdirectory/Missing-result.txt} (100%) create mode 100644 Tests/RunCMake/add_subdirectory/Missing-stderr.txt create mode 100644 Tests/RunCMake/add_subdirectory/Missing.cmake copy Modules/IntelVSImplicitPath/hello.f => Tests/RunCMake/add_subdirectory/Missing/Missing.txt (100%) create mode 100644 Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake hooks/post-receive -- CMake From brad.king at kitware.com Wed Aug 5 10:45:15 2015 From: brad.king at kitware.com (Brad King) Date: Wed, 5 Aug 2015 10:45:15 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1906-gaac63e3 Message-ID: <20150805144515.20FD4B0896@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via aac63e39213c28b139ce4793684e199190aa659a (commit) via f0609182cc2bbce7f6af557d6352e0c434e7acc2 (commit) from 1e0d21e449ca1baed38683acb052f46e26526d73 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=aac63e39213c28b139ce4793684e199190aa659a commit aac63e39213c28b139ce4793684e199190aa659a Merge: 1e0d21e f060918 Author: Brad King AuthorDate: Wed Aug 5 10:45:14 2015 -0400 Commit: CMake Topic Stage CommitDate: Wed Aug 5 10:45:14 2015 -0400 Merge topic 'compiler-version-Fortran' into next f0609182 Fortran: Store detected compiler version persistently (#15684) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f0609182cc2bbce7f6af557d6352e0c434e7acc2 commit f0609182cc2bbce7f6af557d6352e0c434e7acc2 Author: Brad King AuthorDate: Wed Aug 5 10:39:03 2015 -0400 Commit: Brad King CommitDate: Wed Aug 5 10:39:03 2015 -0400 Fortran: Store detected compiler version persistently (#15684) The Fortran compiler version detection infrastructure added by commit v3.3.0-rc1~436^2~9 (Fortran: Add infrastructure to detect compiler version, 2015-02-17) forgot to update CMakeFortranCompiler.cmake.in to save the compiler version persistently as we do already in "CMake{C,CXX}Compiler.cmake.in". Add the missing line now. diff --git a/Modules/CMakeFortranCompiler.cmake.in b/Modules/CMakeFortranCompiler.cmake.in index e4c7618..14fdd60 100644 --- a/Modules/CMakeFortranCompiler.cmake.in +++ b/Modules/CMakeFortranCompiler.cmake.in @@ -1,6 +1,7 @@ set(CMAKE_Fortran_COMPILER "@CMAKE_Fortran_COMPILER@") set(CMAKE_Fortran_COMPILER_ARG1 "@CMAKE_Fortran_COMPILER_ARG1@") set(CMAKE_Fortran_COMPILER_ID "@CMAKE_Fortran_COMPILER_ID@") +set(CMAKE_Fortran_COMPILER_VERSION "@CMAKE_Fortran_COMPILER_VERSION@") set(CMAKE_Fortran_PLATFORM_ID "@CMAKE_Fortran_PLATFORM_ID@") set(CMAKE_Fortran_SIMULATE_ID "@CMAKE_Fortran_SIMULATE_ID@") set(CMAKE_Fortran_SIMULATE_VERSION "@CMAKE_Fortran_SIMULATE_VERSION@") ----------------------------------------------------------------------- Summary of changes: Modules/CMakeFortranCompiler.cmake.in | 1 + 1 file changed, 1 insertion(+) hooks/post-receive -- CMake From steveire at gmail.com Wed Aug 5 11:50:02 2015 From: steveire at gmail.com (Stephen Kelly) Date: Wed, 5 Aug 2015 11:50:02 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1908-ge63dcb4 Message-ID: <20150805155002.59AA1B1091@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via e63dcb41ddd21175acbd57588f5df92397c46d09 (commit) via bc028a4aa580c4f162af5c77d766a34c7026c609 (commit) from aac63e39213c28b139ce4793684e199190aa659a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e63dcb41ddd21175acbd57588f5df92397c46d09 commit e63dcb41ddd21175acbd57588f5df92397c46d09 Merge: aac63e3 bc028a4 Author: Stephen Kelly AuthorDate: Wed Aug 5 11:50:01 2015 -0400 Commit: CMake Topic Stage CommitDate: Wed Aug 5 11:50:01 2015 -0400 Merge topic 'use-generator-target' into next bc028a4a fixup! cmGeneratorTarget: Move GetSOName from cmTarget.. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bc028a4aa580c4f162af5c77d766a34c7026c609 commit bc028a4aa580c4f162af5c77d766a34c7026c609 Author: Stephen Kelly AuthorDate: Wed Aug 5 17:47:13 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 17:49:39 2015 +0200 fixup! cmGeneratorTarget: Move GetSOName from cmTarget.. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index e0c6e86..c432cfb 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -762,9 +762,7 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, return; } - cmGeneratorTarget *gtgt = tgt->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(tgt); + cmGeneratorTarget *gtgt = 0; // Get a full path to the dependent shared library. // Add it to the runtime path computation so that the target being @@ -772,6 +770,9 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, std::string lib; if(tgt) { + cmGeneratorTarget *gtgt = tgt->GetMakefile() + ->GetGlobalGenerator()->GetGeneratorTarget(tgt); + lib = gtgt->GetFullPath(this->Config, this->UseImportLibrary); this->AddLibraryRuntimeInfo(lib, tgt); } @@ -797,7 +798,7 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, } if(order) { - if(tgt) + if(gtgt) { std::string soName = gtgt->GetSOName(this->Config); const char* soname = soName.empty()? 0 : soName.c_str(); ----------------------------------------------------------------------- Summary of changes: Source/cmComputeLinkInformation.cxx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) hooks/post-receive -- CMake From steveire at gmail.com Wed Aug 5 11:51:22 2015 From: steveire at gmail.com (Stephen Kelly) Date: Wed, 5 Aug 2015 11:51:22 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1943-g1d8f34e Message-ID: <20150805155122.DE539B118E@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 1d8f34ecc7322e30cdcad137460581f5f32ffa4f (commit) via 18b2a26e4339737e4e215382b7035b2570ef8bd0 (commit) via c395f3b87e9e2581fb7a2498c85d48d89c2d07b2 (commit) via 707018a6c38c5120cdb953fef0c6561e23fdd73b (commit) via 53c52cbf6449e2c45d4aca0b9b601111b72f24a4 (commit) via 4149496303f97bed90f2043c40df59b8490e7be3 (commit) via de140650d16cfdf43c09b32d44dd3996012e7731 (commit) via 2650762ff98c0c77cfc70209da308dc9d83ba974 (commit) via ebbdeee5ae3b52963ac3511e6aee14506fb07a90 (commit) via 13d7afe429e80c84b0dffe7d82fde70ee4862fe3 (commit) via 48d38cedf73fdb2b7872289e6636ff79033e59e9 (commit) via 8c976738ce700a7827874dab05ae14c555a8b08a (commit) via 66ef59ba503d970a80691fe828f369a258ce69ff (commit) via 9d6f7d3675da15c8f430a110d2b8a349fcf6d4ae (commit) via 3c748aa6a81d3af4af2552ec10f21c22a4cd39e8 (commit) via 7935934a89e062dbab0ca396b40560edc9e904d9 (commit) via d6beb377729cc79b3e5718c9d2cc8b751137b889 (commit) via dd06c55ee9cc330627a6d85f964f69ffa90bf315 (commit) via c6f45bed359dee2cfe947de76ce808eb99ad20da (commit) via bdfebf91ec9b245742af1fe98de1ad47e497616c (commit) via 99fa567ffdb1c5b7d9e102a8949364ed635c6146 (commit) via bb97f53ab24e11aa632c6e50e34d7353c36dfacc (commit) via 0af8a7369d11d820c9fc172c1e3463ead2a4f37e (commit) via 54f23ec7baf5330421abea12be6aba90d4af3503 (commit) via 047a275024b22fa8aaab13b020d4a4580cc234dd (commit) via a4709b427bb9f8e9f129478783977322a7b88497 (commit) via 4ee079e7c2bb5bc8b10d8cd0abd4317ab888d900 (commit) via e65cdf6014d296356c40c37403e1f48302933ccf (commit) via d0ccd406c34e56a1ead7387eae091c4f92db5c00 (commit) via dd3e78c0c841ff3abeaa8bcbb6d721b8fbef01b4 (commit) via 031923b3789733fd2dac507201b703335fb74a9f (commit) via 95d50adcd018fff80ddecddab4b4842fba37e790 (commit) via 42ee51028e9a977e61df50c105a0de782d1f40b7 (commit) via 669fce43e925f66f792651d050a50d7978716bd3 (commit) via 68ce826eca2d3cd22de7bab57bf5d9c129486523 (commit) from e63dcb41ddd21175acbd57588f5df92397c46d09 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1d8f34ecc7322e30cdcad137460581f5f32ffa4f commit 1d8f34ecc7322e30cdcad137460581f5f32ffa4f Merge: e63dcb4 18b2a26 Author: Stephen Kelly AuthorDate: Wed Aug 5 11:51:17 2015 -0400 Commit: CMake Topic Stage CommitDate: Wed Aug 5 11:51:17 2015 -0400 Merge topic 'use-generator-target' into next 18b2a26e cmOrderDirectories: Port to cmGeneratorTarget. c395f3b8 cmGeneratorTarget: Move CompileInfoMap from cmTarget. 707018a6 cmGeneratorTarget: Move GetCompilePDBDirectory from cmTarget. 53c52cbf cmGeneratorTarget: Move GetOutputName from cmTarget. 41494963 cmComputeLinkDepends: Port to cmGeneratorTarget. de140650 cmComputeLinkInformation: Port to cmGeneratorTarget. 2650762f cmGeneratorTarget: Move IsBundleOnApple from cmTarget. ebbdeee5 cmMakefileTargetGenerator: Add accessor for GeneratorTarget. 13d7afe4 cmGeneratorTarget: Move GetLinkClosure from cmTarget. 48d38ced cmGeneratorTarget: Move GetLinkerLanguage from cmTarget. 8c976738 cmGeneratorTarget: Move GetFrameworkDirectory from cmTarget. 66ef59ba cmGeneratorTarget: Move GetFullName from cmTarget. 9d6f7d36 cmGeneratorTarget: Move GetAppBundleDirectory from cmTarget. 3c748aa6 cmGeneratorTarget: Move GetInstallNameDir* from cmTarget. 7935934a cmGeneratorTarget: Move GetMacContentDirectory from cmTarget. d6beb377 cmGeneratorTarget: Move GetFullNameComponents from cmTarget. ... http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=18b2a26e4339737e4e215382b7035b2570ef8bd0 commit 18b2a26e4339737e4e215382b7035b2570ef8bd0 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:51 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 17:50:43 2015 +0200 cmOrderDirectories: Port to cmGeneratorTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 412e63b..c432cfb 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -260,10 +260,10 @@ cmComputeLinkInformation // Allocate internals. this->OrderLinkerSearchPath = - new cmOrderDirectories(this->GlobalGenerator, target->Target, + new cmOrderDirectories(this->GlobalGenerator, target, "linker search path"); this->OrderRuntimeSearchPath = - new cmOrderDirectories(this->GlobalGenerator, target->Target, + new cmOrderDirectories(this->GlobalGenerator, target, "runtime search path"); this->OrderDependentRPath = 0; @@ -370,7 +370,7 @@ cmComputeLinkInformation { this->SharedDependencyMode = SharedDepModeDir; this->OrderDependentRPath = - new cmOrderDirectories(this->GlobalGenerator, target->Target, + new cmOrderDirectories(this->GlobalGenerator, target, "dependent library path"); } diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx index a612437..35ee127 100644 --- a/Source/cmOrderDirectories.cxx +++ b/Source/cmOrderDirectories.cxx @@ -280,7 +280,7 @@ bool cmOrderDirectoriesConstraintLibrary::FindConflict(std::string const& dir) //---------------------------------------------------------------------------- cmOrderDirectories::cmOrderDirectories(cmGlobalGenerator* gg, - cmTarget const* target, + const cmGeneratorTarget* target, const char* purpose) { this->GlobalGenerator = gg; @@ -554,7 +554,8 @@ void cmOrderDirectories::FindImplicitConflicts() << text << "Some of these libraries may not be found correctly."; this->GlobalGenerator->GetCMakeInstance() - ->IssueMessage(cmake::WARNING, w.str(), this->Target->GetBacktrace()); + ->IssueMessage(cmake::WARNING, w.str(), + this->Target->Target->GetBacktrace()); } //---------------------------------------------------------------------------- @@ -635,5 +636,6 @@ void cmOrderDirectories::DiagnoseCycle() } e << "Some of these libraries may not be found correctly."; this->GlobalGenerator->GetCMakeInstance() - ->IssueMessage(cmake::WARNING, e.str(), this->Target->GetBacktrace()); + ->IssueMessage(cmake::WARNING, e.str(), + this->Target->Target->GetBacktrace()); } diff --git a/Source/cmOrderDirectories.h b/Source/cmOrderDirectories.h index cb5a51f..211c786 100644 --- a/Source/cmOrderDirectories.h +++ b/Source/cmOrderDirectories.h @@ -19,7 +19,7 @@ class cmGlobalGenerator; class cmOrderDirectoriesConstraint; class cmOrderDirectoriesConstraintLibrary; -class cmTarget; +class cmGeneratorTarget; /** \class cmOrderDirectories * \brief Compute a safe runtime path order for a set of shared libraries. @@ -27,7 +27,7 @@ class cmTarget; class cmOrderDirectories { public: - cmOrderDirectories(cmGlobalGenerator* gg, cmTarget const* target, + cmOrderDirectories(cmGlobalGenerator* gg, cmGeneratorTarget const* target, const char* purpose); ~cmOrderDirectories(); void AddRuntimeLibrary(std::string const& fullPath, const char* soname = 0); @@ -41,7 +41,7 @@ public: std::vector const& GetOrderedDirectories(); private: cmGlobalGenerator* GlobalGenerator; - cmTarget const* Target; + cmGeneratorTarget const* Target; std::string Purpose; std::vector OrderedDirectories; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c395f3b87e9e2581fb7a2498c85d48d89c2d07b2 commit c395f3b87e9e2581fb7a2498c85d48d89c2d07b2 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:51 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 17:50:43 2015 +0200 cmGeneratorTarget: Move CompileInfoMap from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c6f248c..c831704 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1356,6 +1356,46 @@ cmGeneratorTarget::GetMacContentDirectory(const std::string& config, return fpath; } + +//---------------------------------------------------------------------------- +cmGeneratorTarget::CompileInfo const* cmGeneratorTarget::GetCompileInfo( + const std::string& config) const +{ + // There is no compile information for imported targets. + if(this->IsImported()) + { + return 0; + } + + if(this->GetType() > cmTarget::OBJECT_LIBRARY) + { + std::string msg = "cmTarget::GetCompileInfo called for "; + msg += this->GetName(); + msg += " which has type "; + msg += cmTarget::GetTargetTypeName(this->Target->GetType()); + this->Makefile->IssueMessage(cmake::INTERNAL_ERROR, msg); + return 0; + } + + // Lookup/compute/cache the compile information for this configuration. + std::string config_upper; + if(!config.empty()) + { + config_upper = cmSystemTools::UpperCase(config); + } + CompileInfoMapType::const_iterator i = + this->CompileInfoMap.find(config_upper); + if(i == this->CompileInfoMap.end()) + { + CompileInfo info; + this->Target + ->ComputePDBOutputDir("COMPILE_PDB", config, info.CompilePdbDir); + CompileInfoMapType::value_type entry(config_upper, info); + i = this->CompileInfoMap.insert(entry).first; + } + return &i->second; +} + //---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetModuleDefinitionFile(const std::string& config) const @@ -1827,7 +1867,7 @@ void cmGeneratorTarget::TraceDependencies() std::string cmGeneratorTarget::GetCompilePDBDirectory(const std::string& config) const { - if(cmTarget::CompileInfo const* info = this->Target->GetCompileInfo(config)) + if(CompileInfo const* info = this->GetCompileInfo(config)) { return info->CompilePdbDir; } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 3dbbca1..68e7a8a 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -230,6 +230,16 @@ public: /** Whether this library has soname enabled and platform supports it. */ bool HasSOName(const std::string& config) const; + struct CompileInfo + { + std::string CompilePdbDir; + }; + + CompileInfo const* GetCompileInfo(const std::string& config) const; + + typedef std::map CompileInfoMapType; + mutable CompileInfoMapType CompileInfoMap; + /** Get the name of the compiler pdb file for the target. */ std::string GetCompilePDBName(const std::string& config="") const; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 9308113..1f8f07a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -126,9 +126,6 @@ public: typedef std::map ImportInfoMapType; ImportInfoMapType ImportInfoMap; - typedef std::map CompileInfoMapType; - CompileInfoMapType CompileInfoMap; - // Cache link implementation computation from each configuration. struct OptionalLinkImplementation: public cmTarget::LinkImplementation { @@ -2598,45 +2595,6 @@ cmTarget::OutputInfo const* cmTarget::GetOutputInfo( } //---------------------------------------------------------------------------- -cmTarget::CompileInfo const* cmTarget::GetCompileInfo( - const std::string& config) const -{ - // There is no compile information for imported targets. - if(this->IsImported()) - { - return 0; - } - - if(this->GetType() > cmTarget::OBJECT_LIBRARY) - { - std::string msg = "cmTarget::GetCompileInfo called for "; - msg += this->GetName(); - msg += " which has type "; - msg += cmTarget::GetTargetTypeName(this->GetType()); - this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg); - return 0; - } - - // Lookup/compute/cache the compile information for this configuration. - std::string config_upper; - if(!config.empty()) - { - config_upper = cmSystemTools::UpperCase(config); - } - typedef cmTargetInternals::CompileInfoMapType CompileInfoMapType; - CompileInfoMapType::const_iterator i = - this->Internal->CompileInfoMap.find(config_upper); - if(i == this->Internal->CompileInfoMap.end()) - { - CompileInfo info; - this->ComputePDBOutputDir("COMPILE_PDB", config, info.CompilePdbDir); - CompileInfoMapType::value_type entry(config_upper, info); - i = this->Internal->CompileInfoMap.insert(entry).first; - } - return &i->second; -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetDirectory(const std::string& config, bool implib) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 8689838..e3fbdfd 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -626,13 +626,6 @@ private: void ComputeImportInfo(std::string const& desired_config, ImportInfo& info) const; - // Cache target compile paths for each configuration. - struct CompileInfo - { - std::string CompilePdbDir; - }; - - CompileInfo const* GetCompileInfo(const std::string& config) const; LinkInterface const* GetImportLinkInterface(const std::string& config, cmTarget const* head, http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=707018a6c38c5120cdb953fef0c6561e23fdd73b commit 707018a6c38c5120cdb953fef0c6561e23fdd73b Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:51 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 17:50:42 2015 +0200 cmGeneratorTarget: Move GetCompilePDBDirectory from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index aac941e..c6f248c 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -743,7 +743,7 @@ cmGeneratorTarget::GetCompilePDBName(const std::string& config) const std::string cmGeneratorTarget::GetCompilePDBPath(const std::string& config) const { - std::string dir = this->Target->GetCompilePDBDirectory(config); + std::string dir = this->GetCompilePDBDirectory(config); std::string name = this->GetCompilePDBName(config); if(dir.empty() && !name.empty()) { @@ -1824,6 +1824,16 @@ void cmGeneratorTarget::TraceDependencies() tracer.Trace(); } +std::string +cmGeneratorTarget::GetCompilePDBDirectory(const std::string& config) const +{ + if(cmTarget::CompileInfo const* info = this->Target->GetCompileInfo(config)) + { + return info->CompilePdbDir; + } + return ""; +} + //---------------------------------------------------------------------------- void cmGeneratorTarget::GetAppleArchs(const std::string& config, std::vector& archVec) const diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 52ab6c0..3dbbca1 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -214,6 +214,12 @@ public: */ void TraceDependencies(); + /** Get the directory in which to place the target compiler .pdb file. + If the configuration name is given then the generator will add its + subdirectory for that configuration. Otherwise just the canonical + compiler pdb output directory is given. */ + std::string GetCompilePDBDirectory(const std::string& config = "") const; + /** Get sources that must be built before the given source. */ std::vector const* GetSourceDepends(cmSourceFile const* sf) const; diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index afe145a..ccb0974 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -130,7 +130,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) } std::string compilePdbOutputPath = - this->Target->GetCompilePDBDirectory(this->ConfigName); + this->GeneratorTarget->GetCompilePDBDirectory(this->ConfigName); cmSystemTools::MakeDirectory(compilePdbOutputPath.c_str()); std::string pdbOutputPath = this->Target->GetPDBDirectory(this->ConfigName); diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index bb0f9dd..2f995e8 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -311,7 +311,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules } std::string compilePdbOutputPath = - this->Target->GetCompilePDBDirectory(this->ConfigName); + this->GeneratorTarget->GetCompilePDBDirectory(this->ConfigName); cmSystemTools::MakeDirectory(compilePdbOutputPath.c_str()); std::string pdbOutputPath = this->Target->GetPDBDirectory(this->ConfigName); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 8b64bc4..9308113 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -69,12 +69,6 @@ struct cmTarget::OutputInfo }; //---------------------------------------------------------------------------- -struct cmTarget::CompileInfo -{ - std::string CompilePdbDir; -}; - -//---------------------------------------------------------------------------- class cmTargetInternals { public: @@ -2673,16 +2667,6 @@ std::string cmTarget::GetPDBDirectory(const std::string& config) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetCompilePDBDirectory(const std::string& config) const -{ - if(CompileInfo const* info = this->GetCompileInfo(config)) - { - return info->CompilePdbDir; - } - return ""; -} - -//---------------------------------------------------------------------------- const char* cmTarget::ImportedGetLocation(const std::string& config) const { static std::string location; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index a6f2465..8689838 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -334,12 +334,6 @@ public: pdb output directory is given. */ std::string GetPDBDirectory(const std::string& config) const; - /** Get the directory in which to place the target compiler .pdb file. - If the configuration name is given then the generator will add its - subdirectory for that configuration. Otherwise just the canonical - compiler pdb output directory is given. */ - std::string GetCompilePDBDirectory(const std::string& config = "") const; - const char* ImportedGetLocation(const std::string& config) const; /** Get the target major and minor version numbers interpreted from @@ -633,7 +627,11 @@ private: ImportInfo& info) const; // Cache target compile paths for each configuration. - struct CompileInfo; + struct CompileInfo + { + std::string CompilePdbDir; + }; + CompileInfo const* GetCompileInfo(const std::string& config) const; LinkInterface const* http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=53c52cbf6449e2c45d4aca0b9b601111b72f24a4 commit 53c52cbf6449e2c45d4aca0b9b601111b72f24a4 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:50 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 17:50:42 2015 +0200 cmGeneratorTarget: Move GetOutputName from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 55e2922..aac941e 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -267,6 +267,54 @@ const char *cmGeneratorTarget::GetProperty(const std::string& prop) const } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetOutputName(const std::string& config, + bool implib) const +{ + std::vector props; + std::string type = this->Target->GetOutputTargetType(implib); + std::string configUpper = cmSystemTools::UpperCase(config); + if(!type.empty() && !configUpper.empty()) + { + // _OUTPUT_NAME_ + props.push_back(type + "_OUTPUT_NAME_" + configUpper); + } + if(!type.empty()) + { + // _OUTPUT_NAME + props.push_back(type + "_OUTPUT_NAME"); + } + if(!configUpper.empty()) + { + // OUTPUT_NAME_ + props.push_back("OUTPUT_NAME_" + configUpper); + // _OUTPUT_NAME + props.push_back(configUpper + "_OUTPUT_NAME"); + } + // OUTPUT_NAME + props.push_back("OUTPUT_NAME"); + + std::string outName; + for(std::vector::const_iterator i = props.begin(); + i != props.end(); ++i) + { + if (const char* outNameProp = this->Target->GetProperty(*i)) + { + outName = outNameProp; + break; + } + } + + if (outName.empty()) + { + outName = this->GetName(); + } + + cmGeneratorExpression ge; + cmsys::auto_ptr cge = ge.Parse(outName); + return cge->Evaluate(this->Makefile, config); +} + +//---------------------------------------------------------------------------- std::vector const* cmGeneratorTarget::GetSourceDepends(cmSourceFile const* sf) const { @@ -922,7 +970,7 @@ std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config, bool contentOnly) const { std::string fpath; - fpath += this->Target->GetOutputName(config, false); + fpath += this->GetOutputName(config, false); fpath += "."; const char *ext = this->Target->GetProperty("BUNDLE_EXTENSION"); if (!ext) @@ -949,7 +997,7 @@ cmGeneratorTarget::GetFrameworkDirectory(const std::string& config, bool rootDir) const { std::string fpath; - fpath += this->Target->GetOutputName(config, false); + fpath += this->GetOutputName(config, false); fpath += ".framework"; if(!rootDir) { @@ -2247,7 +2295,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, std::string fw_prefix; if(this->Target->IsFrameworkOnApple()) { - fw_prefix = this->Target->GetOutputName(config, false); + fw_prefix = this->GetOutputName(config, false); fw_prefix += ".framework/"; targetPrefix = fw_prefix.c_str(); targetSuffix = 0; @@ -2265,7 +2313,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, outPrefix = targetPrefix?targetPrefix:""; // Append the target name or property-specified name. - outBase += this->Target->GetOutputName(config, implib); + outBase += this->GetOutputName(config, implib); // Append the per-configuration postfix. outBase += configPostfix?configPostfix:""; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 21e0900..52ab6c0 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -230,6 +230,9 @@ public: /** Get the path for the MSVC /Fd option for this target. */ std::string GetCompilePDBPath(const std::string& config="") const; + // Get the target base name. + std::string GetOutputName(const std::string& config, bool implib) const; + /** * Flags for a given source file as used in this target. Typically assigned * via SET_TARGET_PROPERTIES when the property is a list of source files. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e887ef3..8b64bc4 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3663,54 +3663,6 @@ bool cmTarget::UsesDefaultOutputDir(const std::string& config, } //---------------------------------------------------------------------------- -std::string cmTarget::GetOutputName(const std::string& config, - bool implib) const -{ - std::vector props; - std::string type = this->GetOutputTargetType(implib); - std::string configUpper = cmSystemTools::UpperCase(config); - if(!type.empty() && !configUpper.empty()) - { - // _OUTPUT_NAME_ - props.push_back(type + "_OUTPUT_NAME_" + configUpper); - } - if(!type.empty()) - { - // _OUTPUT_NAME - props.push_back(type + "_OUTPUT_NAME"); - } - if(!configUpper.empty()) - { - // OUTPUT_NAME_ - props.push_back("OUTPUT_NAME_" + configUpper); - // _OUTPUT_NAME - props.push_back(configUpper + "_OUTPUT_NAME"); - } - // OUTPUT_NAME - props.push_back("OUTPUT_NAME"); - - std::string outName; - for(std::vector::const_iterator i = props.begin(); - i != props.end(); ++i) - { - if (const char* outNameProp = this->GetProperty(*i)) - { - outName = outNameProp; - break; - } - } - - if (outName.empty()) - { - outName = this->GetName(); - } - - cmGeneratorExpression ge; - cmsys::auto_ptr cge = ge.Parse(outName); - return cge->Evaluate(this->Makefile, config); -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetFrameworkVersion() const { assert(this->GetType() != INTERFACE_LIBRARY); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e53afff..a6f2465 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -552,9 +552,6 @@ private: // Returns ARCHIVE, LIBRARY, or RUNTIME based on platform and type. const char* GetOutputTargetType(bool implib) const; - // Get the target base name. - std::string GetOutputName(const std::string& config, bool implib) const; - std::string GetFullNameImported(const std::string& config, bool implib) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4149496303f97bed90f2043c40df59b8490e7be3 commit 4149496303f97bed90f2043c40df59b8490e7be3 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:50 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 17:50:42 2015 +0200 cmComputeLinkDepends: Port to cmGeneratorTarget. diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index abd9877..8ba8847 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -173,18 +173,19 @@ items that we know the linker will re-use automatically (shared libs). //---------------------------------------------------------------------------- cmComputeLinkDepends -::cmComputeLinkDepends(cmTarget const* target, const std::string& config) +::cmComputeLinkDepends(const cmGeneratorTarget* target, + const std::string& config) { // Store context information. this->Target = target; - this->Makefile = this->Target->GetMakefile(); + this->Makefile = this->Target->Target->GetMakefile(); this->GlobalGenerator = this->Makefile->GetGlobalGenerator(); this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance(); // The configuration being linked. this->HasConfig = !config.empty(); this->Config = (this->HasConfig)? config : std::string(); - this->LinkType = this->Target->ComputeLinkType(this->Config); + this->LinkType = this->Target->Target->ComputeLinkType(this->Config); // Enable debug mode if requested. this->DebugMode = this->Makefile->IsOn("CMAKE_LINK_DEPENDS_DEBUG_MODE"); @@ -363,7 +364,7 @@ void cmComputeLinkDepends::FollowLinkEntry(BFSEntry const& qe) { // Follow the target dependencies. if(cmTarget::LinkInterface const* iface = - entry.Target->GetLinkInterface(this->Config, this->Target)) + entry.Target->GetLinkInterface(this->Config, this->Target->Target)) { const bool isIface = entry.Target->GetType() == cmTarget::INTERFACE_LIBRARY; @@ -461,7 +462,7 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep) if(entry.Target) { if(cmTarget::LinkInterface const* iface = - entry.Target->GetLinkInterface(this->Config, this->Target)) + entry.Target->GetLinkInterface(this->Config, this->Target->Target)) { // Follow public and private dependencies transitively. this->FollowSharedDeps(index, iface, true); @@ -552,7 +553,7 @@ void cmComputeLinkDepends::AddDirectLinkEntries() { // Add direct link dependencies in this configuration. cmTarget::LinkImplementation const* impl = - this->Target->GetLinkImplementation(this->Config); + this->Target->Target->GetLinkImplementation(this->Config); this->AddLinkEntries(-1, impl->Libraries); for(std::vector::const_iterator wi = impl->WrongConfigLibraries.begin(); @@ -634,7 +635,7 @@ cmTarget const* cmComputeLinkDepends::FindTargetToLink(int depender_index, const std::string& name) { // Look for a target in the scope of the depender. - cmTarget const* from = this->Target; + cmTarget const* from = this->Target->Target; if(depender_index >= 0) { if(cmTarget const* depender = this->EntryList[depender_index].Target) @@ -932,7 +933,7 @@ int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl) if(cmTarget const* target = this->EntryList[*ni].Target) { if(cmTarget::LinkInterface const* iface = - target->GetLinkInterface(this->Config, this->Target)) + target->GetLinkInterface(this->Config, this->Target->Target)) { if(iface->Multiplicity > count) { diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index 51a08c5..b925a4f 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -22,6 +22,7 @@ class cmComputeComponentGraph; class cmGlobalGenerator; class cmMakefile; +class cmGeneratorTarget; class cmTarget; class cmake; @@ -31,7 +32,8 @@ class cmake; class cmComputeLinkDepends { public: - cmComputeLinkDepends(cmTarget const* target, const std::string& config); + cmComputeLinkDepends(cmGeneratorTarget const* target, + const std::string& config); ~cmComputeLinkDepends(); // Basic information about each link item. @@ -57,7 +59,7 @@ public: private: // Context information. - cmTarget const* Target; + cmGeneratorTarget const* Target; cmMakefile* Makefile; cmGlobalGenerator const* GlobalGenerator; cmake* CMakeInstance; diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 7d1cbc7..412e63b 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -497,7 +497,7 @@ bool cmComputeLinkInformation::Compute() } // Compute the ordered link line items. - cmComputeLinkDepends cld(this->Target->Target, this->Config); + cmComputeLinkDepends cld(this->Target, this->Config); cld.SetOldLinkDirMode(this->OldLinkDirMode); cmComputeLinkDepends::EntryVector const& linkEntries = cld.Compute(); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=de140650d16cfdf43c09b32d44dd3996012e7731 commit de140650d16cfdf43c09b32d44dd3996012e7731 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:50 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 17:50:42 2015 +0200 cmComputeLinkInformation: Port to cmGeneratorTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 5afaf87..7d1cbc7 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -242,11 +242,12 @@ because this need be done only for shared libraries without soname-s. //---------------------------------------------------------------------------- cmComputeLinkInformation -::cmComputeLinkInformation(cmTarget const* target, const std::string& config) +::cmComputeLinkInformation(const cmGeneratorTarget* target, + const std::string& config) { // Store context information. this->Target = target; - this->Makefile = this->Target->GetMakefile(); + this->Makefile = this->Target->Target->GetMakefile(); this->GlobalGenerator = this->Makefile->GetGlobalGenerator(); this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance(); @@ -259,17 +260,15 @@ cmComputeLinkInformation // Allocate internals. this->OrderLinkerSearchPath = - new cmOrderDirectories(this->GlobalGenerator, target, + new cmOrderDirectories(this->GlobalGenerator, target->Target, "linker search path"); this->OrderRuntimeSearchPath = - new cmOrderDirectories(this->GlobalGenerator, target, + new cmOrderDirectories(this->GlobalGenerator, target->Target, "runtime search path"); this->OrderDependentRPath = 0; - cmGeneratorTarget *gtgt = this->GlobalGenerator - ->GetGeneratorTarget(this->Target); // Get the language used for linking this target. - this->LinkLanguage = gtgt->GetLinkerLanguage(config); + this->LinkLanguage = this->Target->GetLinkerLanguage(config); if(this->LinkLanguage.empty()) { // The Compute method will do nothing, so skip the rest of the @@ -283,14 +282,14 @@ cmComputeLinkInformation // Check whether we should skip dependencies on shared library files. this->LinkDependsNoShared = - this->Target->GetPropertyAsBool("LINK_DEPENDS_NO_SHARED"); + this->Target->Target->GetPropertyAsBool("LINK_DEPENDS_NO_SHARED"); // On platforms without import libraries there may be a special flag // to use when creating a plugin (module) that obtains symbols from // the program that will load it. this->LoaderFlag = 0; if(!this->UseImportLibrary && - this->Target->GetType() == cmTarget::MODULE_LIBRARY) + this->Target->Target->GetType() == cmTarget::MODULE_LIBRARY) { std::string loader_flag_var = "CMAKE_SHARED_MODULE_LOADER_"; loader_flag_var += this->LinkLanguage; @@ -308,10 +307,10 @@ cmComputeLinkInformation // Get options needed to specify RPATHs. this->RuntimeUseChrpath = false; - if(this->Target->GetType() != cmTarget::STATIC_LIBRARY) + if(this->Target->Target->GetType() != cmTarget::STATIC_LIBRARY) { const char* tType = - ((this->Target->GetType() == cmTarget::EXECUTABLE)? + ((this->Target->Target->GetType() == cmTarget::EXECUTABLE)? "EXECUTABLE" : "SHARED_LIBRARY"); std::string rtVar = "CMAKE_"; rtVar += tType; @@ -325,7 +324,7 @@ cmComputeLinkInformation (this->Makefile-> GetSafeDefinition("CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH")); - this->RuntimeUseChrpath = gtgt->IsChrpathUsed(config); + this->RuntimeUseChrpath = this->Target->IsChrpathUsed(config); // Get options needed to help find dependent libraries. std::string rlVar = "CMAKE_"; @@ -371,15 +370,15 @@ cmComputeLinkInformation { this->SharedDependencyMode = SharedDepModeDir; this->OrderDependentRPath = - new cmOrderDirectories(this->GlobalGenerator, target, + new cmOrderDirectories(this->GlobalGenerator, target->Target, "dependent library path"); } // Add the search path entries requested by the user to path ordering. this->OrderLinkerSearchPath - ->AddUserDirectories(this->Target->GetLinkDirectories()); + ->AddUserDirectories(this->Target->Target->GetLinkDirectories()); this->OrderRuntimeSearchPath - ->AddUserDirectories(this->Target->GetLinkDirectories()); + ->AddUserDirectories(this->Target->Target->GetLinkDirectories()); // Set up the implicit link directories. this->LoadImplicitLinkInfo(); @@ -407,12 +406,13 @@ cmComputeLinkInformation // order to support such projects we need to add the directories // containing libraries linked with a full path to the -L path. this->OldLinkDirMode = - this->Target->GetPolicyStatusCMP0003() != cmPolicies::NEW; + this->Target->Target->GetPolicyStatusCMP0003() != cmPolicies::NEW; if(this->OldLinkDirMode) { // Construct a mask to not bother with this behavior for link // directories already specified by the user. - std::vector const& dirs = this->Target->GetLinkDirectories(); + std::vector const& dirs = + this->Target->Target->GetLinkDirectories(); this->OldLinkDirMask.insert(dirs.begin(), dirs.end()); } @@ -497,7 +497,7 @@ bool cmComputeLinkInformation::Compute() } // Compute the ordered link line items. - cmComputeLinkDepends cld(this->Target, this->Config); + cmComputeLinkDepends cld(this->Target->Target, this->Config); cld.SetOldLinkDirMode(this->OldLinkDirMode); cmComputeLinkDepends::EntryVector const& linkEntries = cld.Compute(); @@ -518,7 +518,8 @@ bool cmComputeLinkInformation::Compute() // Restore the target link type so the correct system runtime // libraries are found. - const char* lss = this->Target->GetProperty("LINK_SEARCH_END_STATIC"); + const char* lss = + this->Target->Target->GetProperty("LINK_SEARCH_END_STATIC"); if(cmSystemTools::IsOn(lss)) { this->SetCurrentLinkType(LinkStatic); @@ -571,7 +572,7 @@ bool cmComputeLinkInformation::Compute() "name." ; this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); } return true; @@ -580,12 +581,9 @@ bool cmComputeLinkInformation::Compute() //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddImplicitLinkInfo() { - cmGeneratorTarget *gtgt = this->Target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(this->Target); - // The link closure lists all languages whose implicit info is needed. - cmGeneratorTarget::LinkClosure const* lc=gtgt->GetLinkClosure(this->Config); + cmGeneratorTarget::LinkClosure const* lc = + this->Target->GetLinkClosure(this->Config); for(std::vector::const_iterator li = lc->Languages.begin(); li != lc->Languages.end(); ++li) { @@ -864,7 +862,8 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo() } // Lookup the starting link type from the target (linked statically?). - const char* lss = this->Target->GetProperty("LINK_SEARCH_START_STATIC"); + const char* lss = + this->Target->Target->GetProperty("LINK_SEARCH_START_STATIC"); this->StartLinkType = cmSystemTools::IsOn(lss)? LinkStatic : LinkShared; this->CurrentLinkType = this->StartLinkType; } @@ -1150,7 +1149,7 @@ void cmComputeLinkInformation::AddFullItem(std::string const& item) // Full path libraries should specify a valid library file name. // See documentation of CMP0008. std::string generator = this->GlobalGenerator->GetName(); - if(this->Target->GetPolicyStatusCMP0008() != cmPolicies::NEW && + if(this->Target->Target->GetPolicyStatusCMP0008() != cmPolicies::NEW && (generator.find("Visual Studio") != generator.npos || generator.find("Xcode") != generator.npos)) { @@ -1231,7 +1230,7 @@ bool cmComputeLinkInformation::CheckImplicitDirItem(std::string const& item) } // Check the policy for whether we should use the approach below. - switch (this->Target->GetPolicyStatusCMP0060()) + switch (this->Target->Target->GetPolicyStatusCMP0060()) { case cmPolicies::WARN: if (this->CMP0060Warn) @@ -1541,7 +1540,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item, this->OrderLinkerSearchPath->AddLinkLibrary(item); // Produce any needed message. - switch(this->Target->GetPolicyStatusCMP0008()) + switch(this->Target->Target->GetPolicyStatusCMP0008()) { case cmPolicies::WARN: { @@ -1558,7 +1557,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item, << " " << item << "\n" << "which is a full-path but not a valid library file name."; this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); } } case cmPolicies::OLD: @@ -1576,7 +1575,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item, << " " << item << "\n" << "which is a full-path but not a valid library file name."; this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); } break; } @@ -1593,7 +1592,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories() } // Enforce policy constraints. - switch(this->Target->GetPolicyStatusCMP0003()) + switch(this->Target->Target->GetPolicyStatusCMP0003()) { case cmPolicies::WARN: if(!this->CMakeInstance->GetState() @@ -1604,7 +1603,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories() std::ostringstream w; this->PrintLinkPolicyDiagnosis(w); this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); } case cmPolicies::OLD: // OLD behavior is to add the paths containing libraries with @@ -1620,7 +1619,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories() e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0003) << "\n"; this->PrintLinkPolicyDiagnosis(e); this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); return false; } } @@ -1924,23 +1923,24 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, // build tree. bool linking_for_install = (for_install || - this->Target->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")); + this->Target->Target->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")); bool use_install_rpath = - (outputRuntime && this->Target->HaveInstallTreeRPATH() && + (outputRuntime && this->Target->Target->HaveInstallTreeRPATH() && linking_for_install); bool use_build_rpath = - (outputRuntime && this->Target->HaveBuildTreeRPATH(this->Config) && + (outputRuntime && this->Target->Target->HaveBuildTreeRPATH(this->Config) && !linking_for_install); bool use_link_rpath = outputRuntime && linking_for_install && !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH") && - this->Target->GetPropertyAsBool("INSTALL_RPATH_USE_LINK_PATH"); + this->Target->Target->GetPropertyAsBool("INSTALL_RPATH_USE_LINK_PATH"); // Construct the RPATH. std::set emitted; if(use_install_rpath) { - const char* install_rpath = this->Target->GetProperty("INSTALL_RPATH"); + const char* install_rpath = + this->Target->Target->GetProperty("INSTALL_RPATH"); cmCLI_ExpandListUnique(install_rpath, runtimeDirs, emitted); } if(use_build_rpath || use_link_rpath) @@ -2012,12 +2012,8 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, // Add runtime paths required by the languages to always be // present. This is done even when skipping rpath support. { - cmGeneratorTarget *gtgt = this->Makefile - ->GetGlobalGenerator() - ->GetGeneratorTarget(this->Target); - cmGeneratorTarget::LinkClosure const* lc = - gtgt->GetLinkClosure(this->Config); + this->Target->GetLinkClosure(this->Config); for(std::vector::const_iterator li = lc->Languages.begin(); li != lc->Languages.end(); ++li) { diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index 2d7a5a5..8b83574 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -29,7 +29,8 @@ class cmOrderDirectories; class cmComputeLinkInformation { public: - cmComputeLinkInformation(cmTarget const* target, const std::string& config); + cmComputeLinkInformation(cmGeneratorTarget const* target, + const std::string& config); ~cmComputeLinkInformation(); bool Compute(); @@ -73,7 +74,7 @@ private: std::set SharedLibrariesLinked; // Context information. - cmTarget const* Target; + cmGeneratorTarget const* Target; cmMakefile* Makefile; cmGlobalGenerator* GlobalGenerator; cmake* CMakeInstance; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c68c2b9..55e2922 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3166,7 +3166,7 @@ cmGeneratorTarget::GetLinkInformation(const std::string& config) const { // Compute information for this configuration. cmComputeLinkInformation* info = - new cmComputeLinkInformation(this->Target, config); + new cmComputeLinkInformation(this, config); if(!info || !info->Compute()) { delete info; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2650762ff98c0c77cfc70209da308dc9d83ba974 commit 2650762ff98c0c77cfc70209da308dc9d83ba974 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:49 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 17:50:42 2015 +0200 cmGeneratorTarget: Move IsBundleOnApple from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c314372..c68c2b9 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -910,6 +910,14 @@ cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, } //---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsBundleOnApple() const +{ + return this->Target->IsFrameworkOnApple() + || this->Target->IsAppBundleOnApple() + || this->Target->IsCFBundleOnApple(); +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config, bool contentOnly) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index a1193a6..21e0900 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -119,6 +119,10 @@ public: std::string GetAppBundleDirectory(const std::string& config, bool contentOnly) const; + /** Return whether this target is an executable Bundle, a framework + or CFBundle on Apple. */ + bool IsBundleOnApple() const; + /** Get the full name of the target according to the settings in its makefile. */ std::string GetFullName(const std::string& config="", diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index d38cf4c..0b3df90 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -313,7 +313,7 @@ cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator() (cmSourceFile const& source, const char* pkgloc) { // Skip OS X content when not building a Framework or Bundle. - if(!this->Generator->GetTarget()->IsBundleOnApple()) + if(!this->Generator->GetGeneratorTarget()->IsBundleOnApple()) { return; } diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 16e1f48..07efa16 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -742,7 +742,7 @@ cmNinjaTargetGenerator::MacOSXContentGeneratorType::operator()( cmSourceFile const& source, const char* pkgloc) { // Skip OS X content when not building a Framework or Bundle. - if(!this->Generator->GetTarget()->IsBundleOnApple()) + if(!this->Generator->GetGeneratorTarget()->IsBundleOnApple()) { return; } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 62aa12a..e887ef3 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -590,13 +590,6 @@ bool cmTarget::IsXCTestOnApple() const } //---------------------------------------------------------------------------- -bool cmTarget::IsBundleOnApple() const -{ - return this->IsFrameworkOnApple() || this->IsAppBundleOnApple() || - this->IsCFBundleOnApple(); -} - -//---------------------------------------------------------------------------- static bool processSources(cmTarget const* tgt, const std::vector &entries, std::vector &srcs, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 9a4915f..e53afff 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -424,10 +424,6 @@ public: /** Return whether this target is an executable Bundle on Apple. */ bool IsAppBundleOnApple() const; - /** Return whether this target is an executable Bundle, a framework - or CFBundle on Apple. */ - bool IsBundleOnApple() const; - /** Return the framework version string. Undefined if IsFrameworkOnApple returns false. */ std::string GetFrameworkVersion() const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ebbdeee5ae3b52963ac3511e6aee14506fb07a90 commit ebbdeee5ae3b52963ac3511e6aee14506fb07a90 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:49 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 17:50:42 2015 +0200 cmMakefileTargetGenerator: Add accessor for GeneratorTarget. diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index b885672..fd4527b 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -53,6 +53,7 @@ public: { return this->ProgressFileNameFull; } cmTarget* GetTarget() { return this->Target;} + cmGeneratorTarget* GetGeneratorTarget() { return this->GeneratorTarget;} protected: http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=13d7afe429e80c84b0dffe7d82fde70ee4862fe3 commit 13d7afe429e80c84b0dffe7d82fde70ee4862fe3 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:49 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 17:50:41 2015 +0200 cmGeneratorTarget: Move GetLinkClosure from cmTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index e9c67af..5afaf87 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -19,6 +19,7 @@ #include "cmOutputConverter.h" #include "cmMakefile.h" #include "cmTarget.h" +#include "cmGeneratorTarget.h" #include "cmake.h" #include "cmAlgorithms.h" @@ -579,8 +580,12 @@ bool cmComputeLinkInformation::Compute() //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddImplicitLinkInfo() { + cmGeneratorTarget *gtgt = this->Target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(this->Target); + // The link closure lists all languages whose implicit info is needed. - cmTarget::LinkClosure const* lc=this->Target->GetLinkClosure(this->Config); + cmGeneratorTarget::LinkClosure const* lc=gtgt->GetLinkClosure(this->Config); for(std::vector::const_iterator li = lc->Languages.begin(); li != lc->Languages.end(); ++li) { @@ -2007,8 +2012,12 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, // Add runtime paths required by the languages to always be // present. This is done even when skipping rpath support. { - cmTarget::LinkClosure const* lc = - this->Target->GetLinkClosure(this->Config); + cmGeneratorTarget *gtgt = this->Makefile + ->GetGlobalGenerator() + ->GetGeneratorTarget(this->Target); + + cmGeneratorTarget::LinkClosure const* lc = + gtgt->GetLinkClosure(this->Config); for(std::vector::const_iterator li = lc->Languages.begin(); li != lc->Languages.end(); ++li) { diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index 3afbb92..2d7a5a5 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -20,6 +20,7 @@ class cmake; class cmGlobalGenerator; class cmMakefile; class cmTarget; +class cmGeneratorTarget; class cmOrderDirectories; /** \class cmComputeLinkInformation diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 4de5e9c..c314372 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -27,6 +27,13 @@ #include #include "assert.h" +#if defined(CMAKE_BUILD_WITH_CMAKE) +#include +#define UNORDERED_SET cmsys::hash_set +#else +#define UNORDERED_SET std::set +#endif + //---------------------------------------------------------------------------- void reportBadObjLib(std::vector const& badObjLib, cmTarget *target, cmake *cm) @@ -1026,6 +1033,223 @@ std::string cmGeneratorTarget::GetInstallNameDirForInstallTree() const } //---------------------------------------------------------------------------- +class cmTargetCollectLinkLanguages +{ +public: + cmTargetCollectLinkLanguages(cmGeneratorTarget const* target, + const std::string& config, + UNORDERED_SET& languages, + cmTarget const* head): + Config(config), Languages(languages), HeadTarget(head), + Makefile(target->Target->GetMakefile()), Target(target) + { this->Visited.insert(target->Target); } + + void Visit(cmLinkItem const& item) + { + if(!item.Target) + { + if(item.find("::") != std::string::npos) + { + bool noMessage = false; + cmake::MessageType messageType = cmake::FATAL_ERROR; + std::stringstream e; + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0028)) + { + case cmPolicies::WARN: + { + e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0028) << "\n"; + messageType = cmake::AUTHOR_WARNING; + } + break; + case cmPolicies::OLD: + noMessage = true; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::NEW: + // Issue the fatal message. + break; + } + + if(!noMessage) + { + e << "Target \"" << this->Target->GetName() + << "\" links to target \"" << item + << "\" but the target was not found. Perhaps a find_package() " + "call is missing for an IMPORTED target, or an ALIAS target is " + "missing?"; + this->Makefile->GetCMakeInstance()->IssueMessage( + messageType, e.str(), this->Target->Target->GetBacktrace()); + } + } + return; + } + if(!this->Visited.insert(item.Target).second) + { + return; + } + + cmTarget::LinkInterface const* iface = + item.Target->GetLinkInterface(this->Config, this->HeadTarget); + if(!iface) { return; } + + for(std::vector::const_iterator + li = iface->Languages.begin(); li != iface->Languages.end(); ++li) + { + this->Languages.insert(*li); + } + + for(std::vector::const_iterator + li = iface->Libraries.begin(); li != iface->Libraries.end(); ++li) + { + this->Visit(*li); + } + } +private: + std::string Config; + UNORDERED_SET& Languages; + cmTarget const* HeadTarget; + cmMakefile* Makefile; + const cmGeneratorTarget* Target; + std::set Visited; +}; + +//---------------------------------------------------------------------------- +cmGeneratorTarget::LinkClosure const* +cmGeneratorTarget::GetLinkClosure(const std::string& config) const +{ + std::string key(cmSystemTools::UpperCase(config)); + LinkClosureMapType::iterator + i = this->LinkClosureMap.find(key); + if(i == this->LinkClosureMap.end()) + { + LinkClosure lc; + this->ComputeLinkClosure(config, lc); + LinkClosureMapType::value_type entry(key, lc); + i = this->LinkClosureMap.insert(entry).first; + } + return &i->second; +} + +//---------------------------------------------------------------------------- +class cmTargetSelectLinker +{ + int Preference; + cmGeneratorTarget const* Target; + cmMakefile* Makefile; + cmGlobalGenerator* GG; + std::set Preferred; +public: + cmTargetSelectLinker(cmGeneratorTarget const* target) + : Preference(0), Target(target) + { + this->Makefile = this->Target->Makefile; + this->GG = this->Makefile->GetGlobalGenerator(); + } + void Consider(const char* lang) + { + int preference = this->GG->GetLinkerPreference(lang); + if(preference > this->Preference) + { + this->Preference = preference; + this->Preferred.clear(); + } + if(preference == this->Preference) + { + this->Preferred.insert(lang); + } + } + std::string Choose() + { + if(this->Preferred.empty()) + { + return ""; + } + else if(this->Preferred.size() > 1) + { + std::stringstream e; + e << "Target " << this->Target->GetName() + << " contains multiple languages with the highest linker preference" + << " (" << this->Preference << "):\n"; + for(std::set::const_iterator + li = this->Preferred.begin(); li != this->Preferred.end(); ++li) + { + e << " " << *li << "\n"; + } + e << "Set the LINKER_LANGUAGE property for this target."; + cmake* cm = this->Makefile->GetCMakeInstance(); + cm->IssueMessage(cmake::FATAL_ERROR, e.str(), + this->Target->Target->GetBacktrace()); + } + return *this->Preferred.begin(); + } +}; + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::ComputeLinkClosure(const std::string& config, + LinkClosure& lc) const +{ + // Get languages built in this target. + UNORDERED_SET languages; + cmTarget::LinkImplementation const* impl = + this->Target->GetLinkImplementation(config); + for(std::vector::const_iterator li = impl->Languages.begin(); + li != impl->Languages.end(); ++li) + { + languages.insert(*li); + } + + // Add interface languages from linked targets. + cmTargetCollectLinkLanguages cll(this, config, languages, this->Target); + for(std::vector::const_iterator li = impl->Libraries.begin(); + li != impl->Libraries.end(); ++li) + { + cll.Visit(*li); + } + + // Store the transitive closure of languages. + for(UNORDERED_SET::const_iterator li = languages.begin(); + li != languages.end(); ++li) + { + lc.Languages.push_back(*li); + } + + // Choose the language whose linker should be used. + if(this->GetProperty("HAS_CXX")) + { + lc.LinkerLanguage = "CXX"; + } + else if(const char* linkerLang = this->GetProperty("LINKER_LANGUAGE")) + { + lc.LinkerLanguage = linkerLang; + } + else + { + // Find the language with the highest preference value. + cmTargetSelectLinker tsl(this); + + // First select from the languages compiled directly in this target. + for(std::vector::const_iterator li = impl->Languages.begin(); + li != impl->Languages.end(); ++li) + { + tsl.Consider(li->c_str()); + } + + // Now consider languages that propagate from linked targets. + for(UNORDERED_SET::const_iterator sit = languages.begin(); + sit != languages.end(); ++sit) + { + std::string propagates = "CMAKE_"+*sit+"_LINKER_PREFERENCE_PROPAGATES"; + if(this->Makefile->IsOn(propagates)) + { + tsl.Consider(sit->c_str()); + } + } + + lc.LinkerLanguage = tsl.Choose(); + } +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, std::string& base, std::string& suffix, @@ -2058,7 +2282,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, std::string cmGeneratorTarget::GetLinkerLanguage(const std::string& config) const { - return this->Target->GetLinkClosure(config)->LinkerLanguage; + return this->GetLinkClosure(config)->LinkerLanguage; } //---------------------------------------------------------------------------- diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 41fb848..a1193a6 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -165,6 +165,20 @@ public: std::string GetModuleDefinitionFile(const std::string& config) const; + /** Link information from the transitive closure of the link + implementation and the interfaces of its dependencies. */ + struct LinkClosure + { + // The preferred linker language. + std::string LinkerLanguage; + + // Languages whose runtime libraries must be linked. + std::vector Languages; + }; + + LinkClosure const* GetLinkClosure(const std::string& config) const; + void ComputeLinkClosure(const std::string& config, LinkClosure& lc) const; + /** Full path with trailing slash to the top-level directory holding object files for this target. Includes the build time config name placeholder if needed for the generator. */ @@ -301,6 +315,9 @@ private: std::string& outPrefix, std::string& outBase, std::string& outSuffix) const; + typedef std::map LinkClosureMapType; + mutable LinkClosureMapType LinkClosureMap; + struct CompatibleInterfacesBase { std::set PropsBool; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index c7118dc..62aa12a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -160,9 +160,6 @@ public: HeadToLinkImplementationMap> LinkImplMapType; LinkImplMapType LinkImplMap; - typedef std::map LinkClosureMapType; - LinkClosureMapType LinkClosureMap; - typedef std::map > SourceFilesMapType; SourceFilesMapType SourceFilesMap; @@ -511,7 +508,6 @@ void cmTarget::ClearLinkMaps() this->Internal->LinkImplMap.clear(); this->Internal->LinkInterfaceMap.clear(); this->Internal->LinkInterfaceUsageRequirementsOnlyMap.clear(); - this->Internal->LinkClosureMap.clear(); this->Internal->SourceFilesMap.clear(); } @@ -3136,223 +3132,6 @@ bool cmTarget::GetPropertyAsBool(const std::string& prop) const } //---------------------------------------------------------------------------- -class cmTargetCollectLinkLanguages -{ -public: - cmTargetCollectLinkLanguages(cmTarget const* target, - const std::string& config, - UNORDERED_SET& languages, - cmTarget const* head): - Config(config), Languages(languages), HeadTarget(head), - Makefile(target->GetMakefile()), Target(target) - { this->Visited.insert(target); } - - void Visit(cmLinkItem const& item) - { - if(!item.Target) - { - if(item.find("::") != std::string::npos) - { - bool noMessage = false; - cmake::MessageType messageType = cmake::FATAL_ERROR; - std::ostringstream e; - switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0028)) - { - case cmPolicies::WARN: - { - e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0028) << "\n"; - messageType = cmake::AUTHOR_WARNING; - } - break; - case cmPolicies::OLD: - noMessage = true; - case cmPolicies::REQUIRED_IF_USED: - case cmPolicies::REQUIRED_ALWAYS: - case cmPolicies::NEW: - // Issue the fatal message. - break; - } - - if(!noMessage) - { - e << "Target \"" << this->Target->GetName() - << "\" links to target \"" << item - << "\" but the target was not found. Perhaps a find_package() " - "call is missing for an IMPORTED target, or an ALIAS target is " - "missing?"; - this->Makefile->GetCMakeInstance()->IssueMessage(messageType, - e.str(), - this->Target->GetBacktrace()); - } - } - return; - } - if(!this->Visited.insert(item.Target).second) - { - return; - } - - cmTarget::LinkInterface const* iface = - item.Target->GetLinkInterface(this->Config, this->HeadTarget); - if(!iface) { return; } - - for(std::vector::const_iterator - li = iface->Languages.begin(); li != iface->Languages.end(); ++li) - { - this->Languages.insert(*li); - } - - for(std::vector::const_iterator - li = iface->Libraries.begin(); li != iface->Libraries.end(); ++li) - { - this->Visit(*li); - } - } -private: - std::string Config; - UNORDERED_SET& Languages; - cmTarget const* HeadTarget; - cmMakefile* Makefile; - const cmTarget* Target; - std::set Visited; -}; - -//---------------------------------------------------------------------------- -cmTarget::LinkClosure const* -cmTarget::GetLinkClosure(const std::string& config) const -{ - std::string key(cmSystemTools::UpperCase(config)); - cmTargetInternals::LinkClosureMapType::iterator - i = this->Internal->LinkClosureMap.find(key); - if(i == this->Internal->LinkClosureMap.end()) - { - LinkClosure lc; - this->ComputeLinkClosure(config, lc); - cmTargetInternals::LinkClosureMapType::value_type entry(key, lc); - i = this->Internal->LinkClosureMap.insert(entry).first; - } - return &i->second; -} - -//---------------------------------------------------------------------------- -class cmTargetSelectLinker -{ - int Preference; - cmTarget const* Target; - cmMakefile* Makefile; - cmGlobalGenerator* GG; - UNORDERED_SET Preferred; -public: - cmTargetSelectLinker(cmTarget const* target): Preference(0), Target(target) - { - this->Makefile = this->Target->GetMakefile(); - this->GG = this->Makefile->GetGlobalGenerator(); - } - void Consider(const std::string& lang) - { - int preference = this->GG->GetLinkerPreference(lang); - if(preference > this->Preference) - { - this->Preference = preference; - this->Preferred.clear(); - } - if(preference == this->Preference) - { - this->Preferred.insert(lang); - } - } - std::string Choose() - { - if(this->Preferred.empty()) - { - return ""; - } - else if(this->Preferred.size() > 1) - { - std::ostringstream e; - e << "Target " << this->Target->GetName() - << " contains multiple languages with the highest linker preference" - << " (" << this->Preference << "):\n"; - for(UNORDERED_SET::const_iterator - li = this->Preferred.begin(); li != this->Preferred.end(); ++li) - { - e << " " << *li << "\n"; - } - e << "Set the LINKER_LANGUAGE property for this target."; - cmake* cm = this->Makefile->GetCMakeInstance(); - cm->IssueMessage(cmake::FATAL_ERROR, e.str(), - this->Target->GetBacktrace()); - } - return *this->Preferred.begin(); - } -}; - -//---------------------------------------------------------------------------- -void cmTarget::ComputeLinkClosure(const std::string& config, - LinkClosure& lc) const -{ - // Get languages built in this target. - UNORDERED_SET languages; - LinkImplementation const* impl = this->GetLinkImplementation(config); - for(std::vector::const_iterator li = impl->Languages.begin(); - li != impl->Languages.end(); ++li) - { - languages.insert(*li); - } - - // Add interface languages from linked targets. - cmTargetCollectLinkLanguages cll(this, config, languages, this); - for(std::vector::const_iterator - li = impl->Libraries.begin(); - li != impl->Libraries.end(); ++li) - { - cll.Visit(*li); - } - - // Store the transitive closure of languages. - for(UNORDERED_SET::const_iterator li = languages.begin(); - li != languages.end(); ++li) - { - lc.Languages.push_back(*li); - } - - // Choose the language whose linker should be used. - if(this->GetProperty("HAS_CXX")) - { - lc.LinkerLanguage = "CXX"; - } - else if(const char* linkerLang = this->GetProperty("LINKER_LANGUAGE")) - { - lc.LinkerLanguage = linkerLang; - } - else - { - // Find the language with the highest preference value. - cmTargetSelectLinker tsl(this); - - // First select from the languages compiled directly in this target. - for(std::vector::const_iterator li = impl->Languages.begin(); - li != impl->Languages.end(); ++li) - { - tsl.Consider(*li); - } - - // Now consider languages that propagate from linked targets. - for(UNORDERED_SET::const_iterator sit = languages.begin(); - sit != languages.end(); ++sit) - { - std::string propagates = "CMAKE_"+*sit+"_LINKER_PREFERENCE_PROPAGATES"; - if(this->Makefile->IsOn(propagates)) - { - tsl.Consider(*sit); - } - } - - lc.LinkerLanguage = tsl.Choose(); - } -} - -//---------------------------------------------------------------------------- void cmTarget::ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index dea9bef..9a4915f 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -315,18 +315,6 @@ public: LinkImplementationLibraries const* GetLinkImplementationLibraries(const std::string& config) const; - /** Link information from the transitive closure of the link - implementation and the interfaces of its dependencies. */ - struct LinkClosure - { - // The preferred linker language. - std::string LinkerLanguage; - - // Languages whose runtime libraries must be linked. - std::vector Languages; - }; - LinkClosure const* GetLinkClosure(const std::string& config) const; - cmTarget const* FindTargetToLink(std::string const& name) const; /** Strip off leading and trailing whitespace from an item named in @@ -662,7 +650,6 @@ private: LinkImplementationLibraries const* GetLinkImplementationLibrariesInternal(const std::string& config, cmTarget const* head) const; - void ComputeLinkClosure(const std::string& config, LinkClosure& lc) const; void ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, cmTarget const* headTarget, http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=48d38cedf73fdb2b7872289e6636ff79033e59e9 commit 48d38cedf73fdb2b7872289e6636ff79033e59e9 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:49 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 17:50:41 2015 +0200 cmGeneratorTarget: Move GetLinkerLanguage from cmTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index cbb257e..e9c67af 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -265,8 +265,10 @@ cmComputeLinkInformation "runtime search path"); this->OrderDependentRPath = 0; + cmGeneratorTarget *gtgt = this->GlobalGenerator + ->GetGeneratorTarget(this->Target); // Get the language used for linking this target. - this->LinkLanguage = this->Target->GetLinkerLanguage(config); + this->LinkLanguage = gtgt->GetLinkerLanguage(config); if(this->LinkLanguage.empty()) { // The Compute method will do nothing, so skip the rest of the @@ -322,9 +324,6 @@ cmComputeLinkInformation (this->Makefile-> GetSafeDefinition("CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH")); - cmGeneratorTarget *gtgt = this->Target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(this->Target); this->RuntimeUseChrpath = gtgt->IsChrpathUsed(config); // Get options needed to help find dependent libraries. diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 49fc96b..a86c2bc 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -990,6 +990,9 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode assert(target); + cmGeneratorTarget* gtgt = + context->Makefile->GetGlobalGenerator()->GetGeneratorTarget(target); + if (propertyName == "LINKER_LANGUAGE") { if (target->LinkLanguagePropagatesToDependents() && @@ -1001,7 +1004,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode "link libraries for a static library"); return std::string(); } - return target->GetLinkerLanguage(context->Config); + return gtgt->GetLinkerLanguage(context->Config); } cmGeneratorExpressionDAGChecker dagChecker(context->Backtrace, @@ -1128,9 +1131,6 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode } } - cmGeneratorTarget* gtgt = - context->Makefile->GetGlobalGenerator()->GetGeneratorTarget(target); - if (!prop) { if (target->IsImported() @@ -1600,7 +1600,7 @@ struct TargetFilesystemArtifactResultCreator cmGeneratorExpressionContext *context, const GeneratorExpressionContent *content) { - std::string language = target->Target->GetLinkerLanguage(context->Config); + std::string language = target->GetLinkerLanguage(context->Config); std::string pdbSupportVar = "CMAKE_" + language + "_LINKER_SUPPORTS_PDB"; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 834a2e3..4de5e9c 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -709,8 +709,7 @@ bool cmGeneratorTarget::HasSOName(const std::string& config) const return ((this->GetType() == cmTarget::SHARED_LIBRARY || this->GetType() == cmTarget::MODULE_LIBRARY) && !this->GetPropertyAsBool("NO_SONAME") && - this->Makefile->GetSONameFlag( - this->Target->GetLinkerLanguage(config))); + this->Makefile->GetSONameFlag(this->GetLinkerLanguage(config))); } //---------------------------------------------------------------------------- @@ -752,7 +751,7 @@ cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const } // Check for rpath support on this platform. - std::string ll = this->Target->GetLinkerLanguage(config); + std::string ll = this->GetLinkerLanguage(config); if(!ll.empty()) { std::string flagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; @@ -823,7 +822,7 @@ bool cmGeneratorTarget::IsChrpathUsed(const std::string& config) const #if defined(CMAKE_USE_ELF_PARSER) // Enable if the rpath flag uses a separator and the target uses ELF // binaries. - std::string ll = this->Target->GetLinkerLanguage(config); + std::string ll = this->GetLinkerLanguage(config); if(!ll.empty()) { std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; @@ -1986,7 +1985,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, const char* suffixVar = this->Target->GetSuffixVariableInternal(implib); // Check for language-specific default prefix and suffix. - std::string ll = this->Target->GetLinkerLanguage(config); + std::string ll = this->GetLinkerLanguage(config); if(!ll.empty()) { if(!targetSuffix && suffixVar && *suffixVar) @@ -2056,6 +2055,13 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, //---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetLinkerLanguage(const std::string& config) const +{ + return this->Target->GetLinkClosure(config)->LinkerLanguage; +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetPDBName(const std::string& config) const { std::string prefix; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 7ee4fc5..41fb848 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -258,6 +258,9 @@ public: /** Return true if builtin chrpath will work for this target */ bool IsChrpathUsed(const std::string& config) const; + ///! Return the preferred linker language for this target + std::string GetLinkerLanguage(const std::string& config = "") const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index 2f9265a..1e57c33 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -128,7 +128,8 @@ void cmGhsMultiTargetGenerator::Generate() { config = "RELEASE"; } - const std::string language(this->Target->GetLinkerLanguage(config)); + const std::string language( + this->GeneratorTarget->GetLinkerLanguage(config)); config = cmSystemTools::UpperCase(config); this->DynamicDownload = this->DetermineIfDynamicDownload(config, language); if (this->DynamicDownload) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 7b0e153..5006828 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1376,7 +1376,8 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmTarget& cmtarget) return; } - std::string llang = cmtarget.GetLinkerLanguage("NOCONFIG"); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&cmtarget); + std::string llang = gtgt->GetLinkerLanguage("NOCONFIG"); if(llang.empty()) { return; } // If the language is compiled as a source trust Xcode to link with it. @@ -1824,7 +1825,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, AddCompileOptions(flags, &target, lang, configName); } - std::string llang = target.GetLinkerLanguage(configName); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); + std::string llang = gtgt->GetLinkerLanguage(configName); if(binary && llang.empty()) { cmSystemTools::Error @@ -1850,7 +1852,6 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, // Add the export symbol definition for shared library objects. this->AppendDefines(ppDefs, exportMacro); } - cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); std::vector targetDefines; target.GetCompileDefinitions(targetDefines, configName, "C"); this->AppendDefines(ppDefs, targetDefines); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 3ab501d..4ec77a1 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1353,7 +1353,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, linkFlags += this->Makefile->GetSafeDefinition(build); linkFlags += " "; } - std::string linkLanguage = target->Target->GetLinkerLanguage(buildType); + std::string linkLanguage = target->GetLinkerLanguage(buildType); if(linkLanguage.empty()) { cmSystemTools::Error diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 014d3be..29e1034 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1270,10 +1270,10 @@ void cmLocalVisualStudio6Generator std::vector configs; target.GetMakefile()->GetConfigurations(configs); std::vector::const_iterator it = configs.begin(); - const std::string& linkLanguage = target.GetLinkerLanguage(*it); + const std::string& linkLanguage = gt->GetLinkerLanguage(*it); for ( ; it != configs.end(); ++it) { - const std::string& configLinkLanguage = target.GetLinkerLanguage(*it); + const std::string& configLinkLanguage = gt->GetLinkerLanguage(*it); if (configLinkLanguage != linkLanguage) { cmSystemTools::Error @@ -1703,10 +1703,10 @@ void cmLocalVisualStudio6Generator std::vector configs; target.GetMakefile()->GetConfigurations(configs); std::vector::const_iterator it = configs.begin(); - const std::string& linkLanguage = target.GetLinkerLanguage(*it); + const std::string& linkLanguage = gt->GetLinkerLanguage(*it); for ( ; it != configs.end(); ++it) { - const std::string& configLinkLanguage = target.GetLinkerLanguage(*it); + const std::string& configLinkLanguage = gt->GetLinkerLanguage(*it); if (configLinkLanguage != linkLanguage) { cmSystemTools::Error diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 9f26712..a38a061 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -664,6 +664,10 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, const char* configType = "10"; const char* projectType = 0; bool targetBuilds = true; + + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); + switch(target.GetType()) { case cmTarget::OBJECT_LIBRARY: @@ -696,7 +700,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, { const std::string& linkLanguage = (this->FortranProject? std::string("Fortran"): - target.GetLinkerLanguage(configName)); + gt->GetLinkerLanguage(configName)); if(linkLanguage.empty()) { cmSystemTools::Error @@ -758,8 +762,6 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, targetOptions.Parse(flags.c_str()); targetOptions.Parse(defineFlags.c_str()); targetOptions.ParseFinish(); - cmGeneratorTarget* gt = - this->GlobalGenerator->GetGeneratorTarget(&target); std::vector targetDefines; target.GetCompileDefinitions(targetDefines, configName, "CXX"); targetOptions.AddDefines(targetDefines); @@ -1635,7 +1637,7 @@ cmLocalVisualStudio7GeneratorFCInfo lg->GlobalGenerator->GetLanguageFromExtension (sf.GetExtension().c_str()); const std::string& sourceLang = lg->GetSourceFileLanguage(sf); - const std::string& linkLanguage = target.GetLinkerLanguage(i->c_str()); + const std::string& linkLanguage = gt->GetLinkerLanguage(i->c_str()); bool needForceLang = false; // source file does not match its extension language if(lang != sourceLang) diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 2fd77c9..afe145a 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -161,7 +161,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) // Get the language to use for linking this executable. std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); // Make sure we have a link language. if(linkLanguage.empty()) diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index b85b8a8..bb0f9dd 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -133,7 +133,7 @@ void cmMakefileLibraryTargetGenerator::WriteObjectLibraryRules() void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules() { std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_STATIC_LIBRARY"; @@ -159,7 +159,7 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink) return; } std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_SHARED_LIBRARY"; @@ -183,7 +183,7 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink) void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink) { std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_SHARED_MODULE"; @@ -206,7 +206,7 @@ void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink) void cmMakefileLibraryTargetGenerator::WriteFrameworkRules(bool relink) { std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_MACOSX_FRAMEWORK"; @@ -238,7 +238,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules // Get the language to use for linking this library. std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); // Make sure we have a link language. if(linkLanguage.empty()) diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index b94e151..d38cf4c 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1509,7 +1509,7 @@ std::string cmMakefileTargetGenerator::GetLinkRule( if(this->Target->HasImplibGNUtoMS()) { std::string ruleVar = "CMAKE_"; - ruleVar += this->Target->GetLinkerLanguage(this->ConfigName); + ruleVar += this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); ruleVar += "_GNUtoMS_RULE"; if(const char* rule = this->Makefile->GetDefinition(ruleVar)) { @@ -1663,7 +1663,8 @@ cmMakefileTargetGenerator { // Lookup the response file reference flag. std::string responseFlagVar = "CMAKE_"; - responseFlagVar += this->Target->GetLinkerLanguage(this->ConfigName); + responseFlagVar += this->GeneratorTarget + ->GetLinkerLanguage(this->ConfigName); responseFlagVar += "_RESPONSE_FILE_LINK_FLAG"; const char* responseFlag = this->Makefile->GetDefinition(responseFlagVar); @@ -1707,7 +1708,8 @@ cmMakefileTargetGenerator // Lookup the response file reference flag. std::string responseFlagVar = "CMAKE_"; - responseFlagVar += this->Target->GetLinkerLanguage(this->ConfigName); + responseFlagVar += this->GeneratorTarget + ->GetLinkerLanguage(this->ConfigName); responseFlagVar += "_RESPONSE_FILE_LINK_FLAG"; const char* responseFlag = this->Makefile->GetDefinition(responseFlagVar); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 1835841..b855bea 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -40,8 +40,7 @@ cmNinjaNormalTargetGenerator(cmGeneratorTarget* target) , TargetNamePDB() , TargetLinkLanguage("") { - this->TargetLinkLanguage = target->Target - ->GetLinkerLanguage(this->GetConfigName()); + this->TargetLinkLanguage = target->GetLinkerLanguage(this->GetConfigName()); if (target->GetType() == cmTarget::EXECUTABLE) this->GetGeneratorTarget()->GetExecutableNames(this->TargetNameOut, this->TargetNameReal, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 37b788d..c7118dc 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3218,12 +3218,6 @@ private: }; //---------------------------------------------------------------------------- -std::string cmTarget::GetLinkerLanguage(const std::string& config) const -{ - return this->GetLinkClosure(config)->LinkerLanguage; -} - -//---------------------------------------------------------------------------- cmTarget::LinkClosure const* cmTarget::GetLinkClosure(const std::string& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index d0cbc66..dea9bef 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -365,9 +365,6 @@ public: void GetTargetVersion(bool soversion, int& major, int& minor, int& patch) const; - ///! Return the preferred linker language for this target - std::string GetLinkerLanguage(const std::string& config = "") const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 2b33c2c..80b8591 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1627,7 +1627,7 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( this->GlobalGenerator->GetLanguageFromExtension (sf.GetExtension().c_str()); std::string sourceLang = this->LocalGenerator->GetSourceFileLanguage(sf); - const std::string& linkLanguage = this->Target->GetLinkerLanguage(); + const std::string& linkLanguage = this->GeneratorTarget->GetLinkerLanguage(); bool needForceLang = false; // source file does not match its extension language if(lang != sourceLang) @@ -1888,7 +1888,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( std::string flags; const std::string& linkLanguage = - this->Target->GetLinkerLanguage(configName.c_str()); + this->GeneratorTarget->GetLinkerLanguage(configName.c_str()); if(linkLanguage.empty()) { cmSystemTools::Error @@ -2371,7 +2371,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) Options& linkOptions = *pOptions; const std::string& linkLanguage = - this->Target->GetLinkerLanguage(config.c_str()); + this->GeneratorTarget->GetLinkerLanguage(config.c_str()); if(linkLanguage.empty()) { cmSystemTools::Error http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8c976738ce700a7827874dab05ae14c555a8b08a commit 8c976738ce700a7827874dab05ae14c555a8b08a Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:48 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 17:50:41 2015 +0200 cmGeneratorTarget: Move GetFrameworkDirectory from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 436e5dd..834a2e3 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -904,6 +904,48 @@ cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config, + bool contentOnly) const +{ + std::string fpath; + fpath += this->Target->GetOutputName(config, false); + fpath += "."; + const char *ext = this->Target->GetProperty("BUNDLE_EXTENSION"); + if (!ext) + { + if (this->Target->IsXCTestOnApple()) + { + ext = "xctest"; + } + else + { + ext = "bundle"; + } + } + fpath += ext; + fpath += "/Contents"; + if(!contentOnly) + fpath += "/MacOS"; + return fpath; +} + +//---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetFrameworkDirectory(const std::string& config, + bool rootDir) const +{ + std::string fpath; + fpath += this->Target->GetOutputName(config, false); + fpath += ".framework"; + if(!rootDir) + { + fpath += "/Versions/"; + fpath += this->Target->GetFrameworkVersion(); + } + return fpath; +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetFullName(const std::string& config, bool implib) const { @@ -1007,11 +1049,11 @@ cmGeneratorTarget::BuildMacContentDirectory(const std::string& base, } if(this->Target->IsFrameworkOnApple()) { - fpath += this->Target->GetFrameworkDirectory(config, contentOnly); + fpath += this->GetFrameworkDirectory(config, contentOnly); } if(this->Target->IsCFBundleOnApple()) { - fpath += this->Target->GetCFBundleDirectory(config, contentOnly); + fpath += this->GetCFBundleDirectory(config, contentOnly); } return fpath; } @@ -1982,7 +2024,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, if(this->Target->IsCFBundleOnApple()) { - fw_prefix = this->Target->GetCFBundleDirectory(config, false); + fw_prefix = this->GetCFBundleDirectory(config, false); fw_prefix += "/"; targetPrefix = fw_prefix.c_str(); targetSuffix = 0; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 1dfdbb3..7ee4fc5 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -124,6 +124,14 @@ public: std::string GetFullName(const std::string& config="", bool implib = false) const; + /** @return the Mac framework directory without the base. */ + std::string GetFrameworkDirectory(const std::string& config, + bool rootDir) const; + + /** @return the Mac CFBundle directory without the base */ + std::string GetCFBundleDirectory(const std::string& config, + bool contentOnly) const; + /** Return the install name directory for the target in the * build tree. For example: "\@rpath/", "\@loader_path/", * or "/full/path/to/library". */ diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 1d85d9c..4fe99e3 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -77,11 +77,11 @@ void cmOSXBundleGenerator::CreateFramework( // Compute the location of the top-level foo.framework directory. std::string contentdir = outpath + "/" + - this->GT->Target->GetFrameworkDirectory(this->ConfigName, true); + this->GT->GetFrameworkDirectory(this->ConfigName, true); contentdir += "/"; std::string newoutpath = outpath + "/" + - this->GT->Target->GetFrameworkDirectory(this->ConfigName, false); + this->GT->GetFrameworkDirectory(this->ConfigName, false); std::string frameworkVersion = this->GT->Target->GetFrameworkVersion(); @@ -172,14 +172,14 @@ void cmOSXBundleGenerator::CreateCFBundle(const std::string& targetName, // Compute bundle directory names. std::string out = root; out += "/"; - out += this->GT->Target->GetCFBundleDirectory(this->ConfigName, false); + out += this->GT->GetCFBundleDirectory(this->ConfigName, false); cmSystemTools::MakeDirectory(out.c_str()); this->Makefile->AddCMakeOutputFile(out); // Configure the Info.plist file. Note that it needs the executable name // to be set. std::string plist = root + "/" + - this->GT->Target->GetCFBundleDirectory(this->ConfigName, true); + this->GT->GetCFBundleDirectory(this->ConfigName, true); plist += "/Info.plist"; std::string name = cmSystemTools::GetFilenameName(targetName); this->LocalGenerator->GenerateAppleInfoPList(this->GT->Target, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index a5ff829..37b788d 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -5126,47 +5126,6 @@ std::string cmTarget::CheckCMP0004(std::string const& item) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetFrameworkDirectory(const std::string& config, - bool rootDir) const -{ - std::string fpath; - fpath += this->GetOutputName(config, false); - fpath += ".framework"; - if(!rootDir) - { - fpath += "/Versions/"; - fpath += this->GetFrameworkVersion(); - } - return fpath; -} - -//---------------------------------------------------------------------------- -std::string cmTarget::GetCFBundleDirectory(const std::string& config, - bool contentOnly) const -{ - std::string fpath; - fpath += this->GetOutputName(config, false); - fpath += "."; - const char *ext = this->GetProperty("BUNDLE_EXTENSION"); - if (!ext) - { - if (this->IsXCTestOnApple()) - { - ext = "xctest"; - } - else - { - ext = "bundle"; - } - } - fpath += ext; - fpath += "/Contents"; - if(!contentOnly) - fpath += "/MacOS"; - return fpath; -} - -//---------------------------------------------------------------------------- cmTargetInternalPointer::cmTargetInternalPointer() { this->Pointer = new cmTargetInternals; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e22d3af..d0cbc66 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -460,14 +460,6 @@ public: /** @return whether this target have a well defined output file name. */ bool HaveWellDefinedOutputFiles() const; - /** @return the Mac framework directory without the base. */ - std::string GetFrameworkDirectory(const std::string& config, - bool rootDir) const; - - /** @return the Mac CFBundle directory without the base */ - std::string GetCFBundleDirectory(const std::string& config, - bool contentOnly) const; - std::vector GetIncludeDirectories( const std::string& config, const std::string& language) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=66ef59ba503d970a80691fe828f369a258ce69ff commit 66ef59ba503d970a80691fe828f369a258ce69ff Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:48 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 17:50:41 2015 +0200 cmGeneratorTarget: Move GetFullName from cmTarget. Bring GetFullNameInternal with it. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 0fdf646..436e5dd 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -576,7 +576,7 @@ const char* cmGeneratorTarget::GetLocationForBuild() const } } location += "/"; - location += this->Target->GetFullName("", false); + location += this->GetFullName("", false); return location.c_str(); } @@ -663,7 +663,7 @@ cmGeneratorTarget::GetCompilePDBName(const std::string& config) const std::string prefix; std::string base; std::string suffix; - this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, false, prefix, base, suffix); // Check for a per-configuration output directory target property. std::string configUpper = cmSystemTools::UpperCase(config); @@ -896,7 +896,7 @@ std::string cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, bool contentOnly) const { - std::string fpath = this->Target->GetFullName(config, false); + std::string fpath = this->GetFullName(config, false); fpath += ".app/Contents"; if(!contentOnly) fpath += "/MacOS"; @@ -905,6 +905,20 @@ cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, //---------------------------------------------------------------------------- std::string +cmGeneratorTarget::GetFullName(const std::string& config, bool implib) const +{ + if(this->Target->IsImported()) + { + return this->Target->GetFullNameImported(config, implib); + } + else + { + return this->GetFullNameInternal(config, implib); + } +} + +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetInstallNameDirForBuildTree( const std::string& config) const { @@ -977,7 +991,7 @@ void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, const std::string& config, bool implib) const { - this->Target->GetFullNameInternal(config, implib, prefix, base, suffix); + this->GetFullNameInternal(config, implib, prefix, base, suffix); } //---------------------------------------------------------------------------- @@ -1655,7 +1669,7 @@ std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config, // Add the full name of the target. if(implib) { - fpath += this->Target->GetFullName(config, true); + fpath += this->GetFullName(config, true); } else if(realname) { @@ -1663,7 +1677,7 @@ std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config, } else { - fpath += this->Target->GetFullName(config, false); + fpath += this->GetFullName(config, false); } return fpath; } @@ -1753,7 +1767,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, std::string prefix; std::string base; std::string suffix; - this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, false, prefix, base, suffix); // The library name. name = prefix+base+suffix; @@ -1782,7 +1796,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, if(this->GetType() == cmTarget::SHARED_LIBRARY || this->GetType() == cmTarget::MODULE_LIBRARY) { - impName = this->Target->GetFullNameInternal(config, true); + impName = this->GetFullNameInternal(config, true); } else { @@ -1828,7 +1842,7 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, std::string prefix; std::string base; std::string suffix; - this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, false, prefix, base, suffix); // The executable name. name = prefix+base+suffix; @@ -1849,19 +1863,163 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, #endif // The import library name. - impName = this->Target->GetFullNameInternal(config, true); + impName = this->GetFullNameInternal(config, true); // The program database file name. pdbName = this->GetPDBName(config); } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetFullNameInternal(const std::string& config, + bool implib) const +{ + std::string prefix; + std::string base; + std::string suffix; + this->GetFullNameInternal(config, implib, prefix, base, suffix); + return prefix+base+suffix; +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GetFullNameInternal(const std::string& config, + bool implib, + std::string& outPrefix, + std::string& outBase, + std::string& outSuffix) const +{ + // Use just the target name for non-main target types. + if(this->GetType() != cmTarget::STATIC_LIBRARY && + this->GetType() != cmTarget::SHARED_LIBRARY && + this->GetType() != cmTarget::MODULE_LIBRARY && + this->GetType() != cmTarget::EXECUTABLE) + { + outPrefix = ""; + outBase = this->GetName(); + outSuffix = ""; + return; + } + + // Return an empty name for the import library if this platform + // does not support import libraries. + if(implib && + !this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) + { + outPrefix = ""; + outBase = ""; + outSuffix = ""; + return; + } + + // The implib option is only allowed for shared libraries, module + // libraries, and executables. + if(this->GetType() != cmTarget::SHARED_LIBRARY && + this->GetType() != cmTarget::MODULE_LIBRARY && + this->GetType() != cmTarget::EXECUTABLE) + { + implib = false; + } + + // Compute the full name for main target types. + const char* targetPrefix = (implib + ? this->GetProperty("IMPORT_PREFIX") + : this->GetProperty("PREFIX")); + const char* targetSuffix = (implib + ? this->GetProperty("IMPORT_SUFFIX") + : this->GetProperty("SUFFIX")); + const char* configPostfix = 0; + if(!config.empty()) + { + std::string configProp = cmSystemTools::UpperCase(config); + configProp += "_POSTFIX"; + configPostfix = this->GetProperty(configProp); + // Mac application bundles and frameworks have no postfix. + if(configPostfix && + (this->Target->IsAppBundleOnApple() + || this->Target->IsFrameworkOnApple())) + { + configPostfix = 0; + } + } + const char* prefixVar = this->Target->GetPrefixVariableInternal(implib); + const char* suffixVar = this->Target->GetSuffixVariableInternal(implib); + + // Check for language-specific default prefix and suffix. + std::string ll = this->Target->GetLinkerLanguage(config); + if(!ll.empty()) + { + if(!targetSuffix && suffixVar && *suffixVar) + { + std::string langSuff = suffixVar + std::string("_") + ll; + targetSuffix = this->Makefile->GetDefinition(langSuff); + } + if(!targetPrefix && prefixVar && *prefixVar) + { + std::string langPrefix = prefixVar + std::string("_") + ll; + targetPrefix = this->Makefile->GetDefinition(langPrefix); + } + } + + // if there is no prefix on the target use the cmake definition + if(!targetPrefix && prefixVar) + { + targetPrefix = this->Makefile->GetSafeDefinition(prefixVar); + } + // if there is no suffix on the target use the cmake definition + if(!targetSuffix && suffixVar) + { + targetSuffix = this->Makefile->GetSafeDefinition(suffixVar); + } + + // frameworks have directory prefix but no suffix + std::string fw_prefix; + if(this->Target->IsFrameworkOnApple()) + { + fw_prefix = this->Target->GetOutputName(config, false); + fw_prefix += ".framework/"; + targetPrefix = fw_prefix.c_str(); + targetSuffix = 0; + } + + if(this->Target->IsCFBundleOnApple()) + { + fw_prefix = this->Target->GetCFBundleDirectory(config, false); + fw_prefix += "/"; + targetPrefix = fw_prefix.c_str(); + targetSuffix = 0; + } + + // Begin the final name with the prefix. + outPrefix = targetPrefix?targetPrefix:""; + + // Append the target name or property-specified name. + outBase += this->Target->GetOutputName(config, implib); + + // Append the per-configuration postfix. + outBase += configPostfix?configPostfix:""; + + // Name shared libraries with their version number on some platforms. + if(const char* soversion = this->GetProperty("SOVERSION")) + { + if(this->GetType() == cmTarget::SHARED_LIBRARY && !implib && + this->Makefile->IsOn("CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION")) + { + outBase += "-"; + outBase += soversion; + } + } + + // Append the suffix. + outSuffix = targetSuffix?targetSuffix:""; +} + + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetPDBName(const std::string& config) const { std::string prefix; std::string base; std::string suffix; - this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, false, prefix, base, suffix); std::vector props; std::string configUpper = diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index f0d8c60..1dfdbb3 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -119,6 +119,11 @@ public: std::string GetAppBundleDirectory(const std::string& config, bool contentOnly) const; + /** Get the full name of the target according to the settings in its + makefile. */ + std::string GetFullName(const std::string& config="", + bool implib = false) const; + /** Return the install name directory for the target in the * build tree. For example: "\@rpath/", "\@loader_path/", * or "/full/path/to/library". */ @@ -279,6 +284,12 @@ private: mutable std::map DebugCompatiblePropertiesDone; + std::string GetFullNameInternal(const std::string& config, + bool implib) const; + void GetFullNameInternal(const std::string& config, bool implib, + std::string& outPrefix, std::string& outBase, + std::string& outSuffix) const; + struct CompatibleInterfacesBase { std::set PropsBool; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index d53ecde..7b0e153 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2742,7 +2742,8 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget, } else { - fullName = cmtarget.GetFullName(defConfig.c_str()); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&cmtarget); + fullName = gtgt->GetFullName(defConfig.c_str()); } fileRef->AddAttribute("path", this->CreateString(fullName.c_str())); fileRef->AddAttribute("refType", this->CreateString("0")); @@ -3688,7 +3689,7 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( std::string universalFile = universal; universalFile += *arch; universalFile += "/"; - universalFile += t->GetFullName(configName); + universalFile += gt->GetFullName(configName); makefileStream << "\t/bin/rm -f " << this->ConvertToRelativeForMake(universalFile.c_str()) diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 61d7847..014d3be 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1115,10 +1115,12 @@ void cmLocalVisualStudio6Generator cmTarget* tgt = this->GlobalGenerator->FindTarget(j->first.c_str()); if(tgt) { + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(tgt); lib = cmSystemTools::GetFilenameWithoutExtension - (tgt->GetFullName().c_str()); + (gt->GetFullName().c_str()); libDebug = cmSystemTools::GetFilenameWithoutExtension - (tgt->GetFullName("Debug").c_str()); + (gt->GetFullName("Debug").c_str()); lib += ".lib"; libDebug += ".lib"; } @@ -1258,8 +1260,8 @@ void cmLocalVisualStudio6Generator extraLinkOptionsRelWithDebInfo += targetLinkFlags; } - - + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); // Get standard libraries for this language. if(targetBuilds) @@ -1328,11 +1330,11 @@ void cmLocalVisualStudio6Generator target.GetType() == cmTarget::SHARED_LIBRARY || target.GetType() == cmTarget::MODULE_LIBRARY) { - outputName = target.GetFullName(); - outputNameDebug = target.GetFullName("Debug"); - outputNameRelease = target.GetFullName("Release"); - outputNameMinSizeRel = target.GetFullName("MinSizeRel"); - outputNameRelWithDebInfo = target.GetFullName("RelWithDebInfo"); + outputName = gt->GetFullName(); + outputNameDebug = gt->GetFullName("Debug"); + outputNameRelease = gt->GetFullName("Release"); + outputNameMinSizeRel = gt->GetFullName("MinSizeRel"); + outputNameRelWithDebInfo = gt->GetFullName("RelWithDebInfo"); } else if(target.GetType() == cmTarget::OBJECT_LIBRARY) { @@ -1429,10 +1431,10 @@ void cmLocalVisualStudio6Generator fullPathImpRelease += "/"; fullPathImpMinSizeRel += "/"; fullPathImpRelWithDebInfo += "/"; - fullPathImpDebug += target.GetFullName("Debug", true); - fullPathImpRelease += target.GetFullName("Release", true); - fullPathImpMinSizeRel += target.GetFullName("MinSizeRel", true); - fullPathImpRelWithDebInfo += target.GetFullName("RelWithDebInfo", true); + fullPathImpDebug += gt->GetFullName("Debug", true); + fullPathImpRelease += gt->GetFullName("Release", true); + fullPathImpMinSizeRel += gt->GetFullName("MinSizeRel", true); + fullPathImpRelWithDebInfo += gt->GetFullName("RelWithDebInfo", true); targetImplibFlagDebug = "/implib:"; targetImplibFlagRelease = "/implib:"; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 799bac6..9f26712 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -803,7 +803,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, if (this->FortranProject) { // Intel Fortran >= 15.0 uses TargetName property. - std::string targetNameFull = target.GetFullName(configName); + std::string targetNameFull = gt->GetFullName(configName); std::string targetName = cmSystemTools::GetFilenameWithoutLastExtension(targetNameFull); std::string targetExt = @@ -1107,7 +1107,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, } case cmTarget::STATIC_LIBRARY: { - std::string targetNameFull = target.GetFullName(configName); + std::string targetNameFull = gt->GetFullName(configName); std::string libpath = target.GetDirectory(configName); libpath += "/"; libpath += targetNameFull; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e8ef770..a5ff829 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3587,20 +3587,6 @@ bool cmTarget::IsImportedSharedLibWithoutSOName( } //---------------------------------------------------------------------------- -std::string cmTarget::GetFullName(const std::string& config, - bool implib) const -{ - if(this->IsImported()) - { - return this->GetFullNameImported(config, implib); - } - else - { - return this->GetFullNameInternal(config, implib); - } -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetFullNameImported(const std::string& config, bool implib) const { @@ -3626,148 +3612,6 @@ cmTarget::ImportedGetFullPath(const std::string& config, bool implib) const } //---------------------------------------------------------------------------- -std::string -cmTarget::GetFullNameInternal(const std::string& config, bool implib) const -{ - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, implib, prefix, base, suffix); - return prefix+base+suffix; -} - -//---------------------------------------------------------------------------- -void cmTarget::GetFullNameInternal(const std::string& config, - bool implib, - std::string& outPrefix, - std::string& outBase, - std::string& outSuffix) const -{ - // Use just the target name for non-main target types. - if(this->GetType() != cmTarget::STATIC_LIBRARY && - this->GetType() != cmTarget::SHARED_LIBRARY && - this->GetType() != cmTarget::MODULE_LIBRARY && - this->GetType() != cmTarget::EXECUTABLE) - { - outPrefix = ""; - outBase = this->GetName(); - outSuffix = ""; - return; - } - - // Return an empty name for the import library if this platform - // does not support import libraries. - if(implib && - !this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) - { - outPrefix = ""; - outBase = ""; - outSuffix = ""; - return; - } - - // The implib option is only allowed for shared libraries, module - // libraries, and executables. - if(this->GetType() != cmTarget::SHARED_LIBRARY && - this->GetType() != cmTarget::MODULE_LIBRARY && - this->GetType() != cmTarget::EXECUTABLE) - { - implib = false; - } - - // Compute the full name for main target types. - const char* targetPrefix = (implib - ? this->GetProperty("IMPORT_PREFIX") - : this->GetProperty("PREFIX")); - const char* targetSuffix = (implib - ? this->GetProperty("IMPORT_SUFFIX") - : this->GetProperty("SUFFIX")); - const char* configPostfix = 0; - if(!config.empty()) - { - std::string configProp = cmSystemTools::UpperCase(config); - configProp += "_POSTFIX"; - configPostfix = this->GetProperty(configProp); - // Mac application bundles and frameworks have no postfix. - if(configPostfix && - (this->IsAppBundleOnApple() || this->IsFrameworkOnApple())) - { - configPostfix = 0; - } - } - const char* prefixVar = this->GetPrefixVariableInternal(implib); - const char* suffixVar = this->GetSuffixVariableInternal(implib); - - // Check for language-specific default prefix and suffix. - std::string ll = this->GetLinkerLanguage(config); - if(!ll.empty()) - { - if(!targetSuffix && suffixVar && *suffixVar) - { - std::string langSuff = suffixVar + std::string("_") + ll; - targetSuffix = this->Makefile->GetDefinition(langSuff); - } - if(!targetPrefix && prefixVar && *prefixVar) - { - std::string langPrefix = prefixVar + std::string("_") + ll; - targetPrefix = this->Makefile->GetDefinition(langPrefix); - } - } - - // if there is no prefix on the target use the cmake definition - if(!targetPrefix && prefixVar) - { - targetPrefix = this->Makefile->GetSafeDefinition(prefixVar); - } - // if there is no suffix on the target use the cmake definition - if(!targetSuffix && suffixVar) - { - targetSuffix = this->Makefile->GetSafeDefinition(suffixVar); - } - - // frameworks have directory prefix but no suffix - std::string fw_prefix; - if(this->IsFrameworkOnApple()) - { - fw_prefix = this->GetOutputName(config, false); - fw_prefix += ".framework/"; - targetPrefix = fw_prefix.c_str(); - targetSuffix = 0; - } - - if(this->IsCFBundleOnApple()) - { - fw_prefix = this->GetCFBundleDirectory(config, false); - fw_prefix += "/"; - targetPrefix = fw_prefix.c_str(); - targetSuffix = 0; - } - - // Begin the final name with the prefix. - outPrefix = targetPrefix?targetPrefix:""; - - // Append the target name or property-specified name. - outBase += this->GetOutputName(config, implib); - - // Append the per-configuration postfix. - outBase += configPostfix?configPostfix:""; - - // Name shared libraries with their version number on some platforms. - if(const char* soversion = this->GetProperty("SOVERSION")) - { - if(this->GetType() == cmTarget::SHARED_LIBRARY && !implib && - this->Makefile->IsOn("CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION")) - { - outBase += "-"; - outBase += soversion; - } - } - - // Append the suffix. - outSuffix = targetSuffix?targetSuffix:""; -} - -//---------------------------------------------------------------------------- void cmTarget::ComputeVersionedName(std::string& vName, std::string const& prefix, std::string const& base, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 4b804da..e22d3af 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -368,11 +368,6 @@ public: ///! Return the preferred linker language for this target std::string GetLinkerLanguage(const std::string& config = "") const; - /** Get the full name of the target according to the settings in its - makefile. */ - std::string GetFullName(const std::string& config="", - bool implib = false) const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; @@ -575,11 +570,6 @@ private: const char* GetSuffixVariableInternal(bool implib) const; const char* GetPrefixVariableInternal(bool implib) const; - std::string GetFullNameInternal(const std::string& config, - bool implib) const; - void GetFullNameInternal(const std::string& config, bool implib, - std::string& outPrefix, std::string& outBase, - std::string& outSuffix) const; // Use a makefile variable to set a default for the given property. // If the variable is not defined use the given default instead. diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 16edf3c..2b33c2c 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1774,7 +1774,7 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions() else { outDir = this->Target->GetDirectory(config->c_str()) + "/"; - targetNameFull = this->Target->GetFullName(config->c_str()); + targetNameFull = this->GeneratorTarget->GetFullName(config->c_str()); } this->ConvertToWindowsSlash(intermediateDir); this->ConvertToWindowsSlash(outDir); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9d6f7d3675da15c8f430a110d2b8a349fcf6d4ae commit 9d6f7d3675da15c8f430a110d2b8a349fcf6d4ae Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:48 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 17:50:40 2015 +0200 cmGeneratorTarget: Move GetAppBundleDirectory from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 2de3c77..0fdf646 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -890,6 +890,19 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const } } + +//---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, + bool contentOnly) const +{ + std::string fpath = this->Target->GetFullName(config, false); + fpath += ".app/Contents"; + if(!contentOnly) + fpath += "/MacOS"; + return fpath; +} + //---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetInstallNameDirForBuildTree( @@ -976,7 +989,7 @@ cmGeneratorTarget::BuildMacContentDirectory(const std::string& base, std::string fpath = base; if(this->Target->IsAppBundleOnApple()) { - fpath += this->Target->GetAppBundleDirectory(config, contentOnly); + fpath += this->GetAppBundleDirectory(config, contentOnly); } if(this->Target->IsFrameworkOnApple()) { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 6d084f7..f0d8c60 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -115,6 +115,10 @@ public: bool realname) const; std::string NormalGetRealName(const std::string& config) const; + /** @return the Mac App directory without the base */ + std::string GetAppBundleDirectory(const std::string& config, + bool contentOnly) const; + /** Return the install name directory for the target in the * build tree. For example: "\@rpath/", "\@loader_path/", * or "/full/path/to/library". */ diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 7df2f78..1d85d9c 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -47,7 +47,7 @@ void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName, // Compute bundle directory names. std::string out = outpath; out += "/"; - out += this->GT->Target->GetAppBundleDirectory(this->ConfigName, false); + out += this->GT->GetAppBundleDirectory(this->ConfigName, false); cmSystemTools::MakeDirectory(out.c_str()); this->Makefile->AddCMakeOutputFile(out); @@ -57,7 +57,7 @@ void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName, // to be set. std::string plist = outpath; plist += "/"; - plist += this->GT->Target->GetAppBundleDirectory(this->ConfigName, true); + plist += this->GT->GetAppBundleDirectory(this->ConfigName, true); plist += "/Info.plist"; this->LocalGenerator->GenerateAppleInfoPList(this->GT->Target, targetName, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index b49ad9b..e8ef770 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -5323,17 +5323,6 @@ std::string cmTarget::GetCFBundleDirectory(const std::string& config, } //---------------------------------------------------------------------------- -std::string cmTarget::GetAppBundleDirectory(const std::string& config, - bool contentOnly) const -{ - std::string fpath = this->GetFullName(config, false); - fpath += ".app/Contents"; - if(!contentOnly) - fpath += "/MacOS"; - return fpath; -} - -//---------------------------------------------------------------------------- cmTargetInternalPointer::cmTargetInternalPointer() { this->Pointer = new cmTargetInternals; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index c1c518f..4b804da 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -473,10 +473,6 @@ public: std::string GetCFBundleDirectory(const std::string& config, bool contentOnly) const; - /** @return the Mac App directory without the base */ - std::string GetAppBundleDirectory(const std::string& config, - bool contentOnly) const; - std::vector GetIncludeDirectories( const std::string& config, const std::string& language) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3c748aa6a81d3af4af2552ec10f21c22a4cd39e8 commit 3c748aa6a81d3af4af2552ec10f21c22a4cd39e8 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:47 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 17:50:40 2015 +0200 cmGeneratorTarget: Move GetInstallNameDir* from cmTarget. diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 6274c3f..fed0dbc 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -333,12 +333,12 @@ cmExportBuildFileGenerator } std::string -cmExportBuildFileGenerator::InstallNameDir(cmTarget* target, +cmExportBuildFileGenerator::InstallNameDir(cmGeneratorTarget* target, const std::string& config) { std::string install_name_dir; - cmMakefile* mf = target->GetMakefile(); + cmMakefile* mf = target->Target->GetMakefile(); if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { install_name_dir = diff --git a/Source/cmExportBuildFileGenerator.h b/Source/cmExportBuildFileGenerator.h index 4d8e062..ff3d2e1 100644 --- a/Source/cmExportBuildFileGenerator.h +++ b/Source/cmExportBuildFileGenerator.h @@ -71,7 +71,8 @@ protected: cmGeneratorTarget* target, ImportPropertyMap& properties); - std::string InstallNameDir(cmTarget* target, const std::string& config); + std::string InstallNameDir(cmGeneratorTarget* target, + const std::string& config); std::vector FindNamespaces(cmMakefile* mf, const std::string& name); diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index e3652c5..cae60b7 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -893,7 +893,7 @@ cmExportFileGenerator { if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { - value = this->InstallNameDir(target->Target, config); + value = this->InstallNameDir(target, config); } prop = "IMPORTED_SONAME"; value += target->GetSOName(config); diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index 4e54740..44f779b 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -200,7 +200,7 @@ private: virtual void ReplaceInstallPrefix(std::string &input); - virtual std::string InstallNameDir(cmTarget* target, + virtual std::string InstallNameDir(cmGeneratorTarget* target, const std::string& config) = 0; }; diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index b0bc686..d55be11 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -546,12 +546,12 @@ cmExportInstallFileGenerator } std::string -cmExportInstallFileGenerator::InstallNameDir(cmTarget* target, +cmExportInstallFileGenerator::InstallNameDir(cmGeneratorTarget* target, const std::string&) { std::string install_name_dir; - cmMakefile* mf = target->GetMakefile(); + cmMakefile* mf = target->Target->GetMakefile(); if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { install_name_dir = diff --git a/Source/cmExportInstallFileGenerator.h b/Source/cmExportInstallFileGenerator.h index 6f86ac9..b06fee5 100644 --- a/Source/cmExportInstallFileGenerator.h +++ b/Source/cmExportInstallFileGenerator.h @@ -83,7 +83,8 @@ protected: std::set& importedLocations ); - std::string InstallNameDir(cmTarget* target, const std::string& config); + std::string InstallNameDir(cmGeneratorTarget* target, + const std::string& config); cmInstallExportGenerator* IEGen; diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx index 94831f8..ba66531 100644 --- a/Source/cmExportTryCompileFileGenerator.cxx +++ b/Source/cmExportTryCompileFileGenerator.cxx @@ -125,12 +125,12 @@ cmExportTryCompileFileGenerator::PopulateProperties(cmTarget const* target, } std::string -cmExportTryCompileFileGenerator::InstallNameDir(cmTarget* target, +cmExportTryCompileFileGenerator::InstallNameDir(cmGeneratorTarget* target, const std::string& config) { std::string install_name_dir; - cmMakefile* mf = target->GetMakefile(); + cmMakefile* mf = target->Target->GetMakefile(); if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { install_name_dir = diff --git a/Source/cmExportTryCompileFileGenerator.h b/Source/cmExportTryCompileFileGenerator.h index 749f3ef..8838eca 100644 --- a/Source/cmExportTryCompileFileGenerator.h +++ b/Source/cmExportTryCompileFileGenerator.h @@ -45,7 +45,7 @@ protected: ImportPropertyMap& properties, std::set &emitted); - std::string InstallNameDir(cmTarget* target, + std::string InstallNameDir(cmGeneratorTarget* target, const std::string& config); private: std::string FindTargets(const std::string& prop, cmTarget const* tgt, diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 45577e5..2de3c77 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -891,6 +891,73 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const } //---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetInstallNameDirForBuildTree( + const std::string& config) const +{ + // If building directly for installation then the build tree install_name + // is the same as the install tree. + if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) + { + return this->GetInstallNameDirForInstallTree(); + } + + // Use the build tree directory for the target. + if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME") && + !this->Makefile->IsOn("CMAKE_SKIP_RPATH") && + !this->GetPropertyAsBool("SKIP_BUILD_RPATH")) + { + std::string dir; + if(this->Target->MacOSXRpathInstallNameDirDefault()) + { + dir = "@rpath"; + } + else + { + dir = this->Target->GetDirectory(config); + } + dir += "/"; + return dir; + } + else + { + return ""; + } +} + +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetInstallNameDirForInstallTree() const +{ + if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) + { + std::string dir; + const char* install_name_dir = this->GetProperty("INSTALL_NAME_DIR"); + + if(!this->Makefile->IsOn("CMAKE_SKIP_RPATH") && + !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH")) + { + if(install_name_dir && *install_name_dir) + { + dir = install_name_dir; + dir += "/"; + } + } + if(!install_name_dir) + { + if(this->Target->MacOSXRpathInstallNameDirDefault()) + { + dir = "@rpath/"; + } + } + return dir; + } + else + { + return ""; + } +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, std::string& base, std::string& suffix, diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 8fc1b44..6d084f7 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -115,6 +115,15 @@ public: bool realname) const; std::string NormalGetRealName(const std::string& config) const; + /** Return the install name directory for the target in the + * build tree. For example: "\@rpath/", "\@loader_path/", + * or "/full/path/to/library". */ + std::string GetInstallNameDirForBuildTree(const std::string& config) const; + + /** Return the install name directory for the target in the + * install tree. For example: "\@rpath/" or "\@loader_path/". */ + std::string GetInstallNameDirForInstallTree() const; + /** Get the soname of the target. Allowed only for a shared library. */ std::string GetSOName(const std::string& config) const; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 03f6d8f..d53ecde 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2331,7 +2331,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, if(target.GetType() == cmTarget::SHARED_LIBRARY) { // Get the install_name directory for the build tree. - install_name_dir = target.GetInstallNameDirForBuildTree(configName); + install_name_dir = gtgt->GetInstallNameDirForBuildTree(configName); // Xcode doesn't create the correct install_name in some cases. // That is, if the INSTALL_PATH is empty, or if we have versioning // of dylib libraries, we want to specify the install_name. diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 24c1c49..30cf175 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -576,11 +576,14 @@ cmInstallTargetGenerator continue; } + cmGeneratorTarget *gtgt = tgt->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(tgt); // If the build tree and install tree use different path // components of the install_name field then we need to create a // mapping to be applied after installation. - std::string for_build = tgt->GetInstallNameDirForBuildTree(config); - std::string for_install = tgt->GetInstallNameDirForInstallTree(); + std::string for_build = gtgt->GetInstallNameDirForBuildTree(config); + std::string for_install = gtgt->GetInstallNameDirForInstallTree(); if(for_build != for_install) { // The directory portions differ. Append the filename to @@ -605,9 +608,9 @@ cmInstallTargetGenerator if(this->Target->GetType() == cmTarget::SHARED_LIBRARY) { std::string for_build = - this->Target->Target->GetInstallNameDirForBuildTree(config); + this->Target->GetInstallNameDirForBuildTree(config); std::string for_install = - this->Target->Target->GetInstallNameDirForInstallTree(); + this->Target->GetInstallNameDirForInstallTree(); if(this->Target->Target->IsFrameworkOnApple() && for_install.empty()) { diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index a2fcbad..b85b8a8 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -666,7 +666,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules { // Get the install_name directory for the build tree. install_name_dir = - this->Target->GetInstallNameDirForBuildTree(this->ConfigName); + this->GeneratorTarget->GetInstallNameDirForBuildTree(this->ConfigName); // Set the rule variable replacement value. if(install_name_dir.empty()) diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index c80f485..1835841 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -537,7 +537,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() vars["SONAME"] = this->TargetNameSO; if (targetType == cmTarget::SHARED_LIBRARY) { - std::string install_dir = target.GetInstallNameDirForBuildTree(cfgName); + std::string install_dir = + this->GetGeneratorTarget()->GetInstallNameDirForBuildTree(cfgName); if (!install_dir.empty()) { vars["INSTALLNAME_DIR"] = localGen.Convert(install_dir, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 0f1d309..b49ad9b 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3846,73 +3846,6 @@ bool cmTarget::HaveInstallTreeRPATH() const } //---------------------------------------------------------------------------- -std::string cmTarget::GetInstallNameDirForBuildTree( - const std::string& config) const -{ - // If building directly for installation then the build tree install_name - // is the same as the install tree. - if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) - { - return GetInstallNameDirForInstallTree(); - } - - // Use the build tree directory for the target. - if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME") && - !this->Makefile->IsOn("CMAKE_SKIP_RPATH") && - !this->GetPropertyAsBool("SKIP_BUILD_RPATH")) - { - std::string dir; - bool macosx_rpath = this->MacOSXRpathInstallNameDirDefault(); - if(macosx_rpath) - { - dir = "@rpath"; - } - else - { - dir = this->GetDirectory(config); - } - dir += "/"; - return dir; - } - else - { - return ""; - } -} - -//---------------------------------------------------------------------------- -std::string cmTarget::GetInstallNameDirForInstallTree() const -{ - if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) - { - std::string dir; - const char* install_name_dir = this->GetProperty("INSTALL_NAME_DIR"); - - if(!this->Makefile->IsOn("CMAKE_SKIP_RPATH") && - !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH")) - { - if(install_name_dir && *install_name_dir) - { - dir = install_name_dir; - dir += "/"; - } - } - if(!install_name_dir) - { - if(this->MacOSXRpathInstallNameDirDefault()) - { - dir = "@rpath/"; - } - } - return dir; - } - else - { - return ""; - } -} - -//---------------------------------------------------------------------------- const char* cmTarget::GetOutputTargetType(bool implib) const { switch(this->GetType()) diff --git a/Source/cmTarget.h b/Source/cmTarget.h index d03ba3b..c1c518f 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -394,15 +394,6 @@ public: bool HaveBuildTreeRPATH(const std::string& config) const; bool HaveInstallTreeRPATH() const; - /** Return the install name directory for the target in the - * build tree. For example: "\@rpath/", "\@loader_path/", - * or "/full/path/to/library". */ - std::string GetInstallNameDirForBuildTree(const std::string& config) const; - - /** Return the install name directory for the target in the - * install tree. For example: "\@rpath/" or "\@loader_path/". */ - std::string GetInstallNameDirForInstallTree() const; - // Get the properties cmPropertyMap &GetProperties() const { return this->Properties; } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7935934a89e062dbab0ca396b40560edc9e904d9 commit 7935934a89e062dbab0ca396b40560edc9e904d9 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:47 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 17:50:40 2015 +0200 cmGeneratorTarget: Move GetMacContentDirectory from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 4be034f..45577e5 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -567,7 +567,7 @@ const char* cmGeneratorTarget::GetLocationForBuild() const if(this->Target->IsAppBundleOnApple()) { - std::string macdir = this->Target->BuildMacContentDirectory("", "", + std::string macdir = this->BuildMacContentDirectory("", "", false); if(!macdir.empty()) { @@ -902,6 +902,47 @@ void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, //---------------------------------------------------------------------------- std::string +cmGeneratorTarget::BuildMacContentDirectory(const std::string& base, + const std::string& config, + bool contentOnly) const +{ + std::string fpath = base; + if(this->Target->IsAppBundleOnApple()) + { + fpath += this->Target->GetAppBundleDirectory(config, contentOnly); + } + if(this->Target->IsFrameworkOnApple()) + { + fpath += this->Target->GetFrameworkDirectory(config, contentOnly); + } + if(this->Target->IsCFBundleOnApple()) + { + fpath += this->Target->GetCFBundleDirectory(config, contentOnly); + } + return fpath; +} + +//---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetMacContentDirectory(const std::string& config, + bool implib) const +{ + // Start with the output directory for the target. + std::string fpath = this->Target->GetDirectory(config, implib); + fpath += "/"; + bool contentOnly = true; + if(this->Target->IsFrameworkOnApple()) + { + // additional files with a framework go into the version specific + // directory + contentOnly = false; + } + fpath = this->BuildMacContentDirectory(fpath, config, contentOnly); + return fpath; +} + +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetModuleDefinitionFile(const std::string& config) const { std::string data; @@ -1527,7 +1568,7 @@ std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config, fpath += "/"; if(this->Target->IsAppBundleOnApple()) { - fpath = this->Target->BuildMacContentDirectory(fpath, config, false); + fpath = this->BuildMacContentDirectory(fpath, config, false); fpath += "/"; } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index f96adad..8fc1b44 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -123,6 +123,15 @@ public: const std::string& config="", bool implib = false) const; + /** Append to @a base the mac content directory and return it. */ + std::string BuildMacContentDirectory(const std::string& base, + const std::string& config = "", + bool contentOnly = true) const; + + /** @return the mac content directory for this target. */ + std::string GetMacContentDirectory(const std::string& config = 0, + bool implib = false) const; + cmTarget* Target; cmMakefile* Makefile; cmLocalGenerator* LocalGenerator; diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 3bc0eb7..7df2f78 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -217,7 +217,7 @@ cmOSXBundleGenerator::InitMacOSXContentDirectory(const char* pkgloc) // Construct the full path to the content subdirectory. std::string macdir = - this->GT->Target->GetMacContentDirectory(this->ConfigName, + this->GT->GetMacContentDirectory(this->ConfigName, /*implib*/ false); macdir += "/"; macdir += pkgloc; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 0d9aa49..0f1d309 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -5401,45 +5401,6 @@ std::string cmTarget::GetAppBundleDirectory(const std::string& config, } //---------------------------------------------------------------------------- -std::string cmTarget::BuildMacContentDirectory(const std::string& base, - const std::string& config, - bool contentOnly) const -{ - std::string fpath = base; - if(this->IsAppBundleOnApple()) - { - fpath += this->GetAppBundleDirectory(config, contentOnly); - } - if(this->IsFrameworkOnApple()) - { - fpath += this->GetFrameworkDirectory(config, contentOnly); - } - if(this->IsCFBundleOnApple()) - { - fpath += this->GetCFBundleDirectory(config, contentOnly); - } - return fpath; -} - -//---------------------------------------------------------------------------- -std::string cmTarget::GetMacContentDirectory(const std::string& config, - bool implib) const -{ - // Start with the output directory for the target. - std::string fpath = this->GetDirectory(config, implib); - fpath += "/"; - bool contentOnly = true; - if(this->IsFrameworkOnApple()) - { - // additional files with a framework go into the version specific - // directory - contentOnly = false; - } - fpath = this->BuildMacContentDirectory(fpath, config, contentOnly); - return fpath; -} - -//---------------------------------------------------------------------------- cmTargetInternalPointer::cmTargetInternalPointer() { this->Pointer = new cmTargetInternals; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 9962fdb..d03ba3b 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -471,10 +471,6 @@ public: directory. */ bool UsesDefaultOutputDir(const std::string& config, bool implib) const; - /** @return the mac content directory for this target. */ - std::string GetMacContentDirectory(const std::string& config, - bool implib) const; - /** @return whether this target have a well defined output file name. */ bool HaveWellDefinedOutputFiles() const; @@ -615,10 +611,6 @@ private: std::string ImportedGetFullPath(const std::string& config, bool implib) const; - /** Append to @a base the mac content directory and return it. */ - std::string BuildMacContentDirectory(const std::string& base, - const std::string& config, - bool contentOnly) const; void GetSourceFiles(std::vector &files, const std::string& config) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d6beb377729cc79b3e5718c9d2cc8b751137b889 commit d6beb377729cc79b3e5718c9d2cc8b751137b889 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:47 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 17:50:40 2015 +0200 cmGeneratorTarget: Move GetFullNameComponents from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 6481390..4be034f 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -891,6 +891,16 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const } //---------------------------------------------------------------------------- +void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, + std::string& base, + std::string& suffix, + const std::string& config, + bool implib) const +{ + this->Target->GetFullNameInternal(config, implib, prefix, base, suffix); +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetModuleDefinitionFile(const std::string& config) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 9ecbbbe..f96adad 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -118,6 +118,11 @@ public: /** Get the soname of the target. Allowed only for a shared library. */ std::string GetSOName(const std::string& config) const; + void GetFullNameComponents(std::string& prefix, + std::string& base, std::string& suffix, + const std::string& config="", + bool implib = false) const; + cmTarget* Target; cmMakefile* Makefile; cmLocalGenerator* LocalGenerator; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index d7ae36d..03f6d8f 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1940,7 +1940,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, std::string pnprefix; std::string pnbase; std::string pnsuffix; - target.GetFullNameComponents(pnprefix, pnbase, pnsuffix, configName); + gtgt->GetFullNameComponents(pnprefix, pnbase, pnsuffix, configName); const char* version = target.GetProperty("VERSION"); const char* soversion = target.GetProperty("SOVERSION"); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 2586b31..c80f485 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -569,7 +569,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() std::string prefix; std::string base; std::string suffix; - target.GetFullNameComponents(prefix, base, suffix); + this->GetGeneratorTarget()->GetFullNameComponents(prefix, base, suffix); std::string dbg_suffix = ".dbg"; // TODO: Where to document? if (mf->GetDefinition("CMAKE_DEBUG_SYMBOL_SUFFIX")) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1183fe4..0d9aa49 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3609,15 +3609,6 @@ cmTarget::GetFullNameImported(const std::string& config, bool implib) const } //---------------------------------------------------------------------------- -void cmTarget::GetFullNameComponents(std::string& prefix, std::string& base, - std::string& suffix, - const std::string& config, - bool implib) const -{ - this->GetFullNameInternal(config, implib, prefix, base, suffix); -} - -//---------------------------------------------------------------------------- std::string cmTarget::ImportedGetFullPath(const std::string& config, bool implib) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 1aef7b3..9962fdb 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -372,10 +372,6 @@ public: makefile. */ std::string GetFullName(const std::string& config="", bool implib = false) const; - void GetFullNameComponents(std::string& prefix, - std::string& base, std::string& suffix, - const std::string& config="", - bool implib = false) const; /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=dd06c55ee9cc330627a6d85f964f69ffa90bf315 commit dd06c55ee9cc330627a6d85f964f69ffa90bf315 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:46 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 17:50:39 2015 +0200 cmGeneratorTarget: Move IsChrPathUsed from cmTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 47406cb..cbb257e 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -321,7 +321,11 @@ cmComputeLinkInformation this->RuntimeAlways = (this->Makefile-> GetSafeDefinition("CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH")); - this->RuntimeUseChrpath = this->Target->IsChrpathUsed(config); + + cmGeneratorTarget *gtgt = this->Target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(this->Target); + this->RuntimeUseChrpath = gtgt->IsChrpathUsed(config); // Get options needed to help find dependent libraries. std::string rlVar = "CMAKE_"; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 505d01f..6481390 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -746,7 +746,7 @@ cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const } // If chrpath is going to be used no relinking is needed. - if(this->Target->IsChrpathUsed(config)) + if(this->IsChrpathUsed(config)) { return false; } @@ -779,6 +779,73 @@ cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const || this->Target->HaveInstallTreeRPATH(); } +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsChrpathUsed(const std::string& config) const +{ + // Only certain target types have an rpath. + if(!(this->GetType() == cmTarget::SHARED_LIBRARY || + this->GetType() == cmTarget::MODULE_LIBRARY || + this->GetType() == cmTarget::EXECUTABLE)) + { + return false; + } + + // If the target will not be installed we do not need to change its + // rpath. + if(!this->Target->GetHaveInstallRule()) + { + return false; + } + + // Skip chrpath if skipping rpath altogether. + if(this->Makefile->IsOn("CMAKE_SKIP_RPATH")) + { + return false; + } + + // Skip chrpath if it does not need to be changed at install time. + if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) + { + return false; + } + + // Allow the user to disable builtin chrpath explicitly. + if(this->Makefile->IsOn("CMAKE_NO_BUILTIN_CHRPATH")) + { + return false; + } + + if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) + { + return true; + } + +#if defined(CMAKE_USE_ELF_PARSER) + // Enable if the rpath flag uses a separator and the target uses ELF + // binaries. + std::string ll = this->Target->GetLinkerLanguage(config); + if(!ll.empty()) + { + std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; + sepVar += ll; + sepVar += "_FLAG_SEP"; + const char* sep = this->Makefile->GetDefinition(sepVar); + if(sep && *sep) + { + // TODO: Add ELF check to ABI detection and get rid of + // CMAKE_EXECUTABLE_FORMAT. + if(const char* fmt = + this->Makefile->GetDefinition("CMAKE_EXECUTABLE_FORMAT")) + { + return strcmp(fmt, "ELF") == 0; + } + } + } +#endif + static_cast(config); + return false; +} + //---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetSOName(const std::string& config) const diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index c9a2508..9ecbbbe 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -215,6 +215,9 @@ public: */ bool NeedRelinkBeforeInstall(const std::string& config) const; + /** Return true if builtin chrpath will work for this target */ + bool IsChrpathUsed(const std::string& config) const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 7a7dcb4..24c1c49 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -656,11 +656,10 @@ cmInstallTargetGenerator std::string const& toDestDirPath) { // Skip the chrpath if the target does not need it. - if(this->ImportLibrary || !this->Target->Target->IsChrpathUsed(config)) + if(this->ImportLibrary || !this->Target->IsChrpathUsed(config)) { return; } - // Skip if on Apple if(this->Target->Target->GetMakefile() ->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) @@ -695,7 +694,7 @@ cmInstallTargetGenerator std::string const& toDestDirPath) { // Skip the chrpath if the target does not need it. - if(this->ImportLibrary || !this->Target->Target->IsChrpathUsed(config)) + if(this->ImportLibrary || !this->Target->IsChrpathUsed(config)) { return; } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 8dd62f9..1183fe4 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4314,73 +4314,6 @@ void cmTarget::GetLanguages(std::set& languages, } //---------------------------------------------------------------------------- -bool cmTarget::IsChrpathUsed(const std::string& config) const -{ - // Only certain target types have an rpath. - if(!(this->GetType() == cmTarget::SHARED_LIBRARY || - this->GetType() == cmTarget::MODULE_LIBRARY || - this->GetType() == cmTarget::EXECUTABLE)) - { - return false; - } - - // If the target will not be installed we do not need to change its - // rpath. - if(!this->GetHaveInstallRule()) - { - return false; - } - - // Skip chrpath if skipping rpath altogether. - if(this->Makefile->IsOn("CMAKE_SKIP_RPATH")) - { - return false; - } - - // Skip chrpath if it does not need to be changed at install time. - if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) - { - return false; - } - - // Allow the user to disable builtin chrpath explicitly. - if(this->Makefile->IsOn("CMAKE_NO_BUILTIN_CHRPATH")) - { - return false; - } - - if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) - { - return true; - } - -#if defined(CMAKE_USE_ELF_PARSER) - // Enable if the rpath flag uses a separator and the target uses ELF - // binaries. - std::string ll = this->GetLinkerLanguage(config); - if(!ll.empty()) - { - std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; - sepVar += ll; - sepVar += "_FLAG_SEP"; - const char* sep = this->Makefile->GetDefinition(sepVar); - if(sep && *sep) - { - // TODO: Add ELF check to ABI detection and get rid of - // CMAKE_EXECUTABLE_FORMAT. - if(const char* fmt = - this->Makefile->GetDefinition("CMAKE_EXECUTABLE_FORMAT")) - { - return strcmp(fmt, "ELF") == 0; - } - } - } -#endif - static_cast(config); - return false; -} - -//---------------------------------------------------------------------------- cmTarget::ImportInfo const* cmTarget::GetImportInfo(const std::string& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 11f715a..1aef7b3 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -398,9 +398,6 @@ public: bool HaveBuildTreeRPATH(const std::string& config) const; bool HaveInstallTreeRPATH() const; - /** Return true if builtin chrpath will work for this target */ - bool IsChrpathUsed(const std::string& config) const; - /** Return the install name directory for the target in the * build tree. For example: "\@rpath/", "\@loader_path/", * or "/full/path/to/library". */ http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c6f45bed359dee2cfe947de76ce808eb99ad20da commit c6f45bed359dee2cfe947de76ce808eb99ad20da Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:46 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 17:50:39 2015 +0200 cmGeneratorTarget: Move NeedRelinkBeforeInstall from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index a29f4c9..505d01f 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -714,6 +714,73 @@ bool cmGeneratorTarget::HasSOName(const std::string& config) const } //---------------------------------------------------------------------------- +bool +cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const +{ + // Only executables and shared libraries can have an rpath and may + // need relinking. + if(this->GetType() != cmTarget::EXECUTABLE && + this->GetType() != cmTarget::SHARED_LIBRARY && + this->GetType() != cmTarget::MODULE_LIBRARY) + { + return false; + } + + // If there is no install location this target will not be installed + // and therefore does not need relinking. + if(!this->Target->GetHaveInstallRule()) + { + return false; + } + + // If skipping all rpaths completely then no relinking is needed. + if(this->Makefile->IsOn("CMAKE_SKIP_RPATH")) + { + return false; + } + + // If building with the install-tree rpath no relinking is needed. + if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) + { + return false; + } + + // If chrpath is going to be used no relinking is needed. + if(this->Target->IsChrpathUsed(config)) + { + return false; + } + + // Check for rpath support on this platform. + std::string ll = this->Target->GetLinkerLanguage(config); + if(!ll.empty()) + { + std::string flagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; + flagVar += ll; + flagVar += "_FLAG"; + if(!this->Makefile->IsSet(flagVar)) + { + // There is no rpath support on this platform so nothing needs + // relinking. + return false; + } + } + else + { + // No linker language is known. This error will be reported by + // other code. + return false; + } + + // If either a build or install tree rpath is set then the rpath + // will likely change between the build tree and install tree and + // this target must be relinked. + return this->Target->HaveBuildTreeRPATH(config) + || this->Target->HaveInstallTreeRPATH(); +} + + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetSOName(const std::string& config) const { if(this->Target->IsImported()) diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 441bbcf..c9a2508 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -210,6 +210,11 @@ public: std::string& realName, std::string& impName, std::string& pdbName, const std::string& config) const; + /** + * Compute whether this target must be relinked before installing. + */ + bool NeedRelinkBeforeInstall(const std::string& config) const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index edf2705..69747a4 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -482,7 +482,7 @@ cmGlobalUnixMakefileGenerator3 // Add this to the list of depends rules in this directory. if((!check_all || !gtarget->GetPropertyAsBool("EXCLUDE_FROM_ALL")) && (!check_relink || - gtarget->Target + gtarget ->NeedRelinkBeforeInstall(lg->GetConfigName()))) { std::string tname = lg->GetRelativeTargetDirectory(*gtarget->Target); @@ -691,7 +691,7 @@ cmGlobalUnixMakefileGenerator3 // Add a local name for the rule to relink the target before // installation. - if(gtarget->Target + if(gtarget ->NeedRelinkBeforeInstall(lg->GetConfigName())) { makeTargetName = lg->GetRelativeTargetDirectory(*gtarget->Target); @@ -876,7 +876,7 @@ cmGlobalUnixMakefileGenerator3 name, depends, commands, true); // Add rules to prepare the target for installation. - if(gtarget->Target + if(gtarget ->NeedRelinkBeforeInstall(lg->GetConfigName())) { localName = lg->GetRelativeTargetDirectory(*gtarget->Target); diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index deabecf..7a7dcb4 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -73,7 +73,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, { // Compute the build tree directory from which to copy the target. std::string fromDirConfig; - if(this->Target->Target->NeedRelinkBeforeInstall(config)) + if(this->Target->NeedRelinkBeforeInstall(config)) { fromDirConfig = this->Target->Target->GetMakefile()->GetCurrentBinaryDirectory(); diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 98bd0ab..ce370bc 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -486,8 +486,7 @@ void cmLocalUnixMakefileGenerator3 // Add a local name for the rule to relink the target before // installation. - if(t->second->Target - ->NeedRelinkBeforeInstall(this->ConfigName)) + if(t->second->NeedRelinkBeforeInstall(this->ConfigName)) { makeTargetName = this->GetRelativeTargetDirectory(*t->second->Target); makeTargetName += "/preinstall"; diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 31a78ad..2fd77c9 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -58,7 +58,7 @@ void cmMakefileExecutableTargetGenerator::WriteRuleFiles() // write the link rules this->WriteExecutableRule(false); - if(this->Target->NeedRelinkBeforeInstall(this->ConfigName)) + if(this->GeneratorTarget->NeedRelinkBeforeInstall(this->ConfigName)) { // Write rules to link an installable version of the target. this->WriteExecutableRule(true); diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 7d0dc49..a2fcbad 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -69,7 +69,7 @@ void cmMakefileLibraryTargetGenerator::WriteRuleFiles() break; case cmTarget::SHARED_LIBRARY: this->WriteSharedLibraryRules(false); - if(this->Target->NeedRelinkBeforeInstall(this->ConfigName)) + if(this->GeneratorTarget->NeedRelinkBeforeInstall(this->ConfigName)) { // Write rules to link an installable version of the target. this->WriteSharedLibraryRules(true); @@ -77,7 +77,7 @@ void cmMakefileLibraryTargetGenerator::WriteRuleFiles() break; case cmTarget::MODULE_LIBRARY: this->WriteModuleLibraryRules(false); - if(this->Target->NeedRelinkBeforeInstall(this->ConfigName)) + if(this->GeneratorTarget->NeedRelinkBeforeInstall(this->ConfigName)) { // Write rules to link an installable version of the target. this->WriteModuleLibraryRules(true); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1e7fb5a..8dd62f9 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3855,70 +3855,6 @@ bool cmTarget::HaveInstallTreeRPATH() const } //---------------------------------------------------------------------------- -bool cmTarget::NeedRelinkBeforeInstall(const std::string& config) const -{ - // Only executables and shared libraries can have an rpath and may - // need relinking. - if(this->TargetTypeValue != cmTarget::EXECUTABLE && - this->TargetTypeValue != cmTarget::SHARED_LIBRARY && - this->TargetTypeValue != cmTarget::MODULE_LIBRARY) - { - return false; - } - - // If there is no install location this target will not be installed - // and therefore does not need relinking. - if(!this->GetHaveInstallRule()) - { - return false; - } - - // If skipping all rpaths completely then no relinking is needed. - if(this->Makefile->IsOn("CMAKE_SKIP_RPATH")) - { - return false; - } - - // If building with the install-tree rpath no relinking is needed. - if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) - { - return false; - } - - // If chrpath is going to be used no relinking is needed. - if(this->IsChrpathUsed(config)) - { - return false; - } - - // Check for rpath support on this platform. - std::string ll = this->GetLinkerLanguage(config); - if(!ll.empty()) - { - std::string flagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; - flagVar += ll; - flagVar += "_FLAG"; - if(!this->Makefile->IsSet(flagVar)) - { - // There is no rpath support on this platform so nothing needs - // relinking. - return false; - } - } - else - { - // No linker language is known. This error will be reported by - // other code. - return false; - } - - // If either a build or install tree rpath is set then the rpath - // will likely change between the build tree and install tree and - // this target must be relinked. - return this->HaveBuildTreeRPATH(config) || this->HaveInstallTreeRPATH(); -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetInstallNameDirForBuildTree( const std::string& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 8c23372..11f715a 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -395,11 +395,6 @@ public: bool GetImplibGNUtoMS(std::string const& gnuName, std::string& out, const char* newExt = 0) const; - /** - * Compute whether this target must be relinked before installing. - */ - bool NeedRelinkBeforeInstall(const std::string& config) const; - bool HaveBuildTreeRPATH(const std::string& config) const; bool HaveInstallTreeRPATH() const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bdfebf91ec9b245742af1fe98de1ad47e497616c commit bdfebf91ec9b245742af1fe98de1ad47e497616c Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:46 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 17:50:39 2015 +0200 cmGeneratorTarget: Move GetPDBName from cmTarget. diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index a20579b..49fc96b 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1625,7 +1625,7 @@ struct TargetFilesystemArtifactResultCreator std::string result = target->Target->GetPDBDirectory(context->Config); result += "/"; - result += target->Target->GetPDBName(context->Config); + result += target->GetPDBName(context->Config); return result; } }; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index a125e47..a29f4c9 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1525,7 +1525,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, } // The program database file name. - pdbName = this->Target->GetPDBName(config); + pdbName = this->GetPDBName(config); } //---------------------------------------------------------------------------- @@ -1587,7 +1587,39 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, impName = this->Target->GetFullNameInternal(config, true); // The program database file name. - pdbName = this->Target->GetPDBName(config); + pdbName = this->GetPDBName(config); +} + +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetPDBName(const std::string& config) const +{ + std::string prefix; + std::string base; + std::string suffix; + this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + + std::vector props; + std::string configUpper = + cmSystemTools::UpperCase(config); + if(!configUpper.empty()) + { + // PDB_NAME_ + props.push_back("PDB_NAME_" + configUpper); + } + + // PDB_NAME + props.push_back("PDB_NAME"); + + for(std::vector::const_iterator i = props.begin(); + i != props.end(); ++i) + { + if(const char* outName = this->GetProperty(*i)) + { + base = outName; + break; + } + } + return prefix+base+".pdb"; } bool cmStrictTargetComparison::operator()(cmTarget const* t1, diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 9cdfd00..441bbcf 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -160,6 +160,9 @@ public: std::vector const* GetSourceDepends(cmSourceFile const* sf) const; + /** Get the name of the pdb file for the target. */ + std::string GetPDBName(const std::string& config="") const; + /** Whether this library has soname enabled and platform supports it. */ bool HasSOName(const std::string& config) const; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index f9125fc..b94e151 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -548,7 +548,7 @@ cmMakefileTargetGenerator this->GeneratorTarget->GetFullPath(this->ConfigName, false, true); targetFullPathPDB = this->Target->GetPDBDirectory(this->ConfigName); targetFullPathPDB += "/"; - targetFullPathPDB += this->Target->GetPDBName(this->ConfigName); + targetFullPathPDB += this->GeneratorTarget->GetPDBName(this->ConfigName); } if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY) { diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index e61ba6f..16e1f48 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -273,7 +273,7 @@ bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(cmNinjaVars& vars) const { pdbPath = this->Target->GetPDBDirectory(this->GetConfigName()); pdbPath += "/"; - pdbPath += this->Target->GetPDBName(this->GetConfigName()); + pdbPath += this->GeneratorTarget->GetPDBName(this->GetConfigName()); } if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 188ad0f..1e7fb5a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3461,37 +3461,6 @@ const char* cmTarget::GetPrefixVariableInternal(bool implib) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetPDBName(const std::string& config) const -{ - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); - - std::vector props; - std::string configUpper = cmSystemTools::UpperCase(config); - if(!configUpper.empty()) - { - // PDB_NAME_ - props.push_back("PDB_NAME_" + configUpper); - } - - // PDB_NAME - props.push_back("PDB_NAME"); - - for(std::vector::const_iterator i = props.begin(); - i != props.end(); ++i) - { - if(const char* outName = this->GetProperty(*i)) - { - base = outName; - break; - } - } - return prefix+base+".pdb"; -} - -//---------------------------------------------------------------------------- bool cmTarget::HasMacOSXRpathInstallNameDir(const std::string& config) const { bool install_name_is_rpath = false; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 162033c..8c23372 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -377,9 +377,6 @@ public: const std::string& config="", bool implib = false) const; - /** Get the name of the pdb file for the target. */ - std::string GetPDBName(const std::string& config) const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=99fa567ffdb1c5b7d9e102a8949364ed635c6146 commit 99fa567ffdb1c5b7d9e102a8949364ed635c6146 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:45 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 17:50:39 2015 +0200 cmGeneratorTarget: Move GetCompilePDBPath from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 2b3ebee..a125e47 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -657,6 +657,51 @@ void cmGeneratorTarget::GetSourceFiles(std::vector &files, } //---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetCompilePDBName(const std::string& config) const +{ + std::string prefix; + std::string base; + std::string suffix; + this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + + // Check for a per-configuration output directory target property. + std::string configUpper = cmSystemTools::UpperCase(config); + std::string configProp = "COMPILE_PDB_NAME_"; + configProp += configUpper; + const char* config_name = this->Target->GetProperty(configProp); + if(config_name && *config_name) + { + return prefix + config_name + ".pdb"; + } + + const char* name = this->Target->GetProperty("COMPILE_PDB_NAME"); + if(name && *name) + { + return prefix + name + ".pdb"; + } + + return ""; +} + +//---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetCompilePDBPath(const std::string& config) const +{ + std::string dir = this->Target->GetCompilePDBDirectory(config); + std::string name = this->GetCompilePDBName(config); + if(dir.empty() && !name.empty()) + { + dir = this->Target->GetPDBDirectory(config); + } + if(!dir.empty()) + { + dir += "/"; + } + return dir + name; +} + +//---------------------------------------------------------------------------- bool cmGeneratorTarget::HasSOName(const std::string& config) const { // soname is supported only for shared libraries and modules, diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 9254265..9cdfd00 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -163,6 +163,12 @@ public: /** Whether this library has soname enabled and platform supports it. */ bool HasSOName(const std::string& config) const; + /** Get the name of the compiler pdb file for the target. */ + std::string GetCompilePDBName(const std::string& config="") const; + + /** Get the path for the MSVC /Fd option for this target. */ + std::string GetCompilePDBPath(const std::string& config="") const; + /** * Flags for a given source file as used in this target. Typically assigned * via SET_TARGET_PROPERTIES when the property is a list of source files. diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index dd4cd33..799bac6 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -881,7 +881,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, if(target.GetType() <= cmTarget::OBJECT_LIBRARY) { // Specify the compiler program database file if configured. - std::string pdb = target.GetCompilePDBPath(configName); + std::string pdb = gt->GetCompilePDBPath(configName); if(!pdb.empty()) { fout << "\t\t\t\tProgramDataBaseFileName=\"" diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index ac8cd29..f9125fc 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -553,7 +553,7 @@ cmMakefileTargetGenerator if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY) { targetFullPathCompilePDB = - this->Target->GetCompilePDBPath(this->ConfigName); + this->GeneratorTarget->GetCompilePDBPath(this->ConfigName); if(targetFullPathCompilePDB.empty()) { targetFullPathCompilePDB = this->Target->GetSupportDirectory() + "/"; diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index cf80424..e61ba6f 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -277,7 +277,8 @@ bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(cmNinjaVars& vars) const } if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY) { - compilePdbPath = this->Target->GetCompilePDBPath(this->GetConfigName()); + compilePdbPath = + this->GeneratorTarget->GetCompilePDBPath(this->GetConfigName()); if(compilePdbPath.empty()) { compilePdbPath = this->Target->GetSupportDirectory() + "/"; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e1b3e94..188ad0f 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3492,49 +3492,6 @@ std::string cmTarget::GetPDBName(const std::string& config) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetCompilePDBName(const std::string& config) const -{ - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); - - // Check for a per-configuration output directory target property. - std::string configUpper = cmSystemTools::UpperCase(config); - std::string configProp = "COMPILE_PDB_NAME_"; - configProp += configUpper; - const char* config_name = this->GetProperty(configProp); - if(config_name && *config_name) - { - return prefix + config_name + ".pdb"; - } - - const char* name = this->GetProperty("COMPILE_PDB_NAME"); - if(name && *name) - { - return prefix + name + ".pdb"; - } - - return ""; -} - -//---------------------------------------------------------------------------- -std::string cmTarget::GetCompilePDBPath(const std::string& config) const -{ - std::string dir = this->GetCompilePDBDirectory(config); - std::string name = this->GetCompilePDBName(config); - if(dir.empty() && !name.empty()) - { - dir = this->GetPDBDirectory(config); - } - if(!dir.empty()) - { - dir += "/"; - } - return dir + name; -} - -//---------------------------------------------------------------------------- bool cmTarget::HasMacOSXRpathInstallNameDir(const std::string& config) const { bool install_name_is_rpath = false; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e89a212..162033c 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -380,12 +380,6 @@ public: /** Get the name of the pdb file for the target. */ std::string GetPDBName(const std::string& config) const; - /** Get the name of the compiler pdb file for the target. */ - std::string GetCompilePDBName(const std::string& config="") const; - - /** Get the path for the MSVC /Fd option for this target. */ - std::string GetCompilePDBPath(const std::string& config="") const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 83775a5..16edf3c 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2026,7 +2026,8 @@ void cmVisualStudio10TargetGenerator::WriteClOptions( } // Specify the compiler program database file if configured. - std::string pdb = this->Target->GetCompilePDBPath(configName.c_str()); + std::string pdb = + this->GeneratorTarget->GetCompilePDBPath(configName.c_str()); if(!pdb.empty()) { this->ConvertToWindowsSlash(pdb); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bb97f53ab24e11aa632c6e50e34d7353c36dfacc commit bb97f53ab24e11aa632c6e50e34d7353c36dfacc Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:45 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 17:50:39 2015 +0200 cmGeneratorTarget: Move HasSOName from cmTarget. diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 8a2cf4b..e3652c5 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -889,7 +889,7 @@ cmExportFileGenerator { std::string prop; std::string value; - if(target->Target->HasSOName(config)) + if(target->HasSOName(config)) { if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 31c2df1..2b3ebee 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -657,6 +657,18 @@ void cmGeneratorTarget::GetSourceFiles(std::vector &files, } //---------------------------------------------------------------------------- +bool cmGeneratorTarget::HasSOName(const std::string& config) const +{ + // soname is supported only for shared libraries and modules, + // and then only when the platform supports an soname flag. + return ((this->GetType() == cmTarget::SHARED_LIBRARY || + this->GetType() == cmTarget::MODULE_LIBRARY) && + !this->GetPropertyAsBool("NO_SONAME") && + this->Makefile->GetSONameFlag( + this->Target->GetLinkerLanguage(config))); +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetSOName(const std::string& config) const { if(this->Target->IsImported()) @@ -1407,7 +1419,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, // Check for library version properties. const char* version = this->GetProperty("VERSION"); const char* soversion = this->GetProperty("SOVERSION"); - if(!this->Target->HasSOName(config) || + if(!this->HasSOName(config) || this->Target->IsFrameworkOnApple()) { // Versioning is supported only for shared libraries and modules, diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 7fb7c32..9254265 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -160,6 +160,9 @@ public: std::vector const* GetSourceDepends(cmSourceFile const* sf) const; + /** Whether this library has soname enabled and platform supports it. */ + bool HasSOName(const std::string& config) const; + /** * Flags for a given source file as used in this target. Typically assigned * via SET_TARGET_PROPERTIES when the property is a list of source files. diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index b44848c..d7ae36d 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1944,7 +1944,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, const char* version = target.GetProperty("VERSION"); const char* soversion = target.GetProperty("SOVERSION"); - if(!target.HasSOName(configName) || target.IsFrameworkOnApple()) + if(!gtgt->HasSOName(configName) || target.IsFrameworkOnApple()) { version = 0; soversion = 0; diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 26273ee..7d0dc49 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -653,7 +653,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules vars.Target = target.c_str(); vars.LinkLibraries = linkLibs.c_str(); vars.ObjectsQuoted = buildObjs.c_str(); - if (this->Target->HasSOName(this->ConfigName)) + if (this->GeneratorTarget->HasSOName(this->ConfigName)) { vars.SONameFlag = this->Makefile->GetSONameFlag(linkLanguage); vars.TargetSOName= targetNameSO.c_str(); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 5d86091..2586b31 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -531,7 +531,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() vars["LANGUAGE_COMPILE_FLAGS"] = t; } - if (target.HasSOName(cfgName)) + if (this->GetGeneratorTarget()->HasSOName(cfgName)) { vars["SONAME_FLAG"] = mf->GetSONameFlag(this->TargetLinkLanguage); vars["SONAME"] = this->TargetNameSO; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 60fe7e4..e1b3e94 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3535,17 +3535,6 @@ std::string cmTarget::GetCompilePDBPath(const std::string& config) const } //---------------------------------------------------------------------------- -bool cmTarget::HasSOName(const std::string& config) const -{ - // soname is supported only for shared libraries and modules, - // and then only when the platform supports an soname flag. - return ((this->GetType() == cmTarget::SHARED_LIBRARY || - this->GetType() == cmTarget::MODULE_LIBRARY) && - !this->GetPropertyAsBool("NO_SONAME") && - this->Makefile->GetSONameFlag(this->GetLinkerLanguage(config))); -} - -//---------------------------------------------------------------------------- bool cmTarget::HasMacOSXRpathInstallNameDir(const std::string& config) const { bool install_name_is_rpath = false; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 15dfb4a..e89a212 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -386,9 +386,6 @@ public: /** Get the path for the MSVC /Fd option for this target. */ std::string GetCompilePDBPath(const std::string& config="") const; - /** Whether this library has soname enabled and platform supports it. */ - bool HasSOName(const std::string& config) const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0af8a7369d11d820c9fc172c1e3463ead2a4f37e commit 0af8a7369d11d820c9fc172c1e3463ead2a4f37e Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:45 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 17:50:39 2015 +0200 cmGeneratorTarget: Move GetLibraryNames from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 6a693f1..31c2df1 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -693,8 +693,8 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const std::string realName; std::string impName; std::string pdbName; - this->Target->GetLibraryNames(name, soName, realName, - impName, pdbName, config); + this->GetLibraryNames(name, soName, realName, + impName, pdbName, config); return soName; } } @@ -1254,7 +1254,7 @@ void cmGeneratorTarget::GenerateTargetManifest( this->GetType() == cmTarget::SHARED_LIBRARY || this->GetType() == cmTarget::MODULE_LIBRARY) { - this->Target->GetLibraryNames(name, soName, realName, impName, pdbName, + this->GetLibraryNames(name, soName, realName, impName, pdbName, config); } else @@ -1378,13 +1378,100 @@ cmGeneratorTarget::NormalGetRealName(const std::string& config) const std::string realName; std::string impName; std::string pdbName; - this->Target->GetLibraryNames(name, soName, realName, - impName, pdbName, config); + this->GetLibraryNames(name, soName, realName, + impName, pdbName, config); return realName; } } //---------------------------------------------------------------------------- +void cmGeneratorTarget::GetLibraryNames(std::string& name, + std::string& soName, + std::string& realName, + std::string& impName, + std::string& pdbName, + const std::string& config) const +{ + // This should not be called for imported targets. + // TODO: Split cmTarget into a class hierarchy to get compile-time + // enforcement of the limited imported target API. + if(this->Target->IsImported()) + { + std::string msg = "GetLibraryNames called on imported target: "; + msg += this->GetName(); + this->LocalGenerator->IssueMessage(cmake::INTERNAL_ERROR, + msg); + return; + } + + // Check for library version properties. + const char* version = this->GetProperty("VERSION"); + const char* soversion = this->GetProperty("SOVERSION"); + if(!this->Target->HasSOName(config) || + this->Target->IsFrameworkOnApple()) + { + // Versioning is supported only for shared libraries and modules, + // and then only when the platform supports an soname flag. + version = 0; + soversion = 0; + } + if(version && !soversion) + { + // The soversion must be set if the library version is set. Use + // the library version as the soversion. + soversion = version; + } + if(!version && soversion) + { + // Use the soversion as the library version. + version = soversion; + } + + // Get the components of the library name. + std::string prefix; + std::string base; + std::string suffix; + this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + + // The library name. + name = prefix+base+suffix; + + if(this->Target->IsFrameworkOnApple()) + { + realName = prefix; + realName += "Versions/"; + realName += this->Target->GetFrameworkVersion(); + realName += "/"; + realName += base; + soName = realName; + } + else + { + // The library's soname. + this->Target->ComputeVersionedName(soName, prefix, base, suffix, + name, soversion); + + // The library's real name on disk. + this->Target->ComputeVersionedName(realName, prefix, base, suffix, + name, version); + } + + // The import library name. + if(this->GetType() == cmTarget::SHARED_LIBRARY || + this->GetType() == cmTarget::MODULE_LIBRARY) + { + impName = this->Target->GetFullNameInternal(config, true); + } + else + { + impName = ""; + } + + // The program database file name. + pdbName = this->Target->GetPDBName(config); +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetExecutableNames(std::string& name, std::string& realName, std::string& impName, @@ -1446,7 +1533,6 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, pdbName = this->Target->GetPDBName(config); } - bool cmStrictTargetComparison::operator()(cmTarget const* t1, cmTarget const* t2) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 49aa65b..7fb7c32 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -191,6 +191,13 @@ public: std::string& impName, std::string& pdbName, const std::string& config) const; + /** Get the names of the library needed to generate a build rule + that takes into account shared library version numbers. This + should be called only on a library target. */ + void GetLibraryNames(std::string& name, std::string& soName, + std::string& realName, std::string& impName, + std::string& pdbName, const std::string& config) const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index c872859..deabecf 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -185,7 +185,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - this->Target->Target->GetLibraryNames(targetName, targetNameSO, + this->Target->GetLibraryNames(targetName, targetNameSO, targetNameReal, targetNameImport, targetNamePDB, config); @@ -411,7 +411,7 @@ cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target, std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - target->GetLibraryNames(targetName, targetNameSO, targetNameReal, + gtgt->GetLibraryNames(targetName, targetNameSO, targetNameReal, targetNameImport, targetNamePDB, config); if(nameType == NameImplib) { diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index daac331..dd4cd33 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1147,7 +1147,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, std::string targetNameFull; std::string targetNameImport; std::string targetNamePDB; - target.GetLibraryNames(targetName, targetNameSO, targetNameFull, + gt->GetLibraryNames(targetName, targetNameSO, targetNameFull, targetNameImport, targetNamePDB, configName); // Compute the link library and directory information. diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 696dcc4..26273ee 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -28,7 +28,7 @@ cmMakefileLibraryTargetGenerator this->CustomCommandDriver = OnDepends; if (this->Target->GetType() != cmTarget::INTERFACE_LIBRARY) { - this->Target->GetLibraryNames( + this->GeneratorTarget->GetLibraryNames( this->TargetNameOut, this->TargetNameSO, this->TargetNameReal, this->TargetNameImport, this->TargetNamePDB, this->ConfigName); } @@ -266,7 +266,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - this->Target->GetLibraryNames( + this->GeneratorTarget->GetLibraryNames( targetName, targetNameSO, targetNameReal, targetNameImport, targetNamePDB, this->ConfigName); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 737510f..5d86091 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -49,7 +49,7 @@ cmNinjaNormalTargetGenerator(cmGeneratorTarget* target) this->TargetNamePDB, GetLocalGenerator()->GetConfigName()); else - target->Target->GetLibraryNames(this->TargetNameOut, + this->GetGeneratorTarget()->GetLibraryNames(this->TargetNameOut, this->TargetNameSO, this->TargetNameReal, this->TargetNameImport, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 22b76e9..60fe7e4 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3862,95 +3862,6 @@ void cmTarget::GetFullNameInternal(const std::string& config, } //---------------------------------------------------------------------------- -void cmTarget::GetLibraryNames(std::string& name, - std::string& soName, - std::string& realName, - std::string& impName, - std::string& pdbName, - const std::string& config) const -{ - // This should not be called for imported targets. - // TODO: Split cmTarget into a class hierarchy to get compile-time - // enforcement of the limited imported target API. - if(this->IsImported()) - { - std::string msg = "GetLibraryNames called on imported target: "; - msg += this->GetName(); - this->Makefile->IssueMessage(cmake::INTERNAL_ERROR, - msg); - return; - } - - assert(this->GetType() != INTERFACE_LIBRARY); - - // Check for library version properties. - const char* version = this->GetProperty("VERSION"); - const char* soversion = this->GetProperty("SOVERSION"); - if(!this->HasSOName(config) || - this->Makefile->IsOn("CMAKE_PLATFORM_NO_VERSIONED_SONAME") || - this->IsFrameworkOnApple()) - { - // Versioning is supported only for shared libraries and modules, - // and then only when the platform supports an soname flag. - version = 0; - soversion = 0; - } - if(version && !soversion) - { - // The soversion must be set if the library version is set. Use - // the library version as the soversion. - soversion = version; - } - if(!version && soversion) - { - // Use the soversion as the library version. - version = soversion; - } - - // Get the components of the library name. - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); - - // The library name. - name = prefix+base+suffix; - - if(this->IsFrameworkOnApple()) - { - realName = prefix; - realName += "Versions/"; - realName += this->GetFrameworkVersion(); - realName += "/"; - realName += base; - soName = realName; - } - else - { - // The library's soname. - this->ComputeVersionedName(soName, prefix, base, suffix, - name, soversion); - // The library's real name on disk. - this->ComputeVersionedName(realName, prefix, base, suffix, - name, version); - } - - // The import library name. - if(this->GetType() == cmTarget::SHARED_LIBRARY || - this->GetType() == cmTarget::MODULE_LIBRARY) - { - impName = this->GetFullNameInternal(config, true); - } - else - { - impName = ""; - } - - // The program database file name. - pdbName = this->GetPDBName(config); -} - -//---------------------------------------------------------------------------- void cmTarget::ComputeVersionedName(std::string& vName, std::string const& prefix, std::string const& base, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 714647c..15dfb4a 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -399,13 +399,6 @@ public: no soname at all. */ bool IsImportedSharedLibWithoutSOName(const std::string& config) const; - /** Get the names of the library needed to generate a build rule - that takes into account shared library version numbers. This - should be called only on a library target. */ - void GetLibraryNames(std::string& name, std::string& soName, - std::string& realName, std::string& impName, - std::string& pdbName, const std::string& config) const; - /** Does this target have a GNU implib to convert to MS format? */ bool HasImplibGNUtoMS() const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 1bb21ff..83775a5 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2477,7 +2477,8 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) } else { - this->Target->GetLibraryNames(targetName, targetNameSO, targetNameFull, + this->GeneratorTarget->GetLibraryNames(targetName, targetNameSO, + targetNameFull, targetNameImport, targetNamePDB, config.c_str()); } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=54f23ec7baf5330421abea12be6aba90d4af3503 commit 54f23ec7baf5330421abea12be6aba90d4af3503 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:44 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 17:50:38 2015 +0200 cmGeneratorTarget: Move GetExecutableNames from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index f9f23a6..6a693f1 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1248,8 +1248,7 @@ void cmGeneratorTarget::GenerateTargetManifest( std::string pdbName; if(this->GetType() == cmTarget::EXECUTABLE) { - this->Target->GetExecutableNames(name, realName, impName, pdbName, - config); + this->GetExecutableNames(name, realName, impName, pdbName, config); } else if(this->GetType() == cmTarget::STATIC_LIBRARY || this->GetType() == cmTarget::SHARED_LIBRARY || @@ -1368,7 +1367,7 @@ cmGeneratorTarget::NormalGetRealName(const std::string& config) const std::string realName; std::string impName; std::string pdbName; - this->Target->GetExecutableNames(name, realName, impName, pdbName, config); + this->GetExecutableNames(name, realName, impName, pdbName, config); return realName; } else @@ -1385,6 +1384,69 @@ cmGeneratorTarget::NormalGetRealName(const std::string& config) const } } +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GetExecutableNames(std::string& name, + std::string& realName, + std::string& impName, + std::string& pdbName, + const std::string& config) const +{ + // This should not be called for imported targets. + // TODO: Split cmTarget into a class hierarchy to get compile-time + // enforcement of the limited imported target API. + if(this->Target->IsImported()) + { + std::string msg = + "GetExecutableNames called on imported target: "; + msg += this->GetName(); + this->LocalGenerator->IssueMessage(cmake::INTERNAL_ERROR, msg); + } + + // This versioning is supported only for executables and then only + // when the platform supports symbolic links. +#if defined(_WIN32) && !defined(__CYGWIN__) + const char* version = 0; +#else + // Check for executable version properties. + const char* version = this->GetProperty("VERSION"); + if(this->GetType() != cmTarget::EXECUTABLE || this->Makefile->IsOn("XCODE")) + { + version = 0; + } +#endif + + // Get the components of the executable name. + std::string prefix; + std::string base; + std::string suffix; + this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + + // The executable name. + name = prefix+base+suffix; + + // The executable's real name on disk. +#if defined(__CYGWIN__) + realName = prefix+base; +#else + realName = name; +#endif + if(version) + { + realName += "-"; + realName += version; + } +#if defined(__CYGWIN__) + realName += suffix; +#endif + + // The import library name. + impName = this->Target->GetFullNameInternal(config, true); + + // The program database file name. + pdbName = this->Target->GetPDBName(config); +} + + bool cmStrictTargetComparison::operator()(cmTarget const* t1, cmTarget const* t2) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 1303ee4..49aa65b 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -184,6 +184,12 @@ public: void GetAutoUicOptions(std::vector &result, const std::string& config) const; + /** Get the names of the executable needed to generate a build rule + that takes into account executable version numbers. This should + be called only on an executable target. */ + void GetExecutableNames(std::string& name, std::string& realName, + std::string& impName, std::string& pdbName, + const std::string& config) const; struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index c64f9a3..c872859 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -125,7 +125,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - this->Target->Target->GetExecutableNames(targetName, targetNameReal, + this->Target->GetExecutableNames(targetName, targetNameReal, targetNameImport, targetNamePDB, config); if(this->ImportLibrary) @@ -372,13 +372,16 @@ cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target, { std::string fname; // Compute the name of the library. + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); if(target->GetType() == cmTarget::EXECUTABLE) { std::string targetName; std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - target->GetExecutableNames(targetName, targetNameReal, + gtgt->GetExecutableNames(targetName, targetNameReal, targetNameImport, targetNamePDB, config); if(nameType == NameImplib) diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 37e08dd..daac331 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1244,7 +1244,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, std::string targetNameFull; std::string targetNameImport; std::string targetNamePDB; - target.GetExecutableNames(targetName, targetNameFull, + gt->GetExecutableNames(targetName, targetNameFull, targetNameImport, targetNamePDB, configName); // Compute the link library and directory information. diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 416063f..31a78ad 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -25,7 +25,7 @@ cmMakefileExecutableTargetGenerator cmMakefileTargetGenerator(target) { this->CustomCommandDriver = OnDepends; - this->Target->GetExecutableNames( + this->GeneratorTarget->GetExecutableNames( this->TargetNameOut, this->TargetNameReal, this->TargetNameImport, this->TargetNamePDB, this->ConfigName); @@ -94,7 +94,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - this->Target->GetExecutableNames + this->GeneratorTarget->GetExecutableNames (targetName, targetNameReal, targetNameImport, targetNamePDB, this->ConfigName); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index c9fa7c0..737510f 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -43,7 +43,7 @@ cmNinjaNormalTargetGenerator(cmGeneratorTarget* target) this->TargetLinkLanguage = target->Target ->GetLinkerLanguage(this->GetConfigName()); if (target->GetType() == cmTarget::EXECUTABLE) - target->Target->GetExecutableNames(this->TargetNameOut, + this->GetGeneratorTarget()->GetExecutableNames(this->TargetNameOut, this->TargetNameReal, this->TargetNameImport, this->TargetNamePDB, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index ded5363..22b76e9 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3968,68 +3968,6 @@ void cmTarget::ComputeVersionedName(std::string& vName, } //---------------------------------------------------------------------------- -void cmTarget::GetExecutableNames(std::string& name, - std::string& realName, - std::string& impName, - std::string& pdbName, - const std::string& config) const -{ - // This should not be called for imported targets. - // TODO: Split cmTarget into a class hierarchy to get compile-time - // enforcement of the limited imported target API. - if(this->IsImported()) - { - std::string msg = - "GetExecutableNames called on imported target: "; - msg += this->GetName(); - this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg); - } - - // This versioning is supported only for executables and then only - // when the platform supports symbolic links. -#if defined(_WIN32) && !defined(__CYGWIN__) - const char* version = 0; -#else - // Check for executable version properties. - const char* version = this->GetProperty("VERSION"); - if(this->GetType() != cmTarget::EXECUTABLE || this->Makefile->IsOn("XCODE")) - { - version = 0; - } -#endif - - // Get the components of the executable name. - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); - - // The executable name. - name = prefix+base+suffix; - - // The executable's real name on disk. -#if defined(__CYGWIN__) - realName = prefix+base; -#else - realName = name; -#endif - if(version) - { - realName += "-"; - realName += version; - } -#if defined(__CYGWIN__) - realName += suffix; -#endif - - // The import library name. - impName = this->GetFullNameInternal(config, true); - - // The program database file name. - pdbName = this->GetPDBName(config); -} - -//---------------------------------------------------------------------------- bool cmTarget::HasImplibGNUtoMS() const { return this->HasImportLibrary() && this->GetPropertyAsBool("GNUtoMS"); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 925e7c6..714647c 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -406,14 +406,6 @@ public: std::string& realName, std::string& impName, std::string& pdbName, const std::string& config) const; - /** Get the names of the executable needed to generate a build rule - that takes into account executable version numbers. This should - be called only on an executable target. */ - void GetExecutableNames(std::string& name, std::string& realName, - std::string& impName, - std::string& pdbName, - const std::string& config) const; - /** Does this target have a GNU implib to convert to MS format? */ bool HasImplibGNUtoMS() const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index f3f291a..1bb21ff 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2471,7 +2471,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) std::string targetNamePDB; if(this->Target->GetType() == cmTarget::EXECUTABLE) { - this->Target->GetExecutableNames(targetName, targetNameFull, + this->GeneratorTarget->GetExecutableNames(targetName, targetNameFull, targetNameImport, targetNamePDB, config.c_str()); } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=047a275024b22fa8aaab13b020d4a4580cc234dd commit 047a275024b22fa8aaab13b020d4a4580cc234dd Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:44 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 17:50:38 2015 +0200 cmGeneratorTarget: Move GetLinkImplementationClosure diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 521a5b7..f9f23a6 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -618,7 +618,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const std::string& dir, } std::vector const& deps = - this->Target->GetLinkImplementationClosure(config); + this->GetLinkImplementationClosure(config); for(std::vector::const_iterator li = deps.begin(), le = deps.end(); li != le; ++li) { @@ -775,6 +775,54 @@ void cmGeneratorTarget::GetAutoUicOptions(std::vector &result, } //---------------------------------------------------------------------------- +void processILibs(const std::string& config, + cmTarget const* headTarget, + cmLinkItem const& item, + std::vector& tgts, + std::set& emitted) +{ + if (item.Target && emitted.insert(item.Target).second) + { + tgts.push_back(item.Target); + if(cmTarget::LinkInterfaceLibraries const* iface = + item.Target->GetLinkInterfaceLibraries(config, headTarget, true)) + { + for(std::vector::const_iterator + it = iface->Libraries.begin(); + it != iface->Libraries.end(); ++it) + { + processILibs(config, headTarget, *it, tgts, emitted); + } + } + } +} + +//---------------------------------------------------------------------------- +const std::vector& +cmGeneratorTarget::GetLinkImplementationClosure( + const std::string& config) const +{ + LinkImplClosure& tgts = + this->LinkImplClosureMap[config]; + if(!tgts.Done) + { + tgts.Done = true; + std::set emitted; + + cmTarget::LinkImplementationLibraries const* impl + = this->Target->GetLinkImplementationLibraries(config); + + for(std::vector::const_iterator + it = impl->Libraries.begin(); + it != impl->Libraries.end(); ++it) + { + processILibs(config, this->Target, *it, tgts , emitted); + } + } + return tgts; +} + +//---------------------------------------------------------------------------- class cmTargetTraceDependencies { public: @@ -1455,7 +1503,7 @@ cmGeneratorTarget::GetCompatibleInterfaces(std::string const& config) const compat.PropsBool.insert("POSITION_INDEPENDENT_CODE"); compat.PropsString.insert("AUTOUIC_OPTIONS"); std::vector const& deps = - this->Target->GetLinkImplementationClosure(config); + this->GetLinkImplementationClosure(config); for(std::vector::const_iterator li = deps.begin(); li != deps.end(); ++li) { @@ -1954,7 +2002,7 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt, || (!impliedByUse && !explicitlySet)); std::vector const& deps = - tgt->Target->GetLinkImplementationClosure(config); + tgt->GetLinkImplementationClosure(config); if(deps.empty()) { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 8e68d39..1303ee4 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -245,6 +245,18 @@ private: cmGeneratorTarget(cmGeneratorTarget const&); void operator=(cmGeneratorTarget const&); + + struct LinkImplClosure: public std::vector + { + LinkImplClosure(): Done(false) {} + bool Done; + }; + mutable std::map LinkImplClosureMap; + +public: + std::vector const& + GetLinkImplementationClosure(const std::string& config) const; + }; struct cmStrictTargetComparison { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 968bd9d..ded5363 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -163,13 +163,6 @@ public: typedef std::map LinkClosureMapType; LinkClosureMapType LinkClosureMap; - struct LinkImplClosure: public std::vector - { - LinkImplClosure(): Done(false) {} - bool Done; - }; - std::map LinkImplClosureMap; - typedef std::map > SourceFilesMapType; SourceFilesMapType SourceFilesMap; @@ -5175,53 +5168,6 @@ cmTarget::GetImportLinkInterface(const std::string& config, } //---------------------------------------------------------------------------- -void processILibs(const std::string& config, - cmTarget const* headTarget, - cmLinkItem const& item, - std::vector& tgts, - std::set& emitted) -{ - if (item.Target && emitted.insert(item.Target).second) - { - tgts.push_back(item.Target); - if(cmTarget::LinkInterfaceLibraries const* iface = - item.Target->GetLinkInterfaceLibraries(config, headTarget, true)) - { - for(std::vector::const_iterator - it = iface->Libraries.begin(); - it != iface->Libraries.end(); ++it) - { - processILibs(config, headTarget, *it, tgts, emitted); - } - } - } -} - -//---------------------------------------------------------------------------- -std::vector const& -cmTarget::GetLinkImplementationClosure(const std::string& config) const -{ - cmTargetInternals::LinkImplClosure& tgts = - this->Internal->LinkImplClosureMap[config]; - if(!tgts.Done) - { - tgts.Done = true; - std::set emitted; - - cmTarget::LinkImplementationLibraries const* impl - = this->GetLinkImplementationLibraries(config); - - for(std::vector::const_iterator - it = impl->Libraries.begin(); - it != impl->Libraries.end(); ++it) - { - processILibs(config, this, *it, tgts , emitted); - } - } - return tgts; -} - -//---------------------------------------------------------------------------- void cmTargetInternals::ComputeLinkInterfaceLibraries( cmTarget const* thisTarget, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 85d9964..925e7c6 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -293,9 +293,6 @@ public: cmTarget const* headTarget, bool usage_requirements_only) const; - std::vector const& - GetLinkImplementationClosure(const std::string& config) const; - /** The link implementation specifies the direct library dependencies needed by the object files of the target. */ struct LinkImplementationLibraries http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a4709b427bb9f8e9f129478783977322a7b88497 commit a4709b427bb9f8e9f129478783977322a7b88497 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:44 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 17:50:38 2015 +0200 cmGeneratorTarget: Move ReportPropertyOrigin from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index fe73fee..521a5b7 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1937,24 +1937,24 @@ std::pair consistentProperty(const char *lhs, //---------------------------------------------------------------------------- template -PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, +PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt, const std::string &p, const std::string& config, const char *defaultValue, CompatibleType t, PropertyType *) { - PropertyType propContent = getTypedProperty(tgt, p); - const bool explicitlySet = tgt->GetProperties() + PropertyType propContent = getTypedProperty(tgt->Target, p); + const bool explicitlySet = tgt->Target->GetProperties() .find(p) - != tgt->GetProperties().end(); + != tgt->Target->GetProperties().end(); const bool impliedByUse = - tgt->IsNullImpliedByLinkLibraries(p); + tgt->Target->IsNullImpliedByLinkLibraries(p); assert((impliedByUse ^ explicitlySet) || (!impliedByUse && !explicitlySet)); std::vector const& deps = - tgt->GetLinkImplementationClosure(config); + tgt->Target->GetLinkImplementationClosure(config); if(deps.empty()) { @@ -2125,7 +2125,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, bool cmGeneratorTarget::GetLinkInterfaceDependentBoolProperty( const std::string &p, const std::string& config) const { - return checkInterfacePropertyCompatibility(this->Target, p, config, + return checkInterfacePropertyCompatibility(this, p, config, "FALSE", BoolType, 0); } @@ -2135,7 +2135,7 @@ const char* cmGeneratorTarget::GetLinkInterfaceDependentStringProperty( const std::string &p, const std::string& config) const { - return checkInterfacePropertyCompatibility(this->Target, + return checkInterfacePropertyCompatibility(this, p, config, "empty", @@ -2147,7 +2147,7 @@ const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMinProperty( const std::string &p, const std::string& config) const { - return checkInterfacePropertyCompatibility(this->Target, + return checkInterfacePropertyCompatibility(this, p, config, "empty", @@ -2159,7 +2159,7 @@ const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMaxProperty( const std::string &p, const std::string& config) const { - return checkInterfacePropertyCompatibility(this->Target, + return checkInterfacePropertyCompatibility(this, p, config, "empty", @@ -2196,3 +2196,43 @@ cmGeneratorTarget::GetLinkInformation(const std::string& config) const } return i->second; } + +//---------------------------------------------------------------------------- +void +cmGeneratorTarget::ReportPropertyOrigin(const std::string &p, + const std::string &result, + const std::string &report, + const std::string &compatibilityType) const +{ + std::vector debugProperties; + const char *debugProp = this->Target->GetMakefile() + ->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); + if (debugProp) + { + cmSystemTools::ExpandListArgument(debugProp, debugProperties); + } + + bool debugOrigin = !this->DebugCompatiblePropertiesDone[p] + && std::find(debugProperties.begin(), + debugProperties.end(), + p) + != debugProperties.end(); + + if (this->Target->GetMakefile()->IsConfigured()) + { + this->DebugCompatiblePropertiesDone[p] = true; + } + if (!debugOrigin) + { + return; + } + + std::string areport = compatibilityType; + areport += std::string(" of property \"") + p + "\" for target \""; + areport += std::string(this->GetName()); + areport += "\" (result: \""; + areport += result; + areport += "\"):\n" + report; + + this->Makefile->GetCMakeInstance()->IssueMessage(cmake::LOG, areport); +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index d65b1ef..8e68d39 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -199,6 +199,11 @@ public: std::vector XamlSources; }; + void ReportPropertyOrigin(const std::string &p, + const std::string &result, + const std::string &report, + const std::string &compatibilityType) const; + private: friend class cmTargetTraceDependencies; struct SourceEntry { std::vector Depends; }; @@ -212,6 +217,8 @@ private: mutable bool SourceFileFlagsConstructed; mutable std::map SourceFlagsMap; + mutable std::map DebugCompatiblePropertiesDone; + struct CompatibleInterfacesBase { std::set PropsBool; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1fa62e7..968bd9d 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4537,46 +4537,6 @@ bool cmTarget::IsNullImpliedByLinkLibraries(const std::string &p) const //---------------------------------------------------------------------------- void -cmTarget::ReportPropertyOrigin(const std::string &p, - const std::string &result, - const std::string &report, - const std::string &compatibilityType) const -{ - std::vector debugProperties; - const char *debugProp = - this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); - if (debugProp) - { - cmSystemTools::ExpandListArgument(debugProp, debugProperties); - } - - bool debugOrigin = !this->DebugCompatiblePropertiesDone[p] - && std::find(debugProperties.begin(), - debugProperties.end(), - p) - != debugProperties.end(); - - if (this->Makefile->IsConfigured()) - { - this->DebugCompatiblePropertiesDone[p] = true; - } - if (!debugOrigin) - { - return; - } - - std::string areport = compatibilityType; - areport += std::string(" of property \"") + p + "\" for target \""; - areport += std::string(this->GetName()); - areport += "\" (result: \""; - areport += result; - areport += "\"):\n" + report; - - this->Makefile->GetCMakeInstance()->IssueMessage(cmake::LOG, areport); -} - -//---------------------------------------------------------------------------- -void cmTarget::GetObjectLibrariesCMP0026(std::vector& objlibs) const { // At configure-time, this method can be called as part of getting the diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 795753e..85d9964 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -565,11 +565,6 @@ public: bool LinkLanguagePropagatesToDependents() const { return this->TargetTypeValue == STATIC_LIBRARY; } - void ReportPropertyOrigin(const std::string &p, - const std::string &result, - const std::string &report, - const std::string &compatibilityType) const; - std::map const& GetMaxLanguageStandards() const { @@ -676,7 +671,6 @@ private: std::set Utilities; mutable std::set LinkImplicitNullProperties; std::map UtilityBacktraces; - mutable std::map DebugCompatiblePropertiesDone; mutable std::map MaxLanguageStandards; cmPolicies::PolicyMap PolicyMap; std::string Name; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4ee079e7c2bb5bc8b10d8cd0abd4317ab888d900 commit 4ee079e7c2bb5bc8b10d8cd0abd4317ab888d900 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:43 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 17:50:38 2015 +0200 cmGeneratorTarget: Make CompatibleType enum private again. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index a9245c0..fe73fee 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1524,18 +1524,26 @@ bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty( return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0; } +enum CompatibleType +{ + BoolType, + StringType, + NumberMinType, + NumberMaxType +}; + template PropertyType getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, - cmTarget::CompatibleType, + CompatibleType, PropertyType *); template<> bool getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, - cmTarget::CompatibleType, bool *) + CompatibleType, bool *) { return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); } @@ -1544,19 +1552,19 @@ template<> const char * getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, - cmTarget::CompatibleType t, + CompatibleType t, const char **) { switch(t) { - case cmTarget::BoolType: + case BoolType: assert(0 && "String compatibility check function called for boolean"); return 0; - case cmTarget::StringType: + case StringType: return tgt->GetLinkInterfaceDependentStringProperty(prop, config); - case cmTarget::NumberMinType: + case NumberMinType: return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config); - case cmTarget::NumberMaxType: + case NumberMaxType: return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config); } assert(0 && "Unreachable!"); @@ -1570,7 +1578,7 @@ void checkPropertyConsistency(cmGeneratorTarget const* depender, const std::string& propName, std::set &emitted, const std::string& config, - cmTarget::CompatibleType t, + CompatibleType t, PropertyType *) { const char *prop = dependee->GetProperty(propName); @@ -1683,7 +1691,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( checkPropertyConsistency(this, li->Target, strBool, - emittedBools, config, cmTarget::BoolType, 0); + emittedBools, config, BoolType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; @@ -1691,7 +1699,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( checkPropertyConsistency(this, li->Target, strString, emittedStrings, config, - cmTarget::StringType, 0); + StringType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; @@ -1699,7 +1707,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( checkPropertyConsistency(this, li->Target, strNumMin, emittedMinNumbers, config, - cmTarget::NumberMinType, 0); + NumberMinType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; @@ -1707,7 +1715,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( checkPropertyConsistency(this, li->Target, strNumMax, emittedMaxNumbers, config, - cmTarget::NumberMaxType, 0); + NumberMaxType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; @@ -1760,17 +1768,17 @@ void cmGeneratorTarget::CheckPropertyCompatibility( } //---------------------------------------------------------------------------- -std::string compatibilityType(cmTarget::CompatibleType t) +std::string compatibilityType(CompatibleType t) { switch(t) { - case cmTarget::BoolType: + case BoolType: return "Boolean compatibility"; - case cmTarget::StringType: + case StringType: return "String compatibility"; - case cmTarget::NumberMaxType: + case NumberMaxType: return "Numeric maximum compatibility"; - case cmTarget::NumberMinType: + case NumberMinType: return "Numeric minimum compatibility"; } assert(0 && "Unreachable!"); @@ -1778,15 +1786,15 @@ std::string compatibilityType(cmTarget::CompatibleType t) } //---------------------------------------------------------------------------- -std::string compatibilityAgree(cmTarget::CompatibleType t, bool dominant) +std::string compatibilityAgree(CompatibleType t, bool dominant) { switch(t) { - case cmTarget::BoolType: - case cmTarget::StringType: + case BoolType: + case StringType: return dominant ? "(Disagree)\n" : "(Agree)\n"; - case cmTarget::NumberMaxType: - case cmTarget::NumberMinType: + case NumberMaxType: + case NumberMinType: return dominant ? "(Dominant)\n" : "(Ignored)\n"; } assert(0 && "Unreachable!"); @@ -1842,12 +1850,12 @@ const char* impliedValue(const char*) template std::pair consistentProperty(PropertyType lhs, PropertyType rhs, - cmTarget::CompatibleType t); + CompatibleType t); //---------------------------------------------------------------------------- template<> std::pair consistentProperty(bool lhs, bool rhs, - cmTarget::CompatibleType) + CompatibleType) { return std::make_pair(lhs == rhs, lhs); } @@ -1863,7 +1871,7 @@ std::pair consistentStringProperty(const char *lhs, //---------------------------------------------------------------------------- std::pair consistentNumberProperty(const char *lhs, const char *rhs, - cmTarget::CompatibleType t) + CompatibleType t) { char *pEnd; @@ -1881,7 +1889,7 @@ std::pair consistentNumberProperty(const char *lhs, return std::pair(false, null_ptr); } - if (t == cmTarget::NumberMaxType) + if (t == NumberMaxType) { return std::make_pair(true, std::max(lnum, rnum) == lnum ? lhs : rhs); } @@ -1895,7 +1903,7 @@ std::pair consistentNumberProperty(const char *lhs, template<> std::pair consistentProperty(const char *lhs, const char *rhs, - cmTarget::CompatibleType t) + CompatibleType t) { if (!lhs && !rhs) { @@ -1914,13 +1922,13 @@ std::pair consistentProperty(const char *lhs, switch(t) { - case cmTarget::BoolType: + case BoolType: assert(0 && "consistentProperty for strings called with BoolType"); return std::pair(false, null_ptr); - case cmTarget::StringType: + case StringType: return consistentStringProperty(lhs, rhs); - case cmTarget::NumberMinType: - case cmTarget::NumberMaxType: + case NumberMinType: + case NumberMaxType: return consistentNumberProperty(lhs, rhs, t); } assert(0 && "Unreachable!"); @@ -1933,7 +1941,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, const std::string &p, const std::string& config, const char *defaultValue, - cmTarget::CompatibleType t, + CompatibleType t, PropertyType *) { PropertyType propContent = getTypedProperty(tgt, p); @@ -2119,7 +2127,7 @@ bool cmGeneratorTarget::GetLinkInterfaceDependentBoolProperty( { return checkInterfacePropertyCompatibility(this->Target, p, config, "FALSE", - cmTarget::BoolType, 0); + BoolType, 0); } //---------------------------------------------------------------------------- @@ -2131,7 +2139,7 @@ const char* cmGeneratorTarget::GetLinkInterfaceDependentStringProperty( p, config, "empty", - cmTarget::StringType, 0); + StringType, 0); } //---------------------------------------------------------------------------- @@ -2143,7 +2151,7 @@ const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMinProperty( p, config, "empty", - cmTarget::NumberMinType, 0); + NumberMinType, 0); } //---------------------------------------------------------------------------- @@ -2155,7 +2163,7 @@ const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMaxProperty( p, config, "empty", - cmTarget::NumberMaxType, 0); + NumberMaxType, 0); } //---------------------------------------------------------------------------- diff --git a/Source/cmTarget.h b/Source/cmTarget.h index b544b0b..795753e 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -581,14 +581,6 @@ public: return this->LinkLibrariesForVS6;} #endif - enum CompatibleType - { - BoolType, - StringType, - NumberMinType, - NumberMaxType - }; - private: bool HandleLocationPropertyPolicy(cmMakefile* context) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e65cdf6014d296356c40c37403e1f48302933ccf commit e65cdf6014d296356c40c37403e1f48302933ccf Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:43 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 17:50:38 2015 +0200 cmGeneratorTarget: Move LinkInterfaceDependent methods from cmTarget. diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index c1641cc..a20579b 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1142,7 +1142,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode context->Config)) { context->HadContextSensitiveCondition = true; - return target->GetLinkInterfaceDependentBoolProperty( + return gtgt->GetLinkInterfaceDependentBoolProperty( propertyName, context->Config) ? "1" : "0"; } @@ -1151,7 +1151,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { context->HadContextSensitiveCondition = true; const char *propContent = - target->GetLinkInterfaceDependentStringProperty( + gtgt->GetLinkInterfaceDependentStringProperty( propertyName, context->Config); return propContent ? propContent : ""; @@ -1161,7 +1161,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { context->HadContextSensitiveCondition = true; const char *propContent = - target->GetLinkInterfaceDependentNumberMinProperty( + gtgt->GetLinkInterfaceDependentNumberMinProperty( propertyName, context->Config); return propContent ? propContent : ""; @@ -1171,7 +1171,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { context->HadContextSensitiveCondition = true; const char *propContent = - target->GetLinkInterfaceDependentNumberMaxProperty( + gtgt->GetLinkInterfaceDependentNumberMaxProperty( propertyName, context->Config); return propContent ? propContent : ""; @@ -1188,7 +1188,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { context->HadContextSensitiveCondition = true; const char *propContent = - target->GetLinkInterfaceDependentNumberMinProperty( + gtgt->GetLinkInterfaceDependentNumberMinProperty( propertyName, context->Config); return propContent ? propContent : ""; @@ -1198,7 +1198,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { context->HadContextSensitiveCondition = true; const char *propContent = - target->GetLinkInterfaceDependentNumberMaxProperty( + gtgt->GetLinkInterfaceDependentNumberMaxProperty( propertyName, context->Config); return propContent ? propContent : ""; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index a7b0349..a9245c0 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -24,6 +24,7 @@ #include +#include #include "assert.h" //---------------------------------------------------------------------------- @@ -753,8 +754,7 @@ void cmGeneratorTarget::GetAutoUicOptions(std::vector &result, const std::string& config) const { const char *prop - = this->Target-> - GetLinkInterfaceDependentStringProperty("AUTOUIC_OPTIONS", + = this->GetLinkInterfaceDependentStringProperty("AUTOUIC_OPTIONS", config); if (!prop) { @@ -1537,7 +1537,7 @@ bool getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& config, cmTarget::CompatibleType, bool *) { - return tgt->Target->GetLinkInterfaceDependentBoolProperty(prop, config); + return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); } template<> @@ -1553,13 +1553,11 @@ const char * getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, assert(0 && "String compatibility check function called for boolean"); return 0; case cmTarget::StringType: - return tgt->Target->GetLinkInterfaceDependentStringProperty(prop, config); + return tgt->GetLinkInterfaceDependentStringProperty(prop, config); case cmTarget::NumberMinType: - return tgt->Target - ->GetLinkInterfaceDependentNumberMinProperty(prop, config); + return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config); case cmTarget::NumberMaxType: - return tgt->Target - ->GetLinkInterfaceDependentNumberMaxProperty(prop, config); + return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config); } assert(0 && "Unreachable!"); return 0; @@ -1762,6 +1760,405 @@ void cmGeneratorTarget::CheckPropertyCompatibility( } //---------------------------------------------------------------------------- +std::string compatibilityType(cmTarget::CompatibleType t) +{ + switch(t) + { + case cmTarget::BoolType: + return "Boolean compatibility"; + case cmTarget::StringType: + return "String compatibility"; + case cmTarget::NumberMaxType: + return "Numeric maximum compatibility"; + case cmTarget::NumberMinType: + return "Numeric minimum compatibility"; + } + assert(0 && "Unreachable!"); + return ""; +} + +//---------------------------------------------------------------------------- +std::string compatibilityAgree(cmTarget::CompatibleType t, bool dominant) +{ + switch(t) + { + case cmTarget::BoolType: + case cmTarget::StringType: + return dominant ? "(Disagree)\n" : "(Agree)\n"; + case cmTarget::NumberMaxType: + case cmTarget::NumberMinType: + return dominant ? "(Dominant)\n" : "(Ignored)\n"; + } + assert(0 && "Unreachable!"); + return ""; +} + +//---------------------------------------------------------------------------- +template +PropertyType getTypedProperty(cmTarget const* tgt, const std::string& prop); + +//---------------------------------------------------------------------------- +template<> +bool getTypedProperty(cmTarget const* tgt, const std::string& prop) +{ + return tgt->GetPropertyAsBool(prop); +} + +//---------------------------------------------------------------------------- +template<> +const char *getTypedProperty(cmTarget const* tgt, + const std::string& prop) +{ + return tgt->GetProperty(prop); +} + +template +std::string valueAsString(PropertyType); +template<> +std::string valueAsString(bool value) +{ + return value ? "TRUE" : "FALSE"; +} +template<> +std::string valueAsString(const char* value) +{ + return value ? value : "(unset)"; +} + +template +PropertyType impliedValue(PropertyType); +template<> +bool impliedValue(bool) +{ + return false; +} +template<> +const char* impliedValue(const char*) +{ + return ""; +} + +//---------------------------------------------------------------------------- +template +std::pair consistentProperty(PropertyType lhs, + PropertyType rhs, + cmTarget::CompatibleType t); + +//---------------------------------------------------------------------------- +template<> +std::pair consistentProperty(bool lhs, bool rhs, + cmTarget::CompatibleType) +{ + return std::make_pair(lhs == rhs, lhs); +} + +//---------------------------------------------------------------------------- +std::pair consistentStringProperty(const char *lhs, + const char *rhs) +{ + const bool b = strcmp(lhs, rhs) == 0; + return std::make_pair(b, b ? lhs : 0); +} + +//---------------------------------------------------------------------------- +std::pair consistentNumberProperty(const char *lhs, + const char *rhs, + cmTarget::CompatibleType t) +{ + char *pEnd; + + const char* const null_ptr = 0; + + long lnum = strtol(lhs, &pEnd, 0); + if (pEnd == lhs || *pEnd != '\0' || errno == ERANGE) + { + return std::pair(false, null_ptr); + } + + long rnum = strtol(rhs, &pEnd, 0); + if (pEnd == rhs || *pEnd != '\0' || errno == ERANGE) + { + return std::pair(false, null_ptr); + } + + if (t == cmTarget::NumberMaxType) + { + return std::make_pair(true, std::max(lnum, rnum) == lnum ? lhs : rhs); + } + else + { + return std::make_pair(true, std::min(lnum, rnum) == lnum ? lhs : rhs); + } +} + +//---------------------------------------------------------------------------- +template<> +std::pair consistentProperty(const char *lhs, + const char *rhs, + cmTarget::CompatibleType t) +{ + if (!lhs && !rhs) + { + return std::make_pair(true, lhs); + } + if (!lhs) + { + return std::make_pair(true, rhs); + } + if (!rhs) + { + return std::make_pair(true, lhs); + } + + const char* const null_ptr = 0; + + switch(t) + { + case cmTarget::BoolType: + assert(0 && "consistentProperty for strings called with BoolType"); + return std::pair(false, null_ptr); + case cmTarget::StringType: + return consistentStringProperty(lhs, rhs); + case cmTarget::NumberMinType: + case cmTarget::NumberMaxType: + return consistentNumberProperty(lhs, rhs, t); + } + assert(0 && "Unreachable!"); + return std::pair(false, null_ptr); +} + +//---------------------------------------------------------------------------- +template +PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, + const std::string &p, + const std::string& config, + const char *defaultValue, + cmTarget::CompatibleType t, + PropertyType *) +{ + PropertyType propContent = getTypedProperty(tgt, p); + const bool explicitlySet = tgt->GetProperties() + .find(p) + != tgt->GetProperties().end(); + const bool impliedByUse = + tgt->IsNullImpliedByLinkLibraries(p); + assert((impliedByUse ^ explicitlySet) + || (!impliedByUse && !explicitlySet)); + + std::vector const& deps = + tgt->GetLinkImplementationClosure(config); + + if(deps.empty()) + { + return propContent; + } + bool propInitialized = explicitlySet; + + std::string report = " * Target \""; + report += tgt->GetName(); + if (explicitlySet) + { + report += "\" has property content \""; + report += valueAsString(propContent); + report += "\"\n"; + } + else if (impliedByUse) + { + report += "\" property is implied by use.\n"; + } + else + { + report += "\" property not set.\n"; + } + + std::string interfaceProperty = "INTERFACE_" + p; + for(std::vector::const_iterator li = + deps.begin(); + li != deps.end(); ++li) + { + // An error should be reported if one dependency + // has INTERFACE_POSITION_INDEPENDENT_CODE ON and the other + // has INTERFACE_POSITION_INDEPENDENT_CODE OFF, or if the + // target itself has a POSITION_INDEPENDENT_CODE which disagrees + // with a dependency. + + cmTarget const* theTarget = *li; + + const bool ifaceIsSet = theTarget->GetProperties() + .find(interfaceProperty) + != theTarget->GetProperties().end(); + PropertyType ifacePropContent = + getTypedProperty(theTarget, + interfaceProperty); + + std::string reportEntry; + if (ifaceIsSet) + { + reportEntry += " * Target \""; + reportEntry += theTarget->GetName(); + reportEntry += "\" property value \""; + reportEntry += valueAsString(ifacePropContent); + reportEntry += "\" "; + } + + if (explicitlySet) + { + if (ifaceIsSet) + { + std::pair consistent = + consistentProperty(propContent, + ifacePropContent, t); + report += reportEntry; + report += compatibilityAgree(t, propContent != consistent.second); + if (!consistent.first) + { + std::ostringstream e; + e << "Property " << p << " on target \"" + << tgt->GetName() << "\" does\nnot match the " + "INTERFACE_" << p << " property requirement\nof " + "dependency \"" << theTarget->GetName() << "\".\n"; + cmSystemTools::Error(e.str().c_str()); + break; + } + else + { + propContent = consistent.second; + continue; + } + } + else + { + // Explicitly set on target and not set in iface. Can't disagree. + continue; + } + } + else if (impliedByUse) + { + propContent = impliedValue(propContent); + + if (ifaceIsSet) + { + std::pair consistent = + consistentProperty(propContent, + ifacePropContent, t); + report += reportEntry; + report += compatibilityAgree(t, propContent != consistent.second); + if (!consistent.first) + { + std::ostringstream e; + e << "Property " << p << " on target \"" + << tgt->GetName() << "\" is\nimplied to be " << defaultValue + << " because it was used to determine the link libraries\n" + "already. The INTERFACE_" << p << " property on\ndependency \"" + << theTarget->GetName() << "\" is in conflict.\n"; + cmSystemTools::Error(e.str().c_str()); + break; + } + else + { + propContent = consistent.second; + continue; + } + } + else + { + // Implicitly set on target and not set in iface. Can't disagree. + continue; + } + } + else + { + if (ifaceIsSet) + { + if (propInitialized) + { + std::pair consistent = + consistentProperty(propContent, + ifacePropContent, t); + report += reportEntry; + report += compatibilityAgree(t, propContent != consistent.second); + if (!consistent.first) + { + std::ostringstream e; + e << "The INTERFACE_" << p << " property of \"" + << theTarget->GetName() << "\" does\nnot agree with the value " + "of " << p << " already determined\nfor \"" + << tgt->GetName() << "\".\n"; + cmSystemTools::Error(e.str().c_str()); + break; + } + else + { + propContent = consistent.second; + continue; + } + } + else + { + report += reportEntry + "(Interface set)\n"; + propContent = ifacePropContent; + propInitialized = true; + } + } + else + { + // Not set. Nothing to agree on. + continue; + } + } + } + + tgt->ReportPropertyOrigin(p, valueAsString(propContent), + report, compatibilityType(t)); + return propContent; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::GetLinkInterfaceDependentBoolProperty( + const std::string &p, const std::string& config) const +{ + return checkInterfacePropertyCompatibility(this->Target, p, config, + "FALSE", + cmTarget::BoolType, 0); +} + +//---------------------------------------------------------------------------- +const char* cmGeneratorTarget::GetLinkInterfaceDependentStringProperty( + const std::string &p, + const std::string& config) const +{ + return checkInterfacePropertyCompatibility(this->Target, + p, + config, + "empty", + cmTarget::StringType, 0); +} + +//---------------------------------------------------------------------------- +const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMinProperty( + const std::string &p, + const std::string& config) const +{ + return checkInterfacePropertyCompatibility(this->Target, + p, + config, + "empty", + cmTarget::NumberMinType, 0); +} + +//---------------------------------------------------------------------------- +const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMaxProperty( + const std::string &p, + const std::string& config) const +{ + return checkInterfacePropertyCompatibility(this->Target, + p, + config, + "empty", + cmTarget::NumberMaxType, 0); +} + +//---------------------------------------------------------------------------- cmComputeLinkInformation* cmGeneratorTarget::GetLinkInformation(const std::string& config) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index ae86e19..d65b1ef 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -96,6 +96,17 @@ public: bool IsLinkInterfaceDependentNumberMaxProperty(const std::string &p, const std::string& config) const; + bool GetLinkInterfaceDependentBoolProperty(const std::string &p, + const std::string& config) const; + + const char *GetLinkInterfaceDependentStringProperty(const std::string &p, + const std::string& config) const; + const char *GetLinkInterfaceDependentNumberMinProperty(const std::string &p, + const std::string& config) const; + const char *GetLinkInterfaceDependentNumberMaxProperty(const std::string &p, + const std::string& config) const; + + /** Get the full path to the target according to the settings in its makefile and the configuration type. */ std::string GetFullPath(const std::string& config="", bool implib = false, diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index eaf812f..3ab501d 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2059,7 +2059,9 @@ void cmLocalGenerator::AddCMP0018Flags(std::string &flags, return; } - if (target->GetLinkInterfaceDependentBoolProperty( + cmGeneratorTarget* gtgt = + this->GlobalGenerator->GetGeneratorTarget(target); + if (gtgt->GetLinkInterfaceDependentBoolProperty( "POSITION_INDEPENDENT_CODE", config)) { diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index a72b176..f1ba2f4 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -547,8 +547,11 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target) { qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR"); } + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); if (const char *targetQtVersion = - target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", "")) + gtgt->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", "")) { qtVersion = targetQtVersion; } @@ -1150,6 +1153,9 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) std::string cmQtAutoGenerators::GetRccExecutable(cmTarget const* target) { + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); cmMakefile *makefile = target->GetMakefile(); const char *qtVersion = makefile->GetDefinition("_target_qt_version"); if (!qtVersion) @@ -1160,8 +1166,7 @@ std::string cmQtAutoGenerators::GetRccExecutable(cmTarget const* target) qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR"); } if (const char *targetQtVersion = - target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", - "")) + gtgt->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", "")) { qtVersion = targetQtVersion; } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index b165545..1fa62e7 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4536,141 +4536,6 @@ bool cmTarget::IsNullImpliedByLinkLibraries(const std::string &p) const } //---------------------------------------------------------------------------- -template -PropertyType getTypedProperty(cmTarget const* tgt, const std::string& prop); - -//---------------------------------------------------------------------------- -template<> -bool getTypedProperty(cmTarget const* tgt, const std::string& prop) -{ - return tgt->GetPropertyAsBool(prop); -} - -//---------------------------------------------------------------------------- -template<> -const char *getTypedProperty(cmTarget const* tgt, - const std::string& prop) -{ - return tgt->GetProperty(prop); -} - -//---------------------------------------------------------------------------- -template -std::pair consistentProperty(PropertyType lhs, - PropertyType rhs, - cmTarget::CompatibleType t); - -//---------------------------------------------------------------------------- -template<> -std::pair consistentProperty(bool lhs, bool rhs, - cmTarget::CompatibleType) -{ - return std::make_pair(lhs == rhs, lhs); -} - -//---------------------------------------------------------------------------- -std::pair consistentStringProperty(const char *lhs, - const char *rhs) -{ - const bool b = strcmp(lhs, rhs) == 0; - return std::make_pair(b, b ? lhs : 0); -} - -//---------------------------------------------------------------------------- -std::pair consistentNumberProperty(const char *lhs, - const char *rhs, - cmTarget::CompatibleType t) -{ - char *pEnd; - - const char* const null_ptr = 0; - - long lnum = strtol(lhs, &pEnd, 0); - if (pEnd == lhs || *pEnd != '\0' || errno == ERANGE) - { - return std::pair(false, null_ptr); - } - - long rnum = strtol(rhs, &pEnd, 0); - if (pEnd == rhs || *pEnd != '\0' || errno == ERANGE) - { - return std::pair(false, null_ptr); - } - - if (t == cmTarget::NumberMaxType) - { - return std::make_pair(true, std::max(lnum, rnum) == lnum ? lhs : rhs); - } - else - { - return std::make_pair(true, std::min(lnum, rnum) == lnum ? lhs : rhs); - } -} - -//---------------------------------------------------------------------------- -template<> -std::pair consistentProperty(const char *lhs, - const char *rhs, - cmTarget::CompatibleType t) -{ - if (!lhs && !rhs) - { - return std::make_pair(true, lhs); - } - if (!lhs) - { - return std::make_pair(true, rhs); - } - if (!rhs) - { - return std::make_pair(true, lhs); - } - - const char* const null_ptr = 0; - - switch(t) - { - case cmTarget::BoolType: - assert(0 && "consistentProperty for strings called with BoolType"); - return std::pair(false, null_ptr); - case cmTarget::StringType: - return consistentStringProperty(lhs, rhs); - case cmTarget::NumberMinType: - case cmTarget::NumberMaxType: - return consistentNumberProperty(lhs, rhs, t); - } - assert(0 && "Unreachable!"); - return std::pair(false, null_ptr); -} - -template -PropertyType impliedValue(PropertyType); -template<> -bool impliedValue(bool) -{ - return false; -} -template<> -const char* impliedValue(const char*) -{ - return ""; -} - - -template -std::string valueAsString(PropertyType); -template<> -std::string valueAsString(bool value) -{ - return value ? "TRUE" : "FALSE"; -} -template<> -std::string valueAsString(const char* value) -{ - return value ? value : "(unset)"; -} - -//---------------------------------------------------------------------------- void cmTarget::ReportPropertyOrigin(const std::string &p, const std::string &result, @@ -4711,270 +4576,6 @@ cmTarget::ReportPropertyOrigin(const std::string &p, } //---------------------------------------------------------------------------- -std::string compatibilityType(cmTarget::CompatibleType t) -{ - switch(t) - { - case cmTarget::BoolType: - return "Boolean compatibility"; - case cmTarget::StringType: - return "String compatibility"; - case cmTarget::NumberMaxType: - return "Numeric maximum compatibility"; - case cmTarget::NumberMinType: - return "Numeric minimum compatibility"; - } - assert(0 && "Unreachable!"); - return ""; -} - -//---------------------------------------------------------------------------- -std::string compatibilityAgree(cmTarget::CompatibleType t, bool dominant) -{ - switch(t) - { - case cmTarget::BoolType: - case cmTarget::StringType: - return dominant ? "(Disagree)\n" : "(Agree)\n"; - case cmTarget::NumberMaxType: - case cmTarget::NumberMinType: - return dominant ? "(Dominant)\n" : "(Ignored)\n"; - } - assert(0 && "Unreachable!"); - return ""; -} - -//---------------------------------------------------------------------------- -template -PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, - const std::string &p, - const std::string& config, - const char *defaultValue, - cmTarget::CompatibleType t, - PropertyType *) -{ - PropertyType propContent = getTypedProperty(tgt, p); - const bool explicitlySet = tgt->GetProperties() - .find(p) - != tgt->GetProperties().end(); - const bool impliedByUse = - tgt->IsNullImpliedByLinkLibraries(p); - assert((impliedByUse ^ explicitlySet) - || (!impliedByUse && !explicitlySet)); - - std::vector const& deps = - tgt->GetLinkImplementationClosure(config); - - if(deps.empty()) - { - return propContent; - } - bool propInitialized = explicitlySet; - - std::string report = " * Target \""; - report += tgt->GetName(); - if (explicitlySet) - { - report += "\" has property content \""; - report += valueAsString(propContent); - report += "\"\n"; - } - else if (impliedByUse) - { - report += "\" property is implied by use.\n"; - } - else - { - report += "\" property not set.\n"; - } - - std::string interfaceProperty = "INTERFACE_" + p; - for(std::vector::const_iterator li = - deps.begin(); - li != deps.end(); ++li) - { - // An error should be reported if one dependency - // has INTERFACE_POSITION_INDEPENDENT_CODE ON and the other - // has INTERFACE_POSITION_INDEPENDENT_CODE OFF, or if the - // target itself has a POSITION_INDEPENDENT_CODE which disagrees - // with a dependency. - - cmTarget const* theTarget = *li; - - const bool ifaceIsSet = theTarget->GetProperties() - .find(interfaceProperty) - != theTarget->GetProperties().end(); - PropertyType ifacePropContent = - getTypedProperty(theTarget, - interfaceProperty); - - std::string reportEntry; - if (ifaceIsSet) - { - reportEntry += " * Target \""; - reportEntry += theTarget->GetName(); - reportEntry += "\" property value \""; - reportEntry += valueAsString(ifacePropContent); - reportEntry += "\" "; - } - - if (explicitlySet) - { - if (ifaceIsSet) - { - std::pair consistent = - consistentProperty(propContent, - ifacePropContent, t); - report += reportEntry; - report += compatibilityAgree(t, propContent != consistent.second); - if (!consistent.first) - { - std::ostringstream e; - e << "Property " << p << " on target \"" - << tgt->GetName() << "\" does\nnot match the " - "INTERFACE_" << p << " property requirement\nof " - "dependency \"" << theTarget->GetName() << "\".\n"; - cmSystemTools::Error(e.str().c_str()); - break; - } - else - { - propContent = consistent.second; - continue; - } - } - else - { - // Explicitly set on target and not set in iface. Can't disagree. - continue; - } - } - else if (impliedByUse) - { - propContent = impliedValue(propContent); - - if (ifaceIsSet) - { - std::pair consistent = - consistentProperty(propContent, - ifacePropContent, t); - report += reportEntry; - report += compatibilityAgree(t, propContent != consistent.second); - if (!consistent.first) - { - std::ostringstream e; - e << "Property " << p << " on target \"" - << tgt->GetName() << "\" is\nimplied to be " << defaultValue - << " because it was used to determine the link libraries\n" - "already. The INTERFACE_" << p << " property on\ndependency \"" - << theTarget->GetName() << "\" is in conflict.\n"; - cmSystemTools::Error(e.str().c_str()); - break; - } - else - { - propContent = consistent.second; - continue; - } - } - else - { - // Implicitly set on target and not set in iface. Can't disagree. - continue; - } - } - else - { - if (ifaceIsSet) - { - if (propInitialized) - { - std::pair consistent = - consistentProperty(propContent, - ifacePropContent, t); - report += reportEntry; - report += compatibilityAgree(t, propContent != consistent.second); - if (!consistent.first) - { - std::ostringstream e; - e << "The INTERFACE_" << p << " property of \"" - << theTarget->GetName() << "\" does\nnot agree with the value " - "of " << p << " already determined\nfor \"" - << tgt->GetName() << "\".\n"; - cmSystemTools::Error(e.str().c_str()); - break; - } - else - { - propContent = consistent.second; - continue; - } - } - else - { - report += reportEntry + "(Interface set)\n"; - propContent = ifacePropContent; - propInitialized = true; - } - } - else - { - // Not set. Nothing to agree on. - continue; - } - } - } - - tgt->ReportPropertyOrigin(p, valueAsString(propContent), - report, compatibilityType(t)); - return propContent; -} - -//---------------------------------------------------------------------------- -bool cmTarget::GetLinkInterfaceDependentBoolProperty(const std::string &p, - const std::string& config) const -{ - return checkInterfacePropertyCompatibility(this, p, config, "FALSE", - BoolType, 0); -} - -//---------------------------------------------------------------------------- -const char * cmTarget::GetLinkInterfaceDependentStringProperty( - const std::string &p, - const std::string& config) const -{ - return checkInterfacePropertyCompatibility(this, - p, - config, - "empty", - StringType, 0); -} - -//---------------------------------------------------------------------------- -const char * cmTarget::GetLinkInterfaceDependentNumberMinProperty( - const std::string &p, - const std::string& config) const -{ - return checkInterfacePropertyCompatibility(this, - p, - config, - "empty", - NumberMinType, 0); -} - -//---------------------------------------------------------------------------- -const char * cmTarget::GetLinkInterfaceDependentNumberMaxProperty( - const std::string &p, - const std::string& config) const -{ - return checkInterfacePropertyCompatibility(this, - p, - config, - "empty", - NumberMaxType, 0); -} - -//---------------------------------------------------------------------------- void cmTarget::GetObjectLibrariesCMP0026(std::vector& objlibs) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 8af74ef..b544b0b 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -553,15 +553,6 @@ public: const std::string& config) const; bool IsNullImpliedByLinkLibraries(const std::string &p) const; - bool GetLinkInterfaceDependentBoolProperty(const std::string &p, - const std::string& config) const; - - const char *GetLinkInterfaceDependentStringProperty(const std::string &p, - const std::string& config) const; - const char *GetLinkInterfaceDependentNumberMinProperty(const std::string &p, - const std::string& config) const; - const char *GetLinkInterfaceDependentNumberMaxProperty(const std::string &p, - const std::string& config) const; std::string GetDebugGeneratorExpressions(const std::string &value, cmTarget::LinkLibraryType llt) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d0ccd406c34e56a1ead7387eae091c4f92db5c00 commit d0ccd406c34e56a1ead7387eae091c4f92db5c00 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:43 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 17:50:37 2015 +0200 cmGeneratorTarget: Port internal API to cmGeneratorTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 1f3effb..a7b0349 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1525,23 +1525,23 @@ bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty( } template -PropertyType getLinkInterfaceDependentProperty(cmTarget const* tgt, +PropertyType getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, cmTarget::CompatibleType, PropertyType *); template<> -bool getLinkInterfaceDependentProperty(cmTarget const* tgt, +bool getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, cmTarget::CompatibleType, bool *) { - return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); + return tgt->Target->GetLinkInterfaceDependentBoolProperty(prop, config); } template<> -const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, +const char * getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, cmTarget::CompatibleType t, @@ -1553,11 +1553,13 @@ const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, assert(0 && "String compatibility check function called for boolean"); return 0; case cmTarget::StringType: - return tgt->GetLinkInterfaceDependentStringProperty(prop, config); + return tgt->Target->GetLinkInterfaceDependentStringProperty(prop, config); case cmTarget::NumberMinType: - return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config); + return tgt->Target + ->GetLinkInterfaceDependentNumberMinProperty(prop, config); case cmTarget::NumberMaxType: - return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config); + return tgt->Target + ->GetLinkInterfaceDependentNumberMaxProperty(prop, config); } assert(0 && "Unreachable!"); return 0; @@ -1565,7 +1567,7 @@ const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, //---------------------------------------------------------------------------- template -void checkPropertyConsistency(cmTarget const* depender, +void checkPropertyConsistency(cmGeneratorTarget const* depender, cmTarget const* dependee, const std::string& propName, std::set &emitted, @@ -1597,7 +1599,7 @@ void checkPropertyConsistency(cmTarget const* depender, << *pi << "\" listed in its " << propName << " property. " "This is not allowed. Only user-defined properties may appear " "listed in the " << propName << " property."; - depender->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, e.str()); + depender->GetLocalGenerator()->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } if(emitted.insert(*pi).second) @@ -1681,14 +1683,14 @@ void cmGeneratorTarget::CheckPropertyCompatibility( continue; } - checkPropertyConsistency(this->Target, li->Target, + checkPropertyConsistency(this, li->Target, strBool, emittedBools, config, cmTarget::BoolType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; } - checkPropertyConsistency(this->Target, li->Target, + checkPropertyConsistency(this, li->Target, strString, emittedStrings, config, cmTarget::StringType, 0); @@ -1696,7 +1698,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( { return; } - checkPropertyConsistency(this->Target, li->Target, + checkPropertyConsistency(this, li->Target, strNumMin, emittedMinNumbers, config, cmTarget::NumberMinType, 0); @@ -1704,7 +1706,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( { return; } - checkPropertyConsistency(this->Target, li->Target, + checkPropertyConsistency(this, li->Target, strNumMax, emittedMaxNumbers, config, cmTarget::NumberMaxType, 0); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=dd3e78c0c841ff3abeaa8bcbb6d721b8fbef01b4 commit dd3e78c0c841ff3abeaa8bcbb6d721b8fbef01b4 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:43 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 17:50:37 2015 +0200 cmGeneratorTarget: Move CheckPropertyCompatibility from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 845c052..1f3effb 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1524,6 +1524,240 @@ bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty( return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0; } +template +PropertyType getLinkInterfaceDependentProperty(cmTarget const* tgt, + const std::string& prop, + const std::string& config, + cmTarget::CompatibleType, + PropertyType *); + +template<> +bool getLinkInterfaceDependentProperty(cmTarget const* tgt, + const std::string& prop, + const std::string& config, + cmTarget::CompatibleType, bool *) +{ + return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); +} + +template<> +const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, + const std::string& prop, + const std::string& config, + cmTarget::CompatibleType t, + const char **) +{ + switch(t) + { + case cmTarget::BoolType: + assert(0 && "String compatibility check function called for boolean"); + return 0; + case cmTarget::StringType: + return tgt->GetLinkInterfaceDependentStringProperty(prop, config); + case cmTarget::NumberMinType: + return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config); + case cmTarget::NumberMaxType: + return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config); + } + assert(0 && "Unreachable!"); + return 0; +} + +//---------------------------------------------------------------------------- +template +void checkPropertyConsistency(cmTarget const* depender, + cmTarget const* dependee, + const std::string& propName, + std::set &emitted, + const std::string& config, + cmTarget::CompatibleType t, + PropertyType *) +{ + const char *prop = dependee->GetProperty(propName); + if (!prop) + { + return; + } + + std::vector props; + cmSystemTools::ExpandListArgument(prop, props); + std::string pdir = + dependee->GetMakefile()->GetRequiredDefinition("CMAKE_ROOT"); + pdir += "/Help/prop_tgt/"; + + for(std::vector::iterator pi = props.begin(); + pi != props.end(); ++pi) + { + std::string pname = cmSystemTools::HelpFileName(*pi); + std::string pfile = pdir + pname + ".rst"; + if(cmSystemTools::FileExists(pfile.c_str(), true)) + { + std::ostringstream e; + e << "Target \"" << dependee->GetName() << "\" has property \"" + << *pi << "\" listed in its " << propName << " property. " + "This is not allowed. Only user-defined properties may appear " + "listed in the " << propName << " property."; + depender->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, e.str()); + return; + } + if(emitted.insert(*pi).second) + { + getLinkInterfaceDependentProperty(depender, *pi, config, + t, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + } + } +} + +static std::string intersect(const std::set &s1, + const std::set &s2) +{ + std::set intersect; + std::set_intersection(s1.begin(),s1.end(), + s2.begin(),s2.end(), + std::inserter(intersect,intersect.begin())); + if (!intersect.empty()) + { + return *intersect.begin(); + } + return ""; +} + +static std::string intersect(const std::set &s1, + const std::set &s2, + const std::set &s3) +{ + std::string result; + result = intersect(s1, s2); + if (!result.empty()) + return result; + result = intersect(s1, s3); + if (!result.empty()) + return result; + return intersect(s2, s3); +} + +static std::string intersect(const std::set &s1, + const std::set &s2, + const std::set &s3, + const std::set &s4) +{ + std::string result; + result = intersect(s1, s2); + if (!result.empty()) + return result; + result = intersect(s1, s3); + if (!result.empty()) + return result; + result = intersect(s1, s4); + if (!result.empty()) + return result; + return intersect(s2, s3, s4); +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::CheckPropertyCompatibility( + cmComputeLinkInformation *info, const std::string& config) const +{ + const cmComputeLinkInformation::ItemVector &deps = info->GetItems(); + + std::set emittedBools; + static std::string strBool = "COMPATIBLE_INTERFACE_BOOL"; + std::set emittedStrings; + static std::string strString = "COMPATIBLE_INTERFACE_STRING"; + std::set emittedMinNumbers; + static std::string strNumMin = "COMPATIBLE_INTERFACE_NUMBER_MIN"; + std::set emittedMaxNumbers; + static std::string strNumMax = "COMPATIBLE_INTERFACE_NUMBER_MAX"; + + for(cmComputeLinkInformation::ItemVector::const_iterator li = + deps.begin(); li != deps.end(); ++li) + { + if (!li->Target) + { + continue; + } + + checkPropertyConsistency(this->Target, li->Target, + strBool, + emittedBools, config, cmTarget::BoolType, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + checkPropertyConsistency(this->Target, li->Target, + strString, + emittedStrings, config, + cmTarget::StringType, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + checkPropertyConsistency(this->Target, li->Target, + strNumMin, + emittedMinNumbers, config, + cmTarget::NumberMinType, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + checkPropertyConsistency(this->Target, li->Target, + strNumMax, + emittedMaxNumbers, config, + cmTarget::NumberMaxType, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + } + + std::string prop = intersect(emittedBools, + emittedStrings, + emittedMinNumbers, + emittedMaxNumbers); + + if (!prop.empty()) + { + // Use a sorted std::vector to keep the error message sorted. + std::vector props; + std::set::const_iterator i = emittedBools.find(prop); + if (i != emittedBools.end()) + { + props.push_back(strBool); + } + i = emittedStrings.find(prop); + if (i != emittedStrings.end()) + { + props.push_back(strString); + } + i = emittedMinNumbers.find(prop); + if (i != emittedMinNumbers.end()) + { + props.push_back(strNumMin); + } + i = emittedMaxNumbers.find(prop); + if (i != emittedMaxNumbers.end()) + { + props.push_back(strNumMax); + } + std::sort(props.begin(), props.end()); + + std::string propsString = cmJoin(cmMakeRange(props).retreat(1), ", "); + propsString += " and the " + props.back(); + + std::ostringstream e; + e << "Property \"" << prop << "\" appears in both the " + << propsString << + " property in the dependencies of target \"" << this->GetName() << + "\". This is not allowed. A property may only require compatibility " + "in a boolean interpretation, a numeric minimum, a numeric maximum or a " + "string interpretation, but not a mixture."; + this->LocalGenerator->IssueMessage(cmake::FATAL_ERROR, e.str()); + } +} //---------------------------------------------------------------------------- cmComputeLinkInformation* @@ -1550,7 +1784,7 @@ cmGeneratorTarget::GetLinkInformation(const std::string& config) const if (info) { - this->Target->CheckPropertyCompatibility(info, config); + this->CheckPropertyCompatibility(info, config); } } return i->second; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index e53f098..ae86e19 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -222,6 +222,9 @@ private: cmTargetLinkInformationMap; mutable cmTargetLinkInformationMap LinkInformation; + void CheckPropertyCompatibility(cmComputeLinkInformation *info, + const std::string& config) const; + cmGeneratorTarget(cmGeneratorTarget const&); void operator=(cmGeneratorTarget const&); }; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index d8904ea..b165545 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4554,23 +4554,16 @@ const char *getTypedProperty(cmTarget const* tgt, return tgt->GetProperty(prop); } -enum CompatibleType -{ - BoolType, - StringType, - NumberMinType, - NumberMaxType -}; - //---------------------------------------------------------------------------- template std::pair consistentProperty(PropertyType lhs, PropertyType rhs, - CompatibleType t); + cmTarget::CompatibleType t); //---------------------------------------------------------------------------- template<> -std::pair consistentProperty(bool lhs, bool rhs, CompatibleType) +std::pair consistentProperty(bool lhs, bool rhs, + cmTarget::CompatibleType) { return std::make_pair(lhs == rhs, lhs); } @@ -4585,8 +4578,8 @@ std::pair consistentStringProperty(const char *lhs, //---------------------------------------------------------------------------- std::pair consistentNumberProperty(const char *lhs, - const char *rhs, - CompatibleType t) + const char *rhs, + cmTarget::CompatibleType t) { char *pEnd; @@ -4604,7 +4597,7 @@ std::pair consistentNumberProperty(const char *lhs, return std::pair(false, null_ptr); } - if (t == NumberMaxType) + if (t == cmTarget::NumberMaxType) { return std::make_pair(true, std::max(lnum, rnum) == lnum ? lhs : rhs); } @@ -4618,7 +4611,7 @@ std::pair consistentNumberProperty(const char *lhs, template<> std::pair consistentProperty(const char *lhs, const char *rhs, - CompatibleType t) + cmTarget::CompatibleType t) { if (!lhs && !rhs) { @@ -4637,13 +4630,13 @@ std::pair consistentProperty(const char *lhs, switch(t) { - case BoolType: + case cmTarget::BoolType: assert(0 && "consistentProperty for strings called with BoolType"); return std::pair(false, null_ptr); - case StringType: + case cmTarget::StringType: return consistentStringProperty(lhs, rhs); - case NumberMinType: - case NumberMaxType: + case cmTarget::NumberMinType: + case cmTarget::NumberMaxType: return consistentNumberProperty(lhs, rhs, t); } assert(0 && "Unreachable!"); @@ -4718,17 +4711,17 @@ cmTarget::ReportPropertyOrigin(const std::string &p, } //---------------------------------------------------------------------------- -std::string compatibilityType(CompatibleType t) +std::string compatibilityType(cmTarget::CompatibleType t) { switch(t) { - case BoolType: + case cmTarget::BoolType: return "Boolean compatibility"; - case StringType: + case cmTarget::StringType: return "String compatibility"; - case NumberMaxType: + case cmTarget::NumberMaxType: return "Numeric maximum compatibility"; - case NumberMinType: + case cmTarget::NumberMinType: return "Numeric minimum compatibility"; } assert(0 && "Unreachable!"); @@ -4736,15 +4729,15 @@ std::string compatibilityType(CompatibleType t) } //---------------------------------------------------------------------------- -std::string compatibilityAgree(CompatibleType t, bool dominant) +std::string compatibilityAgree(cmTarget::CompatibleType t, bool dominant) { switch(t) { - case BoolType: - case StringType: + case cmTarget::BoolType: + case cmTarget::StringType: return dominant ? "(Disagree)\n" : "(Agree)\n"; - case NumberMaxType: - case NumberMinType: + case cmTarget::NumberMaxType: + case cmTarget::NumberMinType: return dominant ? "(Dominant)\n" : "(Ignored)\n"; } assert(0 && "Unreachable!"); @@ -4757,7 +4750,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, const std::string &p, const std::string& config, const char *defaultValue, - CompatibleType t, + cmTarget::CompatibleType t, PropertyType *) { PropertyType propContent = getTypedProperty(tgt, p); @@ -6224,240 +6217,6 @@ std::string cmTarget::CheckCMP0004(std::string const& item) const return lib; } -template -PropertyType getLinkInterfaceDependentProperty(cmTarget const* tgt, - const std::string& prop, - const std::string& config, - CompatibleType, - PropertyType *); - -template<> -bool getLinkInterfaceDependentProperty(cmTarget const* tgt, - const std::string& prop, - const std::string& config, - CompatibleType, bool *) -{ - return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); -} - -template<> -const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, - const std::string& prop, - const std::string& config, - CompatibleType t, - const char **) -{ - switch(t) - { - case BoolType: - assert(0 && "String compatibility check function called for boolean"); - return 0; - case StringType: - return tgt->GetLinkInterfaceDependentStringProperty(prop, config); - case NumberMinType: - return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config); - case NumberMaxType: - return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config); - } - assert(0 && "Unreachable!"); - return 0; -} - -//---------------------------------------------------------------------------- -template -void checkPropertyConsistency(cmTarget const* depender, - cmTarget const* dependee, - const std::string& propName, - std::set &emitted, - const std::string& config, - CompatibleType t, - PropertyType *) -{ - const char *prop = dependee->GetProperty(propName); - if (!prop) - { - return; - } - - std::vector props; - cmSystemTools::ExpandListArgument(prop, props); - std::string pdir = - dependee->GetMakefile()->GetRequiredDefinition("CMAKE_ROOT"); - pdir += "/Help/prop_tgt/"; - - for(std::vector::iterator pi = props.begin(); - pi != props.end(); ++pi) - { - std::string pname = cmSystemTools::HelpFileName(*pi); - std::string pfile = pdir + pname + ".rst"; - if(cmSystemTools::FileExists(pfile.c_str(), true)) - { - std::ostringstream e; - e << "Target \"" << dependee->GetName() << "\" has property \"" - << *pi << "\" listed in its " << propName << " property. " - "This is not allowed. Only user-defined properties may appear " - "listed in the " << propName << " property."; - depender->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, e.str()); - return; - } - if(emitted.insert(*pi).second) - { - getLinkInterfaceDependentProperty(depender, *pi, config, - t, 0); - if (cmSystemTools::GetErrorOccuredFlag()) - { - return; - } - } - } -} - -static std::string intersect(const std::set &s1, - const std::set &s2) -{ - std::set intersect; - std::set_intersection(s1.begin(),s1.end(), - s2.begin(),s2.end(), - std::inserter(intersect,intersect.begin())); - if (!intersect.empty()) - { - return *intersect.begin(); - } - return ""; -} -static std::string intersect(const std::set &s1, - const std::set &s2, - const std::set &s3) -{ - std::string result; - result = intersect(s1, s2); - if (!result.empty()) - return result; - result = intersect(s1, s3); - if (!result.empty()) - return result; - return intersect(s2, s3); -} -static std::string intersect(const std::set &s1, - const std::set &s2, - const std::set &s3, - const std::set &s4) -{ - std::string result; - result = intersect(s1, s2); - if (!result.empty()) - return result; - result = intersect(s1, s3); - if (!result.empty()) - return result; - result = intersect(s1, s4); - if (!result.empty()) - return result; - return intersect(s2, s3, s4); -} - -//---------------------------------------------------------------------------- -void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, - const std::string& config) const -{ - const cmComputeLinkInformation::ItemVector &deps = info->GetItems(); - - std::set emittedBools; - static std::string strBool = "COMPATIBLE_INTERFACE_BOOL"; - std::set emittedStrings; - static std::string strString = "COMPATIBLE_INTERFACE_STRING"; - std::set emittedMinNumbers; - static std::string strNumMin = "COMPATIBLE_INTERFACE_NUMBER_MIN"; - std::set emittedMaxNumbers; - static std::string strNumMax = "COMPATIBLE_INTERFACE_NUMBER_MAX"; - - for(cmComputeLinkInformation::ItemVector::const_iterator li = - deps.begin(); - li != deps.end(); ++li) - { - if (!li->Target) - { - continue; - } - - checkPropertyConsistency(this, li->Target, - strBool, - emittedBools, config, BoolType, 0); - if (cmSystemTools::GetErrorOccuredFlag()) - { - return; - } - checkPropertyConsistency(this, li->Target, - strString, - emittedStrings, config, - StringType, 0); - if (cmSystemTools::GetErrorOccuredFlag()) - { - return; - } - checkPropertyConsistency(this, li->Target, - strNumMin, - emittedMinNumbers, config, - NumberMinType, 0); - if (cmSystemTools::GetErrorOccuredFlag()) - { - return; - } - checkPropertyConsistency(this, li->Target, - strNumMax, - emittedMaxNumbers, config, - NumberMaxType, 0); - if (cmSystemTools::GetErrorOccuredFlag()) - { - return; - } - } - - std::string prop = intersect(emittedBools, - emittedStrings, - emittedMinNumbers, - emittedMaxNumbers); - - if (!prop.empty()) - { - // Use a sorted std::vector to keep the error message sorted. - std::vector props; - std::set::const_iterator i = emittedBools.find(prop); - if (i != emittedBools.end()) - { - props.push_back(strBool); - } - i = emittedStrings.find(prop); - if (i != emittedStrings.end()) - { - props.push_back(strString); - } - i = emittedMinNumbers.find(prop); - if (i != emittedMinNumbers.end()) - { - props.push_back(strNumMin); - } - i = emittedMaxNumbers.find(prop); - if (i != emittedMaxNumbers.end()) - { - props.push_back(strNumMax); - } - std::sort(props.begin(), props.end()); - - std::string propsString = cmJoin(cmMakeRange(props).retreat(1), ", "); - propsString += " and the " + props.back(); - - std::ostringstream e; - e << "Property \"" << prop << "\" appears in both the " - << propsString << - " property in the dependencies of target \"" << this->GetName() << - "\". This is not allowed. A property may only require compatibility " - "in a boolean interpretation, a numeric minimum, a numeric maximum or a " - "string interpretation, but not a mixture."; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); - } -} - //---------------------------------------------------------------------------- std::string cmTarget::GetFrameworkDirectory(const std::string& config, bool rootDir) const diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e3410aa..8af74ef 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -590,6 +590,14 @@ public: return this->LinkLibrariesForVS6;} #endif + enum CompatibleType + { + BoolType, + StringType, + NumberMinType, + NumberMaxType + }; + private: bool HandleLocationPropertyPolicy(cmMakefile* context) const; @@ -754,9 +762,6 @@ private: struct CompileInfo; CompileInfo const* GetCompileInfo(const std::string& config) const; - void CheckPropertyCompatibility(cmComputeLinkInformation *info, - const std::string& config) const; - LinkInterface const* GetImportLinkInterface(const std::string& config, cmTarget const* head, bool usage_requirements_only) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=031923b3789733fd2dac507201b703335fb74a9f commit 031923b3789733fd2dac507201b703335fb74a9f Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:42 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 17:50:37 2015 +0200 cmGeneratorTarget: Move GetLinkInformation from cmTarget diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 26ca375..4840e89 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -276,7 +276,8 @@ std::string cmCommonTargetGenerator::GetFrameworkFlags(std::string const& l) std::string flags; const char* cfg = this->LocalGenerator->GetConfigName().c_str(); - if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(cfg)) + if(cmComputeLinkInformation* cli = + this->GeneratorTarget->GetLinkInformation(cfg)) { std::vector const& frameworks = cli->GetFrameworkPaths(); for(std::vector::const_iterator i = frameworks.begin(); @@ -384,7 +385,7 @@ cmCommonTargetGenerator::GetLinkedTargetDirectories() const std::vector dirs; std::set emitted; if (cmComputeLinkInformation* cli = - this->Target->GetLinkInformation(this->ConfigName)) + this->GeneratorTarget->GetLinkInformation(this->ConfigName)) { cmComputeLinkInformation::ItemVector const& items = cli->GetItems(); for(cmComputeLinkInformation::ItemVector::const_iterator diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index a5050ff..8a2cf4b 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -529,7 +529,7 @@ void getCompatibleInterfaceProperties(cmGeneratorTarget *target, std::set &ifaceProperties, const std::string& config) { - cmComputeLinkInformation *info = target->Target->GetLinkInformation(config); + cmComputeLinkInformation *info = target->GetLinkInformation(config); if (!info) { diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 3dbeff2..845c052 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -229,6 +229,12 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) this->GlobalGenerator = this->Makefile->GetGlobalGenerator(); } +cmGeneratorTarget::~cmGeneratorTarget() +{ + cmDeleteAll(this->LinkInformation); + this->LinkInformation.clear(); +} + cmLocalGenerator* cmGeneratorTarget::GetLocalGenerator() const { return this->LocalGenerator; @@ -1517,3 +1523,35 @@ bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty( } return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0; } + + +//---------------------------------------------------------------------------- +cmComputeLinkInformation* +cmGeneratorTarget::GetLinkInformation(const std::string& config) const +{ + // Lookup any existing information for this configuration. + std::string key(cmSystemTools::UpperCase(config)); + cmTargetLinkInformationMap::iterator + i = this->LinkInformation.find(key); + if(i == this->LinkInformation.end()) + { + // Compute information for this configuration. + cmComputeLinkInformation* info = + new cmComputeLinkInformation(this->Target, config); + if(!info || !info->Compute()) + { + delete info; + info = 0; + } + + // Store the information for this configuration. + cmTargetLinkInformationMap::value_type entry(key, info); + i = this->LinkInformation.insert(entry).first; + + if (info) + { + this->Target->CheckPropertyCompatibility(info, config); + } + } + return i->second; +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 3b32bf5..e53f098 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -20,11 +20,13 @@ class cmLocalGenerator; class cmMakefile; class cmSourceFile; class cmTarget; +class cmComputeLinkInformation; class cmGeneratorTarget { public: cmGeneratorTarget(cmTarget*, cmLocalGenerator* lg); + ~cmGeneratorTarget(); cmLocalGenerator* GetLocalGenerator() const; @@ -36,6 +38,9 @@ public: location is suitable for use as the LOCATION target property. */ const char* GetLocationForBuild() const; + cmComputeLinkInformation* + GetLinkInformation(const std::string& config) const; + int GetType() const; std::string GetName() const; const char *GetProperty(const std::string& prop) const; @@ -213,6 +218,10 @@ private: }; mutable std::map CompatibleInterfacesMap; + typedef std::map + cmTargetLinkInformationMap; + mutable cmTargetLinkInformationMap LinkInformation; + cmGeneratorTarget(cmGeneratorTarget const&); void operator=(cmGeneratorTarget const&); }; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 8cb59f8..b44848c 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2202,7 +2202,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, } } // Add framework search paths needed for linking. - if(cmComputeLinkInformation* cli = target.GetLinkInformation(configName)) + if(cmComputeLinkInformation* cli = gtgt->GetLinkInformation(configName)) { std::vector const& fwDirs = cli->GetFrameworkPaths(); for(std::vector::const_iterator fdi = fwDirs.begin(); @@ -2358,7 +2358,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, this->CreateString(install_name_dir.c_str())); // Create the LD_RUNPATH_SEARCH_PATHS - cmComputeLinkInformation* pcli = target.GetLinkInformation(configName); + cmComputeLinkInformation* pcli = gtgt->GetLinkInformation(configName); if(pcli) { std::string search_paths; @@ -2964,7 +2964,8 @@ void cmGlobalXCodeGenerator } // Compute the link library and directory information. - cmComputeLinkInformation* pcli = cmtarget->GetLinkInformation(configName); + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(cmtarget); + cmComputeLinkInformation* pcli = gtgt->GetLinkInformation(configName); if(!pcli) { continue; diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 01d4b77..c64f9a3 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -18,6 +18,7 @@ #include "cmMakefile.h" #include "cmGeneratorTarget.h" #include "cmake.h" +#include "cmGeneratorTarget.h" #include @@ -557,8 +558,7 @@ cmInstallTargetGenerator // Build a map of build-tree install_name to install-tree install_name for // shared libraries linked to this target. std::map install_name_remap; - if(cmComputeLinkInformation* cli = - this->Target->Target->GetLinkInformation(config)) + if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config)) { std::set const& sharedLibs = cli->GetSharedLibrariesLinked(); @@ -667,8 +667,7 @@ cmInstallTargetGenerator // Get the link information for this target. // It can provide the RPATH. - cmComputeLinkInformation* cli = - this->Target->Target->GetLinkInformation(config); + cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config); if(!cli) { return; @@ -700,8 +699,7 @@ cmInstallTargetGenerator // Get the link information for this target. // It can provide the RPATH. - cmComputeLinkInformation* cli = - this->Target->Target->GetLinkInformation(config); + cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config); if(!cli) { return; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 6b48a44..eaf812f 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1468,7 +1468,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, bool escapeAllowMakeVars = !forResponseFile; std::ostringstream fout; std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); - cmComputeLinkInformation* pcli = tgt.Target->GetLinkInformation(config); + cmComputeLinkInformation* pcli = tgt.GetLinkInformation(config); if(!pcli) { return; diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index cab5a47..61d7847 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1846,8 +1846,10 @@ void cmLocalVisualStudio6Generator const std::string extraOptions, std::string& options) { + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); // Compute the link information for this configuration. - cmComputeLinkInformation* pcli = target.GetLinkInformation(configName); + cmComputeLinkInformation* pcli = gt->GetLinkInformation(configName); if(!pcli) { return; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 572dbde..37e08dd 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1074,6 +1074,9 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, this->ConvertToOutputFormat(this->ModuleDefinitionFile, SHELL); linkOptions.AddFlag("ModuleDefinitionFile", defFile.c_str()); } + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); + if (target.GetType() == cmTarget::SHARED_LIBRARY && this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) { @@ -1148,7 +1151,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, targetNameImport, targetNamePDB, configName); // Compute the link library and directory information. - cmComputeLinkInformation* pcli = target.GetLinkInformation(configName); + cmComputeLinkInformation* pcli = gt->GetLinkInformation(configName); if(!pcli) { return; @@ -1245,7 +1248,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, targetNameImport, targetNamePDB, configName); // Compute the link library and directory information. - cmComputeLinkInformation* pcli = target.GetLinkInformation(configName); + cmComputeLinkInformation* pcli = gt->GetLinkInformation(configName); if(!pcli) { return; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 5edc0f5..ac8cd29 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1446,7 +1446,8 @@ void cmMakefileTargetGenerator // Loop over all library dependencies. const char* cfg = this->LocalGenerator->GetConfigName().c_str(); - if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(cfg)) + if(cmComputeLinkInformation* cli = + this->GeneratorTarget->GetLinkInformation(cfg)) { std::vector const& libDeps = cli->GetDepends(); depends.insert(depends.end(), libDeps.begin(), libDeps.end()); diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 4e4dc3f..cf80424 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -195,7 +195,7 @@ cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const return cmNinjaDeps(); cmComputeLinkInformation* cli = - this->Target->GetLinkInformation(this->GetConfigName()); + this->GeneratorTarget->GetLinkInformation(this->GetConfigName()); if(!cli) return cmNinjaDeps(); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 9c7e46a..d8904ea 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -520,8 +520,6 @@ void cmTarget::ClearLinkMaps() this->Internal->LinkInterfaceUsageRequirementsOnlyMap.clear(); this->Internal->LinkClosureMap.clear(); this->Internal->SourceFilesMap.clear(); - cmDeleteAll(this->LinkInformation); - this->LinkInformation.clear(); } //---------------------------------------------------------------------------- @@ -6461,37 +6459,6 @@ void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, } //---------------------------------------------------------------------------- -cmComputeLinkInformation* -cmTarget::GetLinkInformation(const std::string& config) const -{ - // Lookup any existing information for this configuration. - std::string key(cmSystemTools::UpperCase(config)); - cmTargetLinkInformationMap::iterator - i = this->LinkInformation.find(key); - if(i == this->LinkInformation.end()) - { - // Compute information for this configuration. - cmComputeLinkInformation* info = - new cmComputeLinkInformation(this, config); - if(!info || !info->Compute()) - { - delete info; - info = 0; - } - - // Store the information for this configuration. - cmTargetLinkInformationMap::value_type entry(key, info); - i = this->LinkInformation.insert(entry).first; - - if (info) - { - this->CheckPropertyCompatibility(info, config); - } - } - return i->second; -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetFrameworkDirectory(const std::string& config, bool rootDir) const { @@ -6583,26 +6550,6 @@ std::string cmTarget::GetMacContentDirectory(const std::string& config, } //---------------------------------------------------------------------------- -cmTargetLinkInformationMap -::cmTargetLinkInformationMap(cmTargetLinkInformationMap const& r): derived() -{ - // Ideally cmTarget instances should never be copied. However until - // we can make a sweep to remove that, this copy constructor avoids - // allowing the resources (LinkInformation) from getting copied. In - // the worst case this will lead to extra cmComputeLinkInformation - // instances. We also enforce in debug mode that the map be emptied - // when copied. - static_cast(r); - assert(r.empty()); -} - -//---------------------------------------------------------------------------- -cmTargetLinkInformationMap::~cmTargetLinkInformationMap() -{ - cmDeleteAll(*this); -} - -//---------------------------------------------------------------------------- cmTargetInternalPointer::cmTargetInternalPointer() { this->Pointer = new cmTargetInternals; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index df8cdc1..e3410aa 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -78,15 +78,6 @@ public: bool FromGenex; }; -struct cmTargetLinkInformationMap: - public std::map -{ - typedef std::map derived; - cmTargetLinkInformationMap() {} - cmTargetLinkInformationMap(cmTargetLinkInformationMap const& r); - ~cmTargetLinkInformationMap(); -}; - class cmTargetInternals; class cmTargetInternalPointer { @@ -454,9 +445,6 @@ public: * install tree. For example: "\@rpath/" or "\@loader_path/". */ std::string GetInstallNameDirForInstallTree() const; - cmComputeLinkInformation* - GetLinkInformation(const std::string& config) const; - // Get the properties cmPropertyMap &GetProperties() const { return this->Properties; } @@ -766,7 +754,6 @@ private: struct CompileInfo; CompileInfo const* GetCompileInfo(const std::string& config) const; - mutable cmTargetLinkInformationMap LinkInformation; void CheckPropertyCompatibility(cmComputeLinkInformation *info, const std::string& config) const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 71785e9..f3f291a 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2438,7 +2438,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) cmSystemTools::ExpandListArgument(libs, libVec); cmComputeLinkInformation* pcli = - this->Target->GetLinkInformation(config.c_str()); + this->GeneratorTarget->GetLinkInformation(config.c_str()); if(!pcli) { cmSystemTools::Error http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=95d50adcd018fff80ddecddab4b4842fba37e790 commit 95d50adcd018fff80ddecddab4b4842fba37e790 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:42 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 17:50:37 2015 +0200 Export: Port more API to cmGeneratorTarget. diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 355fc00..6274c3f 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -27,6 +27,7 @@ cmExportBuildFileGenerator::cmExportBuildFileGenerator() //---------------------------------------------------------------------------- bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) { + std::vector allTargets; { std::string expectedTargets; std::string sep; @@ -68,7 +69,8 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) tei = this->Exports.begin(); tei != this->Exports.end(); ++tei) { - cmTarget* te = (*tei)->Target; + cmGeneratorTarget* gte = *tei; + cmTarget* te = gte->Target; this->GenerateImportTargetCode(os, te); te->AppendBuildInterfaceIncludes(); @@ -104,7 +106,7 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) cmGeneratorExpression::BuildInterface, properties, missingTargets); } - this->PopulateCompatibleInterfaceProperties(te, properties); + this->PopulateCompatibleInterfaceProperties(gte, properties); this->GenerateInterfaceProperties(te, os, properties); } diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 3aa2b65..a5050ff 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -525,15 +525,15 @@ void getPropertyContents(cmTarget const* tgt, const std::string& prop, } //---------------------------------------------------------------------------- -void getCompatibleInterfaceProperties(cmTarget *target, +void getCompatibleInterfaceProperties(cmGeneratorTarget *target, std::set &ifaceProperties, const std::string& config) { - cmComputeLinkInformation *info = target->GetLinkInformation(config); + cmComputeLinkInformation *info = target->Target->GetLinkInformation(config); if (!info) { - cmMakefile* mf = target->GetMakefile(); + cmMakefile* mf = target->Target->GetMakefile(); std::ostringstream e; e << "Exporting the target \"" << target->GetName() << "\" is not " "allowed since its linker language cannot be determined"; @@ -568,9 +568,10 @@ void getCompatibleInterfaceProperties(cmTarget *target, //---------------------------------------------------------------------------- void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( - cmTarget *target, + cmGeneratorTarget *gtarget, ImportPropertyMap &properties) { + cmTarget *target = gtarget->Target; this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_BOOL", target, properties); this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_STRING", @@ -591,7 +592,7 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( if (target->GetType() != cmTarget::INTERFACE_LIBRARY) { - getCompatibleInterfaceProperties(target, ifaceProperties, ""); + getCompatibleInterfaceProperties(gtarget, ifaceProperties, ""); std::vector configNames; target->GetMakefile()->GetConfigurations(configNames); @@ -599,7 +600,7 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( for (std::vector::const_iterator ci = configNames.begin(); ci != configNames.end(); ++ci) { - getCompatibleInterfaceProperties(target, ifaceProperties, *ci); + getCompatibleInterfaceProperties(gtarget, ifaceProperties, *ci); } } diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index 2f33200..4e54740 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -132,7 +132,7 @@ protected: std::vector &missingTargets); void PopulateInterfaceProperty(const std::string& propName, cmTarget *target, ImportPropertyMap &properties); - void PopulateCompatibleInterfaceProperties(cmTarget *target, + void PopulateCompatibleInterfaceProperties(cmGeneratorTarget *target, ImportPropertyMap &properties); void GenerateInterfaceProperties(cmTarget const* target, std::ostream& os, const ImportPropertyMap &properties); diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index c88b7b2..b0bc686 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -193,7 +193,11 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE", te, properties); - this->PopulateCompatibleInterfaceProperties(te, properties); + cmGeneratorTarget *gtgt = te->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(te); + + this->PopulateCompatibleInterfaceProperties(gtgt, properties); this->GenerateInterfaceProperties(te, os, properties); } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=42ee51028e9a977e61df50c105a0de782d1f40b7 commit 42ee51028e9a977e61df50c105a0de782d1f40b7 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:42 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 17:50:36 2015 +0200 cmGeneratorTarget: Move IsLinkInterfaceDependent* from cmTarget. diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index c0485db..c1641cc 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1128,6 +1128,9 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode } } + cmGeneratorTarget* gtgt = + context->Makefile->GetGlobalGenerator()->GetGeneratorTarget(target); + if (!prop) { if (target->IsImported() @@ -1135,16 +1138,16 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { return linkedTargetsContent; } - if (target->IsLinkInterfaceDependentBoolProperty(propertyName, - context->Config)) + if (gtgt->IsLinkInterfaceDependentBoolProperty(propertyName, + context->Config)) { context->HadContextSensitiveCondition = true; return target->GetLinkInterfaceDependentBoolProperty( propertyName, context->Config) ? "1" : "0"; } - if (target->IsLinkInterfaceDependentStringProperty(propertyName, - context->Config)) + if (gtgt->IsLinkInterfaceDependentStringProperty(propertyName, + context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = @@ -1153,8 +1156,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode context->Config); return propContent ? propContent : ""; } - if (target->IsLinkInterfaceDependentNumberMinProperty(propertyName, - context->Config)) + if (gtgt->IsLinkInterfaceDependentNumberMinProperty(propertyName, + context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = @@ -1163,8 +1166,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode context->Config); return propContent ? propContent : ""; } - if (target->IsLinkInterfaceDependentNumberMaxProperty(propertyName, - context->Config)) + if (gtgt->IsLinkInterfaceDependentNumberMaxProperty(propertyName, + context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = @@ -1180,8 +1183,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode if (!target->IsImported() && dagCheckerParent && !dagCheckerParent->EvaluatingLinkLibraries()) { - if (target->IsLinkInterfaceDependentNumberMinProperty(propertyName, - context->Config)) + if (gtgt->IsLinkInterfaceDependentNumberMinProperty(propertyName, + context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = @@ -1190,8 +1193,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode context->Config); return propContent ? propContent : ""; } - if (target->IsLinkInterfaceDependentNumberMaxProperty(propertyName, - context->Config)) + if (gtgt->IsLinkInterfaceDependentNumberMaxProperty(propertyName, + context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 95f6aaa..3dbeff2 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1436,3 +1436,84 @@ void cmGeneratorTarget::ConstructSourceFileFlags() const } } } + +//---------------------------------------------------------------------------- +const cmGeneratorTarget::CompatibleInterfacesBase& +cmGeneratorTarget::GetCompatibleInterfaces(std::string const& config) const +{ + cmGeneratorTarget::CompatibleInterfaces& compat = + this->CompatibleInterfacesMap[config]; + if(!compat.Done) + { + compat.Done = true; + compat.PropsBool.insert("POSITION_INDEPENDENT_CODE"); + compat.PropsString.insert("AUTOUIC_OPTIONS"); + std::vector const& deps = + this->Target->GetLinkImplementationClosure(config); + for(std::vector::const_iterator li = deps.begin(); + li != deps.end(); ++li) + { +#define CM_READ_COMPATIBLE_INTERFACE(X, x) \ + if(const char* prop = (*li)->GetProperty("COMPATIBLE_INTERFACE_" #X)) \ + { \ + std::vector props; \ + cmSystemTools::ExpandListArgument(prop, props); \ + compat.Props##x.insert(props.begin(), props.end()); \ + } + CM_READ_COMPATIBLE_INTERFACE(BOOL, Bool) + CM_READ_COMPATIBLE_INTERFACE(STRING, String) + CM_READ_COMPATIBLE_INTERFACE(NUMBER_MIN, NumberMin) + CM_READ_COMPATIBLE_INTERFACE(NUMBER_MAX, NumberMax) +#undef CM_READ_COMPATIBLE_INTERFACE + } + } + return compat; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsLinkInterfaceDependentBoolProperty( + const std::string &p, const std::string& config) const +{ + if (this->Target->GetType() == cmTarget::OBJECT_LIBRARY + || this->Target->GetType() == cmTarget::INTERFACE_LIBRARY) + { + return false; + } + return this->GetCompatibleInterfaces(config).PropsBool.count(p) > 0; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsLinkInterfaceDependentStringProperty( + const std::string &p, const std::string& config) const +{ + if (this->Target->GetType() == cmTarget::OBJECT_LIBRARY + || this->Target->GetType() == cmTarget::INTERFACE_LIBRARY) + { + return false; + } + return this->GetCompatibleInterfaces(config).PropsString.count(p) > 0; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMinProperty( + const std::string &p, const std::string& config) const +{ + if (this->Target->GetType() == cmTarget::OBJECT_LIBRARY + || this->Target->GetType() == cmTarget::INTERFACE_LIBRARY) + { + return false; + } + return this->GetCompatibleInterfaces(config).PropsNumberMin.count(p) > 0; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty( + const std::string &p, const std::string& config) const +{ + if (this->Target->GetType() == cmTarget::OBJECT_LIBRARY + || this->Target->GetType() == cmTarget::INTERFACE_LIBRARY) + { + return false; + } + return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0; +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 3e43711..3b32bf5 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -82,6 +82,15 @@ public: bool GetFeatureAsBool(const std::string& feature, const std::string& config) const; + bool IsLinkInterfaceDependentBoolProperty(const std::string &p, + const std::string& config) const; + bool IsLinkInterfaceDependentStringProperty(const std::string &p, + const std::string& config) const; + bool IsLinkInterfaceDependentNumberMinProperty(const std::string &p, + const std::string& config) const; + bool IsLinkInterfaceDependentNumberMaxProperty(const std::string &p, + const std::string& config) const; + /** Get the full path to the target according to the settings in its makefile and the configuration type. */ std::string GetFullPath(const std::string& config="", bool implib = false, @@ -187,6 +196,23 @@ private: mutable bool SourceFileFlagsConstructed; mutable std::map SourceFlagsMap; + struct CompatibleInterfacesBase + { + std::set PropsBool; + std::set PropsString; + std::set PropsNumberMax; + std::set PropsNumberMin; + }; + CompatibleInterfacesBase const& + GetCompatibleInterfaces(std::string const& config) const; + + struct CompatibleInterfaces: public CompatibleInterfacesBase + { + CompatibleInterfaces(): Done(false) {} + bool Done; + }; + mutable std::map CompatibleInterfacesMap; + cmGeneratorTarget(cmGeneratorTarget const&); void operator=(cmGeneratorTarget const&); }; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 3074f9b..9c7e46a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -170,13 +170,6 @@ public: }; std::map LinkImplClosureMap; - struct CompatibleInterfaces: public cmTarget::CompatibleInterfaces - { - CompatibleInterfaces(): Done(false) {} - bool Done; - }; - std::map CompatibleInterfacesMap; - typedef std::map > SourceFilesMapType; SourceFilesMapType SourceFilesMap; @@ -4991,54 +4984,6 @@ const char * cmTarget::GetLinkInterfaceDependentNumberMaxProperty( } //---------------------------------------------------------------------------- -bool cmTarget::IsLinkInterfaceDependentBoolProperty(const std::string &p, - const std::string& config) const -{ - if (this->TargetTypeValue == OBJECT_LIBRARY - || this->TargetTypeValue == INTERFACE_LIBRARY) - { - return false; - } - return this->GetCompatibleInterfaces(config).PropsBool.count(p) > 0; -} - -//---------------------------------------------------------------------------- -bool cmTarget::IsLinkInterfaceDependentStringProperty(const std::string &p, - const std::string& config) const -{ - if (this->TargetTypeValue == OBJECT_LIBRARY - || this->TargetTypeValue == INTERFACE_LIBRARY) - { - return false; - } - return this->GetCompatibleInterfaces(config).PropsString.count(p) > 0; -} - -//---------------------------------------------------------------------------- -bool cmTarget::IsLinkInterfaceDependentNumberMinProperty(const std::string &p, - const std::string& config) const -{ - if (this->TargetTypeValue == OBJECT_LIBRARY - || this->TargetTypeValue == INTERFACE_LIBRARY) - { - return false; - } - return this->GetCompatibleInterfaces(config).PropsNumberMin.count(p) > 0; -} - -//---------------------------------------------------------------------------- -bool cmTarget::IsLinkInterfaceDependentNumberMaxProperty(const std::string &p, - const std::string& config) const -{ - if (this->TargetTypeValue == OBJECT_LIBRARY - || this->TargetTypeValue == INTERFACE_LIBRARY) - { - return false; - } - return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0; -} - -//---------------------------------------------------------------------------- void cmTarget::GetObjectLibrariesCMP0026(std::vector& objlibs) const { @@ -5725,39 +5670,6 @@ cmTarget::GetLinkImplementationClosure(const std::string& config) const } //---------------------------------------------------------------------------- -cmTarget::CompatibleInterfaces const& -cmTarget::GetCompatibleInterfaces(std::string const& config) const -{ - cmTargetInternals::CompatibleInterfaces& compat = - this->Internal->CompatibleInterfacesMap[config]; - if(!compat.Done) - { - compat.Done = true; - compat.PropsBool.insert("POSITION_INDEPENDENT_CODE"); - compat.PropsString.insert("AUTOUIC_OPTIONS"); - std::vector const& deps = - this->GetLinkImplementationClosure(config); - for(std::vector::const_iterator li = deps.begin(); - li != deps.end(); ++li) - { -#define CM_READ_COMPATIBLE_INTERFACE(X, x) \ - if(const char* prop = (*li)->GetProperty("COMPATIBLE_INTERFACE_" #X)) \ - { \ - std::vector props; \ - cmSystemTools::ExpandListArgument(prop, props); \ - compat.Props##x.insert(props.begin(), props.end()); \ - } - CM_READ_COMPATIBLE_INTERFACE(BOOL, Bool) - CM_READ_COMPATIBLE_INTERFACE(STRING, String) - CM_READ_COMPATIBLE_INTERFACE(NUMBER_MIN, NumberMin) - CM_READ_COMPATIBLE_INTERFACE(NUMBER_MAX, NumberMax) -#undef CM_READ_COMPATIBLE_INTERFACE - } - } - return compat; -} - -//---------------------------------------------------------------------------- void cmTargetInternals::ComputeLinkInterfaceLibraries( cmTarget const* thisTarget, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index d5374a6..df8cdc1 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -305,16 +305,6 @@ public: std::vector const& GetLinkImplementationClosure(const std::string& config) const; - struct CompatibleInterfaces - { - std::set PropsBool; - std::set PropsString; - std::set PropsNumberMax; - std::set PropsNumberMin; - }; - CompatibleInterfaces const& - GetCompatibleInterfaces(std::string const& config) const; - /** The link implementation specifies the direct library dependencies needed by the object files of the target. */ struct LinkImplementationLibraries @@ -575,15 +565,6 @@ public: const std::string& config) const; bool IsNullImpliedByLinkLibraries(const std::string &p) const; - bool IsLinkInterfaceDependentBoolProperty(const std::string &p, - const std::string& config) const; - bool IsLinkInterfaceDependentStringProperty(const std::string &p, - const std::string& config) const; - bool IsLinkInterfaceDependentNumberMinProperty(const std::string &p, - const std::string& config) const; - bool IsLinkInterfaceDependentNumberMaxProperty(const std::string &p, - const std::string& config) const; - bool GetLinkInterfaceDependentBoolProperty(const std::string &p, const std::string& config) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=669fce43e925f66f792651d050a50d7978716bd3 commit 669fce43e925f66f792651d050a50d7978716bd3 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:41 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 17:50:36 2015 +0200 cmGeneratorTarget: Move GetAutoUicOptions from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index e17df9e..95f6aaa 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -743,6 +743,32 @@ cmGeneratorTarget::UseObjectLibraries(std::vector& objs, } //---------------------------------------------------------------------------- +void cmGeneratorTarget::GetAutoUicOptions(std::vector &result, + const std::string& config) const +{ + const char *prop + = this->Target-> + GetLinkInterfaceDependentStringProperty("AUTOUIC_OPTIONS", + config); + if (!prop) + { + return; + } + cmGeneratorExpression ge; + + cmGeneratorExpressionDAGChecker dagChecker( + this->GetName(), + "AUTOUIC_OPTIONS", 0, 0); + cmSystemTools::ExpandListArgument(ge.Parse(prop) + ->Evaluate(this->Makefile, + config, + false, + this->Target, + &dagChecker), + result); +} + +//---------------------------------------------------------------------------- class cmTargetTraceDependencies { public: diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 8e5c2ab..3e43711 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -156,6 +156,9 @@ public: SourceFileType Type; const char* MacFolder; // location inside Mac content folders }; + void GetAutoUicOptions(std::vector &result, + const std::string& config) const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; @@ -176,7 +179,6 @@ private: struct SourceEntry { std::vector Depends; }; typedef std::map SourceEntriesType; SourceEntriesType SourceEntries; - mutable std::map Objects; std::set ExplicitObjectName; mutable std::map > SystemIncludesCache; diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 1322dea..a72b176 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -878,8 +878,11 @@ void cmQtAutoGenerators::MergeUicOptions(std::vector &opts, static void GetUicOpts(cmTarget const* target, const std::string& config, std::string &optString) { + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); std::vector opts; - target->GetAutoUicOptions(opts, config); + gtgt->GetAutoUicOptions(opts, config); optString = cmJoin(opts, ";"); } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 54f9cf0..3074f9b 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2236,31 +2236,6 @@ static void processCompileOptions(cmTarget const* tgt, } //---------------------------------------------------------------------------- -void cmTarget::GetAutoUicOptions(std::vector &result, - const std::string& config) const -{ - const char *prop - = this->GetLinkInterfaceDependentStringProperty("AUTOUIC_OPTIONS", - config); - if (!prop) - { - return; - } - cmGeneratorExpression ge; - - cmGeneratorExpressionDAGChecker dagChecker( - this->GetName(), - "AUTOUIC_OPTIONS", 0, 0); - cmSystemTools::ExpandListArgument(ge.Parse(prop) - ->Evaluate(this->Makefile, - config, - false, - this, - &dagChecker), - result); -} - -//---------------------------------------------------------------------------- void cmTarget::GetCompileOptions(std::vector &result, const std::string& config, const std::string& language) const diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 389f9cd..d5374a6 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -571,8 +571,6 @@ public: void GetCompileOptions(std::vector &result, const std::string& config, const std::string& language) const; - void GetAutoUicOptions(std::vector &result, - const std::string& config) const; void GetCompileFeatures(std::vector &features, const std::string& config) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=68ce826eca2d3cd22de7bab57bf5d9c129486523 commit 68ce826eca2d3cd22de7bab57bf5d9c129486523 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:41 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 17:50:36 2015 +0200 cmGeneratorTarget: Move GetSOName from cmTarget.. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index e63b44f..47406cb 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -756,6 +756,8 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, return; } + cmGeneratorTarget *gtgt = 0; + // Get a full path to the dependent shared library. // Add it to the runtime path computation so that the target being // linked will be able to find it. @@ -763,8 +765,8 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, if(tgt) { cmGeneratorTarget *gtgt = tgt->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(tgt); + ->GetGlobalGenerator()->GetGeneratorTarget(tgt); + lib = gtgt->GetFullPath(this->Config, this->UseImportLibrary); this->AddLibraryRuntimeInfo(lib, tgt); } @@ -790,9 +792,9 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, } if(order) { - if(tgt) + if(gtgt) { - std::string soName = tgt->GetSOName(this->Config); + std::string soName = gtgt->GetSOName(this->Config); const char* soname = soName.empty()? 0 : soName.c_str(); order->AddRuntimeLibrary(lib, soname); } @@ -1804,7 +1806,10 @@ cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath, // Try to get the soname of the library. Only files with this name // could possibly conflict. - std::string soName = target->GetSOName(this->Config); + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); + std::string soName = gtgt->GetSOName(this->Config); const char* soname = soName.empty()? 0 : soName.c_str(); // Include this library in the runtime path ordering. diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index a33cd59..3aa2b65 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -895,7 +895,7 @@ cmExportFileGenerator value = this->InstallNameDir(target->Target, config); } prop = "IMPORTED_SONAME"; - value += target->Target->GetSOName(config); + value += target->GetSOName(config); } else { diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index f3527ff..c0485db 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1584,7 +1584,7 @@ struct TargetFilesystemArtifactResultCreator } std::string result = target->Target->GetDirectory(context->Config); result += "/"; - result += target->Target->GetSOName(context->Config); + result += target->GetSOName(context->Config); return result; } }; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index bd57b3d..e17df9e 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -650,6 +650,49 @@ void cmGeneratorTarget::GetSourceFiles(std::vector &files, } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetSOName(const std::string& config) const +{ + if(this->Target->IsImported()) + { + // Lookup the imported soname. + if(cmTarget::ImportInfo const* info = this->Target->GetImportInfo(config)) + { + if(info->NoSOName) + { + // The imported library has no builtin soname so the name + // searched at runtime will be just the filename. + return cmSystemTools::GetFilenameName(info->Location); + } + else + { + // Use the soname given if any. + if(info->SOName.find("@rpath/") == 0) + { + return info->SOName.substr(6); + } + return info->SOName; + } + } + else + { + return ""; + } + } + else + { + // Compute the soname that will be built. + std::string name; + std::string soName; + std::string realName; + std::string impName; + std::string pdbName; + this->Target->GetLibraryNames(name, soName, realName, + impName, pdbName, config); + return soName; + } +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetModuleDefinitionFile(const std::string& config) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index a584c71..8e5c2ab 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -90,6 +90,9 @@ public: bool realname) const; std::string NormalGetRealName(const std::string& config) const; + /** Get the soname of the target. Allowed only for a shared library. */ + std::string GetSOName(const std::string& config) const; + cmTarget* Target; cmMakefile* Makefile; cmLocalGenerator* LocalGenerator; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 7dea107..8cb59f8 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2345,7 +2345,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, install_name += install_name_dir; install_name += "/"; } - install_name += target.GetSOName(configName); + install_name += gtgt->GetSOName(configName); if((realName != soName) || install_name_dir.empty()) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index cf33791..54f9cf0 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -69,21 +69,6 @@ struct cmTarget::OutputInfo }; //---------------------------------------------------------------------------- -struct cmTarget::ImportInfo -{ - ImportInfo(): NoSOName(false), Multiplicity(0) {} - bool NoSOName; - int Multiplicity; - std::string Location; - std::string SOName; - std::string ImportLibrary; - std::string Languages; - std::string Libraries; - std::string LibrariesProp; - std::string SharedDeps; -}; - -//---------------------------------------------------------------------------- struct cmTarget::CompileInfo { std::string CompilePdbDir; @@ -3602,48 +3587,6 @@ bool cmTarget::HasSOName(const std::string& config) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetSOName(const std::string& config) const -{ - if(this->IsImported()) - { - // Lookup the imported soname. - if(cmTarget::ImportInfo const* info = this->GetImportInfo(config)) - { - if(info->NoSOName) - { - // The imported library has no builtin soname so the name - // searched at runtime will be just the filename. - return cmSystemTools::GetFilenameName(info->Location); - } - else - { - // Use the soname given if any. - if(info->SOName.find("@rpath/") == 0) - { - return info->SOName.substr(6); - } - return info->SOName; - } - } - else - { - return ""; - } - } - else - { - // Compute the soname that will be built. - std::string name; - std::string soName; - std::string realName; - std::string impName; - std::string pdbName; - this->GetLibraryNames(name, soName, realName, impName, pdbName, config); - return soName; - } -} - -//---------------------------------------------------------------------------- bool cmTarget::HasMacOSXRpathInstallNameDir(const std::string& config) const { bool install_name_is_rpath = false; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index f567d50..389f9cd 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -411,9 +411,6 @@ public: /** Whether this library has soname enabled and platform supports it. */ bool HasSOName(const std::string& config) const; - /** Get the soname of the target. Allowed only for a shared library. */ - std::string GetSOName(const std::string& config) const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; @@ -768,7 +765,20 @@ private: std::string& out) const; // Cache import information from properties for each configuration. - struct ImportInfo; + struct ImportInfo + { + ImportInfo(): NoSOName(false), Multiplicity(0) {} + bool NoSOName; + int Multiplicity; + std::string Location; + std::string SOName; + std::string ImportLibrary; + std::string Languages; + std::string Libraries; + std::string LibrariesProp; + std::string SharedDeps; + }; + ImportInfo const* GetImportInfo(const std::string& config) const; void ComputeImportInfo(std::string const& desired_config, ImportInfo& info) const; ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From steveire at gmail.com Wed Aug 5 12:20:31 2015 From: steveire at gmail.com (Stephen Kelly) Date: Wed, 5 Aug 2015 12:20:31 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1945-gcb91af0 Message-ID: <20150805162031.F0DA0B0F87@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via cb91af0e2e44760abbe34853a3b89a5f300e15ad (commit) via 130c3373df6e87821111adbdeb7efefd17556686 (commit) from 1d8f34ecc7322e30cdcad137460581f5f32ffa4f (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cb91af0e2e44760abbe34853a3b89a5f300e15ad commit cb91af0e2e44760abbe34853a3b89a5f300e15ad Merge: 1d8f34e 130c337 Author: Stephen Kelly AuthorDate: Wed Aug 5 12:20:31 2015 -0400 Commit: CMake Topic Stage CommitDate: Wed Aug 5 12:20:31 2015 -0400 Merge topic 'use-generator-target' into next 130c3373 fixup! cmGeneratorTarget: Move GetSOName from cmTarget.. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=130c3373df6e87821111adbdeb7efefd17556686 commit 130c3373df6e87821111adbdeb7efefd17556686 Author: Stephen Kelly AuthorDate: Wed Aug 5 18:20:14 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 18:20:14 2015 +0200 fixup! cmGeneratorTarget: Move GetSOName from cmTarget.. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index c432cfb..c3f36af 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -770,8 +770,7 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, std::string lib; if(tgt) { - cmGeneratorTarget *gtgt = tgt->GetMakefile() - ->GetGlobalGenerator()->GetGeneratorTarget(tgt); + gtgt = tgt->GetMakefile()->GetGlobalGenerator()->GetGeneratorTarget(tgt); lib = gtgt->GetFullPath(this->Config, this->UseImportLibrary); this->AddLibraryRuntimeInfo(lib, tgt); ----------------------------------------------------------------------- Summary of changes: Source/cmComputeLinkInformation.cxx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) hooks/post-receive -- CMake From steveire at gmail.com Wed Aug 5 12:21:17 2015 From: steveire at gmail.com (Stephen Kelly) Date: Wed, 5 Aug 2015 12:21:17 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1980-g2ec5b34 Message-ID: <20150805162117.A1A5BB0FF1@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 2ec5b3466da91b08b3f087f62625a4b6bf88208c (commit) via a309409ead0bde721a17e8b3c4e89fe6a2181423 (commit) via f83e84028ac28ce098ea76bd857ae1663c295494 (commit) via b3f0e35308993de825f00ec18fc6559e6609c9b0 (commit) via 34c437411dad89c671261269f2067129584a4259 (commit) via 4329a71c128f8a8fca48a8827226d09f61fcbe85 (commit) via c93230ac3838231f2f44986e224da1bdaf9a7dfe (commit) via ee26add4f4062d8b53f22e161027a573dc03399c (commit) via c8a5f5ae60c911298fc3c0f168ac3652223722a4 (commit) via f8076644ce21c5c20cb0d368d25c191a05364481 (commit) via 7c809fa2a675b7e669e76683f73397e38dd22999 (commit) via 6da99de3236fbaeebf6a4fc66f7d68f43a59902f (commit) via d6bb319b09d056428468d8894f7d7dd2cb0d963e (commit) via 7a460852fa1bc9df22d4c54bac3d57f909488608 (commit) via d560bfd2739f2594119c49d82485b99bb4fbbe1f (commit) via 89e2a080e977b9632fa13c627b6a5370250d6ed5 (commit) via 62720e44be3e9f28e4c1e7d38206b2c51d34745e (commit) via e27d737e27fbfc8cfde020ec02d6b2c74afb6885 (commit) via 8d2de00244f8338664c16bd8d8ebb03c6f0cb83f (commit) via 3df705681be123d93146156fec3166b41b19465a (commit) via a45fed81e5fd5d9b280c8dd70d50c9606a982a0b (commit) via f0aa660772565545cbcda9ed8ae946b8d5097416 (commit) via 766839c56da82e12b6986fb5cf7c8d86442615bc (commit) via 47803e6f8e98984e740acf2f7c0a217de58717cd (commit) via 7da4c9d4edbdd6df6aa2a9467d6f32a98fc8cac4 (commit) via 97f10e488a5153e45d6a27a730cc1ecbaae7d559 (commit) via 4b86f5edc91ba649908f5b6ab0fb7f1154e38066 (commit) via 5ff813c7a62d6c37b86bbf9a988a91baa4d5b9e6 (commit) via 38d4ba3564b9a37f8042888ffd63bf736852b6b8 (commit) via 90bad039c44195b742740613a34b90697254fdd2 (commit) via 803a7982b4403c690d7b7fa8c49d00a5abae3471 (commit) via c971338416d7376d8b710b5c18957f6a800b3de0 (commit) via 244c5b5dcdc5af1f91a79a81f7f7ec4047759fe8 (commit) via 12bc571c13eda8d504eac788d6b3e5e8d83e3ad3 (commit) via 41abdc17df99662a8e99ba895050dbc8c0e34b8e (commit) from cb91af0e2e44760abbe34853a3b89a5f300e15ad (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2ec5b3466da91b08b3f087f62625a4b6bf88208c commit 2ec5b3466da91b08b3f087f62625a4b6bf88208c Merge: cb91af0 a309409 Author: Stephen Kelly AuthorDate: Wed Aug 5 12:21:11 2015 -0400 Commit: CMake Topic Stage CommitDate: Wed Aug 5 12:21:11 2015 -0400 Merge topic 'use-generator-target' into next a309409e cmOrderDirectories: Port to cmGeneratorTarget. f83e8402 cmGeneratorTarget: Move CompileInfoMap from cmTarget. b3f0e353 cmGeneratorTarget: Move GetCompilePDBDirectory from cmTarget. 34c43741 cmGeneratorTarget: Move GetOutputName from cmTarget. 4329a71c cmComputeLinkDepends: Port to cmGeneratorTarget. c93230ac cmComputeLinkInformation: Port to cmGeneratorTarget. ee26add4 cmGeneratorTarget: Move IsBundleOnApple from cmTarget. c8a5f5ae cmMakefileTargetGenerator: Add accessor for GeneratorTarget. f8076644 cmGeneratorTarget: Move GetLinkClosure from cmTarget. 7c809fa2 cmGeneratorTarget: Move GetLinkerLanguage from cmTarget. 6da99de3 cmGeneratorTarget: Move GetFrameworkDirectory from cmTarget. d6bb319b cmGeneratorTarget: Move GetFullName from cmTarget. 7a460852 cmGeneratorTarget: Move GetAppBundleDirectory from cmTarget. d560bfd2 cmGeneratorTarget: Move GetInstallNameDir* from cmTarget. 89e2a080 cmGeneratorTarget: Move GetMacContentDirectory from cmTarget. 62720e44 cmGeneratorTarget: Move GetFullNameComponents from cmTarget. ... http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a309409ead0bde721a17e8b3c4e89fe6a2181423 commit a309409ead0bde721a17e8b3c4e89fe6a2181423 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:51 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 18:20:50 2015 +0200 cmOrderDirectories: Port to cmGeneratorTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 7a516e2..c3f36af 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -260,10 +260,10 @@ cmComputeLinkInformation // Allocate internals. this->OrderLinkerSearchPath = - new cmOrderDirectories(this->GlobalGenerator, target->Target, + new cmOrderDirectories(this->GlobalGenerator, target, "linker search path"); this->OrderRuntimeSearchPath = - new cmOrderDirectories(this->GlobalGenerator, target->Target, + new cmOrderDirectories(this->GlobalGenerator, target, "runtime search path"); this->OrderDependentRPath = 0; @@ -370,7 +370,7 @@ cmComputeLinkInformation { this->SharedDependencyMode = SharedDepModeDir; this->OrderDependentRPath = - new cmOrderDirectories(this->GlobalGenerator, target->Target, + new cmOrderDirectories(this->GlobalGenerator, target, "dependent library path"); } diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx index a612437..35ee127 100644 --- a/Source/cmOrderDirectories.cxx +++ b/Source/cmOrderDirectories.cxx @@ -280,7 +280,7 @@ bool cmOrderDirectoriesConstraintLibrary::FindConflict(std::string const& dir) //---------------------------------------------------------------------------- cmOrderDirectories::cmOrderDirectories(cmGlobalGenerator* gg, - cmTarget const* target, + const cmGeneratorTarget* target, const char* purpose) { this->GlobalGenerator = gg; @@ -554,7 +554,8 @@ void cmOrderDirectories::FindImplicitConflicts() << text << "Some of these libraries may not be found correctly."; this->GlobalGenerator->GetCMakeInstance() - ->IssueMessage(cmake::WARNING, w.str(), this->Target->GetBacktrace()); + ->IssueMessage(cmake::WARNING, w.str(), + this->Target->Target->GetBacktrace()); } //---------------------------------------------------------------------------- @@ -635,5 +636,6 @@ void cmOrderDirectories::DiagnoseCycle() } e << "Some of these libraries may not be found correctly."; this->GlobalGenerator->GetCMakeInstance() - ->IssueMessage(cmake::WARNING, e.str(), this->Target->GetBacktrace()); + ->IssueMessage(cmake::WARNING, e.str(), + this->Target->Target->GetBacktrace()); } diff --git a/Source/cmOrderDirectories.h b/Source/cmOrderDirectories.h index cb5a51f..211c786 100644 --- a/Source/cmOrderDirectories.h +++ b/Source/cmOrderDirectories.h @@ -19,7 +19,7 @@ class cmGlobalGenerator; class cmOrderDirectoriesConstraint; class cmOrderDirectoriesConstraintLibrary; -class cmTarget; +class cmGeneratorTarget; /** \class cmOrderDirectories * \brief Compute a safe runtime path order for a set of shared libraries. @@ -27,7 +27,7 @@ class cmTarget; class cmOrderDirectories { public: - cmOrderDirectories(cmGlobalGenerator* gg, cmTarget const* target, + cmOrderDirectories(cmGlobalGenerator* gg, cmGeneratorTarget const* target, const char* purpose); ~cmOrderDirectories(); void AddRuntimeLibrary(std::string const& fullPath, const char* soname = 0); @@ -41,7 +41,7 @@ public: std::vector const& GetOrderedDirectories(); private: cmGlobalGenerator* GlobalGenerator; - cmTarget const* Target; + cmGeneratorTarget const* Target; std::string Purpose; std::vector OrderedDirectories; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f83e84028ac28ce098ea76bd857ae1663c295494 commit f83e84028ac28ce098ea76bd857ae1663c295494 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:51 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 18:20:50 2015 +0200 cmGeneratorTarget: Move CompileInfoMap from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c6f248c..c831704 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1356,6 +1356,46 @@ cmGeneratorTarget::GetMacContentDirectory(const std::string& config, return fpath; } + +//---------------------------------------------------------------------------- +cmGeneratorTarget::CompileInfo const* cmGeneratorTarget::GetCompileInfo( + const std::string& config) const +{ + // There is no compile information for imported targets. + if(this->IsImported()) + { + return 0; + } + + if(this->GetType() > cmTarget::OBJECT_LIBRARY) + { + std::string msg = "cmTarget::GetCompileInfo called for "; + msg += this->GetName(); + msg += " which has type "; + msg += cmTarget::GetTargetTypeName(this->Target->GetType()); + this->Makefile->IssueMessage(cmake::INTERNAL_ERROR, msg); + return 0; + } + + // Lookup/compute/cache the compile information for this configuration. + std::string config_upper; + if(!config.empty()) + { + config_upper = cmSystemTools::UpperCase(config); + } + CompileInfoMapType::const_iterator i = + this->CompileInfoMap.find(config_upper); + if(i == this->CompileInfoMap.end()) + { + CompileInfo info; + this->Target + ->ComputePDBOutputDir("COMPILE_PDB", config, info.CompilePdbDir); + CompileInfoMapType::value_type entry(config_upper, info); + i = this->CompileInfoMap.insert(entry).first; + } + return &i->second; +} + //---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetModuleDefinitionFile(const std::string& config) const @@ -1827,7 +1867,7 @@ void cmGeneratorTarget::TraceDependencies() std::string cmGeneratorTarget::GetCompilePDBDirectory(const std::string& config) const { - if(cmTarget::CompileInfo const* info = this->Target->GetCompileInfo(config)) + if(CompileInfo const* info = this->GetCompileInfo(config)) { return info->CompilePdbDir; } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 3dbbca1..68e7a8a 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -230,6 +230,16 @@ public: /** Whether this library has soname enabled and platform supports it. */ bool HasSOName(const std::string& config) const; + struct CompileInfo + { + std::string CompilePdbDir; + }; + + CompileInfo const* GetCompileInfo(const std::string& config) const; + + typedef std::map CompileInfoMapType; + mutable CompileInfoMapType CompileInfoMap; + /** Get the name of the compiler pdb file for the target. */ std::string GetCompilePDBName(const std::string& config="") const; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 9308113..1f8f07a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -126,9 +126,6 @@ public: typedef std::map ImportInfoMapType; ImportInfoMapType ImportInfoMap; - typedef std::map CompileInfoMapType; - CompileInfoMapType CompileInfoMap; - // Cache link implementation computation from each configuration. struct OptionalLinkImplementation: public cmTarget::LinkImplementation { @@ -2598,45 +2595,6 @@ cmTarget::OutputInfo const* cmTarget::GetOutputInfo( } //---------------------------------------------------------------------------- -cmTarget::CompileInfo const* cmTarget::GetCompileInfo( - const std::string& config) const -{ - // There is no compile information for imported targets. - if(this->IsImported()) - { - return 0; - } - - if(this->GetType() > cmTarget::OBJECT_LIBRARY) - { - std::string msg = "cmTarget::GetCompileInfo called for "; - msg += this->GetName(); - msg += " which has type "; - msg += cmTarget::GetTargetTypeName(this->GetType()); - this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg); - return 0; - } - - // Lookup/compute/cache the compile information for this configuration. - std::string config_upper; - if(!config.empty()) - { - config_upper = cmSystemTools::UpperCase(config); - } - typedef cmTargetInternals::CompileInfoMapType CompileInfoMapType; - CompileInfoMapType::const_iterator i = - this->Internal->CompileInfoMap.find(config_upper); - if(i == this->Internal->CompileInfoMap.end()) - { - CompileInfo info; - this->ComputePDBOutputDir("COMPILE_PDB", config, info.CompilePdbDir); - CompileInfoMapType::value_type entry(config_upper, info); - i = this->Internal->CompileInfoMap.insert(entry).first; - } - return &i->second; -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetDirectory(const std::string& config, bool implib) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 8689838..e3fbdfd 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -626,13 +626,6 @@ private: void ComputeImportInfo(std::string const& desired_config, ImportInfo& info) const; - // Cache target compile paths for each configuration. - struct CompileInfo - { - std::string CompilePdbDir; - }; - - CompileInfo const* GetCompileInfo(const std::string& config) const; LinkInterface const* GetImportLinkInterface(const std::string& config, cmTarget const* head, http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b3f0e35308993de825f00ec18fc6559e6609c9b0 commit b3f0e35308993de825f00ec18fc6559e6609c9b0 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:51 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 18:20:50 2015 +0200 cmGeneratorTarget: Move GetCompilePDBDirectory from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index aac941e..c6f248c 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -743,7 +743,7 @@ cmGeneratorTarget::GetCompilePDBName(const std::string& config) const std::string cmGeneratorTarget::GetCompilePDBPath(const std::string& config) const { - std::string dir = this->Target->GetCompilePDBDirectory(config); + std::string dir = this->GetCompilePDBDirectory(config); std::string name = this->GetCompilePDBName(config); if(dir.empty() && !name.empty()) { @@ -1824,6 +1824,16 @@ void cmGeneratorTarget::TraceDependencies() tracer.Trace(); } +std::string +cmGeneratorTarget::GetCompilePDBDirectory(const std::string& config) const +{ + if(cmTarget::CompileInfo const* info = this->Target->GetCompileInfo(config)) + { + return info->CompilePdbDir; + } + return ""; +} + //---------------------------------------------------------------------------- void cmGeneratorTarget::GetAppleArchs(const std::string& config, std::vector& archVec) const diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 52ab6c0..3dbbca1 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -214,6 +214,12 @@ public: */ void TraceDependencies(); + /** Get the directory in which to place the target compiler .pdb file. + If the configuration name is given then the generator will add its + subdirectory for that configuration. Otherwise just the canonical + compiler pdb output directory is given. */ + std::string GetCompilePDBDirectory(const std::string& config = "") const; + /** Get sources that must be built before the given source. */ std::vector const* GetSourceDepends(cmSourceFile const* sf) const; diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index afe145a..ccb0974 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -130,7 +130,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) } std::string compilePdbOutputPath = - this->Target->GetCompilePDBDirectory(this->ConfigName); + this->GeneratorTarget->GetCompilePDBDirectory(this->ConfigName); cmSystemTools::MakeDirectory(compilePdbOutputPath.c_str()); std::string pdbOutputPath = this->Target->GetPDBDirectory(this->ConfigName); diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index bb0f9dd..2f995e8 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -311,7 +311,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules } std::string compilePdbOutputPath = - this->Target->GetCompilePDBDirectory(this->ConfigName); + this->GeneratorTarget->GetCompilePDBDirectory(this->ConfigName); cmSystemTools::MakeDirectory(compilePdbOutputPath.c_str()); std::string pdbOutputPath = this->Target->GetPDBDirectory(this->ConfigName); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 8b64bc4..9308113 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -69,12 +69,6 @@ struct cmTarget::OutputInfo }; //---------------------------------------------------------------------------- -struct cmTarget::CompileInfo -{ - std::string CompilePdbDir; -}; - -//---------------------------------------------------------------------------- class cmTargetInternals { public: @@ -2673,16 +2667,6 @@ std::string cmTarget::GetPDBDirectory(const std::string& config) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetCompilePDBDirectory(const std::string& config) const -{ - if(CompileInfo const* info = this->GetCompileInfo(config)) - { - return info->CompilePdbDir; - } - return ""; -} - -//---------------------------------------------------------------------------- const char* cmTarget::ImportedGetLocation(const std::string& config) const { static std::string location; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index a6f2465..8689838 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -334,12 +334,6 @@ public: pdb output directory is given. */ std::string GetPDBDirectory(const std::string& config) const; - /** Get the directory in which to place the target compiler .pdb file. - If the configuration name is given then the generator will add its - subdirectory for that configuration. Otherwise just the canonical - compiler pdb output directory is given. */ - std::string GetCompilePDBDirectory(const std::string& config = "") const; - const char* ImportedGetLocation(const std::string& config) const; /** Get the target major and minor version numbers interpreted from @@ -633,7 +627,11 @@ private: ImportInfo& info) const; // Cache target compile paths for each configuration. - struct CompileInfo; + struct CompileInfo + { + std::string CompilePdbDir; + }; + CompileInfo const* GetCompileInfo(const std::string& config) const; LinkInterface const* http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=34c437411dad89c671261269f2067129584a4259 commit 34c437411dad89c671261269f2067129584a4259 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:50 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 18:20:50 2015 +0200 cmGeneratorTarget: Move GetOutputName from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 55e2922..aac941e 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -267,6 +267,54 @@ const char *cmGeneratorTarget::GetProperty(const std::string& prop) const } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetOutputName(const std::string& config, + bool implib) const +{ + std::vector props; + std::string type = this->Target->GetOutputTargetType(implib); + std::string configUpper = cmSystemTools::UpperCase(config); + if(!type.empty() && !configUpper.empty()) + { + // _OUTPUT_NAME_ + props.push_back(type + "_OUTPUT_NAME_" + configUpper); + } + if(!type.empty()) + { + // _OUTPUT_NAME + props.push_back(type + "_OUTPUT_NAME"); + } + if(!configUpper.empty()) + { + // OUTPUT_NAME_ + props.push_back("OUTPUT_NAME_" + configUpper); + // _OUTPUT_NAME + props.push_back(configUpper + "_OUTPUT_NAME"); + } + // OUTPUT_NAME + props.push_back("OUTPUT_NAME"); + + std::string outName; + for(std::vector::const_iterator i = props.begin(); + i != props.end(); ++i) + { + if (const char* outNameProp = this->Target->GetProperty(*i)) + { + outName = outNameProp; + break; + } + } + + if (outName.empty()) + { + outName = this->GetName(); + } + + cmGeneratorExpression ge; + cmsys::auto_ptr cge = ge.Parse(outName); + return cge->Evaluate(this->Makefile, config); +} + +//---------------------------------------------------------------------------- std::vector const* cmGeneratorTarget::GetSourceDepends(cmSourceFile const* sf) const { @@ -922,7 +970,7 @@ std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config, bool contentOnly) const { std::string fpath; - fpath += this->Target->GetOutputName(config, false); + fpath += this->GetOutputName(config, false); fpath += "."; const char *ext = this->Target->GetProperty("BUNDLE_EXTENSION"); if (!ext) @@ -949,7 +997,7 @@ cmGeneratorTarget::GetFrameworkDirectory(const std::string& config, bool rootDir) const { std::string fpath; - fpath += this->Target->GetOutputName(config, false); + fpath += this->GetOutputName(config, false); fpath += ".framework"; if(!rootDir) { @@ -2247,7 +2295,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, std::string fw_prefix; if(this->Target->IsFrameworkOnApple()) { - fw_prefix = this->Target->GetOutputName(config, false); + fw_prefix = this->GetOutputName(config, false); fw_prefix += ".framework/"; targetPrefix = fw_prefix.c_str(); targetSuffix = 0; @@ -2265,7 +2313,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, outPrefix = targetPrefix?targetPrefix:""; // Append the target name or property-specified name. - outBase += this->Target->GetOutputName(config, implib); + outBase += this->GetOutputName(config, implib); // Append the per-configuration postfix. outBase += configPostfix?configPostfix:""; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 21e0900..52ab6c0 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -230,6 +230,9 @@ public: /** Get the path for the MSVC /Fd option for this target. */ std::string GetCompilePDBPath(const std::string& config="") const; + // Get the target base name. + std::string GetOutputName(const std::string& config, bool implib) const; + /** * Flags for a given source file as used in this target. Typically assigned * via SET_TARGET_PROPERTIES when the property is a list of source files. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e887ef3..8b64bc4 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3663,54 +3663,6 @@ bool cmTarget::UsesDefaultOutputDir(const std::string& config, } //---------------------------------------------------------------------------- -std::string cmTarget::GetOutputName(const std::string& config, - bool implib) const -{ - std::vector props; - std::string type = this->GetOutputTargetType(implib); - std::string configUpper = cmSystemTools::UpperCase(config); - if(!type.empty() && !configUpper.empty()) - { - // _OUTPUT_NAME_ - props.push_back(type + "_OUTPUT_NAME_" + configUpper); - } - if(!type.empty()) - { - // _OUTPUT_NAME - props.push_back(type + "_OUTPUT_NAME"); - } - if(!configUpper.empty()) - { - // OUTPUT_NAME_ - props.push_back("OUTPUT_NAME_" + configUpper); - // _OUTPUT_NAME - props.push_back(configUpper + "_OUTPUT_NAME"); - } - // OUTPUT_NAME - props.push_back("OUTPUT_NAME"); - - std::string outName; - for(std::vector::const_iterator i = props.begin(); - i != props.end(); ++i) - { - if (const char* outNameProp = this->GetProperty(*i)) - { - outName = outNameProp; - break; - } - } - - if (outName.empty()) - { - outName = this->GetName(); - } - - cmGeneratorExpression ge; - cmsys::auto_ptr cge = ge.Parse(outName); - return cge->Evaluate(this->Makefile, config); -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetFrameworkVersion() const { assert(this->GetType() != INTERFACE_LIBRARY); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e53afff..a6f2465 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -552,9 +552,6 @@ private: // Returns ARCHIVE, LIBRARY, or RUNTIME based on platform and type. const char* GetOutputTargetType(bool implib) const; - // Get the target base name. - std::string GetOutputName(const std::string& config, bool implib) const; - std::string GetFullNameImported(const std::string& config, bool implib) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4329a71c128f8a8fca48a8827226d09f61fcbe85 commit 4329a71c128f8a8fca48a8827226d09f61fcbe85 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:50 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 18:20:49 2015 +0200 cmComputeLinkDepends: Port to cmGeneratorTarget. diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index abd9877..8ba8847 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -173,18 +173,19 @@ items that we know the linker will re-use automatically (shared libs). //---------------------------------------------------------------------------- cmComputeLinkDepends -::cmComputeLinkDepends(cmTarget const* target, const std::string& config) +::cmComputeLinkDepends(const cmGeneratorTarget* target, + const std::string& config) { // Store context information. this->Target = target; - this->Makefile = this->Target->GetMakefile(); + this->Makefile = this->Target->Target->GetMakefile(); this->GlobalGenerator = this->Makefile->GetGlobalGenerator(); this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance(); // The configuration being linked. this->HasConfig = !config.empty(); this->Config = (this->HasConfig)? config : std::string(); - this->LinkType = this->Target->ComputeLinkType(this->Config); + this->LinkType = this->Target->Target->ComputeLinkType(this->Config); // Enable debug mode if requested. this->DebugMode = this->Makefile->IsOn("CMAKE_LINK_DEPENDS_DEBUG_MODE"); @@ -363,7 +364,7 @@ void cmComputeLinkDepends::FollowLinkEntry(BFSEntry const& qe) { // Follow the target dependencies. if(cmTarget::LinkInterface const* iface = - entry.Target->GetLinkInterface(this->Config, this->Target)) + entry.Target->GetLinkInterface(this->Config, this->Target->Target)) { const bool isIface = entry.Target->GetType() == cmTarget::INTERFACE_LIBRARY; @@ -461,7 +462,7 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep) if(entry.Target) { if(cmTarget::LinkInterface const* iface = - entry.Target->GetLinkInterface(this->Config, this->Target)) + entry.Target->GetLinkInterface(this->Config, this->Target->Target)) { // Follow public and private dependencies transitively. this->FollowSharedDeps(index, iface, true); @@ -552,7 +553,7 @@ void cmComputeLinkDepends::AddDirectLinkEntries() { // Add direct link dependencies in this configuration. cmTarget::LinkImplementation const* impl = - this->Target->GetLinkImplementation(this->Config); + this->Target->Target->GetLinkImplementation(this->Config); this->AddLinkEntries(-1, impl->Libraries); for(std::vector::const_iterator wi = impl->WrongConfigLibraries.begin(); @@ -634,7 +635,7 @@ cmTarget const* cmComputeLinkDepends::FindTargetToLink(int depender_index, const std::string& name) { // Look for a target in the scope of the depender. - cmTarget const* from = this->Target; + cmTarget const* from = this->Target->Target; if(depender_index >= 0) { if(cmTarget const* depender = this->EntryList[depender_index].Target) @@ -932,7 +933,7 @@ int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl) if(cmTarget const* target = this->EntryList[*ni].Target) { if(cmTarget::LinkInterface const* iface = - target->GetLinkInterface(this->Config, this->Target)) + target->GetLinkInterface(this->Config, this->Target->Target)) { if(iface->Multiplicity > count) { diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index 51a08c5..b925a4f 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -22,6 +22,7 @@ class cmComputeComponentGraph; class cmGlobalGenerator; class cmMakefile; +class cmGeneratorTarget; class cmTarget; class cmake; @@ -31,7 +32,8 @@ class cmake; class cmComputeLinkDepends { public: - cmComputeLinkDepends(cmTarget const* target, const std::string& config); + cmComputeLinkDepends(cmGeneratorTarget const* target, + const std::string& config); ~cmComputeLinkDepends(); // Basic information about each link item. @@ -57,7 +59,7 @@ public: private: // Context information. - cmTarget const* Target; + cmGeneratorTarget const* Target; cmMakefile* Makefile; cmGlobalGenerator const* GlobalGenerator; cmake* CMakeInstance; diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index f00a8cf..7a516e2 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -497,7 +497,7 @@ bool cmComputeLinkInformation::Compute() } // Compute the ordered link line items. - cmComputeLinkDepends cld(this->Target->Target, this->Config); + cmComputeLinkDepends cld(this->Target, this->Config); cld.SetOldLinkDirMode(this->OldLinkDirMode); cmComputeLinkDepends::EntryVector const& linkEntries = cld.Compute(); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c93230ac3838231f2f44986e224da1bdaf9a7dfe commit c93230ac3838231f2f44986e224da1bdaf9a7dfe Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:50 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 18:20:49 2015 +0200 cmComputeLinkInformation: Port to cmGeneratorTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 269aa69..f00a8cf 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -242,11 +242,12 @@ because this need be done only for shared libraries without soname-s. //---------------------------------------------------------------------------- cmComputeLinkInformation -::cmComputeLinkInformation(cmTarget const* target, const std::string& config) +::cmComputeLinkInformation(const cmGeneratorTarget* target, + const std::string& config) { // Store context information. this->Target = target; - this->Makefile = this->Target->GetMakefile(); + this->Makefile = this->Target->Target->GetMakefile(); this->GlobalGenerator = this->Makefile->GetGlobalGenerator(); this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance(); @@ -259,17 +260,15 @@ cmComputeLinkInformation // Allocate internals. this->OrderLinkerSearchPath = - new cmOrderDirectories(this->GlobalGenerator, target, + new cmOrderDirectories(this->GlobalGenerator, target->Target, "linker search path"); this->OrderRuntimeSearchPath = - new cmOrderDirectories(this->GlobalGenerator, target, + new cmOrderDirectories(this->GlobalGenerator, target->Target, "runtime search path"); this->OrderDependentRPath = 0; - cmGeneratorTarget *gtgt = this->GlobalGenerator - ->GetGeneratorTarget(this->Target); // Get the language used for linking this target. - this->LinkLanguage = gtgt->GetLinkerLanguage(config); + this->LinkLanguage = this->Target->GetLinkerLanguage(config); if(this->LinkLanguage.empty()) { // The Compute method will do nothing, so skip the rest of the @@ -283,14 +282,14 @@ cmComputeLinkInformation // Check whether we should skip dependencies on shared library files. this->LinkDependsNoShared = - this->Target->GetPropertyAsBool("LINK_DEPENDS_NO_SHARED"); + this->Target->Target->GetPropertyAsBool("LINK_DEPENDS_NO_SHARED"); // On platforms without import libraries there may be a special flag // to use when creating a plugin (module) that obtains symbols from // the program that will load it. this->LoaderFlag = 0; if(!this->UseImportLibrary && - this->Target->GetType() == cmTarget::MODULE_LIBRARY) + this->Target->Target->GetType() == cmTarget::MODULE_LIBRARY) { std::string loader_flag_var = "CMAKE_SHARED_MODULE_LOADER_"; loader_flag_var += this->LinkLanguage; @@ -308,10 +307,10 @@ cmComputeLinkInformation // Get options needed to specify RPATHs. this->RuntimeUseChrpath = false; - if(this->Target->GetType() != cmTarget::STATIC_LIBRARY) + if(this->Target->Target->GetType() != cmTarget::STATIC_LIBRARY) { const char* tType = - ((this->Target->GetType() == cmTarget::EXECUTABLE)? + ((this->Target->Target->GetType() == cmTarget::EXECUTABLE)? "EXECUTABLE" : "SHARED_LIBRARY"); std::string rtVar = "CMAKE_"; rtVar += tType; @@ -325,7 +324,7 @@ cmComputeLinkInformation (this->Makefile-> GetSafeDefinition("CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH")); - this->RuntimeUseChrpath = gtgt->IsChrpathUsed(config); + this->RuntimeUseChrpath = this->Target->IsChrpathUsed(config); // Get options needed to help find dependent libraries. std::string rlVar = "CMAKE_"; @@ -371,15 +370,15 @@ cmComputeLinkInformation { this->SharedDependencyMode = SharedDepModeDir; this->OrderDependentRPath = - new cmOrderDirectories(this->GlobalGenerator, target, + new cmOrderDirectories(this->GlobalGenerator, target->Target, "dependent library path"); } // Add the search path entries requested by the user to path ordering. this->OrderLinkerSearchPath - ->AddUserDirectories(this->Target->GetLinkDirectories()); + ->AddUserDirectories(this->Target->Target->GetLinkDirectories()); this->OrderRuntimeSearchPath - ->AddUserDirectories(this->Target->GetLinkDirectories()); + ->AddUserDirectories(this->Target->Target->GetLinkDirectories()); // Set up the implicit link directories. this->LoadImplicitLinkInfo(); @@ -407,12 +406,13 @@ cmComputeLinkInformation // order to support such projects we need to add the directories // containing libraries linked with a full path to the -L path. this->OldLinkDirMode = - this->Target->GetPolicyStatusCMP0003() != cmPolicies::NEW; + this->Target->Target->GetPolicyStatusCMP0003() != cmPolicies::NEW; if(this->OldLinkDirMode) { // Construct a mask to not bother with this behavior for link // directories already specified by the user. - std::vector const& dirs = this->Target->GetLinkDirectories(); + std::vector const& dirs = + this->Target->Target->GetLinkDirectories(); this->OldLinkDirMask.insert(dirs.begin(), dirs.end()); } @@ -497,7 +497,7 @@ bool cmComputeLinkInformation::Compute() } // Compute the ordered link line items. - cmComputeLinkDepends cld(this->Target, this->Config); + cmComputeLinkDepends cld(this->Target->Target, this->Config); cld.SetOldLinkDirMode(this->OldLinkDirMode); cmComputeLinkDepends::EntryVector const& linkEntries = cld.Compute(); @@ -518,7 +518,8 @@ bool cmComputeLinkInformation::Compute() // Restore the target link type so the correct system runtime // libraries are found. - const char* lss = this->Target->GetProperty("LINK_SEARCH_END_STATIC"); + const char* lss = + this->Target->Target->GetProperty("LINK_SEARCH_END_STATIC"); if(cmSystemTools::IsOn(lss)) { this->SetCurrentLinkType(LinkStatic); @@ -571,7 +572,7 @@ bool cmComputeLinkInformation::Compute() "name." ; this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); } return true; @@ -580,12 +581,9 @@ bool cmComputeLinkInformation::Compute() //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddImplicitLinkInfo() { - cmGeneratorTarget *gtgt = this->Target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(this->Target); - // The link closure lists all languages whose implicit info is needed. - cmGeneratorTarget::LinkClosure const* lc=gtgt->GetLinkClosure(this->Config); + cmGeneratorTarget::LinkClosure const* lc = + this->Target->GetLinkClosure(this->Config); for(std::vector::const_iterator li = lc->Languages.begin(); li != lc->Languages.end(); ++li) { @@ -863,7 +861,8 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo() } // Lookup the starting link type from the target (linked statically?). - const char* lss = this->Target->GetProperty("LINK_SEARCH_START_STATIC"); + const char* lss = + this->Target->Target->GetProperty("LINK_SEARCH_START_STATIC"); this->StartLinkType = cmSystemTools::IsOn(lss)? LinkStatic : LinkShared; this->CurrentLinkType = this->StartLinkType; } @@ -1149,7 +1148,7 @@ void cmComputeLinkInformation::AddFullItem(std::string const& item) // Full path libraries should specify a valid library file name. // See documentation of CMP0008. std::string generator = this->GlobalGenerator->GetName(); - if(this->Target->GetPolicyStatusCMP0008() != cmPolicies::NEW && + if(this->Target->Target->GetPolicyStatusCMP0008() != cmPolicies::NEW && (generator.find("Visual Studio") != generator.npos || generator.find("Xcode") != generator.npos)) { @@ -1230,7 +1229,7 @@ bool cmComputeLinkInformation::CheckImplicitDirItem(std::string const& item) } // Check the policy for whether we should use the approach below. - switch (this->Target->GetPolicyStatusCMP0060()) + switch (this->Target->Target->GetPolicyStatusCMP0060()) { case cmPolicies::WARN: if (this->CMP0060Warn) @@ -1540,7 +1539,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item, this->OrderLinkerSearchPath->AddLinkLibrary(item); // Produce any needed message. - switch(this->Target->GetPolicyStatusCMP0008()) + switch(this->Target->Target->GetPolicyStatusCMP0008()) { case cmPolicies::WARN: { @@ -1557,7 +1556,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item, << " " << item << "\n" << "which is a full-path but not a valid library file name."; this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); } } case cmPolicies::OLD: @@ -1575,7 +1574,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item, << " " << item << "\n" << "which is a full-path but not a valid library file name."; this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); } break; } @@ -1592,7 +1591,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories() } // Enforce policy constraints. - switch(this->Target->GetPolicyStatusCMP0003()) + switch(this->Target->Target->GetPolicyStatusCMP0003()) { case cmPolicies::WARN: if(!this->CMakeInstance->GetState() @@ -1603,7 +1602,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories() std::ostringstream w; this->PrintLinkPolicyDiagnosis(w); this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); } case cmPolicies::OLD: // OLD behavior is to add the paths containing libraries with @@ -1619,7 +1618,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories() e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0003) << "\n"; this->PrintLinkPolicyDiagnosis(e); this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); return false; } } @@ -1923,23 +1922,24 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, // build tree. bool linking_for_install = (for_install || - this->Target->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")); + this->Target->Target->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")); bool use_install_rpath = - (outputRuntime && this->Target->HaveInstallTreeRPATH() && + (outputRuntime && this->Target->Target->HaveInstallTreeRPATH() && linking_for_install); bool use_build_rpath = - (outputRuntime && this->Target->HaveBuildTreeRPATH(this->Config) && + (outputRuntime && this->Target->Target->HaveBuildTreeRPATH(this->Config) && !linking_for_install); bool use_link_rpath = outputRuntime && linking_for_install && !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH") && - this->Target->GetPropertyAsBool("INSTALL_RPATH_USE_LINK_PATH"); + this->Target->Target->GetPropertyAsBool("INSTALL_RPATH_USE_LINK_PATH"); // Construct the RPATH. std::set emitted; if(use_install_rpath) { - const char* install_rpath = this->Target->GetProperty("INSTALL_RPATH"); + const char* install_rpath = + this->Target->Target->GetProperty("INSTALL_RPATH"); cmCLI_ExpandListUnique(install_rpath, runtimeDirs, emitted); } if(use_build_rpath || use_link_rpath) @@ -2011,12 +2011,8 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, // Add runtime paths required by the languages to always be // present. This is done even when skipping rpath support. { - cmGeneratorTarget *gtgt = this->Makefile - ->GetGlobalGenerator() - ->GetGeneratorTarget(this->Target); - cmGeneratorTarget::LinkClosure const* lc = - gtgt->GetLinkClosure(this->Config); + this->Target->GetLinkClosure(this->Config); for(std::vector::const_iterator li = lc->Languages.begin(); li != lc->Languages.end(); ++li) { diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index 2d7a5a5..8b83574 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -29,7 +29,8 @@ class cmOrderDirectories; class cmComputeLinkInformation { public: - cmComputeLinkInformation(cmTarget const* target, const std::string& config); + cmComputeLinkInformation(cmGeneratorTarget const* target, + const std::string& config); ~cmComputeLinkInformation(); bool Compute(); @@ -73,7 +74,7 @@ private: std::set SharedLibrariesLinked; // Context information. - cmTarget const* Target; + cmGeneratorTarget const* Target; cmMakefile* Makefile; cmGlobalGenerator* GlobalGenerator; cmake* CMakeInstance; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c68c2b9..55e2922 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3166,7 +3166,7 @@ cmGeneratorTarget::GetLinkInformation(const std::string& config) const { // Compute information for this configuration. cmComputeLinkInformation* info = - new cmComputeLinkInformation(this->Target, config); + new cmComputeLinkInformation(this, config); if(!info || !info->Compute()) { delete info; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ee26add4f4062d8b53f22e161027a573dc03399c commit ee26add4f4062d8b53f22e161027a573dc03399c Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:49 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 18:20:49 2015 +0200 cmGeneratorTarget: Move IsBundleOnApple from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c314372..c68c2b9 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -910,6 +910,14 @@ cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, } //---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsBundleOnApple() const +{ + return this->Target->IsFrameworkOnApple() + || this->Target->IsAppBundleOnApple() + || this->Target->IsCFBundleOnApple(); +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config, bool contentOnly) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index a1193a6..21e0900 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -119,6 +119,10 @@ public: std::string GetAppBundleDirectory(const std::string& config, bool contentOnly) const; + /** Return whether this target is an executable Bundle, a framework + or CFBundle on Apple. */ + bool IsBundleOnApple() const; + /** Get the full name of the target according to the settings in its makefile. */ std::string GetFullName(const std::string& config="", diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index d38cf4c..0b3df90 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -313,7 +313,7 @@ cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator() (cmSourceFile const& source, const char* pkgloc) { // Skip OS X content when not building a Framework or Bundle. - if(!this->Generator->GetTarget()->IsBundleOnApple()) + if(!this->Generator->GetGeneratorTarget()->IsBundleOnApple()) { return; } diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 16e1f48..07efa16 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -742,7 +742,7 @@ cmNinjaTargetGenerator::MacOSXContentGeneratorType::operator()( cmSourceFile const& source, const char* pkgloc) { // Skip OS X content when not building a Framework or Bundle. - if(!this->Generator->GetTarget()->IsBundleOnApple()) + if(!this->Generator->GetGeneratorTarget()->IsBundleOnApple()) { return; } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 62aa12a..e887ef3 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -590,13 +590,6 @@ bool cmTarget::IsXCTestOnApple() const } //---------------------------------------------------------------------------- -bool cmTarget::IsBundleOnApple() const -{ - return this->IsFrameworkOnApple() || this->IsAppBundleOnApple() || - this->IsCFBundleOnApple(); -} - -//---------------------------------------------------------------------------- static bool processSources(cmTarget const* tgt, const std::vector &entries, std::vector &srcs, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 9a4915f..e53afff 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -424,10 +424,6 @@ public: /** Return whether this target is an executable Bundle on Apple. */ bool IsAppBundleOnApple() const; - /** Return whether this target is an executable Bundle, a framework - or CFBundle on Apple. */ - bool IsBundleOnApple() const; - /** Return the framework version string. Undefined if IsFrameworkOnApple returns false. */ std::string GetFrameworkVersion() const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c8a5f5ae60c911298fc3c0f168ac3652223722a4 commit c8a5f5ae60c911298fc3c0f168ac3652223722a4 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:49 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 18:20:49 2015 +0200 cmMakefileTargetGenerator: Add accessor for GeneratorTarget. diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index b885672..fd4527b 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -53,6 +53,7 @@ public: { return this->ProgressFileNameFull; } cmTarget* GetTarget() { return this->Target;} + cmGeneratorTarget* GetGeneratorTarget() { return this->GeneratorTarget;} protected: http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f8076644ce21c5c20cb0d368d25c191a05364481 commit f8076644ce21c5c20cb0d368d25c191a05364481 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:49 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 18:20:49 2015 +0200 cmGeneratorTarget: Move GetLinkClosure from cmTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index c46cab8..269aa69 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -19,6 +19,7 @@ #include "cmOutputConverter.h" #include "cmMakefile.h" #include "cmTarget.h" +#include "cmGeneratorTarget.h" #include "cmake.h" #include "cmAlgorithms.h" @@ -579,8 +580,12 @@ bool cmComputeLinkInformation::Compute() //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddImplicitLinkInfo() { + cmGeneratorTarget *gtgt = this->Target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(this->Target); + // The link closure lists all languages whose implicit info is needed. - cmTarget::LinkClosure const* lc=this->Target->GetLinkClosure(this->Config); + cmGeneratorTarget::LinkClosure const* lc=gtgt->GetLinkClosure(this->Config); for(std::vector::const_iterator li = lc->Languages.begin(); li != lc->Languages.end(); ++li) { @@ -2006,8 +2011,12 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, // Add runtime paths required by the languages to always be // present. This is done even when skipping rpath support. { - cmTarget::LinkClosure const* lc = - this->Target->GetLinkClosure(this->Config); + cmGeneratorTarget *gtgt = this->Makefile + ->GetGlobalGenerator() + ->GetGeneratorTarget(this->Target); + + cmGeneratorTarget::LinkClosure const* lc = + gtgt->GetLinkClosure(this->Config); for(std::vector::const_iterator li = lc->Languages.begin(); li != lc->Languages.end(); ++li) { diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index 3afbb92..2d7a5a5 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -20,6 +20,7 @@ class cmake; class cmGlobalGenerator; class cmMakefile; class cmTarget; +class cmGeneratorTarget; class cmOrderDirectories; /** \class cmComputeLinkInformation diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 4de5e9c..c314372 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -27,6 +27,13 @@ #include #include "assert.h" +#if defined(CMAKE_BUILD_WITH_CMAKE) +#include +#define UNORDERED_SET cmsys::hash_set +#else +#define UNORDERED_SET std::set +#endif + //---------------------------------------------------------------------------- void reportBadObjLib(std::vector const& badObjLib, cmTarget *target, cmake *cm) @@ -1026,6 +1033,223 @@ std::string cmGeneratorTarget::GetInstallNameDirForInstallTree() const } //---------------------------------------------------------------------------- +class cmTargetCollectLinkLanguages +{ +public: + cmTargetCollectLinkLanguages(cmGeneratorTarget const* target, + const std::string& config, + UNORDERED_SET& languages, + cmTarget const* head): + Config(config), Languages(languages), HeadTarget(head), + Makefile(target->Target->GetMakefile()), Target(target) + { this->Visited.insert(target->Target); } + + void Visit(cmLinkItem const& item) + { + if(!item.Target) + { + if(item.find("::") != std::string::npos) + { + bool noMessage = false; + cmake::MessageType messageType = cmake::FATAL_ERROR; + std::stringstream e; + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0028)) + { + case cmPolicies::WARN: + { + e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0028) << "\n"; + messageType = cmake::AUTHOR_WARNING; + } + break; + case cmPolicies::OLD: + noMessage = true; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::NEW: + // Issue the fatal message. + break; + } + + if(!noMessage) + { + e << "Target \"" << this->Target->GetName() + << "\" links to target \"" << item + << "\" but the target was not found. Perhaps a find_package() " + "call is missing for an IMPORTED target, or an ALIAS target is " + "missing?"; + this->Makefile->GetCMakeInstance()->IssueMessage( + messageType, e.str(), this->Target->Target->GetBacktrace()); + } + } + return; + } + if(!this->Visited.insert(item.Target).second) + { + return; + } + + cmTarget::LinkInterface const* iface = + item.Target->GetLinkInterface(this->Config, this->HeadTarget); + if(!iface) { return; } + + for(std::vector::const_iterator + li = iface->Languages.begin(); li != iface->Languages.end(); ++li) + { + this->Languages.insert(*li); + } + + for(std::vector::const_iterator + li = iface->Libraries.begin(); li != iface->Libraries.end(); ++li) + { + this->Visit(*li); + } + } +private: + std::string Config; + UNORDERED_SET& Languages; + cmTarget const* HeadTarget; + cmMakefile* Makefile; + const cmGeneratorTarget* Target; + std::set Visited; +}; + +//---------------------------------------------------------------------------- +cmGeneratorTarget::LinkClosure const* +cmGeneratorTarget::GetLinkClosure(const std::string& config) const +{ + std::string key(cmSystemTools::UpperCase(config)); + LinkClosureMapType::iterator + i = this->LinkClosureMap.find(key); + if(i == this->LinkClosureMap.end()) + { + LinkClosure lc; + this->ComputeLinkClosure(config, lc); + LinkClosureMapType::value_type entry(key, lc); + i = this->LinkClosureMap.insert(entry).first; + } + return &i->second; +} + +//---------------------------------------------------------------------------- +class cmTargetSelectLinker +{ + int Preference; + cmGeneratorTarget const* Target; + cmMakefile* Makefile; + cmGlobalGenerator* GG; + std::set Preferred; +public: + cmTargetSelectLinker(cmGeneratorTarget const* target) + : Preference(0), Target(target) + { + this->Makefile = this->Target->Makefile; + this->GG = this->Makefile->GetGlobalGenerator(); + } + void Consider(const char* lang) + { + int preference = this->GG->GetLinkerPreference(lang); + if(preference > this->Preference) + { + this->Preference = preference; + this->Preferred.clear(); + } + if(preference == this->Preference) + { + this->Preferred.insert(lang); + } + } + std::string Choose() + { + if(this->Preferred.empty()) + { + return ""; + } + else if(this->Preferred.size() > 1) + { + std::stringstream e; + e << "Target " << this->Target->GetName() + << " contains multiple languages with the highest linker preference" + << " (" << this->Preference << "):\n"; + for(std::set::const_iterator + li = this->Preferred.begin(); li != this->Preferred.end(); ++li) + { + e << " " << *li << "\n"; + } + e << "Set the LINKER_LANGUAGE property for this target."; + cmake* cm = this->Makefile->GetCMakeInstance(); + cm->IssueMessage(cmake::FATAL_ERROR, e.str(), + this->Target->Target->GetBacktrace()); + } + return *this->Preferred.begin(); + } +}; + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::ComputeLinkClosure(const std::string& config, + LinkClosure& lc) const +{ + // Get languages built in this target. + UNORDERED_SET languages; + cmTarget::LinkImplementation const* impl = + this->Target->GetLinkImplementation(config); + for(std::vector::const_iterator li = impl->Languages.begin(); + li != impl->Languages.end(); ++li) + { + languages.insert(*li); + } + + // Add interface languages from linked targets. + cmTargetCollectLinkLanguages cll(this, config, languages, this->Target); + for(std::vector::const_iterator li = impl->Libraries.begin(); + li != impl->Libraries.end(); ++li) + { + cll.Visit(*li); + } + + // Store the transitive closure of languages. + for(UNORDERED_SET::const_iterator li = languages.begin(); + li != languages.end(); ++li) + { + lc.Languages.push_back(*li); + } + + // Choose the language whose linker should be used. + if(this->GetProperty("HAS_CXX")) + { + lc.LinkerLanguage = "CXX"; + } + else if(const char* linkerLang = this->GetProperty("LINKER_LANGUAGE")) + { + lc.LinkerLanguage = linkerLang; + } + else + { + // Find the language with the highest preference value. + cmTargetSelectLinker tsl(this); + + // First select from the languages compiled directly in this target. + for(std::vector::const_iterator li = impl->Languages.begin(); + li != impl->Languages.end(); ++li) + { + tsl.Consider(li->c_str()); + } + + // Now consider languages that propagate from linked targets. + for(UNORDERED_SET::const_iterator sit = languages.begin(); + sit != languages.end(); ++sit) + { + std::string propagates = "CMAKE_"+*sit+"_LINKER_PREFERENCE_PROPAGATES"; + if(this->Makefile->IsOn(propagates)) + { + tsl.Consider(sit->c_str()); + } + } + + lc.LinkerLanguage = tsl.Choose(); + } +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, std::string& base, std::string& suffix, @@ -2058,7 +2282,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, std::string cmGeneratorTarget::GetLinkerLanguage(const std::string& config) const { - return this->Target->GetLinkClosure(config)->LinkerLanguage; + return this->GetLinkClosure(config)->LinkerLanguage; } //---------------------------------------------------------------------------- diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 41fb848..a1193a6 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -165,6 +165,20 @@ public: std::string GetModuleDefinitionFile(const std::string& config) const; + /** Link information from the transitive closure of the link + implementation and the interfaces of its dependencies. */ + struct LinkClosure + { + // The preferred linker language. + std::string LinkerLanguage; + + // Languages whose runtime libraries must be linked. + std::vector Languages; + }; + + LinkClosure const* GetLinkClosure(const std::string& config) const; + void ComputeLinkClosure(const std::string& config, LinkClosure& lc) const; + /** Full path with trailing slash to the top-level directory holding object files for this target. Includes the build time config name placeholder if needed for the generator. */ @@ -301,6 +315,9 @@ private: std::string& outPrefix, std::string& outBase, std::string& outSuffix) const; + typedef std::map LinkClosureMapType; + mutable LinkClosureMapType LinkClosureMap; + struct CompatibleInterfacesBase { std::set PropsBool; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index c7118dc..62aa12a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -160,9 +160,6 @@ public: HeadToLinkImplementationMap> LinkImplMapType; LinkImplMapType LinkImplMap; - typedef std::map LinkClosureMapType; - LinkClosureMapType LinkClosureMap; - typedef std::map > SourceFilesMapType; SourceFilesMapType SourceFilesMap; @@ -511,7 +508,6 @@ void cmTarget::ClearLinkMaps() this->Internal->LinkImplMap.clear(); this->Internal->LinkInterfaceMap.clear(); this->Internal->LinkInterfaceUsageRequirementsOnlyMap.clear(); - this->Internal->LinkClosureMap.clear(); this->Internal->SourceFilesMap.clear(); } @@ -3136,223 +3132,6 @@ bool cmTarget::GetPropertyAsBool(const std::string& prop) const } //---------------------------------------------------------------------------- -class cmTargetCollectLinkLanguages -{ -public: - cmTargetCollectLinkLanguages(cmTarget const* target, - const std::string& config, - UNORDERED_SET& languages, - cmTarget const* head): - Config(config), Languages(languages), HeadTarget(head), - Makefile(target->GetMakefile()), Target(target) - { this->Visited.insert(target); } - - void Visit(cmLinkItem const& item) - { - if(!item.Target) - { - if(item.find("::") != std::string::npos) - { - bool noMessage = false; - cmake::MessageType messageType = cmake::FATAL_ERROR; - std::ostringstream e; - switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0028)) - { - case cmPolicies::WARN: - { - e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0028) << "\n"; - messageType = cmake::AUTHOR_WARNING; - } - break; - case cmPolicies::OLD: - noMessage = true; - case cmPolicies::REQUIRED_IF_USED: - case cmPolicies::REQUIRED_ALWAYS: - case cmPolicies::NEW: - // Issue the fatal message. - break; - } - - if(!noMessage) - { - e << "Target \"" << this->Target->GetName() - << "\" links to target \"" << item - << "\" but the target was not found. Perhaps a find_package() " - "call is missing for an IMPORTED target, or an ALIAS target is " - "missing?"; - this->Makefile->GetCMakeInstance()->IssueMessage(messageType, - e.str(), - this->Target->GetBacktrace()); - } - } - return; - } - if(!this->Visited.insert(item.Target).second) - { - return; - } - - cmTarget::LinkInterface const* iface = - item.Target->GetLinkInterface(this->Config, this->HeadTarget); - if(!iface) { return; } - - for(std::vector::const_iterator - li = iface->Languages.begin(); li != iface->Languages.end(); ++li) - { - this->Languages.insert(*li); - } - - for(std::vector::const_iterator - li = iface->Libraries.begin(); li != iface->Libraries.end(); ++li) - { - this->Visit(*li); - } - } -private: - std::string Config; - UNORDERED_SET& Languages; - cmTarget const* HeadTarget; - cmMakefile* Makefile; - const cmTarget* Target; - std::set Visited; -}; - -//---------------------------------------------------------------------------- -cmTarget::LinkClosure const* -cmTarget::GetLinkClosure(const std::string& config) const -{ - std::string key(cmSystemTools::UpperCase(config)); - cmTargetInternals::LinkClosureMapType::iterator - i = this->Internal->LinkClosureMap.find(key); - if(i == this->Internal->LinkClosureMap.end()) - { - LinkClosure lc; - this->ComputeLinkClosure(config, lc); - cmTargetInternals::LinkClosureMapType::value_type entry(key, lc); - i = this->Internal->LinkClosureMap.insert(entry).first; - } - return &i->second; -} - -//---------------------------------------------------------------------------- -class cmTargetSelectLinker -{ - int Preference; - cmTarget const* Target; - cmMakefile* Makefile; - cmGlobalGenerator* GG; - UNORDERED_SET Preferred; -public: - cmTargetSelectLinker(cmTarget const* target): Preference(0), Target(target) - { - this->Makefile = this->Target->GetMakefile(); - this->GG = this->Makefile->GetGlobalGenerator(); - } - void Consider(const std::string& lang) - { - int preference = this->GG->GetLinkerPreference(lang); - if(preference > this->Preference) - { - this->Preference = preference; - this->Preferred.clear(); - } - if(preference == this->Preference) - { - this->Preferred.insert(lang); - } - } - std::string Choose() - { - if(this->Preferred.empty()) - { - return ""; - } - else if(this->Preferred.size() > 1) - { - std::ostringstream e; - e << "Target " << this->Target->GetName() - << " contains multiple languages with the highest linker preference" - << " (" << this->Preference << "):\n"; - for(UNORDERED_SET::const_iterator - li = this->Preferred.begin(); li != this->Preferred.end(); ++li) - { - e << " " << *li << "\n"; - } - e << "Set the LINKER_LANGUAGE property for this target."; - cmake* cm = this->Makefile->GetCMakeInstance(); - cm->IssueMessage(cmake::FATAL_ERROR, e.str(), - this->Target->GetBacktrace()); - } - return *this->Preferred.begin(); - } -}; - -//---------------------------------------------------------------------------- -void cmTarget::ComputeLinkClosure(const std::string& config, - LinkClosure& lc) const -{ - // Get languages built in this target. - UNORDERED_SET languages; - LinkImplementation const* impl = this->GetLinkImplementation(config); - for(std::vector::const_iterator li = impl->Languages.begin(); - li != impl->Languages.end(); ++li) - { - languages.insert(*li); - } - - // Add interface languages from linked targets. - cmTargetCollectLinkLanguages cll(this, config, languages, this); - for(std::vector::const_iterator - li = impl->Libraries.begin(); - li != impl->Libraries.end(); ++li) - { - cll.Visit(*li); - } - - // Store the transitive closure of languages. - for(UNORDERED_SET::const_iterator li = languages.begin(); - li != languages.end(); ++li) - { - lc.Languages.push_back(*li); - } - - // Choose the language whose linker should be used. - if(this->GetProperty("HAS_CXX")) - { - lc.LinkerLanguage = "CXX"; - } - else if(const char* linkerLang = this->GetProperty("LINKER_LANGUAGE")) - { - lc.LinkerLanguage = linkerLang; - } - else - { - // Find the language with the highest preference value. - cmTargetSelectLinker tsl(this); - - // First select from the languages compiled directly in this target. - for(std::vector::const_iterator li = impl->Languages.begin(); - li != impl->Languages.end(); ++li) - { - tsl.Consider(*li); - } - - // Now consider languages that propagate from linked targets. - for(UNORDERED_SET::const_iterator sit = languages.begin(); - sit != languages.end(); ++sit) - { - std::string propagates = "CMAKE_"+*sit+"_LINKER_PREFERENCE_PROPAGATES"; - if(this->Makefile->IsOn(propagates)) - { - tsl.Consider(*sit); - } - } - - lc.LinkerLanguage = tsl.Choose(); - } -} - -//---------------------------------------------------------------------------- void cmTarget::ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index dea9bef..9a4915f 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -315,18 +315,6 @@ public: LinkImplementationLibraries const* GetLinkImplementationLibraries(const std::string& config) const; - /** Link information from the transitive closure of the link - implementation and the interfaces of its dependencies. */ - struct LinkClosure - { - // The preferred linker language. - std::string LinkerLanguage; - - // Languages whose runtime libraries must be linked. - std::vector Languages; - }; - LinkClosure const* GetLinkClosure(const std::string& config) const; - cmTarget const* FindTargetToLink(std::string const& name) const; /** Strip off leading and trailing whitespace from an item named in @@ -662,7 +650,6 @@ private: LinkImplementationLibraries const* GetLinkImplementationLibrariesInternal(const std::string& config, cmTarget const* head) const; - void ComputeLinkClosure(const std::string& config, LinkClosure& lc) const; void ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, cmTarget const* headTarget, http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7c809fa2a675b7e669e76683f73397e38dd22999 commit 7c809fa2a675b7e669e76683f73397e38dd22999 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:49 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 18:20:48 2015 +0200 cmGeneratorTarget: Move GetLinkerLanguage from cmTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index b7555a6..c46cab8 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -265,8 +265,10 @@ cmComputeLinkInformation "runtime search path"); this->OrderDependentRPath = 0; + cmGeneratorTarget *gtgt = this->GlobalGenerator + ->GetGeneratorTarget(this->Target); // Get the language used for linking this target. - this->LinkLanguage = this->Target->GetLinkerLanguage(config); + this->LinkLanguage = gtgt->GetLinkerLanguage(config); if(this->LinkLanguage.empty()) { // The Compute method will do nothing, so skip the rest of the @@ -322,9 +324,6 @@ cmComputeLinkInformation (this->Makefile-> GetSafeDefinition("CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH")); - cmGeneratorTarget *gtgt = this->Target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(this->Target); this->RuntimeUseChrpath = gtgt->IsChrpathUsed(config); // Get options needed to help find dependent libraries. diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 49fc96b..a86c2bc 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -990,6 +990,9 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode assert(target); + cmGeneratorTarget* gtgt = + context->Makefile->GetGlobalGenerator()->GetGeneratorTarget(target); + if (propertyName == "LINKER_LANGUAGE") { if (target->LinkLanguagePropagatesToDependents() && @@ -1001,7 +1004,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode "link libraries for a static library"); return std::string(); } - return target->GetLinkerLanguage(context->Config); + return gtgt->GetLinkerLanguage(context->Config); } cmGeneratorExpressionDAGChecker dagChecker(context->Backtrace, @@ -1128,9 +1131,6 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode } } - cmGeneratorTarget* gtgt = - context->Makefile->GetGlobalGenerator()->GetGeneratorTarget(target); - if (!prop) { if (target->IsImported() @@ -1600,7 +1600,7 @@ struct TargetFilesystemArtifactResultCreator cmGeneratorExpressionContext *context, const GeneratorExpressionContent *content) { - std::string language = target->Target->GetLinkerLanguage(context->Config); + std::string language = target->GetLinkerLanguage(context->Config); std::string pdbSupportVar = "CMAKE_" + language + "_LINKER_SUPPORTS_PDB"; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 834a2e3..4de5e9c 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -709,8 +709,7 @@ bool cmGeneratorTarget::HasSOName(const std::string& config) const return ((this->GetType() == cmTarget::SHARED_LIBRARY || this->GetType() == cmTarget::MODULE_LIBRARY) && !this->GetPropertyAsBool("NO_SONAME") && - this->Makefile->GetSONameFlag( - this->Target->GetLinkerLanguage(config))); + this->Makefile->GetSONameFlag(this->GetLinkerLanguage(config))); } //---------------------------------------------------------------------------- @@ -752,7 +751,7 @@ cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const } // Check for rpath support on this platform. - std::string ll = this->Target->GetLinkerLanguage(config); + std::string ll = this->GetLinkerLanguage(config); if(!ll.empty()) { std::string flagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; @@ -823,7 +822,7 @@ bool cmGeneratorTarget::IsChrpathUsed(const std::string& config) const #if defined(CMAKE_USE_ELF_PARSER) // Enable if the rpath flag uses a separator and the target uses ELF // binaries. - std::string ll = this->Target->GetLinkerLanguage(config); + std::string ll = this->GetLinkerLanguage(config); if(!ll.empty()) { std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; @@ -1986,7 +1985,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, const char* suffixVar = this->Target->GetSuffixVariableInternal(implib); // Check for language-specific default prefix and suffix. - std::string ll = this->Target->GetLinkerLanguage(config); + std::string ll = this->GetLinkerLanguage(config); if(!ll.empty()) { if(!targetSuffix && suffixVar && *suffixVar) @@ -2056,6 +2055,13 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, //---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetLinkerLanguage(const std::string& config) const +{ + return this->Target->GetLinkClosure(config)->LinkerLanguage; +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetPDBName(const std::string& config) const { std::string prefix; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 7ee4fc5..41fb848 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -258,6 +258,9 @@ public: /** Return true if builtin chrpath will work for this target */ bool IsChrpathUsed(const std::string& config) const; + ///! Return the preferred linker language for this target + std::string GetLinkerLanguage(const std::string& config = "") const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index 2f9265a..1e57c33 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -128,7 +128,8 @@ void cmGhsMultiTargetGenerator::Generate() { config = "RELEASE"; } - const std::string language(this->Target->GetLinkerLanguage(config)); + const std::string language( + this->GeneratorTarget->GetLinkerLanguage(config)); config = cmSystemTools::UpperCase(config); this->DynamicDownload = this->DetermineIfDynamicDownload(config, language); if (this->DynamicDownload) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 7b0e153..5006828 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1376,7 +1376,8 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmTarget& cmtarget) return; } - std::string llang = cmtarget.GetLinkerLanguage("NOCONFIG"); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&cmtarget); + std::string llang = gtgt->GetLinkerLanguage("NOCONFIG"); if(llang.empty()) { return; } // If the language is compiled as a source trust Xcode to link with it. @@ -1824,7 +1825,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, AddCompileOptions(flags, &target, lang, configName); } - std::string llang = target.GetLinkerLanguage(configName); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); + std::string llang = gtgt->GetLinkerLanguage(configName); if(binary && llang.empty()) { cmSystemTools::Error @@ -1850,7 +1852,6 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, // Add the export symbol definition for shared library objects. this->AppendDefines(ppDefs, exportMacro); } - cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); std::vector targetDefines; target.GetCompileDefinitions(targetDefines, configName, "C"); this->AppendDefines(ppDefs, targetDefines); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 3ab501d..4ec77a1 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1353,7 +1353,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, linkFlags += this->Makefile->GetSafeDefinition(build); linkFlags += " "; } - std::string linkLanguage = target->Target->GetLinkerLanguage(buildType); + std::string linkLanguage = target->GetLinkerLanguage(buildType); if(linkLanguage.empty()) { cmSystemTools::Error diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 014d3be..29e1034 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1270,10 +1270,10 @@ void cmLocalVisualStudio6Generator std::vector configs; target.GetMakefile()->GetConfigurations(configs); std::vector::const_iterator it = configs.begin(); - const std::string& linkLanguage = target.GetLinkerLanguage(*it); + const std::string& linkLanguage = gt->GetLinkerLanguage(*it); for ( ; it != configs.end(); ++it) { - const std::string& configLinkLanguage = target.GetLinkerLanguage(*it); + const std::string& configLinkLanguage = gt->GetLinkerLanguage(*it); if (configLinkLanguage != linkLanguage) { cmSystemTools::Error @@ -1703,10 +1703,10 @@ void cmLocalVisualStudio6Generator std::vector configs; target.GetMakefile()->GetConfigurations(configs); std::vector::const_iterator it = configs.begin(); - const std::string& linkLanguage = target.GetLinkerLanguage(*it); + const std::string& linkLanguage = gt->GetLinkerLanguage(*it); for ( ; it != configs.end(); ++it) { - const std::string& configLinkLanguage = target.GetLinkerLanguage(*it); + const std::string& configLinkLanguage = gt->GetLinkerLanguage(*it); if (configLinkLanguage != linkLanguage) { cmSystemTools::Error diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 9f26712..a38a061 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -664,6 +664,10 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, const char* configType = "10"; const char* projectType = 0; bool targetBuilds = true; + + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); + switch(target.GetType()) { case cmTarget::OBJECT_LIBRARY: @@ -696,7 +700,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, { const std::string& linkLanguage = (this->FortranProject? std::string("Fortran"): - target.GetLinkerLanguage(configName)); + gt->GetLinkerLanguage(configName)); if(linkLanguage.empty()) { cmSystemTools::Error @@ -758,8 +762,6 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, targetOptions.Parse(flags.c_str()); targetOptions.Parse(defineFlags.c_str()); targetOptions.ParseFinish(); - cmGeneratorTarget* gt = - this->GlobalGenerator->GetGeneratorTarget(&target); std::vector targetDefines; target.GetCompileDefinitions(targetDefines, configName, "CXX"); targetOptions.AddDefines(targetDefines); @@ -1635,7 +1637,7 @@ cmLocalVisualStudio7GeneratorFCInfo lg->GlobalGenerator->GetLanguageFromExtension (sf.GetExtension().c_str()); const std::string& sourceLang = lg->GetSourceFileLanguage(sf); - const std::string& linkLanguage = target.GetLinkerLanguage(i->c_str()); + const std::string& linkLanguage = gt->GetLinkerLanguage(i->c_str()); bool needForceLang = false; // source file does not match its extension language if(lang != sourceLang) diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 2fd77c9..afe145a 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -161,7 +161,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) // Get the language to use for linking this executable. std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); // Make sure we have a link language. if(linkLanguage.empty()) diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index b85b8a8..bb0f9dd 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -133,7 +133,7 @@ void cmMakefileLibraryTargetGenerator::WriteObjectLibraryRules() void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules() { std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_STATIC_LIBRARY"; @@ -159,7 +159,7 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink) return; } std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_SHARED_LIBRARY"; @@ -183,7 +183,7 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink) void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink) { std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_SHARED_MODULE"; @@ -206,7 +206,7 @@ void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink) void cmMakefileLibraryTargetGenerator::WriteFrameworkRules(bool relink) { std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_MACOSX_FRAMEWORK"; @@ -238,7 +238,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules // Get the language to use for linking this library. std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); // Make sure we have a link language. if(linkLanguage.empty()) diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index b94e151..d38cf4c 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1509,7 +1509,7 @@ std::string cmMakefileTargetGenerator::GetLinkRule( if(this->Target->HasImplibGNUtoMS()) { std::string ruleVar = "CMAKE_"; - ruleVar += this->Target->GetLinkerLanguage(this->ConfigName); + ruleVar += this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); ruleVar += "_GNUtoMS_RULE"; if(const char* rule = this->Makefile->GetDefinition(ruleVar)) { @@ -1663,7 +1663,8 @@ cmMakefileTargetGenerator { // Lookup the response file reference flag. std::string responseFlagVar = "CMAKE_"; - responseFlagVar += this->Target->GetLinkerLanguage(this->ConfigName); + responseFlagVar += this->GeneratorTarget + ->GetLinkerLanguage(this->ConfigName); responseFlagVar += "_RESPONSE_FILE_LINK_FLAG"; const char* responseFlag = this->Makefile->GetDefinition(responseFlagVar); @@ -1707,7 +1708,8 @@ cmMakefileTargetGenerator // Lookup the response file reference flag. std::string responseFlagVar = "CMAKE_"; - responseFlagVar += this->Target->GetLinkerLanguage(this->ConfigName); + responseFlagVar += this->GeneratorTarget + ->GetLinkerLanguage(this->ConfigName); responseFlagVar += "_RESPONSE_FILE_LINK_FLAG"; const char* responseFlag = this->Makefile->GetDefinition(responseFlagVar); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 1835841..b855bea 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -40,8 +40,7 @@ cmNinjaNormalTargetGenerator(cmGeneratorTarget* target) , TargetNamePDB() , TargetLinkLanguage("") { - this->TargetLinkLanguage = target->Target - ->GetLinkerLanguage(this->GetConfigName()); + this->TargetLinkLanguage = target->GetLinkerLanguage(this->GetConfigName()); if (target->GetType() == cmTarget::EXECUTABLE) this->GetGeneratorTarget()->GetExecutableNames(this->TargetNameOut, this->TargetNameReal, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 37b788d..c7118dc 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3218,12 +3218,6 @@ private: }; //---------------------------------------------------------------------------- -std::string cmTarget::GetLinkerLanguage(const std::string& config) const -{ - return this->GetLinkClosure(config)->LinkerLanguage; -} - -//---------------------------------------------------------------------------- cmTarget::LinkClosure const* cmTarget::GetLinkClosure(const std::string& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index d0cbc66..dea9bef 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -365,9 +365,6 @@ public: void GetTargetVersion(bool soversion, int& major, int& minor, int& patch) const; - ///! Return the preferred linker language for this target - std::string GetLinkerLanguage(const std::string& config = "") const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 2b33c2c..80b8591 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1627,7 +1627,7 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( this->GlobalGenerator->GetLanguageFromExtension (sf.GetExtension().c_str()); std::string sourceLang = this->LocalGenerator->GetSourceFileLanguage(sf); - const std::string& linkLanguage = this->Target->GetLinkerLanguage(); + const std::string& linkLanguage = this->GeneratorTarget->GetLinkerLanguage(); bool needForceLang = false; // source file does not match its extension language if(lang != sourceLang) @@ -1888,7 +1888,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( std::string flags; const std::string& linkLanguage = - this->Target->GetLinkerLanguage(configName.c_str()); + this->GeneratorTarget->GetLinkerLanguage(configName.c_str()); if(linkLanguage.empty()) { cmSystemTools::Error @@ -2371,7 +2371,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) Options& linkOptions = *pOptions; const std::string& linkLanguage = - this->Target->GetLinkerLanguage(config.c_str()); + this->GeneratorTarget->GetLinkerLanguage(config.c_str()); if(linkLanguage.empty()) { cmSystemTools::Error http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6da99de3236fbaeebf6a4fc66f7d68f43a59902f commit 6da99de3236fbaeebf6a4fc66f7d68f43a59902f Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:48 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 18:20:48 2015 +0200 cmGeneratorTarget: Move GetFrameworkDirectory from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 436e5dd..834a2e3 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -904,6 +904,48 @@ cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config, + bool contentOnly) const +{ + std::string fpath; + fpath += this->Target->GetOutputName(config, false); + fpath += "."; + const char *ext = this->Target->GetProperty("BUNDLE_EXTENSION"); + if (!ext) + { + if (this->Target->IsXCTestOnApple()) + { + ext = "xctest"; + } + else + { + ext = "bundle"; + } + } + fpath += ext; + fpath += "/Contents"; + if(!contentOnly) + fpath += "/MacOS"; + return fpath; +} + +//---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetFrameworkDirectory(const std::string& config, + bool rootDir) const +{ + std::string fpath; + fpath += this->Target->GetOutputName(config, false); + fpath += ".framework"; + if(!rootDir) + { + fpath += "/Versions/"; + fpath += this->Target->GetFrameworkVersion(); + } + return fpath; +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetFullName(const std::string& config, bool implib) const { @@ -1007,11 +1049,11 @@ cmGeneratorTarget::BuildMacContentDirectory(const std::string& base, } if(this->Target->IsFrameworkOnApple()) { - fpath += this->Target->GetFrameworkDirectory(config, contentOnly); + fpath += this->GetFrameworkDirectory(config, contentOnly); } if(this->Target->IsCFBundleOnApple()) { - fpath += this->Target->GetCFBundleDirectory(config, contentOnly); + fpath += this->GetCFBundleDirectory(config, contentOnly); } return fpath; } @@ -1982,7 +2024,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, if(this->Target->IsCFBundleOnApple()) { - fw_prefix = this->Target->GetCFBundleDirectory(config, false); + fw_prefix = this->GetCFBundleDirectory(config, false); fw_prefix += "/"; targetPrefix = fw_prefix.c_str(); targetSuffix = 0; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 1dfdbb3..7ee4fc5 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -124,6 +124,14 @@ public: std::string GetFullName(const std::string& config="", bool implib = false) const; + /** @return the Mac framework directory without the base. */ + std::string GetFrameworkDirectory(const std::string& config, + bool rootDir) const; + + /** @return the Mac CFBundle directory without the base */ + std::string GetCFBundleDirectory(const std::string& config, + bool contentOnly) const; + /** Return the install name directory for the target in the * build tree. For example: "\@rpath/", "\@loader_path/", * or "/full/path/to/library". */ diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 1d85d9c..4fe99e3 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -77,11 +77,11 @@ void cmOSXBundleGenerator::CreateFramework( // Compute the location of the top-level foo.framework directory. std::string contentdir = outpath + "/" + - this->GT->Target->GetFrameworkDirectory(this->ConfigName, true); + this->GT->GetFrameworkDirectory(this->ConfigName, true); contentdir += "/"; std::string newoutpath = outpath + "/" + - this->GT->Target->GetFrameworkDirectory(this->ConfigName, false); + this->GT->GetFrameworkDirectory(this->ConfigName, false); std::string frameworkVersion = this->GT->Target->GetFrameworkVersion(); @@ -172,14 +172,14 @@ void cmOSXBundleGenerator::CreateCFBundle(const std::string& targetName, // Compute bundle directory names. std::string out = root; out += "/"; - out += this->GT->Target->GetCFBundleDirectory(this->ConfigName, false); + out += this->GT->GetCFBundleDirectory(this->ConfigName, false); cmSystemTools::MakeDirectory(out.c_str()); this->Makefile->AddCMakeOutputFile(out); // Configure the Info.plist file. Note that it needs the executable name // to be set. std::string plist = root + "/" + - this->GT->Target->GetCFBundleDirectory(this->ConfigName, true); + this->GT->GetCFBundleDirectory(this->ConfigName, true); plist += "/Info.plist"; std::string name = cmSystemTools::GetFilenameName(targetName); this->LocalGenerator->GenerateAppleInfoPList(this->GT->Target, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index a5ff829..37b788d 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -5126,47 +5126,6 @@ std::string cmTarget::CheckCMP0004(std::string const& item) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetFrameworkDirectory(const std::string& config, - bool rootDir) const -{ - std::string fpath; - fpath += this->GetOutputName(config, false); - fpath += ".framework"; - if(!rootDir) - { - fpath += "/Versions/"; - fpath += this->GetFrameworkVersion(); - } - return fpath; -} - -//---------------------------------------------------------------------------- -std::string cmTarget::GetCFBundleDirectory(const std::string& config, - bool contentOnly) const -{ - std::string fpath; - fpath += this->GetOutputName(config, false); - fpath += "."; - const char *ext = this->GetProperty("BUNDLE_EXTENSION"); - if (!ext) - { - if (this->IsXCTestOnApple()) - { - ext = "xctest"; - } - else - { - ext = "bundle"; - } - } - fpath += ext; - fpath += "/Contents"; - if(!contentOnly) - fpath += "/MacOS"; - return fpath; -} - -//---------------------------------------------------------------------------- cmTargetInternalPointer::cmTargetInternalPointer() { this->Pointer = new cmTargetInternals; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e22d3af..d0cbc66 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -460,14 +460,6 @@ public: /** @return whether this target have a well defined output file name. */ bool HaveWellDefinedOutputFiles() const; - /** @return the Mac framework directory without the base. */ - std::string GetFrameworkDirectory(const std::string& config, - bool rootDir) const; - - /** @return the Mac CFBundle directory without the base */ - std::string GetCFBundleDirectory(const std::string& config, - bool contentOnly) const; - std::vector GetIncludeDirectories( const std::string& config, const std::string& language) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d6bb319b09d056428468d8894f7d7dd2cb0d963e commit d6bb319b09d056428468d8894f7d7dd2cb0d963e Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:48 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 18:20:48 2015 +0200 cmGeneratorTarget: Move GetFullName from cmTarget. Bring GetFullNameInternal with it. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 0fdf646..436e5dd 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -576,7 +576,7 @@ const char* cmGeneratorTarget::GetLocationForBuild() const } } location += "/"; - location += this->Target->GetFullName("", false); + location += this->GetFullName("", false); return location.c_str(); } @@ -663,7 +663,7 @@ cmGeneratorTarget::GetCompilePDBName(const std::string& config) const std::string prefix; std::string base; std::string suffix; - this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, false, prefix, base, suffix); // Check for a per-configuration output directory target property. std::string configUpper = cmSystemTools::UpperCase(config); @@ -896,7 +896,7 @@ std::string cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, bool contentOnly) const { - std::string fpath = this->Target->GetFullName(config, false); + std::string fpath = this->GetFullName(config, false); fpath += ".app/Contents"; if(!contentOnly) fpath += "/MacOS"; @@ -905,6 +905,20 @@ cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, //---------------------------------------------------------------------------- std::string +cmGeneratorTarget::GetFullName(const std::string& config, bool implib) const +{ + if(this->Target->IsImported()) + { + return this->Target->GetFullNameImported(config, implib); + } + else + { + return this->GetFullNameInternal(config, implib); + } +} + +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetInstallNameDirForBuildTree( const std::string& config) const { @@ -977,7 +991,7 @@ void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, const std::string& config, bool implib) const { - this->Target->GetFullNameInternal(config, implib, prefix, base, suffix); + this->GetFullNameInternal(config, implib, prefix, base, suffix); } //---------------------------------------------------------------------------- @@ -1655,7 +1669,7 @@ std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config, // Add the full name of the target. if(implib) { - fpath += this->Target->GetFullName(config, true); + fpath += this->GetFullName(config, true); } else if(realname) { @@ -1663,7 +1677,7 @@ std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config, } else { - fpath += this->Target->GetFullName(config, false); + fpath += this->GetFullName(config, false); } return fpath; } @@ -1753,7 +1767,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, std::string prefix; std::string base; std::string suffix; - this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, false, prefix, base, suffix); // The library name. name = prefix+base+suffix; @@ -1782,7 +1796,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, if(this->GetType() == cmTarget::SHARED_LIBRARY || this->GetType() == cmTarget::MODULE_LIBRARY) { - impName = this->Target->GetFullNameInternal(config, true); + impName = this->GetFullNameInternal(config, true); } else { @@ -1828,7 +1842,7 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, std::string prefix; std::string base; std::string suffix; - this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, false, prefix, base, suffix); // The executable name. name = prefix+base+suffix; @@ -1849,19 +1863,163 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, #endif // The import library name. - impName = this->Target->GetFullNameInternal(config, true); + impName = this->GetFullNameInternal(config, true); // The program database file name. pdbName = this->GetPDBName(config); } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetFullNameInternal(const std::string& config, + bool implib) const +{ + std::string prefix; + std::string base; + std::string suffix; + this->GetFullNameInternal(config, implib, prefix, base, suffix); + return prefix+base+suffix; +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GetFullNameInternal(const std::string& config, + bool implib, + std::string& outPrefix, + std::string& outBase, + std::string& outSuffix) const +{ + // Use just the target name for non-main target types. + if(this->GetType() != cmTarget::STATIC_LIBRARY && + this->GetType() != cmTarget::SHARED_LIBRARY && + this->GetType() != cmTarget::MODULE_LIBRARY && + this->GetType() != cmTarget::EXECUTABLE) + { + outPrefix = ""; + outBase = this->GetName(); + outSuffix = ""; + return; + } + + // Return an empty name for the import library if this platform + // does not support import libraries. + if(implib && + !this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) + { + outPrefix = ""; + outBase = ""; + outSuffix = ""; + return; + } + + // The implib option is only allowed for shared libraries, module + // libraries, and executables. + if(this->GetType() != cmTarget::SHARED_LIBRARY && + this->GetType() != cmTarget::MODULE_LIBRARY && + this->GetType() != cmTarget::EXECUTABLE) + { + implib = false; + } + + // Compute the full name for main target types. + const char* targetPrefix = (implib + ? this->GetProperty("IMPORT_PREFIX") + : this->GetProperty("PREFIX")); + const char* targetSuffix = (implib + ? this->GetProperty("IMPORT_SUFFIX") + : this->GetProperty("SUFFIX")); + const char* configPostfix = 0; + if(!config.empty()) + { + std::string configProp = cmSystemTools::UpperCase(config); + configProp += "_POSTFIX"; + configPostfix = this->GetProperty(configProp); + // Mac application bundles and frameworks have no postfix. + if(configPostfix && + (this->Target->IsAppBundleOnApple() + || this->Target->IsFrameworkOnApple())) + { + configPostfix = 0; + } + } + const char* prefixVar = this->Target->GetPrefixVariableInternal(implib); + const char* suffixVar = this->Target->GetSuffixVariableInternal(implib); + + // Check for language-specific default prefix and suffix. + std::string ll = this->Target->GetLinkerLanguage(config); + if(!ll.empty()) + { + if(!targetSuffix && suffixVar && *suffixVar) + { + std::string langSuff = suffixVar + std::string("_") + ll; + targetSuffix = this->Makefile->GetDefinition(langSuff); + } + if(!targetPrefix && prefixVar && *prefixVar) + { + std::string langPrefix = prefixVar + std::string("_") + ll; + targetPrefix = this->Makefile->GetDefinition(langPrefix); + } + } + + // if there is no prefix on the target use the cmake definition + if(!targetPrefix && prefixVar) + { + targetPrefix = this->Makefile->GetSafeDefinition(prefixVar); + } + // if there is no suffix on the target use the cmake definition + if(!targetSuffix && suffixVar) + { + targetSuffix = this->Makefile->GetSafeDefinition(suffixVar); + } + + // frameworks have directory prefix but no suffix + std::string fw_prefix; + if(this->Target->IsFrameworkOnApple()) + { + fw_prefix = this->Target->GetOutputName(config, false); + fw_prefix += ".framework/"; + targetPrefix = fw_prefix.c_str(); + targetSuffix = 0; + } + + if(this->Target->IsCFBundleOnApple()) + { + fw_prefix = this->Target->GetCFBundleDirectory(config, false); + fw_prefix += "/"; + targetPrefix = fw_prefix.c_str(); + targetSuffix = 0; + } + + // Begin the final name with the prefix. + outPrefix = targetPrefix?targetPrefix:""; + + // Append the target name or property-specified name. + outBase += this->Target->GetOutputName(config, implib); + + // Append the per-configuration postfix. + outBase += configPostfix?configPostfix:""; + + // Name shared libraries with their version number on some platforms. + if(const char* soversion = this->GetProperty("SOVERSION")) + { + if(this->GetType() == cmTarget::SHARED_LIBRARY && !implib && + this->Makefile->IsOn("CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION")) + { + outBase += "-"; + outBase += soversion; + } + } + + // Append the suffix. + outSuffix = targetSuffix?targetSuffix:""; +} + + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetPDBName(const std::string& config) const { std::string prefix; std::string base; std::string suffix; - this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, false, prefix, base, suffix); std::vector props; std::string configUpper = diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index f0d8c60..1dfdbb3 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -119,6 +119,11 @@ public: std::string GetAppBundleDirectory(const std::string& config, bool contentOnly) const; + /** Get the full name of the target according to the settings in its + makefile. */ + std::string GetFullName(const std::string& config="", + bool implib = false) const; + /** Return the install name directory for the target in the * build tree. For example: "\@rpath/", "\@loader_path/", * or "/full/path/to/library". */ @@ -279,6 +284,12 @@ private: mutable std::map DebugCompatiblePropertiesDone; + std::string GetFullNameInternal(const std::string& config, + bool implib) const; + void GetFullNameInternal(const std::string& config, bool implib, + std::string& outPrefix, std::string& outBase, + std::string& outSuffix) const; + struct CompatibleInterfacesBase { std::set PropsBool; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index d53ecde..7b0e153 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2742,7 +2742,8 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget, } else { - fullName = cmtarget.GetFullName(defConfig.c_str()); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&cmtarget); + fullName = gtgt->GetFullName(defConfig.c_str()); } fileRef->AddAttribute("path", this->CreateString(fullName.c_str())); fileRef->AddAttribute("refType", this->CreateString("0")); @@ -3688,7 +3689,7 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( std::string universalFile = universal; universalFile += *arch; universalFile += "/"; - universalFile += t->GetFullName(configName); + universalFile += gt->GetFullName(configName); makefileStream << "\t/bin/rm -f " << this->ConvertToRelativeForMake(universalFile.c_str()) diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 61d7847..014d3be 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1115,10 +1115,12 @@ void cmLocalVisualStudio6Generator cmTarget* tgt = this->GlobalGenerator->FindTarget(j->first.c_str()); if(tgt) { + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(tgt); lib = cmSystemTools::GetFilenameWithoutExtension - (tgt->GetFullName().c_str()); + (gt->GetFullName().c_str()); libDebug = cmSystemTools::GetFilenameWithoutExtension - (tgt->GetFullName("Debug").c_str()); + (gt->GetFullName("Debug").c_str()); lib += ".lib"; libDebug += ".lib"; } @@ -1258,8 +1260,8 @@ void cmLocalVisualStudio6Generator extraLinkOptionsRelWithDebInfo += targetLinkFlags; } - - + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); // Get standard libraries for this language. if(targetBuilds) @@ -1328,11 +1330,11 @@ void cmLocalVisualStudio6Generator target.GetType() == cmTarget::SHARED_LIBRARY || target.GetType() == cmTarget::MODULE_LIBRARY) { - outputName = target.GetFullName(); - outputNameDebug = target.GetFullName("Debug"); - outputNameRelease = target.GetFullName("Release"); - outputNameMinSizeRel = target.GetFullName("MinSizeRel"); - outputNameRelWithDebInfo = target.GetFullName("RelWithDebInfo"); + outputName = gt->GetFullName(); + outputNameDebug = gt->GetFullName("Debug"); + outputNameRelease = gt->GetFullName("Release"); + outputNameMinSizeRel = gt->GetFullName("MinSizeRel"); + outputNameRelWithDebInfo = gt->GetFullName("RelWithDebInfo"); } else if(target.GetType() == cmTarget::OBJECT_LIBRARY) { @@ -1429,10 +1431,10 @@ void cmLocalVisualStudio6Generator fullPathImpRelease += "/"; fullPathImpMinSizeRel += "/"; fullPathImpRelWithDebInfo += "/"; - fullPathImpDebug += target.GetFullName("Debug", true); - fullPathImpRelease += target.GetFullName("Release", true); - fullPathImpMinSizeRel += target.GetFullName("MinSizeRel", true); - fullPathImpRelWithDebInfo += target.GetFullName("RelWithDebInfo", true); + fullPathImpDebug += gt->GetFullName("Debug", true); + fullPathImpRelease += gt->GetFullName("Release", true); + fullPathImpMinSizeRel += gt->GetFullName("MinSizeRel", true); + fullPathImpRelWithDebInfo += gt->GetFullName("RelWithDebInfo", true); targetImplibFlagDebug = "/implib:"; targetImplibFlagRelease = "/implib:"; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 799bac6..9f26712 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -803,7 +803,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, if (this->FortranProject) { // Intel Fortran >= 15.0 uses TargetName property. - std::string targetNameFull = target.GetFullName(configName); + std::string targetNameFull = gt->GetFullName(configName); std::string targetName = cmSystemTools::GetFilenameWithoutLastExtension(targetNameFull); std::string targetExt = @@ -1107,7 +1107,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, } case cmTarget::STATIC_LIBRARY: { - std::string targetNameFull = target.GetFullName(configName); + std::string targetNameFull = gt->GetFullName(configName); std::string libpath = target.GetDirectory(configName); libpath += "/"; libpath += targetNameFull; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e8ef770..a5ff829 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3587,20 +3587,6 @@ bool cmTarget::IsImportedSharedLibWithoutSOName( } //---------------------------------------------------------------------------- -std::string cmTarget::GetFullName(const std::string& config, - bool implib) const -{ - if(this->IsImported()) - { - return this->GetFullNameImported(config, implib); - } - else - { - return this->GetFullNameInternal(config, implib); - } -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetFullNameImported(const std::string& config, bool implib) const { @@ -3626,148 +3612,6 @@ cmTarget::ImportedGetFullPath(const std::string& config, bool implib) const } //---------------------------------------------------------------------------- -std::string -cmTarget::GetFullNameInternal(const std::string& config, bool implib) const -{ - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, implib, prefix, base, suffix); - return prefix+base+suffix; -} - -//---------------------------------------------------------------------------- -void cmTarget::GetFullNameInternal(const std::string& config, - bool implib, - std::string& outPrefix, - std::string& outBase, - std::string& outSuffix) const -{ - // Use just the target name for non-main target types. - if(this->GetType() != cmTarget::STATIC_LIBRARY && - this->GetType() != cmTarget::SHARED_LIBRARY && - this->GetType() != cmTarget::MODULE_LIBRARY && - this->GetType() != cmTarget::EXECUTABLE) - { - outPrefix = ""; - outBase = this->GetName(); - outSuffix = ""; - return; - } - - // Return an empty name for the import library if this platform - // does not support import libraries. - if(implib && - !this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) - { - outPrefix = ""; - outBase = ""; - outSuffix = ""; - return; - } - - // The implib option is only allowed for shared libraries, module - // libraries, and executables. - if(this->GetType() != cmTarget::SHARED_LIBRARY && - this->GetType() != cmTarget::MODULE_LIBRARY && - this->GetType() != cmTarget::EXECUTABLE) - { - implib = false; - } - - // Compute the full name for main target types. - const char* targetPrefix = (implib - ? this->GetProperty("IMPORT_PREFIX") - : this->GetProperty("PREFIX")); - const char* targetSuffix = (implib - ? this->GetProperty("IMPORT_SUFFIX") - : this->GetProperty("SUFFIX")); - const char* configPostfix = 0; - if(!config.empty()) - { - std::string configProp = cmSystemTools::UpperCase(config); - configProp += "_POSTFIX"; - configPostfix = this->GetProperty(configProp); - // Mac application bundles and frameworks have no postfix. - if(configPostfix && - (this->IsAppBundleOnApple() || this->IsFrameworkOnApple())) - { - configPostfix = 0; - } - } - const char* prefixVar = this->GetPrefixVariableInternal(implib); - const char* suffixVar = this->GetSuffixVariableInternal(implib); - - // Check for language-specific default prefix and suffix. - std::string ll = this->GetLinkerLanguage(config); - if(!ll.empty()) - { - if(!targetSuffix && suffixVar && *suffixVar) - { - std::string langSuff = suffixVar + std::string("_") + ll; - targetSuffix = this->Makefile->GetDefinition(langSuff); - } - if(!targetPrefix && prefixVar && *prefixVar) - { - std::string langPrefix = prefixVar + std::string("_") + ll; - targetPrefix = this->Makefile->GetDefinition(langPrefix); - } - } - - // if there is no prefix on the target use the cmake definition - if(!targetPrefix && prefixVar) - { - targetPrefix = this->Makefile->GetSafeDefinition(prefixVar); - } - // if there is no suffix on the target use the cmake definition - if(!targetSuffix && suffixVar) - { - targetSuffix = this->Makefile->GetSafeDefinition(suffixVar); - } - - // frameworks have directory prefix but no suffix - std::string fw_prefix; - if(this->IsFrameworkOnApple()) - { - fw_prefix = this->GetOutputName(config, false); - fw_prefix += ".framework/"; - targetPrefix = fw_prefix.c_str(); - targetSuffix = 0; - } - - if(this->IsCFBundleOnApple()) - { - fw_prefix = this->GetCFBundleDirectory(config, false); - fw_prefix += "/"; - targetPrefix = fw_prefix.c_str(); - targetSuffix = 0; - } - - // Begin the final name with the prefix. - outPrefix = targetPrefix?targetPrefix:""; - - // Append the target name or property-specified name. - outBase += this->GetOutputName(config, implib); - - // Append the per-configuration postfix. - outBase += configPostfix?configPostfix:""; - - // Name shared libraries with their version number on some platforms. - if(const char* soversion = this->GetProperty("SOVERSION")) - { - if(this->GetType() == cmTarget::SHARED_LIBRARY && !implib && - this->Makefile->IsOn("CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION")) - { - outBase += "-"; - outBase += soversion; - } - } - - // Append the suffix. - outSuffix = targetSuffix?targetSuffix:""; -} - -//---------------------------------------------------------------------------- void cmTarget::ComputeVersionedName(std::string& vName, std::string const& prefix, std::string const& base, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 4b804da..e22d3af 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -368,11 +368,6 @@ public: ///! Return the preferred linker language for this target std::string GetLinkerLanguage(const std::string& config = "") const; - /** Get the full name of the target according to the settings in its - makefile. */ - std::string GetFullName(const std::string& config="", - bool implib = false) const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; @@ -575,11 +570,6 @@ private: const char* GetSuffixVariableInternal(bool implib) const; const char* GetPrefixVariableInternal(bool implib) const; - std::string GetFullNameInternal(const std::string& config, - bool implib) const; - void GetFullNameInternal(const std::string& config, bool implib, - std::string& outPrefix, std::string& outBase, - std::string& outSuffix) const; // Use a makefile variable to set a default for the given property. // If the variable is not defined use the given default instead. diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 16edf3c..2b33c2c 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1774,7 +1774,7 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions() else { outDir = this->Target->GetDirectory(config->c_str()) + "/"; - targetNameFull = this->Target->GetFullName(config->c_str()); + targetNameFull = this->GeneratorTarget->GetFullName(config->c_str()); } this->ConvertToWindowsSlash(intermediateDir); this->ConvertToWindowsSlash(outDir); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7a460852fa1bc9df22d4c54bac3d57f909488608 commit 7a460852fa1bc9df22d4c54bac3d57f909488608 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:48 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 18:20:48 2015 +0200 cmGeneratorTarget: Move GetAppBundleDirectory from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 2de3c77..0fdf646 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -890,6 +890,19 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const } } + +//---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, + bool contentOnly) const +{ + std::string fpath = this->Target->GetFullName(config, false); + fpath += ".app/Contents"; + if(!contentOnly) + fpath += "/MacOS"; + return fpath; +} + //---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetInstallNameDirForBuildTree( @@ -976,7 +989,7 @@ cmGeneratorTarget::BuildMacContentDirectory(const std::string& base, std::string fpath = base; if(this->Target->IsAppBundleOnApple()) { - fpath += this->Target->GetAppBundleDirectory(config, contentOnly); + fpath += this->GetAppBundleDirectory(config, contentOnly); } if(this->Target->IsFrameworkOnApple()) { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 6d084f7..f0d8c60 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -115,6 +115,10 @@ public: bool realname) const; std::string NormalGetRealName(const std::string& config) const; + /** @return the Mac App directory without the base */ + std::string GetAppBundleDirectory(const std::string& config, + bool contentOnly) const; + /** Return the install name directory for the target in the * build tree. For example: "\@rpath/", "\@loader_path/", * or "/full/path/to/library". */ diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 7df2f78..1d85d9c 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -47,7 +47,7 @@ void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName, // Compute bundle directory names. std::string out = outpath; out += "/"; - out += this->GT->Target->GetAppBundleDirectory(this->ConfigName, false); + out += this->GT->GetAppBundleDirectory(this->ConfigName, false); cmSystemTools::MakeDirectory(out.c_str()); this->Makefile->AddCMakeOutputFile(out); @@ -57,7 +57,7 @@ void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName, // to be set. std::string plist = outpath; plist += "/"; - plist += this->GT->Target->GetAppBundleDirectory(this->ConfigName, true); + plist += this->GT->GetAppBundleDirectory(this->ConfigName, true); plist += "/Info.plist"; this->LocalGenerator->GenerateAppleInfoPList(this->GT->Target, targetName, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index b49ad9b..e8ef770 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -5323,17 +5323,6 @@ std::string cmTarget::GetCFBundleDirectory(const std::string& config, } //---------------------------------------------------------------------------- -std::string cmTarget::GetAppBundleDirectory(const std::string& config, - bool contentOnly) const -{ - std::string fpath = this->GetFullName(config, false); - fpath += ".app/Contents"; - if(!contentOnly) - fpath += "/MacOS"; - return fpath; -} - -//---------------------------------------------------------------------------- cmTargetInternalPointer::cmTargetInternalPointer() { this->Pointer = new cmTargetInternals; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index c1c518f..4b804da 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -473,10 +473,6 @@ public: std::string GetCFBundleDirectory(const std::string& config, bool contentOnly) const; - /** @return the Mac App directory without the base */ - std::string GetAppBundleDirectory(const std::string& config, - bool contentOnly) const; - std::vector GetIncludeDirectories( const std::string& config, const std::string& language) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d560bfd2739f2594119c49d82485b99bb4fbbe1f commit d560bfd2739f2594119c49d82485b99bb4fbbe1f Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:47 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 18:20:47 2015 +0200 cmGeneratorTarget: Move GetInstallNameDir* from cmTarget. diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 6274c3f..fed0dbc 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -333,12 +333,12 @@ cmExportBuildFileGenerator } std::string -cmExportBuildFileGenerator::InstallNameDir(cmTarget* target, +cmExportBuildFileGenerator::InstallNameDir(cmGeneratorTarget* target, const std::string& config) { std::string install_name_dir; - cmMakefile* mf = target->GetMakefile(); + cmMakefile* mf = target->Target->GetMakefile(); if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { install_name_dir = diff --git a/Source/cmExportBuildFileGenerator.h b/Source/cmExportBuildFileGenerator.h index 4d8e062..ff3d2e1 100644 --- a/Source/cmExportBuildFileGenerator.h +++ b/Source/cmExportBuildFileGenerator.h @@ -71,7 +71,8 @@ protected: cmGeneratorTarget* target, ImportPropertyMap& properties); - std::string InstallNameDir(cmTarget* target, const std::string& config); + std::string InstallNameDir(cmGeneratorTarget* target, + const std::string& config); std::vector FindNamespaces(cmMakefile* mf, const std::string& name); diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index e3652c5..cae60b7 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -893,7 +893,7 @@ cmExportFileGenerator { if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { - value = this->InstallNameDir(target->Target, config); + value = this->InstallNameDir(target, config); } prop = "IMPORTED_SONAME"; value += target->GetSOName(config); diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index 4e54740..44f779b 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -200,7 +200,7 @@ private: virtual void ReplaceInstallPrefix(std::string &input); - virtual std::string InstallNameDir(cmTarget* target, + virtual std::string InstallNameDir(cmGeneratorTarget* target, const std::string& config) = 0; }; diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index b0bc686..d55be11 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -546,12 +546,12 @@ cmExportInstallFileGenerator } std::string -cmExportInstallFileGenerator::InstallNameDir(cmTarget* target, +cmExportInstallFileGenerator::InstallNameDir(cmGeneratorTarget* target, const std::string&) { std::string install_name_dir; - cmMakefile* mf = target->GetMakefile(); + cmMakefile* mf = target->Target->GetMakefile(); if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { install_name_dir = diff --git a/Source/cmExportInstallFileGenerator.h b/Source/cmExportInstallFileGenerator.h index 6f86ac9..b06fee5 100644 --- a/Source/cmExportInstallFileGenerator.h +++ b/Source/cmExportInstallFileGenerator.h @@ -83,7 +83,8 @@ protected: std::set& importedLocations ); - std::string InstallNameDir(cmTarget* target, const std::string& config); + std::string InstallNameDir(cmGeneratorTarget* target, + const std::string& config); cmInstallExportGenerator* IEGen; diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx index 94831f8..ba66531 100644 --- a/Source/cmExportTryCompileFileGenerator.cxx +++ b/Source/cmExportTryCompileFileGenerator.cxx @@ -125,12 +125,12 @@ cmExportTryCompileFileGenerator::PopulateProperties(cmTarget const* target, } std::string -cmExportTryCompileFileGenerator::InstallNameDir(cmTarget* target, +cmExportTryCompileFileGenerator::InstallNameDir(cmGeneratorTarget* target, const std::string& config) { std::string install_name_dir; - cmMakefile* mf = target->GetMakefile(); + cmMakefile* mf = target->Target->GetMakefile(); if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { install_name_dir = diff --git a/Source/cmExportTryCompileFileGenerator.h b/Source/cmExportTryCompileFileGenerator.h index 749f3ef..8838eca 100644 --- a/Source/cmExportTryCompileFileGenerator.h +++ b/Source/cmExportTryCompileFileGenerator.h @@ -45,7 +45,7 @@ protected: ImportPropertyMap& properties, std::set &emitted); - std::string InstallNameDir(cmTarget* target, + std::string InstallNameDir(cmGeneratorTarget* target, const std::string& config); private: std::string FindTargets(const std::string& prop, cmTarget const* tgt, diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 45577e5..2de3c77 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -891,6 +891,73 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const } //---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetInstallNameDirForBuildTree( + const std::string& config) const +{ + // If building directly for installation then the build tree install_name + // is the same as the install tree. + if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) + { + return this->GetInstallNameDirForInstallTree(); + } + + // Use the build tree directory for the target. + if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME") && + !this->Makefile->IsOn("CMAKE_SKIP_RPATH") && + !this->GetPropertyAsBool("SKIP_BUILD_RPATH")) + { + std::string dir; + if(this->Target->MacOSXRpathInstallNameDirDefault()) + { + dir = "@rpath"; + } + else + { + dir = this->Target->GetDirectory(config); + } + dir += "/"; + return dir; + } + else + { + return ""; + } +} + +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetInstallNameDirForInstallTree() const +{ + if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) + { + std::string dir; + const char* install_name_dir = this->GetProperty("INSTALL_NAME_DIR"); + + if(!this->Makefile->IsOn("CMAKE_SKIP_RPATH") && + !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH")) + { + if(install_name_dir && *install_name_dir) + { + dir = install_name_dir; + dir += "/"; + } + } + if(!install_name_dir) + { + if(this->Target->MacOSXRpathInstallNameDirDefault()) + { + dir = "@rpath/"; + } + } + return dir; + } + else + { + return ""; + } +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, std::string& base, std::string& suffix, diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 8fc1b44..6d084f7 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -115,6 +115,15 @@ public: bool realname) const; std::string NormalGetRealName(const std::string& config) const; + /** Return the install name directory for the target in the + * build tree. For example: "\@rpath/", "\@loader_path/", + * or "/full/path/to/library". */ + std::string GetInstallNameDirForBuildTree(const std::string& config) const; + + /** Return the install name directory for the target in the + * install tree. For example: "\@rpath/" or "\@loader_path/". */ + std::string GetInstallNameDirForInstallTree() const; + /** Get the soname of the target. Allowed only for a shared library. */ std::string GetSOName(const std::string& config) const; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 03f6d8f..d53ecde 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2331,7 +2331,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, if(target.GetType() == cmTarget::SHARED_LIBRARY) { // Get the install_name directory for the build tree. - install_name_dir = target.GetInstallNameDirForBuildTree(configName); + install_name_dir = gtgt->GetInstallNameDirForBuildTree(configName); // Xcode doesn't create the correct install_name in some cases. // That is, if the INSTALL_PATH is empty, or if we have versioning // of dylib libraries, we want to specify the install_name. diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 24c1c49..30cf175 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -576,11 +576,14 @@ cmInstallTargetGenerator continue; } + cmGeneratorTarget *gtgt = tgt->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(tgt); // If the build tree and install tree use different path // components of the install_name field then we need to create a // mapping to be applied after installation. - std::string for_build = tgt->GetInstallNameDirForBuildTree(config); - std::string for_install = tgt->GetInstallNameDirForInstallTree(); + std::string for_build = gtgt->GetInstallNameDirForBuildTree(config); + std::string for_install = gtgt->GetInstallNameDirForInstallTree(); if(for_build != for_install) { // The directory portions differ. Append the filename to @@ -605,9 +608,9 @@ cmInstallTargetGenerator if(this->Target->GetType() == cmTarget::SHARED_LIBRARY) { std::string for_build = - this->Target->Target->GetInstallNameDirForBuildTree(config); + this->Target->GetInstallNameDirForBuildTree(config); std::string for_install = - this->Target->Target->GetInstallNameDirForInstallTree(); + this->Target->GetInstallNameDirForInstallTree(); if(this->Target->Target->IsFrameworkOnApple() && for_install.empty()) { diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index a2fcbad..b85b8a8 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -666,7 +666,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules { // Get the install_name directory for the build tree. install_name_dir = - this->Target->GetInstallNameDirForBuildTree(this->ConfigName); + this->GeneratorTarget->GetInstallNameDirForBuildTree(this->ConfigName); // Set the rule variable replacement value. if(install_name_dir.empty()) diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index c80f485..1835841 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -537,7 +537,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() vars["SONAME"] = this->TargetNameSO; if (targetType == cmTarget::SHARED_LIBRARY) { - std::string install_dir = target.GetInstallNameDirForBuildTree(cfgName); + std::string install_dir = + this->GetGeneratorTarget()->GetInstallNameDirForBuildTree(cfgName); if (!install_dir.empty()) { vars["INSTALLNAME_DIR"] = localGen.Convert(install_dir, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 0f1d309..b49ad9b 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3846,73 +3846,6 @@ bool cmTarget::HaveInstallTreeRPATH() const } //---------------------------------------------------------------------------- -std::string cmTarget::GetInstallNameDirForBuildTree( - const std::string& config) const -{ - // If building directly for installation then the build tree install_name - // is the same as the install tree. - if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) - { - return GetInstallNameDirForInstallTree(); - } - - // Use the build tree directory for the target. - if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME") && - !this->Makefile->IsOn("CMAKE_SKIP_RPATH") && - !this->GetPropertyAsBool("SKIP_BUILD_RPATH")) - { - std::string dir; - bool macosx_rpath = this->MacOSXRpathInstallNameDirDefault(); - if(macosx_rpath) - { - dir = "@rpath"; - } - else - { - dir = this->GetDirectory(config); - } - dir += "/"; - return dir; - } - else - { - return ""; - } -} - -//---------------------------------------------------------------------------- -std::string cmTarget::GetInstallNameDirForInstallTree() const -{ - if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) - { - std::string dir; - const char* install_name_dir = this->GetProperty("INSTALL_NAME_DIR"); - - if(!this->Makefile->IsOn("CMAKE_SKIP_RPATH") && - !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH")) - { - if(install_name_dir && *install_name_dir) - { - dir = install_name_dir; - dir += "/"; - } - } - if(!install_name_dir) - { - if(this->MacOSXRpathInstallNameDirDefault()) - { - dir = "@rpath/"; - } - } - return dir; - } - else - { - return ""; - } -} - -//---------------------------------------------------------------------------- const char* cmTarget::GetOutputTargetType(bool implib) const { switch(this->GetType()) diff --git a/Source/cmTarget.h b/Source/cmTarget.h index d03ba3b..c1c518f 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -394,15 +394,6 @@ public: bool HaveBuildTreeRPATH(const std::string& config) const; bool HaveInstallTreeRPATH() const; - /** Return the install name directory for the target in the - * build tree. For example: "\@rpath/", "\@loader_path/", - * or "/full/path/to/library". */ - std::string GetInstallNameDirForBuildTree(const std::string& config) const; - - /** Return the install name directory for the target in the - * install tree. For example: "\@rpath/" or "\@loader_path/". */ - std::string GetInstallNameDirForInstallTree() const; - // Get the properties cmPropertyMap &GetProperties() const { return this->Properties; } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=89e2a080e977b9632fa13c627b6a5370250d6ed5 commit 89e2a080e977b9632fa13c627b6a5370250d6ed5 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:47 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 18:20:47 2015 +0200 cmGeneratorTarget: Move GetMacContentDirectory from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 4be034f..45577e5 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -567,7 +567,7 @@ const char* cmGeneratorTarget::GetLocationForBuild() const if(this->Target->IsAppBundleOnApple()) { - std::string macdir = this->Target->BuildMacContentDirectory("", "", + std::string macdir = this->BuildMacContentDirectory("", "", false); if(!macdir.empty()) { @@ -902,6 +902,47 @@ void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, //---------------------------------------------------------------------------- std::string +cmGeneratorTarget::BuildMacContentDirectory(const std::string& base, + const std::string& config, + bool contentOnly) const +{ + std::string fpath = base; + if(this->Target->IsAppBundleOnApple()) + { + fpath += this->Target->GetAppBundleDirectory(config, contentOnly); + } + if(this->Target->IsFrameworkOnApple()) + { + fpath += this->Target->GetFrameworkDirectory(config, contentOnly); + } + if(this->Target->IsCFBundleOnApple()) + { + fpath += this->Target->GetCFBundleDirectory(config, contentOnly); + } + return fpath; +} + +//---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetMacContentDirectory(const std::string& config, + bool implib) const +{ + // Start with the output directory for the target. + std::string fpath = this->Target->GetDirectory(config, implib); + fpath += "/"; + bool contentOnly = true; + if(this->Target->IsFrameworkOnApple()) + { + // additional files with a framework go into the version specific + // directory + contentOnly = false; + } + fpath = this->BuildMacContentDirectory(fpath, config, contentOnly); + return fpath; +} + +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetModuleDefinitionFile(const std::string& config) const { std::string data; @@ -1527,7 +1568,7 @@ std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config, fpath += "/"; if(this->Target->IsAppBundleOnApple()) { - fpath = this->Target->BuildMacContentDirectory(fpath, config, false); + fpath = this->BuildMacContentDirectory(fpath, config, false); fpath += "/"; } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index f96adad..8fc1b44 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -123,6 +123,15 @@ public: const std::string& config="", bool implib = false) const; + /** Append to @a base the mac content directory and return it. */ + std::string BuildMacContentDirectory(const std::string& base, + const std::string& config = "", + bool contentOnly = true) const; + + /** @return the mac content directory for this target. */ + std::string GetMacContentDirectory(const std::string& config = 0, + bool implib = false) const; + cmTarget* Target; cmMakefile* Makefile; cmLocalGenerator* LocalGenerator; diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 3bc0eb7..7df2f78 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -217,7 +217,7 @@ cmOSXBundleGenerator::InitMacOSXContentDirectory(const char* pkgloc) // Construct the full path to the content subdirectory. std::string macdir = - this->GT->Target->GetMacContentDirectory(this->ConfigName, + this->GT->GetMacContentDirectory(this->ConfigName, /*implib*/ false); macdir += "/"; macdir += pkgloc; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 0d9aa49..0f1d309 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -5401,45 +5401,6 @@ std::string cmTarget::GetAppBundleDirectory(const std::string& config, } //---------------------------------------------------------------------------- -std::string cmTarget::BuildMacContentDirectory(const std::string& base, - const std::string& config, - bool contentOnly) const -{ - std::string fpath = base; - if(this->IsAppBundleOnApple()) - { - fpath += this->GetAppBundleDirectory(config, contentOnly); - } - if(this->IsFrameworkOnApple()) - { - fpath += this->GetFrameworkDirectory(config, contentOnly); - } - if(this->IsCFBundleOnApple()) - { - fpath += this->GetCFBundleDirectory(config, contentOnly); - } - return fpath; -} - -//---------------------------------------------------------------------------- -std::string cmTarget::GetMacContentDirectory(const std::string& config, - bool implib) const -{ - // Start with the output directory for the target. - std::string fpath = this->GetDirectory(config, implib); - fpath += "/"; - bool contentOnly = true; - if(this->IsFrameworkOnApple()) - { - // additional files with a framework go into the version specific - // directory - contentOnly = false; - } - fpath = this->BuildMacContentDirectory(fpath, config, contentOnly); - return fpath; -} - -//---------------------------------------------------------------------------- cmTargetInternalPointer::cmTargetInternalPointer() { this->Pointer = new cmTargetInternals; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 9962fdb..d03ba3b 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -471,10 +471,6 @@ public: directory. */ bool UsesDefaultOutputDir(const std::string& config, bool implib) const; - /** @return the mac content directory for this target. */ - std::string GetMacContentDirectory(const std::string& config, - bool implib) const; - /** @return whether this target have a well defined output file name. */ bool HaveWellDefinedOutputFiles() const; @@ -615,10 +611,6 @@ private: std::string ImportedGetFullPath(const std::string& config, bool implib) const; - /** Append to @a base the mac content directory and return it. */ - std::string BuildMacContentDirectory(const std::string& base, - const std::string& config, - bool contentOnly) const; void GetSourceFiles(std::vector &files, const std::string& config) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=62720e44be3e9f28e4c1e7d38206b2c51d34745e commit 62720e44be3e9f28e4c1e7d38206b2c51d34745e Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:47 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 18:20:47 2015 +0200 cmGeneratorTarget: Move GetFullNameComponents from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 6481390..4be034f 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -891,6 +891,16 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const } //---------------------------------------------------------------------------- +void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, + std::string& base, + std::string& suffix, + const std::string& config, + bool implib) const +{ + this->Target->GetFullNameInternal(config, implib, prefix, base, suffix); +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetModuleDefinitionFile(const std::string& config) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 9ecbbbe..f96adad 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -118,6 +118,11 @@ public: /** Get the soname of the target. Allowed only for a shared library. */ std::string GetSOName(const std::string& config) const; + void GetFullNameComponents(std::string& prefix, + std::string& base, std::string& suffix, + const std::string& config="", + bool implib = false) const; + cmTarget* Target; cmMakefile* Makefile; cmLocalGenerator* LocalGenerator; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index d7ae36d..03f6d8f 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1940,7 +1940,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, std::string pnprefix; std::string pnbase; std::string pnsuffix; - target.GetFullNameComponents(pnprefix, pnbase, pnsuffix, configName); + gtgt->GetFullNameComponents(pnprefix, pnbase, pnsuffix, configName); const char* version = target.GetProperty("VERSION"); const char* soversion = target.GetProperty("SOVERSION"); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 2586b31..c80f485 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -569,7 +569,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() std::string prefix; std::string base; std::string suffix; - target.GetFullNameComponents(prefix, base, suffix); + this->GetGeneratorTarget()->GetFullNameComponents(prefix, base, suffix); std::string dbg_suffix = ".dbg"; // TODO: Where to document? if (mf->GetDefinition("CMAKE_DEBUG_SYMBOL_SUFFIX")) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1183fe4..0d9aa49 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3609,15 +3609,6 @@ cmTarget::GetFullNameImported(const std::string& config, bool implib) const } //---------------------------------------------------------------------------- -void cmTarget::GetFullNameComponents(std::string& prefix, std::string& base, - std::string& suffix, - const std::string& config, - bool implib) const -{ - this->GetFullNameInternal(config, implib, prefix, base, suffix); -} - -//---------------------------------------------------------------------------- std::string cmTarget::ImportedGetFullPath(const std::string& config, bool implib) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 1aef7b3..9962fdb 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -372,10 +372,6 @@ public: makefile. */ std::string GetFullName(const std::string& config="", bool implib = false) const; - void GetFullNameComponents(std::string& prefix, - std::string& base, std::string& suffix, - const std::string& config="", - bool implib = false) const; /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e27d737e27fbfc8cfde020ec02d6b2c74afb6885 commit e27d737e27fbfc8cfde020ec02d6b2c74afb6885 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:46 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 18:20:47 2015 +0200 cmGeneratorTarget: Move IsChrPathUsed from cmTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 72db6f8..b7555a6 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -321,7 +321,11 @@ cmComputeLinkInformation this->RuntimeAlways = (this->Makefile-> GetSafeDefinition("CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH")); - this->RuntimeUseChrpath = this->Target->IsChrpathUsed(config); + + cmGeneratorTarget *gtgt = this->Target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(this->Target); + this->RuntimeUseChrpath = gtgt->IsChrpathUsed(config); // Get options needed to help find dependent libraries. std::string rlVar = "CMAKE_"; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 505d01f..6481390 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -746,7 +746,7 @@ cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const } // If chrpath is going to be used no relinking is needed. - if(this->Target->IsChrpathUsed(config)) + if(this->IsChrpathUsed(config)) { return false; } @@ -779,6 +779,73 @@ cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const || this->Target->HaveInstallTreeRPATH(); } +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsChrpathUsed(const std::string& config) const +{ + // Only certain target types have an rpath. + if(!(this->GetType() == cmTarget::SHARED_LIBRARY || + this->GetType() == cmTarget::MODULE_LIBRARY || + this->GetType() == cmTarget::EXECUTABLE)) + { + return false; + } + + // If the target will not be installed we do not need to change its + // rpath. + if(!this->Target->GetHaveInstallRule()) + { + return false; + } + + // Skip chrpath if skipping rpath altogether. + if(this->Makefile->IsOn("CMAKE_SKIP_RPATH")) + { + return false; + } + + // Skip chrpath if it does not need to be changed at install time. + if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) + { + return false; + } + + // Allow the user to disable builtin chrpath explicitly. + if(this->Makefile->IsOn("CMAKE_NO_BUILTIN_CHRPATH")) + { + return false; + } + + if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) + { + return true; + } + +#if defined(CMAKE_USE_ELF_PARSER) + // Enable if the rpath flag uses a separator and the target uses ELF + // binaries. + std::string ll = this->Target->GetLinkerLanguage(config); + if(!ll.empty()) + { + std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; + sepVar += ll; + sepVar += "_FLAG_SEP"; + const char* sep = this->Makefile->GetDefinition(sepVar); + if(sep && *sep) + { + // TODO: Add ELF check to ABI detection and get rid of + // CMAKE_EXECUTABLE_FORMAT. + if(const char* fmt = + this->Makefile->GetDefinition("CMAKE_EXECUTABLE_FORMAT")) + { + return strcmp(fmt, "ELF") == 0; + } + } + } +#endif + static_cast(config); + return false; +} + //---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetSOName(const std::string& config) const diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index c9a2508..9ecbbbe 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -215,6 +215,9 @@ public: */ bool NeedRelinkBeforeInstall(const std::string& config) const; + /** Return true if builtin chrpath will work for this target */ + bool IsChrpathUsed(const std::string& config) const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 7a7dcb4..24c1c49 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -656,11 +656,10 @@ cmInstallTargetGenerator std::string const& toDestDirPath) { // Skip the chrpath if the target does not need it. - if(this->ImportLibrary || !this->Target->Target->IsChrpathUsed(config)) + if(this->ImportLibrary || !this->Target->IsChrpathUsed(config)) { return; } - // Skip if on Apple if(this->Target->Target->GetMakefile() ->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) @@ -695,7 +694,7 @@ cmInstallTargetGenerator std::string const& toDestDirPath) { // Skip the chrpath if the target does not need it. - if(this->ImportLibrary || !this->Target->Target->IsChrpathUsed(config)) + if(this->ImportLibrary || !this->Target->IsChrpathUsed(config)) { return; } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 8dd62f9..1183fe4 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4314,73 +4314,6 @@ void cmTarget::GetLanguages(std::set& languages, } //---------------------------------------------------------------------------- -bool cmTarget::IsChrpathUsed(const std::string& config) const -{ - // Only certain target types have an rpath. - if(!(this->GetType() == cmTarget::SHARED_LIBRARY || - this->GetType() == cmTarget::MODULE_LIBRARY || - this->GetType() == cmTarget::EXECUTABLE)) - { - return false; - } - - // If the target will not be installed we do not need to change its - // rpath. - if(!this->GetHaveInstallRule()) - { - return false; - } - - // Skip chrpath if skipping rpath altogether. - if(this->Makefile->IsOn("CMAKE_SKIP_RPATH")) - { - return false; - } - - // Skip chrpath if it does not need to be changed at install time. - if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) - { - return false; - } - - // Allow the user to disable builtin chrpath explicitly. - if(this->Makefile->IsOn("CMAKE_NO_BUILTIN_CHRPATH")) - { - return false; - } - - if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) - { - return true; - } - -#if defined(CMAKE_USE_ELF_PARSER) - // Enable if the rpath flag uses a separator and the target uses ELF - // binaries. - std::string ll = this->GetLinkerLanguage(config); - if(!ll.empty()) - { - std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; - sepVar += ll; - sepVar += "_FLAG_SEP"; - const char* sep = this->Makefile->GetDefinition(sepVar); - if(sep && *sep) - { - // TODO: Add ELF check to ABI detection and get rid of - // CMAKE_EXECUTABLE_FORMAT. - if(const char* fmt = - this->Makefile->GetDefinition("CMAKE_EXECUTABLE_FORMAT")) - { - return strcmp(fmt, "ELF") == 0; - } - } - } -#endif - static_cast(config); - return false; -} - -//---------------------------------------------------------------------------- cmTarget::ImportInfo const* cmTarget::GetImportInfo(const std::string& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 11f715a..1aef7b3 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -398,9 +398,6 @@ public: bool HaveBuildTreeRPATH(const std::string& config) const; bool HaveInstallTreeRPATH() const; - /** Return true if builtin chrpath will work for this target */ - bool IsChrpathUsed(const std::string& config) const; - /** Return the install name directory for the target in the * build tree. For example: "\@rpath/", "\@loader_path/", * or "/full/path/to/library". */ http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8d2de00244f8338664c16bd8d8ebb03c6f0cb83f commit 8d2de00244f8338664c16bd8d8ebb03c6f0cb83f Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:46 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 18:20:47 2015 +0200 cmGeneratorTarget: Move NeedRelinkBeforeInstall from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index a29f4c9..505d01f 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -714,6 +714,73 @@ bool cmGeneratorTarget::HasSOName(const std::string& config) const } //---------------------------------------------------------------------------- +bool +cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const +{ + // Only executables and shared libraries can have an rpath and may + // need relinking. + if(this->GetType() != cmTarget::EXECUTABLE && + this->GetType() != cmTarget::SHARED_LIBRARY && + this->GetType() != cmTarget::MODULE_LIBRARY) + { + return false; + } + + // If there is no install location this target will not be installed + // and therefore does not need relinking. + if(!this->Target->GetHaveInstallRule()) + { + return false; + } + + // If skipping all rpaths completely then no relinking is needed. + if(this->Makefile->IsOn("CMAKE_SKIP_RPATH")) + { + return false; + } + + // If building with the install-tree rpath no relinking is needed. + if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) + { + return false; + } + + // If chrpath is going to be used no relinking is needed. + if(this->Target->IsChrpathUsed(config)) + { + return false; + } + + // Check for rpath support on this platform. + std::string ll = this->Target->GetLinkerLanguage(config); + if(!ll.empty()) + { + std::string flagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; + flagVar += ll; + flagVar += "_FLAG"; + if(!this->Makefile->IsSet(flagVar)) + { + // There is no rpath support on this platform so nothing needs + // relinking. + return false; + } + } + else + { + // No linker language is known. This error will be reported by + // other code. + return false; + } + + // If either a build or install tree rpath is set then the rpath + // will likely change between the build tree and install tree and + // this target must be relinked. + return this->Target->HaveBuildTreeRPATH(config) + || this->Target->HaveInstallTreeRPATH(); +} + + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetSOName(const std::string& config) const { if(this->Target->IsImported()) diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 441bbcf..c9a2508 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -210,6 +210,11 @@ public: std::string& realName, std::string& impName, std::string& pdbName, const std::string& config) const; + /** + * Compute whether this target must be relinked before installing. + */ + bool NeedRelinkBeforeInstall(const std::string& config) const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index edf2705..69747a4 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -482,7 +482,7 @@ cmGlobalUnixMakefileGenerator3 // Add this to the list of depends rules in this directory. if((!check_all || !gtarget->GetPropertyAsBool("EXCLUDE_FROM_ALL")) && (!check_relink || - gtarget->Target + gtarget ->NeedRelinkBeforeInstall(lg->GetConfigName()))) { std::string tname = lg->GetRelativeTargetDirectory(*gtarget->Target); @@ -691,7 +691,7 @@ cmGlobalUnixMakefileGenerator3 // Add a local name for the rule to relink the target before // installation. - if(gtarget->Target + if(gtarget ->NeedRelinkBeforeInstall(lg->GetConfigName())) { makeTargetName = lg->GetRelativeTargetDirectory(*gtarget->Target); @@ -876,7 +876,7 @@ cmGlobalUnixMakefileGenerator3 name, depends, commands, true); // Add rules to prepare the target for installation. - if(gtarget->Target + if(gtarget ->NeedRelinkBeforeInstall(lg->GetConfigName())) { localName = lg->GetRelativeTargetDirectory(*gtarget->Target); diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index deabecf..7a7dcb4 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -73,7 +73,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, { // Compute the build tree directory from which to copy the target. std::string fromDirConfig; - if(this->Target->Target->NeedRelinkBeforeInstall(config)) + if(this->Target->NeedRelinkBeforeInstall(config)) { fromDirConfig = this->Target->Target->GetMakefile()->GetCurrentBinaryDirectory(); diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 98bd0ab..ce370bc 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -486,8 +486,7 @@ void cmLocalUnixMakefileGenerator3 // Add a local name for the rule to relink the target before // installation. - if(t->second->Target - ->NeedRelinkBeforeInstall(this->ConfigName)) + if(t->second->NeedRelinkBeforeInstall(this->ConfigName)) { makeTargetName = this->GetRelativeTargetDirectory(*t->second->Target); makeTargetName += "/preinstall"; diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 31a78ad..2fd77c9 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -58,7 +58,7 @@ void cmMakefileExecutableTargetGenerator::WriteRuleFiles() // write the link rules this->WriteExecutableRule(false); - if(this->Target->NeedRelinkBeforeInstall(this->ConfigName)) + if(this->GeneratorTarget->NeedRelinkBeforeInstall(this->ConfigName)) { // Write rules to link an installable version of the target. this->WriteExecutableRule(true); diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 7d0dc49..a2fcbad 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -69,7 +69,7 @@ void cmMakefileLibraryTargetGenerator::WriteRuleFiles() break; case cmTarget::SHARED_LIBRARY: this->WriteSharedLibraryRules(false); - if(this->Target->NeedRelinkBeforeInstall(this->ConfigName)) + if(this->GeneratorTarget->NeedRelinkBeforeInstall(this->ConfigName)) { // Write rules to link an installable version of the target. this->WriteSharedLibraryRules(true); @@ -77,7 +77,7 @@ void cmMakefileLibraryTargetGenerator::WriteRuleFiles() break; case cmTarget::MODULE_LIBRARY: this->WriteModuleLibraryRules(false); - if(this->Target->NeedRelinkBeforeInstall(this->ConfigName)) + if(this->GeneratorTarget->NeedRelinkBeforeInstall(this->ConfigName)) { // Write rules to link an installable version of the target. this->WriteModuleLibraryRules(true); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1e7fb5a..8dd62f9 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3855,70 +3855,6 @@ bool cmTarget::HaveInstallTreeRPATH() const } //---------------------------------------------------------------------------- -bool cmTarget::NeedRelinkBeforeInstall(const std::string& config) const -{ - // Only executables and shared libraries can have an rpath and may - // need relinking. - if(this->TargetTypeValue != cmTarget::EXECUTABLE && - this->TargetTypeValue != cmTarget::SHARED_LIBRARY && - this->TargetTypeValue != cmTarget::MODULE_LIBRARY) - { - return false; - } - - // If there is no install location this target will not be installed - // and therefore does not need relinking. - if(!this->GetHaveInstallRule()) - { - return false; - } - - // If skipping all rpaths completely then no relinking is needed. - if(this->Makefile->IsOn("CMAKE_SKIP_RPATH")) - { - return false; - } - - // If building with the install-tree rpath no relinking is needed. - if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) - { - return false; - } - - // If chrpath is going to be used no relinking is needed. - if(this->IsChrpathUsed(config)) - { - return false; - } - - // Check for rpath support on this platform. - std::string ll = this->GetLinkerLanguage(config); - if(!ll.empty()) - { - std::string flagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; - flagVar += ll; - flagVar += "_FLAG"; - if(!this->Makefile->IsSet(flagVar)) - { - // There is no rpath support on this platform so nothing needs - // relinking. - return false; - } - } - else - { - // No linker language is known. This error will be reported by - // other code. - return false; - } - - // If either a build or install tree rpath is set then the rpath - // will likely change between the build tree and install tree and - // this target must be relinked. - return this->HaveBuildTreeRPATH(config) || this->HaveInstallTreeRPATH(); -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetInstallNameDirForBuildTree( const std::string& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 8c23372..11f715a 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -395,11 +395,6 @@ public: bool GetImplibGNUtoMS(std::string const& gnuName, std::string& out, const char* newExt = 0) const; - /** - * Compute whether this target must be relinked before installing. - */ - bool NeedRelinkBeforeInstall(const std::string& config) const; - bool HaveBuildTreeRPATH(const std::string& config) const; bool HaveInstallTreeRPATH() const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3df705681be123d93146156fec3166b41b19465a commit 3df705681be123d93146156fec3166b41b19465a Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:46 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 18:20:46 2015 +0200 cmGeneratorTarget: Move GetPDBName from cmTarget. diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index a20579b..49fc96b 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1625,7 +1625,7 @@ struct TargetFilesystemArtifactResultCreator std::string result = target->Target->GetPDBDirectory(context->Config); result += "/"; - result += target->Target->GetPDBName(context->Config); + result += target->GetPDBName(context->Config); return result; } }; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index a125e47..a29f4c9 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1525,7 +1525,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, } // The program database file name. - pdbName = this->Target->GetPDBName(config); + pdbName = this->GetPDBName(config); } //---------------------------------------------------------------------------- @@ -1587,7 +1587,39 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, impName = this->Target->GetFullNameInternal(config, true); // The program database file name. - pdbName = this->Target->GetPDBName(config); + pdbName = this->GetPDBName(config); +} + +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetPDBName(const std::string& config) const +{ + std::string prefix; + std::string base; + std::string suffix; + this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + + std::vector props; + std::string configUpper = + cmSystemTools::UpperCase(config); + if(!configUpper.empty()) + { + // PDB_NAME_ + props.push_back("PDB_NAME_" + configUpper); + } + + // PDB_NAME + props.push_back("PDB_NAME"); + + for(std::vector::const_iterator i = props.begin(); + i != props.end(); ++i) + { + if(const char* outName = this->GetProperty(*i)) + { + base = outName; + break; + } + } + return prefix+base+".pdb"; } bool cmStrictTargetComparison::operator()(cmTarget const* t1, diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 9cdfd00..441bbcf 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -160,6 +160,9 @@ public: std::vector const* GetSourceDepends(cmSourceFile const* sf) const; + /** Get the name of the pdb file for the target. */ + std::string GetPDBName(const std::string& config="") const; + /** Whether this library has soname enabled and platform supports it. */ bool HasSOName(const std::string& config) const; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index f9125fc..b94e151 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -548,7 +548,7 @@ cmMakefileTargetGenerator this->GeneratorTarget->GetFullPath(this->ConfigName, false, true); targetFullPathPDB = this->Target->GetPDBDirectory(this->ConfigName); targetFullPathPDB += "/"; - targetFullPathPDB += this->Target->GetPDBName(this->ConfigName); + targetFullPathPDB += this->GeneratorTarget->GetPDBName(this->ConfigName); } if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY) { diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index e61ba6f..16e1f48 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -273,7 +273,7 @@ bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(cmNinjaVars& vars) const { pdbPath = this->Target->GetPDBDirectory(this->GetConfigName()); pdbPath += "/"; - pdbPath += this->Target->GetPDBName(this->GetConfigName()); + pdbPath += this->GeneratorTarget->GetPDBName(this->GetConfigName()); } if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 188ad0f..1e7fb5a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3461,37 +3461,6 @@ const char* cmTarget::GetPrefixVariableInternal(bool implib) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetPDBName(const std::string& config) const -{ - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); - - std::vector props; - std::string configUpper = cmSystemTools::UpperCase(config); - if(!configUpper.empty()) - { - // PDB_NAME_ - props.push_back("PDB_NAME_" + configUpper); - } - - // PDB_NAME - props.push_back("PDB_NAME"); - - for(std::vector::const_iterator i = props.begin(); - i != props.end(); ++i) - { - if(const char* outName = this->GetProperty(*i)) - { - base = outName; - break; - } - } - return prefix+base+".pdb"; -} - -//---------------------------------------------------------------------------- bool cmTarget::HasMacOSXRpathInstallNameDir(const std::string& config) const { bool install_name_is_rpath = false; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 162033c..8c23372 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -377,9 +377,6 @@ public: const std::string& config="", bool implib = false) const; - /** Get the name of the pdb file for the target. */ - std::string GetPDBName(const std::string& config) const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a45fed81e5fd5d9b280c8dd70d50c9606a982a0b commit a45fed81e5fd5d9b280c8dd70d50c9606a982a0b Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:45 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 18:20:46 2015 +0200 cmGeneratorTarget: Move GetCompilePDBPath from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 2b3ebee..a125e47 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -657,6 +657,51 @@ void cmGeneratorTarget::GetSourceFiles(std::vector &files, } //---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetCompilePDBName(const std::string& config) const +{ + std::string prefix; + std::string base; + std::string suffix; + this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + + // Check for a per-configuration output directory target property. + std::string configUpper = cmSystemTools::UpperCase(config); + std::string configProp = "COMPILE_PDB_NAME_"; + configProp += configUpper; + const char* config_name = this->Target->GetProperty(configProp); + if(config_name && *config_name) + { + return prefix + config_name + ".pdb"; + } + + const char* name = this->Target->GetProperty("COMPILE_PDB_NAME"); + if(name && *name) + { + return prefix + name + ".pdb"; + } + + return ""; +} + +//---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetCompilePDBPath(const std::string& config) const +{ + std::string dir = this->Target->GetCompilePDBDirectory(config); + std::string name = this->GetCompilePDBName(config); + if(dir.empty() && !name.empty()) + { + dir = this->Target->GetPDBDirectory(config); + } + if(!dir.empty()) + { + dir += "/"; + } + return dir + name; +} + +//---------------------------------------------------------------------------- bool cmGeneratorTarget::HasSOName(const std::string& config) const { // soname is supported only for shared libraries and modules, diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 9254265..9cdfd00 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -163,6 +163,12 @@ public: /** Whether this library has soname enabled and platform supports it. */ bool HasSOName(const std::string& config) const; + /** Get the name of the compiler pdb file for the target. */ + std::string GetCompilePDBName(const std::string& config="") const; + + /** Get the path for the MSVC /Fd option for this target. */ + std::string GetCompilePDBPath(const std::string& config="") const; + /** * Flags for a given source file as used in this target. Typically assigned * via SET_TARGET_PROPERTIES when the property is a list of source files. diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index dd4cd33..799bac6 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -881,7 +881,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, if(target.GetType() <= cmTarget::OBJECT_LIBRARY) { // Specify the compiler program database file if configured. - std::string pdb = target.GetCompilePDBPath(configName); + std::string pdb = gt->GetCompilePDBPath(configName); if(!pdb.empty()) { fout << "\t\t\t\tProgramDataBaseFileName=\"" diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index ac8cd29..f9125fc 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -553,7 +553,7 @@ cmMakefileTargetGenerator if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY) { targetFullPathCompilePDB = - this->Target->GetCompilePDBPath(this->ConfigName); + this->GeneratorTarget->GetCompilePDBPath(this->ConfigName); if(targetFullPathCompilePDB.empty()) { targetFullPathCompilePDB = this->Target->GetSupportDirectory() + "/"; diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index cf80424..e61ba6f 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -277,7 +277,8 @@ bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(cmNinjaVars& vars) const } if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY) { - compilePdbPath = this->Target->GetCompilePDBPath(this->GetConfigName()); + compilePdbPath = + this->GeneratorTarget->GetCompilePDBPath(this->GetConfigName()); if(compilePdbPath.empty()) { compilePdbPath = this->Target->GetSupportDirectory() + "/"; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e1b3e94..188ad0f 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3492,49 +3492,6 @@ std::string cmTarget::GetPDBName(const std::string& config) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetCompilePDBName(const std::string& config) const -{ - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); - - // Check for a per-configuration output directory target property. - std::string configUpper = cmSystemTools::UpperCase(config); - std::string configProp = "COMPILE_PDB_NAME_"; - configProp += configUpper; - const char* config_name = this->GetProperty(configProp); - if(config_name && *config_name) - { - return prefix + config_name + ".pdb"; - } - - const char* name = this->GetProperty("COMPILE_PDB_NAME"); - if(name && *name) - { - return prefix + name + ".pdb"; - } - - return ""; -} - -//---------------------------------------------------------------------------- -std::string cmTarget::GetCompilePDBPath(const std::string& config) const -{ - std::string dir = this->GetCompilePDBDirectory(config); - std::string name = this->GetCompilePDBName(config); - if(dir.empty() && !name.empty()) - { - dir = this->GetPDBDirectory(config); - } - if(!dir.empty()) - { - dir += "/"; - } - return dir + name; -} - -//---------------------------------------------------------------------------- bool cmTarget::HasMacOSXRpathInstallNameDir(const std::string& config) const { bool install_name_is_rpath = false; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e89a212..162033c 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -380,12 +380,6 @@ public: /** Get the name of the pdb file for the target. */ std::string GetPDBName(const std::string& config) const; - /** Get the name of the compiler pdb file for the target. */ - std::string GetCompilePDBName(const std::string& config="") const; - - /** Get the path for the MSVC /Fd option for this target. */ - std::string GetCompilePDBPath(const std::string& config="") const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 83775a5..16edf3c 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2026,7 +2026,8 @@ void cmVisualStudio10TargetGenerator::WriteClOptions( } // Specify the compiler program database file if configured. - std::string pdb = this->Target->GetCompilePDBPath(configName.c_str()); + std::string pdb = + this->GeneratorTarget->GetCompilePDBPath(configName.c_str()); if(!pdb.empty()) { this->ConvertToWindowsSlash(pdb); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f0aa660772565545cbcda9ed8ae946b8d5097416 commit f0aa660772565545cbcda9ed8ae946b8d5097416 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:45 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 18:20:46 2015 +0200 cmGeneratorTarget: Move HasSOName from cmTarget. diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 8a2cf4b..e3652c5 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -889,7 +889,7 @@ cmExportFileGenerator { std::string prop; std::string value; - if(target->Target->HasSOName(config)) + if(target->HasSOName(config)) { if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 31c2df1..2b3ebee 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -657,6 +657,18 @@ void cmGeneratorTarget::GetSourceFiles(std::vector &files, } //---------------------------------------------------------------------------- +bool cmGeneratorTarget::HasSOName(const std::string& config) const +{ + // soname is supported only for shared libraries and modules, + // and then only when the platform supports an soname flag. + return ((this->GetType() == cmTarget::SHARED_LIBRARY || + this->GetType() == cmTarget::MODULE_LIBRARY) && + !this->GetPropertyAsBool("NO_SONAME") && + this->Makefile->GetSONameFlag( + this->Target->GetLinkerLanguage(config))); +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetSOName(const std::string& config) const { if(this->Target->IsImported()) @@ -1407,7 +1419,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, // Check for library version properties. const char* version = this->GetProperty("VERSION"); const char* soversion = this->GetProperty("SOVERSION"); - if(!this->Target->HasSOName(config) || + if(!this->HasSOName(config) || this->Target->IsFrameworkOnApple()) { // Versioning is supported only for shared libraries and modules, diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 7fb7c32..9254265 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -160,6 +160,9 @@ public: std::vector const* GetSourceDepends(cmSourceFile const* sf) const; + /** Whether this library has soname enabled and platform supports it. */ + bool HasSOName(const std::string& config) const; + /** * Flags for a given source file as used in this target. Typically assigned * via SET_TARGET_PROPERTIES when the property is a list of source files. diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index b44848c..d7ae36d 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1944,7 +1944,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, const char* version = target.GetProperty("VERSION"); const char* soversion = target.GetProperty("SOVERSION"); - if(!target.HasSOName(configName) || target.IsFrameworkOnApple()) + if(!gtgt->HasSOName(configName) || target.IsFrameworkOnApple()) { version = 0; soversion = 0; diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 26273ee..7d0dc49 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -653,7 +653,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules vars.Target = target.c_str(); vars.LinkLibraries = linkLibs.c_str(); vars.ObjectsQuoted = buildObjs.c_str(); - if (this->Target->HasSOName(this->ConfigName)) + if (this->GeneratorTarget->HasSOName(this->ConfigName)) { vars.SONameFlag = this->Makefile->GetSONameFlag(linkLanguage); vars.TargetSOName= targetNameSO.c_str(); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 5d86091..2586b31 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -531,7 +531,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() vars["LANGUAGE_COMPILE_FLAGS"] = t; } - if (target.HasSOName(cfgName)) + if (this->GetGeneratorTarget()->HasSOName(cfgName)) { vars["SONAME_FLAG"] = mf->GetSONameFlag(this->TargetLinkLanguage); vars["SONAME"] = this->TargetNameSO; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 60fe7e4..e1b3e94 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3535,17 +3535,6 @@ std::string cmTarget::GetCompilePDBPath(const std::string& config) const } //---------------------------------------------------------------------------- -bool cmTarget::HasSOName(const std::string& config) const -{ - // soname is supported only for shared libraries and modules, - // and then only when the platform supports an soname flag. - return ((this->GetType() == cmTarget::SHARED_LIBRARY || - this->GetType() == cmTarget::MODULE_LIBRARY) && - !this->GetPropertyAsBool("NO_SONAME") && - this->Makefile->GetSONameFlag(this->GetLinkerLanguage(config))); -} - -//---------------------------------------------------------------------------- bool cmTarget::HasMacOSXRpathInstallNameDir(const std::string& config) const { bool install_name_is_rpath = false; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 15dfb4a..e89a212 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -386,9 +386,6 @@ public: /** Get the path for the MSVC /Fd option for this target. */ std::string GetCompilePDBPath(const std::string& config="") const; - /** Whether this library has soname enabled and platform supports it. */ - bool HasSOName(const std::string& config) const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=766839c56da82e12b6986fb5cf7c8d86442615bc commit 766839c56da82e12b6986fb5cf7c8d86442615bc Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:45 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 18:20:46 2015 +0200 cmGeneratorTarget: Move GetLibraryNames from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 6a693f1..31c2df1 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -693,8 +693,8 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const std::string realName; std::string impName; std::string pdbName; - this->Target->GetLibraryNames(name, soName, realName, - impName, pdbName, config); + this->GetLibraryNames(name, soName, realName, + impName, pdbName, config); return soName; } } @@ -1254,7 +1254,7 @@ void cmGeneratorTarget::GenerateTargetManifest( this->GetType() == cmTarget::SHARED_LIBRARY || this->GetType() == cmTarget::MODULE_LIBRARY) { - this->Target->GetLibraryNames(name, soName, realName, impName, pdbName, + this->GetLibraryNames(name, soName, realName, impName, pdbName, config); } else @@ -1378,13 +1378,100 @@ cmGeneratorTarget::NormalGetRealName(const std::string& config) const std::string realName; std::string impName; std::string pdbName; - this->Target->GetLibraryNames(name, soName, realName, - impName, pdbName, config); + this->GetLibraryNames(name, soName, realName, + impName, pdbName, config); return realName; } } //---------------------------------------------------------------------------- +void cmGeneratorTarget::GetLibraryNames(std::string& name, + std::string& soName, + std::string& realName, + std::string& impName, + std::string& pdbName, + const std::string& config) const +{ + // This should not be called for imported targets. + // TODO: Split cmTarget into a class hierarchy to get compile-time + // enforcement of the limited imported target API. + if(this->Target->IsImported()) + { + std::string msg = "GetLibraryNames called on imported target: "; + msg += this->GetName(); + this->LocalGenerator->IssueMessage(cmake::INTERNAL_ERROR, + msg); + return; + } + + // Check for library version properties. + const char* version = this->GetProperty("VERSION"); + const char* soversion = this->GetProperty("SOVERSION"); + if(!this->Target->HasSOName(config) || + this->Target->IsFrameworkOnApple()) + { + // Versioning is supported only for shared libraries and modules, + // and then only when the platform supports an soname flag. + version = 0; + soversion = 0; + } + if(version && !soversion) + { + // The soversion must be set if the library version is set. Use + // the library version as the soversion. + soversion = version; + } + if(!version && soversion) + { + // Use the soversion as the library version. + version = soversion; + } + + // Get the components of the library name. + std::string prefix; + std::string base; + std::string suffix; + this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + + // The library name. + name = prefix+base+suffix; + + if(this->Target->IsFrameworkOnApple()) + { + realName = prefix; + realName += "Versions/"; + realName += this->Target->GetFrameworkVersion(); + realName += "/"; + realName += base; + soName = realName; + } + else + { + // The library's soname. + this->Target->ComputeVersionedName(soName, prefix, base, suffix, + name, soversion); + + // The library's real name on disk. + this->Target->ComputeVersionedName(realName, prefix, base, suffix, + name, version); + } + + // The import library name. + if(this->GetType() == cmTarget::SHARED_LIBRARY || + this->GetType() == cmTarget::MODULE_LIBRARY) + { + impName = this->Target->GetFullNameInternal(config, true); + } + else + { + impName = ""; + } + + // The program database file name. + pdbName = this->Target->GetPDBName(config); +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetExecutableNames(std::string& name, std::string& realName, std::string& impName, @@ -1446,7 +1533,6 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, pdbName = this->Target->GetPDBName(config); } - bool cmStrictTargetComparison::operator()(cmTarget const* t1, cmTarget const* t2) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 49aa65b..7fb7c32 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -191,6 +191,13 @@ public: std::string& impName, std::string& pdbName, const std::string& config) const; + /** Get the names of the library needed to generate a build rule + that takes into account shared library version numbers. This + should be called only on a library target. */ + void GetLibraryNames(std::string& name, std::string& soName, + std::string& realName, std::string& impName, + std::string& pdbName, const std::string& config) const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index c872859..deabecf 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -185,7 +185,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - this->Target->Target->GetLibraryNames(targetName, targetNameSO, + this->Target->GetLibraryNames(targetName, targetNameSO, targetNameReal, targetNameImport, targetNamePDB, config); @@ -411,7 +411,7 @@ cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target, std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - target->GetLibraryNames(targetName, targetNameSO, targetNameReal, + gtgt->GetLibraryNames(targetName, targetNameSO, targetNameReal, targetNameImport, targetNamePDB, config); if(nameType == NameImplib) { diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index daac331..dd4cd33 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1147,7 +1147,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, std::string targetNameFull; std::string targetNameImport; std::string targetNamePDB; - target.GetLibraryNames(targetName, targetNameSO, targetNameFull, + gt->GetLibraryNames(targetName, targetNameSO, targetNameFull, targetNameImport, targetNamePDB, configName); // Compute the link library and directory information. diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 696dcc4..26273ee 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -28,7 +28,7 @@ cmMakefileLibraryTargetGenerator this->CustomCommandDriver = OnDepends; if (this->Target->GetType() != cmTarget::INTERFACE_LIBRARY) { - this->Target->GetLibraryNames( + this->GeneratorTarget->GetLibraryNames( this->TargetNameOut, this->TargetNameSO, this->TargetNameReal, this->TargetNameImport, this->TargetNamePDB, this->ConfigName); } @@ -266,7 +266,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - this->Target->GetLibraryNames( + this->GeneratorTarget->GetLibraryNames( targetName, targetNameSO, targetNameReal, targetNameImport, targetNamePDB, this->ConfigName); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 737510f..5d86091 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -49,7 +49,7 @@ cmNinjaNormalTargetGenerator(cmGeneratorTarget* target) this->TargetNamePDB, GetLocalGenerator()->GetConfigName()); else - target->Target->GetLibraryNames(this->TargetNameOut, + this->GetGeneratorTarget()->GetLibraryNames(this->TargetNameOut, this->TargetNameSO, this->TargetNameReal, this->TargetNameImport, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 22b76e9..60fe7e4 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3862,95 +3862,6 @@ void cmTarget::GetFullNameInternal(const std::string& config, } //---------------------------------------------------------------------------- -void cmTarget::GetLibraryNames(std::string& name, - std::string& soName, - std::string& realName, - std::string& impName, - std::string& pdbName, - const std::string& config) const -{ - // This should not be called for imported targets. - // TODO: Split cmTarget into a class hierarchy to get compile-time - // enforcement of the limited imported target API. - if(this->IsImported()) - { - std::string msg = "GetLibraryNames called on imported target: "; - msg += this->GetName(); - this->Makefile->IssueMessage(cmake::INTERNAL_ERROR, - msg); - return; - } - - assert(this->GetType() != INTERFACE_LIBRARY); - - // Check for library version properties. - const char* version = this->GetProperty("VERSION"); - const char* soversion = this->GetProperty("SOVERSION"); - if(!this->HasSOName(config) || - this->Makefile->IsOn("CMAKE_PLATFORM_NO_VERSIONED_SONAME") || - this->IsFrameworkOnApple()) - { - // Versioning is supported only for shared libraries and modules, - // and then only when the platform supports an soname flag. - version = 0; - soversion = 0; - } - if(version && !soversion) - { - // The soversion must be set if the library version is set. Use - // the library version as the soversion. - soversion = version; - } - if(!version && soversion) - { - // Use the soversion as the library version. - version = soversion; - } - - // Get the components of the library name. - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); - - // The library name. - name = prefix+base+suffix; - - if(this->IsFrameworkOnApple()) - { - realName = prefix; - realName += "Versions/"; - realName += this->GetFrameworkVersion(); - realName += "/"; - realName += base; - soName = realName; - } - else - { - // The library's soname. - this->ComputeVersionedName(soName, prefix, base, suffix, - name, soversion); - // The library's real name on disk. - this->ComputeVersionedName(realName, prefix, base, suffix, - name, version); - } - - // The import library name. - if(this->GetType() == cmTarget::SHARED_LIBRARY || - this->GetType() == cmTarget::MODULE_LIBRARY) - { - impName = this->GetFullNameInternal(config, true); - } - else - { - impName = ""; - } - - // The program database file name. - pdbName = this->GetPDBName(config); -} - -//---------------------------------------------------------------------------- void cmTarget::ComputeVersionedName(std::string& vName, std::string const& prefix, std::string const& base, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 714647c..15dfb4a 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -399,13 +399,6 @@ public: no soname at all. */ bool IsImportedSharedLibWithoutSOName(const std::string& config) const; - /** Get the names of the library needed to generate a build rule - that takes into account shared library version numbers. This - should be called only on a library target. */ - void GetLibraryNames(std::string& name, std::string& soName, - std::string& realName, std::string& impName, - std::string& pdbName, const std::string& config) const; - /** Does this target have a GNU implib to convert to MS format? */ bool HasImplibGNUtoMS() const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 1bb21ff..83775a5 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2477,7 +2477,8 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) } else { - this->Target->GetLibraryNames(targetName, targetNameSO, targetNameFull, + this->GeneratorTarget->GetLibraryNames(targetName, targetNameSO, + targetNameFull, targetNameImport, targetNamePDB, config.c_str()); } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=47803e6f8e98984e740acf2f7c0a217de58717cd commit 47803e6f8e98984e740acf2f7c0a217de58717cd Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:44 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 18:20:46 2015 +0200 cmGeneratorTarget: Move GetExecutableNames from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index f9f23a6..6a693f1 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1248,8 +1248,7 @@ void cmGeneratorTarget::GenerateTargetManifest( std::string pdbName; if(this->GetType() == cmTarget::EXECUTABLE) { - this->Target->GetExecutableNames(name, realName, impName, pdbName, - config); + this->GetExecutableNames(name, realName, impName, pdbName, config); } else if(this->GetType() == cmTarget::STATIC_LIBRARY || this->GetType() == cmTarget::SHARED_LIBRARY || @@ -1368,7 +1367,7 @@ cmGeneratorTarget::NormalGetRealName(const std::string& config) const std::string realName; std::string impName; std::string pdbName; - this->Target->GetExecutableNames(name, realName, impName, pdbName, config); + this->GetExecutableNames(name, realName, impName, pdbName, config); return realName; } else @@ -1385,6 +1384,69 @@ cmGeneratorTarget::NormalGetRealName(const std::string& config) const } } +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GetExecutableNames(std::string& name, + std::string& realName, + std::string& impName, + std::string& pdbName, + const std::string& config) const +{ + // This should not be called for imported targets. + // TODO: Split cmTarget into a class hierarchy to get compile-time + // enforcement of the limited imported target API. + if(this->Target->IsImported()) + { + std::string msg = + "GetExecutableNames called on imported target: "; + msg += this->GetName(); + this->LocalGenerator->IssueMessage(cmake::INTERNAL_ERROR, msg); + } + + // This versioning is supported only for executables and then only + // when the platform supports symbolic links. +#if defined(_WIN32) && !defined(__CYGWIN__) + const char* version = 0; +#else + // Check for executable version properties. + const char* version = this->GetProperty("VERSION"); + if(this->GetType() != cmTarget::EXECUTABLE || this->Makefile->IsOn("XCODE")) + { + version = 0; + } +#endif + + // Get the components of the executable name. + std::string prefix; + std::string base; + std::string suffix; + this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + + // The executable name. + name = prefix+base+suffix; + + // The executable's real name on disk. +#if defined(__CYGWIN__) + realName = prefix+base; +#else + realName = name; +#endif + if(version) + { + realName += "-"; + realName += version; + } +#if defined(__CYGWIN__) + realName += suffix; +#endif + + // The import library name. + impName = this->Target->GetFullNameInternal(config, true); + + // The program database file name. + pdbName = this->Target->GetPDBName(config); +} + + bool cmStrictTargetComparison::operator()(cmTarget const* t1, cmTarget const* t2) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 1303ee4..49aa65b 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -184,6 +184,12 @@ public: void GetAutoUicOptions(std::vector &result, const std::string& config) const; + /** Get the names of the executable needed to generate a build rule + that takes into account executable version numbers. This should + be called only on an executable target. */ + void GetExecutableNames(std::string& name, std::string& realName, + std::string& impName, std::string& pdbName, + const std::string& config) const; struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index c64f9a3..c872859 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -125,7 +125,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - this->Target->Target->GetExecutableNames(targetName, targetNameReal, + this->Target->GetExecutableNames(targetName, targetNameReal, targetNameImport, targetNamePDB, config); if(this->ImportLibrary) @@ -372,13 +372,16 @@ cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target, { std::string fname; // Compute the name of the library. + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); if(target->GetType() == cmTarget::EXECUTABLE) { std::string targetName; std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - target->GetExecutableNames(targetName, targetNameReal, + gtgt->GetExecutableNames(targetName, targetNameReal, targetNameImport, targetNamePDB, config); if(nameType == NameImplib) diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 37e08dd..daac331 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1244,7 +1244,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, std::string targetNameFull; std::string targetNameImport; std::string targetNamePDB; - target.GetExecutableNames(targetName, targetNameFull, + gt->GetExecutableNames(targetName, targetNameFull, targetNameImport, targetNamePDB, configName); // Compute the link library and directory information. diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 416063f..31a78ad 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -25,7 +25,7 @@ cmMakefileExecutableTargetGenerator cmMakefileTargetGenerator(target) { this->CustomCommandDriver = OnDepends; - this->Target->GetExecutableNames( + this->GeneratorTarget->GetExecutableNames( this->TargetNameOut, this->TargetNameReal, this->TargetNameImport, this->TargetNamePDB, this->ConfigName); @@ -94,7 +94,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - this->Target->GetExecutableNames + this->GeneratorTarget->GetExecutableNames (targetName, targetNameReal, targetNameImport, targetNamePDB, this->ConfigName); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index c9fa7c0..737510f 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -43,7 +43,7 @@ cmNinjaNormalTargetGenerator(cmGeneratorTarget* target) this->TargetLinkLanguage = target->Target ->GetLinkerLanguage(this->GetConfigName()); if (target->GetType() == cmTarget::EXECUTABLE) - target->Target->GetExecutableNames(this->TargetNameOut, + this->GetGeneratorTarget()->GetExecutableNames(this->TargetNameOut, this->TargetNameReal, this->TargetNameImport, this->TargetNamePDB, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index ded5363..22b76e9 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3968,68 +3968,6 @@ void cmTarget::ComputeVersionedName(std::string& vName, } //---------------------------------------------------------------------------- -void cmTarget::GetExecutableNames(std::string& name, - std::string& realName, - std::string& impName, - std::string& pdbName, - const std::string& config) const -{ - // This should not be called for imported targets. - // TODO: Split cmTarget into a class hierarchy to get compile-time - // enforcement of the limited imported target API. - if(this->IsImported()) - { - std::string msg = - "GetExecutableNames called on imported target: "; - msg += this->GetName(); - this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg); - } - - // This versioning is supported only for executables and then only - // when the platform supports symbolic links. -#if defined(_WIN32) && !defined(__CYGWIN__) - const char* version = 0; -#else - // Check for executable version properties. - const char* version = this->GetProperty("VERSION"); - if(this->GetType() != cmTarget::EXECUTABLE || this->Makefile->IsOn("XCODE")) - { - version = 0; - } -#endif - - // Get the components of the executable name. - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); - - // The executable name. - name = prefix+base+suffix; - - // The executable's real name on disk. -#if defined(__CYGWIN__) - realName = prefix+base; -#else - realName = name; -#endif - if(version) - { - realName += "-"; - realName += version; - } -#if defined(__CYGWIN__) - realName += suffix; -#endif - - // The import library name. - impName = this->GetFullNameInternal(config, true); - - // The program database file name. - pdbName = this->GetPDBName(config); -} - -//---------------------------------------------------------------------------- bool cmTarget::HasImplibGNUtoMS() const { return this->HasImportLibrary() && this->GetPropertyAsBool("GNUtoMS"); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 925e7c6..714647c 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -406,14 +406,6 @@ public: std::string& realName, std::string& impName, std::string& pdbName, const std::string& config) const; - /** Get the names of the executable needed to generate a build rule - that takes into account executable version numbers. This should - be called only on an executable target. */ - void GetExecutableNames(std::string& name, std::string& realName, - std::string& impName, - std::string& pdbName, - const std::string& config) const; - /** Does this target have a GNU implib to convert to MS format? */ bool HasImplibGNUtoMS() const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index f3f291a..1bb21ff 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2471,7 +2471,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) std::string targetNamePDB; if(this->Target->GetType() == cmTarget::EXECUTABLE) { - this->Target->GetExecutableNames(targetName, targetNameFull, + this->GeneratorTarget->GetExecutableNames(targetName, targetNameFull, targetNameImport, targetNamePDB, config.c_str()); } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7da4c9d4edbdd6df6aa2a9467d6f32a98fc8cac4 commit 7da4c9d4edbdd6df6aa2a9467d6f32a98fc8cac4 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:44 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 18:20:45 2015 +0200 cmGeneratorTarget: Move GetLinkImplementationClosure diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 521a5b7..f9f23a6 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -618,7 +618,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const std::string& dir, } std::vector const& deps = - this->Target->GetLinkImplementationClosure(config); + this->GetLinkImplementationClosure(config); for(std::vector::const_iterator li = deps.begin(), le = deps.end(); li != le; ++li) { @@ -775,6 +775,54 @@ void cmGeneratorTarget::GetAutoUicOptions(std::vector &result, } //---------------------------------------------------------------------------- +void processILibs(const std::string& config, + cmTarget const* headTarget, + cmLinkItem const& item, + std::vector& tgts, + std::set& emitted) +{ + if (item.Target && emitted.insert(item.Target).second) + { + tgts.push_back(item.Target); + if(cmTarget::LinkInterfaceLibraries const* iface = + item.Target->GetLinkInterfaceLibraries(config, headTarget, true)) + { + for(std::vector::const_iterator + it = iface->Libraries.begin(); + it != iface->Libraries.end(); ++it) + { + processILibs(config, headTarget, *it, tgts, emitted); + } + } + } +} + +//---------------------------------------------------------------------------- +const std::vector& +cmGeneratorTarget::GetLinkImplementationClosure( + const std::string& config) const +{ + LinkImplClosure& tgts = + this->LinkImplClosureMap[config]; + if(!tgts.Done) + { + tgts.Done = true; + std::set emitted; + + cmTarget::LinkImplementationLibraries const* impl + = this->Target->GetLinkImplementationLibraries(config); + + for(std::vector::const_iterator + it = impl->Libraries.begin(); + it != impl->Libraries.end(); ++it) + { + processILibs(config, this->Target, *it, tgts , emitted); + } + } + return tgts; +} + +//---------------------------------------------------------------------------- class cmTargetTraceDependencies { public: @@ -1455,7 +1503,7 @@ cmGeneratorTarget::GetCompatibleInterfaces(std::string const& config) const compat.PropsBool.insert("POSITION_INDEPENDENT_CODE"); compat.PropsString.insert("AUTOUIC_OPTIONS"); std::vector const& deps = - this->Target->GetLinkImplementationClosure(config); + this->GetLinkImplementationClosure(config); for(std::vector::const_iterator li = deps.begin(); li != deps.end(); ++li) { @@ -1954,7 +2002,7 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt, || (!impliedByUse && !explicitlySet)); std::vector const& deps = - tgt->Target->GetLinkImplementationClosure(config); + tgt->GetLinkImplementationClosure(config); if(deps.empty()) { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 8e68d39..1303ee4 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -245,6 +245,18 @@ private: cmGeneratorTarget(cmGeneratorTarget const&); void operator=(cmGeneratorTarget const&); + + struct LinkImplClosure: public std::vector + { + LinkImplClosure(): Done(false) {} + bool Done; + }; + mutable std::map LinkImplClosureMap; + +public: + std::vector const& + GetLinkImplementationClosure(const std::string& config) const; + }; struct cmStrictTargetComparison { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 968bd9d..ded5363 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -163,13 +163,6 @@ public: typedef std::map LinkClosureMapType; LinkClosureMapType LinkClosureMap; - struct LinkImplClosure: public std::vector - { - LinkImplClosure(): Done(false) {} - bool Done; - }; - std::map LinkImplClosureMap; - typedef std::map > SourceFilesMapType; SourceFilesMapType SourceFilesMap; @@ -5175,53 +5168,6 @@ cmTarget::GetImportLinkInterface(const std::string& config, } //---------------------------------------------------------------------------- -void processILibs(const std::string& config, - cmTarget const* headTarget, - cmLinkItem const& item, - std::vector& tgts, - std::set& emitted) -{ - if (item.Target && emitted.insert(item.Target).second) - { - tgts.push_back(item.Target); - if(cmTarget::LinkInterfaceLibraries const* iface = - item.Target->GetLinkInterfaceLibraries(config, headTarget, true)) - { - for(std::vector::const_iterator - it = iface->Libraries.begin(); - it != iface->Libraries.end(); ++it) - { - processILibs(config, headTarget, *it, tgts, emitted); - } - } - } -} - -//---------------------------------------------------------------------------- -std::vector const& -cmTarget::GetLinkImplementationClosure(const std::string& config) const -{ - cmTargetInternals::LinkImplClosure& tgts = - this->Internal->LinkImplClosureMap[config]; - if(!tgts.Done) - { - tgts.Done = true; - std::set emitted; - - cmTarget::LinkImplementationLibraries const* impl - = this->GetLinkImplementationLibraries(config); - - for(std::vector::const_iterator - it = impl->Libraries.begin(); - it != impl->Libraries.end(); ++it) - { - processILibs(config, this, *it, tgts , emitted); - } - } - return tgts; -} - -//---------------------------------------------------------------------------- void cmTargetInternals::ComputeLinkInterfaceLibraries( cmTarget const* thisTarget, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 85d9964..925e7c6 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -293,9 +293,6 @@ public: cmTarget const* headTarget, bool usage_requirements_only) const; - std::vector const& - GetLinkImplementationClosure(const std::string& config) const; - /** The link implementation specifies the direct library dependencies needed by the object files of the target. */ struct LinkImplementationLibraries http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=97f10e488a5153e45d6a27a730cc1ecbaae7d559 commit 97f10e488a5153e45d6a27a730cc1ecbaae7d559 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:44 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 18:20:45 2015 +0200 cmGeneratorTarget: Move ReportPropertyOrigin from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index fe73fee..521a5b7 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1937,24 +1937,24 @@ std::pair consistentProperty(const char *lhs, //---------------------------------------------------------------------------- template -PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, +PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt, const std::string &p, const std::string& config, const char *defaultValue, CompatibleType t, PropertyType *) { - PropertyType propContent = getTypedProperty(tgt, p); - const bool explicitlySet = tgt->GetProperties() + PropertyType propContent = getTypedProperty(tgt->Target, p); + const bool explicitlySet = tgt->Target->GetProperties() .find(p) - != tgt->GetProperties().end(); + != tgt->Target->GetProperties().end(); const bool impliedByUse = - tgt->IsNullImpliedByLinkLibraries(p); + tgt->Target->IsNullImpliedByLinkLibraries(p); assert((impliedByUse ^ explicitlySet) || (!impliedByUse && !explicitlySet)); std::vector const& deps = - tgt->GetLinkImplementationClosure(config); + tgt->Target->GetLinkImplementationClosure(config); if(deps.empty()) { @@ -2125,7 +2125,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, bool cmGeneratorTarget::GetLinkInterfaceDependentBoolProperty( const std::string &p, const std::string& config) const { - return checkInterfacePropertyCompatibility(this->Target, p, config, + return checkInterfacePropertyCompatibility(this, p, config, "FALSE", BoolType, 0); } @@ -2135,7 +2135,7 @@ const char* cmGeneratorTarget::GetLinkInterfaceDependentStringProperty( const std::string &p, const std::string& config) const { - return checkInterfacePropertyCompatibility(this->Target, + return checkInterfacePropertyCompatibility(this, p, config, "empty", @@ -2147,7 +2147,7 @@ const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMinProperty( const std::string &p, const std::string& config) const { - return checkInterfacePropertyCompatibility(this->Target, + return checkInterfacePropertyCompatibility(this, p, config, "empty", @@ -2159,7 +2159,7 @@ const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMaxProperty( const std::string &p, const std::string& config) const { - return checkInterfacePropertyCompatibility(this->Target, + return checkInterfacePropertyCompatibility(this, p, config, "empty", @@ -2196,3 +2196,43 @@ cmGeneratorTarget::GetLinkInformation(const std::string& config) const } return i->second; } + +//---------------------------------------------------------------------------- +void +cmGeneratorTarget::ReportPropertyOrigin(const std::string &p, + const std::string &result, + const std::string &report, + const std::string &compatibilityType) const +{ + std::vector debugProperties; + const char *debugProp = this->Target->GetMakefile() + ->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); + if (debugProp) + { + cmSystemTools::ExpandListArgument(debugProp, debugProperties); + } + + bool debugOrigin = !this->DebugCompatiblePropertiesDone[p] + && std::find(debugProperties.begin(), + debugProperties.end(), + p) + != debugProperties.end(); + + if (this->Target->GetMakefile()->IsConfigured()) + { + this->DebugCompatiblePropertiesDone[p] = true; + } + if (!debugOrigin) + { + return; + } + + std::string areport = compatibilityType; + areport += std::string(" of property \"") + p + "\" for target \""; + areport += std::string(this->GetName()); + areport += "\" (result: \""; + areport += result; + areport += "\"):\n" + report; + + this->Makefile->GetCMakeInstance()->IssueMessage(cmake::LOG, areport); +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index d65b1ef..8e68d39 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -199,6 +199,11 @@ public: std::vector XamlSources; }; + void ReportPropertyOrigin(const std::string &p, + const std::string &result, + const std::string &report, + const std::string &compatibilityType) const; + private: friend class cmTargetTraceDependencies; struct SourceEntry { std::vector Depends; }; @@ -212,6 +217,8 @@ private: mutable bool SourceFileFlagsConstructed; mutable std::map SourceFlagsMap; + mutable std::map DebugCompatiblePropertiesDone; + struct CompatibleInterfacesBase { std::set PropsBool; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1fa62e7..968bd9d 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4537,46 +4537,6 @@ bool cmTarget::IsNullImpliedByLinkLibraries(const std::string &p) const //---------------------------------------------------------------------------- void -cmTarget::ReportPropertyOrigin(const std::string &p, - const std::string &result, - const std::string &report, - const std::string &compatibilityType) const -{ - std::vector debugProperties; - const char *debugProp = - this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); - if (debugProp) - { - cmSystemTools::ExpandListArgument(debugProp, debugProperties); - } - - bool debugOrigin = !this->DebugCompatiblePropertiesDone[p] - && std::find(debugProperties.begin(), - debugProperties.end(), - p) - != debugProperties.end(); - - if (this->Makefile->IsConfigured()) - { - this->DebugCompatiblePropertiesDone[p] = true; - } - if (!debugOrigin) - { - return; - } - - std::string areport = compatibilityType; - areport += std::string(" of property \"") + p + "\" for target \""; - areport += std::string(this->GetName()); - areport += "\" (result: \""; - areport += result; - areport += "\"):\n" + report; - - this->Makefile->GetCMakeInstance()->IssueMessage(cmake::LOG, areport); -} - -//---------------------------------------------------------------------------- -void cmTarget::GetObjectLibrariesCMP0026(std::vector& objlibs) const { // At configure-time, this method can be called as part of getting the diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 795753e..85d9964 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -565,11 +565,6 @@ public: bool LinkLanguagePropagatesToDependents() const { return this->TargetTypeValue == STATIC_LIBRARY; } - void ReportPropertyOrigin(const std::string &p, - const std::string &result, - const std::string &report, - const std::string &compatibilityType) const; - std::map const& GetMaxLanguageStandards() const { @@ -676,7 +671,6 @@ private: std::set Utilities; mutable std::set LinkImplicitNullProperties; std::map UtilityBacktraces; - mutable std::map DebugCompatiblePropertiesDone; mutable std::map MaxLanguageStandards; cmPolicies::PolicyMap PolicyMap; std::string Name; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4b86f5edc91ba649908f5b6ab0fb7f1154e38066 commit 4b86f5edc91ba649908f5b6ab0fb7f1154e38066 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:43 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 18:20:45 2015 +0200 cmGeneratorTarget: Make CompatibleType enum private again. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index a9245c0..fe73fee 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1524,18 +1524,26 @@ bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty( return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0; } +enum CompatibleType +{ + BoolType, + StringType, + NumberMinType, + NumberMaxType +}; + template PropertyType getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, - cmTarget::CompatibleType, + CompatibleType, PropertyType *); template<> bool getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, - cmTarget::CompatibleType, bool *) + CompatibleType, bool *) { return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); } @@ -1544,19 +1552,19 @@ template<> const char * getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, - cmTarget::CompatibleType t, + CompatibleType t, const char **) { switch(t) { - case cmTarget::BoolType: + case BoolType: assert(0 && "String compatibility check function called for boolean"); return 0; - case cmTarget::StringType: + case StringType: return tgt->GetLinkInterfaceDependentStringProperty(prop, config); - case cmTarget::NumberMinType: + case NumberMinType: return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config); - case cmTarget::NumberMaxType: + case NumberMaxType: return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config); } assert(0 && "Unreachable!"); @@ -1570,7 +1578,7 @@ void checkPropertyConsistency(cmGeneratorTarget const* depender, const std::string& propName, std::set &emitted, const std::string& config, - cmTarget::CompatibleType t, + CompatibleType t, PropertyType *) { const char *prop = dependee->GetProperty(propName); @@ -1683,7 +1691,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( checkPropertyConsistency(this, li->Target, strBool, - emittedBools, config, cmTarget::BoolType, 0); + emittedBools, config, BoolType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; @@ -1691,7 +1699,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( checkPropertyConsistency(this, li->Target, strString, emittedStrings, config, - cmTarget::StringType, 0); + StringType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; @@ -1699,7 +1707,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( checkPropertyConsistency(this, li->Target, strNumMin, emittedMinNumbers, config, - cmTarget::NumberMinType, 0); + NumberMinType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; @@ -1707,7 +1715,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( checkPropertyConsistency(this, li->Target, strNumMax, emittedMaxNumbers, config, - cmTarget::NumberMaxType, 0); + NumberMaxType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; @@ -1760,17 +1768,17 @@ void cmGeneratorTarget::CheckPropertyCompatibility( } //---------------------------------------------------------------------------- -std::string compatibilityType(cmTarget::CompatibleType t) +std::string compatibilityType(CompatibleType t) { switch(t) { - case cmTarget::BoolType: + case BoolType: return "Boolean compatibility"; - case cmTarget::StringType: + case StringType: return "String compatibility"; - case cmTarget::NumberMaxType: + case NumberMaxType: return "Numeric maximum compatibility"; - case cmTarget::NumberMinType: + case NumberMinType: return "Numeric minimum compatibility"; } assert(0 && "Unreachable!"); @@ -1778,15 +1786,15 @@ std::string compatibilityType(cmTarget::CompatibleType t) } //---------------------------------------------------------------------------- -std::string compatibilityAgree(cmTarget::CompatibleType t, bool dominant) +std::string compatibilityAgree(CompatibleType t, bool dominant) { switch(t) { - case cmTarget::BoolType: - case cmTarget::StringType: + case BoolType: + case StringType: return dominant ? "(Disagree)\n" : "(Agree)\n"; - case cmTarget::NumberMaxType: - case cmTarget::NumberMinType: + case NumberMaxType: + case NumberMinType: return dominant ? "(Dominant)\n" : "(Ignored)\n"; } assert(0 && "Unreachable!"); @@ -1842,12 +1850,12 @@ const char* impliedValue(const char*) template std::pair consistentProperty(PropertyType lhs, PropertyType rhs, - cmTarget::CompatibleType t); + CompatibleType t); //---------------------------------------------------------------------------- template<> std::pair consistentProperty(bool lhs, bool rhs, - cmTarget::CompatibleType) + CompatibleType) { return std::make_pair(lhs == rhs, lhs); } @@ -1863,7 +1871,7 @@ std::pair consistentStringProperty(const char *lhs, //---------------------------------------------------------------------------- std::pair consistentNumberProperty(const char *lhs, const char *rhs, - cmTarget::CompatibleType t) + CompatibleType t) { char *pEnd; @@ -1881,7 +1889,7 @@ std::pair consistentNumberProperty(const char *lhs, return std::pair(false, null_ptr); } - if (t == cmTarget::NumberMaxType) + if (t == NumberMaxType) { return std::make_pair(true, std::max(lnum, rnum) == lnum ? lhs : rhs); } @@ -1895,7 +1903,7 @@ std::pair consistentNumberProperty(const char *lhs, template<> std::pair consistentProperty(const char *lhs, const char *rhs, - cmTarget::CompatibleType t) + CompatibleType t) { if (!lhs && !rhs) { @@ -1914,13 +1922,13 @@ std::pair consistentProperty(const char *lhs, switch(t) { - case cmTarget::BoolType: + case BoolType: assert(0 && "consistentProperty for strings called with BoolType"); return std::pair(false, null_ptr); - case cmTarget::StringType: + case StringType: return consistentStringProperty(lhs, rhs); - case cmTarget::NumberMinType: - case cmTarget::NumberMaxType: + case NumberMinType: + case NumberMaxType: return consistentNumberProperty(lhs, rhs, t); } assert(0 && "Unreachable!"); @@ -1933,7 +1941,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, const std::string &p, const std::string& config, const char *defaultValue, - cmTarget::CompatibleType t, + CompatibleType t, PropertyType *) { PropertyType propContent = getTypedProperty(tgt, p); @@ -2119,7 +2127,7 @@ bool cmGeneratorTarget::GetLinkInterfaceDependentBoolProperty( { return checkInterfacePropertyCompatibility(this->Target, p, config, "FALSE", - cmTarget::BoolType, 0); + BoolType, 0); } //---------------------------------------------------------------------------- @@ -2131,7 +2139,7 @@ const char* cmGeneratorTarget::GetLinkInterfaceDependentStringProperty( p, config, "empty", - cmTarget::StringType, 0); + StringType, 0); } //---------------------------------------------------------------------------- @@ -2143,7 +2151,7 @@ const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMinProperty( p, config, "empty", - cmTarget::NumberMinType, 0); + NumberMinType, 0); } //---------------------------------------------------------------------------- @@ -2155,7 +2163,7 @@ const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMaxProperty( p, config, "empty", - cmTarget::NumberMaxType, 0); + NumberMaxType, 0); } //---------------------------------------------------------------------------- diff --git a/Source/cmTarget.h b/Source/cmTarget.h index b544b0b..795753e 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -581,14 +581,6 @@ public: return this->LinkLibrariesForVS6;} #endif - enum CompatibleType - { - BoolType, - StringType, - NumberMinType, - NumberMaxType - }; - private: bool HandleLocationPropertyPolicy(cmMakefile* context) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5ff813c7a62d6c37b86bbf9a988a91baa4d5b9e6 commit 5ff813c7a62d6c37b86bbf9a988a91baa4d5b9e6 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:43 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 18:20:45 2015 +0200 cmGeneratorTarget: Move LinkInterfaceDependent methods from cmTarget. diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index c1641cc..a20579b 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1142,7 +1142,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode context->Config)) { context->HadContextSensitiveCondition = true; - return target->GetLinkInterfaceDependentBoolProperty( + return gtgt->GetLinkInterfaceDependentBoolProperty( propertyName, context->Config) ? "1" : "0"; } @@ -1151,7 +1151,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { context->HadContextSensitiveCondition = true; const char *propContent = - target->GetLinkInterfaceDependentStringProperty( + gtgt->GetLinkInterfaceDependentStringProperty( propertyName, context->Config); return propContent ? propContent : ""; @@ -1161,7 +1161,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { context->HadContextSensitiveCondition = true; const char *propContent = - target->GetLinkInterfaceDependentNumberMinProperty( + gtgt->GetLinkInterfaceDependentNumberMinProperty( propertyName, context->Config); return propContent ? propContent : ""; @@ -1171,7 +1171,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { context->HadContextSensitiveCondition = true; const char *propContent = - target->GetLinkInterfaceDependentNumberMaxProperty( + gtgt->GetLinkInterfaceDependentNumberMaxProperty( propertyName, context->Config); return propContent ? propContent : ""; @@ -1188,7 +1188,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { context->HadContextSensitiveCondition = true; const char *propContent = - target->GetLinkInterfaceDependentNumberMinProperty( + gtgt->GetLinkInterfaceDependentNumberMinProperty( propertyName, context->Config); return propContent ? propContent : ""; @@ -1198,7 +1198,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { context->HadContextSensitiveCondition = true; const char *propContent = - target->GetLinkInterfaceDependentNumberMaxProperty( + gtgt->GetLinkInterfaceDependentNumberMaxProperty( propertyName, context->Config); return propContent ? propContent : ""; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index a7b0349..a9245c0 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -24,6 +24,7 @@ #include +#include #include "assert.h" //---------------------------------------------------------------------------- @@ -753,8 +754,7 @@ void cmGeneratorTarget::GetAutoUicOptions(std::vector &result, const std::string& config) const { const char *prop - = this->Target-> - GetLinkInterfaceDependentStringProperty("AUTOUIC_OPTIONS", + = this->GetLinkInterfaceDependentStringProperty("AUTOUIC_OPTIONS", config); if (!prop) { @@ -1537,7 +1537,7 @@ bool getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& config, cmTarget::CompatibleType, bool *) { - return tgt->Target->GetLinkInterfaceDependentBoolProperty(prop, config); + return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); } template<> @@ -1553,13 +1553,11 @@ const char * getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, assert(0 && "String compatibility check function called for boolean"); return 0; case cmTarget::StringType: - return tgt->Target->GetLinkInterfaceDependentStringProperty(prop, config); + return tgt->GetLinkInterfaceDependentStringProperty(prop, config); case cmTarget::NumberMinType: - return tgt->Target - ->GetLinkInterfaceDependentNumberMinProperty(prop, config); + return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config); case cmTarget::NumberMaxType: - return tgt->Target - ->GetLinkInterfaceDependentNumberMaxProperty(prop, config); + return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config); } assert(0 && "Unreachable!"); return 0; @@ -1762,6 +1760,405 @@ void cmGeneratorTarget::CheckPropertyCompatibility( } //---------------------------------------------------------------------------- +std::string compatibilityType(cmTarget::CompatibleType t) +{ + switch(t) + { + case cmTarget::BoolType: + return "Boolean compatibility"; + case cmTarget::StringType: + return "String compatibility"; + case cmTarget::NumberMaxType: + return "Numeric maximum compatibility"; + case cmTarget::NumberMinType: + return "Numeric minimum compatibility"; + } + assert(0 && "Unreachable!"); + return ""; +} + +//---------------------------------------------------------------------------- +std::string compatibilityAgree(cmTarget::CompatibleType t, bool dominant) +{ + switch(t) + { + case cmTarget::BoolType: + case cmTarget::StringType: + return dominant ? "(Disagree)\n" : "(Agree)\n"; + case cmTarget::NumberMaxType: + case cmTarget::NumberMinType: + return dominant ? "(Dominant)\n" : "(Ignored)\n"; + } + assert(0 && "Unreachable!"); + return ""; +} + +//---------------------------------------------------------------------------- +template +PropertyType getTypedProperty(cmTarget const* tgt, const std::string& prop); + +//---------------------------------------------------------------------------- +template<> +bool getTypedProperty(cmTarget const* tgt, const std::string& prop) +{ + return tgt->GetPropertyAsBool(prop); +} + +//---------------------------------------------------------------------------- +template<> +const char *getTypedProperty(cmTarget const* tgt, + const std::string& prop) +{ + return tgt->GetProperty(prop); +} + +template +std::string valueAsString(PropertyType); +template<> +std::string valueAsString(bool value) +{ + return value ? "TRUE" : "FALSE"; +} +template<> +std::string valueAsString(const char* value) +{ + return value ? value : "(unset)"; +} + +template +PropertyType impliedValue(PropertyType); +template<> +bool impliedValue(bool) +{ + return false; +} +template<> +const char* impliedValue(const char*) +{ + return ""; +} + +//---------------------------------------------------------------------------- +template +std::pair consistentProperty(PropertyType lhs, + PropertyType rhs, + cmTarget::CompatibleType t); + +//---------------------------------------------------------------------------- +template<> +std::pair consistentProperty(bool lhs, bool rhs, + cmTarget::CompatibleType) +{ + return std::make_pair(lhs == rhs, lhs); +} + +//---------------------------------------------------------------------------- +std::pair consistentStringProperty(const char *lhs, + const char *rhs) +{ + const bool b = strcmp(lhs, rhs) == 0; + return std::make_pair(b, b ? lhs : 0); +} + +//---------------------------------------------------------------------------- +std::pair consistentNumberProperty(const char *lhs, + const char *rhs, + cmTarget::CompatibleType t) +{ + char *pEnd; + + const char* const null_ptr = 0; + + long lnum = strtol(lhs, &pEnd, 0); + if (pEnd == lhs || *pEnd != '\0' || errno == ERANGE) + { + return std::pair(false, null_ptr); + } + + long rnum = strtol(rhs, &pEnd, 0); + if (pEnd == rhs || *pEnd != '\0' || errno == ERANGE) + { + return std::pair(false, null_ptr); + } + + if (t == cmTarget::NumberMaxType) + { + return std::make_pair(true, std::max(lnum, rnum) == lnum ? lhs : rhs); + } + else + { + return std::make_pair(true, std::min(lnum, rnum) == lnum ? lhs : rhs); + } +} + +//---------------------------------------------------------------------------- +template<> +std::pair consistentProperty(const char *lhs, + const char *rhs, + cmTarget::CompatibleType t) +{ + if (!lhs && !rhs) + { + return std::make_pair(true, lhs); + } + if (!lhs) + { + return std::make_pair(true, rhs); + } + if (!rhs) + { + return std::make_pair(true, lhs); + } + + const char* const null_ptr = 0; + + switch(t) + { + case cmTarget::BoolType: + assert(0 && "consistentProperty for strings called with BoolType"); + return std::pair(false, null_ptr); + case cmTarget::StringType: + return consistentStringProperty(lhs, rhs); + case cmTarget::NumberMinType: + case cmTarget::NumberMaxType: + return consistentNumberProperty(lhs, rhs, t); + } + assert(0 && "Unreachable!"); + return std::pair(false, null_ptr); +} + +//---------------------------------------------------------------------------- +template +PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, + const std::string &p, + const std::string& config, + const char *defaultValue, + cmTarget::CompatibleType t, + PropertyType *) +{ + PropertyType propContent = getTypedProperty(tgt, p); + const bool explicitlySet = tgt->GetProperties() + .find(p) + != tgt->GetProperties().end(); + const bool impliedByUse = + tgt->IsNullImpliedByLinkLibraries(p); + assert((impliedByUse ^ explicitlySet) + || (!impliedByUse && !explicitlySet)); + + std::vector const& deps = + tgt->GetLinkImplementationClosure(config); + + if(deps.empty()) + { + return propContent; + } + bool propInitialized = explicitlySet; + + std::string report = " * Target \""; + report += tgt->GetName(); + if (explicitlySet) + { + report += "\" has property content \""; + report += valueAsString(propContent); + report += "\"\n"; + } + else if (impliedByUse) + { + report += "\" property is implied by use.\n"; + } + else + { + report += "\" property not set.\n"; + } + + std::string interfaceProperty = "INTERFACE_" + p; + for(std::vector::const_iterator li = + deps.begin(); + li != deps.end(); ++li) + { + // An error should be reported if one dependency + // has INTERFACE_POSITION_INDEPENDENT_CODE ON and the other + // has INTERFACE_POSITION_INDEPENDENT_CODE OFF, or if the + // target itself has a POSITION_INDEPENDENT_CODE which disagrees + // with a dependency. + + cmTarget const* theTarget = *li; + + const bool ifaceIsSet = theTarget->GetProperties() + .find(interfaceProperty) + != theTarget->GetProperties().end(); + PropertyType ifacePropContent = + getTypedProperty(theTarget, + interfaceProperty); + + std::string reportEntry; + if (ifaceIsSet) + { + reportEntry += " * Target \""; + reportEntry += theTarget->GetName(); + reportEntry += "\" property value \""; + reportEntry += valueAsString(ifacePropContent); + reportEntry += "\" "; + } + + if (explicitlySet) + { + if (ifaceIsSet) + { + std::pair consistent = + consistentProperty(propContent, + ifacePropContent, t); + report += reportEntry; + report += compatibilityAgree(t, propContent != consistent.second); + if (!consistent.first) + { + std::ostringstream e; + e << "Property " << p << " on target \"" + << tgt->GetName() << "\" does\nnot match the " + "INTERFACE_" << p << " property requirement\nof " + "dependency \"" << theTarget->GetName() << "\".\n"; + cmSystemTools::Error(e.str().c_str()); + break; + } + else + { + propContent = consistent.second; + continue; + } + } + else + { + // Explicitly set on target and not set in iface. Can't disagree. + continue; + } + } + else if (impliedByUse) + { + propContent = impliedValue(propContent); + + if (ifaceIsSet) + { + std::pair consistent = + consistentProperty(propContent, + ifacePropContent, t); + report += reportEntry; + report += compatibilityAgree(t, propContent != consistent.second); + if (!consistent.first) + { + std::ostringstream e; + e << "Property " << p << " on target \"" + << tgt->GetName() << "\" is\nimplied to be " << defaultValue + << " because it was used to determine the link libraries\n" + "already. The INTERFACE_" << p << " property on\ndependency \"" + << theTarget->GetName() << "\" is in conflict.\n"; + cmSystemTools::Error(e.str().c_str()); + break; + } + else + { + propContent = consistent.second; + continue; + } + } + else + { + // Implicitly set on target and not set in iface. Can't disagree. + continue; + } + } + else + { + if (ifaceIsSet) + { + if (propInitialized) + { + std::pair consistent = + consistentProperty(propContent, + ifacePropContent, t); + report += reportEntry; + report += compatibilityAgree(t, propContent != consistent.second); + if (!consistent.first) + { + std::ostringstream e; + e << "The INTERFACE_" << p << " property of \"" + << theTarget->GetName() << "\" does\nnot agree with the value " + "of " << p << " already determined\nfor \"" + << tgt->GetName() << "\".\n"; + cmSystemTools::Error(e.str().c_str()); + break; + } + else + { + propContent = consistent.second; + continue; + } + } + else + { + report += reportEntry + "(Interface set)\n"; + propContent = ifacePropContent; + propInitialized = true; + } + } + else + { + // Not set. Nothing to agree on. + continue; + } + } + } + + tgt->ReportPropertyOrigin(p, valueAsString(propContent), + report, compatibilityType(t)); + return propContent; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::GetLinkInterfaceDependentBoolProperty( + const std::string &p, const std::string& config) const +{ + return checkInterfacePropertyCompatibility(this->Target, p, config, + "FALSE", + cmTarget::BoolType, 0); +} + +//---------------------------------------------------------------------------- +const char* cmGeneratorTarget::GetLinkInterfaceDependentStringProperty( + const std::string &p, + const std::string& config) const +{ + return checkInterfacePropertyCompatibility(this->Target, + p, + config, + "empty", + cmTarget::StringType, 0); +} + +//---------------------------------------------------------------------------- +const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMinProperty( + const std::string &p, + const std::string& config) const +{ + return checkInterfacePropertyCompatibility(this->Target, + p, + config, + "empty", + cmTarget::NumberMinType, 0); +} + +//---------------------------------------------------------------------------- +const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMaxProperty( + const std::string &p, + const std::string& config) const +{ + return checkInterfacePropertyCompatibility(this->Target, + p, + config, + "empty", + cmTarget::NumberMaxType, 0); +} + +//---------------------------------------------------------------------------- cmComputeLinkInformation* cmGeneratorTarget::GetLinkInformation(const std::string& config) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index ae86e19..d65b1ef 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -96,6 +96,17 @@ public: bool IsLinkInterfaceDependentNumberMaxProperty(const std::string &p, const std::string& config) const; + bool GetLinkInterfaceDependentBoolProperty(const std::string &p, + const std::string& config) const; + + const char *GetLinkInterfaceDependentStringProperty(const std::string &p, + const std::string& config) const; + const char *GetLinkInterfaceDependentNumberMinProperty(const std::string &p, + const std::string& config) const; + const char *GetLinkInterfaceDependentNumberMaxProperty(const std::string &p, + const std::string& config) const; + + /** Get the full path to the target according to the settings in its makefile and the configuration type. */ std::string GetFullPath(const std::string& config="", bool implib = false, diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index eaf812f..3ab501d 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2059,7 +2059,9 @@ void cmLocalGenerator::AddCMP0018Flags(std::string &flags, return; } - if (target->GetLinkInterfaceDependentBoolProperty( + cmGeneratorTarget* gtgt = + this->GlobalGenerator->GetGeneratorTarget(target); + if (gtgt->GetLinkInterfaceDependentBoolProperty( "POSITION_INDEPENDENT_CODE", config)) { diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index a72b176..f1ba2f4 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -547,8 +547,11 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target) { qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR"); } + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); if (const char *targetQtVersion = - target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", "")) + gtgt->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", "")) { qtVersion = targetQtVersion; } @@ -1150,6 +1153,9 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) std::string cmQtAutoGenerators::GetRccExecutable(cmTarget const* target) { + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); cmMakefile *makefile = target->GetMakefile(); const char *qtVersion = makefile->GetDefinition("_target_qt_version"); if (!qtVersion) @@ -1160,8 +1166,7 @@ std::string cmQtAutoGenerators::GetRccExecutable(cmTarget const* target) qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR"); } if (const char *targetQtVersion = - target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", - "")) + gtgt->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", "")) { qtVersion = targetQtVersion; } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index b165545..1fa62e7 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4536,141 +4536,6 @@ bool cmTarget::IsNullImpliedByLinkLibraries(const std::string &p) const } //---------------------------------------------------------------------------- -template -PropertyType getTypedProperty(cmTarget const* tgt, const std::string& prop); - -//---------------------------------------------------------------------------- -template<> -bool getTypedProperty(cmTarget const* tgt, const std::string& prop) -{ - return tgt->GetPropertyAsBool(prop); -} - -//---------------------------------------------------------------------------- -template<> -const char *getTypedProperty(cmTarget const* tgt, - const std::string& prop) -{ - return tgt->GetProperty(prop); -} - -//---------------------------------------------------------------------------- -template -std::pair consistentProperty(PropertyType lhs, - PropertyType rhs, - cmTarget::CompatibleType t); - -//---------------------------------------------------------------------------- -template<> -std::pair consistentProperty(bool lhs, bool rhs, - cmTarget::CompatibleType) -{ - return std::make_pair(lhs == rhs, lhs); -} - -//---------------------------------------------------------------------------- -std::pair consistentStringProperty(const char *lhs, - const char *rhs) -{ - const bool b = strcmp(lhs, rhs) == 0; - return std::make_pair(b, b ? lhs : 0); -} - -//---------------------------------------------------------------------------- -std::pair consistentNumberProperty(const char *lhs, - const char *rhs, - cmTarget::CompatibleType t) -{ - char *pEnd; - - const char* const null_ptr = 0; - - long lnum = strtol(lhs, &pEnd, 0); - if (pEnd == lhs || *pEnd != '\0' || errno == ERANGE) - { - return std::pair(false, null_ptr); - } - - long rnum = strtol(rhs, &pEnd, 0); - if (pEnd == rhs || *pEnd != '\0' || errno == ERANGE) - { - return std::pair(false, null_ptr); - } - - if (t == cmTarget::NumberMaxType) - { - return std::make_pair(true, std::max(lnum, rnum) == lnum ? lhs : rhs); - } - else - { - return std::make_pair(true, std::min(lnum, rnum) == lnum ? lhs : rhs); - } -} - -//---------------------------------------------------------------------------- -template<> -std::pair consistentProperty(const char *lhs, - const char *rhs, - cmTarget::CompatibleType t) -{ - if (!lhs && !rhs) - { - return std::make_pair(true, lhs); - } - if (!lhs) - { - return std::make_pair(true, rhs); - } - if (!rhs) - { - return std::make_pair(true, lhs); - } - - const char* const null_ptr = 0; - - switch(t) - { - case cmTarget::BoolType: - assert(0 && "consistentProperty for strings called with BoolType"); - return std::pair(false, null_ptr); - case cmTarget::StringType: - return consistentStringProperty(lhs, rhs); - case cmTarget::NumberMinType: - case cmTarget::NumberMaxType: - return consistentNumberProperty(lhs, rhs, t); - } - assert(0 && "Unreachable!"); - return std::pair(false, null_ptr); -} - -template -PropertyType impliedValue(PropertyType); -template<> -bool impliedValue(bool) -{ - return false; -} -template<> -const char* impliedValue(const char*) -{ - return ""; -} - - -template -std::string valueAsString(PropertyType); -template<> -std::string valueAsString(bool value) -{ - return value ? "TRUE" : "FALSE"; -} -template<> -std::string valueAsString(const char* value) -{ - return value ? value : "(unset)"; -} - -//---------------------------------------------------------------------------- void cmTarget::ReportPropertyOrigin(const std::string &p, const std::string &result, @@ -4711,270 +4576,6 @@ cmTarget::ReportPropertyOrigin(const std::string &p, } //---------------------------------------------------------------------------- -std::string compatibilityType(cmTarget::CompatibleType t) -{ - switch(t) - { - case cmTarget::BoolType: - return "Boolean compatibility"; - case cmTarget::StringType: - return "String compatibility"; - case cmTarget::NumberMaxType: - return "Numeric maximum compatibility"; - case cmTarget::NumberMinType: - return "Numeric minimum compatibility"; - } - assert(0 && "Unreachable!"); - return ""; -} - -//---------------------------------------------------------------------------- -std::string compatibilityAgree(cmTarget::CompatibleType t, bool dominant) -{ - switch(t) - { - case cmTarget::BoolType: - case cmTarget::StringType: - return dominant ? "(Disagree)\n" : "(Agree)\n"; - case cmTarget::NumberMaxType: - case cmTarget::NumberMinType: - return dominant ? "(Dominant)\n" : "(Ignored)\n"; - } - assert(0 && "Unreachable!"); - return ""; -} - -//---------------------------------------------------------------------------- -template -PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, - const std::string &p, - const std::string& config, - const char *defaultValue, - cmTarget::CompatibleType t, - PropertyType *) -{ - PropertyType propContent = getTypedProperty(tgt, p); - const bool explicitlySet = tgt->GetProperties() - .find(p) - != tgt->GetProperties().end(); - const bool impliedByUse = - tgt->IsNullImpliedByLinkLibraries(p); - assert((impliedByUse ^ explicitlySet) - || (!impliedByUse && !explicitlySet)); - - std::vector const& deps = - tgt->GetLinkImplementationClosure(config); - - if(deps.empty()) - { - return propContent; - } - bool propInitialized = explicitlySet; - - std::string report = " * Target \""; - report += tgt->GetName(); - if (explicitlySet) - { - report += "\" has property content \""; - report += valueAsString(propContent); - report += "\"\n"; - } - else if (impliedByUse) - { - report += "\" property is implied by use.\n"; - } - else - { - report += "\" property not set.\n"; - } - - std::string interfaceProperty = "INTERFACE_" + p; - for(std::vector::const_iterator li = - deps.begin(); - li != deps.end(); ++li) - { - // An error should be reported if one dependency - // has INTERFACE_POSITION_INDEPENDENT_CODE ON and the other - // has INTERFACE_POSITION_INDEPENDENT_CODE OFF, or if the - // target itself has a POSITION_INDEPENDENT_CODE which disagrees - // with a dependency. - - cmTarget const* theTarget = *li; - - const bool ifaceIsSet = theTarget->GetProperties() - .find(interfaceProperty) - != theTarget->GetProperties().end(); - PropertyType ifacePropContent = - getTypedProperty(theTarget, - interfaceProperty); - - std::string reportEntry; - if (ifaceIsSet) - { - reportEntry += " * Target \""; - reportEntry += theTarget->GetName(); - reportEntry += "\" property value \""; - reportEntry += valueAsString(ifacePropContent); - reportEntry += "\" "; - } - - if (explicitlySet) - { - if (ifaceIsSet) - { - std::pair consistent = - consistentProperty(propContent, - ifacePropContent, t); - report += reportEntry; - report += compatibilityAgree(t, propContent != consistent.second); - if (!consistent.first) - { - std::ostringstream e; - e << "Property " << p << " on target \"" - << tgt->GetName() << "\" does\nnot match the " - "INTERFACE_" << p << " property requirement\nof " - "dependency \"" << theTarget->GetName() << "\".\n"; - cmSystemTools::Error(e.str().c_str()); - break; - } - else - { - propContent = consistent.second; - continue; - } - } - else - { - // Explicitly set on target and not set in iface. Can't disagree. - continue; - } - } - else if (impliedByUse) - { - propContent = impliedValue(propContent); - - if (ifaceIsSet) - { - std::pair consistent = - consistentProperty(propContent, - ifacePropContent, t); - report += reportEntry; - report += compatibilityAgree(t, propContent != consistent.second); - if (!consistent.first) - { - std::ostringstream e; - e << "Property " << p << " on target \"" - << tgt->GetName() << "\" is\nimplied to be " << defaultValue - << " because it was used to determine the link libraries\n" - "already. The INTERFACE_" << p << " property on\ndependency \"" - << theTarget->GetName() << "\" is in conflict.\n"; - cmSystemTools::Error(e.str().c_str()); - break; - } - else - { - propContent = consistent.second; - continue; - } - } - else - { - // Implicitly set on target and not set in iface. Can't disagree. - continue; - } - } - else - { - if (ifaceIsSet) - { - if (propInitialized) - { - std::pair consistent = - consistentProperty(propContent, - ifacePropContent, t); - report += reportEntry; - report += compatibilityAgree(t, propContent != consistent.second); - if (!consistent.first) - { - std::ostringstream e; - e << "The INTERFACE_" << p << " property of \"" - << theTarget->GetName() << "\" does\nnot agree with the value " - "of " << p << " already determined\nfor \"" - << tgt->GetName() << "\".\n"; - cmSystemTools::Error(e.str().c_str()); - break; - } - else - { - propContent = consistent.second; - continue; - } - } - else - { - report += reportEntry + "(Interface set)\n"; - propContent = ifacePropContent; - propInitialized = true; - } - } - else - { - // Not set. Nothing to agree on. - continue; - } - } - } - - tgt->ReportPropertyOrigin(p, valueAsString(propContent), - report, compatibilityType(t)); - return propContent; -} - -//---------------------------------------------------------------------------- -bool cmTarget::GetLinkInterfaceDependentBoolProperty(const std::string &p, - const std::string& config) const -{ - return checkInterfacePropertyCompatibility(this, p, config, "FALSE", - BoolType, 0); -} - -//---------------------------------------------------------------------------- -const char * cmTarget::GetLinkInterfaceDependentStringProperty( - const std::string &p, - const std::string& config) const -{ - return checkInterfacePropertyCompatibility(this, - p, - config, - "empty", - StringType, 0); -} - -//---------------------------------------------------------------------------- -const char * cmTarget::GetLinkInterfaceDependentNumberMinProperty( - const std::string &p, - const std::string& config) const -{ - return checkInterfacePropertyCompatibility(this, - p, - config, - "empty", - NumberMinType, 0); -} - -//---------------------------------------------------------------------------- -const char * cmTarget::GetLinkInterfaceDependentNumberMaxProperty( - const std::string &p, - const std::string& config) const -{ - return checkInterfacePropertyCompatibility(this, - p, - config, - "empty", - NumberMaxType, 0); -} - -//---------------------------------------------------------------------------- void cmTarget::GetObjectLibrariesCMP0026(std::vector& objlibs) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 8af74ef..b544b0b 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -553,15 +553,6 @@ public: const std::string& config) const; bool IsNullImpliedByLinkLibraries(const std::string &p) const; - bool GetLinkInterfaceDependentBoolProperty(const std::string &p, - const std::string& config) const; - - const char *GetLinkInterfaceDependentStringProperty(const std::string &p, - const std::string& config) const; - const char *GetLinkInterfaceDependentNumberMinProperty(const std::string &p, - const std::string& config) const; - const char *GetLinkInterfaceDependentNumberMaxProperty(const std::string &p, - const std::string& config) const; std::string GetDebugGeneratorExpressions(const std::string &value, cmTarget::LinkLibraryType llt) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=38d4ba3564b9a37f8042888ffd63bf736852b6b8 commit 38d4ba3564b9a37f8042888ffd63bf736852b6b8 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:43 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 18:20:44 2015 +0200 cmGeneratorTarget: Port internal API to cmGeneratorTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 1f3effb..a7b0349 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1525,23 +1525,23 @@ bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty( } template -PropertyType getLinkInterfaceDependentProperty(cmTarget const* tgt, +PropertyType getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, cmTarget::CompatibleType, PropertyType *); template<> -bool getLinkInterfaceDependentProperty(cmTarget const* tgt, +bool getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, cmTarget::CompatibleType, bool *) { - return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); + return tgt->Target->GetLinkInterfaceDependentBoolProperty(prop, config); } template<> -const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, +const char * getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, cmTarget::CompatibleType t, @@ -1553,11 +1553,13 @@ const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, assert(0 && "String compatibility check function called for boolean"); return 0; case cmTarget::StringType: - return tgt->GetLinkInterfaceDependentStringProperty(prop, config); + return tgt->Target->GetLinkInterfaceDependentStringProperty(prop, config); case cmTarget::NumberMinType: - return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config); + return tgt->Target + ->GetLinkInterfaceDependentNumberMinProperty(prop, config); case cmTarget::NumberMaxType: - return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config); + return tgt->Target + ->GetLinkInterfaceDependentNumberMaxProperty(prop, config); } assert(0 && "Unreachable!"); return 0; @@ -1565,7 +1567,7 @@ const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, //---------------------------------------------------------------------------- template -void checkPropertyConsistency(cmTarget const* depender, +void checkPropertyConsistency(cmGeneratorTarget const* depender, cmTarget const* dependee, const std::string& propName, std::set &emitted, @@ -1597,7 +1599,7 @@ void checkPropertyConsistency(cmTarget const* depender, << *pi << "\" listed in its " << propName << " property. " "This is not allowed. Only user-defined properties may appear " "listed in the " << propName << " property."; - depender->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, e.str()); + depender->GetLocalGenerator()->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } if(emitted.insert(*pi).second) @@ -1681,14 +1683,14 @@ void cmGeneratorTarget::CheckPropertyCompatibility( continue; } - checkPropertyConsistency(this->Target, li->Target, + checkPropertyConsistency(this, li->Target, strBool, emittedBools, config, cmTarget::BoolType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; } - checkPropertyConsistency(this->Target, li->Target, + checkPropertyConsistency(this, li->Target, strString, emittedStrings, config, cmTarget::StringType, 0); @@ -1696,7 +1698,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( { return; } - checkPropertyConsistency(this->Target, li->Target, + checkPropertyConsistency(this, li->Target, strNumMin, emittedMinNumbers, config, cmTarget::NumberMinType, 0); @@ -1704,7 +1706,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( { return; } - checkPropertyConsistency(this->Target, li->Target, + checkPropertyConsistency(this, li->Target, strNumMax, emittedMaxNumbers, config, cmTarget::NumberMaxType, 0); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=90bad039c44195b742740613a34b90697254fdd2 commit 90bad039c44195b742740613a34b90697254fdd2 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:43 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 18:20:44 2015 +0200 cmGeneratorTarget: Move CheckPropertyCompatibility from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 845c052..1f3effb 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1524,6 +1524,240 @@ bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty( return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0; } +template +PropertyType getLinkInterfaceDependentProperty(cmTarget const* tgt, + const std::string& prop, + const std::string& config, + cmTarget::CompatibleType, + PropertyType *); + +template<> +bool getLinkInterfaceDependentProperty(cmTarget const* tgt, + const std::string& prop, + const std::string& config, + cmTarget::CompatibleType, bool *) +{ + return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); +} + +template<> +const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, + const std::string& prop, + const std::string& config, + cmTarget::CompatibleType t, + const char **) +{ + switch(t) + { + case cmTarget::BoolType: + assert(0 && "String compatibility check function called for boolean"); + return 0; + case cmTarget::StringType: + return tgt->GetLinkInterfaceDependentStringProperty(prop, config); + case cmTarget::NumberMinType: + return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config); + case cmTarget::NumberMaxType: + return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config); + } + assert(0 && "Unreachable!"); + return 0; +} + +//---------------------------------------------------------------------------- +template +void checkPropertyConsistency(cmTarget const* depender, + cmTarget const* dependee, + const std::string& propName, + std::set &emitted, + const std::string& config, + cmTarget::CompatibleType t, + PropertyType *) +{ + const char *prop = dependee->GetProperty(propName); + if (!prop) + { + return; + } + + std::vector props; + cmSystemTools::ExpandListArgument(prop, props); + std::string pdir = + dependee->GetMakefile()->GetRequiredDefinition("CMAKE_ROOT"); + pdir += "/Help/prop_tgt/"; + + for(std::vector::iterator pi = props.begin(); + pi != props.end(); ++pi) + { + std::string pname = cmSystemTools::HelpFileName(*pi); + std::string pfile = pdir + pname + ".rst"; + if(cmSystemTools::FileExists(pfile.c_str(), true)) + { + std::ostringstream e; + e << "Target \"" << dependee->GetName() << "\" has property \"" + << *pi << "\" listed in its " << propName << " property. " + "This is not allowed. Only user-defined properties may appear " + "listed in the " << propName << " property."; + depender->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, e.str()); + return; + } + if(emitted.insert(*pi).second) + { + getLinkInterfaceDependentProperty(depender, *pi, config, + t, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + } + } +} + +static std::string intersect(const std::set &s1, + const std::set &s2) +{ + std::set intersect; + std::set_intersection(s1.begin(),s1.end(), + s2.begin(),s2.end(), + std::inserter(intersect,intersect.begin())); + if (!intersect.empty()) + { + return *intersect.begin(); + } + return ""; +} + +static std::string intersect(const std::set &s1, + const std::set &s2, + const std::set &s3) +{ + std::string result; + result = intersect(s1, s2); + if (!result.empty()) + return result; + result = intersect(s1, s3); + if (!result.empty()) + return result; + return intersect(s2, s3); +} + +static std::string intersect(const std::set &s1, + const std::set &s2, + const std::set &s3, + const std::set &s4) +{ + std::string result; + result = intersect(s1, s2); + if (!result.empty()) + return result; + result = intersect(s1, s3); + if (!result.empty()) + return result; + result = intersect(s1, s4); + if (!result.empty()) + return result; + return intersect(s2, s3, s4); +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::CheckPropertyCompatibility( + cmComputeLinkInformation *info, const std::string& config) const +{ + const cmComputeLinkInformation::ItemVector &deps = info->GetItems(); + + std::set emittedBools; + static std::string strBool = "COMPATIBLE_INTERFACE_BOOL"; + std::set emittedStrings; + static std::string strString = "COMPATIBLE_INTERFACE_STRING"; + std::set emittedMinNumbers; + static std::string strNumMin = "COMPATIBLE_INTERFACE_NUMBER_MIN"; + std::set emittedMaxNumbers; + static std::string strNumMax = "COMPATIBLE_INTERFACE_NUMBER_MAX"; + + for(cmComputeLinkInformation::ItemVector::const_iterator li = + deps.begin(); li != deps.end(); ++li) + { + if (!li->Target) + { + continue; + } + + checkPropertyConsistency(this->Target, li->Target, + strBool, + emittedBools, config, cmTarget::BoolType, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + checkPropertyConsistency(this->Target, li->Target, + strString, + emittedStrings, config, + cmTarget::StringType, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + checkPropertyConsistency(this->Target, li->Target, + strNumMin, + emittedMinNumbers, config, + cmTarget::NumberMinType, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + checkPropertyConsistency(this->Target, li->Target, + strNumMax, + emittedMaxNumbers, config, + cmTarget::NumberMaxType, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + } + + std::string prop = intersect(emittedBools, + emittedStrings, + emittedMinNumbers, + emittedMaxNumbers); + + if (!prop.empty()) + { + // Use a sorted std::vector to keep the error message sorted. + std::vector props; + std::set::const_iterator i = emittedBools.find(prop); + if (i != emittedBools.end()) + { + props.push_back(strBool); + } + i = emittedStrings.find(prop); + if (i != emittedStrings.end()) + { + props.push_back(strString); + } + i = emittedMinNumbers.find(prop); + if (i != emittedMinNumbers.end()) + { + props.push_back(strNumMin); + } + i = emittedMaxNumbers.find(prop); + if (i != emittedMaxNumbers.end()) + { + props.push_back(strNumMax); + } + std::sort(props.begin(), props.end()); + + std::string propsString = cmJoin(cmMakeRange(props).retreat(1), ", "); + propsString += " and the " + props.back(); + + std::ostringstream e; + e << "Property \"" << prop << "\" appears in both the " + << propsString << + " property in the dependencies of target \"" << this->GetName() << + "\". This is not allowed. A property may only require compatibility " + "in a boolean interpretation, a numeric minimum, a numeric maximum or a " + "string interpretation, but not a mixture."; + this->LocalGenerator->IssueMessage(cmake::FATAL_ERROR, e.str()); + } +} //---------------------------------------------------------------------------- cmComputeLinkInformation* @@ -1550,7 +1784,7 @@ cmGeneratorTarget::GetLinkInformation(const std::string& config) const if (info) { - this->Target->CheckPropertyCompatibility(info, config); + this->CheckPropertyCompatibility(info, config); } } return i->second; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index e53f098..ae86e19 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -222,6 +222,9 @@ private: cmTargetLinkInformationMap; mutable cmTargetLinkInformationMap LinkInformation; + void CheckPropertyCompatibility(cmComputeLinkInformation *info, + const std::string& config) const; + cmGeneratorTarget(cmGeneratorTarget const&); void operator=(cmGeneratorTarget const&); }; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index d8904ea..b165545 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4554,23 +4554,16 @@ const char *getTypedProperty(cmTarget const* tgt, return tgt->GetProperty(prop); } -enum CompatibleType -{ - BoolType, - StringType, - NumberMinType, - NumberMaxType -}; - //---------------------------------------------------------------------------- template std::pair consistentProperty(PropertyType lhs, PropertyType rhs, - CompatibleType t); + cmTarget::CompatibleType t); //---------------------------------------------------------------------------- template<> -std::pair consistentProperty(bool lhs, bool rhs, CompatibleType) +std::pair consistentProperty(bool lhs, bool rhs, + cmTarget::CompatibleType) { return std::make_pair(lhs == rhs, lhs); } @@ -4585,8 +4578,8 @@ std::pair consistentStringProperty(const char *lhs, //---------------------------------------------------------------------------- std::pair consistentNumberProperty(const char *lhs, - const char *rhs, - CompatibleType t) + const char *rhs, + cmTarget::CompatibleType t) { char *pEnd; @@ -4604,7 +4597,7 @@ std::pair consistentNumberProperty(const char *lhs, return std::pair(false, null_ptr); } - if (t == NumberMaxType) + if (t == cmTarget::NumberMaxType) { return std::make_pair(true, std::max(lnum, rnum) == lnum ? lhs : rhs); } @@ -4618,7 +4611,7 @@ std::pair consistentNumberProperty(const char *lhs, template<> std::pair consistentProperty(const char *lhs, const char *rhs, - CompatibleType t) + cmTarget::CompatibleType t) { if (!lhs && !rhs) { @@ -4637,13 +4630,13 @@ std::pair consistentProperty(const char *lhs, switch(t) { - case BoolType: + case cmTarget::BoolType: assert(0 && "consistentProperty for strings called with BoolType"); return std::pair(false, null_ptr); - case StringType: + case cmTarget::StringType: return consistentStringProperty(lhs, rhs); - case NumberMinType: - case NumberMaxType: + case cmTarget::NumberMinType: + case cmTarget::NumberMaxType: return consistentNumberProperty(lhs, rhs, t); } assert(0 && "Unreachable!"); @@ -4718,17 +4711,17 @@ cmTarget::ReportPropertyOrigin(const std::string &p, } //---------------------------------------------------------------------------- -std::string compatibilityType(CompatibleType t) +std::string compatibilityType(cmTarget::CompatibleType t) { switch(t) { - case BoolType: + case cmTarget::BoolType: return "Boolean compatibility"; - case StringType: + case cmTarget::StringType: return "String compatibility"; - case NumberMaxType: + case cmTarget::NumberMaxType: return "Numeric maximum compatibility"; - case NumberMinType: + case cmTarget::NumberMinType: return "Numeric minimum compatibility"; } assert(0 && "Unreachable!"); @@ -4736,15 +4729,15 @@ std::string compatibilityType(CompatibleType t) } //---------------------------------------------------------------------------- -std::string compatibilityAgree(CompatibleType t, bool dominant) +std::string compatibilityAgree(cmTarget::CompatibleType t, bool dominant) { switch(t) { - case BoolType: - case StringType: + case cmTarget::BoolType: + case cmTarget::StringType: return dominant ? "(Disagree)\n" : "(Agree)\n"; - case NumberMaxType: - case NumberMinType: + case cmTarget::NumberMaxType: + case cmTarget::NumberMinType: return dominant ? "(Dominant)\n" : "(Ignored)\n"; } assert(0 && "Unreachable!"); @@ -4757,7 +4750,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, const std::string &p, const std::string& config, const char *defaultValue, - CompatibleType t, + cmTarget::CompatibleType t, PropertyType *) { PropertyType propContent = getTypedProperty(tgt, p); @@ -6224,240 +6217,6 @@ std::string cmTarget::CheckCMP0004(std::string const& item) const return lib; } -template -PropertyType getLinkInterfaceDependentProperty(cmTarget const* tgt, - const std::string& prop, - const std::string& config, - CompatibleType, - PropertyType *); - -template<> -bool getLinkInterfaceDependentProperty(cmTarget const* tgt, - const std::string& prop, - const std::string& config, - CompatibleType, bool *) -{ - return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); -} - -template<> -const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, - const std::string& prop, - const std::string& config, - CompatibleType t, - const char **) -{ - switch(t) - { - case BoolType: - assert(0 && "String compatibility check function called for boolean"); - return 0; - case StringType: - return tgt->GetLinkInterfaceDependentStringProperty(prop, config); - case NumberMinType: - return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config); - case NumberMaxType: - return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config); - } - assert(0 && "Unreachable!"); - return 0; -} - -//---------------------------------------------------------------------------- -template -void checkPropertyConsistency(cmTarget const* depender, - cmTarget const* dependee, - const std::string& propName, - std::set &emitted, - const std::string& config, - CompatibleType t, - PropertyType *) -{ - const char *prop = dependee->GetProperty(propName); - if (!prop) - { - return; - } - - std::vector props; - cmSystemTools::ExpandListArgument(prop, props); - std::string pdir = - dependee->GetMakefile()->GetRequiredDefinition("CMAKE_ROOT"); - pdir += "/Help/prop_tgt/"; - - for(std::vector::iterator pi = props.begin(); - pi != props.end(); ++pi) - { - std::string pname = cmSystemTools::HelpFileName(*pi); - std::string pfile = pdir + pname + ".rst"; - if(cmSystemTools::FileExists(pfile.c_str(), true)) - { - std::ostringstream e; - e << "Target \"" << dependee->GetName() << "\" has property \"" - << *pi << "\" listed in its " << propName << " property. " - "This is not allowed. Only user-defined properties may appear " - "listed in the " << propName << " property."; - depender->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, e.str()); - return; - } - if(emitted.insert(*pi).second) - { - getLinkInterfaceDependentProperty(depender, *pi, config, - t, 0); - if (cmSystemTools::GetErrorOccuredFlag()) - { - return; - } - } - } -} - -static std::string intersect(const std::set &s1, - const std::set &s2) -{ - std::set intersect; - std::set_intersection(s1.begin(),s1.end(), - s2.begin(),s2.end(), - std::inserter(intersect,intersect.begin())); - if (!intersect.empty()) - { - return *intersect.begin(); - } - return ""; -} -static std::string intersect(const std::set &s1, - const std::set &s2, - const std::set &s3) -{ - std::string result; - result = intersect(s1, s2); - if (!result.empty()) - return result; - result = intersect(s1, s3); - if (!result.empty()) - return result; - return intersect(s2, s3); -} -static std::string intersect(const std::set &s1, - const std::set &s2, - const std::set &s3, - const std::set &s4) -{ - std::string result; - result = intersect(s1, s2); - if (!result.empty()) - return result; - result = intersect(s1, s3); - if (!result.empty()) - return result; - result = intersect(s1, s4); - if (!result.empty()) - return result; - return intersect(s2, s3, s4); -} - -//---------------------------------------------------------------------------- -void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, - const std::string& config) const -{ - const cmComputeLinkInformation::ItemVector &deps = info->GetItems(); - - std::set emittedBools; - static std::string strBool = "COMPATIBLE_INTERFACE_BOOL"; - std::set emittedStrings; - static std::string strString = "COMPATIBLE_INTERFACE_STRING"; - std::set emittedMinNumbers; - static std::string strNumMin = "COMPATIBLE_INTERFACE_NUMBER_MIN"; - std::set emittedMaxNumbers; - static std::string strNumMax = "COMPATIBLE_INTERFACE_NUMBER_MAX"; - - for(cmComputeLinkInformation::ItemVector::const_iterator li = - deps.begin(); - li != deps.end(); ++li) - { - if (!li->Target) - { - continue; - } - - checkPropertyConsistency(this, li->Target, - strBool, - emittedBools, config, BoolType, 0); - if (cmSystemTools::GetErrorOccuredFlag()) - { - return; - } - checkPropertyConsistency(this, li->Target, - strString, - emittedStrings, config, - StringType, 0); - if (cmSystemTools::GetErrorOccuredFlag()) - { - return; - } - checkPropertyConsistency(this, li->Target, - strNumMin, - emittedMinNumbers, config, - NumberMinType, 0); - if (cmSystemTools::GetErrorOccuredFlag()) - { - return; - } - checkPropertyConsistency(this, li->Target, - strNumMax, - emittedMaxNumbers, config, - NumberMaxType, 0); - if (cmSystemTools::GetErrorOccuredFlag()) - { - return; - } - } - - std::string prop = intersect(emittedBools, - emittedStrings, - emittedMinNumbers, - emittedMaxNumbers); - - if (!prop.empty()) - { - // Use a sorted std::vector to keep the error message sorted. - std::vector props; - std::set::const_iterator i = emittedBools.find(prop); - if (i != emittedBools.end()) - { - props.push_back(strBool); - } - i = emittedStrings.find(prop); - if (i != emittedStrings.end()) - { - props.push_back(strString); - } - i = emittedMinNumbers.find(prop); - if (i != emittedMinNumbers.end()) - { - props.push_back(strNumMin); - } - i = emittedMaxNumbers.find(prop); - if (i != emittedMaxNumbers.end()) - { - props.push_back(strNumMax); - } - std::sort(props.begin(), props.end()); - - std::string propsString = cmJoin(cmMakeRange(props).retreat(1), ", "); - propsString += " and the " + props.back(); - - std::ostringstream e; - e << "Property \"" << prop << "\" appears in both the " - << propsString << - " property in the dependencies of target \"" << this->GetName() << - "\". This is not allowed. A property may only require compatibility " - "in a boolean interpretation, a numeric minimum, a numeric maximum or a " - "string interpretation, but not a mixture."; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); - } -} - //---------------------------------------------------------------------------- std::string cmTarget::GetFrameworkDirectory(const std::string& config, bool rootDir) const diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e3410aa..8af74ef 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -590,6 +590,14 @@ public: return this->LinkLibrariesForVS6;} #endif + enum CompatibleType + { + BoolType, + StringType, + NumberMinType, + NumberMaxType + }; + private: bool HandleLocationPropertyPolicy(cmMakefile* context) const; @@ -754,9 +762,6 @@ private: struct CompileInfo; CompileInfo const* GetCompileInfo(const std::string& config) const; - void CheckPropertyCompatibility(cmComputeLinkInformation *info, - const std::string& config) const; - LinkInterface const* GetImportLinkInterface(const std::string& config, cmTarget const* head, bool usage_requirements_only) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=803a7982b4403c690d7b7fa8c49d00a5abae3471 commit 803a7982b4403c690d7b7fa8c49d00a5abae3471 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:42 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 18:20:44 2015 +0200 cmGeneratorTarget: Move GetLinkInformation from cmTarget diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 26ca375..4840e89 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -276,7 +276,8 @@ std::string cmCommonTargetGenerator::GetFrameworkFlags(std::string const& l) std::string flags; const char* cfg = this->LocalGenerator->GetConfigName().c_str(); - if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(cfg)) + if(cmComputeLinkInformation* cli = + this->GeneratorTarget->GetLinkInformation(cfg)) { std::vector const& frameworks = cli->GetFrameworkPaths(); for(std::vector::const_iterator i = frameworks.begin(); @@ -384,7 +385,7 @@ cmCommonTargetGenerator::GetLinkedTargetDirectories() const std::vector dirs; std::set emitted; if (cmComputeLinkInformation* cli = - this->Target->GetLinkInformation(this->ConfigName)) + this->GeneratorTarget->GetLinkInformation(this->ConfigName)) { cmComputeLinkInformation::ItemVector const& items = cli->GetItems(); for(cmComputeLinkInformation::ItemVector::const_iterator diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index a5050ff..8a2cf4b 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -529,7 +529,7 @@ void getCompatibleInterfaceProperties(cmGeneratorTarget *target, std::set &ifaceProperties, const std::string& config) { - cmComputeLinkInformation *info = target->Target->GetLinkInformation(config); + cmComputeLinkInformation *info = target->GetLinkInformation(config); if (!info) { diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 3dbeff2..845c052 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -229,6 +229,12 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) this->GlobalGenerator = this->Makefile->GetGlobalGenerator(); } +cmGeneratorTarget::~cmGeneratorTarget() +{ + cmDeleteAll(this->LinkInformation); + this->LinkInformation.clear(); +} + cmLocalGenerator* cmGeneratorTarget::GetLocalGenerator() const { return this->LocalGenerator; @@ -1517,3 +1523,35 @@ bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty( } return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0; } + + +//---------------------------------------------------------------------------- +cmComputeLinkInformation* +cmGeneratorTarget::GetLinkInformation(const std::string& config) const +{ + // Lookup any existing information for this configuration. + std::string key(cmSystemTools::UpperCase(config)); + cmTargetLinkInformationMap::iterator + i = this->LinkInformation.find(key); + if(i == this->LinkInformation.end()) + { + // Compute information for this configuration. + cmComputeLinkInformation* info = + new cmComputeLinkInformation(this->Target, config); + if(!info || !info->Compute()) + { + delete info; + info = 0; + } + + // Store the information for this configuration. + cmTargetLinkInformationMap::value_type entry(key, info); + i = this->LinkInformation.insert(entry).first; + + if (info) + { + this->Target->CheckPropertyCompatibility(info, config); + } + } + return i->second; +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 3b32bf5..e53f098 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -20,11 +20,13 @@ class cmLocalGenerator; class cmMakefile; class cmSourceFile; class cmTarget; +class cmComputeLinkInformation; class cmGeneratorTarget { public: cmGeneratorTarget(cmTarget*, cmLocalGenerator* lg); + ~cmGeneratorTarget(); cmLocalGenerator* GetLocalGenerator() const; @@ -36,6 +38,9 @@ public: location is suitable for use as the LOCATION target property. */ const char* GetLocationForBuild() const; + cmComputeLinkInformation* + GetLinkInformation(const std::string& config) const; + int GetType() const; std::string GetName() const; const char *GetProperty(const std::string& prop) const; @@ -213,6 +218,10 @@ private: }; mutable std::map CompatibleInterfacesMap; + typedef std::map + cmTargetLinkInformationMap; + mutable cmTargetLinkInformationMap LinkInformation; + cmGeneratorTarget(cmGeneratorTarget const&); void operator=(cmGeneratorTarget const&); }; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 8cb59f8..b44848c 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2202,7 +2202,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, } } // Add framework search paths needed for linking. - if(cmComputeLinkInformation* cli = target.GetLinkInformation(configName)) + if(cmComputeLinkInformation* cli = gtgt->GetLinkInformation(configName)) { std::vector const& fwDirs = cli->GetFrameworkPaths(); for(std::vector::const_iterator fdi = fwDirs.begin(); @@ -2358,7 +2358,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, this->CreateString(install_name_dir.c_str())); // Create the LD_RUNPATH_SEARCH_PATHS - cmComputeLinkInformation* pcli = target.GetLinkInformation(configName); + cmComputeLinkInformation* pcli = gtgt->GetLinkInformation(configName); if(pcli) { std::string search_paths; @@ -2964,7 +2964,8 @@ void cmGlobalXCodeGenerator } // Compute the link library and directory information. - cmComputeLinkInformation* pcli = cmtarget->GetLinkInformation(configName); + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(cmtarget); + cmComputeLinkInformation* pcli = gtgt->GetLinkInformation(configName); if(!pcli) { continue; diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 01d4b77..c64f9a3 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -18,6 +18,7 @@ #include "cmMakefile.h" #include "cmGeneratorTarget.h" #include "cmake.h" +#include "cmGeneratorTarget.h" #include @@ -557,8 +558,7 @@ cmInstallTargetGenerator // Build a map of build-tree install_name to install-tree install_name for // shared libraries linked to this target. std::map install_name_remap; - if(cmComputeLinkInformation* cli = - this->Target->Target->GetLinkInformation(config)) + if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config)) { std::set const& sharedLibs = cli->GetSharedLibrariesLinked(); @@ -667,8 +667,7 @@ cmInstallTargetGenerator // Get the link information for this target. // It can provide the RPATH. - cmComputeLinkInformation* cli = - this->Target->Target->GetLinkInformation(config); + cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config); if(!cli) { return; @@ -700,8 +699,7 @@ cmInstallTargetGenerator // Get the link information for this target. // It can provide the RPATH. - cmComputeLinkInformation* cli = - this->Target->Target->GetLinkInformation(config); + cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config); if(!cli) { return; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 6b48a44..eaf812f 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1468,7 +1468,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, bool escapeAllowMakeVars = !forResponseFile; std::ostringstream fout; std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); - cmComputeLinkInformation* pcli = tgt.Target->GetLinkInformation(config); + cmComputeLinkInformation* pcli = tgt.GetLinkInformation(config); if(!pcli) { return; diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index cab5a47..61d7847 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1846,8 +1846,10 @@ void cmLocalVisualStudio6Generator const std::string extraOptions, std::string& options) { + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); // Compute the link information for this configuration. - cmComputeLinkInformation* pcli = target.GetLinkInformation(configName); + cmComputeLinkInformation* pcli = gt->GetLinkInformation(configName); if(!pcli) { return; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 572dbde..37e08dd 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1074,6 +1074,9 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, this->ConvertToOutputFormat(this->ModuleDefinitionFile, SHELL); linkOptions.AddFlag("ModuleDefinitionFile", defFile.c_str()); } + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); + if (target.GetType() == cmTarget::SHARED_LIBRARY && this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) { @@ -1148,7 +1151,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, targetNameImport, targetNamePDB, configName); // Compute the link library and directory information. - cmComputeLinkInformation* pcli = target.GetLinkInformation(configName); + cmComputeLinkInformation* pcli = gt->GetLinkInformation(configName); if(!pcli) { return; @@ -1245,7 +1248,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, targetNameImport, targetNamePDB, configName); // Compute the link library and directory information. - cmComputeLinkInformation* pcli = target.GetLinkInformation(configName); + cmComputeLinkInformation* pcli = gt->GetLinkInformation(configName); if(!pcli) { return; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 5edc0f5..ac8cd29 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1446,7 +1446,8 @@ void cmMakefileTargetGenerator // Loop over all library dependencies. const char* cfg = this->LocalGenerator->GetConfigName().c_str(); - if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(cfg)) + if(cmComputeLinkInformation* cli = + this->GeneratorTarget->GetLinkInformation(cfg)) { std::vector const& libDeps = cli->GetDepends(); depends.insert(depends.end(), libDeps.begin(), libDeps.end()); diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 4e4dc3f..cf80424 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -195,7 +195,7 @@ cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const return cmNinjaDeps(); cmComputeLinkInformation* cli = - this->Target->GetLinkInformation(this->GetConfigName()); + this->GeneratorTarget->GetLinkInformation(this->GetConfigName()); if(!cli) return cmNinjaDeps(); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 9c7e46a..d8904ea 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -520,8 +520,6 @@ void cmTarget::ClearLinkMaps() this->Internal->LinkInterfaceUsageRequirementsOnlyMap.clear(); this->Internal->LinkClosureMap.clear(); this->Internal->SourceFilesMap.clear(); - cmDeleteAll(this->LinkInformation); - this->LinkInformation.clear(); } //---------------------------------------------------------------------------- @@ -6461,37 +6459,6 @@ void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, } //---------------------------------------------------------------------------- -cmComputeLinkInformation* -cmTarget::GetLinkInformation(const std::string& config) const -{ - // Lookup any existing information for this configuration. - std::string key(cmSystemTools::UpperCase(config)); - cmTargetLinkInformationMap::iterator - i = this->LinkInformation.find(key); - if(i == this->LinkInformation.end()) - { - // Compute information for this configuration. - cmComputeLinkInformation* info = - new cmComputeLinkInformation(this, config); - if(!info || !info->Compute()) - { - delete info; - info = 0; - } - - // Store the information for this configuration. - cmTargetLinkInformationMap::value_type entry(key, info); - i = this->LinkInformation.insert(entry).first; - - if (info) - { - this->CheckPropertyCompatibility(info, config); - } - } - return i->second; -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetFrameworkDirectory(const std::string& config, bool rootDir) const { @@ -6583,26 +6550,6 @@ std::string cmTarget::GetMacContentDirectory(const std::string& config, } //---------------------------------------------------------------------------- -cmTargetLinkInformationMap -::cmTargetLinkInformationMap(cmTargetLinkInformationMap const& r): derived() -{ - // Ideally cmTarget instances should never be copied. However until - // we can make a sweep to remove that, this copy constructor avoids - // allowing the resources (LinkInformation) from getting copied. In - // the worst case this will lead to extra cmComputeLinkInformation - // instances. We also enforce in debug mode that the map be emptied - // when copied. - static_cast(r); - assert(r.empty()); -} - -//---------------------------------------------------------------------------- -cmTargetLinkInformationMap::~cmTargetLinkInformationMap() -{ - cmDeleteAll(*this); -} - -//---------------------------------------------------------------------------- cmTargetInternalPointer::cmTargetInternalPointer() { this->Pointer = new cmTargetInternals; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index df8cdc1..e3410aa 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -78,15 +78,6 @@ public: bool FromGenex; }; -struct cmTargetLinkInformationMap: - public std::map -{ - typedef std::map derived; - cmTargetLinkInformationMap() {} - cmTargetLinkInformationMap(cmTargetLinkInformationMap const& r); - ~cmTargetLinkInformationMap(); -}; - class cmTargetInternals; class cmTargetInternalPointer { @@ -454,9 +445,6 @@ public: * install tree. For example: "\@rpath/" or "\@loader_path/". */ std::string GetInstallNameDirForInstallTree() const; - cmComputeLinkInformation* - GetLinkInformation(const std::string& config) const; - // Get the properties cmPropertyMap &GetProperties() const { return this->Properties; } @@ -766,7 +754,6 @@ private: struct CompileInfo; CompileInfo const* GetCompileInfo(const std::string& config) const; - mutable cmTargetLinkInformationMap LinkInformation; void CheckPropertyCompatibility(cmComputeLinkInformation *info, const std::string& config) const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 71785e9..f3f291a 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2438,7 +2438,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) cmSystemTools::ExpandListArgument(libs, libVec); cmComputeLinkInformation* pcli = - this->Target->GetLinkInformation(config.c_str()); + this->GeneratorTarget->GetLinkInformation(config.c_str()); if(!pcli) { cmSystemTools::Error http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c971338416d7376d8b710b5c18957f6a800b3de0 commit c971338416d7376d8b710b5c18957f6a800b3de0 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:42 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 18:20:44 2015 +0200 Export: Port more API to cmGeneratorTarget. diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 355fc00..6274c3f 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -27,6 +27,7 @@ cmExportBuildFileGenerator::cmExportBuildFileGenerator() //---------------------------------------------------------------------------- bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) { + std::vector allTargets; { std::string expectedTargets; std::string sep; @@ -68,7 +69,8 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) tei = this->Exports.begin(); tei != this->Exports.end(); ++tei) { - cmTarget* te = (*tei)->Target; + cmGeneratorTarget* gte = *tei; + cmTarget* te = gte->Target; this->GenerateImportTargetCode(os, te); te->AppendBuildInterfaceIncludes(); @@ -104,7 +106,7 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) cmGeneratorExpression::BuildInterface, properties, missingTargets); } - this->PopulateCompatibleInterfaceProperties(te, properties); + this->PopulateCompatibleInterfaceProperties(gte, properties); this->GenerateInterfaceProperties(te, os, properties); } diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 3aa2b65..a5050ff 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -525,15 +525,15 @@ void getPropertyContents(cmTarget const* tgt, const std::string& prop, } //---------------------------------------------------------------------------- -void getCompatibleInterfaceProperties(cmTarget *target, +void getCompatibleInterfaceProperties(cmGeneratorTarget *target, std::set &ifaceProperties, const std::string& config) { - cmComputeLinkInformation *info = target->GetLinkInformation(config); + cmComputeLinkInformation *info = target->Target->GetLinkInformation(config); if (!info) { - cmMakefile* mf = target->GetMakefile(); + cmMakefile* mf = target->Target->GetMakefile(); std::ostringstream e; e << "Exporting the target \"" << target->GetName() << "\" is not " "allowed since its linker language cannot be determined"; @@ -568,9 +568,10 @@ void getCompatibleInterfaceProperties(cmTarget *target, //---------------------------------------------------------------------------- void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( - cmTarget *target, + cmGeneratorTarget *gtarget, ImportPropertyMap &properties) { + cmTarget *target = gtarget->Target; this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_BOOL", target, properties); this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_STRING", @@ -591,7 +592,7 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( if (target->GetType() != cmTarget::INTERFACE_LIBRARY) { - getCompatibleInterfaceProperties(target, ifaceProperties, ""); + getCompatibleInterfaceProperties(gtarget, ifaceProperties, ""); std::vector configNames; target->GetMakefile()->GetConfigurations(configNames); @@ -599,7 +600,7 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( for (std::vector::const_iterator ci = configNames.begin(); ci != configNames.end(); ++ci) { - getCompatibleInterfaceProperties(target, ifaceProperties, *ci); + getCompatibleInterfaceProperties(gtarget, ifaceProperties, *ci); } } diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index 2f33200..4e54740 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -132,7 +132,7 @@ protected: std::vector &missingTargets); void PopulateInterfaceProperty(const std::string& propName, cmTarget *target, ImportPropertyMap &properties); - void PopulateCompatibleInterfaceProperties(cmTarget *target, + void PopulateCompatibleInterfaceProperties(cmGeneratorTarget *target, ImportPropertyMap &properties); void GenerateInterfaceProperties(cmTarget const* target, std::ostream& os, const ImportPropertyMap &properties); diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index c88b7b2..b0bc686 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -193,7 +193,11 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE", te, properties); - this->PopulateCompatibleInterfaceProperties(te, properties); + cmGeneratorTarget *gtgt = te->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(te); + + this->PopulateCompatibleInterfaceProperties(gtgt, properties); this->GenerateInterfaceProperties(te, os, properties); } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=244c5b5dcdc5af1f91a79a81f7f7ec4047759fe8 commit 244c5b5dcdc5af1f91a79a81f7f7ec4047759fe8 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:42 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 18:20:44 2015 +0200 cmGeneratorTarget: Move IsLinkInterfaceDependent* from cmTarget. diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index c0485db..c1641cc 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1128,6 +1128,9 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode } } + cmGeneratorTarget* gtgt = + context->Makefile->GetGlobalGenerator()->GetGeneratorTarget(target); + if (!prop) { if (target->IsImported() @@ -1135,16 +1138,16 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { return linkedTargetsContent; } - if (target->IsLinkInterfaceDependentBoolProperty(propertyName, - context->Config)) + if (gtgt->IsLinkInterfaceDependentBoolProperty(propertyName, + context->Config)) { context->HadContextSensitiveCondition = true; return target->GetLinkInterfaceDependentBoolProperty( propertyName, context->Config) ? "1" : "0"; } - if (target->IsLinkInterfaceDependentStringProperty(propertyName, - context->Config)) + if (gtgt->IsLinkInterfaceDependentStringProperty(propertyName, + context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = @@ -1153,8 +1156,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode context->Config); return propContent ? propContent : ""; } - if (target->IsLinkInterfaceDependentNumberMinProperty(propertyName, - context->Config)) + if (gtgt->IsLinkInterfaceDependentNumberMinProperty(propertyName, + context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = @@ -1163,8 +1166,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode context->Config); return propContent ? propContent : ""; } - if (target->IsLinkInterfaceDependentNumberMaxProperty(propertyName, - context->Config)) + if (gtgt->IsLinkInterfaceDependentNumberMaxProperty(propertyName, + context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = @@ -1180,8 +1183,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode if (!target->IsImported() && dagCheckerParent && !dagCheckerParent->EvaluatingLinkLibraries()) { - if (target->IsLinkInterfaceDependentNumberMinProperty(propertyName, - context->Config)) + if (gtgt->IsLinkInterfaceDependentNumberMinProperty(propertyName, + context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = @@ -1190,8 +1193,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode context->Config); return propContent ? propContent : ""; } - if (target->IsLinkInterfaceDependentNumberMaxProperty(propertyName, - context->Config)) + if (gtgt->IsLinkInterfaceDependentNumberMaxProperty(propertyName, + context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 95f6aaa..3dbeff2 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1436,3 +1436,84 @@ void cmGeneratorTarget::ConstructSourceFileFlags() const } } } + +//---------------------------------------------------------------------------- +const cmGeneratorTarget::CompatibleInterfacesBase& +cmGeneratorTarget::GetCompatibleInterfaces(std::string const& config) const +{ + cmGeneratorTarget::CompatibleInterfaces& compat = + this->CompatibleInterfacesMap[config]; + if(!compat.Done) + { + compat.Done = true; + compat.PropsBool.insert("POSITION_INDEPENDENT_CODE"); + compat.PropsString.insert("AUTOUIC_OPTIONS"); + std::vector const& deps = + this->Target->GetLinkImplementationClosure(config); + for(std::vector::const_iterator li = deps.begin(); + li != deps.end(); ++li) + { +#define CM_READ_COMPATIBLE_INTERFACE(X, x) \ + if(const char* prop = (*li)->GetProperty("COMPATIBLE_INTERFACE_" #X)) \ + { \ + std::vector props; \ + cmSystemTools::ExpandListArgument(prop, props); \ + compat.Props##x.insert(props.begin(), props.end()); \ + } + CM_READ_COMPATIBLE_INTERFACE(BOOL, Bool) + CM_READ_COMPATIBLE_INTERFACE(STRING, String) + CM_READ_COMPATIBLE_INTERFACE(NUMBER_MIN, NumberMin) + CM_READ_COMPATIBLE_INTERFACE(NUMBER_MAX, NumberMax) +#undef CM_READ_COMPATIBLE_INTERFACE + } + } + return compat; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsLinkInterfaceDependentBoolProperty( + const std::string &p, const std::string& config) const +{ + if (this->Target->GetType() == cmTarget::OBJECT_LIBRARY + || this->Target->GetType() == cmTarget::INTERFACE_LIBRARY) + { + return false; + } + return this->GetCompatibleInterfaces(config).PropsBool.count(p) > 0; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsLinkInterfaceDependentStringProperty( + const std::string &p, const std::string& config) const +{ + if (this->Target->GetType() == cmTarget::OBJECT_LIBRARY + || this->Target->GetType() == cmTarget::INTERFACE_LIBRARY) + { + return false; + } + return this->GetCompatibleInterfaces(config).PropsString.count(p) > 0; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMinProperty( + const std::string &p, const std::string& config) const +{ + if (this->Target->GetType() == cmTarget::OBJECT_LIBRARY + || this->Target->GetType() == cmTarget::INTERFACE_LIBRARY) + { + return false; + } + return this->GetCompatibleInterfaces(config).PropsNumberMin.count(p) > 0; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty( + const std::string &p, const std::string& config) const +{ + if (this->Target->GetType() == cmTarget::OBJECT_LIBRARY + || this->Target->GetType() == cmTarget::INTERFACE_LIBRARY) + { + return false; + } + return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0; +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 3e43711..3b32bf5 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -82,6 +82,15 @@ public: bool GetFeatureAsBool(const std::string& feature, const std::string& config) const; + bool IsLinkInterfaceDependentBoolProperty(const std::string &p, + const std::string& config) const; + bool IsLinkInterfaceDependentStringProperty(const std::string &p, + const std::string& config) const; + bool IsLinkInterfaceDependentNumberMinProperty(const std::string &p, + const std::string& config) const; + bool IsLinkInterfaceDependentNumberMaxProperty(const std::string &p, + const std::string& config) const; + /** Get the full path to the target according to the settings in its makefile and the configuration type. */ std::string GetFullPath(const std::string& config="", bool implib = false, @@ -187,6 +196,23 @@ private: mutable bool SourceFileFlagsConstructed; mutable std::map SourceFlagsMap; + struct CompatibleInterfacesBase + { + std::set PropsBool; + std::set PropsString; + std::set PropsNumberMax; + std::set PropsNumberMin; + }; + CompatibleInterfacesBase const& + GetCompatibleInterfaces(std::string const& config) const; + + struct CompatibleInterfaces: public CompatibleInterfacesBase + { + CompatibleInterfaces(): Done(false) {} + bool Done; + }; + mutable std::map CompatibleInterfacesMap; + cmGeneratorTarget(cmGeneratorTarget const&); void operator=(cmGeneratorTarget const&); }; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 3074f9b..9c7e46a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -170,13 +170,6 @@ public: }; std::map LinkImplClosureMap; - struct CompatibleInterfaces: public cmTarget::CompatibleInterfaces - { - CompatibleInterfaces(): Done(false) {} - bool Done; - }; - std::map CompatibleInterfacesMap; - typedef std::map > SourceFilesMapType; SourceFilesMapType SourceFilesMap; @@ -4991,54 +4984,6 @@ const char * cmTarget::GetLinkInterfaceDependentNumberMaxProperty( } //---------------------------------------------------------------------------- -bool cmTarget::IsLinkInterfaceDependentBoolProperty(const std::string &p, - const std::string& config) const -{ - if (this->TargetTypeValue == OBJECT_LIBRARY - || this->TargetTypeValue == INTERFACE_LIBRARY) - { - return false; - } - return this->GetCompatibleInterfaces(config).PropsBool.count(p) > 0; -} - -//---------------------------------------------------------------------------- -bool cmTarget::IsLinkInterfaceDependentStringProperty(const std::string &p, - const std::string& config) const -{ - if (this->TargetTypeValue == OBJECT_LIBRARY - || this->TargetTypeValue == INTERFACE_LIBRARY) - { - return false; - } - return this->GetCompatibleInterfaces(config).PropsString.count(p) > 0; -} - -//---------------------------------------------------------------------------- -bool cmTarget::IsLinkInterfaceDependentNumberMinProperty(const std::string &p, - const std::string& config) const -{ - if (this->TargetTypeValue == OBJECT_LIBRARY - || this->TargetTypeValue == INTERFACE_LIBRARY) - { - return false; - } - return this->GetCompatibleInterfaces(config).PropsNumberMin.count(p) > 0; -} - -//---------------------------------------------------------------------------- -bool cmTarget::IsLinkInterfaceDependentNumberMaxProperty(const std::string &p, - const std::string& config) const -{ - if (this->TargetTypeValue == OBJECT_LIBRARY - || this->TargetTypeValue == INTERFACE_LIBRARY) - { - return false; - } - return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0; -} - -//---------------------------------------------------------------------------- void cmTarget::GetObjectLibrariesCMP0026(std::vector& objlibs) const { @@ -5725,39 +5670,6 @@ cmTarget::GetLinkImplementationClosure(const std::string& config) const } //---------------------------------------------------------------------------- -cmTarget::CompatibleInterfaces const& -cmTarget::GetCompatibleInterfaces(std::string const& config) const -{ - cmTargetInternals::CompatibleInterfaces& compat = - this->Internal->CompatibleInterfacesMap[config]; - if(!compat.Done) - { - compat.Done = true; - compat.PropsBool.insert("POSITION_INDEPENDENT_CODE"); - compat.PropsString.insert("AUTOUIC_OPTIONS"); - std::vector const& deps = - this->GetLinkImplementationClosure(config); - for(std::vector::const_iterator li = deps.begin(); - li != deps.end(); ++li) - { -#define CM_READ_COMPATIBLE_INTERFACE(X, x) \ - if(const char* prop = (*li)->GetProperty("COMPATIBLE_INTERFACE_" #X)) \ - { \ - std::vector props; \ - cmSystemTools::ExpandListArgument(prop, props); \ - compat.Props##x.insert(props.begin(), props.end()); \ - } - CM_READ_COMPATIBLE_INTERFACE(BOOL, Bool) - CM_READ_COMPATIBLE_INTERFACE(STRING, String) - CM_READ_COMPATIBLE_INTERFACE(NUMBER_MIN, NumberMin) - CM_READ_COMPATIBLE_INTERFACE(NUMBER_MAX, NumberMax) -#undef CM_READ_COMPATIBLE_INTERFACE - } - } - return compat; -} - -//---------------------------------------------------------------------------- void cmTargetInternals::ComputeLinkInterfaceLibraries( cmTarget const* thisTarget, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index d5374a6..df8cdc1 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -305,16 +305,6 @@ public: std::vector const& GetLinkImplementationClosure(const std::string& config) const; - struct CompatibleInterfaces - { - std::set PropsBool; - std::set PropsString; - std::set PropsNumberMax; - std::set PropsNumberMin; - }; - CompatibleInterfaces const& - GetCompatibleInterfaces(std::string const& config) const; - /** The link implementation specifies the direct library dependencies needed by the object files of the target. */ struct LinkImplementationLibraries @@ -575,15 +565,6 @@ public: const std::string& config) const; bool IsNullImpliedByLinkLibraries(const std::string &p) const; - bool IsLinkInterfaceDependentBoolProperty(const std::string &p, - const std::string& config) const; - bool IsLinkInterfaceDependentStringProperty(const std::string &p, - const std::string& config) const; - bool IsLinkInterfaceDependentNumberMinProperty(const std::string &p, - const std::string& config) const; - bool IsLinkInterfaceDependentNumberMaxProperty(const std::string &p, - const std::string& config) const; - bool GetLinkInterfaceDependentBoolProperty(const std::string &p, const std::string& config) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=12bc571c13eda8d504eac788d6b3e5e8d83e3ad3 commit 12bc571c13eda8d504eac788d6b3e5e8d83e3ad3 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:41 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 18:20:43 2015 +0200 cmGeneratorTarget: Move GetAutoUicOptions from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index e17df9e..95f6aaa 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -743,6 +743,32 @@ cmGeneratorTarget::UseObjectLibraries(std::vector& objs, } //---------------------------------------------------------------------------- +void cmGeneratorTarget::GetAutoUicOptions(std::vector &result, + const std::string& config) const +{ + const char *prop + = this->Target-> + GetLinkInterfaceDependentStringProperty("AUTOUIC_OPTIONS", + config); + if (!prop) + { + return; + } + cmGeneratorExpression ge; + + cmGeneratorExpressionDAGChecker dagChecker( + this->GetName(), + "AUTOUIC_OPTIONS", 0, 0); + cmSystemTools::ExpandListArgument(ge.Parse(prop) + ->Evaluate(this->Makefile, + config, + false, + this->Target, + &dagChecker), + result); +} + +//---------------------------------------------------------------------------- class cmTargetTraceDependencies { public: diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 8e5c2ab..3e43711 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -156,6 +156,9 @@ public: SourceFileType Type; const char* MacFolder; // location inside Mac content folders }; + void GetAutoUicOptions(std::vector &result, + const std::string& config) const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; @@ -176,7 +179,6 @@ private: struct SourceEntry { std::vector Depends; }; typedef std::map SourceEntriesType; SourceEntriesType SourceEntries; - mutable std::map Objects; std::set ExplicitObjectName; mutable std::map > SystemIncludesCache; diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 1322dea..a72b176 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -878,8 +878,11 @@ void cmQtAutoGenerators::MergeUicOptions(std::vector &opts, static void GetUicOpts(cmTarget const* target, const std::string& config, std::string &optString) { + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); std::vector opts; - target->GetAutoUicOptions(opts, config); + gtgt->GetAutoUicOptions(opts, config); optString = cmJoin(opts, ";"); } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 54f9cf0..3074f9b 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2236,31 +2236,6 @@ static void processCompileOptions(cmTarget const* tgt, } //---------------------------------------------------------------------------- -void cmTarget::GetAutoUicOptions(std::vector &result, - const std::string& config) const -{ - const char *prop - = this->GetLinkInterfaceDependentStringProperty("AUTOUIC_OPTIONS", - config); - if (!prop) - { - return; - } - cmGeneratorExpression ge; - - cmGeneratorExpressionDAGChecker dagChecker( - this->GetName(), - "AUTOUIC_OPTIONS", 0, 0); - cmSystemTools::ExpandListArgument(ge.Parse(prop) - ->Evaluate(this->Makefile, - config, - false, - this, - &dagChecker), - result); -} - -//---------------------------------------------------------------------------- void cmTarget::GetCompileOptions(std::vector &result, const std::string& config, const std::string& language) const diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 389f9cd..d5374a6 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -571,8 +571,6 @@ public: void GetCompileOptions(std::vector &result, const std::string& config, const std::string& language) const; - void GetAutoUicOptions(std::vector &result, - const std::string& config) const; void GetCompileFeatures(std::vector &features, const std::string& config) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=41abdc17df99662a8e99ba895050dbc8c0e34b8e commit 41abdc17df99662a8e99ba895050dbc8c0e34b8e Author: Stephen Kelly AuthorDate: Tue Aug 4 19:19:41 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 5 18:20:43 2015 +0200 cmGeneratorTarget: Move GetSOName from cmTarget.. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index e63b44f..72db6f8 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -756,15 +756,16 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, return; } + cmGeneratorTarget *gtgt = 0; + // Get a full path to the dependent shared library. // Add it to the runtime path computation so that the target being // linked will be able to find it. std::string lib; if(tgt) { - cmGeneratorTarget *gtgt = tgt->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(tgt); + gtgt = tgt->GetMakefile()->GetGlobalGenerator()->GetGeneratorTarget(tgt); + lib = gtgt->GetFullPath(this->Config, this->UseImportLibrary); this->AddLibraryRuntimeInfo(lib, tgt); } @@ -790,9 +791,9 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, } if(order) { - if(tgt) + if(gtgt) { - std::string soName = tgt->GetSOName(this->Config); + std::string soName = gtgt->GetSOName(this->Config); const char* soname = soName.empty()? 0 : soName.c_str(); order->AddRuntimeLibrary(lib, soname); } @@ -1804,7 +1805,10 @@ cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath, // Try to get the soname of the library. Only files with this name // could possibly conflict. - std::string soName = target->GetSOName(this->Config); + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); + std::string soName = gtgt->GetSOName(this->Config); const char* soname = soName.empty()? 0 : soName.c_str(); // Include this library in the runtime path ordering. diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index a33cd59..3aa2b65 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -895,7 +895,7 @@ cmExportFileGenerator value = this->InstallNameDir(target->Target, config); } prop = "IMPORTED_SONAME"; - value += target->Target->GetSOName(config); + value += target->GetSOName(config); } else { diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index f3527ff..c0485db 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1584,7 +1584,7 @@ struct TargetFilesystemArtifactResultCreator } std::string result = target->Target->GetDirectory(context->Config); result += "/"; - result += target->Target->GetSOName(context->Config); + result += target->GetSOName(context->Config); return result; } }; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index bd57b3d..e17df9e 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -650,6 +650,49 @@ void cmGeneratorTarget::GetSourceFiles(std::vector &files, } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetSOName(const std::string& config) const +{ + if(this->Target->IsImported()) + { + // Lookup the imported soname. + if(cmTarget::ImportInfo const* info = this->Target->GetImportInfo(config)) + { + if(info->NoSOName) + { + // The imported library has no builtin soname so the name + // searched at runtime will be just the filename. + return cmSystemTools::GetFilenameName(info->Location); + } + else + { + // Use the soname given if any. + if(info->SOName.find("@rpath/") == 0) + { + return info->SOName.substr(6); + } + return info->SOName; + } + } + else + { + return ""; + } + } + else + { + // Compute the soname that will be built. + std::string name; + std::string soName; + std::string realName; + std::string impName; + std::string pdbName; + this->Target->GetLibraryNames(name, soName, realName, + impName, pdbName, config); + return soName; + } +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetModuleDefinitionFile(const std::string& config) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index a584c71..8e5c2ab 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -90,6 +90,9 @@ public: bool realname) const; std::string NormalGetRealName(const std::string& config) const; + /** Get the soname of the target. Allowed only for a shared library. */ + std::string GetSOName(const std::string& config) const; + cmTarget* Target; cmMakefile* Makefile; cmLocalGenerator* LocalGenerator; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 7dea107..8cb59f8 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2345,7 +2345,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, install_name += install_name_dir; install_name += "/"; } - install_name += target.GetSOName(configName); + install_name += gtgt->GetSOName(configName); if((realName != soName) || install_name_dir.empty()) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index cf33791..54f9cf0 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -69,21 +69,6 @@ struct cmTarget::OutputInfo }; //---------------------------------------------------------------------------- -struct cmTarget::ImportInfo -{ - ImportInfo(): NoSOName(false), Multiplicity(0) {} - bool NoSOName; - int Multiplicity; - std::string Location; - std::string SOName; - std::string ImportLibrary; - std::string Languages; - std::string Libraries; - std::string LibrariesProp; - std::string SharedDeps; -}; - -//---------------------------------------------------------------------------- struct cmTarget::CompileInfo { std::string CompilePdbDir; @@ -3602,48 +3587,6 @@ bool cmTarget::HasSOName(const std::string& config) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetSOName(const std::string& config) const -{ - if(this->IsImported()) - { - // Lookup the imported soname. - if(cmTarget::ImportInfo const* info = this->GetImportInfo(config)) - { - if(info->NoSOName) - { - // The imported library has no builtin soname so the name - // searched at runtime will be just the filename. - return cmSystemTools::GetFilenameName(info->Location); - } - else - { - // Use the soname given if any. - if(info->SOName.find("@rpath/") == 0) - { - return info->SOName.substr(6); - } - return info->SOName; - } - } - else - { - return ""; - } - } - else - { - // Compute the soname that will be built. - std::string name; - std::string soName; - std::string realName; - std::string impName; - std::string pdbName; - this->GetLibraryNames(name, soName, realName, impName, pdbName, config); - return soName; - } -} - -//---------------------------------------------------------------------------- bool cmTarget::HasMacOSXRpathInstallNameDir(const std::string& config) const { bool install_name_is_rpath = false; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index f567d50..389f9cd 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -411,9 +411,6 @@ public: /** Whether this library has soname enabled and platform supports it. */ bool HasSOName(const std::string& config) const; - /** Get the soname of the target. Allowed only for a shared library. */ - std::string GetSOName(const std::string& config) const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; @@ -768,7 +765,20 @@ private: std::string& out) const; // Cache import information from properties for each configuration. - struct ImportInfo; + struct ImportInfo + { + ImportInfo(): NoSOName(false), Multiplicity(0) {} + bool NoSOName; + int Multiplicity; + std::string Location; + std::string SOName; + std::string ImportLibrary; + std::string Languages; + std::string Libraries; + std::string LibrariesProp; + std::string SharedDeps; + }; + ImportInfo const* GetImportInfo(const std::string& config) const; void ComputeImportInfo(std::string const& desired_config, ImportInfo& info) const; ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From domen.vrankar at gmail.com Wed Aug 5 12:44:33 2015 From: domen.vrankar at gmail.com (Domen Vrankar) Date: Wed, 5 Aug 2015 12:44:33 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1982-g3350a96 Message-ID: <20150805164433.E8B17B099E@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 3350a96d57f0694be3cb0a305aad9ae82b75e790 (commit) via c83c1680cf1ac9b5d01efc3bdf0a7c012326403f (commit) from 2ec5b3466da91b08b3f087f62625a4b6bf88208c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3350a96d57f0694be3cb0a305aad9ae82b75e790 commit 3350a96d57f0694be3cb0a305aad9ae82b75e790 Merge: 2ec5b34 c83c168 Author: Domen Vrankar AuthorDate: Wed Aug 5 12:44:32 2015 -0400 Commit: CMake Topic Stage CommitDate: Wed Aug 5 12:44:32 2015 -0400 Merge topic 'cpack-rpm-documentation-fixes' into next c83c1680 RunCMake/CPack_DEB DEPENDENCIES test package content fix http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c83c1680cf1ac9b5d01efc3bdf0a7c012326403f commit c83c1680cf1ac9b5d01efc3bdf0a7c012326403f Author: Domen Vrankar AuthorDate: Wed Aug 5 18:44:00 2015 +0200 Commit: Domen Vrankar CommitDate: Wed Aug 5 18:44:00 2015 +0200 RunCMake/CPack_DEB DEPENDENCIES test package content fix On Mac shared libraries end with .dylib instead of .so so test should take this into account diff --git a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake index 577a560..c56c670 100644 --- a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake @@ -8,6 +8,7 @@ set(EXPECTED_FILE_CONTENT_2 "^.*/usr/foo_auto${whitespaces_}.*/usr/foo_auto/test set(EXPECTED_FILE_3 "dependencies*-headers.deb") set(EXPECTED_FILE_CONTENT_3 "^.*/usr/bar${whitespaces_}.*/usr/bar/CMakeLists.txt$") set(EXPECTED_FILE_4 "dependencies*-libs.deb") -set(EXPECTED_FILE_CONTENT_4 "^.*/usr/bas${whitespaces_}.*/usr/bas/libtest_lib.so$") +# dynamic lib extension is .so on Linux and .dylib on Mac so we will use a wildcard .* for it +set(EXPECTED_FILE_CONTENT_4 "^.*/usr/bas${whitespaces_}.*/usr/bas/libtest_lib\\..*$") set(EXPECTED_FILE_5 "dependencies*-libs_auto.deb") -set(EXPECTED_FILE_CONTENT_5 "^.*/usr/bas_auto${whitespaces_}.*/usr/bas_auto/libtest_lib.so$") +set(EXPECTED_FILE_CONTENT_5 "^.*/usr/bas_auto${whitespaces_}.*/usr/bas_auto/libtest_lib\\..*$") ----------------------------------------------------------------------- Summary of changes: Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Wed Aug 5 13:31:15 2015 From: brad.king at kitware.com (Brad King) Date: Wed, 5 Aug 2015 13:31:15 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1985-gabfa794 Message-ID: <20150805173115.4A16BB130D@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via abfa7948673c618437c0b9cdaf7588591f334cf2 (commit) via 26f5445bb461910efd42bc80a99a63dd53b49643 (commit) via a15b69cbc75f475601f41c516330c679915676e4 (commit) from 3350a96d57f0694be3cb0a305aad9ae82b75e790 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=abfa7948673c618437c0b9cdaf7588591f334cf2 commit abfa7948673c618437c0b9cdaf7588591f334cf2 Merge: 3350a96 26f5445 Author: Brad King AuthorDate: Wed Aug 5 13:31:14 2015 -0400 Commit: CMake Topic Stage CommitDate: Wed Aug 5 13:31:14 2015 -0400 Merge topic 'install-no-runtime-deps-by-default' into next 26f5445b Do not install 3rd-party dependencies by default a15b69cb CMake Nightly Date Stamp http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=26f5445bb461910efd42bc80a99a63dd53b49643 commit 26f5445bb461910efd42bc80a99a63dd53b49643 Author: Brad King AuthorDate: Wed Aug 5 13:28:35 2015 -0400 Commit: Brad King CommitDate: Wed Aug 5 13:29:57 2015 -0400 Do not install 3rd-party dependencies by default Disable the CMake_INSTALL_DEPENDENCIES option by default and turn it on explicitly in our packaging scripts. This simplifies packaging in distributions that provide the dependencies for us without having to install them. We only need 3rd-party runtime dependencies to be installed for packaging with redistributable binaries. diff --git a/CMakeLists.txt b/CMakeLists.txt index a47c2ad..36244dd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,7 +72,7 @@ endmacro() # option to disable installing 3rd-party dependencies option(CMake_INSTALL_DEPENDENCIES - "Whether to install 3rd-party runtime dependencies" ON) + "Whether to install 3rd-party runtime dependencies" OFF) mark_as_advanced(CMake_INSTALL_DEPENDENCIES) #----------------------------------------------------------------------- diff --git a/Utilities/Release/dash2win64_cygwin.cmake b/Utilities/Release/dash2win64_cygwin.cmake index ac3c527..d15915a 100644 --- a/Utilities/Release/dash2win64_cygwin.cmake +++ b/Utilities/Release/dash2win64_cygwin.cmake @@ -12,6 +12,7 @@ CTEST_TEST_TIMEOUT:STRING=7200 DART_TESTING_TIMEOUT:STRING=7200 SPHINX_HTML:BOOL=ON SPHINX_MAN:BOOL=ON +CMake_INSTALL_DEPENDENCIES:BOOL=ON ") set(CXX g++) set(CC gcc) diff --git a/Utilities/Release/dash2win64_release.cmake b/Utilities/Release/dash2win64_release.cmake index 2511db4..3ea895a 100644 --- a/Utilities/Release/dash2win64_release.cmake +++ b/Utilities/Release/dash2win64_release.cmake @@ -14,6 +14,7 @@ CMAKE_Fortran_COMPILER:FILEPATH=FALSE CMAKE_GENERATOR:INTERNAL=Unix Makefiles BUILD_QtDialog:BOOL:=TRUE CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL:BOOL=TRUE +CMake_INSTALL_DEPENDENCIES:BOOL=ON QT_QMAKE_EXECUTABLE:FILEPATH=c:/Dashboards/Support/qt-build/Qt/bin/qmake.exe ") get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH) diff --git a/Utilities/Release/dashmacmini2_release.cmake b/Utilities/Release/dashmacmini2_release.cmake index ba82aab..01f5b8b 100644 --- a/Utilities/Release/dashmacmini2_release.cmake +++ b/Utilities/Release/dashmacmini2_release.cmake @@ -18,6 +18,7 @@ CMAKE_SKIP_BOOTSTRAP_TEST:STRING=TRUE CPACK_SYSTEM_NAME:STRING=Darwin-universal BUILD_QtDialog:BOOL=TRUE CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL:BOOL=TRUE +CMake_INSTALL_DEPENDENCIES:BOOL=ON QT_QMAKE_EXECUTABLE:FILEPATH=/Users/kitware/Support/qt-4.8.0/install/bin/qmake ") get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH) diff --git a/Utilities/Release/dashmacmini5_release.cmake b/Utilities/Release/dashmacmini5_release.cmake index b407554..be1dfa9 100644 --- a/Utilities/Release/dashmacmini5_release.cmake +++ b/Utilities/Release/dashmacmini5_release.cmake @@ -20,6 +20,7 @@ CMAKE_SKIP_BOOTSTRAP_TEST:STRING=TRUE CPACK_SYSTEM_NAME:STRING=Darwin-x86_64 BUILD_QtDialog:BOOL=TRUE CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL:BOOL=TRUE +CMake_INSTALL_DEPENDENCIES:BOOL=ON QT_QMAKE_EXECUTABLE:FILEPATH=/Users/kitware/Support/qt-4.8.6/install/bin/qmake ") get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH) diff --git a/Utilities/Release/linux64_release.cmake b/Utilities/Release/linux64_release.cmake index 2cd5dfc..25da00a 100644 --- a/Utilities/Release/linux64_release.cmake +++ b/Utilities/Release/linux64_release.cmake @@ -17,6 +17,7 @@ OPENSSL_SSL_LIBRARY:FILEPATH=/home/kitware/openssl-1.0.2d/lib/libssl.a CPACK_SYSTEM_NAME:STRING=Linux-x86_64 BUILD_QtDialog:BOOL:=TRUE CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL:BOOL=TRUE +CMake_INSTALL_DEPENDENCIES:BOOL=ON QT_QMAKE_EXECUTABLE:FILEPATH=/home/kitware/qt-4.8.6/bin/qmake ") get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH) diff --git a/Utilities/Release/magrathea_release.cmake b/Utilities/Release/magrathea_release.cmake index b0e0a3a..b031eb8 100644 --- a/Utilities/Release/magrathea_release.cmake +++ b/Utilities/Release/magrathea_release.cmake @@ -17,6 +17,7 @@ OPENSSL_SSL_LIBRARY:FILEPATH=/home/kitware/openssl-1.0.2d/lib/libssl.a CPACK_SYSTEM_NAME:STRING=Linux-i386 BUILD_QtDialog:BOOL:=TRUE CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL:BOOL=TRUE +CMake_INSTALL_DEPENDENCIES:BOOL=ON QT_QMAKE_EXECUTABLE:FILEPATH=/home/kitware/qt-4.43-install/bin/qmake ") get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH) ----------------------------------------------------------------------- Summary of changes: CMakeLists.txt | 2 +- Source/CMakeVersion.cmake | 2 +- Utilities/Release/dash2win64_cygwin.cmake | 1 + Utilities/Release/dash2win64_release.cmake | 1 + Utilities/Release/dashmacmini2_release.cmake | 1 + Utilities/Release/dashmacmini5_release.cmake | 1 + Utilities/Release/linux64_release.cmake | 1 + Utilities/Release/magrathea_release.cmake | 1 + 8 files changed, 8 insertions(+), 2 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Wed Aug 5 13:54:17 2015 From: brad.king at kitware.com (Brad King) Date: Wed, 5 Aug 2015 13:54:17 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1987-g1ee82fb Message-ID: <20150805175417.3FDC8B1040@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 1ee82fb5e1e83c43d30cc65c857dcdf81aa313d7 (commit) via 2eee2943cce2a7aea7a11b93f2459f5f333eb84c (commit) from abfa7948673c618437c0b9cdaf7588591f334cf2 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1ee82fb5e1e83c43d30cc65c857dcdf81aa313d7 commit 1ee82fb5e1e83c43d30cc65c857dcdf81aa313d7 Merge: abfa794 2eee294 Author: Brad King AuthorDate: Wed Aug 5 13:54:16 2015 -0400 Commit: CMake Topic Stage CommitDate: Wed Aug 5 13:54:16 2015 -0400 Merge topic 'xcode-improve-quoting' into next 2eee2943 Xcode: Invert quoting logic to whitelist of characters http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2eee2943cce2a7aea7a11b93f2459f5f333eb84c commit 2eee2943cce2a7aea7a11b93f2459f5f333eb84c Author: Gregor Jasny AuthorDate: Sun Aug 2 00:06:49 2015 +0200 Commit: Brad King CommitDate: Wed Aug 5 13:51:31 2015 -0400 Xcode: Invert quoting logic to whitelist of characters Our explicit list of characters that require quoting does not account for non-ascii characters (e.g. UTF-8) that also need quoting. Invert the logic to quote a string unless it contains exclusively a set of characters we whitelist. diff --git a/Source/cmXCodeObject.cxx b/Source/cmXCodeObject.cxx index ba6e395..c59c360 100644 --- a/Source/cmXCodeObject.cxx +++ b/Source/cmXCodeObject.cxx @@ -243,7 +243,11 @@ void cmXCodeObject::PrintString(std::ostream& os,std::string String) bool needQuote = (String.empty() || String.find("//") != String.npos || - String.find_first_of(" <>+-*=@[](){},~") != String.npos); + String.find_first_not_of( + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789" + "$_./") != String.npos); const char* quote = needQuote? "\"" : ""; // Print the string, quoted and escaped as necessary. ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From brad.king at kitware.com Wed Aug 5 13:54:37 2015 From: brad.king at kitware.com (Brad King) Date: Wed, 5 Aug 2015 13:54:37 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-692-gfccb3e2 Message-ID: <20150805175437.960DCB0E01@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via fccb3e2dae4993650a980799e571bf6ae6e304e6 (commit) via cc23f0e9d38fe3f880ada549af4e552fc13fc655 (commit) via 3d287de4ea99718ffe2ac6b855c2786d67946be2 (commit) via e72806fb30dd9162aa1b05cb478ae51d1ecd27fa (commit) from a15b69cbc75f475601f41c516330c679915676e4 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fccb3e2dae4993650a980799e571bf6ae6e304e6 commit fccb3e2dae4993650a980799e571bf6ae6e304e6 Merge: a15b69c cc23f0e Author: Brad King AuthorDate: Wed Aug 5 13:54:36 2015 -0400 Commit: CMake Topic Stage CommitDate: Wed Aug 5 13:54:36 2015 -0400 Merge topic 'java-updates' cc23f0e9 UseJava: Teach install_jar new DESTINATION and COMPONENT options 3d287de4 UseJava: Teach add_jar to support file syntax for sources e72806fb FindJava: Add support for idlj and jarsigner tools ----------------------------------------------------------------------- Summary of changes: Help/release/dev/java-updates.rst | 13 +++++ Modules/FindJava.cmake | 94 ++++++++++++++++++++++++++++--------- Modules/UseJava.cmake | 88 ++++++++++++++++++++++++++++------ Tests/CMakeLists.txt | 21 +++++++-- Tests/Java/CMakeLists.txt | 4 ++ 5 files changed, 178 insertions(+), 42 deletions(-) create mode 100644 Help/release/dev/java-updates.rst hooks/post-receive -- CMake From brad.king at kitware.com Wed Aug 5 13:54:39 2015 From: brad.king at kitware.com (Brad King) Date: Wed, 5 Aug 2015 13:54:39 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-694-g863b0a8 Message-ID: <20150805175439.B15D2B1055@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 863b0a8ee9eb7a19226a37edd1d8a398462379a1 (commit) via 2eee2943cce2a7aea7a11b93f2459f5f333eb84c (commit) from fccb3e2dae4993650a980799e571bf6ae6e304e6 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=863b0a8ee9eb7a19226a37edd1d8a398462379a1 commit 863b0a8ee9eb7a19226a37edd1d8a398462379a1 Merge: fccb3e2 2eee294 Author: Brad King AuthorDate: Wed Aug 5 13:54:38 2015 -0400 Commit: CMake Topic Stage CommitDate: Wed Aug 5 13:54:38 2015 -0400 Merge topic 'xcode-improve-quoting' 2eee2943 Xcode: Invert quoting logic to whitelist of characters ----------------------------------------------------------------------- Summary of changes: Source/cmXCodeObject.cxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Wed Aug 5 13:55:02 2015 From: brad.king at kitware.com (Brad King) Date: Wed, 5 Aug 2015 13:55:02 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1990-g31677be Message-ID: <20150805175502.DA998B0E01@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 31677be7228d3890ec7d77757a55dbf70db76ad6 (commit) via 863b0a8ee9eb7a19226a37edd1d8a398462379a1 (commit) via fccb3e2dae4993650a980799e571bf6ae6e304e6 (commit) from 1ee82fb5e1e83c43d30cc65c857dcdf81aa313d7 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=31677be7228d3890ec7d77757a55dbf70db76ad6 commit 31677be7228d3890ec7d77757a55dbf70db76ad6 Merge: 1ee82fb 863b0a8 Author: Brad King AuthorDate: Wed Aug 5 13:54:54 2015 -0400 Commit: Brad King CommitDate: Wed Aug 5 13:54:54 2015 -0400 Merge branch 'master' into next ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From brad.king at kitware.com Wed Aug 5 14:12:37 2015 From: brad.king at kitware.com (Brad King) Date: Wed, 5 Aug 2015 14:12:37 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1992-g662af68 Message-ID: <20150805181237.5F33CB01EE@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 662af68dd367056396d8c48f9854137ff05f45ba (commit) via 43c94281401cfa89bcbe7110727845ed5df984ec (commit) from 31677be7228d3890ec7d77757a55dbf70db76ad6 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=662af68dd367056396d8c48f9854137ff05f45ba commit 662af68dd367056396d8c48f9854137ff05f45ba Merge: 31677be 43c9428 Author: Brad King AuthorDate: Wed Aug 5 14:12:36 2015 -0400 Commit: CMake Topic Stage CommitDate: Wed Aug 5 14:12:36 2015 -0400 Merge topic 'ninja-LINK_DEPENDS' into next 43c94281 Ninja: Honor the LINK_DEPENDS target property (#14796) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=43c94281401cfa89bcbe7110727845ed5df984ec commit 43c94281401cfa89bcbe7110727845ed5df984ec Author: Brad King AuthorDate: Wed Aug 5 14:02:55 2015 -0400 Commit: Brad King CommitDate: Wed Aug 5 14:12:05 2015 -0400 Ninja: Honor the LINK_DEPENDS target property (#14796) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 4e4dc3f..08b2e66 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -209,6 +209,15 @@ cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const result.push_back(this->ConvertToNinjaPath(this->ModuleDefinitionFile)); } + // Add user-specified dependencies. + if (const char* linkDepends = this->Target->GetProperty("LINK_DEPENDS")) + { + std::vector linkDeps; + cmSystemTools::ExpandListArgument(linkDepends, linkDeps); + std::transform(linkDeps.begin(), linkDeps.end(), + std::back_inserter(result), MapToNinjaPath()); + } + return result; } diff --git a/Tests/BuildDepends/CMakeLists.txt b/Tests/BuildDepends/CMakeLists.txt index 7b7353c..36987de 100644 --- a/Tests/BuildDepends/CMakeLists.txt +++ b/Tests/BuildDepends/CMakeLists.txt @@ -34,7 +34,7 @@ if(WIN32 AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "Intel") set(_cmake_options "-DCMAKE_EXE_LINKER_FLAGS=") endif() -if("${CMAKE_GENERATOR}" MATCHES "Make") +if("${CMAKE_GENERATOR}" MATCHES "Make|Ninja") set(TEST_LINK_DEPENDS ${BuildDepends_BINARY_DIR}/Project/linkdep.txt) file(WRITE ${TEST_LINK_DEPENDS} "1") endif() ----------------------------------------------------------------------- Summary of changes: Source/cmNinjaTargetGenerator.cxx | 9 +++++++++ Tests/BuildDepends/CMakeLists.txt | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Thu Aug 6 00:01:09 2015 From: kwrobot at kitware.com (Kitware Robot) Date: Thu, 6 Aug 2015 00:01:09 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-695-g42526ef Message-ID: <20150806040109.49D4DB1119@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 42526efec45993466cbc605eb2cee70194eed4a6 (commit) from 863b0a8ee9eb7a19226a37edd1d8a398462379a1 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=42526efec45993466cbc605eb2cee70194eed4a6 commit 42526efec45993466cbc605eb2cee70194eed4a6 Author: Kitware Robot AuthorDate: Thu Aug 6 00:01:07 2015 -0400 Commit: Kitware Robot CommitDate: Thu Aug 6 00:01:07 2015 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index a9dfae0..c9fec35 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150805) +set(CMake_VERSION_PATCH 20150806) #set(CMake_VERSION_RC 1) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 6 09:34:20 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 6 Aug 2015 09:34:20 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-1997-g6d0cf23 Message-ID: <20150806133420.5D7A0B1380@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 6d0cf23c5d225f629bfc076eac4340cfac28e597 (commit) via 94226751cb9beb7aa1939e9395d4999e30b30600 (commit) via 105011e08fafe23cb4cfd4fcb1468187f9d81f21 (commit) via d882d4770fec6d65d82d818b4979cb5763d253c1 (commit) via 145735b748ab04505ab7a885a54fbd175ccecee2 (commit) from 662af68dd367056396d8c48f9854137ff05f45ba (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6d0cf23c5d225f629bfc076eac4340cfac28e597 commit 6d0cf23c5d225f629bfc076eac4340cfac28e597 Merge: 662af68 9422675 Author: Brad King AuthorDate: Thu Aug 6 09:34:19 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 6 09:34:19 2015 -0400 Merge topic 'cpack-rpm-documentation-fixes' into next 94226751 Tests/RunCMake/CPack: Add dependencies tests 105011e0 Tests/RunCMake/CPack: Bump verify result cmake version d882d477 Tests/RunCMake/CPack/DEB: Add getPackageInfo helper function 145735b7 Tests/RunCMake/CPack: Enable CXX language in tests http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=94226751cb9beb7aa1939e9395d4999e30b30600 commit 94226751cb9beb7aa1939e9395d4999e30b30600 Author: Domen Vrankar AuthorDate: Wed Jul 29 23:39:11 2015 +0200 Commit: Brad King CommitDate: Thu Aug 6 09:33:51 2015 -0400 Tests/RunCMake/CPack: Add dependencies tests Add tests for RPM and DEB package test for currently supported dependency features (requires, provides, conflicts, ...). diff --git a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake new file mode 100644 index 0000000..c56c670 --- /dev/null +++ b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake @@ -0,0 +1,14 @@ +set(whitespaces_ "[\t\n\r ]*") + +set(EXPECTED_FILES_COUNT "5") +set(EXPECTED_FILE_1 "dependencies*-applications.deb") +set(EXPECTED_FILE_CONTENT_1 "^.*/usr/foo${whitespaces_}.*/usr/foo/test_prog$") +set(EXPECTED_FILE_2 "dependencies*-applications_auto.deb") +set(EXPECTED_FILE_CONTENT_2 "^.*/usr/foo_auto${whitespaces_}.*/usr/foo_auto/test_prog$") +set(EXPECTED_FILE_3 "dependencies*-headers.deb") +set(EXPECTED_FILE_CONTENT_3 "^.*/usr/bar${whitespaces_}.*/usr/bar/CMakeLists.txt$") +set(EXPECTED_FILE_4 "dependencies*-libs.deb") +# dynamic lib extension is .so on Linux and .dylib on Mac so we will use a wildcard .* for it +set(EXPECTED_FILE_CONTENT_4 "^.*/usr/bas${whitespaces_}.*/usr/bas/libtest_lib\\..*$") +set(EXPECTED_FILE_5 "dependencies*-libs_auto.deb") +set(EXPECTED_FILE_CONTENT_5 "^.*/usr/bas_auto${whitespaces_}.*/usr/bas_auto/libtest_lib\\..*$") diff --git a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-VerifyResult.cmake b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-VerifyResult.cmake new file mode 100644 index 0000000..44c862d --- /dev/null +++ b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-VerifyResult.cmake @@ -0,0 +1,15 @@ +function(checkDepends_ FILE REGEX) + set(whitespaces_ "[\t\n\r ]*") + + getPackageInfo("${FILE}" "FILE_INFO_") + if(NOT FILE_INFO_ MATCHES "${REGEX}") + message(FATAL_ERROR "Unexpected dependencies in '${FILE}'; file info: '${FILE_INFO_}'") + endif() +endfunction() + +checkDepends_("${FOUND_FILE_1}" ".*Depends${whitespaces_}:${whitespaces_}depend-application, depend-application-b.*") +# use wildcard as we are using dependency auto detection +checkDepends_("${FOUND_FILE_2}" ".*Depends${whitespaces_}:${whitespaces_}.*depend-application, depend-application-b.*") +checkDepends_("${FOUND_FILE_3}" ".*Depends${whitespaces_}:${whitespaces_}depend-headers.*") +checkDepends_("${FOUND_FILE_4}" ".*Depends${whitespaces_}:${whitespaces_}depend-default, depend-default-b.*") +checkDepends_("${FOUND_FILE_5}" ".*Depends${whitespaces_}:${whitespaces_}depend-default, depend-default-b.*") diff --git a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-specifics.cmake b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-specifics.cmake new file mode 100644 index 0000000..9e09428 --- /dev/null +++ b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-specifics.cmake @@ -0,0 +1,15 @@ +set(CPACK_PACKAGE_CONTACT "someone") +set(CPACK_DEB_COMPONENT_INSTALL "ON") + +# false by default +set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS FALSE) +# FIXME can not be tested as libraries first have to be part of a package in order +# to determine their dependencies and we can not be certain if there will be any +set(CPACK_DEBIAN_APPLICATIONS_AUTO_PACKAGE_SHLIBDEPS TRUE) + +set(CPACK_DEBIAN_PACKAGE_DEPENDS "depend-default, depend-default-b") +set(CPACK_DEBIAN_APPLICATIONS_PACKAGE_DEPENDS "depend-application, depend-application-b") +set(CPACK_DEBIAN_APPLICATIONS_AUTO_PACKAGE_DEPENDS "depend-application, depend-application-b") +set(CPACK_DEBIAN_HEADERS_PACKAGE_DEPENDS "depend-headers") + +# TODO add other dependency tests once CPackDeb supports them diff --git a/Tests/RunCMake/CPack/DEPENDENCIES.cmake b/Tests/RunCMake/CPack/DEPENDENCIES.cmake new file mode 100644 index 0000000..0aef925 --- /dev/null +++ b/Tests/RunCMake/CPack/DEPENDENCIES.cmake @@ -0,0 +1,18 @@ +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.hpp" + "int test_lib();") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp" + "#include \"test_lib.hpp\"\nint test_lib() {return 0;}") +add_library(test_lib SHARED "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp") + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp" + "#include \"test_lib.hpp\"\nint main() {return test_lib();}") +add_executable(test_prog "${CMAKE_CURRENT_BINARY_DIR}/main.cpp") +target_link_libraries(test_prog test_lib) + +install(TARGETS test_prog DESTINATION foo COMPONENT applications) +install(TARGETS test_prog DESTINATION foo_auto COMPONENT applications_auto) +install(FILES CMakeLists.txt DESTINATION bar COMPONENT headers) +install(TARGETS test_lib DESTINATION bas COMPONENT libs) +install(TARGETS test_lib DESTINATION bas_auto COMPONENT libs_auto) + +set(CPACK_PACKAGE_NAME "dependencies") diff --git a/Tests/RunCMake/CPack/RPM/DEPENDENCIES-ExpectedFiles.cmake b/Tests/RunCMake/CPack/RPM/DEPENDENCIES-ExpectedFiles.cmake new file mode 100644 index 0000000..cf85dab --- /dev/null +++ b/Tests/RunCMake/CPack/RPM/DEPENDENCIES-ExpectedFiles.cmake @@ -0,0 +1,13 @@ +set(whitespaces_ "[\t\n\r ]*") + +set(EXPECTED_FILES_COUNT "5") +set(EXPECTED_FILE_1 "dependencies*-applications.rpm") +set(EXPECTED_FILE_CONTENT_1 "^/usr/foo${whitespaces_}/usr/foo/test_prog$") +set(EXPECTED_FILE_2 "dependencies*-applications_auto.rpm") +set(EXPECTED_FILE_CONTENT_2 "^/usr/foo_auto${whitespaces_}/usr/foo_auto/test_prog$") +set(EXPECTED_FILE_3 "dependencies*-headers.rpm") +set(EXPECTED_FILE_CONTENT_3 "^/usr/bar${whitespaces_}/usr/bar/CMakeLists.txt$") +set(EXPECTED_FILE_4 "dependencies*-libs.rpm") +set(EXPECTED_FILE_CONTENT_4 "^/usr/bas${whitespaces_}/usr/bas/libtest_lib.so$") +set(EXPECTED_FILE_5 "dependencies*-libs_auto.rpm") +set(EXPECTED_FILE_CONTENT_5 "^/usr/bas_auto${whitespaces_}/usr/bas_auto/libtest_lib.so$") diff --git a/Tests/RunCMake/CPack/RPM/DEPENDENCIES-VerifyResult.cmake b/Tests/RunCMake/CPack/RPM/DEPENDENCIES-VerifyResult.cmake new file mode 100644 index 0000000..fec8889 --- /dev/null +++ b/Tests/RunCMake/CPack/RPM/DEPENDENCIES-VerifyResult.cmake @@ -0,0 +1,45 @@ +function(checkDependencies_ FILE TYPE COMPARE_LIST) + set(whitespaces_ "[\t\n\r ]*") + + execute_process(COMMAND ${RPM_EXECUTABLE} -qp --${TYPE} ${FILE} + WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" + OUTPUT_VARIABLE FILE_DEPENDENCIES_ + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + + string(REPLACE "\n" ";" FILE_DEPENDENCIES_LIST_ "${FILE_DEPENDENCIES_}") + + foreach(COMPARE_REGEX_ IN LISTS COMPARE_LIST) + unset(FOUND_) + + foreach(COMPARE_ IN LISTS FILE_DEPENDENCIES_LIST_) + if(COMPARE_ MATCHES "${COMPARE_REGEX_}") + set(FOUND_ true) + break() + endif() + endforeach() + + if(NOT FOUND_) + message(FATAL_ERROR "Missing dependencies in '${FILE}'; check type: '${TYPE}'; file info: '${FILE_DEPENDENCIES_}'; missing: '${COMPARE_REGEX_}'") + endif() + endforeach() +endfunction() + +# TODO add tests for what should not be present in lists +checkDependencies_("${FOUND_FILE_1}" "requires" "depend-application;depend-application-b") +checkDependencies_("${FOUND_FILE_2}" "requires" "depend-application;depend-application-b;libtest_lib\\.so.*") +checkDependencies_("${FOUND_FILE_3}" "requires" "depend-headers") +checkDependencies_("${FOUND_FILE_4}" "requires" "depend-default;depend-default-b") +checkDependencies_("${FOUND_FILE_5}" "requires" "depend-default;depend-default-b") + +checkDependencies_("${FOUND_FILE_1}" "conflicts" "conflict-application;conflict-application-b") +checkDependencies_("${FOUND_FILE_2}" "conflicts" "conflict-application;conflict-application-b") +checkDependencies_("${FOUND_FILE_3}" "conflicts" "conflict-headers") +checkDependencies_("${FOUND_FILE_4}" "conflicts" "conflict-default;conflict-default-b") +checkDependencies_("${FOUND_FILE_5}" "conflicts" "conflict-default;conflict-default-b") + +checkDependencies_("${FOUND_FILE_1}" "provides" "provided-default;provided-default-b") +checkDependencies_("${FOUND_FILE_2}" "provides" "provided-default;provided-default-b") +checkDependencies_("${FOUND_FILE_3}" "provides" "provided-default;provided-default-b") +checkDependencies_("${FOUND_FILE_4}" "provides" "provided-lib") +checkDependencies_("${FOUND_FILE_5}" "provides" "provided-lib_auto;provided-lib_auto-b") diff --git a/Tests/RunCMake/CPack/RPM/DEPENDENCIES-specifics.cmake b/Tests/RunCMake/CPack/RPM/DEPENDENCIES-specifics.cmake new file mode 100644 index 0000000..2cdfece --- /dev/null +++ b/Tests/RunCMake/CPack/RPM/DEPENDENCIES-specifics.cmake @@ -0,0 +1,22 @@ +set(CPACK_RPM_COMPONENT_INSTALL "ON") + +# FIXME auto autoprov is not tested at the moment as Ubuntu 15.04 rpmbuild +# does not use them correctly: https://bugs.launchpad.net/rpm/+bug/1475755 +set(CPACK_RPM_PACKAGE_AUTOREQ "no") +set(CPACK_RPM_PACKAGE_AUTOPROV "no") +set(CPACK_RPM_applications_auto_PACKAGE_AUTOREQPROV "yes") +set(CPACK_RPM_libs_auto_PACKAGE_AUTOREQPROV "yes") + +set(CPACK_RPM_PACKAGE_REQUIRES "depend-default, depend-default-b") +set(CPACK_RPM_applications_PACKAGE_REQUIRES "depend-application, depend-application-b") +set(CPACK_RPM_applications_auto_PACKAGE_REQUIRES "depend-application, depend-application-b") +set(CPACK_RPM_headers_PACKAGE_REQUIRES "depend-headers") + +set(CPACK_RPM_PACKAGE_CONFLICTS "conflict-default, conflict-default-b") +set(CPACK_RPM_applications_PACKAGE_CONFLICTS "conflict-application, conflict-application-b") +set(CPACK_RPM_applications_auto_PACKAGE_CONFLICTS "conflict-application, conflict-application-b") +set(CPACK_RPM_headers_PACKAGE_CONFLICTS "conflict-headers") + +set(CPACK_RPM_PACKAGE_PROVIDES "provided-default, provided-default-b") +set(CPACK_RPM_libs_PACKAGE_PROVIDES "provided-lib") +set(CPACK_RPM_libs_auto_PACKAGE_PROVIDES "provided-lib_auto, provided-lib_auto-b") diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake index 97ef238..3e5714d 100644 --- a/Tests/RunCMake/CPack/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake @@ -7,3 +7,4 @@ include("${RunCMake_SOURCE_DIR}/CPackTestHelpers.cmake") run_cpack_test(MINIMAL "RPM;DEB" false) run_cpack_test(PARTIALLY_RELOCATABLE_WARNING "RPM" false) run_cpack_test(DEB_EXTRA "DEB" false) +run_cpack_test(DEPENDENCIES "RPM;DEB" true) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=105011e08fafe23cb4cfd4fcb1468187f9d81f21 commit 105011e08fafe23cb4cfd4fcb1468187f9d81f21 Author: Domen Vrankar AuthorDate: Wed Jul 29 23:36:11 2015 +0200 Commit: Brad King CommitDate: Thu Aug 6 09:33:50 2015 -0400 Tests/RunCMake/CPack: Bump verify result cmake version Bumped version to current cmake version so that we always use latest policies. diff --git a/Tests/RunCMake/CPack/VerifyResult.cmake b/Tests/RunCMake/CPack/VerifyResult.cmake index e059d9c..96efa9e 100644 --- a/Tests/RunCMake/CPack/VerifyResult.cmake +++ b/Tests/RunCMake/CPack/VerifyResult.cmake @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1 FATAL_ERROR) +cmake_minimum_required(VERSION ${CMAKE_VERSION} FATAL_ERROR) include("${config_file}") include("${src_dir}/${GENERATOR_TYPE}/Helpers.cmake") http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d882d4770fec6d65d82d818b4979cb5763d253c1 commit d882d4770fec6d65d82d818b4979cb5763d253c1 Author: Domen Vrankar AuthorDate: Wed Jul 29 23:34:17 2015 +0200 Commit: Brad King CommitDate: Thu Aug 6 09:33:50 2015 -0400 Tests/RunCMake/CPack/DEB: Add getPackageInfo helper function getPackageInfo helper function returns package info for provided deb package file diff --git a/Tests/RunCMake/CPack/DEB/Helpers.cmake b/Tests/RunCMake/CPack/DEB/Helpers.cmake index 45c85c3..a204a3c 100644 --- a/Tests/RunCMake/CPack/DEB/Helpers.cmake +++ b/Tests/RunCMake/CPack/DEB/Helpers.cmake @@ -26,3 +26,13 @@ function(verifyDebControl FILE PREFIX VERIFY_FILES) endif() endforeach() endfunction() + +function(getPackageInfo FILE RESULT_VAR) + execute_process(COMMAND ${DPKG_EXECUTABLE} -I ${FILE} + WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" + OUTPUT_VARIABLE package_info_ + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + + set(${RESULT_VAR} "${package_info_}" PARENT_SCOPE) +endfunction() http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=145735b748ab04505ab7a885a54fbd175ccecee2 commit 145735b748ab04505ab7a885a54fbd175ccecee2 Author: Domen Vrankar AuthorDate: Wed Jul 29 23:32:13 2015 +0200 Commit: Brad King CommitDate: Thu Aug 6 09:33:22 2015 -0400 Tests/RunCMake/CPack: Enable CXX language in tests Enable CXX language for CPack tests so that they may compile binaries if needed. diff --git a/Tests/RunCMake/CPack/CMakeLists.txt b/Tests/RunCMake/CPack/CMakeLists.txt index 7905706..46f1367 100644 --- a/Tests/RunCMake/CPack/CMakeLists.txt +++ b/Tests/RunCMake/CPack/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.1 FATAL_ERROR) -project(${RunCMake_TEST} NONE) +project(${RunCMake_TEST} CXX) include(${RunCMake_TEST}.cmake) # include test generator specifics ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 6 09:38:18 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 6 Aug 2015 09:38:18 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-697-gd356bce Message-ID: <20150806133818.E062FB15A8@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via d356bced9b362be1396c91854e0684da6ec6f507 (commit) via c4d2f64f3c9dea3a5fcd8af5bb389db00ccd64df (commit) from 42526efec45993466cbc605eb2cee70194eed4a6 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d356bced9b362be1396c91854e0684da6ec6f507 commit d356bced9b362be1396c91854e0684da6ec6f507 Merge: 42526ef c4d2f64 Author: Brad King AuthorDate: Thu Aug 6 09:38:17 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 6 09:38:17 2015 -0400 Merge topic 'fix-missing-subdir-error' c4d2f64f add_subdirectory: Fix error message on missing CMakeLists.txt (#15680) ----------------------------------------------------------------------- Summary of changes: Source/cmMakefile.cxx | 4 ++-- Tests/RunCMake/CMakeLists.txt | 1 + .../{AutoExportDll => add_subdirectory}/CMakeLists.txt | 0 .../DoesNotExist-result.txt} | 0 Tests/RunCMake/add_subdirectory/DoesNotExist-stderr.txt | 5 +++++ Tests/RunCMake/add_subdirectory/DoesNotExist.cmake | 1 + .../Missing-result.txt} | 0 Tests/RunCMake/add_subdirectory/Missing-stderr.txt | 8 ++++++++ Tests/RunCMake/add_subdirectory/Missing.cmake | 1 + .../RunCMake/add_subdirectory/Missing/Missing.txt | 0 Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake | 4 ++++ 11 files changed, 22 insertions(+), 2 deletions(-) copy Tests/RunCMake/{AutoExportDll => add_subdirectory}/CMakeLists.txt (100%) copy Tests/RunCMake/{CMP0004/CMP0004-NEW-result.txt => add_subdirectory/DoesNotExist-result.txt} (100%) create mode 100644 Tests/RunCMake/add_subdirectory/DoesNotExist-stderr.txt create mode 100644 Tests/RunCMake/add_subdirectory/DoesNotExist.cmake copy Tests/RunCMake/{CMP0004/CMP0004-NEW-result.txt => add_subdirectory/Missing-result.txt} (100%) create mode 100644 Tests/RunCMake/add_subdirectory/Missing-stderr.txt create mode 100644 Tests/RunCMake/add_subdirectory/Missing.cmake copy Modules/IntelVSImplicitPath/hello.f => Tests/RunCMake/add_subdirectory/Missing/Missing.txt (100%) create mode 100644 Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 6 09:38:21 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 6 Aug 2015 09:38:21 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-699-g4f0a6d4 Message-ID: <20150806133821.6FB3EB15A9@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 4f0a6d462e1c22d7c681aac5dd77ce73a560f9f2 (commit) via f0609182cc2bbce7f6af557d6352e0c434e7acc2 (commit) from d356bced9b362be1396c91854e0684da6ec6f507 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4f0a6d462e1c22d7c681aac5dd77ce73a560f9f2 commit 4f0a6d462e1c22d7c681aac5dd77ce73a560f9f2 Merge: d356bce f060918 Author: Brad King AuthorDate: Thu Aug 6 09:38:20 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 6 09:38:20 2015 -0400 Merge topic 'compiler-version-Fortran' f0609182 Fortran: Store detected compiler version persistently (#15684) ----------------------------------------------------------------------- Summary of changes: Modules/CMakeFortranCompiler.cmake.in | 1 + 1 file changed, 1 insertion(+) hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 6 09:38:23 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 6 Aug 2015 09:38:23 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-702-g370e2c6 Message-ID: <20150806133823.D4E93B15AA@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 370e2c6785ce9167c9945763505353816780326c (commit) via 12c3f24827d2459154fcc9773b279f96c303e591 (commit) via 6c0e9ee276e9e35a970990baec09c0c2c85b3804 (commit) from 4f0a6d462e1c22d7c681aac5dd77ce73a560f9f2 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=370e2c6785ce9167c9945763505353816780326c commit 370e2c6785ce9167c9945763505353816780326c Merge: 4f0a6d4 12c3f24 Author: Brad King AuthorDate: Thu Aug 6 09:38:22 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 6 09:38:22 2015 -0400 Merge topic 'refactor-evaluation-files' 12c3f248 cmGeneratorExpressionEvaluationFile: Require generator context. 6c0e9ee2 cmMakefile: Store EvaluationFiles. ----------------------------------------------------------------------- Summary of changes: Source/cmFileCommand.cxx | 7 +-- Source/cmGeneratorExpressionEvaluationFile.cxx | 40 +++++++++-------- Source/cmGeneratorExpressionEvaluationFile.h | 15 ++++--- Source/cmGlobalGenerator.cxx | 56 +++--------------------- Source/cmGlobalGenerator.h | 8 ---- Source/cmGlobalNinjaGenerator.cxx | 26 +++++------ Source/cmLocalGenerator.cxx | 48 ++++++++++++++++++++ Source/cmLocalGenerator.h | 2 + Source/cmMakefile.cxx | 21 +++++++++ Source/cmMakefile.h | 9 ++++ 10 files changed, 129 insertions(+), 103 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 6 09:38:26 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 6 Aug 2015 09:38:26 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-712-g73e3de3 Message-ID: <20150806133826.6290BB15B2@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 73e3de381d87a635e303e2076a46cb739466c1a4 (commit) via 757a1f54085af4645ee1946329e24538162ac054 (commit) via 52dbe654dea7562564be9d880540e6bc706998ba (commit) via 65a5e0c671fc7d42525a6279aebf9a74de2c97a7 (commit) via 348354333a82ce98d733dc2ee939186c53c506f9 (commit) via af0de01c6b3395fb1dba5d2ee0a94c19a9b464e9 (commit) via 6ae8b30bf4127011284a66541ed2116fcb45f007 (commit) via a5fc17b5098ee27fd7ae457ca6c5743bacc384a7 (commit) via 0a01e6c6e7bd428ca0ec99a00924b5b498c6e637 (commit) via f0005bb484bc2b85a169ef7816e33d8e2f16e109 (commit) from 370e2c6785ce9167c9945763505353816780326c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=73e3de381d87a635e303e2076a46cb739466c1a4 commit 73e3de381d87a635e303e2076a46cb739466c1a4 Merge: 370e2c6 757a1f5 Author: Brad King AuthorDate: Thu Aug 6 09:38:24 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 6 09:38:24 2015 -0400 Merge topic 'cmState-policies' 757a1f54 cmState: Move PolicyState from cmMakefile. 52dbe654 cmState: Record the end position of each directory. 65a5e0c6 cmLinkedTree: Add Clear API. 34835433 cmState: Add Type for policy scope. af0de01c cmState: Remove call stack parent tracking. 6ae8b30b cmMakefile: Move policy barriers inside cmState scopes. a5fc17b5 cmMakefile: Re-order policy entries and barriers. 0a01e6c6 cmState: Add Snapshot Type accessor. f0005bb4 Tests: Verify generate-time policy scope behavior. diff --cc Source/cmMakefile.cxx index 165e271,a0a36ec..60a11e1 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@@ -236,15 -235,7 +236,10 @@@ cmMakefile::~cmMakefile( cmDeleteAll(this->ImportedTargetsOwned); cmDeleteAll(this->FinalPassCommands); cmDeleteAll(this->FunctionBlockers); + cmDeleteAll(this->EvaluationFiles); + this->EvaluationFiles.clear(); + this->FunctionBlockers.clear(); - if (this->PolicyStack.size() != 1) - { - cmSystemTools::Error("Internal CMake Error, Policy Stack has not been" - " popped properly"); - } } //---------------------------------------------------------------------------- ----------------------------------------------------------------------- Summary of changes: Source/cmLinkedTree.h | 6 + Source/cmMakefile.cxx | 130 ++++----------- Source/cmMakefile.h | 13 -- Source/cmState.cxx | 171 ++++++++++++++++++-- Source/cmState.h | 15 +- Tests/RunCMake/CMakeLists.txt | 1 + .../RunCMake/{Ninja => PolicyScope}/CMakeLists.txt | 2 +- Tests/RunCMake/PolicyScope/RunCMakeTest.cmake | 4 + .../dir-in-macro-generate-time-result.txt} | 0 .../dir-in-macro-generate-time-stderr.txt} | 4 +- .../PolicyScope/dir-in-macro-generate-time.cmake | 2 + .../PolicyScope/dir-in-macro-include.cmake | 6 + Tests/RunCMake/PolicyScope/dir1/CMakeLists.txt | 5 + .../PolicyScope/dir1/foo.cpp} | 0 .../parent-dir-generate-time-result.txt} | 0 .../PolicyScope/parent-dir-generate-time.cmake | 7 + 16 files changed, 235 insertions(+), 131 deletions(-) copy Tests/RunCMake/{Ninja => PolicyScope}/CMakeLists.txt (66%) create mode 100644 Tests/RunCMake/PolicyScope/RunCMakeTest.cmake copy Tests/RunCMake/{CMP0022/CMP0022-WARN-empty-old-result.txt => PolicyScope/dir-in-macro-generate-time-result.txt} (100%) copy Tests/RunCMake/{GeneratorExpression/CMP0044-WARN-stderr.txt => PolicyScope/dir-in-macro-generate-time-stderr.txt} (69%) create mode 100644 Tests/RunCMake/PolicyScope/dir-in-macro-generate-time.cmake create mode 100644 Tests/RunCMake/PolicyScope/dir-in-macro-include.cmake create mode 100644 Tests/RunCMake/PolicyScope/dir1/CMakeLists.txt copy Tests/{CTestTestCycle/simple.cxx => RunCMake/PolicyScope/dir1/foo.cpp} (100%) copy Tests/RunCMake/{CMP0022/CMP0022-WARN-empty-old-result.txt => PolicyScope/parent-dir-generate-time-result.txt} (100%) create mode 100644 Tests/RunCMake/PolicyScope/parent-dir-generate-time.cmake hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 6 09:38:28 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 6 Aug 2015 09:38:28 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-749-g5570650 Message-ID: <20150806133828.A3AC4B15B2@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 55706506c7bd84ded84a85042ac8bd72f4506411 (commit) via a309409ead0bde721a17e8b3c4e89fe6a2181423 (commit) via f83e84028ac28ce098ea76bd857ae1663c295494 (commit) via b3f0e35308993de825f00ec18fc6559e6609c9b0 (commit) via 34c437411dad89c671261269f2067129584a4259 (commit) via 4329a71c128f8a8fca48a8827226d09f61fcbe85 (commit) via c93230ac3838231f2f44986e224da1bdaf9a7dfe (commit) via ee26add4f4062d8b53f22e161027a573dc03399c (commit) via c8a5f5ae60c911298fc3c0f168ac3652223722a4 (commit) via f8076644ce21c5c20cb0d368d25c191a05364481 (commit) via 7c809fa2a675b7e669e76683f73397e38dd22999 (commit) via 6da99de3236fbaeebf6a4fc66f7d68f43a59902f (commit) via d6bb319b09d056428468d8894f7d7dd2cb0d963e (commit) via 7a460852fa1bc9df22d4c54bac3d57f909488608 (commit) via d560bfd2739f2594119c49d82485b99bb4fbbe1f (commit) via 89e2a080e977b9632fa13c627b6a5370250d6ed5 (commit) via 62720e44be3e9f28e4c1e7d38206b2c51d34745e (commit) via e27d737e27fbfc8cfde020ec02d6b2c74afb6885 (commit) via 8d2de00244f8338664c16bd8d8ebb03c6f0cb83f (commit) via 3df705681be123d93146156fec3166b41b19465a (commit) via a45fed81e5fd5d9b280c8dd70d50c9606a982a0b (commit) via f0aa660772565545cbcda9ed8ae946b8d5097416 (commit) via 766839c56da82e12b6986fb5cf7c8d86442615bc (commit) via 47803e6f8e98984e740acf2f7c0a217de58717cd (commit) via 7da4c9d4edbdd6df6aa2a9467d6f32a98fc8cac4 (commit) via 97f10e488a5153e45d6a27a730cc1ecbaae7d559 (commit) via 4b86f5edc91ba649908f5b6ab0fb7f1154e38066 (commit) via 5ff813c7a62d6c37b86bbf9a988a91baa4d5b9e6 (commit) via 38d4ba3564b9a37f8042888ffd63bf736852b6b8 (commit) via 90bad039c44195b742740613a34b90697254fdd2 (commit) via 803a7982b4403c690d7b7fa8c49d00a5abae3471 (commit) via c971338416d7376d8b710b5c18957f6a800b3de0 (commit) via 244c5b5dcdc5af1f91a79a81f7f7ec4047759fe8 (commit) via 12bc571c13eda8d504eac788d6b3e5e8d83e3ad3 (commit) via 41abdc17df99662a8e99ba895050dbc8c0e34b8e (commit) via 1aa13f2b58e477095f76d28a8d9bb1b83a9dd1f5 (commit) via 1ab59f688f647abe1bc0b5e7a187ec0bac988e0f (commit) from 73e3de381d87a635e303e2076a46cb739466c1a4 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=55706506c7bd84ded84a85042ac8bd72f4506411 commit 55706506c7bd84ded84a85042ac8bd72f4506411 Merge: 73e3de3 a309409 Author: Brad King AuthorDate: Thu Aug 6 09:38:27 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 6 09:38:27 2015 -0400 Merge topic 'use-generator-target' a309409e cmOrderDirectories: Port to cmGeneratorTarget. f83e8402 cmGeneratorTarget: Move CompileInfoMap from cmTarget. b3f0e353 cmGeneratorTarget: Move GetCompilePDBDirectory from cmTarget. 34c43741 cmGeneratorTarget: Move GetOutputName from cmTarget. 4329a71c cmComputeLinkDepends: Port to cmGeneratorTarget. c93230ac cmComputeLinkInformation: Port to cmGeneratorTarget. ee26add4 cmGeneratorTarget: Move IsBundleOnApple from cmTarget. c8a5f5ae cmMakefileTargetGenerator: Add accessor for GeneratorTarget. f8076644 cmGeneratorTarget: Move GetLinkClosure from cmTarget. 7c809fa2 cmGeneratorTarget: Move GetLinkerLanguage from cmTarget. 6da99de3 cmGeneratorTarget: Move GetFrameworkDirectory from cmTarget. d6bb319b cmGeneratorTarget: Move GetFullName from cmTarget. 7a460852 cmGeneratorTarget: Move GetAppBundleDirectory from cmTarget. d560bfd2 cmGeneratorTarget: Move GetInstallNameDir* from cmTarget. 89e2a080 cmGeneratorTarget: Move GetMacContentDirectory from cmTarget. 62720e44 cmGeneratorTarget: Move GetFullNameComponents from cmTarget. ... ----------------------------------------------------------------------- Summary of changes: Source/cmCommonTargetGenerator.cxx | 5 +- Source/cmComputeLinkDepends.cxx | 17 +- Source/cmComputeLinkDepends.h | 6 +- Source/cmComputeLinkInformation.cxx | 80 +- Source/cmComputeLinkInformation.h | 6 +- Source/cmExportBuildFileGenerator.cxx | 10 +- Source/cmExportBuildFileGenerator.h | 3 +- Source/cmExportFileGenerator.cxx | 17 +- Source/cmExportFileGenerator.h | 4 +- Source/cmExportInstallFileGenerator.cxx | 12 +- Source/cmExportInstallFileGenerator.h | 3 +- Source/cmExportTryCompileFileGenerator.cxx | 4 +- Source/cmExportTryCompileFileGenerator.h | 2 +- Source/cmGeneratorExpressionNode.cxx | 47 +- Source/cmGeneratorTarget.cxx | 2957 ++++++++++++++++++++---- Source/cmGeneratorTarget.h | 197 +- Source/cmGhsMultiTargetGenerator.cxx | 3 +- Source/cmGlobalNinjaGenerator.cxx | 4 +- Source/cmGlobalUnixMakefileGenerator3.cxx | 6 +- Source/cmGlobalXCodeGenerator.cxx | 27 +- Source/cmInstallTargetGenerator.cxx | 39 +- Source/cmLocalGenerator.cxx | 8 +- Source/cmLocalUnixMakefileGenerator3.cxx | 3 +- Source/cmLocalVisualStudio6Generator.cxx | 40 +- Source/cmLocalVisualStudio7Generator.cxx | 27 +- Source/cmMakefileExecutableTargetGenerator.cxx | 10 +- Source/cmMakefileLibraryTargetGenerator.cxx | 24 +- Source/cmMakefileTargetGenerator.cxx | 17 +- Source/cmMakefileTargetGenerator.h | 1 + Source/cmNinjaNormalTargetGenerator.cxx | 14 +- Source/cmNinjaTargetGenerator.cxx | 9 +- Source/cmOSXBundleGenerator.cxx | 14 +- Source/cmOrderDirectories.cxx | 8 +- Source/cmOrderDirectories.h | 6 +- Source/cmQtAutoGenerators.cxx | 16 +- Source/cmTarget.cxx | 2095 +---------------- Source/cmTarget.h | 183 +- Source/cmVisualStudio10TargetGenerator.cxx | 18 +- 38 files changed, 3006 insertions(+), 2936 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 6 09:38:30 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 6 Aug 2015 09:38:30 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-751-g78141e7 Message-ID: <20150806133830.9E448B15B0@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 78141e799cac1f25e9d21e487ccaea3381a3715d (commit) via 26f5445bb461910efd42bc80a99a63dd53b49643 (commit) from 55706506c7bd84ded84a85042ac8bd72f4506411 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=78141e799cac1f25e9d21e487ccaea3381a3715d commit 78141e799cac1f25e9d21e487ccaea3381a3715d Merge: 5570650 26f5445 Author: Brad King AuthorDate: Thu Aug 6 09:38:29 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 6 09:38:29 2015 -0400 Merge topic 'install-no-runtime-deps-by-default' 26f5445b Do not install 3rd-party dependencies by default ----------------------------------------------------------------------- Summary of changes: CMakeLists.txt | 2 +- Utilities/Release/dash2win64_cygwin.cmake | 1 + Utilities/Release/dash2win64_release.cmake | 1 + Utilities/Release/dashmacmini2_release.cmake | 1 + Utilities/Release/dashmacmini5_release.cmake | 1 + Utilities/Release/linux64_release.cmake | 1 + Utilities/Release/magrathea_release.cmake | 1 + 7 files changed, 7 insertions(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 6 09:38:32 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 6 Aug 2015 09:38:32 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-753-g91c1b13 Message-ID: <20150806133832.A6B7EB15AB@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 91c1b13d6e369190d6c8293d27cda1f6fba160d3 (commit) via 43c94281401cfa89bcbe7110727845ed5df984ec (commit) from 78141e799cac1f25e9d21e487ccaea3381a3715d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=91c1b13d6e369190d6c8293d27cda1f6fba160d3 commit 91c1b13d6e369190d6c8293d27cda1f6fba160d3 Merge: 78141e7 43c9428 Author: Brad King AuthorDate: Thu Aug 6 09:38:31 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 6 09:38:31 2015 -0400 Merge topic 'ninja-LINK_DEPENDS' 43c94281 Ninja: Honor the LINK_DEPENDS target property (#14796) ----------------------------------------------------------------------- Summary of changes: Source/cmNinjaTargetGenerator.cxx | 9 +++++++++ Tests/BuildDepends/CMakeLists.txt | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 6 09:38:34 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 6 Aug 2015 09:38:34 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-760-g2259080 Message-ID: <20150806133834.D8C12B15AD@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 22590805bffe74c3b4998152556561a2c2b6d177 (commit) via 94226751cb9beb7aa1939e9395d4999e30b30600 (commit) via 105011e08fafe23cb4cfd4fcb1468187f9d81f21 (commit) via d882d4770fec6d65d82d818b4979cb5763d253c1 (commit) via 145735b748ab04505ab7a885a54fbd175ccecee2 (commit) via e26f53a88b2fd16fc54513adfbb8eaab26dd102f (commit) via 64aacb24b65e5496b4148437ed96363ae06e8200 (commit) from 91c1b13d6e369190d6c8293d27cda1f6fba160d3 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=22590805bffe74c3b4998152556561a2c2b6d177 commit 22590805bffe74c3b4998152556561a2c2b6d177 Merge: 91c1b13 9422675 Author: Brad King AuthorDate: Thu Aug 6 09:38:33 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 6 09:38:33 2015 -0400 Merge topic 'cpack-rpm-documentation-fixes' 94226751 Tests/RunCMake/CPack: Add dependencies tests 105011e0 Tests/RunCMake/CPack: Bump verify result cmake version d882d477 Tests/RunCMake/CPack/DEB: Add getPackageInfo helper function 145735b7 Tests/RunCMake/CPack: Enable CXX language in tests e26f53a8 CPack/RPM: missing PACKAGE_CONFLICTS documentation 64aacb24 CPack/RPM: undocumented variables ----------------------------------------------------------------------- Summary of changes: Modules/CPackRPM.cmake | 73 ++++++++++++++++++++ Tests/RunCMake/CPack/CMakeLists.txt | 2 +- .../CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake | 14 ++++ .../CPack/DEB/DEPENDENCIES-VerifyResult.cmake | 15 ++++ .../CPack/DEB/DEPENDENCIES-specifics.cmake | 15 ++++ Tests/RunCMake/CPack/DEB/Helpers.cmake | 10 +++ Tests/RunCMake/CPack/DEPENDENCIES.cmake | 18 +++++ .../CPack/RPM/DEPENDENCIES-ExpectedFiles.cmake | 13 ++++ .../CPack/RPM/DEPENDENCIES-VerifyResult.cmake | 45 ++++++++++++ .../CPack/RPM/DEPENDENCIES-specifics.cmake | 22 ++++++ Tests/RunCMake/CPack/RunCMakeTest.cmake | 1 + Tests/RunCMake/CPack/VerifyResult.cmake | 2 +- 12 files changed, 228 insertions(+), 2 deletions(-) create mode 100644 Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake create mode 100644 Tests/RunCMake/CPack/DEB/DEPENDENCIES-VerifyResult.cmake create mode 100644 Tests/RunCMake/CPack/DEB/DEPENDENCIES-specifics.cmake create mode 100644 Tests/RunCMake/CPack/DEPENDENCIES.cmake create mode 100644 Tests/RunCMake/CPack/RPM/DEPENDENCIES-ExpectedFiles.cmake create mode 100644 Tests/RunCMake/CPack/RPM/DEPENDENCIES-VerifyResult.cmake create mode 100644 Tests/RunCMake/CPack/RPM/DEPENDENCIES-specifics.cmake hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 6 09:39:00 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 6 Aug 2015 09:39:00 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2007-ge48c57b Message-ID: <20150806133900.76CDFB15BA@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via e48c57b81341ee14e0ac61f683224b1dd7b544f0 (commit) via 22590805bffe74c3b4998152556561a2c2b6d177 (commit) via 91c1b13d6e369190d6c8293d27cda1f6fba160d3 (commit) via 78141e799cac1f25e9d21e487ccaea3381a3715d (commit) via 55706506c7bd84ded84a85042ac8bd72f4506411 (commit) via 73e3de381d87a635e303e2076a46cb739466c1a4 (commit) via 370e2c6785ce9167c9945763505353816780326c (commit) via 4f0a6d462e1c22d7c681aac5dd77ce73a560f9f2 (commit) via d356bced9b362be1396c91854e0684da6ec6f507 (commit) via 42526efec45993466cbc605eb2cee70194eed4a6 (commit) from 6d0cf23c5d225f629bfc076eac4340cfac28e597 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e48c57b81341ee14e0ac61f683224b1dd7b544f0 commit e48c57b81341ee14e0ac61f683224b1dd7b544f0 Merge: 6d0cf23 2259080 Author: Brad King AuthorDate: Thu Aug 6 09:38:48 2015 -0400 Commit: Brad King CommitDate: Thu Aug 6 09:38:48 2015 -0400 Merge branch 'master' into next ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 6 11:07:27 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 6 Aug 2015 11:07:27 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2009-gf8d61cb Message-ID: <20150806150728.75B83B14D6@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via f8d61cbe5066a6d8ce3e09afc40cdf1ea0e73631 (commit) via 35aab9df9f299d62edaa6ce611aa30614deb9e9d (commit) from e48c57b81341ee14e0ac61f683224b1dd7b544f0 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f8d61cbe5066a6d8ce3e09afc40cdf1ea0e73631 commit f8d61cbe5066a6d8ce3e09afc40cdf1ea0e73631 Merge: e48c57b 35aab9d Author: Brad King AuthorDate: Thu Aug 6 11:07:25 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 6 11:07:25 2015 -0400 Merge topic 'fix-TARGET_FILE-imported' into next 35aab9df Reject TARGET_PDB_FILE for imported targets instead of crashing http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=35aab9df9f299d62edaa6ce611aa30614deb9e9d commit 35aab9df9f299d62edaa6ce611aa30614deb9e9d Author: Brad King AuthorDate: Mon Aug 3 15:28:41 2015 -0400 Commit: Brad King CommitDate: Thu Aug 6 09:42:31 2015 -0400 Reject TARGET_PDB_FILE for imported targets instead of crashing Reported-by: Justin Borodinsky diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index a86c2bc..44a9adb 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1600,6 +1600,13 @@ struct TargetFilesystemArtifactResultCreator cmGeneratorExpressionContext *context, const GeneratorExpressionContent *content) { + if (target->IsImported()) + { + ::reportError(context, content->GetOriginalExpression(), + "TARGET_PDB_FILE not allowed for IMPORTED targets."); + return std::string(); + } + std::string language = target->GetLinkerLanguage(context->Config); std::string pdbSupportVar = "CMAKE_" + language + "_LINKER_SUPPORTS_PDB"; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c831704..e490368 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1248,6 +1248,7 @@ void cmGeneratorTarget::ComputeLinkClosure(const std::string& config, UNORDERED_SET languages; cmTarget::LinkImplementation const* impl = this->Target->GetLinkImplementation(config); + assert(impl); for(std::vector::const_iterator li = impl->Languages.begin(); li != impl->Languages.end(); ++li) { diff --git a/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE-result.txt b/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE-stderr.txt b/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE-stderr.txt new file mode 100644 index 0000000..d915ecb --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at ImportedTarget-TARGET_PDB_FILE.cmake:2 \(add_custom_target\): + Error evaluating generator expression: + + \$ + + TARGET_PDB_FILE not allowed for IMPORTED targets. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE.cmake b/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE.cmake new file mode 100644 index 0000000..c55c5d5 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE.cmake @@ -0,0 +1,2 @@ +add_library(empty UNKNOWN IMPORTED) +add_custom_target(custom COMMAND echo $) diff --git a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake index 1c8fab5..cba3941 100644 --- a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake @@ -26,6 +26,7 @@ run_cmake(COMPILE_LANGUAGE-add_library) run_cmake(COMPILE_LANGUAGE-add_test) run_cmake(COMPILE_LANGUAGE-unknown-lang) +run_cmake(ImportedTarget-TARGET_PDB_FILE) if(LINKER_SUPPORTS_PDB) run_cmake(NonValidTarget-TARGET_PDB_FILE) run_cmake(ValidTarget-TARGET_PDB_FILE) ----------------------------------------------------------------------- Summary of changes: Source/cmGeneratorExpressionNode.cxx | 7 +++++++ Source/cmGeneratorTarget.cxx | 1 + .../ImportedTarget-TARGET_PDB_FILE-result.txt} | 0 ...ILE-stderr.txt => ImportedTarget-TARGET_PDB_FILE-stderr.txt} | 4 ++-- .../GeneratorExpression/ImportedTarget-TARGET_PDB_FILE.cmake | 2 ++ Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake | 1 + 6 files changed, 13 insertions(+), 2 deletions(-) copy Tests/RunCMake/{CMP0004/CMP0004-NEW-result.txt => GeneratorExpression/ImportedTarget-TARGET_PDB_FILE-result.txt} (100%) copy Tests/RunCMake/GeneratorExpression/{NonValidCompiler-TARGET_PDB_FILE-stderr.txt => ImportedTarget-TARGET_PDB_FILE-stderr.txt} (52%) create mode 100644 Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE.cmake hooks/post-receive -- CMake From johnstonj.public at codenest.com Thu Aug 6 13:44:32 2015 From: johnstonj.public at codenest.com (James Johnston) Date: Thu, 6 Aug 2015 13:44:32 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2011-g925cb2e Message-ID: <20150806174432.BA671B0610@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 925cb2ee6c3614195fc1786a3c909ec3092f3b89 (commit) via afeb4eb243e01df5c7396dc346f2629b21115e2c (commit) from f8d61cbe5066a6d8ce3e09afc40cdf1ea0e73631 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=925cb2ee6c3614195fc1786a3c909ec3092f3b89 commit 925cb2ee6c3614195fc1786a3c909ec3092f3b89 Merge: f8d61cb afeb4eb Author: James Johnston AuthorDate: Thu Aug 6 13:44:31 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 6 13:44:31 2015 -0400 Merge topic 'change-nmake-env-warning' into next afeb4eb2 nmake/jom: Only warn about bad VS environment if compiler not found. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=afeb4eb243e01df5c7396dc346f2629b21115e2c commit afeb4eb243e01df5c7396dc346f2629b21115e2c Author: James Johnston AuthorDate: Wed Aug 5 21:23:07 2015 +0000 Commit: James Johnston CommitDate: Thu Aug 6 17:32:43 2015 +0000 nmake/jom: Only warn about bad VS environment if compiler not found. nmake and jom generators no longer warn about missing INCLUDE/LIB environment variables unless the C/CXX compiler cannot be found. This is useful if the user does not want to use these generators with the Visual C++ compiler, or they do not want to enable any language. diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 3402fbc..ec916ae 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -374,6 +374,8 @@ protected: void SetLanguageEnabledFlag(const std::string& l, cmMakefile* mf); void SetLanguageEnabledMaps(const std::string& l, cmMakefile* mf); void FillExtensionToLanguageMap(const std::string& l, cmMakefile* mf); + virtual void PrintCompilerAdvice(std::ostream& os, std::string const& lang, + const char* envVar) const; virtual bool ComputeTargetDepends(); @@ -462,8 +464,6 @@ private: virtual void ForceLinkerLanguages(); - virtual void PrintCompilerAdvice(std::ostream& os, std::string const& lang, - const char* envVar) const; void CheckCompilerIdCompatibility(cmMakefile* mf, std::string const& lang) const; diff --git a/Source/cmGlobalJOMMakefileGenerator.cxx b/Source/cmGlobalJOMMakefileGenerator.cxx index 50e7053..3f33f91 100644 --- a/Source/cmGlobalJOMMakefileGenerator.cxx +++ b/Source/cmGlobalJOMMakefileGenerator.cxx @@ -36,18 +36,6 @@ void cmGlobalJOMMakefileGenerator // pick a default mf->AddDefinition("CMAKE_GENERATOR_CC", "cl"); mf->AddDefinition("CMAKE_GENERATOR_CXX", "cl"); - if(!(cmSystemTools::GetEnv("INCLUDE") && - cmSystemTools::GetEnv("LIB")) - ) - { - std::string message = "To use the JOM generator, cmake must be run " - "from a shell that can use the compiler cl from the command line. " - "This environment does not contain INCLUDE, LIB, or LIBPATH, and " - "these must be set for the cl compiler to work. "; - mf->IssueMessage(cmake::WARNING, - message); - } - this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional); } @@ -58,3 +46,19 @@ void cmGlobalJOMMakefileGenerator entry.Name = cmGlobalJOMMakefileGenerator::GetActualName(); entry.Brief = "Generates JOM makefiles."; } + +//---------------------------------------------------------------------------- +void cmGlobalJOMMakefileGenerator::PrintCompilerAdvice(std::ostream& os, + std::string const& lang, + const char* envVar) const +{ + if(lang == "CXX" || lang == "C") + { + os << + "To use the JOM generator with Visual C++, cmake must be run from a " + "shell that can use the compiler cl from the command line. This " + "environment is unable to invoke the cl compiler. To fix this problem, " + "run cmake from the Visual Studio Command Prompt (vcvarsall.bat).\n"; + } + this->cmGlobalUnixMakefileGenerator3::PrintCompilerAdvice(os, lang, envVar); +} diff --git a/Source/cmGlobalJOMMakefileGenerator.h b/Source/cmGlobalJOMMakefileGenerator.h index 2185b23..1869fed 100644 --- a/Source/cmGlobalJOMMakefileGenerator.h +++ b/Source/cmGlobalJOMMakefileGenerator.h @@ -42,6 +42,9 @@ public: */ virtual void EnableLanguage(std::vectorconst& languages, cmMakefile *, bool optional); +private: + void PrintCompilerAdvice(std::ostream& os, std::string const& lang, + const char* envVar) const; }; #endif diff --git a/Source/cmGlobalNMakeMakefileGenerator.cxx b/Source/cmGlobalNMakeMakefileGenerator.cxx index 4219c34..7c570a6 100644 --- a/Source/cmGlobalNMakeMakefileGenerator.cxx +++ b/Source/cmGlobalNMakeMakefileGenerator.cxx @@ -36,18 +36,6 @@ void cmGlobalNMakeMakefileGenerator // pick a default mf->AddDefinition("CMAKE_GENERATOR_CC", "cl"); mf->AddDefinition("CMAKE_GENERATOR_CXX", "cl"); - if(!(cmSystemTools::GetEnv("INCLUDE") && - cmSystemTools::GetEnv("LIB")) - ) - { - std::string message = "To use the NMake generator, cmake must be run " - "from a shell that can use the compiler cl from the command line. " - "This environment does not contain INCLUDE, LIB, or LIBPATH, and " - "these must be set for the cl compiler to work. "; - mf->IssueMessage(cmake::WARNING, - message); - } - this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional); } @@ -58,3 +46,19 @@ void cmGlobalNMakeMakefileGenerator entry.Name = cmGlobalNMakeMakefileGenerator::GetActualName(); entry.Brief = "Generates NMake makefiles."; } + +//---------------------------------------------------------------------------- +void cmGlobalNMakeMakefileGenerator::PrintCompilerAdvice(std::ostream& os, + std::string const& lang, + const char* envVar) const +{ + if(lang == "CXX" || lang == "C") + { + os << + "To use the NMake generator with Visual C++, cmake must be run from a " + "shell that can use the compiler cl from the command line. This " + "environment is unable to invoke the cl compiler. To fix this problem, " + "run cmake from the Visual Studio Command Prompt (vcvarsall.bat).\n"; + } + this->cmGlobalUnixMakefileGenerator3::PrintCompilerAdvice(os, lang, envVar); +} diff --git a/Source/cmGlobalNMakeMakefileGenerator.h b/Source/cmGlobalNMakeMakefileGenerator.h index dd72c49..3c8375a 100644 --- a/Source/cmGlobalNMakeMakefileGenerator.h +++ b/Source/cmGlobalNMakeMakefileGenerator.h @@ -40,6 +40,9 @@ public: */ virtual void EnableLanguage(std::vectorconst& languages, cmMakefile *, bool optional); +private: + void PrintCompilerAdvice(std::ostream& os, std::string const& lang, + const char* envVar) const; }; #endif diff --git a/Tests/RunCMake/CompilerNotFound/BadCompilerC-stderr-JOM.txt b/Tests/RunCMake/CompilerNotFound/BadCompilerC-stderr-JOM.txt new file mode 100644 index 0000000..b7db7eb --- /dev/null +++ b/Tests/RunCMake/CompilerNotFound/BadCompilerC-stderr-JOM.txt @@ -0,0 +1,17 @@ +CMake Error at BadCompilerC.cmake:2 \(enable_language\): + The CMAKE_C_COMPILER: + + no-C-compiler + + is not a full path and was not found in the PATH. + + To use the JOM generator with Visual C\+\+, cmake must be run from a shell + that can use the compiler cl from the command line. This environment is + unable to invoke the cl compiler. To fix this problem, run cmake from the + Visual Studio Command Prompt \(vcvarsall.bat\). + + Tell CMake where to find the compiler by setting either the environment + variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to + the compiler, or to the compiler name if it is in the PATH. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/CompilerNotFound/BadCompilerC-stderr-NMake.txt b/Tests/RunCMake/CompilerNotFound/BadCompilerC-stderr-NMake.txt new file mode 100644 index 0000000..03c5933 --- /dev/null +++ b/Tests/RunCMake/CompilerNotFound/BadCompilerC-stderr-NMake.txt @@ -0,0 +1,17 @@ +CMake Error at BadCompilerC.cmake:2 \(enable_language\): + The CMAKE_C_COMPILER: + + no-C-compiler + + is not a full path and was not found in the PATH. + + To use the NMake generator with Visual C\+\+, cmake must be run from a shell + that can use the compiler cl from the command line. This environment is + unable to invoke the cl compiler. To fix this problem, run cmake from the + Visual Studio Command Prompt \(vcvarsall.bat\). + + Tell CMake where to find the compiler by setting either the environment + variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to + the compiler, or to the compiler name if it is in the PATH. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/CompilerNotFound/BadCompilerCXX-stderr-JOM.txt b/Tests/RunCMake/CompilerNotFound/BadCompilerCXX-stderr-JOM.txt new file mode 100644 index 0000000..4b42ea6 --- /dev/null +++ b/Tests/RunCMake/CompilerNotFound/BadCompilerCXX-stderr-JOM.txt @@ -0,0 +1,17 @@ +CMake Error at BadCompilerCXX.cmake:2 \(enable_language\): + The CMAKE_CXX_COMPILER: + + no-CXX-compiler + + is not a full path and was not found in the PATH. + + To use the JOM generator with Visual C\+\+, cmake must be run from a shell + that can use the compiler cl from the command line. This environment is + unable to invoke the cl compiler. To fix this problem, run cmake from the + Visual Studio Command Prompt \(vcvarsall.bat\). + + Tell CMake where to find the compiler by setting either the environment + variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path + to the compiler, or to the compiler name if it is in the PATH. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/CompilerNotFound/BadCompilerCXX-stderr-NMake.txt b/Tests/RunCMake/CompilerNotFound/BadCompilerCXX-stderr-NMake.txt new file mode 100644 index 0000000..1bfcdcc --- /dev/null +++ b/Tests/RunCMake/CompilerNotFound/BadCompilerCXX-stderr-NMake.txt @@ -0,0 +1,17 @@ +CMake Error at BadCompilerCXX.cmake:2 \(enable_language\): + The CMAKE_CXX_COMPILER: + + no-CXX-compiler + + is not a full path and was not found in the PATH. + + To use the NMake generator with Visual C\+\+, cmake must be run from a shell + that can use the compiler cl from the command line. This environment is + unable to invoke the cl compiler. To fix this problem, run cmake from the + Visual Studio Command Prompt \(vcvarsall.bat\). + + Tell CMake where to find the compiler by setting either the environment + variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path + to the compiler, or to the compiler name if it is in the PATH. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/CompilerNotFound/BadCompilerCandCXX-stderr-JOM.txt b/Tests/RunCMake/CompilerNotFound/BadCompilerCandCXX-stderr-JOM.txt new file mode 100644 index 0000000..f25a267 --- /dev/null +++ b/Tests/RunCMake/CompilerNotFound/BadCompilerCandCXX-stderr-JOM.txt @@ -0,0 +1,35 @@ +CMake Error at BadCompilerCandCXX.cmake:3 \(project\): + The CMAKE_C_COMPILER: + + no-C-compiler + + is not a full path and was not found in the PATH. + + To use the JOM generator with Visual C\+\+, cmake must be run from a shell + that can use the compiler cl from the command line. This environment is + unable to invoke the cl compiler. To fix this problem, run cmake from the + Visual Studio Command Prompt \(vcvarsall.bat\). + + Tell CMake where to find the compiler by setting either the environment + variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to + the compiler, or to the compiler name if it is in the PATH. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at BadCompilerCandCXX.cmake:3 \(project\): + The CMAKE_CXX_COMPILER: + + no-CXX-compiler + + is not a full path and was not found in the PATH. + + To use the JOM generator with Visual C\+\+, cmake must be run from a shell + that can use the compiler cl from the command line. This environment is + unable to invoke the cl compiler. To fix this problem, run cmake from the + Visual Studio Command Prompt \(vcvarsall.bat\). + + Tell CMake where to find the compiler by setting either the environment + variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path + to the compiler, or to the compiler name if it is in the PATH. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/CompilerNotFound/BadCompilerCandCXX-stderr-NMake.txt b/Tests/RunCMake/CompilerNotFound/BadCompilerCandCXX-stderr-NMake.txt new file mode 100644 index 0000000..ffcdce8 --- /dev/null +++ b/Tests/RunCMake/CompilerNotFound/BadCompilerCandCXX-stderr-NMake.txt @@ -0,0 +1,35 @@ +CMake Error at BadCompilerCandCXX.cmake:3 \(project\): + The CMAKE_C_COMPILER: + + no-C-compiler + + is not a full path and was not found in the PATH. + + To use the NMake generator with Visual C\+\+, cmake must be run from a shell + that can use the compiler cl from the command line. This environment is + unable to invoke the cl compiler. To fix this problem, run cmake from the + Visual Studio Command Prompt \(vcvarsall.bat\). + + Tell CMake where to find the compiler by setting either the environment + variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to + the compiler, or to the compiler name if it is in the PATH. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at BadCompilerCandCXX.cmake:3 \(project\): + The CMAKE_CXX_COMPILER: + + no-CXX-compiler + + is not a full path and was not found in the PATH. + + To use the NMake generator with Visual C\+\+, cmake must be run from a shell + that can use the compiler cl from the command line. This environment is + unable to invoke the cl compiler. To fix this problem, run cmake from the + Visual Studio Command Prompt \(vcvarsall.bat\). + + Tell CMake where to find the compiler by setting either the environment + variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path + to the compiler, or to the compiler name if it is in the PATH. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/CompilerNotFound/RunCMakeTest.cmake b/Tests/RunCMake/CompilerNotFound/RunCMakeTest.cmake index 8b84f39..19d149c 100644 --- a/Tests/RunCMake/CompilerNotFound/RunCMakeTest.cmake +++ b/Tests/RunCMake/CompilerNotFound/RunCMakeTest.cmake @@ -4,6 +4,20 @@ if("${RunCMake_GENERATOR}" MATCHES "Visual Studio|Xcode") run_cmake(NoCompilerC-IDE) run_cmake(NoCompilerCXX-IDE) run_cmake(NoCompilerCandCXX-IDE) +elseif(RunCMake_GENERATOR STREQUAL "NMake Makefiles") + set(RunCMake-stderr-file BadCompilerC-stderr-NMake.txt) + run_cmake(BadCompilerC) + set(RunCMake-stderr-file BadCompilerCXX-stderr-NMake.txt) + run_cmake(BadCompilerCXX) + set(RunCMake-stderr-file BadCompilerCandCXX-stderr-NMake.txt) + run_cmake(BadCompilerCandCXX) +elseif(RunCMake_GENERATOR STREQUAL "NMake Makefiles JOM") + set(RunCMake-stderr-file BadCompilerC-stderr-JOM.txt) + run_cmake(BadCompilerC) + set(RunCMake-stderr-file BadCompilerCXX-stderr-JOM.txt) + run_cmake(BadCompilerCXX) + set(RunCMake-stderr-file BadCompilerCandCXX-stderr-JOM.txt) + run_cmake(BadCompilerCandCXX) else() run_cmake(BadCompilerC) run_cmake(BadCompilerCXX) ----------------------------------------------------------------------- Summary of changes: Source/cmGlobalGenerator.h | 4 +-- Source/cmGlobalJOMMakefileGenerator.cxx | 28 +++++++++++--------- Source/cmGlobalJOMMakefileGenerator.h | 3 +++ Source/cmGlobalNMakeMakefileGenerator.cxx | 28 +++++++++++--------- Source/cmGlobalNMakeMakefileGenerator.h | 3 +++ ...lerC-stderr.txt => BadCompilerC-stderr-JOM.txt} | 5 ++++ ...rC-stderr.txt => BadCompilerC-stderr-NMake.txt} | 5 ++++ ...XX-stderr.txt => BadCompilerCXX-stderr-JOM.txt} | 5 ++++ ...-stderr.txt => BadCompilerCXX-stderr-NMake.txt} | 5 ++++ ...tderr.txt => BadCompilerCandCXX-stderr-JOM.txt} | 10 +++++++ ...err.txt => BadCompilerCandCXX-stderr-NMake.txt} | 10 +++++++ Tests/RunCMake/CompilerNotFound/RunCMakeTest.cmake | 14 ++++++++++ 12 files changed, 94 insertions(+), 26 deletions(-) copy Tests/RunCMake/CompilerNotFound/{BadCompilerC-stderr.txt => BadCompilerC-stderr-JOM.txt} (61%) copy Tests/RunCMake/CompilerNotFound/{BadCompilerC-stderr.txt => BadCompilerC-stderr-NMake.txt} (60%) copy Tests/RunCMake/CompilerNotFound/{BadCompilerCXX-stderr.txt => BadCompilerCXX-stderr-JOM.txt} (61%) copy Tests/RunCMake/CompilerNotFound/{BadCompilerCXX-stderr.txt => BadCompilerCXX-stderr-NMake.txt} (61%) copy Tests/RunCMake/CompilerNotFound/{BadCompilerCandCXX-stderr.txt => BadCompilerCandCXX-stderr-JOM.txt} (61%) copy Tests/RunCMake/CompilerNotFound/{BadCompilerCandCXX-stderr.txt => BadCompilerCandCXX-stderr-NMake.txt} (60%) hooks/post-receive -- CMake From johnstonj.public at codenest.com Thu Aug 6 14:02:06 2015 From: johnstonj.public at codenest.com (James Johnston) Date: Thu, 6 Aug 2015 14:02:06 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2015-g3f834d0 Message-ID: <20150806180206.8B221B14B6@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 3f834d0477db40bfb619b19ca66969e04d36a323 (commit) via d035e9687a2d28e2f64ec3a316f8abea57e49d63 (commit) via 38ed5866ed212effe0217f193f728ee54ea7378b (commit) via 772ca69f803a8f294d6e04f9e258becc35179233 (commit) from 925cb2ee6c3614195fc1786a3c909ec3092f3b89 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3f834d0477db40bfb619b19ca66969e04d36a323 commit 3f834d0477db40bfb619b19ca66969e04d36a323 Merge: 925cb2e d035e96 Author: James Johnston AuthorDate: Thu Aug 6 14:02:05 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 6 14:02:05 2015 -0400 Merge topic 'fix-get-filename-component' into next d035e968 get_filename_component: Fix bug where CACHE was ignored. 38ed5866 get_filename_component: Added initial tests for PROGRAM component. 772ca69f get_filename_component: Tests now check for proper CACHE usage. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d035e9687a2d28e2f64ec3a316f8abea57e49d63 commit d035e9687a2d28e2f64ec3a316f8abea57e49d63 Author: James Johnston AuthorDate: Wed Aug 5 00:33:59 2015 -0400 Commit: James Johnston CommitDate: Thu Aug 6 17:53:34 2015 +0000 get_filename_component: Fix bug where CACHE was ignored. If PROGRAM_ARGS is provided to get_filename_component, fix bug where the command failed to honor the CACHE argument. Added test cases to RunCMake.get_filename_component that fail when the bug is not fixed to prevent regressions. Signed-off-by: James Johnston diff --git a/Source/cmGetFilenameComponentCommand.cxx b/Source/cmGetFilenameComponentCommand.cxx index 67f9f2d..13a9afb 100644 --- a/Source/cmGetFilenameComponentCommand.cxx +++ b/Source/cmGetFilenameComponentCommand.cxx @@ -24,7 +24,7 @@ bool cmGetFilenameComponentCommand // Check and see if the value has been stored in the cache // already, if so use that value - if(args.size() == 4 && args[3] == "CACHE") + if(args.size() >= 4 && args[args.size() - 1] == "CACHE") { const char* cacheValue = this->Makefile->GetDefinition(args[0]); if(cacheValue && !cmSystemTools::IsNOTFOUND(cacheValue)) @@ -111,7 +111,7 @@ bool cmGetFilenameComponentCommand return false; } - if(args.size() == 4 && args[3] == "CACHE") + if(args.size() >= 4 && args[args.size() - 1] == "CACHE") { if(!programArgs.empty() && !storeArgs.empty()) { diff --git a/Tests/RunCMake/get_filename_component/KnownComponents.cmake b/Tests/RunCMake/get_filename_component/KnownComponents.cmake index 1532792..386109f 100644 --- a/Tests/RunCMake/get_filename_component/KnownComponents.cmake +++ b/Tests/RunCMake/get_filename_component/KnownComponents.cmake @@ -62,6 +62,38 @@ check("CACHE 3" "${test_cache}" "/path/to/other") list(APPEND cache_vars test_cache) +# Test the PROGRAM component type with CACHE specified. + +# 1. Make sure it makes a cache variable in the first place for basic usage: +get_filename_component(test_cache_program_name_1 "/ arg1 arg2" PROGRAM CACHE) +check("PROGRAM CACHE 1 with no args output" "${test_cache_program_name_1}" "/") +list(APPEND cache_vars test_cache_program_name_1) + +# 2. Set some existing cache variables & make sure the function returns them: +set(test_cache_program_name_2 DummyProgramName CACHE FILEPATH "") +get_filename_component(test_cache_program_name_2 "/ arg1 arg2" PROGRAM CACHE) +check("PROGRAM CACHE 2 with no args output" "${test_cache_program_name_2}" + "DummyProgramName") +list(APPEND cache_vars test_cache_program_name_2) + +# 3. Now test basic usage when PROGRAM_ARGS is used: +get_filename_component(test_cache_program_name_3 "/ arg1 arg2" PROGRAM + PROGRAM_ARGS test_cache_program_args_3 CACHE) +check("PROGRAM CACHE 3 name" "${test_cache_program_name_3}" "/") +check("PROGRAM CACHE 3 args" "${test_cache_program_args_3}" " arg1 arg2") +list(APPEND cache_vars test_cache_program_name_3) +list(APPEND cache_vars test_cache_program_args_3) + +# 4. Test that existing cache variables are returned when PROGRAM_ARGS is used: +set(test_cache_program_name_4 DummyPgm CACHE FILEPATH "") +set(test_cache_program_args_4 DummyArgs CACHE STRING "") +get_filename_component(test_cache_program_name_4 "/ arg1 arg2" PROGRAM + PROGRAM_ARGS test_cache_program_args_4 CACHE) +check("PROGRAM CACHE 4 name" "${test_cache_program_name_4}" "DummyPgm") +check("PROGRAM CACHE 4 args" "${test_cache_program_args_4}" "DummyArgs") +list(APPEND cache_vars test_cache_program_name_4) +list(APPEND cache_vars test_cache_program_name_4) + # Test that ONLY the expected cache variables were created. get_cmake_property(current_cache_vars CACHE_VARIABLES) get_cmake_property(current_vars VARIABLES) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=38ed5866ed212effe0217f193f728ee54ea7378b commit 38ed5866ed212effe0217f193f728ee54ea7378b Author: James Johnston AuthorDate: Wed Aug 5 00:30:58 2015 -0400 Commit: James Johnston CommitDate: Thu Aug 6 17:53:25 2015 +0000 get_filename_component: Added initial tests for PROGRAM component. The RunCMake.get_filename_component test now tests basic functionality of the PROGRAM component argument of get_filename_component. Signed-off-by: James Johnston diff --git a/Tests/RunCMake/get_filename_component/KnownComponents.cmake b/Tests/RunCMake/get_filename_component/KnownComponents.cmake index 3f20e1a..1532792 100644 --- a/Tests/RunCMake/get_filename_component/KnownComponents.cmake +++ b/Tests/RunCMake/get_filename_component/KnownComponents.cmake @@ -38,6 +38,18 @@ check("ABSOLUTE .. in windows root" "${test_absolute}" "c:/path/to/filename.ext. list(APPEND non_cache_vars test_absolute) +# Test the PROGRAM component type. +get_filename_component(test_program_name "/ arg1 arg2" PROGRAM) +check("PROGRAM with no args output" "${test_program_name}" "/") + +get_filename_component(test_program_name "/ arg1 arg2" PROGRAM + PROGRAM_ARGS test_program_args) +check("PROGRAM with args output: name" "${test_program_name}" "/") +check("PROGRAM with args output: args" "${test_program_args}" " arg1 arg2") + +list(APPEND non_cache_vars test_program_name) +list(APPEND non_cache_vars test_program_args) + # Test CACHE parameter for most component types. get_filename_component(test_cache "/path/to/filename.ext.in" DIRECTORY CACHE) check("CACHE 1" "${test_cache}" "/path/to") http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=772ca69f803a8f294d6e04f9e258becc35179233 commit 772ca69f803a8f294d6e04f9e258becc35179233 Author: James Johnston AuthorDate: Tue Aug 4 23:47:38 2015 -0400 Commit: James Johnston CommitDate: Thu Aug 6 17:53:12 2015 +0000 get_filename_component: Tests now check for proper CACHE usage. The RunCMake.get_filename_component test was improved to assert that each test variable outputted by get_filename_component is or is not a cache variable, as per the particular test. Signed-off-by: James Johnston diff --git a/Tests/RunCMake/get_filename_component/CMakeLists.txt b/Tests/RunCMake/get_filename_component/CMakeLists.txt index 12cd3c7..74b3ff8 100644 --- a/Tests/RunCMake/get_filename_component/CMakeLists.txt +++ b/Tests/RunCMake/get_filename_component/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 3.3) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/get_filename_component/KnownComponents.cmake b/Tests/RunCMake/get_filename_component/KnownComponents.cmake index 9d7cf90..3f20e1a 100644 --- a/Tests/RunCMake/get_filename_component/KnownComponents.cmake +++ b/Tests/RunCMake/get_filename_component/KnownComponents.cmake @@ -1,9 +1,11 @@ +# Assertion macro macro(check desc actual expect) if(NOT "x${actual}" STREQUAL "x${expect}") message(SEND_ERROR "${desc}: got \"${actual}\", not \"${expect}\"") endif() endmacro() +# General test of all component types given an absolute path. set(filename "/path/to/filename.ext.in") set(expect_DIRECTORY "/path/to") set(expect_NAME "filename.ext.in") @@ -13,14 +15,19 @@ set(expect_PATH "/path/to") foreach(c DIRECTORY NAME EXT NAME_WE PATH) get_filename_component(actual_${c} "${filename}" ${c}) check("${c}" "${actual_${c}}" "${expect_${c}}") + list(APPEND non_cache_vars actual_${c}) endforeach() +# Test Windows paths with DIRECTORY component and an absolute Windows path. get_filename_component(test_slashes "c:\\path\\to\\filename.ext.in" DIRECTORY) check("DIRECTORY from backslashes" "${test_slashes}" "c:/path/to") +list(APPEND non_cache_vars test_slashes) get_filename_component(test_winroot "c:\\filename.ext.in" DIRECTORY) check("DIRECTORY in windows root" "${test_winroot}" "c:/") +list(APPEND non_cache_vars test_winroot) +# Test finding absolute paths. get_filename_component(test_absolute "/path/to/a/../filename.ext.in" ABSOLUTE) check("ABSOLUTE" "${test_absolute}" "/path/to/filename.ext.in") @@ -29,10 +36,36 @@ check("ABSOLUTE .. in root" "${test_absolute}" "/path/to/filename.ext.in") get_filename_component(test_absolute "c:/../path/to/filename.ext.in" ABSOLUTE) check("ABSOLUTE .. in windows root" "${test_absolute}" "c:/path/to/filename.ext.in") +list(APPEND non_cache_vars test_absolute) + +# Test CACHE parameter for most component types. get_filename_component(test_cache "/path/to/filename.ext.in" DIRECTORY CACHE) check("CACHE 1" "${test_cache}" "/path/to") +# Make sure that the existing CACHE entry from previous is honored: get_filename_component(test_cache "/path/to/other/filename.ext.in" DIRECTORY CACHE) check("CACHE 2" "${test_cache}" "/path/to") unset(test_cache CACHE) get_filename_component(test_cache "/path/to/other/filename.ext.in" DIRECTORY CACHE) check("CACHE 3" "${test_cache}" "/path/to/other") + +list(APPEND cache_vars test_cache) + +# Test that ONLY the expected cache variables were created. +get_cmake_property(current_cache_vars CACHE_VARIABLES) +get_cmake_property(current_vars VARIABLES) + +foreach(thisVar ${cache_vars}) + if(NOT thisVar IN_LIST current_cache_vars) + message(SEND_ERROR "${thisVar} expected in cache but was not found.") + endif() +endforeach() + +foreach(thisVar ${non_cache_vars}) + if(thisVar IN_LIST current_cache_vars) + message(SEND_ERROR "${thisVar} unexpectedly found in cache.") + endif() + if(NOT thisVar IN_LIST current_vars) + # Catch likely typo when appending to non_cache_vars: + message(SEND_ERROR "${thisVar} not found in regular variable list.") + endif() +endforeach() ----------------------------------------------------------------------- Summary of changes: Source/cmGetFilenameComponentCommand.cxx | 4 +- .../RunCMake/get_filename_component/CMakeLists.txt | 2 +- .../get_filename_component/KnownComponents.cmake | 77 ++++++++++++++++++++ 3 files changed, 80 insertions(+), 3 deletions(-) hooks/post-receive -- CMake From steveire at gmail.com Thu Aug 6 18:32:52 2015 From: steveire at gmail.com (Stephen Kelly) Date: Thu, 6 Aug 2015 18:32:52 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2018-gd78e968 Message-ID: <20150806223252.5F73DB120E@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via d78e96868e693343cef845dff140432d08e543db (commit) via 1689c91d8d7667426fdca694d801b6189f68d37e (commit) via dd11f72ced8a5a42ae0a1d7ca8a51b94e670a66f (commit) from 3f834d0477db40bfb619b19ca66969e04d36a323 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d78e96868e693343cef845dff140432d08e543db commit d78e96868e693343cef845dff140432d08e543db Merge: 3f834d0 1689c91 Author: Stephen Kelly AuthorDate: Thu Aug 6 18:32:51 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 6 18:32:51 2015 -0400 Merge topic 'rm-Makefile-LocalGenerator' into next 1689c91d cmMakefile: Remove unused method. dd11f72c cmGlobalGenerator: Base exclusion computation on cmGeneratorTarget. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1689c91d8d7667426fdca694d801b6189f68d37e commit 1689c91d8d7667426fdca694d801b6189f68d37e Author: Stephen Kelly AuthorDate: Sat Jun 6 14:27:52 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 00:32:15 2015 +0200 cmMakefile: Remove unused method. diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 27e5bce..1c4da00 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -114,10 +114,6 @@ public: bool GetIsSourceFileTryCompile() const; - ///! Get the current makefile generator. - cmLocalGenerator* GetLocalGenerator() const - { return this->LocalGenerator;} - /** * Help enforce global target name uniqueness. */ http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=dd11f72ced8a5a42ae0a1d7ca8a51b94e670a66f commit dd11f72ced8a5a42ae0a1d7ca8a51b94e670a66f Author: Stephen Kelly AuthorDate: Sat Jun 6 14:09:35 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 00:32:15 2015 +0200 cmGlobalGenerator: Base exclusion computation on cmGeneratorTarget. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 3c818ff..bc3c255 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2054,10 +2054,10 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, } bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, - cmTarget const& target) const + cmGeneratorTarget* target) const { - if(target.GetType() == cmTarget::INTERFACE_LIBRARY - || target.GetPropertyAsBool("EXCLUDE_FROM_ALL")) + if(target->GetType() == cmTarget::INTERFACE_LIBRARY + || target->Target->GetPropertyAsBool("EXCLUDE_FROM_ALL")) { // This target is excluded from its directory. return true; @@ -2066,7 +2066,7 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, { // This target is included in its directory. Check whether the // directory is excluded. - return this->IsExcluded(root, target.GetMakefile()->GetLocalGenerator()); + return this->IsExcluded(root, target->GetLocalGenerator()); } } @@ -2127,15 +2127,16 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap() { cmTarget const& target = t->second; + cmGeneratorTarget* gt = this->GetGeneratorTarget(&target); + // Consider the directory containing the target and all its // parents until something excludes the target. - for(cmLocalGenerator* clg = lg; clg && !this->IsExcluded(clg, target); + for(cmLocalGenerator* clg = lg; clg && !this->IsExcluded(clg, gt); clg = clg->GetParent()) { // This local generator includes the target. std::set& targetSet = this->LocalGeneratorToTargetMap[clg]; - cmGeneratorTarget* gt = this->GetGeneratorTarget(&target); targetSet.insert(gt); // Add dependencies of the included target. An excluded diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 3402fbc..608b59c 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -391,7 +391,7 @@ protected: void FillProjectMap(); void CheckLocalGenerators(); bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen) const; - bool IsExcluded(cmLocalGenerator* root, cmTarget const& target) const; + bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) const; void FillLocalGeneratorToTargetMap(); void CreateDefaultGlobalTargets(cmTargets* targets); cmTarget CreateGlobalTarget(const std::string& name, const char* message, diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 2a749c1..47822b4 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -289,7 +289,7 @@ public: const std::vector& GetLocalGenerators() const { return LocalGenerators; } - bool IsExcluded(cmLocalGenerator* root, cmTarget& target) { + bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) { return cmGlobalGenerator::IsExcluded(root, target); } int GetRuleCmdLength(const std::string& name) { diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 69747a4..76d059ee 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -821,7 +821,7 @@ cmGlobalUnixMakefileGenerator3 localName, depends, commands, true); // add the all/all dependency - if(!this->IsExcluded(this->LocalGenerators[0], *gtarget->Target)) + if(!this->IsExcluded(this->LocalGenerators[0], gtarget)) { depends.clear(); depends.push_back(localName); @@ -889,7 +889,7 @@ cmGlobalUnixMakefileGenerator3 "Pre-install relink rule for target.", localName, depends, commands, true); - if(!this->IsExcluded(this->LocalGenerators[0], *gtarget->Target)) + if(!this->IsExcluded(this->LocalGenerators[0], gtarget)) { depends.clear(); depends.push_back(localName); diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 2f9d79a..cf1be5c 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -111,17 +111,19 @@ bool cmGlobalVisualStudioGenerator::Compute() for(std::vector::iterator i = gen.begin(); i != gen.end(); ++i) { - cmTargets& targets = (*i)->GetMakefile()->GetTargets(); - for(cmTargets::iterator t = targets.begin(); + cmGeneratorTargetsType targets = + (*i)->GetMakefile()->GetGeneratorTargets(); + for(cmGeneratorTargetsType::iterator t = targets.begin(); t != targets.end(); ++t) { - if (t->second.GetType() == cmTarget::GLOBAL_TARGET) + if (t->second->GetType() == cmTarget::GLOBAL_TARGET + || t->first->IsImported()) { continue; } if(!this->IsExcluded(gen[0], t->second)) { - allBuild->AddUtility(t->second.GetName()); + allBuild->AddUtility(t->second->GetName()); } } } diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 9889bd4..1822c97 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -90,7 +90,7 @@ void cmLocalNinjaGenerator::Generate() // Add the target to "all" if required. if (!this->GetGlobalNinjaGenerator()->IsExcluded( this->GetGlobalNinjaGenerator()->GetLocalGenerators()[0], - *t->second->Target)) + t->second)) this->GetGlobalNinjaGenerator()->AddDependencyToAll(t->second->Target); delete tg; } ----------------------------------------------------------------------- Summary of changes: Source/cmGlobalGenerator.cxx | 13 +++++++------ Source/cmGlobalGenerator.h | 2 +- Source/cmGlobalNinjaGenerator.h | 2 +- Source/cmGlobalUnixMakefileGenerator3.cxx | 4 ++-- Source/cmGlobalVisualStudioGenerator.cxx | 10 ++++++---- Source/cmLocalNinjaGenerator.cxx | 2 +- Source/cmMakefile.h | 4 ---- 7 files changed, 18 insertions(+), 19 deletions(-) hooks/post-receive -- CMake From steveire at gmail.com Thu Aug 6 18:36:56 2015 From: steveire at gmail.com (Stephen Kelly) Date: Thu, 6 Aug 2015 18:36:56 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2033-g026814a Message-ID: <20150806223656.5F575B133F@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 026814ad56e9da194baa1597a4de222227920ca5 (commit) via 97eb20f5421c5cfff2df84617404686089ea71fc (commit) via 2d60391127bb5be1b4d55a44f8fbc406a3c4eff6 (commit) via efb9ccca7fd0bb2ca0ec6f4f65d0b4f0ccb83ad4 (commit) via f62f61a08402f7e4239674fd03a6e93631017021 (commit) via ad2b607bf7d072fe3c7363446cb81884be7f4221 (commit) via a58ead9b2f2c8810d8841975ab18486cacb149e9 (commit) via 7965ba9d008172695aeeb48d327e3942c3684fa9 (commit) via a57b7aa45efdad49fc8ba2c9ea0525ab5c991b2c (commit) via d8d6f19e30d0568f1af1297dd616fba0901c388e (commit) via 76d273e3fbab5af282a6402f66820ed926da7717 (commit) via 0c86673edbb9956dc29c31242e244fb1b02013c7 (commit) via ef2771706a641607c146edc738f76e0205ed8577 (commit) via 13b878b534dbfeb2995569f486e3b0684ef584aa (commit) via 2ee3bd6f3e99be2dc1bf2b3111681838f0b8d268 (commit) from d78e96868e693343cef845dff140432d08e543db (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=026814ad56e9da194baa1597a4de222227920ca5 commit 026814ad56e9da194baa1597a4de222227920ca5 Merge: d78e968 97eb20f Author: Stephen Kelly AuthorDate: Thu Aug 6 18:36:53 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 6 18:36:53 2015 -0400 Merge topic 'global-generator-makefiles' into next 97eb20f5 cmQtAutoGenerators: Prefer a generator to access global generator. 2d603911 cmGlobalGenerator: Port Find API to cmMakefile. efb9ccca cmGlobalGenerator: Create global targets from cmMakefiles. f62f61a0 cmGlobalGenerator: Port global target creation to cmMakefile. ad2b607b cmGlobalGenerator: Port Configure-time check to cmMakefile. a58ead9b cmGlobalGenerator: Base final target property computation on Makefiles. 7965ba9d cmGlobalGenerator: Base progress on Makefiles, not LocalGenerators. a57b7aa4 cmExportLibraryDependenciesCommand: Port to cmMakefile. d8d6f19e cmGlobalGenerator: Port configure-time code to cmMakefile. 76d273e3 cmake: Port configure-time code to cmMakefile. 0c86673e cmGlobalGenerator: Store a container of cmMakefiles. ef277170 cmGeneratorTarget: Port internal type to cmGeneratorTarget. 13b878b5 cmGeneratorTarget: Prefer the local generator to access the global. 2ee3bd6f cmGlobalVisualStudioGenerator: Simplify access to cmGeneratorTarget. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=97eb20f5421c5cfff2df84617404686089ea71fc commit 97eb20f5421c5cfff2df84617404686089ea71fc Author: Stephen Kelly AuthorDate: Sun Aug 2 20:39:24 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 00:33:58 2015 +0200 cmQtAutoGenerators: Prefer a generator to access global generator. diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index f1ba2f4..c619cdc 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -369,7 +369,7 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg, #if defined(_WIN32) && !defined(__CYGWIN__) bool usePRE_BUILD = false; - cmGlobalGenerator* gg = makefile->GetGlobalGenerator(); + cmGlobalGenerator* gg = lg->GetGlobalGenerator(); if(gg->GetName().find("Visual Studio") != std::string::npos) { cmGlobalVisualStudioGenerator* vsgg = @@ -396,7 +396,7 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg, std::vector rcc_output; bool const isNinja = - makefile->GetGlobalGenerator()->GetName() == "Ninja"; + lg->GetGlobalGenerator()->GetName() == "Ninja"; if(isNinja #if defined(_WIN32) && !defined(__CYGWIN__) || usePRE_BUILD http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2d60391127bb5be1b4d55a44f8fbc406a3c4eff6 commit 2d60391127bb5be1b4d55a44f8fbc406a3c4eff6 Author: Stephen Kelly AuthorDate: Sun Aug 2 12:39:51 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 00:33:58 2015 +0200 cmGlobalGenerator: Port Find API to cmMakefile. diff --git a/Source/cmGetDirectoryPropertyCommand.cxx b/Source/cmGetDirectoryPropertyCommand.cxx index c056d95..2558876 100644 --- a/Source/cmGetDirectoryPropertyCommand.cxx +++ b/Source/cmGetDirectoryPropertyCommand.cxx @@ -51,10 +51,8 @@ bool cmGetDirectoryPropertyCommand sd = cmSystemTools::CollapseFullPath(sd); // lookup the makefile from the directory name - cmLocalGenerator *lg = - this->Makefile->GetGlobalGenerator()-> - FindLocalGenerator(sd); - if (!lg) + dir = this->Makefile->GetGlobalGenerator()->FindMakefile(sd); + if (!dir) { this->SetError ("DIRECTORY argument provided but requested directory not found. " @@ -62,7 +60,6 @@ bool cmGetDirectoryPropertyCommand "it is valid but has not been processed yet."); return false; } - dir = lg->GetMakefile(); ++i; } diff --git a/Source/cmGetPropertyCommand.cxx b/Source/cmGetPropertyCommand.cxx index 33d638b..4c42f53 100644 --- a/Source/cmGetPropertyCommand.cxx +++ b/Source/cmGetPropertyCommand.cxx @@ -262,13 +262,8 @@ bool cmGetPropertyCommand::HandleDirectoryMode() dir = cmSystemTools::CollapseFullPath(dir); // Lookup the generator. - if(cmLocalGenerator* lg = - (this->Makefile->GetGlobalGenerator()->FindLocalGenerator(dir))) - { - // Use the makefile for the directory found. - mf = lg->GetMakefile(); - } - else + mf = this->Makefile->GetGlobalGenerator()->FindMakefile(dir); + if (!mf) { // Could not find the directory. this->SetError diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 8645317..1e2d091 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2160,6 +2160,20 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap() } } +cmMakefile* +cmGlobalGenerator::FindMakefile(const std::string& start_dir) const +{ + for(std::vector::const_iterator it = + this->Makefiles.begin(); it != this->Makefiles.end(); ++it) + { + std::string sd = (*it)->GetCurrentSourceDirectory(); + if (sd == start_dir) + { + return *it; + } + } + return 0; +} ///! Find a local generator by its startdirectory cmLocalGenerator* diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 616011f..778d946 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -256,6 +256,7 @@ public: that is a framework. */ bool NameResolvesToFramework(const std::string& libname) const; + cmMakefile* FindMakefile(const std::string& start_dir) const; ///! Find a local generator by its startdirectory cmLocalGenerator* FindLocalGenerator(const std::string& start_dir) const; diff --git a/Source/cmSetPropertyCommand.cxx b/Source/cmSetPropertyCommand.cxx index 31e460f..17ad475 100644 --- a/Source/cmSetPropertyCommand.cxx +++ b/Source/cmSetPropertyCommand.cxx @@ -205,14 +205,8 @@ bool cmSetPropertyCommand::HandleDirectoryMode() // The local generators are associated with collapsed paths. dir = cmSystemTools::CollapseFullPath(dir); - // Lookup the generator. - if(cmLocalGenerator* lg = - this->Makefile->GetGlobalGenerator()->FindLocalGenerator(dir)) - { - // Use the makefile for the directory found. - mf = lg->GetMakefile(); - } - else + mf = this->Makefile->GetGlobalGenerator()->FindMakefile(dir); + if (!mf) { // Could not find the directory. this->SetError http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=efb9ccca7fd0bb2ca0ec6f4f65d0b4f0ccb83ad4 commit efb9ccca7fd0bb2ca0ec6f4f65d0b4f0ccb83ad4 Author: Stephen Kelly AuthorDate: Sun Aug 2 12:57:06 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 00:33:57 2015 +0200 cmGlobalGenerator: Create global targets from cmMakefiles. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index f96cf21..8645317 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1193,9 +1193,9 @@ void cmGlobalGenerator::Configure() cmTargets globalTargets; this->CreateDefaultGlobalTargets(&globalTargets); - for (i = 0; i < this->LocalGenerators.size(); ++i) + for (i = 0; i < this->Makefiles.size(); ++i) { - cmMakefile* mf = this->LocalGenerators[i]->GetMakefile(); + cmMakefile* mf = this->Makefiles[i]; cmTargets* targets = &(mf->GetTargets()); cmTargets::iterator tit; for ( tit = globalTargets.begin(); tit != globalTargets.end(); ++ tit ) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f62f61a08402f7e4239674fd03a6e93631017021 commit f62f61a08402f7e4239674fd03a6e93631017021 Author: Stephen Kelly AuthorDate: Sun Aug 2 12:48:08 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 00:33:57 2015 +0200 cmGlobalGenerator: Port global target creation to cmMakefile. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 98961d8..f96cf21 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2247,7 +2247,7 @@ inline std::string removeQuotes(const std::string& s) void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) { - cmMakefile* mf = this->LocalGenerators[0]->GetMakefile(); + cmMakefile* mf = this->Makefiles[0]; const char* cmakeCfgIntDir = this->GetCMakeCFGIntDir(); // CPack http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ad2b607bf7d072fe3c7363446cb81884be7f4221 commit ad2b607bf7d072fe3c7363446cb81884be7f4221 Author: Stephen Kelly AuthorDate: Sun Aug 2 12:45:17 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 00:33:57 2015 +0200 cmGlobalGenerator: Port Configure-time check to cmMakefile. This uses no generate-time state. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 83bfe57..98961d8 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1641,11 +1641,11 @@ void cmGlobalGenerator::CheckLocalGenerators() // std::set notFoundMap; // after it is all done do a ConfigureFinalPass cmState* state = this->GetCMakeInstance()->GetState(); - for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) + for (unsigned int i = 0; i < this->Makefiles.size(); ++i) { - this->LocalGenerators[i]->GetMakefile()->ConfigureFinalPass(); + this->Makefiles[i]->ConfigureFinalPass(); cmTargets &targets = - this->LocalGenerators[i]->GetMakefile()->GetTargets(); + this->Makefiles[i]->GetTargets(); for (cmTargets::iterator l = targets.begin(); l != targets.end(); l++) { @@ -1700,15 +1700,14 @@ void cmGlobalGenerator::CheckLocalGenerators() } std::string text = notFoundMap[varName]; text += "\n used as include directory in directory "; - text += this->LocalGenerators[i] - ->GetMakefile()->GetCurrentSourceDirectory(); + text += this->Makefiles[i]->GetCurrentSourceDirectory(); notFoundMap[varName] = text; } } } this->CMakeInstance->UpdateProgress ("Configuring", 0.9f+0.1f*(static_cast(i)+1.0f)/ - static_cast(this->LocalGenerators.size())); + static_cast(this->Makefiles.size())); } if(!notFoundMap.empty()) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a58ead9b2f2c8810d8841975ab18486cacb149e9 commit a58ead9b2f2c8810d8841975ab18486cacb149e9 Author: Stephen Kelly AuthorDate: Sun Aug 2 12:17:31 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 00:33:56 2015 +0200 cmGlobalGenerator: Base final target property computation on Makefiles. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 5787a9d..83bfe57 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1482,9 +1482,9 @@ void cmGlobalGenerator::CreateQtAutoGeneratorsTargets(AutogensType &autogens) void cmGlobalGenerator::FinalizeTargetCompileInfo() { // Construct per-target generator information. - for(unsigned int i=0; i < this->LocalGenerators.size(); ++i) + for(unsigned int i=0; i < this->Makefiles.size(); ++i) { - cmMakefile *mf = this->LocalGenerators[i]->GetMakefile(); + cmMakefile *mf = this->Makefiles[i]; const cmStringRange noconfig_compile_definitions = mf->GetCompileDefinitionsEntries(); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7965ba9d008172695aeeb48d327e3942c3684fa9 commit 7965ba9d008172695aeeb48d327e3942c3684fa9 Author: Stephen Kelly AuthorDate: Sun Aug 2 12:13:41 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 00:33:56 2015 +0200 cmGlobalGenerator: Base progress on Makefiles, not LocalGenerators. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 5266b23..5787a9d 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1148,9 +1148,9 @@ void cmGlobalGenerator::Configure() // update the cache entry for the number of local generators, this is used // for progress char num[100]; - sprintf(num,"%d",static_cast(this->LocalGenerators.size())); + sprintf(num,"%d",static_cast(this->Makefiles.size())); this->GetCMakeInstance()->AddCacheEntry - ("CMAKE_NUMBER_OF_LOCAL_GENERATORS", num, + ("CMAKE_NUMBER_OF_MAKEFILES", num, "number of local generators", cmState::INTERNAL); // check for link libraries and include directories containing "NOTFOUND" @@ -1742,9 +1742,9 @@ int cmGlobalGenerator::TryCompile(const std::string& srcdir, // take the bulk of the time, so try and guess some progress // by getting closer and closer to 100 without actually getting there. if (!this->CMakeInstance->GetState()->GetInitializedCacheValue - ("CMAKE_NUMBER_OF_LOCAL_GENERATORS")) + ("CMAKE_NUMBER_OF_MAKEFILES")) { - // If CMAKE_NUMBER_OF_LOCAL_GENERATORS is not set + // If CMAKE_NUMBER_OF_MAKEFILES is not set // we are in the first time progress and we have no // idea how long it will be. So, just move 1/10th of the way // there each time, and don't go over 95% @@ -1935,22 +1935,16 @@ std::string cmGlobalGenerator::GenerateCMakeBuildCommand( void cmGlobalGenerator::AddMakefile(cmMakefile *mf) { this->Makefiles.push_back(mf); -} - -//---------------------------------------------------------------------------- -void cmGlobalGenerator::AddLocalGenerator(cmLocalGenerator *lg) -{ - this->LocalGenerators.push_back(lg); // update progress // estimate how many lg there will be const char *numGenC = this->CMakeInstance->GetState()->GetInitializedCacheValue - ("CMAKE_NUMBER_OF_LOCAL_GENERATORS"); + ("CMAKE_NUMBER_OF_MAKEFILES"); if (!numGenC) { - // If CMAKE_NUMBER_OF_LOCAL_GENERATORS is not set + // If CMAKE_NUMBER_OF_MAKEFILES is not set // we are in the first time progress and we have no // idea how long it will be. So, just move half way // there each time, and don't go over 95% @@ -1965,7 +1959,7 @@ void cmGlobalGenerator::AddLocalGenerator(cmLocalGenerator *lg) } int numGen = atoi(numGenC); - float prog = 0.9f*static_cast(this->LocalGenerators.size())/ + float prog = 0.9f*static_cast(this->Makefiles.size())/ static_cast(numGen); if (prog > 0.9f) { @@ -1974,6 +1968,12 @@ void cmGlobalGenerator::AddLocalGenerator(cmLocalGenerator *lg) this->CMakeInstance->UpdateProgress("Configuring", prog); } +//---------------------------------------------------------------------------- +void cmGlobalGenerator::AddLocalGenerator(cmLocalGenerator *lg) +{ + this->LocalGenerators.push_back(lg); +} + void cmGlobalGenerator::AddInstallComponent(const char* component) { if(component && *component) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a57b7aa45efdad49fc8ba2c9ea0525ab5c991b2c commit a57b7aa45efdad49fc8ba2c9ea0525ab5c991b2c Author: Stephen Kelly AuthorDate: Sun Aug 2 13:18:30 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 00:33:56 2015 +0200 cmExportLibraryDependenciesCommand: Port to cmMakefile. diff --git a/Source/cmExportLibraryDependenciesCommand.cxx b/Source/cmExportLibraryDependenciesCommand.cxx index cb150a7..fde8fb1 100644 --- a/Source/cmExportLibraryDependenciesCommand.cxx +++ b/Source/cmExportLibraryDependenciesCommand.cxx @@ -11,7 +11,6 @@ ============================================================================*/ #include "cmExportLibraryDependenciesCommand.h" #include "cmGlobalGenerator.h" -#include "cmLocalGenerator.h" #include "cmGeneratedFileStream.h" #include "cmake.h" #include "cmVersion.h" @@ -82,15 +81,14 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const // the project. cmake* cm = this->Makefile->GetCMakeInstance(); cmGlobalGenerator* global = cm->GetGlobalGenerator(); - const std::vector& locals = global->GetLocalGenerators(); + const std::vector& locals = global->GetMakefiles(); std::map libDepsOld; std::map libDepsNew; std::map libTypes; - for(std::vector::const_iterator i = locals.begin(); + for(std::vector::const_iterator i = locals.begin(); i != locals.end(); ++i) { - const cmLocalGenerator* gen = *i; - const cmTargets &tgts = gen->GetMakefile()->GetTargets(); + const cmTargets &tgts = (*i)->GetTargets(); for(cmTargets::const_iterator l = tgts.begin(); l != tgts.end(); ++l) { http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d8d6f19e30d0568f1af1297dd616fba0901c388e commit d8d6f19e30d0568f1af1297dd616fba0901c388e Author: Stephen Kelly AuthorDate: Sun Aug 2 20:26:32 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 00:33:56 2015 +0200 cmGlobalGenerator: Port configure-time code to cmMakefile. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 749ab6e..5266b23 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2821,9 +2821,9 @@ cmGlobalGenerator::AddRuleHash(const std::vector& outputs, } // Shorten the output name (in expected use case). - cmLocalGenerator* lg = this->GetLocalGenerators()[0]; - std::string fname = lg->Convert(outputs[0], - cmLocalGenerator::HOME_OUTPUT); + cmOutputConverter converter(this->GetMakefiles()[0]->GetStateSnapshot()); + std::string fname = converter.Convert( + outputs[0], cmLocalGenerator::HOME_OUTPUT); // Associate the hash with this output. this->RuleHashes[fname] = hash; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=76d273e3fbab5af282a6402f66820ed926da7717 commit 76d273e3fbab5af282a6402f66820ed926da7717 Author: Stephen Kelly AuthorDate: Sun Aug 2 13:15:47 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 00:33:55 2015 +0200 cmake: Port configure-time code to cmMakefile. diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 8c455b2..d1e6265 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1592,7 +1592,7 @@ int cmake::ActualConfigure() } } - cmMakefile* mf=this->GlobalGenerator->GetLocalGenerators()[0]->GetMakefile(); + cmMakefile* mf=this->GlobalGenerator->GetMakefiles()[0]; if (mf->IsOn("CTEST_USE_LAUNCHERS") && !this->State->GetGlobalProperty("RULE_LAUNCH_COMPILE")) { http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0c86673edbb9956dc29c31242e244fb1b02013c7 commit 0c86673edbb9956dc29c31242e244fb1b02013c7 Author: Stephen Kelly AuthorDate: Sun Aug 2 20:21:22 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 00:33:55 2015 +0200 cmGlobalGenerator: Store a container of cmMakefiles. For use at configure-time. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 3c818ff..749ab6e 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1129,6 +1129,7 @@ void cmGlobalGenerator::Configure() // start with this directory cmLocalGenerator *lg = this->MakeLocalGenerator(); + this->Makefiles.push_back(lg->GetMakefile()); this->LocalGenerators.push_back(lg); // set the Start directories @@ -1599,6 +1600,8 @@ void cmGlobalGenerator::ClearGeneratorMembers() cmDeleteAll(this->BuildExportSets); this->BuildExportSets.clear(); + this->Makefiles.clear(); + cmDeleteAll(this->LocalGenerators); this->LocalGenerators.clear(); @@ -1929,6 +1932,12 @@ std::string cmGlobalGenerator::GenerateCMakeBuildCommand( } //---------------------------------------------------------------------------- +void cmGlobalGenerator::AddMakefile(cmMakefile *mf) +{ + this->Makefiles.push_back(mf); +} + +//---------------------------------------------------------------------------- void cmGlobalGenerator::AddLocalGenerator(cmLocalGenerator *lg) { this->LocalGenerators.push_back(lg); diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 3402fbc..616011f 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -173,6 +173,8 @@ public: cmake *GetCMakeInstance() const { return this->CMakeInstance; } void SetConfiguredFilesPath(cmGlobalGenerator* gen); + const std::vector& GetMakefiles() const { + return this->Makefiles;} const std::vector& GetLocalGenerators() const { return this->LocalGenerators;} @@ -184,6 +186,7 @@ public: void SetCurrentMakefile(cmMakefile* mf) {this->CurrentMakefile = mf;} + void AddMakefile(cmMakefile *mf); void AddLocalGenerator(cmLocalGenerator *lg); ///! Set an generator for an "external makefile based project" @@ -402,6 +405,7 @@ protected: std::string FindMakeProgramFile; std::string ConfiguredFilesPath; cmake *CMakeInstance; + std::vector Makefiles; std::vector LocalGenerators; cmMakefile* CurrentMakefile; // map from project name to vector of local generators in that project diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 60a11e1..85bc493 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1857,6 +1857,7 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath, // create a new local generator and set its parent cmLocalGenerator *lg2 = this->GetGlobalGenerator() ->MakeLocalGenerator(newSnapshot, this->LocalGenerator); + this->GetGlobalGenerator()->AddMakefile(lg2->GetMakefile()); this->GetGlobalGenerator()->AddLocalGenerator(lg2); cmMakefile* subMf = lg2->GetMakefile(); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ef2771706a641607c146edc738f76e0205ed8577 commit ef2771706a641607c146edc738f76e0205ed8577 Author: Stephen Kelly AuthorDate: Sun Aug 2 19:44:31 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 00:33:55 2015 +0200 cmGeneratorTarget: Port internal type to cmGeneratorTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index b19856d..e914cf6 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -36,7 +36,7 @@ //---------------------------------------------------------------------------- void reportBadObjLib(std::vector const& badObjLib, - cmTarget *target, cmake *cm) + cmGeneratorTarget const* target, cmake *cm) { if(!badObjLib.empty()) { @@ -50,7 +50,7 @@ void reportBadObjLib(std::vector const& badObjLib, e << "but may contain only sources that compile, header files, and " "other files that would not affect linking of a normal library."; cm->IssueMessage(cmake::FATAL_ERROR, e.str(), - target->GetBacktrace()); + target->Target->GetBacktrace()); } } @@ -133,14 +133,14 @@ struct TagVisitor { DataType& Data; std::vector BadObjLibFiles; - cmTarget *Target; + cmGeneratorTarget const* Target; cmGlobalGenerator *GlobalGenerator; cmsys::RegularExpression Header; bool IsObjLib; - TagVisitor(cmTarget *target, DataType& data) + TagVisitor(cmGeneratorTarget const* target, DataType& data) : Data(data), Target(target), - GlobalGenerator(target->GetMakefile()->GetGlobalGenerator()), + GlobalGenerator(target->GetLocalGenerator()->GetGlobalGenerator()), Header(CM_HEADER_REGEX), IsObjLib(target->GetType() == cmTarget::OBJECT_LIBRARY) { @@ -362,7 +362,7 @@ static void handleSystemIncludesDep(cmMakefile *mf, cmTarget const* depTgt, { \ std::vector sourceFiles; \ this->Target->GetSourceFiles(sourceFiles, config); \ - TagVisitor visitor(this->Target, data); \ + TagVisitor visitor(this, data); \ for(std::vector::const_iterator si = sourceFiles.begin(); \ si != sourceFiles.end(); ++si) \ { \ http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=13b878b534dbfeb2995569f486e3b0684ef584aa commit 13b878b534dbfeb2995569f486e3b0684ef584aa Author: Stephen Kelly AuthorDate: Sun Aug 2 19:42:31 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 00:33:54 2015 +0200 cmGeneratorTarget: Prefer the local generator to access the global. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c831704..b19856d 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -234,7 +234,7 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) { this->Makefile = this->Target->GetMakefile(); this->LocalGenerator = lg; - this->GlobalGenerator = this->Makefile->GetGlobalGenerator(); + this->GlobalGenerator = this->LocalGenerator->GetGlobalGenerator(); } cmGeneratorTarget::~cmGeneratorTarget() @@ -1556,7 +1556,7 @@ cmTargetTraceDependencies { // Convenience. this->Makefile = this->Target->GetMakefile(); - this->GlobalGenerator = this->Makefile->GetGlobalGenerator(); + this->GlobalGenerator = target->GetLocalGenerator()->GetGlobalGenerator(); this->CurrentEntry = 0; // Queue all the source files already specified for the target. @@ -1944,8 +1944,7 @@ void cmGeneratorTarget::GenerateTargetManifest( { return; } - cmMakefile* mf = this->Target->GetMakefile(); - cmGlobalGenerator* gg = mf->GetGlobalGenerator(); + cmGlobalGenerator* gg = this->LocalGenerator->GetGlobalGenerator(); // Get the names. std::string name; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2ee3bd6f3e99be2dc1bf2b3111681838f0b8d268 commit 2ee3bd6f3e99be2dc1bf2b3111681838f0b8d268 Author: Stephen Kelly AuthorDate: Sun Aug 2 19:40:19 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 00:33:32 2015 +0200 cmGlobalVisualStudioGenerator: Simplify access to cmGeneratorTarget. diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 2f9d79a..4ac259b 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -885,8 +885,7 @@ cmGlobalVisualStudioGenerator::OrderedTargetDependSet for (TargetSet::const_iterator it = targets.begin(); it != targets.end(); ++it) { - cmGeneratorTarget* gt = - (*it)->GetMakefile()->GetGlobalGenerator()->GetGeneratorTarget(*it); + cmGeneratorTarget* gt = this->GetGeneratorTarget(*it); this->insert(gt); } } ----------------------------------------------------------------------- Summary of changes: Source/cmExportLibraryDependenciesCommand.cxx | 8 ++- Source/cmGeneratorTarget.cxx | 19 ++++--- Source/cmGetDirectoryPropertyCommand.cxx | 7 +-- Source/cmGetPropertyCommand.cxx | 9 +--- Source/cmGlobalGenerator.cxx | 68 ++++++++++++++++--------- Source/cmGlobalGenerator.h | 5 ++ Source/cmGlobalVisualStudioGenerator.cxx | 3 +- Source/cmMakefile.cxx | 1 + Source/cmQtAutoGenerators.cxx | 4 +- Source/cmSetPropertyCommand.cxx | 10 +--- Source/cmake.cxx | 2 +- 11 files changed, 73 insertions(+), 63 deletions(-) hooks/post-receive -- CMake From steveire at gmail.com Thu Aug 6 18:39:36 2015 From: steveire at gmail.com (Stephen Kelly) Date: Thu, 6 Aug 2015 18:39:36 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2042-g6b479d5 Message-ID: <20150806223936.F3FFB1697@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 6b479d5ee112efce1565fb8cbdebe389af3a9337 (commit) via 230c212756e641cbfc6327ce796ffa0f617a4c24 (commit) via 37554424986199c41fc8825d81490ba75f271edb (commit) via 94052592b9aa298ed367542841f44cca23b927be (commit) via ddcae2f2e80e10ef8c1a1e32ef9bfd67272ea766 (commit) via 24c9ec4569f08e2320fd1c4f43e01bf9cfefae5a (commit) via 976bd2a8ea0b0d66de06d1c21a483bb29d3ea903 (commit) via 615dec8af09469e9243b473b7b8a1f970bb7d00f (commit) via ba3f3e3b43ae3ce8e61a62b90f57c6cfdf6d2243 (commit) from 026814ad56e9da194baa1597a4de222227920ca5 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6b479d5ee112efce1565fb8cbdebe389af3a9337 commit 6b479d5ee112efce1565fb8cbdebe389af3a9337 Merge: 026814a 230c212 Author: Stephen Kelly AuthorDate: Thu Aug 6 18:39:34 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 6 18:39:34 2015 -0400 Merge topic 'cmState-definitions' into next 230c2127 cmState: Reserve the number of cmLinkedTree nodes if known. 37554424 cmLinkedTree: Add API for size query and reserve. 94052592 cmState: Host variable definitions. ddcae2f2 cmState: Add a VariableScope snapshot type. 24c9ec45 cmState: Add a Base snapshot type. 976bd2a8 cmMakefile: Decouple the container of cmDefinitions from scoping logic. 615dec8a cmDefinitions: Implement in terms of cmLinkedTree. ba3f3e3b cmMakefile: Extract InitializeVarScope method. diff --cc Source/cmGlobalGenerator.cxx index 1885e24,6d079cd..b76f277 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@@ -1148,11 -1183,40 +1184,40 @@@ void cmGlobalGenerator::Configure( // update the cache entry for the number of local generators, this is used // for progress char num[100]; - sprintf(num,"%d",static_cast(this->LocalGenerators.size())); + sprintf(num,"%d",static_cast(this->Makefiles.size())); this->GetCMakeInstance()->AddCacheEntry - ("CMAKE_NUMBER_OF_LOCAL_GENERATORS", num, + ("CMAKE_NUMBER_OF_MAKEFILES", num, "number of local generators", cmState::INTERNAL); + { + std::ostringstream str; + str << this->GetCMakeInstance()->GetState()->DefinitionsSize(); + this->GetCMakeInstance()->AddCacheEntry + ("CMAKE_NUMBER_OF_DEFINITION_STATES", str.str().c_str(), + "number of definition states", cmState::INTERNAL); + } + { + std::ostringstream str; + str << this->GetCMakeInstance()->GetState()->SnapshotsSize(); + this->GetCMakeInstance()->AddCacheEntry + ("CMAKE_NUMBER_OF_SNAPSHOT_STATES", str.str().c_str(), + "number of snapshot states", cmState::INTERNAL); + } + { + std::ostringstream str; + str << this->GetCMakeInstance()->GetState()->ListFilesSize(); + this->GetCMakeInstance()->AddCacheEntry + ("CMAKE_NUMBER_OF_LISTFILE_STATES", str.str().c_str(), + "number of listfile states", cmState::INTERNAL); + } + { + std::ostringstream str; + str << this->GetCMakeInstance()->GetState()->PoliciesSize(); + this->GetCMakeInstance()->AddCacheEntry + ("CMAKE_NUMBER_OF_POLICY_STATES", str.str().c_str(), + "number of policy states", cmState::INTERNAL); + } + // check for link libraries and include directories containing "NOTFOUND" // and for infinite loops this->CheckLocalGenerators(); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=230c212756e641cbfc6327ce796ffa0f617a4c24 commit 230c212756e641cbfc6327ce796ffa0f617a4c24 Author: Stephen Kelly AuthorDate: Sun Jun 21 13:05:15 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 00:37:42 2015 +0200 cmState: Reserve the number of cmLinkedTree nodes if known. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 3c818ff..6d079cd 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1140,6 +1140,42 @@ void cmGlobalGenerator::Configure() this->BinaryDirectories.insert( this->CMakeInstance->GetHomeOutputDirectory()); + if (const char *numStr = + this->GetCMakeInstance()->GetState() + ->GetInitializedCacheValue("CMAKE_NUMBER_OF_DEFINITION_STATES")) + { + int num = atoi(numStr); + this->GetCMakeInstance()->GetState()->ReserveDefinitions(num); + } + if (const char *numStr = + this->GetCMakeInstance()->GetState() + ->GetInitializedCacheValue("CMAKE_NUMBER_OF_SNAPSHOT_STATES")) + { + int num = atoi(numStr); + this->GetCMakeInstance()->GetState()->ReserveSnapshots(num); + } + if (const char *numStr = + this->GetCMakeInstance()->GetState() + ->GetInitializedCacheValue("CMAKE_NUMBER_OF_LISTFILE_STATES")) + { + int num = atoi(numStr); + this->GetCMakeInstance()->GetState()->ReserveListFiles(num); + } + if (const char *numStr = + this->GetCMakeInstance()->GetState() + ->GetInitializedCacheValue("CMAKE_NUMBER_OF_LOCAL_GENERATORS")) + { + int num = atoi(numStr); + this->GetCMakeInstance()->GetState()->ReserveDirectories(num); + } + if (const char *numStr = + this->GetCMakeInstance()->GetState() + ->GetInitializedCacheValue("CMAKE_NUMBER_OF_POLICY_STATES")) + { + int num = atoi(numStr); + this->GetCMakeInstance()->GetState()->ReservePolicies(num); + } + // now do it lg->GetMakefile()->Configure(); lg->GetMakefile()->EnforceDirectoryLevelRules(); @@ -1152,6 +1188,35 @@ void cmGlobalGenerator::Configure() ("CMAKE_NUMBER_OF_LOCAL_GENERATORS", num, "number of local generators", cmState::INTERNAL); + { + std::ostringstream str; + str << this->GetCMakeInstance()->GetState()->DefinitionsSize(); + this->GetCMakeInstance()->AddCacheEntry + ("CMAKE_NUMBER_OF_DEFINITION_STATES", str.str().c_str(), + "number of definition states", cmState::INTERNAL); + } + { + std::ostringstream str; + str << this->GetCMakeInstance()->GetState()->SnapshotsSize(); + this->GetCMakeInstance()->AddCacheEntry + ("CMAKE_NUMBER_OF_SNAPSHOT_STATES", str.str().c_str(), + "number of snapshot states", cmState::INTERNAL); + } + { + std::ostringstream str; + str << this->GetCMakeInstance()->GetState()->ListFilesSize(); + this->GetCMakeInstance()->AddCacheEntry + ("CMAKE_NUMBER_OF_LISTFILE_STATES", str.str().c_str(), + "number of listfile states", cmState::INTERNAL); + } + { + std::ostringstream str; + str << this->GetCMakeInstance()->GetState()->PoliciesSize(); + this->GetCMakeInstance()->AddCacheEntry + ("CMAKE_NUMBER_OF_POLICY_STATES", str.str().c_str(), + "number of policy states", cmState::INTERNAL); + } + // check for link libraries and include directories containing "NOTFOUND" // and for infinite loops this->CheckLocalGenerators(); diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 17ff09c..fc4fa30 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -651,6 +651,56 @@ bool cmState::UseMSYSShell() const return this->MSYSShell; } +size_t cmState::DefinitionsSize() const +{ + return this->VarTree.Size(); +} + +void cmState::ReserveDefinitions(size_t amount) +{ + this->VarTree.Reserve(amount); +} + +size_t cmState::SnapshotsSize() const +{ + return this->SnapshotData.Size(); +} + +void cmState::ReserveSnapshots(size_t amount) +{ + this->SnapshotData.Reserve(amount); +} + +size_t cmState::ListFilesSize() const +{ + return this->ExecutionListFiles.Size(); +} + +void cmState::ReserveListFiles(size_t amount) +{ + this->ExecutionListFiles.Reserve(amount); +} + +size_t cmState::DirectoriesSize() const +{ + return this->BuildsystemDirectory.Size(); +} + +void cmState::ReserveDirectories(size_t amount) +{ + this->BuildsystemDirectory.Reserve(amount); +} + +size_t cmState::PoliciesSize() const +{ + return this->PolicyStack.Size(); +} + +void cmState::ReservePolicies(size_t amount) +{ + this->PolicyStack.Reserve(amount); +} + const char* cmState::GetBinaryDirectory() const { return this->BinaryDirectory.c_str(); diff --git a/Source/cmState.h b/Source/cmState.h index 5499665..8380587 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -270,6 +270,21 @@ public: void SetMSYSShell(bool mSYSShell); bool UseMSYSShell() const; + size_t DefinitionsSize() const; + void ReserveDefinitions(size_t amount); + + size_t SnapshotsSize() const; + void ReserveSnapshots(size_t amount); + + size_t ListFilesSize() const; + void ReserveListFiles(size_t amount); + + size_t DirectoriesSize() const; + void ReserveDirectories(size_t amount); + + size_t PoliciesSize() const; + void ReservePolicies(size_t amount); + private: std::map PropertyDefinitions; std::vector EnabledLanguages; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=37554424986199c41fc8825d81490ba75f271edb commit 37554424986199c41fc8825d81490ba75f271edb Author: Stephen Kelly AuthorDate: Sun Jun 21 13:04:43 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 00:37:42 2015 +0200 cmLinkedTree: Add API for size query and reserve. diff --git a/Source/cmLinkedTree.h b/Source/cmLinkedTree.h index 3bcb940..385dff2 100644 --- a/Source/cmLinkedTree.h +++ b/Source/cmLinkedTree.h @@ -161,6 +161,17 @@ public: this->Data.clear(); } + size_t Size() const + { + return this->UpPositions.size(); + } + + void Reserve(size_t amount) + { + this->UpPositions.reserve(amount); + this->Data.reserve(amount); + } + private: T& GetReference(PositionType pos) { http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=94052592b9aa298ed367542841f44cca23b927be commit 94052592b9aa298ed367542841f44cca23b927be Author: Stephen Kelly AuthorDate: Sun Jun 21 21:26:43 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 00:37:42 2015 +0200 cmState: Host variable definitions. Version them through the snapshot system. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 40c90ea..15cfd0c 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -31,7 +31,6 @@ #endif #include "cmInstallGenerator.h" #include "cmTestGenerator.h" -#include "cmDefinitions.h" #include "cmAlgorithms.h" #include "cmake.h" #include // required for atoi @@ -47,131 +46,7 @@ class cmMakefile::Internals { public: - - enum ScopeType - { - BaseScope, - MacroScope, - FunctionScope, - VariableScope - }; - - struct VarScope - { - ScopeType Type; - cmLinkedTree::iterator Vars; - cmLinkedTree::iterator ParentScope; - }; - - cmLinkedTree VarTree; - cmLinkedTree VarScopes; - cmLinkedTree::iterator VarScopeIter; bool IsSourceFileTryCompile; - - void PushDefinitions(ScopeType scope) - { - assert(this->VarScopeIter.IsValid()); - assert(this->VarScopeIter->Vars.IsValid()); - cmLinkedTree::iterator origin = - this->VarScopeIter->Vars; - cmLinkedTree::iterator parentScope = - this->VarTree.Extend(origin); - this->VarScopeIter->Vars = parentScope; - this->VarScopeIter = this->VarScopes.Extend(this->VarScopeIter); - this->VarScopeIter->ParentScope = parentScope; - this->VarScopeIter->Vars = this->VarTree.Extend(origin); - this->VarScopeIter->Type = scope; - } - - void InitializeVarScope() - { - assert(!this->VarScopeIter.IsValid()); - this->VarScopeIter = this->VarScopes.Extend(this->VarScopes.Root()); - this->VarScopeIter->Vars = this->VarTree.Extend(this->VarTree.Root()); - this->VarScopeIter->ParentScope = this->VarTree.Root(); - this->VarScopeIter->Type = BaseScope; - } - - void InitializeDefinitions(cmMakefile* parent) - { - assert(this->VarScopeIter.IsValid()); - assert(this->VarScopeIter->Vars.IsValid()); - *this->VarScopeIter->Vars = - cmDefinitions::MakeClosure(parent->Internal->VarScopeIter->Vars, - parent->Internal->VarTree.Root()); - } - - const char* GetDefinition(std::string const& name) - { - assert(this->VarScopeIter.IsValid()); - assert(this->VarScopeIter->Vars.IsValid()); - return cmDefinitions::Get(name, - this->VarScopeIter->Vars, this->VarTree.Root()); - } - - bool IsInitialized(std::string const& name) - { - return cmDefinitions::HasKey(name, - this->VarScopeIter->Vars, this->VarTree.Root()); - } - - void SetDefinition(std::string const& name, std::string const& value) - { - this->VarScopeIter->Vars->Set(name, value.c_str()); - } - - void RemoveDefinition(std::string const& name) - { - this->VarScopeIter->Vars->Set(name, 0); - } - - std::vector UnusedKeys() const - { - return this->VarScopeIter->Vars->UnusedKeys(); - } - - std::vector ClosureKeys() const - { - return cmDefinitions::ClosureKeys(this->VarScopeIter->Vars, - this->VarTree.Root()); - } - - void PopDefinitions() - { - ++this->VarScopeIter; - } - - bool RaiseScope(std::string const& var, const char* varDef, cmMakefile* mf) - { - assert(this->VarScopeIter->Vars != this->VarTree.Root()); - if(this->VarScopeIter->ParentScope == this->VarTree.Root()) - { - cmLocalGenerator* plg = mf->LocalGenerator->GetParent(); - if(!plg) - { - return false; - } - // Update the definition in the parent directory top scope. This - // directory's scope was initialized by the closure of the parent - // scope, so we do not need to localize the definition first. - cmMakefile* parent = plg->GetMakefile(); - if (varDef) - { - parent->AddDefinition(var, varDef); - } - else - { - parent->RemoveDefinition(var); - } - return true; - } - // First localize the definition in the current scope. - cmDefinitions::Raise(var, this->VarScopeIter->Vars, this->VarTree.Root()); - - // Now update the definition in the parent scope. - this->VarScopeIter->ParentScope->Set(var, varDef); - return true; - } }; // default is not to be building executables @@ -180,7 +55,6 @@ cmMakefile::cmMakefile(cmLocalGenerator* localGenerator) LocalGenerator(localGenerator), StateSnapshot(localGenerator->GetStateSnapshot()) { - this->Internal->InitializeVarScope(); this->Internal->IsSourceFileTryCompile = false; // Initialize these first since AddDefaultDefinitions calls AddDefinition @@ -1606,9 +1480,6 @@ void cmMakefile::AddLinkLibrary(const std::string& lib) void cmMakefile::InitializeFromParent(cmMakefile* parent) { - // Initialize definitions with the closure of the parent scope. - this->Internal->InitializeDefinitions(parent); - this->StateSnapshot.InitializeFromParent(); this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR", @@ -1673,8 +1544,6 @@ void cmMakefile::PushFunctionScope(std::string const& fileName, fileName); assert(this->StateSnapshot.IsValid()); - this->Internal->PushDefinitions(Internals::FunctionScope); - this->PushLoopBlockBarrier(); #if defined(CMAKE_BUILD_WITH_CMAKE) @@ -1701,8 +1570,6 @@ void cmMakefile::PopFunctionScope(bool reportError) this->PopLoopBlockBarrier(); this->CheckForUnusedVariables(); - - this->Internal->PopDefinitions(); } void cmMakefile::PushMacroScope(std::string const& fileName, @@ -2005,7 +1872,7 @@ void cmMakefile::AddDefinition(const std::string& name, const char* value) { this->LogUnused("changing definition", name); } - this->Internal->SetDefinition(name, value); + this->StateSnapshot.SetDefinition(name, value); #ifdef CMAKE_BUILD_WITH_CMAKE cmVariableWatch* vv = this->GetVariableWatch(); @@ -2068,7 +1935,7 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value, this->GetState()->AddCacheEntry(name, haveVal ? val.c_str() : 0, doc, type); // if there was a definition then remove it - this->Internal->RemoveDefinition(name); + this->StateSnapshot.RemoveDefinition(name); } @@ -2078,7 +1945,9 @@ void cmMakefile::AddDefinition(const std::string& name, bool value) { this->LogUnused("changing definition", name); } - this->Internal->SetDefinition(name, value ? "ON" : "OFF"); + + this->StateSnapshot.SetDefinition(name, value ? "ON" : "OFF"); + #ifdef CMAKE_BUILD_WITH_CMAKE cmVariableWatch* vv = this->GetVariableWatch(); if ( vv ) @@ -2095,7 +1964,7 @@ void cmMakefile::CheckForUnusedVariables() const { return; } - const std::vector& unused = this->Internal->UnusedKeys(); + const std::vector& unused = this->StateSnapshot.UnusedKeys(); std::vector::const_iterator it = unused.begin(); for (; it != unused.end(); ++it) { @@ -2105,12 +1974,12 @@ void cmMakefile::CheckForUnusedVariables() const void cmMakefile::MarkVariableAsUsed(const std::string& var) { - this->Internal->GetDefinition(var); + this->StateSnapshot.GetDefinition(var); } bool cmMakefile::VariableInitialized(const std::string& var) const { - return this->Internal->IsInitialized(var); + return this->StateSnapshot.IsInitialized(var); } void cmMakefile::LogUnused(const char* reason, @@ -2158,7 +2027,7 @@ void cmMakefile::RemoveDefinition(const std::string& name) { this->LogUnused("unsetting", name); } - this->Internal->RemoveDefinition(name); + this->StateSnapshot.RemoveDefinition(name); #ifdef CMAKE_BUILD_WITH_CMAKE cmVariableWatch* vv = this->GetVariableWatch(); if ( vv ) @@ -2624,7 +2493,7 @@ const char* cmMakefile::GetRequiredDefinition(const std::string& name) const bool cmMakefile::IsDefinitionSet(const std::string& name) const { - const char* def = this->Internal->GetDefinition(name); + const char* def = this->StateSnapshot.GetDefinition(name); if(!def) { def = this->GetState()->GetInitializedCacheValue(name); @@ -2645,7 +2514,7 @@ bool cmMakefile::IsDefinitionSet(const std::string& name) const const char* cmMakefile::GetDefinition(const std::string& name) const { - const char* def = this->Internal->GetDefinition(name); + const char* def = this->StateSnapshot.GetDefinition(name); if(!def) { def = this->GetState()->GetInitializedCacheValue(name); @@ -2681,7 +2550,7 @@ const char* cmMakefile::GetSafeDefinition(const std::string& def) const std::vector cmMakefile::GetDefinitions() const { - std::vector res = this->Internal->ClosureKeys(); + std::vector res = this->StateSnapshot.ClosureKeys(); std::vector cacheKeys = this->GetState()->GetCacheEntryKeys(); res.insert(res.end(), cacheKeys.begin(), cacheKeys.end()); std::sort(res.begin(), res.end()); @@ -4460,8 +4329,6 @@ std::string cmMakefile::FormatListFileStack() const void cmMakefile::PushScope() { - this->Internal->PushDefinitions(Internals::VariableScope); - std::string commandName; long line = 0; if (!this->ContextStack.empty()) @@ -4490,7 +4357,6 @@ void cmMakefile::PopScope() this->CheckForUnusedVariables(); - this->Internal->PopDefinitions(); this->StateSnapshot = this->GetState()->Pop(this->StateSnapshot); assert(this->StateSnapshot.IsValid()); @@ -4503,7 +4369,7 @@ void cmMakefile::RaiseScope(const std::string& var, const char *varDef) return; } - if (!this->Internal->RaiseScope(var, varDef, this)) + if (!this->StateSnapshot.RaiseScope(var, varDef)) { std::ostringstream m; m << "Cannot set \"" << var << "\": current scope has no parent."; diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 9e09353..17ff09c 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -15,6 +15,7 @@ #include "cmCacheManager.h" #include "cmCommand.h" #include "cmAlgorithms.h" +#include "cmDefinitions.h" #include @@ -29,6 +30,9 @@ struct cmState::SnapshotDataType cmLinkedTree::iterator ExecutionListFile; cmLinkedTree::iterator BuildSystemDirectory; + cmLinkedTree::iterator Vars; + cmLinkedTree::iterator Root; + cmLinkedTree::iterator Parent; std::string EntryPointCommand; long EntryPointLine; std::vector::size_type IncludeDirectoryPosition; @@ -275,6 +279,10 @@ cmState::Snapshot cmState::Reset() pos->PolicyScope = this->PolicyStack.Root(); assert(pos->Policies.IsValid()); assert(pos->PolicyRoot.IsValid()); + this->VarTree.Clear(); + pos->Vars = this->VarTree.Extend(this->VarTree.Root()); + pos->Parent = this->VarTree.Root(); + pos->Root = this->VarTree.Root(); this->DefineProperty ("RULE_LAUNCH_COMPILE", cmProperty::DIRECTORY, @@ -752,6 +760,10 @@ cmState::Snapshot cmState::CreateBaseSnapshot() pos->PolicyScope = this->PolicyStack.Root(); assert(pos->Policies.IsValid()); assert(pos->PolicyRoot.IsValid()); + pos->Vars = this->VarTree.Extend(this->VarTree.Root()); + assert(pos->Vars.IsValid()); + pos->Parent = this->VarTree.Root(); + pos->Root = this->VarTree.Root(); return cmState::Snapshot(this, pos); } @@ -779,6 +791,25 @@ cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot, pos->PolicyScope = originSnapshot.Position->Policies; assert(pos->Policies.IsValid()); assert(pos->PolicyRoot.IsValid()); + + cmLinkedTree::iterator origin = originSnapshot.Position->Vars; + cmLinkedTree::iterator newVars = this->VarTree.Extend(origin); + + PositionType originPos = originSnapshot.Position; + while(originPos.IsValid()) + { + originPos->Vars = newVars; + if ((originPos->SnapshotType == BaseType) + || (originPos->SnapshotType == FunctionCallType) + || (originPos->SnapshotType == VariableScopeType) + || (originPos->SnapshotType == BuildsystemDirectoryType)) + break; + ++originPos; + } + + pos->Parent = newVars; + pos->Root = origin; + pos->Vars = this->VarTree.Extend(origin); return cmState::Snapshot(this, pos); } @@ -798,6 +829,25 @@ cmState::CreateFunctionCallSnapshot(cmState::Snapshot originSnapshot, originSnapshot.Position->ExecutionListFile, fileName); pos->BuildSystemDirectory->DirectoryEnd = pos; pos->PolicyScope = originSnapshot.Position->Policies; + assert(originSnapshot.Position->Vars.IsValid()); + cmLinkedTree::iterator origin = + originSnapshot.Position->Vars; + cmLinkedTree::iterator newVars = this->VarTree.Extend(origin); + + PositionType originPos = originSnapshot.Position; + while(originPos.IsValid()) + { + originPos->Vars = newVars; + if ((originPos->SnapshotType == BaseType) + || (originPos->SnapshotType == FunctionCallType) + || (originPos->SnapshotType == VariableScopeType) + || (originPos->SnapshotType == BuildsystemDirectoryType)) + break; + ++originPos; + } + + pos->Parent = newVars; + pos->Vars = this->VarTree.Extend(origin); return cmState::Snapshot(this, pos); } @@ -815,6 +865,7 @@ cmState::CreateMacroCallSnapshot(cmState::Snapshot originSnapshot, pos->SnapshotType = MacroCallType; pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile, fileName); + assert(originSnapshot.Position->Vars.IsValid()); pos->BuildSystemDirectory->DirectoryEnd = pos; pos->PolicyScope = originSnapshot.Position->Policies; return cmState::Snapshot(this, pos); @@ -833,6 +884,7 @@ cmState::CreateCallStackSnapshot(cmState::Snapshot originSnapshot, pos->SnapshotType = CallStackType; pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile, fileName); + assert(originSnapshot.Position->Vars.IsValid()); pos->BuildSystemDirectory->DirectoryEnd = pos; pos->PolicyScope = originSnapshot.Position->Policies; return cmState::Snapshot(this, pos); @@ -849,7 +901,27 @@ cmState::CreateVariableScopeSnapshot(cmState::Snapshot originSnapshot, pos->EntryPointLine = entryPointLine; pos->EntryPointCommand = entryPointCommand; pos->SnapshotType = VariableScopeType; + assert(originSnapshot.Position->Vars.IsValid()); + + cmLinkedTree::iterator origin = + originSnapshot.Position->Vars; + cmLinkedTree::iterator newVars = this->VarTree.Extend(origin); + PositionType originPos = originSnapshot.Position; + while(originPos.IsValid()) + { + originPos->Vars = newVars; + if ((originPos->SnapshotType == BaseType) + || (originPos->SnapshotType == FunctionCallType) + || (originPos->SnapshotType == VariableScopeType) + || (originPos->SnapshotType == BuildsystemDirectoryType)) + break; + ++originPos; + } + + pos->Parent = newVars; + pos->Vars = this->VarTree.Extend(origin); + assert(pos->Vars.IsValid()); return cmState::Snapshot(this, pos); } @@ -1141,6 +1213,72 @@ bool cmState::Snapshot::HasDefinedPolicyCMP0011() return !this->Position->Policies->IsEmpty(); } +const char* cmState::Snapshot::GetDefinition(std::string const& name) const +{ + assert(this->Position->Vars.IsValid()); + return cmDefinitions::Get(name, this->Position->Vars, + this->Position->Root); +} + +bool cmState::Snapshot::IsInitialized(std::string const& name) const +{ + return cmDefinitions::HasKey(name, this->Position->Vars, + this->Position->Root); +} + +void cmState::Snapshot::SetDefinition(std::string const& name, + std::string const& value) +{ + this->Position->Vars->Set(name, value.c_str()); +} + +void cmState::Snapshot::RemoveDefinition(std::string const& name) +{ + this->Position->Vars->Set(name, 0); +} + +std::vector cmState::Snapshot::UnusedKeys() const +{ + return this->Position->Vars->UnusedKeys(); +} + +std::vector cmState::Snapshot::ClosureKeys() const +{ + return cmDefinitions::ClosureKeys(this->Position->Vars, + this->Position->Root); +} + +bool cmState::Snapshot::RaiseScope(std::string const& var, const char* varDef) +{ + if(this->Position->ScopeParent == this->Position->DirectoryParent) + { + Snapshot parentDir = this->GetBuildsystemDirectoryParent(); + if(!parentDir.IsValid()) + { + return false; + } + // Update the definition in the parent directory top scope. This + // directory's scope was initialized by the closure of the parent + // scope, so we do not need to localize the definition first. + if (varDef) + { + parentDir.SetDefinition(var, varDef); + } + else + { + parentDir.RemoveDefinition(var); + } + return true; + } + // First localize the definition in the current scope. + cmDefinitions::Raise(var, this->Position->Vars, + this->Position->Root); + + // Now update the definition in the parent scope. + this->Position->Parent->Set(var, varDef); + return true; +} + static const std::string cmPropertySentinal = std::string(); template @@ -1177,6 +1315,11 @@ void InitializeContentFromParent(T& parentContent, void cmState::Snapshot::InitializeFromParent() { PositionType parent = this->Position->DirectoryParent; + assert(this->Position->Vars.IsValid()); + assert(parent->Vars.IsValid()); + + *this->Position->Vars = + cmDefinitions::MakeClosure(parent->Vars, parent->Root); InitializeContentFromParent(parent->BuildSystemDirectory->IncludeDirectories, this->Position->BuildSystemDirectory->IncludeDirectories, diff --git a/Source/cmState.h b/Source/cmState.h index 4d87653..5499665 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -21,6 +21,8 @@ class cmake; class cmCommand; +class cmDefinitions; +class cmListFileBacktrace; class cmState { @@ -52,6 +54,14 @@ public: Snapshot(cmState* state = 0); Snapshot(cmState* state, PositionType position); + const char* GetDefinition(std::string const& name) const; + bool IsInitialized(std::string const& name) const; + void SetDefinition(std::string const& name, std::string const& value); + void RemoveDefinition(std::string const& name); + std::vector UnusedKeys() const; + std::vector ClosureKeys() const; + bool RaiseScope(std::string const& var, const char* varDef); + void SetListFile(std::string const& listfile); std::string GetExecutionListFile() const; @@ -273,6 +283,7 @@ private: cmLinkedTree PolicyStack; cmLinkedTree SnapshotData; + cmLinkedTree VarTree; std::vector SourceDirectoryComponents; std::vector BinaryDirectoryComponents; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ddcae2f2e80e10ef8c1a1e32ef9bfd67272ea766 commit ddcae2f2e80e10ef8c1a1e32ef9bfd67272ea766 Author: Stephen Kelly AuthorDate: Sat Aug 1 19:41:26 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 00:37:41 2015 +0200 cmState: Add a VariableScope snapshot type. Match the scopes currently used in cmMakefile for definitions. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 889c1cb..40c90ea 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4462,6 +4462,17 @@ void cmMakefile::PushScope() { this->Internal->PushDefinitions(Internals::VariableScope); + std::string commandName; + long line = 0; + if (!this->ContextStack.empty()) + { + commandName = this->ContextStack.back()->Name; + line = this->ContextStack.back()->Line; + } + this->StateSnapshot = this->GetState()->CreateVariableScopeSnapshot( + this->StateSnapshot, + commandName, + line); this->PushLoopBlockBarrier(); #if defined(CMAKE_BUILD_WITH_CMAKE) @@ -4480,6 +4491,9 @@ void cmMakefile::PopScope() this->CheckForUnusedVariables(); this->Internal->PopDefinitions(); + this->StateSnapshot = + this->GetState()->Pop(this->StateSnapshot); + assert(this->StateSnapshot.IsValid()); } void cmMakefile::RaiseScope(const std::string& var, const char *varDef) diff --git a/Source/cmState.cxx b/Source/cmState.cxx index c777514..9e09353 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -20,6 +20,7 @@ struct cmState::SnapshotDataType { + cmState::PositionType ScopeParent; cmState::PositionType DirectoryParent; cmLinkedTree::iterator Policies; cmLinkedTree::iterator PolicyRoot; @@ -736,6 +737,7 @@ cmState::Snapshot cmState::CreateBaseSnapshot() { PositionType pos = this->SnapshotData.Extend(this->SnapshotData.Root()); pos->DirectoryParent = this->SnapshotData.Root(); + pos->ScopeParent = this->SnapshotData.Root(); pos->SnapshotType = BaseType; pos->BuildSystemDirectory = this->BuildsystemDirectory.Extend(this->BuildsystemDirectory.Root()); @@ -763,6 +765,7 @@ cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot, pos->EntryPointLine = entryPointLine; pos->EntryPointCommand = entryPointCommand; pos->DirectoryParent = originSnapshot.Position; + pos->ScopeParent = originSnapshot.Position; pos->SnapshotType = BuildsystemDirectoryType; pos->BuildSystemDirectory = this->BuildsystemDirectory.Extend( @@ -787,6 +790,7 @@ cmState::CreateFunctionCallSnapshot(cmState::Snapshot originSnapshot, { PositionType pos = this->SnapshotData.Extend(originSnapshot.Position, *originSnapshot.Position); + pos->ScopeParent = originSnapshot.Position; pos->EntryPointLine = entryPointLine; pos->EntryPointCommand = entryPointCommand; pos->SnapshotType = FunctionCallType; @@ -835,6 +839,21 @@ cmState::CreateCallStackSnapshot(cmState::Snapshot originSnapshot, } cmState::Snapshot +cmState::CreateVariableScopeSnapshot(cmState::Snapshot originSnapshot, + std::string const& entryPointCommand, + long entryPointLine) +{ + PositionType pos = this->SnapshotData.Extend(originSnapshot.Position, + *originSnapshot.Position); + pos->ScopeParent = originSnapshot.Position; + pos->EntryPointLine = entryPointLine; + pos->EntryPointCommand = entryPointCommand; + pos->SnapshotType = VariableScopeType; + + return cmState::Snapshot(this, pos); +} + +cmState::Snapshot cmState::CreateInlineListFileSnapshot(cmState::Snapshot originSnapshot, const std::string& entryPointCommand, long entryPointLine, diff --git a/Source/cmState.h b/Source/cmState.h index bc89cc8..4d87653 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -41,7 +41,8 @@ public: MacroCallType, CallStackType, InlineListFileType, - PolicyScopeType + PolicyScopeType, + VariableScopeType }; class Directory; @@ -155,6 +156,9 @@ public: std::string const& entryPointCommand, long entryPointLine, std::string const& fileName); + Snapshot CreateVariableScopeSnapshot(Snapshot originSnapshot, + std::string const& entryPointCommand, + long entryPointLine); Snapshot CreateInlineListFileSnapshot(Snapshot originSnapshot, const std::string& entryPointCommand, long entryPointLine, http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=24c9ec4569f08e2320fd1c4f43e01bf9cfefae5a commit 24c9ec4569f08e2320fd1c4f43e01bf9cfefae5a Author: Stephen Kelly AuthorDate: Sat Aug 1 19:44:47 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 00:37:41 2015 +0200 cmState: Add a Base snapshot type. For completeness mostly. diff --git a/Source/cmState.cxx b/Source/cmState.cxx index f425861..c777514 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -736,7 +736,7 @@ cmState::Snapshot cmState::CreateBaseSnapshot() { PositionType pos = this->SnapshotData.Extend(this->SnapshotData.Root()); pos->DirectoryParent = this->SnapshotData.Root(); - pos->SnapshotType = BuildsystemDirectoryType; + pos->SnapshotType = BaseType; pos->BuildSystemDirectory = this->BuildsystemDirectory.Extend(this->BuildsystemDirectory.Root()); pos->ExecutionListFile = @@ -1019,7 +1019,8 @@ cmState::Snapshot cmState::Snapshot::GetCallStackParent() const { ++parentPos; } - if (parentPos->SnapshotType == cmState::BuildsystemDirectoryType) + if (parentPos->SnapshotType == cmState::BuildsystemDirectoryType + || parentPos->SnapshotType == cmState::BaseType) { return snapshot; } diff --git a/Source/cmState.h b/Source/cmState.h index 07aa2a5..bc89cc8 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -35,6 +35,7 @@ public: enum SnapshotType { + BaseType, BuildsystemDirectoryType, FunctionCallType, MacroCallType, http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=976bd2a8ea0b0d66de06d1c21a483bb29d3ea903 commit 976bd2a8ea0b0d66de06d1c21a483bb29d3ea903 Author: Stephen Kelly AuthorDate: Sun May 31 11:26:05 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 00:37:41 2015 +0200 cmMakefile: Decouple the container of cmDefinitions from scoping logic. Maintain a Parent tree node for writing to in RaiseScope. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 8ed1d4c..889c1cb 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -47,73 +47,104 @@ class cmMakefile::Internals { public: + + enum ScopeType + { + BaseScope, + MacroScope, + FunctionScope, + VariableScope + }; + + struct VarScope + { + ScopeType Type; + cmLinkedTree::iterator Vars; + cmLinkedTree::iterator ParentScope; + }; + cmLinkedTree VarTree; - cmLinkedTree::iterator VarTreeIter; + cmLinkedTree VarScopes; + cmLinkedTree::iterator VarScopeIter; bool IsSourceFileTryCompile; - void PushDefinitions() + void PushDefinitions(ScopeType scope) { - assert(this->VarTreeIter.IsValid()); - this->VarTreeIter = this->VarTree.Extend(this->VarTreeIter); + assert(this->VarScopeIter.IsValid()); + assert(this->VarScopeIter->Vars.IsValid()); + cmLinkedTree::iterator origin = + this->VarScopeIter->Vars; + cmLinkedTree::iterator parentScope = + this->VarTree.Extend(origin); + this->VarScopeIter->Vars = parentScope; + this->VarScopeIter = this->VarScopes.Extend(this->VarScopeIter); + this->VarScopeIter->ParentScope = parentScope; + this->VarScopeIter->Vars = this->VarTree.Extend(origin); + this->VarScopeIter->Type = scope; } void InitializeVarScope() { - this->VarTreeIter = this->VarTree.Root(); - this->PushDefinitions(); + assert(!this->VarScopeIter.IsValid()); + this->VarScopeIter = this->VarScopes.Extend(this->VarScopes.Root()); + this->VarScopeIter->Vars = this->VarTree.Extend(this->VarTree.Root()); + this->VarScopeIter->ParentScope = this->VarTree.Root(); + this->VarScopeIter->Type = BaseScope; } void InitializeDefinitions(cmMakefile* parent) { - *this->VarTreeIter = - cmDefinitions::MakeClosure(parent->Internal->VarTreeIter, + assert(this->VarScopeIter.IsValid()); + assert(this->VarScopeIter->Vars.IsValid()); + *this->VarScopeIter->Vars = + cmDefinitions::MakeClosure(parent->Internal->VarScopeIter->Vars, parent->Internal->VarTree.Root()); } const char* GetDefinition(std::string const& name) { - assert(this->VarTreeIter != this->VarTree.Root()); + assert(this->VarScopeIter.IsValid()); + assert(this->VarScopeIter->Vars.IsValid()); return cmDefinitions::Get(name, - this->VarTreeIter, this->VarTree.Root()); + this->VarScopeIter->Vars, this->VarTree.Root()); } bool IsInitialized(std::string const& name) { return cmDefinitions::HasKey(name, - this->VarTreeIter, this->VarTree.Root()); + this->VarScopeIter->Vars, this->VarTree.Root()); } void SetDefinition(std::string const& name, std::string const& value) { - this->VarTreeIter->Set(name, value.c_str()); + this->VarScopeIter->Vars->Set(name, value.c_str()); } void RemoveDefinition(std::string const& name) { - this->VarTreeIter->Set(name, 0); + this->VarScopeIter->Vars->Set(name, 0); } std::vector UnusedKeys() const { - return this->VarTreeIter->UnusedKeys(); + return this->VarScopeIter->Vars->UnusedKeys(); } std::vector ClosureKeys() const { - return cmDefinitions::ClosureKeys(this->VarTreeIter, this->VarTree.Root()); + return cmDefinitions::ClosureKeys(this->VarScopeIter->Vars, + this->VarTree.Root()); } void PopDefinitions() { - ++this->VarTreeIter; + ++this->VarScopeIter; } bool RaiseScope(std::string const& var, const char* varDef, cmMakefile* mf) { - cmLinkedTree::iterator it = this->VarTreeIter; - assert(it != this->VarTree.Root()); - ++it; - if(it == this->VarTree.Root()) + assert(this->VarScopeIter->Vars != this->VarTree.Root()); + if(this->VarScopeIter->ParentScope == this->VarTree.Root()) { cmLocalGenerator* plg = mf->LocalGenerator->GetParent(); if(!plg) @@ -135,10 +166,10 @@ public: return true; } // First localize the definition in the current scope. - cmDefinitions::Raise(var, this->VarTreeIter, this->VarTree.Root()); + cmDefinitions::Raise(var, this->VarScopeIter->Vars, this->VarTree.Root()); // Now update the definition in the parent scope. - it->Set(var, varDef); + this->VarScopeIter->ParentScope->Set(var, varDef); return true; } }; @@ -1642,7 +1673,7 @@ void cmMakefile::PushFunctionScope(std::string const& fileName, fileName); assert(this->StateSnapshot.IsValid()); - this->Internal->PushDefinitions(); + this->Internal->PushDefinitions(Internals::FunctionScope); this->PushLoopBlockBarrier(); @@ -4429,7 +4460,7 @@ std::string cmMakefile::FormatListFileStack() const void cmMakefile::PushScope() { - this->Internal->PushDefinitions(); + this->Internal->PushDefinitions(Internals::VariableScope); this->PushLoopBlockBarrier(); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=615dec8af09469e9243b473b7b8a1f970bb7d00f commit 615dec8af09469e9243b473b7b8a1f970bb7d00f Author: Stephen Kelly AuthorDate: Sat May 30 17:08:34 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 00:37:41 2015 +0200 cmDefinitions: Implement in terms of cmLinkedTree. Store the definitions in a cmLinkedTree in the cmMakefile. This can be moved to cmState and then the tree will provide snapshotting possibilities. It will also make the Closure copy created at the start of each cmMakefile unnecesarry. diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx index 2dab169..b06fb5c 100644 --- a/Source/cmDefinitions.cxx +++ b/Source/cmDefinitions.cxx @@ -56,9 +56,9 @@ void cmDefinitions::Raise(const std::string& key, } bool cmDefinitions::HasKey(const std::string& key, - StackConstIter begin, StackConstIter end) + StackIter begin, StackIter end) { - for (StackConstIter it = begin; it != end; ++it) + for (StackIter it = begin; it != end; ++it) { MapType::const_iterator i = it->Map.find(key); if (i != it->Map.end()) @@ -94,12 +94,12 @@ std::vector cmDefinitions::UnusedKeys() const } //---------------------------------------------------------------------------- -cmDefinitions cmDefinitions::MakeClosure(StackConstIter begin, - StackConstIter end) +cmDefinitions cmDefinitions::MakeClosure(StackIter begin, + StackIter end) { cmDefinitions closure; std::set undefined; - for (StackConstIter it = begin; it != end; ++it) + for (StackIter it = begin; it != end; ++it) { // Consider local definitions. for(MapType::const_iterator mi = it->Map.begin(); @@ -125,12 +125,12 @@ cmDefinitions cmDefinitions::MakeClosure(StackConstIter begin, //---------------------------------------------------------------------------- std::vector -cmDefinitions::ClosureKeys(StackConstIter begin, StackConstIter end) +cmDefinitions::ClosureKeys(StackIter begin, StackIter end) { std::set bound; std::vector defined; - for (StackConstIter it = begin; it != end; ++it) + for (StackIter it = begin; it != end; ++it) { defined.reserve(defined.size() + it->Map.size()); for(MapType::const_iterator mi = it->Map.begin(); diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h index 5fdcaab..411867c 100644 --- a/Source/cmDefinitions.h +++ b/Source/cmDefinitions.h @@ -13,6 +13,9 @@ #define cmDefinitions_h #include "cmStandardIncludes.h" + +#include "cmLinkedTree.h" + #if defined(CMAKE_BUILD_WITH_CMAKE) #ifdef CMake_HAVE_CXX11_UNORDERED_MAP #include @@ -32,26 +35,26 @@ */ class cmDefinitions { - typedef std::list::reverse_iterator StackIter; - typedef std::list::const_reverse_iterator StackConstIter; + typedef cmLinkedTree::iterator StackIter; public: static const char* Get(const std::string& key, StackIter begin, StackIter end); - static void Raise(const std::string& key, StackIter begin, StackIter end); + static void Raise(const std::string& key, + StackIter begin, StackIter end); static bool HasKey(const std::string& key, - StackConstIter begin, StackConstIter end); + StackIter begin, StackIter end); /** Set (or unset if null) a value associated with a key. */ void Set(const std::string& key, const char* value); std::vector UnusedKeys() const; - static std::vector ClosureKeys(StackConstIter begin, - StackConstIter end); + static std::vector ClosureKeys(StackIter begin, + StackIter end); - static cmDefinitions MakeClosure(StackConstIter begin, StackConstIter end); + static cmDefinitions MakeClosure(StackIter begin, StackIter end); private: // String with existence boolean. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index e6fc464..8ed1d4c 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -47,70 +47,73 @@ class cmMakefile::Internals { public: - std::list VarStack; + cmLinkedTree VarTree; + cmLinkedTree::iterator VarTreeIter; bool IsSourceFileTryCompile; void PushDefinitions() { - this->VarStack.push_back(cmDefinitions()); + assert(this->VarTreeIter.IsValid()); + this->VarTreeIter = this->VarTree.Extend(this->VarTreeIter); } void InitializeVarScope() { + this->VarTreeIter = this->VarTree.Root(); this->PushDefinitions(); } void InitializeDefinitions(cmMakefile* parent) { - this->VarStack.back() = - cmDefinitions::MakeClosure(parent->Internal->VarStack.rbegin(), - parent->Internal->VarStack.rend()); + *this->VarTreeIter = + cmDefinitions::MakeClosure(parent->Internal->VarTreeIter, + parent->Internal->VarTree.Root()); } const char* GetDefinition(std::string const& name) { - return cmDefinitions::Get(name, this->VarStack.rbegin(), - this->VarStack.rend()); + assert(this->VarTreeIter != this->VarTree.Root()); + return cmDefinitions::Get(name, + this->VarTreeIter, this->VarTree.Root()); } bool IsInitialized(std::string const& name) { - return cmDefinitions::HasKey(name, this->VarStack.rbegin(), - this->VarStack.rend()); + return cmDefinitions::HasKey(name, + this->VarTreeIter, this->VarTree.Root()); } void SetDefinition(std::string const& name, std::string const& value) { - this->VarStack.back().Set(name, value.c_str()); + this->VarTreeIter->Set(name, value.c_str()); } void RemoveDefinition(std::string const& name) { - this->VarStack.back().Set(name, 0); + this->VarTreeIter->Set(name, 0); } std::vector UnusedKeys() const { - return this->VarStack.back().UnusedKeys(); + return this->VarTreeIter->UnusedKeys(); } std::vector ClosureKeys() const { - return cmDefinitions::ClosureKeys(this->VarStack.rbegin(), - this->VarStack.rend()); + return cmDefinitions::ClosureKeys(this->VarTreeIter, this->VarTree.Root()); } void PopDefinitions() { - this->VarStack.pop_back(); + ++this->VarTreeIter; } bool RaiseScope(std::string const& var, const char* varDef, cmMakefile* mf) { - std::list::reverse_iterator it = this->VarStack.rbegin(); - assert(it != this->VarStack.rend()); + cmLinkedTree::iterator it = this->VarTreeIter; + assert(it != this->VarTree.Root()); ++it; - if(it == this->VarStack.rend()) + if(it == this->VarTree.Root()) { cmLocalGenerator* plg = mf->LocalGenerator->GetParent(); if(!plg) @@ -132,7 +135,7 @@ public: return true; } // First localize the definition in the current scope. - cmDefinitions::Raise(var, this->VarStack.rbegin(), this->VarStack.rend()); + cmDefinitions::Raise(var, this->VarTreeIter, this->VarTree.Root()); // Now update the definition in the parent scope. it->Set(var, varDef); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ba3f3e3b43ae3ce8e61a62b90f57c6cfdf6d2243 commit ba3f3e3b43ae3ce8e61a62b90f57c6cfdf6d2243 Author: Stephen Kelly AuthorDate: Mon Jun 8 20:04:24 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 00:37:40 2015 +0200 cmMakefile: Extract InitializeVarScope method. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 60a11e1..e6fc464 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -55,6 +55,11 @@ public: this->VarStack.push_back(cmDefinitions()); } + void InitializeVarScope() + { + this->PushDefinitions(); + } + void InitializeDefinitions(cmMakefile* parent) { this->VarStack.back() = @@ -141,7 +146,7 @@ cmMakefile::cmMakefile(cmLocalGenerator* localGenerator) LocalGenerator(localGenerator), StateSnapshot(localGenerator->GetStateSnapshot()) { - this->Internal->PushDefinitions(); + this->Internal->InitializeVarScope(); this->Internal->IsSourceFileTryCompile = false; // Initialize these first since AddDefaultDefinitions calls AddDefinition ----------------------------------------------------------------------- Summary of changes: Source/cmDefinitions.cxx | 14 +-- Source/cmDefinitions.h | 17 ++-- Source/cmGlobalGenerator.cxx | 65 +++++++++++++ Source/cmLinkedTree.h | 11 +++ Source/cmMakefile.cxx | 135 ++++++-------------------- Source/cmState.cxx | 217 +++++++++++++++++++++++++++++++++++++++++- Source/cmState.h | 33 ++++++- 7 files changed, 367 insertions(+), 125 deletions(-) hooks/post-receive -- CMake From steveire at gmail.com Thu Aug 6 19:03:22 2015 From: steveire at gmail.com (Stephen Kelly) Date: Thu, 6 Aug 2015 19:03:22 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2056-gda69b39 Message-ID: <20150806230322.15CCBB1386@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via da69b3979d6e90bff5ce72b49f9c3b8e8496b648 (commit) via 4730a457d0b9d2f14a07744aea5144e76cb7c266 (commit) via 058624ce98b34dc2bd63c62f89000bf6fdef03c3 (commit) via 23ac9e58959cb125a91b45e80d131ab448d66eec (commit) via d88f83077b3b2c200d58d21bdad65308729ebfd8 (commit) via 83122c32ab533dbb32ce4ce6de70b069a217b437 (commit) via 398cdc2be369239bcd9bac5f98fe937a1253f664 (commit) via 1fe2c9a166727d14b5cc56bfe0425f9be12e578e (commit) via 906c9a26630e4fcf2360dd9e824b0191ecaf887f (commit) via ae94ca1c5902dc12ddd7eb7a9e4b197ddde5c884 (commit) via 239c6d37e28e3a979122999e8555696865fb4824 (commit) via 10040601a2e13cbb0653a20c55c1c696b5cacf29 (commit) via d9da6ee29fe0267ed347860f24f21be647ac81e8 (commit) via 27252b2414f5034b16a447273e1f249fdf317b72 (commit) from 6b479d5ee112efce1565fb8cbdebe389af3a9337 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=da69b3979d6e90bff5ce72b49f9c3b8e8496b648 commit da69b3979d6e90bff5ce72b49f9c3b8e8496b648 Merge: 6b479d5 4730a45 Author: Stephen Kelly AuthorDate: Thu Aug 6 19:03:19 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 6 19:03:19 2015 -0400 Merge topic 'use-generator-target' into next 4730a457 cmTarget: Use a simpler delete algorithm. 058624ce cmTarget: Split storage of sources from genexes. 23ac9e58 cmTarget: Split storage of compile definitions from genexes. d88f8307 cmTarget: Split storage of compile features from genexes. 83122c32 cmTarget: Split storage of compile options from genexes. 398cdc2b cmTarget: Split storage of include directories from genexes. 1fe2c9a1 cmTarget: Request only the link libraries where needed. 906c9a26 cmGeneratorTarget: Move link iface helpers from cmTarget. ae94ca1c cmGeneratorTarget: Move GetLinkInterface from cmTarget. 239c6d37 cmGlobalGenerator: Return null generator target for target. 10040601 cmLinkImplementationLibraries: Move to namespace scope. d9da6ee2 cmLinkItem: Split to separate file. 27252b24 cmComputeLinkInformation: Simplify generator object access. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4730a457d0b9d2f14a07744aea5144e76cb7c266 commit 4730a457d0b9d2f14a07744aea5144e76cb7c266 Author: Stephen Kelly AuthorDate: Tue Aug 4 23:16:12 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 01:03:00 2015 +0200 cmTarget: Use a simpler delete algorithm. This way, the methods can be moved without requiring a local algorithm. The containers use automatic storage. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 54934c1..ef2df21 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -161,14 +161,6 @@ public: cmLinkImplItem cmTargetInternals::TargetPropertyEntry::NoLinkImplItem; //---------------------------------------------------------------------------- -static void deleteAndClear( - std::vector &entries) -{ - cmDeleteAll(entries); - entries.clear(); -} - -//---------------------------------------------------------------------------- cmTargetInternals::~cmTargetInternals() { } @@ -783,7 +775,7 @@ void cmTarget::GetSourceFiles(std::vector &files, this->LinkImplementationLanguageIsContextDependent = false; } - deleteAndClear(linkInterfaceSourcesEntries); + cmDeleteAll(linkInterfaceSourcesEntries); } //---------------------------------------------------------------------------- @@ -2138,7 +2130,7 @@ cmTarget::GetIncludeDirectories(const std::string& config, debugIncludes, language); - deleteAndClear(linkInterfaceIncludeDirectoriesEntries); + cmDeleteAll(linkInterfaceIncludeDirectoriesEntries); return includes; } @@ -2259,7 +2251,7 @@ void cmTarget::GetCompileOptions(std::vector &result, debugOptions, language); - deleteAndClear(linkInterfaceCompileOptionsEntries); + cmDeleteAll(linkInterfaceCompileOptionsEntries); } //---------------------------------------------------------------------------- @@ -2361,7 +2353,7 @@ void cmTarget::GetCompileDefinitions(std::vector &list, debugDefines, language); - deleteAndClear(linkInterfaceCompileDefinitionsEntries); + cmDeleteAll(linkInterfaceCompileDefinitionsEntries); } //---------------------------------------------------------------------------- @@ -2428,7 +2420,7 @@ void cmTarget::GetCompileFeatures(std::vector &result, config, debugFeatures); - deleteAndClear(linkInterfaceCompileFeaturesEntries); + cmDeleteAll(linkInterfaceCompileFeaturesEntries); } //---------------------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=058624ce98b34dc2bd63c62f89000bf6fdef03c3 commit 058624ce98b34dc2bd63c62f89000bf6fdef03c3 Author: Stephen Kelly AuthorDate: Tue Aug 4 21:46:15 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 01:03:00 2015 +0200 cmTarget: Split storage of sources from genexes. diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index ce806ba..b094125 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -313,7 +313,9 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg, makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", mocCppFile.c_str(), false); - target->AddSource(mocCppFile); + std::vector mocCppFiles; + mocCppFiles.push_back(mocCppFile); + target->AddTracedSources(mocCppFiles); } // create a custom target for running generators at buildtime: std::string autogenTargetName = getAutogenTargetName(target); @@ -737,12 +739,7 @@ void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target) } } - for(std::vector::const_iterator fileIt = newRccFiles.begin(); - fileIt != newRccFiles.end(); - ++fileIt) - { - const_cast(target)->AddSource(*fileIt); - } + const_cast(target)->AddTracedSources(newRccFiles); } void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index c14691c..54934c1 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -148,7 +148,9 @@ public: std::vector CompileDefinitionsEntries; std::vector CompileDefinitionsBacktraces; std::vector CompileDefinitionsItems; - std::vector SourceEntries; + std::vector SourceEntries; + std::vector SourceBacktraces; + std::vector SourceItems; std::vector LinkImplementationPropertyEntries; void AddInterfaceEntries( @@ -416,7 +418,8 @@ void cmTarget::SetMakefile(cmMakefile* mf) void CreatePropertyGeneratorExpressions( std::vector const& entries, std::vector const& backtraces, - std::vector& items) + std::vector& items, + bool evaluateForBuildsystem = false) { std::vector::const_iterator btIt = backtraces.begin(); for (std::vector::const_iterator it = entries.begin(); @@ -424,6 +427,7 @@ void CreatePropertyGeneratorExpressions( { cmGeneratorExpression ge(*btIt); cmsys::auto_ptr cge = ge.Parse(*it); + cge->SetEvaluateForBuildsystem(evaluateForBuildsystem); items.push_back(new cmTargetInternals::TargetPropertyEntry(cge)); } } @@ -449,6 +453,11 @@ void cmTarget::Compute() this->Internal->CompileDefinitionsEntries, this->Internal->CompileDefinitionsBacktraces, this->Internal->CompileDefinitionsItems); + + CreatePropertyGeneratorExpressions( + this->Internal->SourceEntries, + this->Internal->SourceBacktraces, + this->Internal->SourceItems, true); } //---------------------------------------------------------------------------- @@ -699,13 +708,11 @@ void cmTarget::GetSourceFiles(std::vector &files, // for TARGET_OBJECTS instead for backwards compatibility with OLD // behavior of CMP0024 and CMP0026 only. - typedef cmTargetInternals::TargetPropertyEntry - TargetPropertyEntry; - for(std::vector::const_iterator + for(std::vector::const_iterator i = this->Internal->SourceEntries.begin(); i != this->Internal->SourceEntries.end(); ++i) { - std::string entry = (*i)->ge->GetInput(); + std::string const& entry = *i; std::vector items; cmSystemTools::ExpandListArgument(entry, items); @@ -747,7 +754,7 @@ void cmTarget::GetSourceFiles(std::vector &files, UNORDERED_SET uniqueSrcs; bool contextDependentDirectSources = processSources(this, - this->Internal->SourceEntries, + this->Internal->SourceItems, files, uniqueSrcs, &dagChecker, @@ -884,11 +891,12 @@ void cmTarget::AddTracedSources(std::vector const& srcs) this->Internal->SourceFilesMap.clear(); this->LinkImplementationLanguageIsContextDependent = true; cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + this->Internal->SourceEntries.push_back(srcFiles); + this->Internal->SourceBacktraces.push_back(lfbt); cmGeneratorExpression ge(lfbt); cmsys::auto_ptr cge = ge.Parse(srcFiles); - cge->SetEvaluateForBuildsystem(true); - this->Internal->SourceEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->SourceItems.push_back( + new cmTargetInternals::TargetPropertyEntry(cge)); } } @@ -924,11 +932,8 @@ void cmTarget::AddSources(std::vector const& srcs) this->Internal->SourceFilesMap.clear(); this->LinkImplementationLanguageIsContextDependent = true; cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - cmsys::auto_ptr cge = ge.Parse(srcFiles); - cge->SetEvaluateForBuildsystem(true); - this->Internal->SourceEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->SourceEntries.push_back(srcFiles); + this->Internal->SourceBacktraces.push_back(lfbt); } } @@ -1032,10 +1037,10 @@ public: } - bool operator()(cmTargetInternals::TargetPropertyEntry* entry) + bool operator()(std::string const& entry) { std::vector files; - cmSystemTools::ExpandListArgument(entry->ge->GetInput(), files); + cmSystemTools::ExpandListArgument(entry, files); std::vector locations(files.size()); std::transform(files.begin(), files.end(), locations.begin(), CreateLocation(this->Needle.GetMakefile())); @@ -1057,11 +1062,8 @@ cmSourceFile* cmTarget::AddSource(const std::string& src) this->Internal->SourceFilesMap.clear(); this->LinkImplementationLanguageIsContextDependent = true; cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - cmsys::auto_ptr cge = ge.Parse(src); - cge->SetEvaluateForBuildsystem(true); - this->Internal->SourceEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->SourceEntries.push_back(src); + this->Internal->SourceBacktraces.push_back(lfbt); } if (cmGeneratorExpression::Find(src) != std::string::npos) { @@ -1736,11 +1738,11 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) } this->Internal->SourceFilesMap.clear(); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); + this->Internal->SourceEntries.clear(); - cmsys::auto_ptr cge = ge.Parse(value); - this->Internal->SourceEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->SourceBacktraces.clear(); + this->Internal->SourceEntries.push_back(value); + this->Internal->SourceBacktraces.push_back(lfbt); } else { @@ -1821,10 +1823,8 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, } this->Internal->SourceFilesMap.clear(); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - cmsys::auto_ptr cge = ge.Parse(value); - this->Internal->SourceEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->SourceEntries.push_back(value); + this->Internal->SourceBacktraces.push_back(lfbt); } else { @@ -2949,13 +2949,11 @@ const char *cmTarget::GetProperty(const std::string& prop, std::ostringstream ss; const char* sep = ""; - typedef cmTargetInternals::TargetPropertyEntry - TargetPropertyEntry; - for(std::vector::const_iterator + for(std::vector::const_iterator i = this->Internal->SourceEntries.begin(); i != this->Internal->SourceEntries.end(); ++i) { - std::string entry = (*i)->ge->GetInput(); + std::string const& entry = *i; std::vector files; cmSystemTools::ExpandListArgument(entry, files); @@ -3610,13 +3608,11 @@ cmTarget::GetObjectLibrariesCMP0026(std::vector& objlibs) const // there is no cmGeneratorTarget at configure-time, so search the SOURCES // for TARGET_OBJECTS instead for backwards compatibility with OLD // behavior of CMP0024 and CMP0026 only. - typedef cmTargetInternals::TargetPropertyEntry - TargetPropertyEntry; - for(std::vector::const_iterator + for(std::vector::const_iterator i = this->Internal->SourceEntries.begin(); i != this->Internal->SourceEntries.end(); ++i) { - std::string entry = (*i)->ge->GetInput(); + std::string const& entry = *i; std::vector files; cmSystemTools::ExpandListArgument(entry, files); @@ -4366,7 +4362,7 @@ cmTargetInternalPointer::~cmTargetInternalPointer() cmDeleteAll(this->Pointer->CompileOptionsItems); cmDeleteAll(this->Pointer->CompileFeaturesItems); cmDeleteAll(this->Pointer->CompileDefinitionsItems); - cmDeleteAll(this->Pointer->SourceEntries); + cmDeleteAll(this->Pointer->SourceItems); delete this->Pointer; } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=23ac9e58959cb125a91b45e80d131ab448d66eec commit 23ac9e58959cb125a91b45e80d131ab448d66eec Author: Stephen Kelly AuthorDate: Tue Aug 4 21:30:17 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 01:02:57 2015 +0200 cmTarget: Split storage of compile definitions from genexes. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1762d2f..c14691c 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -145,7 +145,9 @@ public: std::vector CompileFeaturesEntries; std::vector CompileFeaturesBacktraces; std::vector CompileFeaturesItems; - std::vector CompileDefinitionsEntries; + std::vector CompileDefinitionsEntries; + std::vector CompileDefinitionsBacktraces; + std::vector CompileDefinitionsItems; std::vector SourceEntries; std::vector LinkImplementationPropertyEntries; @@ -442,6 +444,11 @@ void cmTarget::Compute() this->Internal->CompileFeaturesEntries, this->Internal->CompileFeaturesBacktraces, this->Internal->CompileFeaturesItems); + + CreatePropertyGeneratorExpressions( + this->Internal->CompileDefinitionsEntries, + this->Internal->CompileDefinitionsBacktraces, + this->Internal->CompileDefinitionsItems); } //---------------------------------------------------------------------------- @@ -1694,12 +1701,11 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) } else if(prop == "COMPILE_DEFINITIONS") { + this->Internal->CompileDefinitionsEntries.clear(); + this->Internal->CompileDefinitionsBacktraces.clear(); + this->Internal->CompileDefinitionsEntries.push_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - deleteAndClear(this->Internal->CompileDefinitionsEntries); - cmsys::auto_ptr cge = ge.Parse(value); - this->Internal->CompileDefinitionsEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->CompileDefinitionsBacktraces.push_back(lfbt); } else if(prop == "EXPORT_NAME" && this->IsImported()) { @@ -1783,10 +1789,9 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, } else if(prop == "COMPILE_DEFINITIONS") { + this->Internal->CompileDefinitionsEntries.push_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - this->Internal->CompileDefinitionsEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); + this->Internal->CompileDefinitionsBacktraces.push_back(lfbt); } else if(prop == "EXPORT_NAME" && this->IsImported()) { @@ -1918,10 +1923,8 @@ void cmTarget::InsertCompileOption(std::string const& entry, void cmTarget::InsertCompileDefinition(std::string const& entry, cmListFileBacktrace const& bt) { - cmGeneratorExpression ge(bt); - - this->Internal->CompileDefinitionsEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(ge.Parse(entry))); + this->Internal->CompileDefinitionsEntries.push_back(entry); + this->Internal->CompileDefinitionsBacktraces.push_back(bt); } //---------------------------------------------------------------------------- @@ -2303,7 +2306,7 @@ void cmTarget::GetCompileDefinitions(std::vector &list, } processCompileDefinitions(this, - this->Internal->CompileDefinitionsEntries, + this->Internal->CompileDefinitionsItems, list, uniqueOptions, &dagChecker, @@ -2711,22 +2714,6 @@ bool cmTarget::HandleLocationPropertyPolicy(cmMakefile* context) const } //---------------------------------------------------------------------------- -static void MakePropertyList(std::string& output, - std::vector const& values) -{ - output = ""; - std::string sep; - for (std::vector::const_iterator - it = values.begin(), end = values.end(); - it != end; ++it) - { - output += sep; - output += (*it)->ge->GetInput(); - sep = ";"; - } -} - -//---------------------------------------------------------------------------- const char *cmTarget::GetProperty(const std::string& prop) const { return this->GetProperty(prop, this->Makefile); @@ -2934,7 +2921,7 @@ const char *cmTarget::GetProperty(const std::string& prop, } static std::string output; - MakePropertyList(output, this->Internal->CompileDefinitionsEntries); + output = cmJoin(this->Internal->CompileDefinitionsEntries, ";"); return output.c_str(); } else if (prop == propIMPORTED) @@ -4378,7 +4365,7 @@ cmTargetInternalPointer::~cmTargetInternalPointer() cmDeleteAll(this->Pointer->IncludeDirectoriesItems); cmDeleteAll(this->Pointer->CompileOptionsItems); cmDeleteAll(this->Pointer->CompileFeaturesItems); - cmDeleteAll(this->Pointer->CompileDefinitionsEntries); + cmDeleteAll(this->Pointer->CompileDefinitionsItems); cmDeleteAll(this->Pointer->SourceEntries); delete this->Pointer; } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d88f83077b3b2c200d58d21bdad65308729ebfd8 commit d88f83077b3b2c200d58d21bdad65308729ebfd8 Author: Stephen Kelly AuthorDate: Tue Aug 4 21:23:38 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 00:59:46 2015 +0200 cmTarget: Split storage of compile features from genexes. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index ae8fea2..1762d2f 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -142,7 +142,9 @@ public: std::vector CompileOptionsEntries; std::vector CompileOptionsBacktraces; std::vector CompileOptionsItems; - std::vector CompileFeaturesEntries; + std::vector CompileFeaturesEntries; + std::vector CompileFeaturesBacktraces; + std::vector CompileFeaturesItems; std::vector CompileDefinitionsEntries; std::vector SourceEntries; std::vector LinkImplementationPropertyEntries; @@ -435,6 +437,11 @@ void cmTarget::Compute() this->Internal->CompileOptionsEntries, this->Internal->CompileOptionsBacktraces, this->Internal->CompileOptionsItems); + + CreatePropertyGeneratorExpressions( + this->Internal->CompileFeaturesEntries, + this->Internal->CompileFeaturesBacktraces, + this->Internal->CompileFeaturesItems); } //---------------------------------------------------------------------------- @@ -1679,12 +1686,11 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) } else if(prop == "COMPILE_FEATURES") { + this->Internal->CompileFeaturesEntries.clear(); + this->Internal->CompileFeaturesBacktraces.clear(); + this->Internal->CompileFeaturesEntries.push_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - deleteAndClear(this->Internal->CompileFeaturesEntries); - cmsys::auto_ptr cge = ge.Parse(value); - this->Internal->CompileFeaturesEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->CompileFeaturesBacktraces.push_back(lfbt); } else if(prop == "COMPILE_DEFINITIONS") { @@ -1771,10 +1777,9 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, } else if(prop == "COMPILE_FEATURES") { + this->Internal->CompileFeaturesEntries.push_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - this->Internal->CompileFeaturesEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); + this->Internal->CompileFeaturesBacktraces.push_back(lfbt); } else if(prop == "COMPILE_DEFINITIONS") { @@ -2399,7 +2404,7 @@ void cmTarget::GetCompileFeatures(std::vector &result, } processCompileFeatures(this, - this->Internal->CompileFeaturesEntries, + this->Internal->CompileFeaturesItems, result, uniqueFeatures, &dagChecker, @@ -2907,7 +2912,7 @@ const char *cmTarget::GetProperty(const std::string& prop, } static std::string output; - MakePropertyList(output, this->Internal->CompileFeaturesEntries); + output = cmJoin(this->Internal->CompileFeaturesEntries, ";"); return output.c_str(); } else if(prop == propCOMPILE_OPTIONS) @@ -4372,7 +4377,7 @@ cmTargetInternalPointer::~cmTargetInternalPointer() { cmDeleteAll(this->Pointer->IncludeDirectoriesItems); cmDeleteAll(this->Pointer->CompileOptionsItems); - cmDeleteAll(this->Pointer->CompileFeaturesEntries); + cmDeleteAll(this->Pointer->CompileFeaturesItems); cmDeleteAll(this->Pointer->CompileDefinitionsEntries); cmDeleteAll(this->Pointer->SourceEntries); delete this->Pointer; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=83122c32ab533dbb32ce4ce6de70b069a217b437 commit 83122c32ab533dbb32ce4ce6de70b069a217b437 Author: Stephen Kelly AuthorDate: Tue Aug 4 21:19:00 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 00:59:45 2015 +0200 cmTarget: Split storage of compile options from genexes. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 23553c0..ae8fea2 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -139,7 +139,9 @@ public: std::vector IncludeDirectoriesEntries; std::vector IncludeDirectoriesBacktraces; std::vector IncludeDirectoriesItems; - std::vector CompileOptionsEntries; + std::vector CompileOptionsEntries; + std::vector CompileOptionsBacktraces; + std::vector CompileOptionsItems; std::vector CompileFeaturesEntries; std::vector CompileDefinitionsEntries; std::vector SourceEntries; @@ -354,13 +356,12 @@ void cmTarget::SetMakefile(cmMakefile* mf) const cmBacktraceRange parentOptionsBts = this->Makefile->GetCompileOptionsBacktraces(); - cmBacktraceRange::const_iterator btIt = parentOptionsBts.begin(); - for (cmStringRange::const_iterator it - = parentOptions.begin(); - it != parentOptions.end(); ++it, ++btIt) - { - this->InsertCompileOption(*it, *btIt); - } + this->Internal->CompileOptionsEntries.insert( + this->Internal->CompileOptionsEntries.end(), + parentOptions.begin(), parentOptions.end()); + this->Internal->CompileOptionsBacktraces.insert( + this->Internal->CompileOptionsBacktraces.end(), + parentOptionsBts.begin(), parentOptionsBts.end()); } if (this->GetType() != INTERFACE_LIBRARY && this->GetType() != UTILITY) @@ -429,6 +430,11 @@ void cmTarget::Compute() this->Internal->IncludeDirectoriesEntries, this->Internal->IncludeDirectoriesBacktraces, this->Internal->IncludeDirectoriesItems); + + CreatePropertyGeneratorExpressions( + this->Internal->CompileOptionsEntries, + this->Internal->CompileOptionsBacktraces, + this->Internal->CompileOptionsItems); } //---------------------------------------------------------------------------- @@ -1665,12 +1671,11 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) } else if(prop == "COMPILE_OPTIONS") { + this->Internal->CompileOptionsEntries.clear(); + this->Internal->CompileOptionsBacktraces.clear(); + this->Internal->CompileOptionsEntries.push_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - deleteAndClear(this->Internal->CompileOptionsEntries); - cmsys::auto_ptr cge = ge.Parse(value); - this->Internal->CompileOptionsEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->CompileOptionsBacktraces.push_back(lfbt); } else if(prop == "COMPILE_FEATURES") { @@ -1760,10 +1765,9 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, } else if(prop == "COMPILE_OPTIONS") { + this->Internal->CompileOptionsEntries.push_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - this->Internal->CompileOptionsEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); + this->Internal->CompileOptionsBacktraces.push_back(lfbt); } else if(prop == "COMPILE_FEATURES") { @@ -1893,14 +1897,16 @@ void cmTarget::InsertCompileOption(std::string const& entry, cmListFileBacktrace const& bt, bool before) { - cmGeneratorExpression ge(bt); + std::vector::iterator position = + before ? this->Internal->CompileOptionsEntries.begin() + : this->Internal->CompileOptionsEntries.end(); - std::vector::iterator position - = before ? this->Internal->CompileOptionsEntries.begin() - : this->Internal->CompileOptionsEntries.end(); + std::vector::iterator btPosition = + before ? this->Internal->CompileOptionsBacktraces.begin() + : this->Internal->CompileOptionsBacktraces.end(); - this->Internal->CompileOptionsEntries.insert(position, - new cmTargetInternals::TargetPropertyEntry(ge.Parse(entry))); + this->Internal->CompileOptionsEntries.insert(position, entry); + this->Internal->CompileOptionsBacktraces.insert(btPosition, bt); } //---------------------------------------------------------------------------- @@ -2221,7 +2227,7 @@ void cmTarget::GetCompileOptions(std::vector &result, } processCompileOptions(this, - this->Internal->CompileOptionsEntries, + this->Internal->CompileOptionsItems, result, uniqueOptions, &dagChecker, @@ -2912,7 +2918,7 @@ const char *cmTarget::GetProperty(const std::string& prop, } static std::string output; - MakePropertyList(output, this->Internal->CompileOptionsEntries); + output = cmJoin(this->Internal->CompileOptionsEntries, ";"); return output.c_str(); } else if(prop == propCOMPILE_DEFINITIONS) @@ -4365,7 +4371,7 @@ cmTargetInternalPointer cmTargetInternalPointer::~cmTargetInternalPointer() { cmDeleteAll(this->Pointer->IncludeDirectoriesItems); - cmDeleteAll(this->Pointer->CompileOptionsEntries); + cmDeleteAll(this->Pointer->CompileOptionsItems); cmDeleteAll(this->Pointer->CompileFeaturesEntries); cmDeleteAll(this->Pointer->CompileDefinitionsEntries); cmDeleteAll(this->Pointer->SourceEntries); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=398cdc2be369239bcd9bac5f98fe937a1253f664 commit 398cdc2be369239bcd9bac5f98fe937a1253f664 Author: Stephen Kelly AuthorDate: Tue Aug 4 20:25:02 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 00:59:44 2015 +0200 cmTarget: Split storage of include directories from genexes. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 09c796b..195fa0d 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1549,6 +1549,7 @@ void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes, ti != targets.end(); ++ti) { cmTarget* t = &ti->second; + t->Compute(); cmGeneratorTarget* gt = new cmGeneratorTarget(t, lg); this->GeneratorTargets[t] = gt; generatorTargets[t] = gt; diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index d5a5585..51dcab0 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -254,6 +254,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() mf->AddUtilityCommand(CMAKE_CHECK_BUILD_SYSTEM_TARGET, false, no_working_directory, no_depends, noCommandLines); + tgt->Compute(); cmGeneratorTarget* gt = new cmGeneratorTarget(tgt, lg); mf->AddGeneratorTarget(tgt, gt); diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 2f9d79a..b69fc65 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -90,6 +90,7 @@ bool cmGlobalVisualStudioGenerator::Compute() AddUtilityCommand("ALL_BUILD", true, no_working_dir, no_depends, no_commands, false, "Build all projects"); + allBuild->Compute(); cmGeneratorTarget* gt = new cmGeneratorTarget(allBuild, gen[0]); allBuild->GetMakefile()->AddGeneratorTarget(allBuild, gt); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 5006828..aae0b23 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -463,6 +463,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, cmTarget* allbuild = mf->AddUtilityCommand("ALL_BUILD", true, no_depends, no_working_directory, "echo", "Build all projects"); + allBuild->Compute(); cmGeneratorTarget* allBuildGt = new cmGeneratorTarget(allbuild, root); mf->AddGeneratorTarget(allbuild, allBuildGt); @@ -497,6 +498,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, true, no_depends, no_working_directory, "make", "-f", file.c_str()); + check->Compute(); cmGeneratorTarget* checkGt = new cmGeneratorTarget(check, root); mf->AddGeneratorTarget(check, checkGt); } diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index f1ba2f4..ce806ba 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -475,6 +475,8 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg, /*byproducts=*/rcc_output, depends, commandLines, false, autogenComment.c_str()); + autogenTarget->Compute(); + cmGeneratorTarget* gt = new cmGeneratorTarget(autogenTarget, lg); makefile->AddGeneratorTarget(autogenTarget, gt); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 8830bf2..23553c0 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -136,7 +136,9 @@ public: const cmsys::auto_ptr ge; cmLinkImplItem const& LinkImplItem; }; - std::vector IncludeDirectoriesEntries; + std::vector IncludeDirectoriesEntries; + std::vector IncludeDirectoriesBacktraces; + std::vector IncludeDirectoriesItems; std::vector CompileOptionsEntries; std::vector CompileFeaturesEntries; std::vector CompileDefinitionsEntries; @@ -334,13 +336,13 @@ void cmTarget::SetMakefile(cmMakefile* mf) const cmBacktraceRange parentIncludesBts = this->Makefile->GetIncludeDirectoriesBacktraces(); - cmBacktraceRange::const_iterator btIt = parentIncludesBts.begin(); - for (cmStringRange::const_iterator it - = parentIncludes.begin(); - it != parentIncludes.end(); ++it, ++btIt) - { - this->InsertInclude(*it, *btIt); - } + this->Internal->IncludeDirectoriesEntries.insert( + this->Internal->IncludeDirectoriesEntries.end(), + parentIncludes.begin(), parentIncludes.end()); + this->Internal->IncludeDirectoriesBacktraces.insert( + this->Internal->IncludeDirectoriesBacktraces.end(), + parentIncludesBts.begin(), parentIncludesBts.end()); + const std::set parentSystemIncludes = this->Makefile->GetSystemIncludeDirectories(); @@ -352,7 +354,7 @@ void cmTarget::SetMakefile(cmMakefile* mf) const cmBacktraceRange parentOptionsBts = this->Makefile->GetCompileOptionsBacktraces(); - btIt = parentOptionsBts.begin(); + cmBacktraceRange::const_iterator btIt = parentOptionsBts.begin(); for (cmStringRange::const_iterator it = parentOptions.begin(); it != parentOptions.end(); ++it, ++btIt) @@ -406,6 +408,29 @@ void cmTarget::SetMakefile(cmMakefile* mf) } } +void CreatePropertyGeneratorExpressions( + std::vector const& entries, + std::vector const& backtraces, + std::vector& items) +{ + std::vector::const_iterator btIt = backtraces.begin(); + for (std::vector::const_iterator it = entries.begin(); + it != entries.end(); ++it, ++btIt) + { + cmGeneratorExpression ge(*btIt); + cmsys::auto_ptr cge = ge.Parse(*it); + items.push_back(new cmTargetInternals::TargetPropertyEntry(cge)); + } +} + +void cmTarget::Compute() +{ + CreatePropertyGeneratorExpressions( + this->Internal->IncludeDirectoriesEntries, + this->Internal->IncludeDirectoriesBacktraces, + this->Internal->IncludeDirectoriesItems); +} + //---------------------------------------------------------------------------- void cmTarget::AddUtility(const std::string& u, cmMakefile *makefile) { @@ -1632,12 +1657,11 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) } else if(prop == "INCLUDE_DIRECTORIES") { + this->Internal->IncludeDirectoriesEntries.clear(); + this->Internal->IncludeDirectoriesBacktraces.clear(); + this->Internal->IncludeDirectoriesEntries.push_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - deleteAndClear(this->Internal->IncludeDirectoriesEntries); - cmsys::auto_ptr cge = ge.Parse(value); - this->Internal->IncludeDirectoriesEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->IncludeDirectoriesBacktraces.push_back(lfbt); } else if(prop == "COMPILE_OPTIONS") { @@ -1730,10 +1754,9 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, } else if(prop == "INCLUDE_DIRECTORIES") { + this->Internal->IncludeDirectoriesEntries.push_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - this->Internal->IncludeDirectoriesEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); + this->Internal->IncludeDirectoriesBacktraces.push_back(lfbt); } else if(prop == "COMPILE_OPTIONS") { @@ -1853,14 +1876,16 @@ void cmTarget::InsertInclude(std::string const& entry, cmListFileBacktrace const& bt, bool before) { - cmGeneratorExpression ge(bt); + std::vector::iterator position = + before ? this->Internal->IncludeDirectoriesEntries.begin() + : this->Internal->IncludeDirectoriesEntries.end(); - std::vector::iterator position - = before ? this->Internal->IncludeDirectoriesEntries.begin() - : this->Internal->IncludeDirectoriesEntries.end(); + std::vector::iterator btPosition = + before ? this->Internal->IncludeDirectoriesBacktraces.begin() + : this->Internal->IncludeDirectoriesBacktraces.end(); - this->Internal->IncludeDirectoriesEntries.insert(position, - new cmTargetInternals::TargetPropertyEntry(ge.Parse(entry))); + this->Internal->IncludeDirectoriesEntries.insert(position, entry); + this->Internal->IncludeDirectoriesBacktraces.insert(btPosition, bt); } //---------------------------------------------------------------------------- @@ -2049,7 +2074,7 @@ cmTarget::GetIncludeDirectories(const std::string& config, } processIncludeDirectories(this, - this->Internal->IncludeDirectoriesEntries, + this->Internal->IncludeDirectoriesItems, includes, uniqueIncludes, &dagChecker, @@ -2865,7 +2890,7 @@ const char *cmTarget::GetProperty(const std::string& prop, } static std::string output; - MakePropertyList(output, this->Internal->IncludeDirectoriesEntries); + output = cmJoin(this->Internal->IncludeDirectoriesEntries, ";"); return output.c_str(); } else if(prop == propCOMPILE_FEATURES) @@ -4339,7 +4364,7 @@ cmTargetInternalPointer //---------------------------------------------------------------------------- cmTargetInternalPointer::~cmTargetInternalPointer() { - cmDeleteAll(this->Pointer->IncludeDirectoriesEntries); + cmDeleteAll(this->Pointer->IncludeDirectoriesItems); cmDeleteAll(this->Pointer->CompileOptionsEntries); cmDeleteAll(this->Pointer->CompileFeaturesEntries); cmDeleteAll(this->Pointer->CompileDefinitionsEntries); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 3e689ae..dcf6832 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -132,6 +132,8 @@ public: void AddPostBuildCommand(cmCustomCommand const &cmd) {this->PostBuildCommands.push_back(cmd);} + void Compute(); + /** * Get the list of the source files used by this target */ http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1fe2c9a166727d14b5cc56bfe0425f9be12e578e commit 1fe2c9a166727d14b5cc56bfe0425f9be12e578e Author: Stephen Kelly AuthorDate: Tue Aug 4 19:22:30 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 00:59:44 2015 +0200 cmTarget: Request only the link libraries where needed. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index ba72fdc..8830bf2 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2065,7 +2065,8 @@ cmTarget::GetIncludeDirectories(const std::string& config, if(this->Makefile->IsOn("APPLE")) { - LinkImplementation const* impl = this->GetLinkImplementation(config); + cmLinkImplementationLibraries const* impl = + this->GetLinkImplementationLibraries(config); for(std::vector::const_iterator it = impl->Libraries.begin(); it != impl->Libraries.end(); ++it) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=906c9a26630e4fcf2360dd9e824b0191ecaf887f commit 906c9a26630e4fcf2360dd9e824b0191ecaf887f Author: Stephen Kelly AuthorDate: Tue Aug 4 19:22:30 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 00:59:43 2015 +0200 cmGeneratorTarget: Move link iface helpers from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 27d6a99..fa1622e 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3334,6 +3334,51 @@ cmGeneratorTarget::ReportPropertyOrigin(const std::string &p, } //---------------------------------------------------------------------------- +void cmGeneratorTarget::LookupLinkItems(std::vector const& names, + std::vector& items) const +{ + for(std::vector::const_iterator i = names.begin(); + i != names.end(); ++i) + { + std::string name = this->Target->CheckCMP0004(*i); + if(name == this->GetName() || name.empty()) + { + continue; + } + items.push_back(cmLinkItem(name, this->Target->FindTargetToLink(name))); + } +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::ExpandLinkItems(std::string const& prop, + std::string const& value, + std::string const& config, + cmTarget const* headTarget, + bool usage_requirements_only, + std::vector& items, + bool& hadHeadSensitiveCondition) const +{ + cmGeneratorExpression ge; + cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), prop, 0, 0); + // The $ expression may be in a link interface to specify private + // link dependencies that are otherwise excluded from usage requirements. + if(usage_requirements_only) + { + dagChecker.SetTransitivePropertiesOnly(); + } + std::vector libs; + cmsys::auto_ptr cge = ge.Parse(value); + cmSystemTools::ExpandListArgument(cge->Evaluate( + this->Makefile, + config, + false, + headTarget, + this->Target, &dagChecker), libs); + this->LookupLinkItems(libs, items); + hadHeadSensitiveCondition = cge->GetHadHeadSensitiveCondition(); +} + +//---------------------------------------------------------------------------- cmGeneratorTarget::LinkInterface const* cmGeneratorTarget::GetLinkInterface( const std::string& config, cmTarget const* head) const @@ -3368,14 +3413,14 @@ cmGeneratorTarget::LinkInterface const* cmGeneratorTarget::GetLinkInterface( { iface.LibrariesDone = true; this->ComputeLinkInterfaceLibraries( - this->Target, config, iface, head, false); + config, iface, head, false); } if(!iface.AllDone) { iface.AllDone = true; if(iface.Exists) { - this->ComputeLinkInterface(this->Target, config, iface, head); + this->ComputeLinkInterface(config, iface, head); } } @@ -3421,7 +3466,7 @@ cmGeneratorTarget::GetLinkInterfaceLibraries(const std::string& config, { iface.LibrariesDone = true; this->ComputeLinkInterfaceLibraries( - this->Target, config, iface, head, usage_requirements_only); + config, iface, head, usage_requirements_only); } return iface.Exists? &iface : 0; @@ -3458,13 +3503,13 @@ cmGeneratorTarget::GetImportLinkInterface(const std::string& config, iface.AllDone = true; iface.Multiplicity = info->Multiplicity; cmSystemTools::ExpandListArgument(info->Languages, iface.Languages); - this->Target->ExpandLinkItems(info->LibrariesProp, info->Libraries, config, + this->ExpandLinkItems(info->LibrariesProp, info->Libraries, config, headTarget, usage_requirements_only, iface.Libraries, iface.HadHeadSensitiveCondition); std::vector deps; cmSystemTools::ExpandListArgument(info->SharedDeps, deps); - this->Target->LookupLinkItems(deps, iface.SharedDeps); + this->LookupLinkItems(deps, iface.SharedDeps); } return &iface; @@ -3473,7 +3518,6 @@ cmGeneratorTarget::GetImportLinkInterface(const std::string& config, //---------------------------------------------------------------------------- void cmGeneratorTarget::ComputeLinkInterfaceLibraries( - cmTarget const* thisTarget, const std::string& config, OptionalLinkInterface& iface, cmTarget const* headTarget, @@ -3494,15 +3538,15 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( // libraries and executables that export symbols. const char* explicitLibraries = 0; std::string linkIfaceProp; - if(thisTarget->GetPolicyStatusCMP0022() != cmPolicies::OLD && - thisTarget->GetPolicyStatusCMP0022() != cmPolicies::WARN) + if(this->Target->GetPolicyStatusCMP0022() != cmPolicies::OLD && + this->Target->GetPolicyStatusCMP0022() != cmPolicies::WARN) { // CMP0022 NEW behavior is to use INTERFACE_LINK_LIBRARIES. linkIfaceProp = "INTERFACE_LINK_LIBRARIES"; - explicitLibraries = thisTarget->GetProperty(linkIfaceProp); + explicitLibraries = this->Target->GetProperty(linkIfaceProp); } - else if(thisTarget->GetType() == cmTarget::SHARED_LIBRARY || - thisTarget->IsExecutableWithExports()) + else if(this->Target->GetType() == cmTarget::SHARED_LIBRARY || + this->Target->IsExecutableWithExports()) { // CMP0022 OLD behavior is to use LINK_INTERFACE_LIBRARIES if set on a // shared lib or executable. @@ -3510,30 +3554,30 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( // Lookup the per-configuration property. linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; linkIfaceProp += suffix; - explicitLibraries = thisTarget->GetProperty(linkIfaceProp); + explicitLibraries = this->Target->GetProperty(linkIfaceProp); // If not set, try the generic property. if(!explicitLibraries) { linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; - explicitLibraries = thisTarget->GetProperty(linkIfaceProp); + explicitLibraries = this->Target->GetProperty(linkIfaceProp); } } if(explicitLibraries && - thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN && + this->Target->GetPolicyStatusCMP0022() == cmPolicies::WARN && !this->PolicyWarnedCMP0022) { // Compare the explicitly set old link interface properties to the // preferred new link interface property one and warn if different. const char* newExplicitLibraries = - thisTarget->GetProperty("INTERFACE_LINK_LIBRARIES"); + this->Target->GetProperty("INTERFACE_LINK_LIBRARIES"); if (newExplicitLibraries && strcmp(newExplicitLibraries, explicitLibraries) != 0) { std::ostringstream w; w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n" - "Target \"" << thisTarget->GetName() << "\" has an " + "Target \"" << this->Target->GetName() << "\" has an " "INTERFACE_LINK_LIBRARIES property which differs from its " << linkIfaceProp << " properties." "\n" @@ -3541,7 +3585,7 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( " " << newExplicitLibraries << "\n" << linkIfaceProp << ":\n" " " << (explicitLibraries ? explicitLibraries : "(empty)") << "\n"; - thisTarget->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + this->Target->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); this->PolicyWarnedCMP0022 = true; } } @@ -3549,8 +3593,8 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( // There is no implicit link interface for executables or modules // so if none was explicitly set then there is no link interface. if(!explicitLibraries && - (thisTarget->GetType() == cmTarget::EXECUTABLE || - (thisTarget->GetType() == cmTarget::MODULE_LIBRARY))) + (this->Target->GetType() == cmTarget::EXECUTABLE || + (this->Target->GetType() == cmTarget::MODULE_LIBRARY))) { return; } @@ -3560,13 +3604,13 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( if(explicitLibraries) { // The interface libraries have been explicitly set. - thisTarget->ExpandLinkItems(linkIfaceProp, explicitLibraries, config, + this->ExpandLinkItems(linkIfaceProp, explicitLibraries, config, headTarget, usage_requirements_only, iface.Libraries, iface.HadHeadSensitiveCondition); } - else if (thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN - || thisTarget->GetPolicyStatusCMP0022() == cmPolicies::OLD) + else if (this->Target->GetPolicyStatusCMP0022() == cmPolicies::WARN + || this->Target->GetPolicyStatusCMP0022() == cmPolicies::OLD) // If CMP0022 is NEW then the plain tll signature sets the // INTERFACE_LINK_LIBRARIES, so if we get here then the project // cleared the property explicitly and we should not fall back @@ -3574,20 +3618,20 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( { // The link implementation is the default link interface. cmLinkImplementationLibraries const* impl = - thisTarget->GetLinkImplementationLibrariesInternal(config, headTarget); + this->Target->GetLinkImplementationLibrariesInternal(config, headTarget); iface.Libraries.insert(iface.Libraries.end(), impl->Libraries.begin(), impl->Libraries.end()); - if(thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN && + if(this->Target->GetPolicyStatusCMP0022() == cmPolicies::WARN && !this->PolicyWarnedCMP0022 && !usage_requirements_only) { // Compare the link implementation fallback link interface to the // preferred new link interface property and warn if different. std::vector ifaceLibs; static const std::string newProp = "INTERFACE_LINK_LIBRARIES"; - if(const char* newExplicitLibraries = thisTarget->GetProperty(newProp)) + if(const char* newExplicitLibraries = this->Target->GetProperty(newProp)) { bool hadHeadSensitiveConditionDummy = false; - thisTarget->ExpandLinkItems(newProp, newExplicitLibraries, config, + this->ExpandLinkItems(newProp, newExplicitLibraries, config, headTarget, usage_requirements_only, ifaceLibs, hadHeadSensitiveConditionDummy); } @@ -3602,7 +3646,7 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( std::ostringstream w; w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n" - "Target \"" << thisTarget->GetName() << "\" has an " + "Target \"" << this->Target->GetName() << "\" has an " "INTERFACE_LINK_LIBRARIES property. " "This should be preferred as the source of the link interface " "for this library but because CMP0022 is not set CMake is " @@ -3613,7 +3657,7 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( " " << newLibraries << "\n" "Link implementation:\n" " " << oldLibraries << "\n"; - thisTarget->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + this->Target->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); this->PolicyWarnedCMP0022 = true; } } @@ -3621,16 +3665,15 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( } //---------------------------------------------------------------------------- -void cmGeneratorTarget::ComputeLinkInterface(cmTarget const* thisTarget, - const std::string& config, +void cmGeneratorTarget::ComputeLinkInterface(const std::string& config, OptionalLinkInterface& iface, cmTarget const* headTarget) const { if(iface.ExplicitLibraries) { - if(thisTarget->GetType() == cmTarget::SHARED_LIBRARY - || thisTarget->GetType() == cmTarget::STATIC_LIBRARY - || thisTarget->GetType() == cmTarget::INTERFACE_LIBRARY) + if(this->GetType() == cmTarget::SHARED_LIBRARY + || this->GetType() == cmTarget::STATIC_LIBRARY + || this->GetType() == cmTarget::INTERFACE_LIBRARY) { // Shared libraries may have runtime implementation dependencies // on other shared libraries that are not in the interface. @@ -3640,10 +3683,10 @@ void cmGeneratorTarget::ComputeLinkInterface(cmTarget const* thisTarget, { emitted.insert(*li); } - if (thisTarget->GetType() != cmTarget::INTERFACE_LIBRARY) + if (this->GetType() != cmTarget::INTERFACE_LIBRARY) { cmTarget::LinkImplementation const* impl = - thisTarget->GetLinkImplementation(config); + this->Target->GetLinkImplementation(config); for(std::vector::const_iterator li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li) { @@ -3669,28 +3712,28 @@ void cmGeneratorTarget::ComputeLinkInterface(cmTarget const* thisTarget, } } } - else if (thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN - || thisTarget->GetPolicyStatusCMP0022() == cmPolicies::OLD) + else if (this->Target->GetPolicyStatusCMP0022() == cmPolicies::WARN + || this->Target->GetPolicyStatusCMP0022() == cmPolicies::OLD) { // The link implementation is the default link interface. cmLinkImplementationLibraries const* - impl = thisTarget->GetLinkImplementationLibrariesInternal(config, + impl = this->Target->GetLinkImplementationLibrariesInternal(config, headTarget); iface.ImplementationIsInterface = true; iface.WrongConfigLibraries = impl->WrongConfigLibraries; } - if(thisTarget->LinkLanguagePropagatesToDependents()) + if(this->Target->LinkLanguagePropagatesToDependents()) { // Targets using this archive need its language runtime libraries. if(cmTarget::LinkImplementation const* impl = - thisTarget->GetLinkImplementation(config)) + this->Target->GetLinkImplementation(config)) { iface.Languages = impl->Languages; } } - if(thisTarget->GetType() == cmTarget::STATIC_LIBRARY) + if(this->GetType() == cmTarget::STATIC_LIBRARY) { // Construct the property name suffix for this configuration. std::string suffix = "_"; @@ -3707,12 +3750,12 @@ void cmGeneratorTarget::ComputeLinkInterface(cmTarget const* thisTarget, // dependencies? std::string propName = "LINK_INTERFACE_MULTIPLICITY"; propName += suffix; - if(const char* config_reps = thisTarget->GetProperty(propName)) + if(const char* config_reps = this->Target->GetProperty(propName)) { sscanf(config_reps, "%u", &iface.Multiplicity); } else if(const char* reps = - thisTarget->GetProperty("LINK_INTERFACE_MULTIPLICITY")) + this->Target->GetProperty("LINK_INTERFACE_MULTIPLICITY")) { sscanf(reps, "%u", &iface.Multiplicity); } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 94402ed..24163b6 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -431,12 +431,10 @@ private: bool HadHeadSensitiveCondition; const char* ExplicitLibraries; }; - void ComputeLinkInterface(cmTarget const* thisTarget, - const std::string& config, + void ComputeLinkInterface(const std::string& config, OptionalLinkInterface& iface, cmTarget const* head) const; - void ComputeLinkInterfaceLibraries(cmTarget const* thisTarget, - const std::string& config, + void ComputeLinkInterfaceLibraries(const std::string& config, OptionalLinkInterface& iface, cmTarget const* head, bool usage_requirements_only) const; @@ -450,6 +448,14 @@ private: mutable bool PolicyWarnedCMP0022; + void ExpandLinkItems(std::string const& prop, std::string const& value, + std::string const& config, cmTarget const* headTarget, + bool usage_requirements_only, + std::vector& items, + bool& hadHeadSensitiveCondition) const; + void LookupLinkItems(std::vector const& names, + std::vector& items) const; + public: std::vector const& GetLinkImplementationClosure(const std::string& config) const; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index eceabd0..ba72fdc 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3033,51 +3033,6 @@ bool cmTarget::GetPropertyAsBool(const std::string& prop) const } //---------------------------------------------------------------------------- -void cmTarget::ExpandLinkItems(std::string const& prop, - std::string const& value, - std::string const& config, - cmTarget const* headTarget, - bool usage_requirements_only, - std::vector& items, - bool& hadHeadSensitiveCondition) const -{ - cmGeneratorExpression ge; - cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), prop, 0, 0); - // The $ expression may be in a link interface to specify private - // link dependencies that are otherwise excluded from usage requirements. - if(usage_requirements_only) - { - dagChecker.SetTransitivePropertiesOnly(); - } - std::vector libs; - cmsys::auto_ptr cge = ge.Parse(value); - cmSystemTools::ExpandListArgument(cge->Evaluate( - this->Makefile, - config, - false, - headTarget, - this, &dagChecker), libs); - this->LookupLinkItems(libs, items); - hadHeadSensitiveCondition = cge->GetHadHeadSensitiveCondition(); -} - -//---------------------------------------------------------------------------- -void cmTarget::LookupLinkItems(std::vector const& names, - std::vector& items) const -{ - for(std::vector::const_iterator i = names.begin(); - i != names.end(); ++i) - { - std::string name = this->CheckCMP0004(*i); - if(name == this->GetName() || name.empty()) - { - continue; - } - items.push_back(cmLinkItem(name, this->FindTargetToLink(name))); - } -} - -//---------------------------------------------------------------------------- const char* cmTarget::GetSuffixVariableInternal(bool implib) const { switch(this->GetType()) diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 84395e3..3e689ae 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -557,14 +557,6 @@ private: GetLinkImplementationLibrariesInternal(const std::string& config, cmTarget const* head) const; - void ExpandLinkItems(std::string const& prop, std::string const& value, - std::string const& config, cmTarget const* headTarget, - bool usage_requirements_only, - std::vector& items, - bool& hadHeadSensitiveCondition) const; - void LookupLinkItems(std::vector const& names, - std::vector& items) const; - std::string ProcessSourceItemCMP0049(const std::string& s); void ClearLinkMaps(); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ae94ca1c5902dc12ddd7eb7a9e4b197ddde5c884 commit ae94ca1c5902dc12ddd7eb7a9e4b197ddde5c884 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:22:30 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 00:59:35 2015 +0200 cmGeneratorTarget: Move GetLinkInterface from cmTarget. diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 8ba8847..b657765 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -363,8 +363,10 @@ void cmComputeLinkDepends::FollowLinkEntry(BFSEntry const& qe) if(entry.Target) { // Follow the target dependencies. - if(cmTarget::LinkInterface const* iface = - entry.Target->GetLinkInterface(this->Config, this->Target->Target)) + cmGeneratorTarget* gtgt = + this->GlobalGenerator->GetGeneratorTarget(entry.Target); + if(cmGeneratorTarget::LinkInterface const* iface = + gtgt->GetLinkInterface(this->Config, this->Target->Target)) { const bool isIface = entry.Target->GetType() == cmTarget::INTERFACE_LIBRARY; @@ -398,7 +400,8 @@ void cmComputeLinkDepends::FollowLinkEntry(BFSEntry const& qe) //---------------------------------------------------------------------------- void cmComputeLinkDepends -::FollowSharedDeps(int depender_index, cmTarget::LinkInterface const* iface, +::FollowSharedDeps(int depender_index, + cmGeneratorTarget::LinkInterface const* iface, bool follow_interface) { // Follow dependencies if we have not followed them already. @@ -461,8 +464,10 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep) // Target items may have their own dependencies. if(entry.Target) { - if(cmTarget::LinkInterface const* iface = - entry.Target->GetLinkInterface(this->Config, this->Target->Target)) + cmGeneratorTarget* gtgt = + this->GlobalGenerator->GetGeneratorTarget(entry.Target); + if(cmGeneratorTarget::LinkInterface const* iface = + gtgt->GetLinkInterface(this->Config, this->Target->Target)) { // Follow public and private dependencies transitively. this->FollowSharedDeps(index, iface, true); @@ -932,8 +937,10 @@ int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl) { if(cmTarget const* target = this->EntryList[*ni].Target) { - if(cmTarget::LinkInterface const* iface = - target->GetLinkInterface(this->Config, this->Target->Target)) + cmGeneratorTarget* gtgt = + this->GlobalGenerator->GetGeneratorTarget(target); + if(cmGeneratorTarget::LinkInterface const* iface = + gtgt->GetLinkInterface(this->Config, this->Target->Target)) { if(iface->Multiplicity > count) { diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index b925a4f..e61175a 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -13,6 +13,7 @@ #define cmComputeLinkDepends_h #include "cmStandardIncludes.h" +#include "cmGeneratorTarget.h" #include "cmTarget.h" #include "cmGraphAdjacencyList.h" @@ -22,8 +23,6 @@ class cmComputeComponentGraph; class cmGlobalGenerator; class cmMakefile; -class cmGeneratorTarget; -class cmTarget; class cmake; /** \class cmComputeLinkDepends @@ -102,7 +101,7 @@ private: std::queue SharedDepQueue; std::set SharedDepFollowed; void FollowSharedDeps(int depender_index, - cmTarget::LinkInterface const* iface, + cmGeneratorTarget::LinkInterface const* iface, bool follow_interface = false); void QueueSharedDependencies(int depender_index, std::vector const& deps); diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index c4a03a0..fd4b567 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -296,8 +296,8 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, std::set &emitted) { cmGeneratorTarget const* depender = this->Targets[depender_index]; - if(cmTarget::LinkInterface const* iface = - dependee->Target->GetLinkInterface(config, + if(cmGeneratorTarget::LinkInterface const* iface = + dependee->GetLinkInterface(config, depender->Target)) { for(std::vector::const_iterator diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index cae60b7..97eb6b9 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -796,7 +796,7 @@ cmExportFileGenerator std::vector& missingTargets) { // Add the transitive link dependencies for this configuration. - cmTarget::LinkInterface const* iface = target->Target->GetLinkInterface( + cmGeneratorTarget::LinkInterface const* iface = target->GetLinkInterface( config, target->Target); if (!iface) @@ -909,9 +909,8 @@ cmExportFileGenerator } // Add the transitive link dependencies for this configuration. - if(cmTarget::LinkInterface const* iface = - target->Target - ->GetLinkInterface(config, target->Target)) + if(cmGeneratorTarget::LinkInterface const* iface = + target->GetLinkInterface(config, target->Target)) { this->SetImportLinkProperty(suffix, target, "IMPORTED_LINK_INTERFACE_LANGUAGES", diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 49f2515..c097bfb 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1108,8 +1108,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode if(isInterfaceProperty) { - if(cmTarget::LinkInterfaceLibraries const* iface = - target->GetLinkInterfaceLibraries(context->Config, headTarget, true)) + if(cmGeneratorTarget::LinkInterfaceLibraries const* iface = + gtgt->GetLinkInterfaceLibraries(context->Config, headTarget, true)) { linkedTargetsContent = getLinkedTargetsContent(iface->Libraries, target, diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index aed2c07..27d6a99 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1144,8 +1144,11 @@ public: return; } - cmTarget::LinkInterface const* iface = - item.Target->GetLinkInterface(this->Config, this->HeadTarget); + cmGeneratorTarget* gtgt = + this->Target->GetLocalGenerator()->GetGlobalGenerator() + ->GetGeneratorTarget(item.Target); + cmGeneratorTarget::LinkInterface const* iface = + gtgt->GetLinkInterface(this->Config, this->HeadTarget); if(!iface) { return; } for(std::vector::const_iterator @@ -1475,20 +1478,24 @@ void cmGeneratorTarget::GetAutoUicOptions(std::vector &result, void processILibs(const std::string& config, cmTarget const* headTarget, cmLinkItem const& item, + cmGeneratorTarget* itemGT, std::vector& tgts, std::set& emitted) { if (item.Target && emitted.insert(item.Target).second) { tgts.push_back(item.Target); - if(cmTarget::LinkInterfaceLibraries const* iface = - item.Target->GetLinkInterfaceLibraries(config, headTarget, true)) + if(cmGeneratorTarget::LinkInterfaceLibraries const* iface = + itemGT->GetLinkInterfaceLibraries(config, headTarget, true)) { for(std::vector::const_iterator it = iface->Libraries.begin(); it != iface->Libraries.end(); ++it) { - processILibs(config, headTarget, *it, tgts, emitted); + cmGeneratorTarget* gtgt = + itemGT->GetLocalGenerator()->GetGlobalGenerator() + ->GetGeneratorTarget(it->Target); + processILibs(config, headTarget, *it, gtgt, tgts, emitted); } } } @@ -1513,7 +1520,10 @@ cmGeneratorTarget::GetLinkImplementationClosure( it = impl->Libraries.begin(); it != impl->Libraries.end(); ++it) { - processILibs(config, this->Target, *it, tgts , emitted); + cmGeneratorTarget* gtgt = + this->GetLocalGenerator()->GetGlobalGenerator() + ->GetGeneratorTarget(it->Target); + processILibs(config, this->Target, *it, gtgt, tgts, emitted); } } return tgts; @@ -3322,3 +3332,389 @@ cmGeneratorTarget::ReportPropertyOrigin(const std::string &p, this->Makefile->GetCMakeInstance()->IssueMessage(cmake::LOG, areport); } + +//---------------------------------------------------------------------------- +cmGeneratorTarget::LinkInterface const* cmGeneratorTarget::GetLinkInterface( + const std::string& config, + cmTarget const* head) const +{ + // Imported targets have their own link interface. + if(this->Target->IsImported()) + { + return this->GetImportLinkInterface(config, head, false); + } + + // Link interfaces are not supported for executables that do not + // export symbols. + if(this->GetType() == cmTarget::EXECUTABLE && + !this->Target->IsExecutableWithExports()) + { + return 0; + } + + // Lookup any existing link interface for this configuration. + std::string CONFIG = cmSystemTools::UpperCase(config); + HeadToLinkInterfaceMap& hm = this->LinkInterfaceMap[CONFIG]; + + // If the link interface does not depend on the head target + // then return the one we computed first. + if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) + { + return &hm.begin()->second; + } + + OptionalLinkInterface& iface = hm[head]; + if(!iface.LibrariesDone) + { + iface.LibrariesDone = true; + this->ComputeLinkInterfaceLibraries( + this->Target, config, iface, head, false); + } + if(!iface.AllDone) + { + iface.AllDone = true; + if(iface.Exists) + { + this->ComputeLinkInterface(this->Target, config, iface, head); + } + } + + return iface.Exists? &iface : 0; +} + +//---------------------------------------------------------------------------- +cmGeneratorTarget::LinkInterfaceLibraries const* +cmGeneratorTarget::GetLinkInterfaceLibraries(const std::string& config, + cmTarget const* head, + bool usage_requirements_only) const +{ + // Imported targets have their own link interface. + if(this->Target->IsImported()) + { + return this->GetImportLinkInterface(config, head, usage_requirements_only); + } + + // Link interfaces are not supported for executables that do not + // export symbols. + if(this->GetType() == cmTarget::EXECUTABLE && + !this->Target->IsExecutableWithExports()) + { + return 0; + } + + // Lookup any existing link interface for this configuration. + std::string CONFIG = cmSystemTools::UpperCase(config); + HeadToLinkInterfaceMap& hm = + (usage_requirements_only ? + this->LinkInterfaceUsageRequirementsOnlyMap[CONFIG] : + this->LinkInterfaceMap[CONFIG]); + + // If the link interface does not depend on the head target + // then return the one we computed first. + if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) + { + return &hm.begin()->second; + } + + OptionalLinkInterface& iface = hm[head]; + if(!iface.LibrariesDone) + { + iface.LibrariesDone = true; + this->ComputeLinkInterfaceLibraries( + this->Target, config, iface, head, usage_requirements_only); + } + + return iface.Exists? &iface : 0; +} + +//---------------------------------------------------------------------------- +cmGeneratorTarget::LinkInterface const* +cmGeneratorTarget::GetImportLinkInterface(const std::string& config, + cmTarget const* headTarget, + bool usage_requirements_only) const +{ + cmTarget::ImportInfo const* info = this->Target->GetImportInfo(config); + if(!info) + { + return 0; + } + + std::string CONFIG = cmSystemTools::UpperCase(config); + HeadToLinkInterfaceMap& hm = + (usage_requirements_only ? + this->LinkInterfaceUsageRequirementsOnlyMap[CONFIG] : + this->LinkInterfaceMap[CONFIG]); + + // If the link interface does not depend on the head target + // then return the one we computed first. + if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) + { + return &hm.begin()->second; + } + + OptionalLinkInterface& iface = hm[headTarget]; + if(!iface.AllDone) + { + iface.AllDone = true; + iface.Multiplicity = info->Multiplicity; + cmSystemTools::ExpandListArgument(info->Languages, iface.Languages); + this->Target->ExpandLinkItems(info->LibrariesProp, info->Libraries, config, + headTarget, usage_requirements_only, + iface.Libraries, + iface.HadHeadSensitiveCondition); + std::vector deps; + cmSystemTools::ExpandListArgument(info->SharedDeps, deps); + this->Target->LookupLinkItems(deps, iface.SharedDeps); + } + + return &iface; +} + +//---------------------------------------------------------------------------- +void +cmGeneratorTarget::ComputeLinkInterfaceLibraries( + cmTarget const* thisTarget, + const std::string& config, + OptionalLinkInterface& iface, + cmTarget const* headTarget, + bool usage_requirements_only) const +{ + // Construct the property name suffix for this configuration. + std::string suffix = "_"; + if(!config.empty()) + { + suffix += cmSystemTools::UpperCase(config); + } + else + { + suffix += "NOCONFIG"; + } + + // An explicit list of interface libraries may be set for shared + // libraries and executables that export symbols. + const char* explicitLibraries = 0; + std::string linkIfaceProp; + if(thisTarget->GetPolicyStatusCMP0022() != cmPolicies::OLD && + thisTarget->GetPolicyStatusCMP0022() != cmPolicies::WARN) + { + // CMP0022 NEW behavior is to use INTERFACE_LINK_LIBRARIES. + linkIfaceProp = "INTERFACE_LINK_LIBRARIES"; + explicitLibraries = thisTarget->GetProperty(linkIfaceProp); + } + else if(thisTarget->GetType() == cmTarget::SHARED_LIBRARY || + thisTarget->IsExecutableWithExports()) + { + // CMP0022 OLD behavior is to use LINK_INTERFACE_LIBRARIES if set on a + // shared lib or executable. + + // Lookup the per-configuration property. + linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; + linkIfaceProp += suffix; + explicitLibraries = thisTarget->GetProperty(linkIfaceProp); + + // If not set, try the generic property. + if(!explicitLibraries) + { + linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; + explicitLibraries = thisTarget->GetProperty(linkIfaceProp); + } + } + + if(explicitLibraries && + thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN && + !this->PolicyWarnedCMP0022) + { + // Compare the explicitly set old link interface properties to the + // preferred new link interface property one and warn if different. + const char* newExplicitLibraries = + thisTarget->GetProperty("INTERFACE_LINK_LIBRARIES"); + if (newExplicitLibraries + && strcmp(newExplicitLibraries, explicitLibraries) != 0) + { + std::ostringstream w; + w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n" + "Target \"" << thisTarget->GetName() << "\" has an " + "INTERFACE_LINK_LIBRARIES property which differs from its " << + linkIfaceProp << " properties." + "\n" + "INTERFACE_LINK_LIBRARIES:\n" + " " << newExplicitLibraries << "\n" << + linkIfaceProp << ":\n" + " " << (explicitLibraries ? explicitLibraries : "(empty)") << "\n"; + thisTarget->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + this->PolicyWarnedCMP0022 = true; + } + } + + // There is no implicit link interface for executables or modules + // so if none was explicitly set then there is no link interface. + if(!explicitLibraries && + (thisTarget->GetType() == cmTarget::EXECUTABLE || + (thisTarget->GetType() == cmTarget::MODULE_LIBRARY))) + { + return; + } + iface.Exists = true; + iface.ExplicitLibraries = explicitLibraries; + + if(explicitLibraries) + { + // The interface libraries have been explicitly set. + thisTarget->ExpandLinkItems(linkIfaceProp, explicitLibraries, config, + headTarget, usage_requirements_only, + iface.Libraries, + iface.HadHeadSensitiveCondition); + } + else if (thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN + || thisTarget->GetPolicyStatusCMP0022() == cmPolicies::OLD) + // If CMP0022 is NEW then the plain tll signature sets the + // INTERFACE_LINK_LIBRARIES, so if we get here then the project + // cleared the property explicitly and we should not fall back + // to the link implementation. + { + // The link implementation is the default link interface. + cmLinkImplementationLibraries const* impl = + thisTarget->GetLinkImplementationLibrariesInternal(config, headTarget); + iface.Libraries.insert(iface.Libraries.end(), + impl->Libraries.begin(), impl->Libraries.end()); + if(thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN && + !this->PolicyWarnedCMP0022 && !usage_requirements_only) + { + // Compare the link implementation fallback link interface to the + // preferred new link interface property and warn if different. + std::vector ifaceLibs; + static const std::string newProp = "INTERFACE_LINK_LIBRARIES"; + if(const char* newExplicitLibraries = thisTarget->GetProperty(newProp)) + { + bool hadHeadSensitiveConditionDummy = false; + thisTarget->ExpandLinkItems(newProp, newExplicitLibraries, config, + headTarget, usage_requirements_only, + ifaceLibs, hadHeadSensitiveConditionDummy); + } + if (ifaceLibs != iface.Libraries) + { + std::string oldLibraries = cmJoin(impl->Libraries, ";"); + std::string newLibraries = cmJoin(ifaceLibs, ";"); + if(oldLibraries.empty()) + { oldLibraries = "(empty)"; } + if(newLibraries.empty()) + { newLibraries = "(empty)"; } + + std::ostringstream w; + w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n" + "Target \"" << thisTarget->GetName() << "\" has an " + "INTERFACE_LINK_LIBRARIES property. " + "This should be preferred as the source of the link interface " + "for this library but because CMP0022 is not set CMake is " + "ignoring the property and using the link implementation " + "as the link interface instead." + "\n" + "INTERFACE_LINK_LIBRARIES:\n" + " " << newLibraries << "\n" + "Link implementation:\n" + " " << oldLibraries << "\n"; + thisTarget->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + this->PolicyWarnedCMP0022 = true; + } + } + } +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::ComputeLinkInterface(cmTarget const* thisTarget, + const std::string& config, + OptionalLinkInterface& iface, + cmTarget const* headTarget) const +{ + if(iface.ExplicitLibraries) + { + if(thisTarget->GetType() == cmTarget::SHARED_LIBRARY + || thisTarget->GetType() == cmTarget::STATIC_LIBRARY + || thisTarget->GetType() == cmTarget::INTERFACE_LIBRARY) + { + // Shared libraries may have runtime implementation dependencies + // on other shared libraries that are not in the interface. + UNORDERED_SET emitted; + for(std::vector::const_iterator + li = iface.Libraries.begin(); li != iface.Libraries.end(); ++li) + { + emitted.insert(*li); + } + if (thisTarget->GetType() != cmTarget::INTERFACE_LIBRARY) + { + cmTarget::LinkImplementation const* impl = + thisTarget->GetLinkImplementation(config); + for(std::vector::const_iterator + li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li) + { + if(emitted.insert(*li).second) + { + if(li->Target) + { + // This is a runtime dependency on another shared library. + if(li->Target->GetType() == cmTarget::SHARED_LIBRARY) + { + iface.SharedDeps.push_back(*li); + } + } + else + { + // TODO: Recognize shared library file names. Perhaps this + // should be moved to cmComputeLinkInformation, but that creates + // a chicken-and-egg problem since this list is needed for its + // construction. + } + } + } + } + } + } + else if (thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN + || thisTarget->GetPolicyStatusCMP0022() == cmPolicies::OLD) + { + // The link implementation is the default link interface. + cmLinkImplementationLibraries const* + impl = thisTarget->GetLinkImplementationLibrariesInternal(config, + headTarget); + iface.ImplementationIsInterface = true; + iface.WrongConfigLibraries = impl->WrongConfigLibraries; + } + + if(thisTarget->LinkLanguagePropagatesToDependents()) + { + // Targets using this archive need its language runtime libraries. + if(cmTarget::LinkImplementation const* impl = + thisTarget->GetLinkImplementation(config)) + { + iface.Languages = impl->Languages; + } + } + + if(thisTarget->GetType() == cmTarget::STATIC_LIBRARY) + { + // Construct the property name suffix for this configuration. + std::string suffix = "_"; + if(!config.empty()) + { + suffix += cmSystemTools::UpperCase(config); + } + else + { + suffix += "NOCONFIG"; + } + + // How many repetitions are needed if this library has cyclic + // dependencies? + std::string propName = "LINK_INTERFACE_MULTIPLICITY"; + propName += suffix; + if(const char* config_reps = thisTarget->GetProperty(propName)) + { + sscanf(config_reps, "%u", &iface.Multiplicity); + } + else if(const char* reps = + thisTarget->GetProperty("LINK_INTERFACE_MULTIPLICITY")) + { + sscanf(reps, "%u", &iface.Multiplicity); + } + } +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 68e7a8a..94402ed 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -13,6 +13,7 @@ #define cmGeneratorTarget_h #include "cmStandardIncludes.h" +#include "cmLinkItem.h" class cmCustomCommand; class cmGlobalGenerator; @@ -106,6 +107,48 @@ public: const char *GetLinkInterfaceDependentNumberMaxProperty(const std::string &p, const std::string& config) const; + /** The link interface specifies transitive library dependencies and + other information needed by targets that link to this target. */ + struct LinkInterfaceLibraries + { + // Libraries listed in the interface. + std::vector Libraries; + }; + + struct LinkInterface: public LinkInterfaceLibraries + { + // Languages whose runtime libraries must be linked. + std::vector Languages; + + // Shared library dependencies needed for linking on some platforms. + std::vector SharedDeps; + + // Number of repetitions of a strongly connected component of two + // or more static libraries. + int Multiplicity; + + // Libraries listed for other configurations. + // Needed only for OLD behavior of CMP0003. + std::vector WrongConfigLibraries; + + bool ImplementationIsInterface; + + LinkInterface(): Multiplicity(0), ImplementationIsInterface(false) {} + }; + + /** Get the link interface for the given configuration. Returns 0 + if the target cannot be linked. */ + LinkInterface const* GetLinkInterface(const std::string& config, + cmTarget const* headTarget) const; + + LinkInterface const* + GetImportLinkInterface(const std::string& config, cmTarget const* head, + bool usage_requirements_only) const; + + LinkInterfaceLibraries const* + GetLinkInterfaceLibraries(const std::string& config, + cmTarget const* headTarget, + bool usage_requirements_only) const; /** Get the full path to the target according to the settings in its makefile and the configuration type. */ @@ -375,6 +418,38 @@ private: }; mutable std::map LinkImplClosureMap; + // Cache link interface computation from each configuration. + struct OptionalLinkInterface: public LinkInterface + { + OptionalLinkInterface(): + LibrariesDone(false), AllDone(false), + Exists(false), HadHeadSensitiveCondition(false), + ExplicitLibraries(0) {} + bool LibrariesDone; + bool AllDone; + bool Exists; + bool HadHeadSensitiveCondition; + const char* ExplicitLibraries; + }; + void ComputeLinkInterface(cmTarget const* thisTarget, + const std::string& config, + OptionalLinkInterface& iface, + cmTarget const* head) const; + void ComputeLinkInterfaceLibraries(cmTarget const* thisTarget, + const std::string& config, + OptionalLinkInterface& iface, + cmTarget const* head, + bool usage_requirements_only) const; + + struct HeadToLinkInterfaceMap: + public std::map {}; + typedef std::map + LinkInterfaceMapType; + mutable LinkInterfaceMapType LinkInterfaceMap; + mutable LinkInterfaceMapType LinkInterfaceUsageRequirementsOnlyMap; + + mutable bool PolicyWarnedCMP0022; + public: std::vector const& GetLinkImplementationClosure(const std::string& config) const; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1d4313e..eceabd0 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -75,13 +75,11 @@ public: cmTargetInternals() : Backtrace() { - this->PolicyWarnedCMP0022 = false; this->UtilityItemsDone = false; } cmTargetInternals(cmTargetInternals const&) : Backtrace() { - this->PolicyWarnedCMP0022 = false; this->UtilityItemsDone = false; } ~cmTargetInternals(); @@ -89,36 +87,6 @@ public: // The backtrace when the target was created. cmListFileBacktrace Backtrace; - // Cache link interface computation from each configuration. - struct OptionalLinkInterface: public cmTarget::LinkInterface - { - OptionalLinkInterface(): - LibrariesDone(false), AllDone(false), - Exists(false), HadHeadSensitiveCondition(false), - ExplicitLibraries(0) {} - bool LibrariesDone; - bool AllDone; - bool Exists; - bool HadHeadSensitiveCondition; - const char* ExplicitLibraries; - }; - void ComputeLinkInterface(cmTarget const* thisTarget, - const std::string& config, - OptionalLinkInterface& iface, - cmTarget const* head) const; - void ComputeLinkInterfaceLibraries(cmTarget const* thisTarget, - const std::string& config, - OptionalLinkInterface& iface, - cmTarget const* head, - bool usage_requirements_only); - - struct HeadToLinkInterfaceMap: - public std::map {}; - typedef std::map - LinkInterfaceMapType; - LinkInterfaceMapType LinkInterfaceMap; - LinkInterfaceMapType LinkInterfaceUsageRequirementsOnlyMap; - bool PolicyWarnedCMP0022; typedef std::map OutputInfoMapType; OutputInfoMapType OutputInfoMap; @@ -497,8 +465,6 @@ void cmTarget::ClearLinkMaps() { this->LinkImplementationLanguageIsContextDependent = true; this->Internal->LinkImplMap.clear(); - this->Internal->LinkInterfaceMap.clear(); - this->Internal->LinkInterfaceUsageRequirementsOnlyMap.clear(); this->Internal->SourceFilesMap.clear(); } @@ -4091,393 +4057,6 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, } //---------------------------------------------------------------------------- -cmTarget::LinkInterface const* cmTarget::GetLinkInterface( - const std::string& config, - cmTarget const* head) const -{ - // Imported targets have their own link interface. - if(this->IsImported()) - { - return this->GetImportLinkInterface(config, head, false); - } - - // Link interfaces are not supported for executables that do not - // export symbols. - if(this->GetType() == cmTarget::EXECUTABLE && - !this->IsExecutableWithExports()) - { - return 0; - } - - // Lookup any existing link interface for this configuration. - std::string CONFIG = cmSystemTools::UpperCase(config); - cmTargetInternals::HeadToLinkInterfaceMap& hm = - this->Internal->LinkInterfaceMap[CONFIG]; - - // If the link interface does not depend on the head target - // then return the one we computed first. - if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) - { - return &hm.begin()->second; - } - - cmTargetInternals::OptionalLinkInterface& iface = hm[head]; - if(!iface.LibrariesDone) - { - iface.LibrariesDone = true; - this->Internal->ComputeLinkInterfaceLibraries( - this, config, iface, head, false); - } - if(!iface.AllDone) - { - iface.AllDone = true; - if(iface.Exists) - { - this->Internal->ComputeLinkInterface(this, config, iface, head); - } - } - - return iface.Exists? &iface : 0; -} - -//---------------------------------------------------------------------------- -cmTarget::LinkInterfaceLibraries const* -cmTarget::GetLinkInterfaceLibraries(const std::string& config, - cmTarget const* head, - bool usage_requirements_only) const -{ - // Imported targets have their own link interface. - if(this->IsImported()) - { - return this->GetImportLinkInterface(config, head, usage_requirements_only); - } - - // Link interfaces are not supported for executables that do not - // export symbols. - if(this->GetType() == cmTarget::EXECUTABLE && - !this->IsExecutableWithExports()) - { - return 0; - } - - // Lookup any existing link interface for this configuration. - std::string CONFIG = cmSystemTools::UpperCase(config); - cmTargetInternals::HeadToLinkInterfaceMap& hm = - (usage_requirements_only ? - this->Internal->LinkInterfaceUsageRequirementsOnlyMap[CONFIG] : - this->Internal->LinkInterfaceMap[CONFIG]); - - // If the link interface does not depend on the head target - // then return the one we computed first. - if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) - { - return &hm.begin()->second; - } - - cmTargetInternals::OptionalLinkInterface& iface = hm[head]; - if(!iface.LibrariesDone) - { - iface.LibrariesDone = true; - this->Internal->ComputeLinkInterfaceLibraries( - this, config, iface, head, usage_requirements_only); - } - - return iface.Exists? &iface : 0; -} - -//---------------------------------------------------------------------------- -cmTarget::LinkInterface const* -cmTarget::GetImportLinkInterface(const std::string& config, - cmTarget const* headTarget, - bool usage_requirements_only) const -{ - cmTarget::ImportInfo const* info = this->GetImportInfo(config); - if(!info) - { - return 0; - } - - std::string CONFIG = cmSystemTools::UpperCase(config); - cmTargetInternals::HeadToLinkInterfaceMap& hm = - (usage_requirements_only ? - this->Internal->LinkInterfaceUsageRequirementsOnlyMap[CONFIG] : - this->Internal->LinkInterfaceMap[CONFIG]); - - // If the link interface does not depend on the head target - // then return the one we computed first. - if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) - { - return &hm.begin()->second; - } - - cmTargetInternals::OptionalLinkInterface& iface = hm[headTarget]; - if(!iface.AllDone) - { - iface.AllDone = true; - iface.Multiplicity = info->Multiplicity; - cmSystemTools::ExpandListArgument(info->Languages, iface.Languages); - this->ExpandLinkItems(info->LibrariesProp, info->Libraries, config, - headTarget, usage_requirements_only, - iface.Libraries, - iface.HadHeadSensitiveCondition); - std::vector deps; - cmSystemTools::ExpandListArgument(info->SharedDeps, deps); - this->LookupLinkItems(deps, iface.SharedDeps); - } - - return &iface; -} - -//---------------------------------------------------------------------------- -void -cmTargetInternals::ComputeLinkInterfaceLibraries( - cmTarget const* thisTarget, - const std::string& config, - OptionalLinkInterface& iface, - cmTarget const* headTarget, - bool usage_requirements_only) -{ - // Construct the property name suffix for this configuration. - std::string suffix = "_"; - if(!config.empty()) - { - suffix += cmSystemTools::UpperCase(config); - } - else - { - suffix += "NOCONFIG"; - } - - // An explicit list of interface libraries may be set for shared - // libraries and executables that export symbols. - const char* explicitLibraries = 0; - std::string linkIfaceProp; - if(thisTarget->GetPolicyStatusCMP0022() != cmPolicies::OLD && - thisTarget->GetPolicyStatusCMP0022() != cmPolicies::WARN) - { - // CMP0022 NEW behavior is to use INTERFACE_LINK_LIBRARIES. - linkIfaceProp = "INTERFACE_LINK_LIBRARIES"; - explicitLibraries = thisTarget->GetProperty(linkIfaceProp); - } - else if(thisTarget->GetType() == cmTarget::SHARED_LIBRARY || - thisTarget->IsExecutableWithExports()) - { - // CMP0022 OLD behavior is to use LINK_INTERFACE_LIBRARIES if set on a - // shared lib or executable. - - // Lookup the per-configuration property. - linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; - linkIfaceProp += suffix; - explicitLibraries = thisTarget->GetProperty(linkIfaceProp); - - // If not set, try the generic property. - if(!explicitLibraries) - { - linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; - explicitLibraries = thisTarget->GetProperty(linkIfaceProp); - } - } - - if(explicitLibraries && - thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN && - !this->PolicyWarnedCMP0022) - { - // Compare the explicitly set old link interface properties to the - // preferred new link interface property one and warn if different. - const char* newExplicitLibraries = - thisTarget->GetProperty("INTERFACE_LINK_LIBRARIES"); - if (newExplicitLibraries - && strcmp(newExplicitLibraries, explicitLibraries) != 0) - { - std::ostringstream w; - w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n" - "Target \"" << thisTarget->GetName() << "\" has an " - "INTERFACE_LINK_LIBRARIES property which differs from its " << - linkIfaceProp << " properties." - "\n" - "INTERFACE_LINK_LIBRARIES:\n" - " " << newExplicitLibraries << "\n" << - linkIfaceProp << ":\n" - " " << (explicitLibraries ? explicitLibraries : "(empty)") << "\n"; - thisTarget->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); - this->PolicyWarnedCMP0022 = true; - } - } - - // There is no implicit link interface for executables or modules - // so if none was explicitly set then there is no link interface. - if(!explicitLibraries && - (thisTarget->GetType() == cmTarget::EXECUTABLE || - (thisTarget->GetType() == cmTarget::MODULE_LIBRARY))) - { - return; - } - iface.Exists = true; - iface.ExplicitLibraries = explicitLibraries; - - if(explicitLibraries) - { - // The interface libraries have been explicitly set. - thisTarget->ExpandLinkItems(linkIfaceProp, explicitLibraries, config, - headTarget, usage_requirements_only, - iface.Libraries, - iface.HadHeadSensitiveCondition); - } - else if (thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN - || thisTarget->GetPolicyStatusCMP0022() == cmPolicies::OLD) - // If CMP0022 is NEW then the plain tll signature sets the - // INTERFACE_LINK_LIBRARIES, so if we get here then the project - // cleared the property explicitly and we should not fall back - // to the link implementation. - { - // The link implementation is the default link interface. - cmLinkImplementationLibraries const* impl = - thisTarget->GetLinkImplementationLibrariesInternal(config, headTarget); - iface.Libraries.insert(iface.Libraries.end(), - impl->Libraries.begin(), impl->Libraries.end()); - if(thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN && - !this->PolicyWarnedCMP0022 && !usage_requirements_only) - { - // Compare the link implementation fallback link interface to the - // preferred new link interface property and warn if different. - std::vector ifaceLibs; - static const std::string newProp = "INTERFACE_LINK_LIBRARIES"; - if(const char* newExplicitLibraries = thisTarget->GetProperty(newProp)) - { - bool hadHeadSensitiveConditionDummy = false; - thisTarget->ExpandLinkItems(newProp, newExplicitLibraries, config, - headTarget, usage_requirements_only, - ifaceLibs, hadHeadSensitiveConditionDummy); - } - if (ifaceLibs != iface.Libraries) - { - std::string oldLibraries = cmJoin(impl->Libraries, ";"); - std::string newLibraries = cmJoin(ifaceLibs, ";"); - if(oldLibraries.empty()) - { oldLibraries = "(empty)"; } - if(newLibraries.empty()) - { newLibraries = "(empty)"; } - - std::ostringstream w; - w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n" - "Target \"" << thisTarget->GetName() << "\" has an " - "INTERFACE_LINK_LIBRARIES property. " - "This should be preferred as the source of the link interface " - "for this library but because CMP0022 is not set CMake is " - "ignoring the property and using the link implementation " - "as the link interface instead." - "\n" - "INTERFACE_LINK_LIBRARIES:\n" - " " << newLibraries << "\n" - "Link implementation:\n" - " " << oldLibraries << "\n"; - thisTarget->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); - this->PolicyWarnedCMP0022 = true; - } - } - } -} - -//---------------------------------------------------------------------------- -void cmTargetInternals::ComputeLinkInterface(cmTarget const* thisTarget, - const std::string& config, - OptionalLinkInterface& iface, - cmTarget const* headTarget) const -{ - if(iface.ExplicitLibraries) - { - if(thisTarget->GetType() == cmTarget::SHARED_LIBRARY - || thisTarget->GetType() == cmTarget::STATIC_LIBRARY - || thisTarget->GetType() == cmTarget::INTERFACE_LIBRARY) - { - // Shared libraries may have runtime implementation dependencies - // on other shared libraries that are not in the interface. - UNORDERED_SET emitted; - for(std::vector::const_iterator - li = iface.Libraries.begin(); li != iface.Libraries.end(); ++li) - { - emitted.insert(*li); - } - if (thisTarget->GetType() != cmTarget::INTERFACE_LIBRARY) - { - cmTarget::LinkImplementation const* impl = - thisTarget->GetLinkImplementation(config); - for(std::vector::const_iterator - li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li) - { - if(emitted.insert(*li).second) - { - if(li->Target) - { - // This is a runtime dependency on another shared library. - if(li->Target->GetType() == cmTarget::SHARED_LIBRARY) - { - iface.SharedDeps.push_back(*li); - } - } - else - { - // TODO: Recognize shared library file names. Perhaps this - // should be moved to cmComputeLinkInformation, but that creates - // a chicken-and-egg problem since this list is needed for its - // construction. - } - } - } - } - } - } - else if (thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN - || thisTarget->GetPolicyStatusCMP0022() == cmPolicies::OLD) - { - // The link implementation is the default link interface. - cmLinkImplementationLibraries const* - impl = thisTarget->GetLinkImplementationLibrariesInternal(config, - headTarget); - iface.ImplementationIsInterface = true; - iface.WrongConfigLibraries = impl->WrongConfigLibraries; - } - - if(thisTarget->LinkLanguagePropagatesToDependents()) - { - // Targets using this archive need its language runtime libraries. - if(cmTarget::LinkImplementation const* impl = - thisTarget->GetLinkImplementation(config)) - { - iface.Languages = impl->Languages; - } - } - - if(thisTarget->GetType() == cmTarget::STATIC_LIBRARY) - { - // Construct the property name suffix for this configuration. - std::string suffix = "_"; - if(!config.empty()) - { - suffix += cmSystemTools::UpperCase(config); - } - else - { - suffix += "NOCONFIG"; - } - - // How many repetitions are needed if this library has cyclic - // dependencies? - std::string propName = "LINK_INTERFACE_MULTIPLICITY"; - propName += suffix; - if(const char* config_reps = thisTarget->GetProperty(propName)) - { - sscanf(config_reps, "%u", &iface.Multiplicity); - } - else if(const char* reps = - thisTarget->GetProperty("LINK_INTERFACE_MULTIPLICITY")) - { - sscanf(reps, "%u", &iface.Multiplicity); - } - } -} - -//---------------------------------------------------------------------------- void cmTargetInternals::AddInterfaceEntries( cmTarget const* thisTarget, std::string const& config, std::string const& prop, std::vector& entries) diff --git a/Source/cmTarget.h b/Source/cmTarget.h index c5918ba..84395e3 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -231,43 +231,6 @@ public: void GetObjectLibrariesCMP0026(std::vector& objlibs) const; - /** The link interface specifies transitive library dependencies and - other information needed by targets that link to this target. */ - struct LinkInterfaceLibraries - { - // Libraries listed in the interface. - std::vector Libraries; - }; - struct LinkInterface: public LinkInterfaceLibraries - { - // Languages whose runtime libraries must be linked. - std::vector Languages; - - // Shared library dependencies needed for linking on some platforms. - std::vector SharedDeps; - - // Number of repetitions of a strongly connected component of two - // or more static libraries. - int Multiplicity; - - // Libraries listed for other configurations. - // Needed only for OLD behavior of CMP0003. - std::vector WrongConfigLibraries; - - bool ImplementationIsInterface; - - LinkInterface(): Multiplicity(0), ImplementationIsInterface(false) {} - }; - - /** Get the link interface for the given configuration. Returns 0 - if the target cannot be linked. */ - LinkInterface const* GetLinkInterface(const std::string& config, - cmTarget const* headTarget) const; - LinkInterfaceLibraries const* - GetLinkInterfaceLibraries(const std::string& config, - cmTarget const* headTarget, - bool usage_requirements_only) const; - struct LinkImplementation: public cmLinkImplementationLibraries { // Languages whose runtime libraries must be linked. @@ -590,11 +553,6 @@ private: void ComputeImportInfo(std::string const& desired_config, ImportInfo& info) const; - - LinkInterface const* - GetImportLinkInterface(const std::string& config, cmTarget const* head, - bool usage_requirements_only) const; - cmLinkImplementationLibraries const* GetLinkImplementationLibrariesInternal(const std::string& config, cmTarget const* head) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=239c6d37e28e3a979122999e8555696865fb4824 commit 239c6d37e28e3a979122999e8555696865fb4824 Author: Stephen Kelly AuthorDate: Tue Aug 4 21:00:31 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 00:55:21 2015 +0200 cmGlobalGenerator: Return null generator target for target. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 3c818ff..09c796b 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1617,6 +1617,11 @@ void cmGlobalGenerator::ClearGeneratorMembers() cmGeneratorTarget* cmGlobalGenerator::GetGeneratorTarget(cmTarget const* t) const { + if (!t) + { + return 0; + } + cmGeneratorTargetsType::const_iterator ti = this->GeneratorTargets.find(t); if(ti == this->GeneratorTargets.end()) { http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=10040601a2e13cbb0653a20c55c1c696b5cacf29 commit 10040601a2e13cbb0653a20c55c1c696b5cacf29 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:55:46 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 00:51:49 2015 +0200 cmLinkImplementationLibraries: Move to namespace scope. diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index a86c2bc..49f2515 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1120,7 +1120,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode } else if(!interfacePropertyName.empty()) { - if(cmTarget::LinkImplementationLibraries const* impl = + if(cmLinkImplementationLibraries const* impl = target->GetLinkImplementationLibraries(context->Config)) { linkedTargetsContent = diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c831704..aed2c07 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1506,7 +1506,7 @@ cmGeneratorTarget::GetLinkImplementationClosure( tgts.Done = true; std::set emitted; - cmTarget::LinkImplementationLibraries const* impl + cmLinkImplementationLibraries const* impl = this->Target->GetLinkImplementationLibraries(config); for(std::vector::const_iterator diff --git a/Source/cmLinkItem.h b/Source/cmLinkItem.h index da91ed1..a5427de 100644 --- a/Source/cmLinkItem.h +++ b/Source/cmLinkItem.h @@ -44,4 +44,16 @@ public: bool FromGenex; }; +/** The link implementation specifies the direct library + dependencies needed by the object files of the target. */ +struct cmLinkImplementationLibraries +{ + // Libraries linked directly in this configuration. + std::vector Libraries; + + // Libraries linked directly in other configurations. + // Needed only for OLD behavior of CMP0003. + std::vector WrongConfigLibraries; +}; + #endif diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1f8f07a..1d4313e 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3381,7 +3381,7 @@ bool cmTarget::HaveBuildTreeRPATH(const std::string& config) const { return false; } - if(LinkImplementationLibraries const* impl = + if(cmLinkImplementationLibraries const* impl = this->GetLinkImplementationLibraries(config)) { return !impl->Libraries.empty(); @@ -4331,7 +4331,7 @@ cmTargetInternals::ComputeLinkInterfaceLibraries( // to the link implementation. { // The link implementation is the default link interface. - cmTarget::LinkImplementationLibraries const* impl = + cmLinkImplementationLibraries const* impl = thisTarget->GetLinkImplementationLibrariesInternal(config, headTarget); iface.Libraries.insert(iface.Libraries.end(), impl->Libraries.begin(), impl->Libraries.end()); @@ -4431,7 +4431,7 @@ void cmTargetInternals::ComputeLinkInterface(cmTarget const* thisTarget, || thisTarget->GetPolicyStatusCMP0022() == cmPolicies::OLD) { // The link implementation is the default link interface. - cmTarget::LinkImplementationLibraries const* + cmLinkImplementationLibraries const* impl = thisTarget->GetLinkImplementationLibrariesInternal(config, headTarget); iface.ImplementationIsInterface = true; @@ -4482,7 +4482,7 @@ void cmTargetInternals::AddInterfaceEntries( cmTarget const* thisTarget, std::string const& config, std::string const& prop, std::vector& entries) { - if(cmTarget::LinkImplementationLibraries const* impl = + if(cmLinkImplementationLibraries const* impl = thisTarget->GetLinkImplementationLibraries(config)) { for (std::vector::const_iterator @@ -4532,14 +4532,14 @@ cmTarget::GetLinkImplementation(const std::string& config) const } //---------------------------------------------------------------------------- -cmTarget::LinkImplementationLibraries const* +cmLinkImplementationLibraries const* cmTarget::GetLinkImplementationLibraries(const std::string& config) const { return this->GetLinkImplementationLibrariesInternal(config, this); } //---------------------------------------------------------------------------- -cmTarget::LinkImplementationLibraries const* +cmLinkImplementationLibraries const* cmTarget::GetLinkImplementationLibrariesInternal(const std::string& config, cmTarget const* head) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index c4f3817..c5918ba 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -268,18 +268,7 @@ public: cmTarget const* headTarget, bool usage_requirements_only) const; - /** The link implementation specifies the direct library - dependencies needed by the object files of the target. */ - struct LinkImplementationLibraries - { - // Libraries linked directly in this configuration. - std::vector Libraries; - - // Libraries linked directly in other configurations. - // Needed only for OLD behavior of CMP0003. - std::vector WrongConfigLibraries; - }; - struct LinkImplementation: public LinkImplementationLibraries + struct LinkImplementation: public cmLinkImplementationLibraries { // Languages whose runtime libraries must be linked. std::vector Languages; @@ -287,7 +276,7 @@ public: LinkImplementation const* GetLinkImplementation(const std::string& config) const; - LinkImplementationLibraries const* + cmLinkImplementationLibraries const* GetLinkImplementationLibraries(const std::string& config) const; cmTarget const* FindTargetToLink(std::string const& name) const; @@ -606,7 +595,7 @@ private: GetImportLinkInterface(const std::string& config, cmTarget const* head, bool usage_requirements_only) const; - LinkImplementationLibraries const* + cmLinkImplementationLibraries const* GetLinkImplementationLibrariesInternal(const std::string& config, cmTarget const* head) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d9da6ee29fe0267ed347860f24f21be647ac81e8 commit d9da6ee29fe0267ed347860f24f21be647ac81e8 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:49:49 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 00:51:45 2015 +0200 cmLinkItem: Split to separate file. diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 92fee8a..428b364 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -288,6 +288,7 @@ set(SRCS cmInstallDirectoryGenerator.h cmInstallDirectoryGenerator.cxx cmLinkedTree.h + cmLinkItem.h cmListFileCache.cxx cmListFileCache.h cmListFileLexer.c diff --git a/Source/cmLinkItem.h b/Source/cmLinkItem.h new file mode 100644 index 0000000..da91ed1 --- /dev/null +++ b/Source/cmLinkItem.h @@ -0,0 +1,47 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2015 Kitware, Inc. + + 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 cmLinkItem_h +#define cmLinkItem_h + +#include "cmListFileCache.h" + +class cmTarget; + +// Basic information about each link item. +class cmLinkItem: public std::string +{ + typedef std::string std_string; +public: + cmLinkItem(): std_string(), Target(0) {} + cmLinkItem(const std_string& n, + cmTarget const* t): std_string(n), Target(t) {} + cmLinkItem(cmLinkItem const& r): std_string(r), Target(r.Target) {} + cmTarget const* Target; +}; + +class cmLinkImplItem: public cmLinkItem +{ +public: + cmLinkImplItem(): cmLinkItem(), Backtrace(), FromGenex(false) {} + cmLinkImplItem(std::string const& n, + cmTarget const* t, + cmListFileBacktrace const& bt, + bool fromGenex): + cmLinkItem(n, t), Backtrace(bt), FromGenex(fromGenex) {} + cmLinkImplItem(cmLinkImplItem const& r): + cmLinkItem(r), Backtrace(r.Backtrace), FromGenex(r.FromGenex) {} + cmListFileBacktrace Backtrace; + bool FromGenex; +}; + +#endif diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e3fbdfd..c4f3817 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -16,6 +16,7 @@ #include "cmPropertyMap.h" #include "cmPolicies.h" #include "cmListFileCache.h" +#include "cmLinkItem.h" #include #if defined(CMAKE_BUILD_WITH_CMAKE) @@ -52,32 +53,6 @@ class cmTarget; class cmGeneratorTarget; class cmTargetTraceDependencies; -// Basic information about each link item. -class cmLinkItem: public std::string -{ - typedef std::string std_string; -public: - cmLinkItem(): std_string(), Target(0) {} - cmLinkItem(const std_string& n, - cmTarget const* t): std_string(n), Target(t) {} - cmLinkItem(cmLinkItem const& r): std_string(r), Target(r.Target) {} - cmTarget const* Target; -}; -class cmLinkImplItem: public cmLinkItem -{ -public: - cmLinkImplItem(): cmLinkItem(), Backtrace(), FromGenex(false) {} - cmLinkImplItem(std::string const& n, - cmTarget const* t, - cmListFileBacktrace const& bt, - bool fromGenex): - cmLinkItem(n, t), Backtrace(bt), FromGenex(fromGenex) {} - cmLinkImplItem(cmLinkImplItem const& r): - cmLinkItem(r), Backtrace(r.Backtrace), FromGenex(r.FromGenex) {} - cmListFileBacktrace Backtrace; - bool FromGenex; -}; - class cmTargetInternals; class cmTargetInternalPointer { http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=27252b2414f5034b16a447273e1f249fdf317b72 commit 27252b2414f5034b16a447273e1f249fdf317b72 Author: Stephen Kelly AuthorDate: Sun Aug 2 19:35:48 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 00:51:40 2015 +0200 cmComputeLinkInformation: Simplify generator object access. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index c3f36af..c16472e 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -14,6 +14,7 @@ #include "cmComputeLinkDepends.h" #include "cmOrderDirectories.h" +#include "cmLocalGenerator.h" #include "cmGlobalGenerator.h" #include "cmState.h" #include "cmOutputConverter.h" @@ -248,7 +249,8 @@ cmComputeLinkInformation // Store context information. this->Target = target; this->Makefile = this->Target->Target->GetMakefile(); - this->GlobalGenerator = this->Makefile->GetGlobalGenerator(); + this->GlobalGenerator = + this->Target->GetLocalGenerator()->GetGlobalGenerator(); this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance(); // Check whether to recognize OpenBSD-style library versioned names. @@ -540,9 +542,7 @@ bool cmComputeLinkInformation::Compute() i != wrongItems.end(); ++i) { cmTarget const* tgt = *i; - cmGeneratorTarget *gtgt = tgt->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(tgt); + cmGeneratorTarget *gtgt = this->GlobalGenerator->GetGeneratorTarget(tgt); bool implib = (this->UseImportLibrary && (tgt->GetType() == cmTarget::SHARED_LIBRARY)); @@ -646,9 +646,7 @@ void cmComputeLinkInformation::AddItem(std::string const& item, if(tgt && tgt->IsLinkable()) { - cmGeneratorTarget *gtgt = tgt->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(tgt); + cmGeneratorTarget *gtgt = this->GlobalGenerator->GetGeneratorTarget(tgt); // This is a CMake target. Ask the target for its real name. if(impexe && this->LoaderFlag) { @@ -762,7 +760,7 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, return; } - cmGeneratorTarget *gtgt = 0; + cmGeneratorTarget *gtgt = this->GlobalGenerator->GetGeneratorTarget(tgt); // Get a full path to the dependent shared library. // Add it to the runtime path computation so that the target being @@ -1812,9 +1810,7 @@ cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath, // Try to get the soname of the library. Only files with this name // could possibly conflict. - cmGeneratorTarget *gtgt = target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(target); + cmGeneratorTarget *gtgt = this->GlobalGenerator->GetGeneratorTarget(target); std::string soName = gtgt->GetSOName(this->Config); const char* soname = soName.empty()? 0 : soName.c_str(); ----------------------------------------------------------------------- Summary of changes: Source/CMakeLists.txt | 1 + Source/cmComputeLinkDepends.cxx | 21 +- Source/cmComputeLinkDepends.h | 5 +- Source/cmComputeLinkInformation.cxx | 18 +- Source/cmComputeTargetDepends.cxx | 4 +- Source/cmExportFileGenerator.cxx | 7 +- Source/cmGeneratorExpressionNode.cxx | 6 +- Source/cmGeneratorTarget.cxx | 453 ++++++++++++++++- Source/cmGeneratorTarget.h | 81 +++ Source/cmGlobalGenerator.cxx | 6 + Source/cmGlobalVisualStudio8Generator.cxx | 1 + Source/cmGlobalVisualStudioGenerator.cxx | 1 + Source/cmGlobalXCodeGenerator.cxx | 2 + Source/cmLinkItem.h | 59 +++ Source/cmQtAutoGenerators.cxx | 13 +- Source/cmTarget.cxx | 778 ++++++----------------------- Source/cmTarget.h | 96 +--- 17 files changed, 802 insertions(+), 750 deletions(-) create mode 100644 Source/cmLinkItem.h hooks/post-receive -- CMake From steveire at gmail.com Thu Aug 6 22:08:07 2015 From: steveire at gmail.com (Stephen Kelly) Date: Thu, 6 Aug 2015 22:08:07 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2058-g7d31d99 Message-ID: <20150807020808.37173B14A3@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 7d31d99d990b2c64d65a6b82a5f8308024ebb057 (commit) via c392759a43873a46522fe104db3281d7da3cc24f (commit) from da69b3979d6e90bff5ce72b49f9c3b8e8496b648 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7d31d99d990b2c64d65a6b82a5f8308024ebb057 commit 7d31d99d990b2c64d65a6b82a5f8308024ebb057 Merge: da69b39 c392759 Author: Stephen Kelly AuthorDate: Thu Aug 6 22:08:05 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 6 22:08:05 2015 -0400 Merge topic 'use-generator-target' into next c392759a fixup! cmTarget: Split storage of include directories from genexes. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c392759a43873a46522fe104db3281d7da3cc24f commit c392759a43873a46522fe104db3281d7da3cc24f Author: Stephen Kelly AuthorDate: Fri Aug 7 04:07:44 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 04:07:44 2015 +0200 fixup! cmTarget: Split storage of include directories from genexes. diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index aae0b23..39933cb 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -463,7 +463,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, cmTarget* allbuild = mf->AddUtilityCommand("ALL_BUILD", true, no_depends, no_working_directory, "echo", "Build all projects"); - allBuild->Compute(); + allbuild->Compute(); cmGeneratorTarget* allBuildGt = new cmGeneratorTarget(allbuild, root); mf->AddGeneratorTarget(allbuild, allBuildGt); ----------------------------------------------------------------------- Summary of changes: Source/cmGlobalXCodeGenerator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From steveire at gmail.com Thu Aug 6 22:08:30 2015 From: steveire at gmail.com (Stephen Kelly) Date: Thu, 6 Aug 2015 22:08:30 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2065-g4237e9d Message-ID: <20150807020831.002B1B14AB@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 4237e9d3fde9f6fce5cb7fe8c85c21686d8708a5 (commit) via 047b83c77099879ad16da674930fce5d5df9ac4d (commit) via 8b501eeb2bba213580ca900f7ad6251e1c8b79e5 (commit) via ce14c83b5a4115531a6fce4f7523458371a562b3 (commit) via 1faf5abf53a36491e7c374f80b635278691f76e2 (commit) via 345897936dd1bdfb43fba555bffad7d8159c1eec (commit) via 3eeeec4015d83fc87f48042c3125c4ac76689537 (commit) from 7d31d99d990b2c64d65a6b82a5f8308024ebb057 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4237e9d3fde9f6fce5cb7fe8c85c21686d8708a5 commit 4237e9d3fde9f6fce5cb7fe8c85c21686d8708a5 Merge: 7d31d99 047b83c Author: Stephen Kelly AuthorDate: Thu Aug 6 22:08:29 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 6 22:08:29 2015 -0400 Merge topic 'use-generator-target' into next 047b83c7 cmTarget: Use a simpler delete algorithm. 8b501eeb cmTarget: Split storage of sources from genexes. ce14c83b cmTarget: Split storage of compile definitions from genexes. 1faf5abf cmTarget: Split storage of compile features from genexes. 34589793 cmTarget: Split storage of compile options from genexes. 3eeeec40 cmTarget: Split storage of include directories from genexes. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=047b83c77099879ad16da674930fce5d5df9ac4d commit 047b83c77099879ad16da674930fce5d5df9ac4d Author: Stephen Kelly AuthorDate: Tue Aug 4 23:16:12 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 04:08:19 2015 +0200 cmTarget: Use a simpler delete algorithm. This way, the methods can be moved without requiring a local algorithm. The containers use automatic storage. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 54934c1..ef2df21 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -161,14 +161,6 @@ public: cmLinkImplItem cmTargetInternals::TargetPropertyEntry::NoLinkImplItem; //---------------------------------------------------------------------------- -static void deleteAndClear( - std::vector &entries) -{ - cmDeleteAll(entries); - entries.clear(); -} - -//---------------------------------------------------------------------------- cmTargetInternals::~cmTargetInternals() { } @@ -783,7 +775,7 @@ void cmTarget::GetSourceFiles(std::vector &files, this->LinkImplementationLanguageIsContextDependent = false; } - deleteAndClear(linkInterfaceSourcesEntries); + cmDeleteAll(linkInterfaceSourcesEntries); } //---------------------------------------------------------------------------- @@ -2138,7 +2130,7 @@ cmTarget::GetIncludeDirectories(const std::string& config, debugIncludes, language); - deleteAndClear(linkInterfaceIncludeDirectoriesEntries); + cmDeleteAll(linkInterfaceIncludeDirectoriesEntries); return includes; } @@ -2259,7 +2251,7 @@ void cmTarget::GetCompileOptions(std::vector &result, debugOptions, language); - deleteAndClear(linkInterfaceCompileOptionsEntries); + cmDeleteAll(linkInterfaceCompileOptionsEntries); } //---------------------------------------------------------------------------- @@ -2361,7 +2353,7 @@ void cmTarget::GetCompileDefinitions(std::vector &list, debugDefines, language); - deleteAndClear(linkInterfaceCompileDefinitionsEntries); + cmDeleteAll(linkInterfaceCompileDefinitionsEntries); } //---------------------------------------------------------------------------- @@ -2428,7 +2420,7 @@ void cmTarget::GetCompileFeatures(std::vector &result, config, debugFeatures); - deleteAndClear(linkInterfaceCompileFeaturesEntries); + cmDeleteAll(linkInterfaceCompileFeaturesEntries); } //---------------------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8b501eeb2bba213580ca900f7ad6251e1c8b79e5 commit 8b501eeb2bba213580ca900f7ad6251e1c8b79e5 Author: Stephen Kelly AuthorDate: Tue Aug 4 21:46:15 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 04:08:19 2015 +0200 cmTarget: Split storage of sources from genexes. diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index ce806ba..b094125 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -313,7 +313,9 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg, makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", mocCppFile.c_str(), false); - target->AddSource(mocCppFile); + std::vector mocCppFiles; + mocCppFiles.push_back(mocCppFile); + target->AddTracedSources(mocCppFiles); } // create a custom target for running generators at buildtime: std::string autogenTargetName = getAutogenTargetName(target); @@ -737,12 +739,7 @@ void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target) } } - for(std::vector::const_iterator fileIt = newRccFiles.begin(); - fileIt != newRccFiles.end(); - ++fileIt) - { - const_cast(target)->AddSource(*fileIt); - } + const_cast(target)->AddTracedSources(newRccFiles); } void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index c14691c..54934c1 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -148,7 +148,9 @@ public: std::vector CompileDefinitionsEntries; std::vector CompileDefinitionsBacktraces; std::vector CompileDefinitionsItems; - std::vector SourceEntries; + std::vector SourceEntries; + std::vector SourceBacktraces; + std::vector SourceItems; std::vector LinkImplementationPropertyEntries; void AddInterfaceEntries( @@ -416,7 +418,8 @@ void cmTarget::SetMakefile(cmMakefile* mf) void CreatePropertyGeneratorExpressions( std::vector const& entries, std::vector const& backtraces, - std::vector& items) + std::vector& items, + bool evaluateForBuildsystem = false) { std::vector::const_iterator btIt = backtraces.begin(); for (std::vector::const_iterator it = entries.begin(); @@ -424,6 +427,7 @@ void CreatePropertyGeneratorExpressions( { cmGeneratorExpression ge(*btIt); cmsys::auto_ptr cge = ge.Parse(*it); + cge->SetEvaluateForBuildsystem(evaluateForBuildsystem); items.push_back(new cmTargetInternals::TargetPropertyEntry(cge)); } } @@ -449,6 +453,11 @@ void cmTarget::Compute() this->Internal->CompileDefinitionsEntries, this->Internal->CompileDefinitionsBacktraces, this->Internal->CompileDefinitionsItems); + + CreatePropertyGeneratorExpressions( + this->Internal->SourceEntries, + this->Internal->SourceBacktraces, + this->Internal->SourceItems, true); } //---------------------------------------------------------------------------- @@ -699,13 +708,11 @@ void cmTarget::GetSourceFiles(std::vector &files, // for TARGET_OBJECTS instead for backwards compatibility with OLD // behavior of CMP0024 and CMP0026 only. - typedef cmTargetInternals::TargetPropertyEntry - TargetPropertyEntry; - for(std::vector::const_iterator + for(std::vector::const_iterator i = this->Internal->SourceEntries.begin(); i != this->Internal->SourceEntries.end(); ++i) { - std::string entry = (*i)->ge->GetInput(); + std::string const& entry = *i; std::vector items; cmSystemTools::ExpandListArgument(entry, items); @@ -747,7 +754,7 @@ void cmTarget::GetSourceFiles(std::vector &files, UNORDERED_SET uniqueSrcs; bool contextDependentDirectSources = processSources(this, - this->Internal->SourceEntries, + this->Internal->SourceItems, files, uniqueSrcs, &dagChecker, @@ -884,11 +891,12 @@ void cmTarget::AddTracedSources(std::vector const& srcs) this->Internal->SourceFilesMap.clear(); this->LinkImplementationLanguageIsContextDependent = true; cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + this->Internal->SourceEntries.push_back(srcFiles); + this->Internal->SourceBacktraces.push_back(lfbt); cmGeneratorExpression ge(lfbt); cmsys::auto_ptr cge = ge.Parse(srcFiles); - cge->SetEvaluateForBuildsystem(true); - this->Internal->SourceEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->SourceItems.push_back( + new cmTargetInternals::TargetPropertyEntry(cge)); } } @@ -924,11 +932,8 @@ void cmTarget::AddSources(std::vector const& srcs) this->Internal->SourceFilesMap.clear(); this->LinkImplementationLanguageIsContextDependent = true; cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - cmsys::auto_ptr cge = ge.Parse(srcFiles); - cge->SetEvaluateForBuildsystem(true); - this->Internal->SourceEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->SourceEntries.push_back(srcFiles); + this->Internal->SourceBacktraces.push_back(lfbt); } } @@ -1032,10 +1037,10 @@ public: } - bool operator()(cmTargetInternals::TargetPropertyEntry* entry) + bool operator()(std::string const& entry) { std::vector files; - cmSystemTools::ExpandListArgument(entry->ge->GetInput(), files); + cmSystemTools::ExpandListArgument(entry, files); std::vector locations(files.size()); std::transform(files.begin(), files.end(), locations.begin(), CreateLocation(this->Needle.GetMakefile())); @@ -1057,11 +1062,8 @@ cmSourceFile* cmTarget::AddSource(const std::string& src) this->Internal->SourceFilesMap.clear(); this->LinkImplementationLanguageIsContextDependent = true; cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - cmsys::auto_ptr cge = ge.Parse(src); - cge->SetEvaluateForBuildsystem(true); - this->Internal->SourceEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->SourceEntries.push_back(src); + this->Internal->SourceBacktraces.push_back(lfbt); } if (cmGeneratorExpression::Find(src) != std::string::npos) { @@ -1736,11 +1738,11 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) } this->Internal->SourceFilesMap.clear(); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); + this->Internal->SourceEntries.clear(); - cmsys::auto_ptr cge = ge.Parse(value); - this->Internal->SourceEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->SourceBacktraces.clear(); + this->Internal->SourceEntries.push_back(value); + this->Internal->SourceBacktraces.push_back(lfbt); } else { @@ -1821,10 +1823,8 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, } this->Internal->SourceFilesMap.clear(); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - cmsys::auto_ptr cge = ge.Parse(value); - this->Internal->SourceEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->SourceEntries.push_back(value); + this->Internal->SourceBacktraces.push_back(lfbt); } else { @@ -2949,13 +2949,11 @@ const char *cmTarget::GetProperty(const std::string& prop, std::ostringstream ss; const char* sep = ""; - typedef cmTargetInternals::TargetPropertyEntry - TargetPropertyEntry; - for(std::vector::const_iterator + for(std::vector::const_iterator i = this->Internal->SourceEntries.begin(); i != this->Internal->SourceEntries.end(); ++i) { - std::string entry = (*i)->ge->GetInput(); + std::string const& entry = *i; std::vector files; cmSystemTools::ExpandListArgument(entry, files); @@ -3610,13 +3608,11 @@ cmTarget::GetObjectLibrariesCMP0026(std::vector& objlibs) const // there is no cmGeneratorTarget at configure-time, so search the SOURCES // for TARGET_OBJECTS instead for backwards compatibility with OLD // behavior of CMP0024 and CMP0026 only. - typedef cmTargetInternals::TargetPropertyEntry - TargetPropertyEntry; - for(std::vector::const_iterator + for(std::vector::const_iterator i = this->Internal->SourceEntries.begin(); i != this->Internal->SourceEntries.end(); ++i) { - std::string entry = (*i)->ge->GetInput(); + std::string const& entry = *i; std::vector files; cmSystemTools::ExpandListArgument(entry, files); @@ -4366,7 +4362,7 @@ cmTargetInternalPointer::~cmTargetInternalPointer() cmDeleteAll(this->Pointer->CompileOptionsItems); cmDeleteAll(this->Pointer->CompileFeaturesItems); cmDeleteAll(this->Pointer->CompileDefinitionsItems); - cmDeleteAll(this->Pointer->SourceEntries); + cmDeleteAll(this->Pointer->SourceItems); delete this->Pointer; } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ce14c83b5a4115531a6fce4f7523458371a562b3 commit ce14c83b5a4115531a6fce4f7523458371a562b3 Author: Stephen Kelly AuthorDate: Tue Aug 4 21:30:17 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 04:08:19 2015 +0200 cmTarget: Split storage of compile definitions from genexes. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1762d2f..c14691c 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -145,7 +145,9 @@ public: std::vector CompileFeaturesEntries; std::vector CompileFeaturesBacktraces; std::vector CompileFeaturesItems; - std::vector CompileDefinitionsEntries; + std::vector CompileDefinitionsEntries; + std::vector CompileDefinitionsBacktraces; + std::vector CompileDefinitionsItems; std::vector SourceEntries; std::vector LinkImplementationPropertyEntries; @@ -442,6 +444,11 @@ void cmTarget::Compute() this->Internal->CompileFeaturesEntries, this->Internal->CompileFeaturesBacktraces, this->Internal->CompileFeaturesItems); + + CreatePropertyGeneratorExpressions( + this->Internal->CompileDefinitionsEntries, + this->Internal->CompileDefinitionsBacktraces, + this->Internal->CompileDefinitionsItems); } //---------------------------------------------------------------------------- @@ -1694,12 +1701,11 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) } else if(prop == "COMPILE_DEFINITIONS") { + this->Internal->CompileDefinitionsEntries.clear(); + this->Internal->CompileDefinitionsBacktraces.clear(); + this->Internal->CompileDefinitionsEntries.push_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - deleteAndClear(this->Internal->CompileDefinitionsEntries); - cmsys::auto_ptr cge = ge.Parse(value); - this->Internal->CompileDefinitionsEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->CompileDefinitionsBacktraces.push_back(lfbt); } else if(prop == "EXPORT_NAME" && this->IsImported()) { @@ -1783,10 +1789,9 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, } else if(prop == "COMPILE_DEFINITIONS") { + this->Internal->CompileDefinitionsEntries.push_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - this->Internal->CompileDefinitionsEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); + this->Internal->CompileDefinitionsBacktraces.push_back(lfbt); } else if(prop == "EXPORT_NAME" && this->IsImported()) { @@ -1918,10 +1923,8 @@ void cmTarget::InsertCompileOption(std::string const& entry, void cmTarget::InsertCompileDefinition(std::string const& entry, cmListFileBacktrace const& bt) { - cmGeneratorExpression ge(bt); - - this->Internal->CompileDefinitionsEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(ge.Parse(entry))); + this->Internal->CompileDefinitionsEntries.push_back(entry); + this->Internal->CompileDefinitionsBacktraces.push_back(bt); } //---------------------------------------------------------------------------- @@ -2303,7 +2306,7 @@ void cmTarget::GetCompileDefinitions(std::vector &list, } processCompileDefinitions(this, - this->Internal->CompileDefinitionsEntries, + this->Internal->CompileDefinitionsItems, list, uniqueOptions, &dagChecker, @@ -2711,22 +2714,6 @@ bool cmTarget::HandleLocationPropertyPolicy(cmMakefile* context) const } //---------------------------------------------------------------------------- -static void MakePropertyList(std::string& output, - std::vector const& values) -{ - output = ""; - std::string sep; - for (std::vector::const_iterator - it = values.begin(), end = values.end(); - it != end; ++it) - { - output += sep; - output += (*it)->ge->GetInput(); - sep = ";"; - } -} - -//---------------------------------------------------------------------------- const char *cmTarget::GetProperty(const std::string& prop) const { return this->GetProperty(prop, this->Makefile); @@ -2934,7 +2921,7 @@ const char *cmTarget::GetProperty(const std::string& prop, } static std::string output; - MakePropertyList(output, this->Internal->CompileDefinitionsEntries); + output = cmJoin(this->Internal->CompileDefinitionsEntries, ";"); return output.c_str(); } else if (prop == propIMPORTED) @@ -4378,7 +4365,7 @@ cmTargetInternalPointer::~cmTargetInternalPointer() cmDeleteAll(this->Pointer->IncludeDirectoriesItems); cmDeleteAll(this->Pointer->CompileOptionsItems); cmDeleteAll(this->Pointer->CompileFeaturesItems); - cmDeleteAll(this->Pointer->CompileDefinitionsEntries); + cmDeleteAll(this->Pointer->CompileDefinitionsItems); cmDeleteAll(this->Pointer->SourceEntries); delete this->Pointer; } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1faf5abf53a36491e7c374f80b635278691f76e2 commit 1faf5abf53a36491e7c374f80b635278691f76e2 Author: Stephen Kelly AuthorDate: Tue Aug 4 21:23:38 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 04:08:19 2015 +0200 cmTarget: Split storage of compile features from genexes. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index ae8fea2..1762d2f 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -142,7 +142,9 @@ public: std::vector CompileOptionsEntries; std::vector CompileOptionsBacktraces; std::vector CompileOptionsItems; - std::vector CompileFeaturesEntries; + std::vector CompileFeaturesEntries; + std::vector CompileFeaturesBacktraces; + std::vector CompileFeaturesItems; std::vector CompileDefinitionsEntries; std::vector SourceEntries; std::vector LinkImplementationPropertyEntries; @@ -435,6 +437,11 @@ void cmTarget::Compute() this->Internal->CompileOptionsEntries, this->Internal->CompileOptionsBacktraces, this->Internal->CompileOptionsItems); + + CreatePropertyGeneratorExpressions( + this->Internal->CompileFeaturesEntries, + this->Internal->CompileFeaturesBacktraces, + this->Internal->CompileFeaturesItems); } //---------------------------------------------------------------------------- @@ -1679,12 +1686,11 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) } else if(prop == "COMPILE_FEATURES") { + this->Internal->CompileFeaturesEntries.clear(); + this->Internal->CompileFeaturesBacktraces.clear(); + this->Internal->CompileFeaturesEntries.push_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - deleteAndClear(this->Internal->CompileFeaturesEntries); - cmsys::auto_ptr cge = ge.Parse(value); - this->Internal->CompileFeaturesEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->CompileFeaturesBacktraces.push_back(lfbt); } else if(prop == "COMPILE_DEFINITIONS") { @@ -1771,10 +1777,9 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, } else if(prop == "COMPILE_FEATURES") { + this->Internal->CompileFeaturesEntries.push_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - this->Internal->CompileFeaturesEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); + this->Internal->CompileFeaturesBacktraces.push_back(lfbt); } else if(prop == "COMPILE_DEFINITIONS") { @@ -2399,7 +2404,7 @@ void cmTarget::GetCompileFeatures(std::vector &result, } processCompileFeatures(this, - this->Internal->CompileFeaturesEntries, + this->Internal->CompileFeaturesItems, result, uniqueFeatures, &dagChecker, @@ -2907,7 +2912,7 @@ const char *cmTarget::GetProperty(const std::string& prop, } static std::string output; - MakePropertyList(output, this->Internal->CompileFeaturesEntries); + output = cmJoin(this->Internal->CompileFeaturesEntries, ";"); return output.c_str(); } else if(prop == propCOMPILE_OPTIONS) @@ -4372,7 +4377,7 @@ cmTargetInternalPointer::~cmTargetInternalPointer() { cmDeleteAll(this->Pointer->IncludeDirectoriesItems); cmDeleteAll(this->Pointer->CompileOptionsItems); - cmDeleteAll(this->Pointer->CompileFeaturesEntries); + cmDeleteAll(this->Pointer->CompileFeaturesItems); cmDeleteAll(this->Pointer->CompileDefinitionsEntries); cmDeleteAll(this->Pointer->SourceEntries); delete this->Pointer; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=345897936dd1bdfb43fba555bffad7d8159c1eec commit 345897936dd1bdfb43fba555bffad7d8159c1eec Author: Stephen Kelly AuthorDate: Tue Aug 4 21:19:00 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 04:08:19 2015 +0200 cmTarget: Split storage of compile options from genexes. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 23553c0..ae8fea2 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -139,7 +139,9 @@ public: std::vector IncludeDirectoriesEntries; std::vector IncludeDirectoriesBacktraces; std::vector IncludeDirectoriesItems; - std::vector CompileOptionsEntries; + std::vector CompileOptionsEntries; + std::vector CompileOptionsBacktraces; + std::vector CompileOptionsItems; std::vector CompileFeaturesEntries; std::vector CompileDefinitionsEntries; std::vector SourceEntries; @@ -354,13 +356,12 @@ void cmTarget::SetMakefile(cmMakefile* mf) const cmBacktraceRange parentOptionsBts = this->Makefile->GetCompileOptionsBacktraces(); - cmBacktraceRange::const_iterator btIt = parentOptionsBts.begin(); - for (cmStringRange::const_iterator it - = parentOptions.begin(); - it != parentOptions.end(); ++it, ++btIt) - { - this->InsertCompileOption(*it, *btIt); - } + this->Internal->CompileOptionsEntries.insert( + this->Internal->CompileOptionsEntries.end(), + parentOptions.begin(), parentOptions.end()); + this->Internal->CompileOptionsBacktraces.insert( + this->Internal->CompileOptionsBacktraces.end(), + parentOptionsBts.begin(), parentOptionsBts.end()); } if (this->GetType() != INTERFACE_LIBRARY && this->GetType() != UTILITY) @@ -429,6 +430,11 @@ void cmTarget::Compute() this->Internal->IncludeDirectoriesEntries, this->Internal->IncludeDirectoriesBacktraces, this->Internal->IncludeDirectoriesItems); + + CreatePropertyGeneratorExpressions( + this->Internal->CompileOptionsEntries, + this->Internal->CompileOptionsBacktraces, + this->Internal->CompileOptionsItems); } //---------------------------------------------------------------------------- @@ -1665,12 +1671,11 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) } else if(prop == "COMPILE_OPTIONS") { + this->Internal->CompileOptionsEntries.clear(); + this->Internal->CompileOptionsBacktraces.clear(); + this->Internal->CompileOptionsEntries.push_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - deleteAndClear(this->Internal->CompileOptionsEntries); - cmsys::auto_ptr cge = ge.Parse(value); - this->Internal->CompileOptionsEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->CompileOptionsBacktraces.push_back(lfbt); } else if(prop == "COMPILE_FEATURES") { @@ -1760,10 +1765,9 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, } else if(prop == "COMPILE_OPTIONS") { + this->Internal->CompileOptionsEntries.push_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - this->Internal->CompileOptionsEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); + this->Internal->CompileOptionsBacktraces.push_back(lfbt); } else if(prop == "COMPILE_FEATURES") { @@ -1893,14 +1897,16 @@ void cmTarget::InsertCompileOption(std::string const& entry, cmListFileBacktrace const& bt, bool before) { - cmGeneratorExpression ge(bt); + std::vector::iterator position = + before ? this->Internal->CompileOptionsEntries.begin() + : this->Internal->CompileOptionsEntries.end(); - std::vector::iterator position - = before ? this->Internal->CompileOptionsEntries.begin() - : this->Internal->CompileOptionsEntries.end(); + std::vector::iterator btPosition = + before ? this->Internal->CompileOptionsBacktraces.begin() + : this->Internal->CompileOptionsBacktraces.end(); - this->Internal->CompileOptionsEntries.insert(position, - new cmTargetInternals::TargetPropertyEntry(ge.Parse(entry))); + this->Internal->CompileOptionsEntries.insert(position, entry); + this->Internal->CompileOptionsBacktraces.insert(btPosition, bt); } //---------------------------------------------------------------------------- @@ -2221,7 +2227,7 @@ void cmTarget::GetCompileOptions(std::vector &result, } processCompileOptions(this, - this->Internal->CompileOptionsEntries, + this->Internal->CompileOptionsItems, result, uniqueOptions, &dagChecker, @@ -2912,7 +2918,7 @@ const char *cmTarget::GetProperty(const std::string& prop, } static std::string output; - MakePropertyList(output, this->Internal->CompileOptionsEntries); + output = cmJoin(this->Internal->CompileOptionsEntries, ";"); return output.c_str(); } else if(prop == propCOMPILE_DEFINITIONS) @@ -4365,7 +4371,7 @@ cmTargetInternalPointer cmTargetInternalPointer::~cmTargetInternalPointer() { cmDeleteAll(this->Pointer->IncludeDirectoriesItems); - cmDeleteAll(this->Pointer->CompileOptionsEntries); + cmDeleteAll(this->Pointer->CompileOptionsItems); cmDeleteAll(this->Pointer->CompileFeaturesEntries); cmDeleteAll(this->Pointer->CompileDefinitionsEntries); cmDeleteAll(this->Pointer->SourceEntries); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3eeeec4015d83fc87f48042c3125c4ac76689537 commit 3eeeec4015d83fc87f48042c3125c4ac76689537 Author: Stephen Kelly AuthorDate: Tue Aug 4 20:25:02 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 04:08:18 2015 +0200 cmTarget: Split storage of include directories from genexes. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 09c796b..195fa0d 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1549,6 +1549,7 @@ void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes, ti != targets.end(); ++ti) { cmTarget* t = &ti->second; + t->Compute(); cmGeneratorTarget* gt = new cmGeneratorTarget(t, lg); this->GeneratorTargets[t] = gt; generatorTargets[t] = gt; diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index d5a5585..51dcab0 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -254,6 +254,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() mf->AddUtilityCommand(CMAKE_CHECK_BUILD_SYSTEM_TARGET, false, no_working_directory, no_depends, noCommandLines); + tgt->Compute(); cmGeneratorTarget* gt = new cmGeneratorTarget(tgt, lg); mf->AddGeneratorTarget(tgt, gt); diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 2f9d79a..b69fc65 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -90,6 +90,7 @@ bool cmGlobalVisualStudioGenerator::Compute() AddUtilityCommand("ALL_BUILD", true, no_working_dir, no_depends, no_commands, false, "Build all projects"); + allBuild->Compute(); cmGeneratorTarget* gt = new cmGeneratorTarget(allBuild, gen[0]); allBuild->GetMakefile()->AddGeneratorTarget(allBuild, gt); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 5006828..39933cb 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -463,6 +463,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, cmTarget* allbuild = mf->AddUtilityCommand("ALL_BUILD", true, no_depends, no_working_directory, "echo", "Build all projects"); + allbuild->Compute(); cmGeneratorTarget* allBuildGt = new cmGeneratorTarget(allbuild, root); mf->AddGeneratorTarget(allbuild, allBuildGt); @@ -497,6 +498,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, true, no_depends, no_working_directory, "make", "-f", file.c_str()); + check->Compute(); cmGeneratorTarget* checkGt = new cmGeneratorTarget(check, root); mf->AddGeneratorTarget(check, checkGt); } diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index f1ba2f4..ce806ba 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -475,6 +475,8 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg, /*byproducts=*/rcc_output, depends, commandLines, false, autogenComment.c_str()); + autogenTarget->Compute(); + cmGeneratorTarget* gt = new cmGeneratorTarget(autogenTarget, lg); makefile->AddGeneratorTarget(autogenTarget, gt); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 8830bf2..23553c0 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -136,7 +136,9 @@ public: const cmsys::auto_ptr ge; cmLinkImplItem const& LinkImplItem; }; - std::vector IncludeDirectoriesEntries; + std::vector IncludeDirectoriesEntries; + std::vector IncludeDirectoriesBacktraces; + std::vector IncludeDirectoriesItems; std::vector CompileOptionsEntries; std::vector CompileFeaturesEntries; std::vector CompileDefinitionsEntries; @@ -334,13 +336,13 @@ void cmTarget::SetMakefile(cmMakefile* mf) const cmBacktraceRange parentIncludesBts = this->Makefile->GetIncludeDirectoriesBacktraces(); - cmBacktraceRange::const_iterator btIt = parentIncludesBts.begin(); - for (cmStringRange::const_iterator it - = parentIncludes.begin(); - it != parentIncludes.end(); ++it, ++btIt) - { - this->InsertInclude(*it, *btIt); - } + this->Internal->IncludeDirectoriesEntries.insert( + this->Internal->IncludeDirectoriesEntries.end(), + parentIncludes.begin(), parentIncludes.end()); + this->Internal->IncludeDirectoriesBacktraces.insert( + this->Internal->IncludeDirectoriesBacktraces.end(), + parentIncludesBts.begin(), parentIncludesBts.end()); + const std::set parentSystemIncludes = this->Makefile->GetSystemIncludeDirectories(); @@ -352,7 +354,7 @@ void cmTarget::SetMakefile(cmMakefile* mf) const cmBacktraceRange parentOptionsBts = this->Makefile->GetCompileOptionsBacktraces(); - btIt = parentOptionsBts.begin(); + cmBacktraceRange::const_iterator btIt = parentOptionsBts.begin(); for (cmStringRange::const_iterator it = parentOptions.begin(); it != parentOptions.end(); ++it, ++btIt) @@ -406,6 +408,29 @@ void cmTarget::SetMakefile(cmMakefile* mf) } } +void CreatePropertyGeneratorExpressions( + std::vector const& entries, + std::vector const& backtraces, + std::vector& items) +{ + std::vector::const_iterator btIt = backtraces.begin(); + for (std::vector::const_iterator it = entries.begin(); + it != entries.end(); ++it, ++btIt) + { + cmGeneratorExpression ge(*btIt); + cmsys::auto_ptr cge = ge.Parse(*it); + items.push_back(new cmTargetInternals::TargetPropertyEntry(cge)); + } +} + +void cmTarget::Compute() +{ + CreatePropertyGeneratorExpressions( + this->Internal->IncludeDirectoriesEntries, + this->Internal->IncludeDirectoriesBacktraces, + this->Internal->IncludeDirectoriesItems); +} + //---------------------------------------------------------------------------- void cmTarget::AddUtility(const std::string& u, cmMakefile *makefile) { @@ -1632,12 +1657,11 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) } else if(prop == "INCLUDE_DIRECTORIES") { + this->Internal->IncludeDirectoriesEntries.clear(); + this->Internal->IncludeDirectoriesBacktraces.clear(); + this->Internal->IncludeDirectoriesEntries.push_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - deleteAndClear(this->Internal->IncludeDirectoriesEntries); - cmsys::auto_ptr cge = ge.Parse(value); - this->Internal->IncludeDirectoriesEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->IncludeDirectoriesBacktraces.push_back(lfbt); } else if(prop == "COMPILE_OPTIONS") { @@ -1730,10 +1754,9 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, } else if(prop == "INCLUDE_DIRECTORIES") { + this->Internal->IncludeDirectoriesEntries.push_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - this->Internal->IncludeDirectoriesEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); + this->Internal->IncludeDirectoriesBacktraces.push_back(lfbt); } else if(prop == "COMPILE_OPTIONS") { @@ -1853,14 +1876,16 @@ void cmTarget::InsertInclude(std::string const& entry, cmListFileBacktrace const& bt, bool before) { - cmGeneratorExpression ge(bt); + std::vector::iterator position = + before ? this->Internal->IncludeDirectoriesEntries.begin() + : this->Internal->IncludeDirectoriesEntries.end(); - std::vector::iterator position - = before ? this->Internal->IncludeDirectoriesEntries.begin() - : this->Internal->IncludeDirectoriesEntries.end(); + std::vector::iterator btPosition = + before ? this->Internal->IncludeDirectoriesBacktraces.begin() + : this->Internal->IncludeDirectoriesBacktraces.end(); - this->Internal->IncludeDirectoriesEntries.insert(position, - new cmTargetInternals::TargetPropertyEntry(ge.Parse(entry))); + this->Internal->IncludeDirectoriesEntries.insert(position, entry); + this->Internal->IncludeDirectoriesBacktraces.insert(btPosition, bt); } //---------------------------------------------------------------------------- @@ -2049,7 +2074,7 @@ cmTarget::GetIncludeDirectories(const std::string& config, } processIncludeDirectories(this, - this->Internal->IncludeDirectoriesEntries, + this->Internal->IncludeDirectoriesItems, includes, uniqueIncludes, &dagChecker, @@ -2865,7 +2890,7 @@ const char *cmTarget::GetProperty(const std::string& prop, } static std::string output; - MakePropertyList(output, this->Internal->IncludeDirectoriesEntries); + output = cmJoin(this->Internal->IncludeDirectoriesEntries, ";"); return output.c_str(); } else if(prop == propCOMPILE_FEATURES) @@ -4339,7 +4364,7 @@ cmTargetInternalPointer //---------------------------------------------------------------------------- cmTargetInternalPointer::~cmTargetInternalPointer() { - cmDeleteAll(this->Pointer->IncludeDirectoriesEntries); + cmDeleteAll(this->Pointer->IncludeDirectoriesItems); cmDeleteAll(this->Pointer->CompileOptionsEntries); cmDeleteAll(this->Pointer->CompileFeaturesEntries); cmDeleteAll(this->Pointer->CompileDefinitionsEntries); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 3e689ae..dcf6832 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -132,6 +132,8 @@ public: void AddPostBuildCommand(cmCustomCommand const &cmd) {this->PostBuildCommands.push_back(cmd);} + void Compute(); + /** * Get the list of the source files used by this target */ ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From steveire at gmail.com Thu Aug 6 22:10:41 2015 From: steveire at gmail.com (Stephen Kelly) Date: Thu, 6 Aug 2015 22:10:41 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2067-g6ec9f59 Message-ID: <20150807021041.81CCDAFAB0@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 6ec9f59bb05083853f5b25bd8af8733c1c53d650 (commit) via a987e5f5315554be4705eb4be5c0188b068235c0 (commit) from 4237e9d3fde9f6fce5cb7fe8c85c21686d8708a5 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6ec9f59bb05083853f5b25bd8af8733c1c53d650 commit 6ec9f59bb05083853f5b25bd8af8733c1c53d650 Merge: 4237e9d a987e5f Author: Stephen Kelly AuthorDate: Thu Aug 6 22:10:40 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 6 22:10:40 2015 -0400 Merge topic 'global-generator-makefiles' into next a987e5f5 Revert "cmGlobalVisualStudioGenerator: Simplify access to cmGeneratorTarget." http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a987e5f5315554be4705eb4be5c0188b068235c0 commit a987e5f5315554be4705eb4be5c0188b068235c0 Author: Stephen Kelly AuthorDate: Fri Aug 7 04:10:01 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 04:10:01 2015 +0200 Revert "cmGlobalVisualStudioGenerator: Simplify access to cmGeneratorTarget." This reverts commit 2ee3bd6f3e99be2dc1bf2b3111681838f0b8d268. diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 4ac259b..2f9d79a 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -885,7 +885,8 @@ cmGlobalVisualStudioGenerator::OrderedTargetDependSet for (TargetSet::const_iterator it = targets.begin(); it != targets.end(); ++it) { - cmGeneratorTarget* gt = this->GetGeneratorTarget(*it); + cmGeneratorTarget* gt = + (*it)->GetMakefile()->GetGlobalGenerator()->GetGeneratorTarget(*it); this->insert(gt); } } ----------------------------------------------------------------------- Summary of changes: Source/cmGlobalVisualStudioGenerator.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) hooks/post-receive -- CMake From steveire at gmail.com Thu Aug 6 22:10:52 2015 From: steveire at gmail.com (Stephen Kelly) Date: Thu, 6 Aug 2015 22:10:52 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2081-ga4634fb Message-ID: <20150807021052.CC2FEAFAB0@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via a4634fb344e70d913df2d9dbeb41ec697648f4b0 (commit) via 6d8a125e4988d5cb269b3d1e29a6114ecd0c47a4 (commit) via 5f66900e71fdc33b40c46bf8a87b35d88d280769 (commit) via c5b8841fd96727a290e148e8b5132f893f8b4d4e (commit) via 8f75ea3b5e0b43118a6ecba4dc11a583d287705c (commit) via 56f0540b5183036b46babbfc9b9ec0979e54992f (commit) via 19b546ef766acedfcc9e19541c71b6a56d7fe630 (commit) via f8be9ba9c258698ed88a7510cf2ba3335491f3da (commit) via bc1097e3d9a2d9545db849f9eef657477d83509a (commit) via 204aecdf82aa583b213464411069de4c8d7af64b (commit) via 3dd6f0a5bc0b6457c82df0b980a8f6ac87d1a6f9 (commit) via 73e4df99cb4d63f5ea8babb40656a74305d77e12 (commit) via 193699376af09bd77875d4ddfd10c3feb13ecdd2 (commit) via 32f131b0ca68bc88bbb32dbf03e76dfba24defe5 (commit) from 6ec9f59bb05083853f5b25bd8af8733c1c53d650 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a4634fb344e70d913df2d9dbeb41ec697648f4b0 commit a4634fb344e70d913df2d9dbeb41ec697648f4b0 Merge: 6ec9f59 6d8a125 Author: Stephen Kelly AuthorDate: Thu Aug 6 22:10:51 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 6 22:10:51 2015 -0400 Merge topic 'global-generator-makefiles' into next 6d8a125e cmQtAutoGenerators: Prefer a generator to access global generator. 5f66900e cmGlobalGenerator: Port Find API to cmMakefile. c5b8841f cmGlobalGenerator: Create global targets from cmMakefiles. 8f75ea3b cmGlobalGenerator: Port global target creation to cmMakefile. 56f0540b cmGlobalGenerator: Port Configure-time check to cmMakefile. 19b546ef cmGlobalGenerator: Base final target property computation on Makefiles. f8be9ba9 cmGlobalGenerator: Base progress on Makefiles, not LocalGenerators. bc1097e3 cmExportLibraryDependenciesCommand: Port to cmMakefile. 204aecdf cmGlobalGenerator: Port configure-time code to cmMakefile. 3dd6f0a5 cmake: Port configure-time code to cmMakefile. 73e4df99 cmGlobalGenerator: Store a container of cmMakefiles. 19369937 cmGeneratorTarget: Port internal type to cmGeneratorTarget. 32f131b0 cmGeneratorTarget: Prefer the local generator to access the global. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6d8a125e4988d5cb269b3d1e29a6114ecd0c47a4 commit 6d8a125e4988d5cb269b3d1e29a6114ecd0c47a4 Author: Stephen Kelly AuthorDate: Sun Aug 2 20:39:24 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 04:10:29 2015 +0200 cmQtAutoGenerators: Prefer a generator to access global generator. diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index f1ba2f4..c619cdc 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -369,7 +369,7 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg, #if defined(_WIN32) && !defined(__CYGWIN__) bool usePRE_BUILD = false; - cmGlobalGenerator* gg = makefile->GetGlobalGenerator(); + cmGlobalGenerator* gg = lg->GetGlobalGenerator(); if(gg->GetName().find("Visual Studio") != std::string::npos) { cmGlobalVisualStudioGenerator* vsgg = @@ -396,7 +396,7 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg, std::vector rcc_output; bool const isNinja = - makefile->GetGlobalGenerator()->GetName() == "Ninja"; + lg->GetGlobalGenerator()->GetName() == "Ninja"; if(isNinja #if defined(_WIN32) && !defined(__CYGWIN__) || usePRE_BUILD http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5f66900e71fdc33b40c46bf8a87b35d88d280769 commit 5f66900e71fdc33b40c46bf8a87b35d88d280769 Author: Stephen Kelly AuthorDate: Sun Aug 2 12:39:51 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 04:10:29 2015 +0200 cmGlobalGenerator: Port Find API to cmMakefile. diff --git a/Source/cmGetDirectoryPropertyCommand.cxx b/Source/cmGetDirectoryPropertyCommand.cxx index c056d95..2558876 100644 --- a/Source/cmGetDirectoryPropertyCommand.cxx +++ b/Source/cmGetDirectoryPropertyCommand.cxx @@ -51,10 +51,8 @@ bool cmGetDirectoryPropertyCommand sd = cmSystemTools::CollapseFullPath(sd); // lookup the makefile from the directory name - cmLocalGenerator *lg = - this->Makefile->GetGlobalGenerator()-> - FindLocalGenerator(sd); - if (!lg) + dir = this->Makefile->GetGlobalGenerator()->FindMakefile(sd); + if (!dir) { this->SetError ("DIRECTORY argument provided but requested directory not found. " @@ -62,7 +60,6 @@ bool cmGetDirectoryPropertyCommand "it is valid but has not been processed yet."); return false; } - dir = lg->GetMakefile(); ++i; } diff --git a/Source/cmGetPropertyCommand.cxx b/Source/cmGetPropertyCommand.cxx index 33d638b..4c42f53 100644 --- a/Source/cmGetPropertyCommand.cxx +++ b/Source/cmGetPropertyCommand.cxx @@ -262,13 +262,8 @@ bool cmGetPropertyCommand::HandleDirectoryMode() dir = cmSystemTools::CollapseFullPath(dir); // Lookup the generator. - if(cmLocalGenerator* lg = - (this->Makefile->GetGlobalGenerator()->FindLocalGenerator(dir))) - { - // Use the makefile for the directory found. - mf = lg->GetMakefile(); - } - else + mf = this->Makefile->GetGlobalGenerator()->FindMakefile(dir); + if (!mf) { // Could not find the directory. this->SetError diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 8645317..1e2d091 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2160,6 +2160,20 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap() } } +cmMakefile* +cmGlobalGenerator::FindMakefile(const std::string& start_dir) const +{ + for(std::vector::const_iterator it = + this->Makefiles.begin(); it != this->Makefiles.end(); ++it) + { + std::string sd = (*it)->GetCurrentSourceDirectory(); + if (sd == start_dir) + { + return *it; + } + } + return 0; +} ///! Find a local generator by its startdirectory cmLocalGenerator* diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 616011f..778d946 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -256,6 +256,7 @@ public: that is a framework. */ bool NameResolvesToFramework(const std::string& libname) const; + cmMakefile* FindMakefile(const std::string& start_dir) const; ///! Find a local generator by its startdirectory cmLocalGenerator* FindLocalGenerator(const std::string& start_dir) const; diff --git a/Source/cmSetPropertyCommand.cxx b/Source/cmSetPropertyCommand.cxx index 31e460f..17ad475 100644 --- a/Source/cmSetPropertyCommand.cxx +++ b/Source/cmSetPropertyCommand.cxx @@ -205,14 +205,8 @@ bool cmSetPropertyCommand::HandleDirectoryMode() // The local generators are associated with collapsed paths. dir = cmSystemTools::CollapseFullPath(dir); - // Lookup the generator. - if(cmLocalGenerator* lg = - this->Makefile->GetGlobalGenerator()->FindLocalGenerator(dir)) - { - // Use the makefile for the directory found. - mf = lg->GetMakefile(); - } - else + mf = this->Makefile->GetGlobalGenerator()->FindMakefile(dir); + if (!mf) { // Could not find the directory. this->SetError http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c5b8841fd96727a290e148e8b5132f893f8b4d4e commit c5b8841fd96727a290e148e8b5132f893f8b4d4e Author: Stephen Kelly AuthorDate: Sun Aug 2 12:57:06 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 04:10:29 2015 +0200 cmGlobalGenerator: Create global targets from cmMakefiles. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index f96cf21..8645317 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1193,9 +1193,9 @@ void cmGlobalGenerator::Configure() cmTargets globalTargets; this->CreateDefaultGlobalTargets(&globalTargets); - for (i = 0; i < this->LocalGenerators.size(); ++i) + for (i = 0; i < this->Makefiles.size(); ++i) { - cmMakefile* mf = this->LocalGenerators[i]->GetMakefile(); + cmMakefile* mf = this->Makefiles[i]; cmTargets* targets = &(mf->GetTargets()); cmTargets::iterator tit; for ( tit = globalTargets.begin(); tit != globalTargets.end(); ++ tit ) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8f75ea3b5e0b43118a6ecba4dc11a583d287705c commit 8f75ea3b5e0b43118a6ecba4dc11a583d287705c Author: Stephen Kelly AuthorDate: Sun Aug 2 12:48:08 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 04:10:29 2015 +0200 cmGlobalGenerator: Port global target creation to cmMakefile. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 98961d8..f96cf21 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2247,7 +2247,7 @@ inline std::string removeQuotes(const std::string& s) void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) { - cmMakefile* mf = this->LocalGenerators[0]->GetMakefile(); + cmMakefile* mf = this->Makefiles[0]; const char* cmakeCfgIntDir = this->GetCMakeCFGIntDir(); // CPack http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=56f0540b5183036b46babbfc9b9ec0979e54992f commit 56f0540b5183036b46babbfc9b9ec0979e54992f Author: Stephen Kelly AuthorDate: Sun Aug 2 12:45:17 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 04:10:29 2015 +0200 cmGlobalGenerator: Port Configure-time check to cmMakefile. This uses no generate-time state. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 83bfe57..98961d8 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1641,11 +1641,11 @@ void cmGlobalGenerator::CheckLocalGenerators() // std::set notFoundMap; // after it is all done do a ConfigureFinalPass cmState* state = this->GetCMakeInstance()->GetState(); - for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) + for (unsigned int i = 0; i < this->Makefiles.size(); ++i) { - this->LocalGenerators[i]->GetMakefile()->ConfigureFinalPass(); + this->Makefiles[i]->ConfigureFinalPass(); cmTargets &targets = - this->LocalGenerators[i]->GetMakefile()->GetTargets(); + this->Makefiles[i]->GetTargets(); for (cmTargets::iterator l = targets.begin(); l != targets.end(); l++) { @@ -1700,15 +1700,14 @@ void cmGlobalGenerator::CheckLocalGenerators() } std::string text = notFoundMap[varName]; text += "\n used as include directory in directory "; - text += this->LocalGenerators[i] - ->GetMakefile()->GetCurrentSourceDirectory(); + text += this->Makefiles[i]->GetCurrentSourceDirectory(); notFoundMap[varName] = text; } } } this->CMakeInstance->UpdateProgress ("Configuring", 0.9f+0.1f*(static_cast(i)+1.0f)/ - static_cast(this->LocalGenerators.size())); + static_cast(this->Makefiles.size())); } if(!notFoundMap.empty()) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=19b546ef766acedfcc9e19541c71b6a56d7fe630 commit 19b546ef766acedfcc9e19541c71b6a56d7fe630 Author: Stephen Kelly AuthorDate: Sun Aug 2 12:17:31 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 04:10:29 2015 +0200 cmGlobalGenerator: Base final target property computation on Makefiles. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 5787a9d..83bfe57 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1482,9 +1482,9 @@ void cmGlobalGenerator::CreateQtAutoGeneratorsTargets(AutogensType &autogens) void cmGlobalGenerator::FinalizeTargetCompileInfo() { // Construct per-target generator information. - for(unsigned int i=0; i < this->LocalGenerators.size(); ++i) + for(unsigned int i=0; i < this->Makefiles.size(); ++i) { - cmMakefile *mf = this->LocalGenerators[i]->GetMakefile(); + cmMakefile *mf = this->Makefiles[i]; const cmStringRange noconfig_compile_definitions = mf->GetCompileDefinitionsEntries(); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f8be9ba9c258698ed88a7510cf2ba3335491f3da commit f8be9ba9c258698ed88a7510cf2ba3335491f3da Author: Stephen Kelly AuthorDate: Sun Aug 2 12:13:41 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 04:10:28 2015 +0200 cmGlobalGenerator: Base progress on Makefiles, not LocalGenerators. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 5266b23..5787a9d 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1148,9 +1148,9 @@ void cmGlobalGenerator::Configure() // update the cache entry for the number of local generators, this is used // for progress char num[100]; - sprintf(num,"%d",static_cast(this->LocalGenerators.size())); + sprintf(num,"%d",static_cast(this->Makefiles.size())); this->GetCMakeInstance()->AddCacheEntry - ("CMAKE_NUMBER_OF_LOCAL_GENERATORS", num, + ("CMAKE_NUMBER_OF_MAKEFILES", num, "number of local generators", cmState::INTERNAL); // check for link libraries and include directories containing "NOTFOUND" @@ -1742,9 +1742,9 @@ int cmGlobalGenerator::TryCompile(const std::string& srcdir, // take the bulk of the time, so try and guess some progress // by getting closer and closer to 100 without actually getting there. if (!this->CMakeInstance->GetState()->GetInitializedCacheValue - ("CMAKE_NUMBER_OF_LOCAL_GENERATORS")) + ("CMAKE_NUMBER_OF_MAKEFILES")) { - // If CMAKE_NUMBER_OF_LOCAL_GENERATORS is not set + // If CMAKE_NUMBER_OF_MAKEFILES is not set // we are in the first time progress and we have no // idea how long it will be. So, just move 1/10th of the way // there each time, and don't go over 95% @@ -1935,22 +1935,16 @@ std::string cmGlobalGenerator::GenerateCMakeBuildCommand( void cmGlobalGenerator::AddMakefile(cmMakefile *mf) { this->Makefiles.push_back(mf); -} - -//---------------------------------------------------------------------------- -void cmGlobalGenerator::AddLocalGenerator(cmLocalGenerator *lg) -{ - this->LocalGenerators.push_back(lg); // update progress // estimate how many lg there will be const char *numGenC = this->CMakeInstance->GetState()->GetInitializedCacheValue - ("CMAKE_NUMBER_OF_LOCAL_GENERATORS"); + ("CMAKE_NUMBER_OF_MAKEFILES"); if (!numGenC) { - // If CMAKE_NUMBER_OF_LOCAL_GENERATORS is not set + // If CMAKE_NUMBER_OF_MAKEFILES is not set // we are in the first time progress and we have no // idea how long it will be. So, just move half way // there each time, and don't go over 95% @@ -1965,7 +1959,7 @@ void cmGlobalGenerator::AddLocalGenerator(cmLocalGenerator *lg) } int numGen = atoi(numGenC); - float prog = 0.9f*static_cast(this->LocalGenerators.size())/ + float prog = 0.9f*static_cast(this->Makefiles.size())/ static_cast(numGen); if (prog > 0.9f) { @@ -1974,6 +1968,12 @@ void cmGlobalGenerator::AddLocalGenerator(cmLocalGenerator *lg) this->CMakeInstance->UpdateProgress("Configuring", prog); } +//---------------------------------------------------------------------------- +void cmGlobalGenerator::AddLocalGenerator(cmLocalGenerator *lg) +{ + this->LocalGenerators.push_back(lg); +} + void cmGlobalGenerator::AddInstallComponent(const char* component) { if(component && *component) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bc1097e3d9a2d9545db849f9eef657477d83509a commit bc1097e3d9a2d9545db849f9eef657477d83509a Author: Stephen Kelly AuthorDate: Sun Aug 2 13:18:30 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 04:10:28 2015 +0200 cmExportLibraryDependenciesCommand: Port to cmMakefile. diff --git a/Source/cmExportLibraryDependenciesCommand.cxx b/Source/cmExportLibraryDependenciesCommand.cxx index cb150a7..fde8fb1 100644 --- a/Source/cmExportLibraryDependenciesCommand.cxx +++ b/Source/cmExportLibraryDependenciesCommand.cxx @@ -11,7 +11,6 @@ ============================================================================*/ #include "cmExportLibraryDependenciesCommand.h" #include "cmGlobalGenerator.h" -#include "cmLocalGenerator.h" #include "cmGeneratedFileStream.h" #include "cmake.h" #include "cmVersion.h" @@ -82,15 +81,14 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const // the project. cmake* cm = this->Makefile->GetCMakeInstance(); cmGlobalGenerator* global = cm->GetGlobalGenerator(); - const std::vector& locals = global->GetLocalGenerators(); + const std::vector& locals = global->GetMakefiles(); std::map libDepsOld; std::map libDepsNew; std::map libTypes; - for(std::vector::const_iterator i = locals.begin(); + for(std::vector::const_iterator i = locals.begin(); i != locals.end(); ++i) { - const cmLocalGenerator* gen = *i; - const cmTargets &tgts = gen->GetMakefile()->GetTargets(); + const cmTargets &tgts = (*i)->GetTargets(); for(cmTargets::const_iterator l = tgts.begin(); l != tgts.end(); ++l) { http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=204aecdf82aa583b213464411069de4c8d7af64b commit 204aecdf82aa583b213464411069de4c8d7af64b Author: Stephen Kelly AuthorDate: Sun Aug 2 20:26:32 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 04:10:28 2015 +0200 cmGlobalGenerator: Port configure-time code to cmMakefile. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 749ab6e..5266b23 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2821,9 +2821,9 @@ cmGlobalGenerator::AddRuleHash(const std::vector& outputs, } // Shorten the output name (in expected use case). - cmLocalGenerator* lg = this->GetLocalGenerators()[0]; - std::string fname = lg->Convert(outputs[0], - cmLocalGenerator::HOME_OUTPUT); + cmOutputConverter converter(this->GetMakefiles()[0]->GetStateSnapshot()); + std::string fname = converter.Convert( + outputs[0], cmLocalGenerator::HOME_OUTPUT); // Associate the hash with this output. this->RuleHashes[fname] = hash; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3dd6f0a5bc0b6457c82df0b980a8f6ac87d1a6f9 commit 3dd6f0a5bc0b6457c82df0b980a8f6ac87d1a6f9 Author: Stephen Kelly AuthorDate: Sun Aug 2 13:15:47 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 04:10:28 2015 +0200 cmake: Port configure-time code to cmMakefile. diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 8c455b2..d1e6265 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1592,7 +1592,7 @@ int cmake::ActualConfigure() } } - cmMakefile* mf=this->GlobalGenerator->GetLocalGenerators()[0]->GetMakefile(); + cmMakefile* mf=this->GlobalGenerator->GetMakefiles()[0]; if (mf->IsOn("CTEST_USE_LAUNCHERS") && !this->State->GetGlobalProperty("RULE_LAUNCH_COMPILE")) { http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=73e4df99cb4d63f5ea8babb40656a74305d77e12 commit 73e4df99cb4d63f5ea8babb40656a74305d77e12 Author: Stephen Kelly AuthorDate: Sun Aug 2 20:21:22 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 04:10:28 2015 +0200 cmGlobalGenerator: Store a container of cmMakefiles. For use at configure-time. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 3c818ff..749ab6e 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1129,6 +1129,7 @@ void cmGlobalGenerator::Configure() // start with this directory cmLocalGenerator *lg = this->MakeLocalGenerator(); + this->Makefiles.push_back(lg->GetMakefile()); this->LocalGenerators.push_back(lg); // set the Start directories @@ -1599,6 +1600,8 @@ void cmGlobalGenerator::ClearGeneratorMembers() cmDeleteAll(this->BuildExportSets); this->BuildExportSets.clear(); + this->Makefiles.clear(); + cmDeleteAll(this->LocalGenerators); this->LocalGenerators.clear(); @@ -1929,6 +1932,12 @@ std::string cmGlobalGenerator::GenerateCMakeBuildCommand( } //---------------------------------------------------------------------------- +void cmGlobalGenerator::AddMakefile(cmMakefile *mf) +{ + this->Makefiles.push_back(mf); +} + +//---------------------------------------------------------------------------- void cmGlobalGenerator::AddLocalGenerator(cmLocalGenerator *lg) { this->LocalGenerators.push_back(lg); diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 3402fbc..616011f 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -173,6 +173,8 @@ public: cmake *GetCMakeInstance() const { return this->CMakeInstance; } void SetConfiguredFilesPath(cmGlobalGenerator* gen); + const std::vector& GetMakefiles() const { + return this->Makefiles;} const std::vector& GetLocalGenerators() const { return this->LocalGenerators;} @@ -184,6 +186,7 @@ public: void SetCurrentMakefile(cmMakefile* mf) {this->CurrentMakefile = mf;} + void AddMakefile(cmMakefile *mf); void AddLocalGenerator(cmLocalGenerator *lg); ///! Set an generator for an "external makefile based project" @@ -402,6 +405,7 @@ protected: std::string FindMakeProgramFile; std::string ConfiguredFilesPath; cmake *CMakeInstance; + std::vector Makefiles; std::vector LocalGenerators; cmMakefile* CurrentMakefile; // map from project name to vector of local generators in that project diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 60a11e1..85bc493 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1857,6 +1857,7 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath, // create a new local generator and set its parent cmLocalGenerator *lg2 = this->GetGlobalGenerator() ->MakeLocalGenerator(newSnapshot, this->LocalGenerator); + this->GetGlobalGenerator()->AddMakefile(lg2->GetMakefile()); this->GetGlobalGenerator()->AddLocalGenerator(lg2); cmMakefile* subMf = lg2->GetMakefile(); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=193699376af09bd77875d4ddfd10c3feb13ecdd2 commit 193699376af09bd77875d4ddfd10c3feb13ecdd2 Author: Stephen Kelly AuthorDate: Sun Aug 2 19:44:31 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 04:10:28 2015 +0200 cmGeneratorTarget: Port internal type to cmGeneratorTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index b19856d..e914cf6 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -36,7 +36,7 @@ //---------------------------------------------------------------------------- void reportBadObjLib(std::vector const& badObjLib, - cmTarget *target, cmake *cm) + cmGeneratorTarget const* target, cmake *cm) { if(!badObjLib.empty()) { @@ -50,7 +50,7 @@ void reportBadObjLib(std::vector const& badObjLib, e << "but may contain only sources that compile, header files, and " "other files that would not affect linking of a normal library."; cm->IssueMessage(cmake::FATAL_ERROR, e.str(), - target->GetBacktrace()); + target->Target->GetBacktrace()); } } @@ -133,14 +133,14 @@ struct TagVisitor { DataType& Data; std::vector BadObjLibFiles; - cmTarget *Target; + cmGeneratorTarget const* Target; cmGlobalGenerator *GlobalGenerator; cmsys::RegularExpression Header; bool IsObjLib; - TagVisitor(cmTarget *target, DataType& data) + TagVisitor(cmGeneratorTarget const* target, DataType& data) : Data(data), Target(target), - GlobalGenerator(target->GetMakefile()->GetGlobalGenerator()), + GlobalGenerator(target->GetLocalGenerator()->GetGlobalGenerator()), Header(CM_HEADER_REGEX), IsObjLib(target->GetType() == cmTarget::OBJECT_LIBRARY) { @@ -362,7 +362,7 @@ static void handleSystemIncludesDep(cmMakefile *mf, cmTarget const* depTgt, { \ std::vector sourceFiles; \ this->Target->GetSourceFiles(sourceFiles, config); \ - TagVisitor visitor(this->Target, data); \ + TagVisitor visitor(this, data); \ for(std::vector::const_iterator si = sourceFiles.begin(); \ si != sourceFiles.end(); ++si) \ { \ http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=32f131b0ca68bc88bbb32dbf03e76dfba24defe5 commit 32f131b0ca68bc88bbb32dbf03e76dfba24defe5 Author: Stephen Kelly AuthorDate: Sun Aug 2 19:42:31 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 04:10:28 2015 +0200 cmGeneratorTarget: Prefer the local generator to access the global. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c831704..b19856d 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -234,7 +234,7 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) { this->Makefile = this->Target->GetMakefile(); this->LocalGenerator = lg; - this->GlobalGenerator = this->Makefile->GetGlobalGenerator(); + this->GlobalGenerator = this->LocalGenerator->GetGlobalGenerator(); } cmGeneratorTarget::~cmGeneratorTarget() @@ -1556,7 +1556,7 @@ cmTargetTraceDependencies { // Convenience. this->Makefile = this->Target->GetMakefile(); - this->GlobalGenerator = this->Makefile->GetGlobalGenerator(); + this->GlobalGenerator = target->GetLocalGenerator()->GetGlobalGenerator(); this->CurrentEntry = 0; // Queue all the source files already specified for the target. @@ -1944,8 +1944,7 @@ void cmGeneratorTarget::GenerateTargetManifest( { return; } - cmMakefile* mf = this->Target->GetMakefile(); - cmGlobalGenerator* gg = mf->GetGlobalGenerator(); + cmGlobalGenerator* gg = this->LocalGenerator->GetGlobalGenerator(); // Get the names. std::string name; ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From kwrobot at kitware.com Fri Aug 7 00:01:09 2015 From: kwrobot at kitware.com (Kitware Robot) Date: Fri, 7 Aug 2015 00:01:09 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-761-g3cefadb Message-ID: <20150807040109.88FBDB142B@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 3cefadbff07d68c5a6846835ea87cc35eae55a0b (commit) from 22590805bffe74c3b4998152556561a2c2b6d177 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3cefadbff07d68c5a6846835ea87cc35eae55a0b commit 3cefadbff07d68c5a6846835ea87cc35eae55a0b Author: Kitware Robot AuthorDate: Fri Aug 7 00:01:07 2015 -0400 Commit: Kitware Robot CommitDate: Fri Aug 7 00:01:07 2015 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index c9fec35..533a881 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150806) +set(CMake_VERSION_PATCH 20150807) #set(CMake_VERSION_RC 1) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From steveire at gmail.com Fri Aug 7 11:05:54 2015 From: steveire at gmail.com (Stephen Kelly) Date: Fri, 7 Aug 2015 11:05:54 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2085-gffdce7e Message-ID: <20150807150554.2DDC9B15E6@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via ffdce7ed84af2fd2e4e189789ea83a70785f03ad (commit) via 95f456d39b5983119956e071d9d2ac8084eb86d5 (commit) via 0cc9e0588bdca72028ae13571470f3a11fe80b1a (commit) via bc0e24a0d70a4042d505fb9324e5a718603ef75c (commit) from a4634fb344e70d913df2d9dbeb41ec697648f4b0 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ffdce7ed84af2fd2e4e189789ea83a70785f03ad commit ffdce7ed84af2fd2e4e189789ea83a70785f03ad Merge: a4634fb 95f456d Author: Stephen Kelly AuthorDate: Fri Aug 7 11:05:52 2015 -0400 Commit: CMake Topic Stage CommitDate: Fri Aug 7 11:05:52 2015 -0400 Merge topic 'use-generator-target' into next 95f456d3 Revert "cmGlobalGenerator: Return null generator target for target." 0cc9e058 Revert "cmGeneratorTarget: Move GetLinkInterface from cmTarget." bc0e24a0 Revert "cmGeneratorTarget: Move link iface helpers from cmTarget." http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=95f456d39b5983119956e071d9d2ac8084eb86d5 commit 95f456d39b5983119956e071d9d2ac8084eb86d5 Author: Stephen Kelly AuthorDate: Fri Aug 7 17:05:09 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 17:05:09 2015 +0200 Revert "cmGlobalGenerator: Return null generator target for target." This reverts commit 239c6d37e28e3a979122999e8555696865fb4824. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 195fa0d..50e2cd9 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1618,11 +1618,6 @@ void cmGlobalGenerator::ClearGeneratorMembers() cmGeneratorTarget* cmGlobalGenerator::GetGeneratorTarget(cmTarget const* t) const { - if (!t) - { - return 0; - } - cmGeneratorTargetsType::const_iterator ti = this->GeneratorTargets.find(t); if(ti == this->GeneratorTargets.end()) { http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0cc9e0588bdca72028ae13571470f3a11fe80b1a commit 0cc9e0588bdca72028ae13571470f3a11fe80b1a Author: Stephen Kelly AuthorDate: Fri Aug 7 17:05:04 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 17:05:04 2015 +0200 Revert "cmGeneratorTarget: Move GetLinkInterface from cmTarget." This reverts commit ae94ca1c5902dc12ddd7eb7a9e4b197ddde5c884. diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index b657765..8ba8847 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -363,10 +363,8 @@ void cmComputeLinkDepends::FollowLinkEntry(BFSEntry const& qe) if(entry.Target) { // Follow the target dependencies. - cmGeneratorTarget* gtgt = - this->GlobalGenerator->GetGeneratorTarget(entry.Target); - if(cmGeneratorTarget::LinkInterface const* iface = - gtgt->GetLinkInterface(this->Config, this->Target->Target)) + if(cmTarget::LinkInterface const* iface = + entry.Target->GetLinkInterface(this->Config, this->Target->Target)) { const bool isIface = entry.Target->GetType() == cmTarget::INTERFACE_LIBRARY; @@ -400,8 +398,7 @@ void cmComputeLinkDepends::FollowLinkEntry(BFSEntry const& qe) //---------------------------------------------------------------------------- void cmComputeLinkDepends -::FollowSharedDeps(int depender_index, - cmGeneratorTarget::LinkInterface const* iface, +::FollowSharedDeps(int depender_index, cmTarget::LinkInterface const* iface, bool follow_interface) { // Follow dependencies if we have not followed them already. @@ -464,10 +461,8 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep) // Target items may have their own dependencies. if(entry.Target) { - cmGeneratorTarget* gtgt = - this->GlobalGenerator->GetGeneratorTarget(entry.Target); - if(cmGeneratorTarget::LinkInterface const* iface = - gtgt->GetLinkInterface(this->Config, this->Target->Target)) + if(cmTarget::LinkInterface const* iface = + entry.Target->GetLinkInterface(this->Config, this->Target->Target)) { // Follow public and private dependencies transitively. this->FollowSharedDeps(index, iface, true); @@ -937,10 +932,8 @@ int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl) { if(cmTarget const* target = this->EntryList[*ni].Target) { - cmGeneratorTarget* gtgt = - this->GlobalGenerator->GetGeneratorTarget(target); - if(cmGeneratorTarget::LinkInterface const* iface = - gtgt->GetLinkInterface(this->Config, this->Target->Target)) + if(cmTarget::LinkInterface const* iface = + target->GetLinkInterface(this->Config, this->Target->Target)) { if(iface->Multiplicity > count) { diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index e61175a..b925a4f 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -13,7 +13,6 @@ #define cmComputeLinkDepends_h #include "cmStandardIncludes.h" -#include "cmGeneratorTarget.h" #include "cmTarget.h" #include "cmGraphAdjacencyList.h" @@ -23,6 +22,8 @@ class cmComputeComponentGraph; class cmGlobalGenerator; class cmMakefile; +class cmGeneratorTarget; +class cmTarget; class cmake; /** \class cmComputeLinkDepends @@ -101,7 +102,7 @@ private: std::queue SharedDepQueue; std::set SharedDepFollowed; void FollowSharedDeps(int depender_index, - cmGeneratorTarget::LinkInterface const* iface, + cmTarget::LinkInterface const* iface, bool follow_interface = false); void QueueSharedDependencies(int depender_index, std::vector const& deps); diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index fd4b567..c4a03a0 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -296,8 +296,8 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, std::set &emitted) { cmGeneratorTarget const* depender = this->Targets[depender_index]; - if(cmGeneratorTarget::LinkInterface const* iface = - dependee->GetLinkInterface(config, + if(cmTarget::LinkInterface const* iface = + dependee->Target->GetLinkInterface(config, depender->Target)) { for(std::vector::const_iterator diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 97eb6b9..cae60b7 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -796,7 +796,7 @@ cmExportFileGenerator std::vector& missingTargets) { // Add the transitive link dependencies for this configuration. - cmGeneratorTarget::LinkInterface const* iface = target->GetLinkInterface( + cmTarget::LinkInterface const* iface = target->Target->GetLinkInterface( config, target->Target); if (!iface) @@ -909,8 +909,9 @@ cmExportFileGenerator } // Add the transitive link dependencies for this configuration. - if(cmGeneratorTarget::LinkInterface const* iface = - target->GetLinkInterface(config, target->Target)) + if(cmTarget::LinkInterface const* iface = + target->Target + ->GetLinkInterface(config, target->Target)) { this->SetImportLinkProperty(suffix, target, "IMPORTED_LINK_INTERFACE_LANGUAGES", diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index c097bfb..49f2515 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1108,8 +1108,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode if(isInterfaceProperty) { - if(cmGeneratorTarget::LinkInterfaceLibraries const* iface = - gtgt->GetLinkInterfaceLibraries(context->Config, headTarget, true)) + if(cmTarget::LinkInterfaceLibraries const* iface = + target->GetLinkInterfaceLibraries(context->Config, headTarget, true)) { linkedTargetsContent = getLinkedTargetsContent(iface->Libraries, target, diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 27d6a99..aed2c07 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1144,11 +1144,8 @@ public: return; } - cmGeneratorTarget* gtgt = - this->Target->GetLocalGenerator()->GetGlobalGenerator() - ->GetGeneratorTarget(item.Target); - cmGeneratorTarget::LinkInterface const* iface = - gtgt->GetLinkInterface(this->Config, this->HeadTarget); + cmTarget::LinkInterface const* iface = + item.Target->GetLinkInterface(this->Config, this->HeadTarget); if(!iface) { return; } for(std::vector::const_iterator @@ -1478,24 +1475,20 @@ void cmGeneratorTarget::GetAutoUicOptions(std::vector &result, void processILibs(const std::string& config, cmTarget const* headTarget, cmLinkItem const& item, - cmGeneratorTarget* itemGT, std::vector& tgts, std::set& emitted) { if (item.Target && emitted.insert(item.Target).second) { tgts.push_back(item.Target); - if(cmGeneratorTarget::LinkInterfaceLibraries const* iface = - itemGT->GetLinkInterfaceLibraries(config, headTarget, true)) + if(cmTarget::LinkInterfaceLibraries const* iface = + item.Target->GetLinkInterfaceLibraries(config, headTarget, true)) { for(std::vector::const_iterator it = iface->Libraries.begin(); it != iface->Libraries.end(); ++it) { - cmGeneratorTarget* gtgt = - itemGT->GetLocalGenerator()->GetGlobalGenerator() - ->GetGeneratorTarget(it->Target); - processILibs(config, headTarget, *it, gtgt, tgts, emitted); + processILibs(config, headTarget, *it, tgts, emitted); } } } @@ -1520,10 +1513,7 @@ cmGeneratorTarget::GetLinkImplementationClosure( it = impl->Libraries.begin(); it != impl->Libraries.end(); ++it) { - cmGeneratorTarget* gtgt = - this->GetLocalGenerator()->GetGlobalGenerator() - ->GetGeneratorTarget(it->Target); - processILibs(config, this->Target, *it, gtgt, tgts, emitted); + processILibs(config, this->Target, *it, tgts , emitted); } } return tgts; @@ -3332,389 +3322,3 @@ cmGeneratorTarget::ReportPropertyOrigin(const std::string &p, this->Makefile->GetCMakeInstance()->IssueMessage(cmake::LOG, areport); } - -//---------------------------------------------------------------------------- -cmGeneratorTarget::LinkInterface const* cmGeneratorTarget::GetLinkInterface( - const std::string& config, - cmTarget const* head) const -{ - // Imported targets have their own link interface. - if(this->Target->IsImported()) - { - return this->GetImportLinkInterface(config, head, false); - } - - // Link interfaces are not supported for executables that do not - // export symbols. - if(this->GetType() == cmTarget::EXECUTABLE && - !this->Target->IsExecutableWithExports()) - { - return 0; - } - - // Lookup any existing link interface for this configuration. - std::string CONFIG = cmSystemTools::UpperCase(config); - HeadToLinkInterfaceMap& hm = this->LinkInterfaceMap[CONFIG]; - - // If the link interface does not depend on the head target - // then return the one we computed first. - if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) - { - return &hm.begin()->second; - } - - OptionalLinkInterface& iface = hm[head]; - if(!iface.LibrariesDone) - { - iface.LibrariesDone = true; - this->ComputeLinkInterfaceLibraries( - this->Target, config, iface, head, false); - } - if(!iface.AllDone) - { - iface.AllDone = true; - if(iface.Exists) - { - this->ComputeLinkInterface(this->Target, config, iface, head); - } - } - - return iface.Exists? &iface : 0; -} - -//---------------------------------------------------------------------------- -cmGeneratorTarget::LinkInterfaceLibraries const* -cmGeneratorTarget::GetLinkInterfaceLibraries(const std::string& config, - cmTarget const* head, - bool usage_requirements_only) const -{ - // Imported targets have their own link interface. - if(this->Target->IsImported()) - { - return this->GetImportLinkInterface(config, head, usage_requirements_only); - } - - // Link interfaces are not supported for executables that do not - // export symbols. - if(this->GetType() == cmTarget::EXECUTABLE && - !this->Target->IsExecutableWithExports()) - { - return 0; - } - - // Lookup any existing link interface for this configuration. - std::string CONFIG = cmSystemTools::UpperCase(config); - HeadToLinkInterfaceMap& hm = - (usage_requirements_only ? - this->LinkInterfaceUsageRequirementsOnlyMap[CONFIG] : - this->LinkInterfaceMap[CONFIG]); - - // If the link interface does not depend on the head target - // then return the one we computed first. - if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) - { - return &hm.begin()->second; - } - - OptionalLinkInterface& iface = hm[head]; - if(!iface.LibrariesDone) - { - iface.LibrariesDone = true; - this->ComputeLinkInterfaceLibraries( - this->Target, config, iface, head, usage_requirements_only); - } - - return iface.Exists? &iface : 0; -} - -//---------------------------------------------------------------------------- -cmGeneratorTarget::LinkInterface const* -cmGeneratorTarget::GetImportLinkInterface(const std::string& config, - cmTarget const* headTarget, - bool usage_requirements_only) const -{ - cmTarget::ImportInfo const* info = this->Target->GetImportInfo(config); - if(!info) - { - return 0; - } - - std::string CONFIG = cmSystemTools::UpperCase(config); - HeadToLinkInterfaceMap& hm = - (usage_requirements_only ? - this->LinkInterfaceUsageRequirementsOnlyMap[CONFIG] : - this->LinkInterfaceMap[CONFIG]); - - // If the link interface does not depend on the head target - // then return the one we computed first. - if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) - { - return &hm.begin()->second; - } - - OptionalLinkInterface& iface = hm[headTarget]; - if(!iface.AllDone) - { - iface.AllDone = true; - iface.Multiplicity = info->Multiplicity; - cmSystemTools::ExpandListArgument(info->Languages, iface.Languages); - this->Target->ExpandLinkItems(info->LibrariesProp, info->Libraries, config, - headTarget, usage_requirements_only, - iface.Libraries, - iface.HadHeadSensitiveCondition); - std::vector deps; - cmSystemTools::ExpandListArgument(info->SharedDeps, deps); - this->Target->LookupLinkItems(deps, iface.SharedDeps); - } - - return &iface; -} - -//---------------------------------------------------------------------------- -void -cmGeneratorTarget::ComputeLinkInterfaceLibraries( - cmTarget const* thisTarget, - const std::string& config, - OptionalLinkInterface& iface, - cmTarget const* headTarget, - bool usage_requirements_only) const -{ - // Construct the property name suffix for this configuration. - std::string suffix = "_"; - if(!config.empty()) - { - suffix += cmSystemTools::UpperCase(config); - } - else - { - suffix += "NOCONFIG"; - } - - // An explicit list of interface libraries may be set for shared - // libraries and executables that export symbols. - const char* explicitLibraries = 0; - std::string linkIfaceProp; - if(thisTarget->GetPolicyStatusCMP0022() != cmPolicies::OLD && - thisTarget->GetPolicyStatusCMP0022() != cmPolicies::WARN) - { - // CMP0022 NEW behavior is to use INTERFACE_LINK_LIBRARIES. - linkIfaceProp = "INTERFACE_LINK_LIBRARIES"; - explicitLibraries = thisTarget->GetProperty(linkIfaceProp); - } - else if(thisTarget->GetType() == cmTarget::SHARED_LIBRARY || - thisTarget->IsExecutableWithExports()) - { - // CMP0022 OLD behavior is to use LINK_INTERFACE_LIBRARIES if set on a - // shared lib or executable. - - // Lookup the per-configuration property. - linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; - linkIfaceProp += suffix; - explicitLibraries = thisTarget->GetProperty(linkIfaceProp); - - // If not set, try the generic property. - if(!explicitLibraries) - { - linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; - explicitLibraries = thisTarget->GetProperty(linkIfaceProp); - } - } - - if(explicitLibraries && - thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN && - !this->PolicyWarnedCMP0022) - { - // Compare the explicitly set old link interface properties to the - // preferred new link interface property one and warn if different. - const char* newExplicitLibraries = - thisTarget->GetProperty("INTERFACE_LINK_LIBRARIES"); - if (newExplicitLibraries - && strcmp(newExplicitLibraries, explicitLibraries) != 0) - { - std::ostringstream w; - w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n" - "Target \"" << thisTarget->GetName() << "\" has an " - "INTERFACE_LINK_LIBRARIES property which differs from its " << - linkIfaceProp << " properties." - "\n" - "INTERFACE_LINK_LIBRARIES:\n" - " " << newExplicitLibraries << "\n" << - linkIfaceProp << ":\n" - " " << (explicitLibraries ? explicitLibraries : "(empty)") << "\n"; - thisTarget->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); - this->PolicyWarnedCMP0022 = true; - } - } - - // There is no implicit link interface for executables or modules - // so if none was explicitly set then there is no link interface. - if(!explicitLibraries && - (thisTarget->GetType() == cmTarget::EXECUTABLE || - (thisTarget->GetType() == cmTarget::MODULE_LIBRARY))) - { - return; - } - iface.Exists = true; - iface.ExplicitLibraries = explicitLibraries; - - if(explicitLibraries) - { - // The interface libraries have been explicitly set. - thisTarget->ExpandLinkItems(linkIfaceProp, explicitLibraries, config, - headTarget, usage_requirements_only, - iface.Libraries, - iface.HadHeadSensitiveCondition); - } - else if (thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN - || thisTarget->GetPolicyStatusCMP0022() == cmPolicies::OLD) - // If CMP0022 is NEW then the plain tll signature sets the - // INTERFACE_LINK_LIBRARIES, so if we get here then the project - // cleared the property explicitly and we should not fall back - // to the link implementation. - { - // The link implementation is the default link interface. - cmLinkImplementationLibraries const* impl = - thisTarget->GetLinkImplementationLibrariesInternal(config, headTarget); - iface.Libraries.insert(iface.Libraries.end(), - impl->Libraries.begin(), impl->Libraries.end()); - if(thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN && - !this->PolicyWarnedCMP0022 && !usage_requirements_only) - { - // Compare the link implementation fallback link interface to the - // preferred new link interface property and warn if different. - std::vector ifaceLibs; - static const std::string newProp = "INTERFACE_LINK_LIBRARIES"; - if(const char* newExplicitLibraries = thisTarget->GetProperty(newProp)) - { - bool hadHeadSensitiveConditionDummy = false; - thisTarget->ExpandLinkItems(newProp, newExplicitLibraries, config, - headTarget, usage_requirements_only, - ifaceLibs, hadHeadSensitiveConditionDummy); - } - if (ifaceLibs != iface.Libraries) - { - std::string oldLibraries = cmJoin(impl->Libraries, ";"); - std::string newLibraries = cmJoin(ifaceLibs, ";"); - if(oldLibraries.empty()) - { oldLibraries = "(empty)"; } - if(newLibraries.empty()) - { newLibraries = "(empty)"; } - - std::ostringstream w; - w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n" - "Target \"" << thisTarget->GetName() << "\" has an " - "INTERFACE_LINK_LIBRARIES property. " - "This should be preferred as the source of the link interface " - "for this library but because CMP0022 is not set CMake is " - "ignoring the property and using the link implementation " - "as the link interface instead." - "\n" - "INTERFACE_LINK_LIBRARIES:\n" - " " << newLibraries << "\n" - "Link implementation:\n" - " " << oldLibraries << "\n"; - thisTarget->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); - this->PolicyWarnedCMP0022 = true; - } - } - } -} - -//---------------------------------------------------------------------------- -void cmGeneratorTarget::ComputeLinkInterface(cmTarget const* thisTarget, - const std::string& config, - OptionalLinkInterface& iface, - cmTarget const* headTarget) const -{ - if(iface.ExplicitLibraries) - { - if(thisTarget->GetType() == cmTarget::SHARED_LIBRARY - || thisTarget->GetType() == cmTarget::STATIC_LIBRARY - || thisTarget->GetType() == cmTarget::INTERFACE_LIBRARY) - { - // Shared libraries may have runtime implementation dependencies - // on other shared libraries that are not in the interface. - UNORDERED_SET emitted; - for(std::vector::const_iterator - li = iface.Libraries.begin(); li != iface.Libraries.end(); ++li) - { - emitted.insert(*li); - } - if (thisTarget->GetType() != cmTarget::INTERFACE_LIBRARY) - { - cmTarget::LinkImplementation const* impl = - thisTarget->GetLinkImplementation(config); - for(std::vector::const_iterator - li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li) - { - if(emitted.insert(*li).second) - { - if(li->Target) - { - // This is a runtime dependency on another shared library. - if(li->Target->GetType() == cmTarget::SHARED_LIBRARY) - { - iface.SharedDeps.push_back(*li); - } - } - else - { - // TODO: Recognize shared library file names. Perhaps this - // should be moved to cmComputeLinkInformation, but that creates - // a chicken-and-egg problem since this list is needed for its - // construction. - } - } - } - } - } - } - else if (thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN - || thisTarget->GetPolicyStatusCMP0022() == cmPolicies::OLD) - { - // The link implementation is the default link interface. - cmLinkImplementationLibraries const* - impl = thisTarget->GetLinkImplementationLibrariesInternal(config, - headTarget); - iface.ImplementationIsInterface = true; - iface.WrongConfigLibraries = impl->WrongConfigLibraries; - } - - if(thisTarget->LinkLanguagePropagatesToDependents()) - { - // Targets using this archive need its language runtime libraries. - if(cmTarget::LinkImplementation const* impl = - thisTarget->GetLinkImplementation(config)) - { - iface.Languages = impl->Languages; - } - } - - if(thisTarget->GetType() == cmTarget::STATIC_LIBRARY) - { - // Construct the property name suffix for this configuration. - std::string suffix = "_"; - if(!config.empty()) - { - suffix += cmSystemTools::UpperCase(config); - } - else - { - suffix += "NOCONFIG"; - } - - // How many repetitions are needed if this library has cyclic - // dependencies? - std::string propName = "LINK_INTERFACE_MULTIPLICITY"; - propName += suffix; - if(const char* config_reps = thisTarget->GetProperty(propName)) - { - sscanf(config_reps, "%u", &iface.Multiplicity); - } - else if(const char* reps = - thisTarget->GetProperty("LINK_INTERFACE_MULTIPLICITY")) - { - sscanf(reps, "%u", &iface.Multiplicity); - } - } -} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 94402ed..68e7a8a 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -13,7 +13,6 @@ #define cmGeneratorTarget_h #include "cmStandardIncludes.h" -#include "cmLinkItem.h" class cmCustomCommand; class cmGlobalGenerator; @@ -107,48 +106,6 @@ public: const char *GetLinkInterfaceDependentNumberMaxProperty(const std::string &p, const std::string& config) const; - /** The link interface specifies transitive library dependencies and - other information needed by targets that link to this target. */ - struct LinkInterfaceLibraries - { - // Libraries listed in the interface. - std::vector Libraries; - }; - - struct LinkInterface: public LinkInterfaceLibraries - { - // Languages whose runtime libraries must be linked. - std::vector Languages; - - // Shared library dependencies needed for linking on some platforms. - std::vector SharedDeps; - - // Number of repetitions of a strongly connected component of two - // or more static libraries. - int Multiplicity; - - // Libraries listed for other configurations. - // Needed only for OLD behavior of CMP0003. - std::vector WrongConfigLibraries; - - bool ImplementationIsInterface; - - LinkInterface(): Multiplicity(0), ImplementationIsInterface(false) {} - }; - - /** Get the link interface for the given configuration. Returns 0 - if the target cannot be linked. */ - LinkInterface const* GetLinkInterface(const std::string& config, - cmTarget const* headTarget) const; - - LinkInterface const* - GetImportLinkInterface(const std::string& config, cmTarget const* head, - bool usage_requirements_only) const; - - LinkInterfaceLibraries const* - GetLinkInterfaceLibraries(const std::string& config, - cmTarget const* headTarget, - bool usage_requirements_only) const; /** Get the full path to the target according to the settings in its makefile and the configuration type. */ @@ -418,38 +375,6 @@ private: }; mutable std::map LinkImplClosureMap; - // Cache link interface computation from each configuration. - struct OptionalLinkInterface: public LinkInterface - { - OptionalLinkInterface(): - LibrariesDone(false), AllDone(false), - Exists(false), HadHeadSensitiveCondition(false), - ExplicitLibraries(0) {} - bool LibrariesDone; - bool AllDone; - bool Exists; - bool HadHeadSensitiveCondition; - const char* ExplicitLibraries; - }; - void ComputeLinkInterface(cmTarget const* thisTarget, - const std::string& config, - OptionalLinkInterface& iface, - cmTarget const* head) const; - void ComputeLinkInterfaceLibraries(cmTarget const* thisTarget, - const std::string& config, - OptionalLinkInterface& iface, - cmTarget const* head, - bool usage_requirements_only) const; - - struct HeadToLinkInterfaceMap: - public std::map {}; - typedef std::map - LinkInterfaceMapType; - mutable LinkInterfaceMapType LinkInterfaceMap; - mutable LinkInterfaceMapType LinkInterfaceUsageRequirementsOnlyMap; - - mutable bool PolicyWarnedCMP0022; - public: std::vector const& GetLinkImplementationClosure(const std::string& config) const; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index ac02f9f..f1a05ff 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -75,11 +75,13 @@ public: cmTargetInternals() : Backtrace() { + this->PolicyWarnedCMP0022 = false; this->UtilityItemsDone = false; } cmTargetInternals(cmTargetInternals const&) : Backtrace() { + this->PolicyWarnedCMP0022 = false; this->UtilityItemsDone = false; } ~cmTargetInternals(); @@ -87,6 +89,36 @@ public: // The backtrace when the target was created. cmListFileBacktrace Backtrace; + // Cache link interface computation from each configuration. + struct OptionalLinkInterface: public cmTarget::LinkInterface + { + OptionalLinkInterface(): + LibrariesDone(false), AllDone(false), + Exists(false), HadHeadSensitiveCondition(false), + ExplicitLibraries(0) {} + bool LibrariesDone; + bool AllDone; + bool Exists; + bool HadHeadSensitiveCondition; + const char* ExplicitLibraries; + }; + void ComputeLinkInterface(cmTarget const* thisTarget, + const std::string& config, + OptionalLinkInterface& iface, + cmTarget const* head) const; + void ComputeLinkInterfaceLibraries(cmTarget const* thisTarget, + const std::string& config, + OptionalLinkInterface& iface, + cmTarget const* head, + bool usage_requirements_only); + + struct HeadToLinkInterfaceMap: + public std::map {}; + typedef std::map + LinkInterfaceMapType; + LinkInterfaceMapType LinkInterfaceMap; + LinkInterfaceMapType LinkInterfaceUsageRequirementsOnlyMap; + bool PolicyWarnedCMP0022; typedef std::map OutputInfoMapType; OutputInfoMapType OutputInfoMap; @@ -511,6 +543,8 @@ void cmTarget::ClearLinkMaps() { this->LinkImplementationLanguageIsContextDependent = true; this->Internal->LinkImplMap.clear(); + this->Internal->LinkInterfaceMap.clear(); + this->Internal->LinkInterfaceUsageRequirementsOnlyMap.clear(); this->Internal->SourceFilesMap.clear(); } @@ -4069,6 +4103,393 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, } //---------------------------------------------------------------------------- +cmTarget::LinkInterface const* cmTarget::GetLinkInterface( + const std::string& config, + cmTarget const* head) const +{ + // Imported targets have their own link interface. + if(this->IsImported()) + { + return this->GetImportLinkInterface(config, head, false); + } + + // Link interfaces are not supported for executables that do not + // export symbols. + if(this->GetType() == cmTarget::EXECUTABLE && + !this->IsExecutableWithExports()) + { + return 0; + } + + // Lookup any existing link interface for this configuration. + std::string CONFIG = cmSystemTools::UpperCase(config); + cmTargetInternals::HeadToLinkInterfaceMap& hm = + this->Internal->LinkInterfaceMap[CONFIG]; + + // If the link interface does not depend on the head target + // then return the one we computed first. + if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) + { + return &hm.begin()->second; + } + + cmTargetInternals::OptionalLinkInterface& iface = hm[head]; + if(!iface.LibrariesDone) + { + iface.LibrariesDone = true; + this->Internal->ComputeLinkInterfaceLibraries( + this, config, iface, head, false); + } + if(!iface.AllDone) + { + iface.AllDone = true; + if(iface.Exists) + { + this->Internal->ComputeLinkInterface(this, config, iface, head); + } + } + + return iface.Exists? &iface : 0; +} + +//---------------------------------------------------------------------------- +cmTarget::LinkInterfaceLibraries const* +cmTarget::GetLinkInterfaceLibraries(const std::string& config, + cmTarget const* head, + bool usage_requirements_only) const +{ + // Imported targets have their own link interface. + if(this->IsImported()) + { + return this->GetImportLinkInterface(config, head, usage_requirements_only); + } + + // Link interfaces are not supported for executables that do not + // export symbols. + if(this->GetType() == cmTarget::EXECUTABLE && + !this->IsExecutableWithExports()) + { + return 0; + } + + // Lookup any existing link interface for this configuration. + std::string CONFIG = cmSystemTools::UpperCase(config); + cmTargetInternals::HeadToLinkInterfaceMap& hm = + (usage_requirements_only ? + this->Internal->LinkInterfaceUsageRequirementsOnlyMap[CONFIG] : + this->Internal->LinkInterfaceMap[CONFIG]); + + // If the link interface does not depend on the head target + // then return the one we computed first. + if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) + { + return &hm.begin()->second; + } + + cmTargetInternals::OptionalLinkInterface& iface = hm[head]; + if(!iface.LibrariesDone) + { + iface.LibrariesDone = true; + this->Internal->ComputeLinkInterfaceLibraries( + this, config, iface, head, usage_requirements_only); + } + + return iface.Exists? &iface : 0; +} + +//---------------------------------------------------------------------------- +cmTarget::LinkInterface const* +cmTarget::GetImportLinkInterface(const std::string& config, + cmTarget const* headTarget, + bool usage_requirements_only) const +{ + cmTarget::ImportInfo const* info = this->GetImportInfo(config); + if(!info) + { + return 0; + } + + std::string CONFIG = cmSystemTools::UpperCase(config); + cmTargetInternals::HeadToLinkInterfaceMap& hm = + (usage_requirements_only ? + this->Internal->LinkInterfaceUsageRequirementsOnlyMap[CONFIG] : + this->Internal->LinkInterfaceMap[CONFIG]); + + // If the link interface does not depend on the head target + // then return the one we computed first. + if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) + { + return &hm.begin()->second; + } + + cmTargetInternals::OptionalLinkInterface& iface = hm[headTarget]; + if(!iface.AllDone) + { + iface.AllDone = true; + iface.Multiplicity = info->Multiplicity; + cmSystemTools::ExpandListArgument(info->Languages, iface.Languages); + this->ExpandLinkItems(info->LibrariesProp, info->Libraries, config, + headTarget, usage_requirements_only, + iface.Libraries, + iface.HadHeadSensitiveCondition); + std::vector deps; + cmSystemTools::ExpandListArgument(info->SharedDeps, deps); + this->LookupLinkItems(deps, iface.SharedDeps); + } + + return &iface; +} + +//---------------------------------------------------------------------------- +void +cmTargetInternals::ComputeLinkInterfaceLibraries( + cmTarget const* thisTarget, + const std::string& config, + OptionalLinkInterface& iface, + cmTarget const* headTarget, + bool usage_requirements_only) +{ + // Construct the property name suffix for this configuration. + std::string suffix = "_"; + if(!config.empty()) + { + suffix += cmSystemTools::UpperCase(config); + } + else + { + suffix += "NOCONFIG"; + } + + // An explicit list of interface libraries may be set for shared + // libraries and executables that export symbols. + const char* explicitLibraries = 0; + std::string linkIfaceProp; + if(thisTarget->GetPolicyStatusCMP0022() != cmPolicies::OLD && + thisTarget->GetPolicyStatusCMP0022() != cmPolicies::WARN) + { + // CMP0022 NEW behavior is to use INTERFACE_LINK_LIBRARIES. + linkIfaceProp = "INTERFACE_LINK_LIBRARIES"; + explicitLibraries = thisTarget->GetProperty(linkIfaceProp); + } + else if(thisTarget->GetType() == cmTarget::SHARED_LIBRARY || + thisTarget->IsExecutableWithExports()) + { + // CMP0022 OLD behavior is to use LINK_INTERFACE_LIBRARIES if set on a + // shared lib or executable. + + // Lookup the per-configuration property. + linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; + linkIfaceProp += suffix; + explicitLibraries = thisTarget->GetProperty(linkIfaceProp); + + // If not set, try the generic property. + if(!explicitLibraries) + { + linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; + explicitLibraries = thisTarget->GetProperty(linkIfaceProp); + } + } + + if(explicitLibraries && + thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN && + !this->PolicyWarnedCMP0022) + { + // Compare the explicitly set old link interface properties to the + // preferred new link interface property one and warn if different. + const char* newExplicitLibraries = + thisTarget->GetProperty("INTERFACE_LINK_LIBRARIES"); + if (newExplicitLibraries + && strcmp(newExplicitLibraries, explicitLibraries) != 0) + { + std::ostringstream w; + w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n" + "Target \"" << thisTarget->GetName() << "\" has an " + "INTERFACE_LINK_LIBRARIES property which differs from its " << + linkIfaceProp << " properties." + "\n" + "INTERFACE_LINK_LIBRARIES:\n" + " " << newExplicitLibraries << "\n" << + linkIfaceProp << ":\n" + " " << (explicitLibraries ? explicitLibraries : "(empty)") << "\n"; + thisTarget->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + this->PolicyWarnedCMP0022 = true; + } + } + + // There is no implicit link interface for executables or modules + // so if none was explicitly set then there is no link interface. + if(!explicitLibraries && + (thisTarget->GetType() == cmTarget::EXECUTABLE || + (thisTarget->GetType() == cmTarget::MODULE_LIBRARY))) + { + return; + } + iface.Exists = true; + iface.ExplicitLibraries = explicitLibraries; + + if(explicitLibraries) + { + // The interface libraries have been explicitly set. + thisTarget->ExpandLinkItems(linkIfaceProp, explicitLibraries, config, + headTarget, usage_requirements_only, + iface.Libraries, + iface.HadHeadSensitiveCondition); + } + else if (thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN + || thisTarget->GetPolicyStatusCMP0022() == cmPolicies::OLD) + // If CMP0022 is NEW then the plain tll signature sets the + // INTERFACE_LINK_LIBRARIES, so if we get here then the project + // cleared the property explicitly and we should not fall back + // to the link implementation. + { + // The link implementation is the default link interface. + cmLinkImplementationLibraries const* impl = + thisTarget->GetLinkImplementationLibrariesInternal(config, headTarget); + iface.Libraries.insert(iface.Libraries.end(), + impl->Libraries.begin(), impl->Libraries.end()); + if(thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN && + !this->PolicyWarnedCMP0022 && !usage_requirements_only) + { + // Compare the link implementation fallback link interface to the + // preferred new link interface property and warn if different. + std::vector ifaceLibs; + static const std::string newProp = "INTERFACE_LINK_LIBRARIES"; + if(const char* newExplicitLibraries = thisTarget->GetProperty(newProp)) + { + bool hadHeadSensitiveConditionDummy = false; + thisTarget->ExpandLinkItems(newProp, newExplicitLibraries, config, + headTarget, usage_requirements_only, + ifaceLibs, hadHeadSensitiveConditionDummy); + } + if (ifaceLibs != iface.Libraries) + { + std::string oldLibraries = cmJoin(impl->Libraries, ";"); + std::string newLibraries = cmJoin(ifaceLibs, ";"); + if(oldLibraries.empty()) + { oldLibraries = "(empty)"; } + if(newLibraries.empty()) + { newLibraries = "(empty)"; } + + std::ostringstream w; + w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n" + "Target \"" << thisTarget->GetName() << "\" has an " + "INTERFACE_LINK_LIBRARIES property. " + "This should be preferred as the source of the link interface " + "for this library but because CMP0022 is not set CMake is " + "ignoring the property and using the link implementation " + "as the link interface instead." + "\n" + "INTERFACE_LINK_LIBRARIES:\n" + " " << newLibraries << "\n" + "Link implementation:\n" + " " << oldLibraries << "\n"; + thisTarget->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + this->PolicyWarnedCMP0022 = true; + } + } + } +} + +//---------------------------------------------------------------------------- +void cmTargetInternals::ComputeLinkInterface(cmTarget const* thisTarget, + const std::string& config, + OptionalLinkInterface& iface, + cmTarget const* headTarget) const +{ + if(iface.ExplicitLibraries) + { + if(thisTarget->GetType() == cmTarget::SHARED_LIBRARY + || thisTarget->GetType() == cmTarget::STATIC_LIBRARY + || thisTarget->GetType() == cmTarget::INTERFACE_LIBRARY) + { + // Shared libraries may have runtime implementation dependencies + // on other shared libraries that are not in the interface. + UNORDERED_SET emitted; + for(std::vector::const_iterator + li = iface.Libraries.begin(); li != iface.Libraries.end(); ++li) + { + emitted.insert(*li); + } + if (thisTarget->GetType() != cmTarget::INTERFACE_LIBRARY) + { + cmTarget::LinkImplementation const* impl = + thisTarget->GetLinkImplementation(config); + for(std::vector::const_iterator + li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li) + { + if(emitted.insert(*li).second) + { + if(li->Target) + { + // This is a runtime dependency on another shared library. + if(li->Target->GetType() == cmTarget::SHARED_LIBRARY) + { + iface.SharedDeps.push_back(*li); + } + } + else + { + // TODO: Recognize shared library file names. Perhaps this + // should be moved to cmComputeLinkInformation, but that creates + // a chicken-and-egg problem since this list is needed for its + // construction. + } + } + } + } + } + } + else if (thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN + || thisTarget->GetPolicyStatusCMP0022() == cmPolicies::OLD) + { + // The link implementation is the default link interface. + cmLinkImplementationLibraries const* + impl = thisTarget->GetLinkImplementationLibrariesInternal(config, + headTarget); + iface.ImplementationIsInterface = true; + iface.WrongConfigLibraries = impl->WrongConfigLibraries; + } + + if(thisTarget->LinkLanguagePropagatesToDependents()) + { + // Targets using this archive need its language runtime libraries. + if(cmTarget::LinkImplementation const* impl = + thisTarget->GetLinkImplementation(config)) + { + iface.Languages = impl->Languages; + } + } + + if(thisTarget->GetType() == cmTarget::STATIC_LIBRARY) + { + // Construct the property name suffix for this configuration. + std::string suffix = "_"; + if(!config.empty()) + { + suffix += cmSystemTools::UpperCase(config); + } + else + { + suffix += "NOCONFIG"; + } + + // How many repetitions are needed if this library has cyclic + // dependencies? + std::string propName = "LINK_INTERFACE_MULTIPLICITY"; + propName += suffix; + if(const char* config_reps = thisTarget->GetProperty(propName)) + { + sscanf(config_reps, "%u", &iface.Multiplicity); + } + else if(const char* reps = + thisTarget->GetProperty("LINK_INTERFACE_MULTIPLICITY")) + { + sscanf(reps, "%u", &iface.Multiplicity); + } + } +} + +//---------------------------------------------------------------------------- void cmTargetInternals::AddInterfaceEntries( cmTarget const* thisTarget, std::string const& config, std::string const& prop, std::vector& entries) diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 6366e00..490aaa3 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -233,6 +233,43 @@ public: void GetObjectLibrariesCMP0026(std::vector& objlibs) const; + /** The link interface specifies transitive library dependencies and + other information needed by targets that link to this target. */ + struct LinkInterfaceLibraries + { + // Libraries listed in the interface. + std::vector Libraries; + }; + struct LinkInterface: public LinkInterfaceLibraries + { + // Languages whose runtime libraries must be linked. + std::vector Languages; + + // Shared library dependencies needed for linking on some platforms. + std::vector SharedDeps; + + // Number of repetitions of a strongly connected component of two + // or more static libraries. + int Multiplicity; + + // Libraries listed for other configurations. + // Needed only for OLD behavior of CMP0003. + std::vector WrongConfigLibraries; + + bool ImplementationIsInterface; + + LinkInterface(): Multiplicity(0), ImplementationIsInterface(false) {} + }; + + /** Get the link interface for the given configuration. Returns 0 + if the target cannot be linked. */ + LinkInterface const* GetLinkInterface(const std::string& config, + cmTarget const* headTarget) const; + LinkInterfaceLibraries const* + GetLinkInterfaceLibraries(const std::string& config, + cmTarget const* headTarget, + bool usage_requirements_only) const; + struct LinkImplementation: public cmLinkImplementationLibraries { // Languages whose runtime libraries must be linked. @@ -555,6 +592,11 @@ private: void ComputeImportInfo(std::string const& desired_config, ImportInfo& info) const; + + LinkInterface const* + GetImportLinkInterface(const std::string& config, cmTarget const* head, + bool usage_requirements_only) const; + cmLinkImplementationLibraries const* GetLinkImplementationLibrariesInternal(const std::string& config, cmTarget const* head) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bc0e24a0d70a4042d505fb9324e5a718603ef75c commit bc0e24a0d70a4042d505fb9324e5a718603ef75c Author: Stephen Kelly AuthorDate: Fri Aug 7 17:05:00 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 17:05:00 2015 +0200 Revert "cmGeneratorTarget: Move link iface helpers from cmTarget." This reverts commit 906c9a26630e4fcf2360dd9e824b0191ecaf887f. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index fa1622e..27d6a99 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3334,51 +3334,6 @@ cmGeneratorTarget::ReportPropertyOrigin(const std::string &p, } //---------------------------------------------------------------------------- -void cmGeneratorTarget::LookupLinkItems(std::vector const& names, - std::vector& items) const -{ - for(std::vector::const_iterator i = names.begin(); - i != names.end(); ++i) - { - std::string name = this->Target->CheckCMP0004(*i); - if(name == this->GetName() || name.empty()) - { - continue; - } - items.push_back(cmLinkItem(name, this->Target->FindTargetToLink(name))); - } -} - -//---------------------------------------------------------------------------- -void cmGeneratorTarget::ExpandLinkItems(std::string const& prop, - std::string const& value, - std::string const& config, - cmTarget const* headTarget, - bool usage_requirements_only, - std::vector& items, - bool& hadHeadSensitiveCondition) const -{ - cmGeneratorExpression ge; - cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), prop, 0, 0); - // The $ expression may be in a link interface to specify private - // link dependencies that are otherwise excluded from usage requirements. - if(usage_requirements_only) - { - dagChecker.SetTransitivePropertiesOnly(); - } - std::vector libs; - cmsys::auto_ptr cge = ge.Parse(value); - cmSystemTools::ExpandListArgument(cge->Evaluate( - this->Makefile, - config, - false, - headTarget, - this->Target, &dagChecker), libs); - this->LookupLinkItems(libs, items); - hadHeadSensitiveCondition = cge->GetHadHeadSensitiveCondition(); -} - -//---------------------------------------------------------------------------- cmGeneratorTarget::LinkInterface const* cmGeneratorTarget::GetLinkInterface( const std::string& config, cmTarget const* head) const @@ -3413,14 +3368,14 @@ cmGeneratorTarget::LinkInterface const* cmGeneratorTarget::GetLinkInterface( { iface.LibrariesDone = true; this->ComputeLinkInterfaceLibraries( - config, iface, head, false); + this->Target, config, iface, head, false); } if(!iface.AllDone) { iface.AllDone = true; if(iface.Exists) { - this->ComputeLinkInterface(config, iface, head); + this->ComputeLinkInterface(this->Target, config, iface, head); } } @@ -3466,7 +3421,7 @@ cmGeneratorTarget::GetLinkInterfaceLibraries(const std::string& config, { iface.LibrariesDone = true; this->ComputeLinkInterfaceLibraries( - config, iface, head, usage_requirements_only); + this->Target, config, iface, head, usage_requirements_only); } return iface.Exists? &iface : 0; @@ -3503,13 +3458,13 @@ cmGeneratorTarget::GetImportLinkInterface(const std::string& config, iface.AllDone = true; iface.Multiplicity = info->Multiplicity; cmSystemTools::ExpandListArgument(info->Languages, iface.Languages); - this->ExpandLinkItems(info->LibrariesProp, info->Libraries, config, + this->Target->ExpandLinkItems(info->LibrariesProp, info->Libraries, config, headTarget, usage_requirements_only, iface.Libraries, iface.HadHeadSensitiveCondition); std::vector deps; cmSystemTools::ExpandListArgument(info->SharedDeps, deps); - this->LookupLinkItems(deps, iface.SharedDeps); + this->Target->LookupLinkItems(deps, iface.SharedDeps); } return &iface; @@ -3518,6 +3473,7 @@ cmGeneratorTarget::GetImportLinkInterface(const std::string& config, //---------------------------------------------------------------------------- void cmGeneratorTarget::ComputeLinkInterfaceLibraries( + cmTarget const* thisTarget, const std::string& config, OptionalLinkInterface& iface, cmTarget const* headTarget, @@ -3538,15 +3494,15 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( // libraries and executables that export symbols. const char* explicitLibraries = 0; std::string linkIfaceProp; - if(this->Target->GetPolicyStatusCMP0022() != cmPolicies::OLD && - this->Target->GetPolicyStatusCMP0022() != cmPolicies::WARN) + if(thisTarget->GetPolicyStatusCMP0022() != cmPolicies::OLD && + thisTarget->GetPolicyStatusCMP0022() != cmPolicies::WARN) { // CMP0022 NEW behavior is to use INTERFACE_LINK_LIBRARIES. linkIfaceProp = "INTERFACE_LINK_LIBRARIES"; - explicitLibraries = this->Target->GetProperty(linkIfaceProp); + explicitLibraries = thisTarget->GetProperty(linkIfaceProp); } - else if(this->Target->GetType() == cmTarget::SHARED_LIBRARY || - this->Target->IsExecutableWithExports()) + else if(thisTarget->GetType() == cmTarget::SHARED_LIBRARY || + thisTarget->IsExecutableWithExports()) { // CMP0022 OLD behavior is to use LINK_INTERFACE_LIBRARIES if set on a // shared lib or executable. @@ -3554,30 +3510,30 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( // Lookup the per-configuration property. linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; linkIfaceProp += suffix; - explicitLibraries = this->Target->GetProperty(linkIfaceProp); + explicitLibraries = thisTarget->GetProperty(linkIfaceProp); // If not set, try the generic property. if(!explicitLibraries) { linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; - explicitLibraries = this->Target->GetProperty(linkIfaceProp); + explicitLibraries = thisTarget->GetProperty(linkIfaceProp); } } if(explicitLibraries && - this->Target->GetPolicyStatusCMP0022() == cmPolicies::WARN && + thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN && !this->PolicyWarnedCMP0022) { // Compare the explicitly set old link interface properties to the // preferred new link interface property one and warn if different. const char* newExplicitLibraries = - this->Target->GetProperty("INTERFACE_LINK_LIBRARIES"); + thisTarget->GetProperty("INTERFACE_LINK_LIBRARIES"); if (newExplicitLibraries && strcmp(newExplicitLibraries, explicitLibraries) != 0) { std::ostringstream w; w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n" - "Target \"" << this->Target->GetName() << "\" has an " + "Target \"" << thisTarget->GetName() << "\" has an " "INTERFACE_LINK_LIBRARIES property which differs from its " << linkIfaceProp << " properties." "\n" @@ -3585,7 +3541,7 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( " " << newExplicitLibraries << "\n" << linkIfaceProp << ":\n" " " << (explicitLibraries ? explicitLibraries : "(empty)") << "\n"; - this->Target->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + thisTarget->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); this->PolicyWarnedCMP0022 = true; } } @@ -3593,8 +3549,8 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( // There is no implicit link interface for executables or modules // so if none was explicitly set then there is no link interface. if(!explicitLibraries && - (this->Target->GetType() == cmTarget::EXECUTABLE || - (this->Target->GetType() == cmTarget::MODULE_LIBRARY))) + (thisTarget->GetType() == cmTarget::EXECUTABLE || + (thisTarget->GetType() == cmTarget::MODULE_LIBRARY))) { return; } @@ -3604,13 +3560,13 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( if(explicitLibraries) { // The interface libraries have been explicitly set. - this->ExpandLinkItems(linkIfaceProp, explicitLibraries, config, + thisTarget->ExpandLinkItems(linkIfaceProp, explicitLibraries, config, headTarget, usage_requirements_only, iface.Libraries, iface.HadHeadSensitiveCondition); } - else if (this->Target->GetPolicyStatusCMP0022() == cmPolicies::WARN - || this->Target->GetPolicyStatusCMP0022() == cmPolicies::OLD) + else if (thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN + || thisTarget->GetPolicyStatusCMP0022() == cmPolicies::OLD) // If CMP0022 is NEW then the plain tll signature sets the // INTERFACE_LINK_LIBRARIES, so if we get here then the project // cleared the property explicitly and we should not fall back @@ -3618,20 +3574,20 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( { // The link implementation is the default link interface. cmLinkImplementationLibraries const* impl = - this->Target->GetLinkImplementationLibrariesInternal(config, headTarget); + thisTarget->GetLinkImplementationLibrariesInternal(config, headTarget); iface.Libraries.insert(iface.Libraries.end(), impl->Libraries.begin(), impl->Libraries.end()); - if(this->Target->GetPolicyStatusCMP0022() == cmPolicies::WARN && + if(thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN && !this->PolicyWarnedCMP0022 && !usage_requirements_only) { // Compare the link implementation fallback link interface to the // preferred new link interface property and warn if different. std::vector ifaceLibs; static const std::string newProp = "INTERFACE_LINK_LIBRARIES"; - if(const char* newExplicitLibraries = this->Target->GetProperty(newProp)) + if(const char* newExplicitLibraries = thisTarget->GetProperty(newProp)) { bool hadHeadSensitiveConditionDummy = false; - this->ExpandLinkItems(newProp, newExplicitLibraries, config, + thisTarget->ExpandLinkItems(newProp, newExplicitLibraries, config, headTarget, usage_requirements_only, ifaceLibs, hadHeadSensitiveConditionDummy); } @@ -3646,7 +3602,7 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( std::ostringstream w; w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n" - "Target \"" << this->Target->GetName() << "\" has an " + "Target \"" << thisTarget->GetName() << "\" has an " "INTERFACE_LINK_LIBRARIES property. " "This should be preferred as the source of the link interface " "for this library but because CMP0022 is not set CMake is " @@ -3657,7 +3613,7 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( " " << newLibraries << "\n" "Link implementation:\n" " " << oldLibraries << "\n"; - this->Target->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + thisTarget->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); this->PolicyWarnedCMP0022 = true; } } @@ -3665,15 +3621,16 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( } //---------------------------------------------------------------------------- -void cmGeneratorTarget::ComputeLinkInterface(const std::string& config, +void cmGeneratorTarget::ComputeLinkInterface(cmTarget const* thisTarget, + const std::string& config, OptionalLinkInterface& iface, cmTarget const* headTarget) const { if(iface.ExplicitLibraries) { - if(this->GetType() == cmTarget::SHARED_LIBRARY - || this->GetType() == cmTarget::STATIC_LIBRARY - || this->GetType() == cmTarget::INTERFACE_LIBRARY) + if(thisTarget->GetType() == cmTarget::SHARED_LIBRARY + || thisTarget->GetType() == cmTarget::STATIC_LIBRARY + || thisTarget->GetType() == cmTarget::INTERFACE_LIBRARY) { // Shared libraries may have runtime implementation dependencies // on other shared libraries that are not in the interface. @@ -3683,10 +3640,10 @@ void cmGeneratorTarget::ComputeLinkInterface(const std::string& config, { emitted.insert(*li); } - if (this->GetType() != cmTarget::INTERFACE_LIBRARY) + if (thisTarget->GetType() != cmTarget::INTERFACE_LIBRARY) { cmTarget::LinkImplementation const* impl = - this->Target->GetLinkImplementation(config); + thisTarget->GetLinkImplementation(config); for(std::vector::const_iterator li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li) { @@ -3712,28 +3669,28 @@ void cmGeneratorTarget::ComputeLinkInterface(const std::string& config, } } } - else if (this->Target->GetPolicyStatusCMP0022() == cmPolicies::WARN - || this->Target->GetPolicyStatusCMP0022() == cmPolicies::OLD) + else if (thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN + || thisTarget->GetPolicyStatusCMP0022() == cmPolicies::OLD) { // The link implementation is the default link interface. cmLinkImplementationLibraries const* - impl = this->Target->GetLinkImplementationLibrariesInternal(config, + impl = thisTarget->GetLinkImplementationLibrariesInternal(config, headTarget); iface.ImplementationIsInterface = true; iface.WrongConfigLibraries = impl->WrongConfigLibraries; } - if(this->Target->LinkLanguagePropagatesToDependents()) + if(thisTarget->LinkLanguagePropagatesToDependents()) { // Targets using this archive need its language runtime libraries. if(cmTarget::LinkImplementation const* impl = - this->Target->GetLinkImplementation(config)) + thisTarget->GetLinkImplementation(config)) { iface.Languages = impl->Languages; } } - if(this->GetType() == cmTarget::STATIC_LIBRARY) + if(thisTarget->GetType() == cmTarget::STATIC_LIBRARY) { // Construct the property name suffix for this configuration. std::string suffix = "_"; @@ -3750,12 +3707,12 @@ void cmGeneratorTarget::ComputeLinkInterface(const std::string& config, // dependencies? std::string propName = "LINK_INTERFACE_MULTIPLICITY"; propName += suffix; - if(const char* config_reps = this->Target->GetProperty(propName)) + if(const char* config_reps = thisTarget->GetProperty(propName)) { sscanf(config_reps, "%u", &iface.Multiplicity); } else if(const char* reps = - this->Target->GetProperty("LINK_INTERFACE_MULTIPLICITY")) + thisTarget->GetProperty("LINK_INTERFACE_MULTIPLICITY")) { sscanf(reps, "%u", &iface.Multiplicity); } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 24163b6..94402ed 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -431,10 +431,12 @@ private: bool HadHeadSensitiveCondition; const char* ExplicitLibraries; }; - void ComputeLinkInterface(const std::string& config, + void ComputeLinkInterface(cmTarget const* thisTarget, + const std::string& config, OptionalLinkInterface& iface, cmTarget const* head) const; - void ComputeLinkInterfaceLibraries(const std::string& config, + void ComputeLinkInterfaceLibraries(cmTarget const* thisTarget, + const std::string& config, OptionalLinkInterface& iface, cmTarget const* head, bool usage_requirements_only) const; @@ -448,14 +450,6 @@ private: mutable bool PolicyWarnedCMP0022; - void ExpandLinkItems(std::string const& prop, std::string const& value, - std::string const& config, cmTarget const* headTarget, - bool usage_requirements_only, - std::vector& items, - bool& hadHeadSensitiveCondition) const; - void LookupLinkItems(std::vector const& names, - std::vector& items) const; - public: std::vector const& GetLinkImplementationClosure(const std::string& config) const; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index ef2df21..ac02f9f 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3047,6 +3047,51 @@ bool cmTarget::GetPropertyAsBool(const std::string& prop) const } //---------------------------------------------------------------------------- +void cmTarget::ExpandLinkItems(std::string const& prop, + std::string const& value, + std::string const& config, + cmTarget const* headTarget, + bool usage_requirements_only, + std::vector& items, + bool& hadHeadSensitiveCondition) const +{ + cmGeneratorExpression ge; + cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), prop, 0, 0); + // The $ expression may be in a link interface to specify private + // link dependencies that are otherwise excluded from usage requirements. + if(usage_requirements_only) + { + dagChecker.SetTransitivePropertiesOnly(); + } + std::vector libs; + cmsys::auto_ptr cge = ge.Parse(value); + cmSystemTools::ExpandListArgument(cge->Evaluate( + this->Makefile, + config, + false, + headTarget, + this, &dagChecker), libs); + this->LookupLinkItems(libs, items); + hadHeadSensitiveCondition = cge->GetHadHeadSensitiveCondition(); +} + +//---------------------------------------------------------------------------- +void cmTarget::LookupLinkItems(std::vector const& names, + std::vector& items) const +{ + for(std::vector::const_iterator i = names.begin(); + i != names.end(); ++i) + { + std::string name = this->CheckCMP0004(*i); + if(name == this->GetName() || name.empty()) + { + continue; + } + items.push_back(cmLinkItem(name, this->FindTargetToLink(name))); + } +} + +//---------------------------------------------------------------------------- const char* cmTarget::GetSuffixVariableInternal(bool implib) const { switch(this->GetType()) diff --git a/Source/cmTarget.h b/Source/cmTarget.h index dcf6832..6366e00 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -559,6 +559,14 @@ private: GetLinkImplementationLibrariesInternal(const std::string& config, cmTarget const* head) const; + void ExpandLinkItems(std::string const& prop, std::string const& value, + std::string const& config, cmTarget const* headTarget, + bool usage_requirements_only, + std::vector& items, + bool& hadHeadSensitiveCondition) const; + void LookupLinkItems(std::vector const& names, + std::vector& items) const; + std::string ProcessSourceItemCMP0049(const std::string& s); void ClearLinkMaps(); ----------------------------------------------------------------------- Summary of changes: Source/cmComputeLinkDepends.cxx | 21 +- Source/cmComputeLinkDepends.h | 5 +- Source/cmComputeTargetDepends.cxx | 4 +- Source/cmExportFileGenerator.cxx | 7 +- Source/cmGeneratorExpressionNode.cxx | 4 +- Source/cmGeneratorTarget.cxx | 451 +------------------------------- Source/cmGeneratorTarget.h | 81 ------ Source/cmGlobalGenerator.cxx | 5 - Source/cmTarget.cxx | 466 ++++++++++++++++++++++++++++++++++ Source/cmTarget.h | 50 ++++ 10 files changed, 540 insertions(+), 554 deletions(-) hooks/post-receive -- CMake From steveire at gmail.com Fri Aug 7 11:06:32 2015 From: steveire at gmail.com (Stephen Kelly) Date: Fri, 7 Aug 2015 11:06:32 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2093-g010f4f8 Message-ID: <20150807150632.EC285B15F2@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 010f4f8c6a8e6d45d7f49aa083d12f65de714557 (commit) via 03dd19a3eef57d6edfff017dae4aba0a62d9f165 (commit) via 3bbd5425d31e179dbb1b70d944ac24523b0eb46b (commit) via 197f4de110a59332757360110b1e90f6b07e1c97 (commit) via 44e071aeff4d533f116a7721919f9036c5d5a1d1 (commit) via 772ecef4b8037d5ce59d24772c05829872aff406 (commit) via 1f54bc1cf35707a5f1410ff4c6632d7cba351c40 (commit) via 7568199b4de18ed56ad8ef735c145c4a44327355 (commit) from ffdce7ed84af2fd2e4e189789ea83a70785f03ad (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=010f4f8c6a8e6d45d7f49aa083d12f65de714557 commit 010f4f8c6a8e6d45d7f49aa083d12f65de714557 Merge: ffdce7e 03dd19a Author: Stephen Kelly AuthorDate: Fri Aug 7 11:06:31 2015 -0400 Commit: CMake Topic Stage CommitDate: Fri Aug 7 11:06:31 2015 -0400 Merge topic 'use-generator-target' into next 03dd19a3 cmTarget: Use a simpler delete algorithm. 3bbd5425 cmTarget: Split storage of sources from genexes. 197f4de1 cmTarget: Split storage of compile definitions from genexes. 44e071ae cmTarget: Split storage of compile features from genexes. 772ecef4 cmTarget: Split storage of compile options from genexes. 1f54bc1c cmTarget: Split storage of include directories from genexes. 7568199b cmTarget: Request only the link libraries where needed. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=03dd19a3eef57d6edfff017dae4aba0a62d9f165 commit 03dd19a3eef57d6edfff017dae4aba0a62d9f165 Author: Stephen Kelly AuthorDate: Tue Aug 4 23:16:12 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 17:06:20 2015 +0200 cmTarget: Use a simpler delete algorithm. This way, the methods can be moved without requiring a local algorithm. The containers use automatic storage. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index d30f2f5..f1a05ff 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -193,14 +193,6 @@ public: cmLinkImplItem cmTargetInternals::TargetPropertyEntry::NoLinkImplItem; //---------------------------------------------------------------------------- -static void deleteAndClear( - std::vector &entries) -{ - cmDeleteAll(entries); - entries.clear(); -} - -//---------------------------------------------------------------------------- cmTargetInternals::~cmTargetInternals() { } @@ -817,7 +809,7 @@ void cmTarget::GetSourceFiles(std::vector &files, this->LinkImplementationLanguageIsContextDependent = false; } - deleteAndClear(linkInterfaceSourcesEntries); + cmDeleteAll(linkInterfaceSourcesEntries); } //---------------------------------------------------------------------------- @@ -2172,7 +2164,7 @@ cmTarget::GetIncludeDirectories(const std::string& config, debugIncludes, language); - deleteAndClear(linkInterfaceIncludeDirectoriesEntries); + cmDeleteAll(linkInterfaceIncludeDirectoriesEntries); return includes; } @@ -2293,7 +2285,7 @@ void cmTarget::GetCompileOptions(std::vector &result, debugOptions, language); - deleteAndClear(linkInterfaceCompileOptionsEntries); + cmDeleteAll(linkInterfaceCompileOptionsEntries); } //---------------------------------------------------------------------------- @@ -2395,7 +2387,7 @@ void cmTarget::GetCompileDefinitions(std::vector &list, debugDefines, language); - deleteAndClear(linkInterfaceCompileDefinitionsEntries); + cmDeleteAll(linkInterfaceCompileDefinitionsEntries); } //---------------------------------------------------------------------------- @@ -2462,7 +2454,7 @@ void cmTarget::GetCompileFeatures(std::vector &result, config, debugFeatures); - deleteAndClear(linkInterfaceCompileFeaturesEntries); + cmDeleteAll(linkInterfaceCompileFeaturesEntries); } //---------------------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3bbd5425d31e179dbb1b70d944ac24523b0eb46b commit 3bbd5425d31e179dbb1b70d944ac24523b0eb46b Author: Stephen Kelly AuthorDate: Tue Aug 4 21:46:15 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 17:06:19 2015 +0200 cmTarget: Split storage of sources from genexes. diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index ce806ba..b094125 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -313,7 +313,9 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg, makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", mocCppFile.c_str(), false); - target->AddSource(mocCppFile); + std::vector mocCppFiles; + mocCppFiles.push_back(mocCppFile); + target->AddTracedSources(mocCppFiles); } // create a custom target for running generators at buildtime: std::string autogenTargetName = getAutogenTargetName(target); @@ -737,12 +739,7 @@ void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target) } } - for(std::vector::const_iterator fileIt = newRccFiles.begin(); - fileIt != newRccFiles.end(); - ++fileIt) - { - const_cast(target)->AddSource(*fileIt); - } + const_cast(target)->AddTracedSources(newRccFiles); } void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1277fc2..d30f2f5 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -180,7 +180,9 @@ public: std::vector CompileDefinitionsEntries; std::vector CompileDefinitionsBacktraces; std::vector CompileDefinitionsItems; - std::vector SourceEntries; + std::vector SourceEntries; + std::vector SourceBacktraces; + std::vector SourceItems; std::vector LinkImplementationPropertyEntries; void AddInterfaceEntries( @@ -448,7 +450,8 @@ void cmTarget::SetMakefile(cmMakefile* mf) void CreatePropertyGeneratorExpressions( std::vector const& entries, std::vector const& backtraces, - std::vector& items) + std::vector& items, + bool evaluateForBuildsystem = false) { std::vector::const_iterator btIt = backtraces.begin(); for (std::vector::const_iterator it = entries.begin(); @@ -456,6 +459,7 @@ void CreatePropertyGeneratorExpressions( { cmGeneratorExpression ge(*btIt); cmsys::auto_ptr cge = ge.Parse(*it); + cge->SetEvaluateForBuildsystem(evaluateForBuildsystem); items.push_back(new cmTargetInternals::TargetPropertyEntry(cge)); } } @@ -481,6 +485,11 @@ void cmTarget::Compute() this->Internal->CompileDefinitionsEntries, this->Internal->CompileDefinitionsBacktraces, this->Internal->CompileDefinitionsItems); + + CreatePropertyGeneratorExpressions( + this->Internal->SourceEntries, + this->Internal->SourceBacktraces, + this->Internal->SourceItems, true); } //---------------------------------------------------------------------------- @@ -733,13 +742,11 @@ void cmTarget::GetSourceFiles(std::vector &files, // for TARGET_OBJECTS instead for backwards compatibility with OLD // behavior of CMP0024 and CMP0026 only. - typedef cmTargetInternals::TargetPropertyEntry - TargetPropertyEntry; - for(std::vector::const_iterator + for(std::vector::const_iterator i = this->Internal->SourceEntries.begin(); i != this->Internal->SourceEntries.end(); ++i) { - std::string entry = (*i)->ge->GetInput(); + std::string const& entry = *i; std::vector items; cmSystemTools::ExpandListArgument(entry, items); @@ -781,7 +788,7 @@ void cmTarget::GetSourceFiles(std::vector &files, UNORDERED_SET uniqueSrcs; bool contextDependentDirectSources = processSources(this, - this->Internal->SourceEntries, + this->Internal->SourceItems, files, uniqueSrcs, &dagChecker, @@ -918,11 +925,12 @@ void cmTarget::AddTracedSources(std::vector const& srcs) this->Internal->SourceFilesMap.clear(); this->LinkImplementationLanguageIsContextDependent = true; cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + this->Internal->SourceEntries.push_back(srcFiles); + this->Internal->SourceBacktraces.push_back(lfbt); cmGeneratorExpression ge(lfbt); cmsys::auto_ptr cge = ge.Parse(srcFiles); - cge->SetEvaluateForBuildsystem(true); - this->Internal->SourceEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->SourceItems.push_back( + new cmTargetInternals::TargetPropertyEntry(cge)); } } @@ -958,11 +966,8 @@ void cmTarget::AddSources(std::vector const& srcs) this->Internal->SourceFilesMap.clear(); this->LinkImplementationLanguageIsContextDependent = true; cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - cmsys::auto_ptr cge = ge.Parse(srcFiles); - cge->SetEvaluateForBuildsystem(true); - this->Internal->SourceEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->SourceEntries.push_back(srcFiles); + this->Internal->SourceBacktraces.push_back(lfbt); } } @@ -1066,10 +1071,10 @@ public: } - bool operator()(cmTargetInternals::TargetPropertyEntry* entry) + bool operator()(std::string const& entry) { std::vector files; - cmSystemTools::ExpandListArgument(entry->ge->GetInput(), files); + cmSystemTools::ExpandListArgument(entry, files); std::vector locations(files.size()); std::transform(files.begin(), files.end(), locations.begin(), CreateLocation(this->Needle.GetMakefile())); @@ -1091,11 +1096,8 @@ cmSourceFile* cmTarget::AddSource(const std::string& src) this->Internal->SourceFilesMap.clear(); this->LinkImplementationLanguageIsContextDependent = true; cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - cmsys::auto_ptr cge = ge.Parse(src); - cge->SetEvaluateForBuildsystem(true); - this->Internal->SourceEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->SourceEntries.push_back(src); + this->Internal->SourceBacktraces.push_back(lfbt); } if (cmGeneratorExpression::Find(src) != std::string::npos) { @@ -1770,11 +1772,11 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) } this->Internal->SourceFilesMap.clear(); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); + this->Internal->SourceEntries.clear(); - cmsys::auto_ptr cge = ge.Parse(value); - this->Internal->SourceEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->SourceBacktraces.clear(); + this->Internal->SourceEntries.push_back(value); + this->Internal->SourceBacktraces.push_back(lfbt); } else { @@ -1855,10 +1857,8 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, } this->Internal->SourceFilesMap.clear(); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - cmsys::auto_ptr cge = ge.Parse(value); - this->Internal->SourceEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->SourceEntries.push_back(value); + this->Internal->SourceBacktraces.push_back(lfbt); } else { @@ -2983,13 +2983,11 @@ const char *cmTarget::GetProperty(const std::string& prop, std::ostringstream ss; const char* sep = ""; - typedef cmTargetInternals::TargetPropertyEntry - TargetPropertyEntry; - for(std::vector::const_iterator + for(std::vector::const_iterator i = this->Internal->SourceEntries.begin(); i != this->Internal->SourceEntries.end(); ++i) { - std::string entry = (*i)->ge->GetInput(); + std::string const& entry = *i; std::vector files; cmSystemTools::ExpandListArgument(entry, files); @@ -3689,13 +3687,11 @@ cmTarget::GetObjectLibrariesCMP0026(std::vector& objlibs) const // there is no cmGeneratorTarget at configure-time, so search the SOURCES // for TARGET_OBJECTS instead for backwards compatibility with OLD // behavior of CMP0024 and CMP0026 only. - typedef cmTargetInternals::TargetPropertyEntry - TargetPropertyEntry; - for(std::vector::const_iterator + for(std::vector::const_iterator i = this->Internal->SourceEntries.begin(); i != this->Internal->SourceEntries.end(); ++i) { - std::string entry = (*i)->ge->GetInput(); + std::string const& entry = *i; std::vector files; cmSystemTools::ExpandListArgument(entry, files); @@ -4832,7 +4828,7 @@ cmTargetInternalPointer::~cmTargetInternalPointer() cmDeleteAll(this->Pointer->CompileOptionsItems); cmDeleteAll(this->Pointer->CompileFeaturesItems); cmDeleteAll(this->Pointer->CompileDefinitionsItems); - cmDeleteAll(this->Pointer->SourceEntries); + cmDeleteAll(this->Pointer->SourceItems); delete this->Pointer; } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=197f4de110a59332757360110b1e90f6b07e1c97 commit 197f4de110a59332757360110b1e90f6b07e1c97 Author: Stephen Kelly AuthorDate: Tue Aug 4 21:30:17 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 17:06:19 2015 +0200 cmTarget: Split storage of compile definitions from genexes. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index cc1df84..1277fc2 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -177,7 +177,9 @@ public: std::vector CompileFeaturesEntries; std::vector CompileFeaturesBacktraces; std::vector CompileFeaturesItems; - std::vector CompileDefinitionsEntries; + std::vector CompileDefinitionsEntries; + std::vector CompileDefinitionsBacktraces; + std::vector CompileDefinitionsItems; std::vector SourceEntries; std::vector LinkImplementationPropertyEntries; @@ -474,6 +476,11 @@ void cmTarget::Compute() this->Internal->CompileFeaturesEntries, this->Internal->CompileFeaturesBacktraces, this->Internal->CompileFeaturesItems); + + CreatePropertyGeneratorExpressions( + this->Internal->CompileDefinitionsEntries, + this->Internal->CompileDefinitionsBacktraces, + this->Internal->CompileDefinitionsItems); } //---------------------------------------------------------------------------- @@ -1728,12 +1735,11 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) } else if(prop == "COMPILE_DEFINITIONS") { + this->Internal->CompileDefinitionsEntries.clear(); + this->Internal->CompileDefinitionsBacktraces.clear(); + this->Internal->CompileDefinitionsEntries.push_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - deleteAndClear(this->Internal->CompileDefinitionsEntries); - cmsys::auto_ptr cge = ge.Parse(value); - this->Internal->CompileDefinitionsEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->CompileDefinitionsBacktraces.push_back(lfbt); } else if(prop == "EXPORT_NAME" && this->IsImported()) { @@ -1817,10 +1823,9 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, } else if(prop == "COMPILE_DEFINITIONS") { + this->Internal->CompileDefinitionsEntries.push_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - this->Internal->CompileDefinitionsEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); + this->Internal->CompileDefinitionsBacktraces.push_back(lfbt); } else if(prop == "EXPORT_NAME" && this->IsImported()) { @@ -1952,10 +1957,8 @@ void cmTarget::InsertCompileOption(std::string const& entry, void cmTarget::InsertCompileDefinition(std::string const& entry, cmListFileBacktrace const& bt) { - cmGeneratorExpression ge(bt); - - this->Internal->CompileDefinitionsEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(ge.Parse(entry))); + this->Internal->CompileDefinitionsEntries.push_back(entry); + this->Internal->CompileDefinitionsBacktraces.push_back(bt); } //---------------------------------------------------------------------------- @@ -2337,7 +2340,7 @@ void cmTarget::GetCompileDefinitions(std::vector &list, } processCompileDefinitions(this, - this->Internal->CompileDefinitionsEntries, + this->Internal->CompileDefinitionsItems, list, uniqueOptions, &dagChecker, @@ -2745,22 +2748,6 @@ bool cmTarget::HandleLocationPropertyPolicy(cmMakefile* context) const } //---------------------------------------------------------------------------- -static void MakePropertyList(std::string& output, - std::vector const& values) -{ - output = ""; - std::string sep; - for (std::vector::const_iterator - it = values.begin(), end = values.end(); - it != end; ++it) - { - output += sep; - output += (*it)->ge->GetInput(); - sep = ";"; - } -} - -//---------------------------------------------------------------------------- const char *cmTarget::GetProperty(const std::string& prop) const { return this->GetProperty(prop, this->Makefile); @@ -2968,7 +2955,7 @@ const char *cmTarget::GetProperty(const std::string& prop, } static std::string output; - MakePropertyList(output, this->Internal->CompileDefinitionsEntries); + output = cmJoin(this->Internal->CompileDefinitionsEntries, ";"); return output.c_str(); } else if (prop == propIMPORTED) @@ -4844,7 +4831,7 @@ cmTargetInternalPointer::~cmTargetInternalPointer() cmDeleteAll(this->Pointer->IncludeDirectoriesItems); cmDeleteAll(this->Pointer->CompileOptionsItems); cmDeleteAll(this->Pointer->CompileFeaturesItems); - cmDeleteAll(this->Pointer->CompileDefinitionsEntries); + cmDeleteAll(this->Pointer->CompileDefinitionsItems); cmDeleteAll(this->Pointer->SourceEntries); delete this->Pointer; } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=44e071aeff4d533f116a7721919f9036c5d5a1d1 commit 44e071aeff4d533f116a7721919f9036c5d5a1d1 Author: Stephen Kelly AuthorDate: Tue Aug 4 21:23:38 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 17:06:18 2015 +0200 cmTarget: Split storage of compile features from genexes. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 09806e2..cc1df84 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -174,7 +174,9 @@ public: std::vector CompileOptionsEntries; std::vector CompileOptionsBacktraces; std::vector CompileOptionsItems; - std::vector CompileFeaturesEntries; + std::vector CompileFeaturesEntries; + std::vector CompileFeaturesBacktraces; + std::vector CompileFeaturesItems; std::vector CompileDefinitionsEntries; std::vector SourceEntries; std::vector LinkImplementationPropertyEntries; @@ -467,6 +469,11 @@ void cmTarget::Compute() this->Internal->CompileOptionsEntries, this->Internal->CompileOptionsBacktraces, this->Internal->CompileOptionsItems); + + CreatePropertyGeneratorExpressions( + this->Internal->CompileFeaturesEntries, + this->Internal->CompileFeaturesBacktraces, + this->Internal->CompileFeaturesItems); } //---------------------------------------------------------------------------- @@ -1713,12 +1720,11 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) } else if(prop == "COMPILE_FEATURES") { + this->Internal->CompileFeaturesEntries.clear(); + this->Internal->CompileFeaturesBacktraces.clear(); + this->Internal->CompileFeaturesEntries.push_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - deleteAndClear(this->Internal->CompileFeaturesEntries); - cmsys::auto_ptr cge = ge.Parse(value); - this->Internal->CompileFeaturesEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->CompileFeaturesBacktraces.push_back(lfbt); } else if(prop == "COMPILE_DEFINITIONS") { @@ -1805,10 +1811,9 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, } else if(prop == "COMPILE_FEATURES") { + this->Internal->CompileFeaturesEntries.push_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - this->Internal->CompileFeaturesEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); + this->Internal->CompileFeaturesBacktraces.push_back(lfbt); } else if(prop == "COMPILE_DEFINITIONS") { @@ -2433,7 +2438,7 @@ void cmTarget::GetCompileFeatures(std::vector &result, } processCompileFeatures(this, - this->Internal->CompileFeaturesEntries, + this->Internal->CompileFeaturesItems, result, uniqueFeatures, &dagChecker, @@ -2941,7 +2946,7 @@ const char *cmTarget::GetProperty(const std::string& prop, } static std::string output; - MakePropertyList(output, this->Internal->CompileFeaturesEntries); + output = cmJoin(this->Internal->CompileFeaturesEntries, ";"); return output.c_str(); } else if(prop == propCOMPILE_OPTIONS) @@ -4838,7 +4843,7 @@ cmTargetInternalPointer::~cmTargetInternalPointer() { cmDeleteAll(this->Pointer->IncludeDirectoriesItems); cmDeleteAll(this->Pointer->CompileOptionsItems); - cmDeleteAll(this->Pointer->CompileFeaturesEntries); + cmDeleteAll(this->Pointer->CompileFeaturesItems); cmDeleteAll(this->Pointer->CompileDefinitionsEntries); cmDeleteAll(this->Pointer->SourceEntries); delete this->Pointer; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=772ecef4b8037d5ce59d24772c05829872aff406 commit 772ecef4b8037d5ce59d24772c05829872aff406 Author: Stephen Kelly AuthorDate: Tue Aug 4 21:19:00 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 17:06:17 2015 +0200 cmTarget: Split storage of compile options from genexes. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1eb8e6a..09806e2 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -171,7 +171,9 @@ public: std::vector IncludeDirectoriesEntries; std::vector IncludeDirectoriesBacktraces; std::vector IncludeDirectoriesItems; - std::vector CompileOptionsEntries; + std::vector CompileOptionsEntries; + std::vector CompileOptionsBacktraces; + std::vector CompileOptionsItems; std::vector CompileFeaturesEntries; std::vector CompileDefinitionsEntries; std::vector SourceEntries; @@ -386,13 +388,12 @@ void cmTarget::SetMakefile(cmMakefile* mf) const cmBacktraceRange parentOptionsBts = this->Makefile->GetCompileOptionsBacktraces(); - cmBacktraceRange::const_iterator btIt = parentOptionsBts.begin(); - for (cmStringRange::const_iterator it - = parentOptions.begin(); - it != parentOptions.end(); ++it, ++btIt) - { - this->InsertCompileOption(*it, *btIt); - } + this->Internal->CompileOptionsEntries.insert( + this->Internal->CompileOptionsEntries.end(), + parentOptions.begin(), parentOptions.end()); + this->Internal->CompileOptionsBacktraces.insert( + this->Internal->CompileOptionsBacktraces.end(), + parentOptionsBts.begin(), parentOptionsBts.end()); } if (this->GetType() != INTERFACE_LIBRARY && this->GetType() != UTILITY) @@ -461,6 +462,11 @@ void cmTarget::Compute() this->Internal->IncludeDirectoriesEntries, this->Internal->IncludeDirectoriesBacktraces, this->Internal->IncludeDirectoriesItems); + + CreatePropertyGeneratorExpressions( + this->Internal->CompileOptionsEntries, + this->Internal->CompileOptionsBacktraces, + this->Internal->CompileOptionsItems); } //---------------------------------------------------------------------------- @@ -1699,12 +1705,11 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) } else if(prop == "COMPILE_OPTIONS") { + this->Internal->CompileOptionsEntries.clear(); + this->Internal->CompileOptionsBacktraces.clear(); + this->Internal->CompileOptionsEntries.push_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - deleteAndClear(this->Internal->CompileOptionsEntries); - cmsys::auto_ptr cge = ge.Parse(value); - this->Internal->CompileOptionsEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->CompileOptionsBacktraces.push_back(lfbt); } else if(prop == "COMPILE_FEATURES") { @@ -1794,10 +1799,9 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, } else if(prop == "COMPILE_OPTIONS") { + this->Internal->CompileOptionsEntries.push_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - this->Internal->CompileOptionsEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); + this->Internal->CompileOptionsBacktraces.push_back(lfbt); } else if(prop == "COMPILE_FEATURES") { @@ -1927,14 +1931,16 @@ void cmTarget::InsertCompileOption(std::string const& entry, cmListFileBacktrace const& bt, bool before) { - cmGeneratorExpression ge(bt); + std::vector::iterator position = + before ? this->Internal->CompileOptionsEntries.begin() + : this->Internal->CompileOptionsEntries.end(); - std::vector::iterator position - = before ? this->Internal->CompileOptionsEntries.begin() - : this->Internal->CompileOptionsEntries.end(); + std::vector::iterator btPosition = + before ? this->Internal->CompileOptionsBacktraces.begin() + : this->Internal->CompileOptionsBacktraces.end(); - this->Internal->CompileOptionsEntries.insert(position, - new cmTargetInternals::TargetPropertyEntry(ge.Parse(entry))); + this->Internal->CompileOptionsEntries.insert(position, entry); + this->Internal->CompileOptionsBacktraces.insert(btPosition, bt); } //---------------------------------------------------------------------------- @@ -2255,7 +2261,7 @@ void cmTarget::GetCompileOptions(std::vector &result, } processCompileOptions(this, - this->Internal->CompileOptionsEntries, + this->Internal->CompileOptionsItems, result, uniqueOptions, &dagChecker, @@ -2946,7 +2952,7 @@ const char *cmTarget::GetProperty(const std::string& prop, } static std::string output; - MakePropertyList(output, this->Internal->CompileOptionsEntries); + output = cmJoin(this->Internal->CompileOptionsEntries, ";"); return output.c_str(); } else if(prop == propCOMPILE_DEFINITIONS) @@ -4831,7 +4837,7 @@ cmTargetInternalPointer cmTargetInternalPointer::~cmTargetInternalPointer() { cmDeleteAll(this->Pointer->IncludeDirectoriesItems); - cmDeleteAll(this->Pointer->CompileOptionsEntries); + cmDeleteAll(this->Pointer->CompileOptionsItems); cmDeleteAll(this->Pointer->CompileFeaturesEntries); cmDeleteAll(this->Pointer->CompileDefinitionsEntries); cmDeleteAll(this->Pointer->SourceEntries); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1f54bc1cf35707a5f1410ff4c6632d7cba351c40 commit 1f54bc1cf35707a5f1410ff4c6632d7cba351c40 Author: Stephen Kelly AuthorDate: Tue Aug 4 20:25:02 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 17:06:15 2015 +0200 cmTarget: Split storage of include directories from genexes. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 3c818ff..50e2cd9 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1549,6 +1549,7 @@ void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes, ti != targets.end(); ++ti) { cmTarget* t = &ti->second; + t->Compute(); cmGeneratorTarget* gt = new cmGeneratorTarget(t, lg); this->GeneratorTargets[t] = gt; generatorTargets[t] = gt; diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index d5a5585..51dcab0 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -254,6 +254,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() mf->AddUtilityCommand(CMAKE_CHECK_BUILD_SYSTEM_TARGET, false, no_working_directory, no_depends, noCommandLines); + tgt->Compute(); cmGeneratorTarget* gt = new cmGeneratorTarget(tgt, lg); mf->AddGeneratorTarget(tgt, gt); diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 2f9d79a..b69fc65 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -90,6 +90,7 @@ bool cmGlobalVisualStudioGenerator::Compute() AddUtilityCommand("ALL_BUILD", true, no_working_dir, no_depends, no_commands, false, "Build all projects"); + allBuild->Compute(); cmGeneratorTarget* gt = new cmGeneratorTarget(allBuild, gen[0]); allBuild->GetMakefile()->AddGeneratorTarget(allBuild, gt); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 5006828..39933cb 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -463,6 +463,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, cmTarget* allbuild = mf->AddUtilityCommand("ALL_BUILD", true, no_depends, no_working_directory, "echo", "Build all projects"); + allbuild->Compute(); cmGeneratorTarget* allBuildGt = new cmGeneratorTarget(allbuild, root); mf->AddGeneratorTarget(allbuild, allBuildGt); @@ -497,6 +498,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, true, no_depends, no_working_directory, "make", "-f", file.c_str()); + check->Compute(); cmGeneratorTarget* checkGt = new cmGeneratorTarget(check, root); mf->AddGeneratorTarget(check, checkGt); } diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index f1ba2f4..ce806ba 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -475,6 +475,8 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg, /*byproducts=*/rcc_output, depends, commandLines, false, autogenComment.c_str()); + autogenTarget->Compute(); + cmGeneratorTarget* gt = new cmGeneratorTarget(autogenTarget, lg); makefile->AddGeneratorTarget(autogenTarget, gt); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 7b25819..1eb8e6a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -168,7 +168,9 @@ public: const cmsys::auto_ptr ge; cmLinkImplItem const& LinkImplItem; }; - std::vector IncludeDirectoriesEntries; + std::vector IncludeDirectoriesEntries; + std::vector IncludeDirectoriesBacktraces; + std::vector IncludeDirectoriesItems; std::vector CompileOptionsEntries; std::vector CompileFeaturesEntries; std::vector CompileDefinitionsEntries; @@ -366,13 +368,13 @@ void cmTarget::SetMakefile(cmMakefile* mf) const cmBacktraceRange parentIncludesBts = this->Makefile->GetIncludeDirectoriesBacktraces(); - cmBacktraceRange::const_iterator btIt = parentIncludesBts.begin(); - for (cmStringRange::const_iterator it - = parentIncludes.begin(); - it != parentIncludes.end(); ++it, ++btIt) - { - this->InsertInclude(*it, *btIt); - } + this->Internal->IncludeDirectoriesEntries.insert( + this->Internal->IncludeDirectoriesEntries.end(), + parentIncludes.begin(), parentIncludes.end()); + this->Internal->IncludeDirectoriesBacktraces.insert( + this->Internal->IncludeDirectoriesBacktraces.end(), + parentIncludesBts.begin(), parentIncludesBts.end()); + const std::set parentSystemIncludes = this->Makefile->GetSystemIncludeDirectories(); @@ -384,7 +386,7 @@ void cmTarget::SetMakefile(cmMakefile* mf) const cmBacktraceRange parentOptionsBts = this->Makefile->GetCompileOptionsBacktraces(); - btIt = parentOptionsBts.begin(); + cmBacktraceRange::const_iterator btIt = parentOptionsBts.begin(); for (cmStringRange::const_iterator it = parentOptions.begin(); it != parentOptions.end(); ++it, ++btIt) @@ -438,6 +440,29 @@ void cmTarget::SetMakefile(cmMakefile* mf) } } +void CreatePropertyGeneratorExpressions( + std::vector const& entries, + std::vector const& backtraces, + std::vector& items) +{ + std::vector::const_iterator btIt = backtraces.begin(); + for (std::vector::const_iterator it = entries.begin(); + it != entries.end(); ++it, ++btIt) + { + cmGeneratorExpression ge(*btIt); + cmsys::auto_ptr cge = ge.Parse(*it); + items.push_back(new cmTargetInternals::TargetPropertyEntry(cge)); + } +} + +void cmTarget::Compute() +{ + CreatePropertyGeneratorExpressions( + this->Internal->IncludeDirectoriesEntries, + this->Internal->IncludeDirectoriesBacktraces, + this->Internal->IncludeDirectoriesItems); +} + //---------------------------------------------------------------------------- void cmTarget::AddUtility(const std::string& u, cmMakefile *makefile) { @@ -1666,12 +1691,11 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) } else if(prop == "INCLUDE_DIRECTORIES") { + this->Internal->IncludeDirectoriesEntries.clear(); + this->Internal->IncludeDirectoriesBacktraces.clear(); + this->Internal->IncludeDirectoriesEntries.push_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - deleteAndClear(this->Internal->IncludeDirectoriesEntries); - cmsys::auto_ptr cge = ge.Parse(value); - this->Internal->IncludeDirectoriesEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->IncludeDirectoriesBacktraces.push_back(lfbt); } else if(prop == "COMPILE_OPTIONS") { @@ -1764,10 +1788,9 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, } else if(prop == "INCLUDE_DIRECTORIES") { + this->Internal->IncludeDirectoriesEntries.push_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - this->Internal->IncludeDirectoriesEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); + this->Internal->IncludeDirectoriesBacktraces.push_back(lfbt); } else if(prop == "COMPILE_OPTIONS") { @@ -1887,14 +1910,16 @@ void cmTarget::InsertInclude(std::string const& entry, cmListFileBacktrace const& bt, bool before) { - cmGeneratorExpression ge(bt); + std::vector::iterator position = + before ? this->Internal->IncludeDirectoriesEntries.begin() + : this->Internal->IncludeDirectoriesEntries.end(); - std::vector::iterator position - = before ? this->Internal->IncludeDirectoriesEntries.begin() - : this->Internal->IncludeDirectoriesEntries.end(); + std::vector::iterator btPosition = + before ? this->Internal->IncludeDirectoriesBacktraces.begin() + : this->Internal->IncludeDirectoriesBacktraces.end(); - this->Internal->IncludeDirectoriesEntries.insert(position, - new cmTargetInternals::TargetPropertyEntry(ge.Parse(entry))); + this->Internal->IncludeDirectoriesEntries.insert(position, entry); + this->Internal->IncludeDirectoriesBacktraces.insert(btPosition, bt); } //---------------------------------------------------------------------------- @@ -2083,7 +2108,7 @@ cmTarget::GetIncludeDirectories(const std::string& config, } processIncludeDirectories(this, - this->Internal->IncludeDirectoriesEntries, + this->Internal->IncludeDirectoriesItems, includes, uniqueIncludes, &dagChecker, @@ -2899,7 +2924,7 @@ const char *cmTarget::GetProperty(const std::string& prop, } static std::string output; - MakePropertyList(output, this->Internal->IncludeDirectoriesEntries); + output = cmJoin(this->Internal->IncludeDirectoriesEntries, ";"); return output.c_str(); } else if(prop == propCOMPILE_FEATURES) @@ -4805,7 +4830,7 @@ cmTargetInternalPointer //---------------------------------------------------------------------------- cmTargetInternalPointer::~cmTargetInternalPointer() { - cmDeleteAll(this->Pointer->IncludeDirectoriesEntries); + cmDeleteAll(this->Pointer->IncludeDirectoriesItems); cmDeleteAll(this->Pointer->CompileOptionsEntries); cmDeleteAll(this->Pointer->CompileFeaturesEntries); cmDeleteAll(this->Pointer->CompileDefinitionsEntries); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index c5918ba..490aaa3 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -132,6 +132,8 @@ public: void AddPostBuildCommand(cmCustomCommand const &cmd) {this->PostBuildCommands.push_back(cmd);} + void Compute(); + /** * Get the list of the source files used by this target */ http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7568199b4de18ed56ad8ef735c145c4a44327355 commit 7568199b4de18ed56ad8ef735c145c4a44327355 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:22:30 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 17:06:15 2015 +0200 cmTarget: Request only the link libraries where needed. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1d4313e..7b25819 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2099,7 +2099,8 @@ cmTarget::GetIncludeDirectories(const std::string& config, if(this->Makefile->IsOn("APPLE")) { - LinkImplementation const* impl = this->GetLinkImplementation(config); + cmLinkImplementationLibraries const* impl = + this->GetLinkImplementationLibraries(config); for(std::vector::const_iterator it = impl->Libraries.begin(); it != impl->Libraries.end(); ++it) ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From chuck.atkins at kitware.com Fri Aug 7 15:46:23 2015 From: chuck.atkins at kitware.com (Chuck Atkins) Date: Fri, 7 Aug 2015 15:46:23 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2096-gf08cc08 Message-ID: <20150807194623.C104CB0870@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via f08cc08dc647b09d2b5d6e0f681bd551c957db97 (commit) via 7ba7ce98d5f19b64c44d731344fdef26317cd69c (commit) via 3cefadbff07d68c5a6846835ea87cc35eae55a0b (commit) from 010f4f8c6a8e6d45d7f49aa083d12f65de714557 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f08cc08dc647b09d2b5d6e0f681bd551c957db97 commit f08cc08dc647b09d2b5d6e0f681bd551c957db97 Merge: 010f4f8 7ba7ce9 Author: Chuck Atkins AuthorDate: Fri Aug 7 15:46:22 2015 -0400 Commit: CMake Topic Stage CommitDate: Fri Aug 7 15:46:22 2015 -0400 Merge topic 'add-global-link-static-properties' into next 7ba7ce98 Allow LINK_SEARCH_{START,END}_STATIC props to have default values. 3cefadbf CMake Nightly Date Stamp http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7ba7ce98d5f19b64c44d731344fdef26317cd69c commit 7ba7ce98d5f19b64c44d731344fdef26317cd69c Author: Chuck Atkins AuthorDate: Fri Aug 7 15:11:57 2015 -0400 Commit: Chuck Atkins CommitDate: Fri Aug 7 15:27:30 2015 -0400 Allow LINK_SEARCH_{START,END}_STATIC props to have default values. Use the CMAKE_LINK_SEARCH_START_STATIC and CMAKE_LINK_SEARCH_END_STATIC variables to initialize the LINK_SEARCH_START_STATIC and LINK_SEARCH_END_STATIC target properties respectively. diff --git a/Help/prop_tgt/LINK_SEARCH_END_STATIC.rst b/Help/prop_tgt/LINK_SEARCH_END_STATIC.rst index fe105bd..cf9c871 100644 --- a/Help/prop_tgt/LINK_SEARCH_END_STATIC.rst +++ b/Help/prop_tgt/LINK_SEARCH_END_STATIC.rst @@ -10,5 +10,9 @@ paths are not known or (in some cases) are in implicit link directories for the platform. By default CMake adds an option at the end of the library list (if necessary) to set the linker search type back to its starting type. This property switches the final linker -search type to -Bstatic regardless of how it started. See also -LINK_SEARCH_START_STATIC. +search type to -Bstatic regardless of how it started. + +This property is initialized by the value of the variable +CMAKE_LINK_SEARCH_END_STATIC if it is set when a target is created. + +See also LINK_SEARCH_START_STATIC. diff --git a/Help/prop_tgt/LINK_SEARCH_START_STATIC.rst b/Help/prop_tgt/LINK_SEARCH_START_STATIC.rst index ca899fe..2e0f9bd 100644 --- a/Help/prop_tgt/LINK_SEARCH_START_STATIC.rst +++ b/Help/prop_tgt/LINK_SEARCH_START_STATIC.rst @@ -11,4 +11,9 @@ directories for the platform. By default the linker search type is assumed to be -Bdynamic at the beginning of the library list. This property switches the assumption to -Bstatic. It is intended for use when linking an executable statically (e.g. with the GNU -static -option). See also LINK_SEARCH_END_STATIC. +option). + +This property is initialized by the value of the variable +CMAKE_LINK_SEARCH_START_STATIC if it is set when a target is created. + +See also LINK_SEARCH_END_STATIC. diff --git a/Help/prop_tgt/LINK_SEARCH_END_STATIC.rst b/Help/variable/CMAKE_LINK_SEARCH_END_STATIC.rst similarity index 68% copy from Help/prop_tgt/LINK_SEARCH_END_STATIC.rst copy to Help/variable/CMAKE_LINK_SEARCH_END_STATIC.rst index fe105bd..8a9951d 100644 --- a/Help/prop_tgt/LINK_SEARCH_END_STATIC.rst +++ b/Help/variable/CMAKE_LINK_SEARCH_END_STATIC.rst @@ -1,5 +1,5 @@ -LINK_SEARCH_END_STATIC ----------------------- +CMAKE_LINK_SEARCH_END_STATIC +---------------------------- End a link line such that static system libraries are used. @@ -10,5 +10,9 @@ paths are not known or (in some cases) are in implicit link directories for the platform. By default CMake adds an option at the end of the library list (if necessary) to set the linker search type back to its starting type. This property switches the final linker -search type to -Bstatic regardless of how it started. See also -LINK_SEARCH_START_STATIC. +search type to -Bstatic regardless of how it started. + +This variable is used to initialize the target property +LINK_SEARCH_END_STATIC for all targets. + +See also CMAKE_LINK_SEARCH_START_STATIC. diff --git a/Help/prop_tgt/LINK_SEARCH_START_STATIC.rst b/Help/variable/CMAKE_LINK_SEARCH_START_STATIC.rst similarity index 73% copy from Help/prop_tgt/LINK_SEARCH_START_STATIC.rst copy to Help/variable/CMAKE_LINK_SEARCH_START_STATIC.rst index ca899fe..715db4b 100644 --- a/Help/prop_tgt/LINK_SEARCH_START_STATIC.rst +++ b/Help/variable/CMAKE_LINK_SEARCH_START_STATIC.rst @@ -1,5 +1,5 @@ -LINK_SEARCH_START_STATIC ------------------------- +CMAKE_LINK_SEARCH_START_STATIC +------------------------------ Assume the linker looks for static libraries by default. @@ -11,4 +11,9 @@ directories for the platform. By default the linker search type is assumed to be -Bdynamic at the beginning of the library list. This property switches the assumption to -Bstatic. It is intended for use when linking an executable statically (e.g. with the GNU -static -option). See also LINK_SEARCH_END_STATIC. +option). + +This variable is used to initialize the target property +LINK_SEARCH_START_STATIC for all targets. + +See also CMAKE_LINK_SEARCH_END_STATIC. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index c3f36af..dff223f 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -520,9 +520,10 @@ bool cmComputeLinkInformation::Compute() // libraries are found. const char* lss = this->Target->Target->GetProperty("LINK_SEARCH_END_STATIC"); - if(cmSystemTools::IsOn(lss)) + if(lss) { - this->SetCurrentLinkType(LinkStatic); + this->SetCurrentLinkType( + cmSystemTools::IsOn(lss) ? LinkStatic : LinkShared); } else { @@ -864,7 +865,8 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo() const char* lss = this->Target->Target->GetProperty("LINK_SEARCH_START_STATIC"); this->StartLinkType = cmSystemTools::IsOn(lss)? LinkStatic : LinkShared; - this->CurrentLinkType = this->StartLinkType; + this->CurrentLinkType = LinkUnknown; + this->SetCurrentLinkType(this->StartLinkType); } //---------------------------------------------------------------------------- diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1f8f07a..51e6a66 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -306,6 +306,8 @@ void cmTarget::SetMakefile(cmMakefile* mf) this->SetPropertyDefault("CXX_STANDARD", 0); this->SetPropertyDefault("CXX_STANDARD_REQUIRED", 0); this->SetPropertyDefault("CXX_EXTENSIONS", 0); + this->SetPropertyDefault("LINK_SEARCH_START_STATIC", 0); + this->SetPropertyDefault("LINK_SEARCH_END_STATIC", 0); } // Collect the set of configuration types. diff --git a/Tests/LinkStatic/CMakeLists.txt b/Tests/LinkStatic/CMakeLists.txt index 200d4e5..264c85f 100644 --- a/Tests/LinkStatic/CMakeLists.txt +++ b/Tests/LinkStatic/CMakeLists.txt @@ -25,3 +25,39 @@ set(LinkStatic_FLAG "-static" CACHE STRING "Flag to link statically") set_property(TARGET LinkStatic PROPERTY LINK_FLAGS "${LinkStatic_FLAG}") set_property(TARGET LinkStatic PROPERTY LINK_SEARCH_START_STATIC 1) #set_property(TARGET LinkStatic PROPERTY LINK_SEARCH_END_STATIC 1) # insufficient + +set(CMAKE_LINK_SEARCH_START_STATIC ON) +add_executable(LinkStaticInitStart1 LinkStatic.c) +get_property(LSSS TARGET LinkStaticInitStart1 + PROPERTY LINK_SEARCH_START_STATIC) +if(NOT LSSS) + message(FATAL_ERROR "Failed to correctly initialize LINK_SEARCH_START_STATIC") +endif() + +set(CMAKE_LINK_SEARCH_START_STATIC OFF) +add_executable(LinkStaticInitStart2 LinkStatic.c) +get_property(LSSS TARGET LinkStaticInitStart2 + PROPERTY LINK_SEARCH_START_STATIC) +if(LSSS) + message(FATAL_ERROR "Failed to correctly initialize LINK_SEARCH_START_STATIC") +endif() + +unset(CMAKE_LINK_SEARCH_START_STATIC) + +set(CMAKE_LINK_SEARCH_END_STATIC ON) +add_executable(LinkStaticInitEnd1 LinkStatic.c) +get_property(LSES TARGET LinkStaticInitEnd1 + PROPERTY LINK_SEARCH_END_STATIC) +if(NOT LSES) + message(FATAL_ERROR "Failed to correctly initialize LINK_SEARCH_END_STATIC") +endif() + +set(CMAKE_LINK_SEARCH_END_STATIC OFF) +add_executable(LinkStaticInitEnd2 LinkStatic.c) +get_property(LSES TARGET LinkStaticInitEnd2 + PROPERTY LINK_SEARCH_END_STATIC) +if(LSES) + message(FATAL_ERROR "Failed to correctly initialize LINK_SEARCH_END_STATIC") +endif() + +unset(CMAKE_LINK_SEARCH_END_STATIC) ----------------------------------------------------------------------- Summary of changes: Help/prop_tgt/LINK_SEARCH_END_STATIC.rst | 8 +++-- Help/prop_tgt/LINK_SEARCH_START_STATIC.rst | 7 +++- .../CMAKE_LINK_SEARCH_END_STATIC.rst} | 12 ++++--- .../CMAKE_LINK_SEARCH_START_STATIC.rst} | 11 ++++-- Source/CMakeVersion.cmake | 2 +- Source/cmComputeLinkInformation.cxx | 8 +++-- Source/cmTarget.cxx | 2 ++ Tests/LinkStatic/CMakeLists.txt | 36 ++++++++++++++++++++ 8 files changed, 72 insertions(+), 14 deletions(-) copy Help/{prop_tgt/LINK_SEARCH_END_STATIC.rst => variable/CMAKE_LINK_SEARCH_END_STATIC.rst} (68%) copy Help/{prop_tgt/LINK_SEARCH_START_STATIC.rst => variable/CMAKE_LINK_SEARCH_START_STATIC.rst} (73%) hooks/post-receive -- CMake From steveire at gmail.com Fri Aug 7 15:55:06 2015 From: steveire at gmail.com (Stephen Kelly) Date: Fri, 7 Aug 2015 15:55:06 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2098-g67df5c9 Message-ID: <20150807195506.42E7DB0EE1@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 67df5c9aeee85453af8e53562b97f21dd4a40c55 (commit) via 6e13042cec7ca40cdb1a52ae92ccb6693bcba53b (commit) from f08cc08dc647b09d2b5d6e0f681bd551c957db97 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=67df5c9aeee85453af8e53562b97f21dd4a40c55 commit 67df5c9aeee85453af8e53562b97f21dd4a40c55 Merge: f08cc08 6e13042 Author: Stephen Kelly AuthorDate: Fri Aug 7 15:55:05 2015 -0400 Commit: CMake Topic Stage CommitDate: Fri Aug 7 15:55:05 2015 -0400 Merge topic 'use-generator-target' into next 6e13042c Revert "cmTarget: Split storage of sources from genexes." http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6e13042cec7ca40cdb1a52ae92ccb6693bcba53b commit 6e13042cec7ca40cdb1a52ae92ccb6693bcba53b Author: Stephen Kelly AuthorDate: Fri Aug 7 21:54:31 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 21:54:31 2015 +0200 Revert "cmTarget: Split storage of sources from genexes." This reverts commit 3bbd5425d31e179dbb1b70d944ac24523b0eb46b. diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index b094125..ce806ba 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -313,9 +313,7 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg, makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", mocCppFile.c_str(), false); - std::vector mocCppFiles; - mocCppFiles.push_back(mocCppFile); - target->AddTracedSources(mocCppFiles); + target->AddSource(mocCppFile); } // create a custom target for running generators at buildtime: std::string autogenTargetName = getAutogenTargetName(target); @@ -739,7 +737,12 @@ void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target) } } - const_cast(target)->AddTracedSources(newRccFiles); + for(std::vector::const_iterator fileIt = newRccFiles.begin(); + fileIt != newRccFiles.end(); + ++fileIt) + { + const_cast(target)->AddSource(*fileIt); + } } void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index f1a05ff..d3170e4 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -180,9 +180,7 @@ public: std::vector CompileDefinitionsEntries; std::vector CompileDefinitionsBacktraces; std::vector CompileDefinitionsItems; - std::vector SourceEntries; - std::vector SourceBacktraces; - std::vector SourceItems; + std::vector SourceEntries; std::vector LinkImplementationPropertyEntries; void AddInterfaceEntries( @@ -442,8 +440,7 @@ void cmTarget::SetMakefile(cmMakefile* mf) void CreatePropertyGeneratorExpressions( std::vector const& entries, std::vector const& backtraces, - std::vector& items, - bool evaluateForBuildsystem = false) + std::vector& items) { std::vector::const_iterator btIt = backtraces.begin(); for (std::vector::const_iterator it = entries.begin(); @@ -451,7 +448,6 @@ void CreatePropertyGeneratorExpressions( { cmGeneratorExpression ge(*btIt); cmsys::auto_ptr cge = ge.Parse(*it); - cge->SetEvaluateForBuildsystem(evaluateForBuildsystem); items.push_back(new cmTargetInternals::TargetPropertyEntry(cge)); } } @@ -477,11 +473,6 @@ void cmTarget::Compute() this->Internal->CompileDefinitionsEntries, this->Internal->CompileDefinitionsBacktraces, this->Internal->CompileDefinitionsItems); - - CreatePropertyGeneratorExpressions( - this->Internal->SourceEntries, - this->Internal->SourceBacktraces, - this->Internal->SourceItems, true); } //---------------------------------------------------------------------------- @@ -734,11 +725,13 @@ void cmTarget::GetSourceFiles(std::vector &files, // for TARGET_OBJECTS instead for backwards compatibility with OLD // behavior of CMP0024 and CMP0026 only. - for(std::vector::const_iterator + typedef cmTargetInternals::TargetPropertyEntry + TargetPropertyEntry; + for(std::vector::const_iterator i = this->Internal->SourceEntries.begin(); i != this->Internal->SourceEntries.end(); ++i) { - std::string const& entry = *i; + std::string entry = (*i)->ge->GetInput(); std::vector items; cmSystemTools::ExpandListArgument(entry, items); @@ -780,7 +773,7 @@ void cmTarget::GetSourceFiles(std::vector &files, UNORDERED_SET uniqueSrcs; bool contextDependentDirectSources = processSources(this, - this->Internal->SourceItems, + this->Internal->SourceEntries, files, uniqueSrcs, &dagChecker, @@ -917,12 +910,11 @@ void cmTarget::AddTracedSources(std::vector const& srcs) this->Internal->SourceFilesMap.clear(); this->LinkImplementationLanguageIsContextDependent = true; cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->Internal->SourceEntries.push_back(srcFiles); - this->Internal->SourceBacktraces.push_back(lfbt); cmGeneratorExpression ge(lfbt); cmsys::auto_ptr cge = ge.Parse(srcFiles); - this->Internal->SourceItems.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + cge->SetEvaluateForBuildsystem(true); + this->Internal->SourceEntries.push_back( + new cmTargetInternals::TargetPropertyEntry(cge)); } } @@ -958,8 +950,11 @@ void cmTarget::AddSources(std::vector const& srcs) this->Internal->SourceFilesMap.clear(); this->LinkImplementationLanguageIsContextDependent = true; cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->Internal->SourceEntries.push_back(srcFiles); - this->Internal->SourceBacktraces.push_back(lfbt); + cmGeneratorExpression ge(lfbt); + cmsys::auto_ptr cge = ge.Parse(srcFiles); + cge->SetEvaluateForBuildsystem(true); + this->Internal->SourceEntries.push_back( + new cmTargetInternals::TargetPropertyEntry(cge)); } } @@ -1063,10 +1058,10 @@ public: } - bool operator()(std::string const& entry) + bool operator()(cmTargetInternals::TargetPropertyEntry* entry) { std::vector files; - cmSystemTools::ExpandListArgument(entry, files); + cmSystemTools::ExpandListArgument(entry->ge->GetInput(), files); std::vector locations(files.size()); std::transform(files.begin(), files.end(), locations.begin(), CreateLocation(this->Needle.GetMakefile())); @@ -1088,8 +1083,11 @@ cmSourceFile* cmTarget::AddSource(const std::string& src) this->Internal->SourceFilesMap.clear(); this->LinkImplementationLanguageIsContextDependent = true; cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->Internal->SourceEntries.push_back(src); - this->Internal->SourceBacktraces.push_back(lfbt); + cmGeneratorExpression ge(lfbt); + cmsys::auto_ptr cge = ge.Parse(src); + cge->SetEvaluateForBuildsystem(true); + this->Internal->SourceEntries.push_back( + new cmTargetInternals::TargetPropertyEntry(cge)); } if (cmGeneratorExpression::Find(src) != std::string::npos) { @@ -1764,11 +1762,11 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) } this->Internal->SourceFilesMap.clear(); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - + cmGeneratorExpression ge(lfbt); this->Internal->SourceEntries.clear(); - this->Internal->SourceBacktraces.clear(); - this->Internal->SourceEntries.push_back(value); - this->Internal->SourceBacktraces.push_back(lfbt); + cmsys::auto_ptr cge = ge.Parse(value); + this->Internal->SourceEntries.push_back( + new cmTargetInternals::TargetPropertyEntry(cge)); } else { @@ -1849,8 +1847,10 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, } this->Internal->SourceFilesMap.clear(); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->Internal->SourceEntries.push_back(value); - this->Internal->SourceBacktraces.push_back(lfbt); + cmGeneratorExpression ge(lfbt); + cmsys::auto_ptr cge = ge.Parse(value); + this->Internal->SourceEntries.push_back( + new cmTargetInternals::TargetPropertyEntry(cge)); } else { @@ -2975,11 +2975,13 @@ const char *cmTarget::GetProperty(const std::string& prop, std::ostringstream ss; const char* sep = ""; - for(std::vector::const_iterator + typedef cmTargetInternals::TargetPropertyEntry + TargetPropertyEntry; + for(std::vector::const_iterator i = this->Internal->SourceEntries.begin(); i != this->Internal->SourceEntries.end(); ++i) { - std::string const& entry = *i; + std::string entry = (*i)->ge->GetInput(); std::vector files; cmSystemTools::ExpandListArgument(entry, files); @@ -3679,11 +3681,13 @@ cmTarget::GetObjectLibrariesCMP0026(std::vector& objlibs) const // there is no cmGeneratorTarget at configure-time, so search the SOURCES // for TARGET_OBJECTS instead for backwards compatibility with OLD // behavior of CMP0024 and CMP0026 only. - for(std::vector::const_iterator + typedef cmTargetInternals::TargetPropertyEntry + TargetPropertyEntry; + for(std::vector::const_iterator i = this->Internal->SourceEntries.begin(); i != this->Internal->SourceEntries.end(); ++i) { - std::string const& entry = *i; + std::string entry = (*i)->ge->GetInput(); std::vector files; cmSystemTools::ExpandListArgument(entry, files); @@ -4820,7 +4824,7 @@ cmTargetInternalPointer::~cmTargetInternalPointer() cmDeleteAll(this->Pointer->CompileOptionsItems); cmDeleteAll(this->Pointer->CompileFeaturesItems); cmDeleteAll(this->Pointer->CompileDefinitionsItems); - cmDeleteAll(this->Pointer->SourceItems); + cmDeleteAll(this->Pointer->SourceEntries); delete this->Pointer; } ----------------------------------------------------------------------- Summary of changes: Source/cmQtAutoGenerators.cxx | 11 +++--- Source/cmTarget.cxx | 74 ++++++++++++++++++++++------------------- 2 files changed, 46 insertions(+), 39 deletions(-) hooks/post-receive -- CMake From steveire at gmail.com Fri Aug 7 15:55:29 2015 From: steveire at gmail.com (Stephen Kelly) Date: Fri, 7 Aug 2015 15:55:29 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2100-gfef2009 Message-ID: <20150807195529.50938B0F42@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via fef2009bd53ee5089d51ff253d603097a9dfebab (commit) via 29886ce76482a8c857841015b58d1e91a9ee5c8e (commit) from 67df5c9aeee85453af8e53562b97f21dd4a40c55 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fef2009bd53ee5089d51ff253d603097a9dfebab commit fef2009bd53ee5089d51ff253d603097a9dfebab Merge: 67df5c9 29886ce Author: Stephen Kelly AuthorDate: Fri Aug 7 15:55:28 2015 -0400 Commit: CMake Topic Stage CommitDate: Fri Aug 7 15:55:28 2015 -0400 Merge topic 'use-generator-target' into next 29886ce7 cmTarget: Use a simpler delete algorithm. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=29886ce76482a8c857841015b58d1e91a9ee5c8e commit 29886ce76482a8c857841015b58d1e91a9ee5c8e Author: Stephen Kelly AuthorDate: Tue Aug 4 23:16:12 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 7 21:55:17 2015 +0200 cmTarget: Use a simpler delete algorithm. This way, the methods can be moved without requiring a local algorithm. The containers use automatic storage. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1277fc2..d3170e4 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -191,14 +191,6 @@ public: cmLinkImplItem cmTargetInternals::TargetPropertyEntry::NoLinkImplItem; //---------------------------------------------------------------------------- -static void deleteAndClear( - std::vector &entries) -{ - cmDeleteAll(entries); - entries.clear(); -} - -//---------------------------------------------------------------------------- cmTargetInternals::~cmTargetInternals() { } @@ -810,7 +802,7 @@ void cmTarget::GetSourceFiles(std::vector &files, this->LinkImplementationLanguageIsContextDependent = false; } - deleteAndClear(linkInterfaceSourcesEntries); + cmDeleteAll(linkInterfaceSourcesEntries); } //---------------------------------------------------------------------------- @@ -2172,7 +2164,7 @@ cmTarget::GetIncludeDirectories(const std::string& config, debugIncludes, language); - deleteAndClear(linkInterfaceIncludeDirectoriesEntries); + cmDeleteAll(linkInterfaceIncludeDirectoriesEntries); return includes; } @@ -2293,7 +2285,7 @@ void cmTarget::GetCompileOptions(std::vector &result, debugOptions, language); - deleteAndClear(linkInterfaceCompileOptionsEntries); + cmDeleteAll(linkInterfaceCompileOptionsEntries); } //---------------------------------------------------------------------------- @@ -2395,7 +2387,7 @@ void cmTarget::GetCompileDefinitions(std::vector &list, debugDefines, language); - deleteAndClear(linkInterfaceCompileDefinitionsEntries); + cmDeleteAll(linkInterfaceCompileDefinitionsEntries); } //---------------------------------------------------------------------------- @@ -2462,7 +2454,7 @@ void cmTarget::GetCompileFeatures(std::vector &result, config, debugFeatures); - deleteAndClear(linkInterfaceCompileFeaturesEntries); + cmDeleteAll(linkInterfaceCompileFeaturesEntries); } //---------------------------------------------------------------------------- ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From kwrobot at kitware.com Sat Aug 8 00:01:10 2015 From: kwrobot at kitware.com (Kitware Robot) Date: Sat, 8 Aug 2015 00:01:10 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-762-g101ba25 Message-ID: <20150808040110.67B2BB12FF@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 101ba25e6a2c177f9f3a81f3879a171256806756 (commit) from 3cefadbff07d68c5a6846835ea87cc35eae55a0b (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=101ba25e6a2c177f9f3a81f3879a171256806756 commit 101ba25e6a2c177f9f3a81f3879a171256806756 Author: Kitware Robot AuthorDate: Sat Aug 8 00:01:08 2015 -0400 Commit: Kitware Robot CommitDate: Sat Aug 8 00:01:08 2015 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 533a881..e982b81 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150807) +set(CMake_VERSION_PATCH 20150808) #set(CMake_VERSION_RC 1) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From johnstonj.public at codenest.com Sat Aug 8 01:27:55 2015 From: johnstonj.public at codenest.com (James Johnston) Date: Sat, 8 Aug 2015 01:27:55 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2103-g9b72aec Message-ID: <20150808052755.16343B1072@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 9b72aec7b3624b6bb8e409e52a29263591856f81 (commit) via 203b20df98512094cc74061fd1b76e87bd2d3afb (commit) via b28b07db47b181718643399bd2aedc3e6d1b29c4 (commit) from fef2009bd53ee5089d51ff253d603097a9dfebab (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9b72aec7b3624b6bb8e409e52a29263591856f81 commit 9b72aec7b3624b6bb8e409e52a29263591856f81 Merge: fef2009 203b20d Author: James Johnston AuthorDate: Sat Aug 8 01:27:54 2015 -0400 Commit: CMake Topic Stage CommitDate: Sat Aug 8 01:27:54 2015 -0400 Merge topic 'fix-process-error-handling' into next 203b20df cmcmd: Improve error handling when executing a process. b28b07db cmCTestCoverageHandle: Improve error handling. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=203b20df98512094cc74061fd1b76e87bd2d3afb commit 203b20df98512094cc74061fd1b76e87bd2d3afb Author: James Johnston AuthorDate: Sat Aug 8 01:06:27 2015 -0400 Commit: James Johnston CommitDate: Sat Aug 8 01:06:27 2015 -0400 cmcmd: Improve error handling when executing a process. diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 71f47f3..7bee0ea 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -1468,18 +1468,24 @@ bool cmcmd::RunCommand(const char* comment, std::string output; int retCode =0; // use rc command to create .res file - cmSystemTools::RunSingleCommand(command, - &output, &output, - &retCode, 0, cmSystemTools::OUTPUT_NONE); + bool res = cmSystemTools::RunSingleCommand(command, + &output, &output, + &retCode, 0, + cmSystemTools::OUTPUT_NONE); // always print the output of the command, unless // it is the dumb rc command banner, but if the command // returned an error code then print the output anyway as // the banner may be mixed with some other important information. if(output.find("Resource Compiler Version") == output.npos - || retCode !=0) + || !res || retCode) { std::cout << output; } + if (!res) + { + std::cout << comment << " failed to run." << std::endl; + return false; + } // if retCodeOut is requested then always return true // and set the retCodeOut to retCode if(retCodeOut) @@ -1593,7 +1599,10 @@ int cmcmd::VisualStudioLinkIncremental(std::vector& args, mtCommand.push_back(tempManifest); // now run mt.exe to create the final manifest file int mtRet =0; - cmcmd::RunCommand("MT", mtCommand, verbose, &mtRet); + if(!cmcmd::RunCommand("MT", mtCommand, verbose, &mtRet)) + { + return -1; + } // if mt returns 0, then the manifest was not changed and // we do not need to do another link step if(mtRet == 0) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b28b07db47b181718643399bd2aedc3e6d1b29c4 commit b28b07db47b181718643399bd2aedc3e6d1b29c4 Author: James Johnston AuthorDate: Sat Aug 8 00:28:38 2015 -0400 Commit: James Johnston CommitDate: Sat Aug 8 00:28:38 2015 -0400 cmCTestCoverageHandle: Improve error handling. diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 6369e17..65599e0 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -1474,7 +1474,12 @@ int cmCTestCoverageHandler::HandleLCovCoverage( << std::endl, this->Quiet); std::vector files; - this->FindLCovFiles(files); + if (!this->FindLCovFiles(files)) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Error while finding LCov files.\n"); + return 0; + } std::vector::iterator it; if (files.empty()) @@ -1745,18 +1750,28 @@ void cmCTestCoverageHandler::FindGCovFiles(std::vector& files) } //---------------------------------------------------------------------------- -void cmCTestCoverageHandler::FindLCovFiles(std::vector& files) +bool cmCTestCoverageHandler::FindLCovFiles(std::vector& files) { cmsys::Glob gl; gl.RecurseOff(); // No need of recurse if -prof_dir${BUILD_DIR} flag is // used while compiling. gl.RecurseThroughSymlinksOff(); std::string prevBinaryDir; - cmSystemTools::ChangeDirectory( - this->CTest->GetCTestConfiguration("BuildDirectory")); + std::string buildDir = this->CTest->GetCTestConfiguration("BuildDirectory"); + if (cmSystemTools::ChangeDirectory(buildDir)) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Error changing directory to " << buildDir << std::endl); + return false; + } // Run profmerge to merge all *.dyn files into dpi files - cmSystemTools::RunSingleCommand("profmerge"); + if (!cmSystemTools::RunSingleCommand("profmerge")) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Error while running profmerge.\n"); + return false; + } prevBinaryDir = cmSystemTools::GetCurrentWorkingDirectory().c_str(); @@ -1766,10 +1781,16 @@ void cmCTestCoverageHandler::FindLCovFiles(std::vector& files) daGlob += "/*.dpi"; cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " looking for dpi files in: " << daGlob << std::endl, this->Quiet); - gl.FindFiles(daGlob); + if (!gl.FindFiles(daGlob)) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Error while finding files matching " << daGlob << std::endl); + return false; + } files.insert(files.end(), gl.GetFiles().begin(), gl.GetFiles().end()); cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Now searching in: " << daGlob << std::endl, this->Quiet); + return true; } //---------------------------------------------------------------------- diff --git a/Source/CTest/cmCTestCoverageHandler.h b/Source/CTest/cmCTestCoverageHandler.h index 2ca123a..7102d1e 100644 --- a/Source/CTest/cmCTestCoverageHandler.h +++ b/Source/CTest/cmCTestCoverageHandler.h @@ -75,7 +75,7 @@ private: //! Handle coverage using Intel's LCov int HandleLCovCoverage(cmCTestCoverageHandlerContainer* cont); - void FindLCovFiles(std::vector& files); + bool FindLCovFiles(std::vector& files); //! Handle coverage using xdebug php coverage int HandlePHPCoverage(cmCTestCoverageHandlerContainer* cont); ----------------------------------------------------------------------- Summary of changes: Source/CTest/cmCTestCoverageHandler.cxx | 33 +++++++++++++++++++++++++------ Source/CTest/cmCTestCoverageHandler.h | 2 +- Source/cmcmd.cxx | 19 +++++++++++++----- 3 files changed, 42 insertions(+), 12 deletions(-) hooks/post-receive -- CMake From chuck.atkins at kitware.com Sat Aug 8 10:31:49 2015 From: chuck.atkins at kitware.com (Chuck Atkins) Date: Sat, 8 Aug 2015 10:31:49 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2105-g43e2c08 Message-ID: <20150808143149.F0FA0B10C9@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 43e2c0863b0c71fe5573a8d9def948fa7c40cdff (commit) via 542160830ac3284eea8fc988d3103cdb5b99a56e (commit) from 9b72aec7b3624b6bb8e409e52a29263591856f81 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=43e2c0863b0c71fe5573a8d9def948fa7c40cdff commit 43e2c0863b0c71fe5573a8d9def948fa7c40cdff Merge: 9b72aec 5421608 Author: Chuck Atkins AuthorDate: Sat Aug 8 10:31:49 2015 -0400 Commit: CMake Topic Stage CommitDate: Sat Aug 8 10:31:49 2015 -0400 Merge topic 'add-global-link-static-properties' into next 54216083 Allow LINK_SEARCH_{START,END}_STATIC props to have default values. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=542160830ac3284eea8fc988d3103cdb5b99a56e commit 542160830ac3284eea8fc988d3103cdb5b99a56e Author: Chuck Atkins AuthorDate: Fri Aug 7 15:11:57 2015 -0400 Commit: Chuck Atkins CommitDate: Sat Aug 8 10:29:01 2015 -0400 Allow LINK_SEARCH_{START,END}_STATIC props to have default values. Use the CMAKE_LINK_SEARCH_START_STATIC and CMAKE_LINK_SEARCH_END_STATIC variables to initialize the LINK_SEARCH_START_STATIC and LINK_SEARCH_END_STATIC target properties respectively. diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 9066d97..70edf54 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -139,6 +139,8 @@ Variables that Change Behavior /variable/CMAKE_INSTALL_MESSAGE /variable/CMAKE_INSTALL_PREFIX /variable/CMAKE_LIBRARY_PATH + /variable/CMAKE_LINK_SEARCH_END_STATIC + /variable/CMAKE_LINK_SEARCH_START_STATIC /variable/CMAKE_MFC_FLAG /variable/CMAKE_MODULE_PATH /variable/CMAKE_NOT_USING_CONFIG_FLAGS diff --git a/Help/prop_tgt/LINK_SEARCH_END_STATIC.rst b/Help/prop_tgt/LINK_SEARCH_END_STATIC.rst index fe105bd..cf9c871 100644 --- a/Help/prop_tgt/LINK_SEARCH_END_STATIC.rst +++ b/Help/prop_tgt/LINK_SEARCH_END_STATIC.rst @@ -10,5 +10,9 @@ paths are not known or (in some cases) are in implicit link directories for the platform. By default CMake adds an option at the end of the library list (if necessary) to set the linker search type back to its starting type. This property switches the final linker -search type to -Bstatic regardless of how it started. See also -LINK_SEARCH_START_STATIC. +search type to -Bstatic regardless of how it started. + +This property is initialized by the value of the variable +CMAKE_LINK_SEARCH_END_STATIC if it is set when a target is created. + +See also LINK_SEARCH_START_STATIC. diff --git a/Help/prop_tgt/LINK_SEARCH_START_STATIC.rst b/Help/prop_tgt/LINK_SEARCH_START_STATIC.rst index ca899fe..2e0f9bd 100644 --- a/Help/prop_tgt/LINK_SEARCH_START_STATIC.rst +++ b/Help/prop_tgt/LINK_SEARCH_START_STATIC.rst @@ -11,4 +11,9 @@ directories for the platform. By default the linker search type is assumed to be -Bdynamic at the beginning of the library list. This property switches the assumption to -Bstatic. It is intended for use when linking an executable statically (e.g. with the GNU -static -option). See also LINK_SEARCH_END_STATIC. +option). + +This property is initialized by the value of the variable +CMAKE_LINK_SEARCH_START_STATIC if it is set when a target is created. + +See also LINK_SEARCH_END_STATIC. diff --git a/Help/prop_tgt/LINK_SEARCH_END_STATIC.rst b/Help/variable/CMAKE_LINK_SEARCH_END_STATIC.rst similarity index 68% copy from Help/prop_tgt/LINK_SEARCH_END_STATIC.rst copy to Help/variable/CMAKE_LINK_SEARCH_END_STATIC.rst index fe105bd..8a9951d 100644 --- a/Help/prop_tgt/LINK_SEARCH_END_STATIC.rst +++ b/Help/variable/CMAKE_LINK_SEARCH_END_STATIC.rst @@ -1,5 +1,5 @@ -LINK_SEARCH_END_STATIC ----------------------- +CMAKE_LINK_SEARCH_END_STATIC +---------------------------- End a link line such that static system libraries are used. @@ -10,5 +10,9 @@ paths are not known or (in some cases) are in implicit link directories for the platform. By default CMake adds an option at the end of the library list (if necessary) to set the linker search type back to its starting type. This property switches the final linker -search type to -Bstatic regardless of how it started. See also -LINK_SEARCH_START_STATIC. +search type to -Bstatic regardless of how it started. + +This variable is used to initialize the target property +LINK_SEARCH_END_STATIC for all targets. + +See also CMAKE_LINK_SEARCH_START_STATIC. diff --git a/Help/prop_tgt/LINK_SEARCH_START_STATIC.rst b/Help/variable/CMAKE_LINK_SEARCH_START_STATIC.rst similarity index 73% copy from Help/prop_tgt/LINK_SEARCH_START_STATIC.rst copy to Help/variable/CMAKE_LINK_SEARCH_START_STATIC.rst index ca899fe..715db4b 100644 --- a/Help/prop_tgt/LINK_SEARCH_START_STATIC.rst +++ b/Help/variable/CMAKE_LINK_SEARCH_START_STATIC.rst @@ -1,5 +1,5 @@ -LINK_SEARCH_START_STATIC ------------------------- +CMAKE_LINK_SEARCH_START_STATIC +------------------------------ Assume the linker looks for static libraries by default. @@ -11,4 +11,9 @@ directories for the platform. By default the linker search type is assumed to be -Bdynamic at the beginning of the library list. This property switches the assumption to -Bstatic. It is intended for use when linking an executable statically (e.g. with the GNU -static -option). See also LINK_SEARCH_END_STATIC. +option). + +This variable is used to initialize the target property +LINK_SEARCH_START_STATIC for all targets. + +See also CMAKE_LINK_SEARCH_END_STATIC. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index c3f36af..dff223f 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -520,9 +520,10 @@ bool cmComputeLinkInformation::Compute() // libraries are found. const char* lss = this->Target->Target->GetProperty("LINK_SEARCH_END_STATIC"); - if(cmSystemTools::IsOn(lss)) + if(lss) { - this->SetCurrentLinkType(LinkStatic); + this->SetCurrentLinkType( + cmSystemTools::IsOn(lss) ? LinkStatic : LinkShared); } else { @@ -864,7 +865,8 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo() const char* lss = this->Target->Target->GetProperty("LINK_SEARCH_START_STATIC"); this->StartLinkType = cmSystemTools::IsOn(lss)? LinkStatic : LinkShared; - this->CurrentLinkType = this->StartLinkType; + this->CurrentLinkType = LinkUnknown; + this->SetCurrentLinkType(this->StartLinkType); } //---------------------------------------------------------------------------- diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1f8f07a..51e6a66 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -306,6 +306,8 @@ void cmTarget::SetMakefile(cmMakefile* mf) this->SetPropertyDefault("CXX_STANDARD", 0); this->SetPropertyDefault("CXX_STANDARD_REQUIRED", 0); this->SetPropertyDefault("CXX_EXTENSIONS", 0); + this->SetPropertyDefault("LINK_SEARCH_START_STATIC", 0); + this->SetPropertyDefault("LINK_SEARCH_END_STATIC", 0); } // Collect the set of configuration types. diff --git a/Tests/LinkStatic/CMakeLists.txt b/Tests/LinkStatic/CMakeLists.txt index 200d4e5..264c85f 100644 --- a/Tests/LinkStatic/CMakeLists.txt +++ b/Tests/LinkStatic/CMakeLists.txt @@ -25,3 +25,39 @@ set(LinkStatic_FLAG "-static" CACHE STRING "Flag to link statically") set_property(TARGET LinkStatic PROPERTY LINK_FLAGS "${LinkStatic_FLAG}") set_property(TARGET LinkStatic PROPERTY LINK_SEARCH_START_STATIC 1) #set_property(TARGET LinkStatic PROPERTY LINK_SEARCH_END_STATIC 1) # insufficient + +set(CMAKE_LINK_SEARCH_START_STATIC ON) +add_executable(LinkStaticInitStart1 LinkStatic.c) +get_property(LSSS TARGET LinkStaticInitStart1 + PROPERTY LINK_SEARCH_START_STATIC) +if(NOT LSSS) + message(FATAL_ERROR "Failed to correctly initialize LINK_SEARCH_START_STATIC") +endif() + +set(CMAKE_LINK_SEARCH_START_STATIC OFF) +add_executable(LinkStaticInitStart2 LinkStatic.c) +get_property(LSSS TARGET LinkStaticInitStart2 + PROPERTY LINK_SEARCH_START_STATIC) +if(LSSS) + message(FATAL_ERROR "Failed to correctly initialize LINK_SEARCH_START_STATIC") +endif() + +unset(CMAKE_LINK_SEARCH_START_STATIC) + +set(CMAKE_LINK_SEARCH_END_STATIC ON) +add_executable(LinkStaticInitEnd1 LinkStatic.c) +get_property(LSES TARGET LinkStaticInitEnd1 + PROPERTY LINK_SEARCH_END_STATIC) +if(NOT LSES) + message(FATAL_ERROR "Failed to correctly initialize LINK_SEARCH_END_STATIC") +endif() + +set(CMAKE_LINK_SEARCH_END_STATIC OFF) +add_executable(LinkStaticInitEnd2 LinkStatic.c) +get_property(LSES TARGET LinkStaticInitEnd2 + PROPERTY LINK_SEARCH_END_STATIC) +if(LSES) + message(FATAL_ERROR "Failed to correctly initialize LINK_SEARCH_END_STATIC") +endif() + +unset(CMAKE_LINK_SEARCH_END_STATIC) ----------------------------------------------------------------------- Summary of changes: Help/manual/cmake-variables.7.rst | 2 ++ 1 file changed, 2 insertions(+) hooks/post-receive -- CMake From kwrobot at kitware.com Sun Aug 9 00:01:07 2015 From: kwrobot at kitware.com (Kitware Robot) Date: Sun, 9 Aug 2015 00:01:07 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-763-gcf4bbf7 Message-ID: <20150809040107.79718B122C@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via cf4bbf734ceee8cd67bf2ec1fbdb2d9bfedaf3e5 (commit) from 101ba25e6a2c177f9f3a81f3879a171256806756 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cf4bbf734ceee8cd67bf2ec1fbdb2d9bfedaf3e5 commit cf4bbf734ceee8cd67bf2ec1fbdb2d9bfedaf3e5 Author: Kitware Robot AuthorDate: Sun Aug 9 00:01:05 2015 -0400 Commit: Kitware Robot CommitDate: Sun Aug 9 00:01:05 2015 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index e982b81..ed7074b 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150808) +set(CMake_VERSION_PATCH 20150809) #set(CMake_VERSION_RC 1) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From johnstonj.public at codenest.com Sun Aug 9 13:59:02 2015 From: johnstonj.public at codenest.com (James Johnston) Date: Sun, 9 Aug 2015 13:59:02 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2109-g8618bdc Message-ID: <20150809175902.DCDAEB0FEC@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 8618bdc60bfe0f81fe5ce1e1c31afdcf69eb692e (commit) via 874e70bc57f54e5fc898a169797a0b1e45df31f6 (commit) via c5ac2b9df36a57d3b88e80a2d1c382d753faf2da (commit) via 101ba25e6a2c177f9f3a81f3879a171256806756 (commit) from 43e2c0863b0c71fe5573a8d9def948fa7c40cdff (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8618bdc60bfe0f81fe5ce1e1c31afdcf69eb692e commit 8618bdc60bfe0f81fe5ce1e1c31afdcf69eb692e Merge: 43e2c08 874e70b Author: James Johnston AuthorDate: Sun Aug 9 13:59:02 2015 -0400 Commit: CMake Topic Stage CommitDate: Sun Aug 9 13:59:02 2015 -0400 Merge topic 'ninja-version-handling' into next 874e70bc Ninja: Prevent generating if installed Ninja version is too old. c5ac2b9d Ninja: Centralized required Ninja version numbers and comparisons. 101ba25e CMake Nightly Date Stamp http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=874e70bc57f54e5fc898a169797a0b1e45df31f6 commit 874e70bc57f54e5fc898a169797a0b1e45df31f6 Author: James Johnston AuthorDate: Sun Aug 9 13:51:35 2015 -0400 Commit: James Johnston CommitDate: Sun Aug 9 13:51:35 2015 -0400 Ninja: Prevent generating if installed Ninja version is too old. diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index b46d85c..b92ad32 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -547,6 +547,18 @@ void cmGlobalNinjaGenerator // Source/cmake.cxx void cmGlobalNinjaGenerator::Generate() { + // Check minimum Ninja version. + if (cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, + CurrentNinjaVersion().c_str(), + RequiredNinjaVersion().c_str())) + { + std::ostringstream msg; + msg << "The detected version of Ninja (" << this->CurrentNinjaVersion(); + msg << ") is less than the version of Ninja required by CMake ("; + msg << this->RequiredNinjaVersion() << ")."; + this->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, msg.str()); + return; + } this->OpenBuildFileStream(); this->OpenRulesFileStream(); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c5ac2b9df36a57d3b88e80a2d1c382d753faf2da commit c5ac2b9df36a57d3b88e80a2d1c382d753faf2da Author: James Johnston AuthorDate: Sat Aug 8 20:04:08 2015 +0000 Commit: James Johnston CommitDate: Sun Aug 9 13:31:24 2015 -0400 Ninja: Centralized required Ninja version numbers and comparisons. diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 088f0e1..b46d85c 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -1256,7 +1256,7 @@ std::string cmGlobalNinjaGenerator::ninjaCmd() const return "ninja"; } -std::string cmGlobalNinjaGenerator::ninjaVersion() const +std::string cmGlobalNinjaGenerator::CurrentNinjaVersion() const { std::string version; std::string command = ninjaCmd() + " --version"; @@ -1264,13 +1264,14 @@ std::string cmGlobalNinjaGenerator::ninjaVersion() const &version, 0, 0, 0, cmSystemTools::OUTPUT_NONE); - return version; + return cmSystemTools::TrimWhitespace(version); } bool cmGlobalNinjaGenerator::SupportsConsolePool() const { return cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, - ninjaVersion().c_str(), "1.5") == false; + CurrentNinjaVersion().c_str(), + RequiredNinjaVersionForConsolePool().c_str()) == false; } void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os) diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 2a749c1..a1df1c2 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -299,8 +299,10 @@ public: virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const; - std::string ninjaVersion() const; - + std::string CurrentNinjaVersion() const; + // Ninja generator uses 'deps' and 'msvc_deps_prefix' introduced in 1.3 + static std::string RequiredNinjaVersion() { return "1.3"; } + static std::string RequiredNinjaVersionForConsolePool() { return "1.5"; } bool SupportsConsolePool() const; protected: diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 9889bd4..aaad075 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -193,16 +193,14 @@ void cmLocalNinjaGenerator::WriteProjectHeader(std::ostream& os) void cmLocalNinjaGenerator::WriteNinjaRequiredVersion(std::ostream& os) { // Default required version - // Ninja generator uses 'deps' and 'msvc_deps_prefix' introduced in 1.3 - std::string requiredVersion = "1.3"; + std::string requiredVersion = + this->GetGlobalNinjaGenerator()->RequiredNinjaVersion(); // Ninja generator uses the 'console' pool if available (>= 1.5) - std::string usedVersion = this->GetGlobalNinjaGenerator()->ninjaVersion(); - if(cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, - usedVersion.c_str(), - "1.5") == false) + if(this->GetGlobalNinjaGenerator()->SupportsConsolePool()) { - requiredVersion = "1.5"; + requiredVersion = + this->GetGlobalNinjaGenerator()->RequiredNinjaVersionForConsolePool(); } cmGlobalNinjaGenerator::WriteComment(os, ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- Source/cmGlobalNinjaGenerator.cxx | 19 ++++++++++++++++--- Source/cmGlobalNinjaGenerator.h | 6 ++++-- Source/cmLocalNinjaGenerator.cxx | 12 +++++------- 4 files changed, 26 insertions(+), 13 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Mon Aug 10 00:01:11 2015 From: kwrobot at kitware.com (Kitware Robot) Date: Mon, 10 Aug 2015 00:01:11 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-764-g7979e25 Message-ID: <20150810040111.C5C9DB115C@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 7979e25c8b9214a6a1097d5aa3937d6277556342 (commit) from cf4bbf734ceee8cd67bf2ec1fbdb2d9bfedaf3e5 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7979e25c8b9214a6a1097d5aa3937d6277556342 commit 7979e25c8b9214a6a1097d5aa3937d6277556342 Author: Kitware Robot AuthorDate: Mon Aug 10 00:01:09 2015 -0400 Commit: Kitware Robot CommitDate: Mon Aug 10 00:01:09 2015 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index ed7074b..df17741 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150809) +set(CMake_VERSION_PATCH 20150810) #set(CMake_VERSION_RC 1) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 10 09:02:26 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 10 Aug 2015 09:02:26 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2111-g979cf19 Message-ID: <20150810130226.F201BB1430@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 979cf19aa17a4f7f4662b43d17b06cec9c32ad45 (commit) via b695b3b9853fbb03fb135c391593d90298cc17f0 (commit) from 8618bdc60bfe0f81fe5ce1e1c31afdcf69eb692e (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=979cf19aa17a4f7f4662b43d17b06cec9c32ad45 commit 979cf19aa17a4f7f4662b43d17b06cec9c32ad45 Merge: 8618bdc b695b3b Author: Brad King AuthorDate: Mon Aug 10 09:02:26 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 10 09:02:26 2015 -0400 Merge topic 'add-global-link-static-properties' into next b695b3b9 Revert "Allow LINK_SEARCH_{START,END}_STATIC props to have default values." http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b695b3b9853fbb03fb135c391593d90298cc17f0 commit b695b3b9853fbb03fb135c391593d90298cc17f0 Author: Brad King AuthorDate: Mon Aug 10 09:02:05 2015 -0400 Commit: Brad King CommitDate: Mon Aug 10 09:02:05 2015 -0400 Revert "Allow LINK_SEARCH_{START,END}_STATIC props to have default values." This reverts commit 542160830ac3284eea8fc988d3103cdb5b99a56e. The LinkStatic test fails on many machines. diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 70edf54..9066d97 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -139,8 +139,6 @@ Variables that Change Behavior /variable/CMAKE_INSTALL_MESSAGE /variable/CMAKE_INSTALL_PREFIX /variable/CMAKE_LIBRARY_PATH - /variable/CMAKE_LINK_SEARCH_END_STATIC - /variable/CMAKE_LINK_SEARCH_START_STATIC /variable/CMAKE_MFC_FLAG /variable/CMAKE_MODULE_PATH /variable/CMAKE_NOT_USING_CONFIG_FLAGS diff --git a/Help/prop_tgt/LINK_SEARCH_END_STATIC.rst b/Help/prop_tgt/LINK_SEARCH_END_STATIC.rst index cf9c871..fe105bd 100644 --- a/Help/prop_tgt/LINK_SEARCH_END_STATIC.rst +++ b/Help/prop_tgt/LINK_SEARCH_END_STATIC.rst @@ -10,9 +10,5 @@ paths are not known or (in some cases) are in implicit link directories for the platform. By default CMake adds an option at the end of the library list (if necessary) to set the linker search type back to its starting type. This property switches the final linker -search type to -Bstatic regardless of how it started. - -This property is initialized by the value of the variable -CMAKE_LINK_SEARCH_END_STATIC if it is set when a target is created. - -See also LINK_SEARCH_START_STATIC. +search type to -Bstatic regardless of how it started. See also +LINK_SEARCH_START_STATIC. diff --git a/Help/prop_tgt/LINK_SEARCH_START_STATIC.rst b/Help/prop_tgt/LINK_SEARCH_START_STATIC.rst index 2e0f9bd..ca899fe 100644 --- a/Help/prop_tgt/LINK_SEARCH_START_STATIC.rst +++ b/Help/prop_tgt/LINK_SEARCH_START_STATIC.rst @@ -11,9 +11,4 @@ directories for the platform. By default the linker search type is assumed to be -Bdynamic at the beginning of the library list. This property switches the assumption to -Bstatic. It is intended for use when linking an executable statically (e.g. with the GNU -static -option). - -This property is initialized by the value of the variable -CMAKE_LINK_SEARCH_START_STATIC if it is set when a target is created. - -See also LINK_SEARCH_END_STATIC. +option). See also LINK_SEARCH_END_STATIC. diff --git a/Help/variable/CMAKE_LINK_SEARCH_END_STATIC.rst b/Help/variable/CMAKE_LINK_SEARCH_END_STATIC.rst deleted file mode 100644 index 8a9951d..0000000 --- a/Help/variable/CMAKE_LINK_SEARCH_END_STATIC.rst +++ /dev/null @@ -1,18 +0,0 @@ -CMAKE_LINK_SEARCH_END_STATIC ----------------------------- - -End a link line such that static system libraries are used. - -Some linkers support switches such as -Bstatic and -Bdynamic to -determine whether to use static or shared libraries for -lXXX options. -CMake uses these options to set the link type for libraries whose full -paths are not known or (in some cases) are in implicit link -directories for the platform. By default CMake adds an option at the -end of the library list (if necessary) to set the linker search type -back to its starting type. This property switches the final linker -search type to -Bstatic regardless of how it started. - -This variable is used to initialize the target property -LINK_SEARCH_END_STATIC for all targets. - -See also CMAKE_LINK_SEARCH_START_STATIC. diff --git a/Help/variable/CMAKE_LINK_SEARCH_START_STATIC.rst b/Help/variable/CMAKE_LINK_SEARCH_START_STATIC.rst deleted file mode 100644 index 715db4b..0000000 --- a/Help/variable/CMAKE_LINK_SEARCH_START_STATIC.rst +++ /dev/null @@ -1,19 +0,0 @@ -CMAKE_LINK_SEARCH_START_STATIC ------------------------------- - -Assume the linker looks for static libraries by default. - -Some linkers support switches such as -Bstatic and -Bdynamic to -determine whether to use static or shared libraries for -lXXX options. -CMake uses these options to set the link type for libraries whose full -paths are not known or (in some cases) are in implicit link -directories for the platform. By default the linker search type is -assumed to be -Bdynamic at the beginning of the library list. This -property switches the assumption to -Bstatic. It is intended for use -when linking an executable statically (e.g. with the GNU -static -option). - -This variable is used to initialize the target property -LINK_SEARCH_START_STATIC for all targets. - -See also CMAKE_LINK_SEARCH_END_STATIC. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index dff223f..c3f36af 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -520,10 +520,9 @@ bool cmComputeLinkInformation::Compute() // libraries are found. const char* lss = this->Target->Target->GetProperty("LINK_SEARCH_END_STATIC"); - if(lss) + if(cmSystemTools::IsOn(lss)) { - this->SetCurrentLinkType( - cmSystemTools::IsOn(lss) ? LinkStatic : LinkShared); + this->SetCurrentLinkType(LinkStatic); } else { @@ -865,8 +864,7 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo() const char* lss = this->Target->Target->GetProperty("LINK_SEARCH_START_STATIC"); this->StartLinkType = cmSystemTools::IsOn(lss)? LinkStatic : LinkShared; - this->CurrentLinkType = LinkUnknown; - this->SetCurrentLinkType(this->StartLinkType); + this->CurrentLinkType = this->StartLinkType; } //---------------------------------------------------------------------------- diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 51e6a66..1f8f07a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -306,8 +306,6 @@ void cmTarget::SetMakefile(cmMakefile* mf) this->SetPropertyDefault("CXX_STANDARD", 0); this->SetPropertyDefault("CXX_STANDARD_REQUIRED", 0); this->SetPropertyDefault("CXX_EXTENSIONS", 0); - this->SetPropertyDefault("LINK_SEARCH_START_STATIC", 0); - this->SetPropertyDefault("LINK_SEARCH_END_STATIC", 0); } // Collect the set of configuration types. diff --git a/Tests/LinkStatic/CMakeLists.txt b/Tests/LinkStatic/CMakeLists.txt index 264c85f..200d4e5 100644 --- a/Tests/LinkStatic/CMakeLists.txt +++ b/Tests/LinkStatic/CMakeLists.txt @@ -25,39 +25,3 @@ set(LinkStatic_FLAG "-static" CACHE STRING "Flag to link statically") set_property(TARGET LinkStatic PROPERTY LINK_FLAGS "${LinkStatic_FLAG}") set_property(TARGET LinkStatic PROPERTY LINK_SEARCH_START_STATIC 1) #set_property(TARGET LinkStatic PROPERTY LINK_SEARCH_END_STATIC 1) # insufficient - -set(CMAKE_LINK_SEARCH_START_STATIC ON) -add_executable(LinkStaticInitStart1 LinkStatic.c) -get_property(LSSS TARGET LinkStaticInitStart1 - PROPERTY LINK_SEARCH_START_STATIC) -if(NOT LSSS) - message(FATAL_ERROR "Failed to correctly initialize LINK_SEARCH_START_STATIC") -endif() - -set(CMAKE_LINK_SEARCH_START_STATIC OFF) -add_executable(LinkStaticInitStart2 LinkStatic.c) -get_property(LSSS TARGET LinkStaticInitStart2 - PROPERTY LINK_SEARCH_START_STATIC) -if(LSSS) - message(FATAL_ERROR "Failed to correctly initialize LINK_SEARCH_START_STATIC") -endif() - -unset(CMAKE_LINK_SEARCH_START_STATIC) - -set(CMAKE_LINK_SEARCH_END_STATIC ON) -add_executable(LinkStaticInitEnd1 LinkStatic.c) -get_property(LSES TARGET LinkStaticInitEnd1 - PROPERTY LINK_SEARCH_END_STATIC) -if(NOT LSES) - message(FATAL_ERROR "Failed to correctly initialize LINK_SEARCH_END_STATIC") -endif() - -set(CMAKE_LINK_SEARCH_END_STATIC OFF) -add_executable(LinkStaticInitEnd2 LinkStatic.c) -get_property(LSES TARGET LinkStaticInitEnd2 - PROPERTY LINK_SEARCH_END_STATIC) -if(LSES) - message(FATAL_ERROR "Failed to correctly initialize LINK_SEARCH_END_STATIC") -endif() - -unset(CMAKE_LINK_SEARCH_END_STATIC) ----------------------------------------------------------------------- Summary of changes: Help/manual/cmake-variables.7.rst | 2 -- Help/prop_tgt/LINK_SEARCH_END_STATIC.rst | 8 ++--- Help/prop_tgt/LINK_SEARCH_START_STATIC.rst | 7 +---- Help/variable/CMAKE_LINK_SEARCH_END_STATIC.rst | 18 ----------- Help/variable/CMAKE_LINK_SEARCH_START_STATIC.rst | 19 ------------ Source/cmComputeLinkInformation.cxx | 8 ++--- Source/cmTarget.cxx | 2 -- Tests/LinkStatic/CMakeLists.txt | 36 ---------------------- 8 files changed, 6 insertions(+), 94 deletions(-) delete mode 100644 Help/variable/CMAKE_LINK_SEARCH_END_STATIC.rst delete mode 100644 Help/variable/CMAKE_LINK_SEARCH_START_STATIC.rst hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 10 09:13:18 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 10 Aug 2015 09:13:18 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-766-ge8592e5 Message-ID: <20150810131318.34B36B02A6@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via e8592e555fb3f19dd8a5b88948603c72b2a17a8d (commit) via 35aab9df9f299d62edaa6ce611aa30614deb9e9d (commit) from 7979e25c8b9214a6a1097d5aa3937d6277556342 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e8592e555fb3f19dd8a5b88948603c72b2a17a8d commit e8592e555fb3f19dd8a5b88948603c72b2a17a8d Merge: 7979e25 35aab9d Author: Brad King AuthorDate: Mon Aug 10 09:13:16 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 10 09:13:16 2015 -0400 Merge topic 'fix-TARGET_FILE-imported' 35aab9df Reject TARGET_PDB_FILE for imported targets instead of crashing ----------------------------------------------------------------------- Summary of changes: Source/cmGeneratorExpressionNode.cxx | 7 +++++++ Source/cmGeneratorTarget.cxx | 1 + .../ImportedTarget-TARGET_PDB_FILE-result.txt} | 0 ...ILE-stderr.txt => ImportedTarget-TARGET_PDB_FILE-stderr.txt} | 4 ++-- .../GeneratorExpression/ImportedTarget-TARGET_PDB_FILE.cmake | 2 ++ Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake | 1 + 6 files changed, 13 insertions(+), 2 deletions(-) copy Tests/RunCMake/{CMP0004/CMP0004-NEW-result.txt => GeneratorExpression/ImportedTarget-TARGET_PDB_FILE-result.txt} (100%) copy Tests/RunCMake/GeneratorExpression/{NonValidCompiler-TARGET_PDB_FILE-stderr.txt => ImportedTarget-TARGET_PDB_FILE-stderr.txt} (52%) create mode 100644 Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE.cmake hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 10 09:13:20 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 10 Aug 2015 09:13:20 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-768-g3d0a719 Message-ID: <20150810131320.46E9FB0316@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 3d0a719b703a2d4dd9b38b54847453a3f5a2d7f7 (commit) via afeb4eb243e01df5c7396dc346f2629b21115e2c (commit) from e8592e555fb3f19dd8a5b88948603c72b2a17a8d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3d0a719b703a2d4dd9b38b54847453a3f5a2d7f7 commit 3d0a719b703a2d4dd9b38b54847453a3f5a2d7f7 Merge: e8592e5 afeb4eb Author: Brad King AuthorDate: Mon Aug 10 09:13:18 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 10 09:13:18 2015 -0400 Merge topic 'change-nmake-env-warning' afeb4eb2 nmake/jom: Only warn about bad VS environment if compiler not found. ----------------------------------------------------------------------- Summary of changes: Source/cmGlobalGenerator.h | 4 +-- Source/cmGlobalJOMMakefileGenerator.cxx | 28 +++++++++++--------- Source/cmGlobalJOMMakefileGenerator.h | 3 +++ Source/cmGlobalNMakeMakefileGenerator.cxx | 28 +++++++++++--------- Source/cmGlobalNMakeMakefileGenerator.h | 3 +++ ...lerC-stderr.txt => BadCompilerC-stderr-JOM.txt} | 5 ++++ ...rC-stderr.txt => BadCompilerC-stderr-NMake.txt} | 5 ++++ ...XX-stderr.txt => BadCompilerCXX-stderr-JOM.txt} | 5 ++++ ...-stderr.txt => BadCompilerCXX-stderr-NMake.txt} | 5 ++++ ...tderr.txt => BadCompilerCandCXX-stderr-JOM.txt} | 10 +++++++ ...err.txt => BadCompilerCandCXX-stderr-NMake.txt} | 10 +++++++ Tests/RunCMake/CompilerNotFound/RunCMakeTest.cmake | 14 ++++++++++ 12 files changed, 94 insertions(+), 26 deletions(-) copy Tests/RunCMake/CompilerNotFound/{BadCompilerC-stderr.txt => BadCompilerC-stderr-JOM.txt} (61%) copy Tests/RunCMake/CompilerNotFound/{BadCompilerC-stderr.txt => BadCompilerC-stderr-NMake.txt} (60%) copy Tests/RunCMake/CompilerNotFound/{BadCompilerCXX-stderr.txt => BadCompilerCXX-stderr-JOM.txt} (61%) copy Tests/RunCMake/CompilerNotFound/{BadCompilerCXX-stderr.txt => BadCompilerCXX-stderr-NMake.txt} (61%) copy Tests/RunCMake/CompilerNotFound/{BadCompilerCandCXX-stderr.txt => BadCompilerCandCXX-stderr-JOM.txt} (61%) copy Tests/RunCMake/CompilerNotFound/{BadCompilerCandCXX-stderr.txt => BadCompilerCandCXX-stderr-NMake.txt} (60%) hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 10 09:13:22 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 10 Aug 2015 09:13:22 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-772-g16b889d Message-ID: <20150810131322.2927DB033F@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 16b889da9a625d4501beb2150e2635c9608c729e (commit) via d035e9687a2d28e2f64ec3a316f8abea57e49d63 (commit) via 38ed5866ed212effe0217f193f728ee54ea7378b (commit) via 772ca69f803a8f294d6e04f9e258becc35179233 (commit) from 3d0a719b703a2d4dd9b38b54847453a3f5a2d7f7 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=16b889da9a625d4501beb2150e2635c9608c729e commit 16b889da9a625d4501beb2150e2635c9608c729e Merge: 3d0a719 d035e96 Author: Brad King AuthorDate: Mon Aug 10 09:13:20 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 10 09:13:20 2015 -0400 Merge topic 'fix-get-filename-component' d035e968 get_filename_component: Fix bug where CACHE was ignored. 38ed5866 get_filename_component: Added initial tests for PROGRAM component. 772ca69f get_filename_component: Tests now check for proper CACHE usage. ----------------------------------------------------------------------- Summary of changes: Source/cmGetFilenameComponentCommand.cxx | 4 +- .../RunCMake/get_filename_component/CMakeLists.txt | 2 +- .../get_filename_component/KnownComponents.cmake | 77 ++++++++++++++++++++ 3 files changed, 80 insertions(+), 3 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 10 09:13:23 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 10 Aug 2015 09:13:23 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-775-g815a2c0 Message-ID: <20150810131323.E14E9B037D@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 815a2c09d3651c86e954e5626b573054add23ab3 (commit) via 203b20df98512094cc74061fd1b76e87bd2d3afb (commit) via b28b07db47b181718643399bd2aedc3e6d1b29c4 (commit) from 16b889da9a625d4501beb2150e2635c9608c729e (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=815a2c09d3651c86e954e5626b573054add23ab3 commit 815a2c09d3651c86e954e5626b573054add23ab3 Merge: 16b889d 203b20d Author: Brad King AuthorDate: Mon Aug 10 09:13:22 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 10 09:13:22 2015 -0400 Merge topic 'fix-process-error-handling' 203b20df cmcmd: Improve error handling when executing a process. b28b07db cmCTestCoverageHandle: Improve error handling. ----------------------------------------------------------------------- Summary of changes: Source/CTest/cmCTestCoverageHandler.cxx | 33 +++++++++++++++++++++++++------ Source/CTest/cmCTestCoverageHandler.h | 2 +- Source/cmcmd.cxx | 19 +++++++++++++----- 3 files changed, 42 insertions(+), 12 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 10 09:13:25 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 10 Aug 2015 09:13:25 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-778-g2f16e60 Message-ID: <20150810131325.CADA6B0352@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 2f16e608436193f465d4bac181db36464fa88e22 (commit) via 874e70bc57f54e5fc898a169797a0b1e45df31f6 (commit) via c5ac2b9df36a57d3b88e80a2d1c382d753faf2da (commit) from 815a2c09d3651c86e954e5626b573054add23ab3 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2f16e608436193f465d4bac181db36464fa88e22 commit 2f16e608436193f465d4bac181db36464fa88e22 Merge: 815a2c0 874e70b Author: Brad King AuthorDate: Mon Aug 10 09:13:24 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 10 09:13:24 2015 -0400 Merge topic 'ninja-version-handling' 874e70bc Ninja: Prevent generating if installed Ninja version is too old. c5ac2b9d Ninja: Centralized required Ninja version numbers and comparisons. ----------------------------------------------------------------------- Summary of changes: Source/cmGlobalNinjaGenerator.cxx | 19 ++++++++++++++++--- Source/cmGlobalNinjaGenerator.h | 6 ++++-- Source/cmLocalNinjaGenerator.cxx | 12 +++++------- 3 files changed, 25 insertions(+), 12 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 10 09:13:47 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 10 Aug 2015 09:13:47 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2119-gdde71b8 Message-ID: <20150810131347.A0F15B037D@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via dde71b8431a75dcbe91d302779f15abaa9471c3d (commit) via 2f16e608436193f465d4bac181db36464fa88e22 (commit) via 815a2c09d3651c86e954e5626b573054add23ab3 (commit) via 16b889da9a625d4501beb2150e2635c9608c729e (commit) via 3d0a719b703a2d4dd9b38b54847453a3f5a2d7f7 (commit) via e8592e555fb3f19dd8a5b88948603c72b2a17a8d (commit) via 7979e25c8b9214a6a1097d5aa3937d6277556342 (commit) via cf4bbf734ceee8cd67bf2ec1fbdb2d9bfedaf3e5 (commit) from 979cf19aa17a4f7f4662b43d17b06cec9c32ad45 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=dde71b8431a75dcbe91d302779f15abaa9471c3d commit dde71b8431a75dcbe91d302779f15abaa9471c3d Merge: 979cf19 2f16e60 Author: Brad King AuthorDate: Mon Aug 10 09:13:37 2015 -0400 Commit: Brad King CommitDate: Mon Aug 10 09:13:37 2015 -0400 Merge branch 'master' into next ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 10 10:01:46 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 10 Aug 2015 10:01:46 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2121-g225e2d5 Message-ID: <20150810140146.0D175B1401@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 225e2d5bacae40956e489d8232f150607cc7b75a (commit) via cc3f200789ad997065b195d01c137c0470551eff (commit) from dde71b8431a75dcbe91d302779f15abaa9471c3d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=225e2d5bacae40956e489d8232f150607cc7b75a commit 225e2d5bacae40956e489d8232f150607cc7b75a Merge: dde71b8 cc3f200 Author: Brad King AuthorDate: Mon Aug 10 10:01:45 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 10 10:01:45 2015 -0400 Merge topic 'cmState-definitions' into next cc3f2007 Revert topic 'cmState-definitions' diff --cc Source/cmGlobalGenerator.cxx index a19a074,3c818ff..cda26cd --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@@ -1184,40 -1147,11 +1148,11 @@@ void cmGlobalGenerator::Configure( // update the cache entry for the number of local generators, this is used // for progress char num[100]; - sprintf(num,"%d",static_cast(this->LocalGenerators.size())); + sprintf(num,"%d",static_cast(this->Makefiles.size())); this->GetCMakeInstance()->AddCacheEntry - ("CMAKE_NUMBER_OF_LOCAL_GENERATORS", num, + ("CMAKE_NUMBER_OF_MAKEFILES", num, "number of local generators", cmState::INTERNAL); - { - std::ostringstream str; - str << this->GetCMakeInstance()->GetState()->DefinitionsSize(); - this->GetCMakeInstance()->AddCacheEntry - ("CMAKE_NUMBER_OF_DEFINITION_STATES", str.str().c_str(), - "number of definition states", cmState::INTERNAL); - } - { - std::ostringstream str; - str << this->GetCMakeInstance()->GetState()->SnapshotsSize(); - this->GetCMakeInstance()->AddCacheEntry - ("CMAKE_NUMBER_OF_SNAPSHOT_STATES", str.str().c_str(), - "number of snapshot states", cmState::INTERNAL); - } - { - std::ostringstream str; - str << this->GetCMakeInstance()->GetState()->ListFilesSize(); - this->GetCMakeInstance()->AddCacheEntry - ("CMAKE_NUMBER_OF_LISTFILE_STATES", str.str().c_str(), - "number of listfile states", cmState::INTERNAL); - } - { - std::ostringstream str; - str << this->GetCMakeInstance()->GetState()->PoliciesSize(); - this->GetCMakeInstance()->AddCacheEntry - ("CMAKE_NUMBER_OF_POLICY_STATES", str.str().c_str(), - "number of policy states", cmState::INTERNAL); - } - // check for link libraries and include directories containing "NOTFOUND" // and for infinite loops this->CheckLocalGenerators(); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cc3f200789ad997065b195d01c137c0470551eff commit cc3f200789ad997065b195d01c137c0470551eff Author: Brad King AuthorDate: Mon Aug 10 10:01:26 2015 -0400 Commit: Brad King CommitDate: Mon Aug 10 10:01:26 2015 -0400 Revert topic 'cmState-definitions' A performance regression needs to be addressed. diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx index b06fb5c..2dab169 100644 --- a/Source/cmDefinitions.cxx +++ b/Source/cmDefinitions.cxx @@ -56,9 +56,9 @@ void cmDefinitions::Raise(const std::string& key, } bool cmDefinitions::HasKey(const std::string& key, - StackIter begin, StackIter end) + StackConstIter begin, StackConstIter end) { - for (StackIter it = begin; it != end; ++it) + for (StackConstIter it = begin; it != end; ++it) { MapType::const_iterator i = it->Map.find(key); if (i != it->Map.end()) @@ -94,12 +94,12 @@ std::vector cmDefinitions::UnusedKeys() const } //---------------------------------------------------------------------------- -cmDefinitions cmDefinitions::MakeClosure(StackIter begin, - StackIter end) +cmDefinitions cmDefinitions::MakeClosure(StackConstIter begin, + StackConstIter end) { cmDefinitions closure; std::set undefined; - for (StackIter it = begin; it != end; ++it) + for (StackConstIter it = begin; it != end; ++it) { // Consider local definitions. for(MapType::const_iterator mi = it->Map.begin(); @@ -125,12 +125,12 @@ cmDefinitions cmDefinitions::MakeClosure(StackIter begin, //---------------------------------------------------------------------------- std::vector -cmDefinitions::ClosureKeys(StackIter begin, StackIter end) +cmDefinitions::ClosureKeys(StackConstIter begin, StackConstIter end) { std::set bound; std::vector defined; - for (StackIter it = begin; it != end; ++it) + for (StackConstIter it = begin; it != end; ++it) { defined.reserve(defined.size() + it->Map.size()); for(MapType::const_iterator mi = it->Map.begin(); diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h index 411867c..5fdcaab 100644 --- a/Source/cmDefinitions.h +++ b/Source/cmDefinitions.h @@ -13,9 +13,6 @@ #define cmDefinitions_h #include "cmStandardIncludes.h" - -#include "cmLinkedTree.h" - #if defined(CMAKE_BUILD_WITH_CMAKE) #ifdef CMake_HAVE_CXX11_UNORDERED_MAP #include @@ -35,26 +32,26 @@ */ class cmDefinitions { - typedef cmLinkedTree::iterator StackIter; + typedef std::list::reverse_iterator StackIter; + typedef std::list::const_reverse_iterator StackConstIter; public: static const char* Get(const std::string& key, StackIter begin, StackIter end); - static void Raise(const std::string& key, - StackIter begin, StackIter end); + static void Raise(const std::string& key, StackIter begin, StackIter end); static bool HasKey(const std::string& key, - StackIter begin, StackIter end); + StackConstIter begin, StackConstIter end); /** Set (or unset if null) a value associated with a key. */ void Set(const std::string& key, const char* value); std::vector UnusedKeys() const; - static std::vector ClosureKeys(StackIter begin, - StackIter end); + static std::vector ClosureKeys(StackConstIter begin, + StackConstIter end); - static cmDefinitions MakeClosure(StackIter begin, StackIter end); + static cmDefinitions MakeClosure(StackConstIter begin, StackConstIter end); private: // String with existence boolean. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 6d079cd..3c818ff 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1140,42 +1140,6 @@ void cmGlobalGenerator::Configure() this->BinaryDirectories.insert( this->CMakeInstance->GetHomeOutputDirectory()); - if (const char *numStr = - this->GetCMakeInstance()->GetState() - ->GetInitializedCacheValue("CMAKE_NUMBER_OF_DEFINITION_STATES")) - { - int num = atoi(numStr); - this->GetCMakeInstance()->GetState()->ReserveDefinitions(num); - } - if (const char *numStr = - this->GetCMakeInstance()->GetState() - ->GetInitializedCacheValue("CMAKE_NUMBER_OF_SNAPSHOT_STATES")) - { - int num = atoi(numStr); - this->GetCMakeInstance()->GetState()->ReserveSnapshots(num); - } - if (const char *numStr = - this->GetCMakeInstance()->GetState() - ->GetInitializedCacheValue("CMAKE_NUMBER_OF_LISTFILE_STATES")) - { - int num = atoi(numStr); - this->GetCMakeInstance()->GetState()->ReserveListFiles(num); - } - if (const char *numStr = - this->GetCMakeInstance()->GetState() - ->GetInitializedCacheValue("CMAKE_NUMBER_OF_LOCAL_GENERATORS")) - { - int num = atoi(numStr); - this->GetCMakeInstance()->GetState()->ReserveDirectories(num); - } - if (const char *numStr = - this->GetCMakeInstance()->GetState() - ->GetInitializedCacheValue("CMAKE_NUMBER_OF_POLICY_STATES")) - { - int num = atoi(numStr); - this->GetCMakeInstance()->GetState()->ReservePolicies(num); - } - // now do it lg->GetMakefile()->Configure(); lg->GetMakefile()->EnforceDirectoryLevelRules(); @@ -1188,35 +1152,6 @@ void cmGlobalGenerator::Configure() ("CMAKE_NUMBER_OF_LOCAL_GENERATORS", num, "number of local generators", cmState::INTERNAL); - { - std::ostringstream str; - str << this->GetCMakeInstance()->GetState()->DefinitionsSize(); - this->GetCMakeInstance()->AddCacheEntry - ("CMAKE_NUMBER_OF_DEFINITION_STATES", str.str().c_str(), - "number of definition states", cmState::INTERNAL); - } - { - std::ostringstream str; - str << this->GetCMakeInstance()->GetState()->SnapshotsSize(); - this->GetCMakeInstance()->AddCacheEntry - ("CMAKE_NUMBER_OF_SNAPSHOT_STATES", str.str().c_str(), - "number of snapshot states", cmState::INTERNAL); - } - { - std::ostringstream str; - str << this->GetCMakeInstance()->GetState()->ListFilesSize(); - this->GetCMakeInstance()->AddCacheEntry - ("CMAKE_NUMBER_OF_LISTFILE_STATES", str.str().c_str(), - "number of listfile states", cmState::INTERNAL); - } - { - std::ostringstream str; - str << this->GetCMakeInstance()->GetState()->PoliciesSize(); - this->GetCMakeInstance()->AddCacheEntry - ("CMAKE_NUMBER_OF_POLICY_STATES", str.str().c_str(), - "number of policy states", cmState::INTERNAL); - } - // check for link libraries and include directories containing "NOTFOUND" // and for infinite loops this->CheckLocalGenerators(); diff --git a/Source/cmLinkedTree.h b/Source/cmLinkedTree.h index 385dff2..3bcb940 100644 --- a/Source/cmLinkedTree.h +++ b/Source/cmLinkedTree.h @@ -161,17 +161,6 @@ public: this->Data.clear(); } - size_t Size() const - { - return this->UpPositions.size(); - } - - void Reserve(size_t amount) - { - this->UpPositions.reserve(amount); - this->Data.reserve(amount); - } - private: T& GetReference(PositionType pos) { diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 15cfd0c..60a11e1 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -31,6 +31,7 @@ #endif #include "cmInstallGenerator.h" #include "cmTestGenerator.h" +#include "cmDefinitions.h" #include "cmAlgorithms.h" #include "cmake.h" #include // required for atoi @@ -46,7 +47,92 @@ class cmMakefile::Internals { public: + std::list VarStack; bool IsSourceFileTryCompile; + + void PushDefinitions() + { + this->VarStack.push_back(cmDefinitions()); + } + + void InitializeDefinitions(cmMakefile* parent) + { + this->VarStack.back() = + cmDefinitions::MakeClosure(parent->Internal->VarStack.rbegin(), + parent->Internal->VarStack.rend()); + } + + const char* GetDefinition(std::string const& name) + { + return cmDefinitions::Get(name, this->VarStack.rbegin(), + this->VarStack.rend()); + } + + bool IsInitialized(std::string const& name) + { + return cmDefinitions::HasKey(name, this->VarStack.rbegin(), + this->VarStack.rend()); + } + + void SetDefinition(std::string const& name, std::string const& value) + { + this->VarStack.back().Set(name, value.c_str()); + } + + void RemoveDefinition(std::string const& name) + { + this->VarStack.back().Set(name, 0); + } + + std::vector UnusedKeys() const + { + return this->VarStack.back().UnusedKeys(); + } + + std::vector ClosureKeys() const + { + return cmDefinitions::ClosureKeys(this->VarStack.rbegin(), + this->VarStack.rend()); + } + + void PopDefinitions() + { + this->VarStack.pop_back(); + } + + bool RaiseScope(std::string const& var, const char* varDef, cmMakefile* mf) + { + std::list::reverse_iterator it = this->VarStack.rbegin(); + assert(it != this->VarStack.rend()); + ++it; + if(it == this->VarStack.rend()) + { + cmLocalGenerator* plg = mf->LocalGenerator->GetParent(); + if(!plg) + { + return false; + } + // Update the definition in the parent directory top scope. This + // directory's scope was initialized by the closure of the parent + // scope, so we do not need to localize the definition first. + cmMakefile* parent = plg->GetMakefile(); + if (varDef) + { + parent->AddDefinition(var, varDef); + } + else + { + parent->RemoveDefinition(var); + } + return true; + } + // First localize the definition in the current scope. + cmDefinitions::Raise(var, this->VarStack.rbegin(), this->VarStack.rend()); + + // Now update the definition in the parent scope. + it->Set(var, varDef); + return true; + } }; // default is not to be building executables @@ -55,6 +141,7 @@ cmMakefile::cmMakefile(cmLocalGenerator* localGenerator) LocalGenerator(localGenerator), StateSnapshot(localGenerator->GetStateSnapshot()) { + this->Internal->PushDefinitions(); this->Internal->IsSourceFileTryCompile = false; // Initialize these first since AddDefaultDefinitions calls AddDefinition @@ -1480,6 +1567,9 @@ void cmMakefile::AddLinkLibrary(const std::string& lib) void cmMakefile::InitializeFromParent(cmMakefile* parent) { + // Initialize definitions with the closure of the parent scope. + this->Internal->InitializeDefinitions(parent); + this->StateSnapshot.InitializeFromParent(); this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR", @@ -1544,6 +1634,8 @@ void cmMakefile::PushFunctionScope(std::string const& fileName, fileName); assert(this->StateSnapshot.IsValid()); + this->Internal->PushDefinitions(); + this->PushLoopBlockBarrier(); #if defined(CMAKE_BUILD_WITH_CMAKE) @@ -1570,6 +1662,8 @@ void cmMakefile::PopFunctionScope(bool reportError) this->PopLoopBlockBarrier(); this->CheckForUnusedVariables(); + + this->Internal->PopDefinitions(); } void cmMakefile::PushMacroScope(std::string const& fileName, @@ -1872,7 +1966,7 @@ void cmMakefile::AddDefinition(const std::string& name, const char* value) { this->LogUnused("changing definition", name); } - this->StateSnapshot.SetDefinition(name, value); + this->Internal->SetDefinition(name, value); #ifdef CMAKE_BUILD_WITH_CMAKE cmVariableWatch* vv = this->GetVariableWatch(); @@ -1935,7 +2029,7 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value, this->GetState()->AddCacheEntry(name, haveVal ? val.c_str() : 0, doc, type); // if there was a definition then remove it - this->StateSnapshot.RemoveDefinition(name); + this->Internal->RemoveDefinition(name); } @@ -1945,9 +2039,7 @@ void cmMakefile::AddDefinition(const std::string& name, bool value) { this->LogUnused("changing definition", name); } - - this->StateSnapshot.SetDefinition(name, value ? "ON" : "OFF"); - + this->Internal->SetDefinition(name, value ? "ON" : "OFF"); #ifdef CMAKE_BUILD_WITH_CMAKE cmVariableWatch* vv = this->GetVariableWatch(); if ( vv ) @@ -1964,7 +2056,7 @@ void cmMakefile::CheckForUnusedVariables() const { return; } - const std::vector& unused = this->StateSnapshot.UnusedKeys(); + const std::vector& unused = this->Internal->UnusedKeys(); std::vector::const_iterator it = unused.begin(); for (; it != unused.end(); ++it) { @@ -1974,12 +2066,12 @@ void cmMakefile::CheckForUnusedVariables() const void cmMakefile::MarkVariableAsUsed(const std::string& var) { - this->StateSnapshot.GetDefinition(var); + this->Internal->GetDefinition(var); } bool cmMakefile::VariableInitialized(const std::string& var) const { - return this->StateSnapshot.IsInitialized(var); + return this->Internal->IsInitialized(var); } void cmMakefile::LogUnused(const char* reason, @@ -2027,7 +2119,7 @@ void cmMakefile::RemoveDefinition(const std::string& name) { this->LogUnused("unsetting", name); } - this->StateSnapshot.RemoveDefinition(name); + this->Internal->RemoveDefinition(name); #ifdef CMAKE_BUILD_WITH_CMAKE cmVariableWatch* vv = this->GetVariableWatch(); if ( vv ) @@ -2493,7 +2585,7 @@ const char* cmMakefile::GetRequiredDefinition(const std::string& name) const bool cmMakefile::IsDefinitionSet(const std::string& name) const { - const char* def = this->StateSnapshot.GetDefinition(name); + const char* def = this->Internal->GetDefinition(name); if(!def) { def = this->GetState()->GetInitializedCacheValue(name); @@ -2514,7 +2606,7 @@ bool cmMakefile::IsDefinitionSet(const std::string& name) const const char* cmMakefile::GetDefinition(const std::string& name) const { - const char* def = this->StateSnapshot.GetDefinition(name); + const char* def = this->Internal->GetDefinition(name); if(!def) { def = this->GetState()->GetInitializedCacheValue(name); @@ -2550,7 +2642,7 @@ const char* cmMakefile::GetSafeDefinition(const std::string& def) const std::vector cmMakefile::GetDefinitions() const { - std::vector res = this->StateSnapshot.ClosureKeys(); + std::vector res = this->Internal->ClosureKeys(); std::vector cacheKeys = this->GetState()->GetCacheEntryKeys(); res.insert(res.end(), cacheKeys.begin(), cacheKeys.end()); std::sort(res.begin(), res.end()); @@ -4329,17 +4421,8 @@ std::string cmMakefile::FormatListFileStack() const void cmMakefile::PushScope() { - std::string commandName; - long line = 0; - if (!this->ContextStack.empty()) - { - commandName = this->ContextStack.back()->Name; - line = this->ContextStack.back()->Line; - } - this->StateSnapshot = this->GetState()->CreateVariableScopeSnapshot( - this->StateSnapshot, - commandName, - line); + this->Internal->PushDefinitions(); + this->PushLoopBlockBarrier(); #if defined(CMAKE_BUILD_WITH_CMAKE) @@ -4357,9 +4440,7 @@ void cmMakefile::PopScope() this->CheckForUnusedVariables(); - this->StateSnapshot = - this->GetState()->Pop(this->StateSnapshot); - assert(this->StateSnapshot.IsValid()); + this->Internal->PopDefinitions(); } void cmMakefile::RaiseScope(const std::string& var, const char *varDef) @@ -4369,7 +4450,7 @@ void cmMakefile::RaiseScope(const std::string& var, const char *varDef) return; } - if (!this->StateSnapshot.RaiseScope(var, varDef)) + if (!this->Internal->RaiseScope(var, varDef, this)) { std::ostringstream m; m << "Cannot set \"" << var << "\": current scope has no parent."; diff --git a/Source/cmState.cxx b/Source/cmState.cxx index fc4fa30..f425861 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -15,13 +15,11 @@ #include "cmCacheManager.h" #include "cmCommand.h" #include "cmAlgorithms.h" -#include "cmDefinitions.h" #include struct cmState::SnapshotDataType { - cmState::PositionType ScopeParent; cmState::PositionType DirectoryParent; cmLinkedTree::iterator Policies; cmLinkedTree::iterator PolicyRoot; @@ -30,9 +28,6 @@ struct cmState::SnapshotDataType cmLinkedTree::iterator ExecutionListFile; cmLinkedTree::iterator BuildSystemDirectory; - cmLinkedTree::iterator Vars; - cmLinkedTree::iterator Root; - cmLinkedTree::iterator Parent; std::string EntryPointCommand; long EntryPointLine; std::vector::size_type IncludeDirectoryPosition; @@ -279,10 +274,6 @@ cmState::Snapshot cmState::Reset() pos->PolicyScope = this->PolicyStack.Root(); assert(pos->Policies.IsValid()); assert(pos->PolicyRoot.IsValid()); - this->VarTree.Clear(); - pos->Vars = this->VarTree.Extend(this->VarTree.Root()); - pos->Parent = this->VarTree.Root(); - pos->Root = this->VarTree.Root(); this->DefineProperty ("RULE_LAUNCH_COMPILE", cmProperty::DIRECTORY, @@ -651,56 +642,6 @@ bool cmState::UseMSYSShell() const return this->MSYSShell; } -size_t cmState::DefinitionsSize() const -{ - return this->VarTree.Size(); -} - -void cmState::ReserveDefinitions(size_t amount) -{ - this->VarTree.Reserve(amount); -} - -size_t cmState::SnapshotsSize() const -{ - return this->SnapshotData.Size(); -} - -void cmState::ReserveSnapshots(size_t amount) -{ - this->SnapshotData.Reserve(amount); -} - -size_t cmState::ListFilesSize() const -{ - return this->ExecutionListFiles.Size(); -} - -void cmState::ReserveListFiles(size_t amount) -{ - this->ExecutionListFiles.Reserve(amount); -} - -size_t cmState::DirectoriesSize() const -{ - return this->BuildsystemDirectory.Size(); -} - -void cmState::ReserveDirectories(size_t amount) -{ - this->BuildsystemDirectory.Reserve(amount); -} - -size_t cmState::PoliciesSize() const -{ - return this->PolicyStack.Size(); -} - -void cmState::ReservePolicies(size_t amount) -{ - this->PolicyStack.Reserve(amount); -} - const char* cmState::GetBinaryDirectory() const { return this->BinaryDirectory.c_str(); @@ -795,8 +736,7 @@ cmState::Snapshot cmState::CreateBaseSnapshot() { PositionType pos = this->SnapshotData.Extend(this->SnapshotData.Root()); pos->DirectoryParent = this->SnapshotData.Root(); - pos->ScopeParent = this->SnapshotData.Root(); - pos->SnapshotType = BaseType; + pos->SnapshotType = BuildsystemDirectoryType; pos->BuildSystemDirectory = this->BuildsystemDirectory.Extend(this->BuildsystemDirectory.Root()); pos->ExecutionListFile = @@ -810,10 +750,6 @@ cmState::Snapshot cmState::CreateBaseSnapshot() pos->PolicyScope = this->PolicyStack.Root(); assert(pos->Policies.IsValid()); assert(pos->PolicyRoot.IsValid()); - pos->Vars = this->VarTree.Extend(this->VarTree.Root()); - assert(pos->Vars.IsValid()); - pos->Parent = this->VarTree.Root(); - pos->Root = this->VarTree.Root(); return cmState::Snapshot(this, pos); } @@ -827,7 +763,6 @@ cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot, pos->EntryPointLine = entryPointLine; pos->EntryPointCommand = entryPointCommand; pos->DirectoryParent = originSnapshot.Position; - pos->ScopeParent = originSnapshot.Position; pos->SnapshotType = BuildsystemDirectoryType; pos->BuildSystemDirectory = this->BuildsystemDirectory.Extend( @@ -841,25 +776,6 @@ cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot, pos->PolicyScope = originSnapshot.Position->Policies; assert(pos->Policies.IsValid()); assert(pos->PolicyRoot.IsValid()); - - cmLinkedTree::iterator origin = originSnapshot.Position->Vars; - cmLinkedTree::iterator newVars = this->VarTree.Extend(origin); - - PositionType originPos = originSnapshot.Position; - while(originPos.IsValid()) - { - originPos->Vars = newVars; - if ((originPos->SnapshotType == BaseType) - || (originPos->SnapshotType == FunctionCallType) - || (originPos->SnapshotType == VariableScopeType) - || (originPos->SnapshotType == BuildsystemDirectoryType)) - break; - ++originPos; - } - - pos->Parent = newVars; - pos->Root = origin; - pos->Vars = this->VarTree.Extend(origin); return cmState::Snapshot(this, pos); } @@ -871,7 +787,6 @@ cmState::CreateFunctionCallSnapshot(cmState::Snapshot originSnapshot, { PositionType pos = this->SnapshotData.Extend(originSnapshot.Position, *originSnapshot.Position); - pos->ScopeParent = originSnapshot.Position; pos->EntryPointLine = entryPointLine; pos->EntryPointCommand = entryPointCommand; pos->SnapshotType = FunctionCallType; @@ -879,25 +794,6 @@ cmState::CreateFunctionCallSnapshot(cmState::Snapshot originSnapshot, originSnapshot.Position->ExecutionListFile, fileName); pos->BuildSystemDirectory->DirectoryEnd = pos; pos->PolicyScope = originSnapshot.Position->Policies; - assert(originSnapshot.Position->Vars.IsValid()); - cmLinkedTree::iterator origin = - originSnapshot.Position->Vars; - cmLinkedTree::iterator newVars = this->VarTree.Extend(origin); - - PositionType originPos = originSnapshot.Position; - while(originPos.IsValid()) - { - originPos->Vars = newVars; - if ((originPos->SnapshotType == BaseType) - || (originPos->SnapshotType == FunctionCallType) - || (originPos->SnapshotType == VariableScopeType) - || (originPos->SnapshotType == BuildsystemDirectoryType)) - break; - ++originPos; - } - - pos->Parent = newVars; - pos->Vars = this->VarTree.Extend(origin); return cmState::Snapshot(this, pos); } @@ -915,7 +811,6 @@ cmState::CreateMacroCallSnapshot(cmState::Snapshot originSnapshot, pos->SnapshotType = MacroCallType; pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile, fileName); - assert(originSnapshot.Position->Vars.IsValid()); pos->BuildSystemDirectory->DirectoryEnd = pos; pos->PolicyScope = originSnapshot.Position->Policies; return cmState::Snapshot(this, pos); @@ -934,48 +829,12 @@ cmState::CreateCallStackSnapshot(cmState::Snapshot originSnapshot, pos->SnapshotType = CallStackType; pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile, fileName); - assert(originSnapshot.Position->Vars.IsValid()); pos->BuildSystemDirectory->DirectoryEnd = pos; pos->PolicyScope = originSnapshot.Position->Policies; return cmState::Snapshot(this, pos); } cmState::Snapshot -cmState::CreateVariableScopeSnapshot(cmState::Snapshot originSnapshot, - std::string const& entryPointCommand, - long entryPointLine) -{ - PositionType pos = this->SnapshotData.Extend(originSnapshot.Position, - *originSnapshot.Position); - pos->ScopeParent = originSnapshot.Position; - pos->EntryPointLine = entryPointLine; - pos->EntryPointCommand = entryPointCommand; - pos->SnapshotType = VariableScopeType; - assert(originSnapshot.Position->Vars.IsValid()); - - cmLinkedTree::iterator origin = - originSnapshot.Position->Vars; - cmLinkedTree::iterator newVars = this->VarTree.Extend(origin); - - PositionType originPos = originSnapshot.Position; - while(originPos.IsValid()) - { - originPos->Vars = newVars; - if ((originPos->SnapshotType == BaseType) - || (originPos->SnapshotType == FunctionCallType) - || (originPos->SnapshotType == VariableScopeType) - || (originPos->SnapshotType == BuildsystemDirectoryType)) - break; - ++originPos; - } - - pos->Parent = newVars; - pos->Vars = this->VarTree.Extend(origin); - assert(pos->Vars.IsValid()); - return cmState::Snapshot(this, pos); -} - -cmState::Snapshot cmState::CreateInlineListFileSnapshot(cmState::Snapshot originSnapshot, const std::string& entryPointCommand, long entryPointLine, @@ -1160,8 +1019,7 @@ cmState::Snapshot cmState::Snapshot::GetCallStackParent() const { ++parentPos; } - if (parentPos->SnapshotType == cmState::BuildsystemDirectoryType - || parentPos->SnapshotType == cmState::BaseType) + if (parentPos->SnapshotType == cmState::BuildsystemDirectoryType) { return snapshot; } @@ -1263,72 +1121,6 @@ bool cmState::Snapshot::HasDefinedPolicyCMP0011() return !this->Position->Policies->IsEmpty(); } -const char* cmState::Snapshot::GetDefinition(std::string const& name) const -{ - assert(this->Position->Vars.IsValid()); - return cmDefinitions::Get(name, this->Position->Vars, - this->Position->Root); -} - -bool cmState::Snapshot::IsInitialized(std::string const& name) const -{ - return cmDefinitions::HasKey(name, this->Position->Vars, - this->Position->Root); -} - -void cmState::Snapshot::SetDefinition(std::string const& name, - std::string const& value) -{ - this->Position->Vars->Set(name, value.c_str()); -} - -void cmState::Snapshot::RemoveDefinition(std::string const& name) -{ - this->Position->Vars->Set(name, 0); -} - -std::vector cmState::Snapshot::UnusedKeys() const -{ - return this->Position->Vars->UnusedKeys(); -} - -std::vector cmState::Snapshot::ClosureKeys() const -{ - return cmDefinitions::ClosureKeys(this->Position->Vars, - this->Position->Root); -} - -bool cmState::Snapshot::RaiseScope(std::string const& var, const char* varDef) -{ - if(this->Position->ScopeParent == this->Position->DirectoryParent) - { - Snapshot parentDir = this->GetBuildsystemDirectoryParent(); - if(!parentDir.IsValid()) - { - return false; - } - // Update the definition in the parent directory top scope. This - // directory's scope was initialized by the closure of the parent - // scope, so we do not need to localize the definition first. - if (varDef) - { - parentDir.SetDefinition(var, varDef); - } - else - { - parentDir.RemoveDefinition(var); - } - return true; - } - // First localize the definition in the current scope. - cmDefinitions::Raise(var, this->Position->Vars, - this->Position->Root); - - // Now update the definition in the parent scope. - this->Position->Parent->Set(var, varDef); - return true; -} - static const std::string cmPropertySentinal = std::string(); template @@ -1365,11 +1157,6 @@ void InitializeContentFromParent(T& parentContent, void cmState::Snapshot::InitializeFromParent() { PositionType parent = this->Position->DirectoryParent; - assert(this->Position->Vars.IsValid()); - assert(parent->Vars.IsValid()); - - *this->Position->Vars = - cmDefinitions::MakeClosure(parent->Vars, parent->Root); InitializeContentFromParent(parent->BuildSystemDirectory->IncludeDirectories, this->Position->BuildSystemDirectory->IncludeDirectories, diff --git a/Source/cmState.h b/Source/cmState.h index 8380587..07aa2a5 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -21,8 +21,6 @@ class cmake; class cmCommand; -class cmDefinitions; -class cmListFileBacktrace; class cmState { @@ -37,14 +35,12 @@ public: enum SnapshotType { - BaseType, BuildsystemDirectoryType, FunctionCallType, MacroCallType, CallStackType, InlineListFileType, - PolicyScopeType, - VariableScopeType + PolicyScopeType }; class Directory; @@ -54,14 +50,6 @@ public: Snapshot(cmState* state = 0); Snapshot(cmState* state, PositionType position); - const char* GetDefinition(std::string const& name) const; - bool IsInitialized(std::string const& name) const; - void SetDefinition(std::string const& name, std::string const& value); - void RemoveDefinition(std::string const& name); - std::vector UnusedKeys() const; - std::vector ClosureKeys() const; - bool RaiseScope(std::string const& var, const char* varDef); - void SetListFile(std::string const& listfile); std::string GetExecutionListFile() const; @@ -166,9 +154,6 @@ public: std::string const& entryPointCommand, long entryPointLine, std::string const& fileName); - Snapshot CreateVariableScopeSnapshot(Snapshot originSnapshot, - std::string const& entryPointCommand, - long entryPointLine); Snapshot CreateInlineListFileSnapshot(Snapshot originSnapshot, const std::string& entryPointCommand, long entryPointLine, @@ -270,21 +255,6 @@ public: void SetMSYSShell(bool mSYSShell); bool UseMSYSShell() const; - size_t DefinitionsSize() const; - void ReserveDefinitions(size_t amount); - - size_t SnapshotsSize() const; - void ReserveSnapshots(size_t amount); - - size_t ListFilesSize() const; - void ReserveListFiles(size_t amount); - - size_t DirectoriesSize() const; - void ReserveDirectories(size_t amount); - - size_t PoliciesSize() const; - void ReservePolicies(size_t amount); - private: std::map PropertyDefinitions; std::vector EnabledLanguages; @@ -298,7 +268,6 @@ private: cmLinkedTree PolicyStack; cmLinkedTree SnapshotData; - cmLinkedTree VarTree; std::vector SourceDirectoryComponents; std::vector BinaryDirectoryComponents; ----------------------------------------------------------------------- Summary of changes: Source/cmDefinitions.cxx | 14 +-- Source/cmDefinitions.h | 17 ++-- Source/cmGlobalGenerator.cxx | 65 ------------- Source/cmLinkedTree.h | 11 --- Source/cmMakefile.cxx | 135 ++++++++++++++++++++------ Source/cmState.cxx | 217 +----------------------------------------- Source/cmState.h | 33 +------ 7 files changed, 125 insertions(+), 367 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 10 13:28:51 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 10 Aug 2015 13:28:51 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2123-gc708917 Message-ID: <20150810172851.9CA19B1197@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via c708917308f23dda4f9ed94eab33e758c1cf0c94 (commit) via 4e3c7725d0d724d7a8a0e8305d15713e01b20503 (commit) from 225e2d5bacae40956e489d8232f150607cc7b75a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c708917308f23dda4f9ed94eab33e758c1cf0c94 commit c708917308f23dda4f9ed94eab33e758c1cf0c94 Merge: 225e2d5 4e3c772 Author: Brad King AuthorDate: Mon Aug 10 13:28:50 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 10 13:28:50 2015 -0400 Merge topic 'bootstrap-no-ninja' into next 4e3c7725 bootstrap: Do not build Ninja generator http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4e3c7725d0d724d7a8a0e8305d15713e01b20503 commit 4e3c7725d0d724d7a8a0e8305d15713e01b20503 Author: Brad King AuthorDate: Mon Aug 10 13:26:52 2015 -0400 Commit: Brad King CommitDate: Mon Aug 10 13:26:52 2015 -0400 bootstrap: Do not build Ninja generator The CMake bootstrap process uses Makefile generators so there is no need to build the Ninja generators during bootstrap. diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 8c455b2..0321f2c 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -75,7 +75,9 @@ # include "cmGlobalWatcomWMakeGenerator.h" #endif #include "cmGlobalUnixMakefileGenerator3.h" -#include "cmGlobalNinjaGenerator.h" +#if defined(CMAKE_BUILD_WITH_CMAKE) +# include "cmGlobalNinjaGenerator.h" +#endif #include "cmExtraCodeLiteGenerator.h" #if !defined(CMAKE_BOOT_MINGW) @@ -1857,8 +1859,10 @@ void cmake::AddDefaultGenerators() #endif this->Generators.push_back( cmGlobalUnixMakefileGenerator3::NewFactory()); +#if defined(CMAKE_BUILD_WITH_CMAKE) this->Generators.push_back( cmGlobalNinjaGenerator::NewFactory()); +#endif #if defined(CMAKE_USE_WMAKE) this->Generators.push_back( cmGlobalWatcomWMakeGenerator::NewFactory()); diff --git a/bootstrap b/bootstrap index d778bbe..7b9a582 100755 --- a/bootstrap +++ b/bootstrap @@ -322,11 +322,6 @@ CMAKE_CXX_SOURCES="\ cmExprLexer \ cmExprParser \ cmExprParserHelper \ - cmGlobalNinjaGenerator \ - cmLocalNinjaGenerator \ - cmNinjaTargetGenerator \ - cmNinjaNormalTargetGenerator \ - cmNinjaUtilityTargetGenerator \ " if ${cmake_system_mingw}; then ----------------------------------------------------------------------- Summary of changes: Source/cmake.cxx | 6 +++++- bootstrap | 5 ----- 2 files changed, 5 insertions(+), 6 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Tue Aug 11 00:01:08 2015 From: kwrobot at kitware.com (Kitware Robot) Date: Tue, 11 Aug 2015 00:01:08 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-779-g489ab9c Message-ID: <20150811040108.22014B0FD5@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 489ab9cb3aba79c9f3c1c08d3507b0e19e8ca9c0 (commit) from 2f16e608436193f465d4bac181db36464fa88e22 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=489ab9cb3aba79c9f3c1c08d3507b0e19e8ca9c0 commit 489ab9cb3aba79c9f3c1c08d3507b0e19e8ca9c0 Author: Kitware Robot AuthorDate: Tue Aug 11 00:01:05 2015 -0400 Commit: Kitware Robot CommitDate: Tue Aug 11 00:01:05 2015 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index df17741..40653ad 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150810) +set(CMake_VERSION_PATCH 20150811) #set(CMake_VERSION_RC 1) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Tue Aug 11 08:47:07 2015 From: brad.king at kitware.com (Brad King) Date: Tue, 11 Aug 2015 08:47:07 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-782-gf33ccc2 Message-ID: <20150811124707.545A3B080A@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via f33ccc270e29f8df34144a56e14c476b1b48f0af (commit) via 1689c91d8d7667426fdca694d801b6189f68d37e (commit) via dd11f72ced8a5a42ae0a1d7ca8a51b94e670a66f (commit) from 489ab9cb3aba79c9f3c1c08d3507b0e19e8ca9c0 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f33ccc270e29f8df34144a56e14c476b1b48f0af commit f33ccc270e29f8df34144a56e14c476b1b48f0af Merge: 489ab9c 1689c91 Author: Brad King AuthorDate: Tue Aug 11 08:47:05 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 11 08:47:05 2015 -0400 Merge topic 'rm-Makefile-LocalGenerator' 1689c91d cmMakefile: Remove unused method. dd11f72c cmGlobalGenerator: Base exclusion computation on cmGeneratorTarget. ----------------------------------------------------------------------- Summary of changes: Source/cmGlobalGenerator.cxx | 13 +++++++------ Source/cmGlobalGenerator.h | 2 +- Source/cmGlobalNinjaGenerator.h | 2 +- Source/cmGlobalUnixMakefileGenerator3.cxx | 4 ++-- Source/cmGlobalVisualStudioGenerator.cxx | 10 ++++++---- Source/cmLocalNinjaGenerator.cxx | 2 +- Source/cmMakefile.h | 4 ---- 7 files changed, 18 insertions(+), 19 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Tue Aug 11 08:47:09 2015 From: brad.king at kitware.com (Brad King) Date: Tue, 11 Aug 2015 08:47:09 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-792-g6e5953e Message-ID: <20150811124709.A9D3DB082C@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 6e5953e9a441068f753e79f68af176ac34486234 (commit) via 29886ce76482a8c857841015b58d1e91a9ee5c8e (commit) via 197f4de110a59332757360110b1e90f6b07e1c97 (commit) via 44e071aeff4d533f116a7721919f9036c5d5a1d1 (commit) via 772ecef4b8037d5ce59d24772c05829872aff406 (commit) via 1f54bc1cf35707a5f1410ff4c6632d7cba351c40 (commit) via 7568199b4de18ed56ad8ef735c145c4a44327355 (commit) via 10040601a2e13cbb0653a20c55c1c696b5cacf29 (commit) via d9da6ee29fe0267ed347860f24f21be647ac81e8 (commit) via 27252b2414f5034b16a447273e1f249fdf317b72 (commit) from f33ccc270e29f8df34144a56e14c476b1b48f0af (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6e5953e9a441068f753e79f68af176ac34486234 commit 6e5953e9a441068f753e79f68af176ac34486234 Merge: f33ccc2 29886ce Author: Brad King AuthorDate: Tue Aug 11 08:47:08 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 11 08:47:08 2015 -0400 Merge topic 'use-generator-target' 29886ce7 cmTarget: Use a simpler delete algorithm. 197f4de1 cmTarget: Split storage of compile definitions from genexes. 44e071ae cmTarget: Split storage of compile features from genexes. 772ecef4 cmTarget: Split storage of compile options from genexes. 1f54bc1c cmTarget: Split storage of include directories from genexes. 7568199b cmTarget: Request only the link libraries where needed. 10040601 cmLinkImplementationLibraries: Move to namespace scope. d9da6ee2 cmLinkItem: Split to separate file. 27252b24 cmComputeLinkInformation: Simplify generator object access. ----------------------------------------------------------------------- Summary of changes: Source/CMakeLists.txt | 1 + Source/cmComputeLinkInformation.cxx | 18 +-- Source/cmGeneratorExpressionNode.cxx | 2 +- Source/cmGeneratorTarget.cxx | 2 +- Source/cmGlobalGenerator.cxx | 1 + Source/cmGlobalVisualStudio8Generator.cxx | 1 + Source/cmGlobalVisualStudioGenerator.cxx | 1 + Source/cmGlobalXCodeGenerator.cxx | 2 + Source/cmLinkItem.h | 59 +++++++ Source/cmQtAutoGenerators.cxx | 2 + Source/cmTarget.cxx | 244 +++++++++++++++-------------- Source/cmTarget.h | 46 +----- 12 files changed, 212 insertions(+), 167 deletions(-) create mode 100644 Source/cmLinkItem.h hooks/post-receive -- CMake From brad.king at kitware.com Tue Aug 11 08:47:11 2015 From: brad.king at kitware.com (Brad King) Date: Tue, 11 Aug 2015 08:47:11 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-806-g9e51147 Message-ID: <20150811124711.C44E0B085E@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 9e5114764637236849f62f4a82b525d5931b256e (commit) via 6d8a125e4988d5cb269b3d1e29a6114ecd0c47a4 (commit) via 5f66900e71fdc33b40c46bf8a87b35d88d280769 (commit) via c5b8841fd96727a290e148e8b5132f893f8b4d4e (commit) via 8f75ea3b5e0b43118a6ecba4dc11a583d287705c (commit) via 56f0540b5183036b46babbfc9b9ec0979e54992f (commit) via 19b546ef766acedfcc9e19541c71b6a56d7fe630 (commit) via f8be9ba9c258698ed88a7510cf2ba3335491f3da (commit) via bc1097e3d9a2d9545db849f9eef657477d83509a (commit) via 204aecdf82aa583b213464411069de4c8d7af64b (commit) via 3dd6f0a5bc0b6457c82df0b980a8f6ac87d1a6f9 (commit) via 73e4df99cb4d63f5ea8babb40656a74305d77e12 (commit) via 193699376af09bd77875d4ddfd10c3feb13ecdd2 (commit) via 32f131b0ca68bc88bbb32dbf03e76dfba24defe5 (commit) from 6e5953e9a441068f753e79f68af176ac34486234 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9e5114764637236849f62f4a82b525d5931b256e commit 9e5114764637236849f62f4a82b525d5931b256e Merge: 6e5953e 6d8a125 Author: Brad King AuthorDate: Tue Aug 11 08:47:10 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 11 08:47:10 2015 -0400 Merge topic 'global-generator-makefiles' 6d8a125e cmQtAutoGenerators: Prefer a generator to access global generator. 5f66900e cmGlobalGenerator: Port Find API to cmMakefile. c5b8841f cmGlobalGenerator: Create global targets from cmMakefiles. 8f75ea3b cmGlobalGenerator: Port global target creation to cmMakefile. 56f0540b cmGlobalGenerator: Port Configure-time check to cmMakefile. 19b546ef cmGlobalGenerator: Base final target property computation on Makefiles. f8be9ba9 cmGlobalGenerator: Base progress on Makefiles, not LocalGenerators. bc1097e3 cmExportLibraryDependenciesCommand: Port to cmMakefile. 204aecdf cmGlobalGenerator: Port configure-time code to cmMakefile. 3dd6f0a5 cmake: Port configure-time code to cmMakefile. 73e4df99 cmGlobalGenerator: Store a container of cmMakefiles. 19369937 cmGeneratorTarget: Port internal type to cmGeneratorTarget. 32f131b0 cmGeneratorTarget: Prefer the local generator to access the global. ----------------------------------------------------------------------- Summary of changes: Source/cmExportLibraryDependenciesCommand.cxx | 8 ++- Source/cmGeneratorTarget.cxx | 19 ++++--- Source/cmGetDirectoryPropertyCommand.cxx | 7 +-- Source/cmGetPropertyCommand.cxx | 9 +--- Source/cmGlobalGenerator.cxx | 68 ++++++++++++++++--------- Source/cmGlobalGenerator.h | 5 ++ Source/cmMakefile.cxx | 1 + Source/cmQtAutoGenerators.cxx | 4 +- Source/cmSetPropertyCommand.cxx | 10 +--- Source/cmake.cxx | 2 +- 10 files changed, 72 insertions(+), 61 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Tue Aug 11 08:47:13 2015 From: brad.king at kitware.com (Brad King) Date: Tue, 11 Aug 2015 08:47:13 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-808-g422d3f6 Message-ID: <20150811124713.B2B3AB0859@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 422d3f68de6bfa5c3fad68d2b030f2a618a821a2 (commit) via 4e3c7725d0d724d7a8a0e8305d15713e01b20503 (commit) from 9e5114764637236849f62f4a82b525d5931b256e (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=422d3f68de6bfa5c3fad68d2b030f2a618a821a2 commit 422d3f68de6bfa5c3fad68d2b030f2a618a821a2 Merge: 9e51147 4e3c772 Author: Brad King AuthorDate: Tue Aug 11 08:47:12 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 11 08:47:12 2015 -0400 Merge topic 'bootstrap-no-ninja' 4e3c7725 bootstrap: Do not build Ninja generator ----------------------------------------------------------------------- Summary of changes: Source/cmake.cxx | 6 +++++- bootstrap | 5 ----- 2 files changed, 5 insertions(+), 6 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Tue Aug 11 08:47:32 2015 From: brad.king at kitware.com (Brad King) Date: Tue, 11 Aug 2015 08:47:32 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2129-g4ccb6de Message-ID: <20150811124732.30B1BB094D@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 4ccb6de8681083cb15099fd69a9f01ed4515a2a3 (commit) via 422d3f68de6bfa5c3fad68d2b030f2a618a821a2 (commit) via 9e5114764637236849f62f4a82b525d5931b256e (commit) via 6e5953e9a441068f753e79f68af176ac34486234 (commit) via f33ccc270e29f8df34144a56e14c476b1b48f0af (commit) via 489ab9cb3aba79c9f3c1c08d3507b0e19e8ca9c0 (commit) from c708917308f23dda4f9ed94eab33e758c1cf0c94 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4ccb6de8681083cb15099fd69a9f01ed4515a2a3 commit 4ccb6de8681083cb15099fd69a9f01ed4515a2a3 Merge: c708917 422d3f6 Author: Brad King AuthorDate: Tue Aug 11 08:47:22 2015 -0400 Commit: Brad King CommitDate: Tue Aug 11 08:47:22 2015 -0400 Merge branch 'master' into next ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Tue Aug 11 08:56:34 2015 From: brad.king at kitware.com (Brad King) Date: Tue, 11 Aug 2015 08:56:34 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2132-g69e527a Message-ID: <20150811125634.64125B10CE@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 69e527a1c2f170afb6dbb5179fe2f97d609496ea (commit) via bb20daab87518c42a264f14820a7f32644cfd9ac (commit) via 6b64e252425e54995786e3547ae6348462211461 (commit) from 4ccb6de8681083cb15099fd69a9f01ed4515a2a3 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=69e527a1c2f170afb6dbb5179fe2f97d609496ea commit 69e527a1c2f170afb6dbb5179fe2f97d609496ea Merge: 4ccb6de bb20daa Author: Brad King AuthorDate: Tue Aug 11 08:56:33 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 11 08:56:33 2015 -0400 Merge topic 'fix-hpux-link-search-shared-flags' into next bb20daab HP-UX: Fix shared library search flags on HP-UX. 6b64e252 HP-UX: Fix linker search type flags for C shared libs on HP-UX http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bb20daab87518c42a264f14820a7f32644cfd9ac commit bb20daab87518c42a264f14820a7f32644cfd9ac Author: Chuck Atkins AuthorDate: Mon Aug 10 13:27:36 2015 -0400 Commit: Brad King CommitDate: Tue Aug 11 08:51:07 2015 -0400 HP-UX: Fix shared library search flags on HP-UX. In the HP-UX platform file, -Wl,-a-default is used for shared library searches. According to the reference manual for the HP compilers, the default option will search for shared libraries and fallback to static if not available. This restricts the search to use shared libs exclusively with the -Wl,-a,shared flag to put behavior in sync with all other platforms. See "HP Itanium-based Systems HP aC++/HP C Programmer's Guide" Chapter "Tools and Libraries", Section "Creating and Using Libraries" diff --git a/Modules/Platform/HP-UX.cmake b/Modules/Platform/HP-UX.cmake index 581301b..f103975 100644 --- a/Modules/Platform/HP-UX.cmake +++ b/Modules/Platform/HP-UX.cmake @@ -37,7 +37,7 @@ list(APPEND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES foreach(type SHARED_LIBRARY SHARED_MODULE EXE) foreach(lang C CXX) set(CMAKE_${type}_LINK_STATIC_${lang}_FLAGS "-Wl,-a,archive") - set(CMAKE_${type}_LINK_DYNAMIC_${lang}_FLAGS "-Wl,-a,default") + set(CMAKE_${type}_LINK_DYNAMIC_${lang}_FLAGS "-Wl,-a,shared") endforeach() endforeach() http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6b64e252425e54995786e3547ae6348462211461 commit 6b64e252425e54995786e3547ae6348462211461 Author: Chuck Atkins AuthorDate: Mon Aug 10 13:21:40 2015 -0400 Commit: Brad King CommitDate: Tue Aug 11 08:50:24 2015 -0400 HP-UX: Fix linker search type flags for C shared libs on HP-UX Since commit v2.8.7~31^2 (HP: Drive shared library linking with compiler front end, 2011-12-12) the C compiler is used to link shared libraries instead of calling the linker directly, so linker options need to be wrapped as -Wl,-foo instead of -foo. diff --git a/Modules/Platform/HP-UX.cmake b/Modules/Platform/HP-UX.cmake index 65cc731..581301b 100644 --- a/Modules/Platform/HP-UX.cmake +++ b/Modules/Platform/HP-UX.cmake @@ -33,18 +33,11 @@ list(APPEND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES # Initialize C and CXX link type selection flags. These flags are # used when building a shared library, shared module, or executable # that links to other libraries to select whether to use the static or -# shared versions of the libraries. Note that C modules and shared -# libs are built using ld directly so we leave off the "-Wl," portion. -foreach(type SHARED_LIBRARY SHARED_MODULE) - set(CMAKE_${type}_LINK_STATIC_C_FLAGS "-a archive") - set(CMAKE_${type}_LINK_DYNAMIC_C_FLAGS "-a default") -endforeach() -foreach(type EXE) - set(CMAKE_${type}_LINK_STATIC_C_FLAGS "-Wl,-a,archive") - set(CMAKE_${type}_LINK_DYNAMIC_C_FLAGS "-Wl,-a,default") -endforeach() +# shared versions of the libraries. foreach(type SHARED_LIBRARY SHARED_MODULE EXE) - set(CMAKE_${type}_LINK_STATIC_CXX_FLAGS "-Wl,-a,archive") - set(CMAKE_${type}_LINK_DYNAMIC_CXX_FLAGS "-Wl,-a,default") + foreach(lang C CXX) + set(CMAKE_${type}_LINK_STATIC_${lang}_FLAGS "-Wl,-a,archive") + set(CMAKE_${type}_LINK_DYNAMIC_${lang}_FLAGS "-Wl,-a,default") + endforeach() endforeach() ----------------------------------------------------------------------- Summary of changes: Modules/Platform/HP-UX.cmake | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Tue Aug 11 08:56:42 2015 From: brad.king at kitware.com (Brad King) Date: Tue, 11 Aug 2015 08:56:42 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2135-g4c8cbce Message-ID: <20150811125642.CB523B10DE@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 4c8cbce8b9a875e4d34544dded53ba0db1891eb1 (commit) via 8c076a8bdba8c5bc77fc01b3fafafa100fb59657 (commit) via 5790aca4adfc21e9e042e93fa0dd290aab91be5c (commit) from 69e527a1c2f170afb6dbb5179fe2f97d609496ea (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4c8cbce8b9a875e4d34544dded53ba0db1891eb1 commit 4c8cbce8b9a875e4d34544dded53ba0db1891eb1 Merge: 69e527a 8c076a8 Author: Brad King AuthorDate: Tue Aug 11 08:56:42 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 11 08:56:42 2015 -0400 Merge topic 'target_include_directories-relative-SYSTEM-dirs' into next 8c076a8b cmTarget: Remove unused AddSystemIncludeDirectories overload 5790aca4 target_include_directories: Support relative SYSTEM include dirs (#15464) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8c076a8bdba8c5bc77fc01b3fafafa100fb59657 commit 8c076a8bdba8c5bc77fc01b3fafafa100fb59657 Author: Gregor Jasny AuthorDate: Mon Aug 10 21:41:38 2015 +0200 Commit: Brad King CommitDate: Tue Aug 11 08:53:38 2015 -0400 cmTarget: Remove unused AddSystemIncludeDirectories overload diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index d3170e4..316d85c 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -1350,13 +1350,6 @@ cmTarget::AddSystemIncludeDirectories(const std::set &incs) this->SystemIncludeDirectories.insert(incs.begin(), incs.end()); } -//---------------------------------------------------------------------------- -void -cmTarget::AddSystemIncludeDirectories(const std::vector &incs) -{ - this->SystemIncludeDirectories.insert(incs.begin(), incs.end()); -} - #if defined(_WIN32) && !defined(__CYGWIN__) //---------------------------------------------------------------------------- void diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 490aaa3..2007b40 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -427,7 +427,6 @@ public: cmTarget::LinkLibraryType llt) const; void AddSystemIncludeDirectories(const std::set &incs); - void AddSystemIncludeDirectories(const std::vector &incs); std::set const & GetSystemIncludeDirectories() const { return this->SystemIncludeDirectories; } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5790aca4adfc21e9e042e93fa0dd290aab91be5c commit 5790aca4adfc21e9e042e93fa0dd290aab91be5c Author: Gregor Jasny AuthorDate: Sun Aug 9 22:24:34 2015 +0200 Commit: Brad King CommitDate: Tue Aug 11 08:53:00 2015 -0400 target_include_directories: Support relative SYSTEM include dirs (#15464) diff --git a/Source/cmTargetIncludeDirectoriesCommand.cxx b/Source/cmTargetIncludeDirectoriesCommand.cxx index 7824c89..7dfe9ca 100644 --- a/Source/cmTargetIncludeDirectoriesCommand.cxx +++ b/Source/cmTargetIncludeDirectoriesCommand.cxx @@ -75,7 +75,23 @@ bool cmTargetIncludeDirectoriesCommand tgt->InsertInclude(this->Join(content), lfbt, prepend); if (system) { - tgt->AddSystemIncludeDirectories(content); + std::string prefix = + this->Makefile->GetCurrentSourceDirectory() + std::string("/"); + std::set sdirs; + for (std::vector::const_iterator it = content.begin(); + it != content.end(); ++it) + { + if (cmSystemTools::FileIsFullPath(it->c_str()) + || cmGeneratorExpression::Find(*it) == 0) + { + sdirs.insert(*it); + } + else + { + sdirs.insert(prefix + *it); + } + } + tgt->AddSystemIncludeDirectories(sdirs); } return true; } @@ -91,7 +107,7 @@ void cmTargetIncludeDirectoriesCommand if (system) { - std::string joined = cmJoin(content, ";"); + std::string joined = this->Join(content); tgt->AppendProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES", joined.c_str()); } diff --git a/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt index 0215e93..dcee85e 100644 --- a/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt +++ b/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt @@ -35,6 +35,16 @@ add_library(imported_consumer2 imported_consumer.cpp) target_link_libraries(imported_consumer2 imported_consumer) target_compile_options(imported_consumer2 PRIVATE -Werror=unused-variable) +# add a target which has a relative system include +add_library(somelib imported_consumer.cpp) +target_include_directories(somelib SYSTEM PUBLIC "systemlib_header_only") +target_compile_options(somelib PRIVATE -Werror=unused-variable) + +# add a target which consumes a relative system include +add_library(otherlib upstream.cpp) +target_link_libraries(otherlib PUBLIC somelib) +target_compile_options(somelib PRIVATE -Werror=unused-variable) + macro(do_try_compile error_option) set(TC_ARGS IFACE_TRY_COMPILE_${error_option} ----------------------------------------------------------------------- Summary of changes: Source/cmTarget.cxx | 7 ------- Source/cmTarget.h | 1 - Source/cmTargetIncludeDirectoriesCommand.cxx | 20 ++++++++++++++++++-- .../SystemIncludeDirectories/CMakeLists.txt | 10 ++++++++++ 4 files changed, 28 insertions(+), 10 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Tue Aug 11 08:58:51 2015 From: brad.king at kitware.com (Brad King) Date: Tue, 11 Aug 2015 08:58:51 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2137-gfbe703a Message-ID: <20150811125851.AC227B116A@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via fbe703adf5f78d050c3317ad338add067a0889d6 (commit) via 8dc6cbcb248979a10ba96c9e7ce19fe18f009586 (commit) from 4c8cbce8b9a875e4d34544dded53ba0db1891eb1 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fbe703adf5f78d050c3317ad338add067a0889d6 commit fbe703adf5f78d050c3317ad338add067a0889d6 Merge: 4c8cbce 8dc6cbc Author: Brad King AuthorDate: Tue Aug 11 08:58:51 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 11 08:58:51 2015 -0400 Merge topic 'FindProtobuf-vs-x64' into next 8dc6cbcb FindProtobuf: Search x64 directories in VS-built protobuf source (#14833) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8dc6cbcb248979a10ba96c9e7ce19fe18f009586 commit 8dc6cbcb248979a10ba96c9e7ce19fe18f009586 Author: A. Jo?l Lamotte AuthorDate: Wed Jul 8 02:18:38 2015 +0200 Commit: Brad King CommitDate: Tue Aug 11 08:57:21 2015 -0400 FindProtobuf: Search x64 directories in VS-built protobuf source (#14833) Protobuf 2.6.x and lower do not use CMake (cmake is usable in Protobuf 3.x) but provide legacy Visual Studio projects files. Search their output directories in 64-bit builds. diff --git a/Modules/FindProtobuf.cmake b/Modules/FindProtobuf.cmake index f01bd41..335c408 100644 --- a/Modules/FindProtobuf.cmake +++ b/Modules/FindProtobuf.cmake @@ -9,8 +9,9 @@ # ``PROTOBUF_SRC_ROOT_FOLDER`` # When compiling with MSVC, if this cache variable is set # the protobuf-default VS project build locations -# (vsprojects/Debug & vsprojects/Release) will be searched -# for libraries and binaries. +# (vsprojects/Debug and vsprojects/Release +# or vsprojects/x64/Debug and vsprojects/x64/Release) +# will be searched for libraries and binaries. # ``PROTOBUF_IMPORT_DIRS`` # List of additional directories to be searched for # imported .proto files. @@ -146,18 +147,22 @@ function(PROTOBUF_GENERATE_CPP SRCS HDRS) set(${HDRS} ${${HDRS}} PARENT_SCOPE) endfunction() +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(_PROTOBUF_ARCH_DIR x64/) +endif() + # Internal function: search for normal library as well as a debug one # if the debug one is specified also include debug/optimized keywords # in *_LIBRARIES variable function(_protobuf_find_libraries name filename) find_library(${name}_LIBRARY NAMES ${filename} - PATHS ${PROTOBUF_SRC_ROOT_FOLDER}/vsprojects/Release) + PATHS ${PROTOBUF_SRC_ROOT_FOLDER}/vsprojects/${_PROTOBUF_ARCH_DIR}Release) mark_as_advanced(${name}_LIBRARY) find_library(${name}_LIBRARY_DEBUG NAMES ${filename} - PATHS ${PROTOBUF_SRC_ROOT_FOLDER}/vsprojects/Debug) + PATHS ${PROTOBUF_SRC_ROOT_FOLDER}/vsprojects/${_PROTOBUF_ARCH_DIR}Debug) mark_as_advanced(${name}_LIBRARY_DEBUG) if(NOT ${name}_LIBRARY_DEBUG) @@ -234,8 +239,8 @@ find_program(PROTOBUF_PROTOC_EXECUTABLE NAMES protoc DOC "The Google Protocol Buffers Compiler" PATHS - ${PROTOBUF_SRC_ROOT_FOLDER}/vsprojects/Release - ${PROTOBUF_SRC_ROOT_FOLDER}/vsprojects/Debug + ${PROTOBUF_SRC_ROOT_FOLDER}/vsprojects/${_PROTOBUF_ARCH_DIR}Release + ${PROTOBUF_SRC_ROOT_FOLDER}/vsprojects/${_PROTOBUF_ARCH_DIR}Debug ) mark_as_advanced(PROTOBUF_PROTOC_EXECUTABLE) ----------------------------------------------------------------------- Summary of changes: Modules/FindProtobuf.cmake | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Tue Aug 11 09:26:58 2015 From: brad.king at kitware.com (Brad King) Date: Tue, 11 Aug 2015 09:26:58 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2139-gb8f0363 Message-ID: <20150811132658.D786FB1528@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via b8f0363506ae5daa40f9635032dd3ba45c659cf6 (commit) via 6a77a77a62f6bfb66cea622621d6d1b68e775664 (commit) from fbe703adf5f78d050c3317ad338add067a0889d6 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b8f0363506ae5daa40f9635032dd3ba45c659cf6 commit b8f0363506ae5daa40f9635032dd3ba45c659cf6 Merge: fbe703a 6a77a77 Author: Brad King AuthorDate: Tue Aug 11 09:26:58 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 11 09:26:58 2015 -0400 Merge topic 'ExternalProject-hg-clone-without-update' into next 6a77a77a ExternalProject: Tell "hg clone" not to implicitly update http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6a77a77a62f6bfb66cea622621d6d1b68e775664 commit 6a77a77a62f6bfb66cea622621d6d1b68e775664 Author: A. Jo?l Lamotte AuthorDate: Tue Aug 11 01:01:25 2015 +0200 Commit: Brad King CommitDate: Tue Aug 11 09:25:31 2015 -0400 ExternalProject: Tell "hg clone" not to implicitly update By default Mercurial command "clone" will implicitly call "update" with the "default" branch after downloading the cloned repository. However ExternalProject_Add() always generates a second "update" command after cloning with a tag which is either specified or "tip" (equivalent to "default" by default). Therefore ExternalProject will first clone then update to default branch then update to another specified branch if provided. This leads to potentially very long clone operation (in particular when the repository default branch contain subrepos) which can lead to transaction abort triggered by the server. Simply use "hg clone -U" to avoid the implicit update during clone. Our following call to "hg update" will take care of updating anyway. diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index fdb146a..0fbf7c3 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -609,7 +609,7 @@ if(error_code) endif() execute_process( - COMMAND \"${hg_EXECUTABLE}\" clone \"${hg_repository}\" \"${src_name}\" + COMMAND \"${hg_EXECUTABLE}\" clone -U \"${hg_repository}\" \"${src_name}\" WORKING_DIRECTORY \"${work_dir}\" RESULT_VARIABLE error_code ) ----------------------------------------------------------------------- Summary of changes: Modules/ExternalProject.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Tue Aug 11 09:43:10 2015 From: brad.king at kitware.com (Brad King) Date: Tue, 11 Aug 2015 09:43:10 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2141-gb0190e6 Message-ID: <20150811134310.1FBCFB03D3@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via b0190e6d2273999a93481ff0a03f38e94c05c6e2 (commit) via 48c6e7f2cfc95fc851cf9711d9588f3498e647c4 (commit) from b8f0363506ae5daa40f9635032dd3ba45c659cf6 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b0190e6d2273999a93481ff0a03f38e94c05c6e2 commit b0190e6d2273999a93481ff0a03f38e94c05c6e2 Merge: b8f0363 48c6e7f Author: Brad King AuthorDate: Tue Aug 11 09:43:09 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 11 09:43:09 2015 -0400 Merge topic 'ctest-report-compiler-version' into next 48c6e7f2 CTest: Report to CDash the compiler version used to build the project http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=48c6e7f2cfc95fc851cf9711d9588f3498e647c4 commit 48c6e7f2cfc95fc851cf9711d9588f3498e647c4 Author: Daniel Pfeifer AuthorDate: Tue Aug 11 09:52:51 2015 +0200 Commit: Brad King CommitDate: Tue Aug 11 09:40:25 2015 -0400 CTest: Report to CDash the compiler version used to build the project The compiler version reported since commit v2.8.2~1018 (CTest-side support for compiler name and compiler version, 2009-10-12) only reported the version of the compiler used to build CMake, and only if it defined "_COMPILER_VERSION". Instead use the version of the compiler used to build the project CTest is testing. diff --git a/Modules/DartConfiguration.tcl.in b/Modules/DartConfiguration.tcl.in index 918b407..2da8354 100644 --- a/Modules/DartConfiguration.tcl.in +++ b/Modules/DartConfiguration.tcl.in @@ -69,6 +69,7 @@ UpdateType: @UPDATE_TYPE@ # Compiler info Compiler: @CMAKE_CXX_COMPILER@ +CompilerVersion: @CMAKE_CXX_COMPILER_VERSION@ # Dynamic analysis (MemCheck) PurifyCommand: @PURIFYCOMMAND@ diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index f65bd29..b976469 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -1546,9 +1546,8 @@ void cmCTest::StartXML(cmXMLWriter& xml, bool append) xml.Attribute("Append", "true"); } xml.Attribute("CompilerName", this->GetCTestConfiguration("Compiler")); -#ifdef _COMPILER_VERSION - xml.Attribute("CompilerVersion", _COMPILER_VERSION); -#endif + xml.Attribute("CompilerVersion", + this->GetCTestConfiguration("CompilerVersion")); xml.Attribute("OSName", info.GetOSName()); xml.Attribute("Hostname", info.GetHostname()); xml.Attribute("OSRelease", info.GetOSRelease()); ----------------------------------------------------------------------- Summary of changes: Modules/DartConfiguration.tcl.in | 1 + Source/cmCTest.cxx | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) hooks/post-receive -- CMake From chuck.atkins at kitware.com Tue Aug 11 09:46:24 2015 From: chuck.atkins at kitware.com (Chuck Atkins) Date: Tue, 11 Aug 2015 09:46:24 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2143-g1dac5ab Message-ID: <20150811134624.8F3F5B077C@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 1dac5ab737d1286f1e023fad3c0b26d2d57566a3 (commit) via 279714548e5cc50e515c0c9c09c17d9ec45420b1 (commit) from b0190e6d2273999a93481ff0a03f38e94c05c6e2 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1dac5ab737d1286f1e023fad3c0b26d2d57566a3 commit 1dac5ab737d1286f1e023fad3c0b26d2d57566a3 Merge: b0190e6 2797145 Author: Chuck Atkins AuthorDate: Tue Aug 11 09:46:23 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 11 09:46:23 2015 -0400 Merge topic 'add-link-search-static-properties-defaults' into next 27971454 Allow LINK_SEARCH_{START,END}_STATIC props to have default values. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=279714548e5cc50e515c0c9c09c17d9ec45420b1 commit 279714548e5cc50e515c0c9c09c17d9ec45420b1 Author: Chuck Atkins AuthorDate: Fri Aug 7 15:11:57 2015 -0400 Commit: Chuck Atkins CommitDate: Tue Aug 11 09:39:36 2015 -0400 Allow LINK_SEARCH_{START,END}_STATIC props to have default values. Use the CMAKE_LINK_SEARCH_START_STATIC and CMAKE_LINK_SEARCH_END_STATIC variables to initialize the LINK_SEARCH_START_STATIC and LINK_SEARCH_END_STATIC target properties respectively. diff --git a/Help/prop_tgt/LINK_SEARCH_END_STATIC.rst b/Help/prop_tgt/LINK_SEARCH_END_STATIC.rst index fe105bd..cf9c871 100644 --- a/Help/prop_tgt/LINK_SEARCH_END_STATIC.rst +++ b/Help/prop_tgt/LINK_SEARCH_END_STATIC.rst @@ -10,5 +10,9 @@ paths are not known or (in some cases) are in implicit link directories for the platform. By default CMake adds an option at the end of the library list (if necessary) to set the linker search type back to its starting type. This property switches the final linker -search type to -Bstatic regardless of how it started. See also -LINK_SEARCH_START_STATIC. +search type to -Bstatic regardless of how it started. + +This property is initialized by the value of the variable +CMAKE_LINK_SEARCH_END_STATIC if it is set when a target is created. + +See also LINK_SEARCH_START_STATIC. diff --git a/Help/prop_tgt/LINK_SEARCH_START_STATIC.rst b/Help/prop_tgt/LINK_SEARCH_START_STATIC.rst index ca899fe..2e0f9bd 100644 --- a/Help/prop_tgt/LINK_SEARCH_START_STATIC.rst +++ b/Help/prop_tgt/LINK_SEARCH_START_STATIC.rst @@ -11,4 +11,9 @@ directories for the platform. By default the linker search type is assumed to be -Bdynamic at the beginning of the library list. This property switches the assumption to -Bstatic. It is intended for use when linking an executable statically (e.g. with the GNU -static -option). See also LINK_SEARCH_END_STATIC. +option). + +This property is initialized by the value of the variable +CMAKE_LINK_SEARCH_START_STATIC if it is set when a target is created. + +See also LINK_SEARCH_END_STATIC. diff --git a/Help/prop_tgt/LINK_SEARCH_END_STATIC.rst b/Help/variable/CMAKE_LINK_SEARCH_END_STATIC.rst similarity index 68% copy from Help/prop_tgt/LINK_SEARCH_END_STATIC.rst copy to Help/variable/CMAKE_LINK_SEARCH_END_STATIC.rst index fe105bd..8a9951d 100644 --- a/Help/prop_tgt/LINK_SEARCH_END_STATIC.rst +++ b/Help/variable/CMAKE_LINK_SEARCH_END_STATIC.rst @@ -1,5 +1,5 @@ -LINK_SEARCH_END_STATIC ----------------------- +CMAKE_LINK_SEARCH_END_STATIC +---------------------------- End a link line such that static system libraries are used. @@ -10,5 +10,9 @@ paths are not known or (in some cases) are in implicit link directories for the platform. By default CMake adds an option at the end of the library list (if necessary) to set the linker search type back to its starting type. This property switches the final linker -search type to -Bstatic regardless of how it started. See also -LINK_SEARCH_START_STATIC. +search type to -Bstatic regardless of how it started. + +This variable is used to initialize the target property +LINK_SEARCH_END_STATIC for all targets. + +See also CMAKE_LINK_SEARCH_START_STATIC. diff --git a/Help/prop_tgt/LINK_SEARCH_START_STATIC.rst b/Help/variable/CMAKE_LINK_SEARCH_START_STATIC.rst similarity index 73% copy from Help/prop_tgt/LINK_SEARCH_START_STATIC.rst copy to Help/variable/CMAKE_LINK_SEARCH_START_STATIC.rst index ca899fe..715db4b 100644 --- a/Help/prop_tgt/LINK_SEARCH_START_STATIC.rst +++ b/Help/variable/CMAKE_LINK_SEARCH_START_STATIC.rst @@ -1,5 +1,5 @@ -LINK_SEARCH_START_STATIC ------------------------- +CMAKE_LINK_SEARCH_START_STATIC +------------------------------ Assume the linker looks for static libraries by default. @@ -11,4 +11,9 @@ directories for the platform. By default the linker search type is assumed to be -Bdynamic at the beginning of the library list. This property switches the assumption to -Bstatic. It is intended for use when linking an executable statically (e.g. with the GNU -static -option). See also LINK_SEARCH_END_STATIC. +option). + +This variable is used to initialize the target property +LINK_SEARCH_START_STATIC for all targets. + +See also CMAKE_LINK_SEARCH_END_STATIC. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index c16472e..12dddd2 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -522,9 +522,10 @@ bool cmComputeLinkInformation::Compute() // libraries are found. const char* lss = this->Target->Target->GetProperty("LINK_SEARCH_END_STATIC"); - if(cmSystemTools::IsOn(lss)) + if(lss) { - this->SetCurrentLinkType(LinkStatic); + this->SetCurrentLinkType( + cmSystemTools::IsOn(lss) ? LinkStatic : LinkShared); } else { @@ -862,7 +863,8 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo() const char* lss = this->Target->Target->GetProperty("LINK_SEARCH_START_STATIC"); this->StartLinkType = cmSystemTools::IsOn(lss)? LinkStatic : LinkShared; - this->CurrentLinkType = this->StartLinkType; + this->CurrentLinkType = LinkUnknown; + this->SetCurrentLinkType(this->StartLinkType); } //---------------------------------------------------------------------------- diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index d3170e4..2e765ac 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -306,6 +306,8 @@ void cmTarget::SetMakefile(cmMakefile* mf) this->SetPropertyDefault("CXX_STANDARD", 0); this->SetPropertyDefault("CXX_STANDARD_REQUIRED", 0); this->SetPropertyDefault("CXX_EXTENSIONS", 0); + this->SetPropertyDefault("LINK_SEARCH_START_STATIC", 0); + this->SetPropertyDefault("LINK_SEARCH_END_STATIC", 0); } // Collect the set of configuration types. diff --git a/Tests/RunCMake/set_property/LINK_SEARCH_STATIC.cmake b/Tests/RunCMake/set_property/LINK_SEARCH_STATIC.cmake new file mode 100644 index 0000000..70d2fee --- /dev/null +++ b/Tests/RunCMake/set_property/LINK_SEARCH_STATIC.cmake @@ -0,0 +1,73 @@ +project(LinkSearchStatic) + +set(CMAKE_LINK_SEARCH_START_STATIC ON) +add_executable(LinkSearchStartStaticInit1 LinkStatic.c) +get_target_property(LSSS LinkSearchStartStaticInit1 + LINK_SEARCH_START_STATIC) +if(NOT LSSS) + message(FATAL_ERROR "Failed to correctly initialize LINK_SEARCH_START_STATIC") +endif() +unset(CMAKE_LINK_SEARCH_START_STATIC) + +add_executable(LinkSearchStartStaticSet1 LinkStatic.c) +set_target_properties(LinkSearchStartStaticSet1 PROPERTIES + LINK_SEARCH_START_STATIC ON) +get_target_property(LSSS LinkSearchStartStaticSet1 + LINK_SEARCH_START_STATIC) +if(NOT LSSS) + message(FATAL_ERROR "Failed to correctly set LINK_SEARCH_START_STATIC") +endif() + +set(CMAKE_LINK_SEARCH_START_STATIC OFF) +add_executable(LinkSearchStartStaticInit2 LinkStatic.c) +get_target_property(LSSS LinkSearchStartStaticInit2 + LINK_SEARCH_START_STATIC) +if(LSSS) + message(FATAL_ERROR "Failed to correctly initialize LINK_SEARCH_START_STATIC") +endif() +unset(CMAKE_LINK_SEARCH_START_STATIC) + +add_executable(LinkSearchStartStaticSet2 LinkStatic.c) +set_target_properties(LinkSearchStartStaticSet2 PROPERTIES + LINK_SEARCH_START_STATIC OFF) +get_target_property(LSSS LinkSearchStartStaticSet2 + LINK_SEARCH_START_STATIC) +if(LSSS) + message(FATAL_ERROR "Failed to correctly set LINK_SEARCH_START_STATIC") +endif() + +set(CMAKE_LINK_SEARCH_END_STATIC ON) +add_executable(LinkSearchEndStaticInit1 LinkStatic.c) +get_target_property(LSES LinkSearchEndStaticInit1 + LINK_SEARCH_END_STATIC) +if(NOT LSES) + message(FATAL_ERROR "Failed to correctly initialize LINK_SEARCH_END_STATIC") +endif() +unset(CMAKE_LINK_SEARCH_END_STATIC) + +add_executable(LinkSearchEndStaticSet1 LinkStatic.c) +set_target_properties(LinkSearchEndStaticSet1 PROPERTIES + LINK_SEARCH_END_STATIC ON) +get_target_property(LSSS LinkSearchEndStaticSet1 + LINK_SEARCH_END_STATIC) +if(NOT LSSS) + message(FATAL_ERROR "Failed to correctly set LINK_SEARCH_END_STATIC") +endif() + +set(CMAKE_LINK_SEARCH_END_STATIC OFF) +add_executable(LinkSearchEndStaticInit2 LinkStatic.c) +get_target_property(LSES LinkSearchEndStaticInit2 + LINK_SEARCH_END_STATIC) +if(LSES) + message(FATAL_ERROR "Failed to correctly initialize LINK_SEARCH_END_STATIC") +endif() +unset(CMAKE_LINK_SEARCH_END_STATIC) + +add_executable(LinkSearchEndStaticSet2 LinkStatic.c) +set_target_properties(LinkSearchEndStaticSet2 PROPERTIES + LINK_SEARCH_END_STATIC ON) +get_target_property(LSSS LinkSearchEndStaticSet2 + LINK_SEARCH_END_STATIC) +if(NOT LSSS) + message(FATAL_ERROR "Failed to correctly set LINK_SEARCH_END_STATIC") +endif() diff --git a/Tests/RunCMake/set_property/LinkStatic.c b/Tests/RunCMake/set_property/LinkStatic.c new file mode 100644 index 0000000..3600977 --- /dev/null +++ b/Tests/RunCMake/set_property/LinkStatic.c @@ -0,0 +1,5 @@ +#include +int main(void) +{ + return (int)sin(0); +} diff --git a/Tests/RunCMake/set_property/RunCMakeTest.cmake b/Tests/RunCMake/set_property/RunCMakeTest.cmake index 54e63f7..ada8804 100644 --- a/Tests/RunCMake/set_property/RunCMakeTest.cmake +++ b/Tests/RunCMake/set_property/RunCMakeTest.cmake @@ -1,3 +1,4 @@ include(RunCMake) run_cmake(LINK_LIBRARIES) +run_cmake(LINK_SEARCH_STATIC) ----------------------------------------------------------------------- Summary of changes: Help/prop_tgt/LINK_SEARCH_END_STATIC.rst | 8 ++- Help/prop_tgt/LINK_SEARCH_START_STATIC.rst | 7 +- .../CMAKE_LINK_SEARCH_END_STATIC.rst} | 12 ++-- .../CMAKE_LINK_SEARCH_START_STATIC.rst} | 11 ++- Source/cmComputeLinkInformation.cxx | 8 ++- Source/cmTarget.cxx | 2 + .../RunCMake/set_property/LINK_SEARCH_STATIC.cmake | 73 ++++++++++++++++++++ .../set_property}/LinkStatic.c | 0 Tests/RunCMake/set_property/RunCMakeTest.cmake | 1 + 9 files changed, 109 insertions(+), 13 deletions(-) copy Help/{prop_tgt/LINK_SEARCH_END_STATIC.rst => variable/CMAKE_LINK_SEARCH_END_STATIC.rst} (68%) copy Help/{prop_tgt/LINK_SEARCH_START_STATIC.rst => variable/CMAKE_LINK_SEARCH_START_STATIC.rst} (73%) create mode 100644 Tests/RunCMake/set_property/LINK_SEARCH_STATIC.cmake copy Tests/{LinkStatic => RunCMake/set_property}/LinkStatic.c (100%) hooks/post-receive -- CMake From chuck.atkins at kitware.com Tue Aug 11 10:02:03 2015 From: chuck.atkins at kitware.com (Chuck Atkins) Date: Tue, 11 Aug 2015 10:02:03 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2145-gc25a6f4 Message-ID: <20150811140203.AB079B11E0@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via c25a6f43e2f8b1a4f632ac37cc614c8ca6690b86 (commit) via a4b33ad43fa817cea5b66457d413255dd230a159 (commit) from 1dac5ab737d1286f1e023fad3c0b26d2d57566a3 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c25a6f43e2f8b1a4f632ac37cc614c8ca6690b86 commit c25a6f43e2f8b1a4f632ac37cc614c8ca6690b86 Merge: 1dac5ab a4b33ad Author: Chuck Atkins AuthorDate: Tue Aug 11 10:02:02 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 11 10:02:02 2015 -0400 Merge topic 'add-link-search-static-properties-defaults' into next a4b33ad4 Allow LINK_SEARCH_{START,END}_STATIC props to have default values. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a4b33ad43fa817cea5b66457d413255dd230a159 commit a4b33ad43fa817cea5b66457d413255dd230a159 Author: Chuck Atkins AuthorDate: Fri Aug 7 15:11:57 2015 -0400 Commit: Chuck Atkins CommitDate: Tue Aug 11 10:01:02 2015 -0400 Allow LINK_SEARCH_{START,END}_STATIC props to have default values. Use the CMAKE_LINK_SEARCH_START_STATIC and CMAKE_LINK_SEARCH_END_STATIC variables to initialize the LINK_SEARCH_START_STATIC and LINK_SEARCH_END_STATIC target properties respectively. diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 9066d97..e0dbdeb 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -47,6 +47,8 @@ Variables that Provide Information /variable/CMAKE_JOB_POOL_COMPILE /variable/CMAKE_JOB_POOL_LINK /variable/CMAKE_LINK_LIBRARY_SUFFIX + /variable/CMAKE_LINK_SEARCH_END_STATIC + /variable/CMAKE_LINK_SEARCH_START_STATIC /variable/CMAKE_MAJOR_VERSION /variable/CMAKE_MAKE_PROGRAM /variable/CMAKE_MATCH_COUNT diff --git a/Help/prop_tgt/LINK_SEARCH_END_STATIC.rst b/Help/prop_tgt/LINK_SEARCH_END_STATIC.rst index fe105bd..cf9c871 100644 --- a/Help/prop_tgt/LINK_SEARCH_END_STATIC.rst +++ b/Help/prop_tgt/LINK_SEARCH_END_STATIC.rst @@ -10,5 +10,9 @@ paths are not known or (in some cases) are in implicit link directories for the platform. By default CMake adds an option at the end of the library list (if necessary) to set the linker search type back to its starting type. This property switches the final linker -search type to -Bstatic regardless of how it started. See also -LINK_SEARCH_START_STATIC. +search type to -Bstatic regardless of how it started. + +This property is initialized by the value of the variable +CMAKE_LINK_SEARCH_END_STATIC if it is set when a target is created. + +See also LINK_SEARCH_START_STATIC. diff --git a/Help/prop_tgt/LINK_SEARCH_START_STATIC.rst b/Help/prop_tgt/LINK_SEARCH_START_STATIC.rst index ca899fe..2e0f9bd 100644 --- a/Help/prop_tgt/LINK_SEARCH_START_STATIC.rst +++ b/Help/prop_tgt/LINK_SEARCH_START_STATIC.rst @@ -11,4 +11,9 @@ directories for the platform. By default the linker search type is assumed to be -Bdynamic at the beginning of the library list. This property switches the assumption to -Bstatic. It is intended for use when linking an executable statically (e.g. with the GNU -static -option). See also LINK_SEARCH_END_STATIC. +option). + +This property is initialized by the value of the variable +CMAKE_LINK_SEARCH_START_STATIC if it is set when a target is created. + +See also LINK_SEARCH_END_STATIC. diff --git a/Help/prop_tgt/LINK_SEARCH_END_STATIC.rst b/Help/variable/CMAKE_LINK_SEARCH_END_STATIC.rst similarity index 68% copy from Help/prop_tgt/LINK_SEARCH_END_STATIC.rst copy to Help/variable/CMAKE_LINK_SEARCH_END_STATIC.rst index fe105bd..8a9951d 100644 --- a/Help/prop_tgt/LINK_SEARCH_END_STATIC.rst +++ b/Help/variable/CMAKE_LINK_SEARCH_END_STATIC.rst @@ -1,5 +1,5 @@ -LINK_SEARCH_END_STATIC ----------------------- +CMAKE_LINK_SEARCH_END_STATIC +---------------------------- End a link line such that static system libraries are used. @@ -10,5 +10,9 @@ paths are not known or (in some cases) are in implicit link directories for the platform. By default CMake adds an option at the end of the library list (if necessary) to set the linker search type back to its starting type. This property switches the final linker -search type to -Bstatic regardless of how it started. See also -LINK_SEARCH_START_STATIC. +search type to -Bstatic regardless of how it started. + +This variable is used to initialize the target property +LINK_SEARCH_END_STATIC for all targets. + +See also CMAKE_LINK_SEARCH_START_STATIC. diff --git a/Help/prop_tgt/LINK_SEARCH_START_STATIC.rst b/Help/variable/CMAKE_LINK_SEARCH_START_STATIC.rst similarity index 73% copy from Help/prop_tgt/LINK_SEARCH_START_STATIC.rst copy to Help/variable/CMAKE_LINK_SEARCH_START_STATIC.rst index ca899fe..715db4b 100644 --- a/Help/prop_tgt/LINK_SEARCH_START_STATIC.rst +++ b/Help/variable/CMAKE_LINK_SEARCH_START_STATIC.rst @@ -1,5 +1,5 @@ -LINK_SEARCH_START_STATIC ------------------------- +CMAKE_LINK_SEARCH_START_STATIC +------------------------------ Assume the linker looks for static libraries by default. @@ -11,4 +11,9 @@ directories for the platform. By default the linker search type is assumed to be -Bdynamic at the beginning of the library list. This property switches the assumption to -Bstatic. It is intended for use when linking an executable statically (e.g. with the GNU -static -option). See also LINK_SEARCH_END_STATIC. +option). + +This variable is used to initialize the target property +LINK_SEARCH_START_STATIC for all targets. + +See also CMAKE_LINK_SEARCH_END_STATIC. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index c16472e..12dddd2 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -522,9 +522,10 @@ bool cmComputeLinkInformation::Compute() // libraries are found. const char* lss = this->Target->Target->GetProperty("LINK_SEARCH_END_STATIC"); - if(cmSystemTools::IsOn(lss)) + if(lss) { - this->SetCurrentLinkType(LinkStatic); + this->SetCurrentLinkType( + cmSystemTools::IsOn(lss) ? LinkStatic : LinkShared); } else { @@ -862,7 +863,8 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo() const char* lss = this->Target->Target->GetProperty("LINK_SEARCH_START_STATIC"); this->StartLinkType = cmSystemTools::IsOn(lss)? LinkStatic : LinkShared; - this->CurrentLinkType = this->StartLinkType; + this->CurrentLinkType = LinkUnknown; + this->SetCurrentLinkType(this->StartLinkType); } //---------------------------------------------------------------------------- diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index d3170e4..2e765ac 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -306,6 +306,8 @@ void cmTarget::SetMakefile(cmMakefile* mf) this->SetPropertyDefault("CXX_STANDARD", 0); this->SetPropertyDefault("CXX_STANDARD_REQUIRED", 0); this->SetPropertyDefault("CXX_EXTENSIONS", 0); + this->SetPropertyDefault("LINK_SEARCH_START_STATIC", 0); + this->SetPropertyDefault("LINK_SEARCH_END_STATIC", 0); } // Collect the set of configuration types. diff --git a/Tests/RunCMake/set_property/LINK_SEARCH_STATIC.cmake b/Tests/RunCMake/set_property/LINK_SEARCH_STATIC.cmake new file mode 100644 index 0000000..70d2fee --- /dev/null +++ b/Tests/RunCMake/set_property/LINK_SEARCH_STATIC.cmake @@ -0,0 +1,73 @@ +project(LinkSearchStatic) + +set(CMAKE_LINK_SEARCH_START_STATIC ON) +add_executable(LinkSearchStartStaticInit1 LinkStatic.c) +get_target_property(LSSS LinkSearchStartStaticInit1 + LINK_SEARCH_START_STATIC) +if(NOT LSSS) + message(FATAL_ERROR "Failed to correctly initialize LINK_SEARCH_START_STATIC") +endif() +unset(CMAKE_LINK_SEARCH_START_STATIC) + +add_executable(LinkSearchStartStaticSet1 LinkStatic.c) +set_target_properties(LinkSearchStartStaticSet1 PROPERTIES + LINK_SEARCH_START_STATIC ON) +get_target_property(LSSS LinkSearchStartStaticSet1 + LINK_SEARCH_START_STATIC) +if(NOT LSSS) + message(FATAL_ERROR "Failed to correctly set LINK_SEARCH_START_STATIC") +endif() + +set(CMAKE_LINK_SEARCH_START_STATIC OFF) +add_executable(LinkSearchStartStaticInit2 LinkStatic.c) +get_target_property(LSSS LinkSearchStartStaticInit2 + LINK_SEARCH_START_STATIC) +if(LSSS) + message(FATAL_ERROR "Failed to correctly initialize LINK_SEARCH_START_STATIC") +endif() +unset(CMAKE_LINK_SEARCH_START_STATIC) + +add_executable(LinkSearchStartStaticSet2 LinkStatic.c) +set_target_properties(LinkSearchStartStaticSet2 PROPERTIES + LINK_SEARCH_START_STATIC OFF) +get_target_property(LSSS LinkSearchStartStaticSet2 + LINK_SEARCH_START_STATIC) +if(LSSS) + message(FATAL_ERROR "Failed to correctly set LINK_SEARCH_START_STATIC") +endif() + +set(CMAKE_LINK_SEARCH_END_STATIC ON) +add_executable(LinkSearchEndStaticInit1 LinkStatic.c) +get_target_property(LSES LinkSearchEndStaticInit1 + LINK_SEARCH_END_STATIC) +if(NOT LSES) + message(FATAL_ERROR "Failed to correctly initialize LINK_SEARCH_END_STATIC") +endif() +unset(CMAKE_LINK_SEARCH_END_STATIC) + +add_executable(LinkSearchEndStaticSet1 LinkStatic.c) +set_target_properties(LinkSearchEndStaticSet1 PROPERTIES + LINK_SEARCH_END_STATIC ON) +get_target_property(LSSS LinkSearchEndStaticSet1 + LINK_SEARCH_END_STATIC) +if(NOT LSSS) + message(FATAL_ERROR "Failed to correctly set LINK_SEARCH_END_STATIC") +endif() + +set(CMAKE_LINK_SEARCH_END_STATIC OFF) +add_executable(LinkSearchEndStaticInit2 LinkStatic.c) +get_target_property(LSES LinkSearchEndStaticInit2 + LINK_SEARCH_END_STATIC) +if(LSES) + message(FATAL_ERROR "Failed to correctly initialize LINK_SEARCH_END_STATIC") +endif() +unset(CMAKE_LINK_SEARCH_END_STATIC) + +add_executable(LinkSearchEndStaticSet2 LinkStatic.c) +set_target_properties(LinkSearchEndStaticSet2 PROPERTIES + LINK_SEARCH_END_STATIC ON) +get_target_property(LSSS LinkSearchEndStaticSet2 + LINK_SEARCH_END_STATIC) +if(NOT LSSS) + message(FATAL_ERROR "Failed to correctly set LINK_SEARCH_END_STATIC") +endif() diff --git a/Tests/RunCMake/set_property/LinkStatic.c b/Tests/RunCMake/set_property/LinkStatic.c new file mode 100644 index 0000000..3600977 --- /dev/null +++ b/Tests/RunCMake/set_property/LinkStatic.c @@ -0,0 +1,5 @@ +#include +int main(void) +{ + return (int)sin(0); +} diff --git a/Tests/RunCMake/set_property/RunCMakeTest.cmake b/Tests/RunCMake/set_property/RunCMakeTest.cmake index 54e63f7..ada8804 100644 --- a/Tests/RunCMake/set_property/RunCMakeTest.cmake +++ b/Tests/RunCMake/set_property/RunCMakeTest.cmake @@ -1,3 +1,4 @@ include(RunCMake) run_cmake(LINK_LIBRARIES) +run_cmake(LINK_SEARCH_STATIC) ----------------------------------------------------------------------- Summary of changes: Help/manual/cmake-variables.7.rst | 2 ++ 1 file changed, 2 insertions(+) hooks/post-receive -- CMake From brad.king at kitware.com Tue Aug 11 10:26:36 2015 From: brad.king at kitware.com (Brad King) Date: Tue, 11 Aug 2015 10:26:36 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2148-gc7fa36d Message-ID: <20150811142636.B837CB154E@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via c7fa36d3ea7da82bfdfc147d985303b0b5a3a6b7 (commit) via c180f0cbc224bf7f3fe9bcfdeea2d3c712c61084 (commit) via 586b2e5e3633db1e1749dc2bdd69f6240b714139 (commit) from c25a6f43e2f8b1a4f632ac37cc614c8ca6690b86 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c7fa36d3ea7da82bfdfc147d985303b0b5a3a6b7 commit c7fa36d3ea7da82bfdfc147d985303b0b5a3a6b7 Merge: c25a6f4 c180f0c Author: Brad King AuthorDate: Tue Aug 11 10:26:36 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 11 10:26:36 2015 -0400 Merge topic 'tests-use-CMAKE_MAKE_PROGRAM' into next c180f0cb Tests: Fix CMAKE_MAKE_PROGRAM selection in FortranC.Flags test 586b2e5e Tests: Fix CMAKE_MAKE_PROGRAM selection in CMakeOnly tests http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c180f0cbc224bf7f3fe9bcfdeea2d3c712c61084 commit c180f0cbc224bf7f3fe9bcfdeea2d3c712c61084 Author: Brad King AuthorDate: Mon Aug 10 14:09:22 2015 -0400 Commit: Brad King CommitDate: Tue Aug 11 10:18:05 2015 -0400 Tests: Fix CMAKE_MAKE_PROGRAM selection in FortranC.Flags test Use the explicitly-tested make program, if any. diff --git a/Tests/FortranC/Flags.cmake.in b/Tests/FortranC/Flags.cmake.in index 2300fc6..cf361a5 100644 --- a/Tests/FortranC/Flags.cmake.in +++ b/Tests/FortranC/Flags.cmake.in @@ -12,11 +12,17 @@ configure_file("${src}/test_opt.sh.in" "${bld}/fc.sh" @ONLY) set(ID) set(COMMAND) +set(make_program "@CMake_TEST_EXPLICIT_MAKE_PROGRAM@") +if(make_program) + set(maybe_make_program "-DCMAKE_MAKE_PROGRAM=${make_program}") +endif() + execute_process( WORKING_DIRECTORY "${bld}" COMMAND ${CMAKE_COMMAND} "${src}" -G "@CMAKE_GENERATOR@" -A "@CMAKE_GENERATOR_PLATFORM@" -T "@CMAKE_GENERATOR_TOOLSET@" + ${maybe_make_program} "-DFortranC_TEST_FLAGS=1" "-DCMAKE_C_COMPILER=${bld}/cc.sh" "-DCMAKE_C_FLAGS:STRING=@CMAKE_C_FLAGS@" http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=586b2e5e3633db1e1749dc2bdd69f6240b714139 commit 586b2e5e3633db1e1749dc2bdd69f6240b714139 Author: Brad King AuthorDate: Mon Aug 10 14:06:09 2015 -0400 Commit: Brad King CommitDate: Tue Aug 11 10:18:04 2015 -0400 Tests: Fix CMAKE_MAKE_PROGRAM selection in CMakeOnly tests Use the explicitly-tested make program, if any. diff --git a/Tests/CMakeOnly/Test.cmake.in b/Tests/CMakeOnly/Test.cmake.in index 8d3258b..0ae8af1 100644 --- a/Tests/CMakeOnly/Test.cmake.in +++ b/Tests/CMakeOnly/Test.cmake.in @@ -2,6 +2,11 @@ if (NOT TEST_SOURCE) set(TEST_SOURCE "${TEST}") endif () +set(make_program "@CMake_TEST_EXPLICIT_MAKE_PROGRAM@") +if(make_program) + set(maybe_make_program "-DCMAKE_MAKE_PROGRAM=${make_program}") +endif() + set(source_dir "@CMAKE_CURRENT_SOURCE_DIR@/${TEST_SOURCE}") set(binary_dir "@CMAKE_CURRENT_BINARY_DIR@/${TEST}-build") file(REMOVE_RECURSE "${binary_dir}") @@ -11,6 +16,7 @@ execute_process( "${source_dir}" -G "@CMAKE_GENERATOR@" -A "@CMAKE_GENERATOR_PLATFORM@" -T "@CMAKE_GENERATOR_TOOLSET@" + ${maybe_make_program} WORKING_DIRECTORY "${binary_dir}" RESULT_VARIABLE result ) ----------------------------------------------------------------------- Summary of changes: Tests/CMakeOnly/Test.cmake.in | 6 ++++++ Tests/FortranC/Flags.cmake.in | 6 ++++++ 2 files changed, 12 insertions(+) hooks/post-receive -- CMake From brad.king at kitware.com Tue Aug 11 10:31:25 2015 From: brad.king at kitware.com (Brad King) Date: Tue, 11 Aug 2015 10:31:25 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2150-gd1671c4 Message-ID: <20150811143125.B9FDEB15E4@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via d1671c43e1c045002fc87c91a85d6e9b7a54ab97 (commit) via ea5d502e1bbd15aa5b43158caba2f42bd764ba52 (commit) from c7fa36d3ea7da82bfdfc147d985303b0b5a3a6b7 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d1671c43e1c045002fc87c91a85d6e9b7a54ab97 commit d1671c43e1c045002fc87c91a85d6e9b7a54ab97 Merge: c7fa36d ea5d502 Author: Brad King AuthorDate: Tue Aug 11 10:31:24 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 11 10:31:24 2015 -0400 Merge topic 'java-updates' into next ea5d502e UseJava: Add support for javah tool http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ea5d502e1bbd15aa5b43158caba2f42bd764ba52 commit ea5d502e1bbd15aa5b43158caba2f42bd764ba52 Author: Marc Chevrier AuthorDate: Wed Aug 5 07:46:02 2015 +0000 Commit: Brad King CommitDate: Tue Aug 11 10:30:44 2015 -0400 UseJava: Add support for javah tool Add a `create_javah` API. diff --git a/Help/release/dev/java-updates.rst b/Help/release/dev/java-updates.rst index b777807..8fd4ed6 100644 --- a/Help/release/dev/java-updates.rst +++ b/Help/release/dev/java-updates.rst @@ -11,3 +11,6 @@ java-updates * The :module:`UseJava` module ``install_jar`` function learned new ``DESTINATION`` and ``COMPONENT`` options to specify the corresponding :command:`install` command options. + +* The :module:`UseJava` module gained a new ``create_javah`` + function to create C headers from Java classes. diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake index c61591d..dced6ec 100644 --- a/Modules/UseJava.cmake +++ b/Modules/UseJava.cmake @@ -309,6 +309,65 @@ # # # if you don't set the INSTALLPATH. +# +# :: +# +# create_javah(TARGET +# GENERATED_FILES +# CLASSES ... +# [CLASSPATH ...] +# [DEPENDS ...] +# [OUTPUT_NAME |OUTPUT_DIR ] +# ) +# +# Create C header files from java classes. These files provide the connective glue +# that allow your Java and C code to interact. +# +# There are two main signatures for create_javah. The first signature +# returns generated files throught variable specified by GENERATED_FILES option: +# +# :: +# +# Example: +# Create_javah(GENERATED_FILES files_headers +# CLASSES org.cmake.HelloWorld +# CLASSPATH hello.jar +# ) +# +# +# +# The second signature for create_javah creates a target which encapsulates +# header files generation. +# +# :: +# +# Example: +# Create_javah(TARGET target_headers +# CLASSES org.cmake.HelloWorld +# CLASSPATH hello.jar +# ) +# +# +# +# Both signatures share same options. +# +# ``CLASSES ...`` +# Specifies Java classes used to generate headers. +# +# ``CLASSPATH ...`` +# Specifies various paths to look up classes. Here .class files, jar files or targets +# created by command add_jar can be used. +# +# ``DEPENDS ...`` +# Targets on which the javah target depends +# +# ``OUTPUT_NAME `` +# Concatenates the resulting header files for all the classes listed by option CLASSES +# into . Same behavior as option '-o' of javah tool. +# +# ``OUTPUT_DIR `` +# Sets the directory where the header files will be generated. Same behavior as option +# '-d' of javah tool. If not specified, ${CMAKE_CURRENT_BINARY_DIR} is used as output directory. #============================================================================= # Copyright 2013 OpenGamma Ltd. @@ -1131,3 +1190,101 @@ function(create_javadoc _target) DESTINATION ${_javadoc_installpath} ) endfunction() + +function (create_javah) + cmake_parse_arguments(_create_javah + "" + "TARGET;GENERATED_FILES;OUTPUT_NAME;OUTPUT_DIR" + "CLASSES;CLASSPATH;DEPENDS" + ${ARGN}) + + # ckeck parameters + if (NOT _create_javah_TARGET AND NOT _create_javah_GENERATED_FILES) + message (FATAL_ERROR "create_javah: TARGET or GENERATED_FILES must be specified.") + endif() + if (_create_javah_OUTPUT_NAME AND _create_javah_OUTPUT_DIR) + message (FATAL_ERROR "create_javah: OUTPUT_NAME and OUTPUT_DIR are mutually exclusive.") + endif() + + if (NOT _create_javah_CLASSES) + message (FATAL_ERROR "create_javah: CLASSES is a required parameter.") + endif() + + set (_output_files) + if (WIN32 AND NOT CYGWIN AND CMAKE_HOST_SYSTEM_NAME MATCHES "Windows") + set(_classpath_sep ";") + else () + set(_classpath_sep ":") + endif() + + # handle javah options + set (_javah_options) + + if (_create_javah_CLASSPATH) + # CLASSPATH can specify directories, jar files or targets created with add_jar command + set (_classpath) + foreach (_path IN LISTS _create_javah_CLASSPATH) + if (TARGET ${_path}) + get_target_property (_jar_path ${_path} JAR_FILE) + if (_jar_path) + list (APPEND _classpath "${_jar_path}") + list (APPEND _create_javah_DEPENDS "${_path}") + else() + message(SEND_ERROR "create_javah: CLASSPATH target ${_path} is not a jar.") + endif() + elseif (EXISTS "${_path}") + list (APPEND _classpath "${_path}") + if (NOT IS_DIRECTORY "${_path}") + list (APPEND _create_javah_DEPENDS "${_path}") + endif() + else() + message(SEND_ERROR "create_javah: CLASSPATH entry ${_path} does not exist.") + endif() + endforeach() + string (REPLACE ";" "${_classpath_sep}" _classpath "${_classpath}") + list (APPEND _javah_options -classpath ${_classpath}) + endif() + + if (_create_javah_OUTPUT_DIR) + list (APPEND _javah_options -d "${_create_javah_OUTPUT_DIR}") + endif() + + if (_create_javah_OUTPUT_NAME) + list (APPEND _javah_options -o "${_create_javah_OUTPUT_NAME}") + set (_output_files "${_create_javah_OUTPUT_NAME}") + + get_filename_component (_create_javah_OUTPUT_DIR "${_create_javah_OUTPUT_NAME}" DIRECTORY) + get_filename_component (_create_javah_OUTPUT_DIR "${_create_javah_OUTPUT_DIR}" ABSOLUTE) + endif() + + if (NOT _create_javah_OUTPUT_DIR) + set (_create_javah_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}") + endif() + + if (NOT _create_javah_OUTPUT_NAME) + # compute output names + foreach (_class IN LISTS _create_javah_CLASSES) + string (REPLACE "." "_" _c_header "${_class}") + set (_c_header "${_create_javah_OUTPUT_DIR}/${_c_header}.h") + list (APPEND _output_files "${_c_header}") + endforeach() + endif() + + # finalize custom command arguments + if (_create_javah_DEPENDS) + list (INSERT _create_javah_DEPENDS 0 DEPENDS) + endif() + + add_custom_command (OUTPUT ${_output_files} + COMMAND "${Java_JAVAH_EXECUTABLE}" ${_javah_options} -jni ${_create_javah_CLASSES} + ${_create_javah_DEPENDS} + WORKING_DIRECTORY ${_create_javah_OUTPUT_DIR} + COMMENT "Building C header files from classes...") + + if (_create_javah_TARGET) + add_custom_target (${_create_javah_TARGET} ALL DEPENDS ${_output_files}) + endif() + if (_create_javah_GENERATED_FILES) + set (${_create_javah_GENERATED_FILES} ${_output_files} PARENT_SCOPE) + endif() +endfunction() diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 5781a9e..99bc6d0 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -3032,6 +3032,31 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release --build-options ${build_options} --test-command ${JAVA_RUNTIME} -classpath hello2.jar HelloWorld) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJarSourceList") + + # For next test, java tool must have same architecture as toolchain + math(EXPR _object_mode "${CMAKE_SIZEOF_VOID_P} * 8") + execute_process( + COMMAND "${Java_JAVA_EXECUTABLE}" -d${_object_mode} -version + OUTPUT_QUIET ERROR_QUIET RESULT_VARIABLE _result + ) + if(_result EQUAL 0) + if(CMAKE_CONFIGURATION_TYPES) + set (JAVAH_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaJavah/$) + else() + set (JAVAH_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaJavah) + endif() + add_test(NAME Java.Javah COMMAND ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/JavaJavah" + "${CMake_BINARY_DIR}/Tests/JavaJavah" + ${build_generator_args} + --build-project helloJavah + --build-two-config + --build-run-dir "${CMake_BINARY_DIR}/Tests/JavaJavah/" + --build-options ${build_options} + --test-command ${JAVA_RUNTIME} -Djava.library.path=${JAVAH_LIBRARY_PATH} -classpath hello3.jar HelloWorld2) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJavah") + endif() endif() endif() endif() diff --git a/Tests/JavaJavah/B.cpp b/Tests/JavaJavah/B.cpp new file mode 100644 index 0000000..ef5e48c --- /dev/null +++ b/Tests/JavaJavah/B.cpp @@ -0,0 +1,11 @@ + +#include +#include + +#include "B.h" + +JNIEXPORT void JNICALL Java_B_printName +(JNIEnv *, jobject) +{ + std::cout << "B" << std::endl; +} diff --git a/Tests/JavaJavah/B.java b/Tests/JavaJavah/B.java new file mode 100644 index 0000000..d731f39 --- /dev/null +++ b/Tests/JavaJavah/B.java @@ -0,0 +1,19 @@ +class B +{ + public B() + { + } + + public native void printName(); + + static { + try { + + System.loadLibrary("B"); + + } catch (UnsatisfiedLinkError e) { + System.err.println("Native code library failed to load.\n" + e); + System.exit(1); + } + } +} diff --git a/Tests/JavaJavah/CMakeLists.txt b/Tests/JavaJavah/CMakeLists.txt new file mode 100644 index 0000000..83b0ad0 --- /dev/null +++ b/Tests/JavaJavah/CMakeLists.txt @@ -0,0 +1,20 @@ +project(helloJavah Java CXX) + +cmake_minimum_required (VERSION 2.6) +set(CMAKE_VERBOSE_MAKEFILE 1) + +find_package(Java COMPONENTS Development) +include (UseJava) + +# JNI support +find_package(JNI) + +add_jar(hello3 B.java HelloWorld2.java) +create_javah(TARGET B_javah CLASSES B CLASSPATH hello3) + +add_library(B SHARED B.cpp) +add_dependencies(B B_javah) + +target_include_directories(B PRIVATE ${CMAKE_CURRENT_BINARY_DIR} + ${JAVA_INCLUDE_PATH} + ${JAVA_INCLUDE_PATH2}) diff --git a/Tests/JavaJavah/HelloWorld2.java b/Tests/JavaJavah/HelloWorld2.java new file mode 100644 index 0000000..faf7277 --- /dev/null +++ b/Tests/JavaJavah/HelloWorld2.java @@ -0,0 +1,10 @@ +class HelloWorld2 +{ + public static void main(String args[]) + { + B b; + b = new B(); + b.printName(); + System.out.println("Hello World!"); + } +} ----------------------------------------------------------------------- Summary of changes: Help/release/dev/java-updates.rst | 3 + Modules/UseJava.cmake | 157 ++++++++++++++++++++ Tests/CMakeLists.txt | 25 ++++ Tests/JavaJavah/B.cpp | 11 ++ Tests/JavaJavah/B.java | 19 +++ Tests/JavaJavah/CMakeLists.txt | 20 +++ .../HelloWorld.java => JavaJavah/HelloWorld2.java} | 9 +- 7 files changed, 239 insertions(+), 5 deletions(-) create mode 100644 Tests/JavaJavah/B.cpp create mode 100644 Tests/JavaJavah/B.java create mode 100644 Tests/JavaJavah/CMakeLists.txt copy Tests/{Java/HelloWorld.java => JavaJavah/HelloWorld2.java} (57%) hooks/post-receive -- CMake From kwrobot at kitware.com Wed Aug 12 00:01:08 2015 From: kwrobot at kitware.com (Kitware Robot) Date: Wed, 12 Aug 2015 00:01:08 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-809-gb583800 Message-ID: <20150812040108.BCAEAB1B70@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via b583800203aea14aa03629bd27ad07d3f9440b17 (commit) from 422d3f68de6bfa5c3fad68d2b030f2a618a821a2 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b583800203aea14aa03629bd27ad07d3f9440b17 commit b583800203aea14aa03629bd27ad07d3f9440b17 Author: Kitware Robot AuthorDate: Wed Aug 12 00:01:06 2015 -0400 Commit: Kitware Robot CommitDate: Wed Aug 12 00:01:06 2015 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 40653ad..04813b0 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150811) +set(CMake_VERSION_PATCH 20150812) #set(CMake_VERSION_RC 1) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Wed Aug 12 09:16:39 2015 From: brad.king at kitware.com (Brad King) Date: Wed, 12 Aug 2015 09:16:39 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2153-g4dc6b1c Message-ID: <20150812131639.7C692B0E54@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 4dc6b1ce6e7470160c2c787e2f3a7cc6a36fd814 (commit) via e2bc81c0730a45282781c5382bf85c8864b6f600 (commit) via 71153b039cc975c06d341264fce4578cbb0daaeb (commit) from d1671c43e1c045002fc87c91a85d6e9b7a54ab97 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4dc6b1ce6e7470160c2c787e2f3a7cc6a36fd814 commit 4dc6b1ce6e7470160c2c787e2f3a7cc6a36fd814 Merge: d1671c4 e2bc81c Author: Brad King AuthorDate: Wed Aug 12 09:16:37 2015 -0400 Commit: CMake Topic Stage CommitDate: Wed Aug 12 09:16:37 2015 -0400 Merge topic 'OUTPUT_DIRECTORY-genex' into next e2bc81c0 Add generator expression support to OUTPUT_DIRECTORY target properties 71153b03 cmTarget: Detect and diagnose recursion in GetOutputInfo http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e2bc81c0730a45282781c5382bf85c8864b6f600 commit e2bc81c0730a45282781c5382bf85c8864b6f600 Author: Robert Goulet AuthorDate: Tue Aug 11 15:19:03 2015 -0400 Commit: Brad King CommitDate: Wed Aug 12 09:09:36 2015 -0400 Add generator expression support to OUTPUT_DIRECTORY target properties If {ARCHIVE,LIBRARY,RUNTIME}_OUTPUT_DIRECTORY is set with a genex then do not add the per-config subdirectory on multi-config generators. This will allow projects to use $ to place the per-config part of the directory path somewhere other than the end. diff --git a/Help/prop_tgt/ARCHIVE_OUTPUT_DIRECTORY_CONFIG.rst b/Help/prop_tgt/ARCHIVE_OUTPUT_DIRECTORY_CONFIG.rst index 29991eb..12f8bb7 100644 --- a/Help/prop_tgt/ARCHIVE_OUTPUT_DIRECTORY_CONFIG.rst +++ b/Help/prop_tgt/ARCHIVE_OUTPUT_DIRECTORY_CONFIG.rst @@ -11,3 +11,6 @@ per-configuration subdirectory to the specified directory. This property is initialized by the value of the :variable:`CMAKE_ARCHIVE_OUTPUT_DIRECTORY_` variable if it is set when a target is created. + +Contents of ``ARCHIVE_OUTPUT_DIRECTORY_`` may use +:manual:`generator expressions `. diff --git a/Help/prop_tgt/LIBRARY_OUTPUT_DIRECTORY_CONFIG.rst b/Help/prop_tgt/LIBRARY_OUTPUT_DIRECTORY_CONFIG.rst index 6fc0142..28dd404 100644 --- a/Help/prop_tgt/LIBRARY_OUTPUT_DIRECTORY_CONFIG.rst +++ b/Help/prop_tgt/LIBRARY_OUTPUT_DIRECTORY_CONFIG.rst @@ -11,3 +11,6 @@ per-configuration subdirectory to the specified directory. This property is initialized by the value of the :variable:`CMAKE_LIBRARY_OUTPUT_DIRECTORY_` variable if it is set when a target is created. + +Contents of ``LIBRARY_OUTPUT_DIRECTORY_`` may use +:manual:`generator expressions `. diff --git a/Help/prop_tgt/RUNTIME_OUTPUT_DIRECTORY_CONFIG.rst b/Help/prop_tgt/RUNTIME_OUTPUT_DIRECTORY_CONFIG.rst index c100346..94fb277 100644 --- a/Help/prop_tgt/RUNTIME_OUTPUT_DIRECTORY_CONFIG.rst +++ b/Help/prop_tgt/RUNTIME_OUTPUT_DIRECTORY_CONFIG.rst @@ -11,3 +11,6 @@ per-configuration subdirectory to the specified directory. This property is initialized by the value of the :variable:`CMAKE_RUNTIME_OUTPUT_DIRECTORY_` variable if it is set when a target is created. + +Contents of ``RUNTIME_OUTPUT_DIRECTORY_`` may use +:manual:`generator expressions `. diff --git a/Help/prop_tgt/XXX_OUTPUT_DIRECTORY.txt b/Help/prop_tgt/XXX_OUTPUT_DIRECTORY.txt index 0b3d31c..3ae5448 100644 --- a/Help/prop_tgt/XXX_OUTPUT_DIRECTORY.txt +++ b/Help/prop_tgt/XXX_OUTPUT_DIRECTORY.txt @@ -1,8 +1,11 @@ Output directory in which to build |XXX| target files. This property specifies the directory into which |xxx| target files -should be built. Multi-configuration generators (VS, Xcode) append a -per-configuration subdirectory to the specified directory. +should be built. The property value may use +:manual:`generator expressions `. +Multi-configuration generators (VS, Xcode) append a per-configuration +subdirectory to the specified directory unless a generator expression +is used. This property is initialized by the value of the variable |CMAKE_XXX_OUTPUT_DIRECTORY| if it is set when a target is created. diff --git a/Help/release/dev/OUTPUT_DIRECTORY-genex.rst b/Help/release/dev/OUTPUT_DIRECTORY-genex.rst new file mode 100644 index 0000000..8b839c0 --- /dev/null +++ b/Help/release/dev/OUTPUT_DIRECTORY-genex.rst @@ -0,0 +1,7 @@ +OUTPUT_DIRECTORY-genex +---------------------- + +* The :prop_tgt:`ARCHIVE_OUTPUT_DIRECTORY`, + :prop_tgt:`LIBRARY_OUTPUT_DIRECTORY`, and + :prop_tgt:`RUNTIME_OUTPUT_DIRECTORY` target properties learned to + support :manual:`generator expressions `. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index d2d4c67..a94c2dd 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3520,7 +3520,10 @@ bool cmTarget::ComputeOutputDir(const std::string& config, if(const char* config_outdir = this->GetProperty(configProp)) { // Use the user-specified per-configuration output directory. - out = config_outdir; + cmGeneratorExpression ge; + cmsys::auto_ptr cge = + ge.Parse(config_outdir); + out = cge->Evaluate(this->Makefile, config); // Skip per-configuration subdirectory. conf = ""; @@ -3528,7 +3531,17 @@ bool cmTarget::ComputeOutputDir(const std::string& config, else if(const char* outdir = this->GetProperty(propertyName)) { // Use the user-specified output directory. - out = outdir; + cmGeneratorExpression ge; + cmsys::auto_ptr cge = + ge.Parse(outdir); + out = cge->Evaluate(this->Makefile, config); + + // Skip per-configuration subdirectory if the value contained a + // generator expression. + if (out != outdir) + { + conf = ""; + } } else if(this->GetType() == cmTarget::EXECUTABLE) { diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt index df3f178..4df5d07 100644 --- a/Tests/ExportImport/Export/CMakeLists.txt +++ b/Tests/ExportImport/Export/CMakeLists.txt @@ -105,6 +105,19 @@ target_link_libraries(testLib4 add_executable(testExe3 testExe3.c) set_property(TARGET testExe3 PROPERTY MACOSX_BUNDLE 1) +# Test _OUTPUT_DIRECTORY[_] properties with generator expressions +add_executable(testExe4 testExe4.c) +target_link_libraries(testExe4 testExe1lib) +set_property(TARGET testLib7 PROPERTY ARCHIVE_OUTPUT_DIRECTORY_DEBUG testLib7D-$) +set_property(TARGET testLib7 PROPERTY ARCHIVE_OUTPUT_DIRECTORY_RELEASE testLib7R-$) +set_property(TARGET testLib7 PROPERTY ARCHIVE_OUTPUT_DIRECTORY testLib7-$) +set_property(TARGET testLib4 PROPERTY LIBRARY_OUTPUT_DIRECTORY_DEBUG testLib4D-$) +set_property(TARGET testLib4 PROPERTY LIBRARY_OUTPUT_DIRECTORY_RELEASE testLib4R-$) +set_property(TARGET testLib4 PROPERTY LIBRARY_OUTPUT_DIRECTORY testLib4-$) +set_property(TARGET testExe4 PROPERTY RUNTIME_OUTPUT_DIRECTORY_DEBUG testExe4D-$) +set_property(TARGET testExe4 PROPERTY RUNTIME_OUTPUT_DIRECTORY_RELEASE testExe4R-$) +set_property(TARGET testExe4 PROPERTY RUNTIME_OUTPUT_DIRECTORY testExe4-$) + # Test cyclic dependencies. add_library(testLibCycleA STATIC testLibCycleA1.c testLibCycleA2.c testLibCycleA3.c) @@ -450,7 +463,7 @@ install(FILES # Install and export from install tree. install( TARGETS - testExe1 testLib1 testLib2 testExe2 testLib3 testLib4 testExe3 + testExe1 testLib1 testLib2 testExe2 testLib3 testLib4 testExe3 testExe4 testExe2lib testLib4lib testLib4libdbg testLib4libopt testLib6 testLib7 testLibCycleA testLibCycleB @@ -511,7 +524,7 @@ export(TARGETS testExe1 testLib1 testLib2 testLib3 NAMESPACE bld_ FILE ExportBuildTree.cmake ) -export(TARGETS testExe2 testLib4 testLib5 testLib6 testLib7 testExe3 testExe2lib +export(TARGETS testExe2 testLib4 testLib5 testLib6 testLib7 testExe3 testExe4 testExe2lib testLib4lib testLib4libdbg testLib4libopt testLibCycleA testLibCycleB testLibPerConfigDest diff --git a/Tests/ExportImport/Export/testExe4.c b/Tests/ExportImport/Export/testExe4.c new file mode 100644 index 0000000..731057e --- /dev/null +++ b/Tests/ExportImport/Export/testExe4.c @@ -0,0 +1,24 @@ +#include + +int main(int argc, const char* argv[]) +{ + if(argc < 2) + { + fprintf(stderr, "Must specify output file.\n"); + return 1; + } + { + FILE* f = fopen(argv[1], "w"); + if(f) + { + fprintf(f, "int generated_by_testExe4() { return 0; }\n"); + fclose(f); + } + else + { + fprintf(stderr, "Error writing to %s\n", argv[1]); + return 1; + } + } + return 0; +} diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt index a74bad1..0f56495 100644 --- a/Tests/ExportImport/Import/A/CMakeLists.txt +++ b/Tests/ExportImport/Import/A/CMakeLists.txt @@ -19,11 +19,17 @@ add_custom_command( COMMAND exp_testExe3 ${Import_BINARY_DIR}/exp_generated3.c DEPENDS exp_testExe3 ) +add_custom_command( + OUTPUT ${Import_BINARY_DIR}/exp_generated4.c + COMMAND exp_testExe4 ${Import_BINARY_DIR}/exp_generated4.c + DEPENDS exp_testExe4 + ) add_executable(imp_testExe1 imp_testExe1.c ${Import_BINARY_DIR}/exp_generated.c ${Import_BINARY_DIR}/exp_generated3.c + ${Import_BINARY_DIR}/exp_generated4.c ) # Try linking to a library imported from the install tree. @@ -53,11 +59,17 @@ add_custom_command( COMMAND bld_testExe3 ${Import_BINARY_DIR}/bld_generated3.c DEPENDS bld_testExe3 ) +add_custom_command( + OUTPUT ${Import_BINARY_DIR}/bld_generated4.c + COMMAND bld_testExe4 ${Import_BINARY_DIR}/bld_generated4.c + DEPENDS bld_testExe4 + ) add_executable(imp_testExe1b imp_testExe1.c ${Import_BINARY_DIR}/bld_generated.c ${Import_BINARY_DIR}/bld_generated3.c + ${Import_BINARY_DIR}/bld_generated4.c ) # Try linking to a library imported from the build tree. diff --git a/Tests/ExportImport/Import/A/imp_testExe1.c b/Tests/ExportImport/Import/A/imp_testExe1.c index 56cdd2c..0a74309 100644 --- a/Tests/ExportImport/Import/A/imp_testExe1.c +++ b/Tests/ExportImport/Import/A/imp_testExe1.c @@ -1,5 +1,6 @@ extern int generated_by_testExe1(); extern int generated_by_testExe3(); +extern int generated_by_testExe4(); extern int testLib2(); extern int testLib3(); extern int testLib4(); @@ -24,5 +25,5 @@ int main() return (testLib2() + generated_by_testExe1() + testLib3() + testLib4() + testLib5() + testLib6() + testLib7() + testLibCycleA1() + testLibPerConfigDest() - + generated_by_testExe3() + testLib4lib() + testLib4libcfg()); + + generated_by_testExe3() + generated_by_testExe4() + testLib4lib() + testLib4libcfg()); } diff --git a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake index cba3941..21fc851 100644 --- a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake @@ -25,6 +25,7 @@ run_cmake(COMPILE_LANGUAGE-add_executable) run_cmake(COMPILE_LANGUAGE-add_library) run_cmake(COMPILE_LANGUAGE-add_test) run_cmake(COMPILE_LANGUAGE-unknown-lang) +run_cmake(TARGET_FILE-recursion) run_cmake(ImportedTarget-TARGET_PDB_FILE) if(LINKER_SUPPORTS_PDB) diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion-result.txt b/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion-stderr.txt b/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion-stderr.txt new file mode 100644 index 0000000..5b15526 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at TARGET_FILE-recursion.cmake:[0-9]+ \(add_executable\): + Target 'empty1' OUTPUT_DIRECTORY depends on itself. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion.cmake new file mode 100644 index 0000000..7633be1 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion.cmake @@ -0,0 +1,3 @@ +enable_language(C) +add_executable(empty1 empty.c) +set_property(TARGET empty1 PROPERTY RUNTIME_OUTPUT_DIRECTORY $) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=71153b039cc975c06d341264fce4578cbb0daaeb commit 71153b039cc975c06d341264fce4578cbb0daaeb Author: Robert Goulet AuthorDate: Tue Aug 11 15:18:39 2015 -0400 Commit: Brad King CommitDate: Tue Aug 11 15:31:21 2015 -0400 cmTarget: Detect and diagnose recursion in GetOutputInfo diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index d3170e4..d2d4c67 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -66,6 +66,8 @@ struct cmTarget::OutputInfo std::string OutDir; std::string ImpDir; std::string PdbDir; + bool empty() const + { return OutDir.empty() && ImpDir.empty() && PdbDir.empty(); } }; //---------------------------------------------------------------------------- @@ -2609,19 +2611,35 @@ cmTarget::OutputInfo const* cmTarget::GetOutputInfo( config_upper = cmSystemTools::UpperCase(config); } typedef cmTargetInternals::OutputInfoMapType OutputInfoMapType; - OutputInfoMapType::const_iterator i = + OutputInfoMapType::iterator i = this->Internal->OutputInfoMap.find(config_upper); if(i == this->Internal->OutputInfoMap.end()) { + // Add empty info in map to detect potential recursion. OutputInfo info; + OutputInfoMapType::value_type entry(config_upper, info); + i = this->Internal->OutputInfoMap.insert(entry).first; + + // Compute output directories. this->ComputeOutputDir(config, false, info.OutDir); this->ComputeOutputDir(config, true, info.ImpDir); if(!this->ComputePDBOutputDir("PDB", config, info.PdbDir)) { info.PdbDir = info.OutDir; } - OutputInfoMapType::value_type entry(config_upper, info); - i = this->Internal->OutputInfoMap.insert(entry).first; + + // Now update the previously-prepared map entry. + i->second = info; + } + else if(i->second.empty()) + { + // An empty map entry indicates we have been called recursively + // from the above block. + this->Makefile->GetCMakeInstance()->IssueMessage( + cmake::FATAL_ERROR, + "Target '" + this->GetName() + "' OUTPUT_DIRECTORY depends on itself.", + this->GetBacktrace()); + return 0; } return &i->second; } ----------------------------------------------------------------------- Summary of changes: Help/prop_tgt/ARCHIVE_OUTPUT_DIRECTORY_CONFIG.rst | 3 ++ Help/prop_tgt/LIBRARY_OUTPUT_DIRECTORY_CONFIG.rst | 3 ++ Help/prop_tgt/RUNTIME_OUTPUT_DIRECTORY_CONFIG.rst | 3 ++ Help/prop_tgt/XXX_OUTPUT_DIRECTORY.txt | 7 +++- Help/release/dev/OUTPUT_DIRECTORY-genex.rst | 7 ++++ Source/cmTarget.cxx | 41 +++++++++++++++++--- Tests/ExportImport/Export/CMakeLists.txt | 17 +++++++- .../ExportImport/Export/{testExe3.c => testExe4.c} | 2 +- Tests/ExportImport/Import/A/CMakeLists.txt | 12 ++++++ Tests/ExportImport/Import/A/imp_testExe1.c | 3 +- .../GeneratorExpression/RunCMakeTest.cmake | 1 + .../TARGET_FILE-recursion-result.txt} | 0 .../TARGET_FILE-recursion-stderr.txt | 4 ++ .../TARGET_FILE-recursion.cmake | 3 ++ 14 files changed, 95 insertions(+), 11 deletions(-) create mode 100644 Help/release/dev/OUTPUT_DIRECTORY-genex.rst copy Tests/ExportImport/Export/{testExe3.c => testExe4.c} (84%) copy Tests/RunCMake/{CMP0004/CMP0004-NEW-result.txt => GeneratorExpression/TARGET_FILE-recursion-result.txt} (100%) create mode 100644 Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion-stderr.txt create mode 100644 Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion.cmake hooks/post-receive -- CMake From brad.king at kitware.com Wed Aug 12 09:25:04 2015 From: brad.king at kitware.com (Brad King) Date: Wed, 12 Aug 2015 09:25:04 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2155-g65e51df Message-ID: <20150812132504.508E6B13FD@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 65e51dff4210a84a33ceaba5adef6927999c2508 (commit) via 50c9f521e2debce5beb538050fd12d802964a4b1 (commit) from 4dc6b1ce6e7470160c2c787e2f3a7cc6a36fd814 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=65e51dff4210a84a33ceaba5adef6927999c2508 commit 65e51dff4210a84a33ceaba5adef6927999c2508 Merge: 4dc6b1c 50c9f52 Author: Brad King AuthorDate: Wed Aug 12 09:25:03 2015 -0400 Commit: CMake Topic Stage CommitDate: Wed Aug 12 09:25:03 2015 -0400 Merge topic 'FindPkgConfig-capital-messages' into next 50c9f521 FindPkgConfig: Capitalize first letter of all message()s http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=50c9f521e2debce5beb538050fd12d802964a4b1 commit 50c9f521e2debce5beb538050fd12d802964a4b1 Author: Christopher Meng AuthorDate: Wed Aug 12 10:30:53 2015 +0800 Commit: Brad King CommitDate: Wed Aug 12 09:24:44 2015 -0400 FindPkgConfig: Capitalize first letter of all message()s This makes FindPkgConfig output more formal and more consistent with many other messages produced by CMake. diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake index 53c17f1..526a62e 100644 --- a/Modules/FindPkgConfig.cmake +++ b/Modules/FindPkgConfig.cmake @@ -192,9 +192,9 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma # give out status message telling checked module if (NOT ${_is_silent}) if (_pkg_check_modules_cnt EQUAL 1) - message(STATUS "checking for module '${_pkg_check_modules_list}'") + message(STATUS "Checking for module '${_pkg_check_modules_list}'") else() - message(STATUS "checking for modules '${_pkg_check_modules_list}'") + message(STATUS "Checking for modules '${_pkg_check_modules_list}'") endif() endif() @@ -327,7 +327,7 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma # evaluate result and tell failures if (_pkgconfig_retval) if(NOT ${_is_silent}) - message(STATUS " package '${_pkg_check_modules_pkg}' not found") + message(STATUS " Package '${_pkg_check_modules_pkg}' not found") endif() set(_pkg_check_modules_failed 1) @@ -361,7 +361,7 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma _pkgconfig_invoke(${_pkg_check_modules_pkg} "${_pkg_check_prefix}" LIBDIR "" --variable=libdir ) if (NOT ${_is_silent}) - message(STATUS " found ${_pkg_check_modules_pkg}, version ${_pkgconfig_VERSION}") + message(STATUS " Found ${_pkg_check_modules_pkg}, version ${_pkgconfig_VERSION}") endif () endforeach() @@ -529,7 +529,7 @@ macro(pkg_search_module _prefix _module0) _pkgconfig_parse_options(_pkg_modules_alt _pkg_is_required _pkg_is_silent _no_cmake_path _no_cmake_environment_path "${_module0}" ${ARGN}) if (NOT ${_pkg_is_silent}) - message(STATUS "checking for one of the modules '${_pkg_modules_alt}'") + message(STATUS "Checking for one of the modules '${_pkg_modules_alt}'") endif () # iterate through all modules and stop at the first working one. ----------------------------------------------------------------------- Summary of changes: Modules/FindPkgConfig.cmake | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Wed Aug 12 09:30:28 2015 From: brad.king at kitware.com (Brad King) Date: Wed, 12 Aug 2015 09:30:28 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-812-g7216742 Message-ID: <20150812133028.A4A64B1688@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 7216742ea61bd8853cf490d7605c6c7c0cffe187 (commit) via 8c076a8bdba8c5bc77fc01b3fafafa100fb59657 (commit) via 5790aca4adfc21e9e042e93fa0dd290aab91be5c (commit) from b583800203aea14aa03629bd27ad07d3f9440b17 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7216742ea61bd8853cf490d7605c6c7c0cffe187 commit 7216742ea61bd8853cf490d7605c6c7c0cffe187 Merge: b583800 8c076a8 Author: Brad King AuthorDate: Wed Aug 12 09:30:27 2015 -0400 Commit: CMake Topic Stage CommitDate: Wed Aug 12 09:30:27 2015 -0400 Merge topic 'target_include_directories-relative-SYSTEM-dirs' 8c076a8b cmTarget: Remove unused AddSystemIncludeDirectories overload 5790aca4 target_include_directories: Support relative SYSTEM include dirs (#15464) ----------------------------------------------------------------------- Summary of changes: Source/cmTarget.cxx | 7 ------- Source/cmTarget.h | 1 - Source/cmTargetIncludeDirectoriesCommand.cxx | 20 ++++++++++++++++++-- .../SystemIncludeDirectories/CMakeLists.txt | 10 ++++++++++ 4 files changed, 28 insertions(+), 10 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Wed Aug 12 09:30:30 2015 From: brad.king at kitware.com (Brad King) Date: Wed, 12 Aug 2015 09:30:30 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-814-g6731eab Message-ID: <20150812133030.85D79B168C@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 6731eab90cbd692d0e5d98df6db6da0ffd69a881 (commit) via 48c6e7f2cfc95fc851cf9711d9588f3498e647c4 (commit) from 7216742ea61bd8853cf490d7605c6c7c0cffe187 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6731eab90cbd692d0e5d98df6db6da0ffd69a881 commit 6731eab90cbd692d0e5d98df6db6da0ffd69a881 Merge: 7216742 48c6e7f Author: Brad King AuthorDate: Wed Aug 12 09:30:29 2015 -0400 Commit: CMake Topic Stage CommitDate: Wed Aug 12 09:30:29 2015 -0400 Merge topic 'ctest-report-compiler-version' 48c6e7f2 CTest: Report to CDash the compiler version used to build the project ----------------------------------------------------------------------- Summary of changes: Modules/DartConfiguration.tcl.in | 1 + Source/cmCTest.cxx | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Wed Aug 12 09:30:32 2015 From: brad.king at kitware.com (Brad King) Date: Wed, 12 Aug 2015 09:30:32 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-816-g1cb7237 Message-ID: <20150812133034.13FE8B168B@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 1cb7237b51ad56934e4348fdebe85750c2927a99 (commit) via 6a77a77a62f6bfb66cea622621d6d1b68e775664 (commit) from 6731eab90cbd692d0e5d98df6db6da0ffd69a881 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1cb7237b51ad56934e4348fdebe85750c2927a99 commit 1cb7237b51ad56934e4348fdebe85750c2927a99 Merge: 6731eab 6a77a77 Author: Brad King AuthorDate: Wed Aug 12 09:30:31 2015 -0400 Commit: CMake Topic Stage CommitDate: Wed Aug 12 09:30:31 2015 -0400 Merge topic 'ExternalProject-hg-clone-without-update' 6a77a77a ExternalProject: Tell "hg clone" not to implicitly update ----------------------------------------------------------------------- Summary of changes: Modules/ExternalProject.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Wed Aug 12 09:30:36 2015 From: brad.king at kitware.com (Brad King) Date: Wed, 12 Aug 2015 09:30:36 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-818-ge688377 Message-ID: <20150812133036.108B4B168C@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via e6883772ff661017f927633ec863fa4a671c27a5 (commit) via 8dc6cbcb248979a10ba96c9e7ce19fe18f009586 (commit) from 1cb7237b51ad56934e4348fdebe85750c2927a99 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e6883772ff661017f927633ec863fa4a671c27a5 commit e6883772ff661017f927633ec863fa4a671c27a5 Merge: 1cb7237 8dc6cbc Author: Brad King AuthorDate: Wed Aug 12 09:30:34 2015 -0400 Commit: CMake Topic Stage CommitDate: Wed Aug 12 09:30:34 2015 -0400 Merge topic 'FindProtobuf-vs-x64' 8dc6cbcb FindProtobuf: Search x64 directories in VS-built protobuf source (#14833) ----------------------------------------------------------------------- Summary of changes: Modules/FindProtobuf.cmake | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Wed Aug 12 09:30:37 2015 From: brad.king at kitware.com (Brad King) Date: Wed, 12 Aug 2015 09:30:37 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-821-gce254de Message-ID: <20150812133037.EC2C8B16AE@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via ce254de60e32dd1be95b430d37dc9bb67911d158 (commit) via c180f0cbc224bf7f3fe9bcfdeea2d3c712c61084 (commit) via 586b2e5e3633db1e1749dc2bdd69f6240b714139 (commit) from e6883772ff661017f927633ec863fa4a671c27a5 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ce254de60e32dd1be95b430d37dc9bb67911d158 commit ce254de60e32dd1be95b430d37dc9bb67911d158 Merge: e688377 c180f0c Author: Brad King AuthorDate: Wed Aug 12 09:30:36 2015 -0400 Commit: CMake Topic Stage CommitDate: Wed Aug 12 09:30:36 2015 -0400 Merge topic 'tests-use-CMAKE_MAKE_PROGRAM' c180f0cb Tests: Fix CMAKE_MAKE_PROGRAM selection in FortranC.Flags test 586b2e5e Tests: Fix CMAKE_MAKE_PROGRAM selection in CMakeOnly tests ----------------------------------------------------------------------- Summary of changes: Tests/CMakeOnly/Test.cmake.in | 6 ++++++ Tests/FortranC/Flags.cmake.in | 6 ++++++ 2 files changed, 12 insertions(+) hooks/post-receive -- CMake From brad.king at kitware.com Wed Aug 12 09:31:00 2015 From: brad.king at kitware.com (Brad King) Date: Wed, 12 Aug 2015 09:31:00 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2162-gdade9fd Message-ID: <20150812133100.1D092B169C@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via dade9fd21bcf200698ced089ac475447d4f04cea (commit) via ce254de60e32dd1be95b430d37dc9bb67911d158 (commit) via e6883772ff661017f927633ec863fa4a671c27a5 (commit) via 1cb7237b51ad56934e4348fdebe85750c2927a99 (commit) via 6731eab90cbd692d0e5d98df6db6da0ffd69a881 (commit) via 7216742ea61bd8853cf490d7605c6c7c0cffe187 (commit) via b583800203aea14aa03629bd27ad07d3f9440b17 (commit) from 65e51dff4210a84a33ceaba5adef6927999c2508 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=dade9fd21bcf200698ced089ac475447d4f04cea commit dade9fd21bcf200698ced089ac475447d4f04cea Merge: 65e51df ce254de Author: Brad King AuthorDate: Wed Aug 12 09:30:49 2015 -0400 Commit: Brad King CommitDate: Wed Aug 12 09:30:49 2015 -0400 Merge branch 'master' into next ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Wed Aug 12 09:36:46 2015 From: brad.king at kitware.com (Brad King) Date: Wed, 12 Aug 2015 09:36:46 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2164-g5af5ae9 Message-ID: <20150812133646.47C5CB17C0@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 5af5ae973126f7cbdb0f9ebf8140ea8f387b9a24 (commit) via 5ad9b19a7167779b5375d575473152a02280b4d8 (commit) from dade9fd21bcf200698ced089ac475447d4f04cea (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5af5ae973126f7cbdb0f9ebf8140ea8f387b9a24 commit 5af5ae973126f7cbdb0f9ebf8140ea8f387b9a24 Merge: dade9fd 5ad9b19 Author: Brad King AuthorDate: Wed Aug 12 09:36:45 2015 -0400 Commit: CMake Topic Stage CommitDate: Wed Aug 12 09:36:45 2015 -0400 Merge topic 'fix-hpux-link-search-shared-flags' into next 5ad9b19a Revert "HP-UX: Fix shared library search flags on HP-UX." http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5ad9b19a7167779b5375d575473152a02280b4d8 commit 5ad9b19a7167779b5375d575473152a02280b4d8 Author: Brad King AuthorDate: Wed Aug 12 09:35:53 2015 -0400 Commit: Brad King CommitDate: Wed Aug 12 09:35:53 2015 -0400 Revert "HP-UX: Fix shared library search flags on HP-UX." This reverts commit bb20daab87518c42a264f14820a7f32644cfd9ac. It turns out that -a,default is correct because its shared-then-static behavior is equivalent to -Bdynamic on other platforms. diff --git a/Modules/Platform/HP-UX.cmake b/Modules/Platform/HP-UX.cmake index f103975..581301b 100644 --- a/Modules/Platform/HP-UX.cmake +++ b/Modules/Platform/HP-UX.cmake @@ -37,7 +37,7 @@ list(APPEND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES foreach(type SHARED_LIBRARY SHARED_MODULE EXE) foreach(lang C CXX) set(CMAKE_${type}_LINK_STATIC_${lang}_FLAGS "-Wl,-a,archive") - set(CMAKE_${type}_LINK_DYNAMIC_${lang}_FLAGS "-Wl,-a,shared") + set(CMAKE_${type}_LINK_DYNAMIC_${lang}_FLAGS "-Wl,-a,default") endforeach() endforeach() ----------------------------------------------------------------------- Summary of changes: Modules/Platform/HP-UX.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Wed Aug 12 09:37:17 2015 From: brad.king at kitware.com (Brad King) Date: Wed, 12 Aug 2015 09:37:17 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2166-g9fc7e85 Message-ID: <20150812133717.2F6DDB1927@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 9fc7e85fcb4522f1ad6e92fc9000fff59d417d27 (commit) via dc64d8250b686c26a557f58dfad46a0a2101299e (commit) from 5af5ae973126f7cbdb0f9ebf8140ea8f387b9a24 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9fc7e85fcb4522f1ad6e92fc9000fff59d417d27 commit 9fc7e85fcb4522f1ad6e92fc9000fff59d417d27 Merge: 5af5ae9 dc64d82 Author: Brad King AuthorDate: Wed Aug 12 09:37:16 2015 -0400 Commit: CMake Topic Stage CommitDate: Wed Aug 12 09:37:16 2015 -0400 Merge topic 'fix-hpux-link-search-shared-flags' into next dc64d825 HP-UX: Fix linker search type flags for C shared libs on HP-UX http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=dc64d8250b686c26a557f58dfad46a0a2101299e commit dc64d8250b686c26a557f58dfad46a0a2101299e Author: Chuck Atkins AuthorDate: Mon Aug 10 13:21:40 2015 -0400 Commit: Brad King CommitDate: Wed Aug 12 09:36:57 2015 -0400 HP-UX: Fix linker search type flags for C shared libs on HP-UX Since commit v2.8.7~31^2 (HP: Drive shared library linking with compiler front end, 2011-12-12) the C compiler is used to link shared libraries instead of calling the linker directly, so linker options need to be wrapped as -Wl,-foo instead of -foo. diff --git a/Modules/Platform/HP-UX.cmake b/Modules/Platform/HP-UX.cmake index 65cc731..581301b 100644 --- a/Modules/Platform/HP-UX.cmake +++ b/Modules/Platform/HP-UX.cmake @@ -33,18 +33,11 @@ list(APPEND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES # Initialize C and CXX link type selection flags. These flags are # used when building a shared library, shared module, or executable # that links to other libraries to select whether to use the static or -# shared versions of the libraries. Note that C modules and shared -# libs are built using ld directly so we leave off the "-Wl," portion. -foreach(type SHARED_LIBRARY SHARED_MODULE) - set(CMAKE_${type}_LINK_STATIC_C_FLAGS "-a archive") - set(CMAKE_${type}_LINK_DYNAMIC_C_FLAGS "-a default") -endforeach() -foreach(type EXE) - set(CMAKE_${type}_LINK_STATIC_C_FLAGS "-Wl,-a,archive") - set(CMAKE_${type}_LINK_DYNAMIC_C_FLAGS "-Wl,-a,default") -endforeach() +# shared versions of the libraries. foreach(type SHARED_LIBRARY SHARED_MODULE EXE) - set(CMAKE_${type}_LINK_STATIC_CXX_FLAGS "-Wl,-a,archive") - set(CMAKE_${type}_LINK_DYNAMIC_CXX_FLAGS "-Wl,-a,default") + foreach(lang C CXX) + set(CMAKE_${type}_LINK_STATIC_${lang}_FLAGS "-Wl,-a,archive") + set(CMAKE_${type}_LINK_DYNAMIC_${lang}_FLAGS "-Wl,-a,default") + endforeach() endforeach() ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From brad.king at kitware.com Wed Aug 12 09:37:50 2015 From: brad.king at kitware.com (Brad King) Date: Wed, 12 Aug 2015 09:37:50 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2168-g775b29b Message-ID: <20150812133750.704CBB1932@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 775b29b01099f7cd1477031d4b0e147a4f8f0df8 (commit) via 68d427ad7e670b381bac62e8255bff8c539c3aa0 (commit) from 9fc7e85fcb4522f1ad6e92fc9000fff59d417d27 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=775b29b01099f7cd1477031d4b0e147a4f8f0df8 commit 775b29b01099f7cd1477031d4b0e147a4f8f0df8 Merge: 9fc7e85 68d427a Author: Brad King AuthorDate: Wed Aug 12 09:37:49 2015 -0400 Commit: CMake Topic Stage CommitDate: Wed Aug 12 09:37:49 2015 -0400 Merge topic 'java-updates' into next 68d427ad fixup! UseJava: Add support for javah tool http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=68d427ad7e670b381bac62e8255bff8c539c3aa0 commit 68d427ad7e670b381bac62e8255bff8c539c3aa0 Author: Brad King AuthorDate: Wed Aug 12 09:32:01 2015 -0400 Commit: Brad King CommitDate: Wed Aug 12 09:32:01 2015 -0400 fixup! UseJava: Add support for javah tool diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 99bc6d0..f01a983 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -3041,7 +3041,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release ) if(_result EQUAL 0) if(CMAKE_CONFIGURATION_TYPES) - set (JAVAH_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaJavah/$) + set (JAVAH_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaJavah/$) else() set (JAVAH_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaJavah) endif() ----------------------------------------------------------------------- Summary of changes: Tests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Wed Aug 12 09:38:10 2015 From: brad.king at kitware.com (Brad King) Date: Wed, 12 Aug 2015 09:38:10 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2170-g1a6de5a Message-ID: <20150812133810.883C4B1934@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 1a6de5ad88bc7f92f9c573aba5fd64e7601dfa0d (commit) via ac549b47cdfbfa8f587b0ac228096472961b3d78 (commit) from 775b29b01099f7cd1477031d4b0e147a4f8f0df8 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1a6de5ad88bc7f92f9c573aba5fd64e7601dfa0d commit 1a6de5ad88bc7f92f9c573aba5fd64e7601dfa0d Merge: 775b29b ac549b4 Author: Brad King AuthorDate: Wed Aug 12 09:38:09 2015 -0400 Commit: CMake Topic Stage CommitDate: Wed Aug 12 09:38:09 2015 -0400 Merge topic 'java-updates' into next ac549b47 UseJava: Add support for javah tool http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ac549b47cdfbfa8f587b0ac228096472961b3d78 commit ac549b47cdfbfa8f587b0ac228096472961b3d78 Author: Marc Chevrier AuthorDate: Wed Aug 5 07:46:02 2015 +0000 Commit: Brad King CommitDate: Wed Aug 12 09:37:56 2015 -0400 UseJava: Add support for javah tool Add a `create_javah` API. diff --git a/Help/release/dev/java-updates.rst b/Help/release/dev/java-updates.rst index b777807..8fd4ed6 100644 --- a/Help/release/dev/java-updates.rst +++ b/Help/release/dev/java-updates.rst @@ -11,3 +11,6 @@ java-updates * The :module:`UseJava` module ``install_jar`` function learned new ``DESTINATION`` and ``COMPONENT`` options to specify the corresponding :command:`install` command options. + +* The :module:`UseJava` module gained a new ``create_javah`` + function to create C headers from Java classes. diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake index c61591d..dced6ec 100644 --- a/Modules/UseJava.cmake +++ b/Modules/UseJava.cmake @@ -309,6 +309,65 @@ # # # if you don't set the INSTALLPATH. +# +# :: +# +# create_javah(TARGET +# GENERATED_FILES +# CLASSES ... +# [CLASSPATH ...] +# [DEPENDS ...] +# [OUTPUT_NAME |OUTPUT_DIR ] +# ) +# +# Create C header files from java classes. These files provide the connective glue +# that allow your Java and C code to interact. +# +# There are two main signatures for create_javah. The first signature +# returns generated files throught variable specified by GENERATED_FILES option: +# +# :: +# +# Example: +# Create_javah(GENERATED_FILES files_headers +# CLASSES org.cmake.HelloWorld +# CLASSPATH hello.jar +# ) +# +# +# +# The second signature for create_javah creates a target which encapsulates +# header files generation. +# +# :: +# +# Example: +# Create_javah(TARGET target_headers +# CLASSES org.cmake.HelloWorld +# CLASSPATH hello.jar +# ) +# +# +# +# Both signatures share same options. +# +# ``CLASSES ...`` +# Specifies Java classes used to generate headers. +# +# ``CLASSPATH ...`` +# Specifies various paths to look up classes. Here .class files, jar files or targets +# created by command add_jar can be used. +# +# ``DEPENDS ...`` +# Targets on which the javah target depends +# +# ``OUTPUT_NAME `` +# Concatenates the resulting header files for all the classes listed by option CLASSES +# into . Same behavior as option '-o' of javah tool. +# +# ``OUTPUT_DIR `` +# Sets the directory where the header files will be generated. Same behavior as option +# '-d' of javah tool. If not specified, ${CMAKE_CURRENT_BINARY_DIR} is used as output directory. #============================================================================= # Copyright 2013 OpenGamma Ltd. @@ -1131,3 +1190,101 @@ function(create_javadoc _target) DESTINATION ${_javadoc_installpath} ) endfunction() + +function (create_javah) + cmake_parse_arguments(_create_javah + "" + "TARGET;GENERATED_FILES;OUTPUT_NAME;OUTPUT_DIR" + "CLASSES;CLASSPATH;DEPENDS" + ${ARGN}) + + # ckeck parameters + if (NOT _create_javah_TARGET AND NOT _create_javah_GENERATED_FILES) + message (FATAL_ERROR "create_javah: TARGET or GENERATED_FILES must be specified.") + endif() + if (_create_javah_OUTPUT_NAME AND _create_javah_OUTPUT_DIR) + message (FATAL_ERROR "create_javah: OUTPUT_NAME and OUTPUT_DIR are mutually exclusive.") + endif() + + if (NOT _create_javah_CLASSES) + message (FATAL_ERROR "create_javah: CLASSES is a required parameter.") + endif() + + set (_output_files) + if (WIN32 AND NOT CYGWIN AND CMAKE_HOST_SYSTEM_NAME MATCHES "Windows") + set(_classpath_sep ";") + else () + set(_classpath_sep ":") + endif() + + # handle javah options + set (_javah_options) + + if (_create_javah_CLASSPATH) + # CLASSPATH can specify directories, jar files or targets created with add_jar command + set (_classpath) + foreach (_path IN LISTS _create_javah_CLASSPATH) + if (TARGET ${_path}) + get_target_property (_jar_path ${_path} JAR_FILE) + if (_jar_path) + list (APPEND _classpath "${_jar_path}") + list (APPEND _create_javah_DEPENDS "${_path}") + else() + message(SEND_ERROR "create_javah: CLASSPATH target ${_path} is not a jar.") + endif() + elseif (EXISTS "${_path}") + list (APPEND _classpath "${_path}") + if (NOT IS_DIRECTORY "${_path}") + list (APPEND _create_javah_DEPENDS "${_path}") + endif() + else() + message(SEND_ERROR "create_javah: CLASSPATH entry ${_path} does not exist.") + endif() + endforeach() + string (REPLACE ";" "${_classpath_sep}" _classpath "${_classpath}") + list (APPEND _javah_options -classpath ${_classpath}) + endif() + + if (_create_javah_OUTPUT_DIR) + list (APPEND _javah_options -d "${_create_javah_OUTPUT_DIR}") + endif() + + if (_create_javah_OUTPUT_NAME) + list (APPEND _javah_options -o "${_create_javah_OUTPUT_NAME}") + set (_output_files "${_create_javah_OUTPUT_NAME}") + + get_filename_component (_create_javah_OUTPUT_DIR "${_create_javah_OUTPUT_NAME}" DIRECTORY) + get_filename_component (_create_javah_OUTPUT_DIR "${_create_javah_OUTPUT_DIR}" ABSOLUTE) + endif() + + if (NOT _create_javah_OUTPUT_DIR) + set (_create_javah_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}") + endif() + + if (NOT _create_javah_OUTPUT_NAME) + # compute output names + foreach (_class IN LISTS _create_javah_CLASSES) + string (REPLACE "." "_" _c_header "${_class}") + set (_c_header "${_create_javah_OUTPUT_DIR}/${_c_header}.h") + list (APPEND _output_files "${_c_header}") + endforeach() + endif() + + # finalize custom command arguments + if (_create_javah_DEPENDS) + list (INSERT _create_javah_DEPENDS 0 DEPENDS) + endif() + + add_custom_command (OUTPUT ${_output_files} + COMMAND "${Java_JAVAH_EXECUTABLE}" ${_javah_options} -jni ${_create_javah_CLASSES} + ${_create_javah_DEPENDS} + WORKING_DIRECTORY ${_create_javah_OUTPUT_DIR} + COMMENT "Building C header files from classes...") + + if (_create_javah_TARGET) + add_custom_target (${_create_javah_TARGET} ALL DEPENDS ${_output_files}) + endif() + if (_create_javah_GENERATED_FILES) + set (${_create_javah_GENERATED_FILES} ${_output_files} PARENT_SCOPE) + endif() +endfunction() diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 5781a9e..f01a983 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -3032,6 +3032,31 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release --build-options ${build_options} --test-command ${JAVA_RUNTIME} -classpath hello2.jar HelloWorld) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJarSourceList") + + # For next test, java tool must have same architecture as toolchain + math(EXPR _object_mode "${CMAKE_SIZEOF_VOID_P} * 8") + execute_process( + COMMAND "${Java_JAVA_EXECUTABLE}" -d${_object_mode} -version + OUTPUT_QUIET ERROR_QUIET RESULT_VARIABLE _result + ) + if(_result EQUAL 0) + if(CMAKE_CONFIGURATION_TYPES) + set (JAVAH_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaJavah/$) + else() + set (JAVAH_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaJavah) + endif() + add_test(NAME Java.Javah COMMAND ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/JavaJavah" + "${CMake_BINARY_DIR}/Tests/JavaJavah" + ${build_generator_args} + --build-project helloJavah + --build-two-config + --build-run-dir "${CMake_BINARY_DIR}/Tests/JavaJavah/" + --build-options ${build_options} + --test-command ${JAVA_RUNTIME} -Djava.library.path=${JAVAH_LIBRARY_PATH} -classpath hello3.jar HelloWorld2) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJavah") + endif() endif() endif() endif() diff --git a/Tests/JavaJavah/B.cpp b/Tests/JavaJavah/B.cpp new file mode 100644 index 0000000..ef5e48c --- /dev/null +++ b/Tests/JavaJavah/B.cpp @@ -0,0 +1,11 @@ + +#include +#include + +#include "B.h" + +JNIEXPORT void JNICALL Java_B_printName +(JNIEnv *, jobject) +{ + std::cout << "B" << std::endl; +} diff --git a/Tests/JavaJavah/B.java b/Tests/JavaJavah/B.java new file mode 100644 index 0000000..d731f39 --- /dev/null +++ b/Tests/JavaJavah/B.java @@ -0,0 +1,19 @@ +class B +{ + public B() + { + } + + public native void printName(); + + static { + try { + + System.loadLibrary("B"); + + } catch (UnsatisfiedLinkError e) { + System.err.println("Native code library failed to load.\n" + e); + System.exit(1); + } + } +} diff --git a/Tests/JavaJavah/CMakeLists.txt b/Tests/JavaJavah/CMakeLists.txt new file mode 100644 index 0000000..83b0ad0 --- /dev/null +++ b/Tests/JavaJavah/CMakeLists.txt @@ -0,0 +1,20 @@ +project(helloJavah Java CXX) + +cmake_minimum_required (VERSION 2.6) +set(CMAKE_VERBOSE_MAKEFILE 1) + +find_package(Java COMPONENTS Development) +include (UseJava) + +# JNI support +find_package(JNI) + +add_jar(hello3 B.java HelloWorld2.java) +create_javah(TARGET B_javah CLASSES B CLASSPATH hello3) + +add_library(B SHARED B.cpp) +add_dependencies(B B_javah) + +target_include_directories(B PRIVATE ${CMAKE_CURRENT_BINARY_DIR} + ${JAVA_INCLUDE_PATH} + ${JAVA_INCLUDE_PATH2}) diff --git a/Tests/JavaJavah/HelloWorld2.java b/Tests/JavaJavah/HelloWorld2.java new file mode 100644 index 0000000..faf7277 --- /dev/null +++ b/Tests/JavaJavah/HelloWorld2.java @@ -0,0 +1,10 @@ +class HelloWorld2 +{ + public static void main(String args[]) + { + B b; + b = new B(); + b.printName(); + System.out.println("Hello World!"); + } +} ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From brad.king at kitware.com Wed Aug 12 10:22:00 2015 From: brad.king at kitware.com (Brad King) Date: Wed, 12 Aug 2015 10:22:00 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2172-gd50b6fb Message-ID: <20150812142200.C5FA8B1236@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via d50b6fb52f6b1d418da51113533a3c5aece5858b (commit) via f6b552c0d50e274a1f6b77140586eb814b0724e3 (commit) from 1a6de5ad88bc7f92f9c573aba5fd64e7601dfa0d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d50b6fb52f6b1d418da51113533a3c5aece5858b commit d50b6fb52f6b1d418da51113533a3c5aece5858b Merge: 1a6de5a f6b552c Author: Brad King AuthorDate: Wed Aug 12 10:22:00 2015 -0400 Commit: CMake Topic Stage CommitDate: Wed Aug 12 10:22:00 2015 -0400 Merge topic 'java-updates' into next f6b552c0 fixup! UseJava: Add support for javah tool http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f6b552c0d50e274a1f6b77140586eb814b0724e3 commit f6b552c0d50e274a1f6b77140586eb814b0724e3 Author: Brad King AuthorDate: Wed Aug 12 10:13:06 2015 -0400 Commit: Brad King CommitDate: Wed Aug 12 10:14:32 2015 -0400 fixup! UseJava: Add support for javah tool diff --git a/Tests/JavaJavah/B.cpp b/Tests/JavaJavah/B.cpp index ef5e48c..2666757 100644 --- a/Tests/JavaJavah/B.cpp +++ b/Tests/JavaJavah/B.cpp @@ -1,11 +1,10 @@ #include -#include +#include #include "B.h" -JNIEXPORT void JNICALL Java_B_printName -(JNIEnv *, jobject) +JNIEXPORT void JNICALL Java_B_printName(JNIEnv *, jobject) { - std::cout << "B" << std::endl; + printf("B\n"); } diff --git a/Tests/JavaJavah/CMakeLists.txt b/Tests/JavaJavah/CMakeLists.txt index 83b0ad0..bc803a1 100644 --- a/Tests/JavaJavah/CMakeLists.txt +++ b/Tests/JavaJavah/CMakeLists.txt @@ -12,7 +12,7 @@ find_package(JNI) add_jar(hello3 B.java HelloWorld2.java) create_javah(TARGET B_javah CLASSES B CLASSPATH hello3) -add_library(B SHARED B.cpp) +add_library(B MODULE B.cpp) add_dependencies(B B_javah) target_include_directories(B PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ----------------------------------------------------------------------- Summary of changes: Tests/JavaJavah/B.cpp | 7 +++---- Tests/JavaJavah/CMakeLists.txt | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Wed Aug 12 10:22:12 2015 From: brad.king at kitware.com (Brad King) Date: Wed, 12 Aug 2015 10:22:12 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2174-g54f235e Message-ID: <20150812142212.77173B125C@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 54f235ecda0700d9ffea68ee6b254c5ef822dae0 (commit) via cae7bef9d6a51a38fef0cb0f40fb965fca92c1b1 (commit) from d50b6fb52f6b1d418da51113533a3c5aece5858b (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=54f235ecda0700d9ffea68ee6b254c5ef822dae0 commit 54f235ecda0700d9ffea68ee6b254c5ef822dae0 Merge: d50b6fb cae7bef Author: Brad King AuthorDate: Wed Aug 12 10:22:11 2015 -0400 Commit: CMake Topic Stage CommitDate: Wed Aug 12 10:22:11 2015 -0400 Merge topic 'java-updates' into next cae7bef9 UseJava: Add support for javah tool http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cae7bef9d6a51a38fef0cb0f40fb965fca92c1b1 commit cae7bef9d6a51a38fef0cb0f40fb965fca92c1b1 Author: Marc Chevrier AuthorDate: Wed Aug 5 07:46:02 2015 +0000 Commit: Brad King CommitDate: Wed Aug 12 10:22:03 2015 -0400 UseJava: Add support for javah tool Add a `create_javah` API. diff --git a/Help/release/dev/java-updates.rst b/Help/release/dev/java-updates.rst index b777807..8fd4ed6 100644 --- a/Help/release/dev/java-updates.rst +++ b/Help/release/dev/java-updates.rst @@ -11,3 +11,6 @@ java-updates * The :module:`UseJava` module ``install_jar`` function learned new ``DESTINATION`` and ``COMPONENT`` options to specify the corresponding :command:`install` command options. + +* The :module:`UseJava` module gained a new ``create_javah`` + function to create C headers from Java classes. diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake index c61591d..dced6ec 100644 --- a/Modules/UseJava.cmake +++ b/Modules/UseJava.cmake @@ -309,6 +309,65 @@ # # # if you don't set the INSTALLPATH. +# +# :: +# +# create_javah(TARGET +# GENERATED_FILES +# CLASSES ... +# [CLASSPATH ...] +# [DEPENDS ...] +# [OUTPUT_NAME |OUTPUT_DIR ] +# ) +# +# Create C header files from java classes. These files provide the connective glue +# that allow your Java and C code to interact. +# +# There are two main signatures for create_javah. The first signature +# returns generated files throught variable specified by GENERATED_FILES option: +# +# :: +# +# Example: +# Create_javah(GENERATED_FILES files_headers +# CLASSES org.cmake.HelloWorld +# CLASSPATH hello.jar +# ) +# +# +# +# The second signature for create_javah creates a target which encapsulates +# header files generation. +# +# :: +# +# Example: +# Create_javah(TARGET target_headers +# CLASSES org.cmake.HelloWorld +# CLASSPATH hello.jar +# ) +# +# +# +# Both signatures share same options. +# +# ``CLASSES ...`` +# Specifies Java classes used to generate headers. +# +# ``CLASSPATH ...`` +# Specifies various paths to look up classes. Here .class files, jar files or targets +# created by command add_jar can be used. +# +# ``DEPENDS ...`` +# Targets on which the javah target depends +# +# ``OUTPUT_NAME `` +# Concatenates the resulting header files for all the classes listed by option CLASSES +# into . Same behavior as option '-o' of javah tool. +# +# ``OUTPUT_DIR `` +# Sets the directory where the header files will be generated. Same behavior as option +# '-d' of javah tool. If not specified, ${CMAKE_CURRENT_BINARY_DIR} is used as output directory. #============================================================================= # Copyright 2013 OpenGamma Ltd. @@ -1131,3 +1190,101 @@ function(create_javadoc _target) DESTINATION ${_javadoc_installpath} ) endfunction() + +function (create_javah) + cmake_parse_arguments(_create_javah + "" + "TARGET;GENERATED_FILES;OUTPUT_NAME;OUTPUT_DIR" + "CLASSES;CLASSPATH;DEPENDS" + ${ARGN}) + + # ckeck parameters + if (NOT _create_javah_TARGET AND NOT _create_javah_GENERATED_FILES) + message (FATAL_ERROR "create_javah: TARGET or GENERATED_FILES must be specified.") + endif() + if (_create_javah_OUTPUT_NAME AND _create_javah_OUTPUT_DIR) + message (FATAL_ERROR "create_javah: OUTPUT_NAME and OUTPUT_DIR are mutually exclusive.") + endif() + + if (NOT _create_javah_CLASSES) + message (FATAL_ERROR "create_javah: CLASSES is a required parameter.") + endif() + + set (_output_files) + if (WIN32 AND NOT CYGWIN AND CMAKE_HOST_SYSTEM_NAME MATCHES "Windows") + set(_classpath_sep ";") + else () + set(_classpath_sep ":") + endif() + + # handle javah options + set (_javah_options) + + if (_create_javah_CLASSPATH) + # CLASSPATH can specify directories, jar files or targets created with add_jar command + set (_classpath) + foreach (_path IN LISTS _create_javah_CLASSPATH) + if (TARGET ${_path}) + get_target_property (_jar_path ${_path} JAR_FILE) + if (_jar_path) + list (APPEND _classpath "${_jar_path}") + list (APPEND _create_javah_DEPENDS "${_path}") + else() + message(SEND_ERROR "create_javah: CLASSPATH target ${_path} is not a jar.") + endif() + elseif (EXISTS "${_path}") + list (APPEND _classpath "${_path}") + if (NOT IS_DIRECTORY "${_path}") + list (APPEND _create_javah_DEPENDS "${_path}") + endif() + else() + message(SEND_ERROR "create_javah: CLASSPATH entry ${_path} does not exist.") + endif() + endforeach() + string (REPLACE ";" "${_classpath_sep}" _classpath "${_classpath}") + list (APPEND _javah_options -classpath ${_classpath}) + endif() + + if (_create_javah_OUTPUT_DIR) + list (APPEND _javah_options -d "${_create_javah_OUTPUT_DIR}") + endif() + + if (_create_javah_OUTPUT_NAME) + list (APPEND _javah_options -o "${_create_javah_OUTPUT_NAME}") + set (_output_files "${_create_javah_OUTPUT_NAME}") + + get_filename_component (_create_javah_OUTPUT_DIR "${_create_javah_OUTPUT_NAME}" DIRECTORY) + get_filename_component (_create_javah_OUTPUT_DIR "${_create_javah_OUTPUT_DIR}" ABSOLUTE) + endif() + + if (NOT _create_javah_OUTPUT_DIR) + set (_create_javah_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}") + endif() + + if (NOT _create_javah_OUTPUT_NAME) + # compute output names + foreach (_class IN LISTS _create_javah_CLASSES) + string (REPLACE "." "_" _c_header "${_class}") + set (_c_header "${_create_javah_OUTPUT_DIR}/${_c_header}.h") + list (APPEND _output_files "${_c_header}") + endforeach() + endif() + + # finalize custom command arguments + if (_create_javah_DEPENDS) + list (INSERT _create_javah_DEPENDS 0 DEPENDS) + endif() + + add_custom_command (OUTPUT ${_output_files} + COMMAND "${Java_JAVAH_EXECUTABLE}" ${_javah_options} -jni ${_create_javah_CLASSES} + ${_create_javah_DEPENDS} + WORKING_DIRECTORY ${_create_javah_OUTPUT_DIR} + COMMENT "Building C header files from classes...") + + if (_create_javah_TARGET) + add_custom_target (${_create_javah_TARGET} ALL DEPENDS ${_output_files}) + endif() + if (_create_javah_GENERATED_FILES) + set (${_create_javah_GENERATED_FILES} ${_output_files} PARENT_SCOPE) + endif() +endfunction() diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 5781a9e..f01a983 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -3032,6 +3032,31 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release --build-options ${build_options} --test-command ${JAVA_RUNTIME} -classpath hello2.jar HelloWorld) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJarSourceList") + + # For next test, java tool must have same architecture as toolchain + math(EXPR _object_mode "${CMAKE_SIZEOF_VOID_P} * 8") + execute_process( + COMMAND "${Java_JAVA_EXECUTABLE}" -d${_object_mode} -version + OUTPUT_QUIET ERROR_QUIET RESULT_VARIABLE _result + ) + if(_result EQUAL 0) + if(CMAKE_CONFIGURATION_TYPES) + set (JAVAH_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaJavah/$) + else() + set (JAVAH_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaJavah) + endif() + add_test(NAME Java.Javah COMMAND ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/JavaJavah" + "${CMake_BINARY_DIR}/Tests/JavaJavah" + ${build_generator_args} + --build-project helloJavah + --build-two-config + --build-run-dir "${CMake_BINARY_DIR}/Tests/JavaJavah/" + --build-options ${build_options} + --test-command ${JAVA_RUNTIME} -Djava.library.path=${JAVAH_LIBRARY_PATH} -classpath hello3.jar HelloWorld2) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJavah") + endif() endif() endif() endif() diff --git a/Tests/JavaJavah/B.cpp b/Tests/JavaJavah/B.cpp new file mode 100644 index 0000000..2666757 --- /dev/null +++ b/Tests/JavaJavah/B.cpp @@ -0,0 +1,10 @@ + +#include +#include + +#include "B.h" + +JNIEXPORT void JNICALL Java_B_printName(JNIEnv *, jobject) +{ + printf("B\n"); +} diff --git a/Tests/JavaJavah/B.java b/Tests/JavaJavah/B.java new file mode 100644 index 0000000..d731f39 --- /dev/null +++ b/Tests/JavaJavah/B.java @@ -0,0 +1,19 @@ +class B +{ + public B() + { + } + + public native void printName(); + + static { + try { + + System.loadLibrary("B"); + + } catch (UnsatisfiedLinkError e) { + System.err.println("Native code library failed to load.\n" + e); + System.exit(1); + } + } +} diff --git a/Tests/JavaJavah/CMakeLists.txt b/Tests/JavaJavah/CMakeLists.txt new file mode 100644 index 0000000..bc803a1 --- /dev/null +++ b/Tests/JavaJavah/CMakeLists.txt @@ -0,0 +1,20 @@ +project(helloJavah Java CXX) + +cmake_minimum_required (VERSION 2.6) +set(CMAKE_VERBOSE_MAKEFILE 1) + +find_package(Java COMPONENTS Development) +include (UseJava) + +# JNI support +find_package(JNI) + +add_jar(hello3 B.java HelloWorld2.java) +create_javah(TARGET B_javah CLASSES B CLASSPATH hello3) + +add_library(B MODULE B.cpp) +add_dependencies(B B_javah) + +target_include_directories(B PRIVATE ${CMAKE_CURRENT_BINARY_DIR} + ${JAVA_INCLUDE_PATH} + ${JAVA_INCLUDE_PATH2}) diff --git a/Tests/JavaJavah/HelloWorld2.java b/Tests/JavaJavah/HelloWorld2.java new file mode 100644 index 0000000..faf7277 --- /dev/null +++ b/Tests/JavaJavah/HelloWorld2.java @@ -0,0 +1,10 @@ +class HelloWorld2 +{ + public static void main(String args[]) + { + B b; + b = new B(); + b.printName(); + System.out.println("Hello World!"); + } +} ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From brad.king at kitware.com Wed Aug 12 13:42:50 2015 From: brad.king at kitware.com (Brad King) Date: Wed, 12 Aug 2015 13:42:50 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2176-g4e2f5af Message-ID: <20150812174250.4D136B033F@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 4e2f5af4f8c3b22fd99f8aca23401a05216917b6 (commit) via 5c69f02a3ade91bfb85d6c782ca16ac31d993e69 (commit) from 54f235ecda0700d9ffea68ee6b254c5ef822dae0 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4e2f5af4f8c3b22fd99f8aca23401a05216917b6 commit 4e2f5af4f8c3b22fd99f8aca23401a05216917b6 Merge: 54f235e 5c69f02 Author: Brad King AuthorDate: Wed Aug 12 13:42:49 2015 -0400 Commit: CMake Topic Stage CommitDate: Wed Aug 12 13:42:49 2015 -0400 Merge topic 'OUTPUT_DIRECTORY-genex' into next 5c69f02a fixup! Add generator expression support to OUTPUT_DIRECTORY target properties http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5c69f02a3ade91bfb85d6c782ca16ac31d993e69 commit 5c69f02a3ade91bfb85d6c782ca16ac31d993e69 Author: Brad King AuthorDate: Wed Aug 12 13:39:45 2015 -0400 Commit: Brad King CommitDate: Wed Aug 12 13:39:45 2015 -0400 fixup! Add generator expression support to OUTPUT_DIRECTORY target properties diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt index 4df5d07..7fdfaa8 100644 --- a/Tests/ExportImport/Export/CMakeLists.txt +++ b/Tests/ExportImport/Export/CMakeLists.txt @@ -111,9 +111,9 @@ target_link_libraries(testExe4 testExe1lib) set_property(TARGET testLib7 PROPERTY ARCHIVE_OUTPUT_DIRECTORY_DEBUG testLib7D-$) set_property(TARGET testLib7 PROPERTY ARCHIVE_OUTPUT_DIRECTORY_RELEASE testLib7R-$) set_property(TARGET testLib7 PROPERTY ARCHIVE_OUTPUT_DIRECTORY testLib7-$) -set_property(TARGET testLib4 PROPERTY LIBRARY_OUTPUT_DIRECTORY_DEBUG testLib4D-$) -set_property(TARGET testLib4 PROPERTY LIBRARY_OUTPUT_DIRECTORY_RELEASE testLib4R-$) -set_property(TARGET testLib4 PROPERTY LIBRARY_OUTPUT_DIRECTORY testLib4-$) +set_property(TARGET testLib5 PROPERTY LIBRARY_OUTPUT_DIRECTORY_DEBUG testLib5D-$) +set_property(TARGET testLib5 PROPERTY LIBRARY_OUTPUT_DIRECTORY_RELEASE testLib5R-$) +set_property(TARGET testLib5 PROPERTY LIBRARY_OUTPUT_DIRECTORY testLib5-$) set_property(TARGET testExe4 PROPERTY RUNTIME_OUTPUT_DIRECTORY_DEBUG testExe4D-$) set_property(TARGET testExe4 PROPERTY RUNTIME_OUTPUT_DIRECTORY_RELEASE testExe4R-$) set_property(TARGET testExe4 PROPERTY RUNTIME_OUTPUT_DIRECTORY testExe4-$) ----------------------------------------------------------------------- Summary of changes: Tests/ExportImport/Export/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Wed Aug 12 13:43:20 2015 From: brad.king at kitware.com (Brad King) Date: Wed, 12 Aug 2015 13:43:20 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2179-g649dced Message-ID: <20150812174320.1EFD2B0399@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 649dced42143e24afa54fe1b9b597f946c047929 (commit) via d25819bc2623b5144ffc57b694500993ac5759b4 (commit) via e36a05fd7f7d008c4c1e75ebf46eac3072ef71b1 (commit) from 4e2f5af4f8c3b22fd99f8aca23401a05216917b6 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=649dced42143e24afa54fe1b9b597f946c047929 commit 649dced42143e24afa54fe1b9b597f946c047929 Merge: 4e2f5af d25819b Author: Brad King AuthorDate: Wed Aug 12 13:43:19 2015 -0400 Commit: CMake Topic Stage CommitDate: Wed Aug 12 13:43:19 2015 -0400 Merge topic 'OUTPUT_DIRECTORY-genex' into next d25819bc Add generator expression support to OUTPUT_DIRECTORY target properties e36a05fd cmTarget: Detect and diagnose recursion in GetOutputInfo http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d25819bc2623b5144ffc57b694500993ac5759b4 commit d25819bc2623b5144ffc57b694500993ac5759b4 Author: Robert Goulet AuthorDate: Tue Aug 11 15:19:03 2015 -0400 Commit: Brad King CommitDate: Wed Aug 12 13:43:00 2015 -0400 Add generator expression support to OUTPUT_DIRECTORY target properties If {ARCHIVE,LIBRARY,RUNTIME}_OUTPUT_DIRECTORY is set with a genex then do not add the per-config subdirectory on multi-config generators. This will allow projects to use $ to place the per-config part of the directory path somewhere other than the end. diff --git a/Help/prop_tgt/ARCHIVE_OUTPUT_DIRECTORY_CONFIG.rst b/Help/prop_tgt/ARCHIVE_OUTPUT_DIRECTORY_CONFIG.rst index 29991eb..12f8bb7 100644 --- a/Help/prop_tgt/ARCHIVE_OUTPUT_DIRECTORY_CONFIG.rst +++ b/Help/prop_tgt/ARCHIVE_OUTPUT_DIRECTORY_CONFIG.rst @@ -11,3 +11,6 @@ per-configuration subdirectory to the specified directory. This property is initialized by the value of the :variable:`CMAKE_ARCHIVE_OUTPUT_DIRECTORY_` variable if it is set when a target is created. + +Contents of ``ARCHIVE_OUTPUT_DIRECTORY_`` may use +:manual:`generator expressions `. diff --git a/Help/prop_tgt/LIBRARY_OUTPUT_DIRECTORY_CONFIG.rst b/Help/prop_tgt/LIBRARY_OUTPUT_DIRECTORY_CONFIG.rst index 6fc0142..28dd404 100644 --- a/Help/prop_tgt/LIBRARY_OUTPUT_DIRECTORY_CONFIG.rst +++ b/Help/prop_tgt/LIBRARY_OUTPUT_DIRECTORY_CONFIG.rst @@ -11,3 +11,6 @@ per-configuration subdirectory to the specified directory. This property is initialized by the value of the :variable:`CMAKE_LIBRARY_OUTPUT_DIRECTORY_` variable if it is set when a target is created. + +Contents of ``LIBRARY_OUTPUT_DIRECTORY_`` may use +:manual:`generator expressions `. diff --git a/Help/prop_tgt/RUNTIME_OUTPUT_DIRECTORY_CONFIG.rst b/Help/prop_tgt/RUNTIME_OUTPUT_DIRECTORY_CONFIG.rst index c100346..94fb277 100644 --- a/Help/prop_tgt/RUNTIME_OUTPUT_DIRECTORY_CONFIG.rst +++ b/Help/prop_tgt/RUNTIME_OUTPUT_DIRECTORY_CONFIG.rst @@ -11,3 +11,6 @@ per-configuration subdirectory to the specified directory. This property is initialized by the value of the :variable:`CMAKE_RUNTIME_OUTPUT_DIRECTORY_` variable if it is set when a target is created. + +Contents of ``RUNTIME_OUTPUT_DIRECTORY_`` may use +:manual:`generator expressions `. diff --git a/Help/prop_tgt/XXX_OUTPUT_DIRECTORY.txt b/Help/prop_tgt/XXX_OUTPUT_DIRECTORY.txt index 0b3d31c..3ae5448 100644 --- a/Help/prop_tgt/XXX_OUTPUT_DIRECTORY.txt +++ b/Help/prop_tgt/XXX_OUTPUT_DIRECTORY.txt @@ -1,8 +1,11 @@ Output directory in which to build |XXX| target files. This property specifies the directory into which |xxx| target files -should be built. Multi-configuration generators (VS, Xcode) append a -per-configuration subdirectory to the specified directory. +should be built. The property value may use +:manual:`generator expressions `. +Multi-configuration generators (VS, Xcode) append a per-configuration +subdirectory to the specified directory unless a generator expression +is used. This property is initialized by the value of the variable |CMAKE_XXX_OUTPUT_DIRECTORY| if it is set when a target is created. diff --git a/Help/release/dev/OUTPUT_DIRECTORY-genex.rst b/Help/release/dev/OUTPUT_DIRECTORY-genex.rst new file mode 100644 index 0000000..8b839c0 --- /dev/null +++ b/Help/release/dev/OUTPUT_DIRECTORY-genex.rst @@ -0,0 +1,7 @@ +OUTPUT_DIRECTORY-genex +---------------------- + +* The :prop_tgt:`ARCHIVE_OUTPUT_DIRECTORY`, + :prop_tgt:`LIBRARY_OUTPUT_DIRECTORY`, and + :prop_tgt:`RUNTIME_OUTPUT_DIRECTORY` target properties learned to + support :manual:`generator expressions `. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index d2d4c67..a94c2dd 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3520,7 +3520,10 @@ bool cmTarget::ComputeOutputDir(const std::string& config, if(const char* config_outdir = this->GetProperty(configProp)) { // Use the user-specified per-configuration output directory. - out = config_outdir; + cmGeneratorExpression ge; + cmsys::auto_ptr cge = + ge.Parse(config_outdir); + out = cge->Evaluate(this->Makefile, config); // Skip per-configuration subdirectory. conf = ""; @@ -3528,7 +3531,17 @@ bool cmTarget::ComputeOutputDir(const std::string& config, else if(const char* outdir = this->GetProperty(propertyName)) { // Use the user-specified output directory. - out = outdir; + cmGeneratorExpression ge; + cmsys::auto_ptr cge = + ge.Parse(outdir); + out = cge->Evaluate(this->Makefile, config); + + // Skip per-configuration subdirectory if the value contained a + // generator expression. + if (out != outdir) + { + conf = ""; + } } else if(this->GetType() == cmTarget::EXECUTABLE) { diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt index df3f178..7fdfaa8 100644 --- a/Tests/ExportImport/Export/CMakeLists.txt +++ b/Tests/ExportImport/Export/CMakeLists.txt @@ -105,6 +105,19 @@ target_link_libraries(testLib4 add_executable(testExe3 testExe3.c) set_property(TARGET testExe3 PROPERTY MACOSX_BUNDLE 1) +# Test _OUTPUT_DIRECTORY[_] properties with generator expressions +add_executable(testExe4 testExe4.c) +target_link_libraries(testExe4 testExe1lib) +set_property(TARGET testLib7 PROPERTY ARCHIVE_OUTPUT_DIRECTORY_DEBUG testLib7D-$) +set_property(TARGET testLib7 PROPERTY ARCHIVE_OUTPUT_DIRECTORY_RELEASE testLib7R-$) +set_property(TARGET testLib7 PROPERTY ARCHIVE_OUTPUT_DIRECTORY testLib7-$) +set_property(TARGET testLib5 PROPERTY LIBRARY_OUTPUT_DIRECTORY_DEBUG testLib5D-$) +set_property(TARGET testLib5 PROPERTY LIBRARY_OUTPUT_DIRECTORY_RELEASE testLib5R-$) +set_property(TARGET testLib5 PROPERTY LIBRARY_OUTPUT_DIRECTORY testLib5-$) +set_property(TARGET testExe4 PROPERTY RUNTIME_OUTPUT_DIRECTORY_DEBUG testExe4D-$) +set_property(TARGET testExe4 PROPERTY RUNTIME_OUTPUT_DIRECTORY_RELEASE testExe4R-$) +set_property(TARGET testExe4 PROPERTY RUNTIME_OUTPUT_DIRECTORY testExe4-$) + # Test cyclic dependencies. add_library(testLibCycleA STATIC testLibCycleA1.c testLibCycleA2.c testLibCycleA3.c) @@ -450,7 +463,7 @@ install(FILES # Install and export from install tree. install( TARGETS - testExe1 testLib1 testLib2 testExe2 testLib3 testLib4 testExe3 + testExe1 testLib1 testLib2 testExe2 testLib3 testLib4 testExe3 testExe4 testExe2lib testLib4lib testLib4libdbg testLib4libopt testLib6 testLib7 testLibCycleA testLibCycleB @@ -511,7 +524,7 @@ export(TARGETS testExe1 testLib1 testLib2 testLib3 NAMESPACE bld_ FILE ExportBuildTree.cmake ) -export(TARGETS testExe2 testLib4 testLib5 testLib6 testLib7 testExe3 testExe2lib +export(TARGETS testExe2 testLib4 testLib5 testLib6 testLib7 testExe3 testExe4 testExe2lib testLib4lib testLib4libdbg testLib4libopt testLibCycleA testLibCycleB testLibPerConfigDest diff --git a/Tests/ExportImport/Export/testExe4.c b/Tests/ExportImport/Export/testExe4.c new file mode 100644 index 0000000..731057e --- /dev/null +++ b/Tests/ExportImport/Export/testExe4.c @@ -0,0 +1,24 @@ +#include + +int main(int argc, const char* argv[]) +{ + if(argc < 2) + { + fprintf(stderr, "Must specify output file.\n"); + return 1; + } + { + FILE* f = fopen(argv[1], "w"); + if(f) + { + fprintf(f, "int generated_by_testExe4() { return 0; }\n"); + fclose(f); + } + else + { + fprintf(stderr, "Error writing to %s\n", argv[1]); + return 1; + } + } + return 0; +} diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt index a74bad1..0f56495 100644 --- a/Tests/ExportImport/Import/A/CMakeLists.txt +++ b/Tests/ExportImport/Import/A/CMakeLists.txt @@ -19,11 +19,17 @@ add_custom_command( COMMAND exp_testExe3 ${Import_BINARY_DIR}/exp_generated3.c DEPENDS exp_testExe3 ) +add_custom_command( + OUTPUT ${Import_BINARY_DIR}/exp_generated4.c + COMMAND exp_testExe4 ${Import_BINARY_DIR}/exp_generated4.c + DEPENDS exp_testExe4 + ) add_executable(imp_testExe1 imp_testExe1.c ${Import_BINARY_DIR}/exp_generated.c ${Import_BINARY_DIR}/exp_generated3.c + ${Import_BINARY_DIR}/exp_generated4.c ) # Try linking to a library imported from the install tree. @@ -53,11 +59,17 @@ add_custom_command( COMMAND bld_testExe3 ${Import_BINARY_DIR}/bld_generated3.c DEPENDS bld_testExe3 ) +add_custom_command( + OUTPUT ${Import_BINARY_DIR}/bld_generated4.c + COMMAND bld_testExe4 ${Import_BINARY_DIR}/bld_generated4.c + DEPENDS bld_testExe4 + ) add_executable(imp_testExe1b imp_testExe1.c ${Import_BINARY_DIR}/bld_generated.c ${Import_BINARY_DIR}/bld_generated3.c + ${Import_BINARY_DIR}/bld_generated4.c ) # Try linking to a library imported from the build tree. diff --git a/Tests/ExportImport/Import/A/imp_testExe1.c b/Tests/ExportImport/Import/A/imp_testExe1.c index 56cdd2c..0a74309 100644 --- a/Tests/ExportImport/Import/A/imp_testExe1.c +++ b/Tests/ExportImport/Import/A/imp_testExe1.c @@ -1,5 +1,6 @@ extern int generated_by_testExe1(); extern int generated_by_testExe3(); +extern int generated_by_testExe4(); extern int testLib2(); extern int testLib3(); extern int testLib4(); @@ -24,5 +25,5 @@ int main() return (testLib2() + generated_by_testExe1() + testLib3() + testLib4() + testLib5() + testLib6() + testLib7() + testLibCycleA1() + testLibPerConfigDest() - + generated_by_testExe3() + testLib4lib() + testLib4libcfg()); + + generated_by_testExe3() + generated_by_testExe4() + testLib4lib() + testLib4libcfg()); } diff --git a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake index cba3941..21fc851 100644 --- a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake @@ -25,6 +25,7 @@ run_cmake(COMPILE_LANGUAGE-add_executable) run_cmake(COMPILE_LANGUAGE-add_library) run_cmake(COMPILE_LANGUAGE-add_test) run_cmake(COMPILE_LANGUAGE-unknown-lang) +run_cmake(TARGET_FILE-recursion) run_cmake(ImportedTarget-TARGET_PDB_FILE) if(LINKER_SUPPORTS_PDB) diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion-result.txt b/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion-stderr.txt b/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion-stderr.txt new file mode 100644 index 0000000..5b15526 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at TARGET_FILE-recursion.cmake:[0-9]+ \(add_executable\): + Target 'empty1' OUTPUT_DIRECTORY depends on itself. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion.cmake new file mode 100644 index 0000000..7633be1 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion.cmake @@ -0,0 +1,3 @@ +enable_language(C) +add_executable(empty1 empty.c) +set_property(TARGET empty1 PROPERTY RUNTIME_OUTPUT_DIRECTORY $) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e36a05fd7f7d008c4c1e75ebf46eac3072ef71b1 commit e36a05fd7f7d008c4c1e75ebf46eac3072ef71b1 Author: Robert Goulet AuthorDate: Tue Aug 11 15:18:39 2015 -0400 Commit: Brad King CommitDate: Wed Aug 12 13:42:57 2015 -0400 cmTarget: Detect and diagnose recursion in GetOutputInfo diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index d3170e4..d2d4c67 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -66,6 +66,8 @@ struct cmTarget::OutputInfo std::string OutDir; std::string ImpDir; std::string PdbDir; + bool empty() const + { return OutDir.empty() && ImpDir.empty() && PdbDir.empty(); } }; //---------------------------------------------------------------------------- @@ -2609,19 +2611,35 @@ cmTarget::OutputInfo const* cmTarget::GetOutputInfo( config_upper = cmSystemTools::UpperCase(config); } typedef cmTargetInternals::OutputInfoMapType OutputInfoMapType; - OutputInfoMapType::const_iterator i = + OutputInfoMapType::iterator i = this->Internal->OutputInfoMap.find(config_upper); if(i == this->Internal->OutputInfoMap.end()) { + // Add empty info in map to detect potential recursion. OutputInfo info; + OutputInfoMapType::value_type entry(config_upper, info); + i = this->Internal->OutputInfoMap.insert(entry).first; + + // Compute output directories. this->ComputeOutputDir(config, false, info.OutDir); this->ComputeOutputDir(config, true, info.ImpDir); if(!this->ComputePDBOutputDir("PDB", config, info.PdbDir)) { info.PdbDir = info.OutDir; } - OutputInfoMapType::value_type entry(config_upper, info); - i = this->Internal->OutputInfoMap.insert(entry).first; + + // Now update the previously-prepared map entry. + i->second = info; + } + else if(i->second.empty()) + { + // An empty map entry indicates we have been called recursively + // from the above block. + this->Makefile->GetCMakeInstance()->IssueMessage( + cmake::FATAL_ERROR, + "Target '" + this->GetName() + "' OUTPUT_DIRECTORY depends on itself.", + this->GetBacktrace()); + return 0; } return &i->second; } ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From kwrobot at kitware.com Thu Aug 13 00:01:09 2015 From: kwrobot at kitware.com (Kitware Robot) Date: Thu, 13 Aug 2015 00:01:09 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-822-ga0b32a3 Message-ID: <20150813040110.004DFB14BF@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via a0b32a348d34d387b9b60da43f6f146cbd07ca6a (commit) from ce254de60e32dd1be95b430d37dc9bb67911d158 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a0b32a348d34d387b9b60da43f6f146cbd07ca6a commit a0b32a348d34d387b9b60da43f6f146cbd07ca6a Author: Kitware Robot AuthorDate: Thu Aug 13 00:01:07 2015 -0400 Commit: Kitware Robot CommitDate: Thu Aug 13 00:01:07 2015 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 04813b0..620e3e3 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150812) +set(CMake_VERSION_PATCH 20150813) #set(CMake_VERSION_RC 1) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 13 08:57:22 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 13 Aug 2015 08:57:22 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2185-g3fb4274 Message-ID: <20150813125722.0BDF0B146F@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 3fb42748e4361c2cbd2ccd2e67251c703b1caf25 (commit) via 04f2b72bcfb40c826c1a93520dc0623ec7e7d20d (commit) via aaba29b1689a0833dd14cce51154127e62a4baa3 (commit) via 91e8d35ab8ec2d62478a42eff10af88713497fad (commit) via 602cdc06a01b7c5c0eb444111382b09040f677ee (commit) via 706542615828488a5ad197d0ef3dd5e42eb739c4 (commit) from 649dced42143e24afa54fe1b9b597f946c047929 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3fb42748e4361c2cbd2ccd2e67251c703b1caf25 commit 3fb42748e4361c2cbd2ccd2e67251c703b1caf25 Merge: 649dced 04f2b72 Author: Brad King AuthorDate: Thu Aug 13 08:57:13 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 13 08:57:13 2015 -0400 Merge topic 'update-curl' into next 04f2b72b curl: Update README-CMake.txt for new snapshot aaba29b1 curl: Update configuration of build within CMake 91e8d35a Merge branch 'curl-upstream' into update-curl 602cdc06 cmCurl: Tolerate lack of CURLOPT_CAPATH support 70654261 curl 7.44.0 (reduced) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=04f2b72bcfb40c826c1a93520dc0623ec7e7d20d commit 04f2b72bcfb40c826c1a93520dc0623ec7e7d20d Author: Brad King AuthorDate: Wed Aug 12 15:05:28 2015 -0400 Commit: Brad King CommitDate: Wed Aug 12 15:45:46 2015 -0400 curl: Update README-CMake.txt for new snapshot diff --git a/Utilities/cmcurl/README-CMake.txt b/Utilities/cmcurl/README-CMake.txt index 3f053d8..1e75672 100644 --- a/Utilities/cmcurl/README-CMake.txt +++ b/Utilities/cmcurl/README-CMake.txt @@ -11,7 +11,7 @@ branch, but it is merged into our history. Update curl from upstream as follows. Create a local branch to explicitly reference the upstream snapshot branch head: - git branch curl-upstream 3fe5d9bf + git branch curl-upstream 70654261 Use a temporary directory to checkout the branch: @@ -24,7 +24,7 @@ Use a temporary directory to checkout the branch: Now place the (reduced) curl content in this directory. See instructions shown by - git log 3fe5d9bf + git log 70654261 for help extracting the content from the upstream repo. Then run the following commands to commit the new version. Substitute the @@ -34,8 +34,8 @@ appropriate date and version number: GIT_AUTHOR_NAME='Curl Upstream' \ GIT_AUTHOR_EMAIL='curl-library at cool.haxx.se' \ - GIT_AUTHOR_DATE='Wed Sep 10 08:07:58 2014 +0200' \ - git commit -m 'curl 7.38.0 (reduced)' && + GIT_AUTHOR_DATE='Tue Aug 11 20:13:01 2015 +0200' \ + git commit -m 'curl 7.44.0 (reduced)' && git commit --amend Edit the commit message to describe the procedure used to obtain the http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=aaba29b1689a0833dd14cce51154127e62a4baa3 commit aaba29b1689a0833dd14cce51154127e62a4baa3 Author: Brad King AuthorDate: Wed Aug 12 15:04:21 2015 -0400 Commit: Brad King CommitDate: Wed Aug 12 15:45:42 2015 -0400 curl: Update configuration of build within CMake Update our curl build option settings as needed for CMake to account for differences in curl options from 7.38 to 7.44. diff --git a/Utilities/cmcurl/CMakeLists.txt b/Utilities/cmcurl/CMakeLists.txt index 6b01be9..d12c73f 100644 --- a/Utilities/cmcurl/CMakeLists.txt +++ b/Utilities/cmcurl/CMakeLists.txt @@ -3,6 +3,7 @@ set(BUILD_CURL_EXE OFF CACHE INTERNAL "No curl exe") set(BUILD_CURL_TESTS OFF CACHE INTERNAL "No curl tests") set(BUILD_DASHBOARD_REPORTS OFF CACHE INTERNAL "No curl dashboard reports") set(BUILD_RELEASE_DEBUG_DIRS OFF CACHE INTERNAL "No curl release/debug dirs") +set(CMAKE_USE_GSSAPI OFF CACHE INTERNAL "Disable curl gssapi") set(CMAKE_USE_LIBSSH2 OFF CACHE INTERNAL "Disable curl libssh2") set(CMAKE_USE_OPENLDAP OFF CACHE INTERNAL "No curl OpenLDAP") set(CURL_DISABLE_COOKIES OFF CACHE INTERNAL "Do not disable curl cookie support") @@ -16,18 +17,24 @@ set(CURL_DISABLE_IMAP ON CACHE INTERNAL "Disable curl imap protocol?") set(CURL_DISABLE_LDAP ON CACHE INTERNAL "Disable curl ldap protocol?") set(CURL_DISABLE_LDAPS ON CACHE INTERNAL "Disable curl ldaps protocol?") set(CURL_DISABLE_POP3 ON CACHE INTERNAL "Disable curl pop3 protocol?") +set(CURL_DISABLE_PROXY OFF CACHE INTERNAL "Do not disable curl proxy") set(CURL_DISABLE_RTSP ON CACHE INTERNAL "Disable curl rtsp protocol?") set(CURL_DISABLE_SMTP ON CACHE INTERNAL "Disable curl smtp protocol?") set(CURL_DISABLE_TELNET ON CACHE INTERNAL "Disable curl telnet protocol?") set(CURL_DISABLE_TFTP ON CACHE INTERNAL "Disable curl tftp protocol?") -set(CURL_DISABLE_VERBOSE_STRING OFF CACHE INTERNAL "Do not disable curl verbosity") +set(CURL_DISABLE_VERBOSE_STRINGS OFF CACHE INTERNAL "Do not disable curl verbosity") set(CURL_HIDDEN_SYMBOLS OFF CACHE INTERNAL "No curl hidden symbols") -set(CURL_LDAP_WIN OFF CACHE INTERNAL "No curl Windows LDAP") set(CURL_STATICLIB ON CACHE INTERNAL "Static curl") -set(CURL_USE_ARES OFF CACHE INTERNAL "No curl c-ares support") set(DISABLED_THREADSAFE OFF CACHE INTERNAL "Curl can use thread-safe functions") -set(ENABLE_IPV6 OFF CACHE INTERNAL "Curl IPv6 support") +set(ENABLE_ARES OFF CACHE INTERNAL "No curl c-ares support") +set(ENABLE_CURLDEBUG OFF CACHE INTERNAL "No curl TrackMemory features") +set(ENABLE_DEBUG OFF CACHE INTERNAL "No curl debug features") +set(ENABLE_IPV6 OFF CACHE INTERNAL "No curl IPv6 support") +set(ENABLE_MANUAL OFF CACHE INTERNAL "No curl built-in manual") +set(ENABLE_THREADED_RESOLVER OFF CACHE INTERNAL "No curl POSIX threaded DNS lookup") +set(ENABLE_UNIX_SOCKETS OFF CACHE INTERNAL "No curl Unix domain sockets support") set(HTTP_ONLY OFF CACHE INTERNAL "Curl is not http-only") +set(USE_WIN32_LDAP OFF CACHE INTERNAL "No curl Windows LDAP") # Windows Vista and above have inet_pton, but this will link on # older versions and then the executable will fail to launch at http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=91e8d35ab8ec2d62478a42eff10af88713497fad commit 91e8d35ab8ec2d62478a42eff10af88713497fad Merge: 602cdc0 7065426 Author: Brad King AuthorDate: Wed Aug 12 15:43:52 2015 -0400 Commit: Brad King CommitDate: Wed Aug 12 15:43:52 2015 -0400 Merge branch 'curl-upstream' into update-curl Resolve conflicts by taking upstream side when possible and otherwise integrating the changes from both sides. Be carful in CMakeLists.txt where the OPENSSL code block that we modified previously has moved, and preserve our previous modifications in the new location. diff --cc Utilities/cmcurl/CMake/FindGSS.cmake index 0000000,dfaeaf3..dfaeaf3 mode 000000,100644..100644 --- a/Utilities/cmcurl/CMake/FindGSS.cmake +++ b/Utilities/cmcurl/CMake/FindGSS.cmake diff --cc Utilities/cmcurl/CMake/Platforms/WindowsCache.cmake index 0e26a17,0000000..53d0a5e mode 100644,000000..100644 --- a/Utilities/cmcurl/CMake/Platforms/WindowsCache.cmake +++ b/Utilities/cmcurl/CMake/Platforms/WindowsCache.cmake @@@ -1,122 -1,0 +1,122 @@@ +if(NOT UNIX) + if(WIN32) + set(HAVE_LIBDL 0) + set(HAVE_LIBUCB 0) + set(HAVE_LIBSOCKET 0) + set(NOT_NEED_LIBNSL 0) + set(HAVE_LIBNSL 0) ++ set(HAVE_GETHOSTNAME 1) + set(HAVE_LIBZ 0) + set(HAVE_LIBCRYPTO 0) + + set(HAVE_DLOPEN 0) + + set(HAVE_ALLOCA_H 0) + set(HAVE_ARPA_INET_H 0) + set(HAVE_DLFCN_H 0) + set(HAVE_FCNTL_H 1) - set(HAVE_FEATURES_H 0) + set(HAVE_INTTYPES_H 0) + set(HAVE_IO_H 1) + set(HAVE_MALLOC_H 1) + set(HAVE_MEMORY_H 1) + set(HAVE_NETDB_H 0) + set(HAVE_NETINET_IF_ETHER_H 0) + set(HAVE_NETINET_IN_H 0) + set(HAVE_NET_IF_H 0) + set(HAVE_PROCESS_H 1) + set(HAVE_PWD_H 0) + set(HAVE_SETJMP_H 1) + set(HAVE_SGTTY_H 0) + set(HAVE_SIGNAL_H 1) + set(HAVE_SOCKIO_H 0) + set(HAVE_STDINT_H 0) + set(HAVE_STDLIB_H 1) + set(HAVE_STRINGS_H 0) + set(HAVE_STRING_H 1) + set(HAVE_SYS_PARAM_H 0) + set(HAVE_SYS_POLL_H 0) + set(HAVE_SYS_SELECT_H 0) + set(HAVE_SYS_SOCKET_H 0) + set(HAVE_SYS_SOCKIO_H 0) + set(HAVE_SYS_STAT_H 1) + set(HAVE_SYS_TIME_H 0) + set(HAVE_SYS_TYPES_H 1) + set(HAVE_SYS_UTIME_H 1) + set(HAVE_TERMIOS_H 0) + set(HAVE_TERMIO_H 0) + set(HAVE_TIME_H 1) + set(HAVE_UNISTD_H 0) + set(HAVE_UTIME_H 0) + set(HAVE_X509_H 0) + set(HAVE_ZLIB_H 0) + + set(HAVE_SOCKET 1) + set(HAVE_POLL 0) + set(HAVE_SELECT 1) + set(HAVE_STRDUP 1) + set(HAVE_STRSTR 1) + set(HAVE_STRTOK_R 0) + set(HAVE_STRFTIME 1) + set(HAVE_UNAME 0) + set(HAVE_STRCASECMP 0) + set(HAVE_STRICMP 1) + set(HAVE_STRCMPI 1) + set(HAVE_GETHOSTBYADDR 1) + set(HAVE_GETTIMEOFDAY 0) + set(HAVE_INET_ADDR 1) + set(HAVE_INET_NTOA 1) + set(HAVE_INET_NTOA_R 0) + set(HAVE_TCGETATTR 0) + set(HAVE_TCSETATTR 0) + set(HAVE_PERROR 1) + set(HAVE_CLOSESOCKET 1) + set(HAVE_SETVBUF 0) + set(HAVE_SIGSETJMP 0) + set(HAVE_GETPASS_R 0) + set(HAVE_STRLCAT 0) + set(HAVE_GETPWUID 0) + set(HAVE_GETEUID 0) + set(HAVE_UTIME 1) + set(HAVE_RAND_EGD 0) + set(HAVE_RAND_SCREEN 0) + set(HAVE_RAND_STATUS 0) + set(HAVE_GMTIME_R 0) + set(HAVE_LOCALTIME_R 0) + set(HAVE_GETHOSTBYADDR_R 0) + set(HAVE_GETHOSTBYNAME_R 0) + set(HAVE_SIGNAL_FUNC 1) + set(HAVE_SIGNAL_MACRO 0) + + set(HAVE_GETHOSTBYADDR_R_5 0) + set(HAVE_GETHOSTBYADDR_R_5_REENTRANT 0) + set(HAVE_GETHOSTBYADDR_R_7 0) + set(HAVE_GETHOSTBYADDR_R_7_REENTRANT 0) + set(HAVE_GETHOSTBYADDR_R_8 0) + set(HAVE_GETHOSTBYADDR_R_8_REENTRANT 0) + set(HAVE_GETHOSTBYNAME_R_3 0) + set(HAVE_GETHOSTBYNAME_R_3_REENTRANT 0) + set(HAVE_GETHOSTBYNAME_R_5 0) + set(HAVE_GETHOSTBYNAME_R_5_REENTRANT 0) + set(HAVE_GETHOSTBYNAME_R_6 0) + set(HAVE_GETHOSTBYNAME_R_6_REENTRANT 0) + + set(TIME_WITH_SYS_TIME 0) + set(HAVE_O_NONBLOCK 0) + set(HAVE_IN_ADDR_T 0) + set(HAVE_INET_NTOA_R_DECL 0) + set(HAVE_INET_NTOA_R_DECL_REENTRANT 0) + if(ENABLE_IPV6) + set(HAVE_GETADDRINFO 1) + else() + set(HAVE_GETADDRINFO 0) + endif() + set(STDC_HEADERS 1) + set(RETSIGTYPE_TEST 1) + + set(HAVE_SIGACTION 0) + set(HAVE_MACRO_SIGSETJMP 0) + else(WIN32) + message("This file should be included on Windows platform only") + endif(WIN32) +endif(NOT UNIX) + diff --cc Utilities/cmcurl/CMakeLists.txt index 32e4561,0000000..6b01be9 mode 100644,000000..100644 --- a/Utilities/cmcurl/CMakeLists.txt +++ b/Utilities/cmcurl/CMakeLists.txt @@@ -1,1011 -1,0 +1,1246 @@@ +# Set curl options as needed for CMake build +set(BUILD_CURL_EXE OFF CACHE INTERNAL "No curl exe") +set(BUILD_CURL_TESTS OFF CACHE INTERNAL "No curl tests") +set(BUILD_DASHBOARD_REPORTS OFF CACHE INTERNAL "No curl dashboard reports") +set(BUILD_RELEASE_DEBUG_DIRS OFF CACHE INTERNAL "No curl release/debug dirs") +set(CMAKE_USE_LIBSSH2 OFF CACHE INTERNAL "Disable curl libssh2") +set(CMAKE_USE_OPENLDAP OFF CACHE INTERNAL "No curl OpenLDAP") +set(CURL_DISABLE_COOKIES OFF CACHE INTERNAL "Do not disable curl cookie support") +set(CURL_DISABLE_CRYPTO_AUTH OFF CACHE INTERNAL "Do not disable curl crypto auth") +set(CURL_DISABLE_DICT ON CACHE INTERNAL "Disable curl dict protocol?") +set(CURL_DISABLE_FILE OFF CACHE INTERNAL "Disable curl file protocol?") +set(CURL_DISABLE_FTP OFF CACHE INTERNAL "Disable curl ftp protocol?") +set(CURL_DISABLE_GOPHER ON CACHE INTERNAL "Disable curl gopher protocol?") +set(CURL_DISABLE_HTTP OFF CACHE INTERNAL "Disable curl http protocol?") +set(CURL_DISABLE_IMAP ON CACHE INTERNAL "Disable curl imap protocol?") +set(CURL_DISABLE_LDAP ON CACHE INTERNAL "Disable curl ldap protocol?") +set(CURL_DISABLE_LDAPS ON CACHE INTERNAL "Disable curl ldaps protocol?") +set(CURL_DISABLE_POP3 ON CACHE INTERNAL "Disable curl pop3 protocol?") +set(CURL_DISABLE_RTSP ON CACHE INTERNAL "Disable curl rtsp protocol?") +set(CURL_DISABLE_SMTP ON CACHE INTERNAL "Disable curl smtp protocol?") +set(CURL_DISABLE_TELNET ON CACHE INTERNAL "Disable curl telnet protocol?") +set(CURL_DISABLE_TFTP ON CACHE INTERNAL "Disable curl tftp protocol?") +set(CURL_DISABLE_VERBOSE_STRING OFF CACHE INTERNAL "Do not disable curl verbosity") +set(CURL_HIDDEN_SYMBOLS OFF CACHE INTERNAL "No curl hidden symbols") +set(CURL_LDAP_WIN OFF CACHE INTERNAL "No curl Windows LDAP") +set(CURL_STATICLIB ON CACHE INTERNAL "Static curl") +set(CURL_USE_ARES OFF CACHE INTERNAL "No curl c-ares support") +set(DISABLED_THREADSAFE OFF CACHE INTERNAL "Curl can use thread-safe functions") +set(ENABLE_IPV6 OFF CACHE INTERNAL "Curl IPv6 support") +set(HTTP_ONLY OFF CACHE INTERNAL "Curl is not http-only") + +# Windows Vista and above have inet_pton, but this will link on +# older versions and then the executable will fail to launch at +# runtime on older versions because no DLL provides the symbol. +if(WIN32) + set(HAVE_INET_PTON 0 CACHE INTERNAL "Do not use inet_pton") +endif() + +# Disable warnings to avoid changing 3rd party code. +if(CMAKE_C_COMPILER_ID MATCHES + "^(GNU|Clang|AppleClang|XL|VisualAge|SunPro|MIPSpro|HP|Intel)$") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w") +elseif(CMAKE_C_COMPILER_ID STREQUAL "PathScale") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -woffall") +endif() + +#*************************************************************************** +# _ _ ____ _ +# Project ___| | | | _ \| | +# / __| | | | |_) | | +# | (__| |_| | _ <| |___ +# \___|\___/|_| \_\_____| +# - # Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. ++# Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. +# +# This software is licensed as described in the file COPYING, which +# you should have received as part of this distribution. The terms +# are also available at http://curl.haxx.se/docs/copyright.html. +# +# You may opt to use, copy, modify, merge, publish, distribute and/or sell +# copies of the Software, and permit persons to whom the Software is +# furnished to do so, under the terms of the COPYING file. +# +# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY +# KIND, either express or implied. +# +########################################################################### +# cURL/libcurl CMake script +# by Tetetest and Sukender (Benoit Neil) + +# TODO: +# The output .so file lacks the soname number which we currently have within the lib/Makefile.am file +# Add full (4 or 5 libs) SSL support +# Add INSTALL target (EXTRA_DIST variables in Makefile.am may be moved to Makefile.inc so that CMake/CPack is aware of what's to include). +# Add CTests(?) +# Check on all possible platforms +# Test with as many configurations possible (With or without any option) +# Create scripts that help keeping the CMake build system up to date (to reduce maintenance). According to Tetetest: +# - lists of headers that 'configure' checks for; +# - curl-specific tests (the ones that are in m4/curl-*.m4 files); +# - (most obvious thing:) curl version numbers. +# Add documentation subproject +# +# To check: +# (From Daniel Stenberg) The cmake build selected to run gcc with -fPIC on my box while the plain configure script did not. +# (From Daniel Stenberg) The gcc command line use neither -g nor any -O options. As a developer, I also treasure our configure scripts's --enable-debug option that sets a long range of "picky" compiler options. +cmake_minimum_required(VERSION 2.8 FATAL_ERROR) +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake;${CMAKE_MODULE_PATH}") +include(Utilities) +include(Macros) + +project( CURL C ) + +if(0) # This code not needed for building within CMake. +message(WARNING "the curl cmake build system is poorly maintained. Be aware") +endif() + +file (READ ${CURL_SOURCE_DIR}/include/curl/curlver.h CURL_VERSION_H_CONTENTS) - string (REGEX MATCH "LIBCURL_VERSION_MAJOR[ \t]+([0-9]+)" - LIBCURL_VERSION_MJ ${CURL_VERSION_H_CONTENTS}) - string (REGEX MATCH "([0-9]+)" - LIBCURL_VERSION_MJ ${LIBCURL_VERSION_MJ}) - string (REGEX MATCH - "LIBCURL_VERSION_MINOR[ \t]+([0-9]+)" - LIBCURL_VERSION_MI ${CURL_VERSION_H_CONTENTS}) - string (REGEX MATCH "([0-9]+)" LIBCURL_VERSION_MI ${LIBCURL_VERSION_MI}) - string (REGEX MATCH - "LIBCURL_VERSION_PATCH[ \t]+([0-9]+)" - LIBCURL_VERSION_PT ${CURL_VERSION_H_CONTENTS}) - string (REGEX MATCH "([0-9]+)" LIBCURL_VERSION_PT ${LIBCURL_VERSION_PT}) - set (CURL_MAJOR_VERSION ${LIBCURL_VERSION_MJ}) - set (CURL_MINOR_VERSION ${LIBCURL_VERSION_MI}) - set (CURL_PATCH_VERSION ${LIBCURL_VERSION_PT}) ++string (REGEX MATCH "#define LIBCURL_VERSION \"[^\"]*" ++ CURL_VERSION ${CURL_VERSION_H_CONTENTS}) ++string (REGEX REPLACE "[^\"]+\"" "" CURL_VERSION ${CURL_VERSION}) ++string (REGEX MATCH "#define LIBCURL_VERSION_NUM 0x[0-9a-fA-F]+" ++ CURL_VERSION_NUM ${CURL_VERSION_H_CONTENTS}) ++string (REGEX REPLACE "[^0]+0x" "" CURL_VERSION_NUM ${CURL_VERSION_NUM}) + +include_regular_expression("^.*$") # Sukender: Is it necessary? + +# Setup package meta-data +# SET(PACKAGE "curl") - set(CURL_VERSION ${CURL_MAJOR_VERSION}.${CURL_MINOR_VERSION}.${CURL_PATCH_VERSION}) +if(0) # This code not needed for building within CMake. +message(STATUS "curl version=[${CURL_VERSION}]") +endif() +# SET(PACKAGE_TARNAME "curl") +# SET(PACKAGE_NAME "curl") +# SET(PACKAGE_VERSION "-") +# SET(PACKAGE_STRING "curl-") +# SET(PACKAGE_BUGREPORT "a suitable curl mailing list => http://curl.haxx.se/mail/") +set(OPERATING_SYSTEM "${CMAKE_SYSTEM_NAME}") +set(OS "\"${CMAKE_SYSTEM_NAME}\"") + +include_directories(${PROJECT_BINARY_DIR}/include/curl) +include_directories( ${CURL_SOURCE_DIR}/include ) + +option(BUILD_CURL_EXE "Set to ON to build cURL executable." ON) +option(BUILD_CURL_TESTS "Set to ON to build cURL tests." ON) +option(CURL_STATICLIB "Set to ON to build libcurl with static linking." OFF) - option(CURL_USE_ARES "Set to ON to enable c-ares support" OFF) ++option(ENABLE_ARES "Set to ON to enable c-ares support" OFF) ++option(ENABLE_THREADED_RESOLVER "Set to ON to enable POSIX threaded DNS lookup" OFF) ++ ++option(ENABLE_DEBUG "Set to ON to enable curl debug features" OFF) ++option(ENABLE_CURLDEBUG "Set to ON to build with TrackMemory feature enabled" OFF) ++ ++if (ENABLE_DEBUG) ++ # DEBUGBUILD will be defined only for Debug builds ++ if(NOT CMAKE_VERSION VERSION_LESS 3.0) ++ set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$:DEBUGBUILD>) ++ else() ++ set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG DEBUGBUILD) ++ endif() ++ set(ENABLE_CURLDEBUG ON) ++endif() ++ ++if (ENABLE_CURLDEBUG) ++ set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS CURLDEBUG) ++endif() ++ +# initialize CURL_LIBS +set(CURL_LIBS "") + - if(CURL_USE_ARES) - set(USE_ARES ${CURL_USE_ARES}) ++if(ENABLE_THREADED_RESOLVER AND ENABLE_ARES) ++ message(FATAL_ERROR "Options ENABLE_THREADED_RESOLVER and ENABLE_ARES are mutually exclusive") ++endif() ++ ++if(ENABLE_ARES) ++ set(USE_ARES 1) + find_package(CARES REQUIRED) + list(APPEND CURL_LIBS ${CARES_LIBRARY} ) + set(CURL_LIBS ${CURL_LIBS} ${CARES_LIBRARY}) +endif() + +option(BUILD_DASHBOARD_REPORTS "Set to ON to activate reporting of cURL builds here http://www.cdash.org/CDashPublic/index.php?project=CURL" OFF) +if(BUILD_DASHBOARD_REPORTS) + #INCLUDE(Dart) + include(CTest) +endif(BUILD_DASHBOARD_REPORTS) + +if(MSVC) + option(BUILD_RELEASE_DEBUG_DIRS "Set OFF to build each configuration to a separate directory" OFF) + mark_as_advanced(BUILD_RELEASE_DEBUG_DIRS) +endif() + +option(CURL_HIDDEN_SYMBOLS "Set to ON to hide libcurl internal symbols (=hide all symbols that aren't officially external)." ON) +mark_as_advanced(CURL_HIDDEN_SYMBOLS) + +# IF(WIN32) +# OPTION(CURL_WINDOWS_SSPI "Use windows libraries to allow NTLM authentication without openssl" ON) +# MARK_AS_ADVANCED(CURL_WINDOWS_SSPI) +# ENDIF() + +option(HTTP_ONLY "disables all protocols except HTTP (This overrides all CURL_DISABLE_* options)" OFF) +mark_as_advanced(HTTP_ONLY) +option(CURL_DISABLE_FTP "disables FTP" OFF) +mark_as_advanced(CURL_DISABLE_FTP) +option(CURL_DISABLE_LDAP "disables LDAP" OFF) +mark_as_advanced(CURL_DISABLE_LDAP) +option(CURL_DISABLE_TELNET "disables Telnet" OFF) +mark_as_advanced(CURL_DISABLE_TELNET) +option(CURL_DISABLE_DICT "disables DICT" OFF) +mark_as_advanced(CURL_DISABLE_DICT) +option(CURL_DISABLE_FILE "disables FILE" OFF) +mark_as_advanced(CURL_DISABLE_FILE) +option(CURL_DISABLE_TFTP "disables TFTP" OFF) +mark_as_advanced(CURL_DISABLE_TFTP) +option(CURL_DISABLE_HTTP "disables HTTP" OFF) +mark_as_advanced(CURL_DISABLE_HTTP) + +option(CURL_DISABLE_LDAPS "to disable LDAPS" OFF) +mark_as_advanced(CURL_DISABLE_LDAPS) + +option(CURL_DISABLE_RTSP "to disable RTSP" OFF) +mark_as_advanced(CURL_DISABLE_RTSP) +option(CURL_DISABLE_PROXY "to disable proxy" OFF) +mark_as_advanced(CURL_DISABLE_PROXY) +option(CURL_DISABLE_POP3 "to disable POP3" OFF) +mark_as_advanced(CURL_DISABLE_POP3) +option(CURL_DISABLE_IMAP "to disable IMAP" OFF) +mark_as_advanced(CURL_DISABLE_IMAP) +option(CURL_DISABLE_SMTP "to disable SMTP" OFF) +mark_as_advanced(CURL_DISABLE_SMTP) +option(CURL_DISABLE_GOPHER "to disable Gopher" OFF) +mark_as_advanced(CURL_DISABLE_GOPHER) + +if(HTTP_ONLY) + set(CURL_DISABLE_FTP ON) + set(CURL_DISABLE_LDAP ON) + set(CURL_DISABLE_LDAPS ON) + set(CURL_DISABLE_TELNET ON) + set(CURL_DISABLE_DICT ON) + set(CURL_DISABLE_FILE ON) + set(CURL_DISABLE_TFTP ON) + set(CURL_DISABLE_RTSP ON) + set(CURL_DISABLE_POP3 ON) + set(CURL_DISABLE_IMAP ON) + set(CURL_DISABLE_SMTP ON) + set(CURL_DISABLE_GOPHER ON) +endif() + +option(CURL_DISABLE_COOKIES "to disable cookies support" OFF) +mark_as_advanced(CURL_DISABLE_COOKIES) + +option(CURL_DISABLE_CRYPTO_AUTH "to disable cryptographic authentication" OFF) +mark_as_advanced(CURL_DISABLE_CRYPTO_AUTH) +option(CURL_DISABLE_VERBOSE_STRINGS "to disable verbose strings" OFF) +mark_as_advanced(CURL_DISABLE_VERBOSE_STRINGS) +option(DISABLED_THREADSAFE "Set to explicitly specify we don't want to use thread-safe functions" OFF) +mark_as_advanced(DISABLED_THREADSAFE) - option(ENABLE_IPV6 "Define if you want to enable IPv6 support" OFF) ++option(ENABLE_IPV6 "Define if you want to enable IPv6 support" ON) +mark_as_advanced(ENABLE_IPV6) ++if(ENABLE_IPV6) ++ include(CheckStructHasMember) ++ check_struct_has_member("struct sockaddr_in6" sin6_addr "netinet/in.h" ++ HAVE_SOCKADDR_IN6_SIN6_ADDR) ++ check_struct_has_member("struct sockaddr_in6" sin6_scope_id "netinet/in.h" ++ HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID) ++ if(NOT HAVE_SOCKADDR_IN6_SIN6_ADDR) ++ message(WARNING "struct sockaddr_in6 not available, disabling IPv6 support") ++ # Force the feature off as this name is used as guard macro... ++ set(ENABLE_IPV6 OFF ++ CACHE BOOL "Define if you want to enable IPv6 support" FORCE) ++ endif() ++endif() + ++option(ENABLE_MANUAL "to provide the built-in manual" ON) ++unset(USE_MANUAL CACHE) # TODO: cache NROFF/NROFF_MANOPT/USE_MANUAL vars? ++if(ENABLE_MANUAL) ++ find_program(NROFF NAMES gnroff nroff) ++ if(NROFF) ++ # Need a way to write to stdin, this will do ++ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/nroff-input.txt" "test") ++ # Tests for a valid nroff option to generate a manpage ++ foreach(_MANOPT "-man" "-mandoc") ++ execute_process(COMMAND "${NROFF}" ${_MANOPT} ++ OUTPUT_VARIABLE NROFF_MANOPT_OUTPUT ++ INPUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/nroff-input.txt" ++ ERROR_QUIET) ++ # Save the option if it was valid ++ if(NROFF_MANOPT_OUTPUT) ++ message("Found *nroff option: -- ${_MANOPT}") ++ set(NROFF_MANOPT ${_MANOPT}) ++ set(USE_MANUAL 1) ++ break() ++ endif() ++ endforeach() ++ # No need for the temporary file ++ file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/nroff-input.txt") ++ if(NOT USE_MANUAL) ++ message(WARNING "Found no *nroff option to get plaintext from man pages") ++ endif() ++ else() ++ message(WARNING "Found no *nroff program") ++ endif() ++endif() + +# We need ansi c-flags, especially on HP +set(CMAKE_C_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_C_FLAGS}") +set(CMAKE_REQUIRED_FLAGS ${CMAKE_ANSI_CFLAGS}) + +# Disable warnings on Borland to avoid changing 3rd party code. +if(BORLAND) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w-") +endif(BORLAND) + +# If we are on AIX, do the _ALL_SOURCE magic +if(${CMAKE_SYSTEM_NAME} MATCHES AIX) + set(_ALL_SOURCE 1) +endif(${CMAKE_SYSTEM_NAME} MATCHES AIX) + +# Include all the necessary files for macros +include (CheckFunctionExists) +include (CheckIncludeFile) +include (CheckIncludeFiles) +include (CheckLibraryExists) +include (CheckSymbolExists) +include (CheckTypeSize) +include (CheckCSourceCompiles) + +# On windows preload settings +if(WIN32) ++ set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_WINSOCKAPI_") + include(${CMAKE_CURRENT_SOURCE_DIR}/CMake/Platforms/WindowsCache.cmake) +endif(WIN32) + ++if(ENABLE_THREADED_RESOLVER) ++ check_include_file_concat("pthread.h" HAVE_PTHREAD_H) ++ if(HAVE_PTHREAD_H) ++ set(CMAKE_THREAD_PREFER_PTHREAD 1) ++ find_package(Threads) ++ if(CMAKE_USE_PTHREADS_INIT) ++ set(CURL_LIBS ${CURL_LIBS} ${CMAKE_THREAD_LIBS_INIT}) ++ set(USE_THREADS_POSIX 1) ++ endif() ++ endif() ++endif() ++ +# Check for all needed libraries +if(0) # This code not needed for building within CMake. +check_library_exists_concat("dl" dlopen HAVE_LIBDL) +else() + # Use the cmake-defined dl libs as dl is should not be used + # on HPUX, but rather dld this avoids a warning + list(APPEND CURL_LIBS ${CMAKE_DL_LIBS}) +endif() +check_library_exists_concat("socket" connect HAVE_LIBSOCKET) +check_library_exists("c" gethostbyname "" NOT_NEED_LIBNSL) + +# Yellowtab Zeta needs different libraries than BeOS 5. +if(BEOS) + set(NOT_NEED_LIBNSL 1) + check_library_exists_concat("bind" gethostbyname HAVE_LIBBIND) + check_library_exists_concat("bnetapi" closesocket HAVE_LIBBNETAPI) +endif(BEOS) + +check_library_exists_concat("network" recv HAVE_LIBNETWORK) + +if(NOT NOT_NEED_LIBNSL) + check_library_exists_concat("nsl" gethostbyname HAVE_LIBNSL) +endif(NOT NOT_NEED_LIBNSL) + ++check_function_exists(gethostname HAVE_GETHOSTNAME) ++ +if(WIN32) + check_library_exists_concat("ws2_32" getch HAVE_LIBWS2_32) + check_library_exists_concat("winmm" getch HAVE_LIBWINMM) +endif() + ++set(USE_OPENSSL OFF) ++set(HAVE_LIBCRYPTO OFF) ++set(HAVE_LIBSSL OFF) ++ ++if(CMAKE_USE_OPENSSL) ++ find_package(OpenSSL) ++ if(OPENSSL_FOUND) ++ list(APPEND CURL_LIBS ${OPENSSL_LIBRARIES}) ++ set(USE_OPENSSL ON) ++ set(HAVE_LIBCRYPTO ON) ++ set(HAVE_LIBSSL ON) ++ include_directories(${OPENSSL_INCLUDE_DIR}) ++ set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) ++ check_include_file("openssl/crypto.h" HAVE_OPENSSL_CRYPTO_H) ++ check_include_file("openssl/engine.h" HAVE_OPENSSL_ENGINE_H) ++ check_include_file("openssl/err.h" HAVE_OPENSSL_ERR_H) ++ check_include_file("openssl/pem.h" HAVE_OPENSSL_PEM_H) ++ check_include_file("openssl/pkcs12.h" HAVE_OPENSSL_PKCS12_H) ++ check_include_file("openssl/rsa.h" HAVE_OPENSSL_RSA_H) ++ check_include_file("openssl/ssl.h" HAVE_OPENSSL_SSL_H) ++ check_include_file("openssl/x509.h" HAVE_OPENSSL_X509_H) ++ check_include_file("openssl/rand.h" HAVE_OPENSSL_RAND_H) ++ ++ # Optionally build with a specific CA cert bundle. ++ if(CURL_CA_BUNDLE) ++ add_definitions(-DCURL_CA_BUNDLE="${CURL_CA_BUNDLE}") ++ endif() ++ # Optionally build with a specific CA cert dir. ++ if(CURL_CA_PATH) ++ add_definitions(-DCURL_CA_PATH="${CURL_CA_PATH}") ++ endif() ++ endif() ++elseif(WIN32) ++ # Use Windows SSL/TLS native implementation. ++ add_definitions(-DUSE_SCHANNEL) ++ set(USE_WINDOWS_SSPI 1) ++elseif(APPLE) ++ # Use OS X SSL/TLS native implementation if available on target version. ++ if(CMAKE_OSX_DEPLOYMENT_TARGET) ++ set(OSX_VERSION ${CMAKE_OSX_DEPLOYMENT_TARGET}) ++ else() ++ execute_process( ++ COMMAND sw_vers -productVersion ++ OUTPUT_VARIABLE OSX_VERSION ++ OUTPUT_STRIP_TRAILING_WHITESPACE ++ ) ++ endif() ++ if(NOT OSX_VERSION VERSION_LESS 10.6 AND ++ CMAKE_C_COMPILER_ID MATCHES "GNU|Clang|AppleClang") ++ add_definitions(-DUSE_DARWINSSL) ++ list(APPEND CURL_LIBS ++ "-framework CoreFoundation" ++ "-framework Security" ++ ) ++ endif() ++endif() ++ +if(NOT CURL_DISABLE_LDAP) + + if(WIN32) - option(CURL_LDAP_WIN "Use Windows LDAP implementation" ON) - if(CURL_LDAP_WIN) ++ option(USE_WIN32_LDAP "Use Windows LDAP implementation" ON) ++ if(USE_WIN32_LDAP) + check_library_exists("wldap32" cldap_open "" HAVE_WLDAP32) + if(NOT HAVE_WLDAP32) - set(CURL_LDAP_WIN OFF) ++ set(USE_WIN32_LDAP OFF) + endif() + endif() + endif() + + option(CMAKE_USE_OPENLDAP "Use OpenLDAP code." OFF) + mark_as_advanced(CMAKE_USE_OPENLDAP) + set(CMAKE_LDAP_LIB "ldap" CACHE STRING "Name or full path to ldap library") + set(CMAKE_LBER_LIB "lber" CACHE STRING "Name or full path to lber library") + - if(CMAKE_USE_OPENLDAP AND CURL_LDAP_WIN) - message(FATAL_ERROR "Cannot use CURL_LDAP_WIN and CMAKE_USE_OPENLDAP at the same time") ++ if(CMAKE_USE_OPENLDAP AND USE_WIN32_LDAP) ++ message(FATAL_ERROR "Cannot use USE_WIN32_LDAP and CMAKE_USE_OPENLDAP at the same time") + endif() + + # Now that we know, we're not using windows LDAP... - if(NOT CURL_LDAP_WIN) ++ if(NOT USE_WIN32_LDAP) + # Check for LDAP ++ set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_LIBRARIES}) + check_library_exists_concat(${CMAKE_LDAP_LIB} ldap_init HAVE_LIBLDAP) + check_library_exists_concat(${CMAKE_LBER_LIB} ber_init HAVE_LIBLBER) + else() + check_include_file_concat("winldap.h" HAVE_WINLDAP_H) + check_include_file_concat("winber.h" HAVE_WINBER_H) + endif() + + set(CMAKE_LDAP_INCLUDE_DIR "" CACHE STRING "Path to LDAP include directory") + if(CMAKE_LDAP_INCLUDE_DIR) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_LDAP_INCLUDE_DIR}) + endif() + check_include_file_concat("ldap.h" HAVE_LDAP_H) + check_include_file_concat("lber.h" HAVE_LBER_H) + + if(NOT HAVE_LDAP_H) + message(STATUS "LDAP_H not found CURL_DISABLE_LDAP set ON") + set(CURL_DISABLE_LDAP ON CACHE BOOL "" FORCE) + elseif(NOT HAVE_LIBLDAP) + message(STATUS "LDAP library '${CMAKE_LDAP_LIB}' not found CURL_DISABLE_LDAP set ON") + set(CURL_DISABLE_LDAP ON CACHE BOOL "" FORCE) + else() + if(CMAKE_USE_OPENLDAP) + set(USE_OPENLDAP ON) + endif() + if(CMAKE_LDAP_INCLUDE_DIR) + include_directories(${CMAKE_LDAP_INCLUDE_DIR}) + endif() + set(NEED_LBER_H ON) + set(_HEADER_LIST) + if(HAVE_WINDOWS_H) + list(APPEND _HEADER_LIST "windows.h") + endif() + if(HAVE_SYS_TYPES_H) + list(APPEND _HEADER_LIST "sys/types.h") + endif() + list(APPEND _HEADER_LIST "ldap.h") + + set(_SRC_STRING "") + foreach(_HEADER ${_HEADER_LIST}) + set(_INCLUDE_STRING "${_INCLUDE_STRING}#include <${_HEADER}>\n") + endforeach() + + set(_SRC_STRING + " + ${_INCLUDE_STRING} + int main(int argc, char ** argv) + { + BerValue *bvp = NULL; + BerElement *bep = ber_init(bvp); + ber_free(bep, 1); + return 0; + }" + ) - set(CMAKE_REQUIRED_DEFINITIONS "-DLDAP_DEPRECATED=1" "-DWIN32_LEAN_AND_MEAN") - set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_LDAP_LIB}) ++ set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -DLDAP_DEPRECATED=1") ++ list(APPEND CMAKE_REQUIRED_LIBRARIES ${CMAKE_LDAP_LIB}) + if(HAVE_LIBLBER) + list(APPEND CMAKE_REQUIRED_LIBRARIES ${CMAKE_LBER_LIB}) + endif() + check_c_source_compiles("${_SRC_STRING}" NOT_NEED_LBER_H) + + if(NOT_NEED_LBER_H) + set(NEED_LBER_H OFF) + else() + set(CURL_TEST_DEFINES "${CURL_TEST_DEFINES} -DNEED_LBER_H") + endif() + endif() + +endif() + +# No ldap, no ldaps. +if(CURL_DISABLE_LDAP) + if(NOT CURL_DISABLE_LDAPS) + message(STATUS "LDAP needs to be enabled to support LDAPS") + set(CURL_DISABLE_LDAPS ON CACHE BOOL "" FORCE) + endif() +endif() + +if(NOT CURL_DISABLE_LDAPS) + check_include_file_concat("ldap_ssl.h" HAVE_LDAP_SSL_H) + check_include_file_concat("ldapssl.h" HAVE_LDAPSSL_H) +endif() + +# Check for idn +check_library_exists_concat("idn" idna_to_ascii_lz HAVE_LIBIDN) + +# Check for symbol dlopen (same as HAVE_LIBDL) +check_library_exists("${CURL_LIBS}" dlopen "" HAVE_DLOPEN) + - # For other tests to use the same libraries - set(CMAKE_REQUIRED_LIBRARIES ${CURL_LIBS}) - +if(0) # This code not needed for building within CMake. +option(CURL_ZLIB "Set to ON to enable building cURL with zlib support." ON) +set(HAVE_LIBZ OFF) +set(HAVE_ZLIB_H OFF) +set(HAVE_ZLIB OFF) +if(CURL_ZLIB) + find_package(ZLIB QUIET) + if(ZLIB_FOUND) + set(HAVE_ZLIB_H ON) + set(HAVE_ZLIB ON) + set(HAVE_LIBZ ON) + list(APPEND CURL_LIBS ${ZLIB_LIBRARIES}) ++ include_directories(${ZLIB_INCLUDE_DIRS}) + endif() +endif() +endif() + +#----------------------------------------------------------------------------- +# CMake-specific curl code. + +if(CURL_SPECIAL_LIBZ) + set(CURL_LIBS ${CURL_LIBS} "${CURL_SPECIAL_LIBZ}") + include_directories(${CURL_SPECIAL_LIBZ_INCLUDES}) + set(HAVE_LIBZ 0) + set(HAVE_ZLIB_H 0) +endif() + - #----------------------------------------------------------------------------- - - set(USE_SSLEAY OFF) - set(USE_OPENSSL OFF) - set(HAVE_LIBCRYPTO OFF) - set(HAVE_LIBSSL OFF) - - if(CMAKE_USE_OPENSSL) - find_package(OpenSSL) - if(OPENSSL_FOUND) - list(APPEND CURL_LIBS ${OPENSSL_LIBRARIES}) - set(USE_SSLEAY ON) - set(USE_OPENSSL ON) - set(HAVE_LIBCRYPTO ON) - set(HAVE_LIBSSL ON) - include_directories(${OPENSSL_INCLUDE_DIR}) - set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) - check_include_file("openssl/crypto.h" HAVE_OPENSSL_CRYPTO_H) - check_include_file("openssl/engine.h" HAVE_OPENSSL_ENGINE_H) - check_include_file("openssl/err.h" HAVE_OPENSSL_ERR_H) - check_include_file("openssl/pem.h" HAVE_OPENSSL_PEM_H) - check_include_file("openssl/pkcs12.h" HAVE_OPENSSL_PKCS12_H) - check_include_file("openssl/rsa.h" HAVE_OPENSSL_RSA_H) - check_include_file("openssl/ssl.h" HAVE_OPENSSL_SSL_H) - check_include_file("openssl/x509.h" HAVE_OPENSSL_X509_H) - check_include_file("openssl/rand.h" HAVE_OPENSSL_RAND_H) - - # Optionally build with a specific CA cert bundle. - if(CURL_CA_BUNDLE) - add_definitions(-DCURL_CA_BUNDLE="${CURL_CA_BUNDLE}") - endif() - # Optionally build with a specific CA cert dir. - if(CURL_CA_PATH) - add_definitions(-DCURL_CA_PATH="${CURL_CA_PATH}") - endif() - endif(OPENSSL_FOUND) - elseif(WIN32) - # Use Windows SSL/TLS native implementation. - add_definitions(-DUSE_SCHANNEL) - set(USE_WINDOWS_SSPI 1) - elseif(APPLE) - # Use OS X SSL/TLS native implementation if available on target version. - if(CMAKE_OSX_DEPLOYMENT_TARGET) - set(OSX_VERSION ${CMAKE_OSX_DEPLOYMENT_TARGET}) - else() - execute_process( - COMMAND sw_vers -productVersion - OUTPUT_VARIABLE OSX_VERSION - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - endif() - if(NOT OSX_VERSION VERSION_LESS 10.6 AND - CMAKE_C_COMPILER_ID MATCHES "GNU|Clang|AppleClang") - add_definitions(-DUSE_DARWINSSL) - list(APPEND CURL_LIBS - "-framework CoreFoundation" - "-framework Security" - ) - endif() - endif() - +#libSSH2 +option(CMAKE_USE_LIBSSH2 "Use libSSH2" ON) +mark_as_advanced(CMAKE_USE_LIBSSH2) +set(USE_LIBSSH2 OFF) +set(HAVE_LIBSSH2 OFF) +set(HAVE_LIBSSH2_H OFF) + +if(CMAKE_USE_LIBSSH2) + find_package(LibSSH2) + if(LIBSSH2_FOUND) + list(APPEND CURL_LIBS ${LIBSSH2_LIBRARY}) + set(CMAKE_REQUIRED_LIBRARIES ${LIBSSH2_LIBRARY}) + set(CMAKE_REQUIRED_INCLUDES "${LIBSSH2_INCLUDE_DIR}") ++ include_directories("${LIBSSH2_INCLUDE_DIR}") + set(HAVE_LIBSSH2 ON) + set(USE_LIBSSH2 ON) + + # find_package has already found the headers + set(HAVE_LIBSSH2_H ON) + set(CURL_INCLUDES ${CURL_INCLUDES} "${LIBSSH2_INCLUDE_DIR}/libssh2.h") + set(CURL_TEST_DEFINES "${CURL_TEST_DEFINES} -DHAVE_LIBSSH2_H") + + # now check for specific libssh2 symbols as they were added in different versions + set(CMAKE_EXTRA_INCLUDE_FILES "libssh2.h") + check_function_exists(libssh2_version HAVE_LIBSSH2_VERSION) + check_function_exists(libssh2_init HAVE_LIBSSH2_INIT) + check_function_exists(libssh2_exit HAVE_LIBSSH2_EXIT) + check_function_exists(libssh2_scp_send64 HAVE_LIBSSH2_SCP_SEND64) + check_function_exists(libssh2_session_handshake HAVE_LIBSSH2_SESSION_HANDSHAKE) + set(CMAKE_EXTRA_INCLUDE_FILES "") + + endif(LIBSSH2_FOUND) +endif(CMAKE_USE_LIBSSH2) + - # If we have features.h, then do the _BSD_SOURCE magic - check_include_file("features.h" HAVE_FEATURES_H) ++option(CMAKE_USE_GSSAPI "Use GSSAPI implementation (right now only Heimdal is supported with CMake build)" OFF) ++mark_as_advanced(CMAKE_USE_GSSAPI) + - # Check for header files - if(NOT UNIX) - check_include_file_concat("ws2tcpip.h" HAVE_WS2TCPIP_H) - check_include_file_concat("winsock2.h" HAVE_WINSOCK2_H) ++if(CMAKE_USE_GSSAPI) ++ find_package(GSS) ++ ++ set(HAVE_GSSAPI ${GSS_FOUND}) ++ if(GSS_FOUND) ++ ++ message(STATUS "Found ${GSS_FLAVOUR} GSSAPI version: \"${GSS_VERSION}\"") ++ ++ set(CMAKE_REQUIRED_INCLUDES ${GSS_INCLUDE_DIR}) ++ check_include_file_concat("gssapi/gssapi.h" HAVE_GSSAPI_GSSAPI_H) ++ check_include_file_concat("gssapi/gssapi_generic.h" HAVE_GSSAPI_GSSAPI_GENERIC_H) ++ check_include_file_concat("gssapi/gssapi_krb5.h" HAVE_GSSAPI_GSSAPI_KRB5_H) ++ ++ if(GSS_FLAVOUR STREQUAL "Heimdal") ++ set(HAVE_GSSHEIMDAL ON) ++ else() # MIT ++ set(HAVE_GSSMIT ON) ++ set(_INCLUDE_LIST "") ++ if(HAVE_GSSAPI_GSSAPI_H) ++ list(APPEND _INCLUDE_LIST "gssapi/gssapi.h") ++ endif() ++ if(HAVE_GSSAPI_GSSAPI_GENERIC_H) ++ list(APPEND _INCLUDE_LIST "gssapi/gssapi_generic.h") ++ endif() ++ if(HAVE_GSSAPI_GSSAPI_KRB5_H) ++ list(APPEND _INCLUDE_LIST "gssapi/gssapi_krb5.h") ++ endif() ++ ++ string(REPLACE ";" " " _COMPILER_FLAGS_STR "${GSS_COMPILER_FLAGS}") ++ string(REPLACE ";" " " _LINKER_FLAGS_STR "${GSS_LINKER_FLAGS}") ++ ++ foreach(_dir ${GSS_LINK_DIRECTORIES}) ++ set(_LINKER_FLAGS_STR "${_LINKER_FLAGS_STR} -L\"${_dir}\"") ++ endforeach() ++ ++ set(CMAKE_REQUIRED_FLAGS "${_COMPILER_FLAGS_STR} ${_LINKER_FLAGS_STR}") ++ set(CMAKE_REQUIRED_LIBRARIES ${GSS_LIBRARIES}) ++ check_symbol_exists("GSS_C_NT_HOSTBASED_SERVICE" ${_INCLUDE_LIST} HAVE_GSS_C_NT_HOSTBASED_SERVICE) ++ if(NOT HAVE_GSS_C_NT_HOSTBASED_SERVICE) ++ set(HAVE_OLD_GSSMIT ON) ++ endif() ++ ++ endif() ++ ++ include_directories(${GSS_INCLUDE_DIR}) ++ link_directories(${GSS_LINK_DIRECTORIES}) ++ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GSS_COMPILER_FLAGS}") ++ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${GSS_LINKER_FLAGS}") ++ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GSS_LINKER_FLAGS}") ++ list(APPEND CURL_LIBS ${GSS_LIBRARIES}) ++ ++ else() ++ message(WARNING "GSSAPI support has been requested but no supporting libraries found. Skipping.") ++ endif() ++endif() ++ ++option(ENABLE_UNIX_SOCKETS "Define if you want Unix domain sockets support" ON) ++if(ENABLE_UNIX_SOCKETS) ++ include(CheckStructHasMember) ++ check_struct_has_member("struct sockaddr_un" sun_path "sys/un.h" USE_UNIX_SOCKETS) +else() - set(HAVE_WS2TCPIP_H 0) - set(HAVE_WINSOCK2_H 0) ++ unset(USE_UNIX_SOCKETS CACHE) +endif() - check_include_file_concat("stdio.h" HAVE_STDIO_H) ++ ++# Check for header files +if(NOT UNIX) + check_include_file_concat("windows.h" HAVE_WINDOWS_H) + check_include_file_concat("winsock.h" HAVE_WINSOCK_H) ++ check_include_file_concat("ws2tcpip.h" HAVE_WS2TCPIP_H) ++ check_include_file_concat("winsock2.h" HAVE_WINSOCK2_H) +else() + set(HAVE_WINDOWS_H 0) + set(HAVE_WINSOCK_H 0) ++ set(HAVE_WS2TCPIP_H 0) ++ set(HAVE_WINSOCK2_H 0) +endif() + ++check_include_file_concat("stdio.h" HAVE_STDIO_H) +check_include_file_concat("inttypes.h" HAVE_INTTYPES_H) +check_include_file_concat("sys/filio.h" HAVE_SYS_FILIO_H) +check_include_file_concat("sys/ioctl.h" HAVE_SYS_IOCTL_H) +check_include_file_concat("sys/param.h" HAVE_SYS_PARAM_H) +check_include_file_concat("sys/poll.h" HAVE_SYS_POLL_H) +check_include_file_concat("sys/resource.h" HAVE_SYS_RESOURCE_H) +check_include_file_concat("sys/select.h" HAVE_SYS_SELECT_H) +check_include_file_concat("sys/socket.h" HAVE_SYS_SOCKET_H) +check_include_file_concat("sys/sockio.h" HAVE_SYS_SOCKIO_H) +check_include_file_concat("sys/stat.h" HAVE_SYS_STAT_H) +check_include_file_concat("sys/time.h" HAVE_SYS_TIME_H) +check_include_file_concat("sys/types.h" HAVE_SYS_TYPES_H) +check_include_file_concat("sys/uio.h" HAVE_SYS_UIO_H) +check_include_file_concat("sys/un.h" HAVE_SYS_UN_H) +check_include_file_concat("sys/utime.h" HAVE_SYS_UTIME_H) +check_include_file_concat("alloca.h" HAVE_ALLOCA_H) +check_include_file_concat("arpa/inet.h" HAVE_ARPA_INET_H) +check_include_file_concat("arpa/tftp.h" HAVE_ARPA_TFTP_H) +check_include_file_concat("assert.h" HAVE_ASSERT_H) +check_include_file_concat("crypto.h" HAVE_CRYPTO_H) +check_include_file_concat("des.h" HAVE_DES_H) +check_include_file_concat("err.h" HAVE_ERR_H) +check_include_file_concat("errno.h" HAVE_ERRNO_H) +check_include_file_concat("fcntl.h" HAVE_FCNTL_H) - check_include_file_concat("gssapi/gssapi.h" HAVE_GSSAPI_GSSAPI_H) - check_include_file_concat("gssapi/gssapi_generic.h" HAVE_GSSAPI_GSSAPI_GENERIC_H) - check_include_file_concat("gssapi/gssapi_krb5.h" HAVE_GSSAPI_GSSAPI_KRB5_H) +check_include_file_concat("idn-free.h" HAVE_IDN_FREE_H) +check_include_file_concat("ifaddrs.h" HAVE_IFADDRS_H) +check_include_file_concat("io.h" HAVE_IO_H) +check_include_file_concat("krb.h" HAVE_KRB_H) +check_include_file_concat("libgen.h" HAVE_LIBGEN_H) +check_include_file_concat("limits.h" HAVE_LIMITS_H) +check_include_file_concat("locale.h" HAVE_LOCALE_H) +check_include_file_concat("net/if.h" HAVE_NET_IF_H) +check_include_file_concat("netdb.h" HAVE_NETDB_H) +check_include_file_concat("netinet/in.h" HAVE_NETINET_IN_H) +check_include_file_concat("netinet/tcp.h" HAVE_NETINET_TCP_H) + +check_include_file_concat("pem.h" HAVE_PEM_H) +check_include_file_concat("poll.h" HAVE_POLL_H) +check_include_file_concat("pwd.h" HAVE_PWD_H) +check_include_file_concat("rsa.h" HAVE_RSA_H) +check_include_file_concat("setjmp.h" HAVE_SETJMP_H) +check_include_file_concat("sgtty.h" HAVE_SGTTY_H) +check_include_file_concat("signal.h" HAVE_SIGNAL_H) +check_include_file_concat("ssl.h" HAVE_SSL_H) +check_include_file_concat("stdbool.h" HAVE_STDBOOL_H) +check_include_file_concat("stdint.h" HAVE_STDINT_H) +check_include_file_concat("stdio.h" HAVE_STDIO_H) +check_include_file_concat("stdlib.h" HAVE_STDLIB_H) +check_include_file_concat("string.h" HAVE_STRING_H) +check_include_file_concat("strings.h" HAVE_STRINGS_H) +check_include_file_concat("stropts.h" HAVE_STROPTS_H) +check_include_file_concat("termio.h" HAVE_TERMIO_H) +check_include_file_concat("termios.h" HAVE_TERMIOS_H) +check_include_file_concat("time.h" HAVE_TIME_H) +check_include_file_concat("tld.h" HAVE_TLD_H) +check_include_file_concat("unistd.h" HAVE_UNISTD_H) +check_include_file_concat("utime.h" HAVE_UTIME_H) +check_include_file_concat("x509.h" HAVE_X509_H) + +check_include_file_concat("process.h" HAVE_PROCESS_H) +check_include_file_concat("stddef.h" HAVE_STDDEF_H) +check_include_file_concat("dlfcn.h" HAVE_DLFCN_H) +check_include_file_concat("malloc.h" HAVE_MALLOC_H) +check_include_file_concat("memory.h" HAVE_MEMORY_H) +check_include_file_concat("netinet/if_ether.h" HAVE_NETINET_IF_ETHER_H) +check_include_file_concat("stdint.h" HAVE_STDINT_H) +check_include_file_concat("sockio.h" HAVE_SOCKIO_H) +check_include_file_concat("sys/utsname.h" HAVE_SYS_UTSNAME_H) +check_include_file_concat("idna.h" HAVE_IDNA_H) + + + +check_type_size(size_t SIZEOF_SIZE_T) +check_type_size(ssize_t SIZEOF_SSIZE_T) +check_type_size("long long" SIZEOF_LONG_LONG) +check_type_size("long" SIZEOF_LONG) +check_type_size("short" SIZEOF_SHORT) +check_type_size("int" SIZEOF_INT) +check_type_size("__int64" SIZEOF___INT64) +check_type_size("time_t" SIZEOF_TIME_T) +check_type_size("off_t" SIZEOF_OFF_T) + +# Make public versions of some type sizes for curlbuild.h. +foreach(t INT LONG LONG_LONG SSIZE_T) + string(REPLACE "SIZEOF_" "CURL_SIZEOF_" CURL_SIZEOF_${t}_CODE "${SIZEOF_${t}_CODE}") +endforeach() + +if(HAVE_SIZEOF_LONG_LONG) + set(HAVE_LONGLONG 1) + set(HAVE_LL 1) +endif(HAVE_SIZEOF_LONG_LONG) + +find_file(RANDOM_FILE urandom /dev) +mark_as_advanced(RANDOM_FILE) + +# Check for some functions that are used ++if(HAVE_LIBWS2_32) ++ set(CMAKE_REQUIRED_LIBRARIES ws2_32) ++elseif(HAVE_LIBSOCKET) ++ set(CMAKE_REQUIRED_LIBRARIES socket) ++endif() ++ +check_symbol_exists(basename "${CURL_INCLUDES}" HAVE_BASENAME) +check_symbol_exists(socket "${CURL_INCLUDES}" HAVE_SOCKET) +check_symbol_exists(poll "${CURL_INCLUDES}" HAVE_POLL) +check_symbol_exists(select "${CURL_INCLUDES}" HAVE_SELECT) +check_symbol_exists(strdup "${CURL_INCLUDES}" HAVE_STRDUP) +check_symbol_exists(strstr "${CURL_INCLUDES}" HAVE_STRSTR) +check_symbol_exists(strtok_r "${CURL_INCLUDES}" HAVE_STRTOK_R) +check_symbol_exists(strftime "${CURL_INCLUDES}" HAVE_STRFTIME) +check_symbol_exists(uname "${CURL_INCLUDES}" HAVE_UNAME) +check_symbol_exists(strcasecmp "${CURL_INCLUDES}" HAVE_STRCASECMP) +check_symbol_exists(stricmp "${CURL_INCLUDES}" HAVE_STRICMP) +check_symbol_exists(strcmpi "${CURL_INCLUDES}" HAVE_STRCMPI) +check_symbol_exists(strncmpi "${CURL_INCLUDES}" HAVE_STRNCMPI) +check_symbol_exists(alarm "${CURL_INCLUDES}" HAVE_ALARM) +if(NOT HAVE_STRNCMPI) + set(HAVE_STRCMPI) +endif(NOT HAVE_STRNCMPI) +check_symbol_exists(gethostbyaddr "${CURL_INCLUDES}" HAVE_GETHOSTBYADDR) +check_symbol_exists(gethostbyaddr_r "${CURL_INCLUDES}" HAVE_GETHOSTBYADDR_R) +check_symbol_exists(gettimeofday "${CURL_INCLUDES}" HAVE_GETTIMEOFDAY) +check_symbol_exists(inet_addr "${CURL_INCLUDES}" HAVE_INET_ADDR) +check_symbol_exists(inet_ntoa "${CURL_INCLUDES}" HAVE_INET_NTOA) +check_symbol_exists(inet_ntoa_r "${CURL_INCLUDES}" HAVE_INET_NTOA_R) +check_symbol_exists(tcsetattr "${CURL_INCLUDES}" HAVE_TCSETATTR) +check_symbol_exists(tcgetattr "${CURL_INCLUDES}" HAVE_TCGETATTR) +check_symbol_exists(perror "${CURL_INCLUDES}" HAVE_PERROR) +check_symbol_exists(closesocket "${CURL_INCLUDES}" HAVE_CLOSESOCKET) +check_symbol_exists(setvbuf "${CURL_INCLUDES}" HAVE_SETVBUF) +check_symbol_exists(sigsetjmp "${CURL_INCLUDES}" HAVE_SIGSETJMP) +check_symbol_exists(getpass_r "${CURL_INCLUDES}" HAVE_GETPASS_R) +check_symbol_exists(strlcat "${CURL_INCLUDES}" HAVE_STRLCAT) +check_symbol_exists(getpwuid "${CURL_INCLUDES}" HAVE_GETPWUID) +check_symbol_exists(geteuid "${CURL_INCLUDES}" HAVE_GETEUID) +check_symbol_exists(utime "${CURL_INCLUDES}" HAVE_UTIME) +if(CMAKE_USE_OPENSSL) + check_symbol_exists(RAND_status "${CURL_INCLUDES}" HAVE_RAND_STATUS) + check_symbol_exists(RAND_screen "${CURL_INCLUDES}" HAVE_RAND_SCREEN) + check_symbol_exists(RAND_egd "${CURL_INCLUDES}" HAVE_RAND_EGD) + check_symbol_exists(CRYPTO_cleanup_all_ex_data "${CURL_INCLUDES}" + HAVE_CRYPTO_CLEANUP_ALL_EX_DATA) + if(HAVE_LIBCRYPTO AND HAVE_LIBSSL) + set(USE_OPENSSL 1) - set(USE_SSLEAY 1) + endif(HAVE_LIBCRYPTO AND HAVE_LIBSSL) +endif(CMAKE_USE_OPENSSL) +check_symbol_exists(gmtime_r "${CURL_INCLUDES}" HAVE_GMTIME_R) +check_symbol_exists(localtime_r "${CURL_INCLUDES}" HAVE_LOCALTIME_R) + +check_symbol_exists(gethostbyname "${CURL_INCLUDES}" HAVE_GETHOSTBYNAME) +check_symbol_exists(gethostbyname_r "${CURL_INCLUDES}" HAVE_GETHOSTBYNAME_R) + +check_symbol_exists(signal "${CURL_INCLUDES}" HAVE_SIGNAL_FUNC) +check_symbol_exists(SIGALRM "${CURL_INCLUDES}" HAVE_SIGNAL_MACRO) +if(HAVE_SIGNAL_FUNC AND HAVE_SIGNAL_MACRO) + set(HAVE_SIGNAL 1) +endif(HAVE_SIGNAL_FUNC AND HAVE_SIGNAL_MACRO) +check_symbol_exists(uname "${CURL_INCLUDES}" HAVE_UNAME) +check_symbol_exists(strtoll "${CURL_INCLUDES}" HAVE_STRTOLL) +check_symbol_exists(_strtoi64 "${CURL_INCLUDES}" HAVE__STRTOI64) +check_symbol_exists(strerror_r "${CURL_INCLUDES}" HAVE_STRERROR_R) +check_symbol_exists(siginterrupt "${CURL_INCLUDES}" HAVE_SIGINTERRUPT) +check_symbol_exists(perror "${CURL_INCLUDES}" HAVE_PERROR) +check_symbol_exists(fork "${CURL_INCLUDES}" HAVE_FORK) ++check_symbol_exists(getaddrinfo "${CURL_INCLUDES}" HAVE_GETADDRINFO) +check_symbol_exists(freeaddrinfo "${CURL_INCLUDES}" HAVE_FREEADDRINFO) +check_symbol_exists(freeifaddrs "${CURL_INCLUDES}" HAVE_FREEIFADDRS) +check_symbol_exists(pipe "${CURL_INCLUDES}" HAVE_PIPE) +check_symbol_exists(ftruncate "${CURL_INCLUDES}" HAVE_FTRUNCATE) +check_symbol_exists(getprotobyname "${CURL_INCLUDES}" HAVE_GETPROTOBYNAME) +check_symbol_exists(getrlimit "${CURL_INCLUDES}" HAVE_GETRLIMIT) +check_symbol_exists(idn_free "${CURL_INCLUDES}" HAVE_IDN_FREE) +check_symbol_exists(idna_strerror "${CURL_INCLUDES}" HAVE_IDNA_STRERROR) +check_symbol_exists(tld_strerror "${CURL_INCLUDES}" HAVE_TLD_STRERROR) +check_symbol_exists(setlocale "${CURL_INCLUDES}" HAVE_SETLOCALE) +check_symbol_exists(setrlimit "${CURL_INCLUDES}" HAVE_SETRLIMIT) +check_symbol_exists(fcntl "${CURL_INCLUDES}" HAVE_FCNTL) +check_symbol_exists(ioctl "${CURL_INCLUDES}" HAVE_IOCTL) +check_symbol_exists(setsockopt "${CURL_INCLUDES}" HAVE_SETSOCKOPT) + +# symbol exists in win32, but function does not. +check_function_exists(inet_pton HAVE_INET_PTON) + +# sigaction and sigsetjmp are special. Use special mechanism for +# detecting those, but only if previous attempt failed. +if(HAVE_SIGNAL_H) + check_symbol_exists(sigaction "signal.h" HAVE_SIGACTION) +endif(HAVE_SIGNAL_H) + +if(NOT HAVE_SIGSETJMP) + if(HAVE_SETJMP_H) + check_symbol_exists(sigsetjmp "setjmp.h" HAVE_MACRO_SIGSETJMP) + if(HAVE_MACRO_SIGSETJMP) + set(HAVE_SIGSETJMP 1) + endif(HAVE_MACRO_SIGSETJMP) + endif(HAVE_SETJMP_H) +endif(NOT HAVE_SIGSETJMP) + +# If there is no stricmp(), do not allow LDAP to parse URLs +if(NOT HAVE_STRICMP) + set(HAVE_LDAP_URL_PARSE 1) +endif(NOT HAVE_STRICMP) + - - +# Do curl specific tests - if(HAVE_LIBWS2_32) - set(CMAKE_REQUIRED_LIBRARIES ws2_32) - endif() +foreach(CURL_TEST + HAVE_FCNTL_O_NONBLOCK + HAVE_IOCTLSOCKET + HAVE_IOCTLSOCKET_CAMEL + HAVE_IOCTLSOCKET_CAMEL_FIONBIO + HAVE_IOCTLSOCKET_FIONBIO + HAVE_IOCTL_FIONBIO + HAVE_IOCTL_SIOCGIFADDR + HAVE_SETSOCKOPT_SO_NONBLOCK + HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID + TIME_WITH_SYS_TIME + HAVE_O_NONBLOCK + HAVE_GETHOSTBYADDR_R_5 + HAVE_GETHOSTBYADDR_R_7 + HAVE_GETHOSTBYADDR_R_8 + HAVE_GETHOSTBYADDR_R_5_REENTRANT + HAVE_GETHOSTBYADDR_R_7_REENTRANT + HAVE_GETHOSTBYADDR_R_8_REENTRANT + HAVE_GETHOSTBYNAME_R_3 + HAVE_GETHOSTBYNAME_R_5 + HAVE_GETHOSTBYNAME_R_6 + HAVE_GETHOSTBYNAME_R_3_REENTRANT + HAVE_GETHOSTBYNAME_R_5_REENTRANT + HAVE_GETHOSTBYNAME_R_6_REENTRANT + HAVE_SOCKLEN_T + HAVE_IN_ADDR_T + HAVE_BOOL_T + STDC_HEADERS + RETSIGTYPE_TEST + HAVE_INET_NTOA_R_DECL + HAVE_INET_NTOA_R_DECL_REENTRANT + HAVE_GETADDRINFO + HAVE_FILE_OFFSET_BITS + ) + curl_internal_test(${CURL_TEST}) +endforeach(CURL_TEST) +if(HAVE_FILE_OFFSET_BITS) + set(_FILE_OFFSET_BITS 64) +endif(HAVE_FILE_OFFSET_BITS) +foreach(CURL_TEST + HAVE_GLIBC_STRERROR_R + HAVE_POSIX_STRERROR_R + ) + curl_internal_test_run(${CURL_TEST}) +endforeach(CURL_TEST) + +# Check for reentrant +foreach(CURL_TEST + HAVE_GETHOSTBYADDR_R_5 + HAVE_GETHOSTBYADDR_R_7 + HAVE_GETHOSTBYADDR_R_8 + HAVE_GETHOSTBYNAME_R_3 + HAVE_GETHOSTBYNAME_R_5 + HAVE_GETHOSTBYNAME_R_6 + HAVE_INET_NTOA_R_DECL_REENTRANT) + if(NOT ${CURL_TEST}) + if(${CURL_TEST}_REENTRANT) + set(NEED_REENTRANT 1) + endif(${CURL_TEST}_REENTRANT) + endif(NOT ${CURL_TEST}) +endforeach(CURL_TEST) + +if(NEED_REENTRANT) + foreach(CURL_TEST + HAVE_GETHOSTBYADDR_R_5 + HAVE_GETHOSTBYADDR_R_7 + HAVE_GETHOSTBYADDR_R_8 + HAVE_GETHOSTBYNAME_R_3 + HAVE_GETHOSTBYNAME_R_5 + HAVE_GETHOSTBYNAME_R_6) + set(${CURL_TEST} 0) + if(${CURL_TEST}_REENTRANT) + set(${CURL_TEST} 1) + endif(${CURL_TEST}_REENTRANT) + endforeach(CURL_TEST) +endif(NEED_REENTRANT) + +if(HAVE_INET_NTOA_R_DECL_REENTRANT) + set(HAVE_INET_NTOA_R_DECL 1) + set(NEED_REENTRANT 1) +endif(HAVE_INET_NTOA_R_DECL_REENTRANT) + +# Some other minor tests + +if(NOT HAVE_IN_ADDR_T) + set(in_addr_t "unsigned long") +endif(NOT HAVE_IN_ADDR_T) + +# Fix libz / zlib.h + +if(NOT CURL_SPECIAL_LIBZ) + if(NOT HAVE_LIBZ) + set(HAVE_ZLIB_H 0) + endif(NOT HAVE_LIBZ) + + if(NOT HAVE_ZLIB_H) + set(HAVE_LIBZ 0) + endif(NOT HAVE_ZLIB_H) +endif(NOT CURL_SPECIAL_LIBZ) + +if(_FILE_OFFSET_BITS) + set(_FILE_OFFSET_BITS 64) +endif(_FILE_OFFSET_BITS) +set(CMAKE_REQUIRED_FLAGS "-D_FILE_OFFSET_BITS=64") +set(CMAKE_EXTRA_INCLUDE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/curl/curl.h") +check_type_size("curl_off_t" SIZEOF_CURL_OFF_T) +set(CMAKE_EXTRA_INCLUDE_FILES) +set(CMAKE_REQUIRED_FLAGS) + + +# Check for nonblocking +set(HAVE_DISABLED_NONBLOCKING 1) +if(HAVE_FIONBIO OR + HAVE_IOCTLSOCKET OR + HAVE_IOCTLSOCKET_CASE OR + HAVE_O_NONBLOCK) + set(HAVE_DISABLED_NONBLOCKING) +endif(HAVE_FIONBIO OR + HAVE_IOCTLSOCKET OR + HAVE_IOCTLSOCKET_CASE OR + HAVE_O_NONBLOCK) + +if(RETSIGTYPE_TEST) + set(RETSIGTYPE void) +else(RETSIGTYPE_TEST) + set(RETSIGTYPE int) +endif(RETSIGTYPE_TEST) + +if(CMAKE_COMPILER_IS_GNUCC AND APPLE) + include(CheckCCompilerFlag) + check_c_compiler_flag(-Wno-long-double HAVE_C_FLAG_Wno_long_double) + if(HAVE_C_FLAG_Wno_long_double) + # The Mac version of GCC warns about use of long double. Disable it. + get_source_file_property(MPRINTF_COMPILE_FLAGS mprintf.c COMPILE_FLAGS) + if(MPRINTF_COMPILE_FLAGS) + set(MPRINTF_COMPILE_FLAGS "${MPRINTF_COMPILE_FLAGS} -Wno-long-double") + else(MPRINTF_COMPILE_FLAGS) + set(MPRINTF_COMPILE_FLAGS "-Wno-long-double") + endif(MPRINTF_COMPILE_FLAGS) + set_source_files_properties(mprintf.c PROPERTIES + COMPILE_FLAGS ${MPRINTF_COMPILE_FLAGS}) + endif(HAVE_C_FLAG_Wno_long_double) +endif(CMAKE_COMPILER_IS_GNUCC AND APPLE) + +if(HAVE_SOCKLEN_T) + set(CURL_HAVE_SOCKLEN_T 1) + set(CURL_TYPEOF_CURL_SOCKLEN_T "socklen_t") + if(WIN32) + set(CMAKE_EXTRA_INCLUDE_FILES "winsock2.h;ws2tcpip.h") + elseif(HAVE_SYS_SOCKET_H) + set(CMAKE_EXTRA_INCLUDE_FILES "sys/socket.h") + endif() + check_type_size("socklen_t" CURL_SIZEOF_CURL_SOCKLEN_T) + set(CMAKE_EXTRA_INCLUDE_FILES) + if(NOT HAVE_CURL_SIZEOF_CURL_SOCKLEN_T) + message(FATAL_ERROR + "Check for sizeof socklen_t failed, see CMakeFiles/CMakerror.log") + endif() +else() + set(CURL_HAVE_SOCKLEN_T 0) +endif() + +# TODO test which of these headers are required for the typedefs used in curlbuild.h +if(WIN32) + set(CURL_PULL_WS2TCPIP_H ${HAVE_WS2TCPIP_H}) +else() + set(CURL_PULL_SYS_TYPES_H ${HAVE_SYS_TYPES_H}) + set(CURL_PULL_SYS_SOCKET_H ${HAVE_SYS_SOCKET_H}) + set(CURL_PULL_SYS_POLL_H ${HAVE_SYS_POLL_H}) +endif() +set(CURL_PULL_STDINT_H ${HAVE_STDINT_H}) +set(CURL_PULL_INTTYPES_H ${HAVE_INTTYPES_H}) + +include(CMake/OtherTests.cmake) + +add_definitions(-DHAVE_CONFIG_H) + +# For windows, do not allow the compiler to use default target (Vista). +if(WIN32) + add_definitions(-D_WIN32_WINNT=0x0501) +endif(WIN32) + +if(MSVC) + add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE) +endif(MSVC) + - # Sets up the dependencies (zlib, OpenSSL, etc.) of a cURL subproject according to options. - # TODO This is far to be complete! - function(SETUP_CURL_DEPENDENCIES TARGET_NAME) - if(CURL_ZLIB AND ZLIB_FOUND) - include_directories(${ZLIB_INCLUDE_DIR}) - endif() - - if(CMAKE_USE_OPENSSL AND OPENSSL_FOUND) - include_directories(${OPENSSL_INCLUDE_DIR}) - endif() - - if(CMAKE_USE_LIBSSH2 AND LIBSSH2_FOUND) - include_directories(${LIBSSH2_INCLUDE_DIR}) - endif() - - target_link_libraries(${TARGET_NAME} ${CURL_LIBS}) - endfunction() - +# Ugly (but functional) way to include "Makefile.inc" by transforming it (= regenerate it). +function(TRANSFORM_MAKEFILE_INC INPUT_FILE OUTPUT_FILE) + file(READ ${INPUT_FILE} MAKEFILE_INC_TEXT) + string(REPLACE "$(top_srcdir)" "\${CURL_SOURCE_DIR}" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT}) + string(REPLACE "$(top_builddir)" "\${CURL_BINARY_DIR}" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT}) + + string(REGEX REPLACE "\\\\\n" "?!?" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT}) + string(REGEX REPLACE "([a-zA-Z_][a-zA-Z0-9_]*)[\t ]*=[\t ]*([^\n]*)" "SET(\\1 \\2)" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT}) + string(REPLACE "?!?" "\n" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT}) + + string(REGEX REPLACE "\\$\\(([a-zA-Z_][a-zA-Z0-9_]*)\\)" "\${\\1}" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT}) # Replace $() with ${} + string(REGEX REPLACE "@([a-zA-Z_][a-zA-Z0-9_]*)@" "\${\\1}" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT}) # Replace @@ with ${}, even if that may not be read by CMake scripts. + file(WRITE ${OUTPUT_FILE} ${MAKEFILE_INC_TEXT}) + +endfunction() + +add_subdirectory(lib) +if(BUILD_CURL_EXE) + add_subdirectory(src) +endif() +if(BUILD_CURL_TESTS) + add_subdirectory(tests) +endif() + +#----------------------------------------------------------------------------- +# CMake-specific curl code. +add_executable(LIBCURL curltest.c) +target_link_libraries(LIBCURL cmcurl) + +if(CMAKE_CURL_TEST_URL) + add_test(curl LIBCURL ${CMAKE_CURL_TEST_URL}) +endif() + +install(FILES COPYING DESTINATION ${CMAKE_DOC_DIR}/cmcurl) +#----------------------------------------------------------------------------- + +if(0) # This code not needed for building within CMake. ++# TODO support GNUTLS, NSS, POLARSSL, AXTLS, CYASSL, WINSSL, DARWINSSL ++if(USE_OPENSSL) ++ set(SSL_ENABLED 1) ++endif() ++ ++# Helper to populate a list (_items) with a label when conditions (the remaining ++# args) are satisfied ++function(_add_if label) ++ # TODO need to disable policy CMP0054 (CMake 3.1) to allow this indirection ++ if(${ARGN}) ++ set(_items ${_items} "${label}" PARENT_SCOPE) ++ endif() ++endfunction() ++ ++# Clear list and try to detect available features ++set(_items) ++_add_if("SSL" SSL_ENABLED) ++_add_if("IPv6" ENABLE_IPV6) ++_add_if("unix-sockets" USE_UNIX_SOCKETS) ++_add_if("libz" HAVE_LIBZ) ++_add_if("AsynchDNS" USE_ARES OR USE_THREADS_POSIX) ++_add_if("IDN" HAVE_LIBIDN) ++# TODO SSP1 (WinSSL) check is missing ++_add_if("SSPI" USE_WINDOWS_SSPI) ++_add_if("GSS-API" HAVE_GSSAPI) ++# TODO SSP1 missing for SPNEGO ++_add_if("SPNEGO" NOT CURL_DISABLE_CRYPTO_AUTH AND ++ (HAVE_GSSAPI OR USE_WINDOWS_SSPI)) ++_add_if("Kerberos" NOT CURL_DISABLE_CRYPTO_AUTH AND ++ (HAVE_GSSAPI OR USE_WINDOWS_SSPI)) ++# NTLM support requires crypto function adaptions from various SSL libs ++# TODO alternative SSL libs tests for SSP1, GNUTLS, NSS, DARWINSSL ++if(NOT CURL_DISABLE_CRYPTO_AUTH AND (USE_OPENSSL OR ++ USE_WINDOWS_SSPI OR GNUTLS_ENABLED OR NSS_ENABLED OR DARWINSSL_ENABLED)) ++ _add_if("NTLM" 1) ++ # TODO missing option (autoconf: --enable-ntlm-wb) ++ _add_if("NTLM_WB" NOT CURL_DISABLE_HTTP AND NTLM_WB_ENABLED) ++endif() ++# TODO missing option (--enable-tls-srp), depends on GNUTLS_SRP/OPENSSL_SRP ++_add_if("TLS-SRP" USE_TLS_SRP) ++# TODO option --with-nghttp2 tests for nghttp2 lib and nghttp2/nghttp2.h header ++_add_if("HTTP2" USE_NGHTTP2) ++string(REPLACE ";" " " SUPPORT_FEATURES "${_items}") ++message(STATUS "Enabled features: ${SUPPORT_FEATURES}") ++ ++# Clear list and try to detect available protocols ++set(_items) ++_add_if("HTTP" NOT CURL_DISABLE_HTTP) ++_add_if("HTTPS" NOT CURL_DISABLE_HTTP AND SSL_ENABLED) ++_add_if("FTP" NOT CURL_DISABLE_FTP) ++_add_if("FTPS" NOT CURL_DISABLE_FTP AND SSL_ENABLED) ++_add_if("FILE" NOT CURL_DISABLE_FILE) ++_add_if("TELNET" NOT CURL_DISABLE_TELNET) ++_add_if("LDAP" NOT CURL_DISABLE_LDAP) ++# CURL_DISABLE_LDAP implies CURL_DISABLE_LDAPS ++# TODO check HAVE_LDAP_SSL (in autoconf this is enabled with --enable-ldaps) ++_add_if("LDAPS" NOT CURL_DISABLE_LDAPS AND ++ ((USE_OPENLDAP AND SSL_ENABLED) OR ++ (NOT USE_OPENLDAP AND HAVE_LDAP_SSL))) ++_add_if("DICT" NOT CURL_DISABLE_DICT) ++_add_if("TFTP" NOT CURL_DISABLE_TFTP) ++_add_if("GOPHER" NOT CURL_DISABLE_GOPHER) ++_add_if("POP3" NOT CURL_DISABLE_POP3) ++_add_if("POP3S" NOT CURL_DISABLE_POP3 AND SSL_ENABLED) ++_add_if("IMAP" NOT CURL_DISABLE_IMAP) ++_add_if("IMAPS" NOT CURL_DISABLE_IMAP AND SSL_ENABLED) ++_add_if("SMTP" NOT CURL_DISABLE_SMTP) ++_add_if("SMTPS" NOT CURL_DISABLE_SMTP AND SSL_ENABLED) ++_add_if("SCP" USE_LIBSSH2) ++_add_if("SFTP" USE_LIBSSH2) ++_add_if("RTSP" NOT CURL_DISABLE_RTSP) ++_add_if("RTMP" USE_LIBRTMP) ++list(SORT _items) ++string(REPLACE ";" " " SUPPORT_PROTOCOLS "${_items}") ++message(STATUS "Enabled protocols: ${SUPPORT_PROTOCOLS}") ++ ++# curl-config needs the following options to be set. ++set(CC "${CMAKE_C_COMPILER}") ++# TODO probably put a -D... options here? ++set(CONFIGURE_OPTIONS "") ++# TODO when to set "-DCURL_STATICLIB" for CPPFLAG_CURL_STATICLIB? ++set(CPPFLAG_CURL_STATICLIB "") ++# TODO need to set this (see CURL_CHECK_CA_BUNDLE in acinclude.m4) ++set(CURL_CA_BUNDLE "") ++set(CURLVERSION "${CURL_VERSION}") ++set(ENABLE_SHARED "yes") ++if(CURL_STATICLIB) ++ # Broken: LIBCURL_LIBS below; .a lib is not built ++ message(WARNING "Static linking is broken!") ++ set(ENABLE_STATIC "no") ++else() ++ set(ENABLE_STATIC "no") ++endif() ++set(exec_prefix "\${prefix}") ++set(includedir "\${prefix}/include") ++set(LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS}") ++set(LIBCURL_LIBS "") ++set(libdir "${CMAKE_INSTALL_PREFIX}/lib") ++# TODO CURL_LIBS also contains absolute paths which don't work with static -l... ++foreach(_lib ${CMAKE_C_IMPLICIT_LINK_LIBRARIES} ${CURL_LIBS}) ++ set(LIBCURL_LIBS "${LIBCURL_LIBS} -l${_lib}") ++endforeach() ++# "a" (Linux) or "lib" (Windows) ++string(REPLACE "." "" libext "${CMAKE_STATIC_LIBRARY_SUFFIX}") ++set(prefix "${CMAKE_INSTALL_PREFIX}") ++# Set this to "yes" to append all libraries on which -lcurl is dependent ++set(REQUIRE_LIB_DEPS "no") ++# SUPPORT_FEATURES ++# SUPPORT_PROTOCOLS ++set(VERSIONNUM "${CURL_VERSION_NUM}") ++ ++# Finally generate a "curl-config" matching this config ++configure_file("${CURL_SOURCE_DIR}/curl-config.in" ++ "${CURL_BINARY_DIR}/curl-config" @ONLY) ++install(FILES "${CMAKE_BINARY_DIR}/curl-config" ++ DESTINATION bin ++ PERMISSIONS ++ OWNER_READ OWNER_WRITE OWNER_EXECUTE ++ GROUP_READ GROUP_EXECUTE ++ WORLD_READ WORLD_EXECUTE) ++ ++# Finally generate a pkg-config file matching this config ++configure_file("${CURL_SOURCE_DIR}/libcurl.pc.in" ++ "${CURL_BINARY_DIR}/libcurl.pc" @ONLY) ++install(FILES "${CMAKE_BINARY_DIR}/libcurl.pc" ++ DESTINATION lib/pkgconfig) ++ +# This needs to be run very last so other parts of the scripts can take advantage of this. +if(NOT CURL_CONFIG_HAS_BEEN_RUN_BEFORE) + set(CURL_CONFIG_HAS_BEEN_RUN_BEFORE 1 CACHE INTERNAL "Flag to track whether this is the first time running CMake or if CMake has been configured before") +endif() + +# Installation. +# First, install generated curlbuild.h +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/include/curl/curlbuild.h" + DESTINATION include/curl ) +# Next, install other headers excluding curlbuild.h +install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/curl" + DESTINATION include + FILES_MATCHING PATTERN "*.h" + PATTERN "curlbuild.h" EXCLUDE) + + +# Workaround for MSVS10 to avoid the Dialog Hell +# FIXME: This could be removed with future version of CMake. +if(MSVC_VERSION EQUAL 1600) + set(CURL_SLN_FILENAME "${CMAKE_CURRENT_BINARY_DIR}/CURL.sln") + if(EXISTS "${CURL_SLN_FILENAME}") + file(APPEND "${CURL_SLN_FILENAME}" "\n# This should be regenerated!\n") + endif() +endif() +endif() diff --cc Utilities/cmcurl/include/curl/curl.h index 40d0b81,0000000..86ce1ff mode 100644,000000..100644 --- a/Utilities/cmcurl/include/curl/curl.h +++ b/Utilities/cmcurl/include/curl/curl.h @@@ -1,2338 -1,0 +1,2382 @@@ +#ifndef __CURL_CURL_H +#define __CURL_CURL_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. ++ * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ + +/* + * If you have libcurl problems, all docs and details are found here: + * http://curl.haxx.se/libcurl/ + * + * curl-library mailing list subscription and unsubscription web interface: + * http://cool.haxx.se/mailman/listinfo/curl-library/ + */ + +#include "curlver.h" /* libcurl version defines */ +#include "cmcurl/include/curl/curlbuild.h" /* libcurl build definitions */ +#include "curlrules.h" /* libcurl rules enforcement */ + +/* + * Define WIN32 when build target is Win32 API + */ + +#if (defined(_WIN32) || defined(__WIN32__)) && \ + !defined(WIN32) && !defined(__SYMBIAN32__) +#define WIN32 +#endif + +#include +#include + +#if defined(__FreeBSD__) && (__FreeBSD__ >= 2) +/* Needed for __FreeBSD_version symbol definition */ +#include +#endif + +/* The include stuff here below is mainly for time_t! */ +#include +#include + +#if defined(WIN32) && !defined(_WIN32_WCE) && !defined(__CYGWIN__) +#if !(defined(_WINSOCKAPI_) || defined(_WINSOCK_H) || defined(__LWIP_OPT_H__)) +/* The check above prevents the winsock2 inclusion if winsock.h already was + included, since they can't co-exist without problems */ +#include +#include +#endif +#endif + +/* HP-UX systems version 9, 10 and 11 lack sys/select.h and so does oldish + libc5-based Linux systems. Only include it on systems that are known to + require it! */ +#if defined(_AIX) || defined(__NOVELL_LIBC__) || defined(__NetBSD__) || \ + defined(__minix) || defined(__SYMBIAN32__) || defined(__INTEGRITY) || \ + defined(ANDROID) || defined(__ANDROID__) || defined(__OpenBSD__) || \ + (defined(__FreeBSD_version) && (__FreeBSD_version < 800000)) +#include +#endif + +#if !defined(WIN32) && !defined(_WIN32_WCE) +#include +#endif + +#if !defined(WIN32) && !defined(__WATCOMC__) && !defined(__VXWORKS__) +#include +#endif + +#if defined __BEOS__ || defined __HAIKU__ +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void CURL; + +/* + * libcurl external API function linkage decorations. + */ + +#ifdef CURL_STATICLIB +# define CURL_EXTERN +#elif defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__) +# if defined(BUILDING_LIBCURL) +# define CURL_EXTERN __declspec(dllexport) +# else +# define CURL_EXTERN __declspec(dllimport) +# endif +#elif defined(BUILDING_LIBCURL) && defined(CURL_HIDDEN_SYMBOLS) +# define CURL_EXTERN CURL_EXTERN_SYMBOL +#else +# define CURL_EXTERN +#endif + +#ifndef curl_socket_typedef +/* socket typedef */ +#if defined(WIN32) && !defined(__LWIP_OPT_H__) +typedef SOCKET curl_socket_t; +#define CURL_SOCKET_BAD INVALID_SOCKET +#else +typedef int curl_socket_t; +#define CURL_SOCKET_BAD -1 +#endif +#define curl_socket_typedef +#endif /* curl_socket_typedef */ + +struct curl_httppost { + struct curl_httppost *next; /* next entry in the list */ + char *name; /* pointer to allocated name */ + long namelength; /* length of name length */ + char *contents; /* pointer to allocated data contents */ + long contentslength; /* length of contents field */ + char *buffer; /* pointer to allocated buffer contents */ + long bufferlength; /* length of buffer field */ + char *contenttype; /* Content-Type */ + struct curl_slist* contentheader; /* list of extra headers for this form */ + struct curl_httppost *more; /* if one field name has more than one + file, this link should link to following + files */ + long flags; /* as defined below */ +#define HTTPPOST_FILENAME (1<<0) /* specified content is a file name */ +#define HTTPPOST_READFILE (1<<1) /* specified content is a file name */ +#define HTTPPOST_PTRNAME (1<<2) /* name is only stored pointer + do not free in formfree */ +#define HTTPPOST_PTRCONTENTS (1<<3) /* contents is only stored pointer + do not free in formfree */ +#define HTTPPOST_BUFFER (1<<4) /* upload file from buffer */ +#define HTTPPOST_PTRBUFFER (1<<5) /* upload file from pointer contents */ +#define HTTPPOST_CALLBACK (1<<6) /* upload file contents by using the + regular read callback to get the data + and pass the given pointer as custom + pointer */ + + char *showfilename; /* The file name to show. If not set, the + actual file name will be used (if this + is a file part) */ + void *userp; /* custom pointer used for + HTTPPOST_CALLBACK posts */ +}; + +/* This is the CURLOPT_PROGRESSFUNCTION callback proto. It is now considered + deprecated but was the only choice up until 7.31.0 */ +typedef int (*curl_progress_callback)(void *clientp, + double dltotal, + double dlnow, + double ultotal, + double ulnow); + +/* This is the CURLOPT_XFERINFOFUNCTION callback proto. It was introduced in + 7.32.0, it avoids floating point and provides more detailed information. */ +typedef int (*curl_xferinfo_callback)(void *clientp, + curl_off_t dltotal, + curl_off_t dlnow, + curl_off_t ultotal, + curl_off_t ulnow); + +#ifndef CURL_MAX_WRITE_SIZE + /* Tests have proven that 20K is a very bad buffer size for uploads on + Windows, while 16K for some odd reason performed a lot better. + We do the ifndef check to allow this value to easier be changed at build + time for those who feel adventurous. The practical minimum is about + 400 bytes since libcurl uses a buffer of this size as a scratch area + (unrelated to network send operations). */ +#define CURL_MAX_WRITE_SIZE 16384 +#endif + +#ifndef CURL_MAX_HTTP_HEADER +/* The only reason to have a max limit for this is to avoid the risk of a bad + server feeding libcurl with a never-ending header that will cause reallocs + infinitely */ +#define CURL_MAX_HTTP_HEADER (100*1024) +#endif + +/* This is a magic return code for the write callback that, when returned, + will signal libcurl to pause receiving on the current transfer. */ +#define CURL_WRITEFUNC_PAUSE 0x10000001 + +typedef size_t (*curl_write_callback)(char *buffer, + size_t size, + size_t nitems, + void *outstream); + + + +/* enumeration of file types */ +typedef enum { + CURLFILETYPE_FILE = 0, + CURLFILETYPE_DIRECTORY, + CURLFILETYPE_SYMLINK, + CURLFILETYPE_DEVICE_BLOCK, + CURLFILETYPE_DEVICE_CHAR, + CURLFILETYPE_NAMEDPIPE, + CURLFILETYPE_SOCKET, + CURLFILETYPE_DOOR, /* is possible only on Sun Solaris now */ + + CURLFILETYPE_UNKNOWN /* should never occur */ +} curlfiletype; + +#define CURLFINFOFLAG_KNOWN_FILENAME (1<<0) +#define CURLFINFOFLAG_KNOWN_FILETYPE (1<<1) +#define CURLFINFOFLAG_KNOWN_TIME (1<<2) +#define CURLFINFOFLAG_KNOWN_PERM (1<<3) +#define CURLFINFOFLAG_KNOWN_UID (1<<4) +#define CURLFINFOFLAG_KNOWN_GID (1<<5) +#define CURLFINFOFLAG_KNOWN_SIZE (1<<6) +#define CURLFINFOFLAG_KNOWN_HLINKCOUNT (1<<7) + +/* Content of this structure depends on information which is known and is + achievable (e.g. by FTP LIST parsing). Please see the url_easy_setopt(3) man + page for callbacks returning this structure -- some fields are mandatory, + some others are optional. The FLAG field has special meaning. */ +struct curl_fileinfo { + char *filename; + curlfiletype filetype; + time_t time; + unsigned int perm; + int uid; + int gid; + curl_off_t size; + long int hardlinks; + + struct { + /* If some of these fields is not NULL, it is a pointer to b_data. */ + char *time; + char *perm; + char *user; + char *group; + char *target; /* pointer to the target filename of a symlink */ + } strings; + + unsigned int flags; + + /* used internally */ + char * b_data; + size_t b_size; + size_t b_used; +}; + +/* return codes for CURLOPT_CHUNK_BGN_FUNCTION */ +#define CURL_CHUNK_BGN_FUNC_OK 0 +#define CURL_CHUNK_BGN_FUNC_FAIL 1 /* tell the lib to end the task */ +#define CURL_CHUNK_BGN_FUNC_SKIP 2 /* skip this chunk over */ + +/* if splitting of data transfer is enabled, this callback is called before + download of an individual chunk started. Note that parameter "remains" works + only for FTP wildcard downloading (for now), otherwise is not used */ +typedef long (*curl_chunk_bgn_callback)(const void *transfer_info, + void *ptr, + int remains); + +/* return codes for CURLOPT_CHUNK_END_FUNCTION */ +#define CURL_CHUNK_END_FUNC_OK 0 +#define CURL_CHUNK_END_FUNC_FAIL 1 /* tell the lib to end the task */ + +/* If splitting of data transfer is enabled this callback is called after + download of an individual chunk finished. + Note! After this callback was set then it have to be called FOR ALL chunks. + Even if downloading of this chunk was skipped in CHUNK_BGN_FUNC. + This is the reason why we don't need "transfer_info" parameter in this + callback and we are not interested in "remains" parameter too. */ +typedef long (*curl_chunk_end_callback)(void *ptr); + +/* return codes for FNMATCHFUNCTION */ +#define CURL_FNMATCHFUNC_MATCH 0 /* string corresponds to the pattern */ +#define CURL_FNMATCHFUNC_NOMATCH 1 /* pattern doesn't match the string */ +#define CURL_FNMATCHFUNC_FAIL 2 /* an error occurred */ + +/* callback type for wildcard downloading pattern matching. If the + string matches the pattern, return CURL_FNMATCHFUNC_MATCH value, etc. */ +typedef int (*curl_fnmatch_callback)(void *ptr, + const char *pattern, + const char *string); + +/* These are the return codes for the seek callbacks */ +#define CURL_SEEKFUNC_OK 0 +#define CURL_SEEKFUNC_FAIL 1 /* fail the entire transfer */ +#define CURL_SEEKFUNC_CANTSEEK 2 /* tell libcurl seeking can't be done, so + libcurl might try other means instead */ +typedef int (*curl_seek_callback)(void *instream, + curl_off_t offset, + int origin); /* 'whence' */ + +/* This is a return code for the read callback that, when returned, will + signal libcurl to immediately abort the current transfer. */ +#define CURL_READFUNC_ABORT 0x10000000 +/* This is a return code for the read callback that, when returned, will + signal libcurl to pause sending data on the current transfer. */ +#define CURL_READFUNC_PAUSE 0x10000001 + +typedef size_t (*curl_read_callback)(char *buffer, + size_t size, + size_t nitems, + void *instream); + +typedef enum { + CURLSOCKTYPE_IPCXN, /* socket created for a specific IP connection */ + CURLSOCKTYPE_ACCEPT, /* socket created by accept() call */ + CURLSOCKTYPE_LAST /* never use */ +} curlsocktype; + +/* The return code from the sockopt_callback can signal information back + to libcurl: */ +#define CURL_SOCKOPT_OK 0 +#define CURL_SOCKOPT_ERROR 1 /* causes libcurl to abort and return + CURLE_ABORTED_BY_CALLBACK */ +#define CURL_SOCKOPT_ALREADY_CONNECTED 2 + +typedef int (*curl_sockopt_callback)(void *clientp, + curl_socket_t curlfd, + curlsocktype purpose); + +struct curl_sockaddr { + int family; + int socktype; + int protocol; + unsigned int addrlen; /* addrlen was a socklen_t type before 7.18.0 but it + turned really ugly and painful on the systems that + lack this type */ + struct sockaddr addr; +}; + +typedef curl_socket_t +(*curl_opensocket_callback)(void *clientp, + curlsocktype purpose, + struct curl_sockaddr *address); + +typedef int +(*curl_closesocket_callback)(void *clientp, curl_socket_t item); + +typedef enum { + CURLIOE_OK, /* I/O operation successful */ + CURLIOE_UNKNOWNCMD, /* command was unknown to callback */ + CURLIOE_FAILRESTART, /* failed to restart the read */ + CURLIOE_LAST /* never use */ +} curlioerr; + +typedef enum { + CURLIOCMD_NOP, /* no operation */ + CURLIOCMD_RESTARTREAD, /* restart the read stream from start */ + CURLIOCMD_LAST /* never use */ +} curliocmd; + +typedef curlioerr (*curl_ioctl_callback)(CURL *handle, + int cmd, + void *clientp); + +/* + * The following typedef's are signatures of malloc, free, realloc, strdup and + * calloc respectively. Function pointers of these types can be passed to the + * curl_global_init_mem() function to set user defined memory management + * callback routines. + */ +typedef void *(*curl_malloc_callback)(size_t size); +typedef void (*curl_free_callback)(void *ptr); +typedef void *(*curl_realloc_callback)(void *ptr, size_t size); +typedef char *(*curl_strdup_callback)(const char *str); +typedef void *(*curl_calloc_callback)(size_t nmemb, size_t size); + +/* the kind of data that is passed to information_callback*/ +typedef enum { + CURLINFO_TEXT = 0, + CURLINFO_HEADER_IN, /* 1 */ + CURLINFO_HEADER_OUT, /* 2 */ + CURLINFO_DATA_IN, /* 3 */ + CURLINFO_DATA_OUT, /* 4 */ + CURLINFO_SSL_DATA_IN, /* 5 */ + CURLINFO_SSL_DATA_OUT, /* 6 */ + CURLINFO_END +} curl_infotype; + +typedef int (*curl_debug_callback) + (CURL *handle, /* the handle/transfer this concerns */ + curl_infotype type, /* what kind of data */ + char *data, /* points to the data */ + size_t size, /* size of the data pointed to */ + void *userptr); /* whatever the user please */ + +/* All possible error codes from all sorts of curl functions. Future versions + may return other values, stay prepared. + + Always add new return codes last. Never *EVER* remove any. The return + codes must remain the same! + */ + +typedef enum { + CURLE_OK = 0, + CURLE_UNSUPPORTED_PROTOCOL, /* 1 */ + CURLE_FAILED_INIT, /* 2 */ + CURLE_URL_MALFORMAT, /* 3 */ + CURLE_NOT_BUILT_IN, /* 4 - [was obsoleted in August 2007 for + 7.17.0, reused in April 2011 for 7.21.5] */ + CURLE_COULDNT_RESOLVE_PROXY, /* 5 */ + CURLE_COULDNT_RESOLVE_HOST, /* 6 */ + CURLE_COULDNT_CONNECT, /* 7 */ + CURLE_FTP_WEIRD_SERVER_REPLY, /* 8 */ + CURLE_REMOTE_ACCESS_DENIED, /* 9 a service was denied by the server + due to lack of access - when login fails + this is not returned. */ + CURLE_FTP_ACCEPT_FAILED, /* 10 - [was obsoleted in April 2006 for + 7.15.4, reused in Dec 2011 for 7.24.0]*/ + CURLE_FTP_WEIRD_PASS_REPLY, /* 11 */ + CURLE_FTP_ACCEPT_TIMEOUT, /* 12 - timeout occurred accepting server + [was obsoleted in August 2007 for 7.17.0, + reused in Dec 2011 for 7.24.0]*/ + CURLE_FTP_WEIRD_PASV_REPLY, /* 13 */ + CURLE_FTP_WEIRD_227_FORMAT, /* 14 */ + CURLE_FTP_CANT_GET_HOST, /* 15 */ + CURLE_HTTP2, /* 16 - A problem in the http2 framing layer. + [was obsoleted in August 2007 for 7.17.0, + reused in July 2014 for 7.38.0] */ + CURLE_FTP_COULDNT_SET_TYPE, /* 17 */ + CURLE_PARTIAL_FILE, /* 18 */ + CURLE_FTP_COULDNT_RETR_FILE, /* 19 */ + CURLE_OBSOLETE20, /* 20 - NOT USED */ + CURLE_QUOTE_ERROR, /* 21 - quote command failure */ + CURLE_HTTP_RETURNED_ERROR, /* 22 */ + CURLE_WRITE_ERROR, /* 23 */ + CURLE_OBSOLETE24, /* 24 - NOT USED */ + CURLE_UPLOAD_FAILED, /* 25 - failed upload "command" */ + CURLE_READ_ERROR, /* 26 - couldn't open/read from file */ + CURLE_OUT_OF_MEMORY, /* 27 */ + /* Note: CURLE_OUT_OF_MEMORY may sometimes indicate a conversion error + instead of a memory allocation error if CURL_DOES_CONVERSIONS + is defined + */ + CURLE_OPERATION_TIMEDOUT, /* 28 - the timeout time was reached */ + CURLE_OBSOLETE29, /* 29 - NOT USED */ + CURLE_FTP_PORT_FAILED, /* 30 - FTP PORT operation failed */ + CURLE_FTP_COULDNT_USE_REST, /* 31 - the REST command failed */ + CURLE_OBSOLETE32, /* 32 - NOT USED */ + CURLE_RANGE_ERROR, /* 33 - RANGE "command" didn't work */ + CURLE_HTTP_POST_ERROR, /* 34 */ + CURLE_SSL_CONNECT_ERROR, /* 35 - wrong when connecting with SSL */ + CURLE_BAD_DOWNLOAD_RESUME, /* 36 - couldn't resume download */ + CURLE_FILE_COULDNT_READ_FILE, /* 37 */ + CURLE_LDAP_CANNOT_BIND, /* 38 */ + CURLE_LDAP_SEARCH_FAILED, /* 39 */ + CURLE_OBSOLETE40, /* 40 - NOT USED */ + CURLE_FUNCTION_NOT_FOUND, /* 41 */ + CURLE_ABORTED_BY_CALLBACK, /* 42 */ + CURLE_BAD_FUNCTION_ARGUMENT, /* 43 */ + CURLE_OBSOLETE44, /* 44 - NOT USED */ + CURLE_INTERFACE_FAILED, /* 45 - CURLOPT_INTERFACE failed */ + CURLE_OBSOLETE46, /* 46 - NOT USED */ + CURLE_TOO_MANY_REDIRECTS , /* 47 - catch endless re-direct loops */ + CURLE_UNKNOWN_OPTION, /* 48 - User specified an unknown option */ + CURLE_TELNET_OPTION_SYNTAX , /* 49 - Malformed telnet option */ + CURLE_OBSOLETE50, /* 50 - NOT USED */ + CURLE_PEER_FAILED_VERIFICATION, /* 51 - peer's certificate or fingerprint + wasn't verified fine */ + CURLE_GOT_NOTHING, /* 52 - when this is a specific error */ + CURLE_SSL_ENGINE_NOTFOUND, /* 53 - SSL crypto engine not found */ + CURLE_SSL_ENGINE_SETFAILED, /* 54 - can not set SSL crypto engine as + default */ + CURLE_SEND_ERROR, /* 55 - failed sending network data */ + CURLE_RECV_ERROR, /* 56 - failure in receiving network data */ + CURLE_OBSOLETE57, /* 57 - NOT IN USE */ + CURLE_SSL_CERTPROBLEM, /* 58 - problem with the local certificate */ + CURLE_SSL_CIPHER, /* 59 - couldn't use specified cipher */ + CURLE_SSL_CACERT, /* 60 - problem with the CA cert (path?) */ + CURLE_BAD_CONTENT_ENCODING, /* 61 - Unrecognized/bad encoding */ + CURLE_LDAP_INVALID_URL, /* 62 - Invalid LDAP URL */ + CURLE_FILESIZE_EXCEEDED, /* 63 - Maximum file size exceeded */ + CURLE_USE_SSL_FAILED, /* 64 - Requested FTP SSL level failed */ + CURLE_SEND_FAIL_REWIND, /* 65 - Sending the data requires a rewind + that failed */ + CURLE_SSL_ENGINE_INITFAILED, /* 66 - failed to initialise ENGINE */ + CURLE_LOGIN_DENIED, /* 67 - user, password or similar was not + accepted and we failed to login */ + CURLE_TFTP_NOTFOUND, /* 68 - file not found on server */ + CURLE_TFTP_PERM, /* 69 - permission problem on server */ + CURLE_REMOTE_DISK_FULL, /* 70 - out of disk space on server */ + CURLE_TFTP_ILLEGAL, /* 71 - Illegal TFTP operation */ + CURLE_TFTP_UNKNOWNID, /* 72 - Unknown transfer ID */ + CURLE_REMOTE_FILE_EXISTS, /* 73 - File already exists */ + CURLE_TFTP_NOSUCHUSER, /* 74 - No such user */ + CURLE_CONV_FAILED, /* 75 - conversion failed */ + CURLE_CONV_REQD, /* 76 - caller must register conversion + callbacks using curl_easy_setopt options + CURLOPT_CONV_FROM_NETWORK_FUNCTION, + CURLOPT_CONV_TO_NETWORK_FUNCTION, and + CURLOPT_CONV_FROM_UTF8_FUNCTION */ + CURLE_SSL_CACERT_BADFILE, /* 77 - could not load CACERT file, missing + or wrong format */ + CURLE_REMOTE_FILE_NOT_FOUND, /* 78 - remote file not found */ + CURLE_SSH, /* 79 - error from the SSH layer, somewhat + generic so the error message will be of + interest when this has happened */ + + CURLE_SSL_SHUTDOWN_FAILED, /* 80 - Failed to shut down the SSL + connection */ + CURLE_AGAIN, /* 81 - socket is not ready for send/recv, + wait till it's ready and try again (Added + in 7.18.2) */ + CURLE_SSL_CRL_BADFILE, /* 82 - could not load CRL file, missing or + wrong format (Added in 7.19.0) */ + CURLE_SSL_ISSUER_ERROR, /* 83 - Issuer check failed. (Added in + 7.19.0) */ + CURLE_FTP_PRET_FAILED, /* 84 - a PRET command failed */ + CURLE_RTSP_CSEQ_ERROR, /* 85 - mismatch of RTSP CSeq numbers */ + CURLE_RTSP_SESSION_ERROR, /* 86 - mismatch of RTSP Session Ids */ + CURLE_FTP_BAD_FILE_LIST, /* 87 - unable to parse FTP file list */ + CURLE_CHUNK_FAILED, /* 88 - chunk callback reported error */ + CURLE_NO_CONNECTION_AVAILABLE, /* 89 - No connection available, the + session will be queued */ ++ CURLE_SSL_PINNEDPUBKEYNOTMATCH, /* 90 - specified pinned public key did not ++ match */ ++ CURLE_SSL_INVALIDCERTSTATUS, /* 91 - invalid certificate status */ + CURL_LAST /* never use! */ +} CURLcode; + +#ifndef CURL_NO_OLDIES /* define this to test if your app builds with all + the obsolete stuff removed! */ + +/* Previously obsolete error code re-used in 7.38.0 */ +#define CURLE_OBSOLETE16 CURLE_HTTP2 + +/* Previously obsolete error codes re-used in 7.24.0 */ +#define CURLE_OBSOLETE10 CURLE_FTP_ACCEPT_FAILED +#define CURLE_OBSOLETE12 CURLE_FTP_ACCEPT_TIMEOUT + +/* compatibility with older names */ +#define CURLOPT_ENCODING CURLOPT_ACCEPT_ENCODING + +/* The following were added in 7.21.5, April 2011 */ +#define CURLE_UNKNOWN_TELNET_OPTION CURLE_UNKNOWN_OPTION + +/* The following were added in 7.17.1 */ +/* These are scheduled to disappear by 2009 */ +#define CURLE_SSL_PEER_CERTIFICATE CURLE_PEER_FAILED_VERIFICATION + +/* The following were added in 7.17.0 */ +/* These are scheduled to disappear by 2009 */ +#define CURLE_OBSOLETE CURLE_OBSOLETE50 /* no one should be using this! */ +#define CURLE_BAD_PASSWORD_ENTERED CURLE_OBSOLETE46 +#define CURLE_BAD_CALLING_ORDER CURLE_OBSOLETE44 +#define CURLE_FTP_USER_PASSWORD_INCORRECT CURLE_OBSOLETE10 +#define CURLE_FTP_CANT_RECONNECT CURLE_OBSOLETE16 +#define CURLE_FTP_COULDNT_GET_SIZE CURLE_OBSOLETE32 +#define CURLE_FTP_COULDNT_SET_ASCII CURLE_OBSOLETE29 +#define CURLE_FTP_WEIRD_USER_REPLY CURLE_OBSOLETE12 +#define CURLE_FTP_WRITE_ERROR CURLE_OBSOLETE20 +#define CURLE_LIBRARY_NOT_FOUND CURLE_OBSOLETE40 +#define CURLE_MALFORMAT_USER CURLE_OBSOLETE24 +#define CURLE_SHARE_IN_USE CURLE_OBSOLETE57 +#define CURLE_URL_MALFORMAT_USER CURLE_NOT_BUILT_IN + +#define CURLE_FTP_ACCESS_DENIED CURLE_REMOTE_ACCESS_DENIED +#define CURLE_FTP_COULDNT_SET_BINARY CURLE_FTP_COULDNT_SET_TYPE +#define CURLE_FTP_QUOTE_ERROR CURLE_QUOTE_ERROR +#define CURLE_TFTP_DISKFULL CURLE_REMOTE_DISK_FULL +#define CURLE_TFTP_EXISTS CURLE_REMOTE_FILE_EXISTS +#define CURLE_HTTP_RANGE_ERROR CURLE_RANGE_ERROR +#define CURLE_FTP_SSL_FAILED CURLE_USE_SSL_FAILED + +/* The following were added earlier */ + +#define CURLE_OPERATION_TIMEOUTED CURLE_OPERATION_TIMEDOUT + +#define CURLE_HTTP_NOT_FOUND CURLE_HTTP_RETURNED_ERROR +#define CURLE_HTTP_PORT_FAILED CURLE_INTERFACE_FAILED +#define CURLE_FTP_COULDNT_STOR_FILE CURLE_UPLOAD_FAILED + +#define CURLE_FTP_PARTIAL_FILE CURLE_PARTIAL_FILE +#define CURLE_FTP_BAD_DOWNLOAD_RESUME CURLE_BAD_DOWNLOAD_RESUME + +/* This was the error code 50 in 7.7.3 and a few earlier versions, this + is no longer used by libcurl but is instead #defined here only to not + make programs break */ +#define CURLE_ALREADY_COMPLETE 99999 + +/* Provide defines for really old option names */ +#define CURLOPT_FILE CURLOPT_WRITEDATA /* name changed in 7.9.7 */ +#define CURLOPT_INFILE CURLOPT_READDATA /* name changed in 7.9.7 */ +#define CURLOPT_WRITEHEADER CURLOPT_HEADERDATA + +/* Since long deprecated options with no code in the lib that does anything + with them. */ +#define CURLOPT_WRITEINFO CURLOPT_OBSOLETE40 +#define CURLOPT_CLOSEPOLICY CURLOPT_OBSOLETE72 + +#endif /*!CURL_NO_OLDIES*/ + +/* This prototype applies to all conversion callbacks */ +typedef CURLcode (*curl_conv_callback)(char *buffer, size_t length); + +typedef CURLcode (*curl_ssl_ctx_callback)(CURL *curl, /* easy handle */ + void *ssl_ctx, /* actually an + OpenSSL SSL_CTX */ + void *userptr); + +typedef enum { + CURLPROXY_HTTP = 0, /* added in 7.10, new in 7.19.4 default is to use + CONNECT HTTP/1.1 */ + CURLPROXY_HTTP_1_0 = 1, /* added in 7.19.4, force to use CONNECT + HTTP/1.0 */ + CURLPROXY_SOCKS4 = 4, /* support added in 7.15.2, enum existed already + in 7.10 */ + CURLPROXY_SOCKS5 = 5, /* added in 7.10 */ + CURLPROXY_SOCKS4A = 6, /* added in 7.18.0 */ + CURLPROXY_SOCKS5_HOSTNAME = 7 /* Use the SOCKS5 protocol but pass along the + host name rather than the IP address. added + in 7.18.0 */ +} curl_proxytype; /* this enum was added in 7.10 */ + +/* + * Bitmasks for CURLOPT_HTTPAUTH and CURLOPT_PROXYAUTH options: + * + * CURLAUTH_NONE - No HTTP authentication + * CURLAUTH_BASIC - HTTP Basic authentication (default) + * CURLAUTH_DIGEST - HTTP Digest authentication + * CURLAUTH_NEGOTIATE - HTTP Negotiate (SPNEGO) authentication + * CURLAUTH_GSSNEGOTIATE - Alias for CURLAUTH_NEGOTIATE (deprecated) + * CURLAUTH_NTLM - HTTP NTLM authentication + * CURLAUTH_DIGEST_IE - HTTP Digest authentication with IE flavour + * CURLAUTH_NTLM_WB - HTTP NTLM authentication delegated to winbind helper + * CURLAUTH_ONLY - Use together with a single other type to force no + * authentication or just that single type + * CURLAUTH_ANY - All fine types set + * CURLAUTH_ANYSAFE - All fine types except Basic + */ + +#define CURLAUTH_NONE ((unsigned long)0) +#define CURLAUTH_BASIC (((unsigned long)1)<<0) +#define CURLAUTH_DIGEST (((unsigned long)1)<<1) +#define CURLAUTH_NEGOTIATE (((unsigned long)1)<<2) +/* Deprecated since the advent of CURLAUTH_NEGOTIATE */ +#define CURLAUTH_GSSNEGOTIATE CURLAUTH_NEGOTIATE +#define CURLAUTH_NTLM (((unsigned long)1)<<3) +#define CURLAUTH_DIGEST_IE (((unsigned long)1)<<4) +#define CURLAUTH_NTLM_WB (((unsigned long)1)<<5) +#define CURLAUTH_ONLY (((unsigned long)1)<<31) +#define CURLAUTH_ANY (~CURLAUTH_DIGEST_IE) +#define CURLAUTH_ANYSAFE (~(CURLAUTH_BASIC|CURLAUTH_DIGEST_IE)) + +#define CURLSSH_AUTH_ANY ~0 /* all types supported by the server */ +#define CURLSSH_AUTH_NONE 0 /* none allowed, silly but complete */ +#define CURLSSH_AUTH_PUBLICKEY (1<<0) /* public/private key files */ +#define CURLSSH_AUTH_PASSWORD (1<<1) /* password */ +#define CURLSSH_AUTH_HOST (1<<2) /* host key files */ +#define CURLSSH_AUTH_KEYBOARD (1<<3) /* keyboard interactive */ +#define CURLSSH_AUTH_AGENT (1<<4) /* agent (ssh-agent, pageant...) */ +#define CURLSSH_AUTH_DEFAULT CURLSSH_AUTH_ANY + +#define CURLGSSAPI_DELEGATION_NONE 0 /* no delegation (default) */ +#define CURLGSSAPI_DELEGATION_POLICY_FLAG (1<<0) /* if permitted by policy */ +#define CURLGSSAPI_DELEGATION_FLAG (1<<1) /* delegate always */ + +#define CURL_ERROR_SIZE 256 + +enum curl_khtype { + CURLKHTYPE_UNKNOWN, + CURLKHTYPE_RSA1, + CURLKHTYPE_RSA, + CURLKHTYPE_DSS +}; + +struct curl_khkey { + const char *key; /* points to a zero-terminated string encoded with base64 + if len is zero, otherwise to the "raw" data */ + size_t len; + enum curl_khtype keytype; +}; + +/* this is the set of return values expected from the curl_sshkeycallback + callback */ +enum curl_khstat { + CURLKHSTAT_FINE_ADD_TO_FILE, + CURLKHSTAT_FINE, + CURLKHSTAT_REJECT, /* reject the connection, return an error */ + CURLKHSTAT_DEFER, /* do not accept it, but we can't answer right now so + this causes a CURLE_DEFER error but otherwise the + connection will be left intact etc */ + CURLKHSTAT_LAST /* not for use, only a marker for last-in-list */ +}; + +/* this is the set of status codes pass in to the callback */ +enum curl_khmatch { + CURLKHMATCH_OK, /* match */ + CURLKHMATCH_MISMATCH, /* host found, key mismatch! */ + CURLKHMATCH_MISSING, /* no matching host/key found */ + CURLKHMATCH_LAST /* not for use, only a marker for last-in-list */ +}; + +typedef int + (*curl_sshkeycallback) (CURL *easy, /* easy handle */ + const struct curl_khkey *knownkey, /* known */ + const struct curl_khkey *foundkey, /* found */ + enum curl_khmatch, /* libcurl's view on the keys */ + void *clientp); /* custom pointer passed from app */ + +/* parameter for the CURLOPT_USE_SSL option */ +typedef enum { + CURLUSESSL_NONE, /* do not attempt to use SSL */ + CURLUSESSL_TRY, /* try using SSL, proceed anyway otherwise */ + CURLUSESSL_CONTROL, /* SSL for the control connection or fail */ + CURLUSESSL_ALL, /* SSL for all communication or fail */ + CURLUSESSL_LAST /* not an option, never use */ +} curl_usessl; + +/* Definition of bits for the CURLOPT_SSL_OPTIONS argument: */ + +/* - ALLOW_BEAST tells libcurl to allow the BEAST SSL vulnerability in the + name of improving interoperability with older servers. Some SSL libraries + have introduced work-arounds for this flaw but those work-arounds sometimes + make the SSL communication fail. To regain functionality with those broken + servers, a user can this way allow the vulnerability back. */ +#define CURLSSLOPT_ALLOW_BEAST (1<<0) + ++/* - NO_REVOKE tells libcurl to disable certificate revocation checks for those ++ SSL backends where such behavior is present. */ ++#define CURLSSLOPT_NO_REVOKE (1<<1) ++ +#ifndef CURL_NO_OLDIES /* define this to test if your app builds with all + the obsolete stuff removed! */ + +/* Backwards compatibility with older names */ +/* These are scheduled to disappear by 2009 */ + +#define CURLFTPSSL_NONE CURLUSESSL_NONE +#define CURLFTPSSL_TRY CURLUSESSL_TRY +#define CURLFTPSSL_CONTROL CURLUSESSL_CONTROL +#define CURLFTPSSL_ALL CURLUSESSL_ALL +#define CURLFTPSSL_LAST CURLUSESSL_LAST +#define curl_ftpssl curl_usessl +#endif /*!CURL_NO_OLDIES*/ + +/* parameter for the CURLOPT_FTP_SSL_CCC option */ +typedef enum { + CURLFTPSSL_CCC_NONE, /* do not send CCC */ + CURLFTPSSL_CCC_PASSIVE, /* Let the server initiate the shutdown */ + CURLFTPSSL_CCC_ACTIVE, /* Initiate the shutdown */ + CURLFTPSSL_CCC_LAST /* not an option, never use */ +} curl_ftpccc; + +/* parameter for the CURLOPT_FTPSSLAUTH option */ +typedef enum { + CURLFTPAUTH_DEFAULT, /* let libcurl decide */ + CURLFTPAUTH_SSL, /* use "AUTH SSL" */ + CURLFTPAUTH_TLS, /* use "AUTH TLS" */ + CURLFTPAUTH_LAST /* not an option, never use */ +} curl_ftpauth; + +/* parameter for the CURLOPT_FTP_CREATE_MISSING_DIRS option */ +typedef enum { + CURLFTP_CREATE_DIR_NONE, /* do NOT create missing dirs! */ + CURLFTP_CREATE_DIR, /* (FTP/SFTP) if CWD fails, try MKD and then CWD + again if MKD succeeded, for SFTP this does + similar magic */ + CURLFTP_CREATE_DIR_RETRY, /* (FTP only) if CWD fails, try MKD and then CWD + again even if MKD failed! */ + CURLFTP_CREATE_DIR_LAST /* not an option, never use */ +} curl_ftpcreatedir; + +/* parameter for the CURLOPT_FTP_FILEMETHOD option */ +typedef enum { + CURLFTPMETHOD_DEFAULT, /* let libcurl pick */ + CURLFTPMETHOD_MULTICWD, /* single CWD operation for each path part */ + CURLFTPMETHOD_NOCWD, /* no CWD at all */ + CURLFTPMETHOD_SINGLECWD, /* one CWD to full dir, then work on file */ + CURLFTPMETHOD_LAST /* not an option, never use */ +} curl_ftpmethod; + +/* bitmask defines for CURLOPT_HEADEROPT */ +#define CURLHEADER_UNIFIED 0 +#define CURLHEADER_SEPARATE (1<<0) + +/* CURLPROTO_ defines are for the CURLOPT_*PROTOCOLS options */ +#define CURLPROTO_HTTP (1<<0) +#define CURLPROTO_HTTPS (1<<1) +#define CURLPROTO_FTP (1<<2) +#define CURLPROTO_FTPS (1<<3) +#define CURLPROTO_SCP (1<<4) +#define CURLPROTO_SFTP (1<<5) +#define CURLPROTO_TELNET (1<<6) +#define CURLPROTO_LDAP (1<<7) +#define CURLPROTO_LDAPS (1<<8) +#define CURLPROTO_DICT (1<<9) +#define CURLPROTO_FILE (1<<10) +#define CURLPROTO_TFTP (1<<11) +#define CURLPROTO_IMAP (1<<12) +#define CURLPROTO_IMAPS (1<<13) +#define CURLPROTO_POP3 (1<<14) +#define CURLPROTO_POP3S (1<<15) +#define CURLPROTO_SMTP (1<<16) +#define CURLPROTO_SMTPS (1<<17) +#define CURLPROTO_RTSP (1<<18) +#define CURLPROTO_RTMP (1<<19) +#define CURLPROTO_RTMPT (1<<20) +#define CURLPROTO_RTMPE (1<<21) +#define CURLPROTO_RTMPTE (1<<22) +#define CURLPROTO_RTMPS (1<<23) +#define CURLPROTO_RTMPTS (1<<24) +#define CURLPROTO_GOPHER (1<<25) ++#define CURLPROTO_SMB (1<<26) ++#define CURLPROTO_SMBS (1<<27) +#define CURLPROTO_ALL (~0) /* enable everything */ + +/* long may be 32 or 64 bits, but we should never depend on anything else + but 32 */ +#define CURLOPTTYPE_LONG 0 +#define CURLOPTTYPE_OBJECTPOINT 10000 +#define CURLOPTTYPE_FUNCTIONPOINT 20000 +#define CURLOPTTYPE_OFF_T 30000 + +/* name is uppercase CURLOPT_, + type is one of the defined CURLOPTTYPE_ + number is unique identifier */ +#ifdef CINIT +#undef CINIT +#endif + +#ifdef CURL_ISOCPP +#define CINIT(na,t,nu) CURLOPT_ ## na = CURLOPTTYPE_ ## t + nu +#else +/* The macro "##" is ISO C, we assume pre-ISO C doesn't support it. */ +#define LONG CURLOPTTYPE_LONG +#define OBJECTPOINT CURLOPTTYPE_OBJECTPOINT +#define FUNCTIONPOINT CURLOPTTYPE_FUNCTIONPOINT +#define OFF_T CURLOPTTYPE_OFF_T +#define CINIT(name,type,number) CURLOPT_/**/name = type + number +#endif + +/* + * This macro-mania below setups the CURLOPT_[what] enum, to be used with + * curl_easy_setopt(). The first argument in the CINIT() macro is the [what] + * word. + */ + +typedef enum { + /* This is the FILE * or void * the regular output should be written to. */ + CINIT(WRITEDATA, OBJECTPOINT, 1), + + /* The full URL to get/put */ - CINIT(URL, OBJECTPOINT, 2), ++ CINIT(URL, OBJECTPOINT, 2), + + /* Port number to connect to, if other than default. */ + CINIT(PORT, LONG, 3), + + /* Name of proxy to use. */ + CINIT(PROXY, OBJECTPOINT, 4), + + /* "user:password;options" to use when fetching. */ + CINIT(USERPWD, OBJECTPOINT, 5), + + /* "user:password" to use with proxy. */ + CINIT(PROXYUSERPWD, OBJECTPOINT, 6), + + /* Range to get, specified as an ASCII string. */ + CINIT(RANGE, OBJECTPOINT, 7), + + /* not used */ + + /* Specified file stream to upload from (use as input): */ + CINIT(READDATA, OBJECTPOINT, 9), + + /* Buffer to receive error messages in, must be at least CURL_ERROR_SIZE + * bytes big. If this is not used, error messages go to stderr instead: */ + CINIT(ERRORBUFFER, OBJECTPOINT, 10), + + /* Function that will be called to store the output (instead of fwrite). The + * parameters will use fwrite() syntax, make sure to follow them. */ + CINIT(WRITEFUNCTION, FUNCTIONPOINT, 11), + + /* Function that will be called to read the input (instead of fread). The + * parameters will use fread() syntax, make sure to follow them. */ + CINIT(READFUNCTION, FUNCTIONPOINT, 12), + + /* Time-out the read operation after this amount of seconds */ + CINIT(TIMEOUT, LONG, 13), + + /* If the CURLOPT_INFILE is used, this can be used to inform libcurl about + * how large the file being sent really is. That allows better error + * checking and better verifies that the upload was successful. -1 means + * unknown size. + * + * For large file support, there is also a _LARGE version of the key + * which takes an off_t type, allowing platforms with larger off_t + * sizes to handle larger files. See below for INFILESIZE_LARGE. + */ + CINIT(INFILESIZE, LONG, 14), + + /* POST static input fields. */ + CINIT(POSTFIELDS, OBJECTPOINT, 15), + + /* Set the referrer page (needed by some CGIs) */ + CINIT(REFERER, OBJECTPOINT, 16), + + /* Set the FTP PORT string (interface name, named or numerical IP address) + Use i.e '-' to use default address. */ + CINIT(FTPPORT, OBJECTPOINT, 17), + + /* Set the User-Agent string (examined by some CGIs) */ + CINIT(USERAGENT, OBJECTPOINT, 18), + + /* If the download receives less than "low speed limit" bytes/second + * during "low speed time" seconds, the operations is aborted. + * You could i.e if you have a pretty high speed connection, abort if + * it is less than 2000 bytes/sec during 20 seconds. + */ + + /* Set the "low speed limit" */ + CINIT(LOW_SPEED_LIMIT, LONG, 19), + + /* Set the "low speed time" */ + CINIT(LOW_SPEED_TIME, LONG, 20), + + /* Set the continuation offset. + * + * Note there is also a _LARGE version of this key which uses + * off_t types, allowing for large file offsets on platforms which + * use larger-than-32-bit off_t's. Look below for RESUME_FROM_LARGE. + */ + CINIT(RESUME_FROM, LONG, 21), + + /* Set cookie in request: */ + CINIT(COOKIE, OBJECTPOINT, 22), + + /* This points to a linked list of headers, struct curl_slist kind. This + list is also used for RTSP (in spite of its name) */ + CINIT(HTTPHEADER, OBJECTPOINT, 23), + + /* This points to a linked list of post entries, struct curl_httppost */ + CINIT(HTTPPOST, OBJECTPOINT, 24), + + /* name of the file keeping your private SSL-certificate */ + CINIT(SSLCERT, OBJECTPOINT, 25), + + /* password for the SSL or SSH private key */ + CINIT(KEYPASSWD, OBJECTPOINT, 26), + + /* send TYPE parameter? */ + CINIT(CRLF, LONG, 27), + + /* send linked-list of QUOTE commands */ + CINIT(QUOTE, OBJECTPOINT, 28), + + /* send FILE * or void * to store headers to, if you use a callback it + is simply passed to the callback unmodified */ + CINIT(HEADERDATA, OBJECTPOINT, 29), + + /* point to a file to read the initial cookies from, also enables + "cookie awareness" */ + CINIT(COOKIEFILE, OBJECTPOINT, 31), + + /* What version to specifically try to use. + See CURL_SSLVERSION defines below. */ + CINIT(SSLVERSION, LONG, 32), + + /* What kind of HTTP time condition to use, see defines */ + CINIT(TIMECONDITION, LONG, 33), + + /* Time to use with the above condition. Specified in number of seconds + since 1 Jan 1970 */ + CINIT(TIMEVALUE, LONG, 34), + + /* 35 = OBSOLETE */ + + /* Custom request, for customizing the get command like + HTTP: DELETE, TRACE and others + FTP: to use a different list command + */ + CINIT(CUSTOMREQUEST, OBJECTPOINT, 36), + + /* HTTP request, for odd commands like DELETE, TRACE and others */ + CINIT(STDERR, OBJECTPOINT, 37), + + /* 38 is not used */ + + /* send linked-list of post-transfer QUOTE commands */ + CINIT(POSTQUOTE, OBJECTPOINT, 39), + + CINIT(OBSOLETE40, OBJECTPOINT, 40), /* OBSOLETE, do not use! */ + + CINIT(VERBOSE, LONG, 41), /* talk a lot */ + CINIT(HEADER, LONG, 42), /* throw the header out too */ + CINIT(NOPROGRESS, LONG, 43), /* shut off the progress meter */ + CINIT(NOBODY, LONG, 44), /* use HEAD to get http document */ - CINIT(FAILONERROR, LONG, 45), /* no output on http error codes >= 300 */ ++ CINIT(FAILONERROR, LONG, 45), /* no output on http error codes >= 400 */ + CINIT(UPLOAD, LONG, 46), /* this is an upload */ + CINIT(POST, LONG, 47), /* HTTP POST method */ + CINIT(DIRLISTONLY, LONG, 48), /* bare names when listing directories */ + + CINIT(APPEND, LONG, 50), /* Append instead of overwrite on upload! */ + + /* Specify whether to read the user+password from the .netrc or the URL. + * This must be one of the CURL_NETRC_* enums below. */ + CINIT(NETRC, LONG, 51), + + CINIT(FOLLOWLOCATION, LONG, 52), /* use Location: Luke! */ + + CINIT(TRANSFERTEXT, LONG, 53), /* transfer data in text/ASCII format */ + CINIT(PUT, LONG, 54), /* HTTP PUT */ + + /* 55 = OBSOLETE */ + + /* DEPRECATED + * Function that will be called instead of the internal progress display + * function. This function should be defined as the curl_progress_callback + * prototype defines. */ + CINIT(PROGRESSFUNCTION, FUNCTIONPOINT, 56), + + /* Data passed to the CURLOPT_PROGRESSFUNCTION and CURLOPT_XFERINFOFUNCTION + callbacks */ + CINIT(PROGRESSDATA, OBJECTPOINT, 57), +#define CURLOPT_XFERINFODATA CURLOPT_PROGRESSDATA + + /* We want the referrer field set automatically when following locations */ + CINIT(AUTOREFERER, LONG, 58), + + /* Port of the proxy, can be set in the proxy string as well with: + "[host]:[port]" */ + CINIT(PROXYPORT, LONG, 59), + + /* size of the POST input data, if strlen() is not good to use */ + CINIT(POSTFIELDSIZE, LONG, 60), + + /* tunnel non-http operations through a HTTP proxy */ + CINIT(HTTPPROXYTUNNEL, LONG, 61), + + /* Set the interface string to use as outgoing network interface */ + CINIT(INTERFACE, OBJECTPOINT, 62), + + /* Set the krb4/5 security level, this also enables krb4/5 awareness. This + * is a string, 'clear', 'safe', 'confidential' or 'private'. If the string + * is set but doesn't match one of these, 'private' will be used. */ + CINIT(KRBLEVEL, OBJECTPOINT, 63), + + /* Set if we should verify the peer in ssl handshake, set 1 to verify. */ + CINIT(SSL_VERIFYPEER, LONG, 64), + + /* The CApath or CAfile used to validate the peer certificate + this option is used only if SSL_VERIFYPEER is true */ + CINIT(CAINFO, OBJECTPOINT, 65), + + /* 66 = OBSOLETE */ + /* 67 = OBSOLETE */ + + /* Maximum number of http redirects to follow */ + CINIT(MAXREDIRS, LONG, 68), + + /* Pass a long set to 1 to get the date of the requested document (if + possible)! Pass a zero to shut it off. */ + CINIT(FILETIME, LONG, 69), + + /* This points to a linked list of telnet options */ + CINIT(TELNETOPTIONS, OBJECTPOINT, 70), + + /* Max amount of cached alive connections */ + CINIT(MAXCONNECTS, LONG, 71), + + CINIT(OBSOLETE72, LONG, 72), /* OBSOLETE, do not use! */ + + /* 73 = OBSOLETE */ + + /* Set to explicitly use a new connection for the upcoming transfer. + Do not use this unless you're absolutely sure of this, as it makes the + operation slower and is less friendly for the network. */ + CINIT(FRESH_CONNECT, LONG, 74), + + /* Set to explicitly forbid the upcoming transfer's connection to be re-used + when done. Do not use this unless you're absolutely sure of this, as it + makes the operation slower and is less friendly for the network. */ + CINIT(FORBID_REUSE, LONG, 75), + + /* Set to a file name that contains random data for libcurl to use to + seed the random engine when doing SSL connects. */ + CINIT(RANDOM_FILE, OBJECTPOINT, 76), + + /* Set to the Entropy Gathering Daemon socket pathname */ + CINIT(EGDSOCKET, OBJECTPOINT, 77), + + /* Time-out connect operations after this amount of seconds, if connects are + OK within this time, then fine... This only aborts the connect phase. */ + CINIT(CONNECTTIMEOUT, LONG, 78), + + /* Function that will be called to store headers (instead of fwrite). The + * parameters will use fwrite() syntax, make sure to follow them. */ + CINIT(HEADERFUNCTION, FUNCTIONPOINT, 79), + + /* Set this to force the HTTP request to get back to GET. Only really usable + if POST, PUT or a custom request have been used first. + */ + CINIT(HTTPGET, LONG, 80), + + /* Set if we should verify the Common name from the peer certificate in ssl + * handshake, set 1 to check existence, 2 to ensure that it matches the + * provided hostname. */ + CINIT(SSL_VERIFYHOST, LONG, 81), + + /* Specify which file name to write all known cookies in after completed + operation. Set file name to "-" (dash) to make it go to stdout. */ + CINIT(COOKIEJAR, OBJECTPOINT, 82), + + /* Specify which SSL ciphers to use */ + CINIT(SSL_CIPHER_LIST, OBJECTPOINT, 83), + + /* Specify which HTTP version to use! This must be set to one of the + CURL_HTTP_VERSION* enums set below. */ + CINIT(HTTP_VERSION, LONG, 84), + + /* Specifically switch on or off the FTP engine's use of the EPSV command. By + default, that one will always be attempted before the more traditional + PASV command. */ + CINIT(FTP_USE_EPSV, LONG, 85), + + /* type of the file keeping your SSL-certificate ("DER", "PEM", "ENG") */ + CINIT(SSLCERTTYPE, OBJECTPOINT, 86), + + /* name of the file keeping your private SSL-key */ + CINIT(SSLKEY, OBJECTPOINT, 87), + + /* type of the file keeping your private SSL-key ("DER", "PEM", "ENG") */ + CINIT(SSLKEYTYPE, OBJECTPOINT, 88), + + /* crypto engine for the SSL-sub system */ + CINIT(SSLENGINE, OBJECTPOINT, 89), + + /* set the crypto engine for the SSL-sub system as default + the param has no meaning... + */ + CINIT(SSLENGINE_DEFAULT, LONG, 90), + + /* Non-zero value means to use the global dns cache */ + CINIT(DNS_USE_GLOBAL_CACHE, LONG, 91), /* DEPRECATED, do not use! */ + + /* DNS cache timeout */ + CINIT(DNS_CACHE_TIMEOUT, LONG, 92), + + /* send linked-list of pre-transfer QUOTE commands */ + CINIT(PREQUOTE, OBJECTPOINT, 93), + + /* set the debug function */ + CINIT(DEBUGFUNCTION, FUNCTIONPOINT, 94), + + /* set the data for the debug function */ + CINIT(DEBUGDATA, OBJECTPOINT, 95), + + /* mark this as start of a cookie session */ + CINIT(COOKIESESSION, LONG, 96), + + /* The CApath directory used to validate the peer certificate + this option is used only if SSL_VERIFYPEER is true */ + CINIT(CAPATH, OBJECTPOINT, 97), + + /* Instruct libcurl to use a smaller receive buffer */ + CINIT(BUFFERSIZE, LONG, 98), + + /* Instruct libcurl to not use any signal/alarm handlers, even when using + timeouts. This option is useful for multi-threaded applications. + See libcurl-the-guide for more background information. */ + CINIT(NOSIGNAL, LONG, 99), + + /* Provide a CURLShare for mutexing non-ts data */ + CINIT(SHARE, OBJECTPOINT, 100), + + /* indicates type of proxy. accepted values are CURLPROXY_HTTP (default), + CURLPROXY_SOCKS4, CURLPROXY_SOCKS4A and CURLPROXY_SOCKS5. */ + CINIT(PROXYTYPE, LONG, 101), + + /* Set the Accept-Encoding string. Use this to tell a server you would like + the response to be compressed. Before 7.21.6, this was known as + CURLOPT_ENCODING */ + CINIT(ACCEPT_ENCODING, OBJECTPOINT, 102), + + /* Set pointer to private data */ + CINIT(PRIVATE, OBJECTPOINT, 103), + + /* Set aliases for HTTP 200 in the HTTP Response header */ + CINIT(HTTP200ALIASES, OBJECTPOINT, 104), + + /* Continue to send authentication (user+password) when following locations, + even when hostname changed. This can potentially send off the name + and password to whatever host the server decides. */ + CINIT(UNRESTRICTED_AUTH, LONG, 105), + + /* Specifically switch on or off the FTP engine's use of the EPRT command ( + it also disables the LPRT attempt). By default, those ones will always be + attempted before the good old traditional PORT command. */ + CINIT(FTP_USE_EPRT, LONG, 106), + + /* Set this to a bitmask value to enable the particular authentications + methods you like. Use this in combination with CURLOPT_USERPWD. + Note that setting multiple bits may cause extra network round-trips. */ + CINIT(HTTPAUTH, LONG, 107), + + /* Set the ssl context callback function, currently only for OpenSSL ssl_ctx + in second argument. The function must be matching the + curl_ssl_ctx_callback proto. */ + CINIT(SSL_CTX_FUNCTION, FUNCTIONPOINT, 108), + + /* Set the userdata for the ssl context callback function's third + argument */ + CINIT(SSL_CTX_DATA, OBJECTPOINT, 109), + + /* FTP Option that causes missing dirs to be created on the remote server. + In 7.19.4 we introduced the convenience enums for this option using the + CURLFTP_CREATE_DIR prefix. + */ + CINIT(FTP_CREATE_MISSING_DIRS, LONG, 110), + + /* Set this to a bitmask value to enable the particular authentications + methods you like. Use this in combination with CURLOPT_PROXYUSERPWD. + Note that setting multiple bits may cause extra network round-trips. */ + CINIT(PROXYAUTH, LONG, 111), + + /* FTP option that changes the timeout, in seconds, associated with + getting a response. This is different from transfer timeout time and + essentially places a demand on the FTP server to acknowledge commands + in a timely manner. */ + CINIT(FTP_RESPONSE_TIMEOUT, LONG, 112), +#define CURLOPT_SERVER_RESPONSE_TIMEOUT CURLOPT_FTP_RESPONSE_TIMEOUT + + /* Set this option to one of the CURL_IPRESOLVE_* defines (see below) to + tell libcurl to resolve names to those IP versions only. This only has + affect on systems with support for more than one, i.e IPv4 _and_ IPv6. */ + CINIT(IPRESOLVE, LONG, 113), + + /* Set this option to limit the size of a file that will be downloaded from + an HTTP or FTP server. + + Note there is also _LARGE version which adds large file support for + platforms which have larger off_t sizes. See MAXFILESIZE_LARGE below. */ + CINIT(MAXFILESIZE, LONG, 114), + + /* See the comment for INFILESIZE above, but in short, specifies + * the size of the file being uploaded. -1 means unknown. + */ + CINIT(INFILESIZE_LARGE, OFF_T, 115), + + /* Sets the continuation offset. There is also a LONG version of this; + * look above for RESUME_FROM. + */ + CINIT(RESUME_FROM_LARGE, OFF_T, 116), + + /* Sets the maximum size of data that will be downloaded from + * an HTTP or FTP server. See MAXFILESIZE above for the LONG version. + */ + CINIT(MAXFILESIZE_LARGE, OFF_T, 117), + + /* Set this option to the file name of your .netrc file you want libcurl + to parse (using the CURLOPT_NETRC option). If not set, libcurl will do + a poor attempt to find the user's home directory and check for a .netrc + file in there. */ + CINIT(NETRC_FILE, OBJECTPOINT, 118), + + /* Enable SSL/TLS for FTP, pick one of: + CURLUSESSL_TRY - try using SSL, proceed anyway otherwise + CURLUSESSL_CONTROL - SSL for the control connection or fail + CURLUSESSL_ALL - SSL for all communication or fail + */ + CINIT(USE_SSL, LONG, 119), + + /* The _LARGE version of the standard POSTFIELDSIZE option */ + CINIT(POSTFIELDSIZE_LARGE, OFF_T, 120), + + /* Enable/disable the TCP Nagle algorithm */ + CINIT(TCP_NODELAY, LONG, 121), + + /* 122 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */ + /* 123 OBSOLETE. Gone in 7.16.0 */ + /* 124 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */ + /* 125 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */ + /* 126 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */ + /* 127 OBSOLETE. Gone in 7.16.0 */ + /* 128 OBSOLETE. Gone in 7.16.0 */ + + /* When FTP over SSL/TLS is selected (with CURLOPT_USE_SSL), this option + can be used to change libcurl's default action which is to first try + "AUTH SSL" and then "AUTH TLS" in this order, and proceed when a OK + response has been received. + + Available parameters are: + CURLFTPAUTH_DEFAULT - let libcurl decide + CURLFTPAUTH_SSL - try "AUTH SSL" first, then TLS + CURLFTPAUTH_TLS - try "AUTH TLS" first, then SSL + */ + CINIT(FTPSSLAUTH, LONG, 129), + + CINIT(IOCTLFUNCTION, FUNCTIONPOINT, 130), + CINIT(IOCTLDATA, OBJECTPOINT, 131), + + /* 132 OBSOLETE. Gone in 7.16.0 */ + /* 133 OBSOLETE. Gone in 7.16.0 */ + + /* zero terminated string for pass on to the FTP server when asked for + "account" info */ + CINIT(FTP_ACCOUNT, OBJECTPOINT, 134), + + /* feed cookies into cookie engine */ + CINIT(COOKIELIST, OBJECTPOINT, 135), + + /* ignore Content-Length */ + CINIT(IGNORE_CONTENT_LENGTH, LONG, 136), + + /* Set to non-zero to skip the IP address received in a 227 PASV FTP server + response. Typically used for FTP-SSL purposes but is not restricted to + that. libcurl will then instead use the same IP address it used for the + control connection. */ + CINIT(FTP_SKIP_PASV_IP, LONG, 137), + + /* Select "file method" to use when doing FTP, see the curl_ftpmethod + above. */ + CINIT(FTP_FILEMETHOD, LONG, 138), + + /* Local port number to bind the socket to */ + CINIT(LOCALPORT, LONG, 139), + + /* Number of ports to try, including the first one set with LOCALPORT. + Thus, setting it to 1 will make no additional attempts but the first. + */ + CINIT(LOCALPORTRANGE, LONG, 140), + + /* no transfer, set up connection and let application use the socket by + extracting it with CURLINFO_LASTSOCKET */ + CINIT(CONNECT_ONLY, LONG, 141), + + /* Function that will be called to convert from the + network encoding (instead of using the iconv calls in libcurl) */ + CINIT(CONV_FROM_NETWORK_FUNCTION, FUNCTIONPOINT, 142), + + /* Function that will be called to convert to the + network encoding (instead of using the iconv calls in libcurl) */ + CINIT(CONV_TO_NETWORK_FUNCTION, FUNCTIONPOINT, 143), + + /* Function that will be called to convert from UTF8 + (instead of using the iconv calls in libcurl) + Note that this is used only for SSL certificate processing */ + CINIT(CONV_FROM_UTF8_FUNCTION, FUNCTIONPOINT, 144), + + /* if the connection proceeds too quickly then need to slow it down */ + /* limit-rate: maximum number of bytes per second to send or receive */ + CINIT(MAX_SEND_SPEED_LARGE, OFF_T, 145), + CINIT(MAX_RECV_SPEED_LARGE, OFF_T, 146), + + /* Pointer to command string to send if USER/PASS fails. */ + CINIT(FTP_ALTERNATIVE_TO_USER, OBJECTPOINT, 147), + + /* callback function for setting socket options */ + CINIT(SOCKOPTFUNCTION, FUNCTIONPOINT, 148), + CINIT(SOCKOPTDATA, OBJECTPOINT, 149), + + /* set to 0 to disable session ID re-use for this transfer, default is + enabled (== 1) */ + CINIT(SSL_SESSIONID_CACHE, LONG, 150), + + /* allowed SSH authentication methods */ + CINIT(SSH_AUTH_TYPES, LONG, 151), + + /* Used by scp/sftp to do public/private key authentication */ + CINIT(SSH_PUBLIC_KEYFILE, OBJECTPOINT, 152), + CINIT(SSH_PRIVATE_KEYFILE, OBJECTPOINT, 153), + + /* Send CCC (Clear Command Channel) after authentication */ + CINIT(FTP_SSL_CCC, LONG, 154), + + /* Same as TIMEOUT and CONNECTTIMEOUT, but with ms resolution */ + CINIT(TIMEOUT_MS, LONG, 155), + CINIT(CONNECTTIMEOUT_MS, LONG, 156), + + /* set to zero to disable the libcurl's decoding and thus pass the raw body + data to the application even when it is encoded/compressed */ + CINIT(HTTP_TRANSFER_DECODING, LONG, 157), + CINIT(HTTP_CONTENT_DECODING, LONG, 158), + + /* Permission used when creating new files and directories on the remote + server for protocols that support it, SFTP/SCP/FILE */ + CINIT(NEW_FILE_PERMS, LONG, 159), + CINIT(NEW_DIRECTORY_PERMS, LONG, 160), + + /* Set the behaviour of POST when redirecting. Values must be set to one + of CURL_REDIR* defines below. This used to be called CURLOPT_POST301 */ + CINIT(POSTREDIR, LONG, 161), + + /* used by scp/sftp to verify the host's public key */ + CINIT(SSH_HOST_PUBLIC_KEY_MD5, OBJECTPOINT, 162), + + /* Callback function for opening socket (instead of socket(2)). Optionally, + callback is able change the address or refuse to connect returning + CURL_SOCKET_BAD. The callback should have type + curl_opensocket_callback */ + CINIT(OPENSOCKETFUNCTION, FUNCTIONPOINT, 163), + CINIT(OPENSOCKETDATA, OBJECTPOINT, 164), + + /* POST volatile input fields. */ + CINIT(COPYPOSTFIELDS, OBJECTPOINT, 165), + + /* set transfer mode (;type=) when doing FTP via an HTTP proxy */ + CINIT(PROXY_TRANSFER_MODE, LONG, 166), + + /* Callback function for seeking in the input stream */ + CINIT(SEEKFUNCTION, FUNCTIONPOINT, 167), + CINIT(SEEKDATA, OBJECTPOINT, 168), + + /* CRL file */ + CINIT(CRLFILE, OBJECTPOINT, 169), + + /* Issuer certificate */ + CINIT(ISSUERCERT, OBJECTPOINT, 170), + + /* (IPv6) Address scope */ + CINIT(ADDRESS_SCOPE, LONG, 171), + + /* Collect certificate chain info and allow it to get retrievable with + CURLINFO_CERTINFO after the transfer is complete. */ + CINIT(CERTINFO, LONG, 172), + + /* "name" and "pwd" to use when fetching. */ + CINIT(USERNAME, OBJECTPOINT, 173), + CINIT(PASSWORD, OBJECTPOINT, 174), + + /* "name" and "pwd" to use with Proxy when fetching. */ + CINIT(PROXYUSERNAME, OBJECTPOINT, 175), + CINIT(PROXYPASSWORD, OBJECTPOINT, 176), + + /* Comma separated list of hostnames defining no-proxy zones. These should + match both hostnames directly, and hostnames within a domain. For + example, local.com will match local.com and www.local.com, but NOT + notlocal.com or www.notlocal.com. For compatibility with other + implementations of this, .local.com will be considered to be the same as + local.com. A single * is the only valid wildcard, and effectively + disables the use of proxy. */ + CINIT(NOPROXY, OBJECTPOINT, 177), + + /* block size for TFTP transfers */ + CINIT(TFTP_BLKSIZE, LONG, 178), + + /* Socks Service */ + CINIT(SOCKS5_GSSAPI_SERVICE, OBJECTPOINT, 179), + + /* Socks Service */ + CINIT(SOCKS5_GSSAPI_NEC, LONG, 180), + + /* set the bitmask for the protocols that are allowed to be used for the + transfer, which thus helps the app which takes URLs from users or other + external inputs and want to restrict what protocol(s) to deal + with. Defaults to CURLPROTO_ALL. */ + CINIT(PROTOCOLS, LONG, 181), + + /* set the bitmask for the protocols that libcurl is allowed to follow to, + as a subset of the CURLOPT_PROTOCOLS ones. That means the protocol needs + to be set in both bitmasks to be allowed to get redirected to. Defaults + to all protocols except FILE and SCP. */ + CINIT(REDIR_PROTOCOLS, LONG, 182), + + /* set the SSH knownhost file name to use */ + CINIT(SSH_KNOWNHOSTS, OBJECTPOINT, 183), + + /* set the SSH host key callback, must point to a curl_sshkeycallback + function */ + CINIT(SSH_KEYFUNCTION, FUNCTIONPOINT, 184), + + /* set the SSH host key callback custom pointer */ + CINIT(SSH_KEYDATA, OBJECTPOINT, 185), + + /* set the SMTP mail originator */ + CINIT(MAIL_FROM, OBJECTPOINT, 186), + + /* set the SMTP mail receiver(s) */ + CINIT(MAIL_RCPT, OBJECTPOINT, 187), + + /* FTP: send PRET before PASV */ + CINIT(FTP_USE_PRET, LONG, 188), + + /* RTSP request method (OPTIONS, SETUP, PLAY, etc...) */ + CINIT(RTSP_REQUEST, LONG, 189), + + /* The RTSP session identifier */ + CINIT(RTSP_SESSION_ID, OBJECTPOINT, 190), + + /* The RTSP stream URI */ + CINIT(RTSP_STREAM_URI, OBJECTPOINT, 191), + + /* The Transport: header to use in RTSP requests */ + CINIT(RTSP_TRANSPORT, OBJECTPOINT, 192), + + /* Manually initialize the client RTSP CSeq for this handle */ + CINIT(RTSP_CLIENT_CSEQ, LONG, 193), + + /* Manually initialize the server RTSP CSeq for this handle */ + CINIT(RTSP_SERVER_CSEQ, LONG, 194), + + /* The stream to pass to INTERLEAVEFUNCTION. */ + CINIT(INTERLEAVEDATA, OBJECTPOINT, 195), + + /* Let the application define a custom write method for RTP data */ + CINIT(INTERLEAVEFUNCTION, FUNCTIONPOINT, 196), + + /* Turn on wildcard matching */ + CINIT(WILDCARDMATCH, LONG, 197), + + /* Directory matching callback called before downloading of an + individual file (chunk) started */ + CINIT(CHUNK_BGN_FUNCTION, FUNCTIONPOINT, 198), + + /* Directory matching callback called after the file (chunk) + was downloaded, or skipped */ + CINIT(CHUNK_END_FUNCTION, FUNCTIONPOINT, 199), + + /* Change match (fnmatch-like) callback for wildcard matching */ + CINIT(FNMATCH_FUNCTION, FUNCTIONPOINT, 200), + + /* Let the application define custom chunk data pointer */ + CINIT(CHUNK_DATA, OBJECTPOINT, 201), + + /* FNMATCH_FUNCTION user pointer */ + CINIT(FNMATCH_DATA, OBJECTPOINT, 202), + + /* send linked-list of name:port:address sets */ + CINIT(RESOLVE, OBJECTPOINT, 203), + + /* Set a username for authenticated TLS */ + CINIT(TLSAUTH_USERNAME, OBJECTPOINT, 204), + + /* Set a password for authenticated TLS */ + CINIT(TLSAUTH_PASSWORD, OBJECTPOINT, 205), + + /* Set authentication type for authenticated TLS */ + CINIT(TLSAUTH_TYPE, OBJECTPOINT, 206), + + /* Set to 1 to enable the "TE:" header in HTTP requests to ask for + compressed transfer-encoded responses. Set to 0 to disable the use of TE: + in outgoing requests. The current default is 0, but it might change in a + future libcurl release. + + libcurl will ask for the compressed methods it knows of, and if that + isn't any, it will not ask for transfer-encoding at all even if this + option is set to 1. + + */ + CINIT(TRANSFER_ENCODING, LONG, 207), + + /* Callback function for closing socket (instead of close(2)). The callback + should have type curl_closesocket_callback */ + CINIT(CLOSESOCKETFUNCTION, FUNCTIONPOINT, 208), + CINIT(CLOSESOCKETDATA, OBJECTPOINT, 209), + + /* allow GSSAPI credential delegation */ + CINIT(GSSAPI_DELEGATION, LONG, 210), + + /* Set the name servers to use for DNS resolution */ + CINIT(DNS_SERVERS, OBJECTPOINT, 211), + + /* Time-out accept operations (currently for FTP only) after this amount + of miliseconds. */ + CINIT(ACCEPTTIMEOUT_MS, LONG, 212), + + /* Set TCP keepalive */ + CINIT(TCP_KEEPALIVE, LONG, 213), + + /* non-universal keepalive knobs (Linux, AIX, HP-UX, more) */ + CINIT(TCP_KEEPIDLE, LONG, 214), + CINIT(TCP_KEEPINTVL, LONG, 215), + + /* Enable/disable specific SSL features with a bitmask, see CURLSSLOPT_* */ + CINIT(SSL_OPTIONS, LONG, 216), + + /* Set the SMTP auth originator */ + CINIT(MAIL_AUTH, OBJECTPOINT, 217), + + /* Enable/disable SASL initial response */ + CINIT(SASL_IR, LONG, 218), + + /* Function that will be called instead of the internal progress display + * function. This function should be defined as the curl_xferinfo_callback + * prototype defines. (Deprecates CURLOPT_PROGRESSFUNCTION) */ + CINIT(XFERINFOFUNCTION, FUNCTIONPOINT, 219), + + /* The XOAUTH2 bearer token */ + CINIT(XOAUTH2_BEARER, OBJECTPOINT, 220), + + /* Set the interface string to use as outgoing network + * interface for DNS requests. + * Only supported by the c-ares DNS backend */ + CINIT(DNS_INTERFACE, OBJECTPOINT, 221), + + /* Set the local IPv4 address to use for outgoing DNS requests. + * Only supported by the c-ares DNS backend */ + CINIT(DNS_LOCAL_IP4, OBJECTPOINT, 222), + + /* Set the local IPv4 address to use for outgoing DNS requests. + * Only supported by the c-ares DNS backend */ + CINIT(DNS_LOCAL_IP6, OBJECTPOINT, 223), + + /* Set authentication options directly */ + CINIT(LOGIN_OPTIONS, OBJECTPOINT, 224), + + /* Enable/disable TLS NPN extension (http2 over ssl might fail without) */ + CINIT(SSL_ENABLE_NPN, LONG, 225), + + /* Enable/disable TLS ALPN extension (http2 over ssl might fail without) */ + CINIT(SSL_ENABLE_ALPN, LONG, 226), + + /* Time to wait for a response to a HTTP request containing an + * Expect: 100-continue header before sending the data anyway. */ + CINIT(EXPECT_100_TIMEOUT_MS, LONG, 227), + + /* This points to a linked list of headers used for proxy requests only, + struct curl_slist kind */ + CINIT(PROXYHEADER, OBJECTPOINT, 228), + + /* Pass in a bitmask of "header options" */ + CINIT(HEADEROPT, LONG, 229), + ++ /* The public key in DER form used to validate the peer public key ++ this option is used only if SSL_VERIFYPEER is true */ ++ CINIT(PINNEDPUBLICKEY, OBJECTPOINT, 230), ++ ++ /* Path to Unix domain socket */ ++ CINIT(UNIX_SOCKET_PATH, OBJECTPOINT, 231), ++ ++ /* Set if we should verify the certificate status. */ ++ CINIT(SSL_VERIFYSTATUS, LONG, 232), ++ ++ /* Set if we should enable TLS false start. */ ++ CINIT(SSL_FALSESTART, LONG, 233), ++ ++ /* Do not squash dot-dot sequences */ ++ CINIT(PATH_AS_IS, LONG, 234), ++ ++ /* Proxy Service Name */ ++ CINIT(PROXY_SERVICE_NAME, OBJECTPOINT, 235), ++ ++ /* Service Name */ ++ CINIT(SERVICE_NAME, OBJECTPOINT, 236), ++ ++ /* Wait/don't wait for pipe/mutex to clarify */ ++ CINIT(PIPEWAIT, LONG, 237), ++ + CURLOPT_LASTENTRY /* the last unused */ +} CURLoption; + +#ifndef CURL_NO_OLDIES /* define this to test if your app builds with all + the obsolete stuff removed! */ + +/* Backwards compatibility with older names */ +/* These are scheduled to disappear by 2011 */ + +/* This was added in version 7.19.1 */ +#define CURLOPT_POST301 CURLOPT_POSTREDIR + +/* These are scheduled to disappear by 2009 */ + +/* The following were added in 7.17.0 */ +#define CURLOPT_SSLKEYPASSWD CURLOPT_KEYPASSWD +#define CURLOPT_FTPAPPEND CURLOPT_APPEND +#define CURLOPT_FTPLISTONLY CURLOPT_DIRLISTONLY +#define CURLOPT_FTP_SSL CURLOPT_USE_SSL + +/* The following were added earlier */ + +#define CURLOPT_SSLCERTPASSWD CURLOPT_KEYPASSWD +#define CURLOPT_KRB4LEVEL CURLOPT_KRBLEVEL + +#else +/* This is set if CURL_NO_OLDIES is defined at compile-time */ +#undef CURLOPT_DNS_USE_GLOBAL_CACHE /* soon obsolete */ +#endif + + + /* Below here follows defines for the CURLOPT_IPRESOLVE option. If a host + name resolves addresses using more than one IP protocol version, this + option might be handy to force libcurl to use a specific IP version. */ +#define CURL_IPRESOLVE_WHATEVER 0 /* default, resolves addresses to all IP + versions that your system allows */ - #define CURL_IPRESOLVE_V4 1 /* resolve to ipv4 addresses */ - #define CURL_IPRESOLVE_V6 2 /* resolve to ipv6 addresses */ ++#define CURL_IPRESOLVE_V4 1 /* resolve to IPv4 addresses */ ++#define CURL_IPRESOLVE_V6 2 /* resolve to IPv6 addresses */ + + /* three convenient "aliases" that follow the name scheme better */ +#define CURLOPT_RTSPHEADER CURLOPT_HTTPHEADER + + /* These enums are for use with the CURLOPT_HTTP_VERSION option. */ +enum { + CURL_HTTP_VERSION_NONE, /* setting this means we don't care, and that we'd + like the library to choose the best possible + for us! */ + CURL_HTTP_VERSION_1_0, /* please use HTTP 1.0 in the request */ + CURL_HTTP_VERSION_1_1, /* please use HTTP 1.1 in the request */ + CURL_HTTP_VERSION_2_0, /* please use HTTP 2.0 in the request */ + + CURL_HTTP_VERSION_LAST /* *ILLEGAL* http version */ +}; + ++/* Convenience definition simple because the name of the version is HTTP/2 and ++ not 2.0. The 2_0 version of the enum name was set while the version was ++ still planned to be 2.0 and we stick to it for compatibility. */ ++#define CURL_HTTP_VERSION_2 CURL_HTTP_VERSION_2_0 ++ +/* + * Public API enums for RTSP requests + */ +enum { + CURL_RTSPREQ_NONE, /* first in list */ + CURL_RTSPREQ_OPTIONS, + CURL_RTSPREQ_DESCRIBE, + CURL_RTSPREQ_ANNOUNCE, + CURL_RTSPREQ_SETUP, + CURL_RTSPREQ_PLAY, + CURL_RTSPREQ_PAUSE, + CURL_RTSPREQ_TEARDOWN, + CURL_RTSPREQ_GET_PARAMETER, + CURL_RTSPREQ_SET_PARAMETER, + CURL_RTSPREQ_RECORD, + CURL_RTSPREQ_RECEIVE, + CURL_RTSPREQ_LAST /* last in list */ +}; + + /* These enums are for use with the CURLOPT_NETRC option. */ +enum CURL_NETRC_OPTION { + CURL_NETRC_IGNORED, /* The .netrc will never be read. + * This is the default. */ + CURL_NETRC_OPTIONAL, /* A user:password in the URL will be preferred + * to one in the .netrc. */ + CURL_NETRC_REQUIRED, /* A user:password in the URL will be ignored. + * Unless one is set programmatically, the .netrc + * will be queried. */ + CURL_NETRC_LAST +}; + +enum { + CURL_SSLVERSION_DEFAULT, + CURL_SSLVERSION_TLSv1, /* TLS 1.x */ + CURL_SSLVERSION_SSLv2, + CURL_SSLVERSION_SSLv3, + CURL_SSLVERSION_TLSv1_0, + CURL_SSLVERSION_TLSv1_1, + CURL_SSLVERSION_TLSv1_2, + + CURL_SSLVERSION_LAST /* never use, keep last */ +}; + +enum CURL_TLSAUTH { + CURL_TLSAUTH_NONE, + CURL_TLSAUTH_SRP, + CURL_TLSAUTH_LAST /* never use, keep last */ +}; + +/* symbols to use with CURLOPT_POSTREDIR. + CURL_REDIR_POST_301, CURL_REDIR_POST_302 and CURL_REDIR_POST_303 + can be bitwise ORed so that CURL_REDIR_POST_301 | CURL_REDIR_POST_302 + | CURL_REDIR_POST_303 == CURL_REDIR_POST_ALL */ + +#define CURL_REDIR_GET_ALL 0 +#define CURL_REDIR_POST_301 1 +#define CURL_REDIR_POST_302 2 +#define CURL_REDIR_POST_303 4 +#define CURL_REDIR_POST_ALL \ + (CURL_REDIR_POST_301|CURL_REDIR_POST_302|CURL_REDIR_POST_303) + +typedef enum { + CURL_TIMECOND_NONE, + + CURL_TIMECOND_IFMODSINCE, + CURL_TIMECOND_IFUNMODSINCE, + CURL_TIMECOND_LASTMOD, + + CURL_TIMECOND_LAST +} curl_TimeCond; + + +/* curl_strequal() and curl_strnequal() are subject for removal in a future + libcurl, see lib/README.curlx for details */ +CURL_EXTERN int (curl_strequal)(const char *s1, const char *s2); +CURL_EXTERN int (curl_strnequal)(const char *s1, const char *s2, size_t n); + +/* name is uppercase CURLFORM_ */ +#ifdef CFINIT +#undef CFINIT +#endif + +#ifdef CURL_ISOCPP +#define CFINIT(name) CURLFORM_ ## name +#else +/* The macro "##" is ISO C, we assume pre-ISO C doesn't support it. */ +#define CFINIT(name) CURLFORM_/**/name +#endif + +typedef enum { + CFINIT(NOTHING), /********* the first one is unused ************/ + + /* */ + CFINIT(COPYNAME), + CFINIT(PTRNAME), + CFINIT(NAMELENGTH), + CFINIT(COPYCONTENTS), + CFINIT(PTRCONTENTS), + CFINIT(CONTENTSLENGTH), + CFINIT(FILECONTENT), + CFINIT(ARRAY), + CFINIT(OBSOLETE), + CFINIT(FILE), + + CFINIT(BUFFER), + CFINIT(BUFFERPTR), + CFINIT(BUFFERLENGTH), + + CFINIT(CONTENTTYPE), + CFINIT(CONTENTHEADER), + CFINIT(FILENAME), + CFINIT(END), + CFINIT(OBSOLETE2), + + CFINIT(STREAM), + + CURLFORM_LASTENTRY /* the last unused */ +} CURLformoption; + +#undef CFINIT /* done */ + +/* structure to be used as parameter for CURLFORM_ARRAY */ +struct curl_forms { + CURLformoption option; + const char *value; +}; + +/* use this for multipart formpost building */ +/* Returns code for curl_formadd() + * + * Returns: + * CURL_FORMADD_OK on success + * CURL_FORMADD_MEMORY if the FormInfo allocation fails + * CURL_FORMADD_OPTION_TWICE if one option is given twice for one Form + * CURL_FORMADD_NULL if a null pointer was given for a char + * CURL_FORMADD_MEMORY if the allocation of a FormInfo struct failed + * CURL_FORMADD_UNKNOWN_OPTION if an unknown option was used + * CURL_FORMADD_INCOMPLETE if the some FormInfo is not complete (or error) + * CURL_FORMADD_MEMORY if a curl_httppost struct cannot be allocated + * CURL_FORMADD_MEMORY if some allocation for string copying failed. + * CURL_FORMADD_ILLEGAL_ARRAY if an illegal option is used in an array + * + ***************************************************************************/ +typedef enum { + CURL_FORMADD_OK, /* first, no error */ + + CURL_FORMADD_MEMORY, + CURL_FORMADD_OPTION_TWICE, + CURL_FORMADD_NULL, + CURL_FORMADD_UNKNOWN_OPTION, + CURL_FORMADD_INCOMPLETE, + CURL_FORMADD_ILLEGAL_ARRAY, + CURL_FORMADD_DISABLED, /* libcurl was built with this disabled */ + + CURL_FORMADD_LAST /* last */ +} CURLFORMcode; + +/* + * NAME curl_formadd() + * + * DESCRIPTION + * + * Pretty advanced function for building multi-part formposts. Each invoke + * adds one part that together construct a full post. Then use + * CURLOPT_HTTPPOST to send it off to libcurl. + */ +CURL_EXTERN CURLFORMcode curl_formadd(struct curl_httppost **httppost, + struct curl_httppost **last_post, + ...); + +/* + * callback function for curl_formget() + * The void *arg pointer will be the one passed as second argument to + * curl_formget(). + * The character buffer passed to it must not be freed. + * Should return the buffer length passed to it as the argument "len" on + * success. + */ +typedef size_t (*curl_formget_callback)(void *arg, const char *buf, + size_t len); + +/* + * NAME curl_formget() + * + * DESCRIPTION + * + * Serialize a curl_httppost struct built with curl_formadd(). + * Accepts a void pointer as second argument which will be passed to + * the curl_formget_callback function. + * Returns 0 on success. + */ +CURL_EXTERN int curl_formget(struct curl_httppost *form, void *arg, + curl_formget_callback append); +/* + * NAME curl_formfree() + * + * DESCRIPTION + * + * Free a multipart formpost previously built with curl_formadd(). + */ +CURL_EXTERN void curl_formfree(struct curl_httppost *form); + +/* + * NAME curl_getenv() + * + * DESCRIPTION + * + * Returns a malloc()'ed string that MUST be curl_free()ed after usage is + * complete. DEPRECATED - see lib/README.curlx + */ +CURL_EXTERN char *curl_getenv(const char *variable); + +/* + * NAME curl_version() + * + * DESCRIPTION + * + * Returns a static ascii string of the libcurl version. + */ +CURL_EXTERN char *curl_version(void); + +/* + * NAME curl_easy_escape() + * + * DESCRIPTION + * + * Escapes URL strings (converts all letters consider illegal in URLs to their + * %XX versions). This function returns a new allocated string or NULL if an + * error occurred. + */ +CURL_EXTERN char *curl_easy_escape(CURL *handle, + const char *string, + int length); + +/* the previous version: */ +CURL_EXTERN char *curl_escape(const char *string, + int length); + + +/* + * NAME curl_easy_unescape() + * + * DESCRIPTION + * + * Unescapes URL encoding in strings (converts all %XX codes to their 8bit + * versions). This function returns a new allocated string or NULL if an error + * occurred. + * Conversion Note: On non-ASCII platforms the ASCII %XX codes are + * converted into the host encoding. + */ +CURL_EXTERN char *curl_easy_unescape(CURL *handle, + const char *string, + int length, + int *outlength); + +/* the previous version */ +CURL_EXTERN char *curl_unescape(const char *string, + int length); + +/* + * NAME curl_free() + * + * DESCRIPTION + * + * Provided for de-allocation in the same translation unit that did the + * allocation. Added in libcurl 7.10 + */ +CURL_EXTERN void curl_free(void *p); + +/* + * NAME curl_global_init() + * + * DESCRIPTION + * + * curl_global_init() should be invoked exactly once for each application that + * uses libcurl and before any call of other libcurl functions. + * + * This function is not thread-safe! + */ +CURL_EXTERN CURLcode curl_global_init(long flags); + +/* + * NAME curl_global_init_mem() + * + * DESCRIPTION + * + * curl_global_init() or curl_global_init_mem() should be invoked exactly once + * for each application that uses libcurl. This function can be used to + * initialize libcurl and set user defined memory management callback + * functions. Users can implement memory management routines to check for + * memory leaks, check for mis-use of the curl library etc. User registered + * callback routines with be invoked by this library instead of the system + * memory management routines like malloc, free etc. + */ +CURL_EXTERN CURLcode curl_global_init_mem(long flags, + curl_malloc_callback m, + curl_free_callback f, + curl_realloc_callback r, + curl_strdup_callback s, + curl_calloc_callback c); + +/* + * NAME curl_global_cleanup() + * + * DESCRIPTION + * + * curl_global_cleanup() should be invoked exactly once for each application + * that uses libcurl + */ +CURL_EXTERN void curl_global_cleanup(void); + +/* linked-list structure for the CURLOPT_QUOTE option (and other) */ +struct curl_slist { + char *data; + struct curl_slist *next; +}; + +/* + * NAME curl_slist_append() + * + * DESCRIPTION + * + * Appends a string to a linked list. If no list exists, it will be created + * first. Returns the new list, after appending. + */ +CURL_EXTERN struct curl_slist *curl_slist_append(struct curl_slist *, + const char *); + +/* + * NAME curl_slist_free_all() + * + * DESCRIPTION + * + * free a previously built curl_slist. + */ +CURL_EXTERN void curl_slist_free_all(struct curl_slist *); + +/* + * NAME curl_getdate() + * + * DESCRIPTION + * + * Returns the time, in seconds since 1 Jan 1970 of the time string given in + * the first argument. The time argument in the second parameter is unused + * and should be set to NULL. + */ +CURL_EXTERN time_t curl_getdate(const char *p, const time_t *unused); + +/* info about the certificate chain, only for OpenSSL builds. Asked + for with CURLOPT_CERTINFO / CURLINFO_CERTINFO */ +struct curl_certinfo { + int num_of_certs; /* number of certificates with information */ + struct curl_slist **certinfo; /* for each index in this array, there's a + linked list with textual information in the + format "name: value" */ +}; + +/* enum for the different supported SSL backends */ +typedef enum { + CURLSSLBACKEND_NONE = 0, + CURLSSLBACKEND_OPENSSL = 1, + CURLSSLBACKEND_GNUTLS = 2, + CURLSSLBACKEND_NSS = 3, - CURLSSLBACKEND_QSOSSL = 4, ++ CURLSSLBACKEND_OBSOLETE4 = 4, /* Was QSOSSL. */ + CURLSSLBACKEND_GSKIT = 5, + CURLSSLBACKEND_POLARSSL = 6, + CURLSSLBACKEND_CYASSL = 7, + CURLSSLBACKEND_SCHANNEL = 8, + CURLSSLBACKEND_DARWINSSL = 9, + CURLSSLBACKEND_AXTLS = 10 +} curl_sslbackend; + +/* Information about the SSL library used and the respective internal SSL + handle, which can be used to obtain further information regarding the + connection. Asked for with CURLINFO_TLS_SESSION. */ +struct curl_tlssessioninfo { + curl_sslbackend backend; + void *internals; +}; + +#define CURLINFO_STRING 0x100000 +#define CURLINFO_LONG 0x200000 +#define CURLINFO_DOUBLE 0x300000 +#define CURLINFO_SLIST 0x400000 +#define CURLINFO_MASK 0x0fffff +#define CURLINFO_TYPEMASK 0xf00000 + +typedef enum { + CURLINFO_NONE, /* first, never use this */ + CURLINFO_EFFECTIVE_URL = CURLINFO_STRING + 1, + CURLINFO_RESPONSE_CODE = CURLINFO_LONG + 2, + CURLINFO_TOTAL_TIME = CURLINFO_DOUBLE + 3, + CURLINFO_NAMELOOKUP_TIME = CURLINFO_DOUBLE + 4, + CURLINFO_CONNECT_TIME = CURLINFO_DOUBLE + 5, + CURLINFO_PRETRANSFER_TIME = CURLINFO_DOUBLE + 6, + CURLINFO_SIZE_UPLOAD = CURLINFO_DOUBLE + 7, + CURLINFO_SIZE_DOWNLOAD = CURLINFO_DOUBLE + 8, + CURLINFO_SPEED_DOWNLOAD = CURLINFO_DOUBLE + 9, + CURLINFO_SPEED_UPLOAD = CURLINFO_DOUBLE + 10, + CURLINFO_HEADER_SIZE = CURLINFO_LONG + 11, + CURLINFO_REQUEST_SIZE = CURLINFO_LONG + 12, + CURLINFO_SSL_VERIFYRESULT = CURLINFO_LONG + 13, + CURLINFO_FILETIME = CURLINFO_LONG + 14, + CURLINFO_CONTENT_LENGTH_DOWNLOAD = CURLINFO_DOUBLE + 15, + CURLINFO_CONTENT_LENGTH_UPLOAD = CURLINFO_DOUBLE + 16, + CURLINFO_STARTTRANSFER_TIME = CURLINFO_DOUBLE + 17, + CURLINFO_CONTENT_TYPE = CURLINFO_STRING + 18, + CURLINFO_REDIRECT_TIME = CURLINFO_DOUBLE + 19, + CURLINFO_REDIRECT_COUNT = CURLINFO_LONG + 20, + CURLINFO_PRIVATE = CURLINFO_STRING + 21, + CURLINFO_HTTP_CONNECTCODE = CURLINFO_LONG + 22, + CURLINFO_HTTPAUTH_AVAIL = CURLINFO_LONG + 23, + CURLINFO_PROXYAUTH_AVAIL = CURLINFO_LONG + 24, + CURLINFO_OS_ERRNO = CURLINFO_LONG + 25, + CURLINFO_NUM_CONNECTS = CURLINFO_LONG + 26, + CURLINFO_SSL_ENGINES = CURLINFO_SLIST + 27, + CURLINFO_COOKIELIST = CURLINFO_SLIST + 28, + CURLINFO_LASTSOCKET = CURLINFO_LONG + 29, + CURLINFO_FTP_ENTRY_PATH = CURLINFO_STRING + 30, + CURLINFO_REDIRECT_URL = CURLINFO_STRING + 31, + CURLINFO_PRIMARY_IP = CURLINFO_STRING + 32, + CURLINFO_APPCONNECT_TIME = CURLINFO_DOUBLE + 33, + CURLINFO_CERTINFO = CURLINFO_SLIST + 34, + CURLINFO_CONDITION_UNMET = CURLINFO_LONG + 35, + CURLINFO_RTSP_SESSION_ID = CURLINFO_STRING + 36, + CURLINFO_RTSP_CLIENT_CSEQ = CURLINFO_LONG + 37, + CURLINFO_RTSP_SERVER_CSEQ = CURLINFO_LONG + 38, + CURLINFO_RTSP_CSEQ_RECV = CURLINFO_LONG + 39, + CURLINFO_PRIMARY_PORT = CURLINFO_LONG + 40, + CURLINFO_LOCAL_IP = CURLINFO_STRING + 41, + CURLINFO_LOCAL_PORT = CURLINFO_LONG + 42, + CURLINFO_TLS_SESSION = CURLINFO_SLIST + 43, + /* Fill in new entries below here! */ + + CURLINFO_LASTONE = 43 +} CURLINFO; + +/* CURLINFO_RESPONSE_CODE is the new name for the option previously known as + CURLINFO_HTTP_CODE */ +#define CURLINFO_HTTP_CODE CURLINFO_RESPONSE_CODE + +typedef enum { + CURLCLOSEPOLICY_NONE, /* first, never use this */ + + CURLCLOSEPOLICY_OLDEST, + CURLCLOSEPOLICY_LEAST_RECENTLY_USED, + CURLCLOSEPOLICY_LEAST_TRAFFIC, + CURLCLOSEPOLICY_SLOWEST, + CURLCLOSEPOLICY_CALLBACK, + + CURLCLOSEPOLICY_LAST /* last, never use this */ +} curl_closepolicy; + +#define CURL_GLOBAL_SSL (1<<0) +#define CURL_GLOBAL_WIN32 (1<<1) +#define CURL_GLOBAL_ALL (CURL_GLOBAL_SSL|CURL_GLOBAL_WIN32) +#define CURL_GLOBAL_NOTHING 0 +#define CURL_GLOBAL_DEFAULT CURL_GLOBAL_ALL +#define CURL_GLOBAL_ACK_EINTR (1<<2) + + +/***************************************************************************** + * Setup defines, protos etc for the sharing stuff. + */ + +/* Different data locks for a single share */ +typedef enum { + CURL_LOCK_DATA_NONE = 0, + /* CURL_LOCK_DATA_SHARE is used internally to say that + * the locking is just made to change the internal state of the share + * itself. + */ + CURL_LOCK_DATA_SHARE, + CURL_LOCK_DATA_COOKIE, + CURL_LOCK_DATA_DNS, + CURL_LOCK_DATA_SSL_SESSION, + CURL_LOCK_DATA_CONNECT, + CURL_LOCK_DATA_LAST +} curl_lock_data; + +/* Different lock access types */ +typedef enum { + CURL_LOCK_ACCESS_NONE = 0, /* unspecified action */ + CURL_LOCK_ACCESS_SHARED = 1, /* for read perhaps */ + CURL_LOCK_ACCESS_SINGLE = 2, /* for write perhaps */ + CURL_LOCK_ACCESS_LAST /* never use */ +} curl_lock_access; + +typedef void (*curl_lock_function)(CURL *handle, + curl_lock_data data, + curl_lock_access locktype, + void *userptr); +typedef void (*curl_unlock_function)(CURL *handle, + curl_lock_data data, + void *userptr); + +typedef void CURLSH; + +typedef enum { + CURLSHE_OK, /* all is fine */ + CURLSHE_BAD_OPTION, /* 1 */ + CURLSHE_IN_USE, /* 2 */ + CURLSHE_INVALID, /* 3 */ + CURLSHE_NOMEM, /* 4 out of memory */ + CURLSHE_NOT_BUILT_IN, /* 5 feature not present in lib */ + CURLSHE_LAST /* never use */ +} CURLSHcode; + +typedef enum { + CURLSHOPT_NONE, /* don't use */ + CURLSHOPT_SHARE, /* specify a data type to share */ + CURLSHOPT_UNSHARE, /* specify which data type to stop sharing */ + CURLSHOPT_LOCKFUNC, /* pass in a 'curl_lock_function' pointer */ + CURLSHOPT_UNLOCKFUNC, /* pass in a 'curl_unlock_function' pointer */ + CURLSHOPT_USERDATA, /* pass in a user data pointer used in the lock/unlock + callback functions */ + CURLSHOPT_LAST /* never use */ +} CURLSHoption; + +CURL_EXTERN CURLSH *curl_share_init(void); +CURL_EXTERN CURLSHcode curl_share_setopt(CURLSH *, CURLSHoption option, ...); +CURL_EXTERN CURLSHcode curl_share_cleanup(CURLSH *); + +/**************************************************************************** + * Structures for querying information about the curl library at runtime. + */ + +typedef enum { + CURLVERSION_FIRST, + CURLVERSION_SECOND, + CURLVERSION_THIRD, + CURLVERSION_FOURTH, + CURLVERSION_LAST /* never actually use this */ +} CURLversion; + +/* The 'CURLVERSION_NOW' is the symbolic name meant to be used by + basically all programs ever that want to get version information. It is + meant to be a built-in version number for what kind of struct the caller + expects. If the struct ever changes, we redefine the NOW to another enum + from above. */ +#define CURLVERSION_NOW CURLVERSION_FOURTH + +typedef struct { + CURLversion age; /* age of the returned struct */ + const char *version; /* LIBCURL_VERSION */ + unsigned int version_num; /* LIBCURL_VERSION_NUM */ + const char *host; /* OS/host/cpu/machine when configured */ + int features; /* bitmask, see defines below */ + const char *ssl_version; /* human readable string */ + long ssl_version_num; /* not used anymore, always 0 */ + const char *libz_version; /* human readable string */ + /* protocols is terminated by an entry with a NULL protoname */ + const char * const *protocols; + + /* The fields below this were added in CURLVERSION_SECOND */ + const char *ares; + int ares_num; + + /* This field was added in CURLVERSION_THIRD */ + const char *libidn; + + /* These field were added in CURLVERSION_FOURTH */ + + /* Same as '_libiconv_version' if built with HAVE_ICONV */ + int iconv_ver_num; + + const char *libssh_version; /* human readable string */ + +} curl_version_info_data; + - #define CURL_VERSION_IPV6 (1<<0) /* IPv6-enabled */ - #define CURL_VERSION_KERBEROS4 (1<<1) /* kerberos auth is supported */ - #define CURL_VERSION_SSL (1<<2) /* SSL options are present */ - #define CURL_VERSION_LIBZ (1<<3) /* libz features are present */ - #define CURL_VERSION_NTLM (1<<4) /* NTLM auth is supported */ - #define CURL_VERSION_GSSNEGOTIATE (1<<5) /* Negotiate auth support - (deprecated) */ - #define CURL_VERSION_DEBUG (1<<6) /* built with debug capabilities */ - #define CURL_VERSION_ASYNCHDNS (1<<7) /* asynchronous dns resolves */ - #define CURL_VERSION_SPNEGO (1<<8) /* SPNEGO auth is supported */ - #define CURL_VERSION_LARGEFILE (1<<9) /* supports files bigger than 2GB */ - #define CURL_VERSION_IDN (1<<10) /* International Domain Names support */ - #define CURL_VERSION_SSPI (1<<11) /* SSPI is supported */ - #define CURL_VERSION_CONV (1<<12) /* character conversions supported */ - #define CURL_VERSION_CURLDEBUG (1<<13) /* debug memory tracking supported */ - #define CURL_VERSION_TLSAUTH_SRP (1<<14) /* TLS-SRP auth is supported */ - #define CURL_VERSION_NTLM_WB (1<<15) /* NTLM delegating to winbind helper */ - #define CURL_VERSION_HTTP2 (1<<16) /* HTTP2 support built-in */ - #define CURL_VERSION_GSSAPI (1<<17) /* GSS-API is supported */ ++#define CURL_VERSION_IPV6 (1<<0) /* IPv6-enabled */ ++#define CURL_VERSION_KERBEROS4 (1<<1) /* Kerberos V4 auth is supported ++ (deprecated) */ ++#define CURL_VERSION_SSL (1<<2) /* SSL options are present */ ++#define CURL_VERSION_LIBZ (1<<3) /* libz features are present */ ++#define CURL_VERSION_NTLM (1<<4) /* NTLM auth is supported */ ++#define CURL_VERSION_GSSNEGOTIATE (1<<5) /* Negotiate auth is supported ++ (deprecated) */ ++#define CURL_VERSION_DEBUG (1<<6) /* Built with debug capabilities */ ++#define CURL_VERSION_ASYNCHDNS (1<<7) /* Asynchronous DNS resolves */ ++#define CURL_VERSION_SPNEGO (1<<8) /* SPNEGO auth is supported */ ++#define CURL_VERSION_LARGEFILE (1<<9) /* Supports files larger than 2GB */ ++#define CURL_VERSION_IDN (1<<10) /* Internationized Domain Names are ++ supported */ ++#define CURL_VERSION_SSPI (1<<11) /* Built against Windows SSPI */ ++#define CURL_VERSION_CONV (1<<12) /* Character conversions supported */ ++#define CURL_VERSION_CURLDEBUG (1<<13) /* Debug memory tracking supported */ ++#define CURL_VERSION_TLSAUTH_SRP (1<<14) /* TLS-SRP auth is supported */ ++#define CURL_VERSION_NTLM_WB (1<<15) /* NTLM delegation to winbind helper ++ is suported */ ++#define CURL_VERSION_HTTP2 (1<<16) /* HTTP2 support built-in */ ++#define CURL_VERSION_GSSAPI (1<<17) /* Built against a GSS-API library */ ++#define CURL_VERSION_KERBEROS5 (1<<18) /* Kerberos V5 auth is supported */ ++#define CURL_VERSION_UNIX_SOCKETS (1<<19) /* Unix domain sockets support */ + + /* + * NAME curl_version_info() + * + * DESCRIPTION + * + * This function returns a pointer to a static copy of the version info + * struct. See above. + */ +CURL_EXTERN curl_version_info_data *curl_version_info(CURLversion); + +/* + * NAME curl_easy_strerror() + * + * DESCRIPTION + * + * The curl_easy_strerror function may be used to turn a CURLcode value + * into the equivalent human readable error string. This is useful + * for printing meaningful error messages. + */ +CURL_EXTERN const char *curl_easy_strerror(CURLcode); + +/* + * NAME curl_share_strerror() + * + * DESCRIPTION + * + * The curl_share_strerror function may be used to turn a CURLSHcode value + * into the equivalent human readable error string. This is useful + * for printing meaningful error messages. + */ +CURL_EXTERN const char *curl_share_strerror(CURLSHcode); + +/* + * NAME curl_easy_pause() + * + * DESCRIPTION + * + * The curl_easy_pause function pauses or unpauses transfers. Select the new + * state by setting the bitmask, use the convenience defines below. + * + */ +CURL_EXTERN CURLcode curl_easy_pause(CURL *handle, int bitmask); + +#define CURLPAUSE_RECV (1<<0) +#define CURLPAUSE_RECV_CONT (0) + +#define CURLPAUSE_SEND (1<<2) +#define CURLPAUSE_SEND_CONT (0) + +#define CURLPAUSE_ALL (CURLPAUSE_RECV|CURLPAUSE_SEND) +#define CURLPAUSE_CONT (CURLPAUSE_RECV_CONT|CURLPAUSE_SEND_CONT) + +#ifdef __cplusplus +} +#endif + +/* unfortunately, the easy.h and multi.h include files need options and info + stuff before they can be included! */ +#include "easy.h" /* nothing in curl is fun without the easy stuff */ +#include "multi.h" + +/* the typechecker doesn't work in C++ (yet) */ +#if defined(__GNUC__) && defined(__GNUC_MINOR__) && \ + ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) && \ + !defined(__cplusplus) && !defined(CURL_DISABLE_TYPECHECK) +#include "typecheck-gcc.h" +#else +#if defined(__STDC__) && (__STDC__ >= 1) +#if 0 /* Triggers clang -Wdisabled-macro-expansion, skip for CMake. */ +/* This preprocessor magic that replaces a call with the exact same call is + only done to make sure application authors pass exactly three arguments + to these functions. */ +#define curl_easy_setopt(handle,opt,param) curl_easy_setopt(handle,opt,param) +#define curl_easy_getinfo(handle,info,arg) curl_easy_getinfo(handle,info,arg) +#define curl_share_setopt(share,opt,param) curl_share_setopt(share,opt,param) +#define curl_multi_setopt(handle,opt,param) curl_multi_setopt(handle,opt,param) +#endif +#endif /* __STDC__ >= 1 */ +#endif /* gcc >= 4.3 && !__cplusplus */ + +#endif /* __CURL_CURL_H */ diff --cc Utilities/cmcurl/include/curl/curlver.h index c0cb509,0000000..a41fdef mode 100644,000000..100644 --- a/Utilities/cmcurl/include/curl/curlver.h +++ b/Utilities/cmcurl/include/curl/curlver.h @@@ -1,69 -1,0 +1,77 @@@ +#ifndef __CURL_CURLVER_H +#define __CURL_CURLVER_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. ++ * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ + +/* This header file contains nothing but libcurl version info, generated by + a script at release-time. This was made its own header file in 7.11.2 */ + +/* This is the global package copyright */ - #define LIBCURL_COPYRIGHT "1996 - 2014 Daniel Stenberg, ." ++#define LIBCURL_COPYRIGHT "1996 - 2015 Daniel Stenberg, ." + +/* This is the version number of the libcurl package from which this header + file origins: */ - #define LIBCURL_VERSION "7.38.0" ++#define LIBCURL_VERSION "7.44.0" + +/* The numeric version number is also available "in parts" by using these + defines: */ +#define LIBCURL_VERSION_MAJOR 7 - #define LIBCURL_VERSION_MINOR 38 ++#define LIBCURL_VERSION_MINOR 44 +#define LIBCURL_VERSION_PATCH 0 + +/* This is the numeric version of the libcurl version number, meant for easier + parsing and comparions by programs. The LIBCURL_VERSION_NUM define will + always follow this syntax: + + 0xXXYYZZ + + Where XX, YY and ZZ are the main version, release and patch numbers in + hexadecimal (using 8 bits each). All three numbers are always represented + using two digits. 1.2 would appear as "0x010200" while version 9.11.7 + appears as "0x090b07". + + This 6-digit (24 bits) hexadecimal number does not show pre-release number, + and it is always a greater number in a more recent release. It makes + comparisons with greater than and less than work. ++ ++ Note: This define is the full hex number and _does not_ use the ++ CURL_VERSION_BITS() macro since curl's own configure script greps for it ++ and needs it to contain the full number. +*/ - #define LIBCURL_VERSION_NUM 0x072600 ++#define LIBCURL_VERSION_NUM 0x072C00 + +/* + * This is the date and time when the full source package was created. The + * timestamp is not stored in git, as the timestamp is properly set in the + * tarballs by the maketgz script. + * + * The format of the date should follow this template: + * + * "Mon Feb 12 11:35:33 UTC 2007" + */ +#define LIBCURL_TIMESTAMP "DEV" + ++#define CURL_VERSION_BITS(x,y,z) ((x)<<16|(y)<<8|z) ++#define CURL_AT_LEAST_VERSION(x,y,z) \ ++ (LIBCURL_VERSION_NUM >= CURL_VERSION_BITS(x, y, z)) ++ +#endif /* __CURL_CURLVER_H */ diff --cc Utilities/cmcurl/include/curl/multi.h index 10d6006,0000000..0f1561d mode 100644,000000..100644 --- a/Utilities/cmcurl/include/curl/multi.h +++ b/Utilities/cmcurl/include/curl/multi.h @@@ -1,399 -1,0 +1,435 @@@ +#ifndef __CURL_MULTI_H +#define __CURL_MULTI_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * - * Copyright (C) 1998 - 2013, Daniel Stenberg, , et al. ++ * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ +/* + This is an "external" header file. Don't give away any internals here! + + GOALS + + o Enable a "pull" interface. The application that uses libcurl decides where + and when to ask libcurl to get/send data. + + o Enable multiple simultaneous transfers in the same thread without making it + complicated for the application. + + o Enable the application to select() on its own file descriptors and curl's + file descriptors simultaneous easily. + +*/ + +/* + * This header file should not really need to include "curl.h" since curl.h + * itself includes this file and we expect user applications to do #include + * without the need for especially including multi.h. + * + * For some reason we added this include here at one point, and rather than to + * break existing (wrongly written) libcurl applications, we leave it as-is + * but with this warning attached. + */ +#include "curl.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void CURLM; + +typedef enum { + CURLM_CALL_MULTI_PERFORM = -1, /* please call curl_multi_perform() or + curl_multi_socket*() soon */ + CURLM_OK, + CURLM_BAD_HANDLE, /* the passed-in handle is not a valid CURLM handle */ + CURLM_BAD_EASY_HANDLE, /* an easy handle was not good/valid */ + CURLM_OUT_OF_MEMORY, /* if you ever get this, you're in deep sh*t */ + CURLM_INTERNAL_ERROR, /* this is a libcurl bug */ + CURLM_BAD_SOCKET, /* the passed in socket argument did not match */ + CURLM_UNKNOWN_OPTION, /* curl_multi_setopt() with unsupported option */ + CURLM_ADDED_ALREADY, /* an easy handle already added to a multi handle was + attempted to get added - again */ + CURLM_LAST +} CURLMcode; + +/* just to make code nicer when using curl_multi_socket() you can now check + for CURLM_CALL_MULTI_SOCKET too in the same style it works for + curl_multi_perform() and CURLM_CALL_MULTI_PERFORM */ +#define CURLM_CALL_MULTI_SOCKET CURLM_CALL_MULTI_PERFORM + ++/* bitmask bits for CURLMOPT_PIPELINING */ ++#define CURLPIPE_NOTHING 0L ++#define CURLPIPE_HTTP1 1L ++#define CURLPIPE_MULTIPLEX 2L ++ +typedef enum { + CURLMSG_NONE, /* first, not used */ + CURLMSG_DONE, /* This easy handle has completed. 'result' contains + the CURLcode of the transfer */ + CURLMSG_LAST /* last, not used */ +} CURLMSG; + +struct CURLMsg { + CURLMSG msg; /* what this message means */ + CURL *easy_handle; /* the handle it concerns */ + union { + void *whatever; /* message-specific data */ + CURLcode result; /* return code for transfer */ + } data; +}; +typedef struct CURLMsg CURLMsg; + +/* Based on poll(2) structure and values. + * We don't use pollfd and POLL* constants explicitly + * to cover platforms without poll(). */ +#define CURL_WAIT_POLLIN 0x0001 +#define CURL_WAIT_POLLPRI 0x0002 +#define CURL_WAIT_POLLOUT 0x0004 + +struct curl_waitfd { + curl_socket_t fd; + short events; + short revents; /* not supported yet */ +}; + +/* + * Name: curl_multi_init() + * + * Desc: inititalize multi-style curl usage + * + * Returns: a new CURLM handle to use in all 'curl_multi' functions. + */ +CURL_EXTERN CURLM *curl_multi_init(void); + +/* + * Name: curl_multi_add_handle() + * + * Desc: add a standard curl handle to the multi stack + * + * Returns: CURLMcode type, general multi error code. + */ +CURL_EXTERN CURLMcode curl_multi_add_handle(CURLM *multi_handle, + CURL *curl_handle); + + /* + * Name: curl_multi_remove_handle() + * + * Desc: removes a curl handle from the multi stack again + * + * Returns: CURLMcode type, general multi error code. + */ +CURL_EXTERN CURLMcode curl_multi_remove_handle(CURLM *multi_handle, + CURL *curl_handle); + + /* + * Name: curl_multi_fdset() + * + * Desc: Ask curl for its fd_set sets. The app can use these to select() or + * poll() on. We want curl_multi_perform() called as soon as one of + * them are ready. + * + * Returns: CURLMcode type, general multi error code. + */ +CURL_EXTERN CURLMcode curl_multi_fdset(CURLM *multi_handle, + fd_set *read_fd_set, + fd_set *write_fd_set, + fd_set *exc_fd_set, + int *max_fd); + +/* + * Name: curl_multi_wait() + * + * Desc: Poll on all fds within a CURLM set as well as any + * additional fds passed to the function. + * + * Returns: CURLMcode type, general multi error code. + */ +CURL_EXTERN CURLMcode curl_multi_wait(CURLM *multi_handle, + struct curl_waitfd extra_fds[], + unsigned int extra_nfds, + int timeout_ms, + int *ret); + + /* + * Name: curl_multi_perform() + * + * Desc: When the app thinks there's data available for curl it calls this + * function to read/write whatever there is right now. This returns + * as soon as the reads and writes are done. This function does not + * require that there actually is data available for reading or that + * data can be written, it can be called just in case. It returns + * the number of handles that still transfer data in the second + * argument's integer-pointer. + * + * Returns: CURLMcode type, general multi error code. *NOTE* that this only + * returns errors etc regarding the whole multi stack. There might + * still have occurred problems on invidual transfers even when this + * returns OK. + */ +CURL_EXTERN CURLMcode curl_multi_perform(CURLM *multi_handle, + int *running_handles); + + /* + * Name: curl_multi_cleanup() + * + * Desc: Cleans up and removes a whole multi stack. It does not free or + * touch any individual easy handles in any way. We need to define + * in what state those handles will be if this function is called + * in the middle of a transfer. + * + * Returns: CURLMcode type, general multi error code. + */ +CURL_EXTERN CURLMcode curl_multi_cleanup(CURLM *multi_handle); + +/* + * Name: curl_multi_info_read() + * + * Desc: Ask the multi handle if there's any messages/informationals from + * the individual transfers. Messages include informationals such as + * error code from the transfer or just the fact that a transfer is + * completed. More details on these should be written down as well. + * + * Repeated calls to this function will return a new struct each + * time, until a special "end of msgs" struct is returned as a signal + * that there is no more to get at this point. + * + * The data the returned pointer points to will not survive calling + * curl_multi_cleanup(). + * + * The 'CURLMsg' struct is meant to be very simple and only contain + * very basic information. If more involved information is wanted, + * we will provide the particular "transfer handle" in that struct + * and that should/could/would be used in subsequent + * curl_easy_getinfo() calls (or similar). The point being that we + * must never expose complex structs to applications, as then we'll + * undoubtably get backwards compatibility problems in the future. + * + * Returns: A pointer to a filled-in struct, or NULL if it failed or ran out + * of structs. It also writes the number of messages left in the + * queue (after this read) in the integer the second argument points + * to. + */ +CURL_EXTERN CURLMsg *curl_multi_info_read(CURLM *multi_handle, + int *msgs_in_queue); + +/* + * Name: curl_multi_strerror() + * + * Desc: The curl_multi_strerror function may be used to turn a CURLMcode + * value into the equivalent human readable error string. This is + * useful for printing meaningful error messages. + * + * Returns: A pointer to a zero-terminated error message. + */ +CURL_EXTERN const char *curl_multi_strerror(CURLMcode); + +/* + * Name: curl_multi_socket() and + * curl_multi_socket_all() + * + * Desc: An alternative version of curl_multi_perform() that allows the + * application to pass in one of the file descriptors that have been + * detected to have "action" on them and let libcurl perform. + * See man page for details. + */ +#define CURL_POLL_NONE 0 +#define CURL_POLL_IN 1 +#define CURL_POLL_OUT 2 +#define CURL_POLL_INOUT 3 +#define CURL_POLL_REMOVE 4 + +#define CURL_SOCKET_TIMEOUT CURL_SOCKET_BAD + +#define CURL_CSELECT_IN 0x01 +#define CURL_CSELECT_OUT 0x02 +#define CURL_CSELECT_ERR 0x04 + +typedef int (*curl_socket_callback)(CURL *easy, /* easy handle */ + curl_socket_t s, /* socket */ + int what, /* see above */ + void *userp, /* private callback + pointer */ + void *socketp); /* private socket + pointer */ +/* + * Name: curl_multi_timer_callback + * + * Desc: Called by libcurl whenever the library detects a change in the + * maximum number of milliseconds the app is allowed to wait before + * curl_multi_socket() or curl_multi_perform() must be called + * (to allow libcurl's timed events to take place). + * + * Returns: The callback should return zero. + */ +typedef int (*curl_multi_timer_callback)(CURLM *multi, /* multi handle */ + long timeout_ms, /* see above */ + void *userp); /* private callback + pointer */ + +CURL_EXTERN CURLMcode curl_multi_socket(CURLM *multi_handle, curl_socket_t s, + int *running_handles); + +CURL_EXTERN CURLMcode curl_multi_socket_action(CURLM *multi_handle, + curl_socket_t s, + int ev_bitmask, + int *running_handles); + +CURL_EXTERN CURLMcode curl_multi_socket_all(CURLM *multi_handle, + int *running_handles); + +#ifndef CURL_ALLOW_OLD_MULTI_SOCKET +/* This macro below was added in 7.16.3 to push users who recompile to use + the new curl_multi_socket_action() instead of the old curl_multi_socket() +*/ +#define curl_multi_socket(x,y,z) curl_multi_socket_action(x,y,0,z) +#endif + +/* + * Name: curl_multi_timeout() + * + * Desc: Returns the maximum number of milliseconds the app is allowed to + * wait before curl_multi_socket() or curl_multi_perform() must be + * called (to allow libcurl's timed events to take place). + * + * Returns: CURLM error code. + */ +CURL_EXTERN CURLMcode curl_multi_timeout(CURLM *multi_handle, + long *milliseconds); + +#undef CINIT /* re-using the same name as in curl.h */ + +#ifdef CURL_ISOCPP +#define CINIT(name,type,num) CURLMOPT_ ## name = CURLOPTTYPE_ ## type + num +#else +/* The macro "##" is ISO C, we assume pre-ISO C doesn't support it. */ +#define LONG CURLOPTTYPE_LONG +#define OBJECTPOINT CURLOPTTYPE_OBJECTPOINT +#define FUNCTIONPOINT CURLOPTTYPE_FUNCTIONPOINT +#define OFF_T CURLOPTTYPE_OFF_T +#define CINIT(name,type,number) CURLMOPT_/**/name = type + number +#endif + +typedef enum { + /* This is the socket callback function pointer */ + CINIT(SOCKETFUNCTION, FUNCTIONPOINT, 1), + + /* This is the argument passed to the socket callback */ + CINIT(SOCKETDATA, OBJECTPOINT, 2), + + /* set to 1 to enable pipelining for this multi handle */ + CINIT(PIPELINING, LONG, 3), + + /* This is the timer callback function pointer */ + CINIT(TIMERFUNCTION, FUNCTIONPOINT, 4), + + /* This is the argument passed to the timer callback */ + CINIT(TIMERDATA, OBJECTPOINT, 5), + + /* maximum number of entries in the connection cache */ + CINIT(MAXCONNECTS, LONG, 6), + + /* maximum number of (pipelining) connections to one host */ + CINIT(MAX_HOST_CONNECTIONS, LONG, 7), + + /* maximum number of requests in a pipeline */ + CINIT(MAX_PIPELINE_LENGTH, LONG, 8), + + /* a connection with a content-length longer than this + will not be considered for pipelining */ + CINIT(CONTENT_LENGTH_PENALTY_SIZE, OFF_T, 9), + + /* a connection with a chunk length longer than this + will not be considered for pipelining */ + CINIT(CHUNK_LENGTH_PENALTY_SIZE, OFF_T, 10), + + /* a list of site names(+port) that are blacklisted from + pipelining */ + CINIT(PIPELINING_SITE_BL, OBJECTPOINT, 11), + + /* a list of server types that are blacklisted from + pipelining */ + CINIT(PIPELINING_SERVER_BL, OBJECTPOINT, 12), + + /* maximum number of open connections in total */ + CINIT(MAX_TOTAL_CONNECTIONS, LONG, 13), + ++ /* This is the server push callback function pointer */ ++ CINIT(PUSHFUNCTION, FUNCTIONPOINT, 14), ++ ++ /* This is the argument passed to the server push callback */ ++ CINIT(PUSHDATA, OBJECTPOINT, 15), ++ + CURLMOPT_LASTENTRY /* the last unused */ +} CURLMoption; + + +/* + * Name: curl_multi_setopt() + * + * Desc: Sets options for the multi handle. + * + * Returns: CURLM error code. + */ +CURL_EXTERN CURLMcode curl_multi_setopt(CURLM *multi_handle, + CURLMoption option, ...); + + +/* + * Name: curl_multi_assign() + * + * Desc: This function sets an association in the multi handle between the + * given socket and a private pointer of the application. This is + * (only) useful for curl_multi_socket uses. + * + * Returns: CURLM error code. + */ +CURL_EXTERN CURLMcode curl_multi_assign(CURLM *multi_handle, + curl_socket_t sockfd, void *sockp); + ++ ++/* ++ * Name: curl_push_callback ++ * ++ * Desc: This callback gets called when a new stream is being pushed by the ++ * server. It approves or denies the new stream. ++ * ++ * Returns: CURL_PUSH_OK or CURL_PUSH_DENY. ++ */ ++#define CURL_PUSH_OK 0 ++#define CURL_PUSH_DENY 1 ++ ++struct curl_pushheaders; /* forward declaration only */ ++ ++CURL_EXTERN char *curl_pushheader_bynum(struct curl_pushheaders *h, ++ size_t num); ++CURL_EXTERN char *curl_pushheader_byname(struct curl_pushheaders *h, ++ const char *name); ++ ++typedef int (*curl_push_callback)(CURL *parent, ++ CURL *easy, ++ size_t num_headers, ++ struct curl_pushheaders *headers, ++ void *userp); ++ +#ifdef __cplusplus +} /* end of extern "C" */ +#endif + +#endif diff --cc Utilities/cmcurl/lib/CMakeLists.txt index a4621c1,0000000..0d7b717 mode 100644,000000..100644 --- a/Utilities/cmcurl/lib/CMakeLists.txt +++ b/Utilities/cmcurl/lib/CMakeLists.txt @@@ -1,147 -1,0 +1,129 @@@ +set(LIB_NAME cmcurl) + +configure_file(${CURL_SOURCE_DIR}/include/curl/curlbuild.h.cmake + ${CURL_BINARY_DIR}/include/curl/curlbuild.h) +configure_file(curl_config.h.cmake + ${CMAKE_CURRENT_BINARY_DIR}/curl_config.h) + +transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake") +include(${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake) + +list(APPEND HHEADERS + ${CMAKE_CURRENT_BINARY_DIR}/curl_config.h + ${CURL_BINARY_DIR}/include/curl/curlbuild.h + ) + +if(MSVC AND NOT CURL_STATICLIB) + list(APPEND CSOURCES libcurl.rc) +endif() + +# SET(CSOURCES +# # memdebug.c -not used +# # nwlib.c - Not used +# # strtok.c - specify later +# # strtoofft.c - specify later +# ) + +# # if we have Kerberos 4, right now this is never on +# #OPTION(CURL_KRB4 "Use Kerberos 4" OFF) +# IF(CURL_KRB4) +# SET(CSOURCES ${CSOURCES} +# krb4.c +# security.c +# ) +# ENDIF(CURL_KRB4) + +# #OPTION(CURL_MALLOC_DEBUG "Debug mallocs in Curl" OFF) +# MARK_AS_ADVANCED(CURL_MALLOC_DEBUG) +# IF(CURL_MALLOC_DEBUG) +# SET(CSOURCES ${CSOURCES} +# memdebug.c +# ) +# ENDIF(CURL_MALLOC_DEBUG) + +# # only build compat strtoofft if we need to +# IF(NOT HAVE_STRTOLL AND NOT HAVE__STRTOI64) +# SET(CSOURCES ${CSOURCES} +# strtoofft.c +# ) +# ENDIF(NOT HAVE_STRTOLL AND NOT HAVE__STRTOI64) + - if(HAVE_FEATURES_H) - set_source_files_properties( - cookie.c - easy.c - formdata.c - getenv.c - nonblock.c - hash.c - http.c - if2ip.c - mprintf.c - multi.c - sendf.c - telnet.c - transfer.c - url.c - COMPILE_FLAGS -D_BSD_SOURCE) - endif(HAVE_FEATURES_H) - + +# The rest of the build + +include_directories(${CMAKE_CURRENT_BINARY_DIR}/../include) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../include) +include_directories(${CMAKE_CURRENT_BINARY_DIR}/..) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) +include_directories(${CMAKE_CURRENT_BINARY_DIR}) - if(CURL_USE_ARES) ++if(USE_ARES) + include_directories(${CARES_INCLUDE_DIR}) +endif() + +if(CURL_STATICLIB) + # Static lib + set(CURL_USER_DEFINED_DYNAMIC_OR_STATIC STATIC) +else() + # DLL / so dynamic lib + set(CURL_USER_DEFINED_DYNAMIC_OR_STATIC SHARED) +endif() + +# For windows we want to install OPENSSL_LIBRARIES dlls +# and also copy them into the build tree so that testing +# can find them. +if(CMAKE_USE_OPENSSL AND OPENSSL_FOUND AND WIN32) + find_file(CMAKE_EAY_DLL NAME libeay32.dll HINTS ${OPENSSL_INCLUDE_DIR}/..) + find_file(CMAKE_SSL_DLL NAME ssleay32.dll HINTS ${OPENSSL_INCLUDE_DIR}/..) + mark_as_advanced(CMAKE_EAY_DLL CMAKE_SSL_DLL) + if(CMAKE_SSL_DLL AND CMAKE_EAY_DLL) + set(CMAKE_CURL_SSL_DLLS ${CMake_BIN_DIR}/${CMAKE_CFG_INTDIR}/libeay32.dll + ${CMake_BIN_DIR}/${CMAKE_CFG_INTDIR}/ssleay32.dll) + add_custom_command(OUTPUT + ${CMake_BIN_DIR}/${CMAKE_CFG_INTDIR}/libeay32.dll + DEPENDS ${CMAKE_EAY_DLL} + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_EAY_DLL} + ${CMake_BIN_DIR}/${CMAKE_CFG_INTDIR}/libeay32.dll) + add_custom_command(OUTPUT + ${CMake_BIN_DIR}/${CMAKE_CFG_INTDIR}/ssleay32.dll + DEPENDS ${CMAKE_SSL_DLL} + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SSL_DLL} + ${CMake_BIN_DIR}/${CMAKE_CFG_INTDIR}/ssleay32.dll) + install(PROGRAMS ${CMAKE_EAY_DLL} ${CMAKE_SSL_DLL} DESTINATION bin) + endif() +endif() + +add_library( + ${LIB_NAME} + ${CURL_USER_DEFINED_DYNAMIC_OR_STATIC} + ${HHEADERS} ${CSOURCES} + ${CMAKE_CURL_SSL_DLLS} + ) + +target_link_libraries(${LIB_NAME} ${CURL_LIBS}) + +if(0) # This code not needed for building within CMake. +if(WIN32) + add_definitions( -D_USRDLL ) +endif() +endif() + +set_target_properties(${LIB_NAME} PROPERTIES COMPILE_DEFINITIONS BUILDING_LIBCURL) + - setup_curl_dependencies(${LIB_NAME}) - +if(0) # This code not needed for building within CMake. +# Remove the "lib" prefix since the library is already named "libcurl". +set_target_properties(${LIB_NAME} PROPERTIES PREFIX "") +set_target_properties(${LIB_NAME} PROPERTIES IMPORT_PREFIX "") + +if(WIN32) + if(NOT CURL_STATICLIB) + # Add "_imp" as a suffix before the extension to avoid conflicting with the statically linked "libcurl.lib" + set_target_properties(${LIB_NAME} PROPERTIES IMPORT_SUFFIX "_imp.lib") + endif() +endif() + - install(TARGETS ${LIB_NAME} DESTINATION lib) ++install(TARGETS ${LIB_NAME} ++ ARCHIVE DESTINATION lib ++ LIBRARY DESTINATION lib ++ RUNTIME DESTINATION bin) +endif() diff --cc Utilities/cmcurl/lib/curl_config.h.cmake index a561c3d,0000000..06201ec mode 100644,000000..100644 --- a/Utilities/cmcurl/lib/curl_config.h.cmake +++ b/Utilities/cmcurl/lib/curl_config.h.cmake @@@ -1,955 -1,0 +1,961 @@@ +/* lib/curl_config.h.in. Generated somehow by cmake. */ + +/* when building libcurl itself */ +#cmakedefine BUILDING_LIBCURL 1 + +/* to disable cookies support */ +#cmakedefine CURL_DISABLE_COOKIES 1 + +/* to disable cryptographic authentication */ +#cmakedefine CURL_DISABLE_CRYPTO_AUTH 1 + +/* to disable DICT */ +#cmakedefine CURL_DISABLE_DICT 1 + +/* to disable FILE */ +#cmakedefine CURL_DISABLE_FILE 1 + +/* to disable FTP */ +#cmakedefine CURL_DISABLE_FTP 1 + +/* to disable HTTP */ +#cmakedefine CURL_DISABLE_HTTP 1 + +/* to disable LDAP */ +#cmakedefine CURL_DISABLE_LDAP 1 + +/* to disable LDAPS */ +#cmakedefine CURL_DISABLE_LDAPS 1 + +/* to disable proxies */ +#cmakedefine CURL_DISABLE_PROXY 1 + +/* to disable TELNET */ +#cmakedefine CURL_DISABLE_TELNET 1 + +/* to disable TFTP */ +#cmakedefine CURL_DISABLE_TFTP 1 + +/* to disable verbose strings */ +#cmakedefine CURL_DISABLE_VERBOSE_STRINGS 1 + +/* to make a symbol visible */ +#cmakedefine CURL_EXTERN_SYMBOL 1 +/* Ensure using CURL_EXTERN_SYMBOL is possible */ +#ifndef CURL_EXTERN_SYMBOL +#define CURL_EXTERN_SYMBOL +#endif + +/* Use Windows LDAP implementation */ - #cmakedefine CURL_LDAP_WIN 1 ++#cmakedefine USE_WIN32_LDAP 1 + +/* when not building a shared library */ +#cmakedefine CURL_STATICLIB 1 + +/* Set to explicitly specify we don't want to use thread-safe functions */ +#cmakedefine DISABLED_THREADSAFE 1 + +/* your Entropy Gathering Daemon socket pathname */ +#cmakedefine EGD_SOCKET ${EGD_SOCKET} + +/* Define if you want to enable IPv6 support */ +#cmakedefine ENABLE_IPV6 1 + +/* Define to the type qualifier of arg 1 for getnameinfo. */ +#cmakedefine GETNAMEINFO_QUAL_ARG1 ${GETNAMEINFO_QUAL_ARG1} + +/* Define to the type of arg 1 for getnameinfo. */ +#cmakedefine GETNAMEINFO_TYPE_ARG1 ${GETNAMEINFO_TYPE_ARG1} + +/* Define to the type of arg 2 for getnameinfo. */ +#cmakedefine GETNAMEINFO_TYPE_ARG2 ${GETNAMEINFO_TYPE_ARG2} + +/* Define to the type of args 4 and 6 for getnameinfo. */ +#cmakedefine GETNAMEINFO_TYPE_ARG46 ${GETNAMEINFO_TYPE_ARG46} + +/* Define to the type of arg 7 for getnameinfo. */ +#cmakedefine GETNAMEINFO_TYPE_ARG7 ${GETNAMEINFO_TYPE_ARG7} + +/* Specifies the number of arguments to getservbyport_r */ +#cmakedefine GETSERVBYPORT_R_ARGS ${GETSERVBYPORT_R_ARGS} + +/* Specifies the size of the buffer to pass to getservbyport_r */ +#cmakedefine GETSERVBYPORT_R_BUFSIZE ${GETSERVBYPORT_R_BUFSIZE} + +/* Define to 1 if you have the alarm function. */ +#cmakedefine HAVE_ALARM 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_ALLOCA_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_ARPA_INET_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_ARPA_TFTP_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_ASSERT_H 1 + +/* Define to 1 if you have the `basename' function. */ +#cmakedefine HAVE_BASENAME 1 + +/* Define to 1 if bool is an available type. */ +#cmakedefine HAVE_BOOL_T 1 + +/* Define to 1 if you have the clock_gettime function and monotonic timer. */ +#cmakedefine HAVE_CLOCK_GETTIME_MONOTONIC 1 + +/* Define to 1 if you have the `closesocket' function. */ +#cmakedefine HAVE_CLOSESOCKET 1 + +/* Define to 1 if you have the `CRYPTO_cleanup_all_ex_data' function. */ +#cmakedefine HAVE_CRYPTO_CLEANUP_ALL_EX_DATA 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_CRYPTO_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_DES_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_DLFCN_H 1 + +/* Define to 1 if you have the `ENGINE_load_builtin_engines' function. */ +#cmakedefine HAVE_ENGINE_LOAD_BUILTIN_ENGINES 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_ERRNO_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_ERR_H 1 + +/* Define to 1 if you have the fcntl function. */ +#cmakedefine HAVE_FCNTL 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_FCNTL_H 1 + +/* Define to 1 if you have a working fcntl O_NONBLOCK function. */ +#cmakedefine HAVE_FCNTL_O_NONBLOCK 1 + +/* Define to 1 if you have the fdopen function. */ +#cmakedefine HAVE_FDOPEN 1 + +/* Define to 1 if you have the `fork' function. */ +#cmakedefine HAVE_FORK 1 + +/* Define to 1 if you have the freeaddrinfo function. */ +#cmakedefine HAVE_FREEADDRINFO 1 + +/* Define to 1 if you have the freeifaddrs function. */ +#cmakedefine HAVE_FREEIFADDRS 1 + +/* Define to 1 if you have the ftruncate function. */ +#cmakedefine HAVE_FTRUNCATE 1 + +/* Define to 1 if you have a working getaddrinfo function. */ +#cmakedefine HAVE_GETADDRINFO 1 + +/* Define to 1 if you have the `geteuid' function. */ +#cmakedefine HAVE_GETEUID 1 + +/* Define to 1 if you have the gethostbyaddr function. */ +#cmakedefine HAVE_GETHOSTBYADDR 1 + +/* Define to 1 if you have the gethostbyaddr_r function. */ +#cmakedefine HAVE_GETHOSTBYADDR_R 1 + +/* gethostbyaddr_r() takes 5 args */ +#cmakedefine HAVE_GETHOSTBYADDR_R_5 1 + +/* gethostbyaddr_r() takes 7 args */ +#cmakedefine HAVE_GETHOSTBYADDR_R_7 1 + +/* gethostbyaddr_r() takes 8 args */ +#cmakedefine HAVE_GETHOSTBYADDR_R_8 1 + +/* Define to 1 if you have the gethostbyname function. */ +#cmakedefine HAVE_GETHOSTBYNAME 1 + +/* Define to 1 if you have the gethostbyname_r function. */ +#cmakedefine HAVE_GETHOSTBYNAME_R 1 + +/* gethostbyname_r() takes 3 args */ +#cmakedefine HAVE_GETHOSTBYNAME_R_3 1 + +/* gethostbyname_r() takes 5 args */ +#cmakedefine HAVE_GETHOSTBYNAME_R_5 1 + +/* gethostbyname_r() takes 6 args */ +#cmakedefine HAVE_GETHOSTBYNAME_R_6 1 + +/* Define to 1 if you have the gethostname function. */ +#cmakedefine HAVE_GETHOSTNAME 1 + +/* Define to 1 if you have a working getifaddrs function. */ +#cmakedefine HAVE_GETIFADDRS 1 + +/* Define to 1 if you have the getnameinfo function. */ +#cmakedefine HAVE_GETNAMEINFO 1 + +/* Define to 1 if you have the `getpass_r' function. */ +#cmakedefine HAVE_GETPASS_R 1 + +/* Define to 1 if you have the `getppid' function. */ +#cmakedefine HAVE_GETPPID 1 + +/* Define to 1 if you have the `getprotobyname' function. */ +#cmakedefine HAVE_GETPROTOBYNAME 1 + +/* Define to 1 if you have the `getpwuid' function. */ +#cmakedefine HAVE_GETPWUID 1 + +/* Define to 1 if you have the `getrlimit' function. */ +#cmakedefine HAVE_GETRLIMIT 1 + +/* Define to 1 if you have the getservbyport_r function. */ +#cmakedefine HAVE_GETSERVBYPORT_R 1 + +/* Define to 1 if you have the `gettimeofday' function. */ +#cmakedefine HAVE_GETTIMEOFDAY 1 + +/* Define to 1 if you have a working glibc-style strerror_r function. */ +#cmakedefine HAVE_GLIBC_STRERROR_R 1 + +/* Define to 1 if you have a working gmtime_r function. */ +#cmakedefine HAVE_GMTIME_R 1 + +/* if you have the gssapi libraries */ +#cmakedefine HAVE_GSSAPI 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_GSSAPI_GSSAPI_GENERIC_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_GSSAPI_GSSAPI_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_GSSAPI_GSSAPI_KRB5_H 1 + +/* if you have the GNU gssapi libraries */ +#cmakedefine HAVE_GSSGNU 1 + +/* if you have the Heimdal gssapi libraries */ +#cmakedefine HAVE_GSSHEIMDAL 1 + +/* if you have the MIT gssapi libraries */ +#cmakedefine HAVE_GSSMIT 1 + +/* Define to 1 if you have the `idna_strerror' function. */ +#cmakedefine HAVE_IDNA_STRERROR 1 + +/* Define to 1 if you have the `idn_free' function. */ +#cmakedefine HAVE_IDN_FREE 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_IDN_FREE_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_IFADDRS_H 1 + +/* Define to 1 if you have the `inet_addr' function. */ +#cmakedefine HAVE_INET_ADDR 1 + +/* Define to 1 if you have the inet_ntoa_r function. */ +#cmakedefine HAVE_INET_NTOA_R 1 + +/* inet_ntoa_r() takes 2 args */ +#cmakedefine HAVE_INET_NTOA_R_2 1 + +/* inet_ntoa_r() takes 3 args */ +#cmakedefine HAVE_INET_NTOA_R_3 1 + +/* Define to 1 if you have a IPv6 capable working inet_ntop function. */ +#cmakedefine HAVE_INET_NTOP 1 + +/* Define to 1 if you have a IPv6 capable working inet_pton function. */ +#cmakedefine HAVE_INET_PTON 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the ioctl function. */ +#cmakedefine HAVE_IOCTL 1 + +/* Define to 1 if you have the ioctlsocket function. */ +#cmakedefine HAVE_IOCTLSOCKET 1 + +/* Define to 1 if you have the IoctlSocket camel case function. */ +#cmakedefine HAVE_IOCTLSOCKET_CAMEL 1 + +/* Define to 1 if you have a working IoctlSocket camel case FIONBIO function. + */ +#cmakedefine HAVE_IOCTLSOCKET_CAMEL_FIONBIO 1 + +/* Define to 1 if you have a working ioctlsocket FIONBIO function. */ +#cmakedefine HAVE_IOCTLSOCKET_FIONBIO 1 + +/* Define to 1 if you have a working ioctl FIONBIO function. */ +#cmakedefine HAVE_IOCTL_FIONBIO 1 + +/* Define to 1 if you have a working ioctl SIOCGIFADDR function. */ +#cmakedefine HAVE_IOCTL_SIOCGIFADDR 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_IO_H 1 + +/* if you have the Kerberos4 libraries (including -ldes) */ +#cmakedefine HAVE_KRB4 1 + +/* Define to 1 if you have the `krb_get_our_ip_for_realm' function. */ +#cmakedefine HAVE_KRB_GET_OUR_IP_FOR_REALM 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_KRB_H 1 + +/* Define to 1 if you have the lber.h header file. */ +#cmakedefine HAVE_LBER_H 1 + +/* Define to 1 if you have the ldapssl.h header file. */ +#cmakedefine HAVE_LDAPSSL_H 1 + +/* Define to 1 if you have the ldap.h header file. */ +#cmakedefine HAVE_LDAP_H 1 + +/* Use LDAPS implementation */ +#cmakedefine HAVE_LDAP_SSL 1 + +/* Define to 1 if you have the ldap_ssl.h header file. */ +#cmakedefine HAVE_LDAP_SSL_H 1 + +/* Define to 1 if you have the `ldap_url_parse' function. */ +#cmakedefine HAVE_LDAP_URL_PARSE 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_LIBGEN_H 1 + +/* Define to 1 if you have the `idn' library (-lidn). */ +#cmakedefine HAVE_LIBIDN 1 + +/* Define to 1 if you have the `resolv' library (-lresolv). */ +#cmakedefine HAVE_LIBRESOLV 1 + +/* Define to 1 if you have the `resolve' library (-lresolve). */ +#cmakedefine HAVE_LIBRESOLVE 1 + +/* Define to 1 if you have the `socket' library (-lsocket). */ +#cmakedefine HAVE_LIBSOCKET 1 + +/* Define to 1 if you have the `ssh2' library (-lssh2). */ +#cmakedefine HAVE_LIBSSH2 1 + +/* Define to 1 if libssh2 provides `libssh2_version'. */ +#cmakedefine HAVE_LIBSSH2_VERSION 1 + +/* Define to 1 if libssh2 provides `libssh2_init'. */ +#cmakedefine HAVE_LIBSSH2_INIT 1 + +/* Define to 1 if libssh2 provides `libssh2_exit'. */ +#cmakedefine HAVE_LIBSSH2_EXIT 1 + +/* Define to 1 if libssh2 provides `libssh2_scp_send64'. */ +#cmakedefine HAVE_LIBSSH2_SCP_SEND64 1 + +/* Define to 1 if libssh2 provides `libssh2_session_handshake'. */ +#cmakedefine HAVE_LIBSSH2_SESSION_HANDSHAKE 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_LIBSSH2_H 1 + +/* Define to 1 if you have the `ssl' library (-lssl). */ +#cmakedefine HAVE_LIBSSL 1 + +/* if zlib is available */ +#cmakedefine HAVE_LIBZ 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_LIMITS_H 1 + +/* if your compiler supports LL */ +#cmakedefine HAVE_LL 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_LOCALE_H 1 + +/* Define to 1 if you have a working localtime_r function. */ +#cmakedefine HAVE_LOCALTIME_R 1 + +/* Define to 1 if the compiler supports the 'long long' data type. */ +#cmakedefine HAVE_LONGLONG 1 + +/* Define to 1 if you have the malloc.h header file. */ +#cmakedefine HAVE_MALLOC_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_MEMORY_H 1 + +/* Define to 1 if you have the MSG_NOSIGNAL flag. */ +#cmakedefine HAVE_MSG_NOSIGNAL 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_NETDB_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_NETINET_IN_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_NETINET_TCP_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_NET_IF_H 1 + +/* Define to 1 if NI_WITHSCOPEID exists and works. */ +#cmakedefine HAVE_NI_WITHSCOPEID 1 + +/* if you have an old MIT gssapi library, lacking GSS_C_NT_HOSTBASED_SERVICE */ +#cmakedefine HAVE_OLD_GSSMIT 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_OPENSSL_CRYPTO_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_OPENSSL_ENGINE_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_OPENSSL_ERR_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_OPENSSL_PEM_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_OPENSSL_PKCS12_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_OPENSSL_RSA_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_OPENSSL_SSL_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_OPENSSL_X509_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_PEM_H 1 + +/* Define to 1 if you have the `perror' function. */ +#cmakedefine HAVE_PERROR 1 + +/* Define to 1 if you have the `pipe' function. */ +#cmakedefine HAVE_PIPE 1 + +/* Define to 1 if you have a working poll function. */ +#cmakedefine HAVE_POLL 1 + +/* If you have a fine poll */ +#cmakedefine HAVE_POLL_FINE 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_POLL_H 1 + +/* Define to 1 if you have a working POSIX-style strerror_r function. */ +#cmakedefine HAVE_POSIX_STRERROR_R 1 + ++/* Define to 1 if you have the header file */ ++#cmakedefine HAVE_PTHREAD_H 1 ++ +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_PWD_H 1 + +/* Define to 1 if you have the `RAND_egd' function. */ +#cmakedefine HAVE_RAND_EGD 1 + +/* Define to 1 if you have the `RAND_screen' function. */ +#cmakedefine HAVE_RAND_SCREEN 1 + +/* Define to 1 if you have the `RAND_status' function. */ +#cmakedefine HAVE_RAND_STATUS 1 + +/* Define to 1 if you have the recv function. */ +#cmakedefine HAVE_RECV 1 + +/* Define to 1 if you have the recvfrom function. */ +#cmakedefine HAVE_RECVFROM 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_RSA_H 1 + +/* Define to 1 if you have the select function. */ +#cmakedefine HAVE_SELECT 1 + +/* Define to 1 if you have the send function. */ +#cmakedefine HAVE_SEND 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SETJMP_H 1 + +/* Define to 1 if you have the `setlocale' function. */ +#cmakedefine HAVE_SETLOCALE 1 + +/* Define to 1 if you have the `setmode' function. */ +#cmakedefine HAVE_SETMODE 1 + +/* Define to 1 if you have the `setrlimit' function. */ +#cmakedefine HAVE_SETRLIMIT 1 + +/* Define to 1 if you have the setsockopt function. */ +#cmakedefine HAVE_SETSOCKOPT 1 + +/* Define to 1 if you have a working setsockopt SO_NONBLOCK function. */ +#cmakedefine HAVE_SETSOCKOPT_SO_NONBLOCK 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SGTTY_H 1 + +/* Define to 1 if you have the sigaction function. */ +#cmakedefine HAVE_SIGACTION 1 + +/* Define to 1 if you have the siginterrupt function. */ +#cmakedefine HAVE_SIGINTERRUPT 1 + +/* Define to 1 if you have the signal function. */ +#cmakedefine HAVE_SIGNAL 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SIGNAL_H 1 + +/* Define to 1 if you have the sigsetjmp function or macro. */ +#cmakedefine HAVE_SIGSETJMP 1 + +/* Define to 1 if sig_atomic_t is an available typedef. */ +#cmakedefine HAVE_SIG_ATOMIC_T 1 + +/* Define to 1 if sig_atomic_t is already defined as volatile. */ +#cmakedefine HAVE_SIG_ATOMIC_T_VOLATILE 1 + +/* Define to 1 if struct sockaddr_in6 has the sin6_scope_id member */ +#cmakedefine HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID 1 + +/* Define to 1 if you have the `socket' function. */ +#cmakedefine HAVE_SOCKET 1 + +/* Define to 1 if you have the `SSL_get_shutdown' function. */ +#cmakedefine HAVE_SSL_GET_SHUTDOWN 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SSL_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STDBOOL_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STDIO_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STDLIB_H 1 + +/* Define to 1 if you have the strcasecmp function. */ +#cmakedefine HAVE_STRCASECMP 1 + +/* Define to 1 if you have the strcasestr function. */ +#cmakedefine HAVE_STRCASESTR 1 + +/* Define to 1 if you have the strcmpi function. */ +#cmakedefine HAVE_STRCMPI 1 + +/* Define to 1 if you have the strdup function. */ +#cmakedefine HAVE_STRDUP 1 + +/* Define to 1 if you have the strerror_r function. */ +#cmakedefine HAVE_STRERROR_R 1 + +/* Define to 1 if you have the stricmp function. */ +#cmakedefine HAVE_STRICMP 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STRING_H 1 + +/* Define to 1 if you have the strlcat function. */ +#cmakedefine HAVE_STRLCAT 1 + +/* Define to 1 if you have the `strlcpy' function. */ +#cmakedefine HAVE_STRLCPY 1 + +/* Define to 1 if you have the strncasecmp function. */ +#cmakedefine HAVE_STRNCASECMP 1 + +/* Define to 1 if you have the strncmpi function. */ +#cmakedefine HAVE_STRNCMPI 1 + +/* Define to 1 if you have the strnicmp function. */ +#cmakedefine HAVE_STRNICMP 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STROPTS_H 1 + +/* Define to 1 if you have the strstr function. */ +#cmakedefine HAVE_STRSTR 1 + +/* Define to 1 if you have the strtok_r function. */ +#cmakedefine HAVE_STRTOK_R 1 + +/* Define to 1 if you have the strtoll function. */ +#cmakedefine HAVE_STRTOLL 1 + +/* if struct sockaddr_storage is defined */ +#cmakedefine HAVE_STRUCT_SOCKADDR_STORAGE 1 + +/* Define to 1 if you have the timeval struct. */ +#cmakedefine HAVE_STRUCT_TIMEVAL 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_FILIO_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_IOCTL_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_POLL_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_RESOURCE_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_SELECT_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_SOCKET_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_SOCKIO_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_UIO_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_UN_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_UTIME_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_TERMIOS_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_TERMIO_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_TLD_H 1 + +/* Define to 1 if you have the `tld_strerror' function. */ +#cmakedefine HAVE_TLD_STRERROR 1 + +/* Define to 1 if you have the `uname' function. */ +#cmakedefine HAVE_UNAME 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_UNISTD_H 1 + +/* Define to 1 if you have the `utime' function. */ +#cmakedefine HAVE_UTIME 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_UTIME_H 1 + +/* Define to 1 if compiler supports C99 variadic macro style. */ +#cmakedefine HAVE_VARIADIC_MACROS_C99 1 + +/* Define to 1 if compiler supports old gcc variadic macro style. */ +#cmakedefine HAVE_VARIADIC_MACROS_GCC 1 + +/* Define to 1 if you have the winber.h header file. */ +#cmakedefine HAVE_WINBER_H 1 + +/* Define to 1 if you have the windows.h header file. */ +#cmakedefine HAVE_WINDOWS_H 1 + +/* Define to 1 if you have the winldap.h header file. */ +#cmakedefine HAVE_WINLDAP_H 1 + +/* Define to 1 if you have the winsock2.h header file. */ +#cmakedefine HAVE_WINSOCK2_H 1 + +/* Define to 1 if you have the winsock.h header file. */ +#cmakedefine HAVE_WINSOCK_H 1 + +/* Define this symbol if your OS supports changing the contents of argv */ +#cmakedefine HAVE_WRITABLE_ARGV 1 + +/* Define to 1 if you have the writev function. */ +#cmakedefine HAVE_WRITEV 1 + +/* Define to 1 if you have the ws2tcpip.h header file. */ +#cmakedefine HAVE_WS2TCPIP_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_X509_H 1 + +/* Define if you have the header file. */ +#cmakedefine HAVE_PROCESS_H 1 + +/* if you have the zlib.h header file */ +#cmakedefine HAVE_ZLIB_H 1 + +/* Define to the sub-directory in which libtool stores uninstalled libraries. + */ +#cmakedefine LT_OBJDIR ${LT_OBJDIR} + +/* If you lack a fine basename() prototype */ +#cmakedefine NEED_BASENAME_PROTO 1 + +/* Define to 1 if you need the lber.h header file even with ldap.h */ +#cmakedefine NEED_LBER_H 1 + +/* Define to 1 if you need the malloc.h header file even with stdlib.h */ +#cmakedefine NEED_MALLOC_H 1 + +/* Define to 1 if _REENTRANT preprocessor symbol must be defined. */ +#cmakedefine NEED_REENTRANT 1 + +/* cpu-machine-OS */ +#cmakedefine OS ${OS} + +/* Name of package */ +#cmakedefine PACKAGE ${PACKAGE} + +/* Define to the address where bug reports for this package should be sent. */ +#cmakedefine PACKAGE_BUGREPORT ${PACKAGE_BUGREPORT} + +/* Define to the full name of this package. */ +#cmakedefine PACKAGE_NAME ${PACKAGE_NAME} + +/* Define to the full name and version of this package. */ +#cmakedefine PACKAGE_STRING ${PACKAGE_STRING} + +/* Define to the one symbol short name of this package. */ +#cmakedefine PACKAGE_TARNAME ${PACKAGE_TARNAME} + +/* Define to the version of this package. */ +#cmakedefine PACKAGE_VERSION ${PACKAGE_VERSION} + +/* a suitable file to read random data from */ +#cmakedefine RANDOM_FILE "${RANDOM_FILE}" + +/* Define to the type of arg 1 for recvfrom. */ +#cmakedefine RECVFROM_TYPE_ARG1 ${RECVFROM_TYPE_ARG1} + +/* Define to the type pointed by arg 2 for recvfrom. */ +#cmakedefine RECVFROM_TYPE_ARG2 ${RECVFROM_TYPE_ARG2} + +/* Define to 1 if the type pointed by arg 2 for recvfrom is void. */ +#cmakedefine RECVFROM_TYPE_ARG2_IS_VOID 1 + +/* Define to the type of arg 3 for recvfrom. */ +#cmakedefine RECVFROM_TYPE_ARG3 ${RECVFROM_TYPE_ARG3} + +/* Define to the type of arg 4 for recvfrom. */ +#cmakedefine RECVFROM_TYPE_ARG4 ${RECVFROM_TYPE_ARG4} + +/* Define to the type pointed by arg 5 for recvfrom. */ +#cmakedefine RECVFROM_TYPE_ARG5 ${RECVFROM_TYPE_ARG5} + +/* Define to 1 if the type pointed by arg 5 for recvfrom is void. */ +#cmakedefine RECVFROM_TYPE_ARG5_IS_VOID 1 + +/* Define to the type pointed by arg 6 for recvfrom. */ +#cmakedefine RECVFROM_TYPE_ARG6 ${RECVFROM_TYPE_ARG6} + +/* Define to 1 if the type pointed by arg 6 for recvfrom is void. */ +#cmakedefine RECVFROM_TYPE_ARG6_IS_VOID 1 + +/* Define to the function return type for recvfrom. */ +#cmakedefine RECVFROM_TYPE_RETV ${RECVFROM_TYPE_RETV} + +/* Define to the type of arg 1 for recv. */ +#cmakedefine RECV_TYPE_ARG1 ${RECV_TYPE_ARG1} + +/* Define to the type of arg 2 for recv. */ +#cmakedefine RECV_TYPE_ARG2 ${RECV_TYPE_ARG2} + +/* Define to the type of arg 3 for recv. */ +#cmakedefine RECV_TYPE_ARG3 ${RECV_TYPE_ARG3} + +/* Define to the type of arg 4 for recv. */ +#cmakedefine RECV_TYPE_ARG4 ${RECV_TYPE_ARG4} + +/* Define to the function return type for recv. */ +#cmakedefine RECV_TYPE_RETV ${RECV_TYPE_RETV} + +/* Define as the return type of signal handlers (`int' or `void'). */ +#cmakedefine RETSIGTYPE ${RETSIGTYPE} + +/* Define to the type qualifier of arg 5 for select. */ +#cmakedefine SELECT_QUAL_ARG5 ${SELECT_QUAL_ARG5} + +/* Define to the type of arg 1 for select. */ +#cmakedefine SELECT_TYPE_ARG1 ${SELECT_TYPE_ARG1} + +/* Define to the type of args 2, 3 and 4 for select. */ +#cmakedefine SELECT_TYPE_ARG234 ${SELECT_TYPE_ARG234} + +/* Define to the type of arg 5 for select. */ +#cmakedefine SELECT_TYPE_ARG5 ${SELECT_TYPE_ARG5} + +/* Define to the function return type for select. */ +#cmakedefine SELECT_TYPE_RETV ${SELECT_TYPE_RETV} + +/* Define to the type qualifier of arg 2 for send. */ +#cmakedefine SEND_QUAL_ARG2 ${SEND_QUAL_ARG2} + +/* Define to the type of arg 1 for send. */ +#cmakedefine SEND_TYPE_ARG1 ${SEND_TYPE_ARG1} + +/* Define to the type of arg 2 for send. */ +#cmakedefine SEND_TYPE_ARG2 ${SEND_TYPE_ARG2} + +/* Define to the type of arg 3 for send. */ +#cmakedefine SEND_TYPE_ARG3 ${SEND_TYPE_ARG3} + +/* Define to the type of arg 4 for send. */ +#cmakedefine SEND_TYPE_ARG4 ${SEND_TYPE_ARG4} + +/* Define to the function return type for send. */ +#cmakedefine SEND_TYPE_RETV ${SEND_TYPE_RETV} + +/* The size of `int', as computed by sizeof. */ + at SIZEOF_INT_CODE@ + +/* The size of `short', as computed by sizeof. */ + at SIZEOF_SHORT_CODE@ + +/* The size of `long', as computed by sizeof. */ + at SIZEOF_LONG_CODE@ + +/* The size of `off_t', as computed by sizeof. */ + at SIZEOF_OFF_T_CODE@ + +/* The size of `size_t', as computed by sizeof. */ + at SIZEOF_SIZE_T_CODE@ + +/* The size of `ssize_t', as computed by sizeof. */ + at SIZEOF_SSIZE_T_CODE@ + +/* The size of `time_t', as computed by sizeof. */ + at SIZEOF_TIME_T_CODE@ + +/* Define to 1 if you have the ANSI C header files. */ +#cmakedefine STDC_HEADERS 1 + +/* Define to the type of arg 3 for strerror_r. */ +#cmakedefine STRERROR_R_TYPE_ARG3 ${STRERROR_R_TYPE_ARG3} + +/* Define to 1 if you can safely include both and . */ +#cmakedefine TIME_WITH_SYS_TIME 1 + +/* Define if you want to enable c-ares support */ +#cmakedefine USE_ARES 1 + ++/* Define if you want to enable POSIX threaded DNS lookup */ ++#cmakedefine USE_THREADS_POSIX 1 ++ +/* Define to disable non-blocking sockets. */ +#cmakedefine USE_BLOCKING_SOCKETS 1 + +/* if GnuTLS is enabled */ +#cmakedefine USE_GNUTLS 1 + +/* if PolarSSL is enabled */ +#cmakedefine USE_POLARSSL 1 + +/* if libSSH2 is in use */ +#cmakedefine USE_LIBSSH2 1 + +/* If you want to build curl with the built-in manual */ +#cmakedefine USE_MANUAL 1 + +/* if NSS is enabled */ +#cmakedefine USE_NSS 1 + +/* if you want to use OpenLDAP code instead of legacy ldap implementation */ +#cmakedefine USE_OPENLDAP 1 + +/* if OpenSSL is in use */ +#cmakedefine USE_OPENSSL 1 + - /* if SSL is enabled */ - #cmakedefine USE_SSLEAY 1 ++/* if Unix domain sockets are enabled */ ++#cmakedefine USE_UNIX_SOCKETS + +/* to enable SSPI support */ +#cmakedefine USE_WINDOWS_SSPI 1 + +/* Define to 1 if using yaSSL in OpenSSL compatibility mode. */ +#cmakedefine USE_YASSLEMUL 1 + +/* Version number of package */ +#cmakedefine VERSION ${VERSION} + +/* Define to avoid automatic inclusion of winsock.h */ +#cmakedefine WIN32_LEAN_AND_MEAN 1 + +/* Define to 1 if OS is AIX. */ +#ifndef _ALL_SOURCE +# undef _ALL_SOURCE +#endif + +/* Number of bits in a file offset, on hosts where this is settable. */ +#cmakedefine _FILE_OFFSET_BITS ${_FILE_OFFSET_BITS} + +/* Define for large files, on AIX-style hosts. */ +#cmakedefine _LARGE_FILES ${_LARGE_FILES} + +/* define this if you need it to compile thread-safe code */ +#cmakedefine _THREAD_SAFE ${_THREAD_SAFE} + +/* Define to empty if `const' does not conform to ANSI C. */ +#cmakedefine const ${const} + +/* Type to use in place of in_addr_t when system does not provide it. */ +#cmakedefine in_addr_t ${in_addr_t} + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +#undef inline +#endif + +/* Define to `unsigned int' if does not define. */ +#cmakedefine size_t ${size_t} + +/* the signed version of size_t */ +#ifndef SIZEOF_SSIZE_T +# if SIZEOF_LONG == SIZEOF_SIZE_T + typedef long ssize_t; +# elif SIZEOF_LONG_LONG == SIZEOF_SIZE_T + typedef long long ssize_t; +# elif SIZEOF___INT64 == SIZEOF_SIZE_T + typedef __int64 ssize_t; +# else + typedef int ssize_t; +# endif +#endif diff --cc Utilities/cmcurl/lib/curl_des.c index 0000000,42c1df9..42c1df9 mode 000000,100644..100644 --- a/Utilities/cmcurl/lib/curl_des.c +++ b/Utilities/cmcurl/lib/curl_des.c diff --cc Utilities/cmcurl/lib/curl_endian.c index 0000000,bcd66ed..bcd66ed mode 000000,100644..100644 --- a/Utilities/cmcurl/lib/curl_endian.c +++ b/Utilities/cmcurl/lib/curl_endian.c diff --cc Utilities/cmcurl/lib/curl_endian.h index 0000000,e384279..e384279 mode 000000,100644..100644 --- a/Utilities/cmcurl/lib/curl_endian.h +++ b/Utilities/cmcurl/lib/curl_endian.h diff --cc Utilities/cmcurl/lib/curl_sasl_gssapi.c index 0000000,3c6f3ce..3c6f3ce mode 000000,100644..100644 --- a/Utilities/cmcurl/lib/curl_sasl_gssapi.c +++ b/Utilities/cmcurl/lib/curl_sasl_gssapi.c diff --cc Utilities/cmcurl/lib/curl_setup.h index 9cc5758,0000000..19c1baf mode 100644,000000..100644 --- a/Utilities/cmcurl/lib/curl_setup.h +++ b/Utilities/cmcurl/lib/curl_setup.h @@@ -1,708 -1,0 +1,745 @@@ +#ifndef HEADER_CURL_SETUP_H +#define HEADER_CURL_SETUP_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * - * Copyright (C) 1998 - 2013, Daniel Stenberg, , et al. ++ * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ + +/* + * Define WIN32 when build target is Win32 API + */ + +#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) && \ + !defined(__SYMBIAN32__) +#define WIN32 +#endif + +/* + * Include configuration script results or hand-crafted + * configuration file for platforms which lack config tool. + */ + +#ifdef HAVE_CONFIG_H + +#include "curl_config.h" + +#else /* HAVE_CONFIG_H */ + +#ifdef _WIN32_WCE +# include "config-win32ce.h" +#else +# ifdef WIN32 +# include "config-win32.h" +# endif +#endif + +#if defined(macintosh) && defined(__MRC__) +# include "config-mac.h" +#endif + +#ifdef __riscos__ +# include "config-riscos.h" +#endif + +#ifdef __AMIGA__ +# include "config-amigaos.h" +#endif + +#ifdef __SYMBIAN32__ +# include "config-symbian.h" +#endif + +#ifdef __OS400__ +# include "config-os400.h" +#endif + +#ifdef TPF +# include "config-tpf.h" +#endif + +#ifdef __VXWORKS__ +# include "config-vxworks.h" +#endif + +#endif /* HAVE_CONFIG_H */ + +#if defined(_MSC_VER) +# pragma warning(push,1) +#endif + +/* ================================================================ */ +/* Definition of preprocessor macros/symbols which modify compiler */ +/* behavior or generated code characteristics must be done here, */ +/* as appropriate, before any system header file is included. It is */ +/* also possible to have them defined in the config file included */ +/* before this point. As a result of all this we frown inclusion of */ +/* system header files in our config files, avoid this at any cost. */ +/* ================================================================ */ + +/* + * AIX 4.3 and newer needs _THREAD_SAFE defined to build + * proper reentrant code. Others may also need it. + */ + +#ifdef NEED_THREAD_SAFE +# ifndef _THREAD_SAFE +# define _THREAD_SAFE +# endif +#endif + +/* + * Tru64 needs _REENTRANT set for a few function prototypes and + * things to appear in the system header files. Unixware needs it + * to build proper reentrant code. Others may also need it. + */ + +#ifdef NEED_REENTRANT +# ifndef _REENTRANT +# define _REENTRANT +# endif +#endif + +/* Solaris needs this to get a POSIX-conformant getpwuid_r */ +#if defined(sun) || defined(__sun) +# ifndef _POSIX_PTHREAD_SEMANTICS +# define _POSIX_PTHREAD_SEMANTICS 1 +# endif +#endif + +/* ================================================================ */ +/* If you need to include a system header file for your platform, */ +/* please, do it beyond the point further indicated in this file. */ +/* ================================================================ */ + +/* + * libcurl's external interface definitions are also used internally, + * and might also include required system header files to define them. + */ + +#include + +/* + * Compile time sanity checks must also be done when building the library. + */ + +#include + +/* + * Ensure that no one is using the old SIZEOF_CURL_OFF_T macro + */ + +#ifdef SIZEOF_CURL_OFF_T +# error "SIZEOF_CURL_OFF_T shall not be defined!" + Error Compilation_aborted_SIZEOF_CURL_OFF_T_shall_not_be_defined +#endif + +/* + * Disable other protocols when http is the only one desired. + */ + +#ifdef HTTP_ONLY +# ifndef CURL_DISABLE_TFTP +# define CURL_DISABLE_TFTP +# endif +# ifndef CURL_DISABLE_FTP +# define CURL_DISABLE_FTP +# endif +# ifndef CURL_DISABLE_LDAP +# define CURL_DISABLE_LDAP +# endif +# ifndef CURL_DISABLE_TELNET +# define CURL_DISABLE_TELNET +# endif +# ifndef CURL_DISABLE_DICT +# define CURL_DISABLE_DICT +# endif +# ifndef CURL_DISABLE_FILE +# define CURL_DISABLE_FILE +# endif +# ifndef CURL_DISABLE_RTSP +# define CURL_DISABLE_RTSP +# endif +# ifndef CURL_DISABLE_POP3 +# define CURL_DISABLE_POP3 +# endif +# ifndef CURL_DISABLE_IMAP +# define CURL_DISABLE_IMAP +# endif +# ifndef CURL_DISABLE_SMTP +# define CURL_DISABLE_SMTP +# endif +# ifndef CURL_DISABLE_RTSP +# define CURL_DISABLE_RTSP +# endif +# ifndef CURL_DISABLE_RTMP +# define CURL_DISABLE_RTMP +# endif +# ifndef CURL_DISABLE_GOPHER +# define CURL_DISABLE_GOPHER +# endif ++# ifndef CURL_DISABLE_SMB ++# define CURL_DISABLE_SMB ++# endif +#endif + +/* + * When http is disabled rtsp is not supported. + */ + +#if defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_RTSP) +# define CURL_DISABLE_RTSP +#endif + +/* ================================================================ */ +/* No system header file shall be included in this file before this */ +/* point. The only allowed ones are those included from curlbuild.h */ +/* ================================================================ */ + +/* + * OS/400 setup file includes some system headers. + */ + +#ifdef __OS400__ +# include "setup-os400.h" +#endif + +/* + * VMS setup file includes some system headers. + */ + +#ifdef __VMS +# include "setup-vms.h" +#endif + +/* + * Include header files for windows builds before redefining anything. + * Use this preprocessor block only to include or exclude windows.h, + * winsock2.h, ws2tcpip.h or winsock.h. Any other windows thing belongs + * to any other further and independent block. Under Cygwin things work + * just as under linux (e.g. ) and the winsock headers should + * never be included when __CYGWIN__ is defined. configure script takes + * care of this, not defining HAVE_WINDOWS_H, HAVE_WINSOCK_H, HAVE_WINSOCK2_H, + * neither HAVE_WS2TCPIP_H when __CYGWIN__ is defined. + */ + +#ifdef HAVE_WINDOWS_H +# if defined(UNICODE) && !defined(_UNICODE) +# define _UNICODE +# endif +# if defined(_UNICODE) && !defined(UNICODE) +# define UNICODE +# endif +# ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +# endif +# include +# ifdef HAVE_WINSOCK2_H +# include +# ifdef HAVE_WS2TCPIP_H +# include +# endif +# else +# ifdef HAVE_WINSOCK_H +# include +# endif +# endif +# include +# ifdef UNICODE + typedef wchar_t *(*curl_wcsdup_callback)(const wchar_t *str); +# endif +#endif + +/* + * Define USE_WINSOCK to 2 if we have and use WINSOCK2 API, else + * define USE_WINSOCK to 1 if we have and use WINSOCK API, else + * undefine USE_WINSOCK. + */ + +#undef USE_WINSOCK + +#ifdef HAVE_WINSOCK2_H +# define USE_WINSOCK 2 +#else +# ifdef HAVE_WINSOCK_H +# define USE_WINSOCK 1 +# endif +#endif + +#ifdef USE_LWIPSOCK +# include +# include +# include +#endif + +#ifdef HAVE_EXTRA_STRICMP_H +# include +#endif + +#ifdef HAVE_EXTRA_STRDUP_H +# include +#endif + +#ifdef TPF +# include /* for bzero, strcasecmp, and strncasecmp */ +# include /* for strcpy and strlen */ +# include /* for rand and srand */ +# include /* for select and ioctl*/ +# include /* for in_addr_t definition */ +# include /* for tpf_process_signals */ + /* change which select is used for libcurl */ +# define select(a,b,c,d,e) tpf_select_libcurl(a,b,c,d,e) +#endif + +#ifdef __VXWORKS__ +# include /* for generic BSD socket functions */ +# include /* for basic I/O interface functions */ +#endif + +#ifdef __AMIGA__ +# ifndef __ixemul__ +# include +# include +# include +# include +# define select(a,b,c,d,e) WaitSelect(a,b,c,d,e,0) +# endif +#endif + +#include +#ifdef HAVE_ASSERT_H +#include +#endif + +#ifdef __TANDEM /* for nsr-tandem-nsk systems */ +#include +#endif + +#ifndef STDC_HEADERS /* no standard C headers! */ +#include +#endif + +#ifdef __POCC__ +# include +# include +# define sys_nerr EILSEQ +#endif + +/* + * Salford-C kludge section (mostly borrowed from wxWidgets). + */ +#ifdef __SALFORDC__ + #pragma suppress 353 /* Possible nested comments */ + #pragma suppress 593 /* Define not used */ + #pragma suppress 61 /* enum has no name */ + #pragma suppress 106 /* unnamed, unused parameter */ + #include +#endif + +/* Default Windows file API selection. */ +#ifdef _WIN32 +# if defined(_MSC_VER) && (_INTEGRAL_MAX_BITS >= 64) +# define USE_WIN32_LARGE_FILES +# elif defined(__MINGW32__) +# define USE_WIN32_LARGE_FILES +# else +# define USE_WIN32_SMALL_FILES +# endif +#endif + +/* + * Large file (>2Gb) support using WIN32 functions. + */ + +#ifdef USE_WIN32_LARGE_FILES +# include +# include +# include +# undef lseek +# define lseek(fdes,offset,whence) _lseeki64(fdes, offset, whence) +# undef fstat +# define fstat(fdes,stp) _fstati64(fdes, stp) +# undef stat +# define stat(fname,stp) _stati64(fname, stp) +# define struct_stat struct _stati64 +# define LSEEK_ERROR (__int64)-1 +#endif + +/* + * Small file (<2Gb) support using WIN32 functions. + */ + +#ifdef USE_WIN32_SMALL_FILES +# include +# include +# include +# ifndef _WIN32_WCE +# undef lseek +# define lseek(fdes,offset,whence) _lseek(fdes, (long)offset, whence) +# define fstat(fdes,stp) _fstat(fdes, stp) +# define stat(fname,stp) _stat(fname, stp) +# define struct_stat struct _stat +# endif +# define LSEEK_ERROR (long)-1 +#endif + +#ifndef struct_stat +# define struct_stat struct stat +#endif + +#ifndef LSEEK_ERROR +# define LSEEK_ERROR (off_t)-1 +#endif + +/* + * Default sizeof(off_t) in case it hasn't been defined in config file. + */ + +#ifndef SIZEOF_OFF_T +# if defined(__VMS) && !defined(__VAX) +# if defined(_LARGEFILE) +# define SIZEOF_OFF_T 8 +# endif +# elif defined(__OS400__) && defined(__ILEC400__) +# if defined(_LARGE_FILES) +# define SIZEOF_OFF_T 8 +# endif +# elif defined(__MVS__) && defined(__IBMC__) +# if defined(_LP64) || defined(_LARGE_FILES) +# define SIZEOF_OFF_T 8 +# endif +# elif defined(__370__) && defined(__IBMC__) +# if defined(_LP64) || defined(_LARGE_FILES) +# define SIZEOF_OFF_T 8 +# endif +# endif +# ifndef SIZEOF_OFF_T +# define SIZEOF_OFF_T 4 +# endif +#endif + +/* + * Arg 2 type for gethostname in case it hasn't been defined in config file. + */ + +#ifndef GETHOSTNAME_TYPE_ARG2 +# ifdef USE_WINSOCK +# define GETHOSTNAME_TYPE_ARG2 int +# else +# define GETHOSTNAME_TYPE_ARG2 size_t +# endif +#endif + +/* Below we define some functions. They should + + 4. set the SIGALRM signal timeout + 5. set dir/file naming defines + */ + +#ifdef WIN32 + +# define DIR_CHAR "\\" +# define DOT_CHAR "_" + +#else /* WIN32 */ + +# ifdef MSDOS /* Watt-32 */ + +# include +# define select(n,r,w,x,t) select_s(n,r,w,x,t) +# define ioctl(x,y,z) ioctlsocket(x,y,(char *)(z)) +# include +# ifdef word +# undef word +# endif +# ifdef byte +# undef byte +# endif + +# endif /* MSDOS */ + +# ifdef __minix + /* Minix 3 versions up to at least 3.1.3 are missing these prototypes */ + extern char * strtok_r(char *s, const char *delim, char **last); + extern struct tm * gmtime_r(const time_t * const timep, struct tm *tmp); +# endif + +# define DIR_CHAR "/" +# ifndef DOT_CHAR +# define DOT_CHAR "." +# endif + +# ifdef MSDOS +# undef DOT_CHAR +# define DOT_CHAR "_" +# endif + +# ifndef fileno /* sunos 4 have this as a macro! */ + int fileno( FILE *stream); +# endif + +#endif /* WIN32 */ + +/* + * msvc 6.0 requires PSDK in order to have INET6_ADDRSTRLEN + * defined in ws2tcpip.h as well as to provide IPv6 support. + */ + +#if defined(_MSC_VER) && !defined(__POCC__) +# if !defined(HAVE_WS2TCPIP_H) || \ + ((_MSC_VER < 1300) && !defined(INET6_ADDRSTRLEN)) +# undef HAVE_GETADDRINFO_THREADSAFE +# undef HAVE_FREEADDRINFO +# undef HAVE_GETADDRINFO +# undef HAVE_GETNAMEINFO +# undef ENABLE_IPV6 +# endif +#endif + +/* ---------------------------------------------------------------- */ +/* resolver specialty compile-time defines */ +/* CURLRES_* defines to use in the host*.c sources */ +/* ---------------------------------------------------------------- */ + +/* + * lcc-win32 doesn't have _beginthreadex(), lacks threads support. + */ + +#if defined(__LCC__) && defined(WIN32) +# undef USE_THREADS_POSIX +# undef USE_THREADS_WIN32 +#endif + +/* + * MSVC threads support requires a multi-threaded runtime library. + * _beginthreadex() is not available in single-threaded ones. + */ + +#if defined(_MSC_VER) && !defined(__POCC__) && !defined(_MT) +# undef USE_THREADS_POSIX +# undef USE_THREADS_WIN32 +#endif + +/* + * Mutually exclusive CURLRES_* definitions. + */ + +#ifdef USE_ARES +# define CURLRES_ASYNCH +# define CURLRES_ARES +/* now undef the stock libc functions just to avoid them being used */ +# undef HAVE_GETADDRINFO +# undef HAVE_GETHOSTBYNAME +#elif defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32) +# define CURLRES_ASYNCH +# define CURLRES_THREADED +#else +# define CURLRES_SYNCH +#endif + +#ifdef ENABLE_IPV6 +# define CURLRES_IPV6 +#else +# define CURLRES_IPV4 +#endif + +/* ---------------------------------------------------------------- */ + +/* + * When using WINSOCK, TELNET protocol requires WINSOCK2 API. + */ + +#if defined(USE_WINSOCK) && (USE_WINSOCK != 2) +# define CURL_DISABLE_TELNET 1 +#endif + +/* + * msvc 6.0 does not have struct sockaddr_storage and + * does not define IPPROTO_ESP in winsock2.h. But both + * are available if PSDK is properly installed. + */ + +#if defined(_MSC_VER) && !defined(__POCC__) +# if !defined(HAVE_WINSOCK2_H) || ((_MSC_VER < 1300) && !defined(IPPROTO_ESP)) +# undef HAVE_STRUCT_SOCKADDR_STORAGE +# endif +#endif + +/* + * Intentionally fail to build when using msvc 6.0 without PSDK installed. + * The brave of heart can circumvent this, defining ALLOW_MSVC6_WITHOUT_PSDK + * in lib/config-win32.h although absolutely discouraged and unsupported. + */ + +#if defined(_MSC_VER) && !defined(__POCC__) +# if !defined(HAVE_WINDOWS_H) || ((_MSC_VER < 1300) && !defined(_FILETIME_)) +# if !defined(ALLOW_MSVC6_WITHOUT_PSDK) +# error MSVC 6.0 requires "February 2003 Platform SDK" a.k.a. \ + "Windows Server 2003 PSDK" +# else +# define CURL_DISABLE_LDAP 1 +# endif +# endif +#endif + +#ifdef NETWARE +int netware_init(void); +#ifndef __NOVELL_LIBC__ +#include +#include +#endif +#endif + +#if defined(HAVE_LIBIDN) && defined(HAVE_TLD_H) +/* The lib was present and the tld.h header (which is missing in libidn 0.3.X + but we only work with libidn 0.4.1 or later) */ +#define USE_LIBIDN +#endif + +#ifndef SIZEOF_TIME_T +/* assume default size of time_t to be 32 bit */ +#define SIZEOF_TIME_T 4 +#endif + +#define LIBIDN_REQUIRED_VERSION "0.4.1" + - #if defined(USE_GNUTLS) || defined(USE_SSLEAY) || defined(USE_NSS) || \ - defined(USE_QSOSSL) || defined(USE_POLARSSL) || defined(USE_AXTLS) || \ ++#if defined(USE_GNUTLS) || defined(USE_OPENSSL) || defined(USE_NSS) || \ ++ defined(USE_POLARSSL) || defined(USE_AXTLS) || \ + defined(USE_CYASSL) || defined(USE_SCHANNEL) || \ + defined(USE_DARWINSSL) || defined(USE_GSKIT) +#define USE_SSL /* SSL support has been enabled */ +#endif + ++/* Single point where USE_SPNEGO definition might be defined */ +#if !defined(CURL_DISABLE_CRYPTO_AUTH) && \ + (defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)) +#define USE_SPNEGO +#endif + - /* Single point where USE_NTLM definition might be done */ - #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_NTLM) && \ - !defined(CURL_DISABLE_CRYPTO_AUTH) - #if defined(USE_SSLEAY) || defined(USE_WINDOWS_SSPI) || \ - defined(USE_GNUTLS) || defined(USE_NSS) || defined(USE_DARWINSSL) ++/* Single point where USE_KERBEROS5 definition might be defined */ ++#if !defined(CURL_DISABLE_CRYPTO_AUTH) && \ ++ (defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)) ++#define USE_KERBEROS5 ++#endif ++ ++/* Single point where USE_NTLM definition might be defined */ ++#if !defined(CURL_DISABLE_NTLM) && !defined(CURL_DISABLE_CRYPTO_AUTH) ++#if defined(USE_OPENSSL) || defined(USE_WINDOWS_SSPI) || \ ++ defined(USE_GNUTLS) || defined(USE_NSS) || defined(USE_DARWINSSL) || \ ++ defined(USE_OS400CRYPTO) || defined(USE_WIN32_CRYPTO) ++ ++#ifdef HAVE_BORINGSSL /* BoringSSL is not NTLM capable */ ++#undef USE_NTLM ++#else +#define USE_NTLM +#endif +#endif ++#endif + +/* non-configure builds may define CURL_WANTS_CA_BUNDLE_ENV */ +#if defined(CURL_WANTS_CA_BUNDLE_ENV) && !defined(CURL_CA_BUNDLE) +#define CURL_CA_BUNDLE getenv("CURL_CA_BUNDLE") +#endif + +/* + * Provide a mechanism to silence picky compilers, such as gcc 4.6+. + * Parameters should of course normally not be unused, but for example when + * we have multiple implementations of the same interface it may happen. + */ + +#if defined(__GNUC__) && ((__GNUC__ >= 3) || \ + ((__GNUC__ == 2) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ >= 7))) +# define UNUSED_PARAM __attribute__((__unused__)) ++# define WARN_UNUSED_RESULT __attribute__((warn_unused_result)) +#else +# define UNUSED_PARAM /*NOTHING*/ ++# define WARN_UNUSED_RESULT +#endif + +/* + * Include macros and defines that should only be processed once. + */ + +#ifndef HEADER_CURL_SETUP_ONCE_H +#include "curl_setup_once.h" +#endif + +/* + * Definition of our NOP statement Object-like macro + */ + +#ifndef Curl_nop_stmt +# define Curl_nop_stmt do { } WHILE_FALSE +#endif + +/* + * Ensure that Winsock and lwIP TCP/IP stacks are not mixed. + */ + +#if defined(__LWIP_OPT_H__) +# if defined(SOCKET) || \ + defined(USE_WINSOCK) || \ + defined(HAVE_WINSOCK_H) || \ + defined(HAVE_WINSOCK2_H) || \ + defined(HAVE_WS2TCPIP_H) +# error "Winsock and lwIP TCP/IP stack definitions shall not coexist!" +# endif +#endif + +/* + * Portable symbolic names for Winsock shutdown() mode flags. + */ + +#ifdef USE_WINSOCK +# define SHUT_RD 0x00 +# define SHUT_WR 0x01 +# define SHUT_RDWR 0x02 +#endif + +/* Define S_ISREG if not defined by system headers, f.e. MSVC */ +#if !defined(S_ISREG) && defined(S_IFMT) && defined(S_IFREG) +#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +#endif + +/* Define S_ISDIR if not defined by system headers, f.e. MSVC */ +#if !defined(S_ISDIR) && defined(S_IFMT) && defined(S_IFDIR) +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#endif + ++/* In Windows the default file mode is text but an application can override it. ++Therefore we specify it explicitly. https://github.com/bagder/curl/pull/258 ++*/ ++#if defined(WIN32) || defined(MSDOS) ++#define FOPEN_READTEXT "rt" ++#define FOPEN_WRITETEXT "wt" ++#elif defined(__CYGWIN__) ++/* Cygwin has specific behavior we need to address when WIN32 is not defined. ++https://cygwin.com/cygwin-ug-net/using-textbinary.html ++For write we want our output to have line endings of LF and be compatible with ++other Cygwin utilities. For read we want to handle input that may have line ++endings either CRLF or LF so 't' is appropriate. ++*/ ++#define FOPEN_READTEXT "rt" ++#define FOPEN_WRITETEXT "w" ++#else ++#define FOPEN_READTEXT "r" ++#define FOPEN_WRITETEXT "w" ++#endif ++ +#endif /* HEADER_CURL_SETUP_H */ diff --cc Utilities/cmcurl/lib/ftp.c index 1644983,0000000..74c4032 mode 100644,000000..100644 --- a/Utilities/cmcurl/lib/ftp.c +++ b/Utilities/cmcurl/lib/ftp.c @@@ -1,4586 -1,0 +1,4599 @@@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. ++ * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ + +#include "curl_setup.h" + +#ifndef CURL_DISABLE_FTP + +#ifdef HAVE_NETINET_IN_H +#include +#endif +#ifdef HAVE_ARPA_INET_H +#include +#endif +#ifdef HAVE_UTSNAME_H +#include +#endif +#ifdef HAVE_NETDB_H +#include +#endif +#ifdef __VMS +#include +#include +#endif + +#if (defined(NETWARE) && defined(__NOVELL_LIBC__)) +#undef in_addr_t +#define in_addr_t unsigned long +#endif + +#include +#include "urldata.h" +#include "sendf.h" +#include "if2ip.h" +#include "hostip.h" +#include "progress.h" +#include "transfer.h" +#include "escape.h" +#include "http.h" /* for HTTP proxy tunnel stuff */ +#include "socks.h" +#include "ftp.h" +#include "fileinfo.h" +#include "ftplistparser.h" +#include "curl_sec.h" +#include "strtoofft.h" +#include "strequal.h" +#include "vtls/vtls.h" +#include "connect.h" +#include "strerror.h" +#include "inet_ntop.h" +#include "inet_pton.h" +#include "select.h" +#include "parsedate.h" /* for the week day and month names */ +#include "sockaddr.h" /* required for Curl_sockaddr_storage */ +#include "multiif.h" +#include "url.h" +#include "rawstr.h" +#include "speedcheck.h" +#include "warnless.h" +#include "http_proxy.h" +#include "non-ascii.h" - - #define _MPRINTF_REPLACE /* use our functions only */ - #include ++#include "curl_printf.h" + +#include "curl_memory.h" +/* The last #include file should be: */ +#include "memdebug.h" + +#ifndef NI_MAXHOST +#define NI_MAXHOST 1025 +#endif +#ifndef INET_ADDRSTRLEN +#define INET_ADDRSTRLEN 16 +#endif + +#ifdef CURL_DISABLE_VERBOSE_STRINGS +#define ftp_pasv_verbose(a,b,c,d) Curl_nop_stmt +#endif + +/* Local API functions */ +#ifndef DEBUGBUILD +static void _state(struct connectdata *conn, + ftpstate newstate); +#define state(x,y) _state(x,y) +#else +static void _state(struct connectdata *conn, + ftpstate newstate, + int lineno); +#define state(x,y) _state(x,y,__LINE__) +#endif + +static CURLcode ftp_sendquote(struct connectdata *conn, + struct curl_slist *quote); +static CURLcode ftp_quit(struct connectdata *conn); +static CURLcode ftp_parse_url_path(struct connectdata *conn); +static CURLcode ftp_regular_transfer(struct connectdata *conn, bool *done); +#ifndef CURL_DISABLE_VERBOSE_STRINGS +static void ftp_pasv_verbose(struct connectdata *conn, + Curl_addrinfo *ai, + char *newhost, /* ascii version */ + int port); +#endif +static CURLcode ftp_state_prepare_transfer(struct connectdata *conn); +static CURLcode ftp_state_mdtm(struct connectdata *conn); +static CURLcode ftp_state_quote(struct connectdata *conn, + bool init, ftpstate instate); +static CURLcode ftp_nb_type(struct connectdata *conn, + bool ascii, ftpstate newstate); +static int ftp_need_type(struct connectdata *conn, + bool ascii); +static CURLcode ftp_do(struct connectdata *conn, bool *done); +static CURLcode ftp_done(struct connectdata *conn, + CURLcode, bool premature); +static CURLcode ftp_connect(struct connectdata *conn, bool *done); +static CURLcode ftp_disconnect(struct connectdata *conn, bool dead_connection); +static CURLcode ftp_do_more(struct connectdata *conn, int *completed); +static CURLcode ftp_multi_statemach(struct connectdata *conn, bool *done); +static int ftp_getsock(struct connectdata *conn, curl_socket_t *socks, + int numsocks); +static int ftp_domore_getsock(struct connectdata *conn, curl_socket_t *socks, + int numsocks); +static CURLcode ftp_doing(struct connectdata *conn, + bool *dophase_done); +static CURLcode ftp_setup_connection(struct connectdata * conn); + +static CURLcode init_wc_data(struct connectdata *conn); +static CURLcode wc_statemach(struct connectdata *conn); + +static void wc_data_dtor(void *ptr); + +static CURLcode ftp_state_retr(struct connectdata *conn, curl_off_t filesize); + +static CURLcode ftp_readresp(curl_socket_t sockfd, + struct pingpong *pp, + int *ftpcode, + size_t *size); +static CURLcode ftp_dophase_done(struct connectdata *conn, + bool connected); + +/* easy-to-use macro: */ - #define PPSENDF(x,y,z) if((result = Curl_pp_sendf(x,y,z)) != CURLE_OK) \ ++#define PPSENDF(x,y,z) if((result = Curl_pp_sendf(x,y,z))) \ + return result + + +/* + * FTP protocol handler. + */ + +const struct Curl_handler Curl_handler_ftp = { + "FTP", /* scheme */ + ftp_setup_connection, /* setup_connection */ + ftp_do, /* do_it */ + ftp_done, /* done */ + ftp_do_more, /* do_more */ + ftp_connect, /* connect_it */ + ftp_multi_statemach, /* connecting */ + ftp_doing, /* doing */ + ftp_getsock, /* proto_getsock */ + ftp_getsock, /* doing_getsock */ + ftp_domore_getsock, /* domore_getsock */ + ZERO_NULL, /* perform_getsock */ + ftp_disconnect, /* disconnect */ + ZERO_NULL, /* readwrite */ + PORT_FTP, /* defport */ + CURLPROTO_FTP, /* protocol */ + PROTOPT_DUAL | PROTOPT_CLOSEACTION | PROTOPT_NEEDSPWD + | PROTOPT_NOURLQUERY /* flags */ +}; + + +#ifdef USE_SSL +/* + * FTPS protocol handler. + */ + +const struct Curl_handler Curl_handler_ftps = { + "FTPS", /* scheme */ + ftp_setup_connection, /* setup_connection */ + ftp_do, /* do_it */ + ftp_done, /* done */ + ftp_do_more, /* do_more */ + ftp_connect, /* connect_it */ + ftp_multi_statemach, /* connecting */ + ftp_doing, /* doing */ + ftp_getsock, /* proto_getsock */ + ftp_getsock, /* doing_getsock */ + ftp_domore_getsock, /* domore_getsock */ + ZERO_NULL, /* perform_getsock */ + ftp_disconnect, /* disconnect */ + ZERO_NULL, /* readwrite */ + PORT_FTPS, /* defport */ + CURLPROTO_FTPS, /* protocol */ + PROTOPT_SSL | PROTOPT_DUAL | PROTOPT_CLOSEACTION | + PROTOPT_NEEDSPWD | PROTOPT_NOURLQUERY /* flags */ +}; +#endif + +#ifndef CURL_DISABLE_HTTP +/* + * HTTP-proxyed FTP protocol handler. + */ + +static const struct Curl_handler Curl_handler_ftp_proxy = { + "FTP", /* scheme */ + Curl_http_setup_conn, /* setup_connection */ + Curl_http, /* do_it */ + Curl_http_done, /* done */ + ZERO_NULL, /* do_more */ + ZERO_NULL, /* connect_it */ + ZERO_NULL, /* connecting */ + ZERO_NULL, /* doing */ + ZERO_NULL, /* proto_getsock */ + ZERO_NULL, /* doing_getsock */ + ZERO_NULL, /* domore_getsock */ + ZERO_NULL, /* perform_getsock */ + ZERO_NULL, /* disconnect */ + ZERO_NULL, /* readwrite */ + PORT_FTP, /* defport */ + CURLPROTO_HTTP, /* protocol */ + PROTOPT_NONE /* flags */ +}; + + +#ifdef USE_SSL +/* + * HTTP-proxyed FTPS protocol handler. + */ + +static const struct Curl_handler Curl_handler_ftps_proxy = { + "FTPS", /* scheme */ + Curl_http_setup_conn, /* setup_connection */ + Curl_http, /* do_it */ + Curl_http_done, /* done */ + ZERO_NULL, /* do_more */ + ZERO_NULL, /* connect_it */ + ZERO_NULL, /* connecting */ + ZERO_NULL, /* doing */ + ZERO_NULL, /* proto_getsock */ + ZERO_NULL, /* doing_getsock */ + ZERO_NULL, /* domore_getsock */ + ZERO_NULL, /* perform_getsock */ + ZERO_NULL, /* disconnect */ + ZERO_NULL, /* readwrite */ + PORT_FTPS, /* defport */ + CURLPROTO_HTTP, /* protocol */ + PROTOPT_NONE /* flags */ +}; +#endif +#endif + + +/* + * NOTE: back in the old days, we added code in the FTP code that made NOBODY + * requests on files respond with headers passed to the client/stdout that + * looked like HTTP ones. + * + * This approach is not very elegant, it causes confusion and is error-prone. + * It is subject for removal at the next (or at least a future) soname bump. + * Until then you can test the effects of the removal by undefining the + * following define named CURL_FTP_HTTPSTYLE_HEAD. + */ +#define CURL_FTP_HTTPSTYLE_HEAD 1 + +static void freedirs(struct ftp_conn *ftpc) +{ + int i; + if(ftpc->dirs) { + for(i=0; i < ftpc->dirdepth; i++) { - if(ftpc->dirs[i]) { - free(ftpc->dirs[i]); - ftpc->dirs[i]=NULL; - } ++ free(ftpc->dirs[i]); ++ ftpc->dirs[i]=NULL; + } + free(ftpc->dirs); + ftpc->dirs = NULL; + ftpc->dirdepth = 0; + } - if(ftpc->file) { - free(ftpc->file); - ftpc->file = NULL; - } ++ Curl_safefree(ftpc->file); ++ ++ /* no longer of any use */ ++ Curl_safefree(ftpc->newhost); +} + +/* Returns non-zero if the given string contains CR (\r) or LF (\n), + which are not allowed within RFC 959 . + Note: The input string is in the client's encoding which might + not be ASCII, so escape sequences \r & \n must be used instead + of hex values 0x0d & 0x0a. +*/ +static bool isBadFtpString(const char *string) +{ + return ((NULL != strchr(string, '\r')) || + (NULL != strchr(string, '\n'))) ? TRUE : FALSE; +} + +/*********************************************************************** + * + * AcceptServerConnect() + * + * After connection request is received from the server this function is + * called to accept the connection and close the listening socket + * + */ +static CURLcode AcceptServerConnect(struct connectdata *conn) +{ + struct SessionHandle *data = conn->data; + curl_socket_t sock = conn->sock[SECONDARYSOCKET]; + curl_socket_t s = CURL_SOCKET_BAD; +#ifdef ENABLE_IPV6 + struct Curl_sockaddr_storage add; +#else + struct sockaddr_in add; +#endif + curl_socklen_t size = (curl_socklen_t) sizeof(add); + + if(0 == getsockname(sock, (struct sockaddr *) &add, &size)) { + size = sizeof(add); + + s=accept(sock, (struct sockaddr *) &add, &size); + } + Curl_closesocket(conn, sock); /* close the first socket */ + + if(CURL_SOCKET_BAD == s) { + failf(data, "Error accept()ing server connect"); + return CURLE_FTP_PORT_FAILED; + } + infof(data, "Connection accepted from server\n"); + + conn->sock[SECONDARYSOCKET] = s; - curlx_nonblock(s, TRUE); /* enable non-blocking */ ++ (void)curlx_nonblock(s, TRUE); /* enable non-blocking */ + conn->sock_accepted[SECONDARYSOCKET] = TRUE; + + if(data->set.fsockopt) { + int error = 0; + + /* activate callback for setting socket options */ + error = data->set.fsockopt(data->set.sockopt_client, + s, + CURLSOCKTYPE_ACCEPT); + + if(error) { + Curl_closesocket(conn, s); /* close the socket and bail out */ + conn->sock[SECONDARYSOCKET] = CURL_SOCKET_BAD; + return CURLE_ABORTED_BY_CALLBACK; + } + } + + return CURLE_OK; + +} + +/* + * ftp_timeleft_accept() returns the amount of milliseconds left allowed for + * waiting server to connect. If the value is negative, the timeout time has + * already elapsed. + * + * The start time is stored in progress.t_acceptdata - as set with + * Curl_pgrsTime(..., TIMER_STARTACCEPT); + * + */ +static long ftp_timeleft_accept(struct SessionHandle *data) +{ + long timeout_ms = DEFAULT_ACCEPT_TIMEOUT; + long other; + struct timeval now; + + if(data->set.accepttimeout > 0) + timeout_ms = data->set.accepttimeout; + + now = Curl_tvnow(); + + /* check if the generic timeout possibly is set shorter */ + other = Curl_timeleft(data, &now, FALSE); + if(other && (other < timeout_ms)) + /* note that this also works fine for when other happens to be negative + due to it already having elapsed */ + timeout_ms = other; + else { + /* subtract elapsed time */ + timeout_ms -= Curl_tvdiff(now, data->progress.t_acceptdata); + if(!timeout_ms) + /* avoid returning 0 as that means no timeout! */ + return -1; + } + + return timeout_ms; +} + + +/*********************************************************************** + * + * ReceivedServerConnect() + * + * After allowing server to connect to us from data port, this function + * checks both data connection for connection establishment and ctrl + * connection for a negative response regarding a failure in connecting + * + */ +static CURLcode ReceivedServerConnect(struct connectdata *conn, bool *received) +{ + struct SessionHandle *data = conn->data; + curl_socket_t ctrl_sock = conn->sock[FIRSTSOCKET]; + curl_socket_t data_sock = conn->sock[SECONDARYSOCKET]; + struct ftp_conn *ftpc = &conn->proto.ftpc; + struct pingpong *pp = &ftpc->pp; + int result; + long timeout_ms; + ssize_t nread; + int ftpcode; + + *received = FALSE; + + timeout_ms = ftp_timeleft_accept(data); + infof(data, "Checking for server connect\n"); + if(timeout_ms < 0) { + /* if a timeout was already reached, bail out */ + failf(data, "Accept timeout occurred while waiting server connect"); + return CURLE_FTP_ACCEPT_TIMEOUT; + } + + /* First check whether there is a cached response from server */ + if(pp->cache_size && pp->cache && pp->cache[0] > '3') { + /* Data connection could not be established, let's return */ + infof(data, "There is negative response in cache while serv connect\n"); + Curl_GetFTPResponse(&nread, conn, &ftpcode); + return CURLE_FTP_ACCEPT_FAILED; + } + + result = Curl_socket_check(ctrl_sock, data_sock, CURL_SOCKET_BAD, 0); + + /* see if the connection request is already here */ + switch (result) { + case -1: /* error */ + /* let's die here */ + failf(data, "Error while waiting for server connect"); + return CURLE_FTP_ACCEPT_FAILED; + case 0: /* Server connect is not received yet */ + break; /* loop */ + default: + + if(result & CURL_CSELECT_IN2) { + infof(data, "Ready to accept data connection from server\n"); + *received = TRUE; + } + else if(result & CURL_CSELECT_IN) { + infof(data, "Ctrl conn has data while waiting for data conn\n"); + Curl_GetFTPResponse(&nread, conn, &ftpcode); + + if(ftpcode/100 > 3) + return CURLE_FTP_ACCEPT_FAILED; + + return CURLE_FTP_WEIRD_SERVER_REPLY; + } + + break; + } /* switch() */ + + return CURLE_OK; +} + + +/*********************************************************************** + * + * InitiateTransfer() + * + * After connection from server is accepted this function is called to + * setup transfer parameters and initiate the data transfer. + * + */ +static CURLcode InitiateTransfer(struct connectdata *conn) +{ + struct SessionHandle *data = conn->data; + struct FTP *ftp = data->req.protop; + CURLcode result = CURLE_OK; + + if(conn->ssl[SECONDARYSOCKET].use) { + /* since we only have a plaintext TCP connection here, we must now + * do the TLS stuff */ + infof(data, "Doing the SSL/TLS handshake on the data stream\n"); + result = Curl_ssl_connect(conn, SECONDARYSOCKET); + if(result) + return result; + } + + if(conn->proto.ftpc.state_saved == FTP_STOR) { + *(ftp->bytecountp)=0; + + /* When we know we're uploading a specified file, we can get the file + size prior to the actual upload. */ + + Curl_pgrsSetUploadSize(data, data->state.infilesize); + + /* set the SO_SNDBUF for the secondary socket for those who need it */ + Curl_sndbufset(conn->sock[SECONDARYSOCKET]); + + Curl_setup_transfer(conn, -1, -1, FALSE, NULL, /* no download */ + SECONDARYSOCKET, ftp->bytecountp); + } + else { + /* FTP download: */ + Curl_setup_transfer(conn, SECONDARYSOCKET, + conn->proto.ftpc.retr_size_saved, FALSE, + ftp->bytecountp, -1, NULL); /* no upload here */ + } + + conn->proto.ftpc.pp.pending_resp = TRUE; /* expect server response */ + state(conn, FTP_STOP); + + return CURLE_OK; +} + +/*********************************************************************** + * + * AllowServerConnect() + * + * When we've issue the PORT command, we have told the server to connect to + * us. This function checks whether data connection is established if so it is + * accepted. + * + */ +static CURLcode AllowServerConnect(struct connectdata *conn, bool *connected) +{ + struct SessionHandle *data = conn->data; + long timeout_ms; - CURLcode ret = CURLE_OK; ++ CURLcode result = CURLE_OK; + + *connected = FALSE; + infof(data, "Preparing for accepting server on data port\n"); + + /* Save the time we start accepting server connect */ + Curl_pgrsTime(data, TIMER_STARTACCEPT); + + timeout_ms = ftp_timeleft_accept(data); + if(timeout_ms < 0) { + /* if a timeout was already reached, bail out */ + failf(data, "Accept timeout occurred while waiting server connect"); + return CURLE_FTP_ACCEPT_TIMEOUT; + } + + /* see if the connection request is already here */ - ret = ReceivedServerConnect(conn, connected); - if(ret) - return ret; ++ result = ReceivedServerConnect(conn, connected); ++ if(result) ++ return result; + + if(*connected) { - ret = AcceptServerConnect(conn); - if(ret) - return ret; ++ result = AcceptServerConnect(conn); ++ if(result) ++ return result; + - ret = InitiateTransfer(conn); - if(ret) - return ret; ++ result = InitiateTransfer(conn); ++ if(result) ++ return result; + } + else { + /* Add timeout to multi handle and break out of the loop */ - if(ret == CURLE_OK && *connected == FALSE) { ++ if(!result && *connected == FALSE) { + if(data->set.accepttimeout > 0) + Curl_expire(data, data->set.accepttimeout); + else + Curl_expire(data, DEFAULT_ACCEPT_TIMEOUT); + } + } + - return ret; ++ return result; +} + +/* macro to check for a three-digit ftp status code at the start of the + given string */ +#define STATUSCODE(line) (ISDIGIT(line[0]) && ISDIGIT(line[1]) && \ + ISDIGIT(line[2])) + +/* macro to check for the last line in an FTP server response */ +#define LASTLINE(line) (STATUSCODE(line) && (' ' == line[3])) + +static bool ftp_endofresp(struct connectdata *conn, char *line, size_t len, + int *code) +{ + (void)conn; + + if((len > 3) && LASTLINE(line)) { + *code = curlx_sltosi(strtol(line, NULL, 10)); + return TRUE; + } + + return FALSE; +} + +static CURLcode ftp_readresp(curl_socket_t sockfd, + struct pingpong *pp, + int *ftpcode, /* return the ftp-code if done */ + size_t *size) /* size of the response */ +{ + struct connectdata *conn = pp->conn; + struct SessionHandle *data = conn->data; +#ifdef HAVE_GSSAPI + char * const buf = data->state.buffer; +#endif + CURLcode result = CURLE_OK; + int code; + + result = Curl_pp_readresp(sockfd, pp, &code, size); + +#if defined(HAVE_GSSAPI) + /* handle the security-oriented responses 6xx ***/ + /* FIXME: some errorchecking perhaps... ***/ + switch(code) { + case 631: + code = Curl_sec_read_msg(conn, buf, PROT_SAFE); + break; + case 632: + code = Curl_sec_read_msg(conn, buf, PROT_PRIVATE); + break; + case 633: + code = Curl_sec_read_msg(conn, buf, PROT_CONFIDENTIAL); + break; + default: + /* normal ftp stuff we pass through! */ + break; + } +#endif + + /* store the latest code for later retrieval */ + data->info.httpcode=code; + + if(ftpcode) + *ftpcode = code; + + if(421 == code) { + /* 421 means "Service not available, closing control connection." and FTP + * servers use it to signal that idle session timeout has been exceeded. + * If we ignored the response, it could end up hanging in some cases. + * + * This response code can come at any point so having it treated + * generically is a good idea. + */ + infof(data, "We got a 421 - timeout!\n"); + state(conn, FTP_STOP); + return CURLE_OPERATION_TIMEDOUT; + } + + return result; +} + +/* --- parse FTP server responses --- */ + +/* + * Curl_GetFTPResponse() is a BLOCKING function to read the full response + * from a server after a command. + * + */ + +CURLcode Curl_GetFTPResponse(ssize_t *nreadp, /* return number of bytes read */ + struct connectdata *conn, + int *ftpcode) /* return the ftp-code */ +{ + /* + * We cannot read just one byte per read() and then go back to select() as + * the OpenSSL read() doesn't grok that properly. + * + * Alas, read as much as possible, split up into lines, use the ending + * line in a response or continue reading. */ + + curl_socket_t sockfd = conn->sock[FIRSTSOCKET]; + long timeout; /* timeout in milliseconds */ + long interval_ms; + struct SessionHandle *data = conn->data; + CURLcode result = CURLE_OK; + struct ftp_conn *ftpc = &conn->proto.ftpc; + struct pingpong *pp = &ftpc->pp; + size_t nread; + int cache_skip=0; + int value_to_be_ignored=0; + + if(ftpcode) + *ftpcode = 0; /* 0 for errors */ + else + /* make the pointer point to something for the rest of this function */ + ftpcode = &value_to_be_ignored; + + *nreadp=0; + + while(!*ftpcode && !result) { + /* check and reset timeout value every lap */ + timeout = Curl_pp_state_timeout(pp); + + if(timeout <=0 ) { + failf(data, "FTP response timeout"); + return CURLE_OPERATION_TIMEDOUT; /* already too little time */ + } + + interval_ms = 1000; /* use 1 second timeout intervals */ + if(timeout < interval_ms) + interval_ms = timeout; + + /* + * Since this function is blocking, we need to wait here for input on the + * connection and only then we call the response reading function. We do + * timeout at least every second to make the timeout check run. + * + * A caution here is that the ftp_readresp() function has a cache that may + * contain pieces of a response from the previous invoke and we need to + * make sure we don't just wait for input while there is unhandled data in + * that cache. But also, if the cache is there, we call ftp_readresp() and + * the cache wasn't good enough to continue we must not just busy-loop + * around this function. + * + */ + + if(pp->cache && (cache_skip < 2)) { + /* + * There's a cache left since before. We then skipping the wait for + * socket action, unless this is the same cache like the previous round + * as then the cache was deemed not enough to act on and we then need to + * wait for more data anyway. + */ + } + else { + switch (Curl_socket_ready(sockfd, CURL_SOCKET_BAD, interval_ms)) { + case -1: /* select() error, stop reading */ + failf(data, "FTP response aborted due to select/poll error: %d", + SOCKERRNO); + return CURLE_RECV_ERROR; + + case 0: /* timeout */ + if(Curl_pgrsUpdate(conn)) + return CURLE_ABORTED_BY_CALLBACK; + continue; /* just continue in our loop for the timeout duration */ + + default: /* for clarity */ + break; + } + } + result = ftp_readresp(sockfd, pp, ftpcode, &nread); + if(result) + break; + + if(!nread && pp->cache) + /* bump cache skip counter as on repeated skips we must wait for more + data */ + cache_skip++; + else + /* when we got data or there is no cache left, we reset the cache skip + counter */ + cache_skip=0; + + *nreadp += nread; + + } /* while there's buffer left and loop is requested */ + + pp->pending_resp = FALSE; + + return result; +} + +#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS) + /* for debug purposes */ +static const char * const ftp_state_names[]={ + "STOP", + "WAIT220", + "AUTH", + "USER", + "PASS", + "ACCT", + "PBSZ", + "PROT", + "CCC", + "PWD", + "SYST", + "NAMEFMT", + "QUOTE", + "RETR_PREQUOTE", + "STOR_PREQUOTE", + "POSTQUOTE", + "CWD", + "MKD", + "MDTM", + "TYPE", + "LIST_TYPE", + "RETR_TYPE", + "STOR_TYPE", + "SIZE", + "RETR_SIZE", + "STOR_SIZE", + "REST", + "RETR_REST", + "PORT", + "PRET", + "PASV", + "LIST", + "RETR", + "STOR", + "QUIT" +}; +#endif + +/* This is the ONLY way to change FTP state! */ +static void _state(struct connectdata *conn, + ftpstate newstate +#ifdef DEBUGBUILD + , int lineno +#endif + ) +{ + struct ftp_conn *ftpc = &conn->proto.ftpc; - #if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS) ++ ++#if defined(DEBUGBUILD) ++ ++#if defined(CURL_DISABLE_VERBOSE_STRINGS) ++ (void) lineno; ++#else + if(ftpc->state != newstate) + infof(conn->data, "FTP %p (line %d) state change from %s to %s\n", + (void *)ftpc, lineno, ftp_state_names[ftpc->state], + ftp_state_names[newstate]); +#endif ++#endif ++ + ftpc->state = newstate; +} + +static CURLcode ftp_state_user(struct connectdata *conn) +{ + CURLcode result; + struct FTP *ftp = conn->data->req.protop; + /* send USER */ + PPSENDF(&conn->proto.ftpc.pp, "USER %s", ftp->user?ftp->user:""); + + state(conn, FTP_USER); + conn->data->state.ftp_trying_alternative = FALSE; + + return CURLE_OK; +} + +static CURLcode ftp_state_pwd(struct connectdata *conn) +{ + CURLcode result; + + /* send PWD to discover our entry point */ + PPSENDF(&conn->proto.ftpc.pp, "%s", "PWD"); + state(conn, FTP_PWD); + + return CURLE_OK; +} + +/* For the FTP "protocol connect" and "doing" phases only */ +static int ftp_getsock(struct connectdata *conn, + curl_socket_t *socks, + int numsocks) +{ + return Curl_pp_getsock(&conn->proto.ftpc.pp, socks, numsocks); +} + +/* For the FTP "DO_MORE" phase only */ +static int ftp_domore_getsock(struct connectdata *conn, curl_socket_t *socks, + int numsocks) +{ + struct ftp_conn *ftpc = &conn->proto.ftpc; + + if(!numsocks) + return GETSOCK_BLANK; + + /* When in DO_MORE state, we could be either waiting for us to connect to a + * remote site, or we could wait for that site to connect to us. Or just + * handle ordinary commands. + */ + + if(FTP_STOP == ftpc->state) { + int bits = GETSOCK_READSOCK(0); + + /* if stopped and still in this state, then we're also waiting for a + connect on the secondary connection */ + socks[0] = conn->sock[FIRSTSOCKET]; + + if(!conn->data->set.ftp_use_port) { + int s; + int i; + /* PORT is used to tell the server to connect to us, and during that we + don't do happy eyeballs, but we do if we connect to the server */ + for(s=1, i=0; i<2; i++) { + if(conn->tempsock[i] != CURL_SOCKET_BAD) { + socks[s] = conn->tempsock[i]; + bits |= GETSOCK_WRITESOCK(s++); + } + } + } + else { + socks[1] = conn->sock[SECONDARYSOCKET]; + bits |= GETSOCK_WRITESOCK(1); + } + + return bits; + } + else + return Curl_pp_getsock(&conn->proto.ftpc.pp, socks, numsocks); +} + +/* This is called after the FTP_QUOTE state is passed. + + ftp_state_cwd() sends the range of CWD commands to the server to change to + the correct directory. It may also need to send MKD commands to create + missing ones, if that option is enabled. +*/ +static CURLcode ftp_state_cwd(struct connectdata *conn) +{ + CURLcode result = CURLE_OK; + struct ftp_conn *ftpc = &conn->proto.ftpc; + + if(ftpc->cwddone) + /* already done and fine */ + result = ftp_state_mdtm(conn); + else { + ftpc->count2 = 0; /* count2 counts failed CWDs */ + + /* count3 is set to allow a MKD to fail once. In the case when first CWD + fails and then MKD fails (due to another session raced it to create the + dir) this then allows for a second try to CWD to it */ + ftpc->count3 = (conn->data->set.ftp_create_missing_dirs==2)?1:0; + + if(conn->bits.reuse && ftpc->entrypath) { + /* This is a re-used connection. Since we change directory to where the + transfer is taking place, we must first get back to the original dir + where we ended up after login: */ + ftpc->count1 = 0; /* we count this as the first path, then we add one + for all upcoming ones in the ftp->dirs[] array */ + PPSENDF(&conn->proto.ftpc.pp, "CWD %s", ftpc->entrypath); + state(conn, FTP_CWD); + } + else { + if(ftpc->dirdepth) { + ftpc->count1 = 1; + /* issue the first CWD, the rest is sent when the CWD responses are + received... */ + PPSENDF(&conn->proto.ftpc.pp, "CWD %s", ftpc->dirs[ftpc->count1 -1]); + state(conn, FTP_CWD); + } + else { + /* No CWD necessary */ + result = ftp_state_mdtm(conn); + } + } + } + return result; +} + +typedef enum { + EPRT, + PORT, + DONE +} ftpport; + +static CURLcode ftp_state_use_port(struct connectdata *conn, + ftpport fcmd) /* start with this */ + +{ + CURLcode result = CURLE_OK; + struct ftp_conn *ftpc = &conn->proto.ftpc; + struct SessionHandle *data=conn->data; + curl_socket_t portsock= CURL_SOCKET_BAD; + char myhost[256] = ""; + + struct Curl_sockaddr_storage ss; + Curl_addrinfo *res, *ai; + curl_socklen_t sslen; + char hbuf[NI_MAXHOST]; + struct sockaddr *sa=(struct sockaddr *)&ss; + struct sockaddr_in * const sa4 = (void *)sa; +#ifdef ENABLE_IPV6 + struct sockaddr_in6 * const sa6 = (void *)sa; +#endif + char tmp[1024]; + static const char mode[][5] = { "EPRT", "PORT" }; + int rc; + int error; + char *host = NULL; + char *string_ftpport = data->set.str[STRING_FTPPORT]; + struct Curl_dns_entry *h=NULL; + unsigned short port_min = 0; + unsigned short port_max = 0; + unsigned short port; + bool possibly_non_local = TRUE; + + char *addr = NULL; + + /* Step 1, figure out what is requested, + * accepted format : + * (ipv4|ipv6|domain|interface)?(:port(-range)?)? + */ + + if(data->set.str[STRING_FTPPORT] && + (strlen(data->set.str[STRING_FTPPORT]) > 1)) { + +#ifdef ENABLE_IPV6 + size_t addrlen = INET6_ADDRSTRLEN > strlen(string_ftpport) ? + INET6_ADDRSTRLEN : strlen(string_ftpport); +#else + size_t addrlen = INET_ADDRSTRLEN > strlen(string_ftpport) ? + INET_ADDRSTRLEN : strlen(string_ftpport); +#endif + char *ip_start = string_ftpport; + char *ip_end = NULL; + char *port_start = NULL; + char *port_sep = NULL; + + addr = calloc(addrlen+1, 1); + if(!addr) + return CURLE_OUT_OF_MEMORY; + +#ifdef ENABLE_IPV6 + if(*string_ftpport == '[') { + /* [ipv6]:port(-range) */ + ip_start = string_ftpport + 1; + if((ip_end = strchr(string_ftpport, ']')) != NULL ) + strncpy(addr, ip_start, ip_end - ip_start); + } + else +#endif + if(*string_ftpport == ':') { + /* :port */ + ip_end = string_ftpport; + } + else if((ip_end = strchr(string_ftpport, ':')) != NULL) { + /* either ipv6 or (ipv4|domain|interface):port(-range) */ +#ifdef ENABLE_IPV6 + if(Curl_inet_pton(AF_INET6, string_ftpport, sa6) == 1) { + /* ipv6 */ + port_min = port_max = 0; + strcpy(addr, string_ftpport); + ip_end = NULL; /* this got no port ! */ + } + else +#endif + /* (ipv4|domain|interface):port(-range) */ + strncpy(addr, string_ftpport, ip_end - ip_start ); + } + else + /* ipv4|interface */ + strcpy(addr, string_ftpport); + + /* parse the port */ + if(ip_end != NULL) { + if((port_start = strchr(ip_end, ':')) != NULL) { + port_min = curlx_ultous(strtoul(port_start+1, NULL, 10)); + if((port_sep = strchr(port_start, '-')) != NULL) { + port_max = curlx_ultous(strtoul(port_sep + 1, NULL, 10)); + } + else + port_max = port_min; + } + } + + /* correct errors like: + * :1234-1230 + * :-4711 , in this case port_min is (unsigned)-1, + * therefore port_min > port_max for all cases + * but port_max = (unsigned)-1 + */ + if(port_min > port_max ) + port_min = port_max = 0; + + + if(*addr != '\0') { + /* attempt to get the address of the given interface name */ - switch(Curl_if2ip(conn->ip_addr->ai_family, conn->scope, addr, - hbuf, sizeof(hbuf))) { ++ switch(Curl_if2ip(conn->ip_addr->ai_family, ++ Curl_ipv6_scope(conn->ip_addr->ai_addr), ++ conn->scope_id, addr, hbuf, sizeof(hbuf))) { + case IF2IP_NOT_FOUND: + /* not an interface, use the given string as host name instead */ + host = addr; + break; + case IF2IP_AF_NOT_SUPPORTED: + return CURLE_FTP_PORT_FAILED; + case IF2IP_FOUND: + host = hbuf; /* use the hbuf for host name */ + } + } + else + /* there was only a port(-range) given, default the host */ + host = NULL; + } /* data->set.ftpport */ + + if(!host) { + /* not an interface and not a host name, get default by extracting + the IP from the control connection */ + + sslen = sizeof(ss); + if(getsockname(conn->sock[FIRSTSOCKET], sa, &sslen)) { + failf(data, "getsockname() failed: %s", + Curl_strerror(conn, SOCKERRNO) ); - Curl_safefree(addr); ++ free(addr); + return CURLE_FTP_PORT_FAILED; + } + switch(sa->sa_family) { +#ifdef ENABLE_IPV6 + case AF_INET6: + Curl_inet_ntop(sa->sa_family, &sa6->sin6_addr, hbuf, sizeof(hbuf)); + break; +#endif + default: + Curl_inet_ntop(sa->sa_family, &sa4->sin_addr, hbuf, sizeof(hbuf)); + break; + } + host = hbuf; /* use this host name */ + possibly_non_local = FALSE; /* we know it is local now */ + } + + /* resolv ip/host to ip */ + rc = Curl_resolv(conn, host, 0, &h); + if(rc == CURLRESOLV_PENDING) + (void)Curl_resolver_wait_resolv(conn, &h); + if(h) { + res = h->addr; + /* when we return from this function, we can forget about this entry + to we can unlock it now already */ + Curl_resolv_unlock(data, h); + } /* (h) */ + else + res = NULL; /* failure! */ + + if(res == NULL) { + failf(data, "failed to resolve the address provided to PORT: %s", host); - Curl_safefree(addr); ++ free(addr); + return CURLE_FTP_PORT_FAILED; + } + - Curl_safefree(addr); ++ free(addr); + host = NULL; + + /* step 2, create a socket for the requested address */ + + portsock = CURL_SOCKET_BAD; + error = 0; + for(ai = res; ai; ai = ai->ai_next) { + result = Curl_socket(conn, ai, NULL, &portsock); + if(result) { + error = SOCKERRNO; + continue; + } + break; + } + if(!ai) { + failf(data, "socket failure: %s", Curl_strerror(conn, error)); + return CURLE_FTP_PORT_FAILED; + } + + /* step 3, bind to a suitable local address */ + + memcpy(sa, ai->ai_addr, ai->ai_addrlen); + sslen = ai->ai_addrlen; + + for(port = port_min; port <= port_max;) { + if(sa->sa_family == AF_INET) + sa4->sin_port = htons(port); +#ifdef ENABLE_IPV6 + else + sa6->sin6_port = htons(port); +#endif + /* Try binding the given address. */ + if(bind(portsock, sa, sslen) ) { + /* It failed. */ + error = SOCKERRNO; + if(possibly_non_local && (error == EADDRNOTAVAIL)) { + /* The requested bind address is not local. Use the address used for + * the control connection instead and restart the port loop + */ + + infof(data, "bind(port=%hu) on non-local address failed: %s\n", port, + Curl_strerror(conn, error) ); + + sslen = sizeof(ss); + if(getsockname(conn->sock[FIRSTSOCKET], sa, &sslen)) { + failf(data, "getsockname() failed: %s", + Curl_strerror(conn, SOCKERRNO) ); + Curl_closesocket(conn, portsock); + return CURLE_FTP_PORT_FAILED; + } + port = port_min; + possibly_non_local = FALSE; /* don't try this again */ + continue; + } + else if(error != EADDRINUSE && error != EACCES) { + failf(data, "bind(port=%hu) failed: %s", port, + Curl_strerror(conn, error) ); + Curl_closesocket(conn, portsock); + return CURLE_FTP_PORT_FAILED; + } + } + else + break; + + port++; + } + + /* maybe all ports were in use already*/ + if(port > port_max) { + failf(data, "bind() failed, we ran out of ports!"); + Curl_closesocket(conn, portsock); + return CURLE_FTP_PORT_FAILED; + } + + /* get the name again after the bind() so that we can extract the + port number it uses now */ + sslen = sizeof(ss); + if(getsockname(portsock, (struct sockaddr *)sa, &sslen)) { + failf(data, "getsockname() failed: %s", + Curl_strerror(conn, SOCKERRNO) ); + Curl_closesocket(conn, portsock); + return CURLE_FTP_PORT_FAILED; + } + + /* step 4, listen on the socket */ + + if(listen(portsock, 1)) { + failf(data, "socket failure: %s", Curl_strerror(conn, SOCKERRNO)); + Curl_closesocket(conn, portsock); + return CURLE_FTP_PORT_FAILED; + } + + /* step 5, send the proper FTP command */ + + /* get a plain printable version of the numerical address to work with + below */ + Curl_printable_address(ai, myhost, sizeof(myhost)); + +#ifdef ENABLE_IPV6 + if(!conn->bits.ftp_use_eprt && conn->bits.ipv6) + /* EPRT is disabled but we are connected to a IPv6 host, so we ignore the + request and enable EPRT again! */ + conn->bits.ftp_use_eprt = TRUE; +#endif + + for(; fcmd != DONE; fcmd++) { + + if(!conn->bits.ftp_use_eprt && (EPRT == fcmd)) + /* if disabled, goto next */ + continue; + + if((PORT == fcmd) && sa->sa_family != AF_INET) - /* PORT is ipv4 only */ ++ /* PORT is IPv4 only */ + continue; + - switch (sa->sa_family) { ++ switch(sa->sa_family) { + case AF_INET: + port = ntohs(sa4->sin_port); + break; +#ifdef ENABLE_IPV6 + case AF_INET6: + port = ntohs(sa6->sin6_port); + break; +#endif + default: + continue; /* might as well skip this */ + } + + if(EPRT == fcmd) { + /* + * Two fine examples from RFC2428; + * + * EPRT |1|132.235.1.2|6275| + * + * EPRT |2|1080::8:800:200C:417A|5282| + */ + + result = Curl_pp_sendf(&ftpc->pp, "%s |%d|%s|%hu|", mode[fcmd], + sa->sa_family == AF_INET?1:2, + myhost, port); + if(result) { + failf(data, "Failure sending EPRT command: %s", + curl_easy_strerror(result)); + Curl_closesocket(conn, portsock); + /* don't retry using PORT */ + ftpc->count1 = PORT; + /* bail out */ + state(conn, FTP_STOP); + return result; + } + break; + } + else if(PORT == fcmd) { + char *source = myhost; + char *dest = tmp; + + /* translate x.x.x.x to x,x,x,x */ + while(source && *source) { + if(*source == '.') + *dest=','; + else + *dest = *source; + dest++; + source++; + } + *dest = 0; + snprintf(dest, 20, ",%d,%d", (int)(port>>8), (int)(port&0xff)); + + result = Curl_pp_sendf(&ftpc->pp, "%s %s", mode[fcmd], tmp); + if(result) { + failf(data, "Failure sending PORT command: %s", + curl_easy_strerror(result)); + Curl_closesocket(conn, portsock); + /* bail out */ + state(conn, FTP_STOP); + return result; + } + break; + } + } + + /* store which command was sent */ + ftpc->count1 = fcmd; + + /* we set the secondary socket variable to this for now, it is only so that + the cleanup function will close it in case we fail before the true + secondary stuff is made */ + if(CURL_SOCKET_BAD != conn->sock[SECONDARYSOCKET]) + Curl_closesocket(conn, conn->sock[SECONDARYSOCKET]); + conn->sock[SECONDARYSOCKET] = portsock; + + /* this tcpconnect assignment below is a hackish work-around to make the + multi interface with active FTP work - as it will not wait for a + (passive) connect in Curl_is_connected(). + + The *proper* fix is to make sure that the active connection from the + server is done in a non-blocking way. Currently, it is still BLOCKING. + */ + conn->bits.tcpconnect[SECONDARYSOCKET] = TRUE; + + state(conn, FTP_PORT); + return result; +} + +static CURLcode ftp_state_use_pasv(struct connectdata *conn) +{ + struct ftp_conn *ftpc = &conn->proto.ftpc; + CURLcode result = CURLE_OK; + /* + Here's the excecutive summary on what to do: + + PASV is RFC959, expect: + 227 Entering Passive Mode (a1,a2,a3,a4,p1,p2) + + LPSV is RFC1639, expect: + 228 Entering Long Passive Mode (4,4,a1,a2,a3,a4,2,p1,p2) + + EPSV is RFC2428, expect: + 229 Entering Extended Passive Mode (|||port|) + + */ + + static const char mode[][5] = { "EPSV", "PASV" }; + int modeoff; + +#ifdef PF_INET6 + if(!conn->bits.ftp_use_epsv && conn->bits.ipv6) + /* EPSV is disabled but we are connected to a IPv6 host, so we ignore the + request and enable EPSV again! */ + conn->bits.ftp_use_epsv = TRUE; +#endif + + modeoff = conn->bits.ftp_use_epsv?0:1; + + PPSENDF(&ftpc->pp, "%s", mode[modeoff]); + + ftpc->count1 = modeoff; + state(conn, FTP_PASV); + infof(conn->data, "Connect data stream passively\n"); + + return result; +} + +/* + * ftp_state_prepare_transfer() starts PORT, PASV or PRET etc. + * + * REST is the last command in the chain of commands when a "head"-like + * request is made. Thus, if an actual transfer is to be made this is where we + * take off for real. + */ +static CURLcode ftp_state_prepare_transfer(struct connectdata *conn) +{ + CURLcode result = CURLE_OK; + struct FTP *ftp = conn->data->req.protop; + struct SessionHandle *data = conn->data; + + if(ftp->transfer != FTPTRANSFER_BODY) { + /* doesn't transfer any data */ + + /* still possibly do PRE QUOTE jobs */ + state(conn, FTP_RETR_PREQUOTE); + result = ftp_state_quote(conn, TRUE, FTP_RETR_PREQUOTE); + } + else if(data->set.ftp_use_port) { + /* We have chosen to use the PORT (or similar) command */ + result = ftp_state_use_port(conn, EPRT); + } + else { + /* We have chosen (this is default) to use the PASV (or similar) command */ + if(data->set.ftp_use_pret) { + /* The user has requested that we send a PRET command + to prepare the server for the upcoming PASV */ + if(!conn->proto.ftpc.file) { + PPSENDF(&conn->proto.ftpc.pp, "PRET %s", + data->set.str[STRING_CUSTOMREQUEST]? + data->set.str[STRING_CUSTOMREQUEST]: + (data->set.ftp_list_only?"NLST":"LIST")); + } + else if(data->set.upload) { + PPSENDF(&conn->proto.ftpc.pp, "PRET STOR %s", conn->proto.ftpc.file); + } + else { + PPSENDF(&conn->proto.ftpc.pp, "PRET RETR %s", conn->proto.ftpc.file); + } + state(conn, FTP_PRET); + } + else { + result = ftp_state_use_pasv(conn); + } + } + return result; +} + +static CURLcode ftp_state_rest(struct connectdata *conn) +{ + CURLcode result = CURLE_OK; + struct FTP *ftp = conn->data->req.protop; + struct ftp_conn *ftpc = &conn->proto.ftpc; + + if((ftp->transfer != FTPTRANSFER_BODY) && ftpc->file) { + /* if a "head"-like request is being made (on a file) */ + + /* Determine if server can respond to REST command and therefore + whether it supports range */ + PPSENDF(&conn->proto.ftpc.pp, "REST %d", 0); + + state(conn, FTP_REST); + } + else + result = ftp_state_prepare_transfer(conn); + + return result; +} + +static CURLcode ftp_state_size(struct connectdata *conn) +{ + CURLcode result = CURLE_OK; + struct FTP *ftp = conn->data->req.protop; + struct ftp_conn *ftpc = &conn->proto.ftpc; + + if((ftp->transfer == FTPTRANSFER_INFO) && ftpc->file) { + /* if a "head"-like request is being made (on a file) */ + + /* we know ftpc->file is a valid pointer to a file name */ + PPSENDF(&ftpc->pp, "SIZE %s", ftpc->file); + + state(conn, FTP_SIZE); + } + else + result = ftp_state_rest(conn); + + return result; +} + +static CURLcode ftp_state_list(struct connectdata *conn) +{ + CURLcode result = CURLE_OK; + struct SessionHandle *data = conn->data; + + /* If this output is to be machine-parsed, the NLST command might be better + to use, since the LIST command output is not specified or standard in any + way. It has turned out that the NLST list output is not the same on all + servers either... */ + + /* + if FTPFILE_NOCWD was specified, we are currently in + the user's home directory, so we should add the path + as argument for the LIST / NLST / or custom command. + Whether the server will support this, is uncertain. + + The other ftp_filemethods will CWD into dir/dir/ first and + then just do LIST (in that case: nothing to do here) + */ - char *cmd,*lstArg,*slashPos; ++ char *cmd, *lstArg, *slashPos; + + lstArg = NULL; + if((data->set.ftp_filemethod == FTPFILE_NOCWD) && + data->state.path && + data->state.path[0] && - strchr(data->state.path,'/')) { ++ strchr(data->state.path, '/')) { + + lstArg = strdup(data->state.path); + if(!lstArg) + return CURLE_OUT_OF_MEMORY; + + /* Check if path does not end with /, as then we cut off the file part */ + if(lstArg[strlen(lstArg) - 1] != '/') { + + /* chop off the file part if format is dir/dir/file */ - slashPos = strrchr(lstArg,'/'); ++ slashPos = strrchr(lstArg, '/'); + if(slashPos) + *(slashPos+1) = '\0'; + } + } + + cmd = aprintf( "%s%s%s", + data->set.str[STRING_CUSTOMREQUEST]? + data->set.str[STRING_CUSTOMREQUEST]: + (data->set.ftp_list_only?"NLST":"LIST"), + lstArg? " ": "", + lstArg? lstArg: "" ); + + if(!cmd) { - if(lstArg) - free(lstArg); ++ free(lstArg); + return CURLE_OUT_OF_MEMORY; + } + + result = Curl_pp_sendf(&conn->proto.ftpc.pp, "%s", cmd); + - if(lstArg) - free(lstArg); - ++ free(lstArg); + free(cmd); + - if(result != CURLE_OK) ++ if(result) + return result; + + state(conn, FTP_LIST); + + return result; +} + +static CURLcode ftp_state_retr_prequote(struct connectdata *conn) +{ + CURLcode result = CURLE_OK; + + /* We've sent the TYPE, now we must send the list of prequote strings */ + + result = ftp_state_quote(conn, TRUE, FTP_RETR_PREQUOTE); + + return result; +} + +static CURLcode ftp_state_stor_prequote(struct connectdata *conn) +{ + CURLcode result = CURLE_OK; + + /* We've sent the TYPE, now we must send the list of prequote strings */ + + result = ftp_state_quote(conn, TRUE, FTP_STOR_PREQUOTE); + + return result; +} + +static CURLcode ftp_state_type(struct connectdata *conn) +{ + CURLcode result = CURLE_OK; + struct FTP *ftp = conn->data->req.protop; + struct SessionHandle *data = conn->data; + struct ftp_conn *ftpc = &conn->proto.ftpc; + + /* If we have selected NOBODY and HEADER, it means that we only want file + information. Which in FTP can't be much more than the file size and + date. */ + if(data->set.opt_no_body && ftpc->file && + ftp_need_type(conn, data->set.prefer_ascii)) { + /* The SIZE command is _not_ RFC 959 specified, and therefor many servers + may not support it! It is however the only way we have to get a file's + size! */ + + ftp->transfer = FTPTRANSFER_INFO; + /* this means no actual transfer will be made */ + + /* Some servers return different sizes for different modes, and thus we + must set the proper type before we check the size */ + result = ftp_nb_type(conn, data->set.prefer_ascii, FTP_TYPE); + if(result) + return result; + } + else + result = ftp_state_size(conn); + + return result; +} + +/* This is called after the CWD commands have been done in the beginning of + the DO phase */ +static CURLcode ftp_state_mdtm(struct connectdata *conn) +{ + CURLcode result = CURLE_OK; + struct SessionHandle *data = conn->data; + struct ftp_conn *ftpc = &conn->proto.ftpc; + + /* Requested time of file or time-depended transfer? */ + if((data->set.get_filetime || data->set.timecondition) && ftpc->file) { + + /* we have requested to get the modified-time of the file, this is a white + spot as the MDTM is not mentioned in RFC959 */ + PPSENDF(&ftpc->pp, "MDTM %s", ftpc->file); + + state(conn, FTP_MDTM); + } + else + result = ftp_state_type(conn); + + return result; +} + + +/* This is called after the TYPE and possible quote commands have been sent */ +static CURLcode ftp_state_ul_setup(struct connectdata *conn, + bool sizechecked) +{ + CURLcode result = CURLE_OK; + struct FTP *ftp = conn->data->req.protop; + struct SessionHandle *data = conn->data; + struct ftp_conn *ftpc = &conn->proto.ftpc; + int seekerr = CURL_SEEKFUNC_OK; + + if((data->state.resume_from && !sizechecked) || + ((data->state.resume_from > 0) && sizechecked)) { + /* we're about to continue the uploading of a file */ + /* 1. get already existing file's size. We use the SIZE command for this + which may not exist in the server! The SIZE command is not in + RFC959. */ + + /* 2. This used to set REST. But since we can do append, we + don't another ftp command. We just skip the source file + offset and then we APPEND the rest on the file instead */ + + /* 3. pass file-size number of bytes in the source file */ + /* 4. lower the infilesize counter */ + /* => transfer as usual */ + + if(data->state.resume_from < 0 ) { + /* Got no given size to start from, figure it out */ + PPSENDF(&ftpc->pp, "SIZE %s", ftpc->file); + state(conn, FTP_STOR_SIZE); + return result; + } + + /* enable append */ + data->set.ftp_append = TRUE; + + /* Let's read off the proper amount of bytes from the input. */ + if(conn->seek_func) { + seekerr = conn->seek_func(conn->seek_client, data->state.resume_from, + SEEK_SET); + } + + if(seekerr != CURL_SEEKFUNC_OK) { + if(seekerr != CURL_SEEKFUNC_CANTSEEK) { + failf(data, "Could not seek stream"); + return CURLE_FTP_COULDNT_USE_REST; + } + /* seekerr == CURL_SEEKFUNC_CANTSEEK (can't seek to offset) */ + else { + curl_off_t passed=0; + do { + size_t readthisamountnow = + (data->state.resume_from - passed > CURL_OFF_T_C(BUFSIZE)) ? + BUFSIZE : curlx_sotouz(data->state.resume_from - passed); + + size_t actuallyread = - conn->fread_func(data->state.buffer, 1, readthisamountnow, - conn->fread_in); ++ data->set.fread_func(data->state.buffer, 1, readthisamountnow, ++ data->set.in); + + passed += actuallyread; + if((actuallyread == 0) || (actuallyread > readthisamountnow)) { + /* this checks for greater-than only to make sure that the + CURL_READFUNC_ABORT return code still aborts */ + failf(data, "Failed to read data"); + return CURLE_FTP_COULDNT_USE_REST; + } + } while(passed < data->state.resume_from); + } + } + /* now, decrease the size of the read */ + if(data->state.infilesize>0) { + data->state.infilesize -= data->state.resume_from; + + if(data->state.infilesize <= 0) { + infof(data, "File already completely uploaded\n"); + + /* no data to transfer */ + Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL); + + /* Set ->transfer so that we won't get any error in + * ftp_done() because we didn't transfer anything! */ + ftp->transfer = FTPTRANSFER_NONE; + + state(conn, FTP_STOP); + return CURLE_OK; + } + } + /* we've passed, proceed as normal */ + } /* resume_from */ + + PPSENDF(&ftpc->pp, data->set.ftp_append?"APPE %s":"STOR %s", + ftpc->file); + + state(conn, FTP_STOR); + + return result; +} + +static CURLcode ftp_state_quote(struct connectdata *conn, + bool init, + ftpstate instate) +{ + CURLcode result = CURLE_OK; + struct SessionHandle *data = conn->data; + struct FTP *ftp = data->req.protop; + struct ftp_conn *ftpc = &conn->proto.ftpc; + bool quote=FALSE; + struct curl_slist *item; + + switch(instate) { + case FTP_QUOTE: + default: + item = data->set.quote; + break; + case FTP_RETR_PREQUOTE: + case FTP_STOR_PREQUOTE: + item = data->set.prequote; + break; + case FTP_POSTQUOTE: + item = data->set.postquote; + break; + } + + /* + * This state uses: + * 'count1' to iterate over the commands to send + * 'count2' to store wether to allow commands to fail + */ + + if(init) + ftpc->count1 = 0; + else + ftpc->count1++; + + if(item) { + int i = 0; + + /* Skip count1 items in the linked list */ + while((i< ftpc->count1) && item) { + item = item->next; + i++; + } + if(item) { + char *cmd = item->data; + if(cmd[0] == '*') { + cmd++; + ftpc->count2 = 1; /* the sent command is allowed to fail */ + } + else + ftpc->count2 = 0; /* failure means cancel operation */ + + PPSENDF(&ftpc->pp, "%s", cmd); + state(conn, instate); + quote = TRUE; + } + } + + if(!quote) { + /* No more quote to send, continue to ... */ + switch(instate) { + case FTP_QUOTE: + default: + result = ftp_state_cwd(conn); + break; + case FTP_RETR_PREQUOTE: + if(ftp->transfer != FTPTRANSFER_BODY) + state(conn, FTP_STOP); + else { + if(ftpc->known_filesize != -1) { + Curl_pgrsSetDownloadSize(data, ftpc->known_filesize); + result = ftp_state_retr(conn, ftpc->known_filesize); + } + else { + PPSENDF(&ftpc->pp, "SIZE %s", ftpc->file); + state(conn, FTP_RETR_SIZE); + } + } + break; + case FTP_STOR_PREQUOTE: + result = ftp_state_ul_setup(conn, FALSE); + break; + case FTP_POSTQUOTE: + break; + } + } + + return result; +} + +/* called from ftp_state_pasv_resp to switch to PASV in case of EPSV + problems */ +static CURLcode ftp_epsv_disable(struct connectdata *conn) +{ + CURLcode result = CURLE_OK; ++ ++ if(conn->bits.ipv6) { ++ /* We can't disable EPSV when doing IPv6, so this is instead a fail */ ++ failf(conn->data, "Failed EPSV attempt, exiting\n"); ++ return CURLE_FTP_WEIRD_SERVER_REPLY; ++ } ++ + infof(conn->data, "Failed EPSV attempt. Disabling EPSV\n"); + /* disable it for next transfer */ + conn->bits.ftp_use_epsv = FALSE; + conn->data->state.errorbuf = FALSE; /* allow error message to get + rewritten */ + PPSENDF(&conn->proto.ftpc.pp, "%s", "PASV"); + conn->proto.ftpc.count1++; + /* remain in/go to the FTP_PASV state */ + state(conn, FTP_PASV); + return result; +} + +/* + * Perform the necessary magic that needs to be done once the TCP connection + * to the proxy has completed. + */ +static CURLcode proxy_magic(struct connectdata *conn, + char *newhost, unsigned short newport, + bool *magicdone) +{ + CURLcode result = CURLE_OK; - struct SessionHandle *data=conn->data; ++ struct SessionHandle *data = conn->data; ++ ++#if defined(CURL_DISABLE_PROXY) ++ (void) newhost; ++ (void) newport; ++#endif + + *magicdone = FALSE; ++ + switch(conn->proxytype) { + case CURLPROXY_SOCKS5: + case CURLPROXY_SOCKS5_HOSTNAME: + result = Curl_SOCKS5(conn->proxyuser, conn->proxypasswd, newhost, + newport, SECONDARYSOCKET, conn); + *magicdone = TRUE; + break; + case CURLPROXY_SOCKS4: + result = Curl_SOCKS4(conn->proxyuser, newhost, newport, + SECONDARYSOCKET, conn, FALSE); + *magicdone = TRUE; + break; + case CURLPROXY_SOCKS4A: + result = Curl_SOCKS4(conn->proxyuser, newhost, newport, + SECONDARYSOCKET, conn, TRUE); + *magicdone = TRUE; + break; + case CURLPROXY_HTTP: + case CURLPROXY_HTTP_1_0: + /* do nothing here. handled later. */ + break; + default: + failf(data, "unknown proxytype option given"); + result = CURLE_COULDNT_CONNECT; + break; + } + + if(conn->bits.tunnel_proxy && conn->bits.httpproxy) { + /* BLOCKING */ + /* We want "seamless" FTP operations through HTTP proxy tunnel */ + + /* Curl_proxyCONNECT is based on a pointer to a struct HTTP at the + * member conn->proto.http; we want FTP through HTTP and we have to + * change the member temporarily for connecting to the HTTP proxy. After + * Curl_proxyCONNECT we have to set back the member to the original + * struct FTP pointer + */ + struct HTTP http_proxy; + struct FTP *ftp_save = data->req.protop; + memset(&http_proxy, 0, sizeof(http_proxy)); + data->req.protop = &http_proxy; + - result = Curl_proxyCONNECT(conn, SECONDARYSOCKET, newhost, newport); ++ result = Curl_proxyCONNECT(conn, SECONDARYSOCKET, newhost, newport, TRUE); + + data->req.protop = ftp_save; + + if(result) + return result; + + if(conn->tunnel_state[SECONDARYSOCKET] != TUNNEL_COMPLETE) { + /* the CONNECT procedure is not complete, the tunnel is not yet up */ + state(conn, FTP_STOP); /* this phase is completed */ + return result; + } + else + *magicdone = TRUE; + } ++ + return result; +} + ++static char *control_address(struct connectdata *conn) ++{ ++ /* Returns the control connection IP address. ++ If a proxy tunnel is used, returns the original host name instead, because ++ the effective control connection address is the proxy address, ++ not the ftp host. */ ++ if(conn->bits.tunnel_proxy || ++ conn->proxytype == CURLPROXY_SOCKS5 || ++ conn->proxytype == CURLPROXY_SOCKS5_HOSTNAME || ++ conn->proxytype == CURLPROXY_SOCKS4 || ++ conn->proxytype == CURLPROXY_SOCKS4A) ++ return conn->host.name; ++ ++ return conn->ip_addr_str; ++} ++ +static CURLcode ftp_state_pasv_resp(struct connectdata *conn, + int ftpcode) +{ + struct ftp_conn *ftpc = &conn->proto.ftpc; + CURLcode result; + struct SessionHandle *data=conn->data; + struct Curl_dns_entry *addr=NULL; + int rc; + unsigned short connectport; /* the local port connect() should use! */ + char *str=&data->state.buffer[4]; /* start on the first letter */ + ++ /* if we come here again, make sure the former name is cleared */ ++ Curl_safefree(ftpc->newhost); ++ + if((ftpc->count1 == 0) && + (ftpcode == 229)) { + /* positive EPSV response */ + char *ptr = strchr(str, '('); + if(ptr) { + unsigned int num; + char separator[4]; + ptr++; - if(5 == sscanf(ptr, "%c%c%c%u%c", - &separator[0], - &separator[1], - &separator[2], - &num, - &separator[3])) { ++ if(5 == sscanf(ptr, "%c%c%c%u%c", ++ &separator[0], ++ &separator[1], ++ &separator[2], ++ &num, ++ &separator[3])) { + const char sep1 = separator[0]; + int i; + + /* The four separators should be identical, or else this is an oddly + formatted reply and we bail out immediately. */ + for(i=1; i<4; i++) { + if(separator[i] != sep1) { + ptr=NULL; /* set to NULL to signal error */ + break; + } + } + if(num > 0xffff) { + failf(data, "Illegal port number in EPSV reply"); + return CURLE_FTP_WEIRD_PASV_REPLY; + } + if(ptr) { + ftpc->newport = (unsigned short)(num & 0xffff); - - if(conn->bits.tunnel_proxy || - conn->proxytype == CURLPROXY_SOCKS5 || - conn->proxytype == CURLPROXY_SOCKS5_HOSTNAME || - conn->proxytype == CURLPROXY_SOCKS4 || - conn->proxytype == CURLPROXY_SOCKS4A) - /* proxy tunnel -> use other host info because ip_addr_str is the - proxy address not the ftp host */ - snprintf(ftpc->newhost, sizeof(ftpc->newhost), "%s", - conn->host.name); - else - /* use the same IP we are already connected to */ - snprintf(ftpc->newhost, NEWHOST_BUFSIZE, "%s", conn->ip_addr_str); ++ ftpc->newhost = strdup(control_address(conn)); ++ if(!ftpc->newhost) ++ return CURLE_OUT_OF_MEMORY; + } + } + else + ptr=NULL; + } + if(!ptr) { + failf(data, "Weirdly formatted EPSV reply"); + return CURLE_FTP_WEIRD_PASV_REPLY; + } + } + else if((ftpc->count1 == 1) && + (ftpcode == 227)) { + /* positive PASV response */ + int ip[4]; + int port[2]; + + /* + * Scan for a sequence of six comma-separated numbers and use them as + * IP+port indicators. + * + * Found reply-strings include: + * "227 Entering Passive Mode (127,0,0,1,4,51)" + * "227 Data transfer will passively listen to 127,0,0,1,4,51" + * "227 Entering passive mode. 127,0,0,1,4,51" + */ + while(*str) { + if(6 == sscanf(str, "%d,%d,%d,%d,%d,%d", - &ip[0], &ip[1], &ip[2], &ip[3], - &port[0], &port[1])) ++ &ip[0], &ip[1], &ip[2], &ip[3], ++ &port[0], &port[1])) + break; + str++; + } + + if(!*str) { + failf(data, "Couldn't interpret the 227-response"); + return CURLE_FTP_WEIRD_227_FORMAT; + } + + /* we got OK from server */ + if(data->set.ftp_skip_ip) { - /* told to ignore the remotely given IP but instead use the one we used ++ /* told to ignore the remotely given IP but instead use the host we used + for the control connection */ - infof(data, "Skips %d.%d.%d.%d for data connection, uses %s instead\n", ++ infof(data, "Skip %d.%d.%d.%d for data connection, re-use %s instead\n", + ip[0], ip[1], ip[2], ip[3], - conn->ip_addr_str); - if(conn->bits.tunnel_proxy || - conn->proxytype == CURLPROXY_SOCKS5 || - conn->proxytype == CURLPROXY_SOCKS5_HOSTNAME || - conn->proxytype == CURLPROXY_SOCKS4 || - conn->proxytype == CURLPROXY_SOCKS4A) - /* proxy tunnel -> use other host info because ip_addr_str is the - proxy address not the ftp host */ - snprintf(ftpc->newhost, sizeof(ftpc->newhost), "%s", conn->host.name); - else - snprintf(ftpc->newhost, sizeof(ftpc->newhost), "%s", - conn->ip_addr_str); ++ conn->host.name); ++ ftpc->newhost = strdup(control_address(conn)); + } + else - snprintf(ftpc->newhost, sizeof(ftpc->newhost), - "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]); ++ ftpc->newhost = aprintf("%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]); ++ ++ if(!ftpc->newhost) ++ return CURLE_OUT_OF_MEMORY; ++ + ftpc->newport = (unsigned short)(((port[0]<<8) + port[1]) & 0xffff); + } + else if(ftpc->count1 == 0) { + /* EPSV failed, move on to PASV */ + return ftp_epsv_disable(conn); + } + else { + failf(data, "Bad PASV/EPSV response: %03d", ftpcode); + return CURLE_FTP_WEIRD_PASV_REPLY; + } + + if(conn->bits.proxy) { + /* + * This connection uses a proxy and we need to connect to the proxy again + * here. We don't want to rely on a former host lookup that might've + * expired now, instead we remake the lookup here and now! + */ + rc = Curl_resolv(conn, conn->proxy.name, (int)conn->port, &addr); + if(rc == CURLRESOLV_PENDING) + /* BLOCKING, ignores the return code but 'addr' will be NULL in + case of failure */ + (void)Curl_resolver_wait_resolv(conn, &addr); + + connectport = + (unsigned short)conn->port; /* we connect to the proxy's port */ + + if(!addr) { + failf(data, "Can't resolve proxy host %s:%hu", + conn->proxy.name, connectport); + return CURLE_FTP_CANT_GET_HOST; + } + } + else { + /* normal, direct, ftp connection */ + rc = Curl_resolv(conn, ftpc->newhost, ftpc->newport, &addr); + if(rc == CURLRESOLV_PENDING) + /* BLOCKING */ + (void)Curl_resolver_wait_resolv(conn, &addr); + + connectport = ftpc->newport; /* we connect to the remote port */ + + if(!addr) { + failf(data, "Can't resolve new host %s:%hu", ftpc->newhost, connectport); + return CURLE_FTP_CANT_GET_HOST; + } + } + + conn->bits.tcpconnect[SECONDARYSOCKET] = FALSE; + result = Curl_connecthost(conn, addr); + - Curl_resolv_unlock(data, addr); /* we're done using this address */ - + if(result) { ++ Curl_resolv_unlock(data, addr); /* we're done using this address */ + if(ftpc->count1 == 0 && ftpcode == 229) + return ftp_epsv_disable(conn); + + return result; + } + + + /* + * When this is used from the multi interface, this might've returned with + * the 'connected' set to FALSE and thus we are now awaiting a non-blocking + * connect to connect. + */ + + if(data->set.verbose) + /* this just dumps information about this second connection */ - ftp_pasv_verbose(conn, conn->ip_addr, ftpc->newhost, connectport); ++ ftp_pasv_verbose(conn, addr->addr, ftpc->newhost, connectport); + ++ Curl_resolv_unlock(data, addr); /* we're done using this address */ + conn->bits.do_more = TRUE; + state(conn, FTP_STOP); /* this phase is completed */ + + return result; +} + +static CURLcode ftp_state_port_resp(struct connectdata *conn, + int ftpcode) +{ + struct SessionHandle *data = conn->data; + struct ftp_conn *ftpc = &conn->proto.ftpc; + ftpport fcmd = (ftpport)ftpc->count1; + CURLcode result = CURLE_OK; + - if(ftpcode != 200) { ++ /* The FTP spec tells a positive response should have code 200. ++ Be more permissive here to tolerate deviant servers. */ ++ if(ftpcode / 100 != 2) { + /* the command failed */ + + if(EPRT == fcmd) { + infof(data, "disabling EPRT usage\n"); + conn->bits.ftp_use_eprt = FALSE; + } + fcmd++; + + if(fcmd == DONE) { + failf(data, "Failed to do PORT"); + result = CURLE_FTP_PORT_FAILED; + } + else + /* try next */ + result = ftp_state_use_port(conn, fcmd); + } + else { + infof(data, "Connect data stream actively\n"); + state(conn, FTP_STOP); /* end of DO phase */ + result = ftp_dophase_done(conn, FALSE); + } + + return result; +} + +static CURLcode ftp_state_mdtm_resp(struct connectdata *conn, + int ftpcode) +{ + CURLcode result = CURLE_OK; + struct SessionHandle *data=conn->data; + struct FTP *ftp = data->req.protop; + struct ftp_conn *ftpc = &conn->proto.ftpc; + + switch(ftpcode) { + case 213: + { + /* we got a time. Format should be: "YYYYMMDDHHMMSS[.sss]" where the + last .sss part is optional and means fractions of a second */ + int year, month, day, hour, minute, second; + char *buf = data->state.buffer; + if(6 == sscanf(buf+4, "%04d%02d%02d%02d%02d%02d", + &year, &month, &day, &hour, &minute, &second)) { + /* we have a time, reformat it */ + time_t secs=time(NULL); + /* using the good old yacc/bison yuck */ + snprintf(buf, sizeof(conn->data->state.buffer), + "%04d%02d%02d %02d:%02d:%02d GMT", + year, month, day, hour, minute, second); + /* now, convert this into a time() value: */ + data->info.filetime = (long)curl_getdate(buf, &secs); + } + +#ifdef CURL_FTP_HTTPSTYLE_HEAD + /* If we asked for a time of the file and we actually got one as well, + we "emulate" a HTTP-style header in our output. */ + + if(data->set.opt_no_body && + ftpc->file && + data->set.get_filetime && + (data->info.filetime>=0) ) { + time_t filetime = (time_t)data->info.filetime; + struct tm buffer; + const struct tm *tm = &buffer; + + result = Curl_gmtime(filetime, &buffer); + if(result) + return result; + + /* format: "Tue, 15 Nov 1994 12:45:26" */ + snprintf(buf, BUFSIZE-1, + "Last-Modified: %s, %02d %s %4d %02d:%02d:%02d GMT\r\n", + Curl_wkday[tm->tm_wday?tm->tm_wday-1:6], + tm->tm_mday, + Curl_month[tm->tm_mon], + tm->tm_year + 1900, + tm->tm_hour, + tm->tm_min, + tm->tm_sec); + result = Curl_client_write(conn, CLIENTWRITE_BOTH, buf, 0); + if(result) + return result; + } /* end of a ridiculous amount of conditionals */ +#endif + } + break; + default: + infof(data, "unsupported MDTM reply format\n"); + break; + case 550: /* "No such file or directory" */ + failf(data, "Given file does not exist"); + result = CURLE_FTP_COULDNT_RETR_FILE; + break; + } + + if(data->set.timecondition) { + if((data->info.filetime > 0) && (data->set.timevalue > 0)) { + switch(data->set.timecondition) { + case CURL_TIMECOND_IFMODSINCE: + default: + if(data->info.filetime <= data->set.timevalue) { + infof(data, "The requested document is not new enough\n"); + ftp->transfer = FTPTRANSFER_NONE; /* mark to not transfer data */ + data->info.timecond = TRUE; + state(conn, FTP_STOP); + return CURLE_OK; + } + break; + case CURL_TIMECOND_IFUNMODSINCE: + if(data->info.filetime > data->set.timevalue) { + infof(data, "The requested document is not old enough\n"); + ftp->transfer = FTPTRANSFER_NONE; /* mark to not transfer data */ + data->info.timecond = TRUE; + state(conn, FTP_STOP); + return CURLE_OK; + } + break; + } /* switch */ + } + else { + infof(data, "Skipping time comparison\n"); + } + } + + if(!result) + result = ftp_state_type(conn); + + return result; +} + +static CURLcode ftp_state_type_resp(struct connectdata *conn, + int ftpcode, + ftpstate instate) +{ + CURLcode result = CURLE_OK; + struct SessionHandle *data=conn->data; + + if(ftpcode/100 != 2) { + /* "sasserftpd" and "(u)r(x)bot ftpd" both responds with 226 after a + successful 'TYPE I'. While that is not as RFC959 says, it is still a + positive response code and we allow that. */ + failf(data, "Couldn't set desired mode"); + return CURLE_FTP_COULDNT_SET_TYPE; + } + if(ftpcode != 200) + infof(data, "Got a %03d response code instead of the assumed 200\n", + ftpcode); + + if(instate == FTP_TYPE) + result = ftp_state_size(conn); + else if(instate == FTP_LIST_TYPE) + result = ftp_state_list(conn); + else if(instate == FTP_RETR_TYPE) + result = ftp_state_retr_prequote(conn); + else if(instate == FTP_STOR_TYPE) + result = ftp_state_stor_prequote(conn); + + return result; +} + +static CURLcode ftp_state_retr(struct connectdata *conn, + curl_off_t filesize) +{ + CURLcode result = CURLE_OK; + struct SessionHandle *data=conn->data; + struct FTP *ftp = data->req.protop; + struct ftp_conn *ftpc = &conn->proto.ftpc; + + if(data->set.max_filesize && (filesize > data->set.max_filesize)) { + failf(data, "Maximum file size exceeded"); + return CURLE_FILESIZE_EXCEEDED; + } + ftp->downloadsize = filesize; + + if(data->state.resume_from) { + /* We always (attempt to) get the size of downloads, so it is done before + this even when not doing resumes. */ + if(filesize == -1) { + infof(data, "ftp server doesn't support SIZE\n"); + /* We couldn't get the size and therefore we can't know if there really + is a part of the file left to get, although the server will just + close the connection when we start the connection so it won't cause + us any harm, just not make us exit as nicely. */ + } + else { + /* We got a file size report, so we check that there actually is a + part of the file left to get, or else we go home. */ + if(data->state.resume_from< 0) { + /* We're supposed to download the last abs(from) bytes */ + if(filesize < -data->state.resume_from) { + failf(data, "Offset (%" CURL_FORMAT_CURL_OFF_T + ") was beyond file size (%" CURL_FORMAT_CURL_OFF_T ")", + data->state.resume_from, filesize); + return CURLE_BAD_DOWNLOAD_RESUME; + } + /* convert to size to download */ + ftp->downloadsize = -data->state.resume_from; + /* download from where? */ + data->state.resume_from = filesize - ftp->downloadsize; + } + else { + if(filesize < data->state.resume_from) { + failf(data, "Offset (%" CURL_FORMAT_CURL_OFF_T + ") was beyond file size (%" CURL_FORMAT_CURL_OFF_T ")", + data->state.resume_from, filesize); + return CURLE_BAD_DOWNLOAD_RESUME; + } + /* Now store the number of bytes we are expected to download */ + ftp->downloadsize = filesize-data->state.resume_from; + } + } + + if(ftp->downloadsize == 0) { + /* no data to transfer */ + Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL); + infof(data, "File already completely downloaded\n"); + + /* Set ->transfer so that we won't get any error in ftp_done() + * because we didn't transfer the any file */ + ftp->transfer = FTPTRANSFER_NONE; + state(conn, FTP_STOP); + return CURLE_OK; + } + + /* Set resume file transfer offset */ + infof(data, "Instructs server to resume from offset %" + CURL_FORMAT_CURL_OFF_T "\n", data->state.resume_from); + + PPSENDF(&ftpc->pp, "REST %" CURL_FORMAT_CURL_OFF_T, + data->state.resume_from); + + state(conn, FTP_RETR_REST); + } + else { + /* no resume */ + PPSENDF(&ftpc->pp, "RETR %s", ftpc->file); + state(conn, FTP_RETR); + } + + return result; +} + +static CURLcode ftp_state_size_resp(struct connectdata *conn, + int ftpcode, + ftpstate instate) +{ + CURLcode result = CURLE_OK; + struct SessionHandle *data=conn->data; + curl_off_t filesize; + char *buf = data->state.buffer; + + /* get the size from the ascii string: */ + filesize = (ftpcode == 213)?curlx_strtoofft(buf+4, NULL, 0):-1; + + if(instate == FTP_SIZE) { +#ifdef CURL_FTP_HTTPSTYLE_HEAD + if(-1 != filesize) { + snprintf(buf, sizeof(data->state.buffer), + "Content-Length: %" CURL_FORMAT_CURL_OFF_T "\r\n", filesize); + result = Curl_client_write(conn, CLIENTWRITE_BOTH, buf, 0); + if(result) + return result; + } +#endif + Curl_pgrsSetDownloadSize(data, filesize); + result = ftp_state_rest(conn); + } + else if(instate == FTP_RETR_SIZE) { + Curl_pgrsSetDownloadSize(data, filesize); + result = ftp_state_retr(conn, filesize); + } + else if(instate == FTP_STOR_SIZE) { + data->state.resume_from = filesize; + result = ftp_state_ul_setup(conn, TRUE); + } + + return result; +} + +static CURLcode ftp_state_rest_resp(struct connectdata *conn, + int ftpcode, + ftpstate instate) +{ + CURLcode result = CURLE_OK; + struct ftp_conn *ftpc = &conn->proto.ftpc; + + switch(instate) { + case FTP_REST: + default: +#ifdef CURL_FTP_HTTPSTYLE_HEAD + if(ftpcode == 350) { + char buffer[24]= { "Accept-ranges: bytes\r\n" }; + result = Curl_client_write(conn, CLIENTWRITE_BOTH, buffer, 0); + if(result) + return result; + } +#endif + result = ftp_state_prepare_transfer(conn); + break; + + case FTP_RETR_REST: + if(ftpcode != 350) { + failf(conn->data, "Couldn't use REST"); + result = CURLE_FTP_COULDNT_USE_REST; + } + else { + PPSENDF(&ftpc->pp, "RETR %s", ftpc->file); + state(conn, FTP_RETR); + } + break; + } + + return result; +} + +static CURLcode ftp_state_stor_resp(struct connectdata *conn, + int ftpcode, ftpstate instate) +{ + CURLcode result = CURLE_OK; + struct SessionHandle *data = conn->data; + + if(ftpcode>=400) { + failf(data, "Failed FTP upload: %0d", ftpcode); + state(conn, FTP_STOP); + /* oops, we never close the sockets! */ + return CURLE_UPLOAD_FAILED; + } + + conn->proto.ftpc.state_saved = instate; + + /* PORT means we are now awaiting the server to connect to us. */ + if(data->set.ftp_use_port) { + bool connected; + + state(conn, FTP_STOP); /* no longer in STOR state */ + + result = AllowServerConnect(conn, &connected); + if(result) + return result; + + if(!connected) { + struct ftp_conn *ftpc = &conn->proto.ftpc; + infof(data, "Data conn was not available immediately\n"); + ftpc->wait_data_conn = TRUE; + } + + return CURLE_OK; + } + else + return InitiateTransfer(conn); +} + +/* for LIST and RETR responses */ +static CURLcode ftp_state_get_resp(struct connectdata *conn, + int ftpcode, + ftpstate instate) +{ + CURLcode result = CURLE_OK; + struct SessionHandle *data = conn->data; + struct FTP *ftp = data->req.protop; + char *buf = data->state.buffer; + + if((ftpcode == 150) || (ftpcode == 125)) { + + /* + A; + 150 Opening BINARY mode data connection for /etc/passwd (2241 + bytes). (ok, the file is being transferred) + + B: + 150 Opening ASCII mode data connection for /bin/ls + + C: + 150 ASCII data connection for /bin/ls (137.167.104.91,37445) (0 bytes). + + D: + 150 Opening ASCII mode data connection for [file] (0.0.0.0,0) (545 bytes) + + E: + 125 Data connection already open; Transfer starting. */ + + curl_off_t size=-1; /* default unknown size */ + + + /* + * It appears that there are FTP-servers that return size 0 for files when + * SIZE is used on the file while being in BINARY mode. To work around + * that (stupid) behavior, we attempt to parse the RETR response even if + * the SIZE returned size zero. + * + * Debugging help from Salvatore Sorrentino on February 26, 2003. + */ + + if((instate != FTP_LIST) && + !data->set.prefer_ascii && + (ftp->downloadsize < 1)) { + /* + * It seems directory listings either don't show the size or very + * often uses size 0 anyway. ASCII transfers may very well turn out + * that the transferred amount of data is not the same as this line + * tells, why using this number in those cases only confuses us. + * + * Example D above makes this parsing a little tricky */ + char *bytes; + bytes=strstr(buf, " bytes"); + if(bytes--) { + long in=(long)(bytes-buf); + /* this is a hint there is size information in there! ;-) */ + while(--in) { + /* scan for the left parenthesis and break there */ + if('(' == *bytes) + break; + /* skip only digits */ + if(!ISDIGIT(*bytes)) { + bytes=NULL; + break; + } + /* one more estep backwards */ + bytes--; + } + /* if we have nothing but digits: */ + if(bytes++) { + /* get the number! */ + size = curlx_strtoofft(bytes, NULL, 0); + } + } + } + else if(ftp->downloadsize > -1) + size = ftp->downloadsize; + + if(size > data->req.maxdownload && data->req.maxdownload > 0) + size = data->req.size = data->req.maxdownload; + else if((instate != FTP_LIST) && (data->set.prefer_ascii)) + size = -1; /* kludge for servers that understate ASCII mode file size */ + + infof(data, "Maxdownload = %" CURL_FORMAT_CURL_OFF_T "\n", + data->req.maxdownload); + + if(instate != FTP_LIST) + infof(data, "Getting file with size: %" CURL_FORMAT_CURL_OFF_T "\n", + size); + + /* FTP download: */ + conn->proto.ftpc.state_saved = instate; + conn->proto.ftpc.retr_size_saved = size; + + if(data->set.ftp_use_port) { + bool connected; + + result = AllowServerConnect(conn, &connected); + if(result) + return result; + + if(!connected) { + struct ftp_conn *ftpc = &conn->proto.ftpc; + infof(data, "Data conn was not available immediately\n"); + state(conn, FTP_STOP); + ftpc->wait_data_conn = TRUE; + } + } + else + return InitiateTransfer(conn); + } + else { + if((instate == FTP_LIST) && (ftpcode == 450)) { + /* simply no matching files in the dir listing */ + ftp->transfer = FTPTRANSFER_NONE; /* don't download anything */ + state(conn, FTP_STOP); /* this phase is over */ + } + else { + failf(data, "RETR response: %03d", ftpcode); + return instate == FTP_RETR && ftpcode == 550? + CURLE_REMOTE_FILE_NOT_FOUND: + CURLE_FTP_COULDNT_RETR_FILE; + } + } + + return result; +} + +/* after USER, PASS and ACCT */ +static CURLcode ftp_state_loggedin(struct connectdata *conn) +{ + CURLcode result = CURLE_OK; + + if(conn->ssl[FIRSTSOCKET].use) { + /* PBSZ = PROTECTION BUFFER SIZE. + + The 'draft-murray-auth-ftp-ssl' (draft 12, page 7) says: + + Specifically, the PROT command MUST be preceded by a PBSZ + command and a PBSZ command MUST be preceded by a successful + security data exchange (the TLS negotiation in this case) + + ... (and on page 8): + + Thus the PBSZ command must still be issued, but must have a + parameter of '0' to indicate that no buffering is taking place + and the data connection should not be encapsulated. + */ + PPSENDF(&conn->proto.ftpc.pp, "PBSZ %d", 0); + state(conn, FTP_PBSZ); + } + else { + result = ftp_state_pwd(conn); + } + return result; +} + +/* for USER and PASS responses */ +static CURLcode ftp_state_user_resp(struct connectdata *conn, + int ftpcode, + ftpstate instate) +{ + CURLcode result = CURLE_OK; + struct SessionHandle *data = conn->data; + struct FTP *ftp = data->req.protop; + struct ftp_conn *ftpc = &conn->proto.ftpc; + (void)instate; /* no use for this yet */ + + /* some need password anyway, and others just return 2xx ignored */ + if((ftpcode == 331) && (ftpc->state == FTP_USER)) { + /* 331 Password required for ... + (the server requires to send the user's password too) */ + PPSENDF(&ftpc->pp, "PASS %s", ftp->passwd?ftp->passwd:""); + state(conn, FTP_PASS); + } + else if(ftpcode/100 == 2) { + /* 230 User ... logged in. + (the user logged in with or without password) */ + result = ftp_state_loggedin(conn); + } + else if(ftpcode == 332) { + if(data->set.str[STRING_FTP_ACCOUNT]) { + PPSENDF(&ftpc->pp, "ACCT %s", data->set.str[STRING_FTP_ACCOUNT]); + state(conn, FTP_ACCT); + } + else { + failf(data, "ACCT requested but none available"); + result = CURLE_LOGIN_DENIED; + } + } + else { + /* All other response codes, like: + + 530 User ... access denied + (the server denies to log the specified user) */ + + if(conn->data->set.str[STRING_FTP_ALTERNATIVE_TO_USER] && + !conn->data->state.ftp_trying_alternative) { + /* Ok, USER failed. Let's try the supplied command. */ + PPSENDF(&conn->proto.ftpc.pp, "%s", + conn->data->set.str[STRING_FTP_ALTERNATIVE_TO_USER]); + conn->data->state.ftp_trying_alternative = TRUE; + state(conn, FTP_USER); + result = CURLE_OK; + } + else { + failf(data, "Access denied: %03d", ftpcode); + result = CURLE_LOGIN_DENIED; + } + } + return result; +} + +/* for ACCT response */ +static CURLcode ftp_state_acct_resp(struct connectdata *conn, + int ftpcode) +{ + CURLcode result = CURLE_OK; + struct SessionHandle *data = conn->data; + if(ftpcode != 230) { + failf(data, "ACCT rejected by server: %03d", ftpcode); + result = CURLE_FTP_WEIRD_PASS_REPLY; /* FIX */ + } + else + result = ftp_state_loggedin(conn); + + return result; +} + + +static CURLcode ftp_statemach_act(struct connectdata *conn) +{ + CURLcode result; + curl_socket_t sock = conn->sock[FIRSTSOCKET]; + struct SessionHandle *data=conn->data; + int ftpcode; + struct ftp_conn *ftpc = &conn->proto.ftpc; + struct pingpong *pp = &ftpc->pp; + static const char ftpauth[][4] = { "SSL", "TLS" }; + size_t nread = 0; + + if(pp->sendleft) + return Curl_pp_flushsend(pp); + + result = ftp_readresp(sock, pp, &ftpcode, &nread); + if(result) + return result; + + if(ftpcode) { + /* we have now received a full FTP server response */ + switch(ftpc->state) { + case FTP_WAIT220: + if(ftpcode == 230) + /* 230 User logged in - already! */ + return ftp_state_user_resp(conn, ftpcode, ftpc->state); + else if(ftpcode != 220) { + failf(data, "Got a %03d ftp-server response when 220 was expected", + ftpcode); + return CURLE_FTP_WEIRD_SERVER_REPLY; + } + + /* We have received a 220 response fine, now we proceed. */ +#ifdef HAVE_GSSAPI + if(data->set.krb) { + /* If not anonymous login, try a secure login. Note that this + procedure is still BLOCKING. */ + + Curl_sec_request_prot(conn, "private"); + /* We set private first as default, in case the line below fails to + set a valid level */ + Curl_sec_request_prot(conn, data->set.str[STRING_KRB_LEVEL]); + - if(Curl_sec_login(conn) != CURLE_OK) ++ if(Curl_sec_login(conn)) + infof(data, "Logging in with password in cleartext!\n"); + else + infof(data, "Authentication successful\n"); + } +#endif + + if(data->set.use_ssl && !conn->ssl[FIRSTSOCKET].use) { + /* We don't have a SSL/TLS connection yet, but FTPS is + requested. Try a FTPS connection now */ + + ftpc->count3=0; + switch(data->set.ftpsslauth) { + case CURLFTPAUTH_DEFAULT: + case CURLFTPAUTH_SSL: + ftpc->count2 = 1; /* add one to get next */ + ftpc->count1 = 0; + break; + case CURLFTPAUTH_TLS: + ftpc->count2 = -1; /* subtract one to get next */ + ftpc->count1 = 1; + break; + default: + failf(data, "unsupported parameter to CURLOPT_FTPSSLAUTH: %d", + (int)data->set.ftpsslauth); + return CURLE_UNKNOWN_OPTION; /* we don't know what to do */ + } + PPSENDF(&ftpc->pp, "AUTH %s", ftpauth[ftpc->count1]); + state(conn, FTP_AUTH); + } + else { + result = ftp_state_user(conn); + if(result) + return result; + } + + break; + + case FTP_AUTH: + /* we have gotten the response to a previous AUTH command */ + + /* RFC2228 (page 5) says: + * + * If the server is willing to accept the named security mechanism, + * and does not require any security data, it must respond with + * reply code 234/334. + */ + + if((ftpcode == 234) || (ftpcode == 334)) { + /* Curl_ssl_connect is BLOCKING */ + result = Curl_ssl_connect(conn, FIRSTSOCKET); - if(CURLE_OK == result) { ++ if(!result) { + conn->ssl[SECONDARYSOCKET].use = FALSE; /* clear-text data */ + result = ftp_state_user(conn); + } + } + else if(ftpc->count3 < 1) { + ftpc->count3++; + ftpc->count1 += ftpc->count2; /* get next attempt */ + result = Curl_pp_sendf(&ftpc->pp, "AUTH %s", ftpauth[ftpc->count1]); + /* remain in this same state */ + } + else { + if(data->set.use_ssl > CURLUSESSL_TRY) + /* we failed and CURLUSESSL_CONTROL or CURLUSESSL_ALL is set */ + result = CURLE_USE_SSL_FAILED; + else + /* ignore the failure and continue */ + result = ftp_state_user(conn); + } + + if(result) + return result; + break; + + case FTP_USER: + case FTP_PASS: + result = ftp_state_user_resp(conn, ftpcode, ftpc->state); + break; + + case FTP_ACCT: + result = ftp_state_acct_resp(conn, ftpcode); + break; + + case FTP_PBSZ: + PPSENDF(&ftpc->pp, "PROT %c", + data->set.use_ssl == CURLUSESSL_CONTROL ? 'C' : 'P'); + state(conn, FTP_PROT); + + break; + + case FTP_PROT: + if(ftpcode/100 == 2) + /* We have enabled SSL for the data connection! */ + conn->ssl[SECONDARYSOCKET].use = + (data->set.use_ssl != CURLUSESSL_CONTROL) ? TRUE : FALSE; + /* FTP servers typically responds with 500 if they decide to reject + our 'P' request */ + else if(data->set.use_ssl > CURLUSESSL_CONTROL) + /* we failed and bails out */ + return CURLE_USE_SSL_FAILED; + + if(data->set.ftp_ccc) { + /* CCC - Clear Command Channel + */ + PPSENDF(&ftpc->pp, "%s", "CCC"); + state(conn, FTP_CCC); + } + else { + result = ftp_state_pwd(conn); + if(result) + return result; + } + break; + + case FTP_CCC: + if(ftpcode < 500) { + /* First shut down the SSL layer (note: this call will block) */ + result = Curl_ssl_shutdown(conn, FIRSTSOCKET); + + if(result) { + failf(conn->data, "Failed to clear the command channel (CCC)"); + return result; + } + } + + /* Then continue as normal */ + result = ftp_state_pwd(conn); + if(result) + return result; + break; + + case FTP_PWD: + if(ftpcode == 257) { + char *ptr=&data->state.buffer[4]; /* start on the first letter */ + char *dir; + char *store; + + dir = malloc(nread + 1); + if(!dir) + return CURLE_OUT_OF_MEMORY; + + /* Reply format is like + 257[rubbish]"" and the + RFC959 says + + The directory name can contain any character; embedded + double-quotes should be escaped by double-quotes (the + "quote-doubling" convention). + */ + + /* scan for the first double-quote for non-standard responses */ + while(ptr < &data->state.buffer[sizeof(data->state.buffer)] + && *ptr != '\n' && *ptr != '\0' && *ptr != '"') + ptr++; + + if('\"' == *ptr) { + /* it started good */ + ptr++; + for(store = dir; *ptr;) { + if('\"' == *ptr) { + if('\"' == ptr[1]) { + /* "quote-doubling" */ + *store = ptr[1]; + ptr++; + } + else { + /* end of path */ + *store = '\0'; /* zero terminate */ + break; /* get out of this loop */ + } + } + else + *store = *ptr; + store++; + ptr++; + } + + /* If the path name does not look like an absolute path (i.e.: it + does not start with a '/'), we probably need some server-dependent + adjustments. For example, this is the case when connecting to + an OS400 FTP server: this server supports two name syntaxes, + the default one being incompatible with standard pathes. In + addition, this server switches automatically to the regular path + syntax when one is encountered in a command: this results in + having an entrypath in the wrong syntax when later used in CWD. + The method used here is to check the server OS: we do it only + if the path name looks strange to minimize overhead on other + systems. */ + + if(!ftpc->server_os && dir[0] != '/') { + + result = Curl_pp_sendf(&ftpc->pp, "%s", "SYST"); - if(result != CURLE_OK) { ++ if(result) { + free(dir); + return result; + } + Curl_safefree(ftpc->entrypath); + ftpc->entrypath = dir; /* remember this */ + infof(data, "Entry path is '%s'\n", ftpc->entrypath); + /* also save it where getinfo can access it: */ + data->state.most_recent_ftp_entrypath = ftpc->entrypath; + state(conn, FTP_SYST); + break; + } + + Curl_safefree(ftpc->entrypath); + ftpc->entrypath = dir; /* remember this */ + infof(data, "Entry path is '%s'\n", ftpc->entrypath); + /* also save it where getinfo can access it: */ + data->state.most_recent_ftp_entrypath = ftpc->entrypath; + } + else { + /* couldn't get the path */ + free(dir); + infof(data, "Failed to figure out path\n"); + } + } + state(conn, FTP_STOP); /* we are done with the CONNECT phase! */ + DEBUGF(infof(data, "protocol connect phase DONE\n")); + break; + + case FTP_SYST: + if(ftpcode == 215) { + char *ptr=&data->state.buffer[4]; /* start on the first letter */ + char *os; + char *store; + + os = malloc(nread + 1); + if(!os) + return CURLE_OUT_OF_MEMORY; + + /* Reply format is like + 215 + */ + while(*ptr == ' ') + ptr++; + for(store = os; *ptr && *ptr != ' ';) + *store++ = *ptr++; + *store = '\0'; /* zero terminate */ + + /* Check for special servers here. */ + + if(strequal(os, "OS/400")) { + /* Force OS400 name format 1. */ + result = Curl_pp_sendf(&ftpc->pp, "%s", "SITE NAMEFMT 1"); - if(result != CURLE_OK) { ++ if(result) { + free(os); + return result; + } + /* remember target server OS */ + Curl_safefree(ftpc->server_os); + ftpc->server_os = os; + state(conn, FTP_NAMEFMT); + break; + } + else { + /* Nothing special for the target server. */ + /* remember target server OS */ + Curl_safefree(ftpc->server_os); + ftpc->server_os = os; + } + } + else { + /* Cannot identify server OS. Continue anyway and cross fingers. */ + } + + state(conn, FTP_STOP); /* we are done with the CONNECT phase! */ + DEBUGF(infof(data, "protocol connect phase DONE\n")); + break; + + case FTP_NAMEFMT: + if(ftpcode == 250) { + /* Name format change successful: reload initial path. */ + ftp_state_pwd(conn); + break; + } + + state(conn, FTP_STOP); /* we are done with the CONNECT phase! */ + DEBUGF(infof(data, "protocol connect phase DONE\n")); + break; + + case FTP_QUOTE: + case FTP_POSTQUOTE: + case FTP_RETR_PREQUOTE: + case FTP_STOR_PREQUOTE: + if((ftpcode >= 400) && !ftpc->count2) { + /* failure response code, and not allowed to fail */ + failf(conn->data, "QUOT command failed with %03d", ftpcode); + return CURLE_QUOTE_ERROR; + } + result = ftp_state_quote(conn, FALSE, ftpc->state); + if(result) + return result; + + break; + + case FTP_CWD: + if(ftpcode/100 != 2) { + /* failure to CWD there */ + if(conn->data->set.ftp_create_missing_dirs && + ftpc->count1 && !ftpc->count2) { + /* try making it */ + ftpc->count2++; /* counter to prevent CWD-MKD loops */ + PPSENDF(&ftpc->pp, "MKD %s", ftpc->dirs[ftpc->count1 - 1]); + state(conn, FTP_MKD); + } + else { + /* return failure */ + failf(data, "Server denied you to change to the given directory"); + ftpc->cwdfail = TRUE; /* don't remember this path as we failed + to enter it */ + return CURLE_REMOTE_ACCESS_DENIED; + } + } + else { + /* success */ + ftpc->count2=0; + if(++ftpc->count1 <= ftpc->dirdepth) { + /* send next CWD */ + PPSENDF(&ftpc->pp, "CWD %s", ftpc->dirs[ftpc->count1 - 1]); + } + else { + result = ftp_state_mdtm(conn); + if(result) + return result; + } + } + break; + + case FTP_MKD: + if((ftpcode/100 != 2) && !ftpc->count3--) { + /* failure to MKD the dir */ + failf(data, "Failed to MKD dir: %03d", ftpcode); + return CURLE_REMOTE_ACCESS_DENIED; + } + state(conn, FTP_CWD); + /* send CWD */ + PPSENDF(&ftpc->pp, "CWD %s", ftpc->dirs[ftpc->count1 - 1]); + break; + + case FTP_MDTM: + result = ftp_state_mdtm_resp(conn, ftpcode); + break; + + case FTP_TYPE: + case FTP_LIST_TYPE: + case FTP_RETR_TYPE: + case FTP_STOR_TYPE: + result = ftp_state_type_resp(conn, ftpcode, ftpc->state); + break; + + case FTP_SIZE: + case FTP_RETR_SIZE: + case FTP_STOR_SIZE: + result = ftp_state_size_resp(conn, ftpcode, ftpc->state); + break; + + case FTP_REST: + case FTP_RETR_REST: + result = ftp_state_rest_resp(conn, ftpcode, ftpc->state); + break; + + case FTP_PRET: + if(ftpcode != 200) { + /* there only is this one standard OK return code. */ + failf(data, "PRET command not accepted: %03d", ftpcode); + return CURLE_FTP_PRET_FAILED; + } + result = ftp_state_use_pasv(conn); + break; + + case FTP_PASV: + result = ftp_state_pasv_resp(conn, ftpcode); + break; + + case FTP_PORT: + result = ftp_state_port_resp(conn, ftpcode); + break; + + case FTP_LIST: + case FTP_RETR: + result = ftp_state_get_resp(conn, ftpcode, ftpc->state); + break; + + case FTP_STOR: + result = ftp_state_stor_resp(conn, ftpcode, ftpc->state); + break; + + case FTP_QUIT: + /* fallthrough, just stop! */ + default: + /* internal error */ + state(conn, FTP_STOP); + break; + } + } /* if(ftpcode) */ + + return result; +} + + +/* called repeatedly until done from multi.c */ +static CURLcode ftp_multi_statemach(struct connectdata *conn, + bool *done) +{ + struct ftp_conn *ftpc = &conn->proto.ftpc; + CURLcode result = Curl_pp_statemach(&ftpc->pp, FALSE); + + /* Check for the state outside of the Curl_socket_ready() return code checks + since at times we are in fact already in this state when this function + gets called. */ + *done = (ftpc->state == FTP_STOP) ? TRUE : FALSE; + + return result; +} + +static CURLcode ftp_block_statemach(struct connectdata *conn) +{ + struct ftp_conn *ftpc = &conn->proto.ftpc; + struct pingpong *pp = &ftpc->pp; + CURLcode result = CURLE_OK; + + while(ftpc->state != FTP_STOP) { + result = Curl_pp_statemach(pp, TRUE); + if(result) + break; + } + + return result; +} + +/* + * ftp_connect() should do everything that is to be considered a part of + * the connection phase. + * + * The variable 'done' points to will be TRUE if the protocol-layer connect + * phase is done when this function returns, or FALSE if not. + * + */ +static CURLcode ftp_connect(struct connectdata *conn, + bool *done) /* see description above */ +{ + CURLcode result; + struct ftp_conn *ftpc = &conn->proto.ftpc; + struct pingpong *pp = &ftpc->pp; + + *done = FALSE; /* default to not done yet */ + + /* We always support persistent connections on ftp */ + connkeep(conn, "FTP default"); + + pp->response_time = RESP_TIMEOUT; /* set default response time-out */ + pp->statemach_act = ftp_statemach_act; + pp->endofresp = ftp_endofresp; + pp->conn = conn; + + if(conn->handler->flags & PROTOPT_SSL) { + /* BLOCKING */ + result = Curl_ssl_connect(conn, FIRSTSOCKET); + if(result) + return result; + } + + Curl_pp_init(pp); /* init the generic pingpong data */ + + /* When we connect, we start in the state where we await the 220 + response */ + state(conn, FTP_WAIT220); + + result = ftp_multi_statemach(conn, done); + + return result; +} + +/*********************************************************************** + * + * ftp_done() + * + * The DONE function. This does what needs to be done after a single DO has + * performed. + * + * Input argument is already checked for validity. + */ +static CURLcode ftp_done(struct connectdata *conn, CURLcode status, + bool premature) +{ + struct SessionHandle *data = conn->data; + struct FTP *ftp = data->req.protop; + struct ftp_conn *ftpc = &conn->proto.ftpc; + struct pingpong *pp = &ftpc->pp; + ssize_t nread; + int ftpcode; + CURLcode result = CURLE_OK; + bool was_ctl_valid = ftpc->ctl_valid; + char *path; + const char *path_to_use = data->state.path; + + if(!ftp) + /* When the easy handle is removed from the multi while libcurl is still + * trying to resolve the host name, it seems that the ftp struct is not + * yet initialized, but the removal action calls Curl_done() which calls + * this function. So we simply return success if no ftp pointer is set. + */ + return CURLE_OK; + + switch(status) { + case CURLE_BAD_DOWNLOAD_RESUME: + case CURLE_FTP_WEIRD_PASV_REPLY: + case CURLE_FTP_PORT_FAILED: + case CURLE_FTP_ACCEPT_FAILED: + case CURLE_FTP_ACCEPT_TIMEOUT: + case CURLE_FTP_COULDNT_SET_TYPE: + case CURLE_FTP_COULDNT_RETR_FILE: + case CURLE_PARTIAL_FILE: + case CURLE_UPLOAD_FAILED: + case CURLE_REMOTE_ACCESS_DENIED: + case CURLE_FILESIZE_EXCEEDED: + case CURLE_REMOTE_FILE_NOT_FOUND: + case CURLE_WRITE_ERROR: + /* the connection stays alive fine even though this happened */ + /* fall-through */ + case CURLE_OK: /* doesn't affect the control connection's status */ + if(!premature) { + ftpc->ctl_valid = was_ctl_valid; + break; + } + /* until we cope better with prematurely ended requests, let them + * fallback as if in complete failure */ + default: /* by default, an error means the control connection is + wedged and should not be used anymore */ + ftpc->ctl_valid = FALSE; + ftpc->cwdfail = TRUE; /* set this TRUE to prevent us to remember the + current path, as this connection is going */ + connclose(conn, "FTP ended with bad error code"); + result = status; /* use the already set error code */ + break; + } + + /* now store a copy of the directory we are in */ - if(ftpc->prevpath) - free(ftpc->prevpath); ++ free(ftpc->prevpath); + + if(data->set.wildcardmatch) { + if(data->set.chunk_end && ftpc->file) { + data->set.chunk_end(data->wildcard.customptr); + } + ftpc->known_filesize = -1; + } + + /* get the "raw" path */ + path = curl_easy_unescape(data, path_to_use, 0, NULL); + if(!path) { + /* out of memory, but we can limp along anyway (and should try to + * since we may already be in the out of memory cleanup path) */ + if(!result) + result = CURLE_OUT_OF_MEMORY; + ftpc->ctl_valid = FALSE; /* mark control connection as bad */ + connclose(conn, "FTP: out of memory!"); /* mark for connection closure */ + ftpc->prevpath = NULL; /* no path remembering */ + } + else { + size_t flen = ftpc->file?strlen(ftpc->file):0; /* file is "raw" already */ + size_t dlen = strlen(path)-flen; + if(!ftpc->cwdfail) { + if(dlen && (data->set.ftp_filemethod != FTPFILE_NOCWD)) { + ftpc->prevpath = path; + if(flen) + /* if 'path' is not the whole string */ + ftpc->prevpath[dlen]=0; /* terminate */ + } + else { + /* we never changed dir */ + ftpc->prevpath=strdup(""); + free(path); + } + if(ftpc->prevpath) + infof(data, "Remembering we are in dir \"%s\"\n", ftpc->prevpath); + } + else { + ftpc->prevpath = NULL; /* no path */ + free(path); + } + } + /* free the dir tree and file parts */ + freedirs(ftpc); + + /* shut down the socket to inform the server we're done */ + +#ifdef _WIN32_WCE - shutdown(conn->sock[SECONDARYSOCKET],2); /* SD_BOTH */ ++ shutdown(conn->sock[SECONDARYSOCKET], 2); /* SD_BOTH */ +#endif + + if(conn->sock[SECONDARYSOCKET] != CURL_SOCKET_BAD) { + if(!result && ftpc->dont_check && data->req.maxdownload > 0) { + /* partial download completed */ + result = Curl_pp_sendf(pp, "%s", "ABOR"); + if(result) { + failf(data, "Failure sending ABOR command: %s", + curl_easy_strerror(result)); + ftpc->ctl_valid = FALSE; /* mark control connection as bad */ + connclose(conn, "ABOR command failed"); /* connection closure */ + } + } + + if(conn->ssl[SECONDARYSOCKET].use) { + /* The secondary socket is using SSL so we must close down that part + first before we close the socket for real */ + Curl_ssl_close(conn, SECONDARYSOCKET); + + /* Note that we keep "use" set to TRUE since that (next) connection is + still requested to use SSL */ + } + if(CURL_SOCKET_BAD != conn->sock[SECONDARYSOCKET]) { + Curl_closesocket(conn, conn->sock[SECONDARYSOCKET]); + conn->sock[SECONDARYSOCKET] = CURL_SOCKET_BAD; + conn->bits.tcpconnect[SECONDARYSOCKET] = FALSE; + } + } + + if(!result && (ftp->transfer == FTPTRANSFER_BODY) && ftpc->ctl_valid && + pp->pending_resp && !premature) { + /* + * Let's see what the server says about the transfer we just performed, + * but lower the timeout as sometimes this connection has died while the + * data has been transferred. This happens when doing through NATs etc that + * abandon old silent connections. + */ + long old_time = pp->response_time; + + pp->response_time = 60*1000; /* give it only a minute for now */ + pp->response = Curl_tvnow(); /* timeout relative now */ + + result = Curl_GetFTPResponse(&nread, conn, &ftpcode); + + pp->response_time = old_time; /* set this back to previous value */ + + if(!nread && (CURLE_OPERATION_TIMEDOUT == result)) { + failf(data, "control connection looks dead"); + ftpc->ctl_valid = FALSE; /* mark control connection as bad */ + connclose(conn, "Timeout or similar in FTP DONE operation"); /* close */ + } + + if(result) + return result; + + if(ftpc->dont_check && data->req.maxdownload > 0) { + /* we have just sent ABOR and there is no reliable way to check if it was + * successful or not; we have to close the connection now */ + infof(data, "partial download completed, closing connection\n"); + connclose(conn, "Partial download with no ability to check"); + return result; + } + + if(!ftpc->dont_check) { + /* 226 Transfer complete, 250 Requested file action okay, completed. */ + if((ftpcode != 226) && (ftpcode != 250)) { + failf(data, "server did not report OK, got %d", ftpcode); + result = CURLE_PARTIAL_FILE; + } + } + } + + if(result || premature) + /* the response code from the transfer showed an error already so no + use checking further */ + ; + else if(data->set.upload) { + if((-1 != data->state.infilesize) && + (data->state.infilesize != *ftp->bytecountp) && + !data->set.crlf && + (ftp->transfer == FTPTRANSFER_BODY)) { + failf(data, "Uploaded unaligned file size (%" CURL_FORMAT_CURL_OFF_T + " out of %" CURL_FORMAT_CURL_OFF_T " bytes)", + *ftp->bytecountp, data->state.infilesize); + result = CURLE_PARTIAL_FILE; + } + } + else { + if((-1 != data->req.size) && + (data->req.size != *ftp->bytecountp) && +#ifdef CURL_DO_LINEEND_CONV + /* Most FTP servers don't adjust their file SIZE response for CRLFs, so + * we'll check to see if the discrepancy can be explained by the number + * of CRLFs we've changed to LFs. + */ + ((data->req.size + data->state.crlf_conversions) != + *ftp->bytecountp) && +#endif /* CURL_DO_LINEEND_CONV */ + (data->req.maxdownload != *ftp->bytecountp)) { + failf(data, "Received only partial file: %" CURL_FORMAT_CURL_OFF_T + " bytes", *ftp->bytecountp); + result = CURLE_PARTIAL_FILE; + } + else if(!ftpc->dont_check && + !*ftp->bytecountp && + (data->req.size>0)) { + failf(data, "No data was received!"); + result = CURLE_FTP_COULDNT_RETR_FILE; + } + } + + /* clear these for next connection */ + ftp->transfer = FTPTRANSFER_BODY; + ftpc->dont_check = FALSE; + + /* Send any post-transfer QUOTE strings? */ + if(!status && !result && !premature && data->set.postquote) + result = ftp_sendquote(conn, data->set.postquote); + + return result; +} + +/*********************************************************************** + * + * ftp_sendquote() + * + * Where a 'quote' means a list of custom commands to send to the server. + * The quote list is passed as an argument. + * + * BLOCKING + */ + +static +CURLcode ftp_sendquote(struct connectdata *conn, struct curl_slist *quote) +{ + struct curl_slist *item; + ssize_t nread; + int ftpcode; + CURLcode result; + struct ftp_conn *ftpc = &conn->proto.ftpc; + struct pingpong *pp = &ftpc->pp; + + item = quote; + while(item) { + if(item->data) { + char *cmd = item->data; + bool acceptfail = FALSE; + + /* if a command starts with an asterisk, which a legal FTP command never + can, the command will be allowed to fail without it causing any + aborts or cancels etc. It will cause libcurl to act as if the command + is successful, whatever the server reponds. */ + + if(cmd[0] == '*') { + cmd++; + acceptfail = TRUE; + } + + PPSENDF(&conn->proto.ftpc.pp, "%s", cmd); + + pp->response = Curl_tvnow(); /* timeout relative now */ + + result = Curl_GetFTPResponse(&nread, conn, &ftpcode); + if(result) + return result; + + if(!acceptfail && (ftpcode >= 400)) { + failf(conn->data, "QUOT string not accepted: %s", cmd); + return CURLE_QUOTE_ERROR; + } + } + + item = item->next; + } + + return CURLE_OK; +} + +/*********************************************************************** + * + * ftp_need_type() + * + * Returns TRUE if we in the current situation should send TYPE + */ +static int ftp_need_type(struct connectdata *conn, + bool ascii_wanted) +{ + return conn->proto.ftpc.transfertype != (ascii_wanted?'A':'I'); +} + +/*********************************************************************** + * + * ftp_nb_type() + * + * Set TYPE. We only deal with ASCII or BINARY so this function + * sets one of them. + * If the transfer type is not sent, simulate on OK response in newstate + */ +static CURLcode ftp_nb_type(struct connectdata *conn, + bool ascii, ftpstate newstate) +{ + struct ftp_conn *ftpc = &conn->proto.ftpc; + CURLcode result; + char want = (char)(ascii?'A':'I'); + + if(ftpc->transfertype == want) { + state(conn, newstate); + return ftp_state_type_resp(conn, 200, newstate); + } + + PPSENDF(&ftpc->pp, "TYPE %c", want); + state(conn, newstate); + + /* keep track of our current transfer type */ + ftpc->transfertype = want; + return CURLE_OK; +} + +/*************************************************************************** + * + * ftp_pasv_verbose() + * + * This function only outputs some informationals about this second connection + * when we've issued a PASV command before and thus we have connected to a + * possibly new IP address. + * + */ +#ifndef CURL_DISABLE_VERBOSE_STRINGS +static void +ftp_pasv_verbose(struct connectdata *conn, + Curl_addrinfo *ai, + char *newhost, /* ascii version */ + int port) +{ + char buf[256]; + Curl_printable_address(ai, buf, sizeof(buf)); + infof(conn->data, "Connecting to %s (%s) port %d\n", newhost, buf, port); +} +#endif + +/* + Check if this is a range download, and if so, set the internal variables + properly. + */ + +static CURLcode ftp_range(struct connectdata *conn) +{ + curl_off_t from, to; + char *ptr; + char *ptr2; + struct SessionHandle *data = conn->data; + struct ftp_conn *ftpc = &conn->proto.ftpc; + + if(data->state.use_range && data->state.range) { + from=curlx_strtoofft(data->state.range, &ptr, 0); + while(*ptr && (ISSPACE(*ptr) || (*ptr=='-'))) + ptr++; + to=curlx_strtoofft(ptr, &ptr2, 0); + if(ptr == ptr2) { + /* we didn't get any digit */ + to=-1; + } + if((-1 == to) && (from>=0)) { + /* X - */ + data->state.resume_from = from; + DEBUGF(infof(conn->data, "FTP RANGE %" CURL_FORMAT_CURL_OFF_T + " to end of file\n", from)); + } + else if(from < 0) { + /* -Y */ + data->req.maxdownload = -from; + data->state.resume_from = from; + DEBUGF(infof(conn->data, "FTP RANGE the last %" CURL_FORMAT_CURL_OFF_T + " bytes\n", -from)); + } + else { + /* X-Y */ + data->req.maxdownload = (to-from)+1; /* include last byte */ + data->state.resume_from = from; + DEBUGF(infof(conn->data, "FTP RANGE from %" CURL_FORMAT_CURL_OFF_T + " getting %" CURL_FORMAT_CURL_OFF_T " bytes\n", + from, data->req.maxdownload)); + } + DEBUGF(infof(conn->data, "range-download from %" CURL_FORMAT_CURL_OFF_T + " to %" CURL_FORMAT_CURL_OFF_T ", totally %" + CURL_FORMAT_CURL_OFF_T " bytes\n", + from, to, data->req.maxdownload)); + ftpc->dont_check = TRUE; /* dont check for successful transfer */ + } + else + data->req.maxdownload = -1; + return CURLE_OK; +} + + +/* + * ftp_do_more() + * + * This function shall be called when the second FTP (data) connection is + * connected. + * + * 'complete' can return 0 for incomplete, 1 for done and -1 for go back + * (which basically is only for when PASV is being sent to retry a failed + * EPSV). + */ + +static CURLcode ftp_do_more(struct connectdata *conn, int *completep) +{ + struct SessionHandle *data=conn->data; + struct ftp_conn *ftpc = &conn->proto.ftpc; + CURLcode result = CURLE_OK; + bool connected = FALSE; + bool complete = FALSE; + + /* the ftp struct is inited in ftp_connect() */ + struct FTP *ftp = data->req.protop; + + /* if the second connection isn't done yet, wait for it */ + if(!conn->bits.tcpconnect[SECONDARYSOCKET]) { + if(conn->tunnel_state[SECONDARYSOCKET] == TUNNEL_CONNECT) { + /* As we're in TUNNEL_CONNECT state now, we know the proxy name and port + aren't used so we blank their arguments. TODO: make this nicer */ - result = Curl_proxyCONNECT(conn, SECONDARYSOCKET, NULL, 0); ++ result = Curl_proxyCONNECT(conn, SECONDARYSOCKET, NULL, 0, FALSE); + + return result; + } + + result = Curl_is_connected(conn, SECONDARYSOCKET, &connected); + + /* Ready to do more? */ + if(connected) { + DEBUGF(infof(data, "DO-MORE connected phase starts\n")); + if(conn->bits.proxy) { + infof(data, "Connection to proxy confirmed\n"); + result = proxy_magic(conn, ftpc->newhost, ftpc->newport, &connected); + } + } + else { + if(result && (ftpc->count1 == 0)) { + *completep = -1; /* go back to DOING please */ + /* this is a EPSV connect failing, try PASV instead */ + return ftp_epsv_disable(conn); + } + return result; + } + } + + if(ftpc->state) { + /* already in a state so skip the intial commands. + They are only done to kickstart the do_more state */ + result = ftp_multi_statemach(conn, &complete); + + *completep = (int)complete; + + /* if we got an error or if we don't wait for a data connection return + immediately */ + if(result || (ftpc->wait_data_conn != TRUE)) + return result; + + if(ftpc->wait_data_conn) + /* if we reach the end of the FTP state machine here, *complete will be + TRUE but so is ftpc->wait_data_conn, which says we need to wait for + the data connection and therefore we're not actually complete */ + *completep = 0; + } + + if(ftp->transfer <= FTPTRANSFER_INFO) { + /* a transfer is about to take place, or if not a file name was given + so we'll do a SIZE on it later and then we need the right TYPE first */ + + if(ftpc->wait_data_conn == TRUE) { + bool serv_conned; + + result = ReceivedServerConnect(conn, &serv_conned); + if(result) + return result; /* Failed to accept data connection */ + + if(serv_conned) { + /* It looks data connection is established */ + result = AcceptServerConnect(conn); + ftpc->wait_data_conn = FALSE; + if(!result) + result = InitiateTransfer(conn); + + if(result) + return result; + + *completep = 1; /* this state is now complete when the server has + connected back to us */ + } + } + else if(data->set.upload) { + result = ftp_nb_type(conn, data->set.prefer_ascii, FTP_STOR_TYPE); + if(result) + return result; + + result = ftp_multi_statemach(conn, &complete); + *completep = (int)complete; + } + else { + /* download */ + ftp->downloadsize = -1; /* unknown as of yet */ + + result = ftp_range(conn); + if(result) + ; + else if(data->set.ftp_list_only || !ftpc->file) { + /* The specified path ends with a slash, and therefore we think this + is a directory that is requested, use LIST. But before that we + need to set ASCII transfer mode. */ + + /* But only if a body transfer was requested. */ + if(ftp->transfer == FTPTRANSFER_BODY) { + result = ftp_nb_type(conn, TRUE, FTP_LIST_TYPE); + if(result) + return result; + } + /* otherwise just fall through */ + } + else { + result = ftp_nb_type(conn, data->set.prefer_ascii, FTP_RETR_TYPE); + if(result) + return result; + } + + result = ftp_multi_statemach(conn, &complete); + *completep = (int)complete; + } + return result; + } + - if((result == CURLE_OK) && (ftp->transfer != FTPTRANSFER_BODY)) ++ if(!result && (ftp->transfer != FTPTRANSFER_BODY)) + /* no data to transfer. FIX: it feels like a kludge to have this here + too! */ + Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL); + + if(!ftpc->wait_data_conn) { + /* no waiting for the data connection so this is now complete */ + *completep = 1; + DEBUGF(infof(data, "DO-MORE phase ends with %d\n", (int)result)); + } + + return result; +} + + + +/*********************************************************************** + * + * ftp_perform() + * + * This is the actual DO function for FTP. Get a file/directory according to + * the options previously setup. + */ + +static +CURLcode ftp_perform(struct connectdata *conn, + bool *connected, /* connect status after PASV / PORT */ + bool *dophase_done) +{ + /* this is FTP and no proxy */ + CURLcode result=CURLE_OK; + + DEBUGF(infof(conn->data, "DO phase starts\n")); + + if(conn->data->set.opt_no_body) { + /* requested no body means no transfer... */ + struct FTP *ftp = conn->data->req.protop; + ftp->transfer = FTPTRANSFER_INFO; + } + + *dophase_done = FALSE; /* not done yet */ + + /* start the first command in the DO phase */ + result = ftp_state_quote(conn, TRUE, FTP_QUOTE); + if(result) + return result; + + /* run the state-machine */ + result = ftp_multi_statemach(conn, dophase_done); + + *connected = conn->bits.tcpconnect[SECONDARYSOCKET]; + + infof(conn->data, "ftp_perform ends with SECONDARY: %d\n", *connected); + + if(*dophase_done) { + DEBUGF(infof(conn->data, "DO phase is complete1\n")); + } + + return result; +} + +static void wc_data_dtor(void *ptr) +{ + struct ftp_wc_tmpdata *tmp = ptr; + if(tmp) + Curl_ftp_parselist_data_free(&tmp->parser); - Curl_safefree(tmp); ++ free(tmp); +} + +static CURLcode init_wc_data(struct connectdata *conn) +{ + char *last_slash; + char *path = conn->data->state.path; + struct WildcardData *wildcard = &(conn->data->wildcard); - CURLcode ret = CURLE_OK; ++ CURLcode result = CURLE_OK; + struct ftp_wc_tmpdata *ftp_tmp; + + last_slash = strrchr(conn->data->state.path, '/'); + if(last_slash) { + last_slash++; + if(last_slash[0] == '\0') { + wildcard->state = CURLWC_CLEAN; - ret = ftp_parse_url_path(conn); - return ret; ++ result = ftp_parse_url_path(conn); ++ return result; + } + else { + wildcard->pattern = strdup(last_slash); + if(!wildcard->pattern) + return CURLE_OUT_OF_MEMORY; + last_slash[0] = '\0'; /* cut file from path */ + } + } + else { /* there is only 'wildcard pattern' or nothing */ + if(path[0]) { + wildcard->pattern = strdup(path); + if(!wildcard->pattern) + return CURLE_OUT_OF_MEMORY; + path[0] = '\0'; + } + else { /* only list */ + wildcard->state = CURLWC_CLEAN; - ret = ftp_parse_url_path(conn); - return ret; ++ result = ftp_parse_url_path(conn); ++ return result; + } + } + + /* program continues only if URL is not ending with slash, allocate needed + resources for wildcard transfer */ + + /* allocate ftp protocol specific temporary wildcard data */ + ftp_tmp = calloc(1, sizeof(struct ftp_wc_tmpdata)); + if(!ftp_tmp) { + Curl_safefree(wildcard->pattern); + return CURLE_OUT_OF_MEMORY; + } + + /* INITIALIZE parselist structure */ + ftp_tmp->parser = Curl_ftp_parselist_data_alloc(); + if(!ftp_tmp->parser) { + Curl_safefree(wildcard->pattern); - Curl_safefree(ftp_tmp); ++ free(ftp_tmp); + return CURLE_OUT_OF_MEMORY; + } + + wildcard->tmp = ftp_tmp; /* put it to the WildcardData tmp pointer */ + wildcard->tmp_dtor = wc_data_dtor; + + /* wildcard does not support NOCWD option (assert it?) */ + if(conn->data->set.ftp_filemethod == FTPFILE_NOCWD) + conn->data->set.ftp_filemethod = FTPFILE_MULTICWD; + + /* try to parse ftp url */ - ret = ftp_parse_url_path(conn); - if(ret) { ++ result = ftp_parse_url_path(conn); ++ if(result) { + Curl_safefree(wildcard->pattern); + wildcard->tmp_dtor(wildcard->tmp); + wildcard->tmp_dtor = ZERO_NULL; + wildcard->tmp = NULL; - return ret; ++ return result; + } + + wildcard->path = strdup(conn->data->state.path); + if(!wildcard->path) { + Curl_safefree(wildcard->pattern); + wildcard->tmp_dtor(wildcard->tmp); + wildcard->tmp_dtor = ZERO_NULL; + wildcard->tmp = NULL; + return CURLE_OUT_OF_MEMORY; + } + + /* backup old write_function */ + ftp_tmp->backup.write_function = conn->data->set.fwrite_func; + /* parsing write function */ + conn->data->set.fwrite_func = Curl_ftp_parselist; + /* backup old file descriptor */ + ftp_tmp->backup.file_descriptor = conn->data->set.out; + /* let the writefunc callback know what curl pointer is working with */ + conn->data->set.out = conn; + + infof(conn->data, "Wildcard - Parsing started\n"); + return CURLE_OK; +} + +/* This is called recursively */ +static CURLcode wc_statemach(struct connectdata *conn) +{ + struct WildcardData * const wildcard = &(conn->data->wildcard); - CURLcode ret = CURLE_OK; ++ CURLcode result = CURLE_OK; + + switch (wildcard->state) { + case CURLWC_INIT: - ret = init_wc_data(conn); ++ result = init_wc_data(conn); + if(wildcard->state == CURLWC_CLEAN) + /* only listing! */ + break; + else - wildcard->state = ret ? CURLWC_ERROR : CURLWC_MATCHING; ++ wildcard->state = result ? CURLWC_ERROR : CURLWC_MATCHING; + break; + + case CURLWC_MATCHING: { + /* In this state is LIST response successfully parsed, so lets restore + previous WRITEFUNCTION callback and WRITEDATA pointer */ + struct ftp_wc_tmpdata *ftp_tmp = wildcard->tmp; + conn->data->set.fwrite_func = ftp_tmp->backup.write_function; + conn->data->set.out = ftp_tmp->backup.file_descriptor; + ftp_tmp->backup.write_function = ZERO_NULL; + ftp_tmp->backup.file_descriptor = NULL; + wildcard->state = CURLWC_DOWNLOADING; + + if(Curl_ftp_parselist_geterror(ftp_tmp->parser)) { + /* error found in LIST parsing */ + wildcard->state = CURLWC_CLEAN; + return wc_statemach(conn); + } + else if(wildcard->filelist->size == 0) { + /* no corresponding file */ + wildcard->state = CURLWC_CLEAN; + return CURLE_REMOTE_FILE_NOT_FOUND; + } + return wc_statemach(conn); + } + + case CURLWC_DOWNLOADING: { + /* filelist has at least one file, lets get first one */ + struct ftp_conn *ftpc = &conn->proto.ftpc; + struct curl_fileinfo *finfo = wildcard->filelist->head->ptr; + + char *tmp_path = aprintf("%s%s", wildcard->path, finfo->filename); + if(!tmp_path) + return CURLE_OUT_OF_MEMORY; + + /* switch default "state.pathbuffer" and tmp_path, good to see + ftp_parse_url_path function to understand this trick */ + Curl_safefree(conn->data->state.pathbuffer); + conn->data->state.pathbuffer = tmp_path; + conn->data->state.path = tmp_path; + + infof(conn->data, "Wildcard - START of \"%s\"\n", finfo->filename); + if(conn->data->set.chunk_bgn) { + long userresponse = conn->data->set.chunk_bgn( + finfo, wildcard->customptr, (int)wildcard->filelist->size); + switch(userresponse) { + case CURL_CHUNK_BGN_FUNC_SKIP: + infof(conn->data, "Wildcard - \"%s\" skipped by user\n", + finfo->filename); + wildcard->state = CURLWC_SKIP; + return wc_statemach(conn); + case CURL_CHUNK_BGN_FUNC_FAIL: + return CURLE_CHUNK_FAILED; + } + } + + if(finfo->filetype != CURLFILETYPE_FILE) { + wildcard->state = CURLWC_SKIP; + return wc_statemach(conn); + } + + if(finfo->flags & CURLFINFOFLAG_KNOWN_SIZE) + ftpc->known_filesize = finfo->size; + - ret = ftp_parse_url_path(conn); - if(ret) { - return ret; - } ++ result = ftp_parse_url_path(conn); ++ if(result) ++ return result; + + /* we don't need the Curl_fileinfo of first file anymore */ + Curl_llist_remove(wildcard->filelist, wildcard->filelist->head, NULL); + + if(wildcard->filelist->size == 0) { /* remains only one file to down. */ + wildcard->state = CURLWC_CLEAN; + /* after that will be ftp_do called once again and no transfer + will be done because of CURLWC_CLEAN state */ + return CURLE_OK; + } + } break; + + case CURLWC_SKIP: { + if(conn->data->set.chunk_end) + conn->data->set.chunk_end(conn->data->wildcard.customptr); + Curl_llist_remove(wildcard->filelist, wildcard->filelist->head, NULL); + wildcard->state = (wildcard->filelist->size == 0) ? + CURLWC_CLEAN : CURLWC_DOWNLOADING; + return wc_statemach(conn); + } + + case CURLWC_CLEAN: { + struct ftp_wc_tmpdata *ftp_tmp = wildcard->tmp; - ret = CURLE_OK; - if(ftp_tmp) { - ret = Curl_ftp_parselist_geterror(ftp_tmp->parser); - } - wildcard->state = ret ? CURLWC_ERROR : CURLWC_DONE; ++ result = CURLE_OK; ++ if(ftp_tmp) ++ result = Curl_ftp_parselist_geterror(ftp_tmp->parser); ++ ++ wildcard->state = result ? CURLWC_ERROR : CURLWC_DONE; + } break; + + case CURLWC_DONE: + case CURLWC_ERROR: + break; + } + - return ret; ++ return result; +} + +/*********************************************************************** + * + * ftp_do() + * + * This function is registered as 'curl_do' function. It decodes the path + * parts etc as a wrapper to the actual DO function (ftp_perform). + * + * The input argument is already checked for validity. + */ +static CURLcode ftp_do(struct connectdata *conn, bool *done) +{ - CURLcode retcode = CURLE_OK; ++ CURLcode result = CURLE_OK; + struct ftp_conn *ftpc = &conn->proto.ftpc; + + *done = FALSE; /* default to false */ + ftpc->wait_data_conn = FALSE; /* default to no such wait */ + + if(conn->data->set.wildcardmatch) { - retcode = wc_statemach(conn); ++ result = wc_statemach(conn); + if(conn->data->wildcard.state == CURLWC_SKIP || + conn->data->wildcard.state == CURLWC_DONE) { + /* do not call ftp_regular_transfer */ + return CURLE_OK; + } - if(retcode) /* error, loop or skipping the file */ - return retcode; ++ if(result) /* error, loop or skipping the file */ ++ return result; + } + else { /* no wildcard FSM needed */ - retcode = ftp_parse_url_path(conn); - if(retcode) - return retcode; ++ result = ftp_parse_url_path(conn); ++ if(result) ++ return result; + } + - retcode = ftp_regular_transfer(conn, done); ++ result = ftp_regular_transfer(conn, done); + - return retcode; ++ return result; +} + + +CURLcode Curl_ftpsendf(struct connectdata *conn, + const char *fmt, ...) +{ + ssize_t bytes_written; +#define SBUF_SIZE 1024 + char s[SBUF_SIZE]; + size_t write_len; + char *sptr=s; - CURLcode res = CURLE_OK; ++ CURLcode result = CURLE_OK; +#ifdef HAVE_GSSAPI + enum protection_level data_sec = conn->data_prot; +#endif + + va_list ap; + va_start(ap, fmt); + write_len = vsnprintf(s, SBUF_SIZE-3, fmt, ap); + va_end(ap); + + strcpy(&s[write_len], "\r\n"); /* append a trailing CRLF */ + write_len +=2; + + bytes_written=0; + - res = Curl_convert_to_network(conn->data, s, write_len); ++ result = Curl_convert_to_network(conn->data, s, write_len); + /* Curl_convert_to_network calls failf if unsuccessful */ - if(res) - return(res); ++ if(result) ++ return result; + + for(;;) { +#ifdef HAVE_GSSAPI + conn->data_prot = PROT_CMD; +#endif - res = Curl_write(conn, conn->sock[FIRSTSOCKET], sptr, write_len, - &bytes_written); ++ result = Curl_write(conn, conn->sock[FIRSTSOCKET], sptr, write_len, ++ &bytes_written); +#ifdef HAVE_GSSAPI + DEBUGASSERT(data_sec > PROT_NONE && data_sec < PROT_LAST); + conn->data_prot = data_sec; +#endif + - if(CURLE_OK != res) ++ if(result) + break; + + if(conn->data->set.verbose) + Curl_debug(conn->data, CURLINFO_HEADER_OUT, + sptr, (size_t)bytes_written, conn); + + if(bytes_written != (ssize_t)write_len) { + write_len -= bytes_written; + sptr += bytes_written; + } + else + break; + } + - return res; ++ return result; +} + +/*********************************************************************** + * + * ftp_quit() + * + * This should be called before calling sclose() on an ftp control connection + * (not data connections). We should then wait for the response from the + * server before returning. The calling code should then try to close the + * connection. + * + */ +static CURLcode ftp_quit(struct connectdata *conn) +{ + CURLcode result = CURLE_OK; + + if(conn->proto.ftpc.ctl_valid) { + result = Curl_pp_sendf(&conn->proto.ftpc.pp, "%s", "QUIT"); + if(result) { + failf(conn->data, "Failure sending QUIT command: %s", + curl_easy_strerror(result)); + conn->proto.ftpc.ctl_valid = FALSE; /* mark control connection as bad */ + connclose(conn, "QUIT command failed"); /* mark for connection closure */ + state(conn, FTP_STOP); + return result; + } + + state(conn, FTP_QUIT); + + result = ftp_block_statemach(conn); + } + + return result; +} + +/*********************************************************************** + * + * ftp_disconnect() + * + * Disconnect from an FTP server. Cleanup protocol-specific per-connection + * resources. BLOCKING. + */ +static CURLcode ftp_disconnect(struct connectdata *conn, bool dead_connection) +{ + struct ftp_conn *ftpc= &conn->proto.ftpc; + struct pingpong *pp = &ftpc->pp; + + /* We cannot send quit unconditionally. If this connection is stale or + bad in any way, sending quit and waiting around here will make the + disconnect wait in vain and cause more problems than we need to. + + ftp_quit() will check the state of ftp->ctl_valid. If it's ok it + will try to send the QUIT command, otherwise it will just return. + */ + if(dead_connection) + ftpc->ctl_valid = FALSE; + + /* The FTP session may or may not have been allocated/setup at this point! */ + (void)ftp_quit(conn); /* ignore errors on the QUIT */ + + if(ftpc->entrypath) { + struct SessionHandle *data = conn->data; + if(data->state.most_recent_ftp_entrypath == ftpc->entrypath) { + data->state.most_recent_ftp_entrypath = NULL; + } + free(ftpc->entrypath); + ftpc->entrypath = NULL; + } + + freedirs(ftpc); - if(ftpc->prevpath) { - free(ftpc->prevpath); - ftpc->prevpath = NULL; - } - if(ftpc->server_os) { - free(ftpc->server_os); - ftpc->server_os = NULL; - } ++ free(ftpc->prevpath); ++ ftpc->prevpath = NULL; ++ free(ftpc->server_os); ++ ftpc->server_os = NULL; + + Curl_pp_disconnect(pp); + +#ifdef HAVE_GSSAPI + Curl_sec_end(conn); +#endif + + return CURLE_OK; +} + +/*********************************************************************** + * + * ftp_parse_url_path() + * + * Parse the URL path into separate path components. + * + */ +static +CURLcode ftp_parse_url_path(struct connectdata *conn) +{ + struct SessionHandle *data = conn->data; + /* the ftp struct is already inited in ftp_connect() */ + struct FTP *ftp = data->req.protop; + struct ftp_conn *ftpc = &conn->proto.ftpc; + const char *slash_pos; /* position of the first '/' char in curpos */ + const char *path_to_use = data->state.path; + const char *cur_pos; + const char *filename = NULL; + + cur_pos = path_to_use; /* current position in path. point at the begin + of next path component */ + + ftpc->ctl_valid = FALSE; + ftpc->cwdfail = FALSE; + + switch(data->set.ftp_filemethod) { + case FTPFILE_NOCWD: + /* fastest, but less standard-compliant */ + + /* + The best time to check whether the path is a file or directory is right + here. so: + + the first condition in the if() right here, is there just in case + someone decides to set path to NULL one day + */ + if(data->state.path && + data->state.path[0] && + (data->state.path[strlen(data->state.path) - 1] != '/') ) + filename = data->state.path; /* this is a full file path */ + /* + ftpc->file is not used anywhere other than for operations on a file. + In other words, never for directory operations. + So we can safely leave filename as NULL here and use it as a + argument in dir/file decisions. + */ + break; + + case FTPFILE_SINGLECWD: + /* get the last slash */ + if(!path_to_use[0]) { + /* no dir, no file */ + ftpc->dirdepth = 0; + break; + } + slash_pos=strrchr(cur_pos, '/'); + if(slash_pos || !*cur_pos) { + size_t dirlen = slash_pos-cur_pos; + + ftpc->dirs = calloc(1, sizeof(ftpc->dirs[0])); + if(!ftpc->dirs) + return CURLE_OUT_OF_MEMORY; + + if(!dirlen) + dirlen++; + + ftpc->dirs[0] = curl_easy_unescape(conn->data, slash_pos ? cur_pos : "/", + slash_pos ? curlx_uztosi(dirlen) : 1, + NULL); + if(!ftpc->dirs[0]) { + freedirs(ftpc); + return CURLE_OUT_OF_MEMORY; + } + ftpc->dirdepth = 1; /* we consider it to be a single dir */ + filename = slash_pos ? slash_pos+1 : cur_pos; /* rest is file name */ + } + else + filename = cur_pos; /* this is a file name only */ + break; + + default: /* allow pretty much anything */ + case FTPFILE_MULTICWD: + ftpc->dirdepth = 0; + ftpc->diralloc = 5; /* default dir depth to allocate */ + ftpc->dirs = calloc(ftpc->diralloc, sizeof(ftpc->dirs[0])); + if(!ftpc->dirs) + return CURLE_OUT_OF_MEMORY; + + /* we have a special case for listing the root dir only */ + if(strequal(path_to_use, "/")) { + cur_pos++; /* make it point to the zero byte */ + ftpc->dirs[0] = strdup("/"); + ftpc->dirdepth++; + } + else { + /* parse the URL path into separate path components */ + while((slash_pos = strchr(cur_pos, '/')) != NULL) { + /* 1 or 0 pointer offset to indicate absolute directory */ + ssize_t absolute_dir = ((cur_pos - data->state.path > 0) && + (ftpc->dirdepth == 0))?1:0; + + /* seek out the next path component */ + if(slash_pos-cur_pos) { + /* we skip empty path components, like "x//y" since the FTP command + CWD requires a parameter and a non-existent parameter a) doesn't + work on many servers and b) has no effect on the others. */ + int len = curlx_sztosi(slash_pos - cur_pos + absolute_dir); + ftpc->dirs[ftpc->dirdepth] = + curl_easy_unescape(conn->data, cur_pos - absolute_dir, len, NULL); + if(!ftpc->dirs[ftpc->dirdepth]) { /* run out of memory ... */ + failf(data, "no memory"); + freedirs(ftpc); + return CURLE_OUT_OF_MEMORY; + } + if(isBadFtpString(ftpc->dirs[ftpc->dirdepth])) { + free(ftpc->dirs[ftpc->dirdepth]); + freedirs(ftpc); + return CURLE_URL_MALFORMAT; + } + } + else { + cur_pos = slash_pos + 1; /* jump to the rest of the string */ + if(!ftpc->dirdepth) { + /* path starts with a slash, add that as a directory */ + ftpc->dirs[ftpc->dirdepth] = strdup("/"); + if(!ftpc->dirs[ftpc->dirdepth++]) { /* run out of memory ... */ + failf(data, "no memory"); + freedirs(ftpc); + return CURLE_OUT_OF_MEMORY; + } + } + continue; + } + + cur_pos = slash_pos + 1; /* jump to the rest of the string */ + if(++ftpc->dirdepth >= ftpc->diralloc) { + /* enlarge array */ + char **bigger; + ftpc->diralloc *= 2; /* double the size each time */ + bigger = realloc(ftpc->dirs, ftpc->diralloc * sizeof(ftpc->dirs[0])); + if(!bigger) { + freedirs(ftpc); + return CURLE_OUT_OF_MEMORY; + } + ftpc->dirs = bigger; + } + } + } + filename = cur_pos; /* the rest is the file name */ + break; + } /* switch */ + + if(filename && *filename) { + ftpc->file = curl_easy_unescape(conn->data, filename, 0, NULL); + if(NULL == ftpc->file) { + freedirs(ftpc); + failf(data, "no memory"); + return CURLE_OUT_OF_MEMORY; + } + if(isBadFtpString(ftpc->file)) { + freedirs(ftpc); + return CURLE_URL_MALFORMAT; + } + } + else + ftpc->file=NULL; /* instead of point to a zero byte, we make it a NULL + pointer */ + + if(data->set.upload && !ftpc->file && (ftp->transfer == FTPTRANSFER_BODY)) { + /* We need a file name when uploading. Return error! */ + failf(data, "Uploading to a URL without a file name!"); + return CURLE_URL_MALFORMAT; + } + + ftpc->cwddone = FALSE; /* default to not done */ + + if(ftpc->prevpath) { + /* prevpath is "raw" so we convert the input path before we compare the + strings */ + int dlen; + char *path = curl_easy_unescape(conn->data, data->state.path, 0, &dlen); + if(!path) { + freedirs(ftpc); + return CURLE_OUT_OF_MEMORY; + } + + dlen -= ftpc->file?curlx_uztosi(strlen(ftpc->file)):0; + if((dlen == curlx_uztosi(strlen(ftpc->prevpath))) && + strnequal(path, ftpc->prevpath, dlen)) { + infof(data, "Request has same path as previous transfer\n"); + ftpc->cwddone = TRUE; + } + free(path); + } + + return CURLE_OK; +} + +/* call this when the DO phase has completed */ +static CURLcode ftp_dophase_done(struct connectdata *conn, + bool connected) +{ + struct FTP *ftp = conn->data->req.protop; + struct ftp_conn *ftpc = &conn->proto.ftpc; + + if(connected) { + int completed; + CURLcode result = ftp_do_more(conn, &completed); + + if(result) { + if(conn->sock[SECONDARYSOCKET] != CURL_SOCKET_BAD) { + /* close the second socket if it was created already */ + Curl_closesocket(conn, conn->sock[SECONDARYSOCKET]); + conn->sock[SECONDARYSOCKET] = CURL_SOCKET_BAD; + } + return result; + } + } + + if(ftp->transfer != FTPTRANSFER_BODY) + /* no data to transfer */ + Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL); + else if(!connected) + /* since we didn't connect now, we want do_more to get called */ + conn->bits.do_more = TRUE; + + ftpc->ctl_valid = TRUE; /* seems good */ + + return CURLE_OK; +} + +/* called from multi.c while DOing */ +static CURLcode ftp_doing(struct connectdata *conn, + bool *dophase_done) +{ + CURLcode result = ftp_multi_statemach(conn, dophase_done); + + if(result) + DEBUGF(infof(conn->data, "DO phase failed\n")); + else if(*dophase_done) { + result = ftp_dophase_done(conn, FALSE /* not connected */); + + DEBUGF(infof(conn->data, "DO phase is complete2\n")); + } + return result; +} + +/*********************************************************************** + * + * ftp_regular_transfer() + * + * The input argument is already checked for validity. + * + * Performs all commands done before a regular transfer between a local and a + * remote host. + * + * ftp->ctl_valid starts out as FALSE, and gets set to TRUE if we reach the + * ftp_done() function without finding any major problem. + */ +static +CURLcode ftp_regular_transfer(struct connectdata *conn, + bool *dophase_done) +{ + CURLcode result=CURLE_OK; + bool connected=FALSE; + struct SessionHandle *data = conn->data; + struct ftp_conn *ftpc = &conn->proto.ftpc; + data->req.size = -1; /* make sure this is unknown at this point */ + + Curl_pgrsSetUploadCounter(data, 0); + Curl_pgrsSetDownloadCounter(data, 0); + Curl_pgrsSetUploadSize(data, -1); + Curl_pgrsSetDownloadSize(data, -1); + + ftpc->ctl_valid = TRUE; /* starts good */ + + result = ftp_perform(conn, + &connected, /* have we connected after PASV/PORT */ + dophase_done); /* all commands in the DO-phase done? */ + - if(CURLE_OK == result) { ++ if(!result) { + + if(!*dophase_done) + /* the DO phase has not completed yet */ + return CURLE_OK; + + result = ftp_dophase_done(conn, connected); + + if(result) + return result; + } + else + freedirs(ftpc); + + return result; +} + +static CURLcode ftp_setup_connection(struct connectdata *conn) +{ + struct SessionHandle *data = conn->data; + char *type; + char command; + struct FTP *ftp; + + if(conn->bits.httpproxy && !data->set.tunnel_thru_httpproxy) { + /* Unless we have asked to tunnel ftp operations through the proxy, we + switch and use HTTP operations only */ +#ifndef CURL_DISABLE_HTTP + if(conn->handler == &Curl_handler_ftp) + conn->handler = &Curl_handler_ftp_proxy; + else { +#ifdef USE_SSL + conn->handler = &Curl_handler_ftps_proxy; +#else + failf(data, "FTPS not supported!"); + return CURLE_UNSUPPORTED_PROTOCOL; +#endif + } + /* set it up as a HTTP connection instead */ + return conn->handler->setup_connection(conn); +#else + failf(data, "FTP over http proxy requires HTTP support built-in!"); + return CURLE_UNSUPPORTED_PROTOCOL; +#endif + } + + conn->data->req.protop = ftp = malloc(sizeof(struct FTP)); + if(NULL == ftp) + return CURLE_OUT_OF_MEMORY; + + data->state.path++; /* don't include the initial slash */ + data->state.slash_removed = TRUE; /* we've skipped the slash */ + + /* FTP URLs support an extension like ";type=" that + * we'll try to get now! */ + type = strstr(data->state.path, ";type="); + + if(!type) + type = strstr(conn->host.rawalloc, ";type="); + + if(type) { + *type = 0; /* it was in the middle of the hostname */ + command = Curl_raw_toupper(type[6]); + conn->bits.type_set = TRUE; + + switch (command) { + case 'A': /* ASCII mode */ + data->set.prefer_ascii = TRUE; + break; + + case 'D': /* directory mode */ + data->set.ftp_list_only = TRUE; + break; + + case 'I': /* binary mode */ + default: + /* switch off ASCII */ + data->set.prefer_ascii = FALSE; + break; + } + } + + /* get some initial data into the ftp struct */ + ftp->bytecountp = &conn->data->req.bytecount; + ftp->transfer = FTPTRANSFER_BODY; + ftp->downloadsize = 0; + + /* No need to duplicate user+password, the connectdata struct won't change + during a session, but we re-init them here since on subsequent inits + since the conn struct may have changed or been replaced. + */ + ftp->user = conn->user; + ftp->passwd = conn->passwd; + if(isBadFtpString(ftp->user)) + return CURLE_URL_MALFORMAT; + if(isBadFtpString(ftp->passwd)) + return CURLE_URL_MALFORMAT; + + conn->proto.ftpc.known_filesize = -1; /* unknown size for now */ + + return CURLE_OK; +} + +#endif /* CURL_DISABLE_FTP */ diff --cc Utilities/cmcurl/lib/select.c index 03c93f3,0000000..6eff070 mode 100644,000000..100644 --- a/Utilities/cmcurl/lib/select.c +++ b/Utilities/cmcurl/lib/select.c @@@ -1,574 -1,0 +1,578 @@@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. ++ * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ + +#include "curl_setup.h" + +#ifdef HAVE_SYS_SELECT_H +#include +#endif + +#if !defined(HAVE_SELECT) && !defined(HAVE_POLL_FINE) +#error "We can't compile without select() or poll() support." +#endif + +#if defined(__BEOS__) +/* BeOS has FD_SET defined in socket.h */ +#include +#endif + +#ifdef MSDOS +#include /* delay() */ +#endif + ++#ifdef __VXWORKS__ ++#include /* bzero() in FD_SET */ ++#endif ++ +#include + +#include "urldata.h" +#include "connect.h" +#include "select.h" +#include "warnless.h" + +/* Convenience local macros */ + +#define elapsed_ms (int)curlx_tvdiff(curlx_tvnow(), initial_tv) + +int Curl_ack_eintr = 0; +#define error_not_EINTR (Curl_ack_eintr || error != EINTR) + +/* + * Internal function used for waiting a specific amount of ms + * in Curl_socket_ready() and Curl_poll() when no file descriptor + * is provided to wait on, just being used to delay execution. + * WinSock select() and poll() timeout mechanisms need a valid + * socket descriptor in a not null file descriptor set to work. + * Waiting indefinitely with this function is not allowed, a + * zero or negative timeout value will return immediately. + * Timeout resolution, accuracy, as well as maximum supported + * value is system dependent, neither factor is a citical issue + * for the intended use of this function in the library. + * + * Return values: + * -1 = system call error, invalid timeout value, or interrupted + * 0 = specified timeout has elapsed + */ +int Curl_wait_ms(int timeout_ms) +{ +#if !defined(MSDOS) && !defined(USE_WINSOCK) +#ifndef HAVE_POLL_FINE + struct timeval pending_tv; +#endif + struct timeval initial_tv; + int pending_ms; + int error; +#endif + int r = 0; + + if(!timeout_ms) + return 0; + if(timeout_ms < 0) { + SET_SOCKERRNO(EINVAL); + return -1; + } +#if defined(MSDOS) + delay(timeout_ms); +#elif defined(USE_WINSOCK) + Sleep(timeout_ms); +#else + pending_ms = timeout_ms; + initial_tv = curlx_tvnow(); + do { +#if defined(HAVE_POLL_FINE) + r = poll(NULL, 0, pending_ms); +#else + pending_tv.tv_sec = pending_ms / 1000; + pending_tv.tv_usec = (pending_ms % 1000) * 1000; + r = select(0, NULL, NULL, NULL, &pending_tv); +#endif /* HAVE_POLL_FINE */ + if(r != -1) + break; + error = SOCKERRNO; + if(error && error_not_EINTR) + break; + pending_ms = timeout_ms - elapsed_ms; + if(pending_ms <= 0) { + r = 0; /* Simulate a "call timed out" case */ + break; + } + } while(r == -1); +#endif /* USE_WINSOCK */ + if(r) + r = -1; + return r; +} + +/* + * Wait for read or write events on a set of file descriptors. It uses poll() + * when a fine poll() is available, in order to avoid limits with FD_SETSIZE, + * otherwise select() is used. An error is returned if select() is being used + * and a file descriptor is too large for FD_SETSIZE. + * + * A negative timeout value makes this function wait indefinitely, + * unles no valid file descriptor is given, when this happens the + * negative timeout is ignored and the function times out immediately. + * + * Return values: + * -1 = system call error or fd >= FD_SETSIZE + * 0 = timeout + * [bitmask] = action as described below + * + * CURL_CSELECT_IN - first socket is readable + * CURL_CSELECT_IN2 - second socket is readable + * CURL_CSELECT_OUT - write socket is writable + * CURL_CSELECT_ERR - an error condition occurred + */ +int Curl_socket_check(curl_socket_t readfd0, /* two sockets to read from */ + curl_socket_t readfd1, + curl_socket_t writefd, /* socket to write to */ + long timeout_ms) /* milliseconds to wait */ +{ +#ifdef HAVE_POLL_FINE + struct pollfd pfd[3]; + int num; +#else + struct timeval pending_tv; + struct timeval *ptimeout; + fd_set fds_read; + fd_set fds_write; + fd_set fds_err; + curl_socket_t maxfd; +#endif - struct timeval initial_tv = {0,0}; ++ struct timeval initial_tv = {0, 0}; + int pending_ms = 0; + int error; + int r; + int ret; + + if((readfd0 == CURL_SOCKET_BAD) && (readfd1 == CURL_SOCKET_BAD) && + (writefd == CURL_SOCKET_BAD)) { + /* no sockets, just wait */ + r = Curl_wait_ms((int)timeout_ms); + return r; + } + + /* Avoid initial timestamp, avoid curlx_tvnow() call, when elapsed + time in this function does not need to be measured. This happens + when function is called with a zero timeout or a negative timeout + value indicating a blocking call should be performed. */ + + if(timeout_ms > 0) { + pending_ms = (int)timeout_ms; + initial_tv = curlx_tvnow(); + } + +#ifdef HAVE_POLL_FINE + + num = 0; + if(readfd0 != CURL_SOCKET_BAD) { + pfd[num].fd = readfd0; + pfd[num].events = POLLRDNORM|POLLIN|POLLRDBAND|POLLPRI; + pfd[num].revents = 0; + num++; + } + if(readfd1 != CURL_SOCKET_BAD) { + pfd[num].fd = readfd1; + pfd[num].events = POLLRDNORM|POLLIN|POLLRDBAND|POLLPRI; + pfd[num].revents = 0; + num++; + } + if(writefd != CURL_SOCKET_BAD) { + pfd[num].fd = writefd; + pfd[num].events = POLLWRNORM|POLLOUT; + pfd[num].revents = 0; + num++; + } + + do { + if(timeout_ms < 0) + pending_ms = -1; + else if(!timeout_ms) + pending_ms = 0; + r = poll(pfd, num, pending_ms); + if(r != -1) + break; + error = SOCKERRNO; + if(error && error_not_EINTR) + break; + if(timeout_ms > 0) { + pending_ms = (int)(timeout_ms - elapsed_ms); + if(pending_ms <= 0) { + r = 0; /* Simulate a "call timed out" case */ + break; + } + } + } while(r == -1); + + if(r < 0) + return -1; + if(r == 0) + return 0; + + ret = 0; + num = 0; + if(readfd0 != CURL_SOCKET_BAD) { + if(pfd[num].revents & (POLLRDNORM|POLLIN|POLLERR|POLLHUP)) + ret |= CURL_CSELECT_IN; + if(pfd[num].revents & (POLLRDBAND|POLLPRI|POLLNVAL)) + ret |= CURL_CSELECT_ERR; + num++; + } + if(readfd1 != CURL_SOCKET_BAD) { + if(pfd[num].revents & (POLLRDNORM|POLLIN|POLLERR|POLLHUP)) + ret |= CURL_CSELECT_IN2; + if(pfd[num].revents & (POLLRDBAND|POLLPRI|POLLNVAL)) + ret |= CURL_CSELECT_ERR; + num++; + } + if(writefd != CURL_SOCKET_BAD) { + if(pfd[num].revents & (POLLWRNORM|POLLOUT)) + ret |= CURL_CSELECT_OUT; + if(pfd[num].revents & (POLLERR|POLLHUP|POLLNVAL)) + ret |= CURL_CSELECT_ERR; + } + + return ret; + +#else /* HAVE_POLL_FINE */ + + FD_ZERO(&fds_err); + maxfd = (curl_socket_t)-1; + + FD_ZERO(&fds_read); + if(readfd0 != CURL_SOCKET_BAD) { + VERIFY_SOCK(readfd0); + FD_SET(readfd0, &fds_read); + FD_SET(readfd0, &fds_err); + maxfd = readfd0; + } + if(readfd1 != CURL_SOCKET_BAD) { + VERIFY_SOCK(readfd1); + FD_SET(readfd1, &fds_read); + FD_SET(readfd1, &fds_err); + if(readfd1 > maxfd) + maxfd = readfd1; + } + + FD_ZERO(&fds_write); + if(writefd != CURL_SOCKET_BAD) { + VERIFY_SOCK(writefd); + FD_SET(writefd, &fds_write); + FD_SET(writefd, &fds_err); + if(writefd > maxfd) + maxfd = writefd; + } + + ptimeout = (timeout_ms < 0) ? NULL : &pending_tv; + + do { + if(timeout_ms > 0) { + pending_tv.tv_sec = pending_ms / 1000; + pending_tv.tv_usec = (pending_ms % 1000) * 1000; + } + else if(!timeout_ms) { + pending_tv.tv_sec = 0; + pending_tv.tv_usec = 0; + } + + /* WinSock select() must not be called with an fd_set that contains zero + fd flags, or it will return WSAEINVAL. But, it also can't be called + with no fd_sets at all! From the documentation: + + Any two of the parameters, readfds, writefds, or exceptfds, can be + given as null. At least one must be non-null, and any non-null + descriptor set must contain at least one handle to a socket. + + We know that we have at least one bit set in at least two fd_sets in + this case, but we may have no bits set in either fds_read or fd_write, + so check for that and handle it. Luckily, with WinSock, we can _also_ + ask how many bits are set on an fd_set. + + It is unclear why WinSock doesn't just handle this for us instead of + calling this an error. + + Note also that WinSock ignores the first argument, so we don't worry + about the fact that maxfd is computed incorrectly with WinSock (since + curl_socket_t is unsigned in such cases and thus -1 is the largest + value). + */ + r = select((int)maxfd + 1, +#ifndef USE_WINSOCK + &fds_read, + &fds_write, +#else + fds_read.fd_count ? &fds_read : NULL, + fds_write.fd_count ? &fds_write : NULL, +#endif + &fds_err, ptimeout); + if(r != -1) + break; + error = SOCKERRNO; + if(error && error_not_EINTR) + break; + if(timeout_ms > 0) { + pending_ms = timeout_ms - elapsed_ms; + if(pending_ms <= 0) { + r = 0; /* Simulate a "call timed out" case */ + break; + } + } + } while(r == -1); + + if(r < 0) + return -1; + if(r == 0) + return 0; + + ret = 0; + if(readfd0 != CURL_SOCKET_BAD) { + if(FD_ISSET(readfd0, &fds_read)) + ret |= CURL_CSELECT_IN; + if(FD_ISSET(readfd0, &fds_err)) + ret |= CURL_CSELECT_ERR; + } + if(readfd1 != CURL_SOCKET_BAD) { + if(FD_ISSET(readfd1, &fds_read)) + ret |= CURL_CSELECT_IN2; + if(FD_ISSET(readfd1, &fds_err)) + ret |= CURL_CSELECT_ERR; + } + if(writefd != CURL_SOCKET_BAD) { + if(FD_ISSET(writefd, &fds_write)) + ret |= CURL_CSELECT_OUT; + if(FD_ISSET(writefd, &fds_err)) + ret |= CURL_CSELECT_ERR; + } + + return ret; + +#endif /* HAVE_POLL_FINE */ + +} + +/* + * This is a wrapper around poll(). If poll() does not exist, then + * select() is used instead. An error is returned if select() is + * being used and a file descriptor is too large for FD_SETSIZE. + * A negative timeout value makes this function wait indefinitely, + * unles no valid file descriptor is given, when this happens the + * negative timeout is ignored and the function times out immediately. + * + * Return values: + * -1 = system call error or fd >= FD_SETSIZE + * 0 = timeout + * N = number of structures with non zero revent fields + */ +int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms) +{ +#ifndef HAVE_POLL_FINE + struct timeval pending_tv; + struct timeval *ptimeout; + fd_set fds_read; + fd_set fds_write; + fd_set fds_err; + curl_socket_t maxfd; +#endif - struct timeval initial_tv = {0,0}; ++ struct timeval initial_tv = {0, 0}; + bool fds_none = TRUE; + unsigned int i; + int pending_ms = 0; + int error; + int r; + + if(ufds) { + for(i = 0; i < nfds; i++) { + if(ufds[i].fd != CURL_SOCKET_BAD) { + fds_none = FALSE; + break; + } + } + } + if(fds_none) { + r = Curl_wait_ms(timeout_ms); + return r; + } + + /* Avoid initial timestamp, avoid curlx_tvnow() call, when elapsed + time in this function does not need to be measured. This happens + when function is called with a zero timeout or a negative timeout + value indicating a blocking call should be performed. */ + + if(timeout_ms > 0) { + pending_ms = timeout_ms; + initial_tv = curlx_tvnow(); + } + +#ifdef HAVE_POLL_FINE + + do { + if(timeout_ms < 0) + pending_ms = -1; + else if(!timeout_ms) + pending_ms = 0; + r = poll(ufds, nfds, pending_ms); + if(r != -1) + break; + error = SOCKERRNO; + if(error && error_not_EINTR) + break; + if(timeout_ms > 0) { + pending_ms = timeout_ms - elapsed_ms; + if(pending_ms <= 0) { + r = 0; /* Simulate a "call timed out" case */ + break; + } + } + } while(r == -1); + + if(r < 0) + return -1; + if(r == 0) + return 0; + + for(i = 0; i < nfds; i++) { + if(ufds[i].fd == CURL_SOCKET_BAD) + continue; + if(ufds[i].revents & POLLHUP) + ufds[i].revents |= POLLIN; + if(ufds[i].revents & POLLERR) + ufds[i].revents |= (POLLIN|POLLOUT); + } + +#else /* HAVE_POLL_FINE */ + + FD_ZERO(&fds_read); + FD_ZERO(&fds_write); + FD_ZERO(&fds_err); + maxfd = (curl_socket_t)-1; + + for(i = 0; i < nfds; i++) { + ufds[i].revents = 0; + if(ufds[i].fd == CURL_SOCKET_BAD) + continue; + VERIFY_SOCK(ufds[i].fd); + if(ufds[i].events & (POLLIN|POLLOUT|POLLPRI| + POLLRDNORM|POLLWRNORM|POLLRDBAND)) { + if(ufds[i].fd > maxfd) + maxfd = ufds[i].fd; + if(ufds[i].events & (POLLRDNORM|POLLIN)) + FD_SET(ufds[i].fd, &fds_read); + if(ufds[i].events & (POLLWRNORM|POLLOUT)) + FD_SET(ufds[i].fd, &fds_write); + if(ufds[i].events & (POLLRDBAND|POLLPRI)) + FD_SET(ufds[i].fd, &fds_err); + } + } + +#ifdef USE_WINSOCK + /* WinSock select() can't handle zero events. See the comment about this in + Curl_check_socket(). */ + if(fds_read.fd_count == 0 && fds_write.fd_count == 0 + && fds_err.fd_count == 0) { + r = Curl_wait_ms(timeout_ms); + return r; + } +#endif + + ptimeout = (timeout_ms < 0) ? NULL : &pending_tv; + + do { + if(timeout_ms > 0) { + pending_tv.tv_sec = pending_ms / 1000; + pending_tv.tv_usec = (pending_ms % 1000) * 1000; + } + else if(!timeout_ms) { + pending_tv.tv_sec = 0; + pending_tv.tv_usec = 0; + } + r = select((int)maxfd + 1, +#ifndef USE_WINSOCK + &fds_read, &fds_write, &fds_err, +#else + /* WinSock select() can't handle fd_sets with zero bits set, so + don't give it such arguments. See the comment about this in + Curl_check_socket(). + */ + fds_read.fd_count ? &fds_read : NULL, + fds_write.fd_count ? &fds_write : NULL, + fds_err.fd_count ? &fds_err : NULL, +#endif + ptimeout); + if(r != -1) + break; + error = SOCKERRNO; + if(error && error_not_EINTR) + break; + if(timeout_ms > 0) { + pending_ms = timeout_ms - elapsed_ms; + if(pending_ms <= 0) { + r = 0; /* Simulate a "call timed out" case */ + break; + } + } + } while(r == -1); + + if(r < 0) + return -1; + if(r == 0) + return 0; + + r = 0; + for(i = 0; i < nfds; i++) { + ufds[i].revents = 0; + if(ufds[i].fd == CURL_SOCKET_BAD) + continue; + if(FD_ISSET(ufds[i].fd, &fds_read)) + ufds[i].revents |= POLLIN; + if(FD_ISSET(ufds[i].fd, &fds_write)) + ufds[i].revents |= POLLOUT; + if(FD_ISSET(ufds[i].fd, &fds_err)) + ufds[i].revents |= POLLPRI; + if(ufds[i].revents != 0) + r++; + } + +#endif /* HAVE_POLL_FINE */ + + return r; +} + +#ifdef TPF +/* + * This is a replacement for select() on the TPF platform. + * It is used whenever libcurl calls select(). + * The call below to tpf_process_signals() is required because + * TPF's select calls are not signal interruptible. + * + * Return values are the same as select's. + */ +int tpf_select_libcurl(int maxfds, fd_set* reads, fd_set* writes, + fd_set* excepts, struct timeval* tv) +{ + int rc; + + rc = tpf_select_bsd(maxfds, reads, writes, excepts, tv); + tpf_process_signals(); - return(rc); ++ return rc; +} +#endif /* TPF */ diff --cc Utilities/cmcurl/lib/smb.c index 0000000,d461a71..d461a71 mode 000000,100644..100644 --- a/Utilities/cmcurl/lib/smb.c +++ b/Utilities/cmcurl/lib/smb.c diff --cc Utilities/cmcurl/lib/smb.h index 0000000,7852fa1..7852fa1 mode 000000,100644..100644 --- a/Utilities/cmcurl/lib/smb.h +++ b/Utilities/cmcurl/lib/smb.h http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=602cdc06a01b7c5c0eb444111382b09040f677ee commit 602cdc06a01b7c5c0eb444111382b09040f677ee Author: Brad King AuthorDate: Wed Aug 12 15:35:22 2015 -0400 Commit: Brad King CommitDate: Wed Aug 12 15:43:24 2015 -0400 cmCurl: Tolerate lack of CURLOPT_CAPATH support Since curl 7.39 the CURLOPT_CAPATH setting may be rejected with a CURLE_NOT_BUILT_IN error. Simply tolerate this with silent failure since we just will not use the CAPATH setting in this case. diff --git a/Source/cmCurl.cxx b/Source/cmCurl.cxx index 96d3547..ad0c7d3 100644 --- a/Source/cmCurl.cxx +++ b/Source/cmCurl.cxx @@ -13,7 +13,7 @@ #include "cmSystemTools.h" #define check_curl_result(result, errstr) \ - if (result != CURLE_OK) \ + if (result != CURLE_OK && result != CURLE_NOT_BUILT_IN) \ { \ e += e.empty()? "" : "\n"; \ e += errstr; \ http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=706542615828488a5ad197d0ef3dd5e42eb739c4 commit 706542615828488a5ad197d0ef3dd5e42eb739c4 Author: Curl Upstream AuthorDate: Tue Aug 11 20:13:01 2015 +0200 Commit: Brad King CommitDate: Wed Aug 12 14:18:06 2015 -0400 curl 7.44.0 (reduced) Extract upstream curl using the following shell code. url=git://github.com/bagder/curl.git && v=7.44.0 && r=1a7f66a3 && paths=" CMake/* CMakeLists.txt COPYING include/curl/*.h include/curl/curlbuild.h.cmake lib/*.c lib/*.h lib/CMakeLists.txt lib/Makefile.inc lib/curl_config.h.cmake lib/libcurl.rc lib/vtls/*.c lib/vtls/*.h " && mkdir curl-$v-g$r-reduced && git clone $url curl-git && date=$(cd curl-git && git log -n 1 --format='%cd' $r) && (cd curl-git && git checkout $r && git archive --format=tar $r -- $paths) | (cd curl-$v-g$r-reduced && tar xv && rm lib/config-*.h) && echo "g$r date: $date" diff --git a/CMake/CurlCheckCSourceCompiles.cmake b/CMake/CurlCheckCSourceCompiles.cmake deleted file mode 100644 index c5d2bab..0000000 --- a/CMake/CurlCheckCSourceCompiles.cmake +++ /dev/null @@ -1,71 +0,0 @@ -# - Check if the source code provided in the SOURCE argument compiles. -# CURL_CHECK_C_SOURCE_COMPILES(SOURCE VAR) -# - macro which checks if the source code compiles -# SOURCE - source code to try to compile -# VAR - variable to store whether the source code compiled -# -# The following variables may be set before calling this macro to -# modify the way the check is run: -# -# CMAKE_REQUIRED_FLAGS = string of compile command line flags -# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) -# CMAKE_REQUIRED_INCLUDES = list of include directories -# CMAKE_REQUIRED_LIBRARIES = list of libraries to link - -macro(CURL_CHECK_C_SOURCE_COMPILES SOURCE VAR) - if("${VAR}" MATCHES "^${VAR}$" OR "${VAR}" MATCHES "UNKNOWN") - set(message "${VAR}") - # If the number of arguments is greater than 2 (SOURCE VAR) - if(${ARGC} GREATER 2) - # then add the third argument as a message - set(message "${ARGV2} (${VAR})") - endif() - set(MACRO_CHECK_FUNCTION_DEFINITIONS - "-D${VAR} ${CMAKE_REQUIRED_FLAGS}") - if(CMAKE_REQUIRED_LIBRARIES) - set(CURL_CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES - "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") - endif() - if(CMAKE_REQUIRED_INCLUDES) - set(CURL_CHECK_C_SOURCE_COMPILES_ADD_INCLUDES - "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}") - endif() - set(src "") - foreach(def ${EXTRA_DEFINES}) - set(src "${src}#define ${def} 1\n") - endforeach(def) - foreach(inc ${HEADER_INCLUDES}) - set(src "${src}#include <${inc}>\n") - endforeach(inc) - - set(src "${src}\nint main() { ${SOURCE} ; return 0; }") - set(CMAKE_CONFIGURABLE_FILE_CONTENT "${src}") - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CMake/CMakeConfigurableFile.in - "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c" - IMMEDIATE) - message(STATUS "Performing Test ${message}") - try_compile(${VAR} - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c - COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} - CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} - "${CURL_CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES}" - "${CURL_CHECK_C_SOURCE_COMPILES_ADD_INCLUDES}" - OUTPUT_VARIABLE OUTPUT) - if(${VAR}) - set(${VAR} 1 CACHE INTERNAL "Test ${message}") - message(STATUS "Performing Test ${message} - Success") - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Performing C SOURCE FILE Test ${message} succeded with the following output:\n" - "${OUTPUT}\n" - "Source file was:\n${src}\n") - else() - message(STATUS "Performing Test ${message} - Failed") - set(${VAR} "" CACHE INTERNAL "Test ${message}") - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Performing C SOURCE FILE Test ${message} failed with the following output:\n" - "${OUTPUT}\n" - "Source file was:\n${src}\n") - endif() - endif() -endmacro() diff --git a/CMake/CurlCheckCSourceRuns.cmake b/CMake/CurlCheckCSourceRuns.cmake deleted file mode 100644 index 6b14af8..0000000 --- a/CMake/CurlCheckCSourceRuns.cmake +++ /dev/null @@ -1,83 +0,0 @@ -# - Check if the source code provided in the SOURCE argument compiles and runs. -# CURL_CHECK_C_SOURCE_RUNS(SOURCE VAR) -# - macro which checks if the source code runs -# SOURCE - source code to try to compile -# VAR - variable to store size if the type exists. -# -# The following variables may be set before calling this macro to -# modify the way the check is run: -# -# CMAKE_REQUIRED_FLAGS = string of compile command line flags -# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) -# CMAKE_REQUIRED_INCLUDES = list of include directories -# CMAKE_REQUIRED_LIBRARIES = list of libraries to link - -macro(CURL_CHECK_C_SOURCE_RUNS SOURCE VAR) - if("${VAR}" MATCHES "^${VAR}$" OR "${VAR}" MATCHES "UNKNOWN") - set(message "${VAR}") - # If the number of arguments is greater than 2 (SOURCE VAR) - if(${ARGC} GREATER 2) - # then add the third argument as a message - set(message "${ARGV2} (${VAR})") - endif(${ARGC} GREATER 2) - set(MACRO_CHECK_FUNCTION_DEFINITIONS - "-D${VAR} ${CMAKE_REQUIRED_FLAGS}") - if(CMAKE_REQUIRED_LIBRARIES) - set(CURL_CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES - "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") - else(CMAKE_REQUIRED_LIBRARIES) - set(CURL_CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES) - endif(CMAKE_REQUIRED_LIBRARIES) - if(CMAKE_REQUIRED_INCLUDES) - set(CURL_CHECK_C_SOURCE_COMPILES_ADD_INCLUDES - "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}") - else(CMAKE_REQUIRED_INCLUDES) - set(CURL_CHECK_C_SOURCE_COMPILES_ADD_INCLUDES) - endif(CMAKE_REQUIRED_INCLUDES) - set(src "") - foreach(def ${EXTRA_DEFINES}) - set(src "${src}#define ${def} 1\n") - endforeach(def) - foreach(inc ${HEADER_INCLUDES}) - set(src "${src}#include <${inc}>\n") - endforeach(inc) - - set(src "${src}\nint main() { ${SOURCE} ; return 0; }") - set(CMAKE_CONFIGURABLE_FILE_CONTENT "${src}") - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CMake/CMakeConfigurableFile.in - "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c" - IMMEDIATE) - message(STATUS "Performing Test ${message}") - try_run(${VAR} ${VAR}_COMPILED - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c - COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} - CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} - "${CURL_CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES}" - "${CURL_CHECK_C_SOURCE_COMPILES_ADD_INCLUDES}" - OUTPUT_VARIABLE OUTPUT) - # if it did not compile make the return value fail code of 1 - if(NOT ${VAR}_COMPILED) - set(${VAR} 1) - endif(NOT ${VAR}_COMPILED) - # if the return value was 0 then it worked - set(result_var ${${VAR}}) - if("${result_var}" EQUAL 0) - set(${VAR} 1 CACHE INTERNAL "Test ${message}") - message(STATUS "Performing Test ${message} - Success") - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Performing C SOURCE FILE Test ${message} succeded with the following output:\n" - "${OUTPUT}\n" - "Return value: ${${VAR}}\n" - "Source file was:\n${src}\n") - else("${result_var}" EQUAL 0) - message(STATUS "Performing Test ${message} - Failed") - set(${VAR} "" CACHE INTERNAL "Test ${message}") - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Performing C SOURCE FILE Test ${message} failed with the following output:\n" - "${OUTPUT}\n" - "Return value: ${result_var}\n" - "Source file was:\n${src}\n") - endif("${result_var}" EQUAL 0) - endif("${VAR}" MATCHES "^${VAR}$" OR "${VAR}" MATCHES "UNKNOWN") -endmacro(CURL_CHECK_C_SOURCE_RUNS) diff --git a/CMake/CurlTests.c b/CMake/CurlTests.c index 199871a..04d5e7e 100644 --- a/CMake/CurlTests.c +++ b/CMake/CurlTests.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -71,264 +71,88 @@ main () } #endif -#ifdef HAVE_GETHOSTBYADDR_R_5 +/* tests for gethostbyaddr_r or gethostbyname_r */ +#if defined(HAVE_GETHOSTBYADDR_R_5_REENTRANT) || \ + defined(HAVE_GETHOSTBYADDR_R_7_REENTRANT) || \ + defined(HAVE_GETHOSTBYADDR_R_8_REENTRANT) || \ + defined(HAVE_GETHOSTBYNAME_R_3_REENTRANT) || \ + defined(HAVE_GETHOSTBYNAME_R_5_REENTRANT) || \ + defined(HAVE_GETHOSTBYNAME_R_6_REENTRANT) +# define _REENTRANT + /* no idea whether _REENTRANT is always set, just invent a new flag */ +# define TEST_GETHOSTBYFOO_REENTRANT +#endif +#if defined(HAVE_GETHOSTBYADDR_R_5) || \ + defined(HAVE_GETHOSTBYADDR_R_7) || \ + defined(HAVE_GETHOSTBYADDR_R_8) || \ + defined(HAVE_GETHOSTBYNAME_R_3) || \ + defined(HAVE_GETHOSTBYNAME_R_5) || \ + defined(HAVE_GETHOSTBYNAME_R_6) || \ + defined(TEST_GETHOSTBYFOO_REENTRANT) #include #include -int -main () -{ - -char * address; -int length; -int type; -struct hostent h; -struct hostent_data hdata; -int rc; -#ifndef gethostbyaddr_r - (void)gethostbyaddr_r; -#endif -rc = gethostbyaddr_r(address, length, type, &h, &hdata); - ; - return 0; -} -#endif -#ifdef HAVE_GETHOSTBYADDR_R_5_REENTRANT -#define _REENTRANT -#include -#include -int -main () -{ - -char * address; -int length;q -int type; -struct hostent h; -struct hostent_data hdata; -int rc; -#ifndef gethostbyaddr_r - (void)gethostbyaddr_r; -#endif -rc = gethostbyaddr_r(address, length, type, &h, &hdata); - ; - return 0; -} -#endif -#ifdef HAVE_GETHOSTBYADDR_R_7 -#include -#include -int -main () -{ - -char * address; -int length; -int type; -struct hostent h; -char buffer[8192]; -int h_errnop; -struct hostent * hp; - -#ifndef gethostbyaddr_r - (void)gethostbyaddr_r; -#endif -hp = gethostbyaddr_r(address, length, type, &h, - buffer, 8192, &h_errnop); - ; - return 0; -} -#endif -#ifdef HAVE_GETHOSTBYADDR_R_7_REENTRANT -#define _REENTRANT -#include -#include -int -main () +int main(void) { - -char * address; -int length; -int type; -struct hostent h; -char buffer[8192]; -int h_errnop; -struct hostent * hp; - -#ifndef gethostbyaddr_r - (void)gethostbyaddr_r; -#endif -hp = gethostbyaddr_r(address, length, type, &h, - buffer, 8192, &h_errnop); - ; - return 0; -} + char *address = "example.com"; + int length = 0; + int type = 0; + struct hostent h; + int rc = 0; +#if defined(HAVE_GETHOSTBYADDR_R_5) || \ + defined(HAVE_GETHOSTBYADDR_R_5_REENTRANT) || \ + \ + defined(HAVE_GETHOSTBYNAME_R_3) || \ + defined(HAVE_GETHOSTBYNAME_R_3_REENTRANT) + struct hostent_data hdata; +#elif defined(HAVE_GETHOSTBYADDR_R_7) || \ + defined(HAVE_GETHOSTBYADDR_R_7_REENTRANT) || \ + defined(HAVE_GETHOSTBYADDR_R_8) || \ + defined(HAVE_GETHOSTBYADDR_R_8_REENTRANT) || \ + \ + defined(HAVE_GETHOSTBYNAME_R_5) || \ + defined(HAVE_GETHOSTBYNAME_R_5_REENTRANT) || \ + defined(HAVE_GETHOSTBYNAME_R_6) || \ + defined(HAVE_GETHOSTBYNAME_R_6_REENTRANT) + char buffer[8192]; + int h_errnop; + struct hostent *hp; #endif -#ifdef HAVE_GETHOSTBYADDR_R_8 -#include -#include -int -main () -{ - -char * address; -int length; -int type; -struct hostent h; -char buffer[8192]; -int h_errnop; -struct hostent * hp; -int rc; - -#ifndef gethostbyaddr_r - (void)gethostbyaddr_r; -#endif -rc = gethostbyaddr_r(address, length, type, &h, - buffer, 8192, &hp, &h_errnop); - ; - return 0; -} -#endif -#ifdef HAVE_GETHOSTBYADDR_R_8_REENTRANT -#define _REENTRANT -#include -#include -int -main () -{ - -char * address; -int length; -int type; -struct hostent h; -char buffer[8192]; -int h_errnop; -struct hostent * hp; -int rc; #ifndef gethostbyaddr_r (void)gethostbyaddr_r; #endif -rc = gethostbyaddr_r(address, length, type, &h, - buffer, 8192, &hp, &h_errnop); - ; - return 0; -} -#endif -#ifdef HAVE_GETHOSTBYNAME_R_3 -#include -#include -#include -#undef NULL -#define NULL (void *)0 - -int -main () -{ - -struct hostent_data data; -#ifndef gethostbyname_r - (void)gethostbyname_r; -#endif -gethostbyname_r(NULL, NULL, NULL); - ; - return 0; -} -#endif -#ifdef HAVE_GETHOSTBYNAME_R_3_REENTRANT -#define _REENTRANT -#include -#include -#include -#undef NULL -#define NULL (void *)0 - -int -main () -{ - -struct hostent_data data; -#ifndef gethostbyname_r - (void)gethostbyname_r; -#endif -gethostbyname_r(NULL, NULL, NULL); - ; - return 0; -} -#endif -#ifdef HAVE_GETHOSTBYNAME_R_5 -#include -#include -#include -#undef NULL -#define NULL (void *)0 - -int -main () -{ -#ifndef gethostbyname_r - (void)gethostbyname_r; -#endif -gethostbyname_r(NULL, NULL, NULL, 0, NULL); - ; - return 0; -} -#endif -#ifdef HAVE_GETHOSTBYNAME_R_5_REENTRANT -#define _REENTRANT -#include -#include -#undef NULL -#define NULL (void *)0 -int -main () -{ - -#ifndef gethostbyname_r - (void)gethostbyname_r; -#endif -gethostbyname_r(NULL, NULL, NULL, 0, NULL); - ; +#if defined(HAVE_GETHOSTBYADDR_R_5) || \ + defined(HAVE_GETHOSTBYADDR_R_5_REENTRANT) + rc = gethostbyaddr_r(address, length, type, &h, &hdata); +#elif defined(HAVE_GETHOSTBYADDR_R_7) || \ + defined(HAVE_GETHOSTBYADDR_R_7_REENTRANT) + hp = gethostbyaddr_r(address, length, type, &h, buffer, 8192, &h_errnop); + (void)hp; +#elif defined(HAVE_GETHOSTBYADDR_R_8) || \ + defined(HAVE_GETHOSTBYADDR_R_8_REENTRANT) + rc = gethostbyaddr_r(address, length, type, &h, buffer, 8192, &hp, &h_errnop); +#endif + +#if defined(HAVE_GETHOSTBYNAME_R_3) || \ + defined(HAVE_GETHOSTBYNAME_R_3_REENTRANT) + rc = gethostbyname_r(address, &h, &hdata); +#elif defined(HAVE_GETHOSTBYNAME_R_5) || \ + defined(HAVE_GETHOSTBYNAME_R_5_REENTRANT) + rc = gethostbyname_r(address, &h, buffer, 8192, 0, &h_errnop); + (void)hp; /* not used for test */ +#elif defined(HAVE_GETHOSTBYNAME_R_6) || \ + defined(HAVE_GETHOSTBYNAME_R_6_REENTRANT) + rc = gethostbyname_r(address, &h, buffer, 8192, &hp, &h_errnop); +#endif + + (void)length; + (void)type; + (void)rc; return 0; } #endif -#ifdef HAVE_GETHOSTBYNAME_R_6 -#include -#include -#undef NULL -#define NULL (void *)0 - -int -main () -{ -#ifndef gethostbyname_r - (void)gethostbyname_r; -#endif -gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL); - ; - return 0; -} -#endif -#ifdef HAVE_GETHOSTBYNAME_R_6_REENTRANT -#define _REENTRANT -#include -#include -#undef NULL -#define NULL (void *)0 - -int -main () -{ - -#ifndef gethostbyname_r - (void)gethostbyname_r; -#endif -gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL); - ; - return 0; -} -#endif #ifdef HAVE_SOCKLEN_T #ifdef _WIN32 #include diff --git a/CMake/FindGSS.cmake b/CMake/FindGSS.cmake new file mode 100644 index 0000000..dfaeaf3 --- /dev/null +++ b/CMake/FindGSS.cmake @@ -0,0 +1,289 @@ +# - Try to find the GSS Kerberos library +# Once done this will define +# +# GSS_ROOT_DIR - Set this variable to the root installation of GSS +# +# Read-Only variables: +# GSS_FOUND - system has the Heimdal library +# GSS_FLAVOUR - "MIT" or "Heimdal" if anything found. +# GSS_INCLUDE_DIR - the Heimdal include directory +# GSS_LIBRARIES - The libraries needed to use GSS +# GSS_LINK_DIRECTORIES - Directories to add to linker search path +# GSS_LINKER_FLAGS - Additional linker flags +# GSS_COMPILER_FLAGS - Additional compiler flags +# GSS_VERSION - This is set to version advertised by pkg-config or read from manifest. +# In case the library is found but no version info availabe it'll be set to "unknown" + +set(_MIT_MODNAME mit-krb5-gssapi) +set(_HEIMDAL_MODNAME heimdal-gssapi) + +include(CheckIncludeFile) +include(CheckIncludeFiles) +include(CheckTypeSize) + +set(_GSS_ROOT_HINTS + "${GSS_ROOT_DIR}" + "$ENV{GSS_ROOT_DIR}" +) + +# try to find library using system pkg-config if user didn't specify root dir +if(NOT GSS_ROOT_DIR AND NOT "$ENV{GSS_ROOT_DIR}") + if(UNIX) + find_package(PkgConfig QUIET) + pkg_search_module(_GSS_PKG ${_MIT_MODNAME} ${_HEIMDAL_MODNAME}) + list(APPEND _GSS_ROOT_HINTS "${_GSS_PKG_PREFIX}") + elseif(WIN32) + list(APPEND _GSS_ROOT_HINTS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MIT\\Kerberos;InstallDir]") + endif() +endif() + +if(NOT _GSS_FOUND) #not found by pkg-config. Let's take more traditional approach. + find_file(_GSS_CONFIGURE_SCRIPT + NAMES + "krb5-config" + HINTS + ${_GSS_ROOT_HINTS} + PATH_SUFFIXES + bin + NO_CMAKE_PATH + NO_CMAKE_ENVIRONMENT_PATH + ) + + # if not found in user-supplied directories, maybe system knows better + find_file(_GSS_CONFIGURE_SCRIPT + NAMES + "krb5-config" + PATH_SUFFIXES + bin + ) + + if(_GSS_CONFIGURE_SCRIPT) + execute_process( + COMMAND ${_GSS_CONFIGURE_SCRIPT} "--cflags" "gssapi" + OUTPUT_VARIABLE _GSS_CFLAGS + RESULT_VARIABLE _GSS_CONFIGURE_FAILED + ) +message(STATUS "CFLAGS: ${_GSS_CFLAGS}") + if(NOT _GSS_CONFIGURE_FAILED) # 0 means success + # should also work in an odd case when multiple directories are given + string(STRIP "${_GSS_CFLAGS}" _GSS_CFLAGS) + string(REGEX REPLACE " +-I" ";" _GSS_CFLAGS "${_GSS_CFLAGS}") + string(REGEX REPLACE " +-([^I][^ \\t;]*)" ";-\\1"_GSS_CFLAGS "${_GSS_CFLAGS}") + + foreach(_flag ${_GSS_CFLAGS}) + if(_flag MATCHES "^-I.*") + string(REGEX REPLACE "^-I" "" _val "${_flag}") + list(APPEND _GSS_INCLUDE_DIR "${_val}") + else() + list(APPEND _GSS_COMPILER_FLAGS "${_flag}") + endif() + endforeach() + endif() + + execute_process( + COMMAND ${_GSS_CONFIGURE_SCRIPT} "--libs" "gssapi" + OUTPUT_VARIABLE _GSS_LIB_FLAGS + RESULT_VARIABLE _GSS_CONFIGURE_FAILED + ) +message(STATUS "LDFLAGS: ${_GSS_LIB_FLAGS}") + if(NOT _GSS_CONFIGURE_FAILED) # 0 means success + # this script gives us libraries and link directories. Blah. We have to deal with it. + string(STRIP "${_GSS_LIB_FLAGS}" _GSS_LIB_FLAGS) + string(REGEX REPLACE " +-(L|l)" ";-\\1" _GSS_LIB_FLAGS "${_GSS_LIB_FLAGS}") + string(REGEX REPLACE " +-([^Ll][^ \\t;]*)" ";-\\1"_GSS_LIB_FLAGS "${_GSS_LIB_FLAGS}") + + foreach(_flag ${_GSS_LIB_FLAGS}) + if(_flag MATCHES "^-l.*") + string(REGEX REPLACE "^-l" "" _val "${_flag}") + list(APPEND _GSS_LIBRARIES "${_val}") + elseif(_flag MATCHES "^-L.*") + string(REGEX REPLACE "^-L" "" _val "${_flag}") + list(APPEND _GSS_LINK_DIRECTORIES "${_val}") + else() + list(APPEND _GSS_LINKER_FLAGS "${_flag}") + endif() + endforeach() + endif() + + + execute_process( + COMMAND ${_GSS_CONFIGURE_SCRIPT} "--version" + OUTPUT_VARIABLE _GSS_VERSION + RESULT_VARIABLE _GSS_CONFIGURE_FAILED + ) + + # older versions may not have the "--version" parameter. In this case we just don't care. + if(_GSS_CONFIGURE_FAILED) + set(_GSS_VERSION 0) + endif() + + + execute_process( + COMMAND ${_GSS_CONFIGURE_SCRIPT} "--vendor" + OUTPUT_VARIABLE _GSS_VENDOR + RESULT_VARIABLE _GSS_CONFIGURE_FAILED + ) + + # older versions may not have the "--vendor" parameter. In this case we just don't care. + if(_GSS_CONFIGURE_FAILED) + set(GSS_FLAVOUR "Heimdal") # most probably, shouldn't really matter + else() + if(_GSS_VENDOR MATCHES ".*H|heimdal.*") + set(GSS_FLAVOUR "Heimdal") + else() + set(GSS_FLAVOUR "MIT") + endif() + endif() + + else() # either there is no config script or we are on platform that doesn't provide one (Windows?) + + find_path(_GSS_INCLUDE_DIR + NAMES + "gssapi/gssapi.h" + HINTS + ${_GSS_ROOT_HINTS} + PATH_SUFFIXES + include + inc + ) + + if(_GSS_INCLUDE_DIR) #jay, we've found something + set(CMAKE_REQUIRED_INCLUDES "${_GSS_INCLUDE_DIR}") + check_include_files( "gssapi/gssapi_generic.h;gssapi/gssapi_krb5.h" _GSS_HAVE_MIT_HEADERS) + + if(_GSS_HAVE_MIT_HEADERS) + set(GSS_FLAVOUR "MIT") + else() + # prevent compiling the header - just check if we can include it + set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D__ROKEN_H__") + check_include_file( "roken.h" _GSS_HAVE_ROKEN_H) + + check_include_file( "heimdal/roken.h" _GSS_HAVE_HEIMDAL_ROKEN_H) + if(_GSS_HAVE_ROKEN_H OR _GSS_HAVE_HEIMDAL_ROKEN_H) + set(GSS_FLAVOUR "Heimdal") + endif() + set(CMAKE_REQUIRED_DEFINITIONS "") + endif() + else() + # I'm not convienced if this is the right way but this is what autotools do at the moment + find_path(_GSS_INCLUDE_DIR + NAMES + "gssapi.h" + HINTS + ${_GSS_ROOT_HINTS} + PATH_SUFFIXES + include + inc + ) + + if(_GSS_INCLUDE_DIR) + set(GSS_FLAVOUR "Heimdal") + endif() + endif() + + # if we have headers, check if we can link libraries + if(GSS_FLAVOUR) + set(_GSS_LIBDIR_SUFFIXES "") + set(_GSS_LIBDIR_HINTS ${_GSS_ROOT_HINTS}) + get_filename_component(_GSS_CALCULATED_POTENTIAL_ROOT "${_GSS_INCLUDE_DIR}" PATH) + list(APPEND _GSS_LIBDIR_HINTS ${_GSS_CALCULATED_POTENTIAL_ROOT}) + + if(WIN32) + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + list(APPEND _GSS_LIBDIR_SUFFIXES "lib/AMD64") + if(GSS_FLAVOUR STREQUAL "MIT") + set(_GSS_LIBNAME "gssapi64") + else() + set(_GSS_LIBNAME "libgssapi") + endif() + else() + list(APPEND _GSS_LIBDIR_SUFFIXES "lib/i386") + if(GSS_FLAVOUR STREQUAL "MIT") + set(_GSS_LIBNAME "gssapi32") + else() + set(_GSS_LIBNAME "libgssapi") + endif() + endif() + else() + list(APPEND _GSS_LIBDIR_SUFFIXES "lib;lib64") # those suffixes are not checked for HINTS + if(GSS_FLAVOUR STREQUAL "MIT") + set(_GSS_LIBNAME "gssapi_krb5") + else() + set(_GSS_LIBNAME "gssapi") + endif() + endif() + + find_library(_GSS_LIBRARIES + NAMES + ${_GSS_LIBNAME} + HINTS + ${_GSS_LIBDIR_HINTS} + PATH_SUFFIXES + ${_GSS_LIBDIR_SUFFIXES} + ) + + endif() + + endif() +else() + if(_GSS_PKG_${_MIT_MODNAME}_VERSION) + set(GSS_FLAVOUR "MIT") + set(_GSS_VERSION _GSS_PKG_${_MIT_MODNAME}_VERSION) + else() + set(GSS_FLAVOUR "Heimdal") + set(_GSS_VERSION _GSS_PKG_${_MIT_HEIMDAL}_VERSION) + endif() +endif() + +set(GSS_INCLUDE_DIR ${_GSS_INCLUDE_DIR}) +set(GSS_LIBRARIES ${_GSS_LIBRARIES}) +set(GSS_LINK_DIRECTORIES ${_GSS_LINK_DIRECTORIES}) +set(GSS_LINKER_FLAGS ${_GSS_LINKER_FLAGS}) +set(GSS_COMPILER_FLAGS ${_GSS_COMPILER_FLAGS}) +set(GSS_VERSION ${_GSS_VERSION}) + +if(GSS_FLAVOUR) + + if(NOT GSS_VERSION AND GSS_FLAVOUR STREQUAL "Heimdal") + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(HEIMDAL_MANIFEST_FILE "Heimdal.Application.amd64.manifest") + else() + set(HEIMDAL_MANIFEST_FILE "Heimdal.Application.x86.manifest") + endif() + + if(EXISTS "${GSS_INCLUDE_DIR}/${HEIMDAL_MANIFEST_FILE}") + file(STRINGS "${GSS_INCLUDE_DIR}/${HEIMDAL_MANIFEST_FILE}" heimdal_version_str + REGEX "^.*version=\"[0-9]\\.[^\"]+\".*$") + + string(REGEX MATCH "[0-9]\\.[^\"]+" + GSS_VERSION "${heimdal_version_str}") + endif() + + if(NOT GSS_VERSION) + set(GSS_VERSION "Heimdal Unknown") + endif() + elseif(NOT GSS_VERSION AND GSS_FLAVOUR STREQUAL "MIT") + get_filename_component(_MIT_VERSION "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MIT\\Kerberos\\SDK\\CurrentVersion;VersionString]" NAME CACHE) + if(WIN32 AND _MIT_VERSION) + set(GSS_VERSION "${_MIT_VERSION}") + else() + set(GSS_VERSION "MIT Unknown") + endif() + endif() +endif() + + +include(FindPackageHandleStandardArgs) + +set(_GSS_REQUIRED_VARS GSS_LIBRARIES GSS_FLAVOUR) + +find_package_handle_standard_args(GSS + REQUIRED_VARS + ${_GSS_REQUIRED_VARS} + VERSION_VAR + GSS_VERSION + FAIL_MESSAGE + "Could NOT find GSS, try to set the path to GSS root folder in the system variable GSS_ROOT_DIR" +) + +mark_as_advanced(GSS_INCLUDE_DIR GSS_LIBRARIES) diff --git a/CMake/Macros.cmake b/CMake/Macros.cmake index 80a8833..dab005f 100644 --- a/CMake/Macros.cmake +++ b/CMake/Macros.cmake @@ -1,7 +1,10 @@ #File defines convenience macros for available feature testing # This macro checks if the symbol exists in the library and if it -# does, it prepends library to the list. +# does, it prepends library to the list. It is intended to be called +# multiple times with a sequence of possibly dependent libraries in +# order of least-to-most-dependent. Some libraries depend on others +# to link correctly. macro(CHECK_LIBRARY_EXISTS_CONCAT LIBRARY SYMBOL VARIABLE) check_library_exists("${LIBRARY};${CURL_LIBS}" ${SYMBOL} "${CMAKE_LIBRARY_PATH}" ${VARIABLE}) @@ -11,8 +14,11 @@ macro(CHECK_LIBRARY_EXISTS_CONCAT LIBRARY SYMBOL VARIABLE) endmacro(CHECK_LIBRARY_EXISTS_CONCAT) # Check if header file exists and add it to the list. +# This macro is intended to be called multiple times with a sequence of +# possibly dependent header files. Some headers depend on others to be +# compiled correctly. macro(CHECK_INCLUDE_FILE_CONCAT FILE VARIABLE) - check_include_file("${FILE}" ${VARIABLE}) + check_include_files("${CURL_INCLUDES};${FILE}" ${VARIABLE}) if(${VARIABLE}) set(CURL_INCLUDES ${CURL_INCLUDES} ${FILE}) set(CURL_TEST_DEFINES "${CURL_TEST_DEFINES} -D${VARIABLE}") @@ -21,7 +27,7 @@ endmacro(CHECK_INCLUDE_FILE_CONCAT) # For other curl specific tests, use this macro. macro(CURL_INTERNAL_TEST CURL_TEST) - if("${CURL_TEST}" MATCHES "^${CURL_TEST}$") + if(NOT DEFINED "${CURL_TEST}") set(MACRO_CHECK_FUNCTION_DEFINITIONS "-D${CURL_TEST} ${CURL_TEST_DEFINES} ${CMAKE_REQUIRED_FLAGS}") if(CMAKE_REQUIRED_LIBRARIES) @@ -49,11 +55,11 @@ macro(CURL_INTERNAL_TEST CURL_TEST) "Performing Curl Test ${CURL_TEST} failed with the following output:\n" "${OUTPUT}\n") endif(${CURL_TEST}) - endif("${CURL_TEST}" MATCHES "^${CURL_TEST}$") + endif() endmacro(CURL_INTERNAL_TEST) macro(CURL_INTERNAL_TEST_RUN CURL_TEST) - if("${CURL_TEST}_COMPILE" MATCHES "^${CURL_TEST}_COMPILE$") + if(NOT DEFINED "${CURL_TEST}_COMPILE") set(MACRO_CHECK_FUNCTION_DEFINITIONS "-D${CURL_TEST} ${CMAKE_REQUIRED_FLAGS}") if(CMAKE_REQUIRED_LIBRARIES) @@ -85,5 +91,5 @@ macro(CURL_INTERNAL_TEST_RUN CURL_TEST) file(APPEND "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log" "\n\n") endif(${CURL_TEST}_COMPILE AND NOT ${CURL_TEST}) - endif("${CURL_TEST}_COMPILE" MATCHES "^${CURL_TEST}_COMPILE$") + endif() endmacro(CURL_INTERNAL_TEST_RUN) diff --git a/CMake/OtherTests.cmake b/CMake/OtherTests.cmake index 9cd5eac..4f07f22 100644 --- a/CMake/OtherTests.cmake +++ b/CMake/OtherTests.cmake @@ -1,15 +1,10 @@ -include(CurlCheckCSourceCompiles) -set(EXTRA_DEFINES "__unused1\n#undef inline\n#define __unused2") -set(HEADER_INCLUDES) -set(headers_hack) +include(CheckCSourceCompiles) +# The begin of the sources (macros and includes) +set(_source_epilogue "#undef inline") macro(add_header_include check header) if(${check}) - set(headers_hack - "${headers_hack}\n#include <${header}>") - #SET(HEADER_INCLUDES - # ${HEADER_INCLUDES} - # "${header}") + set(_source_epilogue "${_source_epilogue}\n#include <${header}>") endif(${check}) endmacro(add_header_include) @@ -18,8 +13,8 @@ if(HAVE_WINDOWS_H) add_header_include(HAVE_WINDOWS_H "windows.h") add_header_include(HAVE_WINSOCK2_H "winsock2.h") add_header_include(HAVE_WINSOCK_H "winsock.h") - set(EXTRA_DEFINES ${EXTRA_DEFINES} - "__unused7\n#ifndef WIN32_LEAN_AND_MEAN\n#define WIN32_LEAN_AND_MEAN\n#endif\n#define __unused3") + set(_source_epilogue + "${_source_epilogue}\n#ifndef WIN32_LEAN_AND_MEAN\n#define WIN32_LEAN_AND_MEAN\n#endif") set(signature_call_conv "PASCAL") if(HAVE_LIBWS2_32) set(CMAKE_REQUIRED_LIBRARIES ws2_32) @@ -29,14 +24,12 @@ else(HAVE_WINDOWS_H) add_header_include(HAVE_SYS_SOCKET_H "sys/socket.h") endif(HAVE_WINDOWS_H) -set(EXTRA_DEFINES_BACKUP "${EXTRA_DEFINES}") -set(EXTRA_DEFINES "${EXTRA_DEFINES_BACKUP}\n${headers_hack}\n${extern_line}\n#define __unused5") -curl_check_c_source_compiles("recv(0, 0, 0, 0)" curl_cv_recv) +check_c_source_compiles("${_source_epilogue} +int main(void) { + recv(0, 0, 0, 0); + return 0; +}" curl_cv_recv) if(curl_cv_recv) - # AC_CACHE_CHECK([types of arguments and return type for recv], - #[curl_cv_func_recv_args], [ - #SET(curl_cv_func_recv_args "unknown") - #for recv_retv in 'int' 'ssize_t'; do if(NOT DEFINED curl_cv_func_recv_args OR "${curl_cv_func_recv_args}" STREQUAL "unknown") foreach(recv_retv "int" "ssize_t" ) foreach(recv_arg1 "int" "ssize_t" "SOCKET") @@ -44,17 +37,23 @@ if(curl_cv_recv) foreach(recv_arg3 "size_t" "int" "socklen_t" "unsigned int") foreach(recv_arg4 "int" "unsigned int") if(NOT curl_cv_func_recv_done) - set(curl_cv_func_recv_test "UNKNOWN") - set(extern_line "extern ${recv_retv} ${signature_call_conv} recv(${recv_arg1}, ${recv_arg2}, ${recv_arg3}, ${recv_arg4})\;") - set(EXTRA_DEFINES "${EXTRA_DEFINES_BACKUP}\n${headers_hack}\n${extern_line}\n#define __unused5") - curl_check_c_source_compiles(" + unset(curl_cv_func_recv_test CACHE) + check_c_source_compiles(" + ${_source_epilogue} + extern ${recv_retv} ${signature_call_conv} + recv(${recv_arg1}, ${recv_arg2}, ${recv_arg3}, ${recv_arg4}); + int main(void) { ${recv_arg1} s=0; ${recv_arg2} buf=0; ${recv_arg3} len=0; ${recv_arg4} flags=0; - ${recv_retv} res = recv(s, buf, len, flags)" - curl_cv_func_recv_test - "${recv_retv} recv(${recv_arg1}, ${recv_arg2}, ${recv_arg3}, ${recv_arg4})") + ${recv_retv} res = recv(s, buf, len, flags); + (void) res; + return 0; + }" + curl_cv_func_recv_test) + message(STATUS + "Tested: ${recv_retv} recv(${recv_arg1}, ${recv_arg2}, ${recv_arg3}, ${recv_arg4})") if(curl_cv_func_recv_test) set(curl_cv_func_recv_args "${recv_arg1},${recv_arg2},${recv_arg3},${recv_arg4},${recv_retv}") @@ -72,18 +71,13 @@ if(curl_cv_recv) endforeach(recv_arg2) endforeach(recv_arg1) endforeach(recv_retv) - else(NOT DEFINED curl_cv_func_recv_args OR "${curl_cv_func_recv_args}" STREQUAL "unknown") + else() string(REGEX REPLACE "^([^,]*),[^,]*,[^,]*,[^,]*,[^,]*$" "\\1" RECV_TYPE_ARG1 "${curl_cv_func_recv_args}") string(REGEX REPLACE "^[^,]*,([^,]*),[^,]*,[^,]*,[^,]*$" "\\1" RECV_TYPE_ARG2 "${curl_cv_func_recv_args}") string(REGEX REPLACE "^[^,]*,[^,]*,([^,]*),[^,]*,[^,]*$" "\\1" RECV_TYPE_ARG3 "${curl_cv_func_recv_args}") string(REGEX REPLACE "^[^,]*,[^,]*,[^,]*,([^,]*),[^,]*$" "\\1" RECV_TYPE_ARG4 "${curl_cv_func_recv_args}") string(REGEX REPLACE "^[^,]*,[^,]*,[^,]*,[^,]*,([^,]*)$" "\\1" RECV_TYPE_RETV "${curl_cv_func_recv_args}") - #MESSAGE("RECV_TYPE_ARG1 ${RECV_TYPE_ARG1}") - #MESSAGE("RECV_TYPE_ARG2 ${RECV_TYPE_ARG2}") - #MESSAGE("RECV_TYPE_ARG3 ${RECV_TYPE_ARG3}") - #MESSAGE("RECV_TYPE_ARG4 ${RECV_TYPE_ARG4}") - #MESSAGE("RECV_TYPE_RETV ${RECV_TYPE_RETV}") - endif(NOT DEFINED curl_cv_func_recv_args OR "${curl_cv_func_recv_args}" STREQUAL "unknown") + endif() if("${curl_cv_func_recv_args}" STREQUAL "unknown") message(FATAL_ERROR "Cannot find proper types to use for recv args") @@ -94,12 +88,12 @@ endif(curl_cv_recv) set(curl_cv_func_recv_args "${curl_cv_func_recv_args}" CACHE INTERNAL "Arguments for recv") set(HAVE_RECV 1) -curl_check_c_source_compiles("send(0, 0, 0, 0)" curl_cv_send) +check_c_source_compiles("${_source_epilogue} +int main(void) { + send(0, 0, 0, 0); + return 0; +}" curl_cv_send) if(curl_cv_send) - # AC_CACHE_CHECK([types of arguments and return type for send], - #[curl_cv_func_send_args], [ - #SET(curl_cv_func_send_args "unknown") - #for send_retv in 'int' 'ssize_t'; do if(NOT DEFINED curl_cv_func_send_args OR "${curl_cv_func_send_args}" STREQUAL "unknown") foreach(send_retv "int" "ssize_t" ) foreach(send_arg1 "int" "ssize_t" "SOCKET") @@ -107,19 +101,24 @@ if(curl_cv_send) foreach(send_arg3 "size_t" "int" "socklen_t" "unsigned int") foreach(send_arg4 "int" "unsigned int") if(NOT curl_cv_func_send_done) - set(curl_cv_func_send_test "UNKNOWN") - set(extern_line "extern ${send_retv} ${signature_call_conv} send(${send_arg1}, ${send_arg2}, ${send_arg3}, ${send_arg4})\;") - set(EXTRA_DEFINES "${EXTRA_DEFINES_BACKUP}\n${headers_hack}\n${extern_line}\n#define __unused5") - curl_check_c_source_compiles(" + unset(curl_cv_func_send_test CACHE) + check_c_source_compiles(" + ${_source_epilogue} + extern ${send_retv} ${signature_call_conv} + send(${send_arg1}, ${send_arg2}, ${send_arg3}, ${send_arg4}); + int main(void) { ${send_arg1} s=0; ${send_arg2} buf=0; ${send_arg3} len=0; ${send_arg4} flags=0; - ${send_retv} res = send(s, buf, len, flags)" - curl_cv_func_send_test - "${send_retv} send(${send_arg1}, ${send_arg2}, ${send_arg3}, ${send_arg4})") + ${send_retv} res = send(s, buf, len, flags); + (void) res; + return 0; + }" + curl_cv_func_send_test) + message(STATUS + "Tested: ${send_retv} send(${send_arg1}, ${send_arg2}, ${send_arg3}, ${send_arg4})") if(curl_cv_func_send_test) - #MESSAGE("Found arguments: ${curl_cv_func_send_test}") string(REGEX REPLACE "(const) .*" "\\1" send_qual_arg2 "${send_arg2}") string(REGEX REPLACE "const (.*)" "\\1" send_arg2 "${send_arg2}") set(curl_cv_func_send_args @@ -138,20 +137,14 @@ if(curl_cv_send) endforeach(send_arg2) endforeach(send_arg1) endforeach(send_retv) - else(NOT DEFINED curl_cv_func_send_args OR "${curl_cv_func_send_args}" STREQUAL "unknown") + else() string(REGEX REPLACE "^([^,]*),[^,]*,[^,]*,[^,]*,[^,]*,[^,]*$" "\\1" SEND_TYPE_ARG1 "${curl_cv_func_send_args}") string(REGEX REPLACE "^[^,]*,([^,]*),[^,]*,[^,]*,[^,]*,[^,]*$" "\\1" SEND_TYPE_ARG2 "${curl_cv_func_send_args}") string(REGEX REPLACE "^[^,]*,[^,]*,([^,]*),[^,]*,[^,]*,[^,]*$" "\\1" SEND_TYPE_ARG3 "${curl_cv_func_send_args}") string(REGEX REPLACE "^[^,]*,[^,]*,[^,]*,([^,]*),[^,]*,[^,]*$" "\\1" SEND_TYPE_ARG4 "${curl_cv_func_send_args}") string(REGEX REPLACE "^[^,]*,[^,]*,[^,]*,[^,]*,([^,]*),[^,]*$" "\\1" SEND_TYPE_RETV "${curl_cv_func_send_args}") string(REGEX REPLACE "^[^,]*,[^,]*,[^,]*,[^,]*,[^,]*,([^,]*)$" "\\1" SEND_QUAL_ARG2 "${curl_cv_func_send_args}") - #MESSAGE("SEND_TYPE_ARG1 ${SEND_TYPE_ARG1}") - #MESSAGE("SEND_TYPE_ARG2 ${SEND_TYPE_ARG2}") - #MESSAGE("SEND_TYPE_ARG3 ${SEND_TYPE_ARG3}") - #MESSAGE("SEND_TYPE_ARG4 ${SEND_TYPE_ARG4}") - #MESSAGE("SEND_TYPE_RETV ${SEND_TYPE_RETV}") - #MESSAGE("SEND_QUAL_ARG2 ${SEND_QUAL_ARG2}") - endif(NOT DEFINED curl_cv_func_send_args OR "${curl_cv_func_send_args}" STREQUAL "unknown") + endif() if("${curl_cv_func_send_args}" STREQUAL "unknown") message(FATAL_ERROR "Cannot find proper types to use for send args") @@ -163,88 +156,71 @@ endif(curl_cv_send) set(curl_cv_func_send_args "${curl_cv_func_send_args}" CACHE INTERNAL "Arguments for send") set(HAVE_SEND 1) -set(EXTRA_DEFINES "${EXTRA_DEFINES}\n${headers_hack}\n#define __unused5") -curl_check_c_source_compiles("int flag = MSG_NOSIGNAL" HAVE_MSG_NOSIGNAL) - -set(EXTRA_DEFINES "__unused1\n#undef inline\n#define __unused2") -set(HEADER_INCLUDES) -set(headers_hack) +check_c_source_compiles("${_source_epilogue} + int main(void) { + int flag = MSG_NOSIGNAL; + (void)flag; + return 0; + }" HAVE_MSG_NOSIGNAL) -macro(add_header_include check header) - if(${check}) - set(headers_hack - "${headers_hack}\n#include <${header}>") - #SET(HEADER_INCLUDES - # ${HEADER_INCLUDES} - # "${header}") - endif(${check}) -endmacro(add_header_include header) - -if(HAVE_WINDOWS_H) - set(EXTRA_DEFINES ${EXTRA_DEFINES} - "__unused7\n#ifndef WIN32_LEAN_AND_MEAN\n#define WIN32_LEAN_AND_MEAN\n#endif\n#define __unused3") - add_header_include(HAVE_WINDOWS_H "windows.h") - add_header_include(HAVE_WINSOCK2_H "winsock2.h") - add_header_include(HAVE_WINSOCK_H "winsock.h") -else(HAVE_WINDOWS_H) - add_header_include(HAVE_SYS_TYPES_H "sys/types.h") +if(NOT HAVE_WINDOWS_H) add_header_include(HAVE_SYS_TIME_H "sys/time.h") add_header_include(TIME_WITH_SYS_TIME "time.h") add_header_include(HAVE_TIME_H "time.h") -endif(HAVE_WINDOWS_H) -set(EXTRA_DEFINES "${EXTRA_DEFINES}\n${headers_hack}\n#define __unused5") -curl_check_c_source_compiles("struct timeval ts;\nts.tv_sec = 0;\nts.tv_usec = 0" HAVE_STRUCT_TIMEVAL) - - -include(CurlCheckCSourceRuns) -set(EXTRA_DEFINES) -set(HEADER_INCLUDES) +endif() +check_c_source_compiles("${_source_epilogue} +int main(void) { + struct timeval ts; + ts.tv_sec = 0; + ts.tv_usec = 0; + (void)ts; + return 0; +}" HAVE_STRUCT_TIMEVAL) + + +include(CheckCSourceRuns) +set(CMAKE_REQUIRED_FLAGS) if(HAVE_SYS_POLL_H) - set(HEADER_INCLUDES "sys/poll.h") + set(CMAKE_REQUIRED_FLAGS "-DHAVE_SYS_POLL_H") endif(HAVE_SYS_POLL_H) -curl_check_c_source_runs("return poll((void *)0, 0, 10 /*ms*/)" HAVE_POLL_FINE) +check_c_source_runs(" + #ifdef HAVE_SYS_POLL_H + # include + #endif + int main(void) { + return poll((void *)0, 0, 10 /*ms*/); + }" HAVE_POLL_FINE) set(HAVE_SIG_ATOMIC_T 1) -set(EXTRA_DEFINES) -set(HEADER_INCLUDES) +set(CMAKE_REQUIRED_FLAGS) if(HAVE_SIGNAL_H) - set(HEADER_INCLUDES "signal.h") + set(CMAKE_REQUIRED_FLAGS "-DHAVE_SIGNAL_H") set(CMAKE_EXTRA_INCLUDE_FILES "signal.h") endif(HAVE_SIGNAL_H) check_type_size("sig_atomic_t" SIZEOF_SIG_ATOMIC_T) if(HAVE_SIZEOF_SIG_ATOMIC_T) - curl_check_c_source_compiles("static volatile sig_atomic_t dummy = 0" HAVE_SIG_ATOMIC_T_NOT_VOLATILE) + check_c_source_compiles(" + #ifdef HAVE_SIGNAL_H + # include + #endif + int main(void) { + static volatile sig_atomic_t dummy = 0; + (void)dummy; + return 0; + }" HAVE_SIG_ATOMIC_T_NOT_VOLATILE) if(NOT HAVE_SIG_ATOMIC_T_NOT_VOLATILE) set(HAVE_SIG_ATOMIC_T_VOLATILE 1) endif(NOT HAVE_SIG_ATOMIC_T_NOT_VOLATILE) endif(HAVE_SIZEOF_SIG_ATOMIC_T) -set(CHECK_TYPE_SIZE_PREINCLUDE - "#undef inline") - if(HAVE_WINDOWS_H) - set(CHECK_TYPE_SIZE_PREINCLUDE "${CHECK_TYPE_SIZE_PREINCLUDE} - #ifndef WIN32_LEAN_AND_MEAN - #define WIN32_LEAN_AND_MEAN - #endif - #include ") - if(HAVE_WINSOCK2_H) - set(CHECK_TYPE_SIZE_PREINCLUDE "${CHECK_TYPE_SIZE_PREINCLUDE}\n#include ") - endif(HAVE_WINSOCK2_H) -else(HAVE_WINDOWS_H) + set(CMAKE_EXTRA_INCLUDE_FILES winsock2.h) +else() + set(CMAKE_EXTRA_INCLUDE_FILES) if(HAVE_SYS_SOCKET_H) - set(CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES} - "sys/socket.h") + set(CMAKE_EXTRA_INCLUDE_FILES sys/socket.h) endif(HAVE_SYS_SOCKET_H) - if(HAVE_NETINET_IN_H) - set(CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES} - "netinet/in.h") - endif(HAVE_NETINET_IN_H) - if(HAVE_ARPA_INET_H) - set(CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES} - "arpa/inet.h") - endif(HAVE_ARPA_INET_H) -endif(HAVE_WINDOWS_H) +endif() check_type_size("struct sockaddr_storage" SIZEOF_STRUCT_SOCKADDR_STORAGE) if(HAVE_SIZEOF_STRUCT_SOCKADDR_STORAGE) diff --git a/CMake/Platforms/WindowsCache.cmake b/CMake/Platforms/WindowsCache.cmake index 3533a54..6fc2991 100644 --- a/CMake/Platforms/WindowsCache.cmake +++ b/CMake/Platforms/WindowsCache.cmake @@ -5,6 +5,7 @@ if(NOT UNIX) set(HAVE_LIBSOCKET 0) set(NOT_NEED_LIBNSL 0) set(HAVE_LIBNSL 0) + set(HAVE_GETHOSTNAME 1) set(HAVE_LIBZ 0) set(HAVE_LIBCRYPTO 0) @@ -14,7 +15,6 @@ if(NOT UNIX) set(HAVE_ARPA_INET_H 0) set(HAVE_DLFCN_H 0) set(HAVE_FCNTL_H 1) - set(HAVE_FEATURES_H 0) set(HAVE_INTTYPES_H 0) set(HAVE_IO_H 1) set(HAVE_MALLOC_H 1) diff --git a/CMakeLists.txt b/CMakeLists.txt index 845c330..9a42cc7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ # | (__| |_| | _ <| |___ # \___|\___/|_| \_\_____| # -# Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. +# Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms @@ -48,27 +48,17 @@ project( CURL C ) message(WARNING "the curl cmake build system is poorly maintained. Be aware") file (READ ${CURL_SOURCE_DIR}/include/curl/curlver.h CURL_VERSION_H_CONTENTS) -string (REGEX MATCH "LIBCURL_VERSION_MAJOR[ \t]+([0-9]+)" - LIBCURL_VERSION_MJ ${CURL_VERSION_H_CONTENTS}) -string (REGEX MATCH "([0-9]+)" - LIBCURL_VERSION_MJ ${LIBCURL_VERSION_MJ}) -string (REGEX MATCH - "LIBCURL_VERSION_MINOR[ \t]+([0-9]+)" - LIBCURL_VERSION_MI ${CURL_VERSION_H_CONTENTS}) -string (REGEX MATCH "([0-9]+)" LIBCURL_VERSION_MI ${LIBCURL_VERSION_MI}) -string (REGEX MATCH - "LIBCURL_VERSION_PATCH[ \t]+([0-9]+)" - LIBCURL_VERSION_PT ${CURL_VERSION_H_CONTENTS}) -string (REGEX MATCH "([0-9]+)" LIBCURL_VERSION_PT ${LIBCURL_VERSION_PT}) -set (CURL_MAJOR_VERSION ${LIBCURL_VERSION_MJ}) -set (CURL_MINOR_VERSION ${LIBCURL_VERSION_MI}) -set (CURL_PATCH_VERSION ${LIBCURL_VERSION_PT}) +string (REGEX MATCH "#define LIBCURL_VERSION \"[^\"]*" + CURL_VERSION ${CURL_VERSION_H_CONTENTS}) +string (REGEX REPLACE "[^\"]+\"" "" CURL_VERSION ${CURL_VERSION}) +string (REGEX MATCH "#define LIBCURL_VERSION_NUM 0x[0-9a-fA-F]+" + CURL_VERSION_NUM ${CURL_VERSION_H_CONTENTS}) +string (REGEX REPLACE "[^0]+0x" "" CURL_VERSION_NUM ${CURL_VERSION_NUM}) include_regular_expression("^.*$") # Sukender: Is it necessary? # Setup package meta-data # SET(PACKAGE "curl") -set(CURL_VERSION ${CURL_MAJOR_VERSION}.${CURL_MINOR_VERSION}.${CURL_PATCH_VERSION}) message(STATUS "curl version=[${CURL_VERSION}]") # SET(PACKAGE_TARNAME "curl") # SET(PACKAGE_NAME "curl") @@ -84,12 +74,35 @@ include_directories( ${CURL_SOURCE_DIR}/include ) option(BUILD_CURL_EXE "Set to ON to build cURL executable." ON) option(BUILD_CURL_TESTS "Set to ON to build cURL tests." ON) option(CURL_STATICLIB "Set to ON to build libcurl with static linking." OFF) -option(CURL_USE_ARES "Set to ON to enable c-ares support" OFF) +option(ENABLE_ARES "Set to ON to enable c-ares support" OFF) +option(ENABLE_THREADED_RESOLVER "Set to ON to enable POSIX threaded DNS lookup" OFF) + +option(ENABLE_DEBUG "Set to ON to enable curl debug features" OFF) +option(ENABLE_CURLDEBUG "Set to ON to build with TrackMemory feature enabled" OFF) + +if (ENABLE_DEBUG) + # DEBUGBUILD will be defined only for Debug builds + if(NOT CMAKE_VERSION VERSION_LESS 3.0) + set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$:DEBUGBUILD>) + else() + set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG DEBUGBUILD) + endif() + set(ENABLE_CURLDEBUG ON) +endif() + +if (ENABLE_CURLDEBUG) + set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS CURLDEBUG) +endif() + # initialize CURL_LIBS set(CURL_LIBS "") -if(CURL_USE_ARES) - set(USE_ARES ${CURL_USE_ARES}) +if(ENABLE_THREADED_RESOLVER AND ENABLE_ARES) + message(FATAL_ERROR "Options ENABLE_THREADED_RESOLVER and ENABLE_ARES are mutually exclusive") +endif() + +if(ENABLE_ARES) + set(USE_ARES 1) find_package(CARES REQUIRED) list(APPEND CURL_LIBS ${CARES_LIBRARY} ) set(CURL_LIBS ${CURL_LIBS} ${CARES_LIBRARY}) @@ -171,9 +184,52 @@ option(CURL_DISABLE_VERBOSE_STRINGS "to disable verbose strings" OFF) mark_as_advanced(CURL_DISABLE_VERBOSE_STRINGS) option(DISABLED_THREADSAFE "Set to explicitly specify we don't want to use thread-safe functions" OFF) mark_as_advanced(DISABLED_THREADSAFE) -option(ENABLE_IPV6 "Define if you want to enable IPv6 support" OFF) +option(ENABLE_IPV6 "Define if you want to enable IPv6 support" ON) mark_as_advanced(ENABLE_IPV6) +if(ENABLE_IPV6) + include(CheckStructHasMember) + check_struct_has_member("struct sockaddr_in6" sin6_addr "netinet/in.h" + HAVE_SOCKADDR_IN6_SIN6_ADDR) + check_struct_has_member("struct sockaddr_in6" sin6_scope_id "netinet/in.h" + HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID) + if(NOT HAVE_SOCKADDR_IN6_SIN6_ADDR) + message(WARNING "struct sockaddr_in6 not available, disabling IPv6 support") + # Force the feature off as this name is used as guard macro... + set(ENABLE_IPV6 OFF + CACHE BOOL "Define if you want to enable IPv6 support" FORCE) + endif() +endif() +option(ENABLE_MANUAL "to provide the built-in manual" ON) +unset(USE_MANUAL CACHE) # TODO: cache NROFF/NROFF_MANOPT/USE_MANUAL vars? +if(ENABLE_MANUAL) + find_program(NROFF NAMES gnroff nroff) + if(NROFF) + # Need a way to write to stdin, this will do + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/nroff-input.txt" "test") + # Tests for a valid nroff option to generate a manpage + foreach(_MANOPT "-man" "-mandoc") + execute_process(COMMAND "${NROFF}" ${_MANOPT} + OUTPUT_VARIABLE NROFF_MANOPT_OUTPUT + INPUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/nroff-input.txt" + ERROR_QUIET) + # Save the option if it was valid + if(NROFF_MANOPT_OUTPUT) + message("Found *nroff option: -- ${_MANOPT}") + set(NROFF_MANOPT ${_MANOPT}) + set(USE_MANUAL 1) + break() + endif() + endforeach() + # No need for the temporary file + file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/nroff-input.txt") + if(NOT USE_MANUAL) + message(WARNING "Found no *nroff option to get plaintext from man pages") + endif() + else() + message(WARNING "Found no *nroff program") + endif() +endif() # We need ansi c-flags, especially on HP set(CMAKE_C_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_C_FLAGS}") @@ -200,9 +256,22 @@ include (CheckCSourceCompiles) # On windows preload settings if(WIN32) + set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_WINSOCKAPI_") include(${CMAKE_CURRENT_SOURCE_DIR}/CMake/Platforms/WindowsCache.cmake) endif(WIN32) +if(ENABLE_THREADED_RESOLVER) + check_include_file_concat("pthread.h" HAVE_PTHREAD_H) + if(HAVE_PTHREAD_H) + set(CMAKE_THREAD_PREFER_PTHREAD 1) + find_package(Threads) + if(CMAKE_USE_PTHREADS_INIT) + set(CURL_LIBS ${CURL_LIBS} ${CMAKE_THREAD_LIBS_INIT}) + set(USE_THREADS_POSIX 1) + endif() + endif() +endif() + # Check for all needed libraries check_library_exists_concat("dl" dlopen HAVE_LIBDL) check_library_exists_concat("socket" connect HAVE_LIBSOCKET) @@ -219,19 +288,49 @@ if(NOT NOT_NEED_LIBNSL) check_library_exists_concat("nsl" gethostbyname HAVE_LIBNSL) endif(NOT NOT_NEED_LIBNSL) +check_function_exists(gethostname HAVE_GETHOSTNAME) + if(WIN32) check_library_exists_concat("ws2_32" getch HAVE_LIBWS2_32) check_library_exists_concat("winmm" getch HAVE_LIBWINMM) endif() +option(CMAKE_USE_OPENSSL "Use OpenSSL code. Experimental" ON) +mark_as_advanced(CMAKE_USE_OPENSSL) + +set(USE_OPENSSL OFF) +set(HAVE_LIBCRYPTO OFF) +set(HAVE_LIBSSL OFF) + +if(CMAKE_USE_OPENSSL) + find_package(OpenSSL) + if(OPENSSL_FOUND) + list(APPEND CURL_LIBS ${OPENSSL_LIBRARIES}) + set(USE_OPENSSL ON) + set(HAVE_LIBCRYPTO ON) + set(HAVE_LIBSSL ON) + include_directories(${OPENSSL_INCLUDE_DIR}) + set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) + check_include_file("openssl/crypto.h" HAVE_OPENSSL_CRYPTO_H) + check_include_file("openssl/engine.h" HAVE_OPENSSL_ENGINE_H) + check_include_file("openssl/err.h" HAVE_OPENSSL_ERR_H) + check_include_file("openssl/pem.h" HAVE_OPENSSL_PEM_H) + check_include_file("openssl/pkcs12.h" HAVE_OPENSSL_PKCS12_H) + check_include_file("openssl/rsa.h" HAVE_OPENSSL_RSA_H) + check_include_file("openssl/ssl.h" HAVE_OPENSSL_SSL_H) + check_include_file("openssl/x509.h" HAVE_OPENSSL_X509_H) + check_include_file("openssl/rand.h" HAVE_OPENSSL_RAND_H) + endif() +endif() + if(NOT CURL_DISABLE_LDAP) if(WIN32) - option(CURL_LDAP_WIN "Use Windows LDAP implementation" ON) - if(CURL_LDAP_WIN) + option(USE_WIN32_LDAP "Use Windows LDAP implementation" ON) + if(USE_WIN32_LDAP) check_library_exists("wldap32" cldap_open "" HAVE_WLDAP32) if(NOT HAVE_WLDAP32) - set(CURL_LDAP_WIN OFF) + set(USE_WIN32_LDAP OFF) endif() endif() endif() @@ -241,13 +340,14 @@ if(NOT CURL_DISABLE_LDAP) set(CMAKE_LDAP_LIB "ldap" CACHE STRING "Name or full path to ldap library") set(CMAKE_LBER_LIB "lber" CACHE STRING "Name or full path to lber library") - if(CMAKE_USE_OPENLDAP AND CURL_LDAP_WIN) - message(FATAL_ERROR "Cannot use CURL_LDAP_WIN and CMAKE_USE_OPENLDAP at the same time") + if(CMAKE_USE_OPENLDAP AND USE_WIN32_LDAP) + message(FATAL_ERROR "Cannot use USE_WIN32_LDAP and CMAKE_USE_OPENLDAP at the same time") endif() # Now that we know, we're not using windows LDAP... - if(NOT CURL_LDAP_WIN) + if(NOT USE_WIN32_LDAP) # Check for LDAP + set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_LIBRARIES}) check_library_exists_concat(${CMAKE_LDAP_LIB} ldap_init HAVE_LIBLDAP) check_library_exists_concat(${CMAKE_LBER_LIB} ber_init HAVE_LIBLBER) else() @@ -301,8 +401,8 @@ if(NOT CURL_DISABLE_LDAP) return 0; }" ) - set(CMAKE_REQUIRED_DEFINITIONS "-DLDAP_DEPRECATED=1" "-DWIN32_LEAN_AND_MEAN") - set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_LDAP_LIB}) + set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -DLDAP_DEPRECATED=1") + list(APPEND CMAKE_REQUIRED_LIBRARIES ${CMAKE_LDAP_LIB}) if(HAVE_LIBLBER) list(APPEND CMAKE_REQUIRED_LIBRARIES ${CMAKE_LBER_LIB}) endif() @@ -336,9 +436,6 @@ check_library_exists_concat("idn" idna_to_ascii_lz HAVE_LIBIDN) # Check for symbol dlopen (same as HAVE_LIBDL) check_library_exists("${CURL_LIBS}" dlopen "" HAVE_DLOPEN) -# For other tests to use the same libraries -set(CMAKE_REQUIRED_LIBRARIES ${CURL_LIBS}) - option(CURL_ZLIB "Set to ON to enable building cURL with zlib support." ON) set(HAVE_LIBZ OFF) set(HAVE_ZLIB_H OFF) @@ -350,39 +447,10 @@ if(CURL_ZLIB) set(HAVE_ZLIB ON) set(HAVE_LIBZ ON) list(APPEND CURL_LIBS ${ZLIB_LIBRARIES}) + include_directories(${ZLIB_INCLUDE_DIRS}) endif() endif() -option(CMAKE_USE_OPENSSL "Use OpenSSL code. Experimental" ON) -mark_as_advanced(CMAKE_USE_OPENSSL) - -set(USE_SSLEAY OFF) -set(USE_OPENSSL OFF) -set(HAVE_LIBCRYPTO OFF) -set(HAVE_LIBSSL OFF) - -if(CMAKE_USE_OPENSSL) - find_package(OpenSSL) - if(OPENSSL_FOUND) - list(APPEND CURL_LIBS ${OPENSSL_LIBRARIES}) - set(USE_SSLEAY ON) - set(USE_OPENSSL ON) - set(HAVE_LIBCRYPTO ON) - set(HAVE_LIBSSL ON) - include_directories(${OPENSSL_INCLUDE_DIR}) - set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) - check_include_file_concat("openssl/crypto.h" HAVE_OPENSSL_CRYPTO_H) - check_include_file_concat("openssl/engine.h" HAVE_OPENSSL_ENGINE_H) - check_include_file_concat("openssl/err.h" HAVE_OPENSSL_ERR_H) - check_include_file_concat("openssl/pem.h" HAVE_OPENSSL_PEM_H) - check_include_file_concat("openssl/pkcs12.h" HAVE_OPENSSL_PKCS12_H) - check_include_file_concat("openssl/rsa.h" HAVE_OPENSSL_RSA_H) - check_include_file_concat("openssl/ssl.h" HAVE_OPENSSL_SSL_H) - check_include_file_concat("openssl/x509.h" HAVE_OPENSSL_X509_H) - check_include_file_concat("openssl/rand.h" HAVE_OPENSSL_RAND_H) - endif(OPENSSL_FOUND) -endif(CMAKE_USE_OPENSSL) - #libSSH2 option(CMAKE_USE_LIBSSH2 "Use libSSH2" ON) mark_as_advanced(CMAKE_USE_LIBSSH2) @@ -396,6 +464,7 @@ if(CMAKE_USE_LIBSSH2) list(APPEND CURL_LIBS ${LIBSSH2_LIBRARY}) set(CMAKE_REQUIRED_LIBRARIES ${LIBSSH2_LIBRARY}) set(CMAKE_REQUIRED_INCLUDES "${LIBSSH2_INCLUDE_DIR}") + include_directories("${LIBSSH2_INCLUDE_DIR}") set(HAVE_LIBSSH2 ON) set(USE_LIBSSH2 ON) @@ -416,20 +485,82 @@ if(CMAKE_USE_LIBSSH2) endif(LIBSSH2_FOUND) endif(CMAKE_USE_LIBSSH2) -# If we have features.h, then do the _BSD_SOURCE magic -check_include_file("features.h" HAVE_FEATURES_H) +option(CMAKE_USE_GSSAPI "Use GSSAPI implementation (right now only Heimdal is supported with CMake build)" OFF) +mark_as_advanced(CMAKE_USE_GSSAPI) + +if(CMAKE_USE_GSSAPI) + find_package(GSS) + + set(HAVE_GSSAPI ${GSS_FOUND}) + if(GSS_FOUND) + + message(STATUS "Found ${GSS_FLAVOUR} GSSAPI version: \"${GSS_VERSION}\"") + + set(CMAKE_REQUIRED_INCLUDES ${GSS_INCLUDE_DIR}) + check_include_file_concat("gssapi/gssapi.h" HAVE_GSSAPI_GSSAPI_H) + check_include_file_concat("gssapi/gssapi_generic.h" HAVE_GSSAPI_GSSAPI_GENERIC_H) + check_include_file_concat("gssapi/gssapi_krb5.h" HAVE_GSSAPI_GSSAPI_KRB5_H) + + if(GSS_FLAVOUR STREQUAL "Heimdal") + set(HAVE_GSSHEIMDAL ON) + else() # MIT + set(HAVE_GSSMIT ON) + set(_INCLUDE_LIST "") + if(HAVE_GSSAPI_GSSAPI_H) + list(APPEND _INCLUDE_LIST "gssapi/gssapi.h") + endif() + if(HAVE_GSSAPI_GSSAPI_GENERIC_H) + list(APPEND _INCLUDE_LIST "gssapi/gssapi_generic.h") + endif() + if(HAVE_GSSAPI_GSSAPI_KRB5_H) + list(APPEND _INCLUDE_LIST "gssapi/gssapi_krb5.h") + endif() + + string(REPLACE ";" " " _COMPILER_FLAGS_STR "${GSS_COMPILER_FLAGS}") + string(REPLACE ";" " " _LINKER_FLAGS_STR "${GSS_LINKER_FLAGS}") + + foreach(_dir ${GSS_LINK_DIRECTORIES}) + set(_LINKER_FLAGS_STR "${_LINKER_FLAGS_STR} -L\"${_dir}\"") + endforeach() + + set(CMAKE_REQUIRED_FLAGS "${_COMPILER_FLAGS_STR} ${_LINKER_FLAGS_STR}") + set(CMAKE_REQUIRED_LIBRARIES ${GSS_LIBRARIES}) + check_symbol_exists("GSS_C_NT_HOSTBASED_SERVICE" ${_INCLUDE_LIST} HAVE_GSS_C_NT_HOSTBASED_SERVICE) + if(NOT HAVE_GSS_C_NT_HOSTBASED_SERVICE) + set(HAVE_OLD_GSSMIT ON) + endif() + + endif() + + include_directories(${GSS_INCLUDE_DIR}) + link_directories(${GSS_LINK_DIRECTORIES}) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GSS_COMPILER_FLAGS}") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${GSS_LINKER_FLAGS}") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GSS_LINKER_FLAGS}") + list(APPEND CURL_LIBS ${GSS_LIBRARIES}) + + else() + message(WARNING "GSSAPI support has been requested but no supporting libraries found. Skipping.") + endif() +endif() + +option(ENABLE_UNIX_SOCKETS "Define if you want Unix domain sockets support" ON) +if(ENABLE_UNIX_SOCKETS) + include(CheckStructHasMember) + check_struct_has_member("struct sockaddr_un" sun_path "sys/un.h" USE_UNIX_SOCKETS) +else() + unset(USE_UNIX_SOCKETS CACHE) +endif() # Check for header files if(NOT UNIX) - check_include_file_concat("ws2tcpip.h" HAVE_WS2TCPIP_H) - check_include_file_concat("winsock2.h" HAVE_WINSOCK2_H) -endif(NOT UNIX) -check_include_file_concat("stdio.h" HAVE_STDIO_H) -if(NOT UNIX) check_include_file_concat("windows.h" HAVE_WINDOWS_H) check_include_file_concat("winsock.h" HAVE_WINSOCK_H) + check_include_file_concat("ws2tcpip.h" HAVE_WS2TCPIP_H) + check_include_file_concat("winsock2.h" HAVE_WINSOCK2_H) endif(NOT UNIX) +check_include_file_concat("stdio.h" HAVE_STDIO_H) check_include_file_concat("inttypes.h" HAVE_INTTYPES_H) check_include_file_concat("sys/filio.h" HAVE_SYS_FILIO_H) check_include_file_concat("sys/ioctl.h" HAVE_SYS_IOCTL_H) @@ -454,9 +585,6 @@ check_include_file_concat("des.h" HAVE_DES_H) check_include_file_concat("err.h" HAVE_ERR_H) check_include_file_concat("errno.h" HAVE_ERRNO_H) check_include_file_concat("fcntl.h" HAVE_FCNTL_H) -check_include_file_concat("gssapi/gssapi.h" HAVE_GSSAPI_GSSAPI_H) -check_include_file_concat("gssapi/gssapi_generic.h" HAVE_GSSAPI_GSSAPI_GENERIC_H) -check_include_file_concat("gssapi/gssapi_krb5.h" HAVE_GSSAPI_GSSAPI_KRB5_H) check_include_file_concat("idn-free.h" HAVE_IDN_FREE_H) check_include_file_concat("ifaddrs.h" HAVE_IFADDRS_H) check_include_file_concat("io.h" HAVE_IO_H) @@ -576,6 +704,12 @@ find_file(RANDOM_FILE urandom /dev) mark_as_advanced(RANDOM_FILE) # Check for some functions that are used +if(HAVE_LIBWS2_32) + set(CMAKE_REQUIRED_LIBRARIES ws2_32) +elseif(HAVE_LIBSOCKET) + set(CMAKE_REQUIRED_LIBRARIES socket) +endif() + check_symbol_exists(basename "${CURL_INCLUDES}" HAVE_BASENAME) check_symbol_exists(socket "${CURL_INCLUDES}" HAVE_SOCKET) check_symbol_exists(poll "${CURL_INCLUDES}" HAVE_POLL) @@ -618,7 +752,6 @@ if(CMAKE_USE_OPENSSL) HAVE_CRYPTO_CLEANUP_ALL_EX_DATA) if(HAVE_LIBCRYPTO AND HAVE_LIBSSL) set(USE_OPENSSL 1) - set(USE_SSLEAY 1) endif(HAVE_LIBCRYPTO AND HAVE_LIBSSL) endif(CMAKE_USE_OPENSSL) check_symbol_exists(gmtime_r "${CURL_INCLUDES}" HAVE_GMTIME_R) @@ -639,6 +772,7 @@ check_symbol_exists(strerror_r "${CURL_INCLUDES}" HAVE_STRERROR_R) check_symbol_exists(siginterrupt "${CURL_INCLUDES}" HAVE_SIGINTERRUPT) check_symbol_exists(perror "${CURL_INCLUDES}" HAVE_PERROR) check_symbol_exists(fork "${CURL_INCLUDES}" HAVE_FORK) +check_symbol_exists(getaddrinfo "${CURL_INCLUDES}" HAVE_GETADDRINFO) check_symbol_exists(freeaddrinfo "${CURL_INCLUDES}" HAVE_FREEADDRINFO) check_symbol_exists(freeifaddrs "${CURL_INCLUDES}" HAVE_FREEIFADDRS) check_symbol_exists(pipe "${CURL_INCLUDES}" HAVE_PIPE) @@ -677,12 +811,7 @@ if(NOT HAVE_STRICMP) set(HAVE_LDAP_URL_PARSE 1) endif(NOT HAVE_STRICMP) - - # Do curl specific tests -if(HAVE_LIBWS2_32) - set(CMAKE_REQUIRED_LIBRARIES ws2_32) -endif() foreach(CURL_TEST HAVE_FCNTL_O_NONBLOCK HAVE_IOCTLSOCKET @@ -869,24 +998,6 @@ if(MSVC) add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE) endif(MSVC) -# Sets up the dependencies (zlib, OpenSSL, etc.) of a cURL subproject according to options. -# TODO This is far to be complete! -function(SETUP_CURL_DEPENDENCIES TARGET_NAME) - if(CURL_ZLIB AND ZLIB_FOUND) - include_directories(${ZLIB_INCLUDE_DIR}) - endif() - - if(CMAKE_USE_OPENSSL AND OPENSSL_FOUND) - include_directories(${OPENSSL_INCLUDE_DIR}) - endif() - - if(CMAKE_USE_LIBSSH2 AND LIBSSH2_FOUND) - include_directories(${LIBSSH2_INCLUDE_DIR}) - endif() - - target_link_libraries(${TARGET_NAME} ${CURL_LIBS}) -endfunction() - # Ugly (but functional) way to include "Makefile.inc" by transforming it (= regenerate it). function(TRANSFORM_MAKEFILE_INC INPUT_FILE OUTPUT_FILE) file(READ ${INPUT_FILE} MAKEFILE_INC_TEXT) @@ -911,6 +1022,133 @@ if(BUILD_CURL_TESTS) add_subdirectory(tests) endif() +# TODO support GNUTLS, NSS, POLARSSL, AXTLS, CYASSL, WINSSL, DARWINSSL +if(USE_OPENSSL) + set(SSL_ENABLED 1) +endif() + +# Helper to populate a list (_items) with a label when conditions (the remaining +# args) are satisfied +function(_add_if label) + # TODO need to disable policy CMP0054 (CMake 3.1) to allow this indirection + if(${ARGN}) + set(_items ${_items} "${label}" PARENT_SCOPE) + endif() +endfunction() + +# Clear list and try to detect available features +set(_items) +_add_if("SSL" SSL_ENABLED) +_add_if("IPv6" ENABLE_IPV6) +_add_if("unix-sockets" USE_UNIX_SOCKETS) +_add_if("libz" HAVE_LIBZ) +_add_if("AsynchDNS" USE_ARES OR USE_THREADS_POSIX) +_add_if("IDN" HAVE_LIBIDN) +# TODO SSP1 (WinSSL) check is missing +_add_if("SSPI" USE_WINDOWS_SSPI) +_add_if("GSS-API" HAVE_GSSAPI) +# TODO SSP1 missing for SPNEGO +_add_if("SPNEGO" NOT CURL_DISABLE_CRYPTO_AUTH AND + (HAVE_GSSAPI OR USE_WINDOWS_SSPI)) +_add_if("Kerberos" NOT CURL_DISABLE_CRYPTO_AUTH AND + (HAVE_GSSAPI OR USE_WINDOWS_SSPI)) +# NTLM support requires crypto function adaptions from various SSL libs +# TODO alternative SSL libs tests for SSP1, GNUTLS, NSS, DARWINSSL +if(NOT CURL_DISABLE_CRYPTO_AUTH AND (USE_OPENSSL OR + USE_WINDOWS_SSPI OR GNUTLS_ENABLED OR NSS_ENABLED OR DARWINSSL_ENABLED)) + _add_if("NTLM" 1) + # TODO missing option (autoconf: --enable-ntlm-wb) + _add_if("NTLM_WB" NOT CURL_DISABLE_HTTP AND NTLM_WB_ENABLED) +endif() +# TODO missing option (--enable-tls-srp), depends on GNUTLS_SRP/OPENSSL_SRP +_add_if("TLS-SRP" USE_TLS_SRP) +# TODO option --with-nghttp2 tests for nghttp2 lib and nghttp2/nghttp2.h header +_add_if("HTTP2" USE_NGHTTP2) +string(REPLACE ";" " " SUPPORT_FEATURES "${_items}") +message(STATUS "Enabled features: ${SUPPORT_FEATURES}") + +# Clear list and try to detect available protocols +set(_items) +_add_if("HTTP" NOT CURL_DISABLE_HTTP) +_add_if("HTTPS" NOT CURL_DISABLE_HTTP AND SSL_ENABLED) +_add_if("FTP" NOT CURL_DISABLE_FTP) +_add_if("FTPS" NOT CURL_DISABLE_FTP AND SSL_ENABLED) +_add_if("FILE" NOT CURL_DISABLE_FILE) +_add_if("TELNET" NOT CURL_DISABLE_TELNET) +_add_if("LDAP" NOT CURL_DISABLE_LDAP) +# CURL_DISABLE_LDAP implies CURL_DISABLE_LDAPS +# TODO check HAVE_LDAP_SSL (in autoconf this is enabled with --enable-ldaps) +_add_if("LDAPS" NOT CURL_DISABLE_LDAPS AND + ((USE_OPENLDAP AND SSL_ENABLED) OR + (NOT USE_OPENLDAP AND HAVE_LDAP_SSL))) +_add_if("DICT" NOT CURL_DISABLE_DICT) +_add_if("TFTP" NOT CURL_DISABLE_TFTP) +_add_if("GOPHER" NOT CURL_DISABLE_GOPHER) +_add_if("POP3" NOT CURL_DISABLE_POP3) +_add_if("POP3S" NOT CURL_DISABLE_POP3 AND SSL_ENABLED) +_add_if("IMAP" NOT CURL_DISABLE_IMAP) +_add_if("IMAPS" NOT CURL_DISABLE_IMAP AND SSL_ENABLED) +_add_if("SMTP" NOT CURL_DISABLE_SMTP) +_add_if("SMTPS" NOT CURL_DISABLE_SMTP AND SSL_ENABLED) +_add_if("SCP" USE_LIBSSH2) +_add_if("SFTP" USE_LIBSSH2) +_add_if("RTSP" NOT CURL_DISABLE_RTSP) +_add_if("RTMP" USE_LIBRTMP) +list(SORT _items) +string(REPLACE ";" " " SUPPORT_PROTOCOLS "${_items}") +message(STATUS "Enabled protocols: ${SUPPORT_PROTOCOLS}") + +# curl-config needs the following options to be set. +set(CC "${CMAKE_C_COMPILER}") +# TODO probably put a -D... options here? +set(CONFIGURE_OPTIONS "") +# TODO when to set "-DCURL_STATICLIB" for CPPFLAG_CURL_STATICLIB? +set(CPPFLAG_CURL_STATICLIB "") +# TODO need to set this (see CURL_CHECK_CA_BUNDLE in acinclude.m4) +set(CURL_CA_BUNDLE "") +set(CURLVERSION "${CURL_VERSION}") +set(ENABLE_SHARED "yes") +if(CURL_STATICLIB) + # Broken: LIBCURL_LIBS below; .a lib is not built + message(WARNING "Static linking is broken!") + set(ENABLE_STATIC "no") +else() + set(ENABLE_STATIC "no") +endif() +set(exec_prefix "\${prefix}") +set(includedir "\${prefix}/include") +set(LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS}") +set(LIBCURL_LIBS "") +set(libdir "${CMAKE_INSTALL_PREFIX}/lib") +# TODO CURL_LIBS also contains absolute paths which don't work with static -l... +foreach(_lib ${CMAKE_C_IMPLICIT_LINK_LIBRARIES} ${CURL_LIBS}) + set(LIBCURL_LIBS "${LIBCURL_LIBS} -l${_lib}") +endforeach() +# "a" (Linux) or "lib" (Windows) +string(REPLACE "." "" libext "${CMAKE_STATIC_LIBRARY_SUFFIX}") +set(prefix "${CMAKE_INSTALL_PREFIX}") +# Set this to "yes" to append all libraries on which -lcurl is dependent +set(REQUIRE_LIB_DEPS "no") +# SUPPORT_FEATURES +# SUPPORT_PROTOCOLS +set(VERSIONNUM "${CURL_VERSION_NUM}") + +# Finally generate a "curl-config" matching this config +configure_file("${CURL_SOURCE_DIR}/curl-config.in" + "${CURL_BINARY_DIR}/curl-config" @ONLY) +install(FILES "${CMAKE_BINARY_DIR}/curl-config" + DESTINATION bin + PERMISSIONS + OWNER_READ OWNER_WRITE OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE) + +# Finally generate a pkg-config file matching this config +configure_file("${CURL_SOURCE_DIR}/libcurl.pc.in" + "${CURL_BINARY_DIR}/libcurl.pc" @ONLY) +install(FILES "${CMAKE_BINARY_DIR}/libcurl.pc" + DESTINATION lib/pkgconfig) + # This needs to be run very last so other parts of the scripts can take advantage of this. if(NOT CURL_CONFIG_HAS_BEEN_RUN_BEFORE) set(CURL_CONFIG_HAS_BEEN_RUN_BEFORE 1 CACHE INTERNAL "Flag to track whether this is the first time running CMake or if CMake has been configured before") diff --git a/COPYING b/COPYING index dd990b6..6b5d59f 100644 --- a/COPYING +++ b/COPYING @@ -1,6 +1,6 @@ COPYRIGHT AND PERMISSION NOTICE -Copyright (c) 1996 - 2014, Daniel Stenberg, . +Copyright (c) 1996 - 2015, Daniel Stenberg, . All rights reserved. diff --git a/include/curl/curl.h b/include/curl/curl.h index d40b2db..64f9261 100644 --- a/include/curl/curl.h +++ b/include/curl/curl.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -521,6 +521,9 @@ typedef enum { CURLE_CHUNK_FAILED, /* 88 - chunk callback reported error */ CURLE_NO_CONNECTION_AVAILABLE, /* 89 - No connection available, the session will be queued */ + CURLE_SSL_PINNEDPUBKEYNOTMATCH, /* 90 - specified pinned public key did not + match */ + CURLE_SSL_INVALIDCERTSTATUS, /* 91 - invalid certificate status */ CURL_LAST /* never use! */ } CURLcode; @@ -722,6 +725,10 @@ typedef enum { servers, a user can this way allow the vulnerability back. */ #define CURLSSLOPT_ALLOW_BEAST (1<<0) +/* - NO_REVOKE tells libcurl to disable certificate revocation checks for those + SSL backends where such behavior is present. */ +#define CURLSSLOPT_NO_REVOKE (1<<1) + #ifndef CURL_NO_OLDIES /* define this to test if your app builds with all the obsolete stuff removed! */ @@ -803,6 +810,8 @@ typedef enum { #define CURLPROTO_RTMPS (1<<23) #define CURLPROTO_RTMPTS (1<<24) #define CURLPROTO_GOPHER (1<<25) +#define CURLPROTO_SMB (1<<26) +#define CURLPROTO_SMBS (1<<27) #define CURLPROTO_ALL (~0) /* enable everything */ /* long may be 32 or 64 bits, but we should never depend on anything else @@ -841,7 +850,7 @@ typedef enum { CINIT(WRITEDATA, OBJECTPOINT, 1), /* The full URL to get/put */ - CINIT(URL, OBJECTPOINT, 2), + CINIT(URL, OBJECTPOINT, 2), /* Port number to connect to, if other than default. */ CINIT(PORT, LONG, 3), @@ -985,7 +994,7 @@ typedef enum { CINIT(HEADER, LONG, 42), /* throw the header out too */ CINIT(NOPROGRESS, LONG, 43), /* shut off the progress meter */ CINIT(NOBODY, LONG, 44), /* use HEAD to get http document */ - CINIT(FAILONERROR, LONG, 45), /* no output on http error codes >= 300 */ + CINIT(FAILONERROR, LONG, 45), /* no output on http error codes >= 400 */ CINIT(UPLOAD, LONG, 46), /* this is an upload */ CINIT(POST, LONG, 47), /* HTTP POST method */ CINIT(DIRLISTONLY, LONG, 48), /* bare names when listing directories */ @@ -1611,6 +1620,31 @@ typedef enum { /* Pass in a bitmask of "header options" */ CINIT(HEADEROPT, LONG, 229), + /* The public key in DER form used to validate the peer public key + this option is used only if SSL_VERIFYPEER is true */ + CINIT(PINNEDPUBLICKEY, OBJECTPOINT, 230), + + /* Path to Unix domain socket */ + CINIT(UNIX_SOCKET_PATH, OBJECTPOINT, 231), + + /* Set if we should verify the certificate status. */ + CINIT(SSL_VERIFYSTATUS, LONG, 232), + + /* Set if we should enable TLS false start. */ + CINIT(SSL_FALSESTART, LONG, 233), + + /* Do not squash dot-dot sequences */ + CINIT(PATH_AS_IS, LONG, 234), + + /* Proxy Service Name */ + CINIT(PROXY_SERVICE_NAME, OBJECTPOINT, 235), + + /* Service Name */ + CINIT(SERVICE_NAME, OBJECTPOINT, 236), + + /* Wait/don't wait for pipe/mutex to clarify */ + CINIT(PIPEWAIT, LONG, 237), + CURLOPT_LASTENTRY /* the last unused */ } CURLoption; @@ -1647,8 +1681,8 @@ typedef enum { option might be handy to force libcurl to use a specific IP version. */ #define CURL_IPRESOLVE_WHATEVER 0 /* default, resolves addresses to all IP versions that your system allows */ -#define CURL_IPRESOLVE_V4 1 /* resolve to ipv4 addresses */ -#define CURL_IPRESOLVE_V6 2 /* resolve to ipv6 addresses */ +#define CURL_IPRESOLVE_V4 1 /* resolve to IPv4 addresses */ +#define CURL_IPRESOLVE_V6 2 /* resolve to IPv6 addresses */ /* three convenient "aliases" that follow the name scheme better */ #define CURLOPT_RTSPHEADER CURLOPT_HTTPHEADER @@ -1665,6 +1699,11 @@ enum { CURL_HTTP_VERSION_LAST /* *ILLEGAL* http version */ }; +/* Convenience definition simple because the name of the version is HTTP/2 and + not 2.0. The 2_0 version of the enum name was set while the version was + still planned to be 2.0 and we stick to it for compatibility. */ +#define CURL_HTTP_VERSION_2 CURL_HTTP_VERSION_2_0 + /* * Public API enums for RTSP requests */ @@ -2028,7 +2067,7 @@ typedef enum { CURLSSLBACKEND_OPENSSL = 1, CURLSSLBACKEND_GNUTLS = 2, CURLSSLBACKEND_NSS = 3, - CURLSSLBACKEND_QSOSSL = 4, + CURLSSLBACKEND_OBSOLETE4 = 4, /* Was QSOSSL. */ CURLSSLBACKEND_GSKIT = 5, CURLSSLBACKEND_POLARSSL = 6, CURLSSLBACKEND_CYASSL = 7, @@ -2235,25 +2274,30 @@ typedef struct { } curl_version_info_data; -#define CURL_VERSION_IPV6 (1<<0) /* IPv6-enabled */ -#define CURL_VERSION_KERBEROS4 (1<<1) /* kerberos auth is supported */ -#define CURL_VERSION_SSL (1<<2) /* SSL options are present */ -#define CURL_VERSION_LIBZ (1<<3) /* libz features are present */ -#define CURL_VERSION_NTLM (1<<4) /* NTLM auth is supported */ -#define CURL_VERSION_GSSNEGOTIATE (1<<5) /* Negotiate auth support - (deprecated) */ -#define CURL_VERSION_DEBUG (1<<6) /* built with debug capabilities */ -#define CURL_VERSION_ASYNCHDNS (1<<7) /* asynchronous dns resolves */ -#define CURL_VERSION_SPNEGO (1<<8) /* SPNEGO auth is supported */ -#define CURL_VERSION_LARGEFILE (1<<9) /* supports files bigger than 2GB */ -#define CURL_VERSION_IDN (1<<10) /* International Domain Names support */ -#define CURL_VERSION_SSPI (1<<11) /* SSPI is supported */ -#define CURL_VERSION_CONV (1<<12) /* character conversions supported */ -#define CURL_VERSION_CURLDEBUG (1<<13) /* debug memory tracking supported */ -#define CURL_VERSION_TLSAUTH_SRP (1<<14) /* TLS-SRP auth is supported */ -#define CURL_VERSION_NTLM_WB (1<<15) /* NTLM delegating to winbind helper */ -#define CURL_VERSION_HTTP2 (1<<16) /* HTTP2 support built-in */ -#define CURL_VERSION_GSSAPI (1<<17) /* GSS-API is supported */ +#define CURL_VERSION_IPV6 (1<<0) /* IPv6-enabled */ +#define CURL_VERSION_KERBEROS4 (1<<1) /* Kerberos V4 auth is supported + (deprecated) */ +#define CURL_VERSION_SSL (1<<2) /* SSL options are present */ +#define CURL_VERSION_LIBZ (1<<3) /* libz features are present */ +#define CURL_VERSION_NTLM (1<<4) /* NTLM auth is supported */ +#define CURL_VERSION_GSSNEGOTIATE (1<<5) /* Negotiate auth is supported + (deprecated) */ +#define CURL_VERSION_DEBUG (1<<6) /* Built with debug capabilities */ +#define CURL_VERSION_ASYNCHDNS (1<<7) /* Asynchronous DNS resolves */ +#define CURL_VERSION_SPNEGO (1<<8) /* SPNEGO auth is supported */ +#define CURL_VERSION_LARGEFILE (1<<9) /* Supports files larger than 2GB */ +#define CURL_VERSION_IDN (1<<10) /* Internationized Domain Names are + supported */ +#define CURL_VERSION_SSPI (1<<11) /* Built against Windows SSPI */ +#define CURL_VERSION_CONV (1<<12) /* Character conversions supported */ +#define CURL_VERSION_CURLDEBUG (1<<13) /* Debug memory tracking supported */ +#define CURL_VERSION_TLSAUTH_SRP (1<<14) /* TLS-SRP auth is supported */ +#define CURL_VERSION_NTLM_WB (1<<15) /* NTLM delegation to winbind helper + is suported */ +#define CURL_VERSION_HTTP2 (1<<16) /* HTTP2 support built-in */ +#define CURL_VERSION_GSSAPI (1<<17) /* Built against a GSS-API library */ +#define CURL_VERSION_KERBEROS5 (1<<18) /* Kerberos V5 auth is supported */ +#define CURL_VERSION_UNIX_SOCKETS (1<<19) /* Unix domain sockets support */ /* * NAME curl_version_info() diff --git a/include/curl/curlver.h b/include/curl/curlver.h index ac23158..f73d7de 100644 --- a/include/curl/curlver.h +++ b/include/curl/curlver.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -26,16 +26,16 @@ a script at release-time. This was made its own header file in 7.11.2 */ /* This is the global package copyright */ -#define LIBCURL_COPYRIGHT "1996 - 2014 Daniel Stenberg, ." +#define LIBCURL_COPYRIGHT "1996 - 2015 Daniel Stenberg, ." /* This is the version number of the libcurl package from which this header file origins: */ -#define LIBCURL_VERSION "7.38.0-DEV" +#define LIBCURL_VERSION "7.44.0-DEV" /* The numeric version number is also available "in parts" by using these defines: */ #define LIBCURL_VERSION_MAJOR 7 -#define LIBCURL_VERSION_MINOR 38 +#define LIBCURL_VERSION_MINOR 44 #define LIBCURL_VERSION_PATCH 0 /* This is the numeric version of the libcurl version number, meant for easier @@ -52,8 +52,12 @@ This 6-digit (24 bits) hexadecimal number does not show pre-release number, and it is always a greater number in a more recent release. It makes comparisons with greater than and less than work. + + Note: This define is the full hex number and _does not_ use the + CURL_VERSION_BITS() macro since curl's own configure script greps for it + and needs it to contain the full number. */ -#define LIBCURL_VERSION_NUM 0x072600 +#define LIBCURL_VERSION_NUM 0x072C00 /* * This is the date and time when the full source package was created. The @@ -66,4 +70,8 @@ */ #define LIBCURL_TIMESTAMP "DEV" +#define CURL_VERSION_BITS(x,y,z) ((x)<<16|(y)<<8|z) +#define CURL_AT_LEAST_VERSION(x,y,z) \ + (LIBCURL_VERSION_NUM >= CURL_VERSION_BITS(x, y, z)) + #endif /* __CURL_CURLVER_H */ diff --git a/include/curl/mprintf.h b/include/curl/mprintf.h index cc9e7f5..c6b0d76 100644 --- a/include/curl/mprintf.h +++ b/include/curl/mprintf.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2013, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -57,15 +57,8 @@ CURL_EXTERN char *curl_mvaprintf(const char *format, va_list args); # undef vaprintf # define printf curl_mprintf # define fprintf curl_mfprintf -#ifdef CURLDEBUG -/* When built with CURLDEBUG we define away the sprintf functions since we - don't want internal code to be using them */ -# define sprintf sprintf_was_used -# define vsprintf vsprintf_was_used -#else # define sprintf curl_msprintf # define vsprintf curl_mvsprintf -#endif # define snprintf curl_msnprintf # define vprintf curl_mvprintf # define vfprintf curl_mvfprintf diff --git a/include/curl/multi.h b/include/curl/multi.h index 3c4acb0..36e2e94 100644 --- a/include/curl/multi.h +++ b/include/curl/multi.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2013, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -74,6 +74,11 @@ typedef enum { curl_multi_perform() and CURLM_CALL_MULTI_PERFORM */ #define CURLM_CALL_MULTI_SOCKET CURLM_CALL_MULTI_PERFORM +/* bitmask bits for CURLMOPT_PIPELINING */ +#define CURLPIPE_NOTHING 0L +#define CURLPIPE_HTTP1 1L +#define CURLPIPE_MULTIPLEX 2L + typedef enum { CURLMSG_NONE, /* first, not used */ CURLMSG_DONE, /* This easy handle has completed. 'result' contains @@ -365,6 +370,12 @@ typedef enum { /* maximum number of open connections in total */ CINIT(MAX_TOTAL_CONNECTIONS, LONG, 13), + /* This is the server push callback function pointer */ + CINIT(PUSHFUNCTION, FUNCTIONPOINT, 14), + + /* This is the argument passed to the server push callback */ + CINIT(PUSHDATA, OBJECTPOINT, 15), + CURLMOPT_LASTENTRY /* the last unused */ } CURLMoption; @@ -392,6 +403,31 @@ CURL_EXTERN CURLMcode curl_multi_setopt(CURLM *multi_handle, CURL_EXTERN CURLMcode curl_multi_assign(CURLM *multi_handle, curl_socket_t sockfd, void *sockp); + +/* + * Name: curl_push_callback + * + * Desc: This callback gets called when a new stream is being pushed by the + * server. It approves or denies the new stream. + * + * Returns: CURL_PUSH_OK or CURL_PUSH_DENY. + */ +#define CURL_PUSH_OK 0 +#define CURL_PUSH_DENY 1 + +struct curl_pushheaders; /* forward declaration only */ + +CURL_EXTERN char *curl_pushheader_bynum(struct curl_pushheaders *h, + size_t num); +CURL_EXTERN char *curl_pushheader_byname(struct curl_pushheaders *h, + const char *name); + +typedef int (*curl_push_callback)(CURL *parent, + CURL *easy, + size_t num_headers, + struct curl_pushheaders *headers, + void *userp); + #ifdef __cplusplus } /* end of extern "C" */ #endif diff --git a/include/curl/typecheck-gcc.h b/include/curl/typecheck-gcc.h index 69d41a2..13fb0fa 100644 --- a/include/curl/typecheck-gcc.h +++ b/include/curl/typecheck-gcc.h @@ -270,6 +270,8 @@ _CURL_WARNING(_curl_easy_getinfo_err_curl_slist, (option) == CURLOPT_DNS_LOCAL_IP4 || \ (option) == CURLOPT_DNS_LOCAL_IP6 || \ (option) == CURLOPT_LOGIN_OPTIONS || \ + (option) == CURLOPT_PROXY_SERVICE_NAME || \ + (option) == CURLOPT_SERVICE_NAME || \ 0) /* evaluates to true if option takes a curl_write_callback argument */ diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index b2bcf09..49a3409 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -48,25 +48,6 @@ endif() # ) # ENDIF(NOT HAVE_STRTOLL AND NOT HAVE__STRTOI64) -if(HAVE_FEATURES_H) - set_source_files_properties( - cookie.c - easy.c - formdata.c - getenv.c - nonblock.c - hash.c - http.c - if2ip.c - mprintf.c - multi.c - sendf.c - telnet.c - transfer.c - url.c - COMPILE_FLAGS -D_BSD_SOURCE) -endif(HAVE_FEATURES_H) - # The rest of the build @@ -76,7 +57,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../include) include_directories(${CMAKE_CURRENT_BINARY_DIR}/..) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) include_directories(${CMAKE_CURRENT_BINARY_DIR}) -if(CURL_USE_ARES) +if(USE_ARES) include_directories(${CARES_INCLUDE_DIR}) endif() @@ -106,8 +87,6 @@ endif() set_target_properties(${LIB_NAME} PROPERTIES COMPILE_DEFINITIONS BUILDING_LIBCURL) -setup_curl_dependencies(${LIB_NAME}) - # Remove the "lib" prefix since the library is already named "libcurl". set_target_properties(${LIB_NAME} PROPERTIES PREFIX "") set_target_properties(${LIB_NAME} PROPERTIES IMPORT_PREFIX "") @@ -119,4 +98,7 @@ if(WIN32) endif() endif() -install(TARGETS ${LIB_NAME} DESTINATION lib) +install(TARGETS ${LIB_NAME} + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + RUNTIME DESTINATION bin) diff --git a/lib/Makefile.inc b/lib/Makefile.inc index 462d72a..d444a6b 100644 --- a/lib/Makefile.inc +++ b/lib/Makefile.inc @@ -5,7 +5,7 @@ # | (__| |_| | _ <| |___ # \___|\___/|_| \_\_____| # -# Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. +# Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms @@ -20,50 +20,52 @@ # ########################################################################### -LIB_VTLS_CFILES = vtls/openssl.c vtls/gtls.c vtls/vtls.c vtls/nss.c \ - vtls/qssl.c vtls/polarssl.c vtls/polarssl_threadlock.c vtls/axtls.c \ - vtls/cyassl.c vtls/curl_schannel.c vtls/curl_darwinssl.c vtls/gskit.c +LIB_VTLS_CFILES = vtls/openssl.c vtls/gtls.c vtls/vtls.c vtls/nss.c \ + vtls/polarssl.c vtls/polarssl_threadlock.c vtls/axtls.c \ + vtls/cyassl.c vtls/schannel.c vtls/darwinssl.c vtls/gskit.c -LIB_VTLS_HFILES = vtls/qssl.h vtls/openssl.h vtls/vtls.h vtls/gtls.h \ - vtls/nssg.h vtls/polarssl.h vtls/polarssl_threadlock.h vtls/axtls.h \ - vtls/cyassl.h vtls/curl_schannel.h vtls/curl_darwinssl.h vtls/gskit.h +LIB_VTLS_HFILES = vtls/openssl.h vtls/vtls.h vtls/gtls.h \ + vtls/nssg.h vtls/polarssl.h vtls/polarssl_threadlock.h vtls/axtls.h \ + vtls/cyassl.h vtls/schannel.h vtls/darwinssl.h vtls/gskit.h -LIB_CFILES = file.c timeval.c base64.c hostip.c progress.c formdata.c \ - cookie.c http.c sendf.c ftp.c url.c dict.c if2ip.c speedcheck.c \ - ldap.c version.c getenv.c escape.c mprintf.c telnet.c netrc.c \ - getinfo.c transfer.c strequal.c easy.c security.c curl_fnmatch.c \ - fileinfo.c ftplistparser.c wildcard.c krb5.c memdebug.c http_chunks.c \ - strtok.c connect.c llist.c hash.c multi.c content_encoding.c share.c \ - http_digest.c md4.c md5.c http_negotiate.c inet_pton.c strtoofft.c \ - strerror.c amigaos.c hostasyn.c hostip4.c hostip6.c hostsyn.c \ - inet_ntop.c parsedate.c select.c tftp.c splay.c strdup.c socks.c \ - ssh.c rawstr.c curl_addrinfo.c socks_gssapi.c socks_sspi.c \ - curl_sspi.c slist.c nonblock.c curl_memrchr.c imap.c pop3.c smtp.c \ - pingpong.c rtsp.c curl_threads.c warnless.c hmac.c curl_rtmp.c \ - openldap.c curl_gethostname.c gopher.c idn_win32.c \ - http_negotiate_sspi.c http_proxy.c non-ascii.c asyn-ares.c \ - asyn-thread.c curl_gssapi.c curl_ntlm.c curl_ntlm_wb.c \ - curl_ntlm_core.c curl_ntlm_msgs.c curl_sasl.c curl_multibyte.c \ - hostcheck.c bundles.c conncache.c pipeline.c dotdot.c x509asn1.c \ - http2.c curl_sasl_sspi.c +LIB_CFILES = file.c timeval.c base64.c hostip.c progress.c formdata.c \ + cookie.c http.c sendf.c ftp.c url.c dict.c if2ip.c speedcheck.c \ + ldap.c version.c getenv.c escape.c mprintf.c telnet.c netrc.c \ + getinfo.c transfer.c strequal.c easy.c security.c curl_fnmatch.c \ + fileinfo.c ftplistparser.c wildcard.c krb5.c memdebug.c http_chunks.c \ + strtok.c connect.c llist.c hash.c multi.c content_encoding.c share.c \ + http_digest.c md4.c md5.c http_negotiate.c inet_pton.c strtoofft.c \ + strerror.c amigaos.c hostasyn.c hostip4.c hostip6.c hostsyn.c \ + inet_ntop.c parsedate.c select.c tftp.c splay.c strdup.c socks.c \ + ssh.c rawstr.c curl_addrinfo.c socks_gssapi.c socks_sspi.c \ + curl_sspi.c slist.c nonblock.c curl_memrchr.c imap.c pop3.c smtp.c \ + pingpong.c rtsp.c curl_threads.c warnless.c hmac.c curl_rtmp.c \ + openldap.c curl_gethostname.c gopher.c idn_win32.c \ + http_negotiate_sspi.c http_proxy.c non-ascii.c asyn-ares.c \ + asyn-thread.c curl_gssapi.c curl_ntlm.c curl_ntlm_wb.c \ + curl_ntlm_core.c curl_ntlm_msgs.c curl_sasl.c curl_multibyte.c \ + hostcheck.c conncache.c pipeline.c dotdot.c x509asn1.c \ + http2.c curl_sasl_sspi.c smb.c curl_sasl_gssapi.c curl_endian.c \ + curl_des.c -LIB_HFILES = arpa_telnet.h netrc.h file.h timeval.h hostip.h progress.h \ - formdata.h cookie.h http.h sendf.h ftp.h url.h dict.h if2ip.h \ - speedcheck.h urldata.h curl_ldap.h escape.h telnet.h getinfo.h \ - strequal.h curl_sec.h memdebug.h http_chunks.h curl_fnmatch.h \ - wildcard.h fileinfo.h ftplistparser.h strtok.h connect.h llist.h \ - hash.h content_encoding.h share.h curl_md4.h curl_md5.h http_digest.h \ - http_negotiate.h inet_pton.h amigaos.h strtoofft.h strerror.h \ - inet_ntop.h curlx.h curl_memory.h curl_setup.h transfer.h select.h \ - easyif.h multiif.h parsedate.h tftp.h sockaddr.h splay.h strdup.h \ - socks.h ssh.h curl_base64.h rawstr.h curl_addrinfo.h curl_sspi.h \ - slist.h nonblock.h curl_memrchr.h imap.h pop3.h smtp.h pingpong.h \ - rtsp.h curl_threads.h warnless.h curl_hmac.h curl_rtmp.h \ - curl_gethostname.h gopher.h http_proxy.h non-ascii.h asyn.h \ - curl_ntlm.h curl_gssapi.h curl_ntlm_wb.h curl_ntlm_core.h \ - curl_ntlm_msgs.h curl_sasl.h curl_multibyte.h hostcheck.h bundles.h \ - conncache.h curl_setup_once.h multihandle.h setup-vms.h pipeline.h \ - dotdot.h x509asn1.h http2.h sigpipe.h +LIB_HFILES = arpa_telnet.h netrc.h file.h timeval.h hostip.h progress.h \ + formdata.h cookie.h http.h sendf.h ftp.h url.h dict.h if2ip.h \ + speedcheck.h urldata.h curl_ldap.h escape.h telnet.h getinfo.h \ + strequal.h curl_sec.h memdebug.h http_chunks.h curl_fnmatch.h \ + wildcard.h fileinfo.h ftplistparser.h strtok.h connect.h llist.h \ + hash.h content_encoding.h share.h curl_md4.h curl_md5.h http_digest.h \ + http_negotiate.h inet_pton.h amigaos.h strtoofft.h strerror.h \ + inet_ntop.h curlx.h curl_memory.h curl_setup.h transfer.h select.h \ + easyif.h multiif.h parsedate.h tftp.h sockaddr.h splay.h strdup.h \ + socks.h ssh.h curl_base64.h rawstr.h curl_addrinfo.h curl_sspi.h \ + slist.h nonblock.h curl_memrchr.h imap.h pop3.h smtp.h pingpong.h \ + rtsp.h curl_threads.h warnless.h curl_hmac.h curl_rtmp.h \ + curl_gethostname.h gopher.h http_proxy.h non-ascii.h asyn.h \ + curl_ntlm.h curl_gssapi.h curl_ntlm_wb.h curl_ntlm_core.h \ + curl_ntlm_msgs.h curl_sasl.h curl_multibyte.h hostcheck.h \ + conncache.h curl_setup_once.h multihandle.h setup-vms.h pipeline.h \ + dotdot.h x509asn1.h http2.h sigpipe.h smb.h curl_endian.h curl_des.h \ + curl_printf.h LIB_RCFILES = libcurl.rc diff --git a/lib/amigaos.c b/lib/amigaos.c index 34f95e9..e3ff85f 100644 --- a/lib/amigaos.c +++ b/lib/amigaos.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -71,7 +71,7 @@ bool Curl_amiga_init() } #ifdef __libnix__ -ADD2EXIT(Curl_amiga_cleanup,-50); +ADD2EXIT(Curl_amiga_cleanup, -50); #endif #endif /* __AMIGA__ && ! __ixemul__ */ diff --git a/lib/asyn-ares.c b/lib/asyn-ares.c index 01a9c9b..98ecdfd 100644 --- a/lib/asyn-ares.c +++ b/lib/asyn-ares.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -68,9 +68,7 @@ #include "connect.h" #include "select.h" #include "progress.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include +#include "curl_printf.h" # if defined(CURL_STATICLIB) && !defined(CARES_STATICLIB) && \ (defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__)) @@ -166,7 +164,7 @@ void Curl_resolver_cleanup(void *resolver) int Curl_resolver_duphandle(void **to, void *from) { /* Clone the ares channel for the new handle */ - if(ARES_SUCCESS != ares_dup((ares_channel*)to,(ares_channel)from)) + if(ARES_SUCCESS != ares_dup((ares_channel*)to, (ares_channel)from)) return CURLE_FAILED_INIT; return CURLE_OK; } @@ -178,7 +176,7 @@ static void destroy_async_data (struct Curl_async *async); */ void Curl_resolver_cancel(struct connectdata *conn) { - if(conn && conn->data && conn->data->state.resolver) + if(conn->data && conn->data->state.resolver) ares_cancel((ares_channel)conn->data->state.resolver); destroy_async_data(&conn->async); } @@ -188,8 +186,7 @@ void Curl_resolver_cancel(struct connectdata *conn) */ static void destroy_async_data (struct Curl_async *async) { - if(async->hostname) - free(async->hostname); + free(async->hostname); if(async->os_specific) { struct ResolverResults *res = (struct ResolverResults *)async->os_specific; @@ -315,7 +312,7 @@ CURLcode Curl_resolver_is_resolved(struct connectdata *conn, struct SessionHandle *data = conn->data; struct ResolverResults *res = (struct ResolverResults *) conn->async.os_specific; - CURLcode rc = CURLE_OK; + CURLcode result = CURLE_OK; *dns = NULL; @@ -329,7 +326,7 @@ CURLcode Curl_resolver_is_resolved(struct connectdata *conn, if(!conn->async.dns) { failf(data, "Could not resolve: %s (%s)", conn->async.hostname, ares_strerror(conn->async.status)); - rc = conn->bits.proxy?CURLE_COULDNT_RESOLVE_PROXY: + result = conn->bits.proxy?CURLE_COULDNT_RESOLVE_PROXY: CURLE_COULDNT_RESOLVE_HOST; } else @@ -338,7 +335,7 @@ CURLcode Curl_resolver_is_resolved(struct connectdata *conn, destroy_async_data(&conn->async); } - return rc; + return result; } /* @@ -355,7 +352,7 @@ CURLcode Curl_resolver_is_resolved(struct connectdata *conn, CURLcode Curl_resolver_wait_resolv(struct connectdata *conn, struct Curl_dns_entry **entry) { - CURLcode rc=CURLE_OK; + CURLcode result = CURLE_OK; struct SessionHandle *data = conn->data; long timeout; struct timeval now = Curl_tvnow(); @@ -388,13 +385,13 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn, timeout_ms = 1000; waitperform(conn, timeout_ms); - Curl_resolver_is_resolved(conn,&temp_entry); + Curl_resolver_is_resolved(conn, &temp_entry); if(conn->async.done) break; if(Curl_pgrsUpdate(conn)) { - rc = CURLE_ABORTED_BY_CALLBACK; + result = CURLE_ABORTED_BY_CALLBACK; timeout = -1; /* trigger the cancel below */ } else { @@ -403,6 +400,7 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn, timeout -= timediff?timediff:1; /* always deduct at least 1 */ now = now2; /* for next loop */ } + if(timeout < 0) { /* our timeout, so we cancel the ares operation */ ares_cancel((ares_channel)data->state.resolver); @@ -412,18 +410,17 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn, /* Operation complete, if the lookup was successful we now have the entry in the cache. */ - if(entry) *entry = conn->async.dns; - if(rc) + if(result) /* close the connection, since we can't return failure here without cleaning up this connection properly. TODO: remove this action from here, it is not a name resolver decision. */ connclose(conn, "c-ares resolve failed"); - return rc; + return result; } /* Connects results to the list */ @@ -536,15 +533,15 @@ Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn, bufp = strdup(hostname); if(bufp) { struct ResolverResults *res = NULL; - Curl_safefree(conn->async.hostname); + free(conn->async.hostname); conn->async.hostname = bufp; conn->async.port = port; conn->async.done = FALSE; /* not done */ conn->async.status = 0; /* clear */ conn->async.dns = NULL; /* clear */ - res = calloc(sizeof(struct ResolverResults),1); + res = calloc(sizeof(struct ResolverResults), 1); if(!res) { - Curl_safefree(conn->async.hostname); + free(conn->async.hostname); conn->async.hostname = NULL; return NULL; } diff --git a/lib/asyn-thread.c b/lib/asyn-thread.c index e4ad32b..bd47d5a 100644 --- a/lib/asyn-thread.c +++ b/lib/asyn-thread.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -69,11 +69,9 @@ #include "inet_ntop.h" #include "curl_threads.h" #include "connect.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include - +#include "curl_printf.h" #include "curl_memory.h" + /* The last #include file should be: */ #include "memdebug.h" @@ -192,13 +190,12 @@ void destroy_thread_sync_data(struct thread_sync_data * tsd) free(tsd->mtx); } - if(tsd->hostname) - free(tsd->hostname); + free(tsd->hostname); if(tsd->res) Curl_freeaddrinfo(tsd->res); - memset(tsd,0,sizeof(*tsd)); + memset(tsd, 0, sizeof(*tsd)); } /* Initialize resolver thread synchronization data */ @@ -366,9 +363,7 @@ static void destroy_async_data (struct Curl_async *async) } async->os_specific = NULL; - if(async->hostname) - free(async->hostname); - + free(async->hostname); async->hostname = NULL; } @@ -398,7 +393,7 @@ static bool init_resolve_thread (struct connectdata *conn, if(!init_thread_sync_data(td, hostname, port, hints)) goto err_exit; - Curl_safefree(conn->async.hostname); + free(conn->async.hostname); conn->async.hostname = strdup(hostname); if(!conn->async.hostname) goto err_exit; @@ -434,19 +429,21 @@ static bool init_resolve_thread (struct connectdata *conn, static CURLcode resolver_error(struct connectdata *conn) { const char *host_or_proxy; - CURLcode rc; + CURLcode result; + if(conn->bits.httpproxy) { host_or_proxy = "proxy"; - rc = CURLE_COULDNT_RESOLVE_PROXY; + result = CURLE_COULDNT_RESOLVE_PROXY; } else { host_or_proxy = "host"; - rc = CURLE_COULDNT_RESOLVE_HOST; + result = CURLE_COULDNT_RESOLVE_HOST; } failf(conn->data, "Could not resolve %s: %s", host_or_proxy, conn->async.hostname); - return rc; + + return result; } /* @@ -463,13 +460,13 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn, struct Curl_dns_entry **entry) { struct thread_data *td = (struct thread_data*) conn->async.os_specific; - CURLcode rc = CURLE_OK; + CURLcode result = CURLE_OK; DEBUGASSERT(conn && td); /* wait for the thread to resolve the name */ if(Curl_thread_join(&td->thread_hnd)) - rc = getaddrinfo_complete(conn); + result = getaddrinfo_complete(conn); else DEBUGASSERT(0); @@ -480,14 +477,14 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn, if(!conn->async.dns) /* a name was not resolved, report error */ - rc = resolver_error(conn); + result = resolver_error(conn); destroy_async_data(&conn->async); if(!conn->async.dns) connclose(conn, "asynch resolve failed"); - return (rc); + return result; } /* @@ -517,9 +514,9 @@ CURLcode Curl_resolver_is_resolved(struct connectdata *conn, getaddrinfo_complete(conn); if(!conn->async.dns) { - CURLcode rc = resolver_error(conn); + CURLcode result = resolver_error(conn); destroy_async_data(&conn->async); - return rc; + return result; } destroy_async_data(&conn->async); *entry = conn->async.dns; @@ -541,7 +538,7 @@ CURLcode Curl_resolver_is_resolved(struct connectdata *conn, td->poll_interval = 250; td->interval_end = elapsed + td->poll_interval; - Curl_expire_latest(conn->data, td->poll_interval); + Curl_expire(conn->data, td->poll_interval); } return CURLE_OK; @@ -633,7 +630,7 @@ Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn, } if((pf != PF_INET) && !Curl_ipv6works()) - /* the stack seems to be a non-ipv6 one */ + /* The stack seems to be a non-IPv6 one */ pf = PF_INET; #endif /* CURLRES_IPV6 */ diff --git a/lib/base64.c b/lib/base64.c index bd9ba35..6b87eed 100644 --- a/lib/base64.c +++ b/lib/base64.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -23,17 +23,14 @@ /* Base64 encoding/decoding */ #include "curl_setup.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include - +#include "curl_printf.h" #include "urldata.h" /* for the SessionHandle definition */ #include "warnless.h" #include "curl_base64.h" -#include "curl_memory.h" #include "non-ascii.h" -/* include memdebug.h last */ +/* The last #include files should be: */ +#include "curl_memory.h" #include "memdebug.h" /* ---- Base64 Encoding/Decoding Table --- */ @@ -49,10 +46,10 @@ static size_t decodeQuantum(unsigned char *dest, const char *src) { size_t padding = 0; const char *s, *p; - unsigned long i, v, x = 0; + unsigned long i, x = 0; for(i = 0, s = src; i < 4; i++, s++) { - v = 0; + unsigned long v = 0; if(*s == '=') { x = (x << 6); @@ -107,7 +104,6 @@ CURLcode Curl_base64_decode(const char *src, size_t length = 0; size_t padding = 0; size_t i; - size_t result; size_t numQuantums; size_t rawlen = 0; unsigned char *pos; @@ -151,9 +147,9 @@ CURLcode Curl_base64_decode(const char *src, /* Decode the quantums */ for(i = 0; i < numQuantums; i++) { - result = decodeQuantum(pos, src); + size_t result = decodeQuantum(pos, src); if(!result) { - Curl_safefree(newstr); + free(newstr); return CURLE_BAD_CONTENT_ENCODING; } @@ -256,8 +252,7 @@ static CURLcode base64_encode(const char *table64, *output = '\0'; *outptr = base64data; /* return pointer to new data, allocated memory */ - if(convbuf) - free(convbuf); + free(convbuf); *outlen = strlen(base64data); /* return the length of the new data */ diff --git a/lib/bundles.c b/lib/bundles.c deleted file mode 100644 index aadf026..0000000 --- a/lib/bundles.c +++ /dev/null @@ -1,110 +0,0 @@ -/*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - * Copyright (C) 2012, Linus Nielsen Feltzing, - * Copyright (C) 2012, Daniel Stenberg, , et al. - * - * This software is licensed as described in the file COPYING, which - * you should have received as part of this distribution. The terms - * are also available at http://curl.haxx.se/docs/copyright.html. - * - * You may opt to use, copy, modify, merge, publish, distribute and/or sell - * copies of the Software, and permit persons to whom the Software is - * furnished to do so, under the terms of the COPYING file. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ***************************************************************************/ - -#include "curl_setup.h" - -#include - -#include "urldata.h" -#include "url.h" -#include "progress.h" -#include "multiif.h" -#include "bundles.h" -#include "sendf.h" -#include "rawstr.h" - -#include "curl_memory.h" -/* The last #include file should be: */ -#include "memdebug.h" - -static void conn_llist_dtor(void *user, void *element) -{ - struct connectdata *data = element; - (void)user; - - data->bundle = NULL; -} - -CURLcode Curl_bundle_create(struct SessionHandle *data, - struct connectbundle **cb_ptr) -{ - (void)data; - DEBUGASSERT(*cb_ptr == NULL); - *cb_ptr = malloc(sizeof(struct connectbundle)); - if(!*cb_ptr) - return CURLE_OUT_OF_MEMORY; - - (*cb_ptr)->num_connections = 0; - (*cb_ptr)->server_supports_pipelining = FALSE; - - (*cb_ptr)->conn_list = Curl_llist_alloc((curl_llist_dtor) conn_llist_dtor); - if(!(*cb_ptr)->conn_list) { - Curl_safefree(*cb_ptr); - return CURLE_OUT_OF_MEMORY; - } - return CURLE_OK; -} - -void Curl_bundle_destroy(struct connectbundle *cb_ptr) -{ - if(!cb_ptr) - return; - - if(cb_ptr->conn_list) { - Curl_llist_destroy(cb_ptr->conn_list, NULL); - cb_ptr->conn_list = NULL; - } - Curl_safefree(cb_ptr); -} - -/* Add a connection to a bundle */ -CURLcode Curl_bundle_add_conn(struct connectbundle *cb_ptr, - struct connectdata *conn) -{ - if(!Curl_llist_insert_next(cb_ptr->conn_list, cb_ptr->conn_list->tail, conn)) - return CURLE_OUT_OF_MEMORY; - - conn->bundle = cb_ptr; - - cb_ptr->num_connections++; - return CURLE_OK; -} - -/* Remove a connection from a bundle */ -int Curl_bundle_remove_conn(struct connectbundle *cb_ptr, - struct connectdata *conn) -{ - struct curl_llist_element *curr; - - curr = cb_ptr->conn_list->head; - while(curr) { - if(curr->ptr == conn) { - Curl_llist_remove(cb_ptr->conn_list, curr, NULL); - cb_ptr->num_connections--; - conn->bundle = NULL; - return 1; /* we removed a handle */ - } - curr = curr->next; - } - return 0; -} diff --git a/lib/bundles.h b/lib/bundles.h deleted file mode 100644 index 3816c40..0000000 --- a/lib/bundles.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef HEADER_CURL_BUNDLES_H -#define HEADER_CURL_BUNDLES_H -/*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - * Copyright (C) 2012, Linus Nielsen Feltzing, - * - * This software is licensed as described in the file COPYING, which - * you should have received as part of this distribution. The terms - * are also available at http://curl.haxx.se/docs/copyright.html. - * - * You may opt to use, copy, modify, merge, publish, distribute and/or sell - * copies of the Software, and permit persons to whom the Software is - * furnished to do so, under the terms of the COPYING file. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ***************************************************************************/ - -struct connectbundle { - bool server_supports_pipelining; /* TRUE if server supports pipelining, - set after first response */ - size_t num_connections; /* Number of connections in the bundle */ - struct curl_llist *conn_list; /* The connectdata members of the bundle */ -}; - -CURLcode Curl_bundle_create(struct SessionHandle *data, - struct connectbundle **cb_ptr); - -void Curl_bundle_destroy(struct connectbundle *cb_ptr); - -CURLcode Curl_bundle_add_conn(struct connectbundle *cb_ptr, - struct connectdata *conn); - -int Curl_bundle_remove_conn(struct connectbundle *cb_ptr, - struct connectdata *conn); - - -#endif /* HEADER_CURL_BUNDLES_H */ - diff --git a/lib/conncache.c b/lib/conncache.c index 5bbcf3c..c712ed7 100644 --- a/lib/conncache.c +++ b/lib/conncache.c @@ -6,7 +6,7 @@ * \___|\___/|_| \_\_____| * * Copyright (C) 2012, Linus Nielsen Feltzing, - * Copyright (C) 2012 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 2012 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -31,66 +31,134 @@ #include "multiif.h" #include "sendf.h" #include "rawstr.h" -#include "bundles.h" #include "conncache.h" +#include "curl_printf.h" #include "curl_memory.h" /* The last #include file should be: */ #include "memdebug.h" -static void free_bundle_hash_entry(void *freethis) +static void conn_llist_dtor(void *user, void *element) { - struct connectbundle *b = (struct connectbundle *) freethis; + struct connectdata *data = element; + (void)user; - Curl_bundle_destroy(b); + data->bundle = NULL; } -struct conncache *Curl_conncache_init(int size) +static CURLcode bundle_create(struct SessionHandle *data, + struct connectbundle **cb_ptr) { - struct conncache *connc; - - connc = calloc(1, sizeof(struct conncache)); - if(!connc) - return NULL; + (void)data; + DEBUGASSERT(*cb_ptr == NULL); + *cb_ptr = malloc(sizeof(struct connectbundle)); + if(!*cb_ptr) + return CURLE_OUT_OF_MEMORY; + + (*cb_ptr)->num_connections = 0; + (*cb_ptr)->multiuse = BUNDLE_UNKNOWN; + + (*cb_ptr)->conn_list = Curl_llist_alloc((curl_llist_dtor) conn_llist_dtor); + if(!(*cb_ptr)->conn_list) { + Curl_safefree(*cb_ptr); + return CURLE_OUT_OF_MEMORY; + } + return CURLE_OK; +} - connc->hash = Curl_hash_alloc(size, Curl_hash_str, - Curl_str_key_compare, free_bundle_hash_entry); +static void bundle_destroy(struct connectbundle *cb_ptr) +{ + if(!cb_ptr) + return; - if(!connc->hash) { - free(connc); - return NULL; + if(cb_ptr->conn_list) { + Curl_llist_destroy(cb_ptr->conn_list, NULL); + cb_ptr->conn_list = NULL; } + free(cb_ptr); +} + +/* Add a connection to a bundle */ +static CURLcode bundle_add_conn(struct connectbundle *cb_ptr, + struct connectdata *conn) +{ + if(!Curl_llist_insert_next(cb_ptr->conn_list, cb_ptr->conn_list->tail, conn)) + return CURLE_OUT_OF_MEMORY; + + conn->bundle = cb_ptr; - return connc; + cb_ptr->num_connections++; + return CURLE_OK; } -void Curl_conncache_destroy(struct conncache *connc) +/* Remove a connection from a bundle */ +static int bundle_remove_conn(struct connectbundle *cb_ptr, + struct connectdata *conn) { - if(connc) { - Curl_hash_destroy(connc->hash); - connc->hash = NULL; - free(connc); + struct curl_llist_element *curr; + + curr = cb_ptr->conn_list->head; + while(curr) { + if(curr->ptr == conn) { + Curl_llist_remove(cb_ptr->conn_list, curr, NULL); + cb_ptr->num_connections--; + conn->bundle = NULL; + return 1; /* we removed a handle */ + } + curr = curr->next; } + return 0; } -struct connectbundle *Curl_conncache_find_bundle(struct conncache *connc, - char *hostname) +static void free_bundle_hash_entry(void *freethis) { - struct connectbundle *bundle = NULL; + struct connectbundle *b = (struct connectbundle *) freethis; + + bundle_destroy(b); +} +int Curl_conncache_init(struct conncache *connc, int size) +{ + return Curl_hash_init(&connc->hash, size, Curl_hash_str, + Curl_str_key_compare, free_bundle_hash_entry); +} + +void Curl_conncache_destroy(struct conncache *connc) +{ if(connc) - bundle = Curl_hash_pick(connc->hash, hostname, strlen(hostname)+1); + Curl_hash_destroy(&connc->hash); +} + +/* returns an allocated key to find a bundle for this connection */ +static char *hashkey(struct connectdata *conn) +{ + return aprintf("%s:%d", + conn->bits.proxy?conn->proxy.name:conn->host.name, + conn->localport); +} + +/* Look up the bundle with all the connections to the same host this + connectdata struct is setup to use. */ +struct connectbundle *Curl_conncache_find_bundle(struct connectdata *conn, + struct conncache *connc) +{ + struct connectbundle *bundle = NULL; + if(connc) { + char *key = hashkey(conn); + if(key) { + bundle = Curl_hash_pick(&connc->hash, key, strlen(key)); + free(key); + } + } return bundle; } static bool conncache_add_bundle(struct conncache *connc, - char *hostname, + char *key, struct connectbundle *bundle) { - void *p; - - p = Curl_hash_add(connc->hash, hostname, strlen(hostname)+1, bundle); + void *p = Curl_hash_add(&connc->hash, key, strlen(key), bundle); return p?TRUE:FALSE; } @@ -104,14 +172,14 @@ static void conncache_remove_bundle(struct conncache *connc, if(!connc) return; - Curl_hash_start_iterate(connc->hash, &iter); + Curl_hash_start_iterate(&connc->hash, &iter); he = Curl_hash_next_element(&iter); while(he) { if(he->ptr == bundle) { /* The bundle is destroyed by the hash destructor function, free_bundle_hash_entry() */ - Curl_hash_delete(connc->hash, he->key, he->key_len); + Curl_hash_delete(&connc->hash, he->key, he->key_len); return; } @@ -127,23 +195,32 @@ CURLcode Curl_conncache_add_conn(struct conncache *connc, struct connectbundle *new_bundle = NULL; struct SessionHandle *data = conn->data; - bundle = Curl_conncache_find_bundle(data->state.conn_cache, - conn->host.name); + bundle = Curl_conncache_find_bundle(conn, data->state.conn_cache); if(!bundle) { - result = Curl_bundle_create(data, &new_bundle); - if(result != CURLE_OK) + char *key; + int rc; + + result = bundle_create(data, &new_bundle); + if(result) return result; - if(!conncache_add_bundle(data->state.conn_cache, - conn->host.name, new_bundle)) { - Curl_bundle_destroy(new_bundle); + key = hashkey(conn); + if(!key) { + bundle_destroy(new_bundle); + return CURLE_OUT_OF_MEMORY; + } + + rc = conncache_add_bundle(data->state.conn_cache, key, new_bundle); + free(key); + if(!rc) { + bundle_destroy(new_bundle); return CURLE_OUT_OF_MEMORY; } bundle = new_bundle; } - result = Curl_bundle_add_conn(bundle, conn); - if(result != CURLE_OK) { + result = bundle_add_conn(bundle, conn); + if(result) { if(new_bundle) conncache_remove_bundle(data->state.conn_cache, new_bundle); return result; @@ -152,6 +229,10 @@ CURLcode Curl_conncache_add_conn(struct conncache *connc, conn->connection_id = connc->next_connection_id++; connc->num_connections++; + DEBUGF(infof(conn->data, "Added connection %ld. " + "The cache now contains %" CURL_FORMAT_CURL_OFF_TU " members\n", + conn->connection_id, (curl_off_t) connc->num_connections)); + return CURLE_OK; } @@ -163,7 +244,7 @@ void Curl_conncache_remove_conn(struct conncache *connc, /* The bundle pointer can be NULL, since this function can be called due to a failed connection attempt, before being added to a bundle */ if(bundle) { - Curl_bundle_remove_conn(bundle, conn); + bundle_remove_conn(bundle, conn); if(bundle->num_connections == 0) { conncache_remove_bundle(connc, bundle); } @@ -171,8 +252,9 @@ void Curl_conncache_remove_conn(struct conncache *connc, if(connc) { connc->num_connections--; - DEBUGF(infof(conn->data, "The cache now contains %d members\n", - connc->num_connections)); + DEBUGF(infof(conn->data, "The cache now contains %" + CURL_FORMAT_CURL_OFF_TU " members\n", + (curl_off_t) connc->num_connections)); } } } @@ -194,12 +276,11 @@ void Curl_conncache_foreach(struct conncache *connc, if(!connc) return; - Curl_hash_start_iterate(connc->hash, &iter); + Curl_hash_start_iterate(&connc->hash, &iter); he = Curl_hash_next_element(&iter); while(he) { struct connectbundle *bundle; - struct connectdata *conn; bundle = he->ptr; he = Curl_hash_next_element(&iter); @@ -208,7 +289,7 @@ void Curl_conncache_foreach(struct conncache *connc, while(curr) { /* Yes, we need to update curr before calling func(), because func() might decide to remove the connection */ - conn = curr->ptr; + struct connectdata *conn = curr->ptr; curr = curr->next; if(1 == func(conn, param)) @@ -223,14 +304,14 @@ struct connectdata * Curl_conncache_find_first_connection(struct conncache *connc) { struct curl_hash_iterator iter; - struct curl_llist_element *curr; struct curl_hash_element *he; struct connectbundle *bundle; - Curl_hash_start_iterate(connc->hash, &iter); + Curl_hash_start_iterate(&connc->hash, &iter); he = Curl_hash_next_element(&iter); while(he) { + struct curl_llist_element *curr; bundle = he->ptr; curr = bundle->conn_list->head; diff --git a/lib/conncache.h b/lib/conncache.h index d793f24..59181bf 100644 --- a/lib/conncache.h +++ b/lib/conncache.h @@ -7,6 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * + * Copyright (C) 2015, Daniel Stenberg, , et al. * Copyright (C) 2012 - 2014, Linus Nielsen Feltzing, * * This software is licensed as described in the file COPYING, which @@ -23,18 +24,30 @@ ***************************************************************************/ struct conncache { - struct curl_hash *hash; + struct curl_hash hash; size_t num_connections; long next_connection_id; struct timeval last_cleanup; }; -struct conncache *Curl_conncache_init(int size); +#define BUNDLE_NO_MULTIUSE -1 +#define BUNDLE_UNKNOWN 0 /* initial value */ +#define BUNDLE_PIPELINING 1 +#define BUNDLE_MULTIPLEX 2 + +struct connectbundle { + int multiuse; /* supports multi-use */ + size_t num_connections; /* Number of connections in the bundle */ + struct curl_llist *conn_list; /* The connectdata members of the bundle */ +}; + +int Curl_conncache_init(struct conncache *, int size); void Curl_conncache_destroy(struct conncache *connc); -struct connectbundle *Curl_conncache_find_bundle(struct conncache *connc, - char *hostname); +/* return the correct bundle, to a host or a proxy */ +struct connectbundle *Curl_conncache_find_bundle(struct connectdata *conn, + struct conncache *connc); CURLcode Curl_conncache_add_conn(struct conncache *connc, struct connectdata *conn); diff --git a/lib/connect.c b/lib/connect.c index fb315fc..18ac32c 100644 --- a/lib/connect.c +++ b/lib/connect.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -56,15 +56,12 @@ #include #endif -#define _MPRINTF_REPLACE /* use our functions only */ -#include - +#include "curl_printf.h" #include "urldata.h" #include "sendf.h" #include "if2ip.h" #include "strerror.h" #include "connect.h" -#include "curl_memory.h" #include "select.h" #include "url.h" /* for Curl_safefree() */ #include "multiif.h" @@ -77,7 +74,8 @@ #include "conncache.h" #include "multihandle.h" -/* The last #include file should be: */ +/* The last #include files should be: */ +#include "curl_memory.h" #include "memdebug.h" #ifdef __SYMBIAN32__ @@ -238,7 +236,7 @@ long Curl_timeleft(struct SessionHandle *data, } static CURLcode bindlocal(struct connectdata *conn, - curl_socket_t sockfd, int af) + curl_socket_t sockfd, int af, unsigned int scope) { struct SessionHandle *data = conn->data; @@ -257,12 +255,6 @@ static CURLcode bindlocal(struct connectdata *conn, int portnum = data->set.localportrange; const char *dev = data->set.str[STRING_DEVICE]; int error; - char myhost[256] = ""; - int done = 0; /* -1 for error, 1 for address found */ - bool is_interface = FALSE; - bool is_host = FALSE; - static const char *if_prefix = "if!"; - static const char *host_prefix = "host!"; /************************************************************* * Select device to bind socket to @@ -274,6 +266,13 @@ static CURLcode bindlocal(struct connectdata *conn, memset(&sa, 0, sizeof(struct Curl_sockaddr_storage)); if(dev && (strlen(dev)<255) ) { + char myhost[256] = ""; + int done = 0; /* -1 for error, 1 for address found */ + bool is_interface = FALSE; + bool is_host = FALSE; + static const char *if_prefix = "if!"; + static const char *host_prefix = "host!"; + if(strncmp(if_prefix, dev, strlen(if_prefix)) == 0) { dev += strlen(if_prefix); is_interface = TRUE; @@ -285,7 +284,8 @@ static CURLcode bindlocal(struct connectdata *conn, /* interface */ if(!is_host) { - switch(Curl_if2ip(af, conn->scope, dev, myhost, sizeof(myhost))) { + switch(Curl_if2ip(af, scope, conn->scope_id, dev, + myhost, sizeof(myhost))) { case IF2IP_NOT_FOUND: if(is_interface) { /* Do not fall back to treating it as a host name */ @@ -374,7 +374,7 @@ static CURLcode bindlocal(struct connectdata *conn, if(done > 0) { #ifdef ENABLE_IPV6 - /* ipv6 address */ + /* IPv6 address */ if(af == AF_INET6) { #ifdef HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID char *scope_ptr = strchr(myhost, '%'); @@ -397,7 +397,7 @@ static CURLcode bindlocal(struct connectdata *conn, } else #endif - /* ipv4 address */ + /* IPv4 address */ if((af == AF_INET) && (Curl_inet_pton(AF_INET, myhost, &si4->sin_addr) > 0)) { si4->sin_family = AF_INET; @@ -540,7 +540,8 @@ static CURLcode trynextip(struct connectdata *conn, int sockindex, int tempindex) { - CURLcode rc = CURLE_COULDNT_CONNECT; + const int other = tempindex ^ 1; + CURLcode result = CURLE_COULDNT_CONNECT; /* First clean up after the failed socket. Don't close it yet to ensure that the next IP's socket gets a different @@ -558,27 +559,29 @@ static CURLcode trynextip(struct connectdata *conn, family = conn->tempaddr[tempindex]->ai_family; ai = conn->tempaddr[tempindex]->ai_next; } +#ifdef ENABLE_IPV6 else if(conn->tempaddr[0]) { /* happy eyeballs - try the other protocol family */ int firstfamily = conn->tempaddr[0]->ai_family; -#ifdef ENABLE_IPV6 family = (firstfamily == AF_INET) ? AF_INET6 : AF_INET; -#else - family = firstfamily; -#endif ai = conn->tempaddr[0]->ai_next; } +#endif while(ai) { - while(ai && ai->ai_family != family) - ai = ai->ai_next; + if(conn->tempaddr[other]) { + /* we can safely skip addresses of the other protocol family */ + while(ai && ai->ai_family != family) + ai = ai->ai_next; + } if(ai) { - rc = singleipconnect(conn, ai, &conn->tempsock[tempindex]); - if(rc == CURLE_COULDNT_CONNECT) { + result = singleipconnect(conn, ai, &conn->tempsock[tempindex]); + if(result == CURLE_COULDNT_CONNECT) { ai = ai->ai_next; continue; } + conn->tempaddr[tempindex] = ai; } break; @@ -588,7 +591,7 @@ static CURLcode trynextip(struct connectdata *conn, if(fd_to_close != CURL_SOCKET_BAD) Curl_closesocket(conn, fd_to_close); - return rc; + return result; } /* Copies connection info into the session handle to make it available @@ -656,7 +659,6 @@ static bool getaddressinfo(struct sockaddr* sa, char* addr, connection */ void Curl_updateconninfo(struct connectdata *conn, curl_socket_t sockfd) { - int error; curl_socklen_t len; struct Curl_sockaddr_storage ssrem; struct Curl_sockaddr_storage ssloc; @@ -667,6 +669,7 @@ void Curl_updateconninfo(struct connectdata *conn, curl_socket_t sockfd) return; if(!conn->bits.reuse) { + int error; len = sizeof(struct Curl_sockaddr_storage); if(getpeername(sockfd, (struct sockaddr*) &ssrem, &len)) { @@ -677,6 +680,7 @@ void Curl_updateconninfo(struct connectdata *conn, curl_socket_t sockfd) } len = sizeof(struct Curl_sockaddr_storage); + memset(&ssloc, 0, sizeof(ssloc)); if(getsockname(sockfd, (struct sockaddr*) &ssloc, &len)) { error = SOCKERRNO; failf(data, "getsockname() failed with errno %d: %s", @@ -716,11 +720,11 @@ CURLcode Curl_is_connected(struct connectdata *conn, bool *connected) { struct SessionHandle *data = conn->data; - CURLcode code = CURLE_OK; + CURLcode result = CURLE_OK; long allow; int error = 0; struct timeval now; - int result; + int rc; int i; DEBUGASSERT(sockindex >= FIRSTSOCKET && sockindex <= SECONDARYSOCKET); @@ -745,6 +749,7 @@ CURLcode Curl_is_connected(struct connectdata *conn, } for(i=0; i<2; i++) { + const int other = i ^ 1; if(conn->tempsock[i] == CURL_SOCKET_BAD) continue; @@ -756,9 +761,9 @@ CURLcode Curl_is_connected(struct connectdata *conn, #endif /* check socket for connect */ - result = Curl_socket_ready(CURL_SOCKET_BAD, conn->tempsock[i], 0); + rc = Curl_socket_ready(CURL_SOCKET_BAD, conn->tempsock[i], 0); - if(result == 0) { /* no connection yet */ + if(rc == 0) { /* no connection yet */ if(curlx_tvdiff(now, conn->connecttime) >= conn->timeoutms_per_addr) { infof(data, "After %ldms connect time, move on!\n", conn->timeoutms_per_addr); @@ -771,10 +776,9 @@ CURLcode Curl_is_connected(struct connectdata *conn, trynextip(conn, sockindex, 1); } } - else if(result == CURL_CSELECT_OUT) { + else if(rc == CURL_CSELECT_OUT) { if(verifyconnect(conn->tempsock[i], &error)) { /* we are connected with TCP, awesome! */ - int other = i ^ 1; /* use this socket from now on */ conn->sock[sockindex] = conn->tempsock[i]; @@ -788,9 +792,9 @@ CURLcode Curl_is_connected(struct connectdata *conn, } /* see if we need to do any proxy magic first once we connected */ - code = Curl_connected_proxy(conn, sockindex); - if(code) - return code; + result = Curl_connected_proxy(conn, sockindex); + if(result) + return result; conn->bits.tcpconnect[sockindex] = TRUE; @@ -805,7 +809,7 @@ CURLcode Curl_is_connected(struct connectdata *conn, else infof(data, "Connection failed\n"); } - else if(result & CURL_CSELECT_ERR) + else if(rc & CURL_CSELECT_ERR) (void)verifyconnect(conn->tempsock[i], &error); /* @@ -813,10 +817,11 @@ CURLcode Curl_is_connected(struct connectdata *conn, * address" for the given host. But first remember the latest error. */ if(error) { - char ipaddress[MAX_IPADR_LEN]; data->state.os_errno = error; SET_SOCKERRNO(error); if(conn->tempaddr[i]) { + CURLcode status; + char ipaddress[MAX_IPADR_LEN]; Curl_printable_address(conn->tempaddr[i], ipaddress, MAX_IPADR_LEN); infof(data, "connect to %s port %ld failed: %s\n", ipaddress, conn->port, Curl_strerror(conn, error)); @@ -824,21 +829,24 @@ CURLcode Curl_is_connected(struct connectdata *conn, conn->timeoutms_per_addr = conn->tempaddr[i]->ai_next == NULL ? allow : allow / 2; - code = trynextip(conn, sockindex, i); + status = trynextip(conn, sockindex, i); + if(status != CURLE_COULDNT_CONNECT + || conn->tempsock[other] == CURL_SOCKET_BAD) + /* the last attempt failed and no other sockets remain open */ + result = status; } } } - if(code) { + if(result) { /* no more addresses to try */ /* if the first address family runs out of addresses to try before the happy eyeball timeout, go ahead and try the next family now */ if(conn->tempaddr[1] == NULL) { - int rc; - rc = trynextip(conn, sockindex, 1); - if(rc == CURLE_OK) - return CURLE_OK; + result = trynextip(conn, sockindex, 1); + if(!result) + return result; } failf(data, "Failed to connect to %s port %ld: %s", @@ -846,7 +854,7 @@ CURLcode Curl_is_connected(struct connectdata *conn, conn->port, Curl_strerror(conn, error)); } - return code; + return result; } static void tcpnodelay(struct connectdata *conn, @@ -875,7 +883,7 @@ static void tcpnodelay(struct connectdata *conn, infof(data, "Could not set TCP_NODELAY: %s\n", Curl_strerror(conn, SOCKERRNO)); else - infof(data,"TCP_NODELAY set\n"); + infof(data, "TCP_NODELAY set\n"); #else (void)conn; (void)sockfd; @@ -941,16 +949,21 @@ void Curl_sndbufset(curl_socket_t sockfd) detectOsState = DETECT_OS_VISTA_OR_LATER; } #else - ULONGLONG majorVersionMask; + ULONGLONG cm; OSVERSIONINFOEX osver; memset(&osver, 0, sizeof(osver)); osver.dwOSVersionInfoSize = sizeof(osver); osver.dwMajorVersion = majorVersion; - majorVersionMask = VerSetConditionMask(0, VER_MAJORVERSION, - VER_GREATER_EQUAL); - if(VerifyVersionInfo(&osver, VER_MAJORVERSION, majorVersionMask)) + cm = VerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL); + cm = VerSetConditionMask(cm, VER_MINORVERSION, VER_GREATER_EQUAL); + cm = VerSetConditionMask(cm, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL); + cm = VerSetConditionMask(cm, VER_SERVICEPACKMINOR, VER_GREATER_EQUAL); + + if(VerifyVersionInfo(&osver, (VER_MAJORVERSION | VER_MINORVERSION | + VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR), + cm)) detectOsState = DETECT_OS_VISTA_OR_LATER; else detectOsState = DETECT_OS_PREVISTA; @@ -977,10 +990,9 @@ void Curl_sndbufset(curl_socket_t sockfd) * singleipconnect() connects to the given IP only, and it may return without * having connected. */ -static CURLcode -singleipconnect(struct connectdata *conn, - const Curl_addrinfo *ai, - curl_socket_t *sockp) +static CURLcode singleipconnect(struct connectdata *conn, + const Curl_addrinfo *ai, + curl_socket_t *sockp) { struct Curl_sockaddr_ex addr; int rc; @@ -988,14 +1000,15 @@ singleipconnect(struct connectdata *conn, bool isconnected = FALSE; struct SessionHandle *data = conn->data; curl_socket_t sockfd; - CURLcode res = CURLE_OK; + CURLcode result; char ipaddress[MAX_IPADR_LEN]; long port; + bool is_tcp; *sockp = CURL_SOCKET_BAD; - res = Curl_socket(conn, ai, &addr, &sockfd); - if(res) + result = Curl_socket(conn, ai, &addr, &sockfd); + if(result) /* Failed to create the socket, but still return OK since we signal the lack of socket as well. This allows the parent function to keep looping over alternative addresses/socket families etc. */ @@ -1013,14 +1026,20 @@ singleipconnect(struct connectdata *conn, } infof(data, " Trying %s...\n", ipaddress); - if(data->set.tcp_nodelay) +#ifdef ENABLE_IPV6 + is_tcp = (addr.family == AF_INET || addr.family == AF_INET6) && + addr.socktype == SOCK_STREAM; +#else + is_tcp = (addr.family == AF_INET) && addr.socktype == SOCK_STREAM; +#endif + if(is_tcp && data->set.tcp_nodelay) tcpnodelay(conn, sockfd); nosigpipe(conn, sockfd); Curl_sndbufset(sockfd); - if(data->set.tcp_keepalive) + if(is_tcp && data->set.tcp_keepalive) tcpkeepalive(data, sockfd); if(data->set.fsockopt) { @@ -1038,19 +1057,26 @@ singleipconnect(struct connectdata *conn, } /* possibly bind the local end to an IP, interface or port */ - res = bindlocal(conn, sockfd, addr.family); - if(res) { - Curl_closesocket(conn, sockfd); /* close socket and bail out */ - if(res == CURLE_UNSUPPORTED_PROTOCOL) { - /* The address family is not supported on this interface. - We can continue trying addresses */ - return CURLE_OK; + if(addr.family == AF_INET +#ifdef ENABLE_IPV6 + || addr.family == AF_INET6 +#endif + ) { + result = bindlocal(conn, sockfd, addr.family, + Curl_ipv6_scope((struct sockaddr*)&addr.sa_addr)); + if(result) { + Curl_closesocket(conn, sockfd); /* close socket and bail out */ + if(result == CURLE_UNSUPPORTED_PROTOCOL) { + /* The address family is not supported on this interface. + We can continue trying addresses */ + return CURLE_COULDNT_CONNECT; + } + return result; } - return res; } /* set socket non-blocking */ - curlx_nonblock(sockfd, TRUE); + (void)curlx_nonblock(sockfd, TRUE); conn->connecttime = Curl_tvnow(); if(conn->num_addr > 1) @@ -1084,25 +1110,25 @@ singleipconnect(struct connectdata *conn, case EAGAIN: #endif #endif - res = CURLE_OK; + result = CURLE_OK; break; default: /* unknown error, fallthrough and try another address! */ infof(data, "Immediate connect fail for %s: %s\n", - ipaddress, Curl_strerror(conn,error)); + ipaddress, Curl_strerror(conn, error)); data->state.os_errno = error; /* connect failed */ Curl_closesocket(conn, sockfd); - res = CURLE_COULDNT_CONNECT; + result = CURLE_COULDNT_CONNECT; } } - if(!res) + if(!result) *sockp = sockfd; - return res; + return result; } /* @@ -1116,7 +1142,7 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */ { struct SessionHandle *data = conn->data; struct timeval before = Curl_tvnow(); - CURLcode res = CURLE_COULDNT_CONNECT; + CURLcode result = CURLE_COULDNT_CONNECT; long timeout_ms = Curl_timeleft(data, &before, TRUE); @@ -1139,14 +1165,17 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */ /* start connecting to first IP */ while(conn->tempaddr[0]) { - res = singleipconnect(conn, conn->tempaddr[0], &(conn->tempsock[0])); - if(res == CURLE_OK) - break; + result = singleipconnect(conn, conn->tempaddr[0], &(conn->tempsock[0])); + if(!result) + break; conn->tempaddr[0] = conn->tempaddr[0]->ai_next; } - if(conn->tempsock[0] == CURL_SOCKET_BAD) - return res; + if(conn->tempsock[0] == CURL_SOCKET_BAD) { + if(!result) + result = CURLE_COULDNT_CONNECT; + return result; + } data->info.numconnects++; /* to track the number of connections made */ @@ -1181,15 +1210,20 @@ curl_socket_t Curl_getconnectinfo(struct SessionHandle *data, DEBUGASSERT(data); - /* this only works for an easy handle that has been used for - curl_easy_perform()! */ - if(data->state.lastconnect && data->multi_easy) { + /* this works for an easy handle: + * - that has been used for curl_easy_perform() + * - that is associated with a multi handle, and whose connection + * was detached with CURLOPT_CONNECT_ONLY + */ + if(data->state.lastconnect && (data->multi_easy || data->multi)) { struct connectdata *c = data->state.lastconnect; struct connfind find; find.tofind = data->state.lastconnect; find.found = FALSE; - Curl_conncache_foreach(data->multi_easy->conn_cache, &find, conn_is_conn); + Curl_conncache_foreach(data->multi_easy? + &data->multi_easy->conn_cache: + &data->multi->conn_cache, &find, conn_is_conn); if(!find.found) { data->state.lastconnect = NULL; @@ -1240,15 +1274,18 @@ int Curl_closesocket(struct connectdata *conn, accept, then we MUST NOT call the callback but clear the accepted status */ conn->sock_accepted[SECONDARYSOCKET] = FALSE; - else + else { + Curl_multi_closed(conn, sock); return conn->fclosesocket(conn->closesocket_client, sock); + } } - sclose(sock); if(conn) /* tell the multi-socket code about this */ Curl_multi_closed(conn, sock); + sclose(sock); + return 0; } @@ -1312,9 +1349,9 @@ CURLcode Curl_socket(struct connectdata *conn, return CURLE_COULDNT_CONNECT; #if defined(ENABLE_IPV6) && defined(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID) - if(conn->scope && (addr->family == AF_INET6)) { + if(conn->scope_id && (addr->family == AF_INET6)) { struct sockaddr_in6 * const sa6 = (void *)&addr->sa_addr; - sa6->sin6_scope_id = conn->scope; + sa6->sin6_scope_id = conn->scope_id; } #endif @@ -1325,16 +1362,22 @@ CURLcode Curl_socket(struct connectdata *conn, #ifdef CURLDEBUG /* * Curl_conncontrol() is used to set the conn->bits.close bit on or off. It - * MUST be called with the connclose() or connclose() macros with a stated + * MUST be called with the connclose() or connkeep() macros with a stated * reason. The reason is only shown in debug builds but helps to figure out * decision paths when connections are or aren't re-used as expected. */ void Curl_conncontrol(struct connectdata *conn, bool closeit, const char *reason) { - infof(conn->data, "Marked for [%s]: %s\n", closeit?"closure":"keep alive", - reason); - conn->bits.close = closeit; /* the only place in the source code that should - assign this bit */ +#if defined(CURL_DISABLE_VERBOSE_STRINGS) + (void) reason; +#endif + if(closeit != conn->bits.close) { + infof(conn->data, "Marked for [%s]: %s\n", closeit?"closure":"keep alive", + reason); + + conn->bits.close = closeit; /* the only place in the source code that + should assign this bit */ + } } #endif diff --git a/lib/connect.h b/lib/connect.h index 7bc391b..91646c7 100644 --- a/lib/connect.h +++ b/lib/connect.h @@ -41,7 +41,7 @@ long Curl_timeleft(struct SessionHandle *data, #define DEFAULT_CONNECT_TIMEOUT 300000 /* milliseconds == five minutes */ #define HAPPY_EYEBALLS_TIMEOUT 200 /* milliseconds to wait between - ipv4/ipv6 connection attempts */ + IPv4/IPv6 connection attempts */ /* * Used to extract socket and connectdata struct for the most recent diff --git a/lib/cookie.c b/lib/cookie.c index 375485f..22730cf 100644 --- a/lib/cookie.c +++ b/lib/cookie.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -26,14 +26,17 @@ RECEIVING COOKIE INFORMATION ============================ -struct CookieInfo *cookie_init(char *file); +struct CookieInfo *Curl_cookie_init(struct SessionHandle *data, + const char *file, struct CookieInfo *inc, bool newsession); Inits a cookie struct to store data in a local file. This is always called before any cookies are set. -int cookies_set(struct CookieInfo *cookie, char *cookie_line); +struct Cookie *Curl_cookie_add(struct SessionHandle *data, + struct CookieInfo *c, bool httpheader, char *lineptr, + const char *domain, const char *path); - The 'cookie_line' parameter is a full "Set-cookie:" line as + The 'lineptr' parameter is a full "Set-cookie:" line as received from a server. The function need to replace previously stored lines that this new @@ -47,8 +50,8 @@ int cookies_set(struct CookieInfo *cookie, char *cookie_line); SENDING COOKIE INFORMATION ========================== -struct Cookies *cookie_getlist(struct CookieInfo *cookie, - char *host, char *path, bool secure); +struct Cookies *Curl_cookie_getlist(struct CookieInfo *cookie, + char *host, char *path, bool secure); For a given host and path, return a linked list of cookies that the client should send to the server if used now. The secure @@ -81,44 +84,33 @@ Example set of cookies: #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES) -#define _MPRINTF_REPLACE -#include - +#include "curl_printf.h" #include "urldata.h" #include "cookie.h" #include "strequal.h" #include "strtok.h" #include "sendf.h" #include "slist.h" -#include "curl_memory.h" #include "share.h" #include "strtoofft.h" #include "rawstr.h" #include "curl_memrchr.h" #include "inet_pton.h" -/* The last #include file should be: */ +/* The last #include files should be: */ +#include "curl_memory.h" #include "memdebug.h" static void freecookie(struct Cookie *co) { - if(co->expirestr) - free(co->expirestr); - if(co->domain) - free(co->domain); - if(co->path) - free(co->path); - if(co->spath) - free(co->spath); - if(co->name) - free(co->name); - if(co->value) - free(co->value); - if(co->maxage) - free(co->maxage); - if(co->version) - free(co->version); - + free(co->expirestr); + free(co->domain); + free(co->path); + free(co->spath); + free(co->name); + free(co->value); + free(co->maxage); + free(co->version); free(co); } @@ -233,11 +225,14 @@ static char *sanitize_cookie_path(const char *cookie_path) return NULL; /* some stupid site sends path attribute with '"'. */ + len = strlen(new_path); if(new_path[0] == '\"') { - memmove((void *)new_path, (const void *)(new_path + 1), strlen(new_path)); + memmove((void *)new_path, (const void *)(new_path + 1), len); + len--; } - if(new_path[strlen(new_path) - 1] == '\"') { - new_path[strlen(new_path) - 1] = 0x0; + if(len && (new_path[len - 1] == '\"')) { + new_path[len - 1] = 0x0; + len--; } /* RFC6265 5.2.4 The Path Attribute */ @@ -249,8 +244,7 @@ static char *sanitize_cookie_path(const char *cookie_path) } /* convert /hoge/ to /hoge */ - len = strlen(new_path); - if(1 < len && new_path[len - 1] == '/') { + if(len && new_path[len - 1] == '/') { new_path[len - 1] = 0x0; } @@ -259,6 +253,8 @@ static char *sanitize_cookie_path(const char *cookie_path) /* * Load cookies from all given cookie files (CURLOPT_COOKIEFILE). + * + * NOTE: OOM or cookie parsing failures are ignored. */ void Curl_cookie_loadfiles(struct SessionHandle *data) { @@ -266,10 +262,17 @@ void Curl_cookie_loadfiles(struct SessionHandle *data) if(list) { Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE); while(list) { - data->cookies = Curl_cookie_init(data, - list->data, - data->cookies, - data->set.cookiesession); + struct CookieInfo *newcookies = Curl_cookie_init(data, + list->data, + data->cookies, + data->set.cookiesession); + if(!newcookies) + /* Failure may be due to OOM or a bad cookie; both are ignored + * but only the first should be + */ + infof(data, "ignoring failed cookie_init for %s\n", list->data); + else + data->cookies = newcookies; list = list->next; } curl_slist_free_all(data->change.cookielist); /* clean up list */ @@ -286,8 +289,7 @@ void Curl_cookie_loadfiles(struct SessionHandle *data) */ static void strstore(char **str, const char *newstr) { - if(*str) - free(*str); + free(*str); *str = strdup(newstr); } @@ -351,6 +353,8 @@ static bool isip(const char *domain) * Be aware that sometimes we get an IP-only host name, and that might also be * a numerical IPv6 address. * + * Returns NULL on out of memory or invalid cookie. This is suboptimal, + * as they should be treated separately. ***************************************************************************/ struct Cookie * @@ -405,7 +409,7 @@ Curl_cookie_add(struct SessionHandle *data, do { /* we have a = pair or a stand-alone word here */ name[0]=what[0]=0; /* init the buffers */ - if(1 <= sscanf(ptr, "%" MAX_NAME_TXT "[^;\r\n =]=%" + if(1 <= sscanf(ptr, "%" MAX_NAME_TXT "[^;\r\n =] =%" MAX_COOKIE_LINE_TXT "[^;\r\n]", name, what)) { /* Use strstore() below to properly deal with received cookie @@ -820,21 +824,13 @@ Curl_cookie_add(struct SessionHandle *data, /* then free all the old pointers */ free(clist->name); - if(clist->value) - free(clist->value); - if(clist->domain) - free(clist->domain); - if(clist->path) - free(clist->path); - if(clist->spath) - free(clist->spath); - if(clist->expirestr) - free(clist->expirestr); - - if(clist->version) - free(clist->version); - if(clist->maxage) - free(clist->maxage); + free(clist->value); + free(clist->domain); + free(clist->path); + free(clist->spath); + free(clist->expirestr); + free(clist->version); + free(clist->maxage); *clist = *co; /* then store all the new data */ @@ -882,6 +878,7 @@ Curl_cookie_add(struct SessionHandle *data, * * If 'newsession' is TRUE, discard all "session cookies" on read from file. * + * Returns NULL on out of memory. Invalid cookies are ignored. ****************************************************************************/ struct CookieInfo *Curl_cookie_init(struct SessionHandle *data, const char *file, @@ -889,8 +886,9 @@ struct CookieInfo *Curl_cookie_init(struct SessionHandle *data, bool newsession) { struct CookieInfo *c; - FILE *fp; + FILE *fp = NULL; bool fromfile=TRUE; + char *line = NULL; if(NULL == inc) { /* we didn't get a struct, create one */ @@ -898,6 +896,8 @@ struct CookieInfo *Curl_cookie_init(struct SessionHandle *data, if(!c) return NULL; /* failed to get memory */ c->filename = strdup(file?file:"none"); /* copy the name just in case */ + if(!c->filename) + goto fail; /* failed to get memory */ } else { /* we got an already existing one, use that */ @@ -914,7 +914,7 @@ struct CookieInfo *Curl_cookie_init(struct SessionHandle *data, fp = NULL; } else - fp = file?fopen(file, "r"):NULL; + fp = file?fopen(file, FOPEN_READTEXT):NULL; c->newsession = newsession; /* new session? */ @@ -922,25 +922,26 @@ struct CookieInfo *Curl_cookie_init(struct SessionHandle *data, char *lineptr; bool headerline; - char *line = malloc(MAX_COOKIE_LINE); - if(line) { - while(fgets(line, MAX_COOKIE_LINE, fp)) { - if(checkprefix("Set-Cookie:", line)) { - /* This is a cookie line, get it! */ - lineptr=&line[11]; - headerline=TRUE; - } - else { - lineptr=line; - headerline=FALSE; - } - while(*lineptr && ISBLANK(*lineptr)) - lineptr++; - - Curl_cookie_add(data, c, headerline, lineptr, NULL, NULL); + line = malloc(MAX_COOKIE_LINE); + if(!line) + goto fail; + while(fgets(line, MAX_COOKIE_LINE, fp)) { + if(checkprefix("Set-Cookie:", line)) { + /* This is a cookie line, get it! */ + lineptr=&line[11]; + headerline=TRUE; + } + else { + lineptr=line; + headerline=FALSE; } - free(line); /* free the line buffer */ + while(*lineptr && ISBLANK(*lineptr)) + lineptr++; + + Curl_cookie_add(data, c, headerline, lineptr, NULL, NULL); } + free(line); /* free the line buffer */ + if(fromfile) fclose(fp); } @@ -948,6 +949,16 @@ struct CookieInfo *Curl_cookie_init(struct SessionHandle *data, c->running = TRUE; /* now, we're running */ return c; + +fail: + free(line); + if(!inc) + /* Only clean up if we allocated it here, as the original could still be in + * use by a share handle */ + Curl_cookie_cleanup(c); + if(fromfile && fp) + fclose(fp); + return NULL; /* out of memory */ } /* sort this so that the longest path gets before the shorter path */ @@ -1127,16 +1138,14 @@ void Curl_cookie_clearall(struct CookieInfo *cookies) void Curl_cookie_freelist(struct Cookie *co, bool cookiestoo) { struct Cookie *next; - if(co) { - while(co) { - next = co->next; - if(cookiestoo) - freecookie(co); - else - free(co); /* we only free the struct since the "members" are all just - pointed out in the main cookie list! */ - co = next; - } + while(co) { + next = co->next; + if(cookiestoo) + freecookie(co); + else + free(co); /* we only free the struct since the "members" are all just + pointed out in the main cookie list! */ + co = next; } } @@ -1183,23 +1192,14 @@ void Curl_cookie_clearsess(struct CookieInfo *cookies) * * Curl_cookie_cleanup() * - * Free a "cookie object" previous created with cookie_init(). + * Free a "cookie object" previous created with Curl_cookie_init(). * ****************************************************************************/ void Curl_cookie_cleanup(struct CookieInfo *c) { - struct Cookie *co; - struct Cookie *next; if(c) { - if(c->filename) - free(c->filename); - co = c->cookies; - - while(co) { - next = co->next; - freecookie(co); - co = next; - } + free(c->filename); + Curl_cookie_freelist(c->cookies, TRUE); free(c); /* free the base struct as well */ } } @@ -1262,7 +1262,7 @@ static int cookie_output(struct CookieInfo *c, const char *dumphere) use_stdout=TRUE; } else { - out = fopen(dumphere, "w"); + out = fopen(dumphere, FOPEN_WRITETEXT); if(!out) return 1; /* failure */ } @@ -1274,9 +1274,10 @@ static int cookie_output(struct CookieInfo *c, const char *dumphere) "# http://curl.haxx.se/docs/http-cookies.html\n" "# This file was generated by libcurl! Edit at your own risk.\n\n", out); - co = c->cookies; - while(co) { + for(co = c->cookies; co; co = co->next) { + if(!co->domain) + continue; format_ptr = get_netscape_format(co); if(format_ptr == NULL) { fprintf(out, "#\n# Fatal libcurl error\n"); @@ -1286,7 +1287,6 @@ static int cookie_output(struct CookieInfo *c, const char *dumphere) } fprintf(out, "%s\n", format_ptr); free(format_ptr); - co=co->next; } } @@ -1307,10 +1307,9 @@ struct curl_slist *Curl_cookie_list(struct SessionHandle *data) (data->cookies->numcookies == 0)) return NULL; - c = data->cookies->cookies; - - while(c) { - /* fill the list with _all_ the cookies we know */ + for(c = data->cookies->cookies; c; c = c->next) { + if(!c->domain) + continue; line = get_netscape_format(c); if(!line) { curl_slist_free_all(list); @@ -1323,7 +1322,6 @@ struct curl_slist *Curl_cookie_list(struct SessionHandle *data) return NULL; } list = beg; - c = c->next; } return list; diff --git a/lib/curl_addrinfo.c b/lib/curl_addrinfo.c index 10652c6..6627a6b 100644 --- a/lib/curl_addrinfo.c +++ b/lib/curl_addrinfo.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -33,6 +33,9 @@ #ifdef HAVE_ARPA_INET_H # include #endif +#ifdef HAVE_SYS_UN_H +# include +#endif #ifdef __VMS # include @@ -47,15 +50,12 @@ #include "curl_addrinfo.h" #include "inet_pton.h" #include "warnless.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include - +#include "curl_printf.h" #include "curl_memory.h" + /* The last #include file should be: */ #include "memdebug.h" - /* * Curl_freeaddrinfo() * @@ -80,13 +80,8 @@ Curl_freeaddrinfo(Curl_addrinfo *cahead) Curl_addrinfo *ca; for(ca = cahead; ca != NULL; ca = canext) { - - if(ca->ai_addr) - free(ca->ai_addr); - - if(ca->ai_canonname) - free(ca->ai_canonname); - + free(ca->ai_addr); + free(ca->ai_canonname); canext = ca->ai_next; free(ca); @@ -354,7 +349,7 @@ Curl_he2ai(const struct hostent *he, int port) prevai = ai; } - if(result != CURLE_OK) { + if(result) { Curl_freeaddrinfo(firstai); firstai = NULL; } @@ -477,6 +472,42 @@ Curl_addrinfo *Curl_str2addr(char *address, int port) return NULL; /* bad input format */ } +#ifdef USE_UNIX_SOCKETS +/** + * Given a path to a Unix domain socket, return a newly allocated Curl_addrinfo + * struct initialized with this path. + */ +Curl_addrinfo *Curl_unix2addr(const char *path) +{ + Curl_addrinfo *ai; + struct sockaddr_un *sa_un; + size_t path_len; + + ai = calloc(1, sizeof(Curl_addrinfo)); + if(!ai) + return NULL; + if((ai->ai_addr = calloc(1, sizeof(struct sockaddr_un))) == NULL) { + free(ai); + return NULL; + } + /* sun_path must be able to store the NUL-terminated path */ + path_len = strlen(path); + if(path_len >= sizeof(sa_un->sun_path)) { + free(ai->ai_addr); + free(ai); + return NULL; + } + + ai->ai_family = AF_UNIX; + ai->ai_socktype = SOCK_STREAM; /* assume reliable transport for HTTP */ + ai->ai_addrlen = (curl_socklen_t) sizeof(struct sockaddr_un); + sa_un = (void *) ai->ai_addr; + sa_un->sun_family = AF_UNIX; + memcpy(sa_un->sun_path, path, path_len + 1); /* copy NUL byte */ + return ai; +} +#endif + #if defined(CURLDEBUG) && defined(HAVE_FREEADDRINFO) /* * curl_dofreeaddrinfo() diff --git a/lib/curl_addrinfo.h b/lib/curl_addrinfo.h index 6d2b753..4ef8827 100644 --- a/lib/curl_addrinfo.h +++ b/lib/curl_addrinfo.h @@ -79,6 +79,10 @@ Curl_ip2addr(int af, const void *inaddr, const char *hostname, int port); Curl_addrinfo *Curl_str2addr(char *dotted, int port); +#ifdef USE_UNIX_SOCKETS +Curl_addrinfo *Curl_unix2addr(const char *path); +#endif + #if defined(CURLDEBUG) && defined(HAVE_FREEADDRINFO) void curl_dofreeaddrinfo(struct addrinfo *freethis, diff --git a/lib/curl_config.h.cmake b/lib/curl_config.h.cmake index 32bae39..5376aa7 100644 --- a/lib/curl_config.h.cmake +++ b/lib/curl_config.h.cmake @@ -53,7 +53,7 @@ #endif /* Use Windows LDAP implementation */ -#cmakedefine CURL_LDAP_WIN 1 +#cmakedefine USE_WIN32_LDAP 1 /* when not building a shared library */ #cmakedefine CURL_STATICLIB 1 @@ -467,6 +467,9 @@ /* Define to 1 if you have a working POSIX-style strerror_r function. */ #cmakedefine HAVE_POSIX_STRERROR_R 1 +/* Define to 1 if you have the header file */ +#cmakedefine HAVE_PTHREAD_H 1 + /* Define to 1 if you have the header file. */ #cmakedefine HAVE_PWD_H 1 @@ -879,6 +882,9 @@ /* Define if you want to enable c-ares support */ #cmakedefine USE_ARES 1 +/* Define if you want to enable POSIX threaded DNS lookup */ +#cmakedefine USE_THREADS_POSIX 1 + /* Define to disable non-blocking sockets. */ #cmakedefine USE_BLOCKING_SOCKETS 1 @@ -903,8 +909,8 @@ /* if OpenSSL is in use */ #cmakedefine USE_OPENSSL 1 -/* if SSL is enabled */ -#cmakedefine USE_SSLEAY 1 +/* if Unix domain sockets are enabled */ +#cmakedefine USE_UNIX_SOCKETS /* Define to 1 if you are building a Windows target without large file support. */ diff --git a/lib/curl_des.c b/lib/curl_des.c new file mode 100644 index 0000000..42c1df9 --- /dev/null +++ b/lib/curl_des.c @@ -0,0 +1,63 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 2015, Steve Holme, . + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ + +#include "curl_setup.h" + +#if defined(USE_NTLM) && (!defined(USE_OPENSSL) || defined(HAVE_BORINGSSL)) + +#include "curl_des.h" + +/* + * Curl_des_set_odd_parity() + * + * This is used to apply odd parity to the given byte array. It is typically + * used by when a cryptography engines doesn't have it's own version. + * + * The function is a port of the Java based oddParity() function over at: + * + * http://davenport.sourceforge.net/ntlm.html + * + * Parameters: + * + * bytes [in/out] - The data whose parity bits are to be adjusted for + * odd parity. + * len [out] - The length of the data. + */ +void Curl_des_set_odd_parity(unsigned char *bytes, size_t len) +{ + size_t i; + + for(i = 0; i < len; i++) { + unsigned char b = bytes[i]; + + bool needs_parity = (((b >> 7) ^ (b >> 6) ^ (b >> 5) ^ + (b >> 4) ^ (b >> 3) ^ (b >> 2) ^ + (b >> 1)) & 0x01) == 0; + + if(needs_parity) + bytes[i] |= 0x01; + else + bytes[i] &= 0xfe; + } +} + +#endif /* USE_NTLM && (!USE_OPENSSL || HAVE_BORINGSSL) */ diff --git a/lib/curl_md4.h b/lib/curl_des.h similarity index 71% copy from lib/curl_md4.h copy to lib/curl_des.h index b0be9cf..b855db4 100644 --- a/lib/curl_md4.h +++ b/lib/curl_des.h @@ -1,5 +1,5 @@ -#ifndef HEADER_CURL_MD4_H -#define HEADER_CURL_MD4_H +#ifndef HEADER_CURL_DES_H +#define HEADER_CURL_DES_H /*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2010, Daniel Stenberg, , et al. + * Copyright (C) 2015, Steve Holme, . * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -24,10 +24,11 @@ #include "curl_setup.h" -/* NSS crypto library does not provide the MD4 hash algorithm, so that we have - * a local implementation of it */ -#ifdef USE_NSS -void Curl_md4it(unsigned char *output, const unsigned char *input, size_t len); -#endif /* USE_NSS */ +#if defined(USE_NTLM) && (!defined(USE_OPENSSL) || defined(HAVE_BORINGSSL)) -#endif /* HEADER_CURL_MD4_H */ +/* Applies odd parity to the given byte array */ +void Curl_des_set_odd_parity(unsigned char *bytes, size_t length); + +#endif /* USE_NTLM && (!USE_OPENSSL || HAVE_BORINGSSL) */ + +#endif /* HEADER_CURL_DES_H */ diff --git a/lib/curl_endian.c b/lib/curl_endian.c new file mode 100644 index 0000000..bcd66ed --- /dev/null +++ b/lib/curl_endian.c @@ -0,0 +1,236 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ + +#include "curl_setup.h" + +#include "curl_endian.h" + +/* + * Curl_read16_le() + * + * This function converts a 16-bit integer from the little endian format, as + * used in the incoming package to whatever endian format we're using + * natively. + * + * Parameters: + * + * buf [in] - A pointer to a 2 byte buffer. + * + * Returns the integer. + */ +unsigned short Curl_read16_le(unsigned char *buf) +{ + return (unsigned short)(((unsigned short)buf[0]) | + ((unsigned short)buf[1] << 8)); +} + +/* + * Curl_read32_le() + * + * This function converts a 32-bit integer from the little endian format, as + * used in the incoming package to whatever endian format we're using + * natively. + * + * Parameters: + * + * buf [in] - A pointer to a 4 byte buffer. + * + * Returns the integer. + */ +unsigned int Curl_read32_le(unsigned char *buf) +{ + return ((unsigned int)buf[0]) | ((unsigned int)buf[1] << 8) | + ((unsigned int)buf[2] << 16) | ((unsigned int)buf[3] << 24); +} + +#if (CURL_SIZEOF_CURL_OFF_T > 4) +/* + * Curl_read64_le() + * + * This function converts a 64-bit integer from the little endian format, as + * used in the incoming package to whatever endian format we're using + * natively. + * + * Parameters: + * + * buf [in] - A pointer to a 8 byte buffer. + * + * Returns the integer. + */ +#if defined(HAVE_LONGLONG) +unsigned long long Curl_read64_le(unsigned char *buf) +{ + return ((unsigned long long)buf[0]) | + ((unsigned long long)buf[1] << 8) | + ((unsigned long long)buf[2] << 16) | + ((unsigned long long)buf[3] << 24) | + ((unsigned long long)buf[4] << 32) | + ((unsigned long long)buf[5] << 40) | + ((unsigned long long)buf[6] << 48) | + ((unsigned long long)buf[7] << 56); +} +#else +unsigned __int64 Curl_read64_le(unsigned char *buf) +{ + return ((unsigned __int64)buf[0]) | ((unsigned __int64)buf[1] << 8) | + ((unsigned __int64)buf[2] << 16) | ((unsigned __int64)buf[3] << 24) | + ((unsigned __int64)buf[4] << 32) | ((unsigned __int64)buf[5] << 40) | + ((unsigned __int64)buf[6] << 48) | ((unsigned __int64)buf[7] << 56); +} +#endif + +#endif /* CURL_SIZEOF_CURL_OFF_T > 4 */ + +/* + * Curl_read16_be() + * + * This function converts a 16-bit integer from the big endian format, as + * used in the incoming package to whatever endian format we're using + * natively. + * + * Parameters: + * + * buf [in] - A pointer to a 2 byte buffer. + * + * Returns the integer. + */ +unsigned short Curl_read16_be(unsigned char *buf) +{ + return (unsigned short)(((unsigned short)buf[0] << 8) | + ((unsigned short)buf[1])); +} + +/* + * Curl_read32_be() + * + * This function converts a 32-bit integer from the big endian format, as + * used in the incoming package to whatever endian format we're using + * natively. + * + * Parameters: + * + * buf [in] - A pointer to a 4 byte buffer. + * + * Returns the integer. + */ +unsigned int Curl_read32_be(unsigned char *buf) +{ + return ((unsigned int)buf[0] << 24) | ((unsigned int)buf[1] << 16) | + ((unsigned int)buf[2] << 8) | ((unsigned int)buf[3]); +} + +#if (CURL_SIZEOF_CURL_OFF_T > 4) +/* + * Curl_read64_be() + * + * This function converts a 64-bit integer from the big endian format, as + * used in the incoming package to whatever endian format we're using + * natively. + * + * Parameters: + * + * buf [in] - A pointer to a 8 byte buffer. + * + * Returns the integer. + */ +#if defined(HAVE_LONGLONG) +unsigned long long Curl_read64_be(unsigned char *buf) +{ + return ((unsigned long long)buf[0] << 56) | + ((unsigned long long)buf[1] << 48) | + ((unsigned long long)buf[2] << 40) | + ((unsigned long long)buf[3] << 32) | + ((unsigned long long)buf[4] << 24) | + ((unsigned long long)buf[5] << 16) | + ((unsigned long long)buf[6] << 8) | + ((unsigned long long)buf[7]); +} +#else +unsigned __int64 Curl_read64_be(unsigned char *buf) +{ + return ((unsigned __int64)buf[0] << 56) | ((unsigned __int64)buf[1] << 48) | + ((unsigned __int64)buf[2] << 40) | ((unsigned __int64)buf[3] << 32) | + ((unsigned __int64)buf[4] << 24) | ((unsigned __int64)buf[5] << 16) | + ((unsigned __int64)buf[6] << 8) | ((unsigned __int64)buf[7]); +} +#endif + +#endif /* CURL_SIZEOF_CURL_OFF_T > 4 */ + +/* + * Curl_write16_le() + * + * This function converts a 16-bit integer from the native endian format, + * to little endian format ready for sending down the wire. + * + * Parameters: + * + * value [in] - The 16-bit integer value. + * buffer [in] - A pointer to the output buffer. + */ +void Curl_write16_le(const short value, unsigned char *buffer) +{ + buffer[0] = (char)(value & 0x00FF); + buffer[1] = (char)((value & 0xFF00) >> 8); +} + +/* + * Curl_write32_le() + * + * This function converts a 32-bit integer from the native endian format, + * to little endian format ready for sending down the wire. + * + * Parameters: + * + * value [in] - The 32-bit integer value. + * buffer [in] - A pointer to the output buffer. + */ +void Curl_write32_le(const int value, unsigned char *buffer) +{ + buffer[0] = (char)(value & 0x000000FF); + buffer[1] = (char)((value & 0x0000FF00) >> 8); + buffer[2] = (char)((value & 0x00FF0000) >> 16); + buffer[3] = (char)((value & 0xFF000000) >> 24); +} + +#if (CURL_SIZEOF_CURL_OFF_T > 4) +/* + * Curl_write64_le() + * + * This function converts a 64-bit integer from the native endian format, + * to little endian format ready for sending down the wire. + * + * Parameters: + * + * value [in] - The 64-bit integer value. + * buffer [in] - A pointer to the output buffer. + */ +#if defined(HAVE_LONGLONG) +void Curl_write64_le(const long long value, unsigned char *buffer) +#else +void Curl_write64_le(const __int64 value, unsigned char *buffer) +#endif +{ + Curl_write32_le((int)value, buffer); + Curl_write32_le((int)(value >> 32), buffer + 4); +} +#endif /* CURL_SIZEOF_CURL_OFF_T > 4 */ diff --git a/lib/curl_endian.h b/lib/curl_endian.h new file mode 100644 index 0000000..e384279 --- /dev/null +++ b/lib/curl_endian.h @@ -0,0 +1,70 @@ +#ifndef HEADER_CURL_ENDIAN_H +#define HEADER_CURL_ENDIAN_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ + +/* Converts a 16-bit integer from little endian */ +unsigned short Curl_read16_le(unsigned char *buf); + +/* Converts a 32-bit integer from little endian */ +unsigned int Curl_read32_le(unsigned char *buf); + +#if (CURL_SIZEOF_CURL_OFF_T > 4) +/* Converts a 64-bit integer from little endian */ +#if defined(HAVE_LONGLONG) +unsigned long long Curl_read64_le(unsigned char *buf); +#else +unsigned __int64 Curl_read64_le(unsigned char *buf); +#endif +#endif + +/* Converts a 16-bit integer from big endian */ +unsigned short Curl_read16_be(unsigned char *buf); + +/* Converts a 32-bit integer from big endian */ +unsigned int Curl_read32_be(unsigned char *buf); + +#if (CURL_SIZEOF_CURL_OFF_T > 4) +/* Converts a 64-bit integer from big endian */ +#if defined(HAVE_LONGLONG) +unsigned long long Curl_read64_be(unsigned char *buf); +#else +unsigned __int64 Curl_read64_be(unsigned char *buf); +#endif +#endif + +/* Converts a 16-bit integer to little endian */ +void Curl_write16_le(const short value, unsigned char *buffer); + +/* Converts a 32-bit integer to little endian */ +void Curl_write32_le(const int value, unsigned char *buffer); + +#if (CURL_SIZEOF_CURL_OFF_T > 4) +/* Converts a 64-bit integer to little endian */ +#if defined(HAVE_LONGLONG) +void Curl_write64_le(const long long value, unsigned char *buffer); +#else +void Curl_write64_le(const __int64 value, unsigned char *buffer); +#endif +#endif + +#endif /* HEADER_CURL_ENDIAN_H */ diff --git a/lib/curl_fnmatch.c b/lib/curl_fnmatch.c index 63f67b9..1e53918 100644 --- a/lib/curl_fnmatch.c +++ b/lib/curl_fnmatch.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -23,11 +23,8 @@ #include "curl_setup.h" #include "curl_fnmatch.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include - #include "curl_memory.h" + /* The last #include file should be: */ #include "memdebug.h" diff --git a/lib/curl_gssapi.c b/lib/curl_gssapi.c index 232b3ef..9baece5 100644 --- a/lib/curl_gssapi.c +++ b/lib/curl_gssapi.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 2011 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 2011 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -27,9 +27,9 @@ #include "curl_gssapi.h" #include "sendf.h" -static const char spnego_oid_bytes[] = "\x2b\x06\x01\x05\x05\x02"; +static char spnego_oid_bytes[] = "\x2b\x06\x01\x05\x05\x02"; gss_OID_desc Curl_spnego_mech_oid = { 6, &spnego_oid_bytes }; -static const char krb5_oid_bytes[] = "\x2a\x86\x48\x86\xf7\x12\x01\x02\x02"; +static char krb5_oid_bytes[] = "\x2a\x86\x48\x86\xf7\x12\x01\x02\x02"; gss_OID_desc Curl_krb5_mech_oid = { 9, &krb5_oid_bytes }; OM_uint32 Curl_gss_init_sec_context( @@ -41,9 +41,13 @@ OM_uint32 Curl_gss_init_sec_context( gss_channel_bindings_t input_chan_bindings, gss_buffer_t input_token, gss_buffer_t output_token, + const bool mutual_auth, OM_uint32 *ret_flags) { - OM_uint32 req_flags = GSS_C_MUTUAL_FLAG | GSS_C_REPLAY_FLAG; + OM_uint32 req_flags = GSS_C_REPLAY_FLAG; + + if(mutual_auth) + req_flags |= GSS_C_MUTUAL_FLAG; if(data->set.gssapi_delegation & CURLGSSAPI_DELEGATION_POLICY_FLAG) { #ifdef GSS_C_DELEG_POLICY_FLAG @@ -72,4 +76,45 @@ OM_uint32 Curl_gss_init_sec_context( NULL /* time_rec */); } +/* + * Curl_gss_log_error() + * + * This is used to log a GSS-API error status. + * + * Parameters: + * + * data [in] - The session handle. + * status [in] - The status code. + * prefix [in] - The prefix of the log message. + */ +void Curl_gss_log_error(struct SessionHandle *data, OM_uint32 status, + const char *prefix) +{ + OM_uint32 maj_stat; + OM_uint32 min_stat; + OM_uint32 msg_ctx = 0; + gss_buffer_desc status_string; + char buf[1024]; + size_t len; + + snprintf(buf, sizeof(buf), "%s", prefix); + len = strlen(buf); + do { + maj_stat = gss_display_status(&min_stat, + status, + GSS_C_MECH_CODE, + GSS_C_NO_OID, + &msg_ctx, + &status_string); + if(sizeof(buf) > len + status_string.length + 1) { + snprintf(buf + len, sizeof(buf) - len, + ": %s", (char*)status_string.value); + len += status_string.length; + } + gss_release_buffer(&min_stat, &status_string); + } while(!GSS_ERROR(maj_stat) && msg_ctx != 0); + + infof(data, "%s\n", buf); +} + #endif /* HAVE_GSSAPI */ diff --git a/lib/curl_gssapi.h b/lib/curl_gssapi.h index b91bd7e..19aab64 100644 --- a/lib/curl_gssapi.h +++ b/lib/curl_gssapi.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 2011, Daniel Stenberg, , et al. + * Copyright (C) 2011 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -43,7 +43,6 @@ extern gss_OID_desc Curl_spnego_mech_oid; extern gss_OID_desc Curl_krb5_mech_oid; /* Common method for using GSS-API */ - OM_uint32 Curl_gss_init_sec_context( struct SessionHandle *data, OM_uint32 *minor_status, @@ -53,8 +52,24 @@ OM_uint32 Curl_gss_init_sec_context( gss_channel_bindings_t input_chan_bindings, gss_buffer_t input_token, gss_buffer_t output_token, + const bool mutual_auth, OM_uint32 *ret_flags); +/* Helper to log a GSS-API error status */ +void Curl_gss_log_error(struct SessionHandle *data, OM_uint32 status, + const char *prefix); + +/* Provide some definitions missing in old headers */ +#ifdef HAVE_OLD_GSSMIT +#define GSS_C_NT_HOSTBASED_SERVICE gss_nt_service_name +#define NCOMPAT 1 +#endif + +/* Define our privacy and integrity protection values */ +#define GSSAUTH_P_NONE 1 +#define GSSAUTH_P_INTEGRITY 2 +#define GSSAUTH_P_PRIVACY 4 + #endif /* HAVE_GSSAPI */ #endif /* HEADER_CURL_GSSAPI_H */ diff --git a/lib/curl_md4.h b/lib/curl_md4.h index b0be9cf..13c7903 100644 --- a/lib/curl_md4.h +++ b/lib/curl_md4.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2010, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -24,10 +24,12 @@ #include "curl_setup.h" -/* NSS crypto library does not provide the MD4 hash algorithm, so that we have - * a local implementation of it */ -#ifdef USE_NSS +/* NSS and OS/400 crypto library do not provide the MD4 hash algorithm, so + * that we have a local implementation of it */ +#if defined(USE_NSS) || defined(USE_OS400CRYPTO) + void Curl_md4it(unsigned char *output, const unsigned char *input, size_t len); -#endif /* USE_NSS */ + +#endif /* defined(USE_NSS) || defined(USE_OS400CRYPTO) */ #endif /* HEADER_CURL_MD4_H */ diff --git a/lib/curl_memory.h b/lib/curl_memory.h index e3cdc72..bc744cc 100644 --- a/lib/curl_memory.h +++ b/lib/curl_memory.h @@ -28,6 +28,9 @@ * File curl_memory.h must be included by _all_ *.c source files * that use memory related functions strdup, malloc, calloc, realloc * or free, and given source file is used to build libcurl library. + * It should be included immediately before memdebug.h as the last files + * included to avoid undesired interaction with other memory function + * headers in dependent libraries. * * There is nearly no exception to above rule. All libcurl source * files in 'lib' subdirectory as well as those living deep inside diff --git a/lib/curl_memrchr.c b/lib/curl_memrchr.c index a71c2bb..6722c6a 100644 --- a/lib/curl_memrchr.c +++ b/lib/curl_memrchr.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -21,13 +21,9 @@ ***************************************************************************/ #include "curl_setup.h" - #include "curl_memrchr.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include - #include "curl_memory.h" + /* The last #include file should be: */ #include "memdebug.h" diff --git a/lib/curl_multibyte.c b/lib/curl_multibyte.c index 6c02239..403d005 100644 --- a/lib/curl_multibyte.c +++ b/lib/curl_multibyte.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -22,18 +22,16 @@ #include "curl_setup.h" -#if defined(USE_WIN32_IDN) || (defined(USE_WINDOWS_SSPI) && defined(UNICODE)) +#if defined(USE_WIN32_IDN) || ((defined(USE_WINDOWS_SSPI) || \ + defined(USE_WIN32_LDAP)) && defined(UNICODE)) /* * MultiByte conversions using Windows kernel32 library. */ #include "curl_multibyte.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include - #include "curl_memory.h" + /* The last #include file should be: */ #include "memdebug.h" @@ -49,7 +47,8 @@ wchar_t *Curl_convert_UTF8_to_wchar(const char *str_utf8) if(str_w) { if(MultiByteToWideChar(CP_UTF8, 0, str_utf8, -1, str_w, str_w_len) == 0) { - Curl_safefree(str_w); + free(str_w); + return NULL; } } } @@ -70,7 +69,8 @@ char *Curl_convert_wchar_to_UTF8(const wchar_t *str_w) if(str_utf8) { if(WideCharToMultiByte(CP_UTF8, 0, str_w, -1, str_utf8, str_utf8_len, NULL, FALSE) == 0) { - Curl_safefree(str_utf8); + free(str_utf8); + return NULL; } } } @@ -79,4 +79,4 @@ char *Curl_convert_wchar_to_UTF8(const wchar_t *str_w) return str_utf8; } -#endif /* USE_WIN32_IDN || (USE_WINDOWS_SSPI && UNICODE) */ +#endif /* USE_WIN32_IDN || ((USE_WINDOWS_SSPI || USE_WIN32_LDAP) && UNICODE) */ diff --git a/lib/curl_multibyte.h b/lib/curl_multibyte.h index 7ee5eae..dc7ed4c 100644 --- a/lib/curl_multibyte.h +++ b/lib/curl_multibyte.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -23,7 +23,8 @@ ***************************************************************************/ #include "curl_setup.h" -#if defined(USE_WIN32_IDN) || (defined(USE_WINDOWS_SSPI) && defined(UNICODE)) +#if defined(USE_WIN32_IDN) || ((defined(USE_WINDOWS_SSPI) || \ + defined(USE_WIN32_LDAP)) && defined(UNICODE)) /* * MultiByte conversions using Windows kernel32 library. @@ -32,10 +33,11 @@ wchar_t *Curl_convert_UTF8_to_wchar(const char *str_utf8); char *Curl_convert_wchar_to_UTF8(const wchar_t *str_w); -#endif /* USE_WIN32_IDN || (USE_WINDOWS_SSPI && UNICODE) */ +#endif /* USE_WIN32_IDN || ((USE_WINDOWS_SSPI || USE_WIN32_LDAP) && UNICODE) */ -#if defined(USE_WIN32_IDN) || defined(USE_WINDOWS_SSPI) +#if defined(USE_WIN32_IDN) || defined(USE_WINDOWS_SSPI) || \ + defined(USE_WIN32_LDAP) /* * Macros Curl_convert_UTF8_to_tchar(), Curl_convert_tchar_to_UTF8() @@ -85,6 +87,6 @@ typedef union { #endif /* UNICODE */ -#endif /* USE_WIN32_IDN || USE_WINDOWS_SSPI */ +#endif /* USE_WIN32_IDN || USE_WINDOWS_SSPI || USE_WIN32_LDAP */ #endif /* HEADER_CURL_MULTIBYTE_H */ diff --git a/lib/curl_ntlm.c b/lib/curl_ntlm.c index 8c02aba..f9ddf50 100644 --- a/lib/curl_ntlm.c +++ b/lib/curl_ntlm.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -22,7 +22,7 @@ #include "curl_setup.h" -#ifdef USE_NTLM +#if !defined(CURL_DISABLE_HTTP) && defined(USE_NTLM) /* * NTLM details: @@ -39,11 +39,9 @@ #include "curl_ntlm.h" #include "curl_ntlm_msgs.h" #include "curl_ntlm_wb.h" +#include "curl_sasl.h" #include "url.h" -#include "curl_memory.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include +#include "curl_printf.h" #if defined(USE_NSS) #include "vtls/nssg.h" @@ -51,7 +49,8 @@ #include "curl_sspi.h" #endif -/* The last #include file should be: */ +/* The last #include files should be: */ +#include "curl_memory.h" #include "memdebug.h" #if DEBUG_ME @@ -69,12 +68,6 @@ CURLcode Curl_input_ntlm(struct connectdata *conn, struct ntlmdata *ntlm; CURLcode result = CURLE_OK; -#ifdef USE_NSS - result = Curl_nss_force_init(conn->data); - if(result) - return result; -#endif - ntlm = proxy ? &conn->proxyntlm : &conn->ntlm; if(checkprefix("NTLM", header)) { @@ -84,14 +77,18 @@ CURLcode Curl_input_ntlm(struct connectdata *conn, header++; if(*header) { - result = Curl_ntlm_decode_type2_message(conn->data, header, ntlm); - if(CURLE_OK != result) + result = Curl_sasl_decode_ntlm_type2_message(conn->data, header, ntlm); + if(result) return result; ntlm->state = NTLMSTATE_TYPE2; /* We got a type-2 message */ } else { - if(ntlm->state == NTLMSTATE_TYPE3) { + if(ntlm->state == NTLMSTATE_LAST) { + infof(conn->data, "NTLM auth restarted\n"); + Curl_http_ntlm_cleanup(conn); + } + else if(ntlm->state == NTLMSTATE_TYPE3) { infof(conn->data, "NTLM handshake rejected\n"); Curl_http_ntlm_cleanup(conn); ntlm->state = NTLMSTATE_NONE; @@ -112,12 +109,11 @@ CURLcode Curl_input_ntlm(struct connectdata *conn, /* * This is for creating ntlm header output */ -CURLcode Curl_output_ntlm(struct connectdata *conn, - bool proxy) +CURLcode Curl_output_ntlm(struct connectdata *conn, bool proxy) { char *base64 = NULL; size_t len = 0; - CURLcode error; + CURLcode result; /* point to the address of the pointer that holds the string to send to the server, which is for a plain host or for a HTTP proxy */ @@ -175,38 +171,40 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, case NTLMSTATE_TYPE1: default: /* for the weird cases we (re)start here */ /* Create a type-1 message */ - error = Curl_ntlm_create_type1_message(userp, passwdp, ntlm, &base64, - &len); - if(error) - return error; + result = Curl_sasl_create_ntlm_type1_message(userp, passwdp, ntlm, &base64, + &len); + if(result) + return result; if(base64) { - Curl_safefree(*allocuserpwd); + free(*allocuserpwd); *allocuserpwd = aprintf("%sAuthorization: NTLM %s\r\n", proxy ? "Proxy-" : "", base64); free(base64); if(!*allocuserpwd) return CURLE_OUT_OF_MEMORY; + DEBUG_OUT(fprintf(stderr, "**** Header %s\n ", *allocuserpwd)); } break; case NTLMSTATE_TYPE2: /* We already received the type-2 message, create a type-3 message */ - error = Curl_ntlm_create_type3_message(conn->data, userp, passwdp, - ntlm, &base64, &len); - if(error) - return error; + result = Curl_sasl_create_ntlm_type3_message(conn->data, userp, passwdp, + ntlm, &base64, &len); + if(result) + return result; if(base64) { - Curl_safefree(*allocuserpwd); + free(*allocuserpwd); *allocuserpwd = aprintf("%sAuthorization: NTLM %s\r\n", proxy ? "Proxy-" : "", base64); free(base64); if(!*allocuserpwd) return CURLE_OUT_OF_MEMORY; + DEBUG_OUT(fprintf(stderr, "**** %s\n ", *allocuserpwd)); ntlm->state = NTLMSTATE_TYPE3; /* we send a type-3 */ @@ -217,6 +215,9 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, case NTLMSTATE_TYPE3: /* connection is already authenticated, * don't send a header in future requests */ + ntlm->state = NTLMSTATE_LAST; + + case NTLMSTATE_LAST: Curl_safefree(*allocuserpwd); authp->done = TRUE; break; @@ -227,22 +228,12 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, void Curl_http_ntlm_cleanup(struct connectdata *conn) { -#ifdef USE_WINDOWS_SSPI - Curl_ntlm_sspi_cleanup(&conn->ntlm); - Curl_ntlm_sspi_cleanup(&conn->proxyntlm); -#elif defined(NTLM_WB_ENABLED) - Curl_ntlm_wb_cleanup(conn); -#else - (void)conn; -#endif + Curl_sasl_ntlm_cleanup(&conn->ntlm); + Curl_sasl_ntlm_cleanup(&conn->proxyntlm); -#ifndef USE_WINDOWS_SSPI - Curl_safefree(conn->ntlm.target_info); - conn->ntlm.target_info_len = 0; - - Curl_safefree(conn->proxyntlm.target_info); - conn->proxyntlm.target_info_len = 0; +#if defined(NTLM_WB_ENABLED) + Curl_ntlm_wb_cleanup(conn); #endif } -#endif /* USE_NTLM */ +#endif /* !CURL_DISABLE_HTTP && USE_NTLM */ diff --git a/lib/curl_ntlm.h b/lib/curl_ntlm.h index 21a9e9e..947eac2 100644 --- a/lib/curl_ntlm.h +++ b/lib/curl_ntlm.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -24,7 +24,7 @@ #include "curl_setup.h" -#ifdef USE_NTLM +#if !defined(CURL_DISABLE_HTTP) && defined(USE_NTLM) /* this is for ntlm header input */ CURLcode Curl_input_ntlm(struct connectdata *conn, bool proxy, @@ -35,10 +35,6 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, bool proxy); void Curl_http_ntlm_cleanup(struct connectdata *conn); -#else - -#define Curl_http_ntlm_cleanup(a) Curl_nop_stmt - -#endif +#endif /* !CURL_DISABLE_HTTP && USE_NTLM */ #endif /* HEADER_CURL_NTLM_H */ diff --git a/lib/curl_ntlm_core.c b/lib/curl_ntlm_core.c index b011626..2e5b573 100644 --- a/lib/curl_ntlm_core.c +++ b/lib/curl_ntlm_core.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -22,7 +22,7 @@ #include "curl_setup.h" -#if defined(USE_NTLM) && !defined(USE_WINDOWS_SSPI) +#if defined(USE_NTLM) /* * NTLM details: @@ -31,7 +31,9 @@ * http://www.innovation.ch/java/ntlm.html */ -#ifdef USE_SSLEAY +#if !defined(USE_WINDOWS_SSPI) || defined(USE_WIN32_CRYPTO) + +#ifdef USE_OPENSSL # ifdef USE_OPENSSL # include @@ -87,6 +89,11 @@ # include # include +#elif defined(USE_OS400CRYPTO) +# include "cipher.mih" /* mih/cipher */ +# include "curl_md4.h" +#elif defined(USE_WIN32_CRYPTO) +# include #else # error "Can't compile NTLM support without a crypto library." #endif @@ -94,32 +101,27 @@ #include "urldata.h" #include "non-ascii.h" #include "rawstr.h" -#include "curl_memory.h" #include "curl_ntlm_core.h" #include "curl_md5.h" #include "curl_hmac.h" #include "warnless.h" +#include "curl_endian.h" +#include "curl_des.h" +#include "curl_printf.h" -#define _MPRINTF_REPLACE /* use our functions only */ -#include - -/* The last #include file should be: */ +/* The last #include files should be: */ +#include "curl_memory.h" #include "memdebug.h" #define NTLM_HMAC_MD5_LEN (16) #define NTLMv2_BLOB_SIGNATURE "\x01\x01\x00\x00" #define NTLMv2_BLOB_LEN (44 -16 + ntlm->target_info_len + 4) -#ifdef USE_SSLEAY /* - * Turns a 56 bit key into the 64 bit, odd parity key and sets the key. The - * key schedule ks is also set. - */ -static void setup_des_key(const unsigned char *key_56, - DES_key_schedule DESKEYARG(ks)) +* Turns a 56-bit key into being 64-bit wide. +*/ +static void extend_key_56_to_64(const unsigned char *key_56, char *key) { - DES_cblock key; - key[0] = key_56[0]; key[1] = (unsigned char)(((key_56[0] << 7) & 0xFF) | (key_56[1] >> 1)); key[2] = (unsigned char)(((key_56[1] << 6) & 0xFF) | (key_56[2] >> 2)); @@ -128,36 +130,47 @@ static void setup_des_key(const unsigned char *key_56, key[5] = (unsigned char)(((key_56[4] << 3) & 0xFF) | (key_56[5] >> 5)); key[6] = (unsigned char)(((key_56[5] << 2) & 0xFF) | (key_56[6] >> 6)); key[7] = (unsigned char) ((key_56[6] << 1) & 0xFF); - - DES_set_odd_parity(&key); - DES_set_key(&key, ks); } -#else /* defined(USE_SSLEAY) */ - +#ifdef USE_OPENSSL /* - * Turns a 56 bit key into the 64 bit, odd parity key. Used by GnuTLS and NSS. + * Turns a 56 bit key into the 64 bit, odd parity key and sets the key. The + * key schedule ks is also set. */ -static void extend_key_56_to_64(const unsigned char *key_56, char *key) +static void setup_des_key(const unsigned char *key_56, + DES_key_schedule DESKEYARG(ks)) { - key[0] = key_56[0]; - key[1] = (unsigned char)(((key_56[0] << 7) & 0xFF) | (key_56[1] >> 1)); - key[2] = (unsigned char)(((key_56[1] << 6) & 0xFF) | (key_56[2] >> 2)); - key[3] = (unsigned char)(((key_56[2] << 5) & 0xFF) | (key_56[3] >> 3)); - key[4] = (unsigned char)(((key_56[3] << 4) & 0xFF) | (key_56[4] >> 4)); - key[5] = (unsigned char)(((key_56[4] << 3) & 0xFF) | (key_56[5] >> 5)); - key[6] = (unsigned char)(((key_56[5] << 2) & 0xFF) | (key_56[6] >> 6)); - key[7] = (unsigned char) ((key_56[6] << 1) & 0xFF); + DES_cblock key; + + /* Expand the 56-bit key to 64-bits */ + extend_key_56_to_64(key_56, (char *) key); + + /* Set the key parity to odd */ +#if defined(HAVE_BORINGSSL) + Curl_des_set_odd_parity((unsigned char *) &key, sizeof(key)); +#else + DES_set_odd_parity(&key); +#endif + + /* Set the key */ + DES_set_key(&key, ks); } -#if defined(USE_GNUTLS_NETTLE) +#elif defined(USE_GNUTLS_NETTLE) static void setup_des_key(const unsigned char *key_56, struct des_ctx *des) { char key[8]; + + /* Expand the 56-bit key to 64-bits */ extend_key_56_to_64(key_56, key); - des_set_key(des, (const uint8_t*)key); + + /* Set the key parity to odd */ + Curl_des_set_odd_parity((unsigned char *) key, sizeof(key)); + + /* Set the key */ + des_set_key(des, (const uint8_t *) key); } #elif defined(USE_GNUTLS) @@ -169,8 +182,15 @@ static void setup_des_key(const unsigned char *key_56, gcry_cipher_hd_t *des) { char key[8]; + + /* Expand the 56-bit key to 64-bits */ extend_key_56_to_64(key_56, key); - gcry_cipher_setkey(*des, key, 8); + + /* Set the key parity to odd */ + Curl_des_set_odd_parity((unsigned char *) key, sizeof(key)); + + /* Set the key */ + gcry_cipher_setkey(*des, key, sizeof(key)); } #elif defined(USE_NSS) @@ -198,16 +218,21 @@ static bool encrypt_des(const unsigned char *in, unsigned char *out, if(!slot) return FALSE; - /* expand the 56 bit key to 64 bit and wrap by NSS */ + /* Expand the 56-bit key to 64-bits */ extend_key_56_to_64(key_56, key); + + /* Set the key parity to odd */ + Curl_des_set_odd_parity((unsigned char *) key, sizeof(key)); + + /* Import the key */ key_item.data = (unsigned char *)key; - key_item.len = /* hard-wired */ 8; + key_item.len = sizeof(key); symkey = PK11_ImportSymKey(slot, mech, PK11_OriginUnwrap, CKA_ENCRYPT, &key_item, NULL); if(!symkey) goto fail; - /* create DES encryption context */ + /* Create the DES encryption context */ param = PK11_ParamFromIV(mech, /* no IV in ECB mode */ NULL); if(!param) goto fail; @@ -215,7 +240,7 @@ static bool encrypt_des(const unsigned char *in, unsigned char *out, if(!ctx) goto fail; - /* perform the encryption */ + /* Perform the encryption */ if(SECSuccess == PK11_CipherOp(ctx, out, &out_len, /* outbuflen */ 8, (unsigned char *)in, /* inbuflen */ 8) && SECSuccess == PK11_Finalize(ctx)) @@ -242,16 +267,95 @@ static bool encrypt_des(const unsigned char *in, unsigned char *out, size_t out_len; CCCryptorStatus err; + /* Expand the 56-bit key to 64-bits */ extend_key_56_to_64(key_56, key); + + /* Set the key parity to odd */ + Curl_des_set_odd_parity((unsigned char *) key, sizeof(key)); + + /* Perform the encryption */ err = CCCrypt(kCCEncrypt, kCCAlgorithmDES, kCCOptionECBMode, key, kCCKeySizeDES, NULL, in, 8 /* inbuflen */, out, 8 /* outbuflen */, &out_len); + return err == kCCSuccess; } -#endif /* defined(USE_DARWINSSL) */ +#elif defined(USE_OS400CRYPTO) -#endif /* defined(USE_SSLEAY) */ +static bool encrypt_des(const unsigned char *in, unsigned char *out, + const unsigned char *key_56) +{ + char key[8]; + _CIPHER_Control_T ctl; + + /* Setup the cipher control structure */ + ctl.Func_ID = ENCRYPT_ONLY; + ctl.Data_Len = sizeof(key); + + /* Expand the 56-bit key to 64-bits */ + extend_key_56_to_64(key_56, ctl.Crypto_Key); + + /* Set the key parity to odd */ + Curl_des_set_odd_parity((unsigned char *) ctl.Crypto_Key, ctl.Data_Len); + + /* Perform the encryption */ + _CIPHER((_SPCPTR *) &out, &ctl, (_SPCPTR *) &in); + + return TRUE; +} + +#elif defined(USE_WIN32_CRYPTO) + +static bool encrypt_des(const unsigned char *in, unsigned char *out, + const unsigned char *key_56) +{ + HCRYPTPROV hprov; + HCRYPTKEY hkey; + struct { + BLOBHEADER hdr; + unsigned int len; + char key[8]; + } blob; + DWORD len = 8; + + /* Acquire the crypto provider */ + if(!CryptAcquireContext(&hprov, NULL, NULL, PROV_RSA_FULL, + CRYPT_VERIFYCONTEXT)) + return FALSE; + + /* Setup the key blob structure */ + memset(&blob, 0, sizeof(blob)); + blob.hdr.bType = PLAINTEXTKEYBLOB; + blob.hdr.bVersion = 2; + blob.hdr.aiKeyAlg = CALG_DES; + blob.len = sizeof(blob.key); + + /* Expand the 56-bit key to 64-bits */ + extend_key_56_to_64(key_56, blob.key); + + /* Set the key parity to odd */ + Curl_des_set_odd_parity((unsigned char *) blob.key, sizeof(blob.key)); + + /* Import the key */ + if(!CryptImportKey(hprov, (BYTE *) &blob, sizeof(blob), 0, 0, &hkey)) { + CryptReleaseContext(hprov, 0); + + return FALSE; + } + + memcpy(out, in, 8); + + /* Perform the encryption */ + CryptEncrypt(hkey, 0, FALSE, 0, out, &len, len); + + CryptDestroyKey(hkey); + CryptReleaseContext(hprov, 0); + + return TRUE; +} + +#endif /* defined(USE_WIN32_CRYPTO) */ /* * takes a 21 byte array and treats it as 3 56-bit DES keys. The @@ -262,7 +366,7 @@ void Curl_ntlm_core_lm_resp(const unsigned char *keys, const unsigned char *plaintext, unsigned char *results) { -#ifdef USE_SSLEAY +#ifdef USE_OPENSSL DES_key_schedule ks; setup_des_key(keys, DESKEY(ks)); @@ -301,7 +405,8 @@ void Curl_ntlm_core_lm_resp(const unsigned char *keys, setup_des_key(keys + 14, &des); gcry_cipher_encrypt(des, results + 16, 8, plaintext, 8); gcry_cipher_close(des); -#elif defined(USE_NSS) || defined(USE_DARWINSSL) +#elif defined(USE_NSS) || defined(USE_DARWINSSL) || defined(USE_OS400CRYPTO) \ + || defined(USE_WIN32_CRYPTO) encrypt_des(plaintext, results, keys); encrypt_des(plaintext, results + 8, keys + 7); encrypt_des(plaintext, results + 16, keys + 14); @@ -311,11 +416,11 @@ void Curl_ntlm_core_lm_resp(const unsigned char *keys, /* * Set up lanmanager hashed password */ -void Curl_ntlm_core_mk_lm_hash(struct SessionHandle *data, - const char *password, - unsigned char *lmbuffer /* 21 bytes */) +CURLcode Curl_ntlm_core_mk_lm_hash(struct SessionHandle *data, + const char *password, + unsigned char *lmbuffer /* 21 bytes */) { - CURLcode res; + CURLcode result; unsigned char pw[14]; static const unsigned char magic[] = { 0x4B, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25 /* i.e. KGS!@#$% */ @@ -329,14 +434,14 @@ void Curl_ntlm_core_mk_lm_hash(struct SessionHandle *data, * The LanManager hashed password needs to be created using the * password in the network encoding not the host encoding. */ - res = Curl_convert_to_network(data, (char *)pw, 14); - if(res) - return; + result = Curl_convert_to_network(data, (char *)pw, 14); + if(result) + return result; { /* Create LanManager hashed password. */ -#ifdef USE_SSLEAY +#ifdef USE_OPENSSL DES_key_schedule ks; setup_des_key(pw, DESKEY(ks)); @@ -364,13 +469,16 @@ void Curl_ntlm_core_mk_lm_hash(struct SessionHandle *data, setup_des_key(pw + 7, &des); gcry_cipher_encrypt(des, lmbuffer + 8, 8, magic, 8); gcry_cipher_close(des); -#elif defined(USE_NSS) || defined(USE_DARWINSSL) +#elif defined(USE_NSS) || defined(USE_DARWINSSL) || defined(USE_OS400CRYPTO) \ + || defined(USE_WIN32_CRYPTO) encrypt_des(magic, lmbuffer, pw); encrypt_des(magic, lmbuffer + 8, pw + 7); #endif memset(lmbuffer + 16, 0, 21 - 16); } + + return CURLE_OK; } #if USE_NTRESPONSES @@ -384,6 +492,8 @@ static void ascii_to_unicode_le(unsigned char *dest, const char *src, } } +#if USE_NTLM_V2 && !defined(USE_WINDOWS_SSPI) + static void ascii_uppercase_to_unicode_le(unsigned char *dest, const char *src, size_t srclen) { @@ -394,26 +504,11 @@ static void ascii_uppercase_to_unicode_le(unsigned char *dest, } } -static void write32_le(const int value, unsigned char *buffer) -{ - buffer[0] = (char)(value & 0x000000FF); - buffer[1] = (char)((value & 0x0000FF00) >> 8); - buffer[2] = (char)((value & 0x00FF0000) >> 16); - buffer[3] = (char)((value & 0xFF000000) >> 24); -} - -#if defined(HAVE_LONGLONG) -static void write64_le(const long long value, unsigned char *buffer) -#else -static void write64_le(const __int64 value, unsigned char *buffer) -#endif -{ - write32_le((int)value, buffer); - write32_le((int)(value >> 32), buffer + 4); -} +#endif /* USE_NTLM_V2 && !USE_WINDOWS_SSPI */ /* * Set up nt hashed passwords + * @unittest: 1600 */ CURLcode Curl_ntlm_core_mk_nt_hash(struct SessionHandle *data, const char *password, @@ -437,7 +532,7 @@ CURLcode Curl_ntlm_core_mk_nt_hash(struct SessionHandle *data, { /* Create NT hashed password. */ -#ifdef USE_SSLEAY +#ifdef USE_OPENSSL MD4_CTX MD4pw; MD4_Init(&MD4pw); MD4_Update(&MD4pw, pw, 2 * len); @@ -453,10 +548,23 @@ CURLcode Curl_ntlm_core_mk_nt_hash(struct SessionHandle *data, gcry_md_write(MD4pw, pw, 2 * len); memcpy (ntbuffer, gcry_md_read (MD4pw, 0), MD4_DIGEST_LENGTH); gcry_md_close(MD4pw); -#elif defined(USE_NSS) +#elif defined(USE_NSS) || defined(USE_OS400CRYPTO) Curl_md4it(ntbuffer, pw, 2 * len); #elif defined(USE_DARWINSSL) (void)CC_MD4(pw, (CC_LONG)(2 * len), ntbuffer); +#elif defined(USE_WIN32_CRYPTO) + HCRYPTPROV hprov; + if(CryptAcquireContext(&hprov, NULL, NULL, PROV_RSA_FULL, + CRYPT_VERIFYCONTEXT)) { + HCRYPTHASH hhash; + if(CryptCreateHash(hprov, CALG_MD4, 0, 0, &hhash)) { + DWORD length = 16; + CryptHashData(hhash, pw, (unsigned int)len * 2, 0); + CryptGetHashParam(hhash, HP_HASHVAL, ntbuffer, &length, 0); + CryptDestroyHash(hhash); + } + CryptReleaseContext(hprov, 0); + } #endif memset(ntbuffer + 16, 0, 21 - 16); @@ -467,6 +575,8 @@ CURLcode Curl_ntlm_core_mk_nt_hash(struct SessionHandle *data, return CURLE_OK; } +#if USE_NTLM_V2 && !defined(USE_WINDOWS_SSPI) + /* This returns the HMAC MD5 digest */ CURLcode Curl_hmac_md5(const unsigned char *key, unsigned int keylen, const unsigned char *data, unsigned int datalen, @@ -497,7 +607,7 @@ CURLcode Curl_ntlm_core_mk_ntlmv2_hash(const char *user, size_t userlen, /* Unicode representation */ size_t identity_len = (userlen + domlen) * 2; unsigned char *identity = malloc(identity_len); - CURLcode res = CURLE_OK; + CURLcode result = CURLE_OK; if(!identity) return CURLE_OUT_OF_MEMORY; @@ -505,12 +615,12 @@ CURLcode Curl_ntlm_core_mk_ntlmv2_hash(const char *user, size_t userlen, ascii_uppercase_to_unicode_le(identity, user, userlen); ascii_to_unicode_le(identity + (userlen << 1), domain, domlen); - res = Curl_hmac_md5(ntlmhash, 16, identity, curlx_uztoui(identity_len), - ntlmv2hash); + result = Curl_hmac_md5(ntlmhash, 16, identity, curlx_uztoui(identity_len), + ntlmv2hash); - Curl_safefree(identity); + free(identity); - return res; + return result; } /* @@ -559,7 +669,7 @@ CURLcode Curl_ntlm_core_mk_ntlmv2_resp(unsigned char *ntlmv2hash, #else __int64 tw; #endif - CURLcode res = CURLE_OK; + CURLcode result = CURLE_OK; /* Calculate the timestamp */ #ifdef DEBUGBUILD @@ -586,17 +696,17 @@ CURLcode Curl_ntlm_core_mk_ntlmv2_resp(unsigned char *ntlmv2hash, "%c%c%c%c", /* Reserved = 0 */ 0, 0, 0, 0); - write64_le(tw, ptr + 24); + Curl_write64_le(tw, ptr + 24); memcpy(ptr + 32, challenge_client, 8); memcpy(ptr + 44, ntlm->target_info, ntlm->target_info_len); /* Concatenate the Type 2 challenge with the BLOB and do HMAC MD5 */ memcpy(ptr + 8, &ntlm->nonce[0], 8); - res = Curl_hmac_md5(ntlmv2hash, NTLM_HMAC_MD5_LEN, ptr + 8, - NTLMv2_BLOB_LEN + 8, hmac_output); - if(res) { - Curl_safefree(ptr); - return res; + result = Curl_hmac_md5(ntlmv2hash, NTLM_HMAC_MD5_LEN, ptr + 8, + NTLMv2_BLOB_LEN + 8, hmac_output); + if(result) { + free(ptr); + return result; } /* Concatenate the HMAC MD5 output with the BLOB */ @@ -606,7 +716,7 @@ CURLcode Curl_ntlm_core_mk_ntlmv2_resp(unsigned char *ntlmv2hash, *ntresp = ptr; *ntresp_len = len; - return res; + return result; } /* @@ -630,22 +740,26 @@ CURLcode Curl_ntlm_core_mk_lmv2_resp(unsigned char *ntlmv2hash, { unsigned char data[16]; unsigned char hmac_output[16]; - CURLcode res = CURLE_OK; + CURLcode result = CURLE_OK; memcpy(&data[0], challenge_server, 8); memcpy(&data[8], challenge_client, 8); - res = Curl_hmac_md5(ntlmv2hash, 16, &data[0], 16, hmac_output); - if(res) - return res; + result = Curl_hmac_md5(ntlmv2hash, 16, &data[0], 16, hmac_output); + if(result) + return result; /* Concatenate the HMAC MD5 output with the client nonce */ memcpy(lmresp, hmac_output, 16); memcpy(lmresp+16, challenge_client, 8); - return res; + return result; } +#endif /* USE_NTLM_V2 && !USE_WINDOWS_SSPI */ + #endif /* USE_NTRESPONSES */ -#endif /* USE_NTLM && !USE_WINDOWS_SSPI */ +#endif /* !USE_WINDOWS_SSPI || USE_WIN32_CRYPTO */ + +#endif /* USE_NTLM */ diff --git a/lib/curl_ntlm_core.h b/lib/curl_ntlm_core.h index fe41cdd..3a76359 100644 --- a/lib/curl_ntlm_core.h +++ b/lib/curl_ntlm_core.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -24,9 +24,11 @@ #include "curl_setup.h" -#if defined(USE_NTLM) && !defined(USE_WINDOWS_SSPI) +#if defined(USE_NTLM) -#ifdef USE_SSLEAY +#if !defined(USE_WINDOWS_SSPI) || defined(USE_WIN32_CRYPTO) + +#ifdef USE_OPENSSL # if !defined(OPENSSL_VERSION_NUMBER) && \ !defined(HEADER_SSL_H) && !defined(HEADER_MD5_H) # error "curl_ntlm_core.h shall not be included before OpenSSL headers." @@ -34,38 +36,49 @@ # ifdef OPENSSL_NO_MD4 # define USE_NTRESPONSES 0 # define USE_NTLM2SESSION 0 +# define USE_NTLM_V2 0 # endif #endif -/* - * Define USE_NTRESPONSES to 1 in order to make the type-3 message include - * the NT response message. Define USE_NTLM2SESSION to 1 in order to make - * the type-3 message include the NTLM2Session response message, requires - * USE_NTRESPONSES defined to 1. - */ - +/* Define USE_NTRESPONSES to 1 in order to make the type-3 message include + * the NT response message. */ #ifndef USE_NTRESPONSES -# define USE_NTRESPONSES 1 -# define USE_NTLM2SESSION 1 +#define USE_NTRESPONSES 1 +#endif + +/* Define USE_NTLM2SESSION to 1 in order to make the type-3 message include the + NTLM2Session response message, requires USE_NTRESPONSES defined to 1 and a + Crypto engine that we have curl_ssl_md5sum() for. */ +#if !defined(USE_NTLM2SESSION) && USE_NTRESPONSES && !defined(USE_WIN32_CRYPTO) +#define USE_NTLM2SESSION 1 +#endif + +/* Define USE_NTLM_V2 to 1 in order to allow the type-3 message to include the + LMv2 and NTLMv2 response messages, requires USE_NTRESPONSES defined to 1 + and support for 64-bit integers. */ +#if !defined(USE_NTLM_V2) && USE_NTRESPONSES && (CURL_SIZEOF_CURL_OFF_T > 4) +#define USE_NTLM_V2 1 #endif void Curl_ntlm_core_lm_resp(const unsigned char *keys, const unsigned char *plaintext, unsigned char *results); -void Curl_ntlm_core_mk_lm_hash(struct SessionHandle *data, - const char *password, - unsigned char *lmbuffer /* 21 bytes */); +CURLcode Curl_ntlm_core_mk_lm_hash(struct SessionHandle *data, + const char *password, + unsigned char *lmbuffer /* 21 bytes */); #if USE_NTRESPONSES -CURLcode Curl_hmac_md5(const unsigned char *key, unsigned int keylen, - const unsigned char *data, unsigned int datalen, - unsigned char *output); - CURLcode Curl_ntlm_core_mk_nt_hash(struct SessionHandle *data, const char *password, unsigned char *ntbuffer /* 21 bytes */); +#if USE_NTLM_V2 && !defined(USE_WINDOWS_SSPI) + +CURLcode Curl_hmac_md5(const unsigned char *key, unsigned int keylen, + const unsigned char *data, unsigned int datalen, + unsigned char *output); + CURLcode Curl_ntlm_core_mk_ntlmv2_hash(const char *user, size_t userlen, const char *domain, size_t domlen, unsigned char *ntlmhash, @@ -82,8 +95,12 @@ CURLcode Curl_ntlm_core_mk_lmv2_resp(unsigned char *ntlmv2hash, unsigned char *challenge_server, unsigned char *lmresp); -#endif +#endif /* USE_NTLM_V2 && !USE_WINDOWS_SSPI */ + +#endif /* USE_NTRESPONSES */ + +#endif /* !USE_WINDOWS_SSPI || USE_WIN32_CRYPTO */ -#endif /* USE_NTLM && !USE_WINDOWS_SSPI */ +#endif /* USE_NTLM */ #endif /* HEADER_CURL_NTLM_CORE_H */ diff --git a/lib/curl_ntlm_msgs.c b/lib/curl_ntlm_msgs.c index b807926..7f07dec 100644 --- a/lib/curl_ntlm_msgs.c +++ b/lib/curl_ntlm_msgs.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -22,7 +22,7 @@ #include "curl_setup.h" -#ifdef USE_NTLM +#if defined(USE_NTLM) && !defined(USE_WINDOWS_SSPI) /* * NTLM details: @@ -41,21 +41,21 @@ #include "curl_gethostname.h" #include "curl_multibyte.h" #include "warnless.h" -#include "curl_memory.h" - -#ifdef USE_WINDOWS_SSPI -# include "curl_sspi.h" -#endif #include "vtls/vtls.h" +#ifdef USE_NSS +#include "vtls/nssg.h" /* for Curl_nss_force_init() */ +#endif + #define BUILDING_CURL_NTLM_MSGS_C #include "curl_ntlm_msgs.h" +#include "curl_sasl.h" +#include "curl_endian.h" +#include "curl_printf.h" -#define _MPRINTF_REPLACE /* use our functions only */ -#include - -/* The last #include file should be: */ +/* The last #include files should be: */ +#include "curl_memory.h" #include "memdebug.h" /* "NTLMSSP" signature is always in ASCII regardless of the platform */ @@ -147,63 +147,38 @@ static void ntlm_print_hex(FILE *handle, const char *buf, size_t len) # define DEBUG_OUT(x) Curl_nop_stmt #endif -#ifndef USE_WINDOWS_SSPI -/* - * This function converts from the little endian format used in the - * incoming package to whatever endian format we're using natively. - * Argument is a pointer to a 4 byte buffer. - */ -static unsigned int readint_le(unsigned char *buf) -{ - return ((unsigned int)buf[0]) | ((unsigned int)buf[1] << 8) | - ((unsigned int)buf[2] << 16) | ((unsigned int)buf[3] << 24); -} - -/* - * This function converts from the little endian format used in the incoming - * package to whatever endian format we're using natively. Argument is a - * pointer to a 2 byte buffer. - */ -static unsigned int readshort_le(unsigned char *buf) -{ - return ((unsigned int)buf[0]) | ((unsigned int)buf[1] << 8); -} - /* - * Curl_ntlm_decode_type2_target() + * ntlm_decode_type2_target() * * This is used to decode the "target info" in the ntlm type-2 message * received. * * Parameters: * - * data [in] - Pointer to the session handle - * buffer [in] - The decoded base64 ntlm header of Type 2 - * size [in] - The input buffer size, atleast 32 bytes - * ntlm [in] - Pointer to ntlm data struct being used and modified. + * data [in] - The session handle. + * buffer [in] - The decoded type-2 message. + * size [in] - The input buffer size, at least 32 bytes. + * ntlm [in/out] - The ntlm data struct being used and modified. * * Returns CURLE_OK on success. */ -CURLcode Curl_ntlm_decode_type2_target(struct SessionHandle *data, - unsigned char *buffer, - size_t size, - struct ntlmdata *ntlm) +static CURLcode ntlm_decode_type2_target(struct SessionHandle *data, + unsigned char *buffer, + size_t size, + struct ntlmdata *ntlm) { - unsigned int target_info_len = 0; + unsigned short target_info_len = 0; unsigned int target_info_offset = 0; - Curl_safefree(ntlm->target_info); - ntlm->target_info_len = 0; - if(size >= 48) { - target_info_len = readshort_le(&buffer[40]); - target_info_offset = readint_le(&buffer[44]); + target_info_len = Curl_read16_le(&buffer[40]); + target_info_offset = Curl_read32_le(&buffer[44]); if(target_info_len > 0) { if(((target_info_offset + target_info_len) > size) || (target_info_offset < 48)) { infof(data, "NTLM handshake failure (bad type-2 message). " "Target Info Offset Len is set incorrect by the peer\n"); - return CURLE_REMOTE_ACCESS_DENIED; + return CURLE_BAD_CONTENT_ENCODING; } ntlm->target_info = malloc(target_info_len); @@ -211,17 +186,14 @@ CURLcode Curl_ntlm_decode_type2_target(struct SessionHandle *data, return CURLE_OUT_OF_MEMORY; memcpy(ntlm->target_info, &buffer[target_info_offset], target_info_len); - ntlm->target_info_len = target_info_len; - } - } + ntlm->target_info_len = target_info_len; + return CURLE_OK; } -#endif - /* NTLM message structure notes: @@ -239,29 +211,26 @@ CURLcode Curl_ntlm_decode_type2_target(struct SessionHandle *data, */ /* - * Curl_ntlm_decode_type2_message() + * Curl_sasl_decode_ntlm_type2_message() * - * This is used to decode a ntlm type-2 message received from a HTTP or SASL - * based (such as SMTP, POP3 or IMAP) server. The message is first decoded - * from a base64 string into a raw ntlm message and checked for validity - * before the appropriate data for creating a type-3 message is written to - * the given ntlm data structure. + * This is used to decode an already encoded NTLM type-2 message. The message + * is first decoded from a base64 string into a raw NTLM message and checked + * for validity before the appropriate data for creating a type-3 message is + * written to the given NTLM data structure. * * Parameters: * - * data [in] - Pointer to session handle. - * header [in] - Pointer to the input buffer. - * ntlm [in] - Pointer to ntlm data struct being used and modified. + * data [in] - The session handle. + * type2msg [in] - The base64 encoded type-2 message. + * ntlm [in/out] - The ntlm data struct being used and modified. * * Returns CURLE_OK on success. */ -CURLcode Curl_ntlm_decode_type2_message(struct SessionHandle *data, - const char *header, - struct ntlmdata *ntlm) +CURLcode Curl_sasl_decode_ntlm_type2_message(struct SessionHandle *data, + const char *type2msg, + struct ntlmdata *ntlm) { -#ifndef USE_WINDOWS_SSPI static const char type2_marker[] = { 0x02, 0x00, 0x00, 0x00 }; -#endif /* NTLM type-2 message structure: @@ -279,52 +248,52 @@ CURLcode Curl_ntlm_decode_type2_message(struct SessionHandle *data, (*) -> Optional */ - size_t size = 0; - unsigned char *buffer = NULL; - CURLcode error; - -#if defined(CURL_DISABLE_VERBOSE_STRINGS) || defined(USE_WINDOWS_SSPI) + CURLcode result = CURLE_OK; + unsigned char *type2 = NULL; + size_t type2_len = 0; + +#if defined(USE_NSS) + /* Make sure the crypto backend is initialized */ + result = Curl_nss_force_init(data); + if(result) + return result; +#elif defined(CURL_DISABLE_VERBOSE_STRINGS) (void)data; #endif - error = Curl_base64_decode(header, &buffer, &size); - if(error) - return error; - - if(!buffer) { - infof(data, "NTLM handshake failure (unhandled condition)\n"); - return CURLE_REMOTE_ACCESS_DENIED; + /* Decode the base-64 encoded type-2 message */ + if(strlen(type2msg) && *type2msg != '=') { + result = Curl_base64_decode(type2msg, &type2, &type2_len); + if(result) + return result; } -#ifdef USE_WINDOWS_SSPI - ntlm->type_2 = malloc(size + 1); - if(ntlm->type_2 == NULL) { - free(buffer); - return CURLE_OUT_OF_MEMORY; + /* Ensure we have a valid type-2 message */ + if(!type2) { + infof(data, "NTLM handshake failure (empty type-2 message)\n"); + return CURLE_BAD_CONTENT_ENCODING; } - ntlm->n_type_2 = curlx_uztoul(size); - memcpy(ntlm->type_2, buffer, size); -#else + ntlm->flags = 0; - if((size < 32) || - (memcmp(buffer, NTLMSSP_SIGNATURE, 8) != 0) || - (memcmp(buffer + 8, type2_marker, sizeof(type2_marker)) != 0)) { + if((type2_len < 32) || + (memcmp(type2, NTLMSSP_SIGNATURE, 8) != 0) || + (memcmp(type2 + 8, type2_marker, sizeof(type2_marker)) != 0)) { /* This was not a good enough type-2 message */ - free(buffer); + free(type2); infof(data, "NTLM handshake failure (bad type-2 message)\n"); - return CURLE_REMOTE_ACCESS_DENIED; + return CURLE_BAD_CONTENT_ENCODING; } - ntlm->flags = readint_le(&buffer[20]); - memcpy(ntlm->nonce, &buffer[24], 8); + ntlm->flags = Curl_read32_le(&type2[20]); + memcpy(ntlm->nonce, &type2[24], 8); if(ntlm->flags & NTLMFLAG_NEGOTIATE_TARGET_INFO) { - error = Curl_ntlm_decode_type2_target(data, buffer, size, ntlm); - if(error) { - free(buffer); + result = ntlm_decode_type2_target(data, type2, type2_len, ntlm); + if(result) { + free(type2); infof(data, "NTLM handshake failure (bad type-2 message)\n"); - return error; + return result; } } @@ -336,32 +305,12 @@ CURLcode Curl_ntlm_decode_type2_message(struct SessionHandle *data, fprintf(stderr, "\n****\n"); fprintf(stderr, "**** Header %s\n ", header); }); -#endif - free(buffer); - - return CURLE_OK; -} -#ifdef USE_WINDOWS_SSPI -void Curl_ntlm_sspi_cleanup(struct ntlmdata *ntlm) -{ - Curl_safefree(ntlm->type_2); + free(type2); - if(ntlm->has_handles) { - s_pSecFn->DeleteSecurityContext(&ntlm->c_handle); - s_pSecFn->FreeCredentialsHandle(&ntlm->handle); - ntlm->has_handles = 0; - } - - ntlm->max_token_length = 0; - Curl_safefree(ntlm->output_token); - - Curl_sspi_free_identity(ntlm->p_identity); - ntlm->p_identity = NULL; + return result; } -#endif -#ifndef USE_WINDOWS_SSPI /* copy the source to the destination and fill in zeroes in every other destination byte! */ static void unicodecpy(unsigned char *dest, const char *src, size_t length) @@ -372,14 +321,12 @@ static void unicodecpy(unsigned char *dest, const char *src, size_t length) dest[2 * i + 1] = '\0'; } } -#endif /* - * Curl_ntlm_create_type1_message() + * Curl_sasl_create_ntlm_type1_message() * * This is used to generate an already encoded NTLM type-1 message ready for - * sending to the recipient, be it a HTTP or SASL based (such as SMTP, POP3 - * or IMAP) server, using the appropriate compile time crypo API. + * sending to the recipient using the appropriate compile time crypto API. * * Parameters: * @@ -392,11 +339,10 @@ static void unicodecpy(unsigned char *dest, const char *src, size_t length) * * Returns CURLE_OK on success. */ -CURLcode Curl_ntlm_create_type1_message(const char *userp, - const char *passwdp, - struct ntlmdata *ntlm, - char **outptr, - size_t *outlen) +CURLcode Curl_sasl_create_ntlm_type1_message(const char *userp, + const char *passwdp, + struct ntlmdata *ntlm, + char **outptr, size_t *outlen) { /* NTLM type-1 message structure: @@ -414,89 +360,6 @@ CURLcode Curl_ntlm_create_type1_message(const char *userp, size_t size; -#ifdef USE_WINDOWS_SSPI - - PSecPkgInfo SecurityPackage; - SecBuffer type_1_buf; - SecBufferDesc type_1_desc; - SECURITY_STATUS status; - unsigned long attrs; - TimeStamp tsDummy; /* For Windows 9x compatibility of SSPI calls */ - - Curl_ntlm_sspi_cleanup(ntlm); - - /* Query the security package for NTLM */ - status = s_pSecFn->QuerySecurityPackageInfo((TCHAR *) TEXT("NTLM"), - &SecurityPackage); - if(status != SEC_E_OK) - return CURLE_NOT_BUILT_IN; - - ntlm->max_token_length = SecurityPackage->cbMaxToken; - - /* Release the package buffer as it is not required anymore */ - s_pSecFn->FreeContextBuffer(SecurityPackage); - - /* Allocate our output buffer */ - ntlm->output_token = malloc(ntlm->max_token_length); - if(!ntlm->output_token) - return CURLE_OUT_OF_MEMORY; - - if(userp && *userp) { - CURLcode result; - - /* Populate our identity structure */ - result = Curl_create_sspi_identity(userp, passwdp, &ntlm->identity); - if(result) - return result; - - /* Allow proper cleanup of the identity structure */ - ntlm->p_identity = &ntlm->identity; - } - else - /* Use the current Windows user */ - ntlm->p_identity = NULL; - - /* Acquire our credientials handle */ - status = s_pSecFn->AcquireCredentialsHandle(NULL, - (TCHAR *) TEXT("NTLM"), - SECPKG_CRED_OUTBOUND, NULL, - ntlm->p_identity, NULL, NULL, - &ntlm->handle, &tsDummy); - if(status != SEC_E_OK) - return CURLE_OUT_OF_MEMORY; - - /* Setup the type-1 "output" security buffer */ - type_1_desc.ulVersion = SECBUFFER_VERSION; - type_1_desc.cBuffers = 1; - type_1_desc.pBuffers = &type_1_buf; - type_1_buf.BufferType = SECBUFFER_TOKEN; - type_1_buf.pvBuffer = ntlm->output_token; - type_1_buf.cbBuffer = curlx_uztoul(ntlm->max_token_length); - - /* Generate our type-1 message */ - status = s_pSecFn->InitializeSecurityContext(&ntlm->handle, NULL, - (TCHAR *) TEXT(""), - ISC_REQ_CONFIDENTIALITY | - ISC_REQ_REPLAY_DETECT | - ISC_REQ_CONNECTION, - 0, SECURITY_NETWORK_DREP, - NULL, 0, - &ntlm->c_handle, &type_1_desc, - &attrs, &tsDummy); - - if(status == SEC_I_COMPLETE_AND_CONTINUE || - status == SEC_I_CONTINUE_NEEDED) - s_pSecFn->CompleteAuthToken(&ntlm->c_handle, &type_1_desc); - else if(status != SEC_E_OK) { - s_pSecFn->FreeCredentialsHandle(&ntlm->handle); - return CURLE_RECV_ERROR; - } - - ntlm->has_handles = 1; - size = type_1_buf.cbBuffer; - -#else - unsigned char ntlmbuf[NTLM_BUFSIZE]; const char *host = ""; /* empty */ const char *domain = ""; /* empty */ @@ -507,9 +370,11 @@ CURLcode Curl_ntlm_create_type1_message(const char *userp, domain are empty */ (void)userp; (void)passwdp; - (void)ntlm; -#if USE_NTLM2SESSION + /* Clean up any former leftovers and initialise to defaults */ + Curl_sasl_ntlm_cleanup(ntlm); + +#if USE_NTRESPONSES && USE_NTLM2SESSION #define NTLM2FLAG NTLMFLAG_NEGOTIATE_NTLM2_KEY #else #define NTLM2FLAG 0 @@ -550,8 +415,6 @@ CURLcode Curl_ntlm_create_type1_message(const char *userp, /* Initial packet length */ size = 32 + hostlen + domlen; -#endif - DEBUG_OUT({ fprintf(stderr, "* TYPE1 header flags=0x%02.2x%02.2x%02.2x%02.2x " "0x%08.8x ", @@ -575,20 +438,14 @@ CURLcode Curl_ntlm_create_type1_message(const char *userp, }); /* Return with binary blob encoded into base64 */ -#ifdef USE_WINDOWS_SSPI - return Curl_base64_encode(NULL, (char *)ntlm->output_token, size, - outptr, outlen); -#else return Curl_base64_encode(NULL, (char *)ntlmbuf, size, outptr, outlen); -#endif } /* - * Curl_ntlm_create_type3_message() + * Curl_sasl_create_ntlm_type3_message() * * This is used to generate an already encoded NTLM type-3 message ready for - * sending to the recipient, be it a HTTP or SASL based (such as SMTP, POP3 - * or IMAP) server, using the appropriate compile time crypo API. + * sending to the recipient using the appropriate compile time crypto API. * * Parameters: * @@ -602,12 +459,12 @@ CURLcode Curl_ntlm_create_type1_message(const char *userp, * * Returns CURLE_OK on success. */ -CURLcode Curl_ntlm_create_type3_message(struct SessionHandle *data, - const char *userp, - const char *passwdp, - struct ntlmdata *ntlm, - char **outptr, - size_t *outlen) +CURLcode Curl_sasl_create_ntlm_type3_message(struct SessionHandle *data, + const char *userp, + const char *passwdp, + struct ntlmdata *ntlm, + char **outptr, size_t *outlen) + { /* NTLM type-3 message structure: @@ -627,65 +484,8 @@ CURLcode Curl_ntlm_create_type3_message(struct SessionHandle *data, (*) -> Optional */ - size_t size; - -#ifdef USE_WINDOWS_SSPI CURLcode result = CURLE_OK; - SecBuffer type_2_buf; - SecBuffer type_3_buf; - SecBufferDesc type_2_desc; - SecBufferDesc type_3_desc; - SECURITY_STATUS status; - unsigned long attrs; - TimeStamp tsDummy; /* For Windows 9x compatibility of SSPI calls */ - - (void)passwdp; - (void)userp; - (void)data; - - /* Setup the type-2 "input" security buffer */ - type_2_desc.ulVersion = SECBUFFER_VERSION; - type_2_desc.cBuffers = 1; - type_2_desc.pBuffers = &type_2_buf; - type_2_buf.BufferType = SECBUFFER_TOKEN; - type_2_buf.pvBuffer = ntlm->type_2; - type_2_buf.cbBuffer = ntlm->n_type_2; - - /* Setup the type-3 "output" security buffer */ - type_3_desc.ulVersion = SECBUFFER_VERSION; - type_3_desc.cBuffers = 1; - type_3_desc.pBuffers = &type_3_buf; - type_3_buf.BufferType = SECBUFFER_TOKEN; - type_3_buf.pvBuffer = ntlm->output_token; - type_3_buf.cbBuffer = curlx_uztoul(ntlm->max_token_length); - - /* Generate our type-3 message */ - status = s_pSecFn->InitializeSecurityContext(&ntlm->handle, - &ntlm->c_handle, - (TCHAR *) TEXT(""), - ISC_REQ_CONFIDENTIALITY | - ISC_REQ_REPLAY_DETECT | - ISC_REQ_CONNECTION, - 0, SECURITY_NETWORK_DREP, - &type_2_desc, - 0, &ntlm->c_handle, - &type_3_desc, - &attrs, &tsDummy); - if(status != SEC_E_OK) - return CURLE_RECV_ERROR; - - size = type_3_buf.cbBuffer; - - /* Return with binary blob encoded into base64 */ - result = Curl_base64_encode(NULL, (char *)ntlm->output_token, size, - outptr, outlen); - - Curl_ntlm_sspi_cleanup(ntlm); - - return result; - -#else - + size_t size; unsigned char ntlmbuf[NTLM_BUFSIZE]; int lmrespoff; unsigned char lmresp[24]; /* fixed-size */ @@ -706,7 +506,6 @@ CURLcode Curl_ntlm_create_type3_message(struct SessionHandle *data, size_t hostlen = 0; size_t userlen = 0; size_t domlen = 0; - CURLcode res = CURLE_OK; user = strchr(userp, '\\'); if(!user) @@ -733,7 +532,7 @@ CURLcode Curl_ntlm_create_type3_message(struct SessionHandle *data, hostlen = strlen(host); } -#if USE_NTRESPONSES +#if USE_NTRESPONSES && USE_NTLM_V2 if(ntlm->target_info_len) { unsigned char ntbuffer[0x18]; unsigned int entropy[2]; @@ -742,35 +541,35 @@ CURLcode Curl_ntlm_create_type3_message(struct SessionHandle *data, entropy[0] = Curl_rand(data); entropy[1] = Curl_rand(data); - res = Curl_ntlm_core_mk_nt_hash(data, passwdp, ntbuffer); - if(res) - return res; + result = Curl_ntlm_core_mk_nt_hash(data, passwdp, ntbuffer); + if(result) + return result; - res = Curl_ntlm_core_mk_ntlmv2_hash(user, userlen, domain, domlen, - ntbuffer, ntlmv2hash); - if(res) - return res; + result = Curl_ntlm_core_mk_ntlmv2_hash(user, userlen, domain, domlen, + ntbuffer, ntlmv2hash); + if(result) + return result; /* LMv2 response */ - res = Curl_ntlm_core_mk_lmv2_resp(ntlmv2hash, - (unsigned char *)&entropy[0], - &ntlm->nonce[0], lmresp); - if(res) - return res; + result = Curl_ntlm_core_mk_lmv2_resp(ntlmv2hash, + (unsigned char *)&entropy[0], + &ntlm->nonce[0], lmresp); + if(result) + return result; /* NTLMv2 response */ - res = Curl_ntlm_core_mk_ntlmv2_resp(ntlmv2hash, - (unsigned char *)&entropy[0], - ntlm, &ntlmv2resp, &ntresplen); - if(res) - return res; + result = Curl_ntlm_core_mk_ntlmv2_resp(ntlmv2hash, + (unsigned char *)&entropy[0], + ntlm, &ntlmv2resp, &ntresplen); + if(result) + return result; ptr_ntresp = ntlmv2resp; } else #endif -#if USE_NTLM2SESSION +#if USE_NTRESPONSES && USE_NTLM2SESSION /* We don't support NTLM2 if we don't have USE_NTRESPONSES */ if(ntlm->flags & NTLMFLAG_NEGOTIATE_NTLM2_KEY) { unsigned char ntbuffer[0x18]; @@ -792,13 +591,13 @@ CURLcode Curl_ntlm_create_type3_message(struct SessionHandle *data, memcpy(tmp, &ntlm->nonce[0], 8); memcpy(tmp + 8, entropy, 8); - Curl_ssl_md5sum(tmp, 16, md5sum, MD5_DIGEST_LENGTH); - - /* We shall only use the first 8 bytes of md5sum, but the des - code in Curl_ntlm_core_lm_resp only encrypt the first 8 bytes */ - if(CURLE_OUT_OF_MEMORY == - Curl_ntlm_core_mk_nt_hash(data, passwdp, ntbuffer)) - return CURLE_OUT_OF_MEMORY; + result = Curl_ssl_md5sum(tmp, 16, md5sum, MD5_DIGEST_LENGTH); + if(!result) + /* We shall only use the first 8 bytes of md5sum, but the des code in + Curl_ntlm_core_lm_resp only encrypt the first 8 bytes */ + result = Curl_ntlm_core_mk_nt_hash(data, passwdp, ntbuffer); + if(result) + return result; Curl_ntlm_core_lm_resp(ntbuffer, md5sum, ntresp); @@ -815,14 +614,19 @@ CURLcode Curl_ntlm_create_type3_message(struct SessionHandle *data, unsigned char lmbuffer[0x18]; #if USE_NTRESPONSES - if(CURLE_OUT_OF_MEMORY == - Curl_ntlm_core_mk_nt_hash(data, passwdp, ntbuffer)) - return CURLE_OUT_OF_MEMORY; + result = Curl_ntlm_core_mk_nt_hash(data, passwdp, ntbuffer); + if(result) + return result; + Curl_ntlm_core_lm_resp(ntbuffer, &ntlm->nonce[0], ntresp); #endif - Curl_ntlm_core_mk_lm_hash(data, passwdp, lmbuffer); + result = Curl_ntlm_core_mk_lm_hash(data, passwdp, lmbuffer); + if(result) + return result; + Curl_ntlm_core_lm_resp(lmbuffer, &ntlm->nonce[0], lmresp); + /* A safer but less compatible alternative is: * Curl_ntlm_core_lm_resp(ntbuffer, &ntlm->nonce[0], lmresp); * See http://davenport.sourceforge.net/ntlm.html#ntlmVersion2 */ @@ -954,7 +758,7 @@ CURLcode Curl_ntlm_create_type3_message(struct SessionHandle *data, ntlm_print_hex(stderr, (char *)&ntlmbuf[ntrespoff], ntresplen); }); - Curl_safefree(ntlmv2resp);/* Free the dynamic buffer allocated for NTLMv2 */ + free(ntlmv2resp);/* Free the dynamic buffer allocated for NTLMv2 */ #endif @@ -997,14 +801,17 @@ CURLcode Curl_ntlm_create_type3_message(struct SessionHandle *data, size += hostlen; /* Convert domain, user, and host to ASCII but leave the rest as-is */ - res = Curl_convert_to_network(data, (char *)&ntlmbuf[domoff], - size - domoff); - if(res) + result = Curl_convert_to_network(data, (char *)&ntlmbuf[domoff], + size - domoff); + if(result) return CURLE_CONV_FAILED; /* Return with binary blob encoded into base64 */ - return Curl_base64_encode(NULL, (char *)ntlmbuf, size, outptr, outlen); -#endif + result = Curl_base64_encode(NULL, (char *)ntlmbuf, size, outptr, outlen); + + Curl_sasl_ntlm_cleanup(ntlm); + + return result; } -#endif /* USE_NTLM */ +#endif /* USE_NTLM && !USE_WINDOWS_SSPI */ diff --git a/lib/curl_ntlm_msgs.h b/lib/curl_ntlm_msgs.h index 80413c8..2a71431 100644 --- a/lib/curl_ntlm_msgs.h +++ b/lib/curl_ntlm_msgs.h @@ -26,40 +26,6 @@ #ifdef USE_NTLM -/* This is to generate a base64 encoded NTLM type-1 message */ -CURLcode Curl_ntlm_create_type1_message(const char *userp, - const char *passwdp, - struct ntlmdata *ntlm, - char **outptr, - size_t *outlen); - -/* This is to generate a base64 encoded NTLM type-3 message */ -CURLcode Curl_ntlm_create_type3_message(struct SessionHandle *data, - const char *userp, - const char *passwdp, - struct ntlmdata *ntlm, - char **outptr, - size_t *outlen); - -/* This is to decode a NTLM type-2 message */ -CURLcode Curl_ntlm_decode_type2_message(struct SessionHandle *data, - const char* header, - struct ntlmdata* ntlm); - -/* This is to decode target info received in NTLM type-2 message */ -CURLcode Curl_ntlm_decode_type2_target(struct SessionHandle *data, - unsigned char* buffer, - size_t size, - struct ntlmdata* ntlm); - - -/* This is to clean up the ntlm data structure */ -#ifdef USE_WINDOWS_SSPI -void Curl_ntlm_sspi_cleanup(struct ntlmdata *ntlm); -#else -#define Curl_ntlm_sspi_cleanup(x) -#endif - /* NTLM buffer fixed size, large enough for long user + host + domain */ #define NTLM_BUFSIZE 1024 diff --git a/lib/curl_ntlm_wb.c b/lib/curl_ntlm_wb.c index 23ee726..b2a5fb3 100644 --- a/lib/curl_ntlm_wb.c +++ b/lib/curl_ntlm_wb.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -22,7 +22,8 @@ #include "curl_setup.h" -#if defined(USE_NTLM) && defined(NTLM_WB_ENABLED) +#if !defined(CURL_DISABLE_HTTP) && defined(USE_NTLM) && \ + defined(NTLM_WB_ENABLED) /* * NTLM details: @@ -50,12 +51,10 @@ #include "curl_ntlm_wb.h" #include "url.h" #include "strerror.h" -#include "curl_memory.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include +#include "curl_printf.h" -/* The last #include file should be: */ +/* The last #include files should be: */ +#include "curl_memory.h" #include "memdebug.h" #if DEBUG_ME @@ -106,9 +105,9 @@ void Curl_ntlm_wb_cleanup(struct connectdata *conn) conn->ntlm_auth_hlpr_pid = 0; } - Curl_safefree(conn->challenge_header); + free(conn->challenge_header); conn->challenge_header = NULL; - Curl_safefree(conn->response_header); + free(conn->response_header); conn->response_header = NULL; } @@ -245,13 +244,13 @@ static CURLcode ntlm_wb_init(struct connectdata *conn, const char *userp) sclose(sockfds[1]); conn->ntlm_auth_hlpr_socket = sockfds[0]; conn->ntlm_auth_hlpr_pid = child_pid; - Curl_safefree(domain); - Curl_safefree(ntlm_auth_alloc); + free(domain); + free(ntlm_auth_alloc); return CURLE_OK; done: - Curl_safefree(domain); - Curl_safefree(ntlm_auth_alloc); + free(domain); + free(ntlm_auth_alloc); return CURLE_REMOTE_ACCESS_DENIED; } @@ -293,7 +292,7 @@ static CURLcode ntlm_wb_response(struct connectdata *conn, len_out += size; if(buf[len_out - 1] == '\n') { buf[len_out - 1] = '\0'; - goto wrfinish; + break; } newbuf = realloc(buf, len_out + NTLM_BUFSIZE); if(!newbuf) { @@ -302,13 +301,12 @@ static CURLcode ntlm_wb_response(struct connectdata *conn, } buf = newbuf; } - goto done; -wrfinish: + /* Samba/winbind installed but not configured */ if(state == NTLMSTATE_TYPE1 && len_out == 3 && buf[0] == 'P' && buf[1] == 'W') - return CURLE_REMOTE_ACCESS_DENIED; + goto done; /* invalid response */ if(len_out < 4) goto done; @@ -391,12 +389,12 @@ CURLcode Curl_output_ntlm_wb(struct connectdata *conn, if(res) return res; - Curl_safefree(*allocuserpwd); + free(*allocuserpwd); *allocuserpwd = aprintf("%sAuthorization: %s\r\n", proxy ? "Proxy-" : "", conn->response_header); DEBUG_OUT(fprintf(stderr, "**** Header %s\n ", *allocuserpwd)); - Curl_safefree(conn->response_header); + free(conn->response_header); conn->response_header = NULL; break; case NTLMSTATE_TYPE2: @@ -409,7 +407,7 @@ CURLcode Curl_output_ntlm_wb(struct connectdata *conn, if(res) return res; - Curl_safefree(*allocuserpwd); + free(*allocuserpwd); *allocuserpwd = aprintf("%sAuthorization: %s\r\n", proxy ? "Proxy-" : "", conn->response_header); @@ -421,10 +419,8 @@ CURLcode Curl_output_ntlm_wb(struct connectdata *conn, case NTLMSTATE_TYPE3: /* connection is already authenticated, * don't send a header in future requests */ - if(*allocuserpwd) { - free(*allocuserpwd); - *allocuserpwd=NULL; - } + free(*allocuserpwd); + *allocuserpwd=NULL; authp->done = TRUE; break; } @@ -432,4 +428,4 @@ CURLcode Curl_output_ntlm_wb(struct connectdata *conn, return CURLE_OK; } -#endif /* USE_NTLM && NTLM_WB_ENABLED */ +#endif /* !CURL_DISABLE_HTTP && USE_NTLM && NTLM_WB_ENABLED */ diff --git a/lib/curl_ntlm_wb.h b/lib/curl_ntlm_wb.h index db6bc16..828bb57 100644 --- a/lib/curl_ntlm_wb.h +++ b/lib/curl_ntlm_wb.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -24,7 +24,8 @@ #include "curl_setup.h" -#if defined(USE_NTLM) && defined(NTLM_WB_ENABLED) +#if !defined(CURL_DISABLE_HTTP) && defined(USE_NTLM) && \ + defined(NTLM_WB_ENABLED) /* this is for creating ntlm header output by delegating challenge/response to Samba's winbind daemon helper ntlm_auth */ @@ -32,6 +33,6 @@ CURLcode Curl_output_ntlm_wb(struct connectdata *conn, bool proxy); void Curl_ntlm_wb_cleanup(struct connectdata *conn); -#endif /* USE_NTLM && NTLM_WB_ENABLED */ +#endif /* !CURL_DISABLE_HTTP && USE_NTLM && NTLM_WB_ENABLED */ #endif /* HEADER_CURL_NTLM_WB_H */ diff --git a/lib/curl_memrchr.c b/lib/curl_printf.h similarity index 53% copy from lib/curl_memrchr.c copy to lib/curl_printf.h index a71c2bb..086923f 100644 --- a/lib/curl_memrchr.c +++ b/lib/curl_printf.h @@ -1,3 +1,5 @@ +#ifndef HEADER_CURL_PRINTF_H +#define HEADER_CURL_PRINTF_H /*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | @@ -5,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -20,43 +22,35 @@ * ***************************************************************************/ -#include "curl_setup.h" - -#include "curl_memrchr.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include - -#include "curl_memory.h" -/* The last #include file should be: */ -#include "memdebug.h" - -#ifndef HAVE_MEMRCHR - /* - * Curl_memrchr() - * - * Our memrchr() function clone for systems which lack this function. The - * memrchr() function is like the memchr() function, except that it searches - * backwards from the end of the n bytes pointed to by s instead of forward - * from the beginning. + * This header should be included by ALL code in libcurl that uses any + * *rintf() functions. */ -void * -Curl_memrchr(const void *s, int c, size_t n) -{ - const unsigned char *p = s; - const unsigned char *q = s; - - p += n - 1; - - while(p >= q) { - if(*p == (unsigned char)c) - return (void *)p; - p--; - } - - return NULL; -} +#include -#endif /* HAVE_MEMRCHR */ +# undef printf +# undef fprintf +# undef snprintf +# undef vprintf +# undef vfprintf +# undef vsnprintf +# undef aprintf +# undef vaprintf +# define printf curl_mprintf +# define fprintf curl_mfprintf +# define snprintf curl_msnprintf +# define vprintf curl_mvprintf +# define vfprintf curl_mvfprintf +# define vsnprintf curl_mvsnprintf +# define aprintf curl_maprintf +# define vaprintf curl_mvaprintf + +/* We define away the sprintf functions unconditonally since we don't want + internal code to be using them, intentionally or by mistake!*/ +# undef sprintf +# undef vsprintf +# define sprintf sprintf_was_used +# define vsprintf vsprintf_was_used + +#endif /* HEADER_CURL_PRINTF_H */ diff --git a/lib/curl_rtmp.c b/lib/curl_rtmp.c index e0c24b0..2938972 100644 --- a/lib/curl_rtmp.c +++ b/lib/curl_rtmp.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 2012 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 2012 - 2015, Daniel Stenberg, , et al. * Copyright (C) 2010, Howard Chu, * * This software is licensed as described in the file COPYING, which @@ -32,10 +32,6 @@ #include "warnless.h" #include #include - -#define _MPRINTF_REPLACE /* use our functions only */ -#include - #include "curl_memory.h" /* The last #include file should be: */ #include "memdebug.h" @@ -49,7 +45,7 @@ #define DEF_BUFTIME (2*60*60*1000) /* 2 hours */ -static CURLcode rtmp_setup(struct connectdata *conn); +static CURLcode rtmp_setup_connection(struct connectdata *conn); static CURLcode rtmp_do(struct connectdata *conn, bool *done); static CURLcode rtmp_done(struct connectdata *conn, CURLcode, bool premature); static CURLcode rtmp_connect(struct connectdata *conn, bool *done); @@ -64,7 +60,7 @@ static Curl_send rtmp_send; const struct Curl_handler Curl_handler_rtmp = { "RTMP", /* scheme */ - rtmp_setup, /* setup_connection */ + rtmp_setup_connection, /* setup_connection */ rtmp_do, /* do_it */ rtmp_done, /* done */ ZERO_NULL, /* do_more */ @@ -84,7 +80,7 @@ const struct Curl_handler Curl_handler_rtmp = { const struct Curl_handler Curl_handler_rtmpt = { "RTMPT", /* scheme */ - rtmp_setup, /* setup_connection */ + rtmp_setup_connection, /* setup_connection */ rtmp_do, /* do_it */ rtmp_done, /* done */ ZERO_NULL, /* do_more */ @@ -104,7 +100,7 @@ const struct Curl_handler Curl_handler_rtmpt = { const struct Curl_handler Curl_handler_rtmpe = { "RTMPE", /* scheme */ - rtmp_setup, /* setup_connection */ + rtmp_setup_connection, /* setup_connection */ rtmp_do, /* do_it */ rtmp_done, /* done */ ZERO_NULL, /* do_more */ @@ -124,7 +120,7 @@ const struct Curl_handler Curl_handler_rtmpe = { const struct Curl_handler Curl_handler_rtmpte = { "RTMPTE", /* scheme */ - rtmp_setup, /* setup_connection */ + rtmp_setup_connection, /* setup_connection */ rtmp_do, /* do_it */ rtmp_done, /* done */ ZERO_NULL, /* do_more */ @@ -144,7 +140,7 @@ const struct Curl_handler Curl_handler_rtmpte = { const struct Curl_handler Curl_handler_rtmps = { "RTMPS", /* scheme */ - rtmp_setup, /* setup_connection */ + rtmp_setup_connection, /* setup_connection */ rtmp_do, /* do_it */ rtmp_done, /* done */ ZERO_NULL, /* do_more */ @@ -164,7 +160,7 @@ const struct Curl_handler Curl_handler_rtmps = { const struct Curl_handler Curl_handler_rtmpts = { "RTMPTS", /* scheme */ - rtmp_setup, /* setup_connection */ + rtmp_setup_connection, /* setup_connection */ rtmp_do, /* do_it */ rtmp_done, /* done */ ZERO_NULL, /* do_more */ @@ -182,10 +178,9 @@ const struct Curl_handler Curl_handler_rtmpts = { PROTOPT_NONE /* flags*/ }; -static CURLcode rtmp_setup(struct connectdata *conn) +static CURLcode rtmp_setup_connection(struct connectdata *conn) { RTMP *r = RTMP_Alloc(); - if(!r) return CURLE_OUT_OF_MEMORY; @@ -202,7 +197,7 @@ static CURLcode rtmp_setup(struct connectdata *conn) static CURLcode rtmp_connect(struct connectdata *conn, bool *done) { RTMP *r = conn->proto.generic; - SET_RCVTIMEO(tv,10); + SET_RCVTIMEO(tv, 10); r->m_sb.sb_socket = conn->sock[FIRSTSOCKET]; @@ -217,7 +212,7 @@ static CURLcode rtmp_connect(struct connectdata *conn, bool *done) !(r->Link.protocol & RTMP_FEATURE_HTTP)) r->Link.lFlags |= RTMP_LF_BUFX; - curlx_nonblock(r->m_sb.sb_socket, FALSE); + (void)curlx_nonblock(r->m_sb.sb_socket, FALSE); setsockopt(r->m_sb.sb_socket, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(tv)); diff --git a/lib/curl_sasl.c b/lib/curl_sasl.c index 7e2b8af..68646bc 100644 --- a/lib/curl_sasl.c +++ b/lib/curl_sasl.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 2012 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 2012 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -19,6 +19,7 @@ * KIND, either express or implied. * * RFC2195 CRAM-MD5 authentication + * RFC2617 Basic and Digest Access Authentication * RFC2831 DIGEST-MD5 authentication * RFC4422 Simple Authentication and Security Layer (SASL) * RFC4616 PLAIN authentication @@ -36,26 +37,35 @@ #include "curl_md5.h" #include "vtls/vtls.h" #include "curl_hmac.h" -#include "curl_ntlm_msgs.h" #include "curl_sasl.h" #include "warnless.h" -#include "curl_memory.h" #include "strtok.h" +#include "strequal.h" #include "rawstr.h" +#include "sendf.h" +#include "non-ascii.h" /* included for Curl_convert_... prototypes */ +#include "curl_printf.h" -#ifdef USE_NSS -#include "vtls/nssg.h" /* for Curl_nss_force_init() */ -#endif - -#define _MPRINTF_REPLACE /* use our functions only */ -#include - -/* The last #include file should be: */ +/* The last #include files should be: */ +#include "curl_memory.h" #include "memdebug.h" -#if defined(USE_WINDOWS_SSPI) -extern void Curl_sasl_gssapi_cleanup(struct kerberos5data *krb5); -#endif +/* Supported mechanisms */ +const struct { + const char *name; /* Name */ + size_t len; /* Name length */ + unsigned int bit; /* Flag bit */ +} mechtable[] = { + { "LOGIN", 5, SASL_MECH_LOGIN }, + { "PLAIN", 5, SASL_MECH_PLAIN }, + { "CRAM-MD5", 8, SASL_MECH_CRAM_MD5 }, + { "DIGEST-MD5", 10, SASL_MECH_DIGEST_MD5 }, + { "GSSAPI", 6, SASL_MECH_GSSAPI }, + { "EXTERNAL", 8, SASL_MECH_EXTERNAL }, + { "NTLM", 4, SASL_MECH_NTLM }, + { "XOAUTH2", 7, SASL_MECH_XOAUTH2 }, + { ZERO_NULL, 0, 0 } +}; #if !defined(CURL_DISABLE_CRYPTO_AUTH) && !defined(USE_WINDOWS_SSPI) #define DIGEST_QOP_VALUE_AUTH (1 << 0) @@ -66,6 +76,131 @@ extern void Curl_sasl_gssapi_cleanup(struct kerberos5data *krb5); #define DIGEST_QOP_VALUE_STRING_AUTH_INT "auth-int" #define DIGEST_QOP_VALUE_STRING_AUTH_CONF "auth-conf" +/* The CURL_OUTPUT_DIGEST_CONV macro below is for non-ASCII machines. + It converts digest text to ASCII so the MD5 will be correct for + what ultimately goes over the network. +*/ +#define CURL_OUTPUT_DIGEST_CONV(a, b) \ + result = Curl_convert_to_network(a, (char *)b, strlen((const char*)b)); \ + if(result) { \ + free(b); \ + return result; \ + } + +#endif + +#if !defined(CURL_DISABLE_CRYPTO_AUTH) +/* + * Returns 0 on success and then the buffers are filled in fine. + * + * Non-zero means failure to parse. + */ +int Curl_sasl_digest_get_pair(const char *str, char *value, char *content, + const char **endptr) +{ + int c; + bool starts_with_quote = FALSE; + bool escape = FALSE; + + for(c = DIGEST_MAX_VALUE_LENGTH - 1; (*str && (*str != '=') && c--); ) + *value++ = *str++; + *value = 0; + + if('=' != *str++) + /* eek, no match */ + return 1; + + if('\"' == *str) { + /* this starts with a quote so it must end with one as well! */ + str++; + starts_with_quote = TRUE; + } + + for(c = DIGEST_MAX_CONTENT_LENGTH - 1; *str && c--; str++) { + switch(*str) { + case '\\': + if(!escape) { + /* possibly the start of an escaped quote */ + escape = TRUE; + *content++ = '\\'; /* even though this is an escape character, we still + store it as-is in the target buffer */ + continue; + } + break; + case ',': + if(!starts_with_quote) { + /* this signals the end of the content if we didn't get a starting + quote and then we do "sloppy" parsing */ + c = 0; /* the end */ + continue; + } + break; + case '\r': + case '\n': + /* end of string */ + c = 0; + continue; + case '\"': + if(!escape && starts_with_quote) { + /* end of string */ + c = 0; + continue; + } + break; + } + escape = FALSE; + *content++ = *str; + } + *content = 0; + + *endptr = str; + + return 0; /* all is fine! */ +} +#endif + +#if !defined(CURL_DISABLE_CRYPTO_AUTH) && !defined(USE_WINDOWS_SSPI) +/* Convert md5 chunk to RFC2617 (section 3.1.3) -suitable ascii string*/ +static void sasl_digest_md5_to_ascii(unsigned char *source, /* 16 bytes */ + unsigned char *dest) /* 33 bytes */ +{ + int i; + for(i = 0; i < 16; i++) + snprintf((char *)&dest[i*2], 3, "%02x", source[i]); +} + +/* Perform quoted-string escaping as described in RFC2616 and its errata */ +static char *sasl_digest_string_quoted(const char *source) +{ + char *dest, *d; + const char *s = source; + size_t n = 1; /* null terminator */ + + /* Calculate size needed */ + while(*s) { + ++n; + if(*s == '"' || *s == '\\') { + ++n; + } + ++s; + } + + dest = malloc(n); + if(dest) { + s = source; + d = dest; + while(*s) { + if(*s == '"' || *s == '\\') { + *d++ = '\\'; + } + *d++ = *s++; + } + *d = 0; + } + + return dest; +} + /* Retrieves the value for a corresponding key from the challenge string * returns TRUE if the key could be found, FALSE if it does not exists */ @@ -118,11 +253,11 @@ static CURLcode sasl_digest_get_qop_values(const char *options, int *value) token = strtok_r(NULL, ",", &tok_buf); } - Curl_safefree(tmp); + free(tmp); return CURLE_OK; } -#endif +#endif /* !CURL_DISABLE_CRYPTO_AUTH && !USE_WINDOWS_SSPI */ #if !defined(USE_WINDOWS_SSPI) /* @@ -132,8 +267,8 @@ static CURLcode sasl_digest_get_qop_values(const char *options, int *value) * * Parameters: * - * serivce [in] - The service type such as www, smtp, pop or imap. - * instance [in] - The instance name such as the host nme or realm. + * service [in] - The service type such as www, smtp, pop or imap. + * host [in] - The host name or realm. * * Returns a pointer to the newly allocated SPN. */ @@ -145,7 +280,7 @@ char *Curl_sasl_build_spn(const char *service, const char *host) #endif /* - * Curl_sasl_create_plain_message() + * sasl_create_plain_message() * * This is used to generate an already encoded PLAIN message ready * for sending to the recipient. @@ -161,10 +296,10 @@ char *Curl_sasl_build_spn(const char *service, const char *host) * * Returns CURLE_OK on success. */ -CURLcode Curl_sasl_create_plain_message(struct SessionHandle *data, - const char *userp, - const char *passwdp, - char **outptr, size_t *outlen) +static CURLcode sasl_create_plain_message(struct SessionHandle *data, + const char *userp, + const char *passwdp, + char **outptr, size_t *outlen) { CURLcode result; char *plainauth; @@ -191,12 +326,12 @@ CURLcode Curl_sasl_create_plain_message(struct SessionHandle *data, /* Base64 encode the reply */ result = Curl_base64_encode(data, plainauth, 2 * ulen + plen + 2, outptr, outlen); - Curl_safefree(plainauth); + free(plainauth); return result; } /* - * Curl_sasl_create_login_message() + * sasl_create_login_message() * * This is used to generate an already encoded LOGIN message containing the * user name or password ready for sending to the recipient. @@ -211,9 +346,9 @@ CURLcode Curl_sasl_create_plain_message(struct SessionHandle *data, * * Returns CURLE_OK on success. */ -CURLcode Curl_sasl_create_login_message(struct SessionHandle *data, - const char *valuep, char **outptr, - size_t *outlen) +static CURLcode sasl_create_login_message(struct SessionHandle *data, + const char *valuep, char **outptr, + size_t *outlen) { size_t vlen = strlen(valuep); @@ -233,23 +368,47 @@ CURLcode Curl_sasl_create_login_message(struct SessionHandle *data, return Curl_base64_encode(data, valuep, vlen, outptr, outlen); } +/* + * sasl_create_external_message() + * + * This is used to generate an already encoded EXTERNAL message containing + * the user name ready for sending to the recipient. + * + * Parameters: + * + * data [in] - The session handle. + * user [in] - The user name. + * outptr [in/out] - The address where a pointer to newly allocated memory + * holding the result will be stored upon completion. + * outlen [out] - The length of the output message. + * + * Returns CURLE_OK on success. + */ +static CURLcode sasl_create_external_message(struct SessionHandle *data, + const char *user, char **outptr, + size_t *outlen) +{ + /* This is the same formatting as the login message. */ + return sasl_create_login_message(data, user, outptr, outlen); +} + #ifndef CURL_DISABLE_CRYPTO_AUTH /* - * Curl_sasl_decode_cram_md5_message() + * sasl_decode_cram_md5_message() * * This is used to decode an already encoded CRAM-MD5 challenge message. * * Parameters: * - * chlg64 [in] - Pointer to the base64 encoded challenge message. + * chlg64 [in] - The base64 encoded challenge message. * outptr [in/out] - The address where a pointer to newly allocated memory * holding the result will be stored upon completion. * outlen [out] - The length of the output message. * * Returns CURLE_OK on success. */ -CURLcode Curl_sasl_decode_cram_md5_message(const char *chlg64, char **outptr, - size_t *outlen) +static CURLcode sasl_decode_cram_md5_message(const char *chlg64, char **outptr, + size_t *outlen) { CURLcode result = CURLE_OK; size_t chlg64len = strlen(chlg64); @@ -265,7 +424,7 @@ CURLcode Curl_sasl_decode_cram_md5_message(const char *chlg64, char **outptr, } /* - * Curl_sasl_create_cram_md5_message() + * sasl_create_cram_md5_message() * * This is used to generate an already encoded CRAM-MD5 response message ready * for sending to the recipient. @@ -282,11 +441,11 @@ CURLcode Curl_sasl_decode_cram_md5_message(const char *chlg64, char **outptr, * * Returns CURLE_OK on success. */ -CURLcode Curl_sasl_create_cram_md5_message(struct SessionHandle *data, - const char *chlg, - const char *userp, - const char *passwdp, - char **outptr, size_t *outlen) +static CURLcode sasl_create_cram_md5_message(struct SessionHandle *data, + const char *chlg, + const char *userp, + const char *passwdp, + char **outptr, size_t *outlen) { CURLcode result = CURLE_OK; size_t chlglen = 0; @@ -324,7 +483,7 @@ CURLcode Curl_sasl_create_cram_md5_message(struct SessionHandle *data, /* Base64 encode the response */ result = Curl_base64_encode(data, response, 0, outptr, outlen); - Curl_safefree(response); + free(response); return result; } @@ -338,7 +497,7 @@ CURLcode Curl_sasl_create_cram_md5_message(struct SessionHandle *data, * * Parameters: * - * chlg64 [in] - Pointer to the base64 encoded challenge message. + * chlg64 [in] - The base64 encoded challenge message. * nonce [in/out] - The buffer where the nonce will be stored. * nlen [in] - The length of the nonce buffer. * realm [in/out] - The buffer where the realm will be stored. @@ -374,7 +533,7 @@ static CURLcode sasl_decode_digest_md5_message(const char *chlg64, /* Retrieve nonce string from the challenge */ if(!sasl_digest_get_key_value((char *)chlg, "nonce=\"", nonce, nlen, '\"')) { - Curl_safefree(chlg); + free(chlg); return CURLE_BAD_CONTENT_ENCODING; } @@ -386,17 +545,17 @@ static CURLcode sasl_decode_digest_md5_message(const char *chlg64, /* Retrieve algorithm string from the challenge */ if(!sasl_digest_get_key_value((char *)chlg, "algorithm=", alg, alen, ',')) { - Curl_safefree(chlg); + free(chlg); return CURLE_BAD_CONTENT_ENCODING; } /* Retrieve qop-options string from the challenge */ if(!sasl_digest_get_key_value((char *)chlg, "qop=\"", qop, qlen, '\"')) { - Curl_safefree(chlg); + free(chlg); return CURLE_BAD_CONTENT_ENCODING; } - Curl_safefree(chlg); + free(chlg); return CURLE_OK; } @@ -410,7 +569,7 @@ static CURLcode sasl_decode_digest_md5_message(const char *chlg64, * Parameters: * * data [in] - The session handle. - * chlg64 [in] - Pointer to the base64 encoded challenge message. + * chlg64 [in] - The base64 encoded challenge message. * userp [in] - The user name. * passdwp [in] - The user's password. * service [in] - The service type such as www, smtp, pop or imap. @@ -518,7 +677,7 @@ CURLcode Curl_sasl_create_digest_md5_message(struct SessionHandle *data, /* Calculate H(A2) */ ctxt = Curl_MD5_init(Curl_DIGEST_MD5); if(!ctxt) { - Curl_safefree(spn); + free(spn); return CURLE_OUT_OF_MEMORY; } @@ -536,7 +695,7 @@ CURLcode Curl_sasl_create_digest_md5_message(struct SessionHandle *data, /* Now calculate the response hash */ ctxt = Curl_MD5_init(Curl_DIGEST_MD5); if(!ctxt) { - Curl_safefree(spn); + free(spn); return CURLE_OUT_OF_MEMORY; } @@ -569,110 +728,432 @@ CURLcode Curl_sasl_create_digest_md5_message(struct SessionHandle *data, "qop=%s", userp, realm, nonce, cnonce, nonceCount, spn, resp_hash_hex, qop); - Curl_safefree(spn); + free(spn); if(!response) return CURLE_OUT_OF_MEMORY; /* Base64 encode the response */ result = Curl_base64_encode(data, response, 0, outptr, outlen); - Curl_safefree(response); + free(response); return result; } -#endif /* !USE_WINDOWS_SSPI */ -#endif /* CURL_DISABLE_CRYPTO_AUTH */ - -#ifdef USE_NTLM /* - * Curl_sasl_create_ntlm_type1_message() + * Curl_sasl_decode_digest_http_message() * - * This is used to generate an already encoded NTLM type-1 message ready for - * sending to the recipient. + * This is used to decode a HTTP DIGEST challenge message into the seperate + * attributes. * - * Note: This is a simple wrapper of the NTLM function which means that any - * SASL based protocols don't have to include the NTLM functions directly. + * Parameters: + * + * chlg [in] - The challenge message. + * digest [in/out] - The digest data struct being used and modified. + * + * Returns CURLE_OK on success. + */ +CURLcode Curl_sasl_decode_digest_http_message(const char *chlg, + struct digestdata *digest) +{ + bool before = FALSE; /* got a nonce before */ + bool foundAuth = FALSE; + bool foundAuthInt = FALSE; + char *token = NULL; + char *tmp = NULL; + + /* If we already have received a nonce, keep that in mind */ + if(digest->nonce) + before = TRUE; + + /* Clean up any former leftovers and initialise to defaults */ + Curl_sasl_digest_cleanup(digest); + + for(;;) { + char value[DIGEST_MAX_VALUE_LENGTH]; + char content[DIGEST_MAX_CONTENT_LENGTH]; + + /* Pass all additional spaces here */ + while(*chlg && ISSPACE(*chlg)) + chlg++; + + /* Extract a value=content pair */ + if(!Curl_sasl_digest_get_pair(chlg, value, content, &chlg)) { + if(Curl_raw_equal(value, "nonce")) { + digest->nonce = strdup(content); + if(!digest->nonce) + return CURLE_OUT_OF_MEMORY; + } + else if(Curl_raw_equal(value, "stale")) { + if(Curl_raw_equal(content, "true")) { + digest->stale = TRUE; + digest->nc = 1; /* we make a new nonce now */ + } + } + else if(Curl_raw_equal(value, "realm")) { + digest->realm = strdup(content); + if(!digest->realm) + return CURLE_OUT_OF_MEMORY; + } + else if(Curl_raw_equal(value, "opaque")) { + digest->opaque = strdup(content); + if(!digest->opaque) + return CURLE_OUT_OF_MEMORY; + } + else if(Curl_raw_equal(value, "qop")) { + char *tok_buf; + /* Tokenize the list and choose auth if possible, use a temporary + clone of the buffer since strtok_r() ruins it */ + tmp = strdup(content); + if(!tmp) + return CURLE_OUT_OF_MEMORY; + + token = strtok_r(tmp, ",", &tok_buf); + while(token != NULL) { + if(Curl_raw_equal(token, DIGEST_QOP_VALUE_STRING_AUTH)) { + foundAuth = TRUE; + } + else if(Curl_raw_equal(token, DIGEST_QOP_VALUE_STRING_AUTH_INT)) { + foundAuthInt = TRUE; + } + token = strtok_r(NULL, ",", &tok_buf); + } + + free(tmp); + + /* Select only auth or auth-int. Otherwise, ignore */ + if(foundAuth) { + digest->qop = strdup(DIGEST_QOP_VALUE_STRING_AUTH); + if(!digest->qop) + return CURLE_OUT_OF_MEMORY; + } + else if(foundAuthInt) { + digest->qop = strdup(DIGEST_QOP_VALUE_STRING_AUTH_INT); + if(!digest->qop) + return CURLE_OUT_OF_MEMORY; + } + } + else if(Curl_raw_equal(value, "algorithm")) { + digest->algorithm = strdup(content); + if(!digest->algorithm) + return CURLE_OUT_OF_MEMORY; + + if(Curl_raw_equal(content, "MD5-sess")) + digest->algo = CURLDIGESTALGO_MD5SESS; + else if(Curl_raw_equal(content, "MD5")) + digest->algo = CURLDIGESTALGO_MD5; + else + return CURLE_BAD_CONTENT_ENCODING; + } + else { + /* unknown specifier, ignore it! */ + } + } + else + break; /* we're done here */ + + /* Pass all additional spaces here */ + while(*chlg && ISSPACE(*chlg)) + chlg++; + + /* Allow the list to be comma-separated */ + if(',' == *chlg) + chlg++; + } + + /* We had a nonce since before, and we got another one now without + 'stale=true'. This means we provided bad credentials in the previous + request */ + if(before && !digest->stale) + return CURLE_BAD_CONTENT_ENCODING; + + /* We got this header without a nonce, that's a bad Digest line! */ + if(!digest->nonce) + return CURLE_BAD_CONTENT_ENCODING; + + return CURLE_OK; +} + +/* + * Curl_sasl_create_digest_http_message() + * + * This is used to generate a HTTP DIGEST response message ready for sending + * to the recipient. * * Parameters: * - * userp [in] - The user name in the format User or Domain\User. + * data [in] - The session handle. + * userp [in] - The user name. * passdwp [in] - The user's password. - * ntlm [in/out] - The ntlm data struct being used and modified. + * request [in] - The HTTP request. + * uripath [in] - The path of the HTTP uri. + * digest [in/out] - The digest data struct being used and modified. * outptr [in/out] - The address where a pointer to newly allocated memory * holding the result will be stored upon completion. * outlen [out] - The length of the output message. * * Returns CURLE_OK on success. */ -CURLcode Curl_sasl_create_ntlm_type1_message(const char *userp, - const char *passwdp, - struct ntlmdata *ntlm, - char **outptr, size_t *outlen) +CURLcode Curl_sasl_create_digest_http_message(struct SessionHandle *data, + const char *userp, + const char *passwdp, + const unsigned char *request, + const unsigned char *uripath, + struct digestdata *digest, + char **outptr, size_t *outlen) { - return Curl_ntlm_create_type1_message(userp, passwdp, ntlm, outptr, outlen); + CURLcode result; + unsigned char md5buf[16]; /* 16 bytes/128 bits */ + unsigned char request_digest[33]; + unsigned char *md5this; + unsigned char ha1[33];/* 32 digits and 1 zero byte */ + unsigned char ha2[33];/* 32 digits and 1 zero byte */ + char cnoncebuf[33]; + char *cnonce = NULL; + size_t cnonce_sz = 0; + char *userp_quoted; + char *response = NULL; + char *tmp = NULL; + + if(!digest->nc) + digest->nc = 1; + + if(!digest->cnonce) { + snprintf(cnoncebuf, sizeof(cnoncebuf), "%08x%08x%08x%08x", + Curl_rand(data), Curl_rand(data), + Curl_rand(data), Curl_rand(data)); + + result = Curl_base64_encode(data, cnoncebuf, strlen(cnoncebuf), + &cnonce, &cnonce_sz); + if(result) + return result; + + digest->cnonce = cnonce; + } + + /* + if the algorithm is "MD5" or unspecified (which then defaults to MD5): + + A1 = unq(username-value) ":" unq(realm-value) ":" passwd + + if the algorithm is "MD5-sess" then: + + A1 = H( unq(username-value) ":" unq(realm-value) ":" passwd ) + ":" unq(nonce-value) ":" unq(cnonce-value) + */ + + md5this = (unsigned char *) + aprintf("%s:%s:%s", userp, digest->realm, passwdp); + if(!md5this) + return CURLE_OUT_OF_MEMORY; + + CURL_OUTPUT_DIGEST_CONV(data, md5this); /* convert on non-ASCII machines */ + Curl_md5it(md5buf, md5this); + free(md5this); + sasl_digest_md5_to_ascii(md5buf, ha1); + + if(digest->algo == CURLDIGESTALGO_MD5SESS) { + /* nonce and cnonce are OUTSIDE the hash */ + tmp = aprintf("%s:%s:%s", ha1, digest->nonce, digest->cnonce); + if(!tmp) + return CURLE_OUT_OF_MEMORY; + + CURL_OUTPUT_DIGEST_CONV(data, tmp); /* convert on non-ASCII machines */ + Curl_md5it(md5buf, (unsigned char *)tmp); + free(tmp); + sasl_digest_md5_to_ascii(md5buf, ha1); + } + + /* + If the "qop" directive's value is "auth" or is unspecified, then A2 is: + + A2 = Method ":" digest-uri-value + + If the "qop" value is "auth-int", then A2 is: + + A2 = Method ":" digest-uri-value ":" H(entity-body) + + (The "Method" value is the HTTP request method as specified in section + 5.1.1 of RFC 2616) + */ + + md5this = (unsigned char *)aprintf("%s:%s", request, uripath); + + if(digest->qop && Curl_raw_equal(digest->qop, "auth-int")) { + /* We don't support auth-int for PUT or POST at the moment. + TODO: replace md5 of empty string with entity-body for PUT/POST */ + unsigned char *md5this2 = (unsigned char *) + aprintf("%s:%s", md5this, "d41d8cd98f00b204e9800998ecf8427e"); + free(md5this); + md5this = md5this2; + } + + if(!md5this) + return CURLE_OUT_OF_MEMORY; + + CURL_OUTPUT_DIGEST_CONV(data, md5this); /* convert on non-ASCII machines */ + Curl_md5it(md5buf, md5this); + free(md5this); + sasl_digest_md5_to_ascii(md5buf, ha2); + + if(digest->qop) { + md5this = (unsigned char *)aprintf("%s:%s:%08x:%s:%s:%s", + ha1, + digest->nonce, + digest->nc, + digest->cnonce, + digest->qop, + ha2); + } + else { + md5this = (unsigned char *)aprintf("%s:%s:%s", + ha1, + digest->nonce, + ha2); + } + + if(!md5this) + return CURLE_OUT_OF_MEMORY; + + CURL_OUTPUT_DIGEST_CONV(data, md5this); /* convert on non-ASCII machines */ + Curl_md5it(md5buf, md5this); + free(md5this); + sasl_digest_md5_to_ascii(md5buf, request_digest); + + /* for test case 64 (snooped from a Mozilla 1.3a request) + + Authorization: Digest username="testuser", realm="testrealm", \ + nonce="1053604145", uri="/64", response="c55f7f30d83d774a3d2dcacf725abaca" + + Digest parameters are all quoted strings. Username which is provided by + the user will need double quotes and backslashes within it escaped. For + the other fields, this shouldn't be an issue. realm, nonce, and opaque + are copied as is from the server, escapes and all. cnonce is generated + with web-safe characters. uri is already percent encoded. nc is 8 hex + characters. algorithm and qop with standard values only contain web-safe + chracters. + */ + userp_quoted = sasl_digest_string_quoted(userp); + if(!userp_quoted) + return CURLE_OUT_OF_MEMORY; + + if(digest->qop) { + response = aprintf("username=\"%s\", " + "realm=\"%s\", " + "nonce=\"%s\", " + "uri=\"%s\", " + "cnonce=\"%s\", " + "nc=%08x, " + "qop=%s, " + "response=\"%s\"", + userp_quoted, + digest->realm, + digest->nonce, + uripath, + digest->cnonce, + digest->nc, + digest->qop, + request_digest); + + if(Curl_raw_equal(digest->qop, "auth")) + digest->nc++; /* The nc (from RFC) has to be a 8 hex digit number 0 + padded which tells to the server how many times you are + using the same nonce in the qop=auth mode */ + } + else { + response = aprintf("username=\"%s\", " + "realm=\"%s\", " + "nonce=\"%s\", " + "uri=\"%s\", " + "response=\"%s\"", + userp_quoted, + digest->realm, + digest->nonce, + uripath, + request_digest); + } + free(userp_quoted); + if(!response) + return CURLE_OUT_OF_MEMORY; + + /* Add the optional fields */ + if(digest->opaque) { + /* Append the opaque */ + tmp = aprintf("%s, opaque=\"%s\"", response, digest->opaque); + free(response); + if(!tmp) + return CURLE_OUT_OF_MEMORY; + + response = tmp; + } + + if(digest->algorithm) { + /* Append the algorithm */ + tmp = aprintf("%s, algorithm=\"%s\"", response, digest->algorithm); + free(response); + if(!tmp) + return CURLE_OUT_OF_MEMORY; + + response = tmp; + } + + /* Return the output */ + *outptr = response; + *outlen = strlen(response); + + return CURLE_OK; } /* - * Curl_sasl_decode_ntlm_type2_message() + * Curl_sasl_digest_cleanup() * - * This is used to decode an already encoded NTLM type-2 message. + * This is used to clean up the digest specific data. * * Parameters: * - * data [in] - Pointer to session handle. - * type2msg [in] - Pointer to the base64 encoded type-2 message. - * ntlm [in/out] - The ntlm data struct being used and modified. + * digest [in/out] - The digest data struct being cleaned up. * - * Returns CURLE_OK on success. */ -CURLcode Curl_sasl_decode_ntlm_type2_message(struct SessionHandle *data, - const char *type2msg, - struct ntlmdata *ntlm) +void Curl_sasl_digest_cleanup(struct digestdata *digest) { -#ifdef USE_NSS - CURLcode result; - - /* make sure the crypto backend is initialized */ - result = Curl_nss_force_init(data); - if(result) - return result; -#endif - - return Curl_ntlm_decode_type2_message(data, type2msg, ntlm); + Curl_safefree(digest->nonce); + Curl_safefree(digest->cnonce); + Curl_safefree(digest->realm); + Curl_safefree(digest->opaque); + Curl_safefree(digest->qop); + Curl_safefree(digest->algorithm); + + digest->nc = 0; + digest->algo = CURLDIGESTALGO_MD5; /* default algorithm */ + digest->stale = FALSE; /* default means normal, not stale */ } +#endif /* !USE_WINDOWS_SSPI */ + +#endif /* CURL_DISABLE_CRYPTO_AUTH */ +#if defined(USE_NTLM) && !defined(USE_WINDOWS_SSPI) /* - * Curl_sasl_create_ntlm_type3_message() + * Curl_sasl_ntlm_cleanup() * - * This is used to generate an already encoded NTLM type-3 message ready for - * sending to the recipient. + * This is used to clean up the ntlm specific data. * * Parameters: * - * data [in] - Pointer to session handle. - * userp [in] - The user name in the format User or Domain\User. - * passdwp [in] - The user's password. - * ntlm [in/out] - The ntlm data struct being used and modified. - * outptr [in/out] - The address where a pointer to newly allocated memory - * holding the result will be stored upon completion. - * outlen [out] - The length of the output message. + * ntlm [in/out] - The ntlm data struct being cleaned up. * - * Returns CURLE_OK on success. */ -CURLcode Curl_sasl_create_ntlm_type3_message(struct SessionHandle *data, - const char *userp, - const char *passwdp, - struct ntlmdata *ntlm, - char **outptr, size_t *outlen) +void Curl_sasl_ntlm_cleanup(struct ntlmdata *ntlm) { - return Curl_ntlm_create_type3_message(data, userp, passwdp, ntlm, outptr, - outlen); + /* Free the target info */ + Curl_safefree(ntlm->target_info); + + /* Reset any variables */ + ntlm->target_info_len = 0; } -#endif /* USE_NTLM */ +#endif /* USE_NTLM && !USE_WINDOWS_SSPI*/ /* - * Curl_sasl_create_xoauth2_message() + * sasl_create_xoauth2_message() * * This is used to generate an already encoded OAuth 2.0 message ready for * sending to the recipient. @@ -688,10 +1169,10 @@ CURLcode Curl_sasl_create_ntlm_type3_message(struct SessionHandle *data, * * Returns CURLE_OK on success. */ -CURLcode Curl_sasl_create_xoauth2_message(struct SessionHandle *data, - const char *user, - const char *bearer, - char **outptr, size_t *outlen) +static CURLcode sasl_create_xoauth2_message(struct SessionHandle *data, + const char *user, + const char *bearer, + char **outptr, size_t *outlen) { CURLcode result = CURLE_OK; char *xoauth = NULL; @@ -704,7 +1185,7 @@ CURLcode Curl_sasl_create_xoauth2_message(struct SessionHandle *data, /* Base64 encode the reply */ result = Curl_base64_encode(data, xoauth, strlen(xoauth), outptr, outlen); - Curl_safefree(xoauth); + free(xoauth); return result; } @@ -717,25 +1198,472 @@ CURLcode Curl_sasl_create_xoauth2_message(struct SessionHandle *data, * * Parameters: * - * conn [in] - Pointer to the connection data. + * conn [in] - The connection data. * authused [in] - The authentication mechanism used. */ void Curl_sasl_cleanup(struct connectdata *conn, unsigned int authused) { -#if defined(USE_WINDOWS_SSPI) +#if defined(USE_KERBEROS5) /* Cleanup the gssapi structure */ if(authused == SASL_MECH_GSSAPI) { Curl_sasl_gssapi_cleanup(&conn->krb5); } -#ifdef USE_NTLM +#endif + +#if defined(USE_NTLM) /* Cleanup the ntlm structure */ - else if(authused == SASL_MECH_NTLM) { - Curl_ntlm_sspi_cleanup(&conn->ntlm); + if(authused == SASL_MECH_NTLM) { + Curl_sasl_ntlm_cleanup(&conn->ntlm); } #endif -#else + +#if !defined(USE_KERBEROS5) && !defined(USE_NTLM) /* Reserved for future use */ (void)conn; (void)authused; #endif } + +/* + * Curl_sasl_decode_mech() + * + * Convert a SASL mechanism name into a token. + * + * Parameters: + * + * ptr [in] - The mechanism string. + * maxlen [in] - Maximum mechanism string length. + * len [out] - If not NULL, effective name length. + * + * Returns the SASL mechanism token or 0 if no match. + */ +unsigned int Curl_sasl_decode_mech(const char *ptr, size_t maxlen, size_t *len) +{ + unsigned int i; + char c; + + for(i = 0; mechtable[i].name; i++) { + if(maxlen >= mechtable[i].len && + !memcmp(ptr, mechtable[i].name, mechtable[i].len)) { + if(len) + *len = mechtable[i].len; + + if(maxlen == mechtable[i].len) + return mechtable[i].bit; + + c = ptr[mechtable[i].len]; + if(!ISUPPER(c) && !ISDIGIT(c) && c != '-' && c != '_') + return mechtable[i].bit; + } + } + + return 0; +} + +/* + * Curl_sasl_parse_url_auth_option() + * + * Parse the URL login options. + */ +CURLcode Curl_sasl_parse_url_auth_option(struct SASL *sasl, + const char *value, size_t len) +{ + CURLcode result = CURLE_OK; + unsigned int mechbit; + size_t mechlen; + + if(!len) + return CURLE_URL_MALFORMAT; + + if(sasl->resetprefs) { + sasl->resetprefs = FALSE; + sasl->prefmech = SASL_AUTH_NONE; + } + + if(strnequal(value, "*", len)) + sasl->prefmech = SASL_AUTH_DEFAULT; + else if((mechbit = Curl_sasl_decode_mech(value, len, &mechlen)) && + mechlen == len) + sasl->prefmech |= mechbit; + else + result = CURLE_URL_MALFORMAT; + + return result; +} + +/* + * Curl_sasl_init() + * + * Initializes the SASL structure. + */ +void Curl_sasl_init(struct SASL *sasl, const struct SASLproto *params) +{ + sasl->params = params; /* Set protocol dependent parameters */ + sasl->state = SASL_STOP; /* Not yet running */ + sasl->authmechs = SASL_AUTH_NONE; /* No known authentication mechanism yet */ + sasl->prefmech = SASL_AUTH_DEFAULT; /* Prefer all mechanisms */ + sasl->authused = SASL_AUTH_NONE; /* No the authentication mechanism used */ + sasl->resetprefs = TRUE; /* Reset prefmech upon AUTH parsing. */ + sasl->mutual_auth = FALSE; /* No mutual authentication (GSSAPI only) */ + sasl->force_ir = FALSE; /* Respect external option */ +} + +/* + * state() + * + * This is the ONLY way to change SASL state! + */ +static void state(struct SASL *sasl, struct connectdata *conn, + saslstate newstate) +{ +#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS) + /* for debug purposes */ + static const char * const names[]={ + "STOP", + "PLAIN", + "LOGIN", + "LOGIN_PASSWD", + "EXTERNAL", + "CRAMMD5", + "DIGESTMD5", + "DIGESTMD5_RESP", + "NTLM", + "NTLM_TYPE2MSG", + "GSSAPI", + "GSSAPI_TOKEN", + "GSSAPI_NO_DATA", + "XOAUTH2", + "CANCEL", + "FINAL", + /* LAST */ + }; + + if(sasl->state != newstate) + infof(conn->data, "SASL %p state change from %s to %s\n", + (void *)sasl, names[sasl->state], names[newstate]); +#else + (void) conn; +#endif + + sasl->state = newstate; +} + +/* + * Curl_sasl_can_authenticate() + * + * Check if we have enough auth data and capabilities to authenticate. + */ +bool Curl_sasl_can_authenticate(struct SASL *sasl, struct connectdata *conn) +{ + /* Have credentials been provided? */ + if(conn->bits.user_passwd) + return TRUE; + + /* EXTERNAL can authenticate without a user name and/or password */ + if(sasl->authmechs & sasl->prefmech & SASL_MECH_EXTERNAL) + return TRUE; + + return FALSE; +} + +/* + * Curl_sasl_start() + * + * Calculate the required login details for SASL authentication. + */ +CURLcode Curl_sasl_start(struct SASL *sasl, struct connectdata *conn, + bool force_ir, saslprogress *progress) +{ + CURLcode result = CURLE_OK; + struct SessionHandle *data = conn->data; + unsigned int enabledmechs; + const char *mech = NULL; + char *resp = NULL; + size_t len = 0; + saslstate state1 = SASL_STOP; + saslstate state2 = SASL_FINAL; + + sasl->force_ir = force_ir; /* Latch for future use */ + sasl->authused = 0; /* No mechanism used yet */ + enabledmechs = sasl->authmechs & sasl->prefmech; + *progress = SASL_IDLE; + + /* Calculate the supported authentication mechanism, by decreasing order of + security, as well as the initial response where appropriate */ + if((enabledmechs & SASL_MECH_EXTERNAL) && !conn->passwd[0]) { + mech = SASL_MECH_STRING_EXTERNAL; + state1 = SASL_EXTERNAL; + sasl->authused = SASL_MECH_EXTERNAL; + + if(force_ir || data->set.sasl_ir) + result = sasl_create_external_message(data, conn->user, &resp, &len); + } + else if(conn->bits.user_passwd) { +#if defined(USE_KERBEROS5) + if(enabledmechs & SASL_MECH_GSSAPI) { + sasl->mutual_auth = FALSE; /* TODO: Calculate mutual authentication */ + mech = SASL_MECH_STRING_GSSAPI; + state1 = SASL_GSSAPI; + state2 = SASL_GSSAPI_TOKEN; + sasl->authused = SASL_MECH_GSSAPI; + + if(force_ir || data->set.sasl_ir) + result = Curl_sasl_create_gssapi_user_message(data, conn->user, + conn->passwd, + sasl->params->service, + sasl->mutual_auth, + NULL, &conn->krb5, + &resp, &len); + } + else +#endif +#ifndef CURL_DISABLE_CRYPTO_AUTH + if(enabledmechs & SASL_MECH_DIGEST_MD5) { + mech = SASL_MECH_STRING_DIGEST_MD5; + state1 = SASL_DIGESTMD5; + sasl->authused = SASL_MECH_DIGEST_MD5; + } + else if(enabledmechs & SASL_MECH_CRAM_MD5) { + mech = SASL_MECH_STRING_CRAM_MD5; + state1 = SASL_CRAMMD5; + sasl->authused = SASL_MECH_CRAM_MD5; + } + else +#endif +#ifdef USE_NTLM + if(enabledmechs & SASL_MECH_NTLM) { + mech = SASL_MECH_STRING_NTLM; + state1 = SASL_NTLM; + state2 = SASL_NTLM_TYPE2MSG; + sasl->authused = SASL_MECH_NTLM; + + if(force_ir || data->set.sasl_ir) + result = Curl_sasl_create_ntlm_type1_message(conn->user, conn->passwd, + &conn->ntlm, &resp, &len); + } + else +#endif + if((enabledmechs & SASL_MECH_XOAUTH2) || conn->xoauth2_bearer) { + mech = SASL_MECH_STRING_XOAUTH2; + state1 = SASL_XOAUTH2; + sasl->authused = SASL_MECH_XOAUTH2; + + if(force_ir || data->set.sasl_ir) + result = sasl_create_xoauth2_message(data, conn->user, + conn->xoauth2_bearer, + &resp, &len); + } + else if(enabledmechs & SASL_MECH_LOGIN) { + mech = SASL_MECH_STRING_LOGIN; + state1 = SASL_LOGIN; + state2 = SASL_LOGIN_PASSWD; + sasl->authused = SASL_MECH_LOGIN; + + if(force_ir || data->set.sasl_ir) + result = sasl_create_login_message(data, conn->user, &resp, &len); + } + else if(enabledmechs & SASL_MECH_PLAIN) { + mech = SASL_MECH_STRING_PLAIN; + state1 = SASL_PLAIN; + sasl->authused = SASL_MECH_PLAIN; + + if(force_ir || data->set.sasl_ir) + result = sasl_create_plain_message(data, conn->user, conn->passwd, + &resp, &len); + } + } + + if(!result) { + if(resp && sasl->params->maxirlen && + strlen(mech) + len > sasl->params->maxirlen) { + free(resp); + resp = NULL; + } + + if(mech) { + result = sasl->params->sendauth(conn, mech, resp); + if(!result) { + *progress = SASL_INPROGRESS; + state(sasl, conn, resp? state2: state1); + } + } + } + + free(resp); + + return result; +} + +/* + * Curl_sasl_continue() + * + * Continue the authentication. + */ +CURLcode Curl_sasl_continue(struct SASL *sasl, struct connectdata *conn, + int code, saslprogress *progress) +{ + CURLcode result = CURLE_OK; + struct SessionHandle *data = conn->data; + saslstate newstate = SASL_FINAL; + char *resp = NULL; +#if !defined(CURL_DISABLE_CRYPTO_AUTH) + char *serverdata; + char *chlg = NULL; + size_t chlglen = 0; +#endif + size_t len = 0; + + *progress = SASL_INPROGRESS; + + if(sasl->state == SASL_FINAL) { + if(code != sasl->params->finalcode) + result = CURLE_LOGIN_DENIED; + *progress = SASL_DONE; + state(sasl, conn, SASL_STOP); + return result; + } + + if(sasl->state != SASL_CANCEL && code != sasl->params->contcode) { + *progress = SASL_DONE; + state(sasl, conn, SASL_STOP); + return CURLE_LOGIN_DENIED; + } + + switch(sasl->state) { + case SASL_STOP: + *progress = SASL_DONE; + return result; + case SASL_PLAIN: + result = sasl_create_plain_message(data, conn->user, conn->passwd, &resp, + &len); + break; + case SASL_LOGIN: + result = sasl_create_login_message(data, conn->user, &resp, &len); + newstate = SASL_LOGIN_PASSWD; + break; + case SASL_LOGIN_PASSWD: + result = sasl_create_login_message(data, conn->passwd, &resp, &len); + break; + case SASL_EXTERNAL: + result = sasl_create_external_message(data, conn->user, &resp, &len); + break; + +#ifndef CURL_DISABLE_CRYPTO_AUTH + case SASL_CRAMMD5: + sasl->params->getmessage(data->state.buffer, &serverdata); + result = sasl_decode_cram_md5_message(serverdata, &chlg, &chlglen); + if(!result) + result = sasl_create_cram_md5_message(data, chlg, conn->user, + conn->passwd, &resp, &len); + free(chlg); + break; + case SASL_DIGESTMD5: + sasl->params->getmessage(data->state.buffer, &serverdata); + result = Curl_sasl_create_digest_md5_message(data, serverdata, + conn->user, conn->passwd, + sasl->params->service, + &resp, &len); + newstate = SASL_DIGESTMD5_RESP; + break; + case SASL_DIGESTMD5_RESP: + if(!(resp = strdup(""))) + result = CURLE_OUT_OF_MEMORY; + break; +#endif + +#ifdef USE_NTLM + case SASL_NTLM: + /* Create the type-1 message */ + result = Curl_sasl_create_ntlm_type1_message(conn->user, conn->passwd, + &conn->ntlm, &resp, &len); + newstate = SASL_NTLM_TYPE2MSG; + break; + case SASL_NTLM_TYPE2MSG: + /* Decode the type-2 message */ + sasl->params->getmessage(data->state.buffer, &serverdata); + result = Curl_sasl_decode_ntlm_type2_message(data, serverdata, + &conn->ntlm); + if(!result) + result = Curl_sasl_create_ntlm_type3_message(data, conn->user, + conn->passwd, &conn->ntlm, + &resp, &len); + break; +#endif + +#if defined(USE_KERBEROS5) + case SASL_GSSAPI: + result = Curl_sasl_create_gssapi_user_message(data, conn->user, + conn->passwd, + sasl->params->service, + sasl->mutual_auth, NULL, + &conn->krb5, + &resp, &len); + newstate = SASL_GSSAPI_TOKEN; + break; + case SASL_GSSAPI_TOKEN: + sasl->params->getmessage(data->state.buffer, &serverdata); + if(sasl->mutual_auth) { + /* Decode the user token challenge and create the optional response + message */ + result = Curl_sasl_create_gssapi_user_message(data, NULL, NULL, NULL, + sasl->mutual_auth, + serverdata, &conn->krb5, + &resp, &len); + newstate = SASL_GSSAPI_NO_DATA; + } + else + /* Decode the security challenge and create the response message */ + result = Curl_sasl_create_gssapi_security_message(data, serverdata, + &conn->krb5, + &resp, &len); + break; + case SASL_GSSAPI_NO_DATA: + sasl->params->getmessage(data->state.buffer, &serverdata); + /* Decode the security challenge and create the response message */ + result = Curl_sasl_create_gssapi_security_message(data, serverdata, + &conn->krb5, + &resp, &len); + break; +#endif + + case SASL_XOAUTH2: + /* Create the authorisation message */ + result = sasl_create_xoauth2_message(data, conn->user, + conn->xoauth2_bearer, &resp, &len); + break; + case SASL_CANCEL: + /* Remove the offending mechanism from the supported list */ + sasl->authmechs ^= sasl->authused; + + /* Start an alternative SASL authentication */ + result = Curl_sasl_start(sasl, conn, sasl->force_ir, progress); + newstate = sasl->state; /* Use state from Curl_sasl_start() */ + break; + default: + failf(data, "Unsupported SASL authentication mechanism"); + result = CURLE_UNSUPPORTED_PROTOCOL; /* Should not happen */ + break; + } + + switch(result) { + case CURLE_BAD_CONTENT_ENCODING: + /* Cancel dialog */ + result = sasl->params->sendcont(conn, "*"); + newstate = SASL_CANCEL; + break; + case CURLE_OK: + if(resp) + result = sasl->params->sendcont(conn, resp); + break; + default: + newstate = SASL_STOP; /* Stop on error */ + *progress = SASL_DONE; + break; + } + + free(resp); + + state(sasl, conn, newstate); + + return result; +} diff --git a/lib/curl_sasl.h b/lib/curl_sasl.h index e56fa1a..117d60e 100644 --- a/lib/curl_sasl.h +++ b/lib/curl_sasl.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 2012 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 2012 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -26,16 +26,19 @@ struct SessionHandle; struct connectdata; + +#if !defined(CURL_DISABLE_CRYPTO_AUTH) +struct digestdata; +#endif + +#if defined(USE_NTLM) struct ntlmdata; +#endif -#if defined(USE_WINDOWS_SSPI) +#if defined(USE_KERBEROS5) struct kerberos5data; #endif -/* Authentication mechanism values */ -#define SASL_AUTH_NONE 0 -#define SASL_AUTH_ANY ~0U - /* Authentication mechanism flags */ #define SASL_MECH_LOGIN (1 << 0) #define SASL_MECH_PLAIN (1 << 1) @@ -46,6 +49,12 @@ struct kerberos5data; #define SASL_MECH_NTLM (1 << 6) #define SASL_MECH_XOAUTH2 (1 << 7) +/* Authentication mechanism values */ +#define SASL_AUTH_NONE 0 +#define SASL_AUTH_ANY ~0U +#define SASL_AUTH_DEFAULT (SASL_AUTH_ANY & \ + ~(SASL_MECH_EXTERNAL | SASL_MECH_XOAUTH2)) + /* Authentication mechanism strings */ #define SASL_MECH_STRING_LOGIN "LOGIN" #define SASL_MECH_STRING_PLAIN "PLAIN" @@ -56,6 +65,70 @@ struct kerberos5data; #define SASL_MECH_STRING_NTLM "NTLM" #define SASL_MECH_STRING_XOAUTH2 "XOAUTH2" +#if !defined(CURL_DISABLE_CRYPTO_AUTH) +#define DIGEST_MAX_VALUE_LENGTH 256 +#define DIGEST_MAX_CONTENT_LENGTH 1024 +#endif + +enum { + CURLDIGESTALGO_MD5, + CURLDIGESTALGO_MD5SESS +}; + +/* SASL machine states */ +typedef enum { + SASL_STOP, + SASL_PLAIN, + SASL_LOGIN, + SASL_LOGIN_PASSWD, + SASL_EXTERNAL, + SASL_CRAMMD5, + SASL_DIGESTMD5, + SASL_DIGESTMD5_RESP, + SASL_NTLM, + SASL_NTLM_TYPE2MSG, + SASL_GSSAPI, + SASL_GSSAPI_TOKEN, + SASL_GSSAPI_NO_DATA, + SASL_XOAUTH2, + SASL_CANCEL, + SASL_FINAL +} saslstate; + +/* Progress indicator */ +typedef enum { + SASL_IDLE, + SASL_INPROGRESS, + SASL_DONE +} saslprogress; + +/* Protocol dependent SASL parameters */ +struct SASLproto { + const char *service; /* The service name */ + int contcode; /* Code to receive when continuation is expected */ + int finalcode; /* Code to receive upon authentication success */ + size_t maxirlen; /* Maximum initial response length */ + CURLcode (*sendauth)(struct connectdata *conn, + const char *mech, const char *ir); + /* Send authentication command */ + CURLcode (*sendcont)(struct connectdata *conn, const char *contauth); + /* Send authentication continuation */ + void (*getmessage)(char *buffer, char **outptr); + /* Get SASL response message */ +}; + +/* Per-connection parameters */ +struct SASL { + const struct SASLproto *params; /* Protocol dependent parameters */ + saslstate state; /* Current machine state */ + unsigned int authmechs; /* Accepted authentication mechanisms */ + unsigned int prefmech; /* Preferred authentication mechanism */ + unsigned int authused; /* Auth mechanism used for the connection */ + bool resetprefs; /* For URL auth option parsing. */ + bool mutual_auth; /* Mutual authentication enabled (GSSAPI only) */ + bool force_ir; /* Protocol always supports initial response */ +}; + /* This is used to test whether the line starts with the given mechanism */ #define sasl_mech_equal(line, wordlen, mech) \ (wordlen == (sizeof(mech) - 1) / sizeof(char) && \ @@ -68,29 +141,15 @@ char *Curl_sasl_build_spn(const char *service, const char *instance); TCHAR *Curl_sasl_build_spn(const char *service, const char *instance); #endif -/* This is used to generate a base64 encoded PLAIN authentication message */ -CURLcode Curl_sasl_create_plain_message(struct SessionHandle *data, - const char *userp, - const char *passwdp, - char **outptr, size_t *outlen); +/* This is used to extract the realm from a challenge message */ +int Curl_sasl_digest_get_pair(const char *str, char *value, char *content, + const char **endptr); -/* This is used to generate a base64 encoded LOGIN authentication message - containing either the user name or password details */ -CURLcode Curl_sasl_create_login_message(struct SessionHandle *data, - const char *valuep, char **outptr, - size_t *outlen); +#if defined(HAVE_GSSAPI) +char *Curl_sasl_build_gssapi_spn(const char *service, const char *host); +#endif #ifndef CURL_DISABLE_CRYPTO_AUTH -/* This is used to decode a base64 encoded CRAM-MD5 challange message */ -CURLcode Curl_sasl_decode_cram_md5_message(const char *chlg64, char **outptr, - size_t *outlen); - -/* This is used to generate a base64 encoded CRAM-MD5 response message */ -CURLcode Curl_sasl_create_cram_md5_message(struct SessionHandle *data, - const char *chlg, - const char *user, - const char *passwdp, - char **outptr, size_t *outlen); /* This is used to generate a base64 encoded DIGEST-MD5 response message */ CURLcode Curl_sasl_create_digest_md5_message(struct SessionHandle *data, @@ -99,6 +158,22 @@ CURLcode Curl_sasl_create_digest_md5_message(struct SessionHandle *data, const char *passwdp, const char *service, char **outptr, size_t *outlen); + +/* This is used to decode a HTTP DIGEST challenge message */ +CURLcode Curl_sasl_decode_digest_http_message(const char *chlg, + struct digestdata *digest); + +/* This is used to generate a HTTP DIGEST response message */ +CURLcode Curl_sasl_create_digest_http_message(struct SessionHandle *data, + const char *userp, + const char *passwdp, + const unsigned char *request, + const unsigned char *uri, + struct digestdata *digest, + char **outptr, size_t *outlen); + +/* This is used to clean up the digest specific data */ +void Curl_sasl_digest_cleanup(struct digestdata *digest); #endif #ifdef USE_NTLM @@ -121,9 +196,12 @@ CURLcode Curl_sasl_create_ntlm_type3_message(struct SessionHandle *data, struct ntlmdata *ntlm, char **outptr, size_t *outlen); +/* This is used to clean up the ntlm specific data */ +void Curl_sasl_ntlm_cleanup(struct ntlmdata *ntlm); + #endif /* USE_NTLM */ -#if defined(USE_WINDOWS_SSPI) +#if defined(USE_KERBEROS5) /* This is used to generate a base64 encoded GSSAPI (Kerberos V5) user token message */ CURLcode Curl_sasl_create_gssapi_user_message(struct SessionHandle *data, @@ -142,17 +220,35 @@ CURLcode Curl_sasl_create_gssapi_security_message(struct SessionHandle *data, struct kerberos5data *krb5, char **outptr, size_t *outlen); -#endif -/* This is used to generate a base64 encoded XOAUTH2 authentication message - containing the user name and bearer token */ -CURLcode Curl_sasl_create_xoauth2_message(struct SessionHandle *data, - const char *user, - const char *bearer, - char **outptr, size_t *outlen); +/* This is used to clean up the gssapi specific data */ +void Curl_sasl_gssapi_cleanup(struct kerberos5data *krb5); +#endif /* USE_KERBEROS5 */ /* This is used to cleanup any libraries or curl modules used by the sasl functions */ void Curl_sasl_cleanup(struct connectdata *conn, unsigned int authused); +/* Convert a mechanism name to a token */ +unsigned int Curl_sasl_decode_mech(const char *ptr, + size_t maxlen, size_t *len); + +/* Parse the URL login options */ +CURLcode Curl_sasl_parse_url_auth_option(struct SASL *sasl, + const char *value, size_t len); + +/* Initializes an SASL structure */ +void Curl_sasl_init(struct SASL *sasl, const struct SASLproto *params); + +/* Check if we have enough auth data and capabilities to authenticate */ +bool Curl_sasl_can_authenticate(struct SASL *sasl, struct connectdata *conn); + +/* Calculate the required login details for SASL authentication */ +CURLcode Curl_sasl_start(struct SASL *sasl, struct connectdata *conn, + bool force_ir, saslprogress *progress); + +/* Continue an SASL authentication */ +CURLcode Curl_sasl_continue(struct SASL *sasl, struct connectdata *conn, + int code, saslprogress *progress); + #endif /* HEADER_CURL_SASL_H */ diff --git a/lib/curl_sasl_gssapi.c b/lib/curl_sasl_gssapi.c new file mode 100644 index 0000000..3c6f3ce --- /dev/null +++ b/lib/curl_sasl_gssapi.c @@ -0,0 +1,392 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 2014 - 2015, Steve Holme, . + * Copyright (C) 2015, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * RFC4752 The Kerberos V5 ("GSSAPI") SASL Mechanism + * + ***************************************************************************/ + +#include "curl_setup.h" + +#if defined(HAVE_GSSAPI) && defined(USE_KERBEROS5) + +#include + +#include "curl_sasl.h" +#include "urldata.h" +#include "curl_base64.h" +#include "curl_gssapi.h" +#include "sendf.h" +#include "curl_printf.h" + +/* The last #include files should be: */ +#include "curl_memory.h" +#include "memdebug.h" + +/* +* Curl_sasl_build_gssapi_spn() +* +* This is used to build a SPN string in the format service at host. +* +* Parameters: +* +* serivce [in] - The service type such as www, smtp, pop or imap. +* host [in] - The host name or realm. +* +* Returns a pointer to the newly allocated SPN. +*/ +char *Curl_sasl_build_gssapi_spn(const char *service, const char *host) +{ + /* Generate and return our SPN */ + return aprintf("%s@%s", service, host); +} + +/* + * Curl_sasl_create_gssapi_user_message() + * + * This is used to generate an already encoded GSSAPI (Kerberos V5) user token + * message ready for sending to the recipient. + * + * Parameters: + * + * data [in] - The session handle. + * userp [in] - The user name. + * passdwp [in] - The user's password. + * service [in] - The service type such as www, smtp, pop or imap. + * mutual_auth [in] - Flag specifing whether or not mutual authentication + * is enabled. + * chlg64 [in] - Pointer to the optional base64 encoded challenge + * message. + * krb5 [in/out] - The gssapi data struct being used and modified. + * outptr [in/out] - The address where a pointer to newly allocated memory + * holding the result will be stored upon completion. + * outlen [out] - The length of the output message. + * + * Returns CURLE_OK on success. + */ +CURLcode Curl_sasl_create_gssapi_user_message(struct SessionHandle *data, + const char *userp, + const char *passwdp, + const char *service, + const bool mutual_auth, + const char *chlg64, + struct kerberos5data *krb5, + char **outptr, size_t *outlen) +{ + CURLcode result = CURLE_OK; + size_t chlglen = 0; + unsigned char *chlg = NULL; + OM_uint32 gss_status; + OM_uint32 gss_major_status; + OM_uint32 gss_minor_status; + gss_buffer_desc spn_token = GSS_C_EMPTY_BUFFER; + gss_buffer_desc input_token = GSS_C_EMPTY_BUFFER; + gss_buffer_desc output_token = GSS_C_EMPTY_BUFFER; + + (void) userp; + (void) passwdp; + + if(krb5->context == GSS_C_NO_CONTEXT) { + /* Generate our SPN */ + char *spn = Curl_sasl_build_gssapi_spn(service, + data->easy_conn->host.name); + if(!spn) + return CURLE_OUT_OF_MEMORY; + + /* Populate the SPN structure */ + spn_token.value = spn; + spn_token.length = strlen(spn); + + /* Import the SPN */ + gss_major_status = gss_import_name(&gss_minor_status, &spn_token, + GSS_C_NT_HOSTBASED_SERVICE, &krb5->spn); + if(GSS_ERROR(gss_major_status)) { + Curl_gss_log_error(data, gss_minor_status, "gss_import_name() failed: "); + + free(spn); + + return CURLE_OUT_OF_MEMORY; + } + + free(spn); + } + else { + /* Decode the base-64 encoded challenge message */ + if(strlen(chlg64) && *chlg64 != '=') { + result = Curl_base64_decode(chlg64, &chlg, &chlglen); + if(result) + return result; + } + + /* Ensure we have a valid challenge message */ + if(!chlg) { + infof(data, "GSSAPI handshake failure (empty challenge message)\n"); + + return CURLE_BAD_CONTENT_ENCODING; + } + + /* Setup the challenge "input" security buffer */ + input_token.value = chlg; + input_token.length = chlglen; + } + + gss_major_status = Curl_gss_init_sec_context(data, + &gss_minor_status, + &krb5->context, + krb5->spn, + &Curl_krb5_mech_oid, + GSS_C_NO_CHANNEL_BINDINGS, + &input_token, + &output_token, + mutual_auth, + NULL); + + free(input_token.value); + + if(GSS_ERROR(gss_major_status)) { + if(output_token.value) + gss_release_buffer(&gss_status, &output_token); + + Curl_gss_log_error(data, gss_minor_status, + "gss_init_sec_context() failed: "); + + return CURLE_RECV_ERROR; + } + + if(output_token.value && output_token.length) { + /* Base64 encode the response */ + result = Curl_base64_encode(data, (char *) output_token.value, + output_token.length, outptr, outlen); + + gss_release_buffer(&gss_status, &output_token); + } + + return result; +} + +/* + * Curl_sasl_create_gssapi_security_message() + * + * This is used to generate an already encoded GSSAPI (Kerberos V5) security + * token message ready for sending to the recipient. + * + * Parameters: + * + * data [in] - The session handle. + * chlg64 [in] - Pointer to the optional base64 encoded challenge message. + * krb5 [in/out] - The gssapi data struct being used and modified. + * outptr [in/out] - The address where a pointer to newly allocated memory + * holding the result will be stored upon completion. + * outlen [out] - The length of the output message. + * + * Returns CURLE_OK on success. + */ +CURLcode Curl_sasl_create_gssapi_security_message(struct SessionHandle *data, + const char *chlg64, + struct kerberos5data *krb5, + char **outptr, + size_t *outlen) +{ + CURLcode result = CURLE_OK; + size_t chlglen = 0; + size_t messagelen = 0; + unsigned char *chlg = NULL; + unsigned char *message = NULL; + OM_uint32 gss_status; + OM_uint32 gss_major_status; + OM_uint32 gss_minor_status; + gss_buffer_desc input_token = GSS_C_EMPTY_BUFFER; + gss_buffer_desc output_token = GSS_C_EMPTY_BUFFER; + unsigned int indata = 0; + unsigned int outdata = 0; + gss_qop_t qop = GSS_C_QOP_DEFAULT; + unsigned int sec_layer = 0; + unsigned int max_size = 0; + gss_name_t username = GSS_C_NO_NAME; + gss_buffer_desc username_token; + + /* Decode the base-64 encoded input message */ + if(strlen(chlg64) && *chlg64 != '=') { + result = Curl_base64_decode(chlg64, &chlg, &chlglen); + if(result) + return result; + } + + /* Ensure we have a valid challenge message */ + if(!chlg) { + infof(data, "GSSAPI handshake failure (empty security message)\n"); + + return CURLE_BAD_CONTENT_ENCODING; + } + + /* Get the fully qualified username back from the context */ + gss_major_status = gss_inquire_context(&gss_minor_status, krb5->context, + &username, NULL, NULL, NULL, NULL, + NULL, NULL); + if(GSS_ERROR(gss_major_status)) { + Curl_gss_log_error(data, gss_minor_status, + "gss_inquire_context() failed: "); + + free(chlg); + + return CURLE_OUT_OF_MEMORY; + } + + /* Convert the username from internal format to a displayable token */ + gss_major_status = gss_display_name(&gss_minor_status, username, + &username_token, NULL); + if(GSS_ERROR(gss_major_status)) { + Curl_gss_log_error(data, gss_minor_status, "gss_display_name() failed: "); + + free(chlg); + + return CURLE_OUT_OF_MEMORY; + } + + /* Setup the challenge "input" security buffer */ + input_token.value = chlg; + input_token.length = chlglen; + + /* Decrypt the inbound challenge and obtain the qop */ + gss_major_status = gss_unwrap(&gss_minor_status, krb5->context, &input_token, + &output_token, NULL, &qop); + if(GSS_ERROR(gss_major_status)) { + Curl_gss_log_error(data, gss_minor_status, "gss_unwrap() failed: "); + + gss_release_buffer(&gss_status, &username_token); + free(chlg); + + return CURLE_BAD_CONTENT_ENCODING; + } + + /* Not 4 octets long so fail as per RFC4752 Section 3.1 */ + if(output_token.length != 4) { + infof(data, "GSSAPI handshake failure (invalid security data)\n"); + + gss_release_buffer(&gss_status, &username_token); + free(chlg); + + return CURLE_BAD_CONTENT_ENCODING; + } + + /* Copy the data out and free the challenge as it is not required anymore */ + memcpy(&indata, output_token.value, 4); + gss_release_buffer(&gss_status, &output_token); + free(chlg); + + /* Extract the security layer */ + sec_layer = indata & 0x000000FF; + if(!(sec_layer & GSSAUTH_P_NONE)) { + infof(data, "GSSAPI handshake failure (invalid security layer)\n"); + + gss_release_buffer(&gss_status, &username_token); + + return CURLE_BAD_CONTENT_ENCODING; + } + + /* Extract the maximum message size the server can receive */ + max_size = ntohl(indata & 0xFFFFFF00); + if(max_size > 0) { + /* The server has told us it supports a maximum receive buffer, however, as + we don't require one unless we are encrypting data, we tell the server + our receive buffer is zero. */ + max_size = 0; + } + + /* Allocate our message */ + messagelen = sizeof(outdata) + username_token.length + 1; + message = malloc(messagelen); + if(!message) { + gss_release_buffer(&gss_status, &username_token); + + return CURLE_OUT_OF_MEMORY; + } + + /* Populate the message with the security layer, client supported receive + message size and authorization identity including the 0x00 based + terminator. Note: Dispite RFC4752 Section 3.1 stating "The authorization + identity is not terminated with the zero-valued (%x00) octet." it seems + necessary to include it. */ + outdata = htonl(max_size) | sec_layer; + memcpy(message, &outdata, sizeof(outdata)); + memcpy(message + sizeof(outdata), username_token.value, + username_token.length); + message[messagelen - 1] = '\0'; + + /* Free the username token as it is not required anymore */ + gss_release_buffer(&gss_status, &username_token); + + /* Setup the "authentication data" security buffer */ + input_token.value = message; + input_token.length = messagelen; + + /* Encrypt the data */ + gss_major_status = gss_wrap(&gss_minor_status, krb5->context, 0, + GSS_C_QOP_DEFAULT, &input_token, NULL, + &output_token); + if(GSS_ERROR(gss_major_status)) { + Curl_gss_log_error(data, gss_minor_status, "gss_wrap() failed: "); + + free(message); + + return CURLE_OUT_OF_MEMORY; + } + + /* Base64 encode the response */ + result = Curl_base64_encode(data, (char *) output_token.value, + output_token.length, outptr, outlen); + + /* Free the output buffer */ + gss_release_buffer(&gss_status, &output_token); + + /* Free the message buffer */ + free(message); + + return result; +} + +/* + * Curl_sasl_gssapi_cleanup() + * + * This is used to clean up the gssapi specific data. + * + * Parameters: + * + * krb5 [in/out] - The kerberos 5 data struct being cleaned up. + * + */ +void Curl_sasl_gssapi_cleanup(struct kerberos5data *krb5) +{ + OM_uint32 minor_status; + + /* Free our security context */ + if(krb5->context != GSS_C_NO_CONTEXT) { + gss_delete_sec_context(&minor_status, &krb5->context, GSS_C_NO_BUFFER); + krb5->context = GSS_C_NO_CONTEXT; + } + + /* Free the SPN */ + if(krb5->spn != GSS_C_NO_NAME) { + gss_release_name(&minor_status, &krb5->spn); + krb5->spn = GSS_C_NO_NAME; + } +} + +#endif /* HAVE_GSSAPI && USE_KERBEROS5 */ diff --git a/lib/curl_sasl_sspi.c b/lib/curl_sasl_sspi.c index df4da96..b149530 100644 --- a/lib/curl_sasl_sspi.c +++ b/lib/curl_sasl_sspi.c @@ -5,8 +5,8 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * + * Copyright (C) 2014 - 2015, Daniel Stenberg, , et al. * Copyright (C) 2014, Steve Holme, . - * Copyright (C) 2014, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -19,6 +19,7 @@ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * KIND, either express or implied. * + * RFC2617 Basic and Digest Access Authentication * RFC2831 DIGEST-MD5 authentication * RFC4422 Simple Authentication and Security Layer (SASL) * RFC4752 The Kerberos V5 ("GSSAPI") SASL Mechanism @@ -35,17 +36,16 @@ #include "urldata.h" #include "curl_base64.h" #include "warnless.h" -#include "curl_memory.h" #include "curl_multibyte.h" +#include "sendf.h" +#include "strdup.h" +#include "curl_printf.h" +#include "rawstr.h" -#define _MPRINTF_REPLACE /* use our functions only */ -#include - -/* The last #include file should be: */ +/* The last #include files should be: */ +#include "curl_memory.h" #include "memdebug.h" -void Curl_sasl_gssapi_cleanup(struct kerberos5data *krb5); - /* * Curl_sasl_build_spn() * @@ -54,7 +54,7 @@ void Curl_sasl_gssapi_cleanup(struct kerberos5data *krb5); * Parameters: * * serivce [in] - The service type such as www, smtp, pop or imap. - * instance [in] - The instance name such as the host nme or realm. + * host [in] - The host name or realm. * * Returns a pointer to the newly allocated SPN. */ @@ -79,14 +79,13 @@ TCHAR *Curl_sasl_build_spn(const char *service, const char *host) /* Allocate our TCHAR based SPN */ tchar_spn = Curl_convert_UTF8_to_tchar(utf8_spn); if(!tchar_spn) { - Curl_safefree(utf8_spn); + free(utf8_spn); return NULL; } /* Release the UTF8 variant when operating with Unicode */ - if(utf8_spn != tchar_spn) - Curl_safefree(utf8_spn); + Curl_unicodefree(utf8_spn); /* Return our newly allocated SPN */ return tchar_spn; @@ -102,8 +101,8 @@ TCHAR *Curl_sasl_build_spn(const char *service, const char *host) * Parameters: * * data [in] - The session handle. - * chlg64 [in] - Pointer to the base64 encoded challenge message. - * userp [in] - The user name. + * chlg64 [in] - The base64 encoded challenge message. + * userp [in] - The user name in the format User or Domain\User. * passdwp [in] - The user's password. * service [in] - The service type such as www, smtp, pop or imap. * outptr [in/out] - The address where a pointer to newly allocated memory @@ -122,57 +121,54 @@ CURLcode Curl_sasl_create_digest_md5_message(struct SessionHandle *data, CURLcode result = CURLE_OK; TCHAR *spn = NULL; size_t chlglen = 0; - size_t resp_max = 0; - unsigned char *chlg = NULL; - unsigned char *resp = NULL; - CredHandle handle; - CtxtHandle ctx; + size_t token_max = 0; + unsigned char *input_token = NULL; + unsigned char *output_token = NULL; + CredHandle credentials; + CtxtHandle context; PSecPkgInfo SecurityPackage; SEC_WINNT_AUTH_IDENTITY identity; + SEC_WINNT_AUTH_IDENTITY *p_identity; SecBuffer chlg_buf; SecBuffer resp_buf; SecBufferDesc chlg_desc; SecBufferDesc resp_desc; SECURITY_STATUS status; unsigned long attrs; - TimeStamp tsDummy; /* For Windows 9x compatibility of SSPI calls */ + TimeStamp expiry; /* For Windows 9x compatibility of SSPI calls */ /* Decode the base-64 encoded challenge message */ if(strlen(chlg64) && *chlg64 != '=') { - result = Curl_base64_decode(chlg64, &chlg, &chlglen); + result = Curl_base64_decode(chlg64, &input_token, &chlglen); if(result) return result; } /* Ensure we have a valid challenge message */ - if(!chlg) - return CURLE_BAD_CONTENT_ENCODING; + if(!input_token) { + infof(data, "DIGEST-MD5 handshake failure (empty challenge message)\n"); - /* Ensure we have some login credientials as DigestSSP cannot use the current - Windows user like NTLMSSP can */ - if(!userp || !*userp) { - Curl_safefree(chlg); - return CURLE_LOGIN_DENIED; + return CURLE_BAD_CONTENT_ENCODING; } /* Query the security package for DigestSSP */ - status = s_pSecFn->QuerySecurityPackageInfo((TCHAR *) TEXT("WDigest"), + status = s_pSecFn->QuerySecurityPackageInfo((TCHAR *) TEXT(SP_NAME_DIGEST), &SecurityPackage); if(status != SEC_E_OK) { - Curl_safefree(chlg); + free(input_token); return CURLE_NOT_BUILT_IN; } - resp_max = SecurityPackage->cbMaxToken; + token_max = SecurityPackage->cbMaxToken; /* Release the package buffer as it is not required anymore */ s_pSecFn->FreeContextBuffer(SecurityPackage); /* Allocate our response buffer */ - resp = malloc(resp_max); - if(!resp) { - Curl_safefree(chlg); + output_token = malloc(token_max); + if(!output_token) { + free(input_token); return CURLE_OUT_OF_MEMORY; } @@ -180,36 +176,44 @@ CURLcode Curl_sasl_create_digest_md5_message(struct SessionHandle *data, /* Generate our SPN */ spn = Curl_sasl_build_spn(service, data->easy_conn->host.name); if(!spn) { - Curl_safefree(resp); - Curl_safefree(chlg); + free(output_token); + free(input_token); return CURLE_OUT_OF_MEMORY; } - /* Populate our identity structure */ - result = Curl_create_sspi_identity(userp, passwdp, &identity); - if(result) { - Curl_safefree(spn); - Curl_safefree(resp); - Curl_safefree(chlg); + if(userp && *userp) { + /* Populate our identity structure */ + result = Curl_create_sspi_identity(userp, passwdp, &identity); + if(result) { + free(spn); + free(output_token); + free(input_token); + + return result; + } - return result; + /* Allow proper cleanup of the identity structure */ + p_identity = &identity; } + else + /* Use the current Windows user */ + p_identity = NULL; - /* Acquire our credientials handle */ + /* Acquire our credentials handle */ status = s_pSecFn->AcquireCredentialsHandle(NULL, - (TCHAR *) TEXT("WDigest"), + (TCHAR *) TEXT(SP_NAME_DIGEST), SECPKG_CRED_OUTBOUND, NULL, - &identity, NULL, NULL, - &handle, &tsDummy); + p_identity, NULL, NULL, + &credentials, &expiry); if(status != SEC_E_OK) { - Curl_sspi_free_identity(&identity); - Curl_safefree(spn); - Curl_safefree(resp); - Curl_safefree(chlg); + Curl_sspi_free_identity(p_identity); + free(spn); + free(output_token); + free(input_token); - return CURLE_OUT_OF_MEMORY; + return CURLE_LOGIN_DENIED; } /* Setup the challenge "input" security buffer */ @@ -217,7 +221,7 @@ CURLcode Curl_sasl_create_digest_md5_message(struct SessionHandle *data, chlg_desc.cBuffers = 1; chlg_desc.pBuffers = &chlg_buf; chlg_buf.BufferType = SECBUFFER_TOKEN; - chlg_buf.pvBuffer = chlg; + chlg_buf.pvBuffer = input_token; chlg_buf.cbBuffer = curlx_uztoul(chlglen); /* Setup the response "output" security buffer */ @@ -225,52 +229,611 @@ CURLcode Curl_sasl_create_digest_md5_message(struct SessionHandle *data, resp_desc.cBuffers = 1; resp_desc.pBuffers = &resp_buf; resp_buf.BufferType = SECBUFFER_TOKEN; - resp_buf.pvBuffer = resp; - resp_buf.cbBuffer = curlx_uztoul(resp_max); - - /* Generate our challenge-response message */ - status = s_pSecFn->InitializeSecurityContext(&handle, NULL, spn, 0, 0, 0, - &chlg_desc, 0, &ctx, - &resp_desc, &attrs, &tsDummy); - - if(status == SEC_I_COMPLETE_AND_CONTINUE || - status == SEC_I_CONTINUE_NEEDED) - s_pSecFn->CompleteAuthToken(&handle, &resp_desc); - else if(status != SEC_E_OK) { - s_pSecFn->FreeCredentialsHandle(&handle); - Curl_sspi_free_identity(&identity); - Curl_safefree(spn); - Curl_safefree(resp); - Curl_safefree(chlg); + resp_buf.pvBuffer = output_token; + resp_buf.cbBuffer = curlx_uztoul(token_max); + + /* Generate our response message */ + status = s_pSecFn->InitializeSecurityContext(&credentials, NULL, spn, + 0, 0, 0, &chlg_desc, 0, + &context, &resp_desc, &attrs, + &expiry); + + if(status == SEC_I_COMPLETE_NEEDED || + status == SEC_I_COMPLETE_AND_CONTINUE) + s_pSecFn->CompleteAuthToken(&credentials, &resp_desc); + else if(status != SEC_E_OK && status != SEC_I_CONTINUE_NEEDED) { + s_pSecFn->FreeCredentialsHandle(&credentials); + Curl_sspi_free_identity(p_identity); + free(spn); + free(output_token); + free(input_token); return CURLE_RECV_ERROR; } /* Base64 encode the response */ - result = Curl_base64_encode(data, (char *)resp, resp_buf.cbBuffer, outptr, - outlen); + result = Curl_base64_encode(data, (char *) output_token, resp_buf.cbBuffer, + outptr, outlen); /* Free our handles */ - s_pSecFn->DeleteSecurityContext(&ctx); - s_pSecFn->FreeCredentialsHandle(&handle); + s_pSecFn->DeleteSecurityContext(&context); + s_pSecFn->FreeCredentialsHandle(&credentials); /* Free the identity structure */ - Curl_sspi_free_identity(&identity); + Curl_sspi_free_identity(p_identity); /* Free the SPN */ - Curl_safefree(spn); + free(spn); /* Free the response buffer */ - Curl_safefree(resp); + free(output_token); - /* Free the decoeded challenge message */ - Curl_safefree(chlg); + /* Free the decoded challenge message */ + free(input_token); return result; } +/* +* Curl_override_sspi_http_realm() +* +* This is used to populate the domain in a SSPI identity structure +* The realm is extracted from the challenge message and used as the +* domain if it is not already explicitly set. +* +* Parameters: +* +* chlg [in] - The challenge message. +* identity [in/out] - The identity structure. +* +* Returns CURLE_OK on success. +*/ +CURLcode Curl_override_sspi_http_realm(const char *chlg, + SEC_WINNT_AUTH_IDENTITY *identity) +{ + xcharp_u domain, dup_domain; + + /* If domain is blank or unset, check challenge message for realm */ + if(!identity->Domain || !identity->DomainLength) { + for(;;) { + char value[DIGEST_MAX_VALUE_LENGTH]; + char content[DIGEST_MAX_CONTENT_LENGTH]; + + /* Pass all additional spaces here */ + while(*chlg && ISSPACE(*chlg)) + chlg++; + + /* Extract a value=content pair */ + if(!Curl_sasl_digest_get_pair(chlg, value, content, &chlg)) { + if(Curl_raw_equal(value, "realm")) { + + /* Setup identity's domain and length */ + domain.tchar_ptr = Curl_convert_UTF8_to_tchar((char *)content); + if(!domain.tchar_ptr) + return CURLE_OUT_OF_MEMORY; + dup_domain.tchar_ptr = _tcsdup(domain.tchar_ptr); + if(!dup_domain.tchar_ptr) { + Curl_unicodefree(domain.tchar_ptr); + return CURLE_OUT_OF_MEMORY; + } + identity->Domain = dup_domain.tbyte_ptr; + identity->DomainLength = curlx_uztoul(_tcslen(dup_domain.tchar_ptr)); + dup_domain.tchar_ptr = NULL; + + Curl_unicodefree(domain.tchar_ptr); + } + else { + /* unknown specifier, ignore it! */ + } + } + else + break; /* we're done here */ + + /* Pass all additional spaces here */ + while(*chlg && ISSPACE(*chlg)) + chlg++; + + /* Allow the list to be comma-separated */ + if(',' == *chlg) + chlg++; + } + } + + return CURLE_OK; +} + +/* + * Curl_sasl_decode_digest_http_message() + * + * This is used to decode a HTTP DIGEST challenge message into the seperate + * attributes. + * + * Parameters: + * + * chlg [in] - The challenge message. + * digest [in/out] - The digest data struct being used and modified. + * + * Returns CURLE_OK on success. + */ +CURLcode Curl_sasl_decode_digest_http_message(const char *chlg, + struct digestdata *digest) +{ + size_t chlglen = strlen(chlg); + + /* We had an input token before and we got another one now. This means we + provided bad credentials in the previous request. */ + if(digest->input_token) + return CURLE_BAD_CONTENT_ENCODING; + + /* Simply store the challenge for use later */ + digest->input_token = (BYTE *) Curl_memdup(chlg, chlglen); + if(!digest->input_token) + return CURLE_OUT_OF_MEMORY; + + digest->input_token_len = chlglen; + + return CURLE_OK; +} + +/* + * Curl_sasl_create_digest_http_message() + * + * This is used to generate a HTTP DIGEST response message ready for sending + * to the recipient. + * + * Parameters: + * + * data [in] - The session handle. + * userp [in] - The user name in the format User or Domain\User. + * passdwp [in] - The user's password. + * request [in] - The HTTP request. + * uripath [in] - The path of the HTTP uri. + * digest [in/out] - The digest data struct being used and modified. + * outptr [in/out] - The address where a pointer to newly allocated memory + * holding the result will be stored upon completion. + * outlen [out] - The length of the output message. + * + * Returns CURLE_OK on success. + */ +CURLcode Curl_sasl_create_digest_http_message(struct SessionHandle *data, + const char *userp, + const char *passwdp, + const unsigned char *request, + const unsigned char *uripath, + struct digestdata *digest, + char **outptr, size_t *outlen) +{ + size_t token_max; + CredHandle credentials; + CtxtHandle context; + char *resp; + BYTE *output_token; + PSecPkgInfo SecurityPackage; + SEC_WINNT_AUTH_IDENTITY identity; + SEC_WINNT_AUTH_IDENTITY *p_identity; + SecBuffer chlg_buf[3]; + SecBuffer resp_buf; + SecBufferDesc chlg_desc; + SecBufferDesc resp_desc; + SECURITY_STATUS status; + unsigned long attrs; + TimeStamp expiry; /* For Windows 9x compatibility of SSPI calls */ + + (void) data; + + /* Query the security package for DigestSSP */ + status = s_pSecFn->QuerySecurityPackageInfo((TCHAR *) TEXT(SP_NAME_DIGEST), + &SecurityPackage); + if(status != SEC_E_OK) + return CURLE_NOT_BUILT_IN; + + token_max = SecurityPackage->cbMaxToken; + + /* Release the package buffer as it is not required anymore */ + s_pSecFn->FreeContextBuffer(SecurityPackage); + + /* Allocate the output buffer according to the max token size as indicated + by the security package */ + output_token = malloc(token_max); + if(!output_token) + return CURLE_OUT_OF_MEMORY; + + if(userp && *userp) { + /* Populate our identity structure */ + if(Curl_create_sspi_identity(userp, passwdp, &identity)) + return CURLE_OUT_OF_MEMORY; + + /* Populate our identity domain */ + if(Curl_override_sspi_http_realm((const char*)digest->input_token, + &identity)) + return CURLE_OUT_OF_MEMORY; + + /* Allow proper cleanup of the identity structure */ + p_identity = &identity; + } + else + /* Use the current Windows user */ + p_identity = NULL; + + /* Acquire our credentials handle */ + status = s_pSecFn->AcquireCredentialsHandle(NULL, + (TCHAR *) TEXT(SP_NAME_DIGEST), + SECPKG_CRED_OUTBOUND, NULL, + p_identity, NULL, NULL, + &credentials, &expiry); + if(status != SEC_E_OK) { + free(output_token); + + return CURLE_LOGIN_DENIED; + } + + /* Setup the challenge "input" security buffer if present */ + chlg_desc.ulVersion = SECBUFFER_VERSION; + chlg_desc.cBuffers = 3; + chlg_desc.pBuffers = chlg_buf; + chlg_buf[0].BufferType = SECBUFFER_TOKEN; + chlg_buf[0].pvBuffer = digest->input_token; + chlg_buf[0].cbBuffer = curlx_uztoul(digest->input_token_len); + chlg_buf[1].BufferType = SECBUFFER_PKG_PARAMS; + chlg_buf[1].pvBuffer = (void *)request; + chlg_buf[1].cbBuffer = curlx_uztoul(strlen((const char *) request)); + chlg_buf[2].BufferType = SECBUFFER_PKG_PARAMS; + chlg_buf[2].pvBuffer = NULL; + chlg_buf[2].cbBuffer = 0; + + /* Setup the response "output" security buffer */ + resp_desc.ulVersion = SECBUFFER_VERSION; + resp_desc.cBuffers = 1; + resp_desc.pBuffers = &resp_buf; + resp_buf.BufferType = SECBUFFER_TOKEN; + resp_buf.pvBuffer = output_token; + resp_buf.cbBuffer = curlx_uztoul(token_max); + + /* Generate our reponse message */ + status = s_pSecFn->InitializeSecurityContext(&credentials, NULL, + (TCHAR *) uripath, + ISC_REQ_USE_HTTP_STYLE, 0, 0, + &chlg_desc, 0, &context, + &resp_desc, &attrs, &expiry); + + if(status == SEC_I_COMPLETE_NEEDED || + status == SEC_I_COMPLETE_AND_CONTINUE) + s_pSecFn->CompleteAuthToken(&credentials, &resp_desc); + else if(status != SEC_E_OK && status != SEC_I_CONTINUE_NEEDED) { + s_pSecFn->FreeCredentialsHandle(&credentials); + + free(output_token); + + return CURLE_OUT_OF_MEMORY; + } + + resp = malloc(resp_buf.cbBuffer + 1); + if(!resp) { + s_pSecFn->DeleteSecurityContext(&context); + s_pSecFn->FreeCredentialsHandle(&credentials); + + free(output_token); + + return CURLE_OUT_OF_MEMORY; + } + + /* Copy the generated reponse */ + memcpy(resp, resp_buf.pvBuffer, resp_buf.cbBuffer); + resp[resp_buf.cbBuffer] = 0x00; + + /* Return the response */ + *outptr = resp; + *outlen = resp_buf.cbBuffer; + + /* Free our handles */ + s_pSecFn->DeleteSecurityContext(&context); + s_pSecFn->FreeCredentialsHandle(&credentials); + + /* Free the identity structure */ + Curl_sspi_free_identity(p_identity); + + /* Free the response buffer */ + free(output_token); + + return CURLE_OK; +} + +/* + * Curl_sasl_digest_cleanup() + * + * This is used to clean up the digest specific data. + * + * Parameters: + * + * digest [in/out] - The digest data struct being cleaned up. + * + */ +void Curl_sasl_digest_cleanup(struct digestdata *digest) +{ + /* Free the input token */ + Curl_safefree(digest->input_token); + + /* Reset any variables */ + digest->input_token_len = 0; +} #endif /* !CURL_DISABLE_CRYPTO_AUTH */ +#if defined USE_NTLM +/* +* Curl_sasl_create_ntlm_type1_message() +* +* This is used to generate an already encoded NTLM type-1 message ready for +* sending to the recipient. +* +* Parameters: +* +* userp [in] - The user name in the format User or Domain\User. +* passdwp [in] - The user's password. +* ntlm [in/out] - The ntlm data struct being used and modified. +* outptr [in/out] - The address where a pointer to newly allocated memory +* holding the result will be stored upon completion. +* outlen [out] - The length of the output message. +* +* Returns CURLE_OK on success. +*/ +CURLcode Curl_sasl_create_ntlm_type1_message(const char *userp, + const char *passwdp, + struct ntlmdata *ntlm, + char **outptr, size_t *outlen) +{ + PSecPkgInfo SecurityPackage; + SecBuffer type_1_buf; + SecBufferDesc type_1_desc; + SECURITY_STATUS status; + unsigned long attrs; + TimeStamp expiry; /* For Windows 9x compatibility of SSPI calls */ + + /* Clean up any former leftovers and initialise to defaults */ + Curl_sasl_ntlm_cleanup(ntlm); + + /* Query the security package for NTLM */ + status = s_pSecFn->QuerySecurityPackageInfo((TCHAR *) TEXT(SP_NAME_NTLM), + &SecurityPackage); + if(status != SEC_E_OK) + return CURLE_NOT_BUILT_IN; + + ntlm->token_max = SecurityPackage->cbMaxToken; + + /* Release the package buffer as it is not required anymore */ + s_pSecFn->FreeContextBuffer(SecurityPackage); + + /* Allocate our output buffer */ + ntlm->output_token = malloc(ntlm->token_max); + if(!ntlm->output_token) + return CURLE_OUT_OF_MEMORY; + + if(userp && *userp) { + CURLcode result; + + /* Populate our identity structure */ + result = Curl_create_sspi_identity(userp, passwdp, &ntlm->identity); + if(result) + return result; + + /* Allow proper cleanup of the identity structure */ + ntlm->p_identity = &ntlm->identity; + } + else + /* Use the current Windows user */ + ntlm->p_identity = NULL; + + /* Allocate our credentials handle */ + ntlm->credentials = malloc(sizeof(CredHandle)); + if(!ntlm->credentials) + return CURLE_OUT_OF_MEMORY; + + memset(ntlm->credentials, 0, sizeof(CredHandle)); + + /* Acquire our credentials handle */ + status = s_pSecFn->AcquireCredentialsHandle(NULL, + (TCHAR *) TEXT(SP_NAME_NTLM), + SECPKG_CRED_OUTBOUND, NULL, + ntlm->p_identity, NULL, NULL, + ntlm->credentials, &expiry); + if(status != SEC_E_OK) + return CURLE_LOGIN_DENIED; + + /* Allocate our new context handle */ + ntlm->context = malloc(sizeof(CtxtHandle)); + if(!ntlm->context) + return CURLE_OUT_OF_MEMORY; + + memset(ntlm->context, 0, sizeof(CtxtHandle)); + + /* Setup the type-1 "output" security buffer */ + type_1_desc.ulVersion = SECBUFFER_VERSION; + type_1_desc.cBuffers = 1; + type_1_desc.pBuffers = &type_1_buf; + type_1_buf.BufferType = SECBUFFER_TOKEN; + type_1_buf.pvBuffer = ntlm->output_token; + type_1_buf.cbBuffer = curlx_uztoul(ntlm->token_max); + + /* Generate our type-1 message */ + status = s_pSecFn->InitializeSecurityContext(ntlm->credentials, NULL, + (TCHAR *) TEXT(""), + 0, 0, SECURITY_NETWORK_DREP, + NULL, 0, + ntlm->context, &type_1_desc, + &attrs, &expiry); + if(status == SEC_I_COMPLETE_NEEDED || + status == SEC_I_COMPLETE_AND_CONTINUE) + s_pSecFn->CompleteAuthToken(ntlm->context, &type_1_desc); + else if(status != SEC_E_OK && status != SEC_I_CONTINUE_NEEDED) + return CURLE_RECV_ERROR; + + /* Base64 encode the response */ + return Curl_base64_encode(NULL, (char *) ntlm->output_token, + type_1_buf.cbBuffer, outptr, outlen); +} + +/* +* Curl_sasl_decode_ntlm_type2_message() +* +* This is used to decode an already encoded NTLM type-2 message. +* +* Parameters: +* +* data [in] - The session handle. +* type2msg [in] - The base64 encoded type-2 message. +* ntlm [in/out] - The ntlm data struct being used and modified. +* +* Returns CURLE_OK on success. +*/ +CURLcode Curl_sasl_decode_ntlm_type2_message(struct SessionHandle *data, + const char *type2msg, + struct ntlmdata *ntlm) +{ + CURLcode result = CURLE_OK; + unsigned char *type2 = NULL; + size_t type2_len = 0; + +#if defined(CURL_DISABLE_VERBOSE_STRINGS) + (void) data; +#endif + + /* Decode the base-64 encoded type-2 message */ + if(strlen(type2msg) && *type2msg != '=') { + result = Curl_base64_decode(type2msg, &type2, &type2_len); + if(result) + return result; + } + + /* Ensure we have a valid type-2 message */ + if(!type2) { + infof(data, "NTLM handshake failure (empty type-2 message)\n"); + + return CURLE_BAD_CONTENT_ENCODING; + } + + /* Simply store the challenge for use later */ + ntlm->input_token = type2; + ntlm->input_token_len = type2_len; + + return result; +} + +/* +* Curl_sasl_create_ntlm_type3_message() +* +* This is used to generate an already encoded NTLM type-3 message ready for +* sending to the recipient. +* +* Parameters: +* +* data [in] - The session handle. +* userp [in] - The user name in the format User or Domain\User. +* passdwp [in] - The user's password. +* ntlm [in/out] - The ntlm data struct being used and modified. +* outptr [in/out] - The address where a pointer to newly allocated memory +* holding the result will be stored upon completion. +* outlen [out] - The length of the output message. +* +* Returns CURLE_OK on success. +*/ +CURLcode Curl_sasl_create_ntlm_type3_message(struct SessionHandle *data, + const char *userp, + const char *passwdp, + struct ntlmdata *ntlm, + char **outptr, size_t *outlen) +{ + CURLcode result = CURLE_OK; + SecBuffer type_2_buf; + SecBuffer type_3_buf; + SecBufferDesc type_2_desc; + SecBufferDesc type_3_desc; + SECURITY_STATUS status; + unsigned long attrs; + TimeStamp expiry; /* For Windows 9x compatibility of SSPI calls */ + + (void) passwdp; + (void) userp; + + /* Setup the type-2 "input" security buffer */ + type_2_desc.ulVersion = SECBUFFER_VERSION; + type_2_desc.cBuffers = 1; + type_2_desc.pBuffers = &type_2_buf; + type_2_buf.BufferType = SECBUFFER_TOKEN; + type_2_buf.pvBuffer = ntlm->input_token; + type_2_buf.cbBuffer = curlx_uztoul(ntlm->input_token_len); + + /* Setup the type-3 "output" security buffer */ + type_3_desc.ulVersion = SECBUFFER_VERSION; + type_3_desc.cBuffers = 1; + type_3_desc.pBuffers = &type_3_buf; + type_3_buf.BufferType = SECBUFFER_TOKEN; + type_3_buf.pvBuffer = ntlm->output_token; + type_3_buf.cbBuffer = curlx_uztoul(ntlm->token_max); + + /* Generate our type-3 message */ + status = s_pSecFn->InitializeSecurityContext(ntlm->credentials, + ntlm->context, + (TCHAR *) TEXT(""), + 0, 0, SECURITY_NETWORK_DREP, + &type_2_desc, + 0, ntlm->context, + &type_3_desc, + &attrs, &expiry); + if(status != SEC_E_OK) { + infof(data, "NTLM handshake failure (type-3 message): Status=%x\n", + status); + + return CURLE_RECV_ERROR; + } + + /* Base64 encode the response */ + result = Curl_base64_encode(data, (char *) ntlm->output_token, + type_3_buf.cbBuffer, outptr, outlen); + + Curl_sasl_ntlm_cleanup(ntlm); + + return result; +} + +/* + * Curl_sasl_ntlm_cleanup() + * + * This is used to clean up the ntlm specific data. + * + * Parameters: + * + * ntlm [in/out] - The ntlm data struct being cleaned up. + * + */ +void Curl_sasl_ntlm_cleanup(struct ntlmdata *ntlm) +{ + /* Free our security context */ + if(ntlm->context) { + s_pSecFn->DeleteSecurityContext(ntlm->context); + free(ntlm->context); + ntlm->context = NULL; + } + + /* Free our credentials handle */ + if(ntlm->credentials) { + s_pSecFn->FreeCredentialsHandle(ntlm->credentials); + free(ntlm->credentials); + ntlm->credentials = NULL; + } + + /* Free our identity */ + Curl_sspi_free_identity(ntlm->p_identity); + ntlm->p_identity = NULL; + + /* Free the input and output tokens */ + Curl_safefree(ntlm->input_token); + Curl_safefree(ntlm->output_token); + + /* Reset any variables */ + ntlm->token_max = 0; +} +#endif /* USE_NTLM */ + +#if defined(USE_KERBEROS5) /* * Curl_sasl_create_gssapi_user_message() * @@ -280,13 +843,12 @@ CURLcode Curl_sasl_create_digest_md5_message(struct SessionHandle *data, * Parameters: * * data [in] - The session handle. - * userp [in] - The user name. + * userp [in] - The user name in the format User or Domain\User. * passdwp [in] - The user's password. * service [in] - The service type such as www, smtp, pop or imap. * mutual_auth [in] - Flag specifing whether or not mutual authentication * is enabled. - * chlg64 [in] - Pointer to the optional base64 encoded challenge - * message. + * chlg64 [in] - The optional base64 encoded challenge message. * krb5 [in/out] - The gssapi data struct being used and modified. * outptr [in/out] - The address where a pointer to newly allocated memory * holding the result will be stored upon completion. @@ -314,11 +876,12 @@ CURLcode Curl_sasl_create_gssapi_user_message(struct SessionHandle *data, SecBufferDesc resp_desc; SECURITY_STATUS status; unsigned long attrs; - TimeStamp tsDummy; /* For Windows 9x compatibility of SSPI calls */ + TimeStamp expiry; /* For Windows 9x compatibility of SSPI calls */ if(!krb5->credentials) { /* Query the security package for Kerberos */ - status = s_pSecFn->QuerySecurityPackageInfo((TCHAR *) TEXT("Kerberos"), + status = s_pSecFn->QuerySecurityPackageInfo((TCHAR *) + TEXT(SP_NAME_KERBEROS), &SecurityPackage); if(status != SEC_E_OK) { return CURLE_NOT_BUILT_IN; @@ -329,6 +892,11 @@ CURLcode Curl_sasl_create_gssapi_user_message(struct SessionHandle *data, /* Release the package buffer as it is not required anymore */ s_pSecFn->FreeContextBuffer(SecurityPackage); + /* Allocate our response buffer */ + krb5->output_token = malloc(krb5->token_max); + if(!krb5->output_token) + return CURLE_OUT_OF_MEMORY; + /* Generate our SPN */ krb5->spn = Curl_sasl_build_spn(service, data->easy_conn->host.name); if(!krb5->spn) @@ -342,11 +910,6 @@ CURLcode Curl_sasl_create_gssapi_user_message(struct SessionHandle *data, /* Allow proper cleanup of the identity structure */ krb5->p_identity = &krb5->identity; - - /* Allocate our response buffer */ - krb5->output_token = malloc(krb5->token_max); - if(!krb5->output_token) - return CURLE_OUT_OF_MEMORY; } else /* Use the current Windows user */ @@ -359,14 +922,15 @@ CURLcode Curl_sasl_create_gssapi_user_message(struct SessionHandle *data, memset(krb5->credentials, 0, sizeof(CredHandle)); - /* Acquire our credientials handle */ + /* Acquire our credentials handle */ status = s_pSecFn->AcquireCredentialsHandle(NULL, - (TCHAR *) TEXT("Kerberos"), + (TCHAR *) + TEXT(SP_NAME_KERBEROS), SECPKG_CRED_OUTBOUND, NULL, krb5->p_identity, NULL, NULL, - krb5->credentials, &tsDummy); + krb5->credentials, &expiry); if(status != SEC_E_OK) - return CURLE_OUT_OF_MEMORY; + return CURLE_LOGIN_DENIED; /* Allocate our new context handle */ krb5->context = malloc(sizeof(CtxtHandle)); @@ -384,8 +948,11 @@ CURLcode Curl_sasl_create_gssapi_user_message(struct SessionHandle *data, } /* Ensure we have a valid challenge message */ - if(!chlg) + if(!chlg) { + infof(data, "GSSAPI handshake failure (empty challenge message)\n"); + return CURLE_BAD_CONTENT_ENCODING; + } /* Setup the challenge "input" security buffer */ chlg_desc.ulVersion = SECBUFFER_VERSION; @@ -414,10 +981,10 @@ CURLcode Curl_sasl_create_gssapi_user_message(struct SessionHandle *data, chlg ? &chlg_desc : NULL, 0, &context, &resp_desc, &attrs, - &tsDummy); + &expiry); if(status != SEC_E_OK && status != SEC_I_CONTINUE_NEEDED) { - Curl_safefree(chlg); + free(chlg); return CURLE_RECV_ERROR; } @@ -435,7 +1002,7 @@ CURLcode Curl_sasl_create_gssapi_user_message(struct SessionHandle *data, } /* Free the decoded challenge */ - Curl_safefree(chlg); + free(chlg); return result; } @@ -449,7 +1016,7 @@ CURLcode Curl_sasl_create_gssapi_user_message(struct SessionHandle *data, * Parameters: * * data [in] - The session handle. - * chlg64 [in] - Pointer to the optional base64 encoded challenge message. + * chlg64 [in] - The optional base64 encoded challenge message. * krb5 [in/out] - The gssapi data struct being used and modified. * outptr [in/out] - The address where a pointer to newly allocated memory * holding the result will be stored upon completion. @@ -485,8 +1052,7 @@ CURLcode Curl_sasl_create_gssapi_security_message(struct SessionHandle *data, SecPkgContext_Sizes sizes; SecPkgCredentials_Names names; SECURITY_STATUS status; - - /* TODO: Verify the unicodeness of this function */ + char *user_name; /* Decode the base-64 encoded input message */ if(strlen(chlg64) && *chlg64 != '=') { @@ -496,15 +1062,18 @@ CURLcode Curl_sasl_create_gssapi_security_message(struct SessionHandle *data, } /* Ensure we have a valid challenge message */ - if(!chlg) + if(!chlg) { + infof(data, "GSSAPI handshake failure (empty security message)\n"); + return CURLE_BAD_CONTENT_ENCODING; + } /* Get our response size information */ status = s_pSecFn->QueryContextAttributes(krb5->context, SECPKG_ATTR_SIZES, &sizes); if(status != SEC_E_OK) { - Curl_safefree(chlg); + free(chlg); return CURLE_OUT_OF_MEMORY; } @@ -514,7 +1083,7 @@ CURLcode Curl_sasl_create_gssapi_security_message(struct SessionHandle *data, SECPKG_CRED_ATTR_NAMES, &names); if(status != SEC_E_OK) { - Curl_safefree(chlg); + free(chlg); return CURLE_RECV_ERROR; } @@ -530,30 +1099,34 @@ CURLcode Curl_sasl_create_gssapi_security_message(struct SessionHandle *data, input_buf[1].pvBuffer = NULL; input_buf[1].cbBuffer = 0; - /* Decrypt in the inbound challenge obtaining the qop */ + /* Decrypt the inbound challenge and obtain the qop */ status = s_pSecFn->DecryptMessage(krb5->context, &input_desc, 0, &qop); if(status != SEC_E_OK) { - Curl_safefree(chlg); + infof(data, "GSSAPI handshake failure (empty security message)\n"); + + free(chlg); return CURLE_BAD_CONTENT_ENCODING; } - /* Not 4 octets long to fail as per RFC4752 Section 3.1 */ + /* Not 4 octets long so fail as per RFC4752 Section 3.1 */ if(input_buf[1].cbBuffer != 4) { - Curl_safefree(chlg); + infof(data, "GSSAPI handshake failure (invalid security data)\n"); + + free(chlg); return CURLE_BAD_CONTENT_ENCODING; } - /* Copy the data out into a coinput_bufnvenient variable and free the SSPI - allocated buffer as it is not required anymore */ + /* Copy the data out and free the challenge as it is not required anymore */ memcpy(&indata, input_buf[1].pvBuffer, 4); s_pSecFn->FreeContextBuffer(input_buf[1].pvBuffer); + free(chlg); /* Extract the security layer */ sec_layer = indata & 0x000000FF; if(!(sec_layer & KERB_WRAP_NO_ENCRYPT)) { - Curl_safefree(chlg); + infof(data, "GSSAPI handshake failure (invalid security layer)\n"); return CURLE_BAD_CONTENT_ENCODING; } @@ -562,27 +1135,30 @@ CURLcode Curl_sasl_create_gssapi_security_message(struct SessionHandle *data, max_size = ntohl(indata & 0xFFFFFF00); if(max_size > 0) { /* The server has told us it supports a maximum receive buffer, however, as - we don't require one unless we are encrypting data we, tell the server + we don't require one unless we are encrypting data, we tell the server our receive buffer is zero. */ max_size = 0; } - outdata = htonl(max_size) | sec_layer; - /* Allocate the trailer */ trailer = malloc(sizes.cbSecurityTrailer); - if(!trailer) { - Curl_safefree(chlg); + if(!trailer) + return CURLE_OUT_OF_MEMORY; + + /* Convert the user name to UTF8 when operating with Unicode */ + user_name = Curl_convert_tchar_to_UTF8(names.sUserName); + if(!user_name) { + free(trailer); return CURLE_OUT_OF_MEMORY; } /* Allocate our message */ - messagelen = 4 + strlen(names.sUserName) + 1; + messagelen = sizeof(outdata) + strlen(user_name) + 1; message = malloc(messagelen); if(!message) { - Curl_safefree(trailer); - Curl_safefree(chlg); + free(trailer); + Curl_unicodefree(user_name); return CURLE_OUT_OF_MEMORY; } @@ -592,15 +1168,16 @@ CURLcode Curl_sasl_create_gssapi_security_message(struct SessionHandle *data, terminator. Note: Dispite RFC4752 Section 3.1 stating "The authorization identity is not terminated with the zero-valued (%x00) octet." it seems necessary to include it. */ - memcpy(message, &outdata, 4); - strcpy((char *)message + 4, names.sUserName); + outdata = htonl(max_size) | sec_layer; + memcpy(message, &outdata, sizeof(outdata)); + strcpy((char *) message + sizeof(outdata), user_name); + Curl_unicodefree(user_name); /* Allocate the padding */ padding = malloc(sizes.cbBlockSize); if(!padding) { - Curl_safefree(message); - Curl_safefree(trailer); - Curl_safefree(chlg); + free(message); + free(trailer); return CURLE_OUT_OF_MEMORY; } @@ -623,10 +1200,9 @@ CURLcode Curl_sasl_create_gssapi_security_message(struct SessionHandle *data, status = s_pSecFn->EncryptMessage(krb5->context, KERB_WRAP_NO_ENCRYPT, &wrap_desc, 0); if(status != SEC_E_OK) { - Curl_safefree(padding); - Curl_safefree(message); - Curl_safefree(trailer); - Curl_safefree(chlg); + free(padding); + free(message); + free(trailer); return CURLE_OUT_OF_MEMORY; } @@ -636,10 +1212,9 @@ CURLcode Curl_sasl_create_gssapi_security_message(struct SessionHandle *data, wrap_buf[2].cbBuffer; appdata = malloc(appdatalen); if(!appdata) { - Curl_safefree(padding); - Curl_safefree(message); - Curl_safefree(trailer); - Curl_safefree(chlg); + free(padding); + free(message); + free(trailer); return CURLE_OUT_OF_MEMORY; } @@ -656,25 +1231,34 @@ CURLcode Curl_sasl_create_gssapi_security_message(struct SessionHandle *data, outlen); /* Free all of our local buffers */ - Curl_safefree(appdata); - Curl_safefree(padding); - Curl_safefree(message); - Curl_safefree(trailer); - Curl_safefree(chlg); + free(appdata); + free(padding); + free(message); + free(trailer); return result; } +/* + * Curl_sasl_gssapi_cleanup() + * + * This is used to clean up the gssapi specific data. + * + * Parameters: + * + * krb5 [in/out] - The kerberos 5 data struct being cleaned up. + * + */ void Curl_sasl_gssapi_cleanup(struct kerberos5data *krb5) { - /* Free the context */ + /* Free our security context */ if(krb5->context) { s_pSecFn->DeleteSecurityContext(krb5->context); free(krb5->context); krb5->context = NULL; } - /* Free the credientials handle */ + /* Free our credentials handle */ if(krb5->credentials) { s_pSecFn->FreeCredentialsHandle(krb5->credentials); free(krb5->credentials); @@ -692,5 +1276,6 @@ void Curl_sasl_gssapi_cleanup(struct kerberos5data *krb5) /* Reset any variables */ krb5->token_max = 0; } +#endif /* USE_KERBEROS5 */ #endif /* USE_WINDOWS_SSPI */ diff --git a/lib/curl_sec.h b/lib/curl_sec.h index 82151e9..6c48da2 100644 --- a/lib/curl_sec.h +++ b/lib/curl_sec.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2013, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -30,7 +30,7 @@ struct Curl_sec_client_mech { void (*end)(void *); int (*check_prot)(void *, int); int (*overhead)(void *, int, int); - int (*encode)(void *, const void*, int, int, void**, struct connectdata *); + int (*encode)(void *, const void*, int, int, void**); int (*decode)(void *, void*, int, int, struct connectdata *); }; diff --git a/lib/curl_setup.h b/lib/curl_setup.h index 173731c..ab0c139 100644 --- a/lib/curl_setup.h +++ b/lib/curl_setup.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2013, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -190,6 +190,9 @@ # ifndef CURL_DISABLE_GOPHER # define CURL_DISABLE_GOPHER # endif +# ifndef CURL_DISABLE_SMB +# define CURL_DISABLE_SMB +# endif #endif /* @@ -601,26 +604,38 @@ int netware_init(void); #define LIBIDN_REQUIRED_VERSION "0.4.1" -#if defined(USE_GNUTLS) || defined(USE_SSLEAY) || defined(USE_NSS) || \ - defined(USE_QSOSSL) || defined(USE_POLARSSL) || defined(USE_AXTLS) || \ +#if defined(USE_GNUTLS) || defined(USE_OPENSSL) || defined(USE_NSS) || \ + defined(USE_POLARSSL) || defined(USE_AXTLS) || \ defined(USE_CYASSL) || defined(USE_SCHANNEL) || \ defined(USE_DARWINSSL) || defined(USE_GSKIT) #define USE_SSL /* SSL support has been enabled */ #endif +/* Single point where USE_SPNEGO definition might be defined */ #if !defined(CURL_DISABLE_CRYPTO_AUTH) && \ (defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)) #define USE_SPNEGO #endif -/* Single point where USE_NTLM definition might be done */ -#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_NTLM) && \ - !defined(CURL_DISABLE_CRYPTO_AUTH) -#if defined(USE_SSLEAY) || defined(USE_WINDOWS_SSPI) || \ - defined(USE_GNUTLS) || defined(USE_NSS) || defined(USE_DARWINSSL) +/* Single point where USE_KERBEROS5 definition might be defined */ +#if !defined(CURL_DISABLE_CRYPTO_AUTH) && \ + (defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)) +#define USE_KERBEROS5 +#endif + +/* Single point where USE_NTLM definition might be defined */ +#if !defined(CURL_DISABLE_NTLM) && !defined(CURL_DISABLE_CRYPTO_AUTH) +#if defined(USE_OPENSSL) || defined(USE_WINDOWS_SSPI) || \ + defined(USE_GNUTLS) || defined(USE_NSS) || defined(USE_DARWINSSL) || \ + defined(USE_OS400CRYPTO) || defined(USE_WIN32_CRYPTO) + +#ifdef HAVE_BORINGSSL /* BoringSSL is not NTLM capable */ +#undef USE_NTLM +#else #define USE_NTLM #endif #endif +#endif /* non-configure builds may define CURL_WANTS_CA_BUNDLE_ENV */ #if defined(CURL_WANTS_CA_BUNDLE_ENV) && !defined(CURL_CA_BUNDLE) @@ -636,8 +651,10 @@ int netware_init(void); #if defined(__GNUC__) && ((__GNUC__ >= 3) || \ ((__GNUC__ == 2) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ >= 7))) # define UNUSED_PARAM __attribute__((__unused__)) +# define WARN_UNUSED_RESULT __attribute__((warn_unused_result)) #else # define UNUSED_PARAM /*NOTHING*/ +# define WARN_UNUSED_RESULT #endif /* @@ -690,4 +707,24 @@ int netware_init(void); #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) #endif +/* In Windows the default file mode is text but an application can override it. +Therefore we specify it explicitly. https://github.com/bagder/curl/pull/258 +*/ +#if defined(WIN32) || defined(MSDOS) +#define FOPEN_READTEXT "rt" +#define FOPEN_WRITETEXT "wt" +#elif defined(__CYGWIN__) +/* Cygwin has specific behavior we need to address when WIN32 is not defined. +https://cygwin.com/cygwin-ug-net/using-textbinary.html +For write we want our output to have line endings of LF and be compatible with +other Cygwin utilities. For read we want to handle input that may have line +endings either CRLF or LF so 't' is appropriate. +*/ +#define FOPEN_READTEXT "rt" +#define FOPEN_WRITETEXT "w" +#else +#define FOPEN_READTEXT "r" +#define FOPEN_WRITETEXT "w" +#endif + #endif /* HEADER_CURL_SETUP_H */ diff --git a/lib/curl_sspi.c b/lib/curl_sspi.c index f09d288..070424d 100644 --- a/lib/curl_sspi.c +++ b/lib/curl_sspi.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -25,17 +25,12 @@ #ifdef USE_WINDOWS_SSPI #include - #include "curl_sspi.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include - -#include "curl_memory.h" #include "curl_multibyte.h" #include "warnless.h" -/* The last #include file should be: */ +/* The last #include files should be: */ +#include "curl_memory.h" #include "memdebug.h" /* We use our own typedef here since some headers might lack these */ @@ -98,20 +93,25 @@ CURLcode Curl_sspi_global_init(void) osver.dwPlatformId == platformId) securityDll = TRUE; #else - ULONGLONG majorVersionMask; - ULONGLONG platformIdMask; + ULONGLONG cm; OSVERSIONINFOEX osver; memset(&osver, 0, sizeof(osver)); osver.dwOSVersionInfoSize = sizeof(osver); osver.dwMajorVersion = majorVersion; osver.dwPlatformId = platformId; - majorVersionMask = VerSetConditionMask(0, VER_MAJORVERSION, VER_EQUAL); - platformIdMask = VerSetConditionMask(0, VER_PLATFORMID, VER_EQUAL); + + cm = VerSetConditionMask(0, VER_MAJORVERSION, VER_EQUAL); + cm = VerSetConditionMask(cm, VER_MINORVERSION, VER_GREATER_EQUAL); + cm = VerSetConditionMask(cm, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL); + cm = VerSetConditionMask(cm, VER_SERVICEPACKMINOR, VER_GREATER_EQUAL); + cm = VerSetConditionMask(cm, VER_PLATFORMID, VER_EQUAL); /* Verify the major version number == 4 and platform id == WIN_NT */ - if(VerifyVersionInfo(&osver, VER_MAJORVERSION, majorVersionMask) && - VerifyVersionInfo(&osver, VER_PLATFORMID, platformIdMask)) + if(VerifyVersionInfo(&osver, (VER_MAJORVERSION | VER_MINORVERSION | + VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR | + VER_PLATFORMID), + cm)) securityDll = TRUE; #endif @@ -224,7 +224,7 @@ CURLcode Curl_create_sspi_identity(const char *userp, const char *passwdp, Curl_unicodefree(useranddomain.tchar_ptr); - /* Setup ntlm identity's password and length */ + /* Setup the identity's password and length */ passwd.tchar_ptr = Curl_convert_UTF8_to_tchar((char *)passwdp); if(!passwd.tchar_ptr) return CURLE_OUT_OF_MEMORY; diff --git a/lib/curl_sspi.h b/lib/curl_sspi.h index 5ab17d5..8655715 100644 --- a/lib/curl_sspi.h +++ b/lib/curl_sspi.h @@ -43,6 +43,10 @@ CURLcode Curl_sspi_global_init(void); void Curl_sspi_global_cleanup(void); +/* This is used to populate the domain in a SSPI identity structure */ +CURLcode Curl_override_sspi_http_realm(const char *chlg, + SEC_WINNT_AUTH_IDENTITY *identity); + /* This is used to generate an SSPI identity structure */ CURLcode Curl_create_sspi_identity(const char *userp, const char *passwdp, SEC_WINNT_AUTH_IDENTITY *identity); @@ -51,249 +55,276 @@ CURLcode Curl_create_sspi_identity(const char *userp, const char *passwdp, void Curl_sspi_free_identity(SEC_WINNT_AUTH_IDENTITY *identity); /* Forward-declaration of global variables defined in curl_sspi.c */ - extern HMODULE s_hSecDll; extern PSecurityFunctionTable s_pSecFn; /* Provide some definitions missing in old headers */ +#define SP_NAME_DIGEST "WDigest" +#define SP_NAME_NTLM "NTLM" +#define SP_NAME_NEGOTIATE "Negotiate" +#define SP_NAME_KERBEROS "Kerberos" + +#ifndef ISC_REQ_USE_HTTP_STYLE +#define ISC_REQ_USE_HTTP_STYLE 0x01000000 +#endif + +#ifndef ISC_RET_REPLAY_DETECT +#define ISC_RET_REPLAY_DETECT 0x00000004 +#endif + +#ifndef ISC_RET_SEQUENCE_DETECT +#define ISC_RET_SEQUENCE_DETECT 0x00000008 +#endif + +#ifndef ISC_RET_CONFIDENTIALITY +#define ISC_RET_CONFIDENTIALITY 0x00000010 +#endif + +#ifndef ISC_RET_ALLOCATED_MEMORY +#define ISC_RET_ALLOCATED_MEMORY 0x00000100 +#endif + +#ifndef ISC_RET_STREAM +#define ISC_RET_STREAM 0x00008000 +#endif #ifndef SEC_E_INSUFFICIENT_MEMORY -# define SEC_E_INSUFFICIENT_MEMORY ((HRESULT)0x80090300L) +# define SEC_E_INSUFFICIENT_MEMORY ((HRESULT)0x80090300L) #endif #ifndef SEC_E_INVALID_HANDLE -# define SEC_E_INVALID_HANDLE ((HRESULT)0x80090301L) +# define SEC_E_INVALID_HANDLE ((HRESULT)0x80090301L) #endif #ifndef SEC_E_UNSUPPORTED_FUNCTION -# define SEC_E_UNSUPPORTED_FUNCTION ((HRESULT)0x80090302L) +# define SEC_E_UNSUPPORTED_FUNCTION ((HRESULT)0x80090302L) #endif #ifndef SEC_E_TARGET_UNKNOWN -# define SEC_E_TARGET_UNKNOWN ((HRESULT)0x80090303L) +# define SEC_E_TARGET_UNKNOWN ((HRESULT)0x80090303L) #endif #ifndef SEC_E_INTERNAL_ERROR -# define SEC_E_INTERNAL_ERROR ((HRESULT)0x80090304L) +# define SEC_E_INTERNAL_ERROR ((HRESULT)0x80090304L) #endif #ifndef SEC_E_SECPKG_NOT_FOUND -# define SEC_E_SECPKG_NOT_FOUND ((HRESULT)0x80090305L) +# define SEC_E_SECPKG_NOT_FOUND ((HRESULT)0x80090305L) #endif #ifndef SEC_E_NOT_OWNER -# define SEC_E_NOT_OWNER ((HRESULT)0x80090306L) +# define SEC_E_NOT_OWNER ((HRESULT)0x80090306L) #endif #ifndef SEC_E_CANNOT_INSTALL -# define SEC_E_CANNOT_INSTALL ((HRESULT)0x80090307L) +# define SEC_E_CANNOT_INSTALL ((HRESULT)0x80090307L) #endif #ifndef SEC_E_INVALID_TOKEN -# define SEC_E_INVALID_TOKEN ((HRESULT)0x80090308L) +# define SEC_E_INVALID_TOKEN ((HRESULT)0x80090308L) #endif #ifndef SEC_E_CANNOT_PACK -# define SEC_E_CANNOT_PACK ((HRESULT)0x80090309L) +# define SEC_E_CANNOT_PACK ((HRESULT)0x80090309L) #endif #ifndef SEC_E_QOP_NOT_SUPPORTED -# define SEC_E_QOP_NOT_SUPPORTED ((HRESULT)0x8009030AL) +# define SEC_E_QOP_NOT_SUPPORTED ((HRESULT)0x8009030AL) #endif #ifndef SEC_E_NO_IMPERSONATION -# define SEC_E_NO_IMPERSONATION ((HRESULT)0x8009030BL) +# define SEC_E_NO_IMPERSONATION ((HRESULT)0x8009030BL) #endif #ifndef SEC_E_LOGON_DENIED -# define SEC_E_LOGON_DENIED ((HRESULT)0x8009030CL) +# define SEC_E_LOGON_DENIED ((HRESULT)0x8009030CL) #endif #ifndef SEC_E_UNKNOWN_CREDENTIALS -# define SEC_E_UNKNOWN_CREDENTIALS ((HRESULT)0x8009030DL) +# define SEC_E_UNKNOWN_CREDENTIALS ((HRESULT)0x8009030DL) #endif #ifndef SEC_E_NO_CREDENTIALS -# define SEC_E_NO_CREDENTIALS ((HRESULT)0x8009030EL) +# define SEC_E_NO_CREDENTIALS ((HRESULT)0x8009030EL) #endif #ifndef SEC_E_MESSAGE_ALTERED -# define SEC_E_MESSAGE_ALTERED ((HRESULT)0x8009030FL) +# define SEC_E_MESSAGE_ALTERED ((HRESULT)0x8009030FL) #endif #ifndef SEC_E_OUT_OF_SEQUENCE -# define SEC_E_OUT_OF_SEQUENCE ((HRESULT)0x80090310L) +# define SEC_E_OUT_OF_SEQUENCE ((HRESULT)0x80090310L) #endif #ifndef SEC_E_NO_AUTHENTICATING_AUTHORITY -# define SEC_E_NO_AUTHENTICATING_AUTHORITY ((HRESULT)0x80090311L) +# define SEC_E_NO_AUTHENTICATING_AUTHORITY ((HRESULT)0x80090311L) #endif #ifndef SEC_E_BAD_PKGID -# define SEC_E_BAD_PKGID ((HRESULT)0x80090316L) +# define SEC_E_BAD_PKGID ((HRESULT)0x80090316L) #endif #ifndef SEC_E_CONTEXT_EXPIRED -# define SEC_E_CONTEXT_EXPIRED ((HRESULT)0x80090317L) +# define SEC_E_CONTEXT_EXPIRED ((HRESULT)0x80090317L) #endif #ifndef SEC_E_INCOMPLETE_MESSAGE -# define SEC_E_INCOMPLETE_MESSAGE ((HRESULT)0x80090318L) +# define SEC_E_INCOMPLETE_MESSAGE ((HRESULT)0x80090318L) #endif #ifndef SEC_E_INCOMPLETE_CREDENTIALS -# define SEC_E_INCOMPLETE_CREDENTIALS ((HRESULT)0x80090320L) +# define SEC_E_INCOMPLETE_CREDENTIALS ((HRESULT)0x80090320L) #endif #ifndef SEC_E_BUFFER_TOO_SMALL -# define SEC_E_BUFFER_TOO_SMALL ((HRESULT)0x80090321L) +# define SEC_E_BUFFER_TOO_SMALL ((HRESULT)0x80090321L) #endif #ifndef SEC_E_WRONG_PRINCIPAL -# define SEC_E_WRONG_PRINCIPAL ((HRESULT)0x80090322L) +# define SEC_E_WRONG_PRINCIPAL ((HRESULT)0x80090322L) #endif #ifndef SEC_E_TIME_SKEW -# define SEC_E_TIME_SKEW ((HRESULT)0x80090324L) +# define SEC_E_TIME_SKEW ((HRESULT)0x80090324L) #endif #ifndef SEC_E_UNTRUSTED_ROOT -# define SEC_E_UNTRUSTED_ROOT ((HRESULT)0x80090325L) +# define SEC_E_UNTRUSTED_ROOT ((HRESULT)0x80090325L) #endif #ifndef SEC_E_ILLEGAL_MESSAGE -# define SEC_E_ILLEGAL_MESSAGE ((HRESULT)0x80090326L) +# define SEC_E_ILLEGAL_MESSAGE ((HRESULT)0x80090326L) #endif #ifndef SEC_E_CERT_UNKNOWN -# define SEC_E_CERT_UNKNOWN ((HRESULT)0x80090327L) +# define SEC_E_CERT_UNKNOWN ((HRESULT)0x80090327L) #endif #ifndef SEC_E_CERT_EXPIRED -# define SEC_E_CERT_EXPIRED ((HRESULT)0x80090328L) +# define SEC_E_CERT_EXPIRED ((HRESULT)0x80090328L) #endif #ifndef SEC_E_ENCRYPT_FAILURE -# define SEC_E_ENCRYPT_FAILURE ((HRESULT)0x80090329L) +# define SEC_E_ENCRYPT_FAILURE ((HRESULT)0x80090329L) #endif #ifndef SEC_E_DECRYPT_FAILURE -# define SEC_E_DECRYPT_FAILURE ((HRESULT)0x80090330L) +# define SEC_E_DECRYPT_FAILURE ((HRESULT)0x80090330L) #endif #ifndef SEC_E_ALGORITHM_MISMATCH -# define SEC_E_ALGORITHM_MISMATCH ((HRESULT)0x80090331L) +# define SEC_E_ALGORITHM_MISMATCH ((HRESULT)0x80090331L) #endif #ifndef SEC_E_SECURITY_QOS_FAILED -# define SEC_E_SECURITY_QOS_FAILED ((HRESULT)0x80090332L) +# define SEC_E_SECURITY_QOS_FAILED ((HRESULT)0x80090332L) #endif #ifndef SEC_E_UNFINISHED_CONTEXT_DELETED -# define SEC_E_UNFINISHED_CONTEXT_DELETED ((HRESULT)0x80090333L) +# define SEC_E_UNFINISHED_CONTEXT_DELETED ((HRESULT)0x80090333L) #endif #ifndef SEC_E_NO_TGT_REPLY -# define SEC_E_NO_TGT_REPLY ((HRESULT)0x80090334L) +# define SEC_E_NO_TGT_REPLY ((HRESULT)0x80090334L) #endif #ifndef SEC_E_NO_IP_ADDRESSES -# define SEC_E_NO_IP_ADDRESSES ((HRESULT)0x80090335L) +# define SEC_E_NO_IP_ADDRESSES ((HRESULT)0x80090335L) #endif #ifndef SEC_E_WRONG_CREDENTIAL_HANDLE -# define SEC_E_WRONG_CREDENTIAL_HANDLE ((HRESULT)0x80090336L) +# define SEC_E_WRONG_CREDENTIAL_HANDLE ((HRESULT)0x80090336L) #endif #ifndef SEC_E_CRYPTO_SYSTEM_INVALID -# define SEC_E_CRYPTO_SYSTEM_INVALID ((HRESULT)0x80090337L) +# define SEC_E_CRYPTO_SYSTEM_INVALID ((HRESULT)0x80090337L) #endif #ifndef SEC_E_MAX_REFERRALS_EXCEEDED -# define SEC_E_MAX_REFERRALS_EXCEEDED ((HRESULT)0x80090338L) +# define SEC_E_MAX_REFERRALS_EXCEEDED ((HRESULT)0x80090338L) #endif #ifndef SEC_E_MUST_BE_KDC -# define SEC_E_MUST_BE_KDC ((HRESULT)0x80090339L) +# define SEC_E_MUST_BE_KDC ((HRESULT)0x80090339L) #endif #ifndef SEC_E_STRONG_CRYPTO_NOT_SUPPORTED -# define SEC_E_STRONG_CRYPTO_NOT_SUPPORTED ((HRESULT)0x8009033AL) +# define SEC_E_STRONG_CRYPTO_NOT_SUPPORTED ((HRESULT)0x8009033AL) #endif #ifndef SEC_E_TOO_MANY_PRINCIPALS -# define SEC_E_TOO_MANY_PRINCIPALS ((HRESULT)0x8009033BL) +# define SEC_E_TOO_MANY_PRINCIPALS ((HRESULT)0x8009033BL) #endif #ifndef SEC_E_NO_PA_DATA -# define SEC_E_NO_PA_DATA ((HRESULT)0x8009033CL) +# define SEC_E_NO_PA_DATA ((HRESULT)0x8009033CL) #endif #ifndef SEC_E_PKINIT_NAME_MISMATCH -# define SEC_E_PKINIT_NAME_MISMATCH ((HRESULT)0x8009033DL) +# define SEC_E_PKINIT_NAME_MISMATCH ((HRESULT)0x8009033DL) #endif #ifndef SEC_E_SMARTCARD_LOGON_REQUIRED -# define SEC_E_SMARTCARD_LOGON_REQUIRED ((HRESULT)0x8009033EL) +# define SEC_E_SMARTCARD_LOGON_REQUIRED ((HRESULT)0x8009033EL) #endif #ifndef SEC_E_SHUTDOWN_IN_PROGRESS -# define SEC_E_SHUTDOWN_IN_PROGRESS ((HRESULT)0x8009033FL) +# define SEC_E_SHUTDOWN_IN_PROGRESS ((HRESULT)0x8009033FL) #endif #ifndef SEC_E_KDC_INVALID_REQUEST -# define SEC_E_KDC_INVALID_REQUEST ((HRESULT)0x80090340L) +# define SEC_E_KDC_INVALID_REQUEST ((HRESULT)0x80090340L) #endif #ifndef SEC_E_KDC_UNABLE_TO_REFER -# define SEC_E_KDC_UNABLE_TO_REFER ((HRESULT)0x80090341L) +# define SEC_E_KDC_UNABLE_TO_REFER ((HRESULT)0x80090341L) #endif #ifndef SEC_E_KDC_UNKNOWN_ETYPE -# define SEC_E_KDC_UNKNOWN_ETYPE ((HRESULT)0x80090342L) +# define SEC_E_KDC_UNKNOWN_ETYPE ((HRESULT)0x80090342L) #endif #ifndef SEC_E_UNSUPPORTED_PREAUTH -# define SEC_E_UNSUPPORTED_PREAUTH ((HRESULT)0x80090343L) +# define SEC_E_UNSUPPORTED_PREAUTH ((HRESULT)0x80090343L) #endif #ifndef SEC_E_DELEGATION_REQUIRED -# define SEC_E_DELEGATION_REQUIRED ((HRESULT)0x80090345L) +# define SEC_E_DELEGATION_REQUIRED ((HRESULT)0x80090345L) #endif #ifndef SEC_E_BAD_BINDINGS -# define SEC_E_BAD_BINDINGS ((HRESULT)0x80090346L) +# define SEC_E_BAD_BINDINGS ((HRESULT)0x80090346L) #endif #ifndef SEC_E_MULTIPLE_ACCOUNTS -# define SEC_E_MULTIPLE_ACCOUNTS ((HRESULT)0x80090347L) +# define SEC_E_MULTIPLE_ACCOUNTS ((HRESULT)0x80090347L) #endif #ifndef SEC_E_NO_KERB_KEY -# define SEC_E_NO_KERB_KEY ((HRESULT)0x80090348L) +# define SEC_E_NO_KERB_KEY ((HRESULT)0x80090348L) #endif #ifndef SEC_E_CERT_WRONG_USAGE -# define SEC_E_CERT_WRONG_USAGE ((HRESULT)0x80090349L) +# define SEC_E_CERT_WRONG_USAGE ((HRESULT)0x80090349L) #endif #ifndef SEC_E_DOWNGRADE_DETECTED -# define SEC_E_DOWNGRADE_DETECTED ((HRESULT)0x80090350L) +# define SEC_E_DOWNGRADE_DETECTED ((HRESULT)0x80090350L) #endif #ifndef SEC_E_SMARTCARD_CERT_REVOKED -# define SEC_E_SMARTCARD_CERT_REVOKED ((HRESULT)0x80090351L) +# define SEC_E_SMARTCARD_CERT_REVOKED ((HRESULT)0x80090351L) #endif #ifndef SEC_E_ISSUING_CA_UNTRUSTED -# define SEC_E_ISSUING_CA_UNTRUSTED ((HRESULT)0x80090352L) +# define SEC_E_ISSUING_CA_UNTRUSTED ((HRESULT)0x80090352L) #endif #ifndef SEC_E_REVOCATION_OFFLINE_C -# define SEC_E_REVOCATION_OFFLINE_C ((HRESULT)0x80090353L) +# define SEC_E_REVOCATION_OFFLINE_C ((HRESULT)0x80090353L) #endif #ifndef SEC_E_PKINIT_CLIENT_FAILURE -# define SEC_E_PKINIT_CLIENT_FAILURE ((HRESULT)0x80090354L) +# define SEC_E_PKINIT_CLIENT_FAILURE ((HRESULT)0x80090354L) #endif #ifndef SEC_E_SMARTCARD_CERT_EXPIRED -# define SEC_E_SMARTCARD_CERT_EXPIRED ((HRESULT)0x80090355L) +# define SEC_E_SMARTCARD_CERT_EXPIRED ((HRESULT)0x80090355L) #endif #ifndef SEC_E_NO_S4U_PROT_SUPPORT -# define SEC_E_NO_S4U_PROT_SUPPORT ((HRESULT)0x80090356L) +# define SEC_E_NO_S4U_PROT_SUPPORT ((HRESULT)0x80090356L) #endif #ifndef SEC_E_CROSSREALM_DELEGATION_FAILURE -# define SEC_E_CROSSREALM_DELEGATION_FAILURE ((HRESULT)0x80090357L) +# define SEC_E_CROSSREALM_DELEGATION_FAILURE ((HRESULT)0x80090357L) #endif #ifndef SEC_E_REVOCATION_OFFLINE_KDC -# define SEC_E_REVOCATION_OFFLINE_KDC ((HRESULT)0x80090358L) +# define SEC_E_REVOCATION_OFFLINE_KDC ((HRESULT)0x80090358L) #endif #ifndef SEC_E_ISSUING_CA_UNTRUSTED_KDC -# define SEC_E_ISSUING_CA_UNTRUSTED_KDC ((HRESULT)0x80090359L) +# define SEC_E_ISSUING_CA_UNTRUSTED_KDC ((HRESULT)0x80090359L) #endif #ifndef SEC_E_KDC_CERT_EXPIRED -# define SEC_E_KDC_CERT_EXPIRED ((HRESULT)0x8009035AL) +# define SEC_E_KDC_CERT_EXPIRED ((HRESULT)0x8009035AL) #endif #ifndef SEC_E_KDC_CERT_REVOKED -# define SEC_E_KDC_CERT_REVOKED ((HRESULT)0x8009035BL) +# define SEC_E_KDC_CERT_REVOKED ((HRESULT)0x8009035BL) #endif #ifndef SEC_E_INVALID_PARAMETER -# define SEC_E_INVALID_PARAMETER ((HRESULT)0x8009035DL) +# define SEC_E_INVALID_PARAMETER ((HRESULT)0x8009035DL) #endif #ifndef SEC_E_DELEGATION_POLICY -# define SEC_E_DELEGATION_POLICY ((HRESULT)0x8009035EL) +# define SEC_E_DELEGATION_POLICY ((HRESULT)0x8009035EL) #endif #ifndef SEC_E_POLICY_NLTM_ONLY -# define SEC_E_POLICY_NLTM_ONLY ((HRESULT)0x8009035FL) +# define SEC_E_POLICY_NLTM_ONLY ((HRESULT)0x8009035FL) #endif #ifndef SEC_I_CONTINUE_NEEDED -# define SEC_I_CONTINUE_NEEDED ((HRESULT)0x00090312L) +# define SEC_I_CONTINUE_NEEDED ((HRESULT)0x00090312L) #endif #ifndef SEC_I_COMPLETE_NEEDED -# define SEC_I_COMPLETE_NEEDED ((HRESULT)0x00090313L) +# define SEC_I_COMPLETE_NEEDED ((HRESULT)0x00090313L) #endif #ifndef SEC_I_COMPLETE_AND_CONTINUE -# define SEC_I_COMPLETE_AND_CONTINUE ((HRESULT)0x00090314L) +# define SEC_I_COMPLETE_AND_CONTINUE ((HRESULT)0x00090314L) #endif #ifndef SEC_I_LOCAL_LOGON -# define SEC_I_LOCAL_LOGON ((HRESULT)0x00090315L) +# define SEC_I_LOCAL_LOGON ((HRESULT)0x00090315L) #endif #ifndef SEC_I_CONTEXT_EXPIRED -# define SEC_I_CONTEXT_EXPIRED ((HRESULT)0x00090317L) +# define SEC_I_CONTEXT_EXPIRED ((HRESULT)0x00090317L) #endif #ifndef SEC_I_INCOMPLETE_CREDENTIALS -# define SEC_I_INCOMPLETE_CREDENTIALS ((HRESULT)0x00090320L) +# define SEC_I_INCOMPLETE_CREDENTIALS ((HRESULT)0x00090320L) #endif #ifndef SEC_I_RENEGOTIATE -# define SEC_I_RENEGOTIATE ((HRESULT)0x00090321L) +# define SEC_I_RENEGOTIATE ((HRESULT)0x00090321L) #endif #ifndef SEC_I_NO_LSA_CONTEXT -# define SEC_I_NO_LSA_CONTEXT ((HRESULT)0x00090323L) +# define SEC_I_NO_LSA_CONTEXT ((HRESULT)0x00090323L) #endif #ifndef SEC_I_SIGNATURE_NEEDED -# define SEC_I_SIGNATURE_NEEDED ((HRESULT)0x0009035CL) +# define SEC_I_SIGNATURE_NEEDED ((HRESULT)0x0009035CL) #endif #ifdef UNICODE diff --git a/lib/curl_threads.c b/lib/curl_threads.c index d40e024..f9b812e 100644 --- a/lib/curl_threads.c +++ b/lib/curl_threads.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2013, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -33,10 +33,6 @@ #endif #include "curl_threads.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include - #include "curl_memory.h" /* The last #include file should be: */ #include "memdebug.h" @@ -77,8 +73,8 @@ curl_thread_t Curl_thread_create(unsigned int (*func) (void*), void *arg) return t; err: - Curl_safefree(t); - Curl_safefree(ac); + free(t); + free(ac); return curl_thread_t_null; } @@ -123,7 +119,12 @@ void Curl_thread_destroy(curl_thread_t hnd) int Curl_thread_join(curl_thread_t *hnd) { +#if !defined(_WIN32_WINNT) || !defined(_WIN32_WINNT_VISTA) || \ + (_WIN32_WINNT < _WIN32_WINNT_VISTA) int ret = (WaitForSingleObject(*hnd, INFINITE) == WAIT_OBJECT_0); +#else + int ret = (WaitForSingleObjectEx(*hnd, INFINITE, FALSE) == WAIT_OBJECT_0); +#endif Curl_thread_destroy(*hnd); diff --git a/lib/curl_threads.h b/lib/curl_threads.h index 6457cbb..0f3191a 100644 --- a/lib/curl_threads.h +++ b/lib/curl_threads.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2010, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -37,7 +37,12 @@ # define curl_mutex_t CRITICAL_SECTION # define curl_thread_t HANDLE # define curl_thread_t_null (HANDLE)0 -# define Curl_mutex_init(m) InitializeCriticalSection(m) +# if !defined(_WIN32_WINNT) || !defined(_WIN32_WINNT_VISTA) || \ + (_WIN32_WINNT < _WIN32_WINNT_VISTA) +# define Curl_mutex_init(m) InitializeCriticalSection(m) +# else +# define Curl_mutex_init(m) InitializeCriticalSectionEx(m, 0, 1) +# endif # define Curl_mutex_acquire(m) EnterCriticalSection(m) # define Curl_mutex_release(m) LeaveCriticalSection(m) # define Curl_mutex_destroy(m) DeleteCriticalSection(m) diff --git a/lib/curlx.h b/lib/curlx.h index 9dc90a0..979e7d7 100644 --- a/lib/curlx.h +++ b/lib/curlx.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2008, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -90,8 +90,7 @@ #ifdef ENABLE_CURLX_PRINTF /* If this define is set, we define all "standard" printf() functions to use the curlx_* version instead. It makes the source code transparent and - easier to understand/patch. Undefine them first in case _MPRINTF_REPLACE - is set. */ + easier to understand/patch. Undefine them first. */ # undef printf # undef fprintf # undef sprintf diff --git a/lib/dict.c b/lib/dict.c index 86ddfb9..06d7699 100644 --- a/lib/dict.c +++ b/lib/dict.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -57,10 +57,6 @@ #include "strequal.h" #include "dict.h" #include "rawstr.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include - #include "curl_memory.h" /* The last #include file should be: */ #include "memdebug.h" @@ -101,7 +97,7 @@ static char *unescape_word(struct SessionHandle *data, const char *inputbuff) char *dictp; char *ptr; int len; - char byte; + char ch; int olen=0; newp = curl_easy_unescape(data, inputbuff, 0, &len); @@ -113,13 +109,13 @@ static char *unescape_word(struct SessionHandle *data, const char *inputbuff) /* According to RFC2229 section 2.2, these letters need to be escaped with \[letter] */ for(ptr = newp; - (byte = *ptr) != 0; + (ch = *ptr) != 0; ptr++) { - if((byte <= 32) || (byte == 127) || - (byte == '\'') || (byte == '\"') || (byte == '\\')) { + if((ch <= 32) || (ch == 127) || + (ch == '\'') || (ch == '\"') || (ch == '\\')) { dictp[olen++] = '\\'; } - dictp[olen++] = byte; + dictp[olen++] = ch; } dictp[olen]=0; } diff --git a/lib/easy.c b/lib/easy.c index 160712e..316acb1 100644 --- a/lib/easy.c +++ b/lib/easy.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -60,7 +60,6 @@ #include "hostip.h" #include "share.h" #include "strdup.h" -#include "curl_memory.h" #include "progress.h" #include "easyif.h" #include "select.h" @@ -74,11 +73,11 @@ #include "conncache.h" #include "multiif.h" #include "sigpipe.h" +#include "ssh.h" +#include "curl_printf.h" -#define _MPRINTF_REPLACE /* use our functions only */ -#include - -/* The last #include file should be: */ +/* The last #include files should be: */ +#include "curl_memory.h" #include "memdebug.h" /* win32_cleanup() is for win32 socket cleanup functionality, the opposite @@ -136,9 +135,9 @@ static CURLcode win32_init(void) #ifdef USE_WINDOWS_SSPI { - CURLcode err = Curl_sspi_global_init(); - if(err != CURLE_OK) - return err; + CURLcode result = Curl_sspi_global_init(); + if(result) + return result; } #endif @@ -243,7 +242,7 @@ CURLcode curl_global_init(long flags) } if(flags & CURL_GLOBAL_WIN32) - if(win32_init() != CURLE_OK) { + if(win32_init()) { DEBUGF(fprintf(stderr, "Error: win32_init failed\n")); return CURLE_FAILED_INIT; } @@ -265,7 +264,7 @@ CURLcode curl_global_init(long flags) idna_init(); #endif - if(Curl_resolver_global_init() != CURLE_OK) { + if(Curl_resolver_global_init()) { DEBUGF(fprintf(stderr, "Error: resolver_global_init failed\n")); return CURLE_FAILED_INIT; } @@ -293,7 +292,7 @@ CURLcode curl_global_init_mem(long flags, curl_malloc_callback m, curl_free_callback f, curl_realloc_callback r, curl_strdup_callback s, curl_calloc_callback c) { - CURLcode code = CURLE_OK; + CURLcode result = CURLE_OK; /* Invalid input, return immediately */ if(!m || !f || !r || !s || !c) @@ -308,8 +307,8 @@ CURLcode curl_global_init_mem(long flags, curl_malloc_callback m, } /* Call the actual init function first */ - code = curl_global_init(flags); - if(code == CURLE_OK) { + result = curl_global_init(flags); + if(!result) { Curl_cmalloc = m; Curl_cfree = f; Curl_cstrdup = s; @@ -317,7 +316,7 @@ CURLcode curl_global_init_mem(long flags, curl_malloc_callback m, Curl_ccalloc = c; } - return code; + return result; } /** @@ -357,13 +356,13 @@ void curl_global_cleanup(void) */ CURL *curl_easy_init(void) { - CURLcode res; + CURLcode result; struct SessionHandle *data; /* Make sure we inited the global SSL stuff */ if(!initialized) { - res = curl_global_init(CURL_GLOBAL_DEFAULT); - if(res) { + result = curl_global_init(CURL_GLOBAL_DEFAULT); + if(result) { /* something in the global init failed, return nothing */ DEBUGF(fprintf(stderr, "Error: curl_global_init failed\n")); return NULL; @@ -371,8 +370,8 @@ CURL *curl_easy_init(void) } /* We use curl_open() with undefined URL so far */ - res = Curl_open(&data); - if(res != CURLE_OK) { + result = Curl_open(&data); + if(result) { DEBUGF(fprintf(stderr, "Error: Curl_open failed\n")); return NULL; } @@ -390,17 +389,17 @@ CURLcode curl_easy_setopt(CURL *curl, CURLoption tag, ...) { va_list arg; struct SessionHandle *data = curl; - CURLcode ret; + CURLcode result; if(!curl) return CURLE_BAD_FUNCTION_ARGUMENT; va_start(arg, tag); - ret = Curl_setopt(data, tag, arg); + result = Curl_setopt(data, tag, arg); va_end(arg); - return ret; + return result; } #ifdef CURLDEBUG @@ -490,6 +489,10 @@ static int events_socket(CURL *easy, /* easy handle */ struct events *ev = userp; struct socketmonitor *m; struct socketmonitor *prev=NULL; + +#if defined(CURL_DISABLE_VERBOSE_STRINGS) + (void) easy; +#endif (void)socketp; m = ev->list; @@ -570,7 +573,7 @@ static CURLcode wait_or_timeout(struct Curl_multi *multi, struct events *ev) { bool done = FALSE; CURLMcode mcode; - CURLcode rc = CURLE_OK; + CURLcode result = CURLE_OK; while(!done) { CURLMsg *msg; @@ -630,6 +633,9 @@ static CURLcode wait_or_timeout(struct Curl_multi *multi, struct events *ev) ev->ms += curlx_tvdiff(after, before); } + else + return CURLE_RECV_ERROR; + if(mcode) return CURLE_URL_MALFORMAT; /* TODO: return a proper error! */ @@ -637,12 +643,12 @@ static CURLcode wait_or_timeout(struct Curl_multi *multi, struct events *ev) second argument */ msg = curl_multi_info_read(multi, &pollrc); if(msg) { - rc = msg->data.result; + result = msg->data.result; done = TRUE; } } - return rc; + return result; } @@ -668,7 +674,7 @@ static CURLcode easy_transfer(CURLM *multi) { bool done = FALSE; CURLMcode mcode = CURLM_OK; - CURLcode code = CURLE_OK; + CURLcode result = CURLE_OK; struct timeval before; int without_fds = 0; /* count number of consecutive returns from curl_multi_wait() without any filedescriptors */ @@ -683,7 +689,7 @@ static CURLcode easy_transfer(CURLM *multi) if(mcode == CURLM_OK) { if(ret == -1) { /* poll() failed not on EINTR, indicate a network problem */ - code = CURLE_RECV_ERROR; + result = CURLE_RECV_ERROR; break; } else if(ret == 0) { @@ -714,7 +720,7 @@ static CURLcode easy_transfer(CURLM *multi) int rc; CURLMsg *msg = curl_multi_info_read(multi, &rc); if(msg) { - code = msg->data.result; + result = msg->data.result; done = TRUE; } } @@ -728,7 +734,7 @@ static CURLcode easy_transfer(CURLM *multi) CURLE_BAD_FUNCTION_ARGUMENT; } - return code; + return result; } @@ -753,7 +759,7 @@ static CURLcode easy_perform(struct SessionHandle *data, bool events) { CURLM *multi; CURLMcode mcode; - CURLcode code = CURLE_OK; + CURLcode result = CURLE_OK; SIGPIPE_VARIABLE(pipe_st); if(!data) @@ -794,7 +800,7 @@ static CURLcode easy_perform(struct SessionHandle *data, bool events) data->multi = multi; /* run the transfer */ - code = events ? easy_events(multi) : easy_transfer(multi); + result = events ? easy_events(multi) : easy_transfer(multi); /* ignoring the return code isn't nice, but atm we can't really handle a failure here, room for future improvement! */ @@ -803,7 +809,7 @@ static CURLcode easy_perform(struct SessionHandle *data, bool events) sigpipe_restore(&pipe_st); /* The multi handle is kept alive, owned by the easy handle */ - return code; + return result; } @@ -854,16 +860,16 @@ CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ...) { va_list arg; void *paramp; - CURLcode ret; + CURLcode result; struct SessionHandle *data = (struct SessionHandle *)curl; va_start(arg, info); paramp = va_arg(arg, void *); - ret = Curl_getinfo(data, info, paramp); + result = Curl_getinfo(data, info, paramp); va_end(arg); - return ret; + return result; } /* @@ -890,7 +896,7 @@ CURL *curl_easy_duphandle(CURL *incurl) outcurl->state.headersize = HEADERSIZE; /* copy all userdefined values */ - if(Curl_dupset(outcurl, data) != CURLE_OK) + if(Curl_dupset(outcurl, data)) goto fail; /* the connection cache is setup on demand */ @@ -936,7 +942,7 @@ CURL *curl_easy_duphandle(CURL *incurl) /* Clone the resolver handle, if present, for the new handle */ if(Curl_resolver_duphandle(&outcurl->state.resolver, - data->state.resolver) != CURLE_OK) + data->state.resolver)) goto fail; Curl_convert_setup(outcurl); @@ -1018,73 +1024,15 @@ CURLcode curl_easy_pause(CURL *curl, int action) /* we have a buffer for sending that we now seem to be able to deliver since the receive pausing is lifted! */ - /* get the pointer, type and length in local copies since the function may - return PAUSE again and then we'll get a new copy allocted and stored in + /* get the pointer in local copy since the function may return PAUSE + again and then we'll get a new copy allocted and stored in the tempwrite variables */ char *tempwrite = data->state.tempwrite; - char *freewrite = tempwrite; /* store this pointer to free it later */ - size_t tempsize = data->state.tempwritesize; - int temptype = data->state.tempwritetype; - size_t chunklen; - - /* clear tempwrite here just to make sure it gets cleared if there's no - further use of it, and make sure we don't clear it after the function - invoke as it may have been set to a new value by then */ - data->state.tempwrite = NULL; - - /* since the write callback API is define to never exceed - CURL_MAX_WRITE_SIZE bytes in a single call, and since we may in fact - have more data than that in our buffer here, we must loop sending the - data in multiple calls until there's no data left or we get another - pause returned. - - A tricky part is that the function we call will "buffer" the data - itself when it pauses on a particular buffer, so we may need to do some - extra trickery if we get a pause return here. - */ - do { - chunklen = (tempsize > CURL_MAX_WRITE_SIZE)?CURL_MAX_WRITE_SIZE:tempsize; - - result = Curl_client_write(data->easy_conn, - temptype, tempwrite, chunklen); - if(result) - /* failures abort the loop at once */ - break; - - if(data->state.tempwrite && (tempsize - chunklen)) { - /* Ouch, the reading is again paused and the block we send is now - "cached". If this is the final chunk we can leave it like this, but - if we have more chunks that are cached after this, we need to free - the newly cached one and put back a version that is truly the entire - contents that is saved for later - */ - char *newptr; - - /* note that tempsize is still the size as before the callback was - used, and thus the whole piece of data to keep */ - newptr = realloc(data->state.tempwrite, tempsize); - - if(!newptr) { - free(data->state.tempwrite); /* free old area */ - data->state.tempwrite = NULL; - result = CURLE_OUT_OF_MEMORY; - /* tempwrite will be freed further down */ - break; - } - data->state.tempwrite = newptr; /* store new pointer */ - memcpy(newptr, tempwrite, tempsize); - data->state.tempwritesize = tempsize; /* store new size */ - /* tempwrite will be freed further down */ - break; /* go back to pausing until further notice */ - } - else { - tempsize -= chunklen; /* left after the call above */ - tempwrite += chunklen; /* advance the pointer */ - } - } while((result == CURLE_OK) && tempsize); - - free(freewrite); /* this is unconditionally no longer used */ + data->state.tempwrite = NULL; + result = Curl_client_chop_write(data->easy_conn, data->state.tempwritetype, + tempwrite, data->state.tempwritesize); + free(tempwrite); } /* if there's no error and we're not pausing both directions, we want @@ -1129,20 +1077,20 @@ static CURLcode easy_connection(struct SessionHandle *data, CURLcode curl_easy_recv(CURL *curl, void *buffer, size_t buflen, size_t *n) { curl_socket_t sfd; - CURLcode ret; + CURLcode result; ssize_t n1; struct connectdata *c; struct SessionHandle *data = (struct SessionHandle *)curl; - ret = easy_connection(data, &sfd, &c); - if(ret) - return ret; + result = easy_connection(data, &sfd, &c); + if(result) + return result; *n = 0; - ret = Curl_read(c, sfd, buffer, buflen, &n1); + result = Curl_read(c, sfd, buffer, buflen, &n1); - if(ret != CURLE_OK) - return ret; + if(result) + return result; *n = (size_t)n1; @@ -1157,26 +1105,26 @@ CURLcode curl_easy_send(CURL *curl, const void *buffer, size_t buflen, size_t *n) { curl_socket_t sfd; - CURLcode ret; + CURLcode result; ssize_t n1; struct connectdata *c = NULL; struct SessionHandle *data = (struct SessionHandle *)curl; - ret = easy_connection(data, &sfd, &c); - if(ret) - return ret; + result = easy_connection(data, &sfd, &c); + if(result) + return result; *n = 0; - ret = Curl_write(c, sfd, buffer, buflen, &n1); + result = Curl_write(c, sfd, buffer, buflen, &n1); if(n1 == -1) return CURLE_SEND_ERROR; /* detect EAGAIN */ - if((CURLE_OK == ret) && (0 == n1)) + if(!result && !n1) return CURLE_AGAIN; *n = (size_t)n1; - return ret; + return result; } diff --git a/lib/escape.c b/lib/escape.c index d7f8a8f..24abb93 100644 --- a/lib/escape.c +++ b/lib/escape.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -27,16 +27,14 @@ #include -#include "curl_memory.h" #include "urldata.h" #include "warnless.h" #include "non-ascii.h" #include "escape.h" +#include "curl_printf.h" -#define _MPRINTF_REPLACE /* use our functions only */ -#include - -/* The last #include file should be: */ +/* The last #include files should be: */ +#include "curl_memory.h" #include "memdebug.h" /* Portable character check (remember EBCDIC). Do not use isalnum() because @@ -87,7 +85,7 @@ char *curl_easy_escape(CURL *handle, const char *string, int inlength) size_t newlen = alloc; size_t strindex=0; size_t length; - CURLcode res; + CURLcode result; ns = malloc(alloc); if(!ns) @@ -115,8 +113,8 @@ char *curl_easy_escape(CURL *handle, const char *string, int inlength) } } - res = Curl_convert_to_network(handle, &in, 1); - if(res) { + result = Curl_convert_to_network(handle, &in, 1); + if(result) { /* Curl_convert_to_network calls failf if unsuccessful */ free(ns); return NULL; @@ -152,7 +150,7 @@ CURLcode Curl_urldecode(struct SessionHandle *data, unsigned char in; size_t strindex=0; unsigned long hex; - CURLcode res; + CURLcode result; if(!ns) return CURLE_OUT_OF_MEMORY; @@ -172,16 +170,17 @@ CURLcode Curl_urldecode(struct SessionHandle *data, in = curlx_ultouc(hex); /* this long is never bigger than 255 anyway */ - res = Curl_convert_from_network(data, &in, 1); - if(res) { + result = Curl_convert_from_network(data, &in, 1); + if(result) { /* Curl_convert_from_network calls failf if unsuccessful */ free(ns); - return res; + return result; } string+=2; alloc-=2; } + if(reject_ctrl && (in < 0x20)) { free(ns); return CURLE_URL_MALFORMAT; @@ -228,6 +227,5 @@ char *curl_easy_unescape(CURL *handle, const char *string, int length, the library's memory system */ void curl_free(void *p) { - if(p) - free(p); + free(p); } diff --git a/lib/file.c b/lib/file.c index 73df42e..175b107 100644 --- a/lib/file.c +++ b/lib/file.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -59,14 +59,12 @@ #include "getinfo.h" #include "transfer.h" #include "url.h" -#include "curl_memory.h" #include "parsedate.h" /* for the week day and month names */ #include "warnless.h" +#include "curl_printf.h" -#define _MPRINTF_REPLACE /* use our functions only */ -#include - -/* The last #include file should be: */ +/* The last #include files should be: */ +#include "curl_memory.h" #include "memdebug.h" #if defined(WIN32) || defined(MSDOS) || defined(__EMX__) || \ @@ -196,8 +194,9 @@ static CURLcode file_connect(struct connectdata *conn, bool *done) int i; char *actual_path; #endif + int real_path_len; - real_path = curl_easy_unescape(data, data->state.path, 0, NULL); + real_path = curl_easy_unescape(data, data->state.path, 0, &real_path_len); if(!real_path) return CURLE_OUT_OF_MEMORY; @@ -222,16 +221,23 @@ static CURLcode file_connect(struct connectdata *conn, bool *done) (actual_path[2] == ':' || actual_path[2] == '|')) { actual_path[2] = ':'; actual_path++; + real_path_len--; } /* change path separators from '/' to '\\' for DOS, Windows and OS/2 */ - for(i=0; actual_path[i] != '\0'; ++i) + for(i=0; i < real_path_len; ++i) if(actual_path[i] == '/') actual_path[i] = '\\'; + else if(!actual_path[i]) /* binary zero */ + return CURLE_URL_MALFORMAT; fd = open_readonly(actual_path, O_RDONLY|O_BINARY); file->path = actual_path; #else + if(memchr(real_path, 0, real_path_len)) + /* binary zeroes indicate foul play */ + return CURLE_URL_MALFORMAT; + fd = open_readonly(real_path, O_RDONLY); file->path = real_path; #endif @@ -295,7 +301,7 @@ static CURLcode file_upload(struct connectdata *conn) const char *dir = strchr(file->path, DIRSEP); int fd; int mode; - CURLcode res=CURLE_OK; + CURLcode result = CURLE_OK; struct SessionHandle *data = conn->data; char *buf = data->state.buffer; size_t nread; @@ -309,8 +315,6 @@ static CURLcode file_upload(struct connectdata *conn) * Since FILE: doesn't do the full init, we need to provide some extra * assignments here. */ - conn->fread_func = data->set.fread_func; - conn->fread_in = data->set.in; conn->data->req.upload_fromhere = buf; if(!dir) @@ -351,10 +355,10 @@ static CURLcode file_upload(struct connectdata *conn) data->state.resume_from = (curl_off_t)file_stat.st_size; } - while(res == CURLE_OK) { + while(!result) { int readcount; - res = Curl_fillreadbuffer(conn, BUFSIZE, &readcount); - if(res) + result = Curl_fillreadbuffer(conn, BUFSIZE, &readcount); + if(result) break; if(readcount <= 0) /* fix questionable compare error. curlvms */ @@ -381,7 +385,7 @@ static CURLcode file_upload(struct connectdata *conn) /* write the data to the target */ nwrite = write(fd, buf2, nread); if(nwrite != nread) { - res = CURLE_SEND_ERROR; + result = CURLE_SEND_ERROR; break; } @@ -390,16 +394,16 @@ static CURLcode file_upload(struct connectdata *conn) Curl_pgrsSetUploadCounter(data, bytecount); if(Curl_pgrsUpdate(conn)) - res = CURLE_ABORTED_BY_CALLBACK; + result = CURLE_ABORTED_BY_CALLBACK; else - res = Curl_speedcheck(data, now); + result = Curl_speedcheck(data, now); } - if(!res && Curl_pgrsUpdate(conn)) - res = CURLE_ABORTED_BY_CALLBACK; + if(!result && Curl_pgrsUpdate(conn)) + result = CURLE_ABORTED_BY_CALLBACK; close(fd); - return res; + return result; } /* @@ -417,7 +421,7 @@ static CURLcode file_do(struct connectdata *conn, bool *done) are supported. This means that files on remotely mounted directories (via NFS, Samba, NT sharing) can be accessed through a file:// URL */ - CURLcode res = CURLE_OK; + CURLcode result = CURLE_OK; struct_stat statbuf; /* struct_stat instead of struct stat just to allow the Windows version to have a different struct without having to redefine the simple word 'stat' */ @@ -464,7 +468,6 @@ static CURLcode file_do(struct connectdata *conn, bool *done) information. Which for FILE can't be much more than the file size and date. */ if(data->set.opt_no_body && data->set.include_header && fstated) { - CURLcode result; snprintf(buf, sizeof(data->state.buffer), "Content-Length: %" CURL_FORMAT_CURL_OFF_T "\r\n", expected_size); result = Curl_client_write(conn, CLIENTWRITE_BOTH, buf, 0); @@ -546,7 +549,7 @@ static CURLcode file_do(struct connectdata *conn, bool *done) Curl_pgrsTime(data, TIMER_STARTTRANSFER); - while(res == CURLE_OK) { + while(!result) { /* Don't fill a whole buffer if we want less than all data */ size_t bytestoread = (expected_size < CURL_OFF_T_C(BUFSIZE) - CURL_OFF_T_C(1)) ? @@ -563,21 +566,21 @@ static CURLcode file_do(struct connectdata *conn, bool *done) bytecount += nread; expected_size -= nread; - res = Curl_client_write(conn, CLIENTWRITE_BODY, buf, nread); - if(res) - return res; + result = Curl_client_write(conn, CLIENTWRITE_BODY, buf, nread); + if(result) + return result; Curl_pgrsSetDownloadCounter(data, bytecount); if(Curl_pgrsUpdate(conn)) - res = CURLE_ABORTED_BY_CALLBACK; + result = CURLE_ABORTED_BY_CALLBACK; else - res = Curl_speedcheck(data, now); + result = Curl_speedcheck(data, now); } if(Curl_pgrsUpdate(conn)) - res = CURLE_ABORTED_BY_CALLBACK; + result = CURLE_ABORTED_BY_CALLBACK; - return res; + return result; } #endif diff --git a/lib/fileinfo.c b/lib/fileinfo.c index 8c8ee98..0904937 100644 --- a/lib/fileinfo.c +++ b/lib/fileinfo.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 2010-2011, Daniel Stenberg, , et al. + * Copyright (C) 2010 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -24,10 +24,6 @@ #include "strdup.h" #include "fileinfo.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include - #include "curl_memory.h" /* The last #include file should be: */ #include "memdebug.h" diff --git a/lib/formdata.c b/lib/formdata.c index 3260928..9e8ce4e 100644 --- a/lib/formdata.c +++ b/lib/formdata.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -24,7 +24,7 @@ #include -#if !defined(CURL_DISABLE_HTTP) || defined(USE_SSLEAY) +#ifndef CURL_DISABLE_HTTP #if defined(HAVE_LIBGEN_H) && defined(HAVE_BASENAME) #include @@ -34,19 +34,14 @@ #include "formdata.h" #include "vtls/vtls.h" #include "strequal.h" -#include "curl_memory.h" #include "sendf.h" +#include "strdup.h" +#include "curl_printf.h" -#define _MPRINTF_REPLACE /* use our functions only */ -#include - -/* The last #include file should be: */ +/* The last #include files should be: */ +#include "curl_memory.h" #include "memdebug.h" -#endif /* !defined(CURL_DISABLE_HTTP) || defined(USE_SSLEAY) */ - -#ifndef CURL_DISABLE_HTTP - #ifndef HAVE_BASENAME static char *Curl_basename(char *path); #define basename(x) Curl_basename((x)) @@ -214,46 +209,6 @@ static const char *ContentTypeForFilename(const char *filename, /*************************************************************************** * - * memdup() - * - * Copies the 'source' data to a newly allocated buffer buffer (that is - * returned). Uses buffer_length if not null, else uses strlen to determine - * the length of the buffer to be copied - * - * Returns the new pointer or NULL on failure. - * - ***************************************************************************/ -static char *memdup(const char *src, size_t buffer_length) -{ - size_t length; - bool add = FALSE; - char *buffer; - - if(buffer_length) - length = buffer_length; - else if(src) { - length = strlen(src); - add = TRUE; - } - else - /* no length and a NULL src pointer! */ - return strdup(""); - - buffer = malloc(length+add); - if(!buffer) - return NULL; /* fail */ - - memcpy(buffer, src, length); - - /* if length unknown do null termination */ - if(add) - buffer[length] = '\0'; - - return buffer; -} - -/*************************************************************************** - * * FormAdd() * * Stores a formpost parameter and builds the appropriate linked list. @@ -460,7 +415,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost, else { form = AddFormInfo(fname, NULL, current_form); if(!form) { - Curl_safefree(fname); + free(fname); return_value = CURL_FORMADD_MEMORY; } else { @@ -549,7 +504,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost, else { form = AddFormInfo(NULL, type, current_form); if(!form) { - Curl_safefree(type); + free(type); return_value = CURL_FORMADD_MEMORY; } else { @@ -682,9 +637,12 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost, (form == first_form) ) { /* Note that there's small risk that form->name is NULL here if the app passed in a bad combo, so we better check for that first. */ - if(form->name) + if(form->name) { /* copy name (without strdup; possibly contains null characters) */ - form->name = memdup(form->name, form->namelength); + form->name = Curl_memdup(form->name, form->namelength? + form->namelength: + strlen(form->name)+1); + } if(!form->name) { return_value = CURL_FORMADD_MEMORY; break; @@ -693,9 +651,11 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost, } if(!(form->flags & (HTTPPOST_FILENAME | HTTPPOST_READFILE | HTTPPOST_PTRCONTENTS | HTTPPOST_PTRBUFFER | - HTTPPOST_CALLBACK)) ) { + HTTPPOST_CALLBACK)) && form->value) { /* copy value (without strdup; possibly contains null characters) */ - form->value = memdup(form->value, form->contentslength); + form->value = Curl_memdup(form->value, form->contentslength? + form->contentslength: + strlen(form->value)+1); if(!form->value) { return_value = CURL_FORMADD_MEMORY; break; @@ -751,7 +711,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost, now by the httppost linked list */ while(first_form) { FormInfo *ptr = first_form->more; - Curl_safefree(first_form); + free(first_form); first_form = ptr; } @@ -796,7 +756,7 @@ curl_off_t VmsRealFileSize(const char * name, int ret_stat; FILE * file; - file = fopen(name, "r"); + file = fopen(name, "r"); /* VMS */ if(file == NULL) return 0; @@ -954,13 +914,13 @@ void Curl_formclean(struct FormData **form_ptr) int curl_formget(struct curl_httppost *form, void *arg, curl_formget_callback append) { - CURLcode rc; + CURLcode result; curl_off_t size; struct FormData *data, *ptr; - rc = Curl_getformdata(NULL, &data, form, NULL, &size); - if(rc != CURLE_OK) - return (int)rc; + result = Curl_getformdata(NULL, &data, form, NULL, &size); + if(result) + return (int)result; for(ptr = data; ptr; ptr = ptr->next) { if((ptr->type == FORM_FILE) || (ptr->type == FORM_CALLBACK)) { @@ -1009,19 +969,16 @@ void curl_formfree(struct curl_httppost *form) next=form->next; /* the following form line */ /* recurse to sub-contents */ - if(form->more) - curl_formfree(form->more); + curl_formfree(form->more); - if(!(form->flags & HTTPPOST_PTRNAME) && form->name) + if(!(form->flags & HTTPPOST_PTRNAME)) free(form->name); /* free the name */ if(!(form->flags & - (HTTPPOST_PTRCONTENTS|HTTPPOST_BUFFER|HTTPPOST_CALLBACK)) && - form->contents) + (HTTPPOST_PTRCONTENTS|HTTPPOST_BUFFER|HTTPPOST_CALLBACK)) + ) free(form->contents); /* free the contents */ - if(form->contenttype) - free(form->contenttype); /* free the content type */ - if(form->showfilename) - free(form->showfilename); /* free the faked file name */ + free(form->contenttype); /* free the content type */ + free(form->showfilename); /* free the faked file name */ free(form); /* free the struct */ } while((form = next) != NULL); /* continue */ @@ -1111,7 +1068,7 @@ static CURLcode formdata_add_filename(const struct curl_httppost *file, /* filename need be escaped */ filename_escaped = malloc(strlen(filename)*2+1); if(!filename_escaped) { - Curl_safefree(filebasename); + free(filebasename); return CURLE_OUT_OF_MEMORY; } p0 = filename_escaped; @@ -1127,8 +1084,8 @@ static CURLcode formdata_add_filename(const struct curl_httppost *file, result = AddFormDataf(form, size, "; filename=\"%s\"", filename); - Curl_safefree(filename_escaped); - Curl_safefree(filebasename); + free(filename_escaped); + free(filebasename); return result; } @@ -1178,7 +1135,7 @@ CURLcode Curl_getformdata(struct SessionHandle *data, boundary); if(result) { - Curl_safefree(boundary); + free(boundary); return result; } /* we DO NOT include that line in the total size of the POST, since it'll be @@ -1221,7 +1178,7 @@ CURLcode Curl_getformdata(struct SessionHandle *data, /* If used, this is a link to more file names, we must then do the magic to include several files with the same field name */ - Curl_safefree(fileboundary); + free(fileboundary); fileboundary = formboundary(data); if(!fileboundary) { result = CURLE_OUT_OF_MEMORY; @@ -1369,22 +1326,20 @@ CURLcode Curl_getformdata(struct SessionHandle *data, } while((post = post->next) != NULL); /* for each field */ /* end-boundary for everything */ - if(CURLE_OK == result) - result = AddFormDataf(&form, &size, - "\r\n--%s--\r\n", - boundary); + if(!result) + result = AddFormDataf(&form, &size, "\r\n--%s--\r\n", boundary); if(result) { Curl_formclean(&firstform); - Curl_safefree(fileboundary); - Curl_safefree(boundary); + free(fileboundary); + free(boundary); return result; } *sizep = size; - Curl_safefree(fileboundary); - Curl_safefree(boundary); + free(fileboundary); + free(boundary); *finalform = firstform; @@ -1430,7 +1385,7 @@ static FILE * vmsfopenread(const char *file, const char *mode) { case FAB$C_VAR: case FAB$C_VFC: case FAB$C_STMCR: - return fopen(file, "r"); + return fopen(file, "r"); /* VMS */ break; default: return fopen(file, "r", "rfm=stmlf", "ctx=stm"); diff --git a/lib/ftp.c b/lib/ftp.c index 715afc2..fade092 100644 --- a/lib/ftp.c +++ b/lib/ftp.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -77,9 +77,7 @@ #include "warnless.h" #include "http_proxy.h" #include "non-ascii.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include +#include "curl_printf.h" #include "curl_memory.h" /* The last #include file should be: */ @@ -157,7 +155,7 @@ static CURLcode ftp_dophase_done(struct connectdata *conn, bool connected); /* easy-to-use macro: */ -#define PPSENDF(x,y,z) if((result = Curl_pp_sendf(x,y,z)) != CURLE_OK) \ +#define PPSENDF(x,y,z) if((result = Curl_pp_sendf(x,y,z))) \ return result @@ -285,19 +283,17 @@ static void freedirs(struct ftp_conn *ftpc) int i; if(ftpc->dirs) { for(i=0; i < ftpc->dirdepth; i++) { - if(ftpc->dirs[i]) { - free(ftpc->dirs[i]); - ftpc->dirs[i]=NULL; - } + free(ftpc->dirs[i]); + ftpc->dirs[i]=NULL; } free(ftpc->dirs); ftpc->dirs = NULL; ftpc->dirdepth = 0; } - if(ftpc->file) { - free(ftpc->file); - ftpc->file = NULL; - } + Curl_safefree(ftpc->file); + + /* no longer of any use */ + Curl_safefree(ftpc->newhost); } /* Returns non-zero if the given string contains CR (\r) or LF (\n), @@ -346,7 +342,7 @@ static CURLcode AcceptServerConnect(struct connectdata *conn) infof(data, "Connection accepted from server\n"); conn->sock[SECONDARYSOCKET] = s; - curlx_nonblock(s, TRUE); /* enable non-blocking */ + (void)curlx_nonblock(s, TRUE); /* enable non-blocking */ conn->sock_accepted[SECONDARYSOCKET] = TRUE; if(data->set.fsockopt) { @@ -541,7 +537,7 @@ static CURLcode AllowServerConnect(struct connectdata *conn, bool *connected) { struct SessionHandle *data = conn->data; long timeout_ms; - CURLcode ret = CURLE_OK; + CURLcode result = CURLE_OK; *connected = FALSE; infof(data, "Preparing for accepting server on data port\n"); @@ -557,22 +553,22 @@ static CURLcode AllowServerConnect(struct connectdata *conn, bool *connected) } /* see if the connection request is already here */ - ret = ReceivedServerConnect(conn, connected); - if(ret) - return ret; + result = ReceivedServerConnect(conn, connected); + if(result) + return result; if(*connected) { - ret = AcceptServerConnect(conn); - if(ret) - return ret; + result = AcceptServerConnect(conn); + if(result) + return result; - ret = InitiateTransfer(conn); - if(ret) - return ret; + result = InitiateTransfer(conn); + if(result) + return result; } else { /* Add timeout to multi handle and break out of the loop */ - if(ret == CURLE_OK && *connected == FALSE) { + if(!result && *connected == FALSE) { if(data->set.accepttimeout > 0) Curl_expire(data, data->set.accepttimeout); else @@ -580,7 +576,7 @@ static CURLcode AllowServerConnect(struct connectdata *conn, bool *connected) } } - return ret; + return result; } /* macro to check for a three-digit ftp status code at the start of the @@ -821,12 +817,19 @@ static void _state(struct connectdata *conn, ) { struct ftp_conn *ftpc = &conn->proto.ftpc; -#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS) + +#if defined(DEBUGBUILD) + +#if defined(CURL_DISABLE_VERBOSE_STRINGS) + (void) lineno; +#else if(ftpc->state != newstate) infof(conn->data, "FTP %p (line %d) state change from %s to %s\n", (void *)ftpc, lineno, ftp_state_names[ftpc->state], ftp_state_names[newstate]); #endif +#endif + ftpc->state = newstate; } @@ -1072,8 +1075,9 @@ static CURLcode ftp_state_use_port(struct connectdata *conn, if(*addr != '\0') { /* attempt to get the address of the given interface name */ - switch(Curl_if2ip(conn->ip_addr->ai_family, conn->scope, addr, - hbuf, sizeof(hbuf))) { + switch(Curl_if2ip(conn->ip_addr->ai_family, + Curl_ipv6_scope(conn->ip_addr->ai_addr), + conn->scope_id, addr, hbuf, sizeof(hbuf))) { case IF2IP_NOT_FOUND: /* not an interface, use the given string as host name instead */ host = addr; @@ -1097,7 +1101,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn, if(getsockname(conn->sock[FIRSTSOCKET], sa, &sslen)) { failf(data, "getsockname() failed: %s", Curl_strerror(conn, SOCKERRNO) ); - Curl_safefree(addr); + free(addr); return CURLE_FTP_PORT_FAILED; } switch(sa->sa_family) { @@ -1129,11 +1133,11 @@ static CURLcode ftp_state_use_port(struct connectdata *conn, if(res == NULL) { failf(data, "failed to resolve the address provided to PORT: %s", host); - Curl_safefree(addr); + free(addr); return CURLE_FTP_PORT_FAILED; } - Curl_safefree(addr); + free(addr); host = NULL; /* step 2, create a socket for the requested address */ @@ -1246,10 +1250,10 @@ static CURLcode ftp_state_use_port(struct connectdata *conn, continue; if((PORT == fcmd) && sa->sa_family != AF_INET) - /* PORT is ipv4 only */ + /* PORT is IPv4 only */ continue; - switch (sa->sa_family) { + switch(sa->sa_family) { case AF_INET: port = ntohs(sa4->sin_port); break; @@ -1487,13 +1491,13 @@ static CURLcode ftp_state_list(struct connectdata *conn) The other ftp_filemethods will CWD into dir/dir/ first and then just do LIST (in that case: nothing to do here) */ - char *cmd,*lstArg,*slashPos; + char *cmd, *lstArg, *slashPos; lstArg = NULL; if((data->set.ftp_filemethod == FTPFILE_NOCWD) && data->state.path && data->state.path[0] && - strchr(data->state.path,'/')) { + strchr(data->state.path, '/')) { lstArg = strdup(data->state.path); if(!lstArg) @@ -1503,7 +1507,7 @@ static CURLcode ftp_state_list(struct connectdata *conn) if(lstArg[strlen(lstArg) - 1] != '/') { /* chop off the file part if format is dir/dir/file */ - slashPos = strrchr(lstArg,'/'); + slashPos = strrchr(lstArg, '/'); if(slashPos) *(slashPos+1) = '\0'; } @@ -1517,19 +1521,16 @@ static CURLcode ftp_state_list(struct connectdata *conn) lstArg? lstArg: "" ); if(!cmd) { - if(lstArg) - free(lstArg); + free(lstArg); return CURLE_OUT_OF_MEMORY; } result = Curl_pp_sendf(&conn->proto.ftpc.pp, "%s", cmd); - if(lstArg) - free(lstArg); - + free(lstArg); free(cmd); - if(result != CURLE_OK) + if(result) return result; state(conn, FTP_LIST); @@ -1669,8 +1670,8 @@ static CURLcode ftp_state_ul_setup(struct connectdata *conn, BUFSIZE : curlx_sotouz(data->state.resume_from - passed); size_t actuallyread = - conn->fread_func(data->state.buffer, 1, readthisamountnow, - conn->fread_in); + data->set.fread_func(data->state.buffer, 1, readthisamountnow, + data->set.in); passed += actuallyread; if((actuallyread == 0) || (actuallyread > readthisamountnow)) { @@ -1807,6 +1808,13 @@ static CURLcode ftp_state_quote(struct connectdata *conn, static CURLcode ftp_epsv_disable(struct connectdata *conn) { CURLcode result = CURLE_OK; + + if(conn->bits.ipv6) { + /* We can't disable EPSV when doing IPv6, so this is instead a fail */ + failf(conn->data, "Failed EPSV attempt, exiting\n"); + return CURLE_FTP_WEIRD_SERVER_REPLY; + } + infof(conn->data, "Failed EPSV attempt. Disabling EPSV\n"); /* disable it for next transfer */ conn->bits.ftp_use_epsv = FALSE; @@ -1828,9 +1836,15 @@ static CURLcode proxy_magic(struct connectdata *conn, bool *magicdone) { CURLcode result = CURLE_OK; - struct SessionHandle *data=conn->data; + struct SessionHandle *data = conn->data; + +#if defined(CURL_DISABLE_PROXY) + (void) newhost; + (void) newport; +#endif *magicdone = FALSE; + switch(conn->proxytype) { case CURLPROXY_SOCKS5: case CURLPROXY_SOCKS5_HOSTNAME: @@ -1873,7 +1887,7 @@ static CURLcode proxy_magic(struct connectdata *conn, memset(&http_proxy, 0, sizeof(http_proxy)); data->req.protop = &http_proxy; - result = Curl_proxyCONNECT(conn, SECONDARYSOCKET, newhost, newport); + result = Curl_proxyCONNECT(conn, SECONDARYSOCKET, newhost, newport, TRUE); data->req.protop = ftp_save; @@ -1888,9 +1902,26 @@ static CURLcode proxy_magic(struct connectdata *conn, else *magicdone = TRUE; } + return result; } +static char *control_address(struct connectdata *conn) +{ + /* Returns the control connection IP address. + If a proxy tunnel is used, returns the original host name instead, because + the effective control connection address is the proxy address, + not the ftp host. */ + if(conn->bits.tunnel_proxy || + conn->proxytype == CURLPROXY_SOCKS5 || + conn->proxytype == CURLPROXY_SOCKS5_HOSTNAME || + conn->proxytype == CURLPROXY_SOCKS4 || + conn->proxytype == CURLPROXY_SOCKS4A) + return conn->host.name; + + return conn->ip_addr_str; +} + static CURLcode ftp_state_pasv_resp(struct connectdata *conn, int ftpcode) { @@ -1902,6 +1933,9 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn, unsigned short connectport; /* the local port connect() should use! */ char *str=&data->state.buffer[4]; /* start on the first letter */ + /* if we come here again, make sure the former name is cleared */ + Curl_safefree(ftpc->newhost); + if((ftpc->count1 == 0) && (ftpcode == 229)) { /* positive EPSV response */ @@ -1910,12 +1944,12 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn, unsigned int num; char separator[4]; ptr++; - if(5 == sscanf(ptr, "%c%c%c%u%c", - &separator[0], - &separator[1], - &separator[2], - &num, - &separator[3])) { + if(5 == sscanf(ptr, "%c%c%c%u%c", + &separator[0], + &separator[1], + &separator[2], + &num, + &separator[3])) { const char sep1 = separator[0]; int i; @@ -1933,19 +1967,9 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn, } if(ptr) { ftpc->newport = (unsigned short)(num & 0xffff); - - if(conn->bits.tunnel_proxy || - conn->proxytype == CURLPROXY_SOCKS5 || - conn->proxytype == CURLPROXY_SOCKS5_HOSTNAME || - conn->proxytype == CURLPROXY_SOCKS4 || - conn->proxytype == CURLPROXY_SOCKS4A) - /* proxy tunnel -> use other host info because ip_addr_str is the - proxy address not the ftp host */ - snprintf(ftpc->newhost, sizeof(ftpc->newhost), "%s", - conn->host.name); - else - /* use the same IP we are already connected to */ - snprintf(ftpc->newhost, NEWHOST_BUFSIZE, "%s", conn->ip_addr_str); + ftpc->newhost = strdup(control_address(conn)); + if(!ftpc->newhost) + return CURLE_OUT_OF_MEMORY; } } else @@ -1973,8 +1997,8 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn, */ while(*str) { if(6 == sscanf(str, "%d,%d,%d,%d,%d,%d", - &ip[0], &ip[1], &ip[2], &ip[3], - &port[0], &port[1])) + &ip[0], &ip[1], &ip[2], &ip[3], + &port[0], &port[1])) break; str++; } @@ -1986,26 +2010,19 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn, /* we got OK from server */ if(data->set.ftp_skip_ip) { - /* told to ignore the remotely given IP but instead use the one we used + /* told to ignore the remotely given IP but instead use the host we used for the control connection */ - infof(data, "Skips %d.%d.%d.%d for data connection, uses %s instead\n", + infof(data, "Skip %d.%d.%d.%d for data connection, re-use %s instead\n", ip[0], ip[1], ip[2], ip[3], - conn->ip_addr_str); - if(conn->bits.tunnel_proxy || - conn->proxytype == CURLPROXY_SOCKS5 || - conn->proxytype == CURLPROXY_SOCKS5_HOSTNAME || - conn->proxytype == CURLPROXY_SOCKS4 || - conn->proxytype == CURLPROXY_SOCKS4A) - /* proxy tunnel -> use other host info because ip_addr_str is the - proxy address not the ftp host */ - snprintf(ftpc->newhost, sizeof(ftpc->newhost), "%s", conn->host.name); - else - snprintf(ftpc->newhost, sizeof(ftpc->newhost), "%s", - conn->ip_addr_str); + conn->host.name); + ftpc->newhost = strdup(control_address(conn)); } else - snprintf(ftpc->newhost, sizeof(ftpc->newhost), - "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]); + ftpc->newhost = aprintf("%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]); + + if(!ftpc->newhost) + return CURLE_OUT_OF_MEMORY; + ftpc->newport = (unsigned short)(((port[0]<<8) + port[1]) & 0xffff); } else if(ftpc->count1 == 0) { @@ -2056,9 +2073,8 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn, conn->bits.tcpconnect[SECONDARYSOCKET] = FALSE; result = Curl_connecthost(conn, addr); - Curl_resolv_unlock(data, addr); /* we're done using this address */ - if(result) { + Curl_resolv_unlock(data, addr); /* we're done using this address */ if(ftpc->count1 == 0 && ftpcode == 229) return ftp_epsv_disable(conn); @@ -2074,8 +2090,9 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn, if(data->set.verbose) /* this just dumps information about this second connection */ - ftp_pasv_verbose(conn, conn->ip_addr, ftpc->newhost, connectport); + ftp_pasv_verbose(conn, addr->addr, ftpc->newhost, connectport); + Curl_resolv_unlock(data, addr); /* we're done using this address */ conn->bits.do_more = TRUE; state(conn, FTP_STOP); /* this phase is completed */ @@ -2090,7 +2107,9 @@ static CURLcode ftp_state_port_resp(struct connectdata *conn, ftpport fcmd = (ftpport)ftpc->count1; CURLcode result = CURLE_OK; - if(ftpcode != 200) { + /* The FTP spec tells a positive response should have code 200. + Be more permissive here to tolerate deviant servers. */ + if(ftpcode / 100 != 2) { /* the command failed */ if(EPRT == fcmd) { @@ -2714,7 +2733,7 @@ static CURLcode ftp_statemach_act(struct connectdata *conn) set a valid level */ Curl_sec_request_prot(conn, data->set.str[STRING_KRB_LEVEL]); - if(Curl_sec_login(conn) != CURLE_OK) + if(Curl_sec_login(conn)) infof(data, "Logging in with password in cleartext!\n"); else infof(data, "Authentication successful\n"); @@ -2765,7 +2784,7 @@ static CURLcode ftp_statemach_act(struct connectdata *conn) if((ftpcode == 234) || (ftpcode == 334)) { /* Curl_ssl_connect is BLOCKING */ result = Curl_ssl_connect(conn, FIRSTSOCKET); - if(CURLE_OK == result) { + if(!result) { conn->ssl[SECONDARYSOCKET].use = FALSE; /* clear-text data */ result = ftp_state_user(conn); } @@ -2907,7 +2926,7 @@ static CURLcode ftp_statemach_act(struct connectdata *conn) if(!ftpc->server_os && dir[0] != '/') { result = Curl_pp_sendf(&ftpc->pp, "%s", "SYST"); - if(result != CURLE_OK) { + if(result) { free(dir); return result; } @@ -2960,7 +2979,7 @@ static CURLcode ftp_statemach_act(struct connectdata *conn) if(strequal(os, "OS/400")) { /* Force OS400 name format 1. */ result = Curl_pp_sendf(&ftpc->pp, "%s", "SITE NAMEFMT 1"); - if(result != CURLE_OK) { + if(result) { free(os); return result; } @@ -3254,8 +3273,7 @@ static CURLcode ftp_done(struct connectdata *conn, CURLcode status, } /* now store a copy of the directory we are in */ - if(ftpc->prevpath) - free(ftpc->prevpath); + free(ftpc->prevpath); if(data->set.wildcardmatch) { if(data->set.chunk_end && ftpc->file) { @@ -3304,7 +3322,7 @@ static CURLcode ftp_done(struct connectdata *conn, CURLcode status, /* shut down the socket to inform the server we're done */ #ifdef _WIN32_WCE - shutdown(conn->sock[SECONDARYSOCKET],2); /* SD_BOTH */ + shutdown(conn->sock[SECONDARYSOCKET], 2); /* SD_BOTH */ #endif if(conn->sock[SECONDARYSOCKET] != CURL_SOCKET_BAD) { @@ -3627,7 +3645,7 @@ static CURLcode ftp_do_more(struct connectdata *conn, int *completep) if(conn->tunnel_state[SECONDARYSOCKET] == TUNNEL_CONNECT) { /* As we're in TUNNEL_CONNECT state now, we know the proxy name and port aren't used so we blank their arguments. TODO: make this nicer */ - result = Curl_proxyCONNECT(conn, SECONDARYSOCKET, NULL, 0); + result = Curl_proxyCONNECT(conn, SECONDARYSOCKET, NULL, 0, FALSE); return result; } @@ -3736,7 +3754,7 @@ static CURLcode ftp_do_more(struct connectdata *conn, int *completep) return result; } - if((result == CURLE_OK) && (ftp->transfer != FTPTRANSFER_BODY)) + if(!result && (ftp->transfer != FTPTRANSFER_BODY)) /* no data to transfer. FIX: it feels like a kludge to have this here too! */ Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL); @@ -3801,7 +3819,7 @@ static void wc_data_dtor(void *ptr) struct ftp_wc_tmpdata *tmp = ptr; if(tmp) Curl_ftp_parselist_data_free(&tmp->parser); - Curl_safefree(tmp); + free(tmp); } static CURLcode init_wc_data(struct connectdata *conn) @@ -3809,7 +3827,7 @@ static CURLcode init_wc_data(struct connectdata *conn) char *last_slash; char *path = conn->data->state.path; struct WildcardData *wildcard = &(conn->data->wildcard); - CURLcode ret = CURLE_OK; + CURLcode result = CURLE_OK; struct ftp_wc_tmpdata *ftp_tmp; last_slash = strrchr(conn->data->state.path, '/'); @@ -3817,8 +3835,8 @@ static CURLcode init_wc_data(struct connectdata *conn) last_slash++; if(last_slash[0] == '\0') { wildcard->state = CURLWC_CLEAN; - ret = ftp_parse_url_path(conn); - return ret; + result = ftp_parse_url_path(conn); + return result; } else { wildcard->pattern = strdup(last_slash); @@ -3836,8 +3854,8 @@ static CURLcode init_wc_data(struct connectdata *conn) } else { /* only list */ wildcard->state = CURLWC_CLEAN; - ret = ftp_parse_url_path(conn); - return ret; + result = ftp_parse_url_path(conn); + return result; } } @@ -3855,7 +3873,7 @@ static CURLcode init_wc_data(struct connectdata *conn) ftp_tmp->parser = Curl_ftp_parselist_data_alloc(); if(!ftp_tmp->parser) { Curl_safefree(wildcard->pattern); - Curl_safefree(ftp_tmp); + free(ftp_tmp); return CURLE_OUT_OF_MEMORY; } @@ -3867,13 +3885,13 @@ static CURLcode init_wc_data(struct connectdata *conn) conn->data->set.ftp_filemethod = FTPFILE_MULTICWD; /* try to parse ftp url */ - ret = ftp_parse_url_path(conn); - if(ret) { + result = ftp_parse_url_path(conn); + if(result) { Curl_safefree(wildcard->pattern); wildcard->tmp_dtor(wildcard->tmp); wildcard->tmp_dtor = ZERO_NULL; wildcard->tmp = NULL; - return ret; + return result; } wildcard->path = strdup(conn->data->state.path); @@ -3902,16 +3920,16 @@ static CURLcode init_wc_data(struct connectdata *conn) static CURLcode wc_statemach(struct connectdata *conn) { struct WildcardData * const wildcard = &(conn->data->wildcard); - CURLcode ret = CURLE_OK; + CURLcode result = CURLE_OK; switch (wildcard->state) { case CURLWC_INIT: - ret = init_wc_data(conn); + result = init_wc_data(conn); if(wildcard->state == CURLWC_CLEAN) /* only listing! */ break; else - wildcard->state = ret ? CURLWC_ERROR : CURLWC_MATCHING; + wildcard->state = result ? CURLWC_ERROR : CURLWC_MATCHING; break; case CURLWC_MATCHING: { @@ -3975,10 +3993,9 @@ static CURLcode wc_statemach(struct connectdata *conn) if(finfo->flags & CURLFINFOFLAG_KNOWN_SIZE) ftpc->known_filesize = finfo->size; - ret = ftp_parse_url_path(conn); - if(ret) { - return ret; - } + result = ftp_parse_url_path(conn); + if(result) + return result; /* we don't need the Curl_fileinfo of first file anymore */ Curl_llist_remove(wildcard->filelist, wildcard->filelist->head, NULL); @@ -4002,11 +4019,11 @@ static CURLcode wc_statemach(struct connectdata *conn) case CURLWC_CLEAN: { struct ftp_wc_tmpdata *ftp_tmp = wildcard->tmp; - ret = CURLE_OK; - if(ftp_tmp) { - ret = Curl_ftp_parselist_geterror(ftp_tmp->parser); - } - wildcard->state = ret ? CURLWC_ERROR : CURLWC_DONE; + result = CURLE_OK; + if(ftp_tmp) + result = Curl_ftp_parselist_geterror(ftp_tmp->parser); + + wildcard->state = result ? CURLWC_ERROR : CURLWC_DONE; } break; case CURLWC_DONE: @@ -4014,7 +4031,7 @@ static CURLcode wc_statemach(struct connectdata *conn) break; } - return ret; + return result; } /*********************************************************************** @@ -4028,31 +4045,31 @@ static CURLcode wc_statemach(struct connectdata *conn) */ static CURLcode ftp_do(struct connectdata *conn, bool *done) { - CURLcode retcode = CURLE_OK; + CURLcode result = CURLE_OK; struct ftp_conn *ftpc = &conn->proto.ftpc; *done = FALSE; /* default to false */ ftpc->wait_data_conn = FALSE; /* default to no such wait */ if(conn->data->set.wildcardmatch) { - retcode = wc_statemach(conn); + result = wc_statemach(conn); if(conn->data->wildcard.state == CURLWC_SKIP || conn->data->wildcard.state == CURLWC_DONE) { /* do not call ftp_regular_transfer */ return CURLE_OK; } - if(retcode) /* error, loop or skipping the file */ - return retcode; + if(result) /* error, loop or skipping the file */ + return result; } else { /* no wildcard FSM needed */ - retcode = ftp_parse_url_path(conn); - if(retcode) - return retcode; + result = ftp_parse_url_path(conn); + if(result) + return result; } - retcode = ftp_regular_transfer(conn, done); + result = ftp_regular_transfer(conn, done); - return retcode; + return result; } @@ -4064,7 +4081,7 @@ CURLcode Curl_ftpsendf(struct connectdata *conn, char s[SBUF_SIZE]; size_t write_len; char *sptr=s; - CURLcode res = CURLE_OK; + CURLcode result = CURLE_OK; #ifdef HAVE_GSSAPI enum protection_level data_sec = conn->data_prot; #endif @@ -4079,23 +4096,23 @@ CURLcode Curl_ftpsendf(struct connectdata *conn, bytes_written=0; - res = Curl_convert_to_network(conn->data, s, write_len); + result = Curl_convert_to_network(conn->data, s, write_len); /* Curl_convert_to_network calls failf if unsuccessful */ - if(res) - return(res); + if(result) + return result; for(;;) { #ifdef HAVE_GSSAPI conn->data_prot = PROT_CMD; #endif - res = Curl_write(conn, conn->sock[FIRSTSOCKET], sptr, write_len, - &bytes_written); + result = Curl_write(conn, conn->sock[FIRSTSOCKET], sptr, write_len, + &bytes_written); #ifdef HAVE_GSSAPI DEBUGASSERT(data_sec > PROT_NONE && data_sec < PROT_LAST); conn->data_prot = data_sec; #endif - if(CURLE_OK != res) + if(result) break; if(conn->data->set.verbose) @@ -4110,7 +4127,7 @@ CURLcode Curl_ftpsendf(struct connectdata *conn, break; } - return res; + return result; } /*********************************************************************** @@ -4181,14 +4198,10 @@ static CURLcode ftp_disconnect(struct connectdata *conn, bool dead_connection) } freedirs(ftpc); - if(ftpc->prevpath) { - free(ftpc->prevpath); - ftpc->prevpath = NULL; - } - if(ftpc->server_os) { - free(ftpc->server_os); - ftpc->server_os = NULL; - } + free(ftpc->prevpath); + ftpc->prevpath = NULL; + free(ftpc->server_os); + ftpc->server_os = NULL; Curl_pp_disconnect(pp); @@ -4479,7 +4492,7 @@ CURLcode ftp_regular_transfer(struct connectdata *conn, &connected, /* have we connected after PASV/PORT */ dophase_done); /* all commands in the DO-phase done? */ - if(CURLE_OK == result) { + if(!result) { if(!*dophase_done) /* the DO phase has not completed yet */ diff --git a/lib/ftp.h b/lib/ftp.h index b6bfc02..833447b 100644 --- a/lib/ftp.h +++ b/lib/ftp.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2013, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -147,11 +147,10 @@ struct ftp_conn { curl_off_t known_filesize; /* file size is different from -1, if wildcard LIST parsing was done and wc_statemach set it */ - /* newhost must be able to hold a full IP-style address in ASCII, which - in the IPv6 case means 5*8-1 = 39 letters */ -#define NEWHOST_BUFSIZE 48 - char newhost[NEWHOST_BUFSIZE]; /* this is the pair to connect the DATA... */ - unsigned short newport; /* connection to */ + /* newhost is the (allocated) IP addr or host name to connect the data + connection to */ + char *newhost; /* this is the pair to connect the DATA... */ + unsigned short newport; /* connection to */ }; diff --git a/lib/ftplistparser.c b/lib/ftplistparser.c index 4a46dd1..17e0a66 100644 --- a/lib/ftplistparser.c +++ b/lib/ftplistparser.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -23,13 +23,13 @@ /** * Now implemented: * - * 1) UNIX version 1 + * 1) Unix version 1 * drwxr-xr-x 1 user01 ftp 512 Jan 29 23:32 prog - * 2) UNIX version 2 + * 2) Unix version 2 * drwxr-xr-x 1 user01 ftp 512 Jan 29 1997 prog - * 3) UNIX version 3 + * 3) Unix version 3 * drwxr-xr-x 1 1 1 512 Jan 29 23:32 prog - * 4) UNIX symlink + * 4) Unix symlink * lrwxr-xr-x 1 user01 ftp 512 Jan 29 23:32 prog -> prog2000 * 5) DOS style * 01-29-97 11:32PM prog @@ -49,10 +49,6 @@ #include "ftp.h" #include "ftplistparser.h" #include "curl_fnmatch.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include - #include "curl_memory.h" /* The last #include file should be: */ #include "memdebug.h" @@ -191,8 +187,7 @@ struct ftp_parselist_data *Curl_ftp_parselist_data_alloc(void) void Curl_ftp_parselist_data_free(struct ftp_parselist_data **pl_data) { - if(*pl_data) - free(*pl_data); + free(*pl_data); *pl_data = NULL; } @@ -365,7 +360,7 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb, struct ftp_parselist_data *parser = tmpdata->parser; struct curl_fileinfo *finfo; unsigned long i = 0; - CURLcode rc; + CURLcode result; if(parser->error) { /* error in previous call */ /* scenario: @@ -758,9 +753,9 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb, finfo->b_data[parser->item_offset + parser->item_length - 1] = 0; parser->offsets.filename = parser->item_offset; parser->state.UNIX.main = PL_UNIX_FILETYPE; - rc = ftp_pl_insert_finfo(conn, finfo); - if(rc) { - PL_ERROR(conn, rc); + result = ftp_pl_insert_finfo(conn, finfo); + if(result) { + PL_ERROR(conn, result); return bufflen; } } @@ -770,9 +765,9 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb, finfo->b_data[parser->item_offset + parser->item_length] = 0; parser->offsets.filename = parser->item_offset; parser->state.UNIX.main = PL_UNIX_FILETYPE; - rc = ftp_pl_insert_finfo(conn, finfo); - if(rc) { - PL_ERROR(conn, rc); + result = ftp_pl_insert_finfo(conn, finfo); + if(result) { + PL_ERROR(conn, result); return bufflen; } } @@ -866,9 +861,9 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb, else if(c == '\n') { finfo->b_data[parser->item_offset + parser->item_length - 1] = 0; parser->offsets.symlink_target = parser->item_offset; - rc = ftp_pl_insert_finfo(conn, finfo); - if(rc) { - PL_ERROR(conn, rc); + result = ftp_pl_insert_finfo(conn, finfo); + if(result) { + PL_ERROR(conn, result); return bufflen; } parser->state.UNIX.main = PL_UNIX_FILETYPE; @@ -878,9 +873,9 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb, if(c == '\n') { finfo->b_data[parser->item_offset + parser->item_length - 1] = 0; parser->offsets.symlink_target = parser->item_offset; - rc = ftp_pl_insert_finfo(conn, finfo); - if(rc) { - PL_ERROR(conn, rc); + result = ftp_pl_insert_finfo(conn, finfo); + if(result) { + PL_ERROR(conn, result); return bufflen; } parser->state.UNIX.main = PL_UNIX_FILETYPE; @@ -1011,9 +1006,9 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb, parser->offsets.filename = parser->item_offset; finfo->b_data[finfo->b_used - 1] = 0; parser->offsets.filename = parser->item_offset; - rc = ftp_pl_insert_finfo(conn, finfo); - if(rc) { - PL_ERROR(conn, rc); + result = ftp_pl_insert_finfo(conn, finfo); + if(result) { + PL_ERROR(conn, result); return bufflen; } parser->state.NT.main = PL_WINNT_DATE; @@ -1023,9 +1018,9 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb, case PL_WINNT_FILENAME_WINEOL: if(c == '\n') { parser->offsets.filename = parser->item_offset; - rc = ftp_pl_insert_finfo(conn, finfo); - if(rc) { - PL_ERROR(conn, rc); + result = ftp_pl_insert_finfo(conn, finfo); + if(result) { + PL_ERROR(conn, result); return bufflen; } parser->state.NT.main = PL_WINNT_DATE; @@ -1041,7 +1036,7 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb, } break; default: - return bufflen+1; + return bufflen + 1; } i++; diff --git a/lib/getinfo.c b/lib/getinfo.c index 8905d36..910f520 100644 --- a/lib/getinfo.c +++ b/lib/getinfo.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -27,12 +27,12 @@ #include "urldata.h" #include "getinfo.h" -#include "curl_memory.h" #include "vtls/vtls.h" #include "connect.h" /* Curl_getconnectinfo() */ #include "progress.h" -/* Make this the last #include */ +/* The last #include files should be: */ +#include "curl_memory.h" #include "memdebug.h" /* @@ -42,7 +42,7 @@ CURLcode Curl_initinfo(struct SessionHandle *data) { struct Progress *pro = &data->progress; - struct PureInfo *info =&data->info; + struct PureInfo *info = &data->info; pro->t_nslookup = 0; pro->t_connect = 0; @@ -58,8 +58,7 @@ CURLcode Curl_initinfo(struct SessionHandle *data) info->filetime = -1; /* -1 is an illegal time and thus means unknown */ info->timecond = FALSE; - if(info->contenttype) - free(info->contenttype); + free(info->contenttype); info->contenttype = NULL; info->header_size = 0; @@ -116,6 +115,7 @@ static CURLcode getinfo_char(struct SessionHandle *data, CURLINFO info, default: return CURLE_BAD_FUNCTION_ARGUMENT; } + return CURLE_OK; } @@ -202,6 +202,7 @@ static CURLcode getinfo_long(struct SessionHandle *data, CURLINFO info, default: return CURLE_BAD_FUNCTION_ARGUMENT; } + return CURLE_OK; } @@ -254,6 +255,7 @@ static CURLcode getinfo_double(struct SessionHandle *data, CURLINFO info, default: return CURLE_BAD_FUNCTION_ARGUMENT; } + return CURLE_OK; } @@ -261,8 +263,8 @@ static CURLcode getinfo_slist(struct SessionHandle *data, CURLINFO info, struct curl_slist **param_slistp) { union { - struct curl_certinfo * to_certinfo; - struct curl_slist * to_slist; + struct curl_certinfo *to_certinfo; + struct curl_slist *to_slist; } ptr; switch(info) { @@ -303,7 +305,7 @@ static CURLcode getinfo_slist(struct SessionHandle *data, CURLINFO info, break; /* no SSL session found */ /* Return the TLS session information from the relevant backend */ -#ifdef USE_SSLEAY +#ifdef USE_OPENSSL internals = conn->ssl[sockindex].ctx; #endif #ifdef USE_GNUTLS @@ -312,9 +314,6 @@ static CURLcode getinfo_slist(struct SessionHandle *data, CURLINFO info, #ifdef USE_NSS internals = conn->ssl[sockindex].handle; #endif -#ifdef USE_QSOSSL - internals = conn->ssl[sockindex].handle; -#endif #ifdef USE_GSKIT internals = conn->ssl[sockindex].handle; #endif @@ -331,22 +330,23 @@ static CURLcode getinfo_slist(struct SessionHandle *data, CURLINFO info, default: return CURLE_BAD_FUNCTION_ARGUMENT; } + return CURLE_OK; } CURLcode Curl_getinfo(struct SessionHandle *data, CURLINFO info, ...) { va_list arg; - long *param_longp=NULL; - double *param_doublep=NULL; - char **param_charp=NULL; - struct curl_slist **param_slistp=NULL; + long *param_longp = NULL; + double *param_doublep = NULL; + char **param_charp = NULL; + struct curl_slist **param_slistp = NULL; int type; /* default return code is to error out! */ - CURLcode ret = CURLE_BAD_FUNCTION_ARGUMENT; + CURLcode result = CURLE_BAD_FUNCTION_ARGUMENT; if(!data) - return ret; + return result; va_start(arg, info); @@ -354,28 +354,29 @@ CURLcode Curl_getinfo(struct SessionHandle *data, CURLINFO info, ...) switch(type) { case CURLINFO_STRING: param_charp = va_arg(arg, char **); - if(NULL != param_charp) - ret = getinfo_char(data, info, param_charp); + if(param_charp) + result = getinfo_char(data, info, param_charp); break; case CURLINFO_LONG: param_longp = va_arg(arg, long *); - if(NULL != param_longp) - ret = getinfo_long(data, info, param_longp); + if(param_longp) + result = getinfo_long(data, info, param_longp); break; case CURLINFO_DOUBLE: param_doublep = va_arg(arg, double *); - if(NULL != param_doublep) - ret = getinfo_double(data, info, param_doublep); + if(param_doublep) + result = getinfo_double(data, info, param_doublep); break; case CURLINFO_SLIST: param_slistp = va_arg(arg, struct curl_slist **); - if(NULL != param_slistp) - ret = getinfo_slist(data, info, param_slistp); + if(param_slistp) + result = getinfo_slist(data, info, param_slistp); break; default: break; } va_end(arg); - return ret; + + return result; } diff --git a/lib/gopher.c b/lib/gopher.c index b1dd65f..954cad8 100644 --- a/lib/gopher.c +++ b/lib/gopher.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -36,10 +36,6 @@ #include "select.h" #include "url.h" #include "warnless.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include - #include "curl_memory.h" /* The last #include file should be: */ #include "memdebug.h" @@ -121,10 +117,10 @@ static CURLcode gopher_do(struct connectdata *conn, bool *done) for(;;) { result = Curl_write(conn, sockfd, sel, k, &amount); - if(CURLE_OK == result) { /* Which may not have written it all! */ + if(!result) { /* Which may not have written it all! */ result = Curl_client_write(conn, CLIENTWRITE_HEADER, sel, amount); if(result) { - Curl_safefree(sel_org); + free(sel_org); return result; } k -= amount; @@ -134,7 +130,7 @@ static CURLcode gopher_do(struct connectdata *conn, bool *done) } else { failf(data, "Failed sending Gopher request"); - Curl_safefree(sel_org); + free(sel_org); return result; } /* Don't busyloop. The entire loop thing is a work-around as it causes a @@ -149,12 +145,12 @@ static CURLcode gopher_do(struct connectdata *conn, bool *done) Curl_socket_ready(CURL_SOCKET_BAD, sockfd, 100); } - Curl_safefree(sel_org); + free(sel_org); /* We can use Curl_sendf to send the terminal \r\n relatively safely and save allocing another string/doing another _write loop. */ result = Curl_sendf(sockfd, conn, "\r\n"); - if(result != CURLE_OK) { + if(result) { failf(data, "Failed sending Gopher request"); return result; } diff --git a/lib/hash.c b/lib/hash.c index 4a12e1a..c46760a 100644 --- a/lib/hash.c +++ b/lib/hash.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2013, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -24,10 +24,6 @@ #include "hash.h" #include "llist.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include - #include "curl_memory.h" /* The last #include file should be: */ #include "memdebug.h" @@ -93,32 +89,6 @@ Curl_hash_init(struct curl_hash *h, } } -struct curl_hash * -Curl_hash_alloc(int slots, - hash_function hfunc, - comp_function comparator, - curl_hash_dtor dtor) -{ - struct curl_hash *h; - - if(!slots || !hfunc || !comparator ||!dtor) { - return NULL; /* failure */ - } - - h = malloc(sizeof(struct curl_hash)); - if(h) { - if(Curl_hash_init(h, slots, hfunc, comparator, dtor)) { - /* failure */ - free(h); - h = NULL; - } - } - - return h; -} - - - static struct curl_hash_element * mk_hash_element(const void *key, size_t key_len, const void *p) { @@ -242,8 +212,11 @@ Curl_hash_apply(curl_hash *h, void *user, } #endif +/* Destroys all the entries in the given hash and resets its attributes, + * prepping the given hash for [static|dynamic] deallocation. + */ void -Curl_hash_clean(struct curl_hash *h) +Curl_hash_destroy(struct curl_hash *h) { int i; @@ -257,6 +230,17 @@ Curl_hash_clean(struct curl_hash *h) h->slots = 0; } +/* Removes all the entries in the given hash. + * + * @unittest: 1602 + */ +void +Curl_hash_clean(struct curl_hash *h) +{ + Curl_hash_clean_with_criterium(h, NULL, NULL); +} + +/* Cleans all entries that pass the comp function criteria. */ void Curl_hash_clean_with_criterium(struct curl_hash *h, void *user, int (*comp)(void *, void *)) @@ -276,7 +260,7 @@ Curl_hash_clean_with_criterium(struct curl_hash *h, void *user, struct curl_hash_element *he = le->ptr; lnext = le->next; /* ask the callback function if we shall remove this entry or not */ - if(comp(user, he->ptr)) { + if(comp == NULL || comp(user, he->ptr)) { Curl_llist_remove(list, le, (void *) h); --h->size; /* one less entry in the hash now */ } @@ -285,17 +269,6 @@ Curl_hash_clean_with_criterium(struct curl_hash *h, void *user, } } -void -Curl_hash_destroy(struct curl_hash *h) -{ - if(!h) - return; - - Curl_hash_clean(h); - - free(h); -} - size_t Curl_hash_str(void* key, size_t key_length, size_t slots_num) { const char* key_str = (const char *) key; @@ -310,16 +283,11 @@ size_t Curl_hash_str(void* key, size_t key_length, size_t slots_num) return (h % slots_num); } -size_t Curl_str_key_compare(void*k1, size_t key1_len, void*k2, size_t key2_len) +size_t Curl_str_key_compare(void *k1, size_t key1_len, + void *k2, size_t key2_len) { - char *key1 = (char *)k1; - char *key2 = (char *)k2; - - if(key1_len == key2_len && - *key1 == *key2 && - memcmp(key1, key2, key1_len) == 0) { + if((key1_len == key2_len) && !memcmp(k1, k2, key1_len)) return 1; - } return 0; } diff --git a/lib/hash.h b/lib/hash.h index aa935d4..b13a236 100644 --- a/lib/hash.h +++ b/lib/hash.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2007, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -74,22 +74,16 @@ int Curl_hash_init(struct curl_hash *h, comp_function comparator, curl_hash_dtor dtor); -struct curl_hash *Curl_hash_alloc(int slots, - hash_function hfunc, - comp_function comparator, - curl_hash_dtor dtor); - void *Curl_hash_add(struct curl_hash *h, void *key, size_t key_len, void *p); int Curl_hash_delete(struct curl_hash *h, void *key, size_t key_len); void *Curl_hash_pick(struct curl_hash *, void * key, size_t key_len); void Curl_hash_apply(struct curl_hash *h, void *user, void (*cb)(void *user, void *ptr)); int Curl_hash_count(struct curl_hash *h); +void Curl_hash_destroy(struct curl_hash *h); void Curl_hash_clean(struct curl_hash *h); void Curl_hash_clean_with_criterium(struct curl_hash *h, void *user, int (*comp)(void *, void *)); -void Curl_hash_destroy(struct curl_hash *h); - size_t Curl_hash_str(void* key, size_t key_length, size_t slots_num); size_t Curl_str_key_compare(void*k1, size_t key1_len, void*k2, size_t key2_len); diff --git a/lib/hmac.c b/lib/hmac.c index dace820..0d2d5f4 100644 --- a/lib/hmac.c +++ b/lib/hmac.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -27,10 +27,6 @@ #ifndef CURL_DISABLE_CRYPTO_AUTH #include "curl_hmac.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include - #include "curl_memory.h" /* The last #include file should be: */ #include "memdebug.h" diff --git a/lib/hostasyn.c b/lib/hostasyn.c index 8151b67..17b8be0 100644 --- a/lib/hostasyn.c +++ b/lib/hostasyn.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -47,10 +47,6 @@ #include "share.h" #include "strerror.h" #include "url.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include - #include "curl_memory.h" /* The last #include file should be: */ #include "memdebug.h" @@ -75,7 +71,7 @@ CURLcode Curl_addrinfo_callback(struct connectdata *conn, struct Curl_addrinfo *ai) { struct Curl_dns_entry *dns = NULL; - CURLcode rc = CURLE_OK; + CURLcode result = CURLE_OK; conn->async.status = status; @@ -92,14 +88,14 @@ CURLcode Curl_addrinfo_callback(struct connectdata *conn, if(!dns) { /* failed to store, cleanup and return error */ Curl_freeaddrinfo(ai); - rc = CURLE_OUT_OF_MEMORY; + result = CURLE_OUT_OF_MEMORY; } if(data->share) Curl_share_unlock(data, CURL_LOCK_DATA_DNS); } else { - rc = CURLE_OUT_OF_MEMORY; + result = CURLE_OUT_OF_MEMORY; } } @@ -110,9 +106,9 @@ CURLcode Curl_addrinfo_callback(struct connectdata *conn, async struct */ conn->async.done = TRUE; - /* ipv4: The input hostent struct will be freed by ares when we return from + /* IPv4: The input hostent struct will be freed by ares when we return from this function */ - return rc; + return result; } /* Call this function after Curl_connect() has returned async=TRUE and @@ -123,21 +119,21 @@ CURLcode Curl_addrinfo_callback(struct connectdata *conn, CURLcode Curl_async_resolved(struct connectdata *conn, bool *protocol_done) { - CURLcode code; + CURLcode result; if(conn->async.dns) { conn->dns_entry = conn->async.dns; conn->async.dns = NULL; } - code = Curl_setup_conn(conn, protocol_done); + result = Curl_setup_conn(conn, protocol_done); - if(code) + if(result) /* We're not allowed to return failure with memory left allocated in the connectdata struct, free those here */ Curl_disconnect(conn, FALSE); /* close the connection */ - return code; + return result; } /* diff --git a/lib/hostcheck.c b/lib/hostcheck.c index 42eb2ee..62a26e4 100644 --- a/lib/hostcheck.c +++ b/lib/hostcheck.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -22,8 +22,7 @@ #include "curl_setup.h" -#if defined(USE_SSLEAY) || defined(USE_AXTLS) || defined(USE_QSOSSL) || \ - defined(USE_GSKIT) +#if defined(USE_OPENSSL) || defined(USE_AXTLS) || defined(USE_GSKIT) /* these backends use functions from this file */ #ifdef HAVE_NETINET_IN_H @@ -145,4 +144,4 @@ int Curl_cert_hostcheck(const char *match_pattern, const char *hostname) return res; } -#endif /* SSLEAY or AXTLS or QSOSSL or GSKIT */ +#endif /* OPENSSL or AXTLS or GSKIT */ diff --git a/lib/hostip.c b/lib/hostip.c index 73b3f82..82f3897 100644 --- a/lib/hostip.c +++ b/lib/hostip.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -56,10 +56,7 @@ #include "url.h" #include "inet_ntop.h" #include "warnless.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include - +#include "curl_printf.h" #include "curl_memory.h" /* The last #include file should be: */ #include "memdebug.h" @@ -98,8 +95,8 @@ * hostip.c - method-independent resolver functions and utility functions * hostasyn.c - functions for asynchronous name resolves * hostsyn.c - functions for synchronous name resolves - * hostip4.c - ipv4-specific functions - * hostip6.c - ipv6-specific functions + * hostip4.c - IPv4 specific functions + * hostip6.c - IPv6 specific functions * * The two asynchronous name resolver backends are implemented in: * asyn-ares.c - functions for ares-using name resolves @@ -140,11 +137,7 @@ struct curl_hash *Curl_global_host_cache_init(void) void Curl_global_host_cache_dtor(void) { if(host_cache_initialized) { - /* first make sure that any custom "CURLOPT_RESOLVE" names are - cleared off */ - Curl_hostcache_clean(NULL, &hostname_cache); - /* then free the remaining hash completely */ - Curl_hash_clean(&hostname_cache); + Curl_hash_destroy(&hostname_cache); host_cache_initialized = 0; } } @@ -237,7 +230,8 @@ hostcache_timestamp_remove(void *datap, void *hc) (struct hostcache_prune_data *) datap; struct Curl_dns_entry *c = (struct Curl_dns_entry *) hc; - return !c->inuse && (data->now - c->timestamp >= data->cache_timeout); + return (0 != c->timestamp) + && (data->now - c->timestamp >= data->cache_timeout); } /* @@ -283,40 +277,54 @@ void Curl_hostcache_prune(struct SessionHandle *data) Curl_share_unlock(data, CURL_LOCK_DATA_DNS); } -/* - * Check if the entry should be pruned. Assumes a locked cache. - */ -static int -remove_entry_if_stale(struct SessionHandle *data, struct Curl_dns_entry *dns) +#ifdef HAVE_SIGSETJMP +/* Beware this is a global and unique instance. This is used to store the + return address that we can jump back to from inside a signal handler. This + is not thread-safe stuff. */ +sigjmp_buf curl_jmpenv; +#endif + +/* lookup address, returns entry if found and not stale */ +static struct Curl_dns_entry * +fetch_addr(struct connectdata *conn, + const char *hostname, + int port) { - struct hostcache_prune_data user; + char *entry_id = NULL; + struct Curl_dns_entry *dns = NULL; + size_t entry_len; + struct SessionHandle *data = conn->data; - if(!dns || (data->set.dns_cache_timeout == -1) || !data->dns.hostcache || - dns->inuse) - /* cache forever means never prune, and NULL hostcache means we can't do - it, if it still is in use then we leave it */ - return 0; + /* Create an entry id, based upon the hostname and port */ + entry_id = create_hostcache_id(hostname, port); + /* If we can't create the entry id, fail */ + if(!entry_id) + return dns; - time(&user.now); - user.cache_timeout = data->set.dns_cache_timeout; + entry_len = strlen(entry_id); - if(!hostcache_timestamp_remove(&user,dns) ) - return 0; + /* See if its already in our dns cache */ + dns = Curl_hash_pick(data->dns.hostcache, entry_id, entry_len+1); - Curl_hash_clean_with_criterium(data->dns.hostcache, - (void *) &user, - hostcache_timestamp_remove); + if(dns && (data->set.dns_cache_timeout != -1)) { + /* See whether the returned entry is stale. Done before we release lock */ + struct hostcache_prune_data user; - return 1; -} + time(&user.now); + user.cache_timeout = data->set.dns_cache_timeout; + if(hostcache_timestamp_remove(&user, dns)) { + infof(data, "Hostname in DNS cache was stale, zapped\n"); + dns = NULL; /* the memory deallocation is being handled by the hash */ + Curl_hash_delete(data->dns.hostcache, entry_id, entry_len+1); + } + } -#ifdef HAVE_SIGSETJMP -/* Beware this is a global and unique instance. This is used to store the - return address that we can jump back to from inside a signal handler. This - is not thread-safe stuff. */ -sigjmp_buf curl_jmpenv; -#endif + /* free the allocated entry_id again */ + free(entry_id); + + return dns; +} /* * Curl_fetch_addr() fetches a 'Curl_dns_entry' already in the DNS cache. @@ -328,35 +336,27 @@ sigjmp_buf curl_jmpenv; * lookups for the same hostname requested by different handles. * * Returns the Curl_dns_entry entry pointer or NULL if not in the cache. + * + * The returned data *MUST* be "unlocked" with Curl_resolv_unlock() after + * use, or we'll leak memory! */ struct Curl_dns_entry * Curl_fetch_addr(struct connectdata *conn, const char *hostname, - int port, int *stale) + int port) { - char *entry_id = NULL; - struct Curl_dns_entry *dns = NULL; - size_t entry_len; struct SessionHandle *data = conn->data; + struct Curl_dns_entry *dns = NULL; - /* Create an entry id, based upon the hostname and port */ - entry_id = create_hostcache_id(hostname, port); - /* If we can't create the entry id, fail */ - if(!entry_id) - return dns; - - entry_len = strlen(entry_id); + if(data->share) + Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE); - /* See if its already in our dns cache */ - dns = Curl_hash_pick(data->dns.hostcache, entry_id, entry_len+1); + dns = fetch_addr(conn, hostname, port); - /* free the allocated entry_id again */ - free(entry_id); + if(dns) dns->inuse++; /* we use it! */ - /* See whether the returned entry is stale. Done before we release lock */ - *stale = remove_entry_if_stale(data, dns); - if(*stale) - dns = NULL; /* the memory deallocation is being handled by the hash */ + if(data->share) + Curl_share_unlock(data, CURL_LOCK_DATA_DNS); return dns; } @@ -395,11 +395,11 @@ Curl_cache_addr(struct SessionHandle *data, return NULL; } - dns->inuse = 0; /* init to not used */ + dns->inuse = 1; /* the cache has the first reference */ dns->addr = addr; /* this is the address(es) */ time(&dns->timestamp); if(dns->timestamp == 0) - dns->timestamp = 1; /* zero indicates that entry isn't in hash table */ + dns->timestamp = 1; /* zero indicates CURLOPT_RESOLVE entry */ /* Store the resolved data in our DNS cache. */ dns2 = Curl_hash_add(data->dns.hostcache, entry_id, entry_len+1, @@ -448,21 +448,17 @@ int Curl_resolv(struct connectdata *conn, struct Curl_dns_entry *dns = NULL; struct SessionHandle *data = conn->data; CURLcode result; - int stale, rc = CURLRESOLV_ERROR; /* default to failure */ + int rc = CURLRESOLV_ERROR; /* default to failure */ *entry = NULL; if(data->share) Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE); - dns = Curl_fetch_addr(conn, hostname, port, &stale); - - infof(data, "Hostname was %sfound in DNS cache\n", dns||stale?"":"NOT "); - if(stale) - infof(data, "Hostname in DNS cache was stale, zapped\n"); - + dns = fetch_addr(conn, hostname, port); if(dns) { + infof(data, "Hostname %s was found in DNS cache\n", hostname); dns->inuse++; /* we use it! */ rc = CURLRESOLV_RESOLVED; } @@ -611,32 +607,6 @@ int Curl_resolv_timeout(struct connectdata *conn, we want to wait less than one second we must bail out already now. */ return CURLRESOLV_TIMEDOUT; - /************************************************************* - * Set signal handler to catch SIGALRM - * Store the old value to be able to set it back later! - *************************************************************/ -#ifdef HAVE_SIGACTION - sigaction(SIGALRM, NULL, &sigact); - keep_sigact = sigact; - keep_copysig = TRUE; /* yes, we have a copy */ - sigact.sa_handler = alarmfunc; -#ifdef SA_RESTART - /* HPUX doesn't have SA_RESTART but defaults to that behaviour! */ - sigact.sa_flags &= ~SA_RESTART; -#endif - /* now set the new struct */ - sigaction(SIGALRM, &sigact, NULL); -#else /* HAVE_SIGACTION */ - /* no sigaction(), revert to the much lamer signal() */ -#ifdef HAVE_SIGNAL - keep_sigact = signal(SIGALRM, alarmfunc); -#endif -#endif /* HAVE_SIGACTION */ - - /* alarm() makes a signal get sent when the timeout fires off, and that - will abort system calls */ - prev_alarm = alarm(curlx_sltoui(timeout/1000L)); - /* This allows us to time-out from the name resolver, as the timeout will generate a signal and we will siglongjmp() from that here. This technique has problems (see alarmfunc). @@ -649,6 +619,33 @@ int Curl_resolv_timeout(struct connectdata *conn, rc = CURLRESOLV_ERROR; goto clean_up; } + else { + /************************************************************* + * Set signal handler to catch SIGALRM + * Store the old value to be able to set it back later! + *************************************************************/ +#ifdef HAVE_SIGACTION + sigaction(SIGALRM, NULL, &sigact); + keep_sigact = sigact; + keep_copysig = TRUE; /* yes, we have a copy */ + sigact.sa_handler = alarmfunc; +#ifdef SA_RESTART + /* HPUX doesn't have SA_RESTART but defaults to that behaviour! */ + sigact.sa_flags &= ~SA_RESTART; +#endif + /* now set the new struct */ + sigaction(SIGALRM, &sigact, NULL); +#else /* HAVE_SIGACTION */ + /* no sigaction(), revert to the much lamer signal() */ +#ifdef HAVE_SIGNAL + keep_sigact = signal(SIGALRM, alarmfunc); +#endif +#endif /* HAVE_SIGACTION */ + + /* alarm() makes a signal get sent when the timeout fires off, and that + will abort system calls */ + prev_alarm = alarm(curlx_sltoui(timeout/1000L)); + } #else #ifndef CURLRES_ASYNCH @@ -720,54 +717,37 @@ clean_up: */ void Curl_resolv_unlock(struct SessionHandle *data, struct Curl_dns_entry *dns) { - DEBUGASSERT(dns && (dns->inuse>0)); - if(data && data->share) Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE); - dns->inuse--; - /* only free if nobody is using AND it is not in hostcache (timestamp == - 0) */ - if(dns->inuse == 0 && dns->timestamp == 0) { - Curl_freeaddrinfo(dns->addr); - free(dns); - } + freednsentry(dns); if(data && data->share) Curl_share_unlock(data, CURL_LOCK_DATA_DNS); } /* - * File-internal: free a cache dns entry. + * File-internal: release cache dns entry reference, free if inuse drops to 0 */ static void freednsentry(void *freethis) { - struct Curl_dns_entry *p = (struct Curl_dns_entry *) freethis; + struct Curl_dns_entry *dns = (struct Curl_dns_entry *) freethis; + DEBUGASSERT(dns && (dns->inuse>0)); - /* mark the entry as not in hostcache */ - p->timestamp = 0; - if(p->inuse == 0) { - Curl_freeaddrinfo(p->addr); - free(p); + dns->inuse--; + if(dns->inuse == 0) { + Curl_freeaddrinfo(dns->addr); + free(dns); } } /* - * Curl_mk_dnscache() creates a new DNS cache and returns the handle for it. + * Curl_mk_dnscache() inits a new DNS cache and returns success/failure. */ -struct curl_hash *Curl_mk_dnscache(void) +int Curl_mk_dnscache(struct curl_hash *hash) { - return Curl_hash_alloc(7, Curl_hash_str, Curl_str_key_compare, freednsentry); -} - -static int hostcache_inuse(void *data, void *hc) -{ - struct Curl_dns_entry *c = (struct Curl_dns_entry *) hc; - - if(c->inuse == 1) - Curl_resolv_unlock(data, c); - - return 1; /* free all entries */ + return Curl_hash_init(hash, 7, Curl_hash_str, Curl_str_key_compare, + freednsentry); } /* @@ -780,11 +760,13 @@ static int hostcache_inuse(void *data, void *hc) void Curl_hostcache_clean(struct SessionHandle *data, struct curl_hash *hash) { - /* Entries added to the hostcache with the CURLOPT_RESOLVE function are - * still present in the cache with the inuse counter set to 1. Detect them - * and cleanup! - */ - Curl_hash_clean_with_criterium(hash, data, hostcache_inuse); + if(data && data->share) + Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE); + + Curl_hash_clean(hash); + + if(data && data->share) + Curl_share_unlock(data, CURL_LOCK_DATA_DNS); } @@ -799,18 +781,52 @@ CURLcode Curl_loadhostpairs(struct SessionHandle *data) if(!hostp->data) continue; if(hostp->data[0] == '-') { - /* TODO: mark an entry for removal */ + char *entry_id; + size_t entry_len; + + if(2 != sscanf(hostp->data + 1, "%255[^:]:%d", hostname, &port)) { + infof(data, "Couldn't parse CURLOPT_RESOLVE removal entry '%s'!\n", + hostp->data); + continue; + } + + /* Create an entry id, based upon the hostname and port */ + entry_id = create_hostcache_id(hostname, port); + /* If we can't create the entry id, fail */ + if(!entry_id) { + return CURLE_OUT_OF_MEMORY; + } + + entry_len = strlen(entry_id); + + if(data->share) + Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE); + + /* delete entry, ignore if it didn't exist */ + Curl_hash_delete(data->dns.hostcache, entry_id, entry_len+1); + + if(data->share) + Curl_share_unlock(data, CURL_LOCK_DATA_DNS); + + /* free the allocated entry_id again */ + free(entry_id); } - else if(3 == sscanf(hostp->data, "%255[^:]:%d:%255s", hostname, &port, - address)) { + else { struct Curl_dns_entry *dns; Curl_addrinfo *addr; char *entry_id; size_t entry_len; + if(3 != sscanf(hostp->data, "%255[^:]:%d:%255s", hostname, &port, + address)) { + infof(data, "Couldn't parse CURLOPT_RESOLVE entry '%s'!\n", + hostp->data); + continue; + } + addr = Curl_str2addr(address, port); if(!addr) { - infof(data, "Resolve %s found illegal!\n", hostp->data); + infof(data, "Address in '%s' found illegal!\n", hostp->data); continue; } @@ -833,9 +849,16 @@ CURLcode Curl_loadhostpairs(struct SessionHandle *data) /* free the allocated entry_id again */ free(entry_id); - if(!dns) + if(!dns) { /* if not in the cache already, put this host in the cache */ dns = Curl_cache_addr(data, addr, hostname, port); + if(dns) { + dns->timestamp = 0; /* mark as added by CURLOPT_RESOLVE */ + /* release the returned reference; the cache itself will keep the + * entry alive: */ + dns->inuse--; + } + } else /* this is a duplicate, free it again */ Curl_freeaddrinfo(addr); diff --git a/lib/hostip.h b/lib/hostip.h index 4404651..d5b44bc 100644 --- a/lib/hostip.h +++ b/lib/hostip.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2013, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -65,11 +65,10 @@ void Curl_global_host_cache_dtor(void); struct Curl_dns_entry { Curl_addrinfo *addr; - /* timestamp == 0 -- entry not in hostcache - timestamp != 0 -- entry is in hostcache */ + /* timestamp == 0 -- CURLOPT_RESOLVE entry, doesn't timeout */ time_t timestamp; - long inuse; /* use-counter, make very sure you decrease this - when you're done using the address you received */ + /* use-counter, use Curl_resolv_unlock to release reference */ + long inuse; }; /* @@ -92,7 +91,7 @@ int Curl_resolv_timeout(struct connectdata *conn, const char *hostname, #ifdef CURLRES_IPV6 /* - * Curl_ipv6works() returns TRUE if ipv6 seems to work. + * Curl_ipv6works() returns TRUE if IPv6 seems to work. */ bool Curl_ipv6works(void); #else @@ -125,8 +124,8 @@ void Curl_resolv_unlock(struct SessionHandle *data, /* for debugging purposes only: */ void Curl_scan_cache_used(void *user, void *ptr); -/* make a new dns cache and return the handle */ -struct curl_hash *Curl_mk_dnscache(void); +/* init a new dns cache and return success */ +int Curl_mk_dnscache(struct curl_hash *hash); /* prune old entries from the DNS cache */ void Curl_hostcache_prune(struct SessionHandle *data); @@ -175,13 +174,14 @@ const char *Curl_printable_address(const Curl_addrinfo *ip, * Curl_fetch_addr() fetches a 'Curl_dns_entry' already in the DNS cache. * * Returns the Curl_dns_entry entry pointer or NULL if not in the cache. + * + * The returned data *MUST* be "unlocked" with Curl_resolv_unlock() after + * use, or we'll leak memory! */ struct Curl_dns_entry * Curl_fetch_addr(struct connectdata *conn, const char *hostname, - int port, - int *stale); - + int port); /* * Curl_cache_addr() stores a 'Curl_addrinfo' struct in the DNS cache. * diff --git a/lib/hostip4.c b/lib/hostip4.c index 1e39f4a..37b0369 100644 --- a/lib/hostip4.c +++ b/lib/hostip4.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2013, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -48,18 +48,15 @@ #include "strerror.h" #include "url.h" #include "inet_pton.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include - +#include "curl_printf.h" #include "curl_memory.h" /* The last #include file should be: */ #include "memdebug.h" /*********************************************************************** - * Only for plain-ipv4 builds + * Only for plain IPv4 builds **********************************************************************/ -#ifdef CURLRES_IPV4 /* plain ipv4 code coming up */ +#ifdef CURLRES_IPV4 /* plain IPv4 code coming up */ /* * Curl_ipvalid() checks what CURL_IPRESOLVE_* requirements that might've * been set and returns TRUE if they are OK. @@ -67,7 +64,7 @@ bool Curl_ipvalid(struct connectdata *conn) { if(conn->ip_version == CURL_IPRESOLVE_V6) - /* an ipv6 address was requested and we can't get/use one */ + /* An IPv6 address was requested and we can't get/use one */ return FALSE; return TRUE; /* OK, proceed */ @@ -76,7 +73,7 @@ bool Curl_ipvalid(struct connectdata *conn) #ifdef CURLRES_SYNCH /* - * Curl_getaddrinfo() - the ipv4 synchronous version. + * Curl_getaddrinfo() - the IPv4 synchronous version. * * The original code to this function was from the Dancer source code, written * by Bjorn Reese, it has since been patched and modified considerably. diff --git a/lib/hostip6.c b/lib/hostip6.c index 8327004..6ab131a 100644 --- a/lib/hostip6.c +++ b/lib/hostip6.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2013, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -49,16 +49,13 @@ #include "url.h" #include "inet_pton.h" #include "connect.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include - +#include "curl_printf.h" #include "curl_memory.h" /* The last #include file should be: */ #include "memdebug.h" /*********************************************************************** - * Only for ipv6-enabled builds + * Only for IPv6-enabled builds **********************************************************************/ #ifdef CURLRES_IPV6 @@ -97,7 +94,7 @@ int curl_dogetnameinfo(GETNAMEINFO_QUAL_ARG1 GETNAMEINFO_TYPE_ARG1 sa, #endif /* defined(CURLDEBUG) && defined(HAVE_GETNAMEINFO) */ /* - * Curl_ipv6works() returns TRUE if ipv6 seems to work. + * Curl_ipv6works() returns TRUE if IPv6 seems to work. */ bool Curl_ipv6works(void) { @@ -109,7 +106,7 @@ bool Curl_ipv6works(void) /* probe to see if we have a working IPv6 stack */ curl_socket_t s = socket(PF_INET6, SOCK_DGRAM, 0); if(s == CURL_SOCKET_BAD) - /* an ipv6 address was requested but we can't get/use one */ + /* an IPv6 address was requested but we can't get/use one */ ipv6_works = 0; else { ipv6_works = 1; @@ -152,7 +149,7 @@ static void dump_addrinfo(struct connectdata *conn, const Curl_addrinfo *ai) #endif /* - * Curl_getaddrinfo() when built ipv6-enabled (non-threading and + * Curl_getaddrinfo() when built IPv6-enabled (non-threading and * non-ares version). * * Returns name information about the given hostname and port number. If @@ -192,7 +189,7 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn, } if((pf != PF_INET) && !Curl_ipv6works()) - /* the stack seems to be a non-ipv6 one */ + /* The stack seems to be a non-IPv6 one */ pf = PF_INET; memset(&hints, 0, sizeof(hints)); diff --git a/lib/hostsyn.c b/lib/hostsyn.c index 4ad3c63..fb1de35 100644 --- a/lib/hostsyn.c +++ b/lib/hostsyn.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2013, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -47,10 +47,6 @@ #include "share.h" #include "strerror.h" #include "url.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include - #include "curl_memory.h" /* The last #include file should be: */ #include "memdebug.h" diff --git a/lib/http.c b/lib/http.c index 35baa34..9817d72 100644 --- a/lib/http.c +++ b/lib/http.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -63,7 +63,6 @@ #include "share.h" #include "hostip.h" #include "http.h" -#include "curl_memory.h" #include "select.h" #include "parsedate.h" /* for the week day and month names */ #include "strtoofft.h" @@ -73,15 +72,14 @@ #include "http_proxy.h" #include "warnless.h" #include "non-ascii.h" -#include "bundles.h" +#include "conncache.h" #include "pipeline.h" #include "http2.h" #include "connect.h" +#include "curl_printf.h" -#define _MPRINTF_REPLACE /* use our functions only */ -#include - -/* The last #include file should be: */ +/* The last #include files should be: */ +#include "curl_memory.h" #include "memdebug.h" /* @@ -155,12 +153,18 @@ CURLcode Curl_http_setup_conn(struct connectdata *conn) { /* allocate the HTTP-specific struct for the SessionHandle, only to survive during this request */ + struct HTTP *http; DEBUGASSERT(conn->data->req.protop == NULL); - conn->data->req.protop = calloc(1, sizeof(struct HTTP)); - if(!conn->data->req.protop) + http = calloc(1, sizeof(struct HTTP)); + if(!http) return CURLE_OUT_OF_MEMORY; + conn->data->req.protop = http; + + Curl_http2_setup_conn(conn); + Curl_http2_setup_req(conn->data); + return CURLE_OK; } @@ -279,7 +283,7 @@ static CURLcode http_output_basic(struct connectdata *conn, bool proxy) char **userp; const char *user; const char *pwd; - CURLcode error; + CURLcode result; if(proxy) { userp = &conn->allocptr.proxyuserpwd; @@ -294,16 +298,16 @@ static CURLcode http_output_basic(struct connectdata *conn, bool proxy) snprintf(data->state.buffer, sizeof(data->state.buffer), "%s:%s", user, pwd); - error = Curl_base64_encode(data, - data->state.buffer, strlen(data->state.buffer), - &authorization, &size); - if(error) - return error; + result = Curl_base64_encode(data, + data->state.buffer, strlen(data->state.buffer), + &authorization, &size); + if(result) + return result; if(!authorization) return CURLE_REMOTE_ACCESS_DENIED; - Curl_safefree(*userp); + free(*userp); *userp = aprintf("%sAuthorization: Basic %s\r\n", proxy?"Proxy-":"", authorization); @@ -392,16 +396,21 @@ static CURLcode http_perhapsrewind(struct connectdata *conn) bytessent = http->writebytecount; - if(conn->bits.authneg) + if(conn->bits.authneg) { /* This is a state where we are known to be negotiating and we don't send any data then. */ expectsend = 0; + } + else if(!conn->bits.protoconnstart) { + /* HTTP CONNECT in progress: there is no body */ + expectsend = 0; + } else { /* figure out how much data we are expected to send */ switch(data->set.httpreq) { case HTTPREQ_POST: - if(data->set.postfieldsize != -1) - expectsend = data->set.postfieldsize; + if(data->state.infilesize != -1) + expectsend = data->state.infilesize; else if(data->set.postfields) expectsend = (curl_off_t)strlen(data->set.postfields); break; @@ -420,6 +429,7 @@ static CURLcode http_perhapsrewind(struct connectdata *conn) conn->bits.rewindaftersend = FALSE; /* default */ if((expectsend == -1) || (expectsend > bytessent)) { +#if defined(USE_NTLM) /* There is still data left to send */ if((data->state.authproxy.picked == CURLAUTH_NTLM) || (data->state.authhost.picked == CURLAUTH_NTLM) || @@ -439,6 +449,7 @@ static CURLcode http_perhapsrewind(struct connectdata *conn) return CURLE_OK; } + if(conn->bits.close) /* this is already marked to get closed */ return CURLE_OK; @@ -447,9 +458,9 @@ static CURLcode http_perhapsrewind(struct connectdata *conn) CURL_FORMAT_CURL_OFF_T " bytes\n", (curl_off_t)(expectsend - bytessent)); } +#endif - /* This is not NTLM or many bytes left to send: close - */ + /* This is not NTLM or many bytes left to send: close */ connclose(conn, "Mid-auth HTTP and much data left to send"); data->req.size = 0; /* don't download any more than 0 bytes */ @@ -476,7 +487,7 @@ CURLcode Curl_http_auth_act(struct connectdata *conn) struct SessionHandle *data = conn->data; bool pickhost = FALSE; bool pickproxy = FALSE; - CURLcode code = CURLE_OK; + CURLcode result = CURLE_OK; if(100 <= data->req.httpcode && 199 >= data->req.httpcode) /* this is a transient response code, ignore */ @@ -512,9 +523,9 @@ CURLcode Curl_http_auth_act(struct connectdata *conn) if((data->set.httpreq != HTTPREQ_GET) && (data->set.httpreq != HTTPREQ_HEAD) && !conn->bits.rewindaftersend) { - code = http_perhapsrewind(conn); - if(code) - return code; + result = http_perhapsrewind(conn); + if(result) + return result; } } @@ -536,10 +547,10 @@ CURLcode Curl_http_auth_act(struct connectdata *conn) if(http_should_fail(conn)) { failf (data, "The requested URL returned error: %d", data->req.httpcode); - code = CURLE_HTTP_RETURNED_ERROR; + result = CURLE_HTTP_RETURNED_ERROR; } - return code; + return result; } @@ -554,9 +565,11 @@ output_auth_headers(struct connectdata *conn, const char *path, bool proxy) { - struct SessionHandle *data = conn->data; - const char *auth=NULL; + const char *auth = NULL; CURLcode result = CURLE_OK; +#if defined(USE_SPNEGO) || !defined(CURL_DISABLE_VERBOSE_STRINGS) + struct SessionHandle *data = conn->data; +#endif #ifdef USE_SPNEGO struct negotiatedata *negdata = proxy? &data->state.proxyneg:&data->state.negotiate; @@ -672,7 +685,7 @@ Curl_http_output_auth(struct connectdata *conn, if((conn->bits.httpproxy && conn->bits.proxy_user_passwd) || conn->bits.user_passwd) - /* continue please */ ; + /* continue please */; else { authhost->done = TRUE; authproxy->done = TRUE; @@ -773,14 +786,13 @@ CURLcode Curl_http_input_auth(struct connectdata *conn, bool proxy, while(*auth) { #ifdef USE_SPNEGO if(checkprefix("Negotiate", auth)) { - int neg; *availp |= CURLAUTH_NEGOTIATE; authp->avail |= CURLAUTH_NEGOTIATE; if(authp->picked == CURLAUTH_NEGOTIATE) { if(negdata->state == GSS_AUTHSENT || negdata->state == GSS_AUTHNONE) { - neg = Curl_input_negotiate(conn, proxy, auth); - if(neg == 0) { + CURLcode result = Curl_input_negotiate(conn, proxy, auth); + if(!result) { DEBUGASSERT(!data->req.newurl); data->req.newurl = strdup(data->change.url); if(!data->req.newurl) @@ -804,9 +816,8 @@ CURLcode Curl_http_input_auth(struct connectdata *conn, bool proxy, if(authp->picked == CURLAUTH_NTLM || authp->picked == CURLAUTH_NTLM_WB) { /* NTLM authentication is picked and activated */ - CURLcode ntlm = - Curl_input_ntlm(conn, proxy, auth); - if(CURLE_OK == ntlm) { + CURLcode result = Curl_input_ntlm(conn, proxy, auth); + if(!result) { data->state.authproblem = FALSE; #ifdef NTLM_WB_ENABLED if(authp->picked == CURLAUTH_NTLM_WB) { @@ -844,7 +855,7 @@ CURLcode Curl_http_input_auth(struct connectdata *conn, bool proxy, infof(data, "Ignoring duplicate digest auth header.\n"); } else { - CURLdigest dig; + CURLcode result; *availp |= CURLAUTH_DIGEST; authp->avail |= CURLAUTH_DIGEST; @@ -852,9 +863,8 @@ CURLcode Curl_http_input_auth(struct connectdata *conn, bool proxy, * authentication isn't activated yet, as we need to store the * incoming data from this header in case we are gonna use * Digest. */ - dig = Curl_input_digest(conn, proxy, auth); - - if(CURLDIGEST_FINE != dig) { + result = Curl_input_digest(conn, proxy, auth); + if(result) { infof(data, "Authentication problem. Ignoring this.\n"); data->state.authproblem = TRUE; } @@ -991,8 +1001,8 @@ static size_t readmoredata(char *buffer, /* move backup data into focus and continue on that */ http->postdata = http->backup.postdata; http->postsize = http->backup.postsize; - conn->fread_func = http->backup.fread_func; - conn->fread_in = http->backup.fread_in; + conn->data->set.fread_func = http->backup.fread_func; + conn->data->set.in = http->backup.fread_in; http->sending++; /* move one step up */ @@ -1023,6 +1033,16 @@ Curl_send_buffer *Curl_add_buffer_init(void) } /* + * Curl_add_buffer_free() frees all associated resources. + */ +void Curl_add_buffer_free(Curl_send_buffer *buff) +{ + if(buff) /* deal with NULL input */ + free(buff->buffer); + free(buff); +} + +/* * Curl_add_buffer_send() sends a header buffer and frees all associated * memory. Body data may be appended to the header data if desired. * @@ -1041,7 +1061,7 @@ CURLcode Curl_add_buffer_send(Curl_send_buffer *in, { ssize_t amount; - CURLcode res; + CURLcode result; char *ptr; size_t size; struct HTTP *http = conn->data->req.protop; @@ -1064,14 +1084,12 @@ CURLcode Curl_add_buffer_send(Curl_send_buffer *in, DEBUGASSERT(size > included_body_bytes); - res = Curl_convert_to_network(conn->data, ptr, headersize); + result = Curl_convert_to_network(conn->data, ptr, headersize); /* Curl_convert_to_network calls failf if unsuccessful */ - if(res) { + if(result) { /* conversion failed, free memory and return to the caller */ - if(in->buffer) - free(in->buffer); - free(in); - return res; + Curl_add_buffer_free(in); + return result; } @@ -1096,9 +1114,9 @@ CURLcode Curl_add_buffer_send(Curl_send_buffer *in, else sendsize = size; - res = Curl_write(conn, sockfd, ptr, sendsize, &amount); + result = Curl_write(conn, sockfd, ptr, sendsize, &amount); - if(CURLE_OK == res) { + if(!result) { /* * Note that we may not send the entire chunk at once, and we have a set * number of data bytes at the end of the big buffer (out of which we may @@ -1139,14 +1157,14 @@ CURLcode Curl_add_buffer_send(Curl_send_buffer *in, ptr = in->buffer + amount; /* backup the currently set pointers */ - http->backup.fread_func = conn->fread_func; - http->backup.fread_in = conn->fread_in; + http->backup.fread_func = conn->data->set.fread_func; + http->backup.fread_in = conn->data->set.in; http->backup.postdata = http->postdata; http->backup.postsize = http->postsize; /* set the new pointers for the request-sending */ - conn->fread_func = (curl_read_callback)readmoredata; - conn->fread_in = (void *)conn; + conn->data->set.fread_func = (curl_read_callback)readmoredata; + conn->data->set.in = (void *)conn; http->postdata = ptr; http->postsize = (curl_off_t)size; @@ -1169,14 +1187,12 @@ CURLcode Curl_add_buffer_send(Curl_send_buffer *in, */ return CURLE_SEND_ERROR; else - conn->writechannel_inuse = FALSE; + Curl_pipeline_leave_write(conn); } } - if(in->buffer) - free(in->buffer); - free(in); + Curl_add_buffer_free(in); - return res; + return result; } @@ -1197,8 +1213,7 @@ CURLcode Curl_add_bufferf(Curl_send_buffer *in, const char *fmt, ...) return result; } /* If we failed, we cleanup the whole buffer and return error */ - if(in->buffer) - free(in->buffer); + free(in->buffer); free(in); return CURLE_OUT_OF_MEMORY; } @@ -1378,7 +1393,7 @@ static CURLcode https_connecting(struct connectdata *conn, bool *done) } #endif -#if defined(USE_SSLEAY) || defined(USE_GNUTLS) || defined(USE_SCHANNEL) || \ +#if defined(USE_OPENSSL) || defined(USE_GNUTLS) || defined(USE_SCHANNEL) || \ defined(USE_DARWINSSL) || defined(USE_POLARSSL) || defined(USE_NSS) /* This function is for OpenSSL, GnuTLS, darwinssl, schannel and polarssl only. It should be made to query the generic SSL layer instead. */ @@ -1417,7 +1432,7 @@ static int https_getsock(struct connectdata *conn, return GETSOCK_BLANK; } #endif /* USE_SSL */ -#endif /* USE_SSLEAY || USE_GNUTLS || USE_SCHANNEL */ +#endif /* USE_OPENSSL || USE_GNUTLS || USE_SCHANNEL */ /* * Curl_http_done() gets called from Curl_done() after a single HTTP request @@ -1428,19 +1443,26 @@ CURLcode Curl_http_done(struct connectdata *conn, CURLcode status, bool premature) { struct SessionHandle *data = conn->data; - struct HTTP *http =data->req.protop; + struct HTTP *http = data->req.protop; +#ifdef USE_NGHTTP2 + struct http_conn *httpc = &conn->proto.httpc; +#endif Curl_unencode_cleanup(conn); #ifdef USE_SPNEGO if(data->state.proxyneg.state == GSS_AUTHSENT || - data->state.negotiate.state == GSS_AUTHSENT) + data->state.negotiate.state == GSS_AUTHSENT) { + /* add forbid re-use if http-code != 401/407 as a WA only needed for + * 401/407 that signal auth failure (empty) otherwise state will be RECV + * with current code */ + if((data->req.httpcode != 401) && (data->req.httpcode != 407)) + connclose(conn, "Negotiate transfer completed"); Curl_cleanup_negotiate(data); + } #endif /* set the proper values (possibly modified on POST) */ - conn->fread_func = data->set.fread_func; /* restore */ - conn->fread_in = data->set.in; /* restore */ conn->seek_func = data->set.seek_func; /* restore */ conn->seek_client = data->set.seek_client; /* restore */ @@ -1448,13 +1470,27 @@ CURLcode Curl_http_done(struct connectdata *conn, return CURLE_OK; if(http->send_buffer) { - Curl_send_buffer *buff = http->send_buffer; - - free(buff->buffer); - free(buff); + Curl_add_buffer_free(http->send_buffer); http->send_buffer = NULL; /* clear the pointer */ } +#ifdef USE_NGHTTP2 + if(http->header_recvbuf) { + DEBUGF(infof(data, "free header_recvbuf!!\n")); + Curl_add_buffer_free(http->header_recvbuf); + http->header_recvbuf = NULL; /* clear the pointer */ + for(; http->push_headers_used > 0; --http->push_headers_used) { + free(http->push_headers[http->push_headers_used - 1]); + } + free(http->push_headers); + http->push_headers = NULL; + } + if(http->stream_id) { + nghttp2_session_set_stream_user_data(httpc->h2, http->stream_id, 0); + http->stream_id = 0; + } +#endif + if(HTTPREQ_POST_FORM == data->set.httpreq) { data->req.bytecount = http->readbytecount + http->writebytecount; @@ -1468,8 +1504,8 @@ CURLcode Curl_http_done(struct connectdata *conn, else if(HTTPREQ_PUT == data->set.httpreq) data->req.bytecount = http->readbytecount + http->writebytecount; - if(status != CURLE_OK) - return (status); + if(status) + return status; if(!premature && /* this check is pointless when DONE is called before the entire operation is complete */ @@ -1517,10 +1553,11 @@ static CURLcode expect100(struct SessionHandle *data, const char *ptr; data->state.expect100header = FALSE; /* default to false unless it is set to TRUE below */ - if(use_http_1_1plus(data, conn)) { - /* if not doing HTTP 1.0 or disabled explicitly, we add a Expect: - 100-continue to the headers which actually speeds up post operations - (as there is one packet coming back from the web server) */ + if(use_http_1_1plus(data, conn) && + (conn->httpversion != 20)) { + /* if not doing HTTP 1.0 or version 2, or disabled explicitly, we add an + Expect: 100-continue to the headers which actually speeds up post + operations (as there is one packet coming back from the web server) */ ptr = Curl_checkheaders(conn, "Expect:"); if(ptr) { data->state.expect100header = @@ -1529,7 +1566,7 @@ static CURLcode expect100(struct SessionHandle *data, else { result = Curl_add_bufferf(req_buffer, "Expect: 100-continue\r\n"); - if(result == CURLE_OK) + if(!result) data->state.expect100header = TRUE; } } @@ -1659,10 +1696,8 @@ CURLcode Curl_add_timecondition(struct SessionHandle *data, { const struct tm *tm; char *buf = data->state.buffer; - CURLcode result = CURLE_OK; struct tm keeptime; - - result = Curl_gmtime(data->set.timevalue, &keeptime); + CURLcode result = Curl_gmtime(data->set.timevalue, &keeptime); if(result) { failf(data, "Invalid TIMEVALUE"); return result; @@ -1713,8 +1748,8 @@ CURLcode Curl_add_timecondition(struct SessionHandle *data, */ CURLcode Curl_http(struct connectdata *conn, bool *done) { - struct SessionHandle *data=conn->data; - CURLcode result=CURLE_OK; + struct SessionHandle *data = conn->data; + CURLcode result = CURLE_OK; struct HTTP *http; const char *ppath = data->state.path; bool paste_ftp_userpwd = FALSE; @@ -1724,7 +1759,9 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) const char *ptr; const char *request; Curl_HttpReq httpreq = data->set.httpreq; +#if !defined(CURL_DISABLE_COOKIES) char *addcookies = NULL; +#endif curl_off_t included_body = 0; const char *httpstring; Curl_send_buffer *req_buffer; @@ -1738,8 +1775,9 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) if(conn->httpversion < 20) { /* unless the connection is re-used and already http2 */ - switch (conn->negnpn) { - case NPN_HTTP2: + switch(conn->negnpn) { + case CURL_HTTP_VERSION_2_0: + conn->httpversion = 20; /* we know we're on HTTP/2 now */ result = Curl_http2_init(conn); if(result) return result; @@ -1748,11 +1786,11 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) if(result) return result; - result = Curl_http2_switched(conn); + result = Curl_http2_switched(conn, NULL, 0); if(result) return result; break; - case NPN_HTTP1_1: + case CURL_HTTP_VERSION_1_1: /* continue with HTTP/1.1 when explicitly requested */ break; default: @@ -1770,10 +1808,8 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) http = data->req.protop; if(!data->state.this_is_a_follow) { - /* this is not a followed location, get the original host name */ - if(data->state.first_host) - /* Free to avoid leaking memory on multiple requests*/ - free(data->state.first_host); + /* Free to avoid leaking memory on multiple requests*/ + free(data->state.first_host); data->state.first_host = strdup(conn->host.name); if(!data->state.first_host) @@ -1817,7 +1853,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) it might have been used in the proxy connect, but if we have got a header with the user-agent string specified, we erase the previously made string here. */ - if(Curl_checkheaders(conn, "User-Agent:") && conn->allocptr.uagent) { + if(Curl_checkheaders(conn, "User-Agent:")) { free(conn->allocptr.uagent); conn->allocptr.uagent=NULL; } @@ -1846,8 +1882,10 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) else conn->allocptr.ref = NULL; +#if !defined(CURL_DISABLE_COOKIES) if(data->set.str[STRING_COOKIE] && !Curl_checkheaders(conn, "Cookie:")) addcookies = data->set.str[STRING_COOKIE]; +#endif if(!Curl_checkheaders(conn, "Accept-Encoding:") && data->set.str[STRING_ENCODING]) { @@ -1958,7 +1996,14 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) } #endif - conn->allocptr.host = NULL; + if(strcmp("Host:", ptr)) { + conn->allocptr.host = aprintf("%s\r\n", ptr); + if(!conn->allocptr.host) + return CURLE_OUT_OF_MEMORY; + } + else + /* when clearing the header */ + conn->allocptr.host = NULL; } else { /* When building Host: headers, we must put the host name within @@ -2153,8 +2198,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) if(((httpreq == HTTPREQ_GET) || (httpreq == HTTPREQ_HEAD)) && !Curl_checkheaders(conn, "Range:")) { /* if a line like this was already allocated, free the previous one */ - if(conn->allocptr.rangeline) - free(conn->allocptr.rangeline); + free(conn->allocptr.rangeline); conn->allocptr.rangeline = aprintf("Range: bytes=%s\r\n", data->state.range); } @@ -2162,8 +2206,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) !Curl_checkheaders(conn, "Content-Range:")) { /* if a line like this was already allocated, free the previous one */ - if(conn->allocptr.rangeline) - free(conn->allocptr.rangeline); + free(conn->allocptr.rangeline); if(data->set.set_resume_from < 0) { /* Upload resume was asked for, but we don't know the size of the @@ -2227,11 +2270,11 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) Curl_add_bufferf(req_buffer, "%s" /* ftp typecode (;type=x) */ " HTTP/%s\r\n" /* HTTP version */ + "%s" /* host */ "%s" /* proxyuserpwd */ "%s" /* userpwd */ "%s" /* range */ "%s" /* user agent */ - "%s" /* host */ "%s" /* accept */ "%s" /* TE: */ "%s" /* accept-encoding */ @@ -2241,6 +2284,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) ftp_typecode, httpstring, + (conn->allocptr.host?conn->allocptr.host:""), conn->allocptr.proxyuserpwd? conn->allocptr.proxyuserpwd:"", conn->allocptr.userpwd?conn->allocptr.userpwd:"", @@ -2250,7 +2294,6 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) *data->set.str[STRING_USERAGENT] && conn->allocptr.uagent)? conn->allocptr.uagent:"", - (conn->allocptr.host?conn->allocptr.host:""), http->p_accept?http->p_accept:"", conn->allocptr.te?conn->allocptr.te:"", (data->set.str[STRING_ENCODING] && @@ -2266,18 +2309,26 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) te ); + /* clear userpwd to avoid re-using credentials from re-used connections */ + Curl_safefree(conn->allocptr.userpwd); + /* - * Free userpwd now --- cannot reuse this for Negotiate and possibly NTLM - * with basic and digest, it will be freed anyway by the next request + * Free proxyuserpwd for Negotiate/NTLM. Cannot reuse as it is associated + * with the connection and shouldn't be repeated over it either. */ - - Curl_safefree (conn->allocptr.userpwd); - conn->allocptr.userpwd = NULL; + switch (data->state.authproxy.picked) { + case CURLAUTH_NEGOTIATE: + case CURLAUTH_NTLM: + case CURLAUTH_NTLM_WB: + Curl_safefree(conn->allocptr.proxyuserpwd); + break; + } if(result) return result; if(!(conn->handler->flags&PROTOPT_SSL) && + conn->httpversion != 20 && (data->set.httpversion == CURL_HTTP_VERSION_2_0)) { /* append HTTP2 upgrade magic stuff to the HTTP request if it isn't done over SSL */ @@ -2322,17 +2373,16 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) } Curl_cookie_freelist(store, FALSE); /* free the cookie list */ } - if(addcookies && (CURLE_OK == result)) { + if(addcookies && !result) { if(!count) result = Curl_add_bufferf(req_buffer, "Cookie: "); - if(CURLE_OK == result) { - result = Curl_add_bufferf(req_buffer, "%s%s", - count?"; ":"", + if(!result) { + result = Curl_add_bufferf(req_buffer, "%s%s", count?"; ":"", addcookies); count++; } } - if(count && (CURLE_OK == result)) + if(count && !result) result = Curl_add_buffer(req_buffer, "\r\n", 2); if(result) @@ -2384,14 +2434,14 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) /* Get the currently set callback function pointer and store that in the form struct since we might want the actual user-provided callback later - on. The conn->fread_func pointer itself will be changed for the + on. The data->set.fread_func pointer itself will be changed for the multipart case to the function that returns a multipart formatted stream. */ - http->form.fread_func = conn->fread_func; + http->form.fread_func = data->set.fread_func; /* Set the read function to read from the generated form data */ - conn->fread_func = (curl_read_callback)Curl_FormReader; - conn->fread_in = &http->form; + data->set.fread_func = (curl_read_callback)Curl_FormReader; + data->set.in = &http->form; http->sending = HTTPSEND_BODY; @@ -2511,8 +2561,8 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) postsize = 0; else { /* figure out the size of the postfields */ - postsize = (data->set.postfieldsize != -1)? - data->set.postfieldsize: + postsize = (data->state.infilesize != -1)? + data->state.infilesize: (data->set.postfields? (curl_off_t)strlen(data->set.postfields):-1); } @@ -2584,17 +2634,16 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) if(postsize) { /* Append the POST data chunky-style */ result = Curl_add_bufferf(req_buffer, "%x\r\n", (int)postsize); - if(CURLE_OK == result) { + if(!result) { result = Curl_add_buffer(req_buffer, data->set.postfields, (size_t)postsize); - if(CURLE_OK == result) - result = Curl_add_buffer(req_buffer, "\r\n", 2); + if(!result) + result = Curl_add_buffer(req_buffer, "\r\n", 2); included_body = postsize + 2; } } - if(CURLE_OK == result) - result = Curl_add_buffer(req_buffer, - "\x30\x0d\x0a\x0d\x0a", 5); + if(!result) + result = Curl_add_buffer(req_buffer, "\x30\x0d\x0a\x0d\x0a", 5); /* 0 CR LF CR LF */ included_body += 5; } @@ -2610,8 +2659,8 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) http->sending = HTTPSEND_BODY; - conn->fread_func = (curl_read_callback)readmoredata; - conn->fread_in = (void *)conn; + data->set.fread_func = (curl_read_callback)readmoredata; + data->set.in = (void *)conn; /* set the upload size to the progress meter */ Curl_pgrsSetUploadSize(data, http->postsize); @@ -2636,7 +2685,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) return result; } - else if(data->set.postfieldsize) { + else if(data->state.infilesize) { /* set the upload size to the progress meter */ Curl_pgrsSetUploadSize(data, postsize?postsize:-1); @@ -2997,10 +3046,12 @@ CURLcode Curl_http_readwrite_headers(struct SessionHandle *data, infof(data, "Received 101\n"); k->upgr101 = UPGR101_RECEIVED; - /* switch to http2 now */ - result = Curl_http2_switched(conn); + /* switch to http2 now. The bytes after response headers + are also processed here, otherwise they are lost. */ + result = Curl_http2_switched(conn, k->str, *nread); if(result) return result; + *nread = 0; } break; default: @@ -3025,6 +3076,19 @@ CURLcode Curl_http_readwrite_headers(struct SessionHandle *data, } } + /* At this point we have some idea about the fate of the connection. + If we are closing the connection it may result auth failure. */ +#if defined(USE_NTLM) + if(conn->bits.close && + (((data->req.httpcode == 401) && + (conn->ntlm.state == NTLMSTATE_TYPE2)) || + ((data->req.httpcode == 407) && + (conn->proxyntlm.state == NTLMSTATE_TYPE2)))) { + infof(data, "Connection closure while negotiating auth (HTTP 1.0?)\n"); + data->state.authproblem = TRUE; + } +#endif + /* * When all the headers have been parsed, see if we should give * up and return an error. @@ -3203,13 +3267,26 @@ CURLcode Curl_http_readwrite_headers(struct SessionHandle *data, #endif /* CURL_DOES_CONVERSIONS */ if(conn->handler->protocol & PROTO_FAMILY_HTTP) { + /* + * https://tools.ietf.org/html/rfc7230#section-3.1.2 + * + * The reponse code is always a three-digit number in HTTP as the spec + * says. We try to allow any number here, but we cannot make + * guarantees on future behaviors since it isn't within the protocol. + */ nc = sscanf(HEADER1, - " HTTP/%d.%d %3d", + " HTTP/%d.%d %d", &httpversion_major, &conn->httpversion, &k->httpcode); if(nc==3) { conn->httpversion += 10 * httpversion_major; + + if(k->upgr101 == UPGR101_RECEIVED) { + /* supposedly upgraded to http2 now */ + if(conn->httpversion != 20) + infof(data, "Lying server, not serving HTTP/2\n"); + } } else { /* this is the real world, not a Nirvana @@ -3287,20 +3364,25 @@ CURLcode Curl_http_readwrite_headers(struct SessionHandle *data, infof(data, "HTTP 1.0, assume close after body\n"); connclose(conn, "HTTP/1.0 close after body"); } + else if(conn->httpversion == 20 || + (k->upgr101 == UPGR101_REQUESTED && k->httpcode == 101)) { + DEBUGF(infof(data, "HTTP/2 found, allow multiplexing\n")); + + /* HTTP/2 cannot blacklist multiplexing since it is a core + functionality of the protocol */ + conn->bundle->multiuse = BUNDLE_MULTIPLEX; + } else if(conn->httpversion >= 11 && !conn->bits.close) { - struct connectbundle *cb_ptr; - /* If HTTP version is >= 1.1 and connection is persistent server supports pipelining. */ DEBUGF(infof(data, "HTTP 1.1 or later with persistent connection, " "pipelining supported\n")); /* Activate pipelining if needed */ - cb_ptr = conn->bundle; - if(cb_ptr) { + if(conn->bundle) { if(!Curl_pipeline_site_blacklisted(data, conn)) - cb_ptr->server_supports_pipelining = TRUE; + conn->bundle->multiuse = BUNDLE_PIPELINING; } } @@ -3379,14 +3461,17 @@ CURLcode Curl_http_readwrite_headers(struct SessionHandle *data, } } else if(checkprefix("Server:", k->p)) { - char *server_name = Curl_copy_header_value(k->p); - - /* Turn off pipelining if the server version is blacklisted */ - if(conn->bundle && conn->bundle->server_supports_pipelining) { - if(Curl_pipeline_server_blacklisted(data, server_name)) - conn->bundle->server_supports_pipelining = FALSE; + if(conn->httpversion < 20) { + /* only do this for non-h2 servers */ + char *server_name = Curl_copy_header_value(k->p); + + /* Turn off pipelining if the server version is blacklisted */ + if(conn->bundle && (conn->bundle->multiuse == BUNDLE_PIPELINING)) { + if(Curl_pipeline_server_blacklisted(data, server_name)) + conn->bundle->multiuse = BUNDLE_NO_MULTIUSE; + } + free(server_name); } - Curl_safefree(server_name); } else if((conn->httpversion == 10) && conn->bits.httpproxy && @@ -3483,14 +3568,6 @@ CURLcode Curl_http_readwrite_headers(struct SessionHandle *data, k->auto_decoding = GZIP; start += 6; } - else if(checkprefix("compress", start)) { - k->auto_decoding = COMPRESS; - start += 8; - } - else if(checkprefix("x-compress", start)) { - k->auto_decoding = COMPRESS; - start += 10; - } else /* unknown! */ break; @@ -3523,9 +3600,6 @@ CURLcode Curl_http_readwrite_headers(struct SessionHandle *data, else if(checkprefix("gzip", start) || checkprefix("x-gzip", start)) k->auto_decoding = GZIP; - else if(checkprefix("compress", start) - || checkprefix("x-compress", start)) - k->auto_decoding = COMPRESS; } else if(checkprefix("Content-Range:", k->p)) { /* Content-Range: bytes [num]- @@ -3591,7 +3665,7 @@ CURLcode Curl_http_readwrite_headers(struct SessionHandle *data, result = Curl_http_input_auth(conn, proxy, auth); - Curl_safefree(auth); + free(auth); if(result) return result; diff --git a/lib/http.h b/lib/http.h index 907755a..fe4f39b 100644 --- a/lib/http.h +++ b/lib/http.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -60,6 +60,7 @@ struct Curl_send_buffer { typedef struct Curl_send_buffer Curl_send_buffer; Curl_send_buffer *Curl_add_buffer_init(void); +void Curl_add_buffer_free(Curl_send_buffer *buff); CURLcode Curl_add_bufferf(Curl_send_buffer *in, const char *fmt, ...); CURLcode Curl_add_buffer(Curl_send_buffer *in, const void *inptr, size_t size); CURLcode Curl_add_buffer_send(Curl_send_buffer *in, @@ -152,42 +153,69 @@ struct HTTP { void *send_buffer; /* used if the request couldn't be sent in one chunk, points to an allocated send_buffer struct */ + +#ifdef USE_NGHTTP2 + /*********** for HTTP/2 we store stream-local data here *************/ + int32_t stream_id; /* stream we are interested in */ + + bool bodystarted; + /* We store non-final and final response headers here, per-stream */ + Curl_send_buffer *header_recvbuf; + size_t nread_header_recvbuf; /* number of bytes in header_recvbuf fed into + upper layer */ + int status_code; /* HTTP status code */ + const uint8_t *pausedata; /* pointer to data received in on_data_chunk */ + size_t pauselen; /* the number of bytes left in data */ + bool closed; /* TRUE on HTTP2 stream close */ + uint32_t error_code; /* HTTP/2 error code */ + + char *mem; /* points to a buffer in memory to store received data */ + size_t len; /* size of the buffer 'mem' points to */ + size_t memlen; /* size of data copied to mem */ + + const uint8_t *upload_mem; /* points to a buffer to read from */ + size_t upload_len; /* size of the buffer 'upload_mem' points to */ + curl_off_t upload_left; /* number of bytes left to upload */ + + char **push_headers; /* allocated array */ + size_t push_headers_used; /* number of entries filled in */ + size_t push_headers_alloc; /* number of entries allocated */ +#endif }; typedef int (*sending)(void); /* Curl_send */ typedef int (*recving)(void); /* Curl_recv */ +#ifdef USE_NGHTTP2 +/* h2 settings for this connection */ +struct h2settings { + uint32_t max_concurrent_streams; + bool enable_push; +}; +#endif + + struct http_conn { #ifdef USE_NGHTTP2 #define H2_BINSETTINGS_LEN 80 nghttp2_session *h2; uint8_t binsettings[H2_BINSETTINGS_LEN]; size_t binlen; /* length of the binsettings data */ - char *mem; /* points to a buffer in memory to store */ - size_t len; /* size of the buffer 'mem' points to */ - bool bodystarted; sending send_underlying; /* underlying send Curl_send callback */ recving recv_underlying; /* underlying recv Curl_recv callback */ - bool closed; /* TRUE on HTTP2 stream close */ - Curl_send_buffer *header_recvbuf; /* store response headers. We - store non-final and final - response headers into it. */ - size_t nread_header_recvbuf; /* number of bytes in header_recvbuf - fed into upper layer */ - int32_t stream_id; /* stream we are interested in */ - const uint8_t *data; /* pointer to data chunk, received in - on_data_chunk */ - size_t datalen; /* the number of bytes left in data */ char *inbuf; /* buffer to receive data from underlying socket */ + size_t inbuflen; /* number of bytes filled in inbuf */ + size_t nread_inbuf; /* number of bytes read from in inbuf */ /* We need separate buffer for transmission and reception because we may call nghttp2_session_send() after the nghttp2_session_mem_recv() but mem buffer is still not full. In this case, we wrongly sends the content of mem buffer if we share them for both cases. */ - const uint8_t *upload_mem; /* points to a buffer to read from */ - size_t upload_len; /* size of the buffer 'upload_mem' points to */ - size_t upload_left; /* number of bytes left to upload */ - int status_code; /* HTTP status code */ + int32_t pause_stream_id; /* stream ID which paused + nghttp2_session_mem_recv */ + + /* this is a hash of all individual streams (SessionHandle structs) */ + struct h2settings settings; #else int unused; /* prevent a compiler warning */ #endif diff --git a/lib/http2.c b/lib/http2.c index 604514d..0024add 100644 --- a/lib/http2.c +++ b/lib/http2.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -23,22 +23,24 @@ #include "curl_setup.h" #ifdef USE_NGHTTP2 -#define _MPRINTF_REPLACE -#include - +#include "curl_printf.h" #include #include "urldata.h" #include "http2.h" #include "http.h" #include "sendf.h" #include "curl_base64.h" -#include "curl_memory.h" #include "rawstr.h" #include "multiif.h" +#include "conncache.h" +#include "url.h" -/* include memdebug.h last */ +/* The last #include files should be: */ +#include "curl_memory.h" #include "memdebug.h" +#define MIN(x,y) ((x)<(y)?(x):(y)) + #if (NGHTTP2_VERSION_NUM < 0x000600) #error too old nghttp2 version, upgrade! #endif @@ -50,7 +52,7 @@ static int http2_perform_getsock(const struct connectdata *conn, sockets */ int numsocks) { - const struct http_conn *httpc = &conn->proto.httpc; + const struct http_conn *c = &conn->proto.httpc; int bitmap = GETSOCK_BLANK; (void)numsocks; @@ -58,10 +60,10 @@ static int http2_perform_getsock(const struct connectdata *conn, because of renegotiation. */ sock[0] = conn->sock[FIRSTSOCKET]; - if(nghttp2_session_want_read(httpc->h2)) + if(nghttp2_session_want_read(c->h2)) bitmap |= GETSOCK_READSOCK(FIRSTSOCKET); - if(nghttp2_session_want_write(httpc->h2)) + if(nghttp2_session_want_write(c->h2)) bitmap |= GETSOCK_WRITESOCK(FIRSTSOCKET); return bitmap; @@ -78,23 +80,54 @@ static int http2_getsock(struct connectdata *conn, static CURLcode http2_disconnect(struct connectdata *conn, bool dead_connection) { - struct http_conn *httpc = &conn->proto.httpc; + struct HTTP *http = conn->data->req.protop; + struct http_conn *c = &conn->proto.httpc; (void)dead_connection; - infof(conn->data, "HTTP/2 DISCONNECT starts now\n"); - - nghttp2_session_del(httpc->h2); + DEBUGF(infof(conn->data, "HTTP/2 DISCONNECT starts now\n")); - Curl_safefree(httpc->header_recvbuf->buffer); - Curl_safefree(httpc->header_recvbuf); + nghttp2_session_del(c->h2); + Curl_safefree(c->inbuf); - Curl_safefree(httpc->inbuf); + if(http) { + Curl_add_buffer_free(http->header_recvbuf); + http->header_recvbuf = NULL; /* clear the pointer */ + for(; http->push_headers_used > 0; --http->push_headers_used) { + free(http->push_headers[http->push_headers_used - 1]); + } + free(http->push_headers); + http->push_headers = NULL; + } - infof(conn->data, "HTTP/2 DISCONNECT done\n"); + DEBUGF(infof(conn->data, "HTTP/2 DISCONNECT done\n")); return CURLE_OK; } +/* called from Curl_http_setup_conn */ +void Curl_http2_setup_req(struct SessionHandle *data) +{ + struct HTTP *http = data->req.protop; + + http->nread_header_recvbuf = 0; + http->bodystarted = FALSE; + http->status_code = -1; + http->pausedata = NULL; + http->pauselen = 0; + http->error_code = NGHTTP2_NO_ERROR; + http->closed = FALSE; + http->mem = data->state.buffer; + http->len = BUFSIZE; + http->memlen = 0; +} + +/* called from Curl_http_setup_conn */ +void Curl_http2_setup_conn(struct connectdata *conn) +{ + conn->proto.httpc.settings.max_concurrent_streams = + DEFAULT_MAX_CONCURRENT_STREAMS; +} + /* * HTTP2 handler interface. This isn't added to the general list of protocols * but will be used at run-time when the protocol is dynamically switched from @@ -104,7 +137,7 @@ const struct Curl_handler Curl_handler_http2 = { "HTTP2", /* scheme */ ZERO_NULL, /* setup_connection */ Curl_http, /* do_it */ - ZERO_NULL, /* done */ + Curl_http_done, /* done */ ZERO_NULL, /* do_more */ ZERO_NULL, /* connect_it */ ZERO_NULL, /* connecting */ @@ -124,7 +157,7 @@ const struct Curl_handler Curl_handler_http2_ssl = { "HTTP2", /* scheme */ ZERO_NULL, /* setup_connection */ Curl_http, /* do_it */ - ZERO_NULL, /* done */ + Curl_http_done, /* done */ ZERO_NULL, /* do_more */ ZERO_NULL, /* connect_it */ ZERO_NULL, /* connecting */ @@ -160,17 +193,17 @@ static ssize_t send_callback(nghttp2_session *h2, void *userp) { struct connectdata *conn = (struct connectdata *)userp; - struct http_conn *httpc = &conn->proto.httpc; + struct http_conn *c = &conn->proto.httpc; ssize_t written; - CURLcode rc; + CURLcode result = CURLE_OK; + (void)h2; (void)flags; - rc = 0; - written = ((Curl_send*)httpc->send_underlying)(conn, FIRSTSOCKET, - data, length, &rc); + written = ((Curl_send*)c->send_underlying)(conn, FIRSTSOCKET, + data, length, &result); - if(rc == CURLE_AGAIN) { + if(result == CURLE_AGAIN) { return NGHTTP2_ERR_WOULDBLOCK; } @@ -185,25 +218,205 @@ static ssize_t send_callback(nghttp2_session *h2, return written; } + +/* We pass a pointer to this struct in the push callback, but the contents of + the struct are hidden from the user. */ +struct curl_pushheaders { + struct SessionHandle *data; + const nghttp2_push_promise *frame; +}; + +/* + * push header access function. Only to be used from within the push callback + */ +char *curl_pushheader_bynum(struct curl_pushheaders *h, size_t num) +{ + /* Verify that we got a good easy handle in the push header struct, mostly to + detect rubbish input fast(er). */ + if(!h || !GOOD_EASY_HANDLE(h->data)) + return NULL; + else { + struct HTTP *stream = h->data->req.protop; + if(num < stream->push_headers_used) + return stream->push_headers[num]; + } + return NULL; +} + +/* + * push header access function. Only to be used from within the push callback + */ +char *curl_pushheader_byname(struct curl_pushheaders *h, const char *header) +{ + /* Verify that we got a good easy handle in the push header struct, + mostly to detect rubbish input fast(er). Also empty header name + is just a rubbish too. We have to allow ":" at the beginning of + the header, but header == ":" must be rejected. If we have ':' in + the middle of header, it could be matched in middle of the value, + this is because we do prefix match.*/ + if(!h || !GOOD_EASY_HANDLE(h->data) || !header || !header[0] || + Curl_raw_equal(header, ":") || strchr(header + 1, ':')) + return NULL; + else { + struct HTTP *stream = h->data->req.protop; + size_t len = strlen(header); + size_t i; + for(i=0; ipush_headers_used; i++) { + if(!strncmp(header, stream->push_headers[i], len)) { + /* sub-match, make sure that it us followed by a colon */ + if(stream->push_headers[i][len] != ':') + continue; + return &stream->push_headers[i][len+1]; + } + } + } + return NULL; +} + +static CURL *duphandle(struct SessionHandle *data) +{ + struct SessionHandle *second = curl_easy_duphandle(data); + if(second) { + /* setup the request struct */ + struct HTTP *http = calloc(1, sizeof(struct HTTP)); + if(!http) { + (void)Curl_close(second); + second = NULL; + } + else { + second->req.protop = http; + http->header_recvbuf = Curl_add_buffer_init(); + if(!http->header_recvbuf) { + free(http); + (void)Curl_close(second); + second = NULL; + } + else + Curl_http2_setup_req(second); + } + } + return second; +} + + +static int push_promise(struct SessionHandle *data, + struct connectdata *conn, + const nghttp2_push_promise *frame) +{ + int rv; + DEBUGF(infof(data, "PUSH_PROMISE received, stream %u!\n", + frame->promised_stream_id)); + if(data->multi->push_cb) { + struct HTTP *stream; + struct curl_pushheaders heads; + CURLMcode rc; + struct http_conn *httpc; + size_t i; + /* clone the parent */ + CURL *newhandle = duphandle(data); + if(!newhandle) { + infof(data, "failed to duplicate handle\n"); + rv = 1; /* FAIL HARD */ + goto fail; + } + + heads.data = data; + heads.frame = frame; + /* ask the application */ + DEBUGF(infof(data, "Got PUSH_PROMISE, ask application!\n")); + + stream = data->req.protop; + if(!stream) { + failf(data, "Internal NULL stream!\n"); + rv = 1; + goto fail; + } + + rv = data->multi->push_cb(data, newhandle, + stream->push_headers_used, &heads, + data->multi->push_userp); + + /* free the headers again */ + for(i=0; ipush_headers_used; i++) + free(stream->push_headers[i]); + free(stream->push_headers); + stream->push_headers = NULL; + + if(rv) { + /* denied, kill off the new handle again */ + (void)Curl_close(newhandle); + goto fail; + } + + /* approved, add to the multi handle and immediately switch to PERFORM + state with the given connection !*/ + rc = Curl_multi_add_perform(data->multi, newhandle, conn); + if(rc) { + infof(data, "failed to add handle to multi\n"); + Curl_close(newhandle); + rv = 1; + goto fail; + } + + httpc = &conn->proto.httpc; + nghttp2_session_set_stream_user_data(httpc->h2, + frame->promised_stream_id, newhandle); + } + else { + DEBUGF(infof(data, "Got PUSH_PROMISE, ignore it!\n")); + rv = 1; + } + fail: + return rv; +} + static int on_frame_recv(nghttp2_session *session, const nghttp2_frame *frame, void *userp) { - struct connectdata *conn = (struct connectdata *)userp; - struct http_conn *c = &conn->proto.httpc; + struct connectdata *conn = NULL; + struct http_conn *httpc = NULL; + struct SessionHandle *data_s = NULL; + struct HTTP *stream = NULL; + static int lastStream = -1; int rv; size_t left, ncopy; + int32_t stream_id = frame->hd.stream_id; - (void)session; - (void)frame; - infof(conn->data, "on_frame_recv() was called with header %x\n", - frame->hd.type); + (void)userp; + + if(!stream_id) { + /* stream ID zero is for connection-oriented stuff */ + return 0; + } + data_s = nghttp2_session_get_stream_user_data(session, + frame->hd.stream_id); + if(lastStream != frame->hd.stream_id) { + lastStream = frame->hd.stream_id; + } + if(!data_s) { + DEBUGF(infof(conn->data, + "No SessionHandle associated with stream: %x\n", + stream_id)); + return 0; + } + + stream = data_s->req.protop; + if(!stream) + return NGHTTP2_ERR_CALLBACK_FAILURE; + + DEBUGF(infof(data_s, "on_frame_recv() header %x stream %x\n", + frame->hd.type, stream_id)); + + conn = data_s->easy_conn; + assert(conn); + assert(conn->data == data_s); + httpc = &conn->proto.httpc; switch(frame->hd.type) { case NGHTTP2_DATA: - /* If body started, then receiving DATA is illegal. */ - if(!c->bodystarted) { + /* If body started on this stream, then receiving DATA is illegal. */ + if(!stream->bodystarted) { rv = nghttp2_submit_rst_stream(session, NGHTTP2_FLAG_NONE, - frame->hd.stream_id, - NGHTTP2_PROTOCOL_ERROR); + stream_id, NGHTTP2_PROTOCOL_ERROR); if(nghttp2_is_fatal(rv)) { return NGHTTP2_ERR_CALLBACK_FAILURE; @@ -214,74 +427,96 @@ static int on_frame_recv(nghttp2_session *session, const nghttp2_frame *frame, if(frame->headers.cat == NGHTTP2_HCAT_REQUEST) break; - if(c->bodystarted) { - /* Only valid HEADERS after body started is trailer header, - which is not fully supported in this code. If HEADERS is not - trailer, then it is a PROTOCOL_ERROR. */ - if((frame->hd.flags & NGHTTP2_FLAG_END_STREAM) == 0) { - rv = nghttp2_submit_rst_stream(session, NGHTTP2_FLAG_NONE, - frame->hd.stream_id, - NGHTTP2_PROTOCOL_ERROR); - - if(nghttp2_is_fatal(rv)) { - return NGHTTP2_ERR_CALLBACK_FAILURE; - } - } + if(stream->bodystarted) { + /* Only valid HEADERS after body started is trailer HEADERS. We + ignores trailer HEADERS for now. nghttp2 guarantees that it + has END_STREAM flag set. */ break; } - if(c->status_code == -1) { - /* No :status header field means PROTOCOL_ERROR. */ - rv = nghttp2_submit_rst_stream(session, NGHTTP2_FLAG_NONE, - frame->hd.stream_id, - NGHTTP2_PROTOCOL_ERROR); - - if(nghttp2_is_fatal(rv)) { - return NGHTTP2_ERR_CALLBACK_FAILURE; - } - - break; - } + /* nghttp2 guarantees that :status is received, and we store it to + stream->status_code */ + DEBUGASSERT(stream->status_code != -1); /* Only final status code signals the end of header */ - if(c->status_code / 100 != 1) { - c->bodystarted = TRUE; + if(stream->status_code / 100 != 1) { + stream->bodystarted = TRUE; + stream->status_code = -1; } - c->status_code = -1; + Curl_add_buffer(stream->header_recvbuf, "\r\n", 2); - Curl_add_buffer(c->header_recvbuf, "\r\n", 2); + left = stream->header_recvbuf->size_used - stream->nread_header_recvbuf; + ncopy = MIN(stream->len, left); + + memcpy(&stream->mem[stream->memlen], + stream->header_recvbuf->buffer + stream->nread_header_recvbuf, + ncopy); + stream->nread_header_recvbuf += ncopy; - left = c->header_recvbuf->size_used - c->nread_header_recvbuf; - ncopy = c->len < left ? c->len : left; + DEBUGF(infof(data_s, "Store %zu bytes headers from stream %u at %p\n", + ncopy, stream_id, stream->mem)); - memcpy(c->mem, c->header_recvbuf->buffer + c->nread_header_recvbuf, ncopy); - c->nread_header_recvbuf += ncopy; + stream->len -= ncopy; + stream->memlen += ncopy; - c->mem += ncopy; - c->len -= ncopy; + data_s->state.drain++; + Curl_expire(data_s, 1); break; case NGHTTP2_PUSH_PROMISE: - rv = nghttp2_submit_rst_stream(session, NGHTTP2_FLAG_NONE, - frame->push_promise.promised_stream_id, - NGHTTP2_CANCEL); - if(nghttp2_is_fatal(rv)) { - return rv; + rv = push_promise(data_s, conn, &frame->push_promise); + if(rv) { /* deny! */ + rv = nghttp2_submit_rst_stream(session, NGHTTP2_FLAG_NONE, + frame->push_promise.promised_stream_id, + NGHTTP2_CANCEL); + if(nghttp2_is_fatal(rv)) { + return rv; + } } break; + case NGHTTP2_SETTINGS: + { + uint32_t max_conn = httpc->settings.max_concurrent_streams; + DEBUGF(infof(conn->data, "Got SETTINGS for stream %u!\n", stream_id)); + httpc->settings.max_concurrent_streams = + nghttp2_session_get_remote_settings( + session, NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS); + httpc->settings.enable_push = + nghttp2_session_get_remote_settings( + session, NGHTTP2_SETTINGS_ENABLE_PUSH); + DEBUGF(infof(conn->data, "MAX_CONCURRENT_STREAMS == %d\n", + httpc->settings.max_concurrent_streams)); + DEBUGF(infof(conn->data, "ENABLE_PUSH == %s\n", + httpc->settings.enable_push?"TRUE":"false")); + if(max_conn != httpc->settings.max_concurrent_streams) { + /* only signal change if the value actually changed */ + infof(conn->data, + "Connection state changed (MAX_CONCURRENT_STREAMS updated)!\n"); + Curl_multi_connchanged(conn->data->multi); + } + } + break; + default: + DEBUGF(infof(conn->data, "Got frame type %x for stream %u!\n", + frame->hd.type, stream_id)); + break; } return 0; } static int on_invalid_frame_recv(nghttp2_session *session, const nghttp2_frame *frame, - uint32_t error_code, void *userp) + int lib_error_code, void *userp) { - struct connectdata *conn = (struct connectdata *)userp; - (void)session; - (void)frame; - infof(conn->data, "on_invalid_frame_recv() was called, error_code = %d\n", - error_code); + struct SessionHandle *data_s = NULL; + (void)userp; + + data_s = nghttp2_session_get_stream_user_data(session, frame->hd.stream_id); + if(data_s) { + DEBUGF(infof(data_s, + "on_invalid_frame_recv() was called, error=%d:%s\n", + lib_error_code, nghttp2_strerror(lib_error_code))); + } return 0; } @@ -289,30 +524,50 @@ static int on_data_chunk_recv(nghttp2_session *session, uint8_t flags, int32_t stream_id, const uint8_t *data, size_t len, void *userp) { - struct connectdata *conn = (struct connectdata *)userp; - struct http_conn *c = &conn->proto.httpc; + struct HTTP *stream; + struct SessionHandle *data_s; size_t nread; (void)session; (void)flags; (void)data; - infof(conn->data, "on_data_chunk_recv() " - "len = %u, stream = %x\n", len, stream_id); + (void)userp; - if(stream_id != c->stream_id) { - return 0; - } + DEBUGASSERT(stream_id); /* should never be a zero stream ID here */ - nread = c->len < len ? c->len : len; - memcpy(c->mem, data, nread); + /* get the stream from the hash based on Stream ID */ + data_s = nghttp2_session_get_stream_user_data(session, stream_id); + if(!data_s) + /* Receiving a Stream ID not in the hash should not happen, this is an + internal error more than anything else! */ + return NGHTTP2_ERR_CALLBACK_FAILURE; + + stream = data_s->req.protop; + if(!stream) + return NGHTTP2_ERR_CALLBACK_FAILURE; - c->mem += nread; - c->len -= nread; + nread = MIN(stream->len, len); + memcpy(&stream->mem[stream->memlen], data, nread); - infof(conn->data, "%zu data written\n", nread); + stream->len -= nread; + stream->memlen += nread; + + data_s->state.drain++; + Curl_expire(data_s, 1); /* TODO: fix so that this can be set to 0 for + immediately? */ + + DEBUGF(infof(data_s, "%zu data received for stream %u " + "(%zu left in buffer %p, total %zu)\n", + nread, stream_id, + stream->len, stream->mem, + stream->memlen)); if(nread < len) { - c->data = data + nread; - c->datalen = len - nread; + stream->pausedata = data + nread; + stream->pauselen = len - nread; + DEBUGF(infof(data_s, "NGHTTP2_ERR_PAUSE - %zu bytes out of buffer" + ", stream %u\n", + len - nread, stream_id)); + data_s->easy_conn->proto.httpc.pause_stream_id = stream_id; return NGHTTP2_ERR_PAUSE; } return 0; @@ -322,59 +577,89 @@ static int before_frame_send(nghttp2_session *session, const nghttp2_frame *frame, void *userp) { - struct connectdata *conn = (struct connectdata *)userp; - (void)session; - (void)frame; - infof(conn->data, "before_frame_send() was called\n"); + struct SessionHandle *data_s; + (void)userp; + + data_s = nghttp2_session_get_stream_user_data(session, frame->hd.stream_id); + if(data_s) { + DEBUGF(infof(data_s, "before_frame_send() was called\n")); + } + return 0; } static int on_frame_send(nghttp2_session *session, const nghttp2_frame *frame, void *userp) { - struct connectdata *conn = (struct connectdata *)userp; - (void)session; - (void)frame; - infof(conn->data, "on_frame_send() was called\n"); + struct SessionHandle *data_s; + (void)userp; + + data_s = nghttp2_session_get_stream_user_data(session, frame->hd.stream_id); + if(data_s) { + DEBUGF(infof(data_s, "on_frame_send() was called, length = %zd\n", + frame->hd.length)); + } return 0; } static int on_frame_not_send(nghttp2_session *session, const nghttp2_frame *frame, int lib_error_code, void *userp) { - struct connectdata *conn = (struct connectdata *)userp; - (void)session; - (void)frame; - infof(conn->data, "on_frame_not_send() was called, lib_error_code = %d\n", - lib_error_code); + struct SessionHandle *data_s; + (void)userp; + + data_s = nghttp2_session_get_stream_user_data(session, frame->hd.stream_id); + if(data_s) { + DEBUGF(infof(data_s, + "on_frame_not_send() was called, lib_error_code = %d\n", + lib_error_code)); + } return 0; } static int on_stream_close(nghttp2_session *session, int32_t stream_id, uint32_t error_code, void *userp) { - struct connectdata *conn = (struct connectdata *)userp; - struct http_conn *c = &conn->proto.httpc; + struct SessionHandle *data_s; + struct HTTP *stream; (void)session; (void)stream_id; - infof(conn->data, "on_stream_close() was called, error_code = %d\n", - error_code); - - if(stream_id != c->stream_id) { - return 0; - } + (void)userp; + + if(stream_id) { + /* get the stream from the hash based on Stream ID, stream ID zero is for + connection-oriented stuff */ + data_s = nghttp2_session_get_stream_user_data(session, stream_id); + if(!data_s) { + /* We could get stream ID not in the hash. For example, if we + decided to reject stream (e.g., PUSH_PROMISE). */ + return 0; + } + DEBUGF(infof(data_s, "on_stream_close(), error_code = %d, stream %u\n", + error_code, stream_id)); + stream = data_s->req.protop; + if(!stream) + return NGHTTP2_ERR_CALLBACK_FAILURE; - c->closed = TRUE; + stream->error_code = error_code; + stream->closed = TRUE; + /* remove the entry from the hash as the stream is now gone */ + nghttp2_session_set_stream_user_data(session, stream_id, 0); + DEBUGF(infof(data_s, "Removed stream %u hash!\n", stream_id)); + } return 0; } static int on_begin_headers(nghttp2_session *session, const nghttp2_frame *frame, void *userp) { - struct connectdata *conn = (struct connectdata *)userp; - (void)session; - (void)frame; - infof(conn->data, "on_begin_headers() was called\n"); + struct SessionHandle *data_s = NULL; + (void)userp; + + data_s = nghttp2_session_get_stream_user_data(session, frame->hd.stream_id); + if(data_s) { + DEBUGF(infof(data_s, "on_begin_headers() was called\n")); + } return 0; } @@ -405,8 +690,6 @@ static int decode_status_code(const uint8_t *value, size_t len) return res; } -static const char STATUS[] = ":status"; - /* frame->hd.type is either NGHTTP2_HEADERS or NGHTTP2_PUSH_PROMISE */ static int on_header(nghttp2_session *session, const nghttp2_frame *frame, const uint8_t *name, size_t namelen, @@ -414,93 +697,94 @@ static int on_header(nghttp2_session *session, const nghttp2_frame *frame, uint8_t flags, void *userp) { - struct connectdata *conn = (struct connectdata *)userp; - struct http_conn *c = &conn->proto.httpc; - int rv; - int goodname; - int goodheader; + struct HTTP *stream; + struct SessionHandle *data_s; + int32_t stream_id = frame->hd.stream_id; - (void)session; - (void)frame; (void)flags; + (void)userp; - if(frame->hd.stream_id != c->stream_id) { - return 0; + DEBUGASSERT(stream_id); /* should never be a zero stream ID here */ + + /* get the stream from the hash based on Stream ID */ + data_s = nghttp2_session_get_stream_user_data(session, stream_id); + if(!data_s) + /* Receiving a Stream ID not in the hash should not happen, this is an + internal error more than anything else! */ + return NGHTTP2_ERR_CALLBACK_FAILURE; + + stream = data_s->req.protop; + if(!stream) { + failf(data_s, "Internal NULL stream! 5\n"); + return NGHTTP2_ERR_CALLBACK_FAILURE; } - if(c->bodystarted) { + if(stream->bodystarted) /* Ignore trailer or HEADERS not mapped to HTTP semantics. The consequence is handled in on_frame_recv(). */ return 0; - } - goodname = nghttp2_check_header_name(name, namelen); - goodheader = nghttp2_check_header_value(value, valuelen); + /* Store received PUSH_PROMISE headers to be used when the subsequent + PUSH_PROMISE callback comes */ + if(frame->hd.type == NGHTTP2_PUSH_PROMISE) { + char *h; - if(!goodname || !goodheader) { - - infof(conn->data, "Detected bad incoming header %s%s, reset stream!\n", - goodname?"":"name", - goodheader?"":"value"); - - rv = nghttp2_submit_rst_stream(session, NGHTTP2_FLAG_NONE, - frame->hd.stream_id, - NGHTTP2_PROTOCOL_ERROR); - - if(nghttp2_is_fatal(rv)) { - return NGHTTP2_ERR_CALLBACK_FAILURE; + if(!stream->push_headers) { + stream->push_headers_alloc = 10; + stream->push_headers = malloc(stream->push_headers_alloc * + sizeof(char *)); + stream->push_headers_used = 0; } - - return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE; - } - - if(namelen == sizeof(":status") - 1 && - memcmp(STATUS, name, namelen) == 0) { - - /* :status must appear exactly once. */ - if(c->status_code != -1 || - (c->status_code = decode_status_code(value, valuelen)) == -1) { - - rv = nghttp2_submit_rst_stream(session, NGHTTP2_FLAG_NONE, - frame->hd.stream_id, - NGHTTP2_PROTOCOL_ERROR); - if(nghttp2_is_fatal(rv)) { - return NGHTTP2_ERR_CALLBACK_FAILURE; + else if(stream->push_headers_used == + stream->push_headers_alloc) { + char **headp; + stream->push_headers_alloc *= 2; + headp = realloc(stream->push_headers, + stream->push_headers_alloc * sizeof(char *)); + if(!headp) { + free(stream->push_headers); + stream->push_headers = NULL; + return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE; } - - return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE; + stream->push_headers = headp; } - - Curl_add_buffer(c->header_recvbuf, "HTTP/2.0 ", 9); - Curl_add_buffer(c->header_recvbuf, value, valuelen); - Curl_add_buffer(c->header_recvbuf, "\r\n", 2); - + h = aprintf("%s:%s", name, value); + if(h) + stream->push_headers[stream->push_headers_used++] = h; return 0; } - else { - /* Here we are sure that namelen > 0 because of - nghttp2_check_header_name(). Pseudo header other than :status - is illegal. */ - if(c->status_code == -1 || name[0] == ':') { - rv = nghttp2_submit_rst_stream(session, NGHTTP2_FLAG_NONE, - frame->hd.stream_id, - NGHTTP2_PROTOCOL_ERROR); - if(nghttp2_is_fatal(rv)) { - return NGHTTP2_ERR_CALLBACK_FAILURE; - } - return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE; - } + if(namelen == sizeof(":status") - 1 && + memcmp(":status", name, namelen) == 0) { + /* nghttp2 guarantees :status is received first and only once, and + value is 3 digits status code, and decode_status_code always + succeeds. */ + stream->status_code = decode_status_code(value, valuelen); + DEBUGASSERT(stream->status_code != -1); + + Curl_add_buffer(stream->header_recvbuf, "HTTP/2.0 ", 9); + Curl_add_buffer(stream->header_recvbuf, value, valuelen); + Curl_add_buffer(stream->header_recvbuf, "\r\n", 2); + data_s->state.drain++; + Curl_expire(data_s, 1); + + DEBUGF(infof(data_s, "h2 status: HTTP/2 %03d\n", + stream->status_code)); + return 0; + } - /* convert to a HTTP1-style header */ - Curl_add_buffer(c->header_recvbuf, name, namelen); - Curl_add_buffer(c->header_recvbuf, ":", 1); - Curl_add_buffer(c->header_recvbuf, value, valuelen); - Curl_add_buffer(c->header_recvbuf, "\r\n", 2); + /* nghttp2 guarantees that namelen > 0, and :status was already + received, and this is not pseudo-header field . */ + /* convert to a HTTP1-style header */ + Curl_add_buffer(stream->header_recvbuf, name, namelen); + Curl_add_buffer(stream->header_recvbuf, ":", 1); + Curl_add_buffer(stream->header_recvbuf, value, valuelen); + Curl_add_buffer(stream->header_recvbuf, "\r\n", 2); + data_s->state.drain++; + Curl_expire(data_s, 1); - infof(conn->data, "got http2 header: %.*s: %.*s\n", - namelen, name, valuelen, value); - } + DEBUGF(infof(data_s, "h2 header: %.*s: %.*s\n", namelen, name, valuelen, + value)); return 0; /* 0 is successful */ } @@ -512,26 +796,45 @@ static ssize_t data_source_read_callback(nghttp2_session *session, nghttp2_data_source *source, void *userp) { - struct connectdata *conn = (struct connectdata *)userp; - struct http_conn *c = &conn->proto.httpc; + struct SessionHandle *data_s; + struct HTTP *stream = NULL; size_t nread; - (void)session; - (void)stream_id; (void)source; + (void)userp; + + if(stream_id) { + /* get the stream from the hash based on Stream ID, stream ID zero is for + connection-oriented stuff */ + data_s = nghttp2_session_get_stream_user_data(session, stream_id); + if(!data_s) + /* Receiving a Stream ID not in the hash should not happen, this is an + internal error more than anything else! */ + return NGHTTP2_ERR_CALLBACK_FAILURE; - nread = c->upload_len < length ? c->upload_len : length; + stream = data_s->req.protop; + if(!stream) + return NGHTTP2_ERR_CALLBACK_FAILURE; + } + else + return NGHTTP2_ERR_INVALID_ARGUMENT; + + nread = MIN(stream->upload_len, length); if(nread > 0) { - memcpy(buf, c->upload_mem, nread); - c->upload_mem += nread; - c->upload_len -= nread; - c->upload_left -= nread; + memcpy(buf, stream->upload_mem, nread); + stream->upload_mem += nread; + stream->upload_len -= nread; + stream->upload_left -= nread; } - if(c->upload_left == 0) + if(stream->upload_left == 0) *data_flags = 1; else if(nread == 0) return NGHTTP2_ERR_DEFERRED; + DEBUGF(infof(data_s, "data_source_read_callback: " + "returns %zu bytes stream %u\n", + nread, stream_id)); + return nread; } @@ -543,7 +846,7 @@ static nghttp2_settings_entry settings[] = { { NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE, NGHTTP2_INITIAL_WINDOW_SIZE }, }; -#define H2_BUFSIZE 4096 +#define H2_BUFSIZE 32768 /* * Initialize nghttp2 for a Curl connection @@ -595,8 +898,7 @@ CURLcode Curl_http2_init(struct connectdata *conn) nghttp2_session_callbacks_set_on_header_callback(callbacks, on_header); /* The nghttp2 session is not yet setup, do it */ - rc = nghttp2_session_client_new(&conn->proto.httpc.h2, - callbacks, conn); + rc = nghttp2_session_client_new(&conn->proto.httpc.h2, callbacks, conn); nghttp2_session_callbacks_del(callbacks); @@ -604,6 +906,11 @@ CURLcode Curl_http2_init(struct connectdata *conn) failf(conn->data, "Couldn't initialize nghttp2!"); return CURLE_OUT_OF_MEMORY; /* most likely at least */ } + + if(rc) { + failf(conn->data, "Couldn't init stream hash!"); + return CURLE_OUT_OF_MEMORY; /* most likely at least */ + } } return CURLE_OK; } @@ -630,14 +937,6 @@ CURLcode Curl_http2_request_upgrade(Curl_send_buffer *req, struct SingleRequest *k = &conn->data->req; uint8_t *binsettings = conn->proto.httpc.binsettings; - result = Curl_http2_init(conn); - if(result) - return result; - - result = Curl_http2_setup(conn); - if(result) - return result; - /* As long as we have a fixed set of settings, we don't have to dynamically * figure out the base64 strings since it'll always be the same. However, * the settings will likely not be fixed every time in the future. @@ -663,13 +962,32 @@ CURLcode Curl_http2_request_upgrade(Curl_send_buffer *req, "Upgrade: %s\r\n" "HTTP2-Settings: %s\r\n", NGHTTP2_CLEARTEXT_PROTO_VERSION_ID, base64); - Curl_safefree(base64); + free(base64); k->upgr101 = UPGR101_REQUESTED; return result; } +static ssize_t http2_handle_stream_close(struct http_conn *httpc, + struct SessionHandle *data, + struct HTTP *stream, CURLcode *err) { + if(httpc->pause_stream_id == stream->stream_id) { + httpc->pause_stream_id = 0; + } + /* Reset to FALSE to prevent infinite loop in readwrite_data + function. */ + stream->closed = FALSE; + if(stream->error_code != NGHTTP2_NO_ERROR) { + failf(data, "HTTP/2 stream %u was not closed cleanly: error_code = %d", + stream->stream_id, stream->error_code); + *err = CURLE_HTTP2; + return -1; + } + DEBUGF(infof(data, "http2_recv returns 0, http2_handle_stream_close\n")); + return 0; +} + /* * If the read would block (EWOULDBLOCK) we return -1. Otherwise we return * a regular CURLcode value. @@ -677,102 +995,188 @@ CURLcode Curl_http2_request_upgrade(Curl_send_buffer *req, static ssize_t http2_recv(struct connectdata *conn, int sockindex, char *mem, size_t len, CURLcode *err) { - CURLcode rc; + CURLcode result = CURLE_OK; ssize_t rv; ssize_t nread; struct http_conn *httpc = &conn->proto.httpc; + struct SessionHandle *data = conn->data; + struct HTTP *stream = data->req.protop; (void)sockindex; /* we always do HTTP2 on sockindex 0 */ - if(httpc->closed) { - /* Reset to FALSE to prevent infinite loop in readwrite_data - function. */ - httpc->closed = FALSE; - return 0; + /* If stream is closed, return 0 to signal the http routine to close + the connection. We need to handle stream closure here, + otherwise, we may be going to read from underlying connection, + and gets EAGAIN, and we will get stuck there. */ + if(stream->memlen == 0 && stream->closed) { + return http2_handle_stream_close(httpc, data, stream, err); } /* Nullify here because we call nghttp2_session_send() and they might refer to the old buffer. */ - httpc->upload_mem = NULL; - httpc->upload_len = 0; + stream->upload_mem = NULL; + stream->upload_len = 0; - if(httpc->bodystarted && - httpc->nread_header_recvbuf < httpc->header_recvbuf->size_used) { + /* + * At this point 'stream' is just in the SessionHandle the connection + * identifies as its owner at this time. + */ + + if(stream->bodystarted && + stream->nread_header_recvbuf < stream->header_recvbuf->size_used) { + /* If there is body data pending for this stream to return, do that */ size_t left = - httpc->header_recvbuf->size_used - httpc->nread_header_recvbuf; - size_t ncopy = len < left ? len : left; - memcpy(mem, httpc->header_recvbuf->buffer + httpc->nread_header_recvbuf, + stream->header_recvbuf->size_used - stream->nread_header_recvbuf; + size_t ncopy = MIN(len, left); + memcpy(mem, stream->header_recvbuf->buffer + stream->nread_header_recvbuf, ncopy); - httpc->nread_header_recvbuf += ncopy; + stream->nread_header_recvbuf += ncopy; + + infof(data, "http2_recv: Got %d bytes from header_recvbuf\n", + (int)ncopy); return ncopy; } - if(httpc->data) { - nread = len < httpc->datalen ? len : httpc->datalen; - memcpy(mem, httpc->data, nread); + infof(data, "http2_recv: %d bytes buffer at %p (stream %u)\n", + len, mem, stream->stream_id); + + if((data->state.drain) && stream->memlen) { + DEBUGF(infof(data, "http2_recv: DRAIN %zu bytes stream %u!! (%p => %p)\n", + stream->memlen, stream->stream_id, + stream->mem, mem)); + if(mem != stream->mem) { + /* if we didn't get the same buffer this time, we must move the data to + the beginning */ + memmove(mem, stream->mem, stream->memlen); + stream->len = len - stream->memlen; + stream->mem = mem; + } + } + else if(stream->pausedata) { + nread = MIN(len, stream->pauselen); + memcpy(mem, stream->pausedata, nread); + + stream->pausedata += nread; + stream->pauselen -= nread; - httpc->data += nread; - httpc->datalen -= nread; + infof(data, "%zu data bytes written\n", nread); + if(stream->pauselen == 0) { + DEBUGF(infof(data, "Unpaused by stream %u\n", stream->stream_id)); + assert(httpc->pause_stream_id == stream->stream_id); + httpc->pause_stream_id = 0; - infof(conn->data, "%zu data written\n", nread); - if(httpc->datalen == 0) { - httpc->data = NULL; - httpc->datalen = 0; + stream->pausedata = NULL; + stream->pauselen = 0; } + infof(data, "http2_recv: returns unpaused %zd bytes on stream %u\n", + nread, stream->stream_id); return nread; } + else if(httpc->pause_stream_id) { + /* If a stream paused nghttp2_session_mem_recv previously, and has + not processed all data, it still refers to the buffer in + nghttp2_session. If we call nghttp2_session_mem_recv(), we may + overwrite that buffer. To avoid that situation, just return + here with CURLE_AGAIN. This could be busy loop since data in + socket is not read. But it seems that usually streams are + notified with its drain property, and socket is read again + quickly. */ + *err = CURLE_AGAIN; + return -1; + } + else { + char *inbuf; + /* remember where to store incoming data for this stream and how big the + buffer is */ + stream->mem = mem; + stream->len = len; + stream->memlen = 0; + + if(httpc->inbuflen == 0) { + nread = ((Curl_recv *)httpc->recv_underlying)( + conn, FIRSTSOCKET, httpc->inbuf, H2_BUFSIZE, &result); + + if(result == CURLE_AGAIN) { + *err = result; + return -1; + } - conn->proto.httpc.mem = mem; - conn->proto.httpc.len = len; - - infof(conn->data, "http2_recv: %d bytes buffer\n", - conn->proto.httpc.len); + if(nread == -1) { + failf(data, "Failed receiving HTTP2 data"); + *err = result; + return 0; + } - rc = 0; - nread = ((Curl_recv*)httpc->recv_underlying)(conn, FIRSTSOCKET, - httpc->inbuf, H2_BUFSIZE, &rc); + if(nread == 0) { + failf(data, "Unexpected EOF"); + *err = CURLE_RECV_ERROR; + return -1; + } - if(rc == CURLE_AGAIN) { - *err = rc; - return -1; - } + DEBUGF(infof(data, "nread=%zd\n", nread)); - if(nread == -1) { - failf(conn->data, "Failed receiving HTTP2 data"); - *err = rc; - return 0; - } + httpc->inbuflen = nread; + inbuf = httpc->inbuf; + } + else { + nread = httpc->inbuflen - httpc->nread_inbuf; + inbuf = httpc->inbuf + httpc->nread_inbuf; - infof(conn->data, "nread=%zd\n", nread); - rv = nghttp2_session_mem_recv(httpc->h2, - (const uint8_t *)httpc->inbuf, nread); + DEBUGF(infof(data, "Use data left in connection buffer, nread=%zd\n", + nread)); + } + rv = nghttp2_session_mem_recv(httpc->h2, (const uint8_t *)inbuf, nread); - if(nghttp2_is_fatal((int)rv)) { - failf(conn->data, "nghttp2_session_mem_recv() returned %d:%s\n", - rv, nghttp2_strerror((int)rv)); - *err = CURLE_RECV_ERROR; - return 0; - } - infof(conn->data, "nghttp2_session_mem_recv() returns %zd\n", rv); - /* Always send pending frames in nghttp2 session, because - nghttp2_session_mem_recv() may queue new frame */ - rv = nghttp2_session_send(httpc->h2); - if(rv != 0) { - *err = CURLE_SEND_ERROR; - return 0; + if(nghttp2_is_fatal((int)rv)) { + failf(data, "nghttp2_session_mem_recv() returned %d:%s\n", + rv, nghttp2_strerror((int)rv)); + *err = CURLE_RECV_ERROR; + return 0; + } + DEBUGF(infof(data, "nghttp2_session_mem_recv() returns %zd\n", rv)); + if(nread == rv) { + DEBUGF(infof(data, "All data in connection buffer processed\n")); + httpc->inbuflen = 0; + httpc->nread_inbuf = 0; + } + else { + httpc->nread_inbuf += rv; + DEBUGF(infof(data, "%zu bytes left in connection buffer\n", + httpc->inbuflen - httpc->nread_inbuf)); + } + /* Always send pending frames in nghttp2 session, because + nghttp2_session_mem_recv() may queue new frame */ + rv = nghttp2_session_send(httpc->h2); + if(rv != 0) { + *err = CURLE_SEND_ERROR; + return 0; + } } - if(len != httpc->len) { - return len - conn->proto.httpc.len; + if(stream->memlen) { + ssize_t retlen = stream->memlen; + infof(data, "http2_recv: returns %zd for stream %u\n", + retlen, stream->stream_id); + stream->memlen = 0; + + if(httpc->pause_stream_id == stream->stream_id) { + /* data for this stream is returned now, but this stream caused a pause + already so we need it called again asap */ + DEBUGF(infof(data, "Data returned for PAUSED stream %u\n", + stream->stream_id)); + } + else + data->state.drain = 0; /* this stream is hereby drained */ + + return retlen; } /* If stream is closed, return 0 to signal the http routine to close the connection */ - if(httpc->closed) { - /* Reset to FALSE to prevent infinite loop in readwrite_data - function. */ - httpc->closed = FALSE; - return 0; + if(stream->closed) { + return http2_handle_stream_close(httpc, data, stream, err); } *err = CURLE_AGAIN; + DEBUGF(infof(data, "http2_recv returns AGAIN for stream %u\n", + stream->stream_id)); return -1; } @@ -791,6 +1195,7 @@ static ssize_t http2_send(struct connectdata *conn, int sockindex, */ int rv; struct http_conn *httpc = &conn->proto.httpc; + struct HTTP *stream = conn->data->req.protop; nghttp2_nv *nva; size_t nheader; size_t i; @@ -799,23 +1204,41 @@ static ssize_t http2_send(struct connectdata *conn, int sockindex, char *end; nghttp2_data_provider data_prd; int32_t stream_id; + nghttp2_session *h2 = httpc->h2; (void)sockindex; - infof(conn->data, "http2_send len=%zu\n", len); + DEBUGF(infof(conn->data, "http2_send len=%zu\n", len)); - if(httpc->stream_id != -1) { + if(stream->stream_id != -1) { /* If stream_id != -1, we have dispatched request HEADERS, and now are going to send or sending request body in DATA frame */ - httpc->upload_mem = mem; - httpc->upload_len = len; - nghttp2_session_resume_data(httpc->h2, httpc->stream_id); - rv = nghttp2_session_send(httpc->h2); + stream->upload_mem = mem; + stream->upload_len = len; + nghttp2_session_resume_data(h2, stream->stream_id); + rv = nghttp2_session_send(h2); if(nghttp2_is_fatal(rv)) { *err = CURLE_SEND_ERROR; return -1; } - return len - httpc->upload_len; + len -= stream->upload_len; + + /* Nullify here because we call nghttp2_session_send() and they + might refer to the old buffer. */ + stream->upload_mem = NULL; + stream->upload_len = 0; + + if(stream->upload_left) { + /* we are sure that we have more data to send here. Calling the + following API will make nghttp2_session_want_write() return + nonzero if remote window allows it, which then libcurl checks + socket is writable or not. See http2_perform_getsock(). */ + nghttp2_session_resume_data(h2, stream->stream_id); + } + + DEBUGF(infof(conn->data, "http2_send returns %zu for stream %u\n", len, + stream->stream_id)); + return len; } /* Calculate number of headers contained in [mem, mem + len) */ @@ -838,6 +1261,8 @@ static ssize_t http2_send(struct connectdata *conn, int sockindex, } /* Extract :method, :path from request line */ end = strchr(hdbuf, ' '); + if(!end) + goto fail; nva[0].name = (unsigned char *)":method"; nva[0].namelen = (uint16_t)strlen((char *)nva[0].name); nva[0].value = (unsigned char *)hdbuf; @@ -847,6 +1272,8 @@ static ssize_t http2_send(struct connectdata *conn, int sockindex, hdbuf = end + 1; end = strchr(hdbuf, ' '); + if(!end) + goto fail; nva[1].name = (unsigned char *)":path"; nva[1].namelen = (uint16_t)strlen((char *)nva[1].name); nva[1].value = (unsigned char *)hdbuf; @@ -863,13 +1290,16 @@ static ssize_t http2_send(struct connectdata *conn, int sockindex, nva[2].flags = NGHTTP2_NV_FLAG_NONE; hdbuf = strchr(hdbuf, 0x0a); + if(!hdbuf) + goto fail; ++hdbuf; authority_idx = 0; for(i = 3; i < nheader; ++i) { end = strchr(hdbuf, ':'); - assert(end); + if(!end) + goto fail; if(end - hdbuf == 4 && Curl_raw_nequal("host", hdbuf, 4)) { authority_idx = i; nva[i].name = (unsigned char *)":authority"; @@ -882,7 +1312,8 @@ static ssize_t http2_send(struct connectdata *conn, int sockindex, hdbuf = end + 1; for(; *hdbuf == ' '; ++hdbuf); end = strchr(hdbuf, 0x0d); - assert(end); + if(!end) + goto fail; nva[i].value = (unsigned char *)hdbuf; nva[i].valuelen = (uint16_t)(end - hdbuf); nva[i].flags = NGHTTP2_NV_FLAG_NONE; @@ -894,11 +1325,15 @@ static ssize_t http2_send(struct connectdata *conn, int sockindex, if(nva[i].namelen == 14 && Curl_raw_nequal("content-length", (char*)nva[i].name, 14)) { size_t j; + stream->upload_left = 0; for(j = 0; j < nva[i].valuelen; ++j) { - httpc->upload_left *= 10; - httpc->upload_left += nva[i].value[j] - '0'; + stream->upload_left *= 10; + stream->upload_left += nva[i].value[j] - '0'; } - infof(conn->data, "request content-length=%zu\n", httpc->upload_left); + DEBUGF(infof(conn->data, + "request content-length=%" + CURL_FORMAT_CURL_OFF_T + "\n", stream->upload_left)); } } @@ -917,31 +1352,34 @@ static ssize_t http2_send(struct connectdata *conn, int sockindex, case HTTPREQ_PUT: data_prd.read_callback = data_source_read_callback; data_prd.source.ptr = NULL; - stream_id = nghttp2_submit_request(httpc->h2, NULL, nva, nheader, - &data_prd, NULL); + stream_id = nghttp2_submit_request(h2, NULL, nva, nheader, + &data_prd, conn->data); break; default: - stream_id = nghttp2_submit_request(httpc->h2, NULL, nva, nheader, - NULL, NULL); + stream_id = nghttp2_submit_request(h2, NULL, nva, nheader, + NULL, conn->data); } Curl_safefree(nva); if(stream_id < 0) { + DEBUGF(infof(conn->data, "http2_send() send error\n")); *err = CURLE_SEND_ERROR; return -1; } - httpc->stream_id = stream_id; + infof(conn->data, "Using Stream ID: %x (easy handle %p)\n", + stream_id, conn->data); + stream->stream_id = stream_id; - rv = nghttp2_session_send(httpc->h2); + rv = nghttp2_session_send(h2); if(rv != 0) { *err = CURLE_SEND_ERROR; return -1; } - if(httpc->stream_id != -1) { + if(stream->stream_id != -1) { /* If whole HEADERS frame was sent off to the underlying socket, the nghttp2 library calls data_source_read_callback. But only it found that no data available, so it deferred the DATA @@ -950,67 +1388,83 @@ static ssize_t http2_send(struct connectdata *conn, int sockindex, writable socket check is performed. To workaround this, we issue nghttp2_session_resume_data() here to bring back DATA transmission from deferred state. */ - nghttp2_session_resume_data(httpc->h2, httpc->stream_id); + nghttp2_session_resume_data(h2, stream->stream_id); } return len; + + fail: + free(nva); + *err = CURLE_SEND_ERROR; + return -1; } CURLcode Curl_http2_setup(struct connectdata *conn) { + CURLcode result; struct http_conn *httpc = &conn->proto.httpc; + struct HTTP *stream = conn->data->req.protop; + + stream->stream_id = -1; + + if(!stream->header_recvbuf) + stream->header_recvbuf = Curl_add_buffer_init(); + + if((conn->handler == &Curl_handler_http2_ssl) || + (conn->handler == &Curl_handler_http2)) + return CURLE_OK; /* already done */ + if(conn->handler->flags & PROTOPT_SSL) conn->handler = &Curl_handler_http2_ssl; else conn->handler = &Curl_handler_http2; - infof(conn->data, "Using HTTP2\n"); - httpc->bodystarted = FALSE; - httpc->closed = FALSE; - httpc->header_recvbuf = Curl_add_buffer_init(); - httpc->nread_header_recvbuf = 0; - httpc->data = NULL; - httpc->datalen = 0; - httpc->upload_left = 0; - httpc->upload_mem = NULL; - httpc->upload_len = 0; - httpc->stream_id = -1; - httpc->status_code = -1; + result = Curl_http2_init(conn); + if(result) + return result; + + infof(conn->data, "Using HTTP2, server supports multi-use\n"); + stream->upload_left = 0; + stream->upload_mem = NULL; + stream->upload_len = 0; + httpc->inbuflen = 0; + httpc->nread_inbuf = 0; + + httpc->pause_stream_id = 0; + + conn->bits.multiplex = TRUE; /* at least potentially multiplexed */ conn->httpversion = 20; + conn->bundle->multiuse = BUNDLE_MULTIPLEX; - return 0; + infof(conn->data, "Connection state changed (HTTP/2 confirmed)\n"); + Curl_multi_connchanged(conn->data->multi); + + return CURLE_OK; } -CURLcode Curl_http2_switched(struct connectdata *conn) +CURLcode Curl_http2_switched(struct connectdata *conn, + const char *mem, size_t nread) { - CURLcode rc; + CURLcode result; struct http_conn *httpc = &conn->proto.httpc; int rv; + ssize_t nproc; struct SessionHandle *data = conn->data; + struct HTTP *stream = conn->data->req.protop; + + result = Curl_http2_setup(conn); + if(result) + return result; httpc->recv_underlying = (recving)conn->recv[FIRSTSOCKET]; httpc->send_underlying = (sending)conn->send[FIRSTSOCKET]; conn->recv[FIRSTSOCKET] = http2_recv; conn->send[FIRSTSOCKET] = http2_send; - rv = (int) ((Curl_send*)httpc->send_underlying) - (conn, FIRSTSOCKET, - NGHTTP2_CLIENT_CONNECTION_PREFACE, - NGHTTP2_CLIENT_CONNECTION_PREFACE_LEN, - &rc); - if(rc) - /* TODO: This may get CURLE_AGAIN */ - return rc; - - if(rv != 24) { - failf(data, "Only sent partial HTTP2 packet"); - return CURLE_SEND_ERROR; - } - if(conn->data->req.upgr101 == UPGR101_RECEIVED) { /* stream 1 is opened implicitly on upgrade */ - httpc->stream_id = 1; + stream->stream_id = 1; /* queue SETTINGS frame (again) */ rv = nghttp2_session_upgrade(httpc->h2, httpc->binsettings, httpc->binlen, NULL); @@ -1019,10 +1473,14 @@ CURLcode Curl_http2_switched(struct connectdata *conn) nghttp2_strerror(rv), rv); return CURLE_HTTP2; } + + nghttp2_session_set_stream_user_data(httpc->h2, + stream->stream_id, + conn->data); } else { /* stream ID is unknown at this point */ - httpc->stream_id = -1; + stream->stream_id = -1; rv = nghttp2_submit_settings(httpc->h2, NGHTTP2_FLAG_NONE, NULL, 0); if(rv != 0) { failf(data, "nghttp2_submit_settings() failed: %s(%d)", @@ -1030,7 +1488,75 @@ CURLcode Curl_http2_switched(struct connectdata *conn) return CURLE_HTTP2; } } + + /* we are going to copy mem to httpc->inbuf. This is required since + mem is part of buffer pointed by stream->mem, and callbacks + called by nghttp2_session_mem_recv() will write stream specific + data into stream->mem, overwriting data already there. */ + if(H2_BUFSIZE < nread) { + failf(data, "connection buffer size is too small to store data following " + "HTTP Upgrade response header: buflen=%zu, datalen=%zu", + H2_BUFSIZE, nread); + return CURLE_HTTP2; + } + + infof(conn->data, "Copying HTTP/2 data in stream buffer to connection buffer" + " after upgrade: len=%zu\n", + nread); + + memcpy(httpc->inbuf, mem, nread); + httpc->inbuflen = nread; + + nproc = nghttp2_session_mem_recv(httpc->h2, (const uint8_t *)httpc->inbuf, + httpc->inbuflen); + + if(nghttp2_is_fatal((int)nproc)) { + failf(data, "nghttp2_session_mem_recv() failed: %s(%d)", + nghttp2_strerror((int)nproc), (int)nproc); + return CURLE_HTTP2; + } + + DEBUGF(infof(data, "nghttp2_session_mem_recv() returns %zd\n", nproc)); + + if((ssize_t)nread == nproc) { + httpc->inbuflen = 0; + httpc->nread_inbuf = 0; + } + else { + httpc->nread_inbuf += nproc; + } + + /* Try to send some frames since we may read SETTINGS already. */ + rv = nghttp2_session_send(httpc->h2); + + if(rv != 0) { + failf(data, "nghttp2_session_send() failed: %s(%d)", + nghttp2_strerror(rv), rv); + return CURLE_HTTP2; + } + return CURLE_OK; } -#endif +#else /* !USE_NGHTTP2 */ + +/* Satisfy external references even if http2 is not compiled in. */ + +#define CURL_DISABLE_TYPECHECK +#include + +char *curl_pushheader_bynum(struct curl_pushheaders *h, size_t num) +{ + (void) h; + (void) num; + return NULL; +} + +char *curl_pushheader_byname(struct curl_pushheaders *h, const char *header) +{ + (void) h; + (void) header; + return NULL; +} + +#endif /* USE_NGHTTP2 */ diff --git a/lib/http2.h b/lib/http2.h index 66aa6fd..bb7ad9c 100644 --- a/lib/http2.h +++ b/lib/http2.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -26,6 +26,11 @@ #ifdef USE_NGHTTP2 #include "http.h" + +/* value for MAX_CONCURRENT_STREAMS we use until we get an updated setting + from the peer */ +#define DEFAULT_MAX_CONCURRENT_STREAMS 13 + /* * Store nghttp2 version info in this buffer, Prefix with a space. Return * total length written. @@ -37,13 +42,19 @@ CURLcode Curl_http2_send_request(struct connectdata *conn); CURLcode Curl_http2_request_upgrade(Curl_send_buffer *req, struct connectdata *conn); CURLcode Curl_http2_setup(struct connectdata *conn); -CURLcode Curl_http2_switched(struct connectdata *conn); +CURLcode Curl_http2_switched(struct connectdata *conn, + const char *data, size_t nread); +/* called from Curl_http_setup_conn */ +void Curl_http2_setup_conn(struct connectdata *conn); +void Curl_http2_setup_req(struct SessionHandle *data); #else /* USE_NGHTTP2 */ #define Curl_http2_init(x) CURLE_UNSUPPORTED_PROTOCOL #define Curl_http2_send_request(x) CURLE_UNSUPPORTED_PROTOCOL #define Curl_http2_request_upgrade(x,y) CURLE_UNSUPPORTED_PROTOCOL #define Curl_http2_setup(x) CURLE_UNSUPPORTED_PROTOCOL -#define Curl_http2_switched(x) CURLE_UNSUPPORTED_PROTOCOL +#define Curl_http2_switched(x,y,z) CURLE_UNSUPPORTED_PROTOCOL +#define Curl_http2_setup_conn(x) +#define Curl_http2_setup_req(x) #endif #endif /* HEADER_CURL_HTTP2_H */ diff --git a/lib/http_chunks.c b/lib/http_chunks.c index 61a6098..7e91b37 100644 --- a/lib/http_chunks.c +++ b/lib/http_chunks.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -29,15 +29,12 @@ #include "content_encoding.h" #include "http.h" -#include "curl_memory.h" #include "non-ascii.h" /* for Curl_convert_to_network prototype */ #include "strtoofft.h" #include "warnless.h" -#define _MPRINTF_REPLACE /* use our functions only */ -#include - -/* The last #include file should be: */ +/* The last #include files should be: */ +#include "curl_memory.h" #include "memdebug.h" /* @@ -158,7 +155,7 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn, if(result) { /* Curl_convert_from_network calls failf if unsuccessful */ /* Treat it as a bad hex character */ - return CHUNKE_ILLEGAL_HEX ; + return CHUNKE_ILLEGAL_HEX; } ch->datasize=curlx_strtoofft(ch->hexbuffer, &endptr, 16); @@ -221,7 +218,6 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn, (ssize_t)piece); break; - case COMPRESS: default: failf (conn->data, "Unrecognized content encoding type. " diff --git a/lib/http_digest.c b/lib/http_digest.c index 55f5108..929e2c6 100644 --- a/lib/http_digest.c +++ b/lib/http_digest.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -26,94 +26,14 @@ #include "urldata.h" #include "rawstr.h" -#include "curl_base64.h" -#include "curl_md5.h" +#include "curl_sasl.h" #include "http_digest.h" -#include "strtok.h" -#include "curl_memory.h" -#include "vtls/vtls.h" /* for Curl_rand() */ -#include "non-ascii.h" /* included for Curl_convert_... prototypes */ -#include "warnless.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include +#include "curl_printf.h" -/* The last #include file should be: */ +/* The last #include files should be: */ +#include "curl_memory.h" #include "memdebug.h" -#define MAX_VALUE_LENGTH 256 -#define MAX_CONTENT_LENGTH 1024 - -static void digest_cleanup_one(struct digestdata *dig); - -/* - * Return 0 on success and then the buffers are filled in fine. - * - * Non-zero means failure to parse. - */ -static int get_pair(const char *str, char *value, char *content, - const char **endptr) -{ - int c; - bool starts_with_quote = FALSE; - bool escape = FALSE; - - for(c=MAX_VALUE_LENGTH-1; (*str && (*str != '=') && c--); ) - *value++ = *str++; - *value=0; - - if('=' != *str++) - /* eek, no match */ - return 1; - - if('\"' == *str) { - /* this starts with a quote so it must end with one as well! */ - str++; - starts_with_quote = TRUE; - } - - for(c=MAX_CONTENT_LENGTH-1; *str && c--; str++) { - switch(*str) { - case '\\': - if(!escape) { - /* possibly the start of an escaped quote */ - escape = TRUE; - *content++ = '\\'; /* even though this is an escape character, we still - store it as-is in the target buffer */ - continue; - } - break; - case ',': - if(!starts_with_quote) { - /* this signals the end of the content if we didn't get a starting - quote and then we do "sloppy" parsing */ - c=0; /* the end */ - continue; - } - break; - case '\r': - case '\n': - /* end of string */ - c=0; - continue; - case '\"': - if(!escape && starts_with_quote) { - /* end of string */ - c=0; - continue; - } - break; - } - escape = FALSE; - *content++ = *str; - } - *content=0; - - *endptr = str; - - return 0; /* all is fine! */ -} - /* Test example headers: WWW-Authenticate: Digest realm="testrealm", nonce="1053604598" @@ -121,177 +41,31 @@ Proxy-Authenticate: Digest realm="testrealm", nonce="1053604598" */ -CURLdigest Curl_input_digest(struct connectdata *conn, - bool proxy, - const char *header) /* rest of the *-authenticate: - header */ +CURLcode Curl_input_digest(struct connectdata *conn, + bool proxy, + const char *header) /* rest of the *-authenticate: + header */ { - char *token = NULL; - char *tmp = NULL; - bool foundAuth = FALSE; - bool foundAuthInt = FALSE; - struct SessionHandle *data=conn->data; - bool before = FALSE; /* got a nonce before */ - struct digestdata *d; + struct SessionHandle *data = conn->data; + + /* Point to the correct struct with this */ + struct digestdata *digest; if(proxy) { - d = &data->state.proxydigest; + digest = &data->state.proxydigest; } else { - d = &data->state.digest; - } - - if(checkprefix("Digest", header)) { - header += strlen("Digest"); - - /* If we already have received a nonce, keep that in mind */ - if(d->nonce) - before = TRUE; - - /* clear off any former leftovers and init to defaults */ - digest_cleanup_one(d); - - for(;;) { - char value[MAX_VALUE_LENGTH]; - char content[MAX_CONTENT_LENGTH]; - - while(*header && ISSPACE(*header)) - header++; - - /* extract a value=content pair */ - if(!get_pair(header, value, content, &header)) { - if(Curl_raw_equal(value, "nonce")) { - d->nonce = strdup(content); - if(!d->nonce) - return CURLDIGEST_NOMEM; - } - else if(Curl_raw_equal(value, "stale")) { - if(Curl_raw_equal(content, "true")) { - d->stale = TRUE; - d->nc = 1; /* we make a new nonce now */ - } - } - else if(Curl_raw_equal(value, "realm")) { - d->realm = strdup(content); - if(!d->realm) - return CURLDIGEST_NOMEM; - } - else if(Curl_raw_equal(value, "opaque")) { - d->opaque = strdup(content); - if(!d->opaque) - return CURLDIGEST_NOMEM; - } - else if(Curl_raw_equal(value, "qop")) { - char *tok_buf; - /* tokenize the list and choose auth if possible, use a temporary - clone of the buffer since strtok_r() ruins it */ - tmp = strdup(content); - if(!tmp) - return CURLDIGEST_NOMEM; - token = strtok_r(tmp, ",", &tok_buf); - while(token != NULL) { - if(Curl_raw_equal(token, "auth")) { - foundAuth = TRUE; - } - else if(Curl_raw_equal(token, "auth-int")) { - foundAuthInt = TRUE; - } - token = strtok_r(NULL, ",", &tok_buf); - } - free(tmp); - /*select only auth o auth-int. Otherwise, ignore*/ - if(foundAuth) { - d->qop = strdup("auth"); - if(!d->qop) - return CURLDIGEST_NOMEM; - } - else if(foundAuthInt) { - d->qop = strdup("auth-int"); - if(!d->qop) - return CURLDIGEST_NOMEM; - } - } - else if(Curl_raw_equal(value, "algorithm")) { - d->algorithm = strdup(content); - if(!d->algorithm) - return CURLDIGEST_NOMEM; - if(Curl_raw_equal(content, "MD5-sess")) - d->algo = CURLDIGESTALGO_MD5SESS; - else if(Curl_raw_equal(content, "MD5")) - d->algo = CURLDIGESTALGO_MD5; - else - return CURLDIGEST_BADALGO; - } - else { - /* unknown specifier, ignore it! */ - } - } - else - break; /* we're done here */ - - /* pass all additional spaces here */ - while(*header && ISSPACE(*header)) - header++; - if(',' == *header) - /* allow the list to be comma-separated */ - header++; - } - /* We had a nonce since before, and we got another one now without - 'stale=true'. This means we provided bad credentials in the previous - request */ - if(before && !d->stale) - return CURLDIGEST_BAD; - - /* We got this header without a nonce, that's a bad Digest line! */ - if(!d->nonce) - return CURLDIGEST_BAD; + digest = &data->state.digest; } - else - /* else not a digest, get out */ - return CURLDIGEST_NONE; - - return CURLDIGEST_FINE; -} -/* convert md5 chunk to RFC2617 (section 3.1.3) -suitable ascii string*/ -static void md5_to_ascii(unsigned char *source, /* 16 bytes */ - unsigned char *dest) /* 33 bytes */ -{ - int i; - for(i=0; i<16; i++) - snprintf((char *)&dest[i*2], 3, "%02x", source[i]); -} - -/* Perform quoted-string escaping as described in RFC2616 and its errata */ -static char *string_quoted(const char *source) -{ - char *dest, *d; - const char *s = source; - size_t n = 1; /* null terminator */ - - /* Calculate size needed */ - while(*s) { - ++n; - if(*s == '"' || *s == '\\') { - ++n; - } - ++s; - } + if(!checkprefix("Digest", header)) + return CURLE_BAD_CONTENT_ENCODING; - dest = malloc(n); - if(dest) { - s = source; - d = dest; - while(*s) { - if(*s == '"' || *s == '\\') { - *d++ = '\\'; - } - *d++ = *s++; - } - *d = 0; - } + header += strlen("Digest"); + while(*header && ISSPACE(*header)) + header++; - return dest; + return Curl_sasl_decode_digest_http_message(header, digest); } CURLcode Curl_output_digest(struct connectdata *conn, @@ -299,49 +73,35 @@ CURLcode Curl_output_digest(struct connectdata *conn, const unsigned char *request, const unsigned char *uripath) { - /* We have a Digest setup for this, use it! Now, to get all the details for - this sorted out, I must urge you dear friend to read up on the RFC2617 - section 3.2.2, */ - size_t urilen; - unsigned char md5buf[16]; /* 16 bytes/128 bits */ - unsigned char request_digest[33]; - unsigned char *md5this; - unsigned char ha1[33];/* 32 digits and 1 zero byte */ - unsigned char ha2[33];/* 32 digits and 1 zero byte */ - char cnoncebuf[33]; - char *cnonce = NULL; - size_t cnonce_sz = 0; - char *tmp = NULL; + CURLcode result; + struct SessionHandle *data = conn->data; + unsigned char *path; + char *tmp; + char *response; + size_t len; + bool have_chlg; + + /* Point to the address of the pointer that holds the string to send to the + server, which is for a plain host or for a HTTP proxy */ char **allocuserpwd; - size_t userlen; + + /* Point to the name and password for this */ const char *userp; - char *userp_quoted; const char *passwdp; - struct auth *authp; - struct SessionHandle *data = conn->data; - struct digestdata *d; - CURLcode rc; -/* The CURL_OUTPUT_DIGEST_CONV macro below is for non-ASCII machines. - It converts digest text to ASCII so the MD5 will be correct for - what ultimately goes over the network. -*/ -#define CURL_OUTPUT_DIGEST_CONV(a, b) \ - rc = Curl_convert_to_network(a, (char *)b, strlen((const char*)b)); \ - if(rc != CURLE_OK) { \ - free(b); \ - return rc; \ - } + /* Point to the correct struct with this */ + struct digestdata *digest; + struct auth *authp; if(proxy) { - d = &data->state.proxydigest; + digest = &data->state.proxydigest; allocuserpwd = &conn->allocptr.proxyuserpwd; userp = conn->proxyuser; passwdp = conn->proxypasswd; authp = &data->state.authproxy; } else { - d = &data->state.digest; + digest = &data->state.digest; allocuserpwd = &conn->allocptr.userpwd; userp = conn->user; passwdp = conn->passwd; @@ -352,75 +112,21 @@ CURLcode Curl_output_digest(struct connectdata *conn, /* not set means empty */ if(!userp) - userp=""; + userp = ""; if(!passwdp) - passwdp=""; + passwdp = ""; + +#if defined(USE_WINDOWS_SSPI) + have_chlg = digest->input_token ? TRUE : FALSE; +#else + have_chlg = digest->nonce ? TRUE : FALSE; +#endif - if(!d->nonce) { + if(!have_chlg) { authp->done = FALSE; return CURLE_OK; } - authp->done = TRUE; - - if(!d->nc) - d->nc = 1; - - if(!d->cnonce) { - snprintf(cnoncebuf, sizeof(cnoncebuf), "%08x%08x%08x%08x", - Curl_rand(data), Curl_rand(data), - Curl_rand(data), Curl_rand(data)); - rc = Curl_base64_encode(data, cnoncebuf, strlen(cnoncebuf), - &cnonce, &cnonce_sz); - if(rc) - return rc; - d->cnonce = cnonce; - } - - /* - if the algorithm is "MD5" or unspecified (which then defaults to MD5): - - A1 = unq(username-value) ":" unq(realm-value) ":" passwd - - if the algorithm is "MD5-sess" then: - - A1 = H( unq(username-value) ":" unq(realm-value) ":" passwd ) - ":" unq(nonce-value) ":" unq(cnonce-value) - */ - - md5this = (unsigned char *) - aprintf("%s:%s:%s", userp, d->realm, passwdp); - if(!md5this) - return CURLE_OUT_OF_MEMORY; - - CURL_OUTPUT_DIGEST_CONV(data, md5this); /* convert on non-ASCII machines */ - Curl_md5it(md5buf, md5this); - Curl_safefree(md5this); - md5_to_ascii(md5buf, ha1); - - if(d->algo == CURLDIGESTALGO_MD5SESS) { - /* nonce and cnonce are OUTSIDE the hash */ - tmp = aprintf("%s:%s:%s", ha1, d->nonce, d->cnonce); - if(!tmp) - return CURLE_OUT_OF_MEMORY; - CURL_OUTPUT_DIGEST_CONV(data, tmp); /* convert on non-ASCII machines */ - Curl_md5it(md5buf, (unsigned char *)tmp); - Curl_safefree(tmp); - md5_to_ascii(md5buf, ha1); - } - - /* - If the "qop" directive's value is "auth" or is unspecified, then A2 is: - - A2 = Method ":" digest-uri-value - - If the "qop" value is "auth-int", then A2 is: - - A2 = Method ":" digest-uri-value ":" H(entity-body) - - (The "Method" value is the HTTP request method as specified in section - 5.1.1 of RFC 2616) - */ /* So IE browsers < v7 cut off the URI part at the query part when they evaluate the MD5 and some (IIS?) servers work with them so we may need to @@ -435,164 +141,39 @@ CURLcode Curl_output_digest(struct connectdata *conn, http://www.fngtps.com/2006/09/http-authentication */ - if(authp->iestyle && ((tmp = strchr((char *)uripath, '?')) != NULL)) - urilen = tmp - (char *)uripath; - else - urilen = strlen((char *)uripath); - - md5this = (unsigned char *)aprintf("%s:%.*s", request, urilen, uripath); + if(authp->iestyle && ((tmp = strchr((char *)uripath, '?')) != NULL)) { + size_t urilen = tmp - (char *)uripath; - if(d->qop && Curl_raw_equal(d->qop, "auth-int")) { - /* We don't support auth-int for PUT or POST at the moment. - TODO: replace md5 of empty string with entity-body for PUT/POST */ - unsigned char *md5this2 = (unsigned char *) - aprintf("%s:%s", md5this, "d41d8cd98f00b204e9800998ecf8427e"); - Curl_safefree(md5this); - md5this = md5this2; + path = (unsigned char *) aprintf("%.*s", urilen, uripath); } + else + path = (unsigned char *) strdup((char *) uripath); - if(!md5this) - return CURLE_OUT_OF_MEMORY; - - CURL_OUTPUT_DIGEST_CONV(data, md5this); /* convert on non-ASCII machines */ - Curl_md5it(md5buf, md5this); - Curl_safefree(md5this); - md5_to_ascii(md5buf, ha2); - - if(d->qop) { - md5this = (unsigned char *)aprintf("%s:%s:%08x:%s:%s:%s", - ha1, - d->nonce, - d->nc, - d->cnonce, - d->qop, - ha2); - } - else { - md5this = (unsigned char *)aprintf("%s:%s:%s", - ha1, - d->nonce, - ha2); - } - if(!md5this) + if(!path) return CURLE_OUT_OF_MEMORY; - CURL_OUTPUT_DIGEST_CONV(data, md5this); /* convert on non-ASCII machines */ - Curl_md5it(md5buf, md5this); - Curl_safefree(md5this); - md5_to_ascii(md5buf, request_digest); - - /* for test case 64 (snooped from a Mozilla 1.3a request) - - Authorization: Digest username="testuser", realm="testrealm", \ - nonce="1053604145", uri="/64", response="c55f7f30d83d774a3d2dcacf725abaca" - - Digest parameters are all quoted strings. Username which is provided by - the user will need double quotes and backslashes within it escaped. For - the other fields, this shouldn't be an issue. realm, nonce, and opaque - are copied as is from the server, escapes and all. cnonce is generated - with web-safe characters. uri is already percent encoded. nc is 8 hex - characters. algorithm and qop with standard values only contain web-safe - chracters. - */ - userp_quoted = string_quoted(userp); - if(!userp_quoted) - return CURLE_OUT_OF_MEMORY; + result = Curl_sasl_create_digest_http_message(data, userp, passwdp, request, + path, digest, &response, &len); + free(path); + if(result) + return result; - if(d->qop) { - *allocuserpwd = - aprintf( "%sAuthorization: Digest " - "username=\"%s\", " - "realm=\"%s\", " - "nonce=\"%s\", " - "uri=\"%.*s\", " - "cnonce=\"%s\", " - "nc=%08x, " - "qop=%s, " - "response=\"%s\"", - proxy?"Proxy-":"", - userp_quoted, - d->realm, - d->nonce, - urilen, uripath, /* this is the PATH part of the URL */ - d->cnonce, - d->nc, - d->qop, - request_digest); - - if(Curl_raw_equal(d->qop, "auth")) - d->nc++; /* The nc (from RFC) has to be a 8 hex digit number 0 padded - which tells to the server how many times you are using the - same nonce in the qop=auth mode. */ - } - else { - *allocuserpwd = - aprintf( "%sAuthorization: Digest " - "username=\"%s\", " - "realm=\"%s\", " - "nonce=\"%s\", " - "uri=\"%.*s\", " - "response=\"%s\"", - proxy?"Proxy-":"", - userp_quoted, - d->realm, - d->nonce, - urilen, uripath, /* this is the PATH part of the URL */ - request_digest); - } - Curl_safefree(userp_quoted); + *allocuserpwd = aprintf("%sAuthorization: Digest %s\r\n", + proxy ? "Proxy-" : "", + response); + free(response); if(!*allocuserpwd) return CURLE_OUT_OF_MEMORY; - /* Add optional fields */ - if(d->opaque) { - /* append opaque */ - tmp = aprintf("%s, opaque=\"%s\"", *allocuserpwd, d->opaque); - if(!tmp) - return CURLE_OUT_OF_MEMORY; - free(*allocuserpwd); - *allocuserpwd = tmp; - } - - if(d->algorithm) { - /* append algorithm */ - tmp = aprintf("%s, algorithm=\"%s\"", *allocuserpwd, d->algorithm); - if(!tmp) - return CURLE_OUT_OF_MEMORY; - free(*allocuserpwd); - *allocuserpwd = tmp; - } - - /* append CRLF + zero (3 bytes) to the userpwd header */ - userlen = strlen(*allocuserpwd); - tmp = realloc(*allocuserpwd, userlen + 3); - if(!tmp) - return CURLE_OUT_OF_MEMORY; - strcpy(&tmp[userlen], "\r\n"); /* append the data */ - *allocuserpwd = tmp; + authp->done = TRUE; return CURLE_OK; } -static void digest_cleanup_one(struct digestdata *d) -{ - Curl_safefree(d->nonce); - Curl_safefree(d->cnonce); - Curl_safefree(d->realm); - Curl_safefree(d->opaque); - Curl_safefree(d->qop); - Curl_safefree(d->algorithm); - - d->nc = 0; - d->algo = CURLDIGESTALGO_MD5; /* default algorithm */ - d->stale = FALSE; /* default means normal, not stale */ -} - - void Curl_digest_cleanup(struct SessionHandle *data) { - digest_cleanup_one(&data->state.digest); - digest_cleanup_one(&data->state.proxydigest); + Curl_sasl_digest_cleanup(&data->state.digest); + Curl_sasl_digest_cleanup(&data->state.proxydigest); } #endif diff --git a/lib/http_digest.h b/lib/http_digest.h index c6a4e91..d13d563 100644 --- a/lib/http_digest.h +++ b/lib/http_digest.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -23,24 +23,9 @@ ***************************************************************************/ #include "curl_setup.h" -typedef enum { - CURLDIGEST_NONE, /* not a digest */ - CURLDIGEST_BAD, /* a digest, but one we don't like */ - CURLDIGEST_BADALGO, /* unsupported algorithm requested */ - CURLDIGEST_NOMEM, - CURLDIGEST_FINE, /* a digest we act on */ - - CURLDIGEST_LAST /* last entry in this enum, don't use */ -} CURLdigest; - -enum { - CURLDIGESTALGO_MD5, - CURLDIGESTALGO_MD5SESS -}; - /* this is for digest header input */ -CURLdigest Curl_input_digest(struct connectdata *conn, - bool proxy, const char *header); +CURLcode Curl_input_digest(struct connectdata *conn, + bool proxy, const char *header); /* this is for creating digest header output */ CURLcode Curl_output_digest(struct connectdata *conn, diff --git a/lib/http_negotiate.c b/lib/http_negotiate.c index c8bfa29..a1baf29 100644 --- a/lib/http_negotiate.c +++ b/lib/http_negotiate.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -22,13 +22,7 @@ #include "curl_setup.h" -#ifdef HAVE_GSSAPI -#ifdef HAVE_OLD_GSSMIT -#define GSS_C_NT_HOSTBASED_SERVICE gss_nt_service_name -#define NCOMPAT 1 -#endif - -#ifndef CURL_DISABLE_HTTP +#if defined(HAVE_GSSAPI) && !defined(CURL_DISABLE_HTTP) && defined(USE_SPNEGO) #include "urldata.h" #include "sendf.h" @@ -36,97 +30,63 @@ #include "rawstr.h" #include "curl_base64.h" #include "http_negotiate.h" -#include "curl_memory.h" +#include "curl_sasl.h" #include "url.h" +#include "curl_printf.h" -#define _MPRINTF_REPLACE /* use our functions only */ -#include - -/* The last #include file should be: */ +/* The last #include files should be: */ +#include "curl_memory.h" #include "memdebug.h" -static int -get_gss_name(struct connectdata *conn, bool proxy, gss_name_t *server) -{ - OM_uint32 major_status, minor_status; - gss_buffer_desc token = GSS_C_EMPTY_BUFFER; - char name[2048]; - const char* service = "HTTP"; - - token.length = strlen(service) + 1 + strlen(proxy ? conn->proxy.name : - conn->host.name) + 1; - if(token.length + 1 > sizeof(name)) - return EMSGSIZE; - - snprintf(name, sizeof(name), "%s@%s", service, proxy ? conn->proxy.name : - conn->host.name); - - token.value = (void *) name; - major_status = gss_import_name(&minor_status, - &token, - GSS_C_NT_HOSTBASED_SERVICE, - server); - - return GSS_ERROR(major_status) ? -1 : 0; -} - -static void -log_gss_error(struct connectdata *conn, OM_uint32 error_status, - const char *prefix) -{ - OM_uint32 maj_stat, min_stat; - OM_uint32 msg_ctx = 0; - gss_buffer_desc status_string; - char buf[1024]; - size_t len; - - snprintf(buf, sizeof(buf), "%s", prefix); - len = strlen(buf); - do { - maj_stat = gss_display_status(&min_stat, - error_status, - GSS_C_MECH_CODE, - GSS_C_NO_OID, - &msg_ctx, - &status_string); - if(sizeof(buf) > len + status_string.length + 1) { - snprintf(buf + len, sizeof(buf) - len, - ": %s", (char*) status_string.value); - len += status_string.length; - } - gss_release_buffer(&min_stat, &status_string); - } while(!GSS_ERROR(maj_stat) && msg_ctx != 0); - - infof(conn->data, "%s\n", buf); -} - -/* returning zero (0) means success, everything else is treated as "failure" - with no care exactly what the failure was */ -int Curl_input_negotiate(struct connectdata *conn, bool proxy, - const char *header) +CURLcode Curl_input_negotiate(struct connectdata *conn, bool proxy, + const char *header) { struct SessionHandle *data = conn->data; struct negotiatedata *neg_ctx = proxy?&data->state.proxyneg: &data->state.negotiate; OM_uint32 major_status, minor_status, discard_st; + gss_buffer_desc spn_token = GSS_C_EMPTY_BUFFER; gss_buffer_desc input_token = GSS_C_EMPTY_BUFFER; gss_buffer_desc output_token = GSS_C_EMPTY_BUFFER; - int ret; size_t len; size_t rawlen = 0; - CURLcode error; + CURLcode result; if(neg_ctx->context && neg_ctx->status == GSS_S_COMPLETE) { /* We finished successfully our part of authentication, but server * rejected it (since we're again here). Exit with an error since we * can't invent anything better */ Curl_cleanup_negotiate(data); - return -1; + return CURLE_LOGIN_DENIED; } - if(neg_ctx->server_name == NULL && - (ret = get_gss_name(conn, proxy, &neg_ctx->server_name))) - return ret; + if(!neg_ctx->server_name) { + /* Generate our SPN */ + char *spn = Curl_sasl_build_gssapi_spn( + proxy ? data->set.str[STRING_PROXY_SERVICE_NAME] : + data->set.str[STRING_SERVICE_NAME], + proxy ? conn->proxy.name : conn->host.name); + if(!spn) + return CURLE_OUT_OF_MEMORY; + + /* Populate the SPN structure */ + spn_token.value = spn; + spn_token.length = strlen(spn); + + /* Import the SPN */ + major_status = gss_import_name(&minor_status, &spn_token, + GSS_C_NT_HOSTBASED_SERVICE, + &neg_ctx->server_name); + if(GSS_ERROR(major_status)) { + Curl_gss_log_error(data, minor_status, "gss_import_name() failed: "); + + free(spn); + + return CURLE_OUT_OF_MEMORY; + } + + free(spn); + } header += strlen("Negotiate"); while(*header && ISSPACE(*header)) @@ -134,10 +94,17 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy, len = strlen(header); if(len > 0) { - error = Curl_base64_decode(header, - (unsigned char **)&input_token.value, &rawlen); - if(error || rawlen == 0) - return -1; + result = Curl_base64_decode(header, (unsigned char **)&input_token.value, + &rawlen); + if(result) + return result; + + if(!rawlen) { + infof(data, "Negotiate handshake failure (empty challenge message)\n"); + + return CURLE_BAD_CONTENT_ENCODING; + } + input_token.length = rawlen; DEBUGASSERT(input_token.value != NULL); @@ -151,6 +118,7 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy, GSS_C_NO_CHANNEL_BINDINGS, &input_token, &output_token, + TRUE, NULL); Curl_safefree(input_token.value); @@ -158,20 +126,21 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy, if(GSS_ERROR(major_status)) { if(output_token.value) gss_release_buffer(&discard_st, &output_token); - log_gss_error(conn, minor_status, "gss_init_sec_context() failed: "); - return -1; + Curl_gss_log_error(conn->data, minor_status, + "gss_init_sec_context() failed: "); + return CURLE_OUT_OF_MEMORY; } if(!output_token.value || !output_token.length) { if(output_token.value) gss_release_buffer(&discard_st, &output_token); - return -1; + return CURLE_OUT_OF_MEMORY; } neg_ctx->output_token = output_token; - return 0; -} + return CURLE_OK; +} CURLcode Curl_output_negotiate(struct connectdata *conn, bool proxy) { @@ -180,18 +149,18 @@ CURLcode Curl_output_negotiate(struct connectdata *conn, bool proxy) char *encoded = NULL; size_t len = 0; char *userp; - CURLcode error; + CURLcode result; OM_uint32 discard_st; - error = Curl_base64_encode(conn->data, - neg_ctx->output_token.value, - neg_ctx->output_token.length, - &encoded, &len); - if(error) { + result = Curl_base64_encode(conn->data, + neg_ctx->output_token.value, + neg_ctx->output_token.length, + &encoded, &len); + if(result) { gss_release_buffer(&discard_st, &neg_ctx->output_token); neg_ctx->output_token.value = NULL; neg_ctx->output_token.length = 0; - return error; + return result; } if(!encoded || !len) { @@ -212,7 +181,7 @@ CURLcode Curl_output_negotiate(struct connectdata *conn, bool proxy) conn->allocptr.userpwd = userp; } - Curl_safefree(encoded); + free(encoded); return (userp == NULL) ? CURLE_OUT_OF_MEMORY : CURLE_OK; } @@ -238,6 +207,4 @@ void Curl_cleanup_negotiate(struct SessionHandle *data) cleanup(&data->state.proxyneg); } - -#endif -#endif +#endif /* HAVE_GSSAPI && !CURL_DISABLE_HTTP && USE_SPNEGO */ diff --git a/lib/http_negotiate.h b/lib/http_negotiate.h index f7efe8c..a8eb980 100644 --- a/lib/http_negotiate.h +++ b/lib/http_negotiate.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -25,8 +25,8 @@ #ifdef USE_SPNEGO /* this is for Negotiate header input */ -int Curl_input_negotiate(struct connectdata *conn, bool proxy, - const char *header); +CURLcode Curl_input_negotiate(struct connectdata *conn, bool proxy, + const char *header); /* this is for creating Negotiate header output */ CURLcode Curl_output_negotiate(struct connectdata *conn, bool proxy); diff --git a/lib/http_negotiate_sspi.c b/lib/http_negotiate_sspi.c index 61581f1..a50ea96 100644 --- a/lib/http_negotiate_sspi.c +++ b/lib/http_negotiate_sspi.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -33,30 +33,27 @@ #include "curl_base64.h" #include "curl_sasl.h" #include "http_negotiate.h" -#include "curl_memory.h" #include "curl_multibyte.h" +#include "curl_printf.h" -#define _MPRINTF_REPLACE /* use our functions only */ -#include - -/* The last #include file should be: */ +/* The last #include files should be: */ +#include "curl_memory.h" #include "memdebug.h" -/* returning zero (0) means success, everything else is treated as "failure" - with no care exactly what the failure was */ -int Curl_input_negotiate(struct connectdata *conn, bool proxy, - const char *header) +CURLcode Curl_input_negotiate(struct connectdata *conn, bool proxy, + const char *header) { + struct SessionHandle *data = conn->data; BYTE *input_token = NULL; SecBufferDesc out_buff_desc; SecBuffer out_sec_buff; SecBufferDesc in_buff_desc; SecBuffer in_sec_buff; - unsigned long context_attributes; - TimeStamp lifetime; - int ret; + SECURITY_STATUS status; + unsigned long attrs; + TimeStamp expiry; /* For Windows 9x compatibility of SSPI calls */ size_t len = 0, input_token_len = 0; - CURLcode error; + CURLcode result; /* Point to the username and password */ const char *userp; @@ -68,12 +65,12 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy, if(proxy) { userp = conn->proxyuser; passwdp = conn->proxypasswd; - neg_ctx = &conn->data->state.proxyneg; + neg_ctx = &data->state.proxyneg; } else { userp = conn->user; passwdp = conn->passwd; - neg_ctx = &conn->data->state.negotiate; + neg_ctx = &data->state.negotiate; } /* Not set means empty */ @@ -87,34 +84,36 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy, /* We finished successfully our part of authentication, but server * rejected it (since we're again here). Exit with an error since we * can't invent anything better */ - Curl_cleanup_negotiate(conn->data); - return -1; + Curl_cleanup_negotiate(data); + return CURLE_LOGIN_DENIED; } if(!neg_ctx->server_name) { /* Check proxy auth requested but no given proxy name */ if(proxy && !conn->proxy.name) - return -1; + return CURLE_BAD_FUNCTION_ARGUMENT; /* Generate our SPN */ - neg_ctx->server_name = Curl_sasl_build_spn("HTTP", - proxy ? conn->proxy.name : - conn->host.name); + neg_ctx->server_name = Curl_sasl_build_spn( + proxy ? data->set.str[STRING_PROXY_SERVICE_NAME] : + data->set.str[STRING_SERVICE_NAME], + proxy ? conn->proxy.name : conn->host.name); if(!neg_ctx->server_name) - return -1; + return CURLE_OUT_OF_MEMORY; } if(!neg_ctx->output_token) { PSecPkgInfo SecurityPackage; - ret = s_pSecFn->QuerySecurityPackageInfo((TCHAR *) TEXT("Negotiate"), - &SecurityPackage); - if(ret != SEC_E_OK) - return -1; + status = s_pSecFn->QuerySecurityPackageInfo((TCHAR *) + TEXT(SP_NAME_NEGOTIATE), + &SecurityPackage); + if(status != SEC_E_OK) + return CURLE_NOT_BUILT_IN; /* Allocate input and output buffers according to the max token size as indicated by the security package */ - neg_ctx->max_token_length = SecurityPackage->cbMaxToken; - neg_ctx->output_token = malloc(neg_ctx->max_token_length); + neg_ctx->token_max = SecurityPackage->cbMaxToken; + neg_ctx->output_token = malloc(neg_ctx->token_max); s_pSecFn->FreeContextBuffer(SecurityPackage); } @@ -129,7 +128,7 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy, if(neg_ctx->context) { /* The server rejected our authentication and hasn't suppled any more negotiation mechanisms */ - return -1; + return CURLE_LOGIN_DENIED; } /* We have to acquire credentials and allocate memory for the context */ @@ -137,13 +136,13 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy, neg_ctx->context = malloc(sizeof(CtxtHandle)); if(!neg_ctx->credentials || !neg_ctx->context) - return -1; + return CURLE_OUT_OF_MEMORY; if(userp && *userp) { /* Populate our identity structure */ - error = Curl_create_sspi_identity(userp, passwdp, &neg_ctx->identity); - if(error) - return -1; + result = Curl_create_sspi_identity(userp, passwdp, &neg_ctx->identity); + if(result) + return result; /* Allow proper cleanup of the identity structure */ neg_ctx->p_identity = &neg_ctx->identity; @@ -155,19 +154,26 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy, /* Acquire our credientials handle */ neg_ctx->status = s_pSecFn->AcquireCredentialsHandle(NULL, - (TCHAR *) TEXT("Negotiate"), + (TCHAR *) TEXT(SP_NAME_NEGOTIATE), SECPKG_CRED_OUTBOUND, NULL, neg_ctx->p_identity, NULL, NULL, - neg_ctx->credentials, &lifetime); + neg_ctx->credentials, &expiry); if(neg_ctx->status != SEC_E_OK) - return -1; + return CURLE_LOGIN_DENIED; } else { - error = Curl_base64_decode(header, - (unsigned char **)&input_token, - &input_token_len); - if(error || !input_token_len) - return -1; + result = Curl_base64_decode(header, + (unsigned char **)&input_token, + &input_token_len); + if(result) + return result; + + if(!input_token_len) { + infof(data, + "Negotiate handshake failure (empty challenge message)\n"); + + return CURLE_BAD_CONTENT_ENCODING; + } } /* Setup the "output" security buffer */ @@ -176,7 +182,7 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy, out_buff_desc.pBuffers = &out_sec_buff; out_sec_buff.BufferType = SECBUFFER_TOKEN; out_sec_buff.pvBuffer = neg_ctx->output_token; - out_sec_buff.cbBuffer = curlx_uztoul(neg_ctx->max_token_length); + out_sec_buff.cbBuffer = curlx_uztoul(neg_ctx->token_max); /* Setup the "input" security buffer if present */ if(input_token) { @@ -200,28 +206,27 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy, 0, neg_ctx->context, &out_buff_desc, - &context_attributes, - &lifetime); + &attrs, + &expiry); - Curl_safefree(input_token); + free(input_token); if(GSS_ERROR(neg_ctx->status)) - return -1; + return CURLE_OUT_OF_MEMORY; if(neg_ctx->status == SEC_I_COMPLETE_NEEDED || neg_ctx->status == SEC_I_COMPLETE_AND_CONTINUE) { neg_ctx->status = s_pSecFn->CompleteAuthToken(neg_ctx->context, &out_buff_desc); if(GSS_ERROR(neg_ctx->status)) - return -1; + return CURLE_RECV_ERROR; } neg_ctx->output_token_length = out_sec_buff.cbBuffer; - return 0; + return CURLE_OK; } - CURLcode Curl_output_negotiate(struct connectdata *conn, bool proxy) { struct negotiatedata *neg_ctx = proxy?&conn->data->state.proxyneg: @@ -258,25 +263,30 @@ CURLcode Curl_output_negotiate(struct connectdata *conn, bool proxy) static void cleanup(struct negotiatedata *neg_ctx) { + /* Free our security context */ if(neg_ctx->context) { s_pSecFn->DeleteSecurityContext(neg_ctx->context); free(neg_ctx->context); neg_ctx->context = NULL; } + /* Free our credentials handle */ if(neg_ctx->credentials) { s_pSecFn->FreeCredentialsHandle(neg_ctx->credentials); free(neg_ctx->credentials); neg_ctx->credentials = NULL; } - neg_ctx->max_token_length = 0; - Curl_safefree(neg_ctx->output_token); + /* Free our identity */ + Curl_sspi_free_identity(neg_ctx->p_identity); + neg_ctx->p_identity = NULL; + /* Free the SPN and output token */ Curl_safefree(neg_ctx->server_name); + Curl_safefree(neg_ctx->output_token); - Curl_sspi_free_identity(neg_ctx->p_identity); - neg_ctx->p_identity = NULL; + /* Reset any variables */ + neg_ctx->token_max = 0; } void Curl_cleanup_negotiate(struct SessionHandle *data) diff --git a/lib/http_proxy.c b/lib/http_proxy.c index 5343eb7..4373d62 100644 --- a/lib/http_proxy.c +++ b/lib/http_proxy.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -35,10 +35,7 @@ #include "progress.h" #include "non-ascii.h" #include "connect.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include - +#include "curl_printf.h" #include "curlx.h" #include "curl_memory.h" @@ -71,10 +68,11 @@ CURLcode Curl_proxy_connect(struct connectdata *conn) conn->data->req.protop = &http_proxy; connkeep(conn, "HTTP proxy CONNECT"); result = Curl_proxyCONNECT(conn, FIRSTSOCKET, - conn->host.name, conn->remote_port); + conn->host.name, conn->remote_port, FALSE); conn->data->req.protop = prot_save; if(CURLE_OK != result) return result; + Curl_safefree(conn->allocptr.proxyuserpwd); #else return CURLE_NOT_BUILT_IN; #endif @@ -87,12 +85,16 @@ CURLcode Curl_proxy_connect(struct connectdata *conn) * Curl_proxyCONNECT() requires that we're connected to a HTTP proxy. This * function will issue the necessary commands to get a seamless tunnel through * this proxy. After that, the socket can be used just as a normal socket. + * + * 'blocking' set to TRUE means that this function will do the entire CONNECT + * + response in a blocking fashion. Should be avoided! */ CURLcode Curl_proxyCONNECT(struct connectdata *conn, int sockindex, const char *hostname, - int remote_port) + int remote_port, + bool blocking) { int subversion=0; struct SessionHandle *data=conn->data; @@ -123,13 +125,11 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn, infof(data, "Establish HTTP proxy tunnel to %s:%hu\n", hostname, remote_port); - if(data->req.newurl) { /* This only happens if we've looped here due to authentication reasons, and we don't really use the newly cloned URL here then. Just free() it. */ - free(data->req.newurl); - data->req.newurl = NULL; - } + free(data->req.newurl); + data->req.newurl = NULL; /* initialize a dynamic send-buffer */ req_buffer = Curl_add_buffer_init(); @@ -139,7 +139,7 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn, host_port = aprintf("%s:%hu", hostname, remote_port); if(!host_port) { - free(req_buffer); + Curl_add_buffer_free(req_buffer); return CURLE_OUT_OF_MEMORY; } @@ -148,7 +148,7 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn, free(host_port); - if(CURLE_OK == result) { + if(!result) { char *host=(char *)""; const char *proxyconn=""; const char *useragent=""; @@ -159,7 +159,7 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn, hostname, conn->bits.ipv6_ip?"]":"", remote_port); if(!hostheader) { - free(req_buffer); + Curl_add_buffer_free(req_buffer); return CURLE_OUT_OF_MEMORY; } @@ -167,7 +167,7 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn, host = aprintf("Host: %s\r\n", hostheader); if(!host) { free(hostheader); - free(req_buffer); + Curl_add_buffer_free(req_buffer); return CURLE_OUT_OF_MEMORY; } } @@ -197,14 +197,14 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn, free(host); free(hostheader); - if(CURLE_OK == result) + if(!result) result = Curl_add_custom_headers(conn, TRUE, req_buffer); - if(CURLE_OK == result) + if(!result) /* CRLF terminate the request */ result = Curl_add_bufferf(req_buffer, "\r\n"); - if(CURLE_OK == result) { + if(!result) { /* Send the connect request to the proxy */ /* BLOCKING */ result = @@ -216,7 +216,7 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn, failf(data, "Failed sending CONNECT to proxy"); } - Curl_safefree(req_buffer); + Curl_add_buffer_free(req_buffer); if(result) return result; @@ -229,12 +229,14 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn, return CURLE_RECV_ERROR; } - if(0 == Curl_socket_ready(tunnelsocket, CURL_SOCKET_BAD, 0)) - /* return so we'll be called again polling-style */ - return CURLE_OK; - else { - DEBUGF(infof(data, - "Read response immediately from proxy CONNECT\n")); + if(!blocking) { + if(0 == Curl_socket_ready(tunnelsocket, CURL_SOCKET_BAD, 0)) + /* return so we'll be called again polling-style */ + return CURLE_OK; + else { + DEBUGF(infof(data, + "Read response immediately from proxy CONNECT\n")); + } } /* at this point, the tunnel_connecting phase is over. */ @@ -252,7 +254,6 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn, nread=0; perline=0; - keepon=TRUE; while((nreadbits.proxy_connect_closed = TRUE; - infof(data, "Proxy CONNECT connection closed"); + infof(data, "Proxy CONNECT connection closed\n"); } else { error = SELECT_ERROR; @@ -468,7 +469,7 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn, result = Curl_http_input_auth(conn, proxy, auth); - Curl_safefree(auth); + free(auth); if(result) return result; @@ -555,11 +556,8 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn, infof(data, "Connect me again please\n"); } else { - if(data->req.newurl) { - /* this won't be used anymore for the CONNECT so free it now */ - free(data->req.newurl); - data->req.newurl = NULL; - } + free(data->req.newurl); + data->req.newurl = NULL; /* failure, close this connection to avoid re-use */ connclose(conn, "proxy CONNECT failure"); Curl_closesocket(conn, conn->sock[sockindex]); diff --git a/lib/http_proxy.h b/lib/http_proxy.h index 2b5e9c9..9c4f020 100644 --- a/lib/http_proxy.h +++ b/lib/http_proxy.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -26,7 +26,8 @@ /* ftp can use this as well */ CURLcode Curl_proxyCONNECT(struct connectdata *conn, int tunnelsocket, - const char *hostname, int remote_port); + const char *hostname, int remote_port, + bool blocking); /* Default proxy timeout in milliseconds */ #define PROXY_TIMEOUT (3600*1000) @@ -34,7 +35,7 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn, CURLcode Curl_proxy_connect(struct connectdata *conn); #else -#define Curl_proxyCONNECT(x,y,z,w) CURLE_NOT_BUILT_IN +#define Curl_proxyCONNECT(x,y,z,w,v) CURLE_NOT_BUILT_IN #define Curl_proxy_connect(x) CURLE_OK #endif diff --git a/lib/idn_win32.c b/lib/idn_win32.c index 464964b..b369723 100644 --- a/lib/idn_win32.c +++ b/lib/idn_win32.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -35,8 +35,31 @@ #include "memdebug.h" #ifdef WANT_IDN_PROTOTYPES -WINBASEAPI int WINAPI IdnToAscii(DWORD, const WCHAR *, int, WCHAR *, int); -WINBASEAPI int WINAPI IdnToUnicode(DWORD, const WCHAR *, int, WCHAR *, int); +# if defined(_SAL_VERSION) +WINNORMALIZEAPI int WINAPI +IdnToAscii(_In_ DWORD dwFlags, + _In_reads_(cchUnicodeChar) LPCWSTR lpUnicodeCharStr, + _In_ int cchUnicodeChar, + _Out_writes_opt_(cchASCIIChar) LPWSTR lpASCIICharStr, + _In_ int cchASCIIChar); +WINNORMALIZEAPI int WINAPI +IdnToUnicode(_In_ DWORD dwFlags, + _In_reads_(cchASCIIChar) LPCWSTR lpASCIICharStr, + _In_ int cchASCIIChar, + _Out_writes_opt_(cchUnicodeChar) LPWSTR lpUnicodeCharStr, + _In_ int cchUnicodeChar); +# else +WINBASEAPI int WINAPI IdnToAscii(DWORD dwFlags, + const WCHAR *lpUnicodeCharStr, + int cchUnicodeChar, + WCHAR *lpASCIICharStr, + int cchASCIIChar); +WINBASEAPI int WINAPI IdnToUnicode(DWORD dwFlags, + const WCHAR *lpASCIICharStr, + int cchASCIIChar, + WCHAR *lpUnicodeCharStr, + int cchUnicodeChar); +# endif #endif #define IDN_MAX_LENGTH 255 diff --git a/lib/if2ip.c b/lib/if2ip.c index 05ae7d6..6e6f969 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2013, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -53,9 +53,7 @@ #include "inet_ntop.h" #include "strequal.h" #include "if2ip.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include +#include "curl_printf.h" #include "curl_memory.h" /* The last #include file should be: */ @@ -63,6 +61,38 @@ /* ------------------------------------------------------------------ */ +/* Return the scope of the given address. */ +unsigned int Curl_ipv6_scope(const struct sockaddr *sa) +{ +#ifndef ENABLE_IPV6 + (void) sa; +#else + if(sa->sa_family == AF_INET6) { + const struct sockaddr_in6 * sa6 = (const struct sockaddr_in6 *) sa; + const unsigned char * b = sa6->sin6_addr.s6_addr; + unsigned short w = (unsigned short) ((b[0] << 8) | b[1]); + + switch(w & 0xFFC0) { + case 0xFE80: + return IPV6_SCOPE_LINKLOCAL; + case 0xFEC0: + return IPV6_SCOPE_SITELOCAL; + case 0x0000: + w = b[1] | b[2] | b[3] | b[4] | b[5] | b[6] | b[7] | b[8] | b[9] | + b[10] | b[11] | b[12] | b[13] | b[14]; + if(w || b[15] != 0x01) + break; + return IPV6_SCOPE_NODELOCAL; + default: + break; + } + } +#endif + + return IPV6_SCOPE_GLOBAL; +} + + #if defined(HAVE_GETIFADDRS) bool Curl_if_is_interface_name(const char *interf) @@ -84,41 +114,58 @@ bool Curl_if_is_interface_name(const char *interf) } if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope, - const char *interf, char *buf, int buf_size) + unsigned int remote_scope_id, const char *interf, + char *buf, int buf_size) { struct ifaddrs *iface, *head; if2ip_result_t res = IF2IP_NOT_FOUND; #ifndef ENABLE_IPV6 (void) remote_scope; + +#ifndef HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID + (void) remote_scope_id; +#endif + #endif if(getifaddrs(&head) >= 0) { - for(iface=head; iface != NULL; iface=iface->ifa_next) { + for(iface = head; iface != NULL; iface=iface->ifa_next) { if(iface->ifa_addr != NULL) { if(iface->ifa_addr->sa_family == af) { if(curl_strequal(iface->ifa_name, interf)) { void *addr; char *ip; - char scope[12]=""; + char scope[12] = ""; char ipstr[64]; #ifdef ENABLE_IPV6 if(af == AF_INET6) { unsigned int scopeid = 0; + unsigned int ifscope = Curl_ipv6_scope(iface->ifa_addr); + + if(ifscope != remote_scope) { + /* We are interested only in interface addresses whose + scope matches the remote address we want to + connect to: global for global, link-local for + link-local, etc... */ + if(res == IF2IP_NOT_FOUND) res = IF2IP_AF_NOT_SUPPORTED; + continue; + } + addr = &((struct sockaddr_in6 *)iface->ifa_addr)->sin6_addr; #ifdef HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID /* Include the scope of this interface as part of the address */ scopeid = ((struct sockaddr_in6 *)iface->ifa_addr)->sin6_scope_id; -#endif - if(scopeid != remote_scope) { - /* We are interested only in interface addresses whose - scope ID matches the remote address we want to - connect to: global (0) for global, link-local for - link-local, etc... */ - if(res == IF2IP_NOT_FOUND) res = IF2IP_AF_NOT_SUPPORTED; + + /* If given, scope id should match. */ + if(remote_scope_id && scopeid != remote_scope_id) { + if(res == IF2IP_NOT_FOUND) + res = IF2IP_AF_NOT_SUPPORTED; + continue; } +#endif if(scopeid) snprintf(scope, sizeof(scope), "%%%u", scopeid); } @@ -137,8 +184,10 @@ if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope, } } } + freeifaddrs(head); } + return res; } @@ -149,12 +198,13 @@ bool Curl_if_is_interface_name(const char *interf) /* This is here just to support the old interfaces */ char buf[256]; - return (Curl_if2ip(AF_INET, 0, interf, buf, sizeof(buf)) == + return (Curl_if2ip(AF_INET, 0 /* unused */, 0, interf, buf, sizeof(buf)) == IF2IP_NOT_FOUND) ? FALSE : TRUE; } if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope, - const char *interf, char *buf, int buf_size) + unsigned int remote_scope_id, const char *interf, + char *buf, int buf_size) { struct ifreq req; struct in_addr in; @@ -163,6 +213,7 @@ if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope, size_t len; (void)remote_scope; + (void)remote_scope_id; if(!interf || (af != AF_INET)) return IF2IP_NOT_FOUND; @@ -205,10 +256,12 @@ bool Curl_if_is_interface_name(const char *interf) } if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope, - const char *interf, char *buf, int buf_size) + unsigned int remote_scope_id, const char *interf, + char *buf, int buf_size) { (void) af; (void) remote_scope; + (void) remote_scope_id; (void) interf; (void) buf; (void) buf_size; diff --git a/lib/if2ip.h b/lib/if2ip.h index ac58752..78bb0bd 100644 --- a/lib/if2ip.h +++ b/lib/if2ip.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -23,6 +23,14 @@ ***************************************************************************/ #include "curl_setup.h" +/* IPv6 address scopes. */ +#define IPV6_SCOPE_GLOBAL 0 /* Global scope. */ +#define IPV6_SCOPE_LINKLOCAL 1 /* Link-local scope. */ +#define IPV6_SCOPE_SITELOCAL 2 /* Site-local scope (deprecated). */ +#define IPV6_SCOPE_NODELOCAL 3 /* Loopback. */ + +unsigned int Curl_ipv6_scope(const struct sockaddr *sa); + bool Curl_if_is_interface_name(const char *interf); typedef enum { @@ -32,7 +40,8 @@ typedef enum { } if2ip_result_t; if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope, - const char *interf, char *buf, int buf_size); + unsigned int remote_scope_id, const char *interf, + char *buf, int buf_size); #ifdef __INTERIX diff --git a/lib/imap.c b/lib/imap.c index 9fc4728..e6d83f2 100644 --- a/lib/imap.c +++ b/lib/imap.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -61,7 +61,6 @@ #include #include "urldata.h" #include "sendf.h" -#include "if2ip.h" #include "hostip.h" #include "progress.h" #include "transfer.h" @@ -81,9 +80,7 @@ #include "rawstr.h" #include "curl_sasl.h" #include "warnless.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include +#include "curl_printf.h" #include "curl_memory.h" /* The last #include file should be: */ @@ -106,10 +103,12 @@ static CURLcode imap_sendf(struct connectdata *conn, const char *fmt, ...); static CURLcode imap_parse_url_options(struct connectdata *conn); static CURLcode imap_parse_url_path(struct connectdata *conn); static CURLcode imap_parse_custom_request(struct connectdata *conn); -static CURLcode imap_calc_sasl_details(struct connectdata *conn, - const char **mech, - char **initresp, size_t *len, - imapstate *state1, imapstate *state2); +static CURLcode imap_perform_authenticate(struct connectdata *conn, + const char *mech, + const char *initresp); +static CURLcode imap_continue_authenticate(struct connectdata *conn, + const char *resp); +static void imap_get_message(char *buffer, char** outptr); /* * IMAP protocol handler. @@ -132,7 +131,7 @@ const struct Curl_handler Curl_handler_imap = { ZERO_NULL, /* readwrite */ PORT_IMAP, /* defport */ CURLPROTO_IMAP, /* protocol */ - PROTOPT_CLOSEACTION | PROTOPT_NEEDSPWD /* flags */ + PROTOPT_CLOSEACTION /* flags */ }; #ifdef USE_SSL @@ -157,8 +156,7 @@ const struct Curl_handler Curl_handler_imaps = { ZERO_NULL, /* readwrite */ PORT_IMAPS, /* defport */ CURLPROTO_IMAPS, /* protocol */ - PROTOPT_CLOSEACTION | PROTOPT_SSL | - PROTOPT_NEEDSPWD /* flags */ + PROTOPT_CLOSEACTION | PROTOPT_SSL /* flags */ }; #endif @@ -214,6 +212,18 @@ static const struct Curl_handler Curl_handler_imaps_proxy = { #endif #endif +/* SASL parameters for the imap protocol */ +static const struct SASLproto saslimap = { + "imap", /* The service name */ + '+', /* Code received when continuation is expected */ + 'O', /* Code to receive upon authentication success */ + 0, /* Maximum initial response length (no max) */ + imap_perform_authenticate, /* Send authentication command */ + imap_continue_authenticate, /* Send authentication continuation */ + imap_get_message /* Get SASL response message */ +}; + + #ifdef USE_SSL static void imap_to_imaps(struct connectdata *conn) { @@ -354,16 +364,7 @@ static bool imap_endofresp(struct connectdata *conn, char *line, size_t len, (len >= 2 && !memcmp("+ ", line, 2))) { switch(imapc->state) { /* States which are interested in continuation responses */ - case IMAP_AUTHENTICATE_PLAIN: - case IMAP_AUTHENTICATE_LOGIN: - case IMAP_AUTHENTICATE_LOGIN_PASSWD: - case IMAP_AUTHENTICATE_CRAMMD5: - case IMAP_AUTHENTICATE_DIGESTMD5: - case IMAP_AUTHENTICATE_DIGESTMD5_RESP: - case IMAP_AUTHENTICATE_NTLM: - case IMAP_AUTHENTICATE_NTLM_TYPE2MSG: - case IMAP_AUTHENTICATE_XOAUTH2: - case IMAP_AUTHENTICATE_FINAL: + case IMAP_AUTHENTICATE: case IMAP_APPEND: *resp = '+'; break; @@ -426,20 +427,7 @@ static void state(struct connectdata *conn, imapstate newstate) "CAPABILITY", "STARTTLS", "UPGRADETLS", - "AUTHENTICATE_PLAIN", - "AUTHENTICATE_LOGIN", - "AUTHENTICATE_LOGIN_PASSWD", - "AUTHENTICATE_CRAMMD5", - "AUTHENTICATE_DIGESTMD5", - "AUTHENTICATE_DIGESTMD5_RESP", - "AUTHENTICATE_NTLM", - "AUTHENTICATE_NTLM_TYPE2MSG", - "AUTHENTICATE_GSSAPI", - "AUTHENTICATE_GSSAPI_TOKEN", - "AUTHENTICATE_GSSAPI_NO_DATA", - "AUTHENTICATE_XOAUTH2", - "AUTHENTICATE_CANCEL", - "AUTHENTICATE_FINAL", + "AUTHENTICATE", "LOGIN", "LIST", "SELECT", @@ -472,9 +460,9 @@ static CURLcode imap_perform_capability(struct connectdata *conn) CURLcode result = CURLE_OK; struct imap_conn *imapc = &conn->proto.imapc; - imapc->authmechs = 0; /* No known authentication mechanisms yet */ - imapc->authused = 0; /* Clear the authentication mechanism used */ - imapc->tls_supported = FALSE; /* Clear the TLS capability */ + imapc->sasl.authmechs = SASL_AUTH_NONE; /* No known auth. mechanisms yet */ + imapc->sasl.authused = SASL_AUTH_NONE; /* Clear the auth. mechanism used */ + imapc->tls_supported = FALSE; /* Clear the TLS capability */ /* Send the CAPABILITY command */ result = imap_sendf(conn, "CAPABILITY"); @@ -559,8 +547,8 @@ static CURLcode imap_perform_login(struct connectdata *conn) result = imap_sendf(conn, "LOGIN %s %s", user ? user : "", passwd ? passwd : ""); - Curl_safefree(user); - Curl_safefree(passwd); + free(user); + free(passwd); if(!result) state(conn, IMAP_LOGIN); @@ -577,24 +565,17 @@ static CURLcode imap_perform_login(struct connectdata *conn) */ static CURLcode imap_perform_authenticate(struct connectdata *conn, const char *mech, - const char *initresp, - imapstate state1, imapstate state2) + const char *initresp) { CURLcode result = CURLE_OK; if(initresp) { /* Send the AUTHENTICATE command with the initial response */ result = imap_sendf(conn, "AUTHENTICATE %s %s", mech, initresp); - - if(!result) - state(conn, state2); } else { /* Send the AUTHENTICATE command */ result = imap_sendf(conn, "AUTHENTICATE %s", mech); - - if(!result) - state(conn, state1); } return result; @@ -602,6 +583,20 @@ static CURLcode imap_perform_authenticate(struct connectdata *conn, /*********************************************************************** * + * imap_continue_authenticate() + * + * Sends SASL continuation data or cancellation. + */ +static CURLcode imap_continue_authenticate(struct connectdata *conn, + const char *resp) +{ + struct imap_conn *imapc = &conn->proto.imapc; + + return Curl_pp_sendf(&imapc->pp, "%s", resp); +} + +/*********************************************************************** + * * imap_perform_authentication() * * Initiates the authentication sequence, with the appropriate SASL @@ -612,33 +607,22 @@ static CURLcode imap_perform_authentication(struct connectdata *conn) { CURLcode result = CURLE_OK; struct imap_conn *imapc = &conn->proto.imapc; - const char *mech = NULL; - char *initresp = NULL; - size_t len = 0; - imapstate state1 = IMAP_STOP; - imapstate state2 = IMAP_STOP; + saslprogress progress; - /* Check we have a username and password to authenticate with and end the + /* Check we have enough data to authenticate with and end the connect phase if we don't */ - if(!conn->bits.user_passwd) { + if(!Curl_sasl_can_authenticate(&imapc->sasl, conn)) { state(conn, IMAP_STOP); - return result; } /* Calculate the SASL login details */ - result = imap_calc_sasl_details(conn, &mech, &initresp, &len, &state1, - &state2); + result = Curl_sasl_start(&imapc->sasl, conn, imapc->ir_supported, &progress); if(!result) { - if(mech && (imapc->preftype & IMAP_TYPE_SASL)) { - /* Perform SASL based authentication */ - result = imap_perform_authenticate(conn, mech, initresp, state1, state2); - - Curl_safefree(initresp); - } - else if((!imapc->login_disabled) && - (imapc->preftype & IMAP_TYPE_CLEARTEXT)) + if(progress == SASL_INPROGRESS) + state(conn, IMAP_AUTHENTICATE); + else if(!imapc->login_disabled && (imapc->preftype & IMAP_TYPE_CLEARTEXT)) /* Perform clear text authentication */ result = imap_perform_login(conn); else { @@ -677,7 +661,7 @@ static CURLcode imap_perform_list(struct connectdata *conn) /* Send the LIST command */ result = imap_sendf(conn, "LIST \"%s\" *", mailbox); - Curl_safefree(mailbox); + free(mailbox); } if(!result) @@ -718,7 +702,7 @@ static CURLcode imap_perform_select(struct connectdata *conn) /* Send the SELECT command */ result = imap_sendf(conn, "SELECT %s", mailbox); - Curl_safefree(mailbox); + free(mailbox); if(!result) state(conn, IMAP_SELECT); @@ -793,7 +777,7 @@ static CURLcode imap_perform_append(struct connectdata *conn) result = imap_sendf(conn, "APPEND %s (\\Seen) {%" CURL_FORMAT_CURL_OFF_T "}", mailbox, conn->data->state.infilesize); - Curl_safefree(mailbox); + free(mailbox); if(!result) state(conn, IMAP_APPEND); @@ -915,26 +899,16 @@ static CURLcode imap_state_capability_resp(struct connectdata *conn, /* Do we have a SASL based authentication mechanism? */ else if(wordlen > 5 && !memcmp(line, "AUTH=", 5)) { + size_t llen; + unsigned int mechbit; + line += 5; wordlen -= 5; /* Test the word for a matching authentication mechanism */ - if(sasl_mech_equal(line, wordlen, SASL_MECH_STRING_LOGIN)) - imapc->authmechs |= SASL_MECH_LOGIN; - else if(sasl_mech_equal(line, wordlen, SASL_MECH_STRING_PLAIN)) - imapc->authmechs |= SASL_MECH_PLAIN; - else if(sasl_mech_equal(line, wordlen, SASL_MECH_STRING_CRAM_MD5)) - imapc->authmechs |= SASL_MECH_CRAM_MD5; - else if(sasl_mech_equal(line, wordlen, SASL_MECH_STRING_DIGEST_MD5)) - imapc->authmechs |= SASL_MECH_DIGEST_MD5; - else if(sasl_mech_equal(line, wordlen, SASL_MECH_STRING_GSSAPI)) - imapc->authmechs |= SASL_MECH_GSSAPI; - else if(sasl_mech_equal(line, wordlen, SASL_MECH_STRING_EXTERNAL)) - imapc->authmechs |= SASL_MECH_EXTERNAL; - else if(sasl_mech_equal(line, wordlen, SASL_MECH_STRING_NTLM)) - imapc->authmechs |= SASL_MECH_NTLM; - else if(sasl_mech_equal(line, wordlen, SASL_MECH_STRING_XOAUTH2)) - imapc->authmechs |= SASL_MECH_XOAUTH2; + if((mechbit = Curl_sasl_decode_mech(line, wordlen, &llen)) && + llen == wordlen) + imapc->sasl.authmechs |= mechbit; } line += wordlen; @@ -987,569 +961,36 @@ static CURLcode imap_state_starttls_resp(struct connectdata *conn, return result; } -/* For AUTHENTICATE PLAIN (without initial response) responses */ -static CURLcode imap_state_auth_plain_resp(struct connectdata *conn, - int imapcode, - imapstate instate) -{ - CURLcode result = CURLE_OK; - struct SessionHandle *data = conn->data; - size_t len = 0; - char *plainauth = NULL; - - (void)instate; /* no use for this yet */ - - if(imapcode != '+') { - failf(data, "Access denied. %c", imapcode); - result = CURLE_LOGIN_DENIED; - } - else { - /* Create the authorisation message */ - result = Curl_sasl_create_plain_message(data, conn->user, conn->passwd, - &plainauth, &len); - if(!result && plainauth) { - /* Send the message */ - result = Curl_pp_sendf(&conn->proto.imapc.pp, "%s", plainauth); - - if(!result) - state(conn, IMAP_AUTHENTICATE_FINAL); - } - } - - Curl_safefree(plainauth); - - return result; -} - -/* For AUTHENTICATE LOGIN (without initial response) responses */ -static CURLcode imap_state_auth_login_resp(struct connectdata *conn, - int imapcode, - imapstate instate) -{ - CURLcode result = CURLE_OK; - struct SessionHandle *data = conn->data; - size_t len = 0; - char *authuser = NULL; - - (void)instate; /* no use for this yet */ - - if(imapcode != '+') { - failf(data, "Access denied: %d", imapcode); - result = CURLE_LOGIN_DENIED; - } - else { - /* Create the user message */ - result = Curl_sasl_create_login_message(data, conn->user, - &authuser, &len); - if(!result && authuser) { - /* Send the user */ - result = Curl_pp_sendf(&conn->proto.imapc.pp, "%s", authuser); - - if(!result) - state(conn, IMAP_AUTHENTICATE_LOGIN_PASSWD); - } - } - - Curl_safefree(authuser); - - return result; -} - -/* For AUTHENTICATE LOGIN user entry responses */ -static CURLcode imap_state_auth_login_password_resp(struct connectdata *conn, - int imapcode, - imapstate instate) -{ - CURLcode result = CURLE_OK; - struct SessionHandle *data = conn->data; - size_t len = 0; - char *authpasswd = NULL; - - (void)instate; /* no use for this yet */ - - if(imapcode != '+') { - failf(data, "Access denied: %d", imapcode); - result = CURLE_LOGIN_DENIED; - } - else { - /* Create the password message */ - result = Curl_sasl_create_login_message(data, conn->passwd, - &authpasswd, &len); - if(!result && authpasswd) { - /* Send the password */ - result = Curl_pp_sendf(&conn->proto.imapc.pp, "%s", authpasswd); - - if(!result) - state(conn, IMAP_AUTHENTICATE_FINAL); - } - } - - Curl_safefree(authpasswd); - - return result; -} - -#ifndef CURL_DISABLE_CRYPTO_AUTH -/* For AUTHENTICATE CRAM-MD5 responses */ -static CURLcode imap_state_auth_cram_resp(struct connectdata *conn, - int imapcode, - imapstate instate) -{ - CURLcode result = CURLE_OK; - struct SessionHandle *data = conn->data; - char *chlg = NULL; - char *chlg64 = NULL; - char *rplyb64 = NULL; - size_t len = 0; - - (void)instate; /* no use for this yet */ - - if(imapcode != '+') { - failf(data, "Access denied: %d", imapcode); - return CURLE_LOGIN_DENIED; - } - - /* Get the challenge message */ - imap_get_message(data->state.buffer, &chlg64); - - /* Decode the challenge message */ - result = Curl_sasl_decode_cram_md5_message(chlg64, &chlg, &len); - if(result) { - /* Send the cancellation */ - result = Curl_pp_sendf(&conn->proto.imapc.pp, "%s", "*"); - - if(!result) - state(conn, IMAP_AUTHENTICATE_CANCEL); - } - else { - /* Create the response message */ - result = Curl_sasl_create_cram_md5_message(data, chlg, conn->user, - conn->passwd, &rplyb64, &len); - if(!result && rplyb64) { - /* Send the response */ - result = Curl_pp_sendf(&conn->proto.imapc.pp, "%s", rplyb64); - - if(!result) - state(conn, IMAP_AUTHENTICATE_FINAL); - } - } - - Curl_safefree(chlg); - Curl_safefree(rplyb64); - - return result; -} - -/* For AUTHENTICATE DIGEST-MD5 challenge responses */ -static CURLcode imap_state_auth_digest_resp(struct connectdata *conn, - int imapcode, - imapstate instate) -{ - CURLcode result = CURLE_OK; - struct SessionHandle *data = conn->data; - char *chlg64 = NULL; - char *rplyb64 = NULL; - size_t len = 0; - - (void)instate; /* no use for this yet */ - - if(imapcode != '+') { - failf(data, "Access denied: %d", imapcode); - return CURLE_LOGIN_DENIED; - } - - /* Get the challenge message */ - imap_get_message(data->state.buffer, &chlg64); - - /* Create the response message */ - result = Curl_sasl_create_digest_md5_message(data, chlg64, - conn->user, conn->passwd, - "imap", &rplyb64, &len); - if(result) { - if(result == CURLE_BAD_CONTENT_ENCODING) { - /* Send the cancellation */ - result = Curl_pp_sendf(&conn->proto.imapc.pp, "%s", "*"); - - if(!result) - state(conn, IMAP_AUTHENTICATE_CANCEL); - } - } - else { - /* Send the response */ - result = Curl_pp_sendf(&conn->proto.imapc.pp, "%s", rplyb64); - - if(!result) - state(conn, IMAP_AUTHENTICATE_DIGESTMD5_RESP); - } - - Curl_safefree(rplyb64); - - return result; -} - -/* For AUTHENTICATE DIGEST-MD5 challenge-response responses */ -static CURLcode imap_state_auth_digest_resp_resp(struct connectdata *conn, - int imapcode, - imapstate instate) -{ - CURLcode result = CURLE_OK; - struct SessionHandle *data = conn->data; - - (void)instate; /* no use for this yet */ - - if(imapcode != '+') { - failf(data, "Authentication failed: %d", imapcode); - result = CURLE_LOGIN_DENIED; - } - else { - /* Send an empty response */ - result = Curl_pp_sendf(&conn->proto.imapc.pp, "%s", ""); - - if(!result) - state(conn, IMAP_AUTHENTICATE_FINAL); - } - - return result; -} -#endif - -#ifdef USE_NTLM -/* For AUTHENTICATE NTLM (without initial response) responses */ -static CURLcode imap_state_auth_ntlm_resp(struct connectdata *conn, - int imapcode, - imapstate instate) -{ - CURLcode result = CURLE_OK; - struct SessionHandle *data = conn->data; - size_t len = 0; - char *type1msg = NULL; - - (void)instate; /* no use for this yet */ - - if(imapcode != '+') { - failf(data, "Access denied: %d", imapcode); - result = CURLE_LOGIN_DENIED; - } - else { - /* Create the type-1 message */ - result = Curl_sasl_create_ntlm_type1_message(conn->user, conn->passwd, - &conn->ntlm, - &type1msg, &len); - if(!result && type1msg) { - /* Send the message */ - result = Curl_pp_sendf(&conn->proto.imapc.pp, "%s", type1msg); - - if(!result) - state(conn, IMAP_AUTHENTICATE_NTLM_TYPE2MSG); - } - } - - Curl_safefree(type1msg); - - return result; -} - -/* For NTLM type-2 responses (sent in reponse to our type-1 message) */ -static CURLcode imap_state_auth_ntlm_type2msg_resp(struct connectdata *conn, - int imapcode, - imapstate instate) -{ - CURLcode result = CURLE_OK; - struct SessionHandle *data = conn->data; - char *type2msg = NULL; - char *type3msg = NULL; - size_t len = 0; - - (void)instate; /* no use for this yet */ - - if(imapcode != '+') { - failf(data, "Access denied: %d", imapcode); - result = CURLE_LOGIN_DENIED; - } - else { - /* Get the challenge message */ - imap_get_message(data->state.buffer, &type2msg); - - /* Decode the type-2 message */ - result = Curl_sasl_decode_ntlm_type2_message(data, type2msg, &conn->ntlm); - if(result) { - /* Send the cancellation */ - result = Curl_pp_sendf(&conn->proto.imapc.pp, "%s", "*"); - - if(!result) - state(conn, IMAP_AUTHENTICATE_CANCEL); - } - else { - /* Create the type-3 message */ - result = Curl_sasl_create_ntlm_type3_message(data, conn->user, - conn->passwd, &conn->ntlm, - &type3msg, &len); - if(!result && type3msg) { - /* Send the message */ - result = Curl_pp_sendf(&conn->proto.imapc.pp, "%s", type3msg); - - if(!result) - state(conn, IMAP_AUTHENTICATE_FINAL); - } - } - } - - Curl_safefree(type3msg); - - return result; -} -#endif - -#if defined(USE_WINDOWS_SSPI) -/* For AUTHENTICATE GSSAPI (without initial response) responses */ -static CURLcode imap_state_auth_gssapi_resp(struct connectdata *conn, - int imapcode, - imapstate instate) -{ - CURLcode result = CURLE_OK; - struct SessionHandle *data = conn->data; - struct imap_conn *imapc = &conn->proto.imapc; - size_t len = 0; - char *respmsg = NULL; - - (void)instate; /* no use for this yet */ - - if(imapcode != '+') { - failf(data, "Access denied: %d", imapcode); - result = CURLE_LOGIN_DENIED; - } - else { - /* Create the initial response message */ - result = Curl_sasl_create_gssapi_user_message(data, conn->user, - conn->passwd, "imap", - imapc->mutual_auth, - NULL, &conn->krb5, - &respmsg, &len); - if(!result && respmsg) { - /* Send the message */ - result = Curl_pp_sendf(&imapc->pp, "%s", respmsg); - - if(!result) - state(conn, IMAP_AUTHENTICATE_GSSAPI_TOKEN); - } - } - - Curl_safefree(respmsg); - - return result; -} - -/* For AUTHENTICATE GSSAPI user token responses */ -static CURLcode imap_state_auth_gssapi_token_resp(struct connectdata *conn, - int imapcode, - imapstate instate) +/* For SASL authentication responses */ +static CURLcode imap_state_auth_resp(struct connectdata *conn, + int imapcode, + imapstate instate) { CURLcode result = CURLE_OK; struct SessionHandle *data = conn->data; struct imap_conn *imapc = &conn->proto.imapc; - char *chlgmsg = NULL; - char *respmsg = NULL; - size_t len = 0; + saslprogress progress; (void)instate; /* no use for this yet */ - if(imapcode != '+') { - failf(data, "Access denied: %d", imapcode); - result = CURLE_LOGIN_DENIED; - } - else { - /* Get the challenge message */ - imap_get_message(data->state.buffer, &chlgmsg); - - if(imapc->mutual_auth) - /* Decode the user token challenge and create the optional response - message */ - result = Curl_sasl_create_gssapi_user_message(data, NULL, NULL, NULL, - imapc->mutual_auth, - chlgmsg, &conn->krb5, - &respmsg, &len); - else - /* Decode the security challenge and create the response message */ - result = Curl_sasl_create_gssapi_security_message(data, chlgmsg, - &conn->krb5, - &respmsg, &len); - - if(result) { - if(result == CURLE_BAD_CONTENT_ENCODING) { - /* Send the cancellation */ - result = Curl_pp_sendf(&imapc->pp, "%s", "*"); - - if(!result) - state(conn, IMAP_AUTHENTICATE_CANCEL); - } - } - else { - /* Send the response */ - if(respmsg) - result = Curl_pp_sendf(&imapc->pp, "%s", respmsg); - else - result = Curl_pp_sendf(&imapc->pp, "%s", ""); - - if(!result) - state(conn, (imapc->mutual_auth ? IMAP_AUTHENTICATE_GSSAPI_NO_DATA : - IMAP_AUTHENTICATE_FINAL)); - } - } - - Curl_safefree(respmsg); - - return result; -} - -/* For AUTHENTICATE GSSAPI no data responses */ -static CURLcode imap_state_auth_gssapi_no_data_resp(struct connectdata *conn, - int imapcode, - imapstate instate) -{ - CURLcode result = CURLE_OK; - struct SessionHandle *data = conn->data; - char *chlgmsg = NULL; - char *respmsg = NULL; - size_t len = 0; - - (void)instate; /* no use for this yet */ - - if(imapcode != '+') { - failf(data, "Access denied: %d", imapcode); - result = CURLE_LOGIN_DENIED; - } - else { - /* Get the challenge message */ - imap_get_message(data->state.buffer, &chlgmsg); - - /* Decode the security challenge and create the response message */ - result = Curl_sasl_create_gssapi_security_message(data, chlgmsg, - &conn->krb5, - &respmsg, &len); - if(result) { - if(result == CURLE_BAD_CONTENT_ENCODING) { - /* Send the cancellation */ - result = Curl_pp_sendf(&conn->proto.imapc.pp, "%s", "*"); - - if(!result) - state(conn, IMAP_AUTHENTICATE_CANCEL); - } - } - else { - /* Send the response */ - if(respmsg) { - result = Curl_pp_sendf(&conn->proto.imapc.pp, "%s", respmsg); - - if(!result) - state(conn, IMAP_AUTHENTICATE_FINAL); + result = Curl_sasl_continue(&imapc->sasl, conn, imapcode, &progress); + if(!result) + switch(progress) { + case SASL_DONE: + state(conn, IMAP_STOP); /* Authenticated */ + break; + case SASL_IDLE: /* No mechanism left after cancellation */ + if((!imapc->login_disabled) && (imapc->preftype & IMAP_TYPE_CLEARTEXT)) + /* Perform clear text authentication */ + result = imap_perform_login(conn); + else { + failf(data, "Authentication cancelled"); + result = CURLE_LOGIN_DENIED; } + break; + default: + break; } - } - - Curl_safefree(respmsg); - - return result; -} -#endif - -/* For AUTHENTICATE XOAUTH2 (without initial response) responses */ -static CURLcode imap_state_auth_xoauth2_resp(struct connectdata *conn, - int imapcode, - imapstate instate) -{ - CURLcode result = CURLE_OK; - struct SessionHandle *data = conn->data; - size_t len = 0; - char *xoauth = NULL; - - (void)instate; /* no use for this yet */ - - if(imapcode != '+') { - failf(data, "Access denied: %d", imapcode); - result = CURLE_LOGIN_DENIED; - } - else { - /* Create the authorisation message */ - result = Curl_sasl_create_xoauth2_message(conn->data, conn->user, - conn->xoauth2_bearer, - &xoauth, &len); - if(!result && xoauth) { - /* Send the message */ - result = Curl_pp_sendf(&conn->proto.imapc.pp, "%s", xoauth); - - if(!result) - state(conn, IMAP_AUTHENTICATE_FINAL); - } - } - - Curl_safefree(xoauth); - - return result; -} - -/* For AUTHENTICATE cancellation responses */ -static CURLcode imap_state_auth_cancel_resp(struct connectdata *conn, - int imapcode, - imapstate instate) -{ - CURLcode result = CURLE_OK; - struct SessionHandle *data = conn->data; - struct imap_conn *imapc = &conn->proto.imapc; - const char *mech = NULL; - char *initresp = NULL; - size_t len = 0; - imapstate state1 = IMAP_STOP; - imapstate state2 = IMAP_STOP; - - (void)imapcode; - (void)instate; /* no use for this yet */ - - /* Remove the offending mechanism from the supported list */ - imapc->authmechs ^= imapc->authused; - - /* Calculate alternative SASL login details */ - result = imap_calc_sasl_details(conn, &mech, &initresp, &len, &state1, - &state2); - - if(!result) { - /* Do we have any mechanisms left or can we fallback to clear text? */ - if(mech) { - /* Retry SASL based authentication */ - result = imap_perform_authenticate(conn, mech, initresp, state1, state2); - - Curl_safefree(initresp); - } - else if((!imapc->login_disabled) && - (imapc->preftype & IMAP_TYPE_CLEARTEXT)) - /* Perform clear text authentication */ - result = imap_perform_login(conn); - else { - failf(data, "Authentication cancelled"); - - result = CURLE_LOGIN_DENIED; - } - } - - return result; -} - -/* For final responses in the AUTHENTICATE sequence */ -static CURLcode imap_state_auth_final_resp(struct connectdata *conn, - int imapcode, - imapstate instate) -{ - CURLcode result = CURLE_OK; - struct SessionHandle *data = conn->data; - - (void)instate; /* no use for this yet */ - - if(imapcode != 'O') { - failf(data, "Authentication failed: %d", imapcode); - result = CURLE_LOGIN_DENIED; - } - else - /* End of connect phase */ - state(conn, IMAP_STOP); return result; } @@ -1873,69 +1314,8 @@ static CURLcode imap_statemach_act(struct connectdata *conn) result = imap_state_starttls_resp(conn, imapcode, imapc->state); break; - case IMAP_AUTHENTICATE_PLAIN: - result = imap_state_auth_plain_resp(conn, imapcode, imapc->state); - break; - - case IMAP_AUTHENTICATE_LOGIN: - result = imap_state_auth_login_resp(conn, imapcode, imapc->state); - break; - - case IMAP_AUTHENTICATE_LOGIN_PASSWD: - result = imap_state_auth_login_password_resp(conn, imapcode, - imapc->state); - break; - -#ifndef CURL_DISABLE_CRYPTO_AUTH - case IMAP_AUTHENTICATE_CRAMMD5: - result = imap_state_auth_cram_resp(conn, imapcode, imapc->state); - break; - - case IMAP_AUTHENTICATE_DIGESTMD5: - result = imap_state_auth_digest_resp(conn, imapcode, imapc->state); - break; - - case IMAP_AUTHENTICATE_DIGESTMD5_RESP: - result = imap_state_auth_digest_resp_resp(conn, imapcode, imapc->state); - break; -#endif - -#ifdef USE_NTLM - case IMAP_AUTHENTICATE_NTLM: - result = imap_state_auth_ntlm_resp(conn, imapcode, imapc->state); - break; - - case IMAP_AUTHENTICATE_NTLM_TYPE2MSG: - result = imap_state_auth_ntlm_type2msg_resp(conn, imapcode, - imapc->state); - break; -#endif - -#if defined(USE_WINDOWS_SSPI) - case IMAP_AUTHENTICATE_GSSAPI: - result = imap_state_auth_gssapi_resp(conn, imapcode, imapc->state); - break; - - case IMAP_AUTHENTICATE_GSSAPI_TOKEN: - result = imap_state_auth_gssapi_token_resp(conn, imapcode, imapc->state); - break; - - case IMAP_AUTHENTICATE_GSSAPI_NO_DATA: - result = imap_state_auth_gssapi_no_data_resp(conn, imapcode, - imapc->state); - break; -#endif - - case IMAP_AUTHENTICATE_XOAUTH2: - result = imap_state_auth_xoauth2_resp(conn, imapcode, imapc->state); - break; - - case IMAP_AUTHENTICATE_CANCEL: - result = imap_state_auth_cancel_resp(conn, imapcode, imapc->state); - break; - - case IMAP_AUTHENTICATE_FINAL: - result = imap_state_auth_final_resp(conn, imapcode, imapc->state); + case IMAP_AUTHENTICATE: + result = imap_state_auth_resp(conn, imapcode, imapc->state); break; case IMAP_LOGIN: @@ -2062,7 +1442,7 @@ static CURLcode imap_connect(struct connectdata *conn, bool *done) /* Set the default preferred authentication type and mechanism */ imapc->preftype = IMAP_TYPE_ANY; - imapc->prefmech = SASL_AUTH_ANY; + Curl_sasl_init(&imapc->sasl, &saslimap); /* Initialise the pingpong layer */ Curl_pp_init(pp); @@ -2275,7 +1655,7 @@ static CURLcode imap_disconnect(struct connectdata *conn, bool dead_connection) Curl_pp_disconnect(&imapc->pp); /* Cleanup the SASL module */ - Curl_sasl_cleanup(conn, imapc->authused); + Curl_sasl_cleanup(conn, imapc->sasl.authused); /* Cleanup our connection based variables */ Curl_safefree(imapc->mailbox); @@ -2420,7 +1800,7 @@ static CURLcode imap_sendf(struct connectdata *conn, const char *fmt, ...) result = Curl_pp_vsendf(&imapc->pp, taggedfmt, ap); va_end(ap); - Curl_safefree(taggedfmt); + free(taggedfmt); return result; } @@ -2448,7 +1828,7 @@ static char *imap_atom(const char *str) if(!str) return NULL; - /* Count any unescapped characters */ + /* Count any unescaped characters */ p1 = str; while(*p1) { if(*p1 == '\\') @@ -2461,7 +1841,7 @@ static char *imap_atom(const char *str) p1++; } - /* Does the input contain any unescapped characters? */ + /* Does the input contain any unescaped characters? */ if(!backsp_count && !quote_count && !space_exists) return strdup(str); @@ -2549,69 +1929,42 @@ static CURLcode imap_parse_url_options(struct connectdata *conn) { CURLcode result = CURLE_OK; struct imap_conn *imapc = &conn->proto.imapc; - const char *options = conn->options; - const char *ptr = options; - bool reset = TRUE; + const char *ptr = conn->options; + + imapc->sasl.resetprefs = TRUE; - while(ptr && *ptr) { + while(!result && ptr && *ptr) { const char *key = ptr; + const char *value; while(*ptr && *ptr != '=') ptr++; - if(strnequal(key, "AUTH", 4)) { - size_t len = 0; - const char *value = ++ptr; + value = ptr + 1; - if(reset) { - reset = FALSE; - imapc->preftype = IMAP_TYPE_NONE; - imapc->prefmech = SASL_AUTH_NONE; - } - - while(*ptr && *ptr != ';') { - ptr++; - len++; - } - - if(strnequal(value, "*", len)) { - imapc->preftype = IMAP_TYPE_ANY; - imapc->prefmech = SASL_AUTH_ANY; - } - else if(strnequal(value, SASL_MECH_STRING_LOGIN, len)) { - imapc->preftype = IMAP_TYPE_SASL; - imapc->prefmech |= SASL_MECH_LOGIN; - } - else if(strnequal(value, SASL_MECH_STRING_PLAIN, len)) { - imapc->preftype = IMAP_TYPE_SASL; - imapc->prefmech |= SASL_MECH_PLAIN; - } - else if(strnequal(value, SASL_MECH_STRING_CRAM_MD5, len)) { - imapc->preftype = IMAP_TYPE_SASL; - imapc->prefmech |= SASL_MECH_CRAM_MD5; - } - else if(strnequal(value, SASL_MECH_STRING_DIGEST_MD5, len)) { - imapc->preftype = IMAP_TYPE_SASL; - imapc->prefmech |= SASL_MECH_DIGEST_MD5; - } - else if(strnequal(value, SASL_MECH_STRING_GSSAPI, len)) { - imapc->preftype = IMAP_TYPE_SASL; - imapc->prefmech |= SASL_MECH_GSSAPI; - } - else if(strnequal(value, SASL_MECH_STRING_NTLM, len)) { - imapc->preftype = IMAP_TYPE_SASL; - imapc->prefmech |= SASL_MECH_NTLM; - } - else if(strnequal(value, SASL_MECH_STRING_XOAUTH2, len)) { - imapc->preftype = IMAP_TYPE_SASL; - imapc->prefmech |= SASL_MECH_XOAUTH2; - } + while(*ptr && *ptr != ';') + ptr++; - if(*ptr == ';') - ptr++; - } + if(strnequal(key, "AUTH=", 5)) + result = Curl_sasl_parse_url_auth_option(&imapc->sasl, + value, ptr - value); else result = CURLE_URL_MALFORMAT; + + if(*ptr == ';') + ptr++; + } + + switch(imapc->sasl.prefmech) { + case SASL_AUTH_NONE: + imapc->preftype = IMAP_TYPE_NONE; + break; + case SASL_AUTH_DEFAULT: + imapc->preftype = IMAP_TYPE_ANY; + break; + default: + imapc->preftype = IMAP_TYPE_SASL; + break; } return result; @@ -2678,7 +2031,7 @@ static CURLcode imap_parse_url_path(struct connectdata *conn) /* Decode the value parameter */ result = Curl_urldecode(data, begin, ptr - begin, &value, &valuelen, TRUE); if(result) { - Curl_safefree(name); + free(name); return result; } @@ -2717,14 +2070,14 @@ static CURLcode imap_parse_url_path(struct connectdata *conn) value = NULL; } else { - Curl_safefree(name); - Curl_safefree(value); + free(name); + free(value); return CURLE_URL_MALFORMAT; } - Curl_safefree(name); - Curl_safefree(value); + free(name); + free(value); } /* Does the URL contain a query parameter? Only valid when we have a mailbox @@ -2786,108 +2139,4 @@ static CURLcode imap_parse_custom_request(struct connectdata *conn) return result; } -/*********************************************************************** - * - * imap_calc_sasl_details() - * - * Calculate the required login details for SASL authentication. - */ -static CURLcode imap_calc_sasl_details(struct connectdata *conn, - const char **mech, - char **initresp, size_t *len, - imapstate *state1, imapstate *state2) -{ - CURLcode result = CURLE_OK; - struct SessionHandle *data = conn->data; - struct imap_conn *imapc = &conn->proto.imapc; - - /* Calculate the supported authentication mechanism, by decreasing order of - security, as well as the initial response where appropriate */ -#if defined(USE_WINDOWS_SSPI) - if((imapc->authmechs & SASL_MECH_GSSAPI) && - (imapc->prefmech & SASL_MECH_GSSAPI)) { - imapc->mutual_auth = FALSE; /* TODO: Calculate mutual authentication */ - - *mech = SASL_MECH_STRING_GSSAPI; - *state1 = IMAP_AUTHENTICATE_GSSAPI; - *state2 = IMAP_AUTHENTICATE_GSSAPI_TOKEN; - imapc->authused = SASL_MECH_GSSAPI; - - if(imapc->ir_supported || data->set.sasl_ir) - result = Curl_sasl_create_gssapi_user_message(data, conn->user, - conn->passwd, "imap", - imapc->mutual_auth, - NULL, &conn->krb5, - initresp, len); - } - else -#endif -#ifndef CURL_DISABLE_CRYPTO_AUTH - if((imapc->authmechs & SASL_MECH_DIGEST_MD5) && - (imapc->prefmech & SASL_MECH_DIGEST_MD5)) { - *mech = SASL_MECH_STRING_DIGEST_MD5; - *state1 = IMAP_AUTHENTICATE_DIGESTMD5; - imapc->authused = SASL_MECH_DIGEST_MD5; - } - else if((imapc->authmechs & SASL_MECH_CRAM_MD5) && - (imapc->prefmech & SASL_MECH_CRAM_MD5)) { - *mech = SASL_MECH_STRING_CRAM_MD5; - *state1 = IMAP_AUTHENTICATE_CRAMMD5; - imapc->authused = SASL_MECH_CRAM_MD5; - } - else -#endif -#ifdef USE_NTLM - if((imapc->authmechs & SASL_MECH_NTLM) && - (imapc->prefmech & SASL_MECH_NTLM)) { - *mech = SASL_MECH_STRING_NTLM; - *state1 = IMAP_AUTHENTICATE_NTLM; - *state2 = IMAP_AUTHENTICATE_NTLM_TYPE2MSG; - imapc->authused = SASL_MECH_NTLM; - - if(imapc->ir_supported || data->set.sasl_ir) - result = Curl_sasl_create_ntlm_type1_message(conn->user, conn->passwd, - &conn->ntlm, - initresp, len); - } - else -#endif - if(((imapc->authmechs & SASL_MECH_XOAUTH2) && - (imapc->prefmech & SASL_MECH_XOAUTH2) && - (imapc->prefmech != SASL_AUTH_ANY)) || conn->xoauth2_bearer) { - *mech = SASL_MECH_STRING_XOAUTH2; - *state1 = IMAP_AUTHENTICATE_XOAUTH2; - *state2 = IMAP_AUTHENTICATE_FINAL; - imapc->authused = SASL_MECH_XOAUTH2; - - if(imapc->ir_supported || data->set.sasl_ir) - result = Curl_sasl_create_xoauth2_message(data, conn->user, - conn->xoauth2_bearer, - initresp, len); - } - else if((imapc->authmechs & SASL_MECH_LOGIN) && - (imapc->prefmech & SASL_MECH_LOGIN)) { - *mech = SASL_MECH_STRING_LOGIN; - *state1 = IMAP_AUTHENTICATE_LOGIN; - *state2 = IMAP_AUTHENTICATE_LOGIN_PASSWD; - imapc->authused = SASL_MECH_LOGIN; - - if(imapc->ir_supported || data->set.sasl_ir) - result = Curl_sasl_create_login_message(data, conn->user, initresp, len); - } - else if((imapc->authmechs & SASL_MECH_PLAIN) && - (imapc->prefmech & SASL_MECH_PLAIN)) { - *mech = SASL_MECH_STRING_PLAIN; - *state1 = IMAP_AUTHENTICATE_PLAIN; - *state2 = IMAP_AUTHENTICATE_FINAL; - imapc->authused = SASL_MECH_PLAIN; - - if(imapc->ir_supported || data->set.sasl_ir) - result = Curl_sasl_create_plain_message(data, conn->user, conn->passwd, - initresp, len); - } - - return result; -} - #endif /* CURL_DISABLE_IMAP */ diff --git a/lib/imap.h b/lib/imap.h index 768fc4b..3189daa 100644 --- a/lib/imap.h +++ b/lib/imap.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 2009 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 2009 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -23,6 +23,7 @@ ***************************************************************************/ #include "pingpong.h" +#include "curl_sasl.h" /**************************************************************************** * IMAP unique setup @@ -35,20 +36,7 @@ typedef enum { IMAP_STARTTLS, IMAP_UPGRADETLS, /* asynchronously upgrade the connection to SSL/TLS (multi mode only) */ - IMAP_AUTHENTICATE_PLAIN, - IMAP_AUTHENTICATE_LOGIN, - IMAP_AUTHENTICATE_LOGIN_PASSWD, - IMAP_AUTHENTICATE_CRAMMD5, - IMAP_AUTHENTICATE_DIGESTMD5, - IMAP_AUTHENTICATE_DIGESTMD5_RESP, - IMAP_AUTHENTICATE_NTLM, - IMAP_AUTHENTICATE_NTLM_TYPE2MSG, - IMAP_AUTHENTICATE_GSSAPI, - IMAP_AUTHENTICATE_GSSAPI_TOKEN, - IMAP_AUTHENTICATE_GSSAPI_NO_DATA, - IMAP_AUTHENTICATE_XOAUTH2, - IMAP_AUTHENTICATE_CANCEL, - IMAP_AUTHENTICATE_FINAL, + IMAP_AUTHENTICATE, IMAP_LOGIN, IMAP_LIST, IMAP_SELECT, @@ -83,16 +71,13 @@ struct imap_conn { struct pingpong pp; imapstate state; /* Always use imap.c:state() to change state! */ bool ssldone; /* Is connect() over SSL done? */ - unsigned int authmechs; /* Accepted authentication mechanisms */ + struct SASL sasl; /* SASL-related parameters */ unsigned int preftype; /* Preferred authentication type */ - unsigned int prefmech; /* Preferred authentication mechanism */ - unsigned int authused; /* Auth mechanism used for the connection */ int cmdid; /* Last used command ID */ char resptag[5]; /* Response tag to wait for */ bool tls_supported; /* StartTLS capability supported by server */ bool login_disabled; /* LOGIN command disabled by server */ bool ir_supported; /* Initial response supported by server */ - bool mutual_auth; /* Mutual authentication enabled (GSSAPI only) */ char *mailbox; /* The last selected mailbox */ char *mailbox_uidvalidity; /* UIDVALIDITY parsed from select response */ }; diff --git a/lib/inet_ntop.c b/lib/inet_ntop.c index c327150..da9a3ab 100644 --- a/lib/inet_ntop.c +++ b/lib/inet_ntop.c @@ -32,8 +32,7 @@ #include #endif -#define _MPRINTF_REPLACE /* use our functions only */ -#include +#include "curl_printf.h" #include "inet_ntop.h" diff --git a/lib/inet_ntop.h b/lib/inet_ntop.h index db28ed8..cc4bdbb 100644 --- a/lib/inet_ntop.h +++ b/lib/inet_ntop.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2009, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -31,7 +31,7 @@ char *Curl_inet_ntop(int af, const void *addr, char *buf, size_t size); #include #endif #define Curl_inet_ntop(af,addr,buf,size) \ - inet_ntop(af,addr,buf,(curl_socklen_t)size) + inet_ntop(af, addr, buf, (curl_socklen_t)size) #endif #endif /* HEADER_CURL_INET_NTOP_H */ diff --git a/lib/krb5.c b/lib/krb5.c index 7e82a68..ad7dd67 100644 --- a/lib/krb5.c +++ b/lib/krb5.c @@ -1,8 +1,8 @@ /* GSSAPI/krb5 support for FTP - loosely based on old krb4.c * - * Copyright (c) 1995, 1996, 1997, 1998, 1999, 2013 Kungliga Tekniska H?gskolan + * Copyright (c) 1995, 1996, 1997, 1998, 1999 Kungliga Tekniska H?gskolan * (Royal Institute of Technology, Stockholm, Sweden). - * Copyright (c) 2004 - 2012 Daniel Stenberg + * Copyright (c) 2004 - 2015 Daniel Stenberg * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -34,13 +34,7 @@ #include "curl_setup.h" -#ifndef CURL_DISABLE_FTP -#ifdef HAVE_GSSAPI - -#ifdef HAVE_OLD_GSSMIT -#define GSS_C_NT_HOSTBASED_SERVICE gss_nt_service_name -#define NCOMPAT 1 -#endif +#if defined(HAVE_GSSAPI) && !defined(CURL_DISABLE_FTP) #ifdef HAVE_NETDB_H #include @@ -52,13 +46,11 @@ #include "curl_gssapi.h" #include "sendf.h" #include "curl_sec.h" -#include "curl_memory.h" #include "warnless.h" +#include "curl_printf.h" -#define _MPRINTF_REPLACE /* use our functions only */ -#include - -/* The last #include file should be: */ +/* The last #include files should be: */ +#include "curl_memory.h" #include "memdebug.h" #define LOCAL_ADDR (&conn->local_addr) @@ -121,8 +113,7 @@ krb5_overhead(void *app_data, int level, int len) } static int -krb5_encode(void *app_data, const void *from, int length, int level, void **to, - struct connectdata *conn UNUSED_PARAM) +krb5_encode(void *app_data, const void *from, int length, int level, void **to) { gss_ctx_id_t *context = app_data; gss_buffer_desc dec, enc; @@ -130,9 +121,6 @@ krb5_encode(void *app_data, const void *from, int length, int level, void **to, int state; int len; - /* shut gcc up */ - conn = NULL; - /* NOTE that the cast is safe, neither of the krb5, gnu gss and heimdal * libraries modify the input buffer in gss_seal() */ @@ -240,6 +228,7 @@ krb5_auth(void *app_data, struct connectdata *conn) &chan, gssresp, &output_buffer, + TRUE, NULL); if(gssresp) { @@ -257,7 +246,8 @@ krb5_auth(void *app_data, struct connectdata *conn) result = Curl_base64_encode(data, (char *)output_buffer.value, output_buffer.length, &p, &base64_sz); if(result) { - Curl_infof(data,"base64-encoding: %s\n", curl_easy_strerror(result)); + Curl_infof(data, "base64-encoding: %s\n", + curl_easy_strerror(result)); ret = AUTH_CONTINUE; break; } @@ -289,7 +279,8 @@ krb5_auth(void *app_data, struct connectdata *conn) (unsigned char **)&_gssresp.value, &_gssresp.length); if(result) { - Curl_failf(data,"base64-decoding: %s", curl_easy_strerror(result)); + Curl_failf(data, "base64-decoding: %s", + curl_easy_strerror(result)); ret = AUTH_CONTINUE; break; } @@ -338,5 +329,4 @@ struct Curl_sec_client_mech Curl_krb5_client_mech = { krb5_decode }; -#endif /* HAVE_GSSAPI */ -#endif /* CURL_DISABLE_FTP */ +#endif /* HAVE_GSSAPI && !CURL_DISABLE_FTP */ diff --git a/lib/ldap.c b/lib/ldap.c index ae48448..4d91282 100644 --- a/lib/ldap.c +++ b/lib/ldap.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -35,7 +35,7 @@ * OpenLDAP library versions, USE_OPENLDAP shall not be defined. */ -#ifdef CURL_LDAP_WIN /* Use Windows LDAP implementation. */ +#ifdef USE_WIN32_LDAP /* Use Windows LDAP implementation. */ # include # ifndef LDAP_VENDOR_NAME # error Your Platform SDK is NOT sufficient for LDAP support! \ @@ -54,6 +54,15 @@ # endif /* HAVE_LDAP_SSL && HAVE_LDAP_SSL_H */ #endif +/* These are macros in both (in above ) and typedefs + * in BoringSSL's + */ +#ifdef HAVE_BORINGSSL +# undef X509_NAME +# undef X509_CERT_PAIR +# undef X509_EXTENSIONS +#endif + #include "urldata.h" #include #include "sendf.h" @@ -63,14 +72,14 @@ #include "strequal.h" #include "strtok.h" #include "curl_ldap.h" -#include "curl_memory.h" +#include "curl_multibyte.h" #include "curl_base64.h" #include "rawstr.h" #include "connect.h" +#include "curl_printf.h" -#define _MPRINTF_REPLACE /* use our functions only */ -#include - +/* The last #include files should be: */ +#include "curl_memory.h" #include "memdebug.h" #ifndef HAVE_LDAP_URL_PARSE @@ -80,10 +89,19 @@ typedef struct { char *lud_host; int lud_port; +#if defined(USE_WIN32_LDAP) + TCHAR *lud_dn; + TCHAR **lud_attrs; +#else char *lud_dn; char **lud_attrs; +#endif int lud_scope; +#if defined(USE_WIN32_LDAP) + TCHAR *lud_filter; +#else char *lud_filter; +#endif char **lud_exts; size_t lud_attrs_dups; /* how many were dup'ed, this field is not in the "real" struct so can only be used in code @@ -168,11 +186,11 @@ const struct Curl_handler Curl_handler_ldaps = { static CURLcode Curl_ldap(struct connectdata *conn, bool *done) { - CURLcode status = CURLE_OK; + CURLcode result = CURLE_OK; int rc = 0; LDAP *server = NULL; LDAPURLDesc *ludp = NULL; - LDAPMessage *result = NULL; + LDAPMessage *ldapmsg = NULL; LDAPMessage *entryIterator; int num = 0; struct SessionHandle *data=conn->data; @@ -182,7 +200,16 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done) size_t val_b64_sz = 0; curl_off_t dlsize = 0; #ifdef LDAP_OPT_NETWORK_TIMEOUT - struct timeval ldap_timeout = {10,0}; /* 10 sec connection/search timeout */ + struct timeval ldap_timeout = {10, 0}; /* 10 sec connection/search timeout */ +#endif +#if defined(USE_WIN32_LDAP) + TCHAR *host = NULL; + TCHAR *user = NULL; + TCHAR *passwd = NULL; +#else + char *host = NULL; + char *user = NULL; + char *passwd = NULL; #endif *done = TRUE; /* unconditionally */ @@ -197,7 +224,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done) #endif if(rc != 0) { failf(data, "LDAP local: %s", ldap_err2string(rc)); - status = CURLE_LDAP_INVALID_URL; + result = CURLE_LDAP_INVALID_URL; goto quit; } @@ -207,6 +234,32 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done) infof(data, "LDAP local: trying to establish %s connection\n", ldap_ssl ? "encrypted" : "cleartext"); +#if defined(USE_WIN32_LDAP) + host = Curl_convert_UTF8_to_tchar(conn->host.name); + if(!host) { + result = CURLE_OUT_OF_MEMORY; + + goto quit; + } + + if(conn->bits.user_passwd) { + user = Curl_convert_UTF8_to_tchar(conn->user); + passwd = Curl_convert_UTF8_to_tchar(conn->passwd); + if(!user || !passwd) { + result = CURLE_OUT_OF_MEMORY; + + goto quit; + } + } +#else + host = conn->host.name; + + if(conn->bits.user_passwd) { + user = conn->user; + passwd = conn->passwd; + } +#endif + #ifdef LDAP_OPT_NETWORK_TIMEOUT ldap_set_option(NULL, LDAP_OPT_NETWORK_TIMEOUT, &ldap_timeout); #endif @@ -214,9 +267,9 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done) if(ldap_ssl) { #ifdef HAVE_LDAP_SSL -#ifdef CURL_LDAP_WIN +#ifdef USE_WIN32_LDAP /* Win32 LDAP SDK doesn't support insecure mode without CA! */ - server = ldap_sslinit(conn->host.name, (int)conn->port, 1); + server = ldap_sslinit(host, (int)conn->port, 1); ldap_set_option(server, LDAP_OPT_SSL, LDAP_OPT_ON); #else int ldap_option; @@ -225,7 +278,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done) rc = ldapssl_client_init(NULL, NULL); if(rc != LDAP_SUCCESS) { failf(data, "LDAP local: ldapssl_client_init %s", ldap_err2string(rc)); - status = CURLE_SSL_CERTPROBLEM; + result = CURLE_SSL_CERTPROBLEM; goto quit; } if(data->set.ssl.verifypeer) { @@ -237,7 +290,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done) if(!ldap_ca) { failf(data, "LDAP local: ERROR %s CA cert not set!", (cert_type == LDAPSSL_CERT_FILETYPE_DER ? "DER" : "PEM")); - status = CURLE_SSL_CERTPROBLEM; + result = CURLE_SSL_CERTPROBLEM; goto quit; } infof(data, "LDAP local: using %s CA cert '%s'\n", @@ -248,7 +301,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done) failf(data, "LDAP local: ERROR setting %s CA cert: %s", (cert_type == LDAPSSL_CERT_FILETYPE_DER ? "DER" : "PEM"), ldap_err2string(rc)); - status = CURLE_SSL_CERTPROBLEM; + result = CURLE_SSL_CERTPROBLEM; goto quit; } ldap_option = LDAPSSL_VERIFY_SERVER; @@ -259,14 +312,14 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done) if(rc != LDAP_SUCCESS) { failf(data, "LDAP local: ERROR setting cert verify mode: %s", ldap_err2string(rc)); - status = CURLE_SSL_CERTPROBLEM; + result = CURLE_SSL_CERTPROBLEM; goto quit; } - server = ldapssl_init(conn->host.name, (int)conn->port, 1); + server = ldapssl_init(host, (int)conn->port, 1); if(server == NULL) { failf(data, "LDAP local: Cannot connect to %s:%ld", - conn->host.name, conn->port); - status = CURLE_COULDNT_CONNECT; + conn->host.dispname, conn->port); + result = CURLE_COULDNT_CONNECT; goto quit; } #elif defined(LDAP_OPT_X_TLS) @@ -275,12 +328,12 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done) if((data->set.str[STRING_CERT_TYPE]) && (!Curl_raw_equal(data->set.str[STRING_CERT_TYPE], "PEM"))) { failf(data, "LDAP local: ERROR OpenLDAP only supports PEM cert-type!"); - status = CURLE_SSL_CERTPROBLEM; + result = CURLE_SSL_CERTPROBLEM; goto quit; } if(!ldap_ca) { failf(data, "LDAP local: ERROR PEM CA cert not set!"); - status = CURLE_SSL_CERTPROBLEM; + result = CURLE_SSL_CERTPROBLEM; goto quit; } infof(data, "LDAP local: using PEM CA cert: %s\n", ldap_ca); @@ -288,7 +341,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done) if(rc != LDAP_SUCCESS) { failf(data, "LDAP local: ERROR setting PEM CA cert: %s", ldap_err2string(rc)); - status = CURLE_SSL_CERTPROBLEM; + result = CURLE_SSL_CERTPROBLEM; goto quit; } ldap_option = LDAP_OPT_X_TLS_DEMAND; @@ -300,14 +353,14 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done) if(rc != LDAP_SUCCESS) { failf(data, "LDAP local: ERROR setting cert verify mode: %s", ldap_err2string(rc)); - status = CURLE_SSL_CERTPROBLEM; + result = CURLE_SSL_CERTPROBLEM; goto quit; } - server = ldap_init(conn->host.name, (int)conn->port); + server = ldap_init(host, (int)conn->port); if(server == NULL) { failf(data, "LDAP local: Cannot connect to %s:%ld", - conn->host.name, conn->port); - status = CURLE_COULDNT_CONNECT; + conn->host.dispname, conn->port); + result = CURLE_COULDNT_CONNECT; goto quit; } ldap_option = LDAP_OPT_X_TLS_HARD; @@ -315,7 +368,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done) if(rc != LDAP_SUCCESS) { failf(data, "LDAP local: ERROR setting SSL/TLS mode: %s", ldap_err2string(rc)); - status = CURLE_SSL_CERTPROBLEM; + result = CURLE_SSL_CERTPROBLEM; goto quit; } /* @@ -323,7 +376,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done) if(rc != LDAP_SUCCESS) { failf(data, "LDAP local: ERROR starting SSL/TLS mode: %s", ldap_err2string(rc)); - status = CURLE_SSL_CERTPROBLEM; + result = CURLE_SSL_CERTPROBLEM; goto quit; } */ @@ -332,126 +385,278 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done) should check in first place if we can support LDAP SSL/TLS */ failf(data, "LDAP local: SSL/TLS not supported with this version " "of the OpenLDAP toolkit\n"); - status = CURLE_SSL_CERTPROBLEM; + result = CURLE_SSL_CERTPROBLEM; goto quit; #endif #endif #endif /* CURL_LDAP_USE_SSL */ } else { - server = ldap_init(conn->host.name, (int)conn->port); + server = ldap_init(host, (int)conn->port); if(server == NULL) { failf(data, "LDAP local: Cannot connect to %s:%ld", - conn->host.name, conn->port); - status = CURLE_COULDNT_CONNECT; + conn->host.dispname, conn->port); + result = CURLE_COULDNT_CONNECT; goto quit; } } -#ifdef CURL_LDAP_WIN +#ifdef USE_WIN32_LDAP ldap_set_option(server, LDAP_OPT_PROTOCOL_VERSION, &ldap_proto); #endif - rc = ldap_simple_bind_s(server, - conn->bits.user_passwd ? conn->user : NULL, - conn->bits.user_passwd ? conn->passwd : NULL); + rc = ldap_simple_bind_s(server, user, passwd); if(!ldap_ssl && rc != 0) { ldap_proto = LDAP_VERSION2; ldap_set_option(server, LDAP_OPT_PROTOCOL_VERSION, &ldap_proto); - rc = ldap_simple_bind_s(server, - conn->bits.user_passwd ? conn->user : NULL, - conn->bits.user_passwd ? conn->passwd : NULL); + rc = ldap_simple_bind_s(server, user, passwd); } if(rc != 0) { failf(data, "LDAP local: ldap_simple_bind_s %s", ldap_err2string(rc)); - status = CURLE_LDAP_CANNOT_BIND; + result = CURLE_LDAP_CANNOT_BIND; goto quit; } rc = ldap_search_s(server, ludp->lud_dn, ludp->lud_scope, - ludp->lud_filter, ludp->lud_attrs, 0, &result); + ludp->lud_filter, ludp->lud_attrs, 0, &ldapmsg); if(rc != 0 && rc != LDAP_SIZELIMIT_EXCEEDED) { failf(data, "LDAP remote: %s", ldap_err2string(rc)); - status = CURLE_LDAP_SEARCH_FAILED; + result = CURLE_LDAP_SEARCH_FAILED; goto quit; } - for(num = 0, entryIterator = ldap_first_entry(server, result); + for(num = 0, entryIterator = ldap_first_entry(server, ldapmsg); entryIterator; entryIterator = ldap_next_entry(server, entryIterator), num++) { BerElement *ber = NULL; +#if defined(USE_WIN32_LDAP) + TCHAR *attribute; +#else char *attribute; /*! suspicious that this isn't 'const' */ - char *dn = ldap_get_dn(server, entryIterator); +#endif int i; - Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"DN: ", 4); - Curl_client_write(conn, CLIENTWRITE_BODY, (char *)dn, 0); - Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1); + /* Get the DN and write it to the client */ + { + char *name; + size_t name_len; +#if defined(USE_WIN32_LDAP) + TCHAR *dn = ldap_get_dn(server, entryIterator); + name = Curl_convert_tchar_to_UTF8(dn); + if(!name) { + ldap_memfree(dn); + + result = CURLE_OUT_OF_MEMORY; + + goto quit; + } +#else + char *dn = name = ldap_get_dn(server, entryIterator); +#endif + name_len = strlen(name); + + result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"DN: ", 4); + if(result) { +#if defined(USE_WIN32_LDAP) + Curl_unicodefree(name); +#endif + ldap_memfree(dn); + + goto quit; + } + + result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *) name, + name_len); + if(result) { +#if defined(USE_WIN32_LDAP) + Curl_unicodefree(name); +#endif + ldap_memfree(dn); + + goto quit; + } + + result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1); + if(result) { +#if defined(USE_WIN32_LDAP) + Curl_unicodefree(name); +#endif + ldap_memfree(dn); + + goto quit; + } - dlsize += strlen(dn)+5; + dlsize += name_len + 5; +#if defined(USE_WIN32_LDAP) + Curl_unicodefree(name); +#endif + ldap_memfree(dn); + } + + /* Get the attributes and write them to the client */ for(attribute = ldap_first_attribute(server, entryIterator, &ber); attribute; attribute = ldap_next_attribute(server, entryIterator, ber)) { - BerValue **vals = ldap_get_values_len(server, entryIterator, attribute); + BerValue **vals; + size_t attr_len; +#if defined(USE_WIN32_LDAP) + char *attr = Curl_convert_tchar_to_UTF8(attribute); + if(!attr) { + if(ber) + ber_free(ber, 0); + + result = CURLE_OUT_OF_MEMORY; + + goto quit; + } +#else + char *attr = attribute; +#endif + attr_len = strlen(attr); + vals = ldap_get_values_len(server, entryIterator, attribute); if(vals != NULL) { for(i = 0; (vals[i] != NULL); i++) { - Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\t", 1); - Curl_client_write(conn, CLIENTWRITE_BODY, (char *) attribute, 0); - Curl_client_write(conn, CLIENTWRITE_BODY, (char *)": ", 2); - dlsize += strlen(attribute)+3; - - if((strlen(attribute) > 7) && - (strcmp(";binary", - (char *)attribute + - (strlen((char *)attribute) - 7)) == 0)) { + result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\t", 1); + if(result) { + ldap_value_free_len(vals); +#if defined(USE_WIN32_LDAP) + Curl_unicodefree(attr); +#endif + ldap_memfree(attribute); + if(ber) + ber_free(ber, 0); + + goto quit; + } + + result = Curl_client_write(conn, CLIENTWRITE_BODY, + (char *) attr, attr_len); + if(result) { + ldap_value_free_len(vals); +#if defined(USE_WIN32_LDAP) + Curl_unicodefree(attr); +#endif + ldap_memfree(attribute); + if(ber) + ber_free(ber, 0); + + goto quit; + } + + result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)": ", 2); + if(result) { + ldap_value_free_len(vals); +#if defined(USE_WIN32_LDAP) + Curl_unicodefree(attr); +#endif + ldap_memfree(attribute); + if(ber) + ber_free(ber, 0); + + goto quit; + } + + dlsize += attr_len + 3; + + if((attr_len > 7) && + (strcmp(";binary", (char *) attr + (attr_len - 7)) == 0)) { /* Binary attribute, encode to base64. */ - CURLcode error = Curl_base64_encode(data, - vals[i]->bv_val, - vals[i]->bv_len, - &val_b64, - &val_b64_sz); - if(error) { + result = Curl_base64_encode(data, + vals[i]->bv_val, + vals[i]->bv_len, + &val_b64, + &val_b64_sz); + if(result) { ldap_value_free_len(vals); +#if defined(USE_WIN32_LDAP) + Curl_unicodefree(attr); +#endif ldap_memfree(attribute); - ldap_memfree(dn); if(ber) ber_free(ber, 0); - status = error; + goto quit; } + if(val_b64_sz > 0) { - Curl_client_write(conn, CLIENTWRITE_BODY, val_b64, val_b64_sz); + result = Curl_client_write(conn, CLIENTWRITE_BODY, val_b64, + val_b64_sz); free(val_b64); + if(result) { + ldap_value_free_len(vals); +#if defined(USE_WIN32_LDAP) + Curl_unicodefree(attr); +#endif + ldap_memfree(attribute); + if(ber) + ber_free(ber, 0); + + goto quit; + } + dlsize += val_b64_sz; } } else { - Curl_client_write(conn, CLIENTWRITE_BODY, vals[i]->bv_val, - vals[i]->bv_len); + result = Curl_client_write(conn, CLIENTWRITE_BODY, vals[i]->bv_val, + vals[i]->bv_len); + if(result) { + ldap_value_free_len(vals); +#if defined(USE_WIN32_LDAP) + Curl_unicodefree(attr); +#endif + ldap_memfree(attribute); + if(ber) + ber_free(ber, 0); + + goto quit; + } + dlsize += vals[i]->bv_len; } - Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 0); + + result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1); + if(result) { + ldap_value_free_len(vals); +#if defined(USE_WIN32_LDAP) + Curl_unicodefree(attr); +#endif + ldap_memfree(attribute); + if(ber) + ber_free(ber, 0); + + goto quit; + } + dlsize++; } /* Free memory used to store values */ ldap_value_free_len(vals); } - Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1); + + /* Free the attribute as we are done with it */ +#if defined(USE_WIN32_LDAP) + Curl_unicodefree(attr); +#endif + ldap_memfree(attribute); + + result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1); + if(result) + goto quit; dlsize++; Curl_pgrsSetDownloadCounter(data, dlsize); - ldap_memfree(attribute); } - ldap_memfree(dn); + if(ber) ber_free(ber, 0); } quit: - if(result) { - ldap_msgfree(result); + if(ldapmsg) { + ldap_msgfree(ldapmsg); LDAP_TRACE (("Received %d entries\n", num)); } if(rc == LDAP_SIZELIMIT_EXCEEDED) @@ -465,11 +670,17 @@ quit: ldapssl_client_deinit(); #endif /* HAVE_LDAP_SSL && CURL_HAS_NOVELL_LDAPSDK */ +#if defined(USE_WIN32_LDAP) + Curl_unicodefree(passwd); + Curl_unicodefree(user); + Curl_unicodefree(host); +#endif + /* no data to transfer */ Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL); connclose(conn, "LDAP connection always disable re-use"); - return status; + return result; } #ifdef DEBUG_LDAP @@ -513,57 +724,34 @@ static int str2scope (const char *p) /* * Split 'str' into strings separated by commas. - * Note: res[] points into 'str'. + * Note: out[] points into 'str'. */ -static char **split_str (char *str) +static bool split_str(char *str, char ***out, size_t *count) { - char **res, *lasts, *s; - int i; - - for(i = 2, s = strchr(str,','); s; i++) - s = strchr(++s,','); + char **res; + char *lasts; + char *s; + size_t i; + size_t items = 1; + + s = strchr(str, ','); + while(s) { + items++; + s = strchr(++s, ','); + } - res = calloc(i, sizeof(char*)); + res = calloc(items, sizeof(char *)); if(!res) - return NULL; + return FALSE; - for(i = 0, s = strtok_r(str, ",", &lasts); s; + for(i = 0, s = strtok_r(str, ",", &lasts); s && i < items; s = strtok_r(NULL, ",", &lasts), i++) res[i] = s; - return res; -} - -/* - * Unescape the LDAP-URL components - */ -static bool unescape_elements (void *data, LDAPURLDesc *ludp) -{ - int i; - - if(ludp->lud_filter) { - ludp->lud_filter = curl_easy_unescape(data, ludp->lud_filter, 0, NULL); - if(!ludp->lud_filter) - return FALSE; - } - - for(i = 0; ludp->lud_attrs && ludp->lud_attrs[i]; i++) { - ludp->lud_attrs[i] = curl_easy_unescape(data, ludp->lud_attrs[i], - 0, NULL); - if(!ludp->lud_attrs[i]) - return FALSE; - ludp->lud_attrs_dups++; - } - if(ludp->lud_dn) { - char *dn = ludp->lud_dn; - char *new_dn = curl_easy_unescape(data, dn, 0, NULL); + *out = res; + *count = items; - free(dn); - ludp->lud_dn = new_dn; - if(!new_dn) - return (FALSE); - } - return (TRUE); + return TRUE; } /* @@ -582,8 +770,11 @@ static bool unescape_elements (void *data, LDAPURLDesc *ludp) */ static int _ldap_url_parse2 (const struct connectdata *conn, LDAPURLDesc *ludp) { - char *p, *q; - int i; + int rc = LDAP_SUCCESS; + char *path; + char *p; + char *q; + size_t i; if(!conn->data || !conn->data->state.path || @@ -595,74 +786,190 @@ static int _ldap_url_parse2 (const struct connectdata *conn, LDAPURLDesc *ludp) ludp->lud_port = conn->remote_port; ludp->lud_host = conn->host.name; - /* parse DN (Distinguished Name). - */ - ludp->lud_dn = strdup(conn->data->state.path+1); - if(!ludp->lud_dn) + /* Duplicate the path */ + p = path = strdup(conn->data->state.path + 1); + if(!path) return LDAP_NO_MEMORY; - p = strchr(ludp->lud_dn, '?'); - LDAP_TRACE (("DN '%.*s'\n", p ? (size_t)(p-ludp->lud_dn) : - strlen(ludp->lud_dn), ludp->lud_dn)); + /* Parse the DN (Distinguished Name) */ + q = strchr(p, '?'); + if(q) + *q++ = '\0'; + + if(*p) { + char *dn = p; + char *unescaped; - if(!p) - goto success; + LDAP_TRACE (("DN '%s'\n", dn)); - *p++ = '\0'; + /* Unescape the DN */ + unescaped = curl_easy_unescape(conn->data, dn, 0, NULL); + if(!unescaped) { + rc = LDAP_NO_MEMORY; - /* parse attributes. skip "??". - */ + goto quit; + } + +#if defined(USE_WIN32_LDAP) + /* Convert the unescaped string to a tchar */ + ludp->lud_dn = Curl_convert_UTF8_to_tchar(unescaped); + + /* Free the unescaped string as we are done with it */ + Curl_unicodefree(unescaped); + + if(!ludp->lud_dn) { + rc = LDAP_NO_MEMORY; + + goto quit; + } +#else + ludp->lud_dn = unescaped; +#endif + } + + p = q; + if(!p) + goto quit; + + /* Parse the attributes. skip "??" */ q = strchr(p, '?'); if(q) *q++ = '\0'; - if(*p && *p != '?') { - ludp->lud_attrs = split_str(p); - if(!ludp->lud_attrs) - return LDAP_NO_MEMORY; + if(*p) { + char **attributes; + size_t count = 0; + + /* Split the string into an array of attributes */ + if(!split_str(p, &attributes, &count)) { + rc = LDAP_NO_MEMORY; + + goto quit; + } + + /* Allocate our array (+1 for the NULL entry) */ +#if defined(USE_WIN32_LDAP) + ludp->lud_attrs = calloc(count + 1, sizeof(TCHAR *)); +#else + ludp->lud_attrs = calloc(count + 1, sizeof(char *)); +#endif + if(!ludp->lud_attrs) { + free(attributes); + + rc = LDAP_NO_MEMORY; + + goto quit; + } + + for(i = 0; i < count; i++) { + char *unescaped; + + LDAP_TRACE (("attr[%d] '%s'\n", i, attributes[i])); + + /* Unescape the attribute */ + unescaped = curl_easy_unescape(conn->data, attributes[i], 0, NULL); + if(!unescaped) { + free(attributes); + + rc = LDAP_NO_MEMORY; + + goto quit; + } + +#if defined(USE_WIN32_LDAP) + /* Convert the unescaped string to a tchar */ + ludp->lud_attrs[i] = Curl_convert_UTF8_to_tchar(unescaped); + + /* Free the unescaped string as we are done with it */ + Curl_unicodefree(unescaped); + + if(!ludp->lud_attrs[i]) { + free(attributes); - for(i = 0; ludp->lud_attrs[i]; i++) - LDAP_TRACE (("attr[%d] '%s'\n", i, ludp->lud_attrs[i])); + rc = LDAP_NO_MEMORY; + + goto quit; + } +#else + ludp->lud_attrs[i] = unescaped; +#endif + + ludp->lud_attrs_dups++; + } + + free(attributes); } p = q; if(!p) - goto success; + goto quit; - /* parse scope. skip "??" - */ + /* Parse the scope. skip "??" */ q = strchr(p, '?'); if(q) *q++ = '\0'; - if(*p && *p != '?') { + if(*p) { ludp->lud_scope = str2scope(p); if(ludp->lud_scope == -1) { - return LDAP_INVALID_SYNTAX; + rc = LDAP_INVALID_SYNTAX; + + goto quit; } LDAP_TRACE (("scope %d\n", ludp->lud_scope)); } p = q; if(!p) - goto success; + goto quit; - /* parse filter - */ + /* Parse the filter */ q = strchr(p, '?'); if(q) *q++ = '\0'; - if(!*p) { - return LDAP_INVALID_SYNTAX; + + if(*p) { + char *filter = p; + char *unescaped; + + LDAP_TRACE (("filter '%s'\n", filter)); + + /* Unescape the filter */ + unescaped = curl_easy_unescape(conn->data, filter, 0, NULL); + if(!unescaped) { + rc = LDAP_NO_MEMORY; + + goto quit; + } + +#if defined(USE_WIN32_LDAP) + /* Convert the unescaped string to a tchar */ + ludp->lud_filter = Curl_convert_UTF8_to_tchar(unescaped); + + /* Free the unescaped string as we are done with it */ + Curl_unicodefree(unescaped); + + if(!ludp->lud_filter) { + rc = LDAP_NO_MEMORY; + + goto quit; + } +#else + ludp->lud_filter = unescaped; +#endif } - ludp->lud_filter = p; - LDAP_TRACE (("filter '%s'\n", ludp->lud_filter)); + p = q; + if(p && !*p) { + rc = LDAP_INVALID_SYNTAX; - success: - if(!unescape_elements(conn->data, ludp)) - return LDAP_NO_MEMORY; - return LDAP_SUCCESS; + goto quit; + } + +quit: + free(path); + + return rc; } static int _ldap_url_parse (const struct connectdata *conn, @@ -691,11 +998,8 @@ static void _ldap_free_urldesc (LDAPURLDesc *ludp) if(!ludp) return; - if(ludp->lud_dn) - free(ludp->lud_dn); - - if(ludp->lud_filter) - free(ludp->lud_filter); + free(ludp->lud_dn); + free(ludp->lud_filter); if(ludp->lud_attrs) { for(i = 0; i < ludp->lud_attrs_dups; i++) diff --git a/lib/md4.c b/lib/md4.c index 6930e02..60f73a2 100644 --- a/lib/md4.c +++ b/lib/md4.c @@ -1,282 +1,304 @@ -/*- - Copyright (C) 1990-2, RSA Data Security, Inc. All rights reserved. - - License to copy and use this software is granted provided that it - is identified as the "RSA Data Security, Inc. MD4 Message-Digest - Algorithm" in all material mentioning or referencing this software - or this function. - - License is also granted to make and use derivative works provided - that such works are identified as "derived from the RSA Data - Security, Inc. MD4 Message-Digest Algorithm" in all material - mentioning or referencing the derived work. - - RSA Data Security, Inc. makes no representations concerning either - the merchantability of this software or the suitability of this - software for any particular purpose. It is provided "as is" - without express or implied warranty of any kind. - - These notices must be retained in any copies of any part of this - documentation and/or software. +/* + * This is an OpenSSL-compatible implementation of the RSA Data Security, Inc. + * MD4 Message-Digest Algorithm (RFC 1320). + * + * Homepage: + http://openwall.info/wiki/people/solar/software/public-domain-source-code/md4 + * + * Author: + * Alexander Peslyak, better known as Solar Designer + * + * This software was written by Alexander Peslyak in 2001. No copyright is + * claimed, and the software is hereby placed in the public domain. In case + * this attempt to disclaim copyright and place the software in the public + * domain is deemed null and void, then the software is Copyright (c) 2001 + * Alexander Peslyak and it is hereby released to the general public under the + * following terms: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted. + * + * There's ABSOLUTELY NO WARRANTY, express or implied. + * + * (This is a heavily cut-down "BSD license".) + * + * This differs from Colin Plumb's older public domain implementation in that + * no exactly 32-bit integer data type is required (any 32-bit or wider + * unsigned integer data type will do), there's no compile-time endianness + * configuration, and the function prototypes match OpenSSL's. No code from + * Colin Plumb's implementation has been reused; this comment merely compares + * the properties of the two independent implementations. + * + * The primary goals of this implementation are portability and ease of use. + * It is meant to be fast, but not as fast as possible. Some known + * optimizations are not included to reduce source code size and avoid + * compile-time configuration. */ #include "curl_setup.h" -/* NSS crypto library does not provide the MD4 hash algorithm, so that we have - * a local implementation of it */ -#ifdef USE_NSS +/* NSS and OS/400 crypto library do not provide the MD4 hash algorithm, so + * that we have a local implementation of it */ +#if defined(USE_NSS) || defined(USE_OS400CRYPTO) #include "curl_md4.h" #include "warnless.h" -typedef unsigned int UINT4; +#ifndef HAVE_OPENSSL -typedef struct MD4Context { - UINT4 state[4]; /* state (ABCD) */ - UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */ - unsigned char buffer[64]; /* input buffer */ +#include + +/* Any 32-bit or wider unsigned integer data type will do */ +typedef unsigned int MD4_u32plus; + +typedef struct { + MD4_u32plus lo, hi; + MD4_u32plus a, b, c, d; + unsigned char buffer[64]; + MD4_u32plus block[16]; } MD4_CTX; -/* Constants for MD4Transform routine. - */ -#define S11 3 -#define S12 7 -#define S13 11 -#define S14 19 -#define S21 3 -#define S22 5 -#define S23 9 -#define S24 13 -#define S31 3 -#define S32 9 -#define S33 11 -#define S34 15 - -static void MD4Transform(UINT4 [4], const unsigned char [64]); -static void Encode(unsigned char *, UINT4 *, unsigned int); -static void Decode(UINT4 *, const unsigned char *, unsigned int); - -static unsigned char PADDING[64] = { - 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; - -/* F, G and H are basic MD4 functions. - */ -#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) -#define G(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z))) -#define H(x, y, z) ((x) ^ (y) ^ (z)) +static void MD4_Init(MD4_CTX *ctx); +static void MD4_Update(MD4_CTX *ctx, const void *data, unsigned long size); +static void MD4_Final(unsigned char *result, MD4_CTX *ctx); -/* ROTATE_LEFT rotates x left n bits. +/* + * The basic MD4 functions. + * + * F and G are optimized compared to their RFC 1320 definitions, with the + * optimization for F borrowed from Colin Plumb's MD5 implementation. */ -#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) - -/* FF, GG and HH are transformations for rounds 1, 2 and 3 */ -/* Rotation is separate from addition to prevent recomputation */ -#define FF(a, b, c, d, x, s) { \ - (a) += F ((b), (c), (d)) + (x); \ - (a) = ROTATE_LEFT ((a), (s)); \ - } -#define GG(a, b, c, d, x, s) { \ - (a) += G ((b), (c), (d)) + (x) + (UINT4)0x5a827999; \ - (a) = ROTATE_LEFT ((a), (s)); \ - } -#define HH(a, b, c, d, x, s) { \ - (a) += H ((b), (c), (d)) + (x) + (UINT4)0x6ed9eba1; \ - (a) = ROTATE_LEFT ((a), (s)); \ - } +#define F(x, y, z) ((z) ^ ((x) & ((y) ^ (z)))) +#define G(x, y, z) (((x) & ((y) | (z))) | ((y) & (z))) +#define H(x, y, z) ((x) ^ (y) ^ (z)) -/* MD4 initialization. Begins an MD4 operation, writing a new context. +/* + * The MD4 transformation for all three rounds. */ -static void MD4Init(MD4_CTX *context) +#define STEP(f, a, b, c, d, x, s) \ + (a) += f((b), (c), (d)) + (x); \ + (a) = (((a) << (s)) | (((a) & 0xffffffff) >> (32 - (s)))); + +/* + * SET reads 4 input bytes in little-endian byte order and stores them + * in a properly aligned word in host byte order. + * + * The check for little-endian architectures that tolerate unaligned + * memory accesses is just an optimization. Nothing will break if it + * doesn't work. + */ +#if defined(__i386__) || defined(__x86_64__) || defined(__vax__) +#define SET(n) \ + (*(MD4_u32plus *)&ptr[(n) * 4]) +#define GET(n) \ + SET(n) +#else +#define SET(n) \ + (ctx->block[(n)] = \ + (MD4_u32plus)ptr[(n) * 4] | \ + ((MD4_u32plus)ptr[(n) * 4 + 1] << 8) | \ + ((MD4_u32plus)ptr[(n) * 4 + 2] << 16) | \ + ((MD4_u32plus)ptr[(n) * 4 + 3] << 24)) +#define GET(n) \ + (ctx->block[(n)]) +#endif + +/* + * This processes one or more 64-byte data blocks, but does NOT update + * the bit counters. There are no alignment requirements. + */ +static const void *body(MD4_CTX *ctx, const void *data, unsigned long size) { - context->count[0] = context->count[1] = 0; - - /* Load magic initialization constants. - */ - context->state[0] = 0x67452301; - context->state[1] = 0xefcdab89; - context->state[2] = 0x98badcfe; - context->state[3] = 0x10325476; + const unsigned char *ptr; + MD4_u32plus a, b, c, d; + MD4_u32plus saved_a, saved_b, saved_c, saved_d; + + ptr = (const unsigned char *)data; + + a = ctx->a; + b = ctx->b; + c = ctx->c; + d = ctx->d; + + do { + saved_a = a; + saved_b = b; + saved_c = c; + saved_d = d; + +/* Round 1 */ + STEP(F, a, b, c, d, SET(0), 3) + STEP(F, d, a, b, c, SET(1), 7) + STEP(F, c, d, a, b, SET(2), 11) + STEP(F, b, c, d, a, SET(3), 19) + STEP(F, a, b, c, d, SET(4), 3) + STEP(F, d, a, b, c, SET(5), 7) + STEP(F, c, d, a, b, SET(6), 11) + STEP(F, b, c, d, a, SET(7), 19) + STEP(F, a, b, c, d, SET(8), 3) + STEP(F, d, a, b, c, SET(9), 7) + STEP(F, c, d, a, b, SET(10), 11) + STEP(F, b, c, d, a, SET(11), 19) + STEP(F, a, b, c, d, SET(12), 3) + STEP(F, d, a, b, c, SET(13), 7) + STEP(F, c, d, a, b, SET(14), 11) + STEP(F, b, c, d, a, SET(15), 19) + +/* Round 2 */ + STEP(G, a, b, c, d, GET(0) + 0x5a827999, 3) + STEP(G, d, a, b, c, GET(4) + 0x5a827999, 5) + STEP(G, c, d, a, b, GET(8) + 0x5a827999, 9) + STEP(G, b, c, d, a, GET(12) + 0x5a827999, 13) + STEP(G, a, b, c, d, GET(1) + 0x5a827999, 3) + STEP(G, d, a, b, c, GET(5) + 0x5a827999, 5) + STEP(G, c, d, a, b, GET(9) + 0x5a827999, 9) + STEP(G, b, c, d, a, GET(13) + 0x5a827999, 13) + STEP(G, a, b, c, d, GET(2) + 0x5a827999, 3) + STEP(G, d, a, b, c, GET(6) + 0x5a827999, 5) + STEP(G, c, d, a, b, GET(10) + 0x5a827999, 9) + STEP(G, b, c, d, a, GET(14) + 0x5a827999, 13) + STEP(G, a, b, c, d, GET(3) + 0x5a827999, 3) + STEP(G, d, a, b, c, GET(7) + 0x5a827999, 5) + STEP(G, c, d, a, b, GET(11) + 0x5a827999, 9) + STEP(G, b, c, d, a, GET(15) + 0x5a827999, 13) + +/* Round 3 */ + STEP(H, a, b, c, d, GET(0) + 0x6ed9eba1, 3) + STEP(H, d, a, b, c, GET(8) + 0x6ed9eba1, 9) + STEP(H, c, d, a, b, GET(4) + 0x6ed9eba1, 11) + STEP(H, b, c, d, a, GET(12) + 0x6ed9eba1, 15) + STEP(H, a, b, c, d, GET(2) + 0x6ed9eba1, 3) + STEP(H, d, a, b, c, GET(10) + 0x6ed9eba1, 9) + STEP(H, c, d, a, b, GET(6) + 0x6ed9eba1, 11) + STEP(H, b, c, d, a, GET(14) + 0x6ed9eba1, 15) + STEP(H, a, b, c, d, GET(1) + 0x6ed9eba1, 3) + STEP(H, d, a, b, c, GET(9) + 0x6ed9eba1, 9) + STEP(H, c, d, a, b, GET(5) + 0x6ed9eba1, 11) + STEP(H, b, c, d, a, GET(13) + 0x6ed9eba1, 15) + STEP(H, a, b, c, d, GET(3) + 0x6ed9eba1, 3) + STEP(H, d, a, b, c, GET(11) + 0x6ed9eba1, 9) + STEP(H, c, d, a, b, GET(7) + 0x6ed9eba1, 11) + STEP(H, b, c, d, a, GET(15) + 0x6ed9eba1, 15) + + a += saved_a; + b += saved_b; + c += saved_c; + d += saved_d; + + ptr += 64; + } while(size -= 64); + + ctx->a = a; + ctx->b = b; + ctx->c = c; + ctx->d = d; + + return ptr; } -/* MD4 block update operation. Continues an MD4 message-digest - operation, processing another message block, and updating the - context. - */ -static void MD4Update(MD4_CTX *context, const unsigned char *input, - unsigned int inputLen) +static void MD4_Init(MD4_CTX *ctx) { - unsigned int i, bufindex, partLen; - - /* Compute number of bytes mod 64 */ - bufindex = (unsigned int)((context->count[0] >> 3) & 0x3F); - /* Update number of bits */ - if((context->count[0] += ((UINT4)inputLen << 3)) - < ((UINT4)inputLen << 3)) - context->count[1]++; - context->count[1] += ((UINT4)inputLen >> 29); - - partLen = 64 - bufindex; - /* Transform as many times as possible. - */ - if(inputLen >= partLen) { - memcpy(&context->buffer[bufindex], input, partLen); - MD4Transform (context->state, context->buffer); - - for(i = partLen; i + 63 < inputLen; i += 64) - MD4Transform (context->state, &input[i]); - - bufindex = 0; - } - else - i = 0; + ctx->a = 0x67452301; + ctx->b = 0xefcdab89; + ctx->c = 0x98badcfe; + ctx->d = 0x10325476; - /* Buffer remaining input */ - memcpy(&context->buffer[bufindex], &input[i], inputLen-i); + ctx->lo = 0; + ctx->hi = 0; } -/* MD4 padding. */ -static void MD4Pad(MD4_CTX *context) +static void MD4_Update(MD4_CTX *ctx, const void *data, unsigned long size) { - unsigned char bits[8]; - unsigned int bufindex, padLen; + MD4_u32plus saved_lo; + unsigned long used, available; - /* Save number of bits */ - Encode (bits, context->count, 8); + saved_lo = ctx->lo; + if((ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo) + ctx->hi++; + ctx->hi += (MD4_u32plus)size >> 29; - /* Pad out to 56 mod 64. - */ - bufindex = (unsigned int)((context->count[0] >> 3) & 0x3f); - padLen = (bufindex < 56) ? (56 - bufindex) : (120 - bufindex); - MD4Update (context, PADDING, padLen); + used = saved_lo & 0x3f; - /* Append length (before padding) */ - MD4Update (context, bits, 8); -} + if(used) { + available = 64 - used; -/* MD4 finalization. Ends an MD4 message-digest operation, writing the - the message digest and zeroizing the context. - */ -static void MD4Final (unsigned char digest[16], MD4_CTX *context) -{ - /* Do padding */ - MD4Pad (context); + if(size < available) { + memcpy(&ctx->buffer[used], data, size); + return; + } - /* Store state in digest */ - Encode (digest, context->state, 16); + memcpy(&ctx->buffer[used], data, available); + data = (const unsigned char *)data + available; + size -= available; + body(ctx, ctx->buffer, 64); + } - /* Zeroize sensitive information. - */ - memset(context, 0, sizeof(*context)); -} + if(size >= 64) { + data = body(ctx, data, size & ~(unsigned long)0x3f); + size &= 0x3f; + } -/* MD4 basic transformation. Transforms state based on block. - */ -static void MD4Transform (UINT4 state[4], const unsigned char block[64]) -{ - UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16]; - - Decode (x, block, 64); - - /* Round 1 */ - FF (a, b, c, d, x[ 0], S11); /* 1 */ - FF (d, a, b, c, x[ 1], S12); /* 2 */ - FF (c, d, a, b, x[ 2], S13); /* 3 */ - FF (b, c, d, a, x[ 3], S14); /* 4 */ - FF (a, b, c, d, x[ 4], S11); /* 5 */ - FF (d, a, b, c, x[ 5], S12); /* 6 */ - FF (c, d, a, b, x[ 6], S13); /* 7 */ - FF (b, c, d, a, x[ 7], S14); /* 8 */ - FF (a, b, c, d, x[ 8], S11); /* 9 */ - FF (d, a, b, c, x[ 9], S12); /* 10 */ - FF (c, d, a, b, x[10], S13); /* 11 */ - FF (b, c, d, a, x[11], S14); /* 12 */ - FF (a, b, c, d, x[12], S11); /* 13 */ - FF (d, a, b, c, x[13], S12); /* 14 */ - FF (c, d, a, b, x[14], S13); /* 15 */ - FF (b, c, d, a, x[15], S14); /* 16 */ - - /* Round 2 */ - GG (a, b, c, d, x[ 0], S21); /* 17 */ - GG (d, a, b, c, x[ 4], S22); /* 18 */ - GG (c, d, a, b, x[ 8], S23); /* 19 */ - GG (b, c, d, a, x[12], S24); /* 20 */ - GG (a, b, c, d, x[ 1], S21); /* 21 */ - GG (d, a, b, c, x[ 5], S22); /* 22 */ - GG (c, d, a, b, x[ 9], S23); /* 23 */ - GG (b, c, d, a, x[13], S24); /* 24 */ - GG (a, b, c, d, x[ 2], S21); /* 25 */ - GG (d, a, b, c, x[ 6], S22); /* 26 */ - GG (c, d, a, b, x[10], S23); /* 27 */ - GG (b, c, d, a, x[14], S24); /* 28 */ - GG (a, b, c, d, x[ 3], S21); /* 29 */ - GG (d, a, b, c, x[ 7], S22); /* 30 */ - GG (c, d, a, b, x[11], S23); /* 31 */ - GG (b, c, d, a, x[15], S24); /* 32 */ - - /* Round 3 */ - HH (a, b, c, d, x[ 0], S31); /* 33 */ - HH (d, a, b, c, x[ 8], S32); /* 34 */ - HH (c, d, a, b, x[ 4], S33); /* 35 */ - HH (b, c, d, a, x[12], S34); /* 36 */ - HH (a, b, c, d, x[ 2], S31); /* 37 */ - HH (d, a, b, c, x[10], S32); /* 38 */ - HH (c, d, a, b, x[ 6], S33); /* 39 */ - HH (b, c, d, a, x[14], S34); /* 40 */ - HH (a, b, c, d, x[ 1], S31); /* 41 */ - HH (d, a, b, c, x[ 9], S32); /* 42 */ - HH (c, d, a, b, x[ 5], S33); /* 43 */ - HH (b, c, d, a, x[13], S34); /* 44 */ - HH (a, b, c, d, x[ 3], S31); /* 45 */ - HH (d, a, b, c, x[11], S32); /* 46 */ - HH (c, d, a, b, x[ 7], S33); /* 47 */ - HH (b, c, d, a, x[15], S34); /* 48 */ - - state[0] += a; - state[1] += b; - state[2] += c; - state[3] += d; - - /* Zeroize sensitive information. - */ - memset(x, 0, sizeof(x)); + memcpy(ctx->buffer, data, size); } -/* Encodes input (UINT4) into output (unsigned char). Assumes len is - a multiple of 4. - */ -static void Encode(unsigned char *output, UINT4 *input, unsigned int len) +static void MD4_Final(unsigned char *result, MD4_CTX *ctx) { - unsigned int i, j; + unsigned long used, available; - for(i = 0, j = 0; j < len; i++, j += 4) { - output[j] = (unsigned char)(input[i] & 0xff); - output[j+1] = (unsigned char)((input[i] >> 8) & 0xff); - output[j+2] = (unsigned char)((input[i] >> 16) & 0xff); - output[j+3] = (unsigned char)((input[i] >> 24) & 0xff); - } -} + used = ctx->lo & 0x3f; -/* Decodes input (unsigned char) into output (UINT4). Assumes len is - a multiple of 4. - */ -static void Decode (UINT4 *output, const unsigned char *input, - unsigned int len) -{ - unsigned int i, j; + ctx->buffer[used++] = 0x80; + + available = 64 - used; - for(i = 0, j = 0; j < len; i++, j += 4) - output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) | - (((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24); + if(available < 8) { + memset(&ctx->buffer[used], 0, available); + body(ctx, ctx->buffer, 64); + used = 0; + available = 64; + } + + memset(&ctx->buffer[used], 0, available - 8); + + ctx->lo <<= 3; + ctx->buffer[56] = curlx_ultouc((ctx->lo)&0xff); + ctx->buffer[57] = curlx_ultouc((ctx->lo >> 8)&0xff); + ctx->buffer[58] = curlx_ultouc((ctx->lo >> 16)&0xff); + ctx->buffer[59] = curlx_ultouc((ctx->lo >> 24)&0xff); + ctx->buffer[60] = curlx_ultouc((ctx->hi)&0xff); + ctx->buffer[61] = curlx_ultouc((ctx->hi >> 8)&0xff); + ctx->buffer[62] = curlx_ultouc((ctx->hi >> 16)&0xff); + ctx->buffer[63] = curlx_ultouc(ctx->hi >> 24); + + body(ctx, ctx->buffer, 64); + + result[0] = curlx_ultouc((ctx->a)&0xff); + result[1] = curlx_ultouc((ctx->a >> 8)&0xff); + result[2] = curlx_ultouc((ctx->a >> 16)&0xff); + result[3] = curlx_ultouc(ctx->a >> 24); + result[4] = curlx_ultouc((ctx->b)&0xff); + result[5] = curlx_ultouc((ctx->b >> 8)&0xff); + result[6] = curlx_ultouc((ctx->b >> 16)&0xff); + result[7] = curlx_ultouc(ctx->b >> 24); + result[8] = curlx_ultouc((ctx->c)&0xff); + result[9] = curlx_ultouc((ctx->c >> 8)&0xff); + result[10] = curlx_ultouc((ctx->c >> 16)&0xff); + result[11] = curlx_ultouc(ctx->c >> 24); + result[12] = curlx_ultouc((ctx->d)&0xff); + result[13] = curlx_ultouc((ctx->d >> 8)&0xff); + result[14] = curlx_ultouc((ctx->d >> 16)&0xff); + result[15] = curlx_ultouc(ctx->d >> 24); + + memset(ctx, 0, sizeof(*ctx)); } +#endif + void Curl_md4it(unsigned char *output, const unsigned char *input, size_t len) { MD4_CTX ctx; - MD4Init(&ctx); - MD4Update(&ctx, input, curlx_uztoui(len)); - MD4Final(output, &ctx); + MD4_Init(&ctx); + MD4_Update(&ctx, input, curlx_uztoui(len)); + MD4_Final(output, &ctx); } -#endif /* USE_NSS */ +#endif /* defined(USE_NSS) || defined(USE_OS400CRYPTO) */ diff --git a/lib/md5.c b/lib/md5.c index af39fd4..b604c10 100644 --- a/lib/md5.c +++ b/lib/md5.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -28,11 +28,10 @@ #include "curl_hmac.h" #include "warnless.h" -#include "curl_memory.h" - #if defined(USE_GNUTLS_NETTLE) #include +#include "curl_memory.h" /* The last #include file should be: */ #include "memdebug.h" @@ -58,6 +57,7 @@ static void MD5_Final(unsigned char digest[16], MD5_CTX * ctx) #elif defined(USE_GNUTLS) #include +#include "curl_memory.h" /* The last #include file should be: */ #include "memdebug.h" @@ -81,14 +81,12 @@ static void MD5_Final(unsigned char digest[16], MD5_CTX * ctx) gcry_md_close(*ctx); } -#elif defined(USE_SSLEAY) +#elif defined(USE_OPENSSL) /* When OpenSSL is available we use the MD5-function from OpenSSL */ - -# ifdef USE_OPENSSL -# include -# else -# include -# endif +#include +#include "curl_memory.h" +/* The last #include file should be: */ +#include "memdebug.h" #elif (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && \ (__MAC_OS_X_VERSION_MAX_ALLOWED >= 1040)) || \ @@ -103,6 +101,9 @@ static void MD5_Final(unsigned char digest[16], MD5_CTX * ctx) reliable than defining COMMON_DIGEST_FOR_OPENSSL on older cats. */ # include # define MD5_CTX CC_MD5_CTX +#include "curl_memory.h" +/* The last #include file should be: */ +#include "memdebug.h" static void MD5_Init(MD5_CTX *ctx) { @@ -124,6 +125,9 @@ static void MD5_Final(unsigned char digest[16], MD5_CTX *ctx) #elif defined(_WIN32) #include +#include "curl_memory.h" +/* The last #include file should be: */ +#include "memdebug.h" typedef struct { HCRYPTPROV hCryptProv; @@ -157,314 +161,326 @@ static void MD5_Final(unsigned char digest[16], MD5_CTX *ctx) CryptReleaseContext(ctx->hCryptProv, 0); } +#elif defined(USE_AXTLS) +#include +#include +#include +#include "curl_memory.h" +/* The last #include file should be: */ +#include "memdebug.h" #else /* When no other crypto library is available we use this code segment */ - -/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All -rights reserved. - -License to copy and use this software is granted provided that it -is identified as the "RSA Data Security, Inc. MD5 Message-Digest -Algorithm" in all material mentioning or referencing this software -or this function. - -License is also granted to make and use derivative works provided -that such works are identified as "derived from the RSA Data -Security, Inc. MD5 Message-Digest Algorithm" in all material -mentioning or referencing the derived work. - -RSA Data Security, Inc. makes no representations concerning either -the merchantability of this software or the suitability of this -software for any particular purpose. It is provided "as is" -without express or implied warranty of any kind. - -These notices must be retained in any copies of any part of this -documentation and/or software. +/* + * This is an OpenSSL-compatible implementation of the RSA Data Security, Inc. + * MD5 Message-Digest Algorithm (RFC 1321). + * + * Homepage: + http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5 + * + * Author: + * Alexander Peslyak, better known as Solar Designer + * + * This software was written by Alexander Peslyak in 2001. No copyright is + * claimed, and the software is hereby placed in the public domain. + * In case this attempt to disclaim copyright and place the software in the + * public domain is deemed null and void, then the software is + * Copyright (c) 2001 Alexander Peslyak and it is hereby released to the + * general public under the following terms: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted. + * + * There's ABSOLUTELY NO WARRANTY, express or implied. + * + * (This is a heavily cut-down "BSD license".) + * + * This differs from Colin Plumb's older public domain implementation in that + * no exactly 32-bit integer data type is required (any 32-bit or wider + * unsigned integer data type will do), there's no compile-time endianness + * configuration, and the function prototypes match OpenSSL's. No code from + * Colin Plumb's implementation has been reused; this comment merely compares + * the properties of the two independent implementations. + * + * The primary goals of this implementation are portability and ease of use. + * It is meant to be fast, but not as fast as possible. Some known + * optimizations are not included to reduce source code size and avoid + * compile-time configuration. */ -/* UINT4 defines a four byte word */ -typedef unsigned int UINT4; +#include -/* MD5 context. */ -struct md5_ctx { - UINT4 state[4]; /* state (ABCD) */ - UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */ - unsigned char buffer[64]; /* input buffer */ -}; - -typedef struct md5_ctx MD5_CTX; +/* The last #include files should be: */ +#include "curl_memory.h" +#include "memdebug.h" -static void MD5_Init(struct md5_ctx *); -static void MD5_Update(struct md5_ctx *, const unsigned char *, unsigned int); -static void MD5_Final(unsigned char [16], struct md5_ctx *); +/* Any 32-bit or wider unsigned integer data type will do */ +typedef unsigned int MD5_u32plus; -/* Constants for MD5Transform routine. - */ +typedef struct { + MD5_u32plus lo, hi; + MD5_u32plus a, b, c, d; + unsigned char buffer[64]; + MD5_u32plus block[16]; +} MD5_CTX; -#define S11 7 -#define S12 12 -#define S13 17 -#define S14 22 -#define S21 5 -#define S22 9 -#define S23 14 -#define S24 20 -#define S31 4 -#define S32 11 -#define S33 16 -#define S34 23 -#define S41 6 -#define S42 10 -#define S43 15 -#define S44 21 - -static void MD5Transform(UINT4 [4], const unsigned char [64]); -static void Encode(unsigned char *, UINT4 *, unsigned int); -static void Decode(UINT4 *, const unsigned char *, unsigned int); - -static const unsigned char PADDING[64] = { - 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; +static void MD5_Init(MD5_CTX *ctx); +static void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size); +static void MD5_Final(unsigned char *result, MD5_CTX *ctx); -/* F, G, H and I are basic MD5 functions. +/* + * The basic MD5 functions. + * + * F and G are optimized compared to their RFC 1321 definitions for + * architectures that lack an AND-NOT instruction, just like in Colin Plumb's + * implementation. */ -#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) -#define G(x, y, z) (((x) & (z)) | ((y) & (~z))) -#define H(x, y, z) ((x) ^ (y) ^ (z)) -#define I(x, y, z) ((y) ^ ((x) | (~z))) - -/* ROTATE_LEFT rotates x left n bits. +#define F(x, y, z) ((z) ^ ((x) & ((y) ^ (z)))) +#define G(x, y, z) ((y) ^ ((z) & ((x) ^ (y)))) +#define H(x, y, z) (((x) ^ (y)) ^ (z)) +#define H2(x, y, z) ((x) ^ ((y) ^ (z))) +#define I(x, y, z) ((y) ^ ((x) | ~(z))) + +/* + * The MD5 transformation for all four rounds. */ -#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) - -/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4. -Rotation is separate from addition to prevent recomputation. +#define STEP(f, a, b, c, d, x, t, s) \ + (a) += f((b), (c), (d)) + (x) + (t); \ + (a) = (((a) << (s)) | (((a) & 0xffffffff) >> (32 - (s)))); \ + (a) += (b); + +/* + * SET reads 4 input bytes in little-endian byte order and stores them + * in a properly aligned word in host byte order. + * + * The check for little-endian architectures that tolerate unaligned + * memory accesses is just an optimization. Nothing will break if it + * doesn't work. */ -#define FF(a, b, c, d, x, s, ac) { \ - (a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } -#define GG(a, b, c, d, x, s, ac) { \ - (a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } -#define HH(a, b, c, d, x, s, ac) { \ - (a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } -#define II(a, b, c, d, x, s, ac) { \ - (a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } - -/* MD5 initialization. Begins an MD5 operation, writing a new context. +#if defined(__i386__) || defined(__x86_64__) || defined(__vax__) +#define SET(n) \ + (*(MD5_u32plus *)&ptr[(n) * 4]) +#define GET(n) \ + SET(n) +#else +#define SET(n) \ + (ctx->block[(n)] = \ + (MD5_u32plus)ptr[(n) * 4] | \ + ((MD5_u32plus)ptr[(n) * 4 + 1] << 8) | \ + ((MD5_u32plus)ptr[(n) * 4 + 2] << 16) | \ + ((MD5_u32plus)ptr[(n) * 4 + 3] << 24)) +#define GET(n) \ + (ctx->block[(n)]) +#endif + +/* + * This processes one or more 64-byte data blocks, but does NOT update + * the bit counters. There are no alignment requirements. */ -static void MD5_Init(struct md5_ctx *context) +static const void *body(MD5_CTX *ctx, const void *data, unsigned long size) { - context->count[0] = context->count[1] = 0; - /* Load magic initialization constants. */ - context->state[0] = 0x67452301; - context->state[1] = 0xefcdab89; - context->state[2] = 0x98badcfe; - context->state[3] = 0x10325476; + const unsigned char *ptr; + MD5_u32plus a, b, c, d; + MD5_u32plus saved_a, saved_b, saved_c, saved_d; + + ptr = (const unsigned char *)data; + + a = ctx->a; + b = ctx->b; + c = ctx->c; + d = ctx->d; + + do { + saved_a = a; + saved_b = b; + saved_c = c; + saved_d = d; + +/* Round 1 */ + STEP(F, a, b, c, d, SET(0), 0xd76aa478, 7) + STEP(F, d, a, b, c, SET(1), 0xe8c7b756, 12) + STEP(F, c, d, a, b, SET(2), 0x242070db, 17) + STEP(F, b, c, d, a, SET(3), 0xc1bdceee, 22) + STEP(F, a, b, c, d, SET(4), 0xf57c0faf, 7) + STEP(F, d, a, b, c, SET(5), 0x4787c62a, 12) + STEP(F, c, d, a, b, SET(6), 0xa8304613, 17) + STEP(F, b, c, d, a, SET(7), 0xfd469501, 22) + STEP(F, a, b, c, d, SET(8), 0x698098d8, 7) + STEP(F, d, a, b, c, SET(9), 0x8b44f7af, 12) + STEP(F, c, d, a, b, SET(10), 0xffff5bb1, 17) + STEP(F, b, c, d, a, SET(11), 0x895cd7be, 22) + STEP(F, a, b, c, d, SET(12), 0x6b901122, 7) + STEP(F, d, a, b, c, SET(13), 0xfd987193, 12) + STEP(F, c, d, a, b, SET(14), 0xa679438e, 17) + STEP(F, b, c, d, a, SET(15), 0x49b40821, 22) + +/* Round 2 */ + STEP(G, a, b, c, d, GET(1), 0xf61e2562, 5) + STEP(G, d, a, b, c, GET(6), 0xc040b340, 9) + STEP(G, c, d, a, b, GET(11), 0x265e5a51, 14) + STEP(G, b, c, d, a, GET(0), 0xe9b6c7aa, 20) + STEP(G, a, b, c, d, GET(5), 0xd62f105d, 5) + STEP(G, d, a, b, c, GET(10), 0x02441453, 9) + STEP(G, c, d, a, b, GET(15), 0xd8a1e681, 14) + STEP(G, b, c, d, a, GET(4), 0xe7d3fbc8, 20) + STEP(G, a, b, c, d, GET(9), 0x21e1cde6, 5) + STEP(G, d, a, b, c, GET(14), 0xc33707d6, 9) + STEP(G, c, d, a, b, GET(3), 0xf4d50d87, 14) + STEP(G, b, c, d, a, GET(8), 0x455a14ed, 20) + STEP(G, a, b, c, d, GET(13), 0xa9e3e905, 5) + STEP(G, d, a, b, c, GET(2), 0xfcefa3f8, 9) + STEP(G, c, d, a, b, GET(7), 0x676f02d9, 14) + STEP(G, b, c, d, a, GET(12), 0x8d2a4c8a, 20) + +/* Round 3 */ + STEP(H, a, b, c, d, GET(5), 0xfffa3942, 4) + STEP(H2, d, a, b, c, GET(8), 0x8771f681, 11) + STEP(H, c, d, a, b, GET(11), 0x6d9d6122, 16) + STEP(H2, b, c, d, a, GET(14), 0xfde5380c, 23) + STEP(H, a, b, c, d, GET(1), 0xa4beea44, 4) + STEP(H2, d, a, b, c, GET(4), 0x4bdecfa9, 11) + STEP(H, c, d, a, b, GET(7), 0xf6bb4b60, 16) + STEP(H2, b, c, d, a, GET(10), 0xbebfbc70, 23) + STEP(H, a, b, c, d, GET(13), 0x289b7ec6, 4) + STEP(H2, d, a, b, c, GET(0), 0xeaa127fa, 11) + STEP(H, c, d, a, b, GET(3), 0xd4ef3085, 16) + STEP(H2, b, c, d, a, GET(6), 0x04881d05, 23) + STEP(H, a, b, c, d, GET(9), 0xd9d4d039, 4) + STEP(H2, d, a, b, c, GET(12), 0xe6db99e5, 11) + STEP(H, c, d, a, b, GET(15), 0x1fa27cf8, 16) + STEP(H2, b, c, d, a, GET(2), 0xc4ac5665, 23) + +/* Round 4 */ + STEP(I, a, b, c, d, GET(0), 0xf4292244, 6) + STEP(I, d, a, b, c, GET(7), 0x432aff97, 10) + STEP(I, c, d, a, b, GET(14), 0xab9423a7, 15) + STEP(I, b, c, d, a, GET(5), 0xfc93a039, 21) + STEP(I, a, b, c, d, GET(12), 0x655b59c3, 6) + STEP(I, d, a, b, c, GET(3), 0x8f0ccc92, 10) + STEP(I, c, d, a, b, GET(10), 0xffeff47d, 15) + STEP(I, b, c, d, a, GET(1), 0x85845dd1, 21) + STEP(I, a, b, c, d, GET(8), 0x6fa87e4f, 6) + STEP(I, d, a, b, c, GET(15), 0xfe2ce6e0, 10) + STEP(I, c, d, a, b, GET(6), 0xa3014314, 15) + STEP(I, b, c, d, a, GET(13), 0x4e0811a1, 21) + STEP(I, a, b, c, d, GET(4), 0xf7537e82, 6) + STEP(I, d, a, b, c, GET(11), 0xbd3af235, 10) + STEP(I, c, d, a, b, GET(2), 0x2ad7d2bb, 15) + STEP(I, b, c, d, a, GET(9), 0xeb86d391, 21) + + a += saved_a; + b += saved_b; + c += saved_c; + d += saved_d; + + ptr += 64; + } while(size -= 64); + + ctx->a = a; + ctx->b = b; + ctx->c = c; + ctx->d = d; + + return ptr; } -/* MD5 block update operation. Continues an MD5 message-digest - operation, processing another message block, and updating the - context. - */ -static void MD5_Update (struct md5_ctx *context, /* context */ - const unsigned char *input, /* input block */ - unsigned int inputLen) /* length of input block */ +static void MD5_Init(MD5_CTX *ctx) { - unsigned int i, bufindex, partLen; + ctx->a = 0x67452301; + ctx->b = 0xefcdab89; + ctx->c = 0x98badcfe; + ctx->d = 0x10325476; - /* Compute number of bytes mod 64 */ - bufindex = (unsigned int)((context->count[0] >> 3) & 0x3F); + ctx->lo = 0; + ctx->hi = 0; +} - /* Update number of bits */ - if((context->count[0] += ((UINT4)inputLen << 3)) - < ((UINT4)inputLen << 3)) - context->count[1]++; - context->count[1] += ((UINT4)inputLen >> 29); +static void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size) +{ + MD5_u32plus saved_lo; + unsigned long used, available; + + saved_lo = ctx->lo; + if((ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo) + ctx->hi++; + ctx->hi += (MD5_u32plus)size >> 29; - partLen = 64 - bufindex; + used = saved_lo & 0x3f; - /* Transform as many times as possible. */ - if(inputLen >= partLen) { - memcpy(&context->buffer[bufindex], input, partLen); - MD5Transform(context->state, context->buffer); + if(used) { + available = 64 - used; - for(i = partLen; i + 63 < inputLen; i += 64) - MD5Transform(context->state, &input[i]); + if(size < available) { + memcpy(&ctx->buffer[used], data, size); + return; + } + + memcpy(&ctx->buffer[used], data, available); + data = (const unsigned char *)data + available; + size -= available; + body(ctx, ctx->buffer, 64); + } - bufindex = 0; + if(size >= 64) { + data = body(ctx, data, size & ~(unsigned long)0x3f); + size &= 0x3f; } - else - i = 0; - /* Buffer remaining input */ - memcpy(&context->buffer[bufindex], &input[i], inputLen-i); + memcpy(ctx->buffer, data, size); } -/* MD5 finalization. Ends an MD5 message-digest operation, writing the - the message digest and zeroizing the context. -*/ -static void MD5_Final(unsigned char digest[16], /* message digest */ - struct md5_ctx *context) /* context */ +static void MD5_Final(unsigned char *result, MD5_CTX *ctx) { - unsigned char bits[8]; - unsigned int count, padLen; + unsigned long used, available; - /* Save number of bits */ - Encode (bits, context->count, 8); + used = ctx->lo & 0x3f; - /* Pad out to 56 mod 64. */ - count = (unsigned int)((context->count[0] >> 3) & 0x3f); - padLen = (count < 56) ? (56 - count) : (120 - count); - MD5_Update (context, PADDING, padLen); + ctx->buffer[used++] = 0x80; - /* Append length (before padding) */ - MD5_Update (context, bits, 8); + available = 64 - used; - /* Store state in digest */ - Encode (digest, context->state, 16); - - /* Zeroize sensitive information. */ - memset ((void *)context, 0, sizeof (*context)); -} - -/* MD5 basic transformation. Transforms state based on block. */ -static void MD5Transform(UINT4 state[4], - const unsigned char block[64]) -{ - UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16]; - - Decode (x, block, 64); - - /* Round 1 */ - FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */ - FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */ - FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */ - FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */ - FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */ - FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */ - FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */ - FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */ - FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */ - FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */ - FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */ - FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */ - FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */ - FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */ - FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */ - FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */ - - /* Round 2 */ - GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */ - GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */ - GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */ - GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */ - GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */ - GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */ - GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */ - GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */ - GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */ - GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */ - GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */ - GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */ - GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */ - GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */ - GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */ - GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */ - - /* Round 3 */ - HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */ - HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */ - HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */ - HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */ - HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */ - HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */ - HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */ - HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */ - HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */ - HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */ - HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */ - HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */ - HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */ - HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */ - HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */ - HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */ - - /* Round 4 */ - II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */ - II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */ - II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */ - II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */ - II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */ - II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */ - II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */ - II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */ - II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */ - II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */ - II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */ - II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */ - II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */ - II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */ - II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */ - II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */ - - state[0] += a; - state[1] += b; - state[2] += c; - state[3] += d; - - /* Zeroize sensitive information. */ - memset((void *)x, 0, sizeof (x)); -} - -/* Encodes input (UINT4) into output (unsigned char). Assumes len is - a multiple of 4. - */ -static void Encode (unsigned char *output, - UINT4 *input, - unsigned int len) -{ - unsigned int i, j; - - for(i = 0, j = 0; j < len; i++, j += 4) { - output[j] = (unsigned char)(input[i] & 0xff); - output[j+1] = (unsigned char)((input[i] >> 8) & 0xff); - output[j+2] = (unsigned char)((input[i] >> 16) & 0xff); - output[j+3] = (unsigned char)((input[i] >> 24) & 0xff); + if(available < 8) { + memset(&ctx->buffer[used], 0, available); + body(ctx, ctx->buffer, 64); + used = 0; + available = 64; } -} - -/* Decodes input (unsigned char) into output (UINT4). Assumes len is - a multiple of 4. -*/ -static void Decode (UINT4 *output, - const unsigned char *input, - unsigned int len) -{ - unsigned int i, j; - for(i = 0, j = 0; j < len; i++, j += 4) - output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) | - (((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24); + memset(&ctx->buffer[used], 0, available - 8); + + ctx->lo <<= 3; + ctx->buffer[56] = curlx_ultouc((ctx->lo)&0xff); + ctx->buffer[57] = curlx_ultouc((ctx->lo >> 8)&0xff); + ctx->buffer[58] = curlx_ultouc((ctx->lo >> 16)&0xff); + ctx->buffer[59] = curlx_ultouc(ctx->lo >> 24); + ctx->buffer[60] = curlx_ultouc((ctx->hi)&0xff); + ctx->buffer[61] = curlx_ultouc((ctx->hi >> 8)&0xff); + ctx->buffer[62] = curlx_ultouc((ctx->hi >> 16)&0xff); + ctx->buffer[63] = curlx_ultouc(ctx->hi >> 24); + + body(ctx, ctx->buffer, 64); + + result[0] = curlx_ultouc((ctx->a)&0xff); + result[1] = curlx_ultouc((ctx->a >> 8)&0xff); + result[2] = curlx_ultouc((ctx->a >> 16)&0xff); + result[3] = curlx_ultouc(ctx->a >> 24); + result[4] = curlx_ultouc((ctx->b)&0xff); + result[5] = curlx_ultouc((ctx->b >> 8)&0xff); + result[6] = curlx_ultouc((ctx->b >> 16)&0xff); + result[7] = curlx_ultouc(ctx->b >> 24); + result[8] = curlx_ultouc((ctx->c)&0xff); + result[9] = curlx_ultouc((ctx->c >> 8)&0xff); + result[10] = curlx_ultouc((ctx->c >> 16)&0xff); + result[11] = curlx_ultouc(ctx->c >> 24); + result[12] = curlx_ultouc((ctx->d)&0xff); + result[13] = curlx_ultouc((ctx->d >> 8)&0xff); + result[14] = curlx_ultouc((ctx->d >> 16)&0xff); + result[15] = curlx_ultouc(ctx->d >> 24); + + memset(ctx, 0, sizeof(*ctx)); } #endif /* CRYPTO LIBS */ -/* The last #include file should be: */ -#include "memdebug.h" - const HMAC_params Curl_HMAC_MD5[] = { { (HMAC_hinit_func) MD5_Init, /* Hash initialization function. */ @@ -486,6 +502,9 @@ const MD5_params Curl_DIGEST_MD5[] = { } }; +/* + * @unittest: 1601 + */ void Curl_md5it(unsigned char *outbuffer, /* 16 bytes */ const unsigned char *input) { diff --git a/lib/memdebug.c b/lib/memdebug.c index 4afa620..dd8889b 100644 --- a/lib/memdebug.c +++ b/lib/memdebug.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2013, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -26,8 +26,7 @@ #include -#define _MPRINTF_REPLACE -#include +#include "curl_printf.h" #include "urldata.h" #define MEMDEBUG_NODEFINES /* don't redefine the standard functions */ @@ -113,7 +112,7 @@ void curl_memdebug(const char *logname) { if(!logfile) { if(logname && *logname) - logfile = fopen(logname, "w"); + logfile = fopen(logname, FOPEN_WRITETEXT); else logfile = stderr; #ifdef MEMDEBUG_LOG_SYNC @@ -343,10 +342,10 @@ curl_socket_t curl_socket(int domain, int type, int protocol, int line, const char *source) { const char *fmt = (sizeof(curl_socket_t) == sizeof(int)) ? - "FD %s:%d socket() = %d\n" : - (sizeof(curl_socket_t) == sizeof(long)) ? - "FD %s:%d socket() = %ld\n" : - "FD %s:%d socket() = %zd\n" ; + "FD %s:%d socket() = %d\n" : + (sizeof(curl_socket_t) == sizeof(long)) ? + "FD %s:%d socket() = %ld\n" : + "FD %s:%d socket() = %zd\n"; curl_socket_t sockfd = socket(domain, type, protocol); @@ -362,10 +361,10 @@ int curl_socketpair(int domain, int type, int protocol, int line, const char *source) { const char *fmt = (sizeof(curl_socket_t) == sizeof(int)) ? - "FD %s:%d socketpair() = %d %d\n" : - (sizeof(curl_socket_t) == sizeof(long)) ? - "FD %s:%d socketpair() = %ld %ld\n" : - "FD %s:%d socketpair() = %zd %zd\n" ; + "FD %s:%d socketpair() = %d %d\n" : + (sizeof(curl_socket_t) == sizeof(long)) ? + "FD %s:%d socketpair() = %ld %ld\n" : + "FD %s:%d socketpair() = %zd %zd\n"; int res = socketpair(domain, type, protocol, socket_vector); @@ -380,10 +379,10 @@ curl_socket_t curl_accept(curl_socket_t s, void *saddr, void *saddrlen, int line, const char *source) { const char *fmt = (sizeof(curl_socket_t) == sizeof(int)) ? - "FD %s:%d accept() = %d\n" : - (sizeof(curl_socket_t) == sizeof(long)) ? - "FD %s:%d accept() = %ld\n" : - "FD %s:%d accept() = %zd\n" ; + "FD %s:%d accept() = %d\n" : + (sizeof(curl_socket_t) == sizeof(long)) ? + "FD %s:%d accept() = %ld\n" : + "FD %s:%d accept() = %zd\n"; struct sockaddr *addr = (struct sockaddr *)saddr; curl_socklen_t *addrlen = (curl_socklen_t *)saddrlen; @@ -400,10 +399,10 @@ curl_socket_t curl_accept(curl_socket_t s, void *saddr, void *saddrlen, void curl_mark_sclose(curl_socket_t sockfd, int line, const char *source) { const char *fmt = (sizeof(curl_socket_t) == sizeof(int)) ? - "FD %s:%d sclose(%d)\n" : - (sizeof(curl_socket_t) == sizeof(long)) ? - "FD %s:%d sclose(%ld)\n" : - "FD %s:%d sclose(%zd)\n" ; + "FD %s:%d sclose(%d)\n": + (sizeof(curl_socket_t) == sizeof(long)) ? + "FD %s:%d sclose(%ld)\n": + "FD %s:%d sclose(%zd)\n"; if(source) curl_memlog(fmt, source, line, sockfd); diff --git a/lib/memdebug.h b/lib/memdebug.h index bd565c8..cfac1e0 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -8,7 +8,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2013, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -104,13 +104,13 @@ CURL_EXTERN int curl_fclose(FILE *file, int line, const char *source); #endif #define socket(domain,type,protocol)\ - curl_socket(domain,type,protocol,__LINE__,__FILE__) + curl_socket(domain, type, protocol, __LINE__, __FILE__) #undef accept /* for those with accept as a macro */ #define accept(sock,addr,len)\ - curl_accept(sock,addr,len,__LINE__,__FILE__) + curl_accept(sock, addr, len, __LINE__, __FILE__) #ifdef HAVE_SOCKETPAIR #define socketpair(domain,type,protocol,socket_vector)\ - curl_socketpair(domain,type,protocol,socket_vector,__LINE__,__FILE__) + curl_socketpair(domain, type, protocol, socket_vector, __LINE__, __FILE__) #endif #ifdef HAVE_GETADDRINFO @@ -119,25 +119,25 @@ CURL_EXTERN int curl_fclose(FILE *file, int line, const char *source); our macro as for other platforms. Instead, we redefine the new name they define getaddrinfo to become! */ #define ogetaddrinfo(host,serv,hint,res) \ - curl_dogetaddrinfo(host,serv,hint,res,__LINE__,__FILE__) + curl_dogetaddrinfo(host, serv, hint, res, __LINE__, __FILE__) #else #undef getaddrinfo #define getaddrinfo(host,serv,hint,res) \ - curl_dogetaddrinfo(host,serv,hint,res,__LINE__,__FILE__) + curl_dogetaddrinfo(host, serv, hint, res, __LINE__, __FILE__) #endif #endif /* HAVE_GETADDRINFO */ #ifdef HAVE_GETNAMEINFO #undef getnameinfo #define getnameinfo(sa,salen,host,hostlen,serv,servlen,flags) \ - curl_dogetnameinfo(sa,salen,host,hostlen,serv,servlen,flags, __LINE__, \ - __FILE__) + curl_dogetnameinfo(sa, salen, host, hostlen, serv, servlen, flags, \ + __LINE__, __FILE__) #endif /* HAVE_GETNAMEINFO */ #ifdef HAVE_FREEADDRINFO #undef freeaddrinfo #define freeaddrinfo(data) \ - curl_dofreeaddrinfo(data,__LINE__,__FILE__) + curl_dofreeaddrinfo(data, __LINE__, __FILE__) #endif /* HAVE_FREEADDRINFO */ /* sclose is probably already defined, redefine it! */ @@ -171,6 +171,6 @@ CURL_EXTERN int curl_fclose(FILE *file, int line, const char *source); */ #define Curl_safefree(ptr) \ - do {if((ptr)) {free((ptr)); (ptr) = NULL;}} WHILE_FALSE + do { free((ptr)); (ptr) = NULL;} WHILE_FALSE #endif /* HEADER_CURL_MEMDEBUG_H */ diff --git a/lib/multi.c b/lib/multi.c index a1dc2c8..0052087 100644 --- a/lib/multi.c +++ b/lib/multi.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -39,14 +39,10 @@ #include "warnless.h" #include "speedcheck.h" #include "conncache.h" -#include "bundles.h" #include "multihandle.h" #include "pipeline.h" #include "sigpipe.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include - +#include "curl_printf.h" #include "curl_memory.h" /* The last #include file should be: */ #include "memdebug.h" @@ -66,15 +62,11 @@ #define GOOD_MULTI_HANDLE(x) \ ((x) && (((struct Curl_multi *)(x))->type == CURL_MULTI_HANDLE)) -#define GOOD_EASY_HANDLE(x) \ - ((x) && (((struct SessionHandle *)(x))->magic == CURLEASY_MAGIC_NUMBER)) static void singlesocket(struct Curl_multi *multi, struct SessionHandle *data); static int update_timer(struct Curl_multi *multi); -static bool isHandleAtHead(struct SessionHandle *handle, - struct curl_llist *pipeline); static CURLMcode add_next_timeout(struct timeval now, struct Curl_multi *multi, struct SessionHandle *d); @@ -89,6 +81,7 @@ static const char * const statename[]={ "WAITRESOLVE", "WAITCONNECT", "WAITPROXYCONNECT", + "SENDPROTOCONNECT", "PROTOCONNECT", "WAITDO", "DO", @@ -113,20 +106,23 @@ static void mstate(struct SessionHandle *data, CURLMstate state #endif ) { -#ifdef DEBUGBUILD - long connection_id = -5000; -#endif CURLMstate oldstate = data->mstate; +#if defined(DEBUGBUILD) && defined(CURL_DISABLE_VERBOSE_STRINGS) + (void) lineno; +#endif + if(oldstate == state) /* don't bother when the new state is the same as the old state */ return; data->mstate = state; -#ifdef DEBUGBUILD +#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS) if(data->mstate >= CURLM_STATE_CONNECT_PEND && data->mstate < CURLM_STATE_COMPLETED) { + long connection_id = -5000; + if(data->easy_conn) connection_id = data->easy_conn->connection_id; @@ -136,6 +132,7 @@ static void mstate(struct SessionHandle *data, CURLMstate state (void *)data, lineno, connection_id); } #endif + if(state == CURLM_STATE_COMPLETED) /* changing to COMPLETED means there's one less easy handle 'alive' */ data->multi->num_alive--; @@ -153,7 +150,6 @@ static void mstate(struct SessionHandle *data, CURLMstate state struct Curl_sh_entry { struct SessionHandle *easy; - time_t timestamp; int action; /* what action READ/WRITE this socket waits for */ curl_socket_t socket; /* mainly to ease debugging */ void *socketp; /* settable by users with curl_multi_assign() */ @@ -180,11 +176,12 @@ static struct Curl_sh_entry *sh_addentry(struct curl_hash *sh, check = calloc(1, sizeof(struct Curl_sh_entry)); if(!check) return NULL; /* major failure */ + check->easy = data; check->socket = s; /* make/add new hash entry */ - if(NULL == Curl_hash_add(sh, (char *)&s, sizeof(curl_socket_t), check)) { + if(!Curl_hash_add(sh, (char *)&s, sizeof(curl_socket_t), check)) { free(check); return NULL; /* major failure */ } @@ -214,8 +211,7 @@ static void sh_freeentry(void *freethis) { struct Curl_sh_entry *p = (struct Curl_sh_entry *) freethis; - if(p) - free(p); + free(p); } static size_t fd_key_compare(void *k1, size_t k1_len, void *k2, size_t k2_len) @@ -251,10 +247,10 @@ static size_t hash_fd(void *key, size_t key_length, size_t slots_num) * per call." * */ -static struct curl_hash *sh_init(int hashsize) +static int sh_init(struct curl_hash *hash, int hashsize) { - return Curl_hash_alloc(hashsize, hash_fd, fd_key_compare, - sh_freeentry); + return Curl_hash_init(hash, hashsize, hash_fd, fd_key_compare, + sh_freeentry); } /* @@ -293,16 +289,13 @@ struct Curl_multi *Curl_multi_handle(int hashsize, /* socket hash */ multi->type = CURL_MULTI_HANDLE; - multi->hostcache = Curl_mk_dnscache(); - if(!multi->hostcache) + if(Curl_mk_dnscache(&multi->hostcache)) goto error; - multi->sockhash = sh_init(hashsize); - if(!multi->sockhash) + if(sh_init(&multi->sockhash, hashsize)) goto error; - multi->conn_cache = Curl_conncache_init(chashsize); - if(!multi->conn_cache) + if(Curl_conncache_init(&multi->conn_cache, chashsize)) goto error; multi->msglist = Curl_llist_alloc(multi_freeamsg); @@ -319,7 +312,7 @@ struct Curl_multi *Curl_multi_handle(int hashsize, /* socket hash */ goto error; multi->closure_handle->multi = multi; - multi->closure_handle->state.conn_cache = multi->conn_cache; + multi->closure_handle->state.conn_cache = &multi->conn_cache; multi->max_pipeline_length = 5; @@ -329,12 +322,9 @@ struct Curl_multi *Curl_multi_handle(int hashsize, /* socket hash */ error: - Curl_hash_destroy(multi->sockhash); - multi->sockhash = NULL; - Curl_hash_destroy(multi->hostcache); - multi->hostcache = NULL; - Curl_conncache_destroy(multi->conn_cache); - multi->conn_cache = NULL; + Curl_hash_destroy(&multi->sockhash); + Curl_hash_destroy(&multi->hostcache); + Curl_conncache_destroy(&multi->conn_cache); Curl_close(multi->closure_handle); multi->closure_handle = NULL; Curl_llist_destroy(multi->msglist, NULL); @@ -403,14 +393,12 @@ CURLMcode curl_multi_add_handle(CURLM *multi_handle, easy handle's one is currently not set. */ else if(!data->dns.hostcache || (data->dns.hostcachetype == HCACHE_NONE)) { - data->dns.hostcache = multi->hostcache; + data->dns.hostcache = &multi->hostcache; data->dns.hostcachetype = HCACHE_MULTI; } /* Point to the multi's connection cache */ - data->state.conn_cache = multi->conn_cache; - - data->state.infilesize = data->set.filesize; + data->state.conn_cache = &multi->conn_cache; /* This adds the new entry at the 'end' of the doubly-linked circular list of SessionHandle structs to try and maintain a FIFO queue so @@ -426,8 +414,7 @@ CURLMcode curl_multi_add_handle(CURLM *multi_handle, multi->easylp = data; /* the new last node */ } else { - /* first node, make both prev and next be NULL! */ - data->next = NULL; + /* first node, make prev NULL! */ data->prev = NULL; multi->easylp = multi->easyp = data; /* both first and last */ } @@ -487,6 +474,9 @@ CURLMcode curl_multi_remove_handle(CURLM *multi_handle, struct Curl_multi *multi=(struct Curl_multi *)multi_handle; struct SessionHandle *easy = curl_handle; struct SessionHandle *data = easy; + bool premature; + bool easy_owns_conn; + struct curl_llist_element *e; /* First, make some basic checks that the CURLM handle is a good handle */ if(!GOOD_MULTI_HANDLE(multi)) @@ -500,131 +490,127 @@ CURLMcode curl_multi_remove_handle(CURLM *multi_handle, if(!data->multi) return CURLM_OK; /* it is already removed so let's say it is fine! */ - if(easy) { - bool premature = (data->mstate < CURLM_STATE_COMPLETED) ? TRUE : FALSE; - bool easy_owns_conn = (data->easy_conn && - (data->easy_conn->data == easy)) ? - TRUE : FALSE; + premature = (data->mstate < CURLM_STATE_COMPLETED) ? TRUE : FALSE; + easy_owns_conn = (data->easy_conn && (data->easy_conn->data == easy)) ? + TRUE : FALSE; - /* If the 'state' is not INIT or COMPLETED, we might need to do something - nice to put the easy_handle in a good known state when this returns. */ - if(premature) - /* this handle is "alive" so we need to count down the total number of - alive connections when this is removed */ - multi->num_alive--; + /* If the 'state' is not INIT or COMPLETED, we might need to do something + nice to put the easy_handle in a good known state when this returns. */ + if(premature) { + /* this handle is "alive" so we need to count down the total number of + alive connections when this is removed */ + multi->num_alive--; - if(data->easy_conn && - (data->easy_conn->send_pipe->size + - data->easy_conn->recv_pipe->size > 1) && - data->mstate > CURLM_STATE_WAITDO && - data->mstate < CURLM_STATE_COMPLETED) { - /* If the handle is in a pipeline and has started sending off its - request but not received its response yet, we need to close - connection. */ - connclose(data->easy_conn, "Removed with partial response"); - /* Set connection owner so that Curl_done() closes it. - We can sefely do this here since connection is killed. */ - data->easy_conn->data = easy; - } + /* When this handle gets removed, other handles may be able to get the + connection */ + Curl_multi_process_pending_handles(multi); + } - /* The timer must be shut down before data->multi is set to NULL, - else the timenode will remain in the splay tree after - curl_easy_cleanup is called. */ - Curl_expire(data, 0); + if(data->easy_conn && + data->mstate > CURLM_STATE_DO && + data->mstate < CURLM_STATE_COMPLETED) { + /* If the handle is in a pipeline and has started sending off its + request but not received its response yet, we need to close + connection. */ + connclose(data->easy_conn, "Removed with partial response"); + /* Set connection owner so that Curl_done() closes it. + We can safely do this here since connection is killed. */ + data->easy_conn->data = easy; + easy_owns_conn = TRUE; + } - /* destroy the timeout list that is held in the easy handle */ - if(data->state.timeoutlist) { - Curl_llist_destroy(data->state.timeoutlist, NULL); - data->state.timeoutlist = NULL; - } + /* The timer must be shut down before data->multi is set to NULL, + else the timenode will remain in the splay tree after + curl_easy_cleanup is called. */ + Curl_expire(data, 0); - if(data->dns.hostcachetype == HCACHE_MULTI) { - /* stop using the multi handle's DNS cache */ - data->dns.hostcache = NULL; - data->dns.hostcachetype = HCACHE_NONE; - } + /* destroy the timeout list that is held in the easy handle */ + if(data->state.timeoutlist) { + Curl_llist_destroy(data->state.timeoutlist, NULL); + data->state.timeoutlist = NULL; + } - if(data->easy_conn) { + if(data->dns.hostcachetype == HCACHE_MULTI) { + /* stop using the multi handle's DNS cache */ + data->dns.hostcache = NULL; + data->dns.hostcachetype = HCACHE_NONE; + } - /* we must call Curl_done() here (if we still "own it") so that we don't - leave a half-baked one around */ - if(easy_owns_conn) { + if(data->easy_conn) { - /* Curl_done() clears the conn->data field to lose the association - between the easy handle and the connection + /* we must call Curl_done() here (if we still "own it") so that we don't + leave a half-baked one around */ + if(easy_owns_conn) { - Note that this ignores the return code simply because there's - nothing really useful to do with it anyway! */ - (void)Curl_done(&data->easy_conn, data->result, premature); - } - else - /* Clear connection pipelines, if Curl_done above was not called */ - Curl_getoff_all_pipelines(data, data->easy_conn); + /* Curl_done() clears the conn->data field to lose the association + between the easy handle and the connection + + Note that this ignores the return code simply because there's + nothing really useful to do with it anyway! */ + (void)Curl_done(&data->easy_conn, data->result, premature); } + else + /* Clear connection pipelines, if Curl_done above was not called */ + Curl_getoff_all_pipelines(data, data->easy_conn); + } - Curl_wildcard_dtor(&data->wildcard); + Curl_wildcard_dtor(&data->wildcard); - /* as this was using a shared connection cache we clear the pointer - to that since we're not part of that multi handle anymore */ - data->state.conn_cache = NULL; + /* as this was using a shared connection cache we clear the pointer to that + since we're not part of that multi handle anymore */ + data->state.conn_cache = NULL; - /* change state without using multistate(), only to make singlesocket() do - what we want */ - data->mstate = CURLM_STATE_COMPLETED; - singlesocket(multi, easy); /* to let the application know what sockets - that vanish with this handle */ + /* change state without using multistate(), only to make singlesocket() do + what we want */ + data->mstate = CURLM_STATE_COMPLETED; + singlesocket(multi, easy); /* to let the application know what sockets that + vanish with this handle */ - /* Remove the association between the connection and the handle */ - if(data->easy_conn) { - data->easy_conn->data = NULL; - data->easy_conn = NULL; - } + /* Remove the association between the connection and the handle */ + if(data->easy_conn) { + data->easy_conn->data = NULL; + data->easy_conn = NULL; + } - data->multi = NULL; /* clear the association to this multi handle */ + data->multi = NULL; /* clear the association to this multi handle */ - { - /* make sure there's no pending message in the queue sent from this easy - handle */ - struct curl_llist_element *e; + /* make sure there's no pending message in the queue sent from this easy + handle */ - for(e = multi->msglist->head; e; e = e->next) { - struct Curl_message *msg = e->ptr; + for(e = multi->msglist->head; e; e = e->next) { + struct Curl_message *msg = e->ptr; - if(msg->extmsg.easy_handle == easy) { - Curl_llist_remove(multi->msglist, e, NULL); - /* there can only be one from this specific handle */ - break; - } - } + if(msg->extmsg.easy_handle == easy) { + Curl_llist_remove(multi->msglist, e, NULL); + /* there can only be one from this specific handle */ + break; } + } - /* make the previous node point to our next */ - if(data->prev) - data->prev->next = data->next; - else - multi->easyp = data->next; /* point to first node */ - - /* make our next point to our previous node */ - if(data->next) - data->next->prev = data->prev; - else - multi->easylp = data->prev; /* point to last node */ + /* make the previous node point to our next */ + if(data->prev) + data->prev->next = data->next; + else + multi->easyp = data->next; /* point to first node */ - /* NOTE NOTE NOTE - We do not touch the easy handle here! */ + /* make our next point to our previous node */ + if(data->next) + data->next->prev = data->prev; + else + multi->easylp = data->prev; /* point to last node */ - multi->num_easy--; /* one less to care about now */ + /* NOTE NOTE NOTE + We do not touch the easy handle here! */ + multi->num_easy--; /* one less to care about now */ - update_timer(multi); - return CURLM_OK; - } - else - return CURLM_BAD_EASY_HANDLE; /* twasn't found */ + update_timer(multi); + return CURLM_OK; } -bool Curl_multi_pipeline_enabled(const struct Curl_multi *multi) +/* Return TRUE if the application asked for a certain set of pipelining */ +bool Curl_pipeline_wanted(const struct Curl_multi *multi, int bits) { - return (multi && multi->pipelining_enabled) ? TRUE : FALSE; + return (multi && (multi->pipelining & bits)) ? TRUE : FALSE; } void Curl_multi_handlePipeBreak(struct SessionHandle *data) @@ -650,14 +636,24 @@ static int waitconnect_getsock(struct connectdata *conn, } } + return rc; +} + +static int waitproxyconnect_getsock(struct connectdata *conn, + curl_socket_t *sock, + int numsocks) +{ + if(!numsocks) + return GETSOCK_BLANK; + + sock[0] = conn->sock[FIRSTSOCKET]; + /* when we've sent a CONNECT to a proxy, we should rather wait for the socket to become readable to be able to get the response headers */ - if(conn->tunnel_state[FIRSTSOCKET] == TUNNEL_CONNECT) { - sock[0] = conn->sock[FIRSTSOCKET]; - rc = GETSOCK_READSOCK(0); - } + if(conn->tunnel_state[FIRSTSOCKET] == TUNNEL_CONNECT) + return GETSOCK_READSOCK(0); - return rc; + return GETSOCK_WRITESOCK(0); } static int domore_getsock(struct connectdata *conn, @@ -710,6 +706,7 @@ static int multi_getsock(struct SessionHandle *data, return Curl_resolver_getsock(data->easy_conn, socks, numsocks); case CURLM_STATE_PROTOCONNECT: + case CURLM_STATE_SENDPROTOCONNECT: return Curl_protocol_getsock(data->easy_conn, socks, numsocks); case CURLM_STATE_DO: @@ -717,6 +714,8 @@ static int multi_getsock(struct SessionHandle *data, return Curl_doing_getsock(data->easy_conn, socks, numsocks); case CURLM_STATE_WAITPROXYCONNECT: + return waitproxyconnect_getsock(data->easy_conn, socks, numsocks); + case CURLM_STATE_WAITCONNECT: return waitconnect_getsock(data->easy_conn, socks, numsocks); @@ -917,12 +916,62 @@ CURLMcode curl_multi_wait(CURLM *multi_handle, else i = 0; - Curl_safefree(ufds); + free(ufds); if(ret) *ret = i; return CURLM_OK; } +/* + * Curl_multi_connchanged() is called to tell that there is a connection in + * this multi handle that has changed state (pipelining become possible, the + * number of allowed streams changed or similar), and a subsequent use of this + * multi handle should move CONNECT_PEND handles back to CONNECT to have them + * retry. + */ +void Curl_multi_connchanged(struct Curl_multi *multi) +{ + multi->recheckstate = TRUE; +} + +/* + * multi_ischanged() is called + * + * Returns TRUE/FALSE whether the state is changed to trigger a CONNECT_PEND + * => CONNECT action. + * + * Set 'clear' to TRUE to have it also clear the state variable. + */ +static bool multi_ischanged(struct Curl_multi *multi, bool clear) +{ + bool retval = multi->recheckstate; + if(clear) + multi->recheckstate = FALSE; + return retval; +} + +CURLMcode Curl_multi_add_perform(struct Curl_multi *multi, + struct SessionHandle *data, + struct connectdata *conn) +{ + CURLMcode rc; + + rc = curl_multi_add_handle(multi, data); + if(!rc) { + struct SingleRequest *k = &data->req; + + /* pass in NULL for 'conn' here since we don't want to init the + connection, only this transfer */ + Curl_init_do(data, NULL); + + /* take this handle to the perform state right away */ + multistate(data, CURLM_STATE_PERFORM); + data->easy_conn = conn; + k->keepon |= KEEP_RECV; /* setup to receive! */ + } + return rc; +} + static CURLMcode multi_runsingle(struct Curl_multi *multi, struct timeval now, struct SessionHandle *data) @@ -933,7 +982,8 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, bool protocol_connect = FALSE; bool dophase_done = FALSE; bool done = FALSE; - CURLMcode result = CURLM_OK; + CURLMcode rc; + CURLcode result = CURLE_OK; struct SingleRequest *k; long timeout_ms; int control; @@ -942,26 +992,25 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, return CURLM_BAD_EASY_HANDLE; do { - /* this is a single-iteration do-while loop just to allow a - break to skip to the end of it */ bool disconnect_conn = FALSE; + rc = CURLM_OK; /* Handle the case when the pipe breaks, i.e., the connection we're using gets cleaned up and we're left with nothing. */ if(data->state.pipe_broke) { - infof(data, "Pipe broke: handle 0x%p, url = %s\n", + infof(data, "Pipe broke: handle %p, url = %s\n", (void *)data, data->state.path); if(data->mstate < CURLM_STATE_COMPLETED) { /* Head back to the CONNECT state */ multistate(data, CURLM_STATE_CONNECT); - result = CURLM_CALL_MULTI_PERFORM; - data->result = CURLE_OK; + rc = CURLM_CALL_MULTI_PERFORM; + result = CURLE_OK; } data->state.pipe_broke = FALSE; data->easy_conn = NULL; - break; + continue; } if(!data->easy_conn && @@ -974,6 +1023,11 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, return CURLM_INTERNAL_ERROR; } + if(multi_ischanged(multi, TRUE)) { + DEBUGF(infof(data, "multi changed, check CONNECT_PEND queue!\n")); + Curl_multi_process_pending_handles(multi); + } + if(data->easy_conn && data->mstate > CURLM_STATE_CONNECT && data->mstate < CURLM_STATE_COMPLETED) /* Make sure we set the connection's current owner */ @@ -1014,26 +1068,28 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, } } - /* Force the connection closed because the server could continue to - send us stuff at any time. (The disconnect_conn logic used below - doesn't work at this point). */ - connclose(data->easy_conn, "Disconnected with pending data"); - data->result = CURLE_OPERATION_TIMEDOUT; - multistate(data, CURLM_STATE_COMPLETED); - break; + /* Force connection closed if the connection has indeed been used */ + if(data->mstate > CURLM_STATE_DO) { + connclose(data->easy_conn, "Disconnected with pending data"); + disconnect_conn = TRUE; + } + result = CURLE_OPERATION_TIMEDOUT; + (void)Curl_done(&data->easy_conn, result, TRUE); + /* Skip the statemachine and go directly to error handling section. */ + goto statemachine_end; } } switch(data->mstate) { case CURLM_STATE_INIT: /* init this transfer. */ - data->result=Curl_pretransfer(data); + result=Curl_pretransfer(data); - if(CURLE_OK == data->result) { + if(!result) { /* after init, go CONNECT */ multistate(data, CURLM_STATE_CONNECT); Curl_pgrsTime(data, TIMER_STARTOP); - result = CURLM_CALL_MULTI_PERFORM; + rc = CURLM_CALL_MULTI_PERFORM; } break; @@ -1045,25 +1101,25 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, case CURLM_STATE_CONNECT: /* Connect. We want to get a connection identifier filled in. */ Curl_pgrsTime(data, TIMER_STARTSINGLE); - data->result = Curl_connect(data, &data->easy_conn, - &async, &protocol_connect); - if(CURLE_NO_CONNECTION_AVAILABLE == data->result) { + result = Curl_connect(data, &data->easy_conn, + &async, &protocol_connect); + if(CURLE_NO_CONNECTION_AVAILABLE == result) { /* There was no connection available. We will go to the pending state and wait for an available connection. */ multistate(data, CURLM_STATE_CONNECT_PEND); /* add this handle to the list of connect-pending handles */ if(!Curl_llist_insert_next(multi->pending, multi->pending->tail, data)) - data->result = CURLE_OUT_OF_MEMORY; + result = CURLE_OUT_OF_MEMORY; else - data->result = CURLE_OK; + result = CURLE_OK; break; } - if(CURLE_OK == data->result) { + if(!result) { /* Add this handle to the send or pend pipeline */ - data->result = Curl_add_handle_to_pipeline(data, data->easy_conn); - if(CURLE_OK != data->result) + result = Curl_add_handle_to_pipeline(data, data->easy_conn); + if(result) disconnect_conn = TRUE; else { if(async) @@ -1073,10 +1129,10 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, /* after the connect has been sent off, go WAITCONNECT unless the protocol connect is already done and we can go directly to WAITDO or DO! */ - result = CURLM_CALL_MULTI_PERFORM; + rc = CURLM_CALL_MULTI_PERFORM; if(protocol_connect) - multistate(data, multi->pipelining_enabled? + multistate(data, Curl_pipeline_wanted(multi, CURLPIPE_HTTP1)? CURLM_STATE_WAITDO:CURLM_STATE_DO); else { #ifndef CURL_DISABLE_HTTP @@ -1096,31 +1152,21 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, { struct Curl_dns_entry *dns = NULL; struct connectdata *conn = data->easy_conn; - int stale; /* check if we have the name resolved by now */ - if(data->share) - Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE); - - dns = Curl_fetch_addr(conn, conn->host.name, (int)conn->port, &stale); + dns = Curl_fetch_addr(conn, conn->host.name, (int)conn->port); if(dns) { - dns->inuse++; /* we use it! */ #ifdef CURLRES_ASYNCH conn->async.dns = dns; conn->async.done = TRUE; #endif - data->result = CURLRESOLV_RESOLVED; + result = CURLE_OK; infof(data, "Hostname was found in DNS cache\n"); } - if(stale) - infof(data, "Hostname in DNS cache was stale, zapped\n"); - - if(data->share) - Curl_share_unlock(data, CURL_LOCK_DATA_DNS); if(!dns) - data->result = Curl_resolver_is_resolved(data->easy_conn, &dns); + result = Curl_resolver_is_resolved(data->easy_conn, &dns); /* Update sockets here, because the socket(s) may have been closed and the application thus needs to be told, even if it @@ -1133,18 +1179,17 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, if(dns) { /* Perform the next step in the connection phase, and then move on to the WAITCONNECT state */ - data->result = Curl_async_resolved(data->easy_conn, - &protocol_connect); + result = Curl_async_resolved(data->easy_conn, &protocol_connect); - if(CURLE_OK != data->result) + if(result) /* if Curl_async_resolved() returns failure, the connection struct is already freed and gone */ data->easy_conn = NULL; /* no more connection */ else { /* call again please so that we get the next socket setup */ - result = CURLM_CALL_MULTI_PERFORM; + rc = CURLM_CALL_MULTI_PERFORM; if(protocol_connect) - multistate(data, multi->pipelining_enabled? + multistate(data, Curl_pipeline_wanted(multi, CURLPIPE_HTTP1)? CURLM_STATE_WAITDO:CURLM_STATE_DO); else { #ifndef CURL_DISABLE_HTTP @@ -1157,7 +1202,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, } } - if(CURLE_OK != data->result) { + if(result) { /* failure detected */ disconnect_conn = TRUE; break; @@ -1168,109 +1213,82 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, #ifndef CURL_DISABLE_HTTP case CURLM_STATE_WAITPROXYCONNECT: /* this is HTTP-specific, but sending CONNECT to a proxy is HTTP... */ - data->result = Curl_http_connect(data->easy_conn, &protocol_connect); + result = Curl_http_connect(data->easy_conn, &protocol_connect); + rc = CURLM_CALL_MULTI_PERFORM; if(data->easy_conn->bits.proxy_connect_closed) { /* connect back to proxy again */ - data->result = CURLE_OK; - result = CURLM_CALL_MULTI_PERFORM; + result = CURLE_OK; + Curl_done(&data->easy_conn, CURLE_OK, FALSE); multistate(data, CURLM_STATE_CONNECT); } - else if(CURLE_OK == data->result) { + else if(!result) { if(data->easy_conn->tunnel_state[FIRSTSOCKET] == TUNNEL_COMPLETE) - multistate(data, CURLM_STATE_WAITCONNECT); + /* initiate protocol connect phase */ + multistate(data, CURLM_STATE_SENDPROTOCONNECT); } break; #endif case CURLM_STATE_WAITCONNECT: - /* awaiting a completion of an asynch connect */ - data->result = Curl_is_connected(data->easy_conn, - FIRSTSOCKET, - &connected); - if(connected) { - - if(!data->result) - /* if everything is still fine we do the protocol-specific connect - setup */ - data->result = Curl_protocol_connect(data->easy_conn, - &protocol_connect); - } - - if(data->easy_conn->bits.proxy_connect_closed) { - /* connect back to proxy again since it was closed in a proxy CONNECT - setup */ - data->result = CURLE_OK; - result = CURLM_CALL_MULTI_PERFORM; - multistate(data, CURLM_STATE_CONNECT); - break; + /* awaiting a completion of an asynch TCP connect */ + result = Curl_is_connected(data->easy_conn, FIRSTSOCKET, &connected); + if(connected && !result) { + rc = CURLM_CALL_MULTI_PERFORM; + multistate(data, data->easy_conn->bits.tunnel_proxy? + CURLM_STATE_WAITPROXYCONNECT: + CURLM_STATE_SENDPROTOCONNECT); } - else if(CURLE_OK != data->result) { + else if(result) { /* failure detected */ /* Just break, the cleaning up is handled all in one place */ disconnect_conn = TRUE; break; } + break; - if(connected) { - if(!protocol_connect) { - /* We have a TCP connection, but 'protocol_connect' may be false - and then we continue to 'STATE_PROTOCONNECT'. If protocol - connect is TRUE, we move on to STATE_DO. - BUT if we are using a proxy we must change to WAITPROXYCONNECT - */ -#ifndef CURL_DISABLE_HTTP - if(data->easy_conn->tunnel_state[FIRSTSOCKET] == TUNNEL_CONNECT) - multistate(data, CURLM_STATE_WAITPROXYCONNECT); - else -#endif - multistate(data, CURLM_STATE_PROTOCONNECT); - - } - else - /* after the connect has completed, go WAITDO or DO */ - multistate(data, multi->pipelining_enabled? - CURLM_STATE_WAITDO:CURLM_STATE_DO); - - result = CURLM_CALL_MULTI_PERFORM; + case CURLM_STATE_SENDPROTOCONNECT: + result = Curl_protocol_connect(data->easy_conn, &protocol_connect); + if(!protocol_connect) + /* switch to waiting state */ + multistate(data, CURLM_STATE_PROTOCONNECT); + else if(!result) { + /* protocol connect has completed, go WAITDO or DO */ + multistate(data, Curl_pipeline_wanted(multi, CURLPIPE_HTTP1)? + CURLM_STATE_WAITDO:CURLM_STATE_DO); + rc = CURLM_CALL_MULTI_PERFORM; + } + else if(result) { + /* failure detected */ + Curl_posttransfer(data); + Curl_done(&data->easy_conn, result, TRUE); + disconnect_conn = TRUE; } break; case CURLM_STATE_PROTOCONNECT: /* protocol-specific connect phase */ - data->result = Curl_protocol_connecting(data->easy_conn, - &protocol_connect); - if((data->result == CURLE_OK) && protocol_connect) { + result = Curl_protocol_connecting(data->easy_conn, &protocol_connect); + if(!result && protocol_connect) { /* after the connect has completed, go WAITDO or DO */ - multistate(data, multi->pipelining_enabled? + multistate(data, Curl_pipeline_wanted(multi, CURLPIPE_HTTP1)? CURLM_STATE_WAITDO:CURLM_STATE_DO); - result = CURLM_CALL_MULTI_PERFORM; + rc = CURLM_CALL_MULTI_PERFORM; } - else if(data->result) { + else if(result) { /* failure detected */ Curl_posttransfer(data); - Curl_done(&data->easy_conn, data->result, TRUE); + Curl_done(&data->easy_conn, result, TRUE); disconnect_conn = TRUE; } break; case CURLM_STATE_WAITDO: /* Wait for our turn to DO when we're pipelining requests */ -#ifdef DEBUGBUILD - infof(data, "WAITDO: Conn %ld send pipe %zu inuse %s athead %s\n", - data->easy_conn->connection_id, - data->easy_conn->send_pipe->size, - data->easy_conn->writechannel_inuse?"TRUE":"FALSE", - isHandleAtHead(data, - data->easy_conn->send_pipe)?"TRUE":"FALSE"); -#endif - if(!data->easy_conn->writechannel_inuse && - isHandleAtHead(data, - data->easy_conn->send_pipe)) { - /* Grab the channel */ - data->easy_conn->writechannel_inuse = TRUE; + if(Curl_pipeline_checkget_write(data, data->easy_conn)) { + /* Grabbed the channel */ multistate(data, CURLM_STATE_DO); - result = CURLM_CALL_MULTI_PERFORM; + rc = CURLM_CALL_MULTI_PERFORM; } break; @@ -1279,16 +1297,16 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, /* keep connection open for application to use the socket */ connkeep(data->easy_conn, "CONNECT_ONLY"); multistate(data, CURLM_STATE_DONE); - data->result = CURLE_OK; - result = CURLM_CALL_MULTI_PERFORM; + result = CURLE_OK; + rc = CURLM_CALL_MULTI_PERFORM; } else { /* Perform the protocol's DO action */ - data->result = Curl_do(&data->easy_conn, &dophase_done); + result = Curl_do(&data->easy_conn, &dophase_done); /* When Curl_do() returns failure, data->easy_conn might be NULL! */ - if(CURLE_OK == data->result) { + if(!result) { if(!dophase_done) { /* some steps needed for wildcard matching */ if(data->set.wildcardmatch) { @@ -1297,14 +1315,14 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, /* skip some states if it is important */ Curl_done(&data->easy_conn, CURLE_OK, FALSE); multistate(data, CURLM_STATE_DONE); - result = CURLM_CALL_MULTI_PERFORM; + rc = CURLM_CALL_MULTI_PERFORM; break; } } /* DO was not completed in one function call, we must continue DOING... */ multistate(data, CURLM_STATE_DOING); - result = CURLM_OK; + rc = CURLM_OK; } /* after DO, go DO_DONE... or DO_MORE */ @@ -1312,15 +1330,15 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, /* we're supposed to do more, but we need to sit down, relax and wait a little while first */ multistate(data, CURLM_STATE_DO_MORE); - result = CURLM_OK; + rc = CURLM_OK; } else { /* we're done with the DO, now DO_DONE */ multistate(data, CURLM_STATE_DO_DONE); - result = CURLM_CALL_MULTI_PERFORM; + rc = CURLM_CALL_MULTI_PERFORM; } } - else if((CURLE_SEND_ERROR == data->result) && + else if((CURLE_SEND_ERROR == result) && data->easy_conn->bits.reuse) { /* * In this situation, a connection that we were trying to use @@ -1335,48 +1353,49 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, drc = Curl_retry_request(data->easy_conn, &newurl); if(drc) { /* a failure here pretty much implies an out of memory */ - data->result = drc; + result = drc; disconnect_conn = TRUE; } else retry = (newurl)?TRUE:FALSE; Curl_posttransfer(data); - drc = Curl_done(&data->easy_conn, data->result, FALSE); + drc = Curl_done(&data->easy_conn, result, FALSE); /* When set to retry the connection, we must to go back to * the CONNECT state */ if(retry) { - if((drc == CURLE_OK) || (drc == CURLE_SEND_ERROR)) { + if(!drc || (drc == CURLE_SEND_ERROR)) { follow = FOLLOW_RETRY; drc = Curl_follow(data, newurl, follow); - if(drc == CURLE_OK) { + if(!drc) { multistate(data, CURLM_STATE_CONNECT); - result = CURLM_CALL_MULTI_PERFORM; - data->result = CURLE_OK; + rc = CURLM_CALL_MULTI_PERFORM; + result = CURLE_OK; } else { /* Follow failed */ - data->result = drc; + result = drc; free(newurl); } } else { /* done didn't return OK or SEND_ERROR */ - data->result = drc; + result = drc; free(newurl); } } else { /* Have error handler disconnect conn if we can't retry */ disconnect_conn = TRUE; + free(newurl); } } else { /* failure detected */ Curl_posttransfer(data); if(data->easy_conn) - Curl_done(&data->easy_conn, data->result, FALSE); + Curl_done(&data->easy_conn, result, FALSE); disconnect_conn = TRUE; } } @@ -1384,21 +1403,21 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, case CURLM_STATE_DOING: /* we continue DOING until the DO phase is complete */ - data->result = Curl_protocol_doing(data->easy_conn, - &dophase_done); - if(CURLE_OK == data->result) { + result = Curl_protocol_doing(data->easy_conn, + &dophase_done); + if(!result) { if(dophase_done) { /* after DO, go DO_DONE or DO_MORE */ multistate(data, data->easy_conn->bits.do_more? CURLM_STATE_DO_MORE: CURLM_STATE_DO_DONE); - result = CURLM_CALL_MULTI_PERFORM; + rc = CURLM_CALL_MULTI_PERFORM; } /* dophase_done */ } else { /* failure detected */ Curl_posttransfer(data); - Curl_done(&data->easy_conn, data->result, FALSE); + Curl_done(&data->easy_conn, result, FALSE); disconnect_conn = TRUE; } break; @@ -1407,27 +1426,27 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, /* * When we are connected, DO MORE and then go DO_DONE */ - data->result = Curl_do_more(data->easy_conn, &control); + result = Curl_do_more(data->easy_conn, &control); /* No need to remove this handle from the send pipeline here since that is done in Curl_done() */ - if(CURLE_OK == data->result) { + if(!result) { if(control) { /* if positive, advance to DO_DONE if negative, go back to DOING */ multistate(data, control==1? CURLM_STATE_DO_DONE: CURLM_STATE_DOING); - result = CURLM_CALL_MULTI_PERFORM; + rc = CURLM_CALL_MULTI_PERFORM; } else /* stay in DO_MORE */ - result = CURLM_OK; + rc = CURLM_OK; } else { /* failure detected */ Curl_posttransfer(data); - Curl_done(&data->easy_conn, data->result, FALSE); + Curl_done(&data->easy_conn, result, FALSE); disconnect_conn = TRUE; } break; @@ -1445,37 +1464,24 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, multistate(data, CURLM_STATE_WAITPERFORM); else multistate(data, CURLM_STATE_DONE); - result = CURLM_CALL_MULTI_PERFORM; + rc = CURLM_CALL_MULTI_PERFORM; break; case CURLM_STATE_WAITPERFORM: /* Wait for our turn to PERFORM */ - if(!data->easy_conn->readchannel_inuse && - isHandleAtHead(data, - data->easy_conn->recv_pipe)) { - /* Grab the channel */ - data->easy_conn->readchannel_inuse = TRUE; + if(Curl_pipeline_checkget_read(data, data->easy_conn)) { + /* Grabbed the channel */ multistate(data, CURLM_STATE_PERFORM); - result = CURLM_CALL_MULTI_PERFORM; + rc = CURLM_CALL_MULTI_PERFORM; } -#ifdef DEBUGBUILD - else { - infof(data, "WAITPERFORM: Conn %ld recv pipe %zu inuse %s athead %s\n", - data->easy_conn->connection_id, - data->easy_conn->recv_pipe->size, - data->easy_conn->readchannel_inuse?"TRUE":"FALSE", - isHandleAtHead(data, - data->easy_conn->recv_pipe)?"TRUE":"FALSE"); - } -#endif break; case CURLM_STATE_TOOFAST: /* limit-rate exceeded in either direction */ /* if both rates are within spec, resume transfer */ if(Curl_pgrsUpdate(data->easy_conn)) - data->result = CURLE_ABORTED_BY_CALLBACK; + result = CURLE_ABORTED_BY_CALLBACK; else - data->result = Curl_speedcheck(data, now); + result = Curl_speedcheck(data, now); if(( (data->set.max_send_speed == 0) || (data->progress.ulspeed < data->set.max_send_speed )) && @@ -1485,7 +1491,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, break; case CURLM_STATE_PERFORM: - { + { char *newurl = NULL; bool retry = FALSE; @@ -1512,7 +1518,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, multistate(data, CURLM_STATE_TOOFAST); - /* Calculate download rate-limitation timeout. */ + /* Calculate download rate-limitation timeout. */ buffersize = (int)(data->set.buffer_size ? data->set.buffer_size : BUFSIZE); timeout_ms = Curl_sleep_time(data->set.max_recv_speed, @@ -1522,21 +1528,19 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, } /* read/write data if it is ready to do so */ - data->result = Curl_readwrite(data->easy_conn, &done); + result = Curl_readwrite(data->easy_conn, data, &done); k = &data->req; - if(!(k->keepon & KEEP_RECV)) { + if(!(k->keepon & KEEP_RECV)) /* We're done receiving */ - data->easy_conn->readchannel_inuse = FALSE; - } + Curl_pipeline_leave_read(data->easy_conn); - if(!(k->keepon & KEEP_SEND)) { + if(!(k->keepon & KEEP_SEND)) /* We're done sending */ - data->easy_conn->writechannel_inuse = FALSE; - } + Curl_pipeline_leave_write(data->easy_conn); - if(done || (data->result == CURLE_RECV_ERROR)) { + if(done || (result == CURLE_RECV_ERROR)) { /* If CURLE_RECV_ERROR happens early enough, we assume it was a race * condition and the server closed the re-used connection exactly when * we wanted to use it, so figure out if that is indeed the case. @@ -1548,12 +1552,12 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, if(retry) { /* if we are to retry, set the result to OK and consider the request as done */ - data->result = CURLE_OK; + result = CURLE_OK; done = TRUE; } } - if(data->result) { + if(result) { /* * The transfer phase returned error, we mark the connection to get * closed to prevent being re-used. This is because we can't possibly @@ -1566,7 +1570,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, connclose(data->easy_conn, "Transfer returned error"); Curl_posttransfer(data); - Curl_done(&data->easy_conn, data->result, FALSE); + Curl_done(&data->easy_conn, result, FALSE); } else if(done) { followtype follow=FOLLOW_NONE; @@ -1590,18 +1594,19 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, if(!retry) { /* if the URL is a follow-location and not just a retried request then figure out the URL here */ + free(newurl); newurl = data->req.newurl; data->req.newurl = NULL; follow = FOLLOW_REDIR; } else follow = FOLLOW_RETRY; - data->result = Curl_done(&data->easy_conn, CURLE_OK, FALSE); - if(CURLE_OK == data->result) { - data->result = Curl_follow(data, newurl, follow); - if(CURLE_OK == data->result) { + result = Curl_done(&data->easy_conn, CURLE_OK, FALSE); + if(!result) { + result = Curl_follow(data, newurl, follow); + if(!result) { multistate(data, CURLM_STATE_CONNECT); - result = CURLM_CALL_MULTI_PERFORM; + rc = CURLM_CALL_MULTI_PERFORM; newurl = NULL; /* handed over the memory ownership to Curl_follow(), make sure we don't free() it here */ @@ -1614,30 +1619,28 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, /* but first check to see if we got a location info even though we're not following redirects */ if(data->req.location) { - if(newurl) - free(newurl); + free(newurl); newurl = data->req.location; data->req.location = NULL; - data->result = Curl_follow(data, newurl, FOLLOW_FAKE); - if(CURLE_OK == data->result) + result = Curl_follow(data, newurl, FOLLOW_FAKE); + if(!result) newurl = NULL; /* allocation was handed over Curl_follow() */ else disconnect_conn = TRUE; } multistate(data, CURLM_STATE_DONE); - result = CURLM_CALL_MULTI_PERFORM; + rc = CURLM_CALL_MULTI_PERFORM; } } - if(newurl) - free(newurl); + free(newurl); break; - } + } case CURLM_STATE_DONE: /* this state is highly transient, so run another loop after this */ - result = CURLM_CALL_MULTI_PERFORM; + rc = CURLM_CALL_MULTI_PERFORM; if(data->easy_conn) { CURLcode res; @@ -1648,11 +1651,11 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, Curl_multi_process_pending_handles(multi); /* post-transfer command */ - res = Curl_done(&data->easy_conn, data->result, FALSE); + res = Curl_done(&data->easy_conn, result, FALSE); /* allow a previously set error code take precedence */ - if(!data->result) - data->result = res; + if(!result) + result = res; /* * If there are other handles on the pipeline, Curl_done won't set @@ -1692,14 +1695,16 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, break; case CURLM_STATE_MSGSENT: + data->result = result; return CURLM_OK; /* do nothing */ default: return CURLM_INTERNAL_ERROR; } + statemachine_end: if(data->mstate < CURLM_STATE_COMPLETED) { - if(CURLE_OK != data->result) { + if(result) { /* * If an error was returned, and we aren't in completed state now, * then we go to completed and consider this transfer aborted. @@ -1710,20 +1715,21 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, data->state.pipe_broke = FALSE; + /* Check if we can move pending requests to send pipe */ + Curl_multi_process_pending_handles(multi); + if(data->easy_conn) { /* if this has a connection, unsubscribe from the pipelines */ - data->easy_conn->writechannel_inuse = FALSE; - data->easy_conn->readchannel_inuse = FALSE; - Curl_removeHandleFromPipeline(data, - data->easy_conn->send_pipe); - Curl_removeHandleFromPipeline(data, - data->easy_conn->recv_pipe); - /* Check if we can move pending requests to send pipe */ - Curl_multi_process_pending_handles(multi); + Curl_pipeline_leave_write(data->easy_conn); + Curl_pipeline_leave_read(data->easy_conn); + Curl_removeHandleFromPipeline(data, data->easy_conn->send_pipe); + Curl_removeHandleFromPipeline(data, data->easy_conn->recv_pipe); if(disconnect_conn) { + /* Don't attempt to send data over a connection that timed out */ + bool dead_connection = result == CURLE_OPERATION_TIMEDOUT; /* disconnect properly */ - Curl_disconnect(data->easy_conn, /* dead_connection */ FALSE); + Curl_disconnect(data->easy_conn, dead_connection); /* This is where we make sure that the easy_conn pointer is reset. We don't have to do this in every case block above where a @@ -1742,31 +1748,34 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, else if(data->easy_conn && Curl_pgrsUpdate(data->easy_conn)) { /* aborted due to progress callback return code must close the connection */ - data->result = CURLE_ABORTED_BY_CALLBACK; + result = CURLE_ABORTED_BY_CALLBACK; connclose(data->easy_conn, "Aborted by callback"); /* if not yet in DONE state, go there, otherwise COMPLETED */ multistate(data, (data->mstate < CURLM_STATE_DONE)? CURLM_STATE_DONE: CURLM_STATE_COMPLETED); - result = CURLM_CALL_MULTI_PERFORM; + rc = CURLM_CALL_MULTI_PERFORM; } } - } WHILE_FALSE; /* just to break out from! */ - if(CURLM_STATE_COMPLETED == data->mstate) { - /* now fill in the Curl_message with this info */ - msg = &data->msg; + if(CURLM_STATE_COMPLETED == data->mstate) { + /* now fill in the Curl_message with this info */ + msg = &data->msg; - msg->extmsg.msg = CURLMSG_DONE; - msg->extmsg.easy_handle = data; - msg->extmsg.data.result = data->result; + msg->extmsg.msg = CURLMSG_DONE; + msg->extmsg.easy_handle = data; + msg->extmsg.data.result = result; - result = multi_addmsg(multi, msg); + rc = multi_addmsg(multi, msg); - multistate(data, CURLM_STATE_MSGSENT); - } + multistate(data, CURLM_STATE_MSGSENT); + } + } while((rc == CURLM_CALL_MULTI_PERFORM) || multi_ischanged(multi, FALSE)); - return result; + data->result = result; + + + return rc; } @@ -1796,9 +1805,7 @@ CURLMcode curl_multi_perform(CURLM *multi_handle, int *running_handles) } sigpipe_ignore(data, &pipe_st); - do - result = multi_runsingle(multi, now, data); - while(CURLM_CALL_MULTI_PERFORM == result); + result = multi_runsingle(multi, now, data); sigpipe_restore(&pipe_st); if(data->set.wildcardmatch) { @@ -1843,7 +1850,7 @@ static void close_all_connections(struct Curl_multi *multi) { struct connectdata *conn; - conn = Curl_conncache_find_first_connection(multi->conn_cache); + conn = Curl_conncache_find_first_connection(&multi->conn_cache); while(conn) { SIGPIPE_VARIABLE(pipe_st); conn->data = multi->closure_handle; @@ -1853,7 +1860,7 @@ static void close_all_connections(struct Curl_multi *multi) (void)Curl_disconnect(conn, FALSE); sigpipe_restore(&pipe_st); - conn = Curl_conncache_find_first_connection(multi->conn_cache); + conn = Curl_conncache_find_first_connection(&multi->conn_cache); } } @@ -1876,15 +1883,15 @@ CURLMcode curl_multi_cleanup(CURLM *multi_handle) sigpipe_ignore(multi->closure_handle, &pipe_st); restore_pipe = TRUE; - multi->closure_handle->dns.hostcache = multi->hostcache; + multi->closure_handle->dns.hostcache = &multi->hostcache; Curl_hostcache_clean(multi->closure_handle, multi->closure_handle->dns.hostcache); Curl_close(multi->closure_handle); } - Curl_hash_destroy(multi->sockhash); - Curl_conncache_destroy(multi->conn_cache); + Curl_hash_destroy(&multi->sockhash); + Curl_conncache_destroy(&multi->conn_cache); Curl_llist_destroy(multi->msglist, NULL); Curl_llist_destroy(multi->pending, NULL); @@ -1906,7 +1913,7 @@ CURLMcode curl_multi_cleanup(CURLM *multi_handle) data = nextdata; } - Curl_hash_destroy(multi->hostcache); + Curl_hash_destroy(&multi->hostcache); /* Free the blacklists by setting them to NULL */ Curl_pipeline_set_site_blacklist(NULL, &multi->pipelining_site_bl); @@ -1995,7 +2002,7 @@ static void singlesocket(struct Curl_multi *multi, s = socks[i]; /* get it from the hash */ - entry = Curl_hash_pick(multi->sockhash, (char *)&s, sizeof(s)); + entry = Curl_hash_pick(&multi->sockhash, (char *)&s, sizeof(s)); if(curraction & GETSOCK_READSOCK(i)) action |= CURL_POLL_IN; @@ -2010,7 +2017,7 @@ static void singlesocket(struct Curl_multi *multi, } else { /* this is a socket we didn't have before, add it! */ - entry = sh_addentry(multi->sockhash, s, data); + entry = sh_addentry(&multi->sockhash, s, data); if(!entry) /* fatal */ return; @@ -2046,7 +2053,7 @@ static void singlesocket(struct Curl_multi *multi, /* this socket has been removed. Tell the app to remove it */ remove_sock_from_hash = TRUE; - entry = Curl_hash_pick(multi->sockhash, (char *)&s, sizeof(s)); + entry = Curl_hash_pick(&multi->sockhash, (char *)&s, sizeof(s)); if(entry) { /* check if the socket to be removed serves a connection which has other easy-s in a pipeline. In this case the socket should not be @@ -2061,7 +2068,7 @@ static void singlesocket(struct Curl_multi *multi, for the recv_pipe, or the first (in case this particular easy isn't already) */ if(entry->easy == data) { - if(isHandleAtHead(data, easy_conn->recv_pipe)) + if(Curl_recvpipe_head(data, easy_conn)) entry->easy = easy_conn->recv_pipe->head->next->ptr; else entry->easy = easy_conn->recv_pipe->head->ptr; @@ -2075,7 +2082,7 @@ static void singlesocket(struct Curl_multi *multi, for the send_pipe, or the first (in case this particular easy isn't already) */ if(entry->easy == data) { - if(isHandleAtHead(data, easy_conn->send_pipe)) + if(Curl_sendpipe_head(data, easy_conn)) entry->easy = easy_conn->send_pipe->head->next->ptr; else entry->easy = easy_conn->send_pipe->head->ptr; @@ -2101,7 +2108,7 @@ static void singlesocket(struct Curl_multi *multi, CURL_POLL_REMOVE, multi->socket_userp, entry->socketp); - sh_delentry(multi->sockhash, s); + sh_delentry(&multi->sockhash, s); } } @@ -2115,7 +2122,7 @@ static void singlesocket(struct Curl_multi *multi, * Curl_multi_closed() * * Used by the connect code to tell the multi_socket code that one of the - * sockets we were using have just been closed. This function will then + * sockets we were using is about to be closed. This function will then * remove it from the sockethash for this handle to make the multi_socket API * behave properly, especially for the case when libcurl will create another * socket again and it gets the same file descriptor number. @@ -2128,7 +2135,7 @@ void Curl_multi_closed(struct connectdata *conn, curl_socket_t s) /* this is set if this connection is part of a handle that is added to a multi handle, and only then this is necessary */ struct Curl_sh_entry *entry = - Curl_hash_pick(multi->sockhash, (char *)&s, sizeof(s)); + Curl_hash_pick(&multi->sockhash, (char *)&s, sizeof(s)); if(entry) { if(multi->socket_cb) @@ -2137,7 +2144,7 @@ void Curl_multi_closed(struct connectdata *conn, curl_socket_t s) entry->socketp); /* now remove it from the socket hash */ - sh_delentry(multi->sockhash, s); + sh_delentry(&multi->sockhash, s); } } } @@ -2230,7 +2237,7 @@ static CURLMcode multi_socket(struct Curl_multi *multi, else if(s != CURL_SOCKET_TIMEOUT) { struct Curl_sh_entry *entry = - Curl_hash_pick(multi->sockhash, (char *)&s, sizeof(s)); + Curl_hash_pick(&multi->sockhash, (char *)&s, sizeof(s)); if(!entry) /* Unmatched socket, we can't act on it but we ignore this fact. In @@ -2268,9 +2275,7 @@ static CURLMcode multi_socket(struct Curl_multi *multi, data->easy_conn->cselect_bits = ev_bitmask; sigpipe_ignore(data, &pipe_st); - do - result = multi_runsingle(multi, now, data); - while(CURLM_CALL_MULTI_PERFORM == result); + result = multi_runsingle(multi, now, data); sigpipe_restore(&pipe_st); if(data->easy_conn && @@ -2312,9 +2317,7 @@ static CURLMcode multi_socket(struct Curl_multi *multi, SIGPIPE_VARIABLE(pipe_st); sigpipe_ignore(data, &pipe_st); - do - result = multi_runsingle(multi, now, data); - while(CURLM_CALL_MULTI_PERFORM == result); + result = multi_runsingle(multi, now, data); sigpipe_restore(&pipe_st); if(CURLM_OK >= result) @@ -2358,8 +2361,14 @@ CURLMcode curl_multi_setopt(CURLM *multi_handle, case CURLMOPT_SOCKETDATA: multi->socket_userp = va_arg(param, void *); break; + case CURLMOPT_PUSHFUNCTION: + multi->push_cb = va_arg(param, curl_push_callback); + break; + case CURLMOPT_PUSHDATA: + multi->push_userp = va_arg(param, void *); + break; case CURLMOPT_PIPELINING: - multi->pipelining_enabled = (0 != va_arg(param, long)) ? TRUE : FALSE; + multi->pipelining = va_arg(param, long); break; case CURLMOPT_TIMERFUNCTION: multi->timer_cb = va_arg(param, curl_multi_timer_callback); @@ -2437,7 +2446,7 @@ CURLMcode curl_multi_socket_all(CURLM *multi_handle, int *running_handles) static CURLMcode multi_timeout(struct Curl_multi *multi, long *timeout_ms) { - static struct timeval tv_zero = {0,0}; + static struct timeval tv_zero = {0, 0}; if(multi->timetree) { /* we have a tree of expire times */ @@ -2495,7 +2504,7 @@ static int update_timer(struct Curl_multi *multi) return -1; } if(timeout_ms < 0) { - static const struct timeval none={0,0}; + static const struct timeval none={0, 0}; if(Curl_splaycomparekeys(none, multi->timer_lastcall)) { multi->timer_lastcall = none; /* there's no timeout now but there was one previously, tell the app to @@ -2517,22 +2526,6 @@ static int update_timer(struct Curl_multi *multi) return multi->timer_cb((CURLM*)multi, timeout_ms, multi->timer_userp); } -void Curl_multi_set_easy_connection(struct SessionHandle *handle, - struct connectdata *conn) -{ - handle->easy_conn = conn; -} - -static bool isHandleAtHead(struct SessionHandle *handle, - struct curl_llist *pipeline) -{ - struct curl_llist_element *curr = pipeline->head; - if(curr) - return (curr->ptr == handle) ? TRUE : FALSE; - - return FALSE; -} - /* * multi_freetimeout() * @@ -2698,24 +2691,24 @@ void Curl_expire(struct SessionHandle *data, long milli) */ void Curl_expire_latest(struct SessionHandle *data, long milli) { - struct timeval *exp = &data->state.expiretime; + struct timeval *expire = &data->state.expiretime; struct timeval set; set = Curl_tvnow(); - set.tv_sec += milli/1000; - set.tv_usec += (milli%1000)*1000; + set.tv_sec += milli / 1000; + set.tv_usec += (milli % 1000) * 1000; if(set.tv_usec >= 1000000) { set.tv_sec++; set.tv_usec -= 1000000; } - if(exp->tv_sec || exp->tv_usec) { + if(expire->tv_sec || expire->tv_usec) { /* This means that the struct is added as a node in the splay tree. Compare if the new time is earlier, and only remove-old/add-new if it is. */ - long diff = curlx_tvdiff(set, *exp); + long diff = curlx_tvdiff(set, *expire); if(diff > 0) /* the new expire time was later than the top time, so just skip this */ return; @@ -2732,7 +2725,8 @@ CURLMcode curl_multi_assign(CURLM *multi_handle, struct Curl_multi *multi = (struct Curl_multi *)multi_handle; if(s != CURL_SOCKET_BAD) - there = Curl_hash_pick(multi->sockhash, (char *)&s, sizeof(curl_socket_t)); + there = Curl_hash_pick(&multi->sockhash, (char *)&s, + sizeof(curl_socket_t)); if(!there) return CURLM_BAD_SOCKET; @@ -2752,11 +2746,6 @@ size_t Curl_multi_max_total_connections(struct Curl_multi *multi) return multi ? multi->max_total_connections : 0; } -size_t Curl_multi_max_pipeline_length(struct Curl_multi *multi) -{ - return multi ? multi->max_pipeline_length : 0; -} - curl_off_t Curl_multi_content_length_penalty_size(struct Curl_multi *multi) { return multi ? multi->content_length_penalty_size : 0; @@ -2816,7 +2805,7 @@ void Curl_multi_dump(const struct Curl_multi *multi_handle) for(i=0; i < data->numsocks; i++) { curl_socket_t s = data->sockets[i]; struct Curl_sh_entry *entry = - Curl_hash_pick(multi->sockhash, (char *)&s, sizeof(s)); + Curl_hash_pick(&multi->sockhash, (char *)&s, sizeof(s)); fprintf(stderr, "%d ", (int)s); if(!entry) { diff --git a/lib/multihandle.h b/lib/multihandle.h index 1a4b1d9..6c24f50 100644 --- a/lib/multihandle.h +++ b/lib/multihandle.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -22,6 +22,8 @@ * ***************************************************************************/ +#include "conncache.h" + struct Curl_message { /* the 'CURLMsg' is the part that is visible to the external user */ struct CURLMsg extmsg; @@ -35,22 +37,23 @@ typedef enum { CURLM_STATE_CONNECT_PEND, /* 1 - no connections, waiting for one */ CURLM_STATE_CONNECT, /* 2 - resolve/connect has been sent off */ CURLM_STATE_WAITRESOLVE, /* 3 - awaiting the resolve to finalize */ - CURLM_STATE_WAITCONNECT, /* 4 - awaiting the connect to finalize */ + CURLM_STATE_WAITCONNECT, /* 4 - awaiting the TCP connect to finalize */ CURLM_STATE_WAITPROXYCONNECT, /* 5 - awaiting proxy CONNECT to finalize */ - CURLM_STATE_PROTOCONNECT, /* 6 - completing the protocol-specific connect + CURLM_STATE_SENDPROTOCONNECT, /* 6 - initiate protocol connect procedure */ + CURLM_STATE_PROTOCONNECT, /* 7 - completing the protocol-specific connect phase */ - CURLM_STATE_WAITDO, /* 7 - wait for our turn to send the request */ - CURLM_STATE_DO, /* 8 - start send off the request (part 1) */ - CURLM_STATE_DOING, /* 9 - sending off the request (part 1) */ - CURLM_STATE_DO_MORE, /* 10 - send off the request (part 2) */ - CURLM_STATE_DO_DONE, /* 11 - done sending off request */ - CURLM_STATE_WAITPERFORM, /* 12 - wait for our turn to read the response */ - CURLM_STATE_PERFORM, /* 13 - transfer data */ - CURLM_STATE_TOOFAST, /* 14 - wait because limit-rate exceeded */ - CURLM_STATE_DONE, /* 15 - post data transfer operation */ - CURLM_STATE_COMPLETED, /* 16 - operation complete */ - CURLM_STATE_MSGSENT, /* 17 - the operation complete message is sent */ - CURLM_STATE_LAST /* 18 - not a true state, never use this */ + CURLM_STATE_WAITDO, /* 8 - wait for our turn to send the request */ + CURLM_STATE_DO, /* 9 - start send off the request (part 1) */ + CURLM_STATE_DOING, /* 10 - sending off the request (part 1) */ + CURLM_STATE_DO_MORE, /* 11 - send off the request (part 2) */ + CURLM_STATE_DO_DONE, /* 12 - done sending off request */ + CURLM_STATE_WAITPERFORM, /* 13 - wait for our turn to read the response */ + CURLM_STATE_PERFORM, /* 14 - transfer data */ + CURLM_STATE_TOOFAST, /* 15 - wait because limit-rate exceeded */ + CURLM_STATE_DONE, /* 16 - post data transfer operation */ + CURLM_STATE_COMPLETED, /* 17 - operation complete */ + CURLM_STATE_MSGSENT, /* 18 - the operation complete message is sent */ + CURLM_STATE_LAST /* 19 - not a true state, never use this */ } CURLMstate; /* we support N sockets per easy handle. Set the corresponding bit to what @@ -59,6 +62,8 @@ typedef enum { #define GETSOCK_READABLE (0x00ff) #define GETSOCK_WRITABLE (0xff00) +#define CURLPIPE_ANY (CURLPIPE_HTTP1 | CURLPIPE_MULTIPLEX) + /* This is the struct known as CURLM on the outside */ struct Curl_multi { /* First a simple identifier to easier detect if a user mix up @@ -82,8 +87,12 @@ struct Curl_multi { curl_socket_callback socket_cb; void *socket_userp; + /* callback function and user data pointer for server push */ + curl_push_callback push_cb; + void *push_userp; + /* Hostname cache */ - struct curl_hash *hostcache; + struct curl_hash hostcache; /* timetree points to the splay-tree of time nodes to figure out expire times of all currently set timers */ @@ -92,13 +101,15 @@ struct Curl_multi { /* 'sockhash' is the lookup hash for socket descriptor => easy handles (note the pluralis form, there can be more than one easy handle waiting on the same actual socket) */ - struct curl_hash *sockhash; + struct curl_hash sockhash; - /* Whether pipelining is enabled for this multi handle */ - bool pipelining_enabled; + /* pipelining wanted bits (CURLPIPE*) */ + long pipelining; + + bool recheckstate; /* see Curl_multi_connchanged */ /* Shared connection cache (bundles)*/ - struct conncache *conn_cache; + struct conncache conn_cache; /* This handle will be used for closing the cached connections in curl_multi_cleanup() */ @@ -139,4 +150,3 @@ struct Curl_multi { }; #endif /* HEADER_CURL_MULTIHANDLE_H */ - diff --git a/lib/multiif.h b/lib/multiif.h index c77b3ca..e6323ad 100644 --- a/lib/multiif.h +++ b/lib/multiif.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -27,8 +27,7 @@ */ void Curl_expire(struct SessionHandle *data, long milli); void Curl_expire_latest(struct SessionHandle *data, long milli); - -bool Curl_multi_pipeline_enabled(const struct Curl_multi* multi); +bool Curl_pipeline_wanted(const struct Curl_multi* multi, int bits); void Curl_multi_handlePipeBreak(struct SessionHandle *data); /* Internal version of curl_multi_init() accepts size parameters for the @@ -55,18 +54,11 @@ struct Curl_multi *Curl_multi_handle(int hashsize, int chashsize); void Curl_multi_dump(const struct Curl_multi *multi_handle); #endif -/* Update the current connection of a One_Easy handle */ -void Curl_multi_set_easy_connection(struct SessionHandle *handle, - struct connectdata *conn); - void Curl_multi_process_pending_handles(struct Curl_multi *multi); /* Return the value of the CURLMOPT_MAX_HOST_CONNECTIONS option */ size_t Curl_multi_max_host_connections(struct Curl_multi *multi); -/* Return the value of the CURLMOPT_MAX_PIPELINE_LENGTH option */ -size_t Curl_multi_max_pipeline_length(struct Curl_multi *multi); - /* Return the value of the CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE option */ curl_off_t Curl_multi_content_length_penalty_size(struct Curl_multi *multi); @@ -82,11 +74,13 @@ struct curl_llist *Curl_multi_pipelining_server_bl(struct Curl_multi *multi); /* Return the value of the CURLMOPT_MAX_TOTAL_CONNECTIONS option */ size_t Curl_multi_max_total_connections(struct Curl_multi *multi); +void Curl_multi_connchanged(struct Curl_multi *multi); + /* * Curl_multi_closed() * * Used by the connect code to tell the multi_socket code that one of the - * sockets we were using have just been closed. This function will then + * sockets we were using is about to be closed. This function will then * remove it from the sockethash for this handle to make the multi_socket API * behave properly, especially for the case when libcurl will create another * socket again and it gets the same file descriptor number. @@ -94,4 +88,10 @@ size_t Curl_multi_max_total_connections(struct Curl_multi *multi); void Curl_multi_closed(struct connectdata *conn, curl_socket_t s); +/* + * Add a handle and move it into PERFORM state at once. For pushed streams. + */ +CURLMcode Curl_multi_add_perform(struct Curl_multi *multi, + struct SessionHandle *data, + struct connectdata *conn); #endif /* HEADER_CURL_MULTIIF_H */ diff --git a/lib/netrc.c b/lib/netrc.c index 7435d94..06f8ea1 100644 --- a/lib/netrc.c +++ b/lib/netrc.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -31,13 +31,11 @@ #include "strequal.h" #include "strtok.h" -#include "curl_memory.h" #include "rawstr.h" +#include "curl_printf.h" -#define _MPRINTF_REPLACE /* use our functions only */ -#include - -/* The last #include file should be: */ +/* The last #include files should be: */ +#include "curl_memory.h" #include "memdebug.h" /* Get user and password from .netrc when given a machine name */ @@ -104,16 +102,16 @@ int Curl_parsenetrc(const char *host, netrcfile = curl_maprintf("%s%s%s", home, DIR_CHAR, NETRC); if(home_alloc) - Curl_safefree(home); + free(home); if(!netrcfile) { return -1; } netrc_alloc = TRUE; } - file = fopen(netrcfile, "r"); + file = fopen(netrcfile, FOPEN_READTEXT); if(netrc_alloc) - Curl_safefree(netrcfile); + free(netrcfile); if(file) { char *tok; char *tok_buf; @@ -139,6 +137,10 @@ int Curl_parsenetrc(const char *host, 'password'. */ state=HOSTFOUND; } + else if(Curl_raw_equal("default", tok)) { + state=HOSTVALID; + retcode=0; /* we did find our host */ + } break; case HOSTFOUND: if(Curl_raw_equal(host, tok)) { diff --git a/lib/non-ascii.c b/lib/non-ascii.c index 91d6a54..6ccb449 100644 --- a/lib/non-ascii.c +++ b/lib/non-ascii.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -82,17 +82,16 @@ CURLcode Curl_convert_clone(struct SessionHandle *data, CURLcode Curl_convert_to_network(struct SessionHandle *data, char *buffer, size_t length) { - CURLcode rc; - if(data->set.convtonetwork) { /* use translation callback */ - rc = data->set.convtonetwork(buffer, length); - if(rc != CURLE_OK) { + CURLcode result = data->set.convtonetwork(buffer, length); + if(result) { failf(data, "CURLOPT_CONV_TO_NETWORK_FUNCTION callback returned %d: %s", - (int)rc, curl_easy_strerror(rc)); + (int)result, curl_easy_strerror(result)); } - return rc; + + return result; } else { #ifdef HAVE_ICONV @@ -143,17 +142,16 @@ CURLcode Curl_convert_to_network(struct SessionHandle *data, CURLcode Curl_convert_from_network(struct SessionHandle *data, char *buffer, size_t length) { - CURLcode rc; - if(data->set.convfromnetwork) { /* use translation callback */ - rc = data->set.convfromnetwork(buffer, length); - if(rc != CURLE_OK) { + CURLcode result = data->set.convfromnetwork(buffer, length); + if(result) { failf(data, "CURLOPT_CONV_FROM_NETWORK_FUNCTION callback returned %d: %s", - (int)rc, curl_easy_strerror(rc)); + (int)result, curl_easy_strerror(result)); } - return rc; + + return result; } else { #ifdef HAVE_ICONV @@ -204,17 +202,16 @@ CURLcode Curl_convert_from_network(struct SessionHandle *data, CURLcode Curl_convert_from_utf8(struct SessionHandle *data, char *buffer, size_t length) { - CURLcode rc; - if(data->set.convfromutf8) { /* use translation callback */ - rc = data->set.convfromutf8(buffer, length); - if(rc != CURLE_OK) { + CURLcode result = data->set.convfromutf8(buffer, length); + if(result) { failf(data, "CURLOPT_CONV_FROM_UTF8_FUNCTION callback returned %d: %s", - (int)rc, curl_easy_strerror(rc)); + (int)result, curl_easy_strerror(result)); } - return rc; + + return result; } else { #ifdef HAVE_ICONV @@ -319,24 +316,22 @@ void Curl_convert_close(struct SessionHandle *data) */ CURLcode Curl_convert_form(struct SessionHandle *data, struct FormData *form) { - struct FormData *next; - CURLcode rc; - - if(!form) - return CURLE_OK; + CURLcode result; if(!data) return CURLE_BAD_FUNCTION_ARGUMENT; - do { - next=form->next; /* the following form line */ + while(form) { if(form->type == FORM_DATA) { - rc = Curl_convert_to_network(data, form->line, form->length); + result = Curl_convert_to_network(data, form->line, form->length); /* Curl_convert_to_network calls failf if unsuccessful */ - if(rc != CURLE_OK) - return rc; + if(result) + return result; } - } while((form = next) != NULL); /* continue */ + + form = form->next; + } + return CURLE_OK; } diff --git a/lib/nwlib.c b/lib/nwlib.c index 252bf11..bd3f27e 100644 --- a/lib/nwlib.c +++ b/lib/nwlib.c @@ -282,9 +282,7 @@ int DisposeLibraryData( void *data ) if(data) { void *tenbytes = ((libdata_t *) data)->tenbytes; - if(tenbytes) - free(tenbytes); - + free(tenbytes); free(data); } @@ -296,9 +294,7 @@ void DisposeThreadData( void *data ) if(data) { void *twentybytes = ((libthreaddata_t *) data)->twentybytes; - if(twentybytes) - free(twentybytes); - + free(twentybytes); free(data); } } diff --git a/lib/openldap.c b/lib/openldap.c index df8d938..bee552f 100644 --- a/lib/openldap.c +++ b/lib/openldap.c @@ -5,8 +5,8 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 2010, 2013, Howard Chu, - * Copyright (C) 2011 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 2010, Howard Chu, + * Copyright (C) 2011 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -44,13 +44,12 @@ #include "vtls/vtls.h" #include "transfer.h" #include "curl_ldap.h" -#include "curl_memory.h" #include "curl_base64.h" #include "connect.h" +#include "curl_printf.h" -#define _MPRINTF_REPLACE /* use our functions only */ -#include - +/* The last #include files should be: */ +#include "curl_memory.h" #include "memdebug.h" #ifndef _LDAP_PVT_H @@ -59,7 +58,7 @@ extern int ldap_init_fd(ber_socket_t fd, int proto, const char *url, LDAP **ld); #endif -static CURLcode ldap_setup(struct connectdata *conn); +static CURLcode ldap_setup_connection(struct connectdata *conn); static CURLcode ldap_do(struct connectdata *conn, bool *done); static CURLcode ldap_done(struct connectdata *conn, CURLcode, bool); static CURLcode ldap_connect(struct connectdata *conn, bool *done); @@ -74,7 +73,7 @@ static Curl_recv ldap_recv; const struct Curl_handler Curl_handler_ldap = { "LDAP", /* scheme */ - ldap_setup, /* setup_connection */ + ldap_setup_connection, /* setup_connection */ ldap_do, /* do_it */ ldap_done, /* done */ ZERO_NULL, /* do_more */ @@ -99,7 +98,7 @@ const struct Curl_handler Curl_handler_ldap = { const struct Curl_handler Curl_handler_ldaps = { "LDAPS", /* scheme */ - ldap_setup, /* setup_connection */ + ldap_setup_connection, /* setup_connection */ ldap_do, /* do_it */ ldap_done, /* done */ ZERO_NULL, /* do_more */ @@ -148,7 +147,7 @@ typedef struct ldapreqinfo { int nument; } ldapreqinfo; -static CURLcode ldap_setup(struct connectdata *conn) +static CURLcode ldap_setup_connection(struct connectdata *conn) { ldapconninfo *li; LDAPURLDesc *lud; @@ -190,9 +189,11 @@ static Sockbuf_IO ldapsb_tls; static CURLcode ldap_connect(struct connectdata *conn, bool *done) { ldapconninfo *li = conn->proto.generic; - struct SessionHandle *data=conn->data; + struct SessionHandle *data = conn->data; int rc, proto = LDAP_VERSION3; - char hosturl[1024], *ptr; + char hosturl[1024]; + char *ptr; + (void)done; strcpy(hosturl, "ldap"); @@ -213,10 +214,10 @@ static CURLcode ldap_connect(struct connectdata *conn, bool *done) #ifdef USE_SSL if(conn->handler->flags & PROTOPT_SSL) { - CURLcode res; - res = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, &li->ssldone); - if(res) - return res; + CURLcode result; + result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, &li->ssldone); + if(result) + return result; } #endif @@ -226,9 +227,9 @@ static CURLcode ldap_connect(struct connectdata *conn, bool *done) static CURLcode ldap_connecting(struct connectdata *conn, bool *done) { ldapconninfo *li = conn->proto.generic; - struct SessionHandle *data=conn->data; - LDAPMessage *result = NULL; - struct timeval tv = {0,1}, *tvp; + struct SessionHandle *data = conn->data; + LDAPMessage *msg = NULL; + struct timeval tv = {0, 1}, *tvp; int rc, err; char *info = NULL; @@ -236,11 +237,12 @@ static CURLcode ldap_connecting(struct connectdata *conn, bool *done) if(conn->handler->flags & PROTOPT_SSL) { /* Is the SSL handshake complete yet? */ if(!li->ssldone) { - CURLcode res = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, - &li->ssldone); - if(res || !li->ssldone) - return res; + CURLcode result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, + &li->ssldone); + if(result || !li->ssldone) + return result; } + /* Have we installed the libcurl SSL handlers into the sockbuf yet? */ if(!li->sslinst) { Sockbuf *sb; @@ -279,7 +281,7 @@ retry: return CURLE_OK; } - rc = ldap_result(li->ld, li->msgid, LDAP_MSG_ONE, tvp, &result); + rc = ldap_result(li->ld, li->msgid, LDAP_MSG_ONE, tvp, &msg); if(rc < 0) { failf(data, "LDAP local: bind ldap_result %s", ldap_err2string(rc)); return CURLE_LDAP_CANNOT_BIND; @@ -288,11 +290,13 @@ retry: /* timed out */ return CURLE_OK; } - rc = ldap_parse_result(li->ld, result, &err, NULL, &info, NULL, NULL, 1); + + rc = ldap_parse_result(li->ld, msg, &err, NULL, &info, NULL, NULL, 1); if(rc) { failf(data, "LDAP local: bind ldap_parse_result %s", ldap_err2string(rc)); return CURLE_LDAP_CANNOT_BIND; } + /* Try to fallback to LDAPv2? */ if(err == LDAP_PROTOCOL_ERROR) { int proto; @@ -321,6 +325,7 @@ retry: ldap_memfree(info); conn->recv[FIRSTSOCKET] = ldap_recv; *done = TRUE; + return CURLE_OK; } @@ -375,7 +380,7 @@ static CURLcode ldap_do(struct connectdata *conn, bool *done) failf(data, "LDAP local: ldap_search_ext %s", ldap_err2string(rc)); return CURLE_LDAP_SEARCH_FAILED; } - lr = calloc(1,sizeof(ldapreqinfo)); + lr = calloc(1, sizeof(ldapreqinfo)); if(!lr) return CURLE_OUT_OF_MEMORY; lr->msgid = msgid; @@ -389,6 +394,7 @@ static CURLcode ldap_done(struct connectdata *conn, CURLcode res, bool premature) { ldapreqinfo *lr = conn->data->req.protop; + (void)res; (void)premature; @@ -402,6 +408,7 @@ static CURLcode ldap_done(struct connectdata *conn, CURLcode res, conn->data->req.protop = NULL; free(lr); } + return CURLE_OK; } @@ -409,18 +416,19 @@ static ssize_t ldap_recv(struct connectdata *conn, int sockindex, char *buf, size_t len, CURLcode *err) { ldapconninfo *li = conn->proto.generic; - struct SessionHandle *data=conn->data; + struct SessionHandle *data = conn->data; ldapreqinfo *lr = data->req.protop; int rc, ret; - LDAPMessage *result = NULL; + LDAPMessage *msg = NULL; LDAPMessage *ent; BerElement *ber = NULL; - struct timeval tv = {0,1}; + struct timeval tv = {0, 1}; + (void)len; (void)buf; (void)sockindex; - rc = ldap_result(li->ld, lr->msgid, LDAP_MSG_RECEIVED, &tv, &result); + rc = ldap_result(li->ld, lr->msgid, LDAP_MSG_RECEIVED, &tv, &msg); if(rc < 0) { failf(data, "LDAP local: search ldap_result %s", ldap_err2string(rc)); *err = CURLE_RECV_ERROR; @@ -431,10 +439,10 @@ static ssize_t ldap_recv(struct connectdata *conn, int sockindex, char *buf, ret = -1; /* timed out */ - if(result == NULL) + if(!msg) return ret; - for(ent = ldap_first_message(li->ld, result); ent; + for(ent = ldap_first_message(li->ld, msg); ent; ent = ldap_next_message(li->ld, ent)) { struct berval bv, *bvals, **bvp = &bvals; int binary = 0, msgtype; @@ -477,9 +485,18 @@ static ssize_t ldap_recv(struct connectdata *conn, int sockindex, char *buf, *err = CURLE_RECV_ERROR; return -1; } - Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"DN: ", 4); - Curl_client_write(conn, CLIENTWRITE_BODY, (char *)bv.bv_val, bv.bv_len); - Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1); + *err = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"DN: ", 4); + if(*err) + return -1; + + *err = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)bv.bv_val, + bv.bv_len); + if(*err) + return -1; + + *err = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1); + if(*err) + return -1; data->req.bytecount += bv.bv_len + 5; for(rc = ldap_get_attribute_ber(li->ld, ent, ber, &bv, bvp); @@ -496,10 +513,18 @@ static ssize_t ldap_recv(struct connectdata *conn, int sockindex, char *buf, for(i=0; bvals[i].bv_val != NULL; i++) { int binval = 0; - Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\t", 1); - Curl_client_write(conn, CLIENTWRITE_BODY, (char *)bv.bv_val, - bv.bv_len); - Curl_client_write(conn, CLIENTWRITE_BODY, (char *)":", 1); + *err = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\t", 1); + if(*err) + return -1; + + *err = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)bv.bv_val, + bv.bv_len); + if(*err) + return -1; + + *err = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)":", 1); + if(*err) + return -1; data->req.bytecount += bv.bv_len + 2; if(!binary) { @@ -529,36 +554,55 @@ static ssize_t ldap_recv(struct connectdata *conn, int sockindex, char *buf, if(error) { ber_memfree(bvals); ber_free(ber, 0); - ldap_msgfree(result); + ldap_msgfree(msg); *err = error; return -1; } - Curl_client_write(conn, CLIENTWRITE_BODY, (char *)": ", 2); + *err = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)": ", 2); + if(*err) + return -1; + data->req.bytecount += 2; if(val_b64_sz > 0) { - Curl_client_write(conn, CLIENTWRITE_BODY, val_b64, val_b64_sz); + *err = Curl_client_write(conn, CLIENTWRITE_BODY, val_b64, + val_b64_sz); + if(*err) + return -1; free(val_b64); data->req.bytecount += val_b64_sz; } } else { - Curl_client_write(conn, CLIENTWRITE_BODY, (char *)" ", 1); - Curl_client_write(conn, CLIENTWRITE_BODY, bvals[i].bv_val, - bvals[i].bv_len); + *err = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)" ", 1); + if(*err) + return -1; + + *err = Curl_client_write(conn, CLIENTWRITE_BODY, bvals[i].bv_val, + bvals[i].bv_len); + if(*err) + return -1; + data->req.bytecount += bvals[i].bv_len + 1; } - Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 0); + *err = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 0); + if(*err) + return -1; + data->req.bytecount++; } ber_memfree(bvals); - Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 0); + *err = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 0); + if(*err) + return -1; data->req.bytecount++; } - Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 0); + *err = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 0); + if(*err) + return -1; data->req.bytecount++; ber_free(ber, 0); } - ldap_msgfree(result); + ldap_msgfree(msg); return ret; } diff --git a/lib/parsedate.c b/lib/parsedate.c index ecb8dfb..3e168f5 100644 --- a/lib/parsedate.c +++ b/lib/parsedate.c @@ -545,7 +545,7 @@ static int parsedate(const char *date, time_t *output) time_t curl_getdate(const char *p, const time_t *now) { - time_t parsed; + time_t parsed = -1; int rc = parsedate(p, &parsed); (void)now; /* legacy argument from the past that we ignore */ diff --git a/lib/pingpong.c b/lib/pingpong.c index c7e89d0..1670792 100644 --- a/lib/pingpong.c +++ b/lib/pingpong.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2013, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -34,9 +34,7 @@ #include "multiif.h" #include "non-ascii.h" #include "vtls/vtls.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include +#include "curl_printf.h" #include "curl_memory.h" /* The last #include file should be: */ @@ -165,7 +163,7 @@ CURLcode Curl_pp_vsendf(struct pingpong *pp, size_t write_len; char *fmt_crlf; char *s; - CURLcode error; + CURLcode result; struct connectdata *conn = pp->conn; struct SessionHandle *data = conn->data; @@ -191,26 +189,26 @@ CURLcode Curl_pp_vsendf(struct pingpong *pp, Curl_pp_init(pp); - error = Curl_convert_to_network(data, s, write_len); + result = Curl_convert_to_network(data, s, write_len); /* Curl_convert_to_network calls failf if unsuccessful */ - if(error) { + if(result) { free(s); - return error; + return result; } #ifdef HAVE_GSSAPI conn->data_prot = PROT_CMD; #endif - error = Curl_write(conn, conn->sock[FIRSTSOCKET], s, write_len, + result = Curl_write(conn, conn->sock[FIRSTSOCKET], s, write_len, &bytes_written); #ifdef HAVE_GSSAPI DEBUGASSERT(data_sec > PROT_NONE && data_sec < PROT_LAST); conn->data_prot = data_sec; #endif - if(error) { + if(result) { free(s); - return error; + return result; } if(conn->data->set.verbose) @@ -247,15 +245,15 @@ CURLcode Curl_pp_vsendf(struct pingpong *pp, CURLcode Curl_pp_sendf(struct pingpong *pp, const char *fmt, ...) { - CURLcode res; + CURLcode result; va_list ap; va_start(ap, fmt); - res = Curl_pp_vsendf(pp, fmt, ap); + result = Curl_pp_vsendf(pp, fmt, ap); va_end(ap); - return res; + return result; } /* @@ -285,8 +283,6 @@ CURLcode Curl_pp_readresp(curl_socket_t sockfd, /* number of bytes in the current line, so far */ perline = (ssize_t)(ptr-pp->linestart_resp); - keepon=TRUE; - while((pp->nread_respcache) { @@ -305,30 +301,28 @@ CURLcode Curl_pp_readresp(curl_socket_t sockfd, pp->cache_size = 0; /* zero the size just in case */ } else { - int res; #ifdef HAVE_GSSAPI enum protection_level prot = conn->data_prot; conn->data_prot = PROT_CLEAR; #endif DEBUGASSERT((ptr+BUFSIZE-pp->nread_resp) <= (buf+BUFSIZE+1)); - res = Curl_read(conn, sockfd, ptr, BUFSIZE-pp->nread_resp, - &gotbytes); + result = Curl_read(conn, sockfd, ptr, BUFSIZE-pp->nread_resp, + &gotbytes); #ifdef HAVE_GSSAPI DEBUGASSERT(prot > PROT_NONE && prot < PROT_LAST); conn->data_prot = prot; #endif - if(res == CURLE_AGAIN) + if(result == CURLE_AGAIN) return CURLE_OK; /* return */ - if((res == CURLE_OK) && (gotbytes > 0)) + if(!result && (gotbytes > 0)) /* convert from the network encoding */ - res = Curl_convert_from_network(data, ptr, gotbytes); + result = Curl_convert_from_network(data, ptr, gotbytes); /* Curl_convert_from_network calls failf if unsuccessful */ - if(CURLE_OK != res) { - result = (CURLcode)res; /* Set outer result variable to this error. */ + if(result) + /* Set outer result variable to this error. */ keepon = FALSE; - } } if(!keepon) @@ -478,11 +472,9 @@ CURLcode Curl_pp_flushsend(struct pingpong *pp) /* we have a piece of a command still left to send */ struct connectdata *conn = pp->conn; ssize_t written; - CURLcode result = CURLE_OK; curl_socket_t sock = conn->sock[FIRSTSOCKET]; - - result = Curl_write(conn, sock, pp->sendthis + pp->sendsize - - pp->sendleft, pp->sendleft, &written); + CURLcode result = Curl_write(conn, sock, pp->sendthis + pp->sendsize - + pp->sendleft, pp->sendleft, &written); if(result) return result; @@ -501,10 +493,8 @@ CURLcode Curl_pp_flushsend(struct pingpong *pp) CURLcode Curl_pp_disconnect(struct pingpong *pp) { - if(pp->cache) { - free(pp->cache); - pp->cache = NULL; - } + free(pp->cache); + pp->cache = NULL; return CURLE_OK; } diff --git a/lib/pipeline.c b/lib/pipeline.c index 8d2544b..1b38836 100644 --- a/lib/pipeline.c +++ b/lib/pipeline.c @@ -6,7 +6,7 @@ * \___|\___/|_| \_\_____| * * Copyright (C) 2013, Linus Nielsen Feltzing, - * Copyright (C) 2013-2014, Daniel Stenberg, , et al. + * Copyright (C) 2013-2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -32,7 +32,6 @@ #include "pipeline.h" #include "sendf.h" #include "rawstr.h" -#include "bundles.h" #include "curl_memory.h" /* The last #include file should be: */ @@ -49,15 +48,13 @@ static void site_blacklist_llist_dtor(void *user, void *element) (void)user; Curl_safefree(entry->hostname); - Curl_safefree(entry); + free(entry); } static void server_blacklist_llist_dtor(void *user, void *element) { - char *server_name = element; (void)user; - - Curl_safefree(server_name); + free(element); } bool Curl_pipeline_penalized(struct SessionHandle *data, @@ -94,20 +91,29 @@ bool Curl_pipeline_penalized(struct SessionHandle *data, return FALSE; } +static CURLcode addHandleToPipeline(struct SessionHandle *data, + struct curl_llist *pipeline) +{ + if(!Curl_llist_insert_next(pipeline, pipeline->tail, data)) + return CURLE_OUT_OF_MEMORY; + return CURLE_OK; +} + + CURLcode Curl_add_handle_to_pipeline(struct SessionHandle *handle, struct connectdata *conn) { struct curl_llist_element *sendhead = conn->send_pipe->head; struct curl_llist *pipeline; - CURLcode rc; + CURLcode result; pipeline = conn->send_pipe; - rc = Curl_addHandleToPipeline(handle, pipeline); + result = addHandleToPipeline(handle, pipeline); if(pipeline == conn->send_pipe && sendhead != conn->send_pipe->head) { /* this is a new one as head, expire it */ - conn->writechannel_inuse = FALSE; /* not in use yet */ + Curl_pipeline_leave_write(conn); /* not in use yet */ Curl_expire(conn->send_pipe->head->ptr, 1); } @@ -115,7 +121,7 @@ CURLcode Curl_add_handle_to_pipeline(struct SessionHandle *handle, print_pipeline(conn); #endif - return rc; + return result; } /* Move this transfer from the sending list to the receiving list. @@ -138,7 +144,7 @@ void Curl_move_handle_from_send_to_recv_pipe(struct SessionHandle *handle, if(conn->send_pipe->head) { /* Since there's a new easy handle at the start of the send pipeline, set its timeout value to 1ms to make it trigger instantly */ - conn->writechannel_inuse = FALSE; /* not used now */ + Curl_pipeline_leave_write(conn); /* not used now */ #ifdef DEBUGBUILD infof(conn->data, "%p is at send pipe head B!\n", (void *)conn->send_pipe->head->ptr); @@ -251,7 +257,7 @@ CURLMcode Curl_pipeline_set_site_blacklist(char **sites, bool Curl_pipeline_server_blacklisted(struct SessionHandle *handle, char *server_name) { - if(handle->multi) { + if(handle->multi && server_name) { struct curl_llist *blacklist = Curl_multi_pipelining_server_bl(handle->multi); @@ -272,7 +278,7 @@ bool Curl_pipeline_server_blacklisted(struct SessionHandle *handle, } } - infof(handle, "Server %s is not blacklisted\n", server_name); + DEBUGF(infof(handle, "Server %s is not blacklisted\n", server_name)); } return FALSE; } @@ -314,6 +320,93 @@ CURLMcode Curl_pipeline_set_server_blacklist(char **servers, return CURLM_OK; } +static bool pipe_head(struct SessionHandle *data, + struct curl_llist *pipeline) +{ + struct curl_llist_element *curr = pipeline->head; + if(curr) + return (curr->ptr == data) ? TRUE : FALSE; + + return FALSE; +} + +/* returns TRUE if the given handle is head of the recv pipe */ +bool Curl_recvpipe_head(struct SessionHandle *data, + struct connectdata *conn) +{ + return pipe_head(data, conn->recv_pipe); +} + +/* returns TRUE if the given handle is head of the send pipe */ +bool Curl_sendpipe_head(struct SessionHandle *data, + struct connectdata *conn) +{ + return pipe_head(data, conn->send_pipe); +} + + +/* + * Check if the write channel is available and this handle as at the head, + * then grab the channel and return TRUE. + * + * If not available, return FALSE. + */ + +bool Curl_pipeline_checkget_write(struct SessionHandle *data, + struct connectdata *conn) +{ + if(conn->bits.multiplex) + /* when multiplexing, we can use it at once */ + return TRUE; + + if(!conn->writechannel_inuse && Curl_sendpipe_head(data, conn)) { + /* Grab the channel */ + conn->writechannel_inuse = TRUE; + return TRUE; + } + return FALSE; +} + + +/* + * Check if the read channel is available and this handle as at the head, then + * grab the channel and return TRUE. + * + * If not available, return FALSE. + */ + +bool Curl_pipeline_checkget_read(struct SessionHandle *data, + struct connectdata *conn) +{ + if(conn->bits.multiplex) + /* when multiplexing, we can use it at once */ + return TRUE; + + if(!conn->readchannel_inuse && Curl_recvpipe_head(data, conn)) { + /* Grab the channel */ + conn->readchannel_inuse = TRUE; + return TRUE; + } + return FALSE; +} + +/* + * The current user of the pipeline write channel gives it up. + */ +void Curl_pipeline_leave_write(struct connectdata *conn) +{ + conn->writechannel_inuse = FALSE; +} + +/* + * The current user of the pipeline read channel gives it up. + */ +void Curl_pipeline_leave_read(struct connectdata *conn) +{ + conn->readchannel_inuse = FALSE; +} + + #if 0 void print_pipeline(struct connectdata *conn) { diff --git a/lib/pipeline.h b/lib/pipeline.h index 96c4c33..bf229f1 100644 --- a/lib/pipeline.h +++ b/lib/pipeline.h @@ -7,6 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * + * Copyright (C) 2015, Daniel Stenberg, , et al. * Copyright (C) 2013 - 2014, Linus Nielsen Feltzing, * * This software is licensed as described in the file COPYING, which @@ -41,4 +42,15 @@ bool Curl_pipeline_server_blacklisted(struct SessionHandle *handle, CURLMcode Curl_pipeline_set_server_blacklist(char **servers, struct curl_llist **list_ptr); +bool Curl_pipeline_checkget_write(struct SessionHandle *data, + struct connectdata *conn); +bool Curl_pipeline_checkget_read(struct SessionHandle *data, + struct connectdata *conn); +void Curl_pipeline_leave_write(struct connectdata *conn); +void Curl_pipeline_leave_read(struct connectdata *conn); +bool Curl_recvpipe_head(struct SessionHandle *data, + struct connectdata *conn); +bool Curl_sendpipe_head(struct SessionHandle *data, + struct connectdata *conn); + #endif /* HEADER_CURL_PIPELINE_H */ diff --git a/lib/pop3.c b/lib/pop3.c index dc64f81..53510a2 100644 --- a/lib/pop3.c +++ b/lib/pop3.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -63,7 +63,6 @@ #include #include "urldata.h" #include "sendf.h" -#include "if2ip.h" #include "hostip.h" #include "progress.h" #include "transfer.h" @@ -84,10 +83,7 @@ #include "curl_sasl.h" #include "curl_md5.h" #include "warnless.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include - +#include "curl_printf.h" #include "curl_memory.h" /* The last #include file should be: */ #include "memdebug.h" @@ -107,10 +103,10 @@ static CURLcode pop3_setup_connection(struct connectdata *conn); static CURLcode pop3_parse_url_options(struct connectdata *conn); static CURLcode pop3_parse_url_path(struct connectdata *conn); static CURLcode pop3_parse_custom_request(struct connectdata *conn); -static CURLcode pop3_calc_sasl_details(struct connectdata *conn, - const char **mech, - char **initresp, size_t *len, - pop3state *state1, pop3state *state2); +static CURLcode pop3_perform_auth(struct connectdata *conn, const char *mech, + const char *initresp); +static CURLcode pop3_continue_auth(struct connectdata *conn, const char *resp); +static void pop3_get_message(char *buffer, char** outptr); /* * POP3 protocol handler. @@ -215,6 +211,17 @@ static const struct Curl_handler Curl_handler_pop3s_proxy = { #endif #endif +/* SASL parameters for the pop3 protocol */ +static const struct SASLproto saslpop3 = { + "pop", /* The service name */ + '+', /* Code received when continuation is expected */ + '+', /* Code to receive upon authentication success */ + 255 - 8, /* Maximum initial response length (no max) */ + pop3_perform_auth, /* Send authentication command */ + pop3_continue_auth, /* Send authentication continuation */ + pop3_get_message /* Get SASL response message */ +}; + #ifdef USE_SSL static void pop3_to_pop3s(struct connectdata *conn) { @@ -313,20 +320,7 @@ static void state(struct connectdata *conn, pop3state newstate) "CAPA", "STARTTLS", "UPGRADETLS", - "AUTH_PLAIN", - "AUTH_LOGIN", - "AUTH_LOGIN_PASSWD", - "AUTH_CRAMMD5", - "AUTH_DIGESTMD5", - "AUTH_DIGESTMD5_RESP", - "AUTH_NTLM", - "AUTH_NTLM_TYPE2MSG", - "AUTH_GSSAPI", - "AUTH_GSSAPI_TOKEN", - "AUTH_GSSAPI_NO_DATA", - "AUTH_XOAUTH2", - "AUTH_CANCEL", - "AUTH_FINAL", + "AUTH", "APOP", "USER", "PASS", @@ -355,9 +349,9 @@ static CURLcode pop3_perform_capa(struct connectdata *conn) CURLcode result = CURLE_OK; struct pop3_conn *pop3c = &conn->proto.pop3c; - pop3c->authmechs = 0; /* No known authentication mechanisms yet */ - pop3c->authused = 0; /* Clear the authentication mechanism used */ - pop3c->tls_supported = FALSE; /* Clear the TLS capability */ + pop3c->sasl.authmechs = SASL_AUTH_NONE; /* No known auth. mechanisms yet */ + pop3c->sasl.authused = SASL_AUTH_NONE; /* Clear the auth. mechanism used */ + pop3c->tls_supported = FALSE; /* Clear the TLS capability */ /* Send the CAPA command */ result = Curl_pp_sendf(&pop3c->pp, "%s", "CAPA"); @@ -501,25 +495,18 @@ static CURLcode pop3_perform_apop(struct connectdata *conn) */ static CURLcode pop3_perform_auth(struct connectdata *conn, const char *mech, - const char *initresp, size_t len, - pop3state state1, pop3state state2) + const char *initresp) { CURLcode result = CURLE_OK; struct pop3_conn *pop3c = &conn->proto.pop3c; - if(initresp && 8 + strlen(mech) + len <= 255) { /* AUTH ... */ + if(initresp) { /* AUTH ... */ /* Send the AUTH command with the initial response */ result = Curl_pp_sendf(&pop3c->pp, "AUTH %s %s", mech, initresp); - - if(!result) - state(conn, state2); } else { /* Send the AUTH command */ result = Curl_pp_sendf(&pop3c->pp, "AUTH %s", mech); - - if(!result) - state(conn, state1); } return result; @@ -527,6 +514,20 @@ static CURLcode pop3_perform_auth(struct connectdata *conn, /*********************************************************************** * + * pop3_continue_auth() + * + * Sends SASL continuation data or cancellation. + */ +static CURLcode pop3_continue_auth(struct connectdata *conn, + const char *resp) +{ + struct pop3_conn *pop3c = &conn->proto.pop3c; + + return Curl_pp_sendf(&pop3c->pp, "%s", resp); +} + +/*********************************************************************** + * * pop3_perform_authentication() * * Initiates the authentication sequence, with the appropriate SASL @@ -537,40 +538,32 @@ static CURLcode pop3_perform_authentication(struct connectdata *conn) { CURLcode result = CURLE_OK; struct pop3_conn *pop3c = &conn->proto.pop3c; - const char *mech = NULL; - char *initresp = NULL; - size_t len = 0; - pop3state state1 = POP3_STOP; - pop3state state2 = POP3_STOP; + saslprogress progress = SASL_IDLE; - /* Check we have a username and password to authenticate with and end the + /* Check we have enough data to authenticate with and end the connect phase if we don't */ - if(!conn->bits.user_passwd) { + if(!Curl_sasl_can_authenticate(&pop3c->sasl, conn)) { state(conn, POP3_STOP); - return result; } - /* Calculate the SASL login details */ - if(pop3c->authtypes & POP3_TYPE_SASL) - result = pop3_calc_sasl_details(conn, &mech, &initresp, &len, &state1, - &state2); + if(pop3c->authtypes & pop3c->preftype & POP3_TYPE_SASL) { + /* Calculate the SASL login details */ + result = Curl_sasl_start(&pop3c->sasl, conn, FALSE, &progress); - if(!result) { - if(mech && (pop3c->preftype & POP3_TYPE_SASL)) { - /* Perform SASL based authentication */ - result = pop3_perform_auth(conn, mech, initresp, len, state1, state2); + if(!result) + if(progress == SASL_INPROGRESS) + state(conn, POP3_AUTH); + } - Curl_safefree(initresp); - } + if(!result && progress == SASL_IDLE) { #ifndef CURL_DISABLE_CRYPTO_AUTH - else if((pop3c->authtypes & POP3_TYPE_APOP) && - (pop3c->preftype & POP3_TYPE_APOP)) + if(pop3c->authtypes & pop3c->preftype & POP3_TYPE_APOP) /* Perform APOP authentication */ result = pop3_perform_apop(conn); + else #endif - else if((pop3c->authtypes & POP3_TYPE_CLEARTEXT) && - (pop3c->preftype & POP3_TYPE_CLEARTEXT)) + if(pop3c->authtypes & pop3c->preftype & POP3_TYPE_CLEARTEXT) /* Perform clear text authentication */ result = pop3_perform_user(conn); else { @@ -727,6 +720,9 @@ static CURLcode pop3_state_capa_resp(struct connectdata *conn, int pop3code, /* Loop through the data line */ for(;;) { + size_t llen; + unsigned int mechbit; + while(len && (*line == ' ' || *line == '\t' || *line == '\r' || *line == '\n')) { @@ -745,22 +741,9 @@ static CURLcode pop3_state_capa_resp(struct connectdata *conn, int pop3code, wordlen++; /* Test the word for a matching authentication mechanism */ - if(sasl_mech_equal(line, wordlen, SASL_MECH_STRING_LOGIN)) - pop3c->authmechs |= SASL_MECH_LOGIN; - else if(sasl_mech_equal(line, wordlen, SASL_MECH_STRING_PLAIN)) - pop3c->authmechs |= SASL_MECH_PLAIN; - else if(sasl_mech_equal(line, wordlen, SASL_MECH_STRING_CRAM_MD5)) - pop3c->authmechs |= SASL_MECH_CRAM_MD5; - else if(sasl_mech_equal(line, wordlen, SASL_MECH_STRING_DIGEST_MD5)) - pop3c->authmechs |= SASL_MECH_DIGEST_MD5; - else if(sasl_mech_equal(line, wordlen, SASL_MECH_STRING_GSSAPI)) - pop3c->authmechs |= SASL_MECH_GSSAPI; - else if(sasl_mech_equal(line, wordlen, SASL_MECH_STRING_EXTERNAL)) - pop3c->authmechs |= SASL_MECH_EXTERNAL; - else if(sasl_mech_equal(line, wordlen, SASL_MECH_STRING_NTLM)) - pop3c->authmechs |= SASL_MECH_NTLM; - else if(sasl_mech_equal(line, wordlen, SASL_MECH_STRING_XOAUTH2)) - pop3c->authmechs |= SASL_MECH_XOAUTH2; + if((mechbit = Curl_sasl_decode_mech(line, wordlen, &llen)) && + llen == wordlen) + pop3c->sasl.authmechs |= mechbit; line += wordlen; len -= wordlen; @@ -818,575 +801,42 @@ static CURLcode pop3_state_starttls_resp(struct connectdata *conn, return result; } -/* For AUTH PLAIN (without initial response) responses */ -static CURLcode pop3_state_auth_plain_resp(struct connectdata *conn, - int pop3code, - pop3state instate) -{ - CURLcode result = CURLE_OK; - struct SessionHandle *data = conn->data; - size_t len = 0; - char *plainauth = NULL; - - (void)instate; /* no use for this yet */ - - if(pop3code != '+') { - failf(data, "Access denied. %c", pop3code); - result = CURLE_LOGIN_DENIED; - } - else { - /* Create the authorisation message */ - result = Curl_sasl_create_plain_message(data, conn->user, conn->passwd, - &plainauth, &len); - if(!result && plainauth) { - /* Send the message */ - result = Curl_pp_sendf(&conn->proto.pop3c.pp, "%s", plainauth); - - if(!result) - state(conn, POP3_AUTH_FINAL); - } - } - - Curl_safefree(plainauth); - - return result; -} - -/* For AUTH LOGIN (without initial response) responses */ -static CURLcode pop3_state_auth_login_resp(struct connectdata *conn, - int pop3code, - pop3state instate) -{ - CURLcode result = CURLE_OK; - struct SessionHandle *data = conn->data; - size_t len = 0; - char *authuser = NULL; - - (void)instate; /* no use for this yet */ - - if(pop3code != '+') { - failf(data, "Access denied: %d", pop3code); - result = CURLE_LOGIN_DENIED; - } - else { - /* Create the user message */ - result = Curl_sasl_create_login_message(data, conn->user, - &authuser, &len); - if(!result && authuser) { - /* Send the user */ - result = Curl_pp_sendf(&conn->proto.pop3c.pp, "%s", authuser); - - if(!result) - state(conn, POP3_AUTH_LOGIN_PASSWD); - } - } - - Curl_safefree(authuser); - - return result; -} - -/* For AUTH LOGIN user entry responses */ -static CURLcode pop3_state_auth_login_password_resp(struct connectdata *conn, - int pop3code, - pop3state instate) -{ - CURLcode result = CURLE_OK; - struct SessionHandle *data = conn->data; - size_t len = 0; - char *authpasswd = NULL; - - (void)instate; /* no use for this yet */ - - if(pop3code != '+') { - failf(data, "Access denied: %d", pop3code); - result = CURLE_LOGIN_DENIED; - } - else { - /* Create the password message */ - result = Curl_sasl_create_login_message(data, conn->passwd, - &authpasswd, &len); - if(!result && authpasswd) { - /* Send the password */ - result = Curl_pp_sendf(&conn->proto.pop3c.pp, "%s", authpasswd); - - if(!result) - state(conn, POP3_AUTH_FINAL); - } - } - - Curl_safefree(authpasswd); - - return result; -} - -#ifndef CURL_DISABLE_CRYPTO_AUTH -/* For AUTH CRAM-MD5 responses */ -static CURLcode pop3_state_auth_cram_resp(struct connectdata *conn, - int pop3code, - pop3state instate) -{ - CURLcode result = CURLE_OK; - struct SessionHandle *data = conn->data; - char *chlg = NULL; - char *chlg64 = NULL; - char *rplyb64 = NULL; - size_t len = 0; - - (void)instate; /* no use for this yet */ - - if(pop3code != '+') { - failf(data, "Access denied: %d", pop3code); - return CURLE_LOGIN_DENIED; - } - - /* Get the challenge message */ - pop3_get_message(data->state.buffer, &chlg64); - - /* Decode the challenge message */ - result = Curl_sasl_decode_cram_md5_message(chlg64, &chlg, &len); - if(result) { - /* Send the cancellation */ - result = Curl_pp_sendf(&conn->proto.pop3c.pp, "%s", "*"); - - if(!result) - state(conn, POP3_AUTH_CANCEL); - } - else { - /* Create the response message */ - result = Curl_sasl_create_cram_md5_message(data, chlg, conn->user, - conn->passwd, &rplyb64, &len); - if(!result && rplyb64) { - /* Send the response */ - result = Curl_pp_sendf(&conn->proto.pop3c.pp, "%s", rplyb64); - - if(!result) - state(conn, POP3_AUTH_FINAL); - } - } - - Curl_safefree(chlg); - Curl_safefree(rplyb64); - - return result; -} - -/* For AUTH DIGEST-MD5 challenge responses */ -static CURLcode pop3_state_auth_digest_resp(struct connectdata *conn, - int pop3code, - pop3state instate) -{ - CURLcode result = CURLE_OK; - struct SessionHandle *data = conn->data; - char *chlg64 = NULL; - char *rplyb64 = NULL; - size_t len = 0; - - (void)instate; /* no use for this yet */ - - if(pop3code != '+') { - failf(data, "Access denied: %d", pop3code); - return CURLE_LOGIN_DENIED; - } - - /* Get the challenge message */ - pop3_get_message(data->state.buffer, &chlg64); - - /* Create the response message */ - result = Curl_sasl_create_digest_md5_message(data, chlg64, - conn->user, conn->passwd, - "pop", &rplyb64, &len); - if(result) { - if(result == CURLE_BAD_CONTENT_ENCODING) { - /* Send the cancellation */ - result = Curl_pp_sendf(&conn->proto.pop3c.pp, "%s", "*"); - - if(!result) - state(conn, POP3_AUTH_CANCEL); - } - } - else { - /* Send the response */ - result = Curl_pp_sendf(&conn->proto.pop3c.pp, "%s", rplyb64); - - if(!result) - state(conn, POP3_AUTH_DIGESTMD5_RESP); - } - - Curl_safefree(rplyb64); - - return result; -} - -/* For AUTH DIGEST-MD5 challenge-response responses */ -static CURLcode pop3_state_auth_digest_resp_resp(struct connectdata *conn, - int pop3code, - pop3state instate) -{ - CURLcode result = CURLE_OK; - struct SessionHandle *data = conn->data; - - (void)instate; /* no use for this yet */ - - if(pop3code != '+') { - failf(data, "Authentication failed: %d", pop3code); - result = CURLE_LOGIN_DENIED; - } - else { - /* Send an empty response */ - result = Curl_pp_sendf(&conn->proto.pop3c.pp, "%s", ""); - - if(!result) - state(conn, POP3_AUTH_FINAL); - } - - return result; -} -#endif - -#ifdef USE_NTLM -/* For AUTH NTLM (without initial response) responses */ -static CURLcode pop3_state_auth_ntlm_resp(struct connectdata *conn, - int pop3code, - pop3state instate) -{ - CURLcode result = CURLE_OK; - struct SessionHandle *data = conn->data; - size_t len = 0; - char *type1msg = NULL; - - (void)instate; /* no use for this yet */ - - if(pop3code != '+') { - failf(data, "Access denied: %d", pop3code); - result = CURLE_LOGIN_DENIED; - } - else { - /* Create the type-1 message */ - result = Curl_sasl_create_ntlm_type1_message(conn->user, conn->passwd, - &conn->ntlm, - &type1msg, &len); - if(!result && type1msg) { - /* Send the message */ - result = Curl_pp_sendf(&conn->proto.pop3c.pp, "%s", type1msg); - - if(!result) - state(conn, POP3_AUTH_NTLM_TYPE2MSG); - } - } - - Curl_safefree(type1msg); - - return result; -} - -/* For NTLM type-2 responses (sent in reponse to our type-1 message) */ -static CURLcode pop3_state_auth_ntlm_type2msg_resp(struct connectdata *conn, - int pop3code, - pop3state instate) -{ - CURLcode result = CURLE_OK; - struct SessionHandle *data = conn->data; - char *type2msg = NULL; - char *type3msg = NULL; - size_t len = 0; - - (void)instate; /* no use for this yet */ - - if(pop3code != '+') { - failf(data, "Access denied: %d", pop3code); - result = CURLE_LOGIN_DENIED; - } - else { - /* Get the type-2 message */ - pop3_get_message(data->state.buffer, &type2msg); - - /* Decode the type-2 message */ - result = Curl_sasl_decode_ntlm_type2_message(data, type2msg, &conn->ntlm); - if(result) { - /* Send the cancellation */ - result = Curl_pp_sendf(&conn->proto.pop3c.pp, "%s", "*"); - - if(!result) - state(conn, POP3_AUTH_CANCEL); - } - else { - /* Create the type-3 message */ - result = Curl_sasl_create_ntlm_type3_message(data, conn->user, - conn->passwd, &conn->ntlm, - &type3msg, &len); - if(!result && type3msg) { - /* Send the message */ - result = Curl_pp_sendf(&conn->proto.pop3c.pp, "%s", type3msg); - - if(!result) - state(conn, POP3_AUTH_FINAL); - } - } - } - - Curl_safefree(type3msg); - - return result; -} -#endif - -#if defined(USE_WINDOWS_SSPI) -/* For AUTH GSSAPI (without initial response) responses */ -static CURLcode pop3_state_auth_gssapi_resp(struct connectdata *conn, - int pop3code, - pop3state instate) -{ - CURLcode result = CURLE_OK; - struct SessionHandle *data = conn->data; - struct pop3_conn *pop3c = &conn->proto.pop3c; - size_t len = 0; - char *respmsg = NULL; - - (void)instate; /* no use for this yet */ - - if(pop3code != '+') { - failf(data, "Access denied: %d", pop3code); - result = CURLE_LOGIN_DENIED; - } - else { - /* Create the initial response message */ - result = Curl_sasl_create_gssapi_user_message(data, conn->user, - conn->passwd, "pop", - pop3c->mutual_auth, - NULL, &conn->krb5, - &respmsg, &len); - if(!result && respmsg) { - /* Send the message */ - result = Curl_pp_sendf(&pop3c->pp, "%s", respmsg); - - if(!result) - state(conn, POP3_AUTH_GSSAPI_TOKEN); - } - } - - Curl_safefree(respmsg); - - return result; -} - -/* For AUTH GSSAPI user token responses */ -static CURLcode pop3_state_auth_gssapi_token_resp(struct connectdata *conn, - int pop3code, - pop3state instate) -{ - CURLcode result = CURLE_OK; - struct SessionHandle *data = conn->data; - struct pop3_conn *pop3c = &conn->proto.pop3c; - char *chlgmsg = NULL; - char *respmsg = NULL; - size_t len = 0; - - (void)instate; /* no use for this yet */ - - if(pop3code != '+') { - failf(data, "Access denied: %d", pop3code); - result = CURLE_LOGIN_DENIED; - } - else { - /* Get the challenge message */ - pop3_get_message(data->state.buffer, &chlgmsg); - - if(pop3c->mutual_auth) - /* Decode the user token challenge and create the optional response - message */ - result = Curl_sasl_create_gssapi_user_message(data, NULL, NULL, NULL, - pop3c->mutual_auth, - chlgmsg, &conn->krb5, - &respmsg, &len); - else - /* Decode the security challenge and create the response message */ - result = Curl_sasl_create_gssapi_security_message(data, chlgmsg, - &conn->krb5, - &respmsg, &len); - - if(result) { - if(result == CURLE_BAD_CONTENT_ENCODING) { - /* Send the cancellation */ - result = Curl_pp_sendf(&pop3c->pp, "%s", "*"); - - if(!result) - state(conn, POP3_AUTH_CANCEL); - } - } - else { - /* Send the response */ - if(respmsg) - result = Curl_pp_sendf(&pop3c->pp, "%s", respmsg); - else - result = Curl_pp_sendf(&pop3c->pp, "%s", ""); - - if(!result) - state(conn, (pop3c->mutual_auth ? POP3_AUTH_GSSAPI_NO_DATA : - POP3_AUTH_FINAL)); - } - } - - Curl_safefree(respmsg); - - return result; -} - -/* For AUTH GSSAPI no data responses */ -static CURLcode pop3_state_auth_gssapi_no_data_resp(struct connectdata *conn, - int pop3code, - pop3state instate) -{ - CURLcode result = CURLE_OK; - struct SessionHandle *data = conn->data; - char *chlgmsg = NULL; - char *respmsg = NULL; - size_t len = 0; - - (void)instate; /* no use for this yet */ - - if(pop3code != '+') { - failf(data, "Access denied: %d", pop3code); - result = CURLE_LOGIN_DENIED; - } - else { - /* Get the challenge message */ - pop3_get_message(data->state.buffer, &chlgmsg); - - /* Decode the security challenge and create the security message */ - result = Curl_sasl_create_gssapi_security_message(data, chlgmsg, - &conn->krb5, - &respmsg, &len); - if(result) { - if(result == CURLE_BAD_CONTENT_ENCODING) { - /* Send the cancellation */ - result = Curl_pp_sendf(&conn->proto.pop3c.pp, "%s", "*"); - - if(!result) - state(conn, POP3_AUTH_CANCEL); - } - } - else { - /* Send the response */ - if(respmsg) { - result = Curl_pp_sendf(&conn->proto.pop3c.pp, "%s", respmsg); - - if(!result) - state(conn, POP3_AUTH_FINAL); - } - } - } - - Curl_safefree(respmsg); - - return result; -} -#endif - -/* For AUTH XOAUTH2 (without initial response) responses */ -static CURLcode pop3_state_auth_xoauth2_resp(struct connectdata *conn, - int pop3code, pop3state instate) -{ - CURLcode result = CURLE_OK; - struct SessionHandle *data = conn->data; - size_t len = 0; - char *xoauth = NULL; - - (void)instate; /* no use for this yet */ - - if(pop3code != '+') { - failf(data, "Access denied: %d", pop3code); - result = CURLE_LOGIN_DENIED; - } - else { - /* Create the authorisation message */ - result = Curl_sasl_create_xoauth2_message(conn->data, conn->user, - conn->xoauth2_bearer, - &xoauth, &len); - if(!result && xoauth) { - /* Send the message */ - result = Curl_pp_sendf(&conn->proto.pop3c.pp, "%s", xoauth); - - if(!result) - state(conn, POP3_AUTH_FINAL); - } - } - - Curl_safefree(xoauth); - - return result; -} - -/* For AUTH cancellation responses */ -static CURLcode pop3_state_auth_cancel_resp(struct connectdata *conn, - int pop3code, - pop3state instate) +/* For SASL authentication responses */ +static CURLcode pop3_state_auth_resp(struct connectdata *conn, + int pop3code, + pop3state instate) { CURLcode result = CURLE_OK; struct SessionHandle *data = conn->data; struct pop3_conn *pop3c = &conn->proto.pop3c; - const char *mech = NULL; - char *initresp = NULL; - size_t len = 0; - pop3state state1 = POP3_STOP; - pop3state state2 = POP3_STOP; + saslprogress progress; - (void)pop3code; (void)instate; /* no use for this yet */ - /* Remove the offending mechanism from the supported list */ - pop3c->authmechs ^= pop3c->authused; - - /* Calculate alternative SASL login details */ - result = pop3_calc_sasl_details(conn, &mech, &initresp, &len, &state1, - &state2); - - if(!result) { - /* Do we have any mechanisms left or can we fallback to another - authentication type? */ - if(mech) { - /* Retry SASL based authentication */ - result = pop3_perform_auth(conn, mech, initresp, len, state1, state2); - - Curl_safefree(initresp); - } + result = Curl_sasl_continue(&pop3c->sasl, conn, pop3code, &progress); + if(!result) + switch(progress) { + case SASL_DONE: + state(conn, POP3_STOP); /* Authenticated */ + break; + case SASL_IDLE: /* No mechanism left after cancellation */ #ifndef CURL_DISABLE_CRYPTO_AUTH - else if((pop3c->authtypes & POP3_TYPE_APOP) && - (pop3c->preftype & POP3_TYPE_APOP)) - /* Perform APOP authentication */ - result = pop3_perform_apop(conn); + if(pop3c->authtypes & pop3c->preftype & POP3_TYPE_APOP) + /* Perform APOP authentication */ + result = pop3_perform_apop(conn); + else #endif - else if((pop3c->authtypes & POP3_TYPE_CLEARTEXT) && - (pop3c->preftype & POP3_TYPE_CLEARTEXT)) - /* Perform clear text authentication */ - result = pop3_perform_user(conn); - else { - failf(data, "Authentication cancelled"); - - result = CURLE_LOGIN_DENIED; + if(pop3c->authtypes & pop3c->preftype & POP3_TYPE_CLEARTEXT) + /* Perform clear text authentication */ + result = pop3_perform_user(conn); + else { + failf(data, "Authentication cancelled"); + result = CURLE_LOGIN_DENIED; + } + break; + default: + break; } - } - - return result; -} - -/* For final responses in the AUTH sequence */ -static CURLcode pop3_state_auth_final_resp(struct connectdata *conn, - int pop3code, - pop3state instate) -{ - CURLcode result = CURLE_OK; - struct SessionHandle *data = conn->data; - - (void)instate; /* no use for this yet */ - - if(pop3code != '+') { - failf(data, "Authentication failed: %d", pop3code); - result = CURLE_LOGIN_DENIED; - } - else - /* End of connect phase */ - state(conn, POP3_STOP); return result; } @@ -1553,69 +1003,8 @@ static CURLcode pop3_statemach_act(struct connectdata *conn) result = pop3_state_starttls_resp(conn, pop3code, pop3c->state); break; - case POP3_AUTH_PLAIN: - result = pop3_state_auth_plain_resp(conn, pop3code, pop3c->state); - break; - - case POP3_AUTH_LOGIN: - result = pop3_state_auth_login_resp(conn, pop3code, pop3c->state); - break; - - case POP3_AUTH_LOGIN_PASSWD: - result = pop3_state_auth_login_password_resp(conn, pop3code, - pop3c->state); - break; - -#ifndef CURL_DISABLE_CRYPTO_AUTH - case POP3_AUTH_CRAMMD5: - result = pop3_state_auth_cram_resp(conn, pop3code, pop3c->state); - break; - - case POP3_AUTH_DIGESTMD5: - result = pop3_state_auth_digest_resp(conn, pop3code, pop3c->state); - break; - - case POP3_AUTH_DIGESTMD5_RESP: - result = pop3_state_auth_digest_resp_resp(conn, pop3code, pop3c->state); - break; -#endif - -#ifdef USE_NTLM - case POP3_AUTH_NTLM: - result = pop3_state_auth_ntlm_resp(conn, pop3code, pop3c->state); - break; - - case POP3_AUTH_NTLM_TYPE2MSG: - result = pop3_state_auth_ntlm_type2msg_resp(conn, pop3code, - pop3c->state); - break; -#endif - -#if defined(USE_WINDOWS_SSPI) - case POP3_AUTH_GSSAPI: - result = pop3_state_auth_gssapi_resp(conn, pop3code, pop3c->state); - break; - - case POP3_AUTH_GSSAPI_TOKEN: - result = pop3_state_auth_gssapi_token_resp(conn, pop3code, pop3c->state); - break; - - case POP3_AUTH_GSSAPI_NO_DATA: - result = pop3_state_auth_gssapi_no_data_resp(conn, pop3code, - pop3c->state); - break; -#endif - - case POP3_AUTH_XOAUTH2: - result = pop3_state_auth_xoauth2_resp(conn, pop3code, pop3c->state); - break; - - case POP3_AUTH_CANCEL: - result = pop3_state_auth_cancel_resp(conn, pop3code, pop3c->state); - break; - - case POP3_AUTH_FINAL: - result = pop3_state_auth_final_resp(conn, pop3code, pop3c->state); + case POP3_AUTH: + result = pop3_state_auth_resp(conn, pop3code, pop3c->state); break; #ifndef CURL_DISABLE_CRYPTO_AUTH @@ -1728,7 +1117,7 @@ static CURLcode pop3_connect(struct connectdata *conn, bool *done) /* Set the default preferred authentication type and mechanism */ pop3c->preftype = POP3_TYPE_ANY; - pop3c->prefmech = SASL_AUTH_ANY; + Curl_sasl_init(&pop3c->sasl, &saslpop3); /* Initialise the pingpong layer */ Curl_pp_init(pp); @@ -1880,7 +1269,7 @@ static CURLcode pop3_disconnect(struct connectdata *conn, bool dead_connection) Curl_pp_disconnect(&pop3c->pp); /* Cleanup the SASL module */ - Curl_sasl_cleanup(conn, pop3c->authused); + Curl_sasl_cleanup(conn, pop3c->sasl.authused); /* Cleanup our connection based variables */ Curl_safefree(pop3c->apoptimestamp); @@ -1995,75 +1384,52 @@ static CURLcode pop3_parse_url_options(struct connectdata *conn) { CURLcode result = CURLE_OK; struct pop3_conn *pop3c = &conn->proto.pop3c; - const char *options = conn->options; - const char *ptr = options; - bool reset = TRUE; + const char *ptr = conn->options; + + pop3c->sasl.resetprefs = TRUE; - while(ptr && *ptr) { + while(!result && ptr && *ptr) { const char *key = ptr; + const char *value; while(*ptr && *ptr != '=') ptr++; - if(strnequal(key, "AUTH", 4)) { - size_t len = 0; - const char *value = ++ptr; + value = ptr + 1; - if(reset) { - reset = FALSE; - pop3c->preftype = POP3_TYPE_NONE; - pop3c->prefmech = SASL_AUTH_NONE; - } + while(*ptr && *ptr != ';') + ptr++; - while(*ptr && *ptr != ';') { - ptr++; - len++; - } + if(strnequal(key, "AUTH=", 5)) { + result = Curl_sasl_parse_url_auth_option(&pop3c->sasl, + value, ptr - value); - if(strnequal(value, "*", len)) { - pop3c->preftype = POP3_TYPE_ANY; - pop3c->prefmech = SASL_AUTH_ANY; - } - else if(strnequal(value, "+APOP", len)) { + if(result && strnequal(value, "+APOP", ptr - value)) { pop3c->preftype = POP3_TYPE_APOP; - pop3c->prefmech = SASL_AUTH_NONE; - } - else if(strnequal(value, SASL_MECH_STRING_LOGIN, len)) { - pop3c->preftype = POP3_TYPE_SASL; - pop3c->prefmech |= SASL_MECH_LOGIN; - } - else if(strnequal(value, SASL_MECH_STRING_PLAIN, len)) { - pop3c->preftype = POP3_TYPE_SASL; - pop3c->prefmech |= SASL_MECH_PLAIN; - } - else if(strnequal(value, SASL_MECH_STRING_CRAM_MD5, len)) { - pop3c->preftype = POP3_TYPE_SASL; - pop3c->prefmech |= SASL_MECH_CRAM_MD5; - } - else if(strnequal(value, SASL_MECH_STRING_DIGEST_MD5, len)) { - pop3c->preftype = POP3_TYPE_SASL; - pop3c->prefmech |= SASL_MECH_DIGEST_MD5; - } - else if(strnequal(value, SASL_MECH_STRING_GSSAPI, len)) { - pop3c->preftype = POP3_TYPE_SASL; - pop3c->prefmech |= SASL_MECH_GSSAPI; - } - else if(strnequal(value, SASL_MECH_STRING_NTLM, len)) { - pop3c->preftype = POP3_TYPE_SASL; - pop3c->prefmech |= SASL_MECH_NTLM; - } - else if(strnequal(value, SASL_MECH_STRING_XOAUTH2, len)) { - pop3c->preftype = POP3_TYPE_SASL; - pop3c->prefmech |= SASL_MECH_XOAUTH2; + pop3c->sasl.prefmech = SASL_AUTH_NONE; + result = CURLE_OK; } - - if(*ptr == ';') - ptr++; } else result = CURLE_URL_MALFORMAT; + + if(*ptr == ';') + ptr++; } + if(pop3c->preftype != POP3_TYPE_APOP) + switch(pop3c->sasl.prefmech) { + case SASL_AUTH_NONE: + pop3c->preftype = POP3_TYPE_NONE; + break; + case SASL_AUTH_DEFAULT: + pop3c->preftype = POP3_TYPE_ANY; + break; + default: + pop3c->preftype = POP3_TYPE_SASL; + break; + } + return result; } @@ -2106,110 +1472,6 @@ static CURLcode pop3_parse_custom_request(struct connectdata *conn) /*********************************************************************** * - * pop3_calc_sasl_details() - * - * Calculate the required login details for SASL authentication. - */ -static CURLcode pop3_calc_sasl_details(struct connectdata *conn, - const char **mech, - char **initresp, size_t *len, - pop3state *state1, pop3state *state2) -{ - CURLcode result = CURLE_OK; - struct SessionHandle *data = conn->data; - struct pop3_conn *pop3c = &conn->proto.pop3c; - - /* Calculate the supported authentication mechanism, by decreasing order of - security, as well as the initial response where appropriate */ -#if defined(USE_WINDOWS_SSPI) - if((pop3c->authmechs & SASL_MECH_GSSAPI) && - (pop3c->prefmech & SASL_MECH_GSSAPI)) { - pop3c->mutual_auth = FALSE; /* TODO: Calculate mutual authentication */ - - *mech = SASL_MECH_STRING_GSSAPI; - *state1 = POP3_AUTH_GSSAPI; - *state2 = POP3_AUTH_GSSAPI_TOKEN; - pop3c->authused = SASL_MECH_GSSAPI; - - if(data->set.sasl_ir) - result = Curl_sasl_create_gssapi_user_message(data, conn->user, - conn->passwd, "pop", - pop3c->mutual_auth, - NULL, &conn->krb5, - initresp, len); - } - else -#endif -#ifndef CURL_DISABLE_CRYPTO_AUTH - if((pop3c->authmechs & SASL_MECH_DIGEST_MD5) && - (pop3c->prefmech & SASL_MECH_DIGEST_MD5)) { - *mech = SASL_MECH_STRING_DIGEST_MD5; - *state1 = POP3_AUTH_DIGESTMD5; - pop3c->authused = SASL_MECH_DIGEST_MD5; - } - else if((pop3c->authmechs & SASL_MECH_CRAM_MD5) && - (pop3c->prefmech & SASL_MECH_CRAM_MD5)) { - *mech = SASL_MECH_STRING_CRAM_MD5; - *state1 = POP3_AUTH_CRAMMD5; - pop3c->authused = SASL_MECH_CRAM_MD5; - } - else -#endif -#ifdef USE_NTLM - if((pop3c->authmechs & SASL_MECH_NTLM) && - (pop3c->prefmech & SASL_MECH_NTLM)) { - *mech = SASL_MECH_STRING_NTLM; - *state1 = POP3_AUTH_NTLM; - *state2 = POP3_AUTH_NTLM_TYPE2MSG; - pop3c->authused = SASL_MECH_NTLM; - - if(data->set.sasl_ir) - result = Curl_sasl_create_ntlm_type1_message(conn->user, conn->passwd, - &conn->ntlm, - initresp, len); - } - else -#endif - if(((pop3c->authmechs & SASL_MECH_XOAUTH2) && - (pop3c->prefmech & SASL_MECH_XOAUTH2) && - (pop3c->prefmech != SASL_AUTH_ANY)) || conn->xoauth2_bearer) { - *mech = SASL_MECH_STRING_XOAUTH2; - *state1 = POP3_AUTH_XOAUTH2; - *state2 = POP3_AUTH_FINAL; - pop3c->authused = SASL_MECH_XOAUTH2; - - if(data->set.sasl_ir) - result = Curl_sasl_create_xoauth2_message(data, conn->user, - conn->xoauth2_bearer, - initresp, len); - } - else if((pop3c->authmechs & SASL_MECH_LOGIN) && - (pop3c->prefmech & SASL_MECH_LOGIN)) { - *mech = SASL_MECH_STRING_LOGIN; - *state1 = POP3_AUTH_LOGIN; - *state2 = POP3_AUTH_LOGIN_PASSWD; - pop3c->authused = SASL_MECH_LOGIN; - - if(data->set.sasl_ir) - result = Curl_sasl_create_login_message(data, conn->user, initresp, len); - } - else if((pop3c->authmechs & SASL_MECH_PLAIN) && - (pop3c->prefmech & SASL_MECH_PLAIN)) { - *mech = SASL_MECH_STRING_PLAIN; - *state1 = POP3_AUTH_PLAIN; - *state2 = POP3_AUTH_FINAL; - pop3c->authused = SASL_MECH_PLAIN; - - if(data->set.sasl_ir) - result = Curl_sasl_create_plain_message(data, conn->user, conn->passwd, - initresp, len); - } - - return result; -} - -/*********************************************************************** - * * Curl_pop3_write() * * This function scans the body after the end-of-body and writes everything diff --git a/lib/pop3.h b/lib/pop3.h index 729a55a..7bc53aa 100644 --- a/lib/pop3.h +++ b/lib/pop3.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 2009 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 2009 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -23,6 +23,7 @@ ***************************************************************************/ #include "pingpong.h" +#include "curl_sasl.h" /**************************************************************************** * POP3 unique setup @@ -35,20 +36,7 @@ typedef enum { POP3_STARTTLS, POP3_UPGRADETLS, /* asynchronously upgrade the connection to SSL/TLS (multi mode only) */ - POP3_AUTH_PLAIN, - POP3_AUTH_LOGIN, - POP3_AUTH_LOGIN_PASSWD, - POP3_AUTH_CRAMMD5, - POP3_AUTH_DIGESTMD5, - POP3_AUTH_DIGESTMD5_RESP, - POP3_AUTH_NTLM, - POP3_AUTH_NTLM_TYPE2MSG, - POP3_AUTH_GSSAPI, - POP3_AUTH_GSSAPI_TOKEN, - POP3_AUTH_GSSAPI_NO_DATA, - POP3_AUTH_XOAUTH2, - POP3_AUTH_CANCEL, - POP3_AUTH_FINAL, + POP3_AUTH, POP3_APOP, POP3_USER, POP3_PASS, @@ -77,14 +65,11 @@ struct pop3_conn { have been received so far */ size_t strip; /* Number of bytes from the start to ignore as non-body */ + struct SASL sasl; /* SASL-related storage */ unsigned int authtypes; /* Accepted authentication types */ - unsigned int authmechs; /* Accepted SASL authentication mechanisms */ unsigned int preftype; /* Preferred authentication type */ - unsigned int prefmech; /* Preferred SASL authentication mechanism */ - unsigned int authused; /* SASL auth mechanism used for the connection */ char *apoptimestamp; /* APOP timestamp from the server greeting */ bool tls_supported; /* StartTLS capability supported by server */ - bool mutual_auth; /* Mutual authentication enabled (GSSAPI only) */ }; extern const struct Curl_handler Curl_handler_pop3; diff --git a/lib/progress.c b/lib/progress.c index f147ce7..b46e274 100644 --- a/lib/progress.c +++ b/lib/progress.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -25,9 +25,7 @@ #include "urldata.h" #include "sendf.h" #include "progress.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include +#include "curl_printf.h" /* Provide a string that is 2 + 1 + 2 + 1 + 2 = 8 letters long (plus the zero byte) */ diff --git a/lib/rtsp.c b/lib/rtsp.c index 029738d..c30afd3 100644 --- a/lib/rtsp.c +++ b/lib/rtsp.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -34,14 +34,12 @@ #include "progress.h" #include "rtsp.h" #include "rawstr.h" -#include "curl_memory.h" #include "select.h" #include "connect.h" +#include "curl_printf.h" -#define _MPRINTF_REPLACE /* use our functions only */ -#include - -/* The last #include file should be: */ +/* The last #include files should be: */ +#include "curl_memory.h" #include "memdebug.h" /* @@ -265,11 +263,10 @@ static CURLcode rtsp_do(struct connectdata *conn, bool *done) * Since all RTSP requests are included here, there is no need to * support custom requests like HTTP. **/ - DEBUGASSERT((rtspreq > RTSPREQ_NONE && rtspreq < RTSPREQ_LAST)); data->set.opt_no_body = TRUE; /* most requests don't contain a body */ switch(rtspreq) { - case RTSPREQ_NONE: - failf(data, "Got invalid RTSP request: RTSPREQ_NONE"); + default: + failf(data, "Got invalid RTSP request"); return CURLE_BAD_FUNCTION_ARGUMENT; case RTSPREQ_OPTIONS: p_request = "OPTIONS"; @@ -325,7 +322,7 @@ static CURLcode rtsp_do(struct connectdata *conn, bool *done) if(!p_session_id && (rtspreq & ~(RTSPREQ_OPTIONS | RTSPREQ_DESCRIBE | RTSPREQ_SETUP))) { failf(data, "Refusing to issue an RTSP request [%s] without a session ID.", - p_request ? p_request : ""); + p_request); return CURLE_BAD_FUNCTION_ARGUMENT; } @@ -443,8 +440,7 @@ static CURLcode rtsp_do(struct connectdata *conn, bool *done) Curl_add_bufferf(req_buffer, "%s %s RTSP/1.0\r\n" /* Request Stream-URI RTSP/1.0 */ "CSeq: %ld\r\n", /* CSeq */ - (p_request ? p_request : ""), p_stream_uri, - rtsp->CSeq_sent); + p_request, p_stream_uri, rtsp->CSeq_sent); if(result) return result; @@ -498,8 +494,8 @@ static CURLcode rtsp_do(struct connectdata *conn, bool *done) } else { - postsize = (data->set.postfieldsize != -1)? - data->set.postfieldsize: + postsize = (data->state.infilesize != -1)? + data->state.infilesize: (data->set.postfields? (curl_off_t)strlen(data->set.postfields):0); data->set.httpreq = HTTPREQ_POST; } diff --git a/lib/security.c b/lib/security.c index 508c7b4..014bbf1 100644 --- a/lib/security.c +++ b/lib/security.c @@ -7,10 +7,10 @@ * rewrite to work around the paragraph 2 in the BSD licenses as explained * below. * - * Copyright (c) 1998, 1999, 2013 Kungliga Tekniska H?gskolan + * Copyright (c) 1998, 1999 Kungliga Tekniska H?gskolan * (Royal Institute of Technology, Stockholm, Sweden). * - * Copyright (C) 2001 - 2013, Daniel Stenberg, , et al. + * Copyright (C) 2001 - 2015, Daniel Stenberg, , et al. * * All rights reserved. * @@ -109,19 +109,12 @@ static char level_to_char(int level) { return 'P'; } -static const struct Curl_sec_client_mech * const mechs[] = { -#ifdef HAVE_GSSAPI - &Curl_krb5_client_mech, -#endif - NULL -}; - /* Send an FTP command defined by |message| and the optional arguments. The function returns the ftp_code. If an error occurs, -1 is returned. */ static int ftp_send_command(struct connectdata *conn, const char *message, ...) { int ftp_code; - ssize_t nread; + ssize_t nread=0; va_list args; char print_buffer[50]; @@ -129,11 +122,11 @@ static int ftp_send_command(struct connectdata *conn, const char *message, ...) vsnprintf(print_buffer, sizeof(print_buffer), message, args); va_end(args); - if(Curl_ftpsendf(conn, print_buffer) != CURLE_OK) { + if(Curl_ftpsendf(conn, print_buffer)) { ftp_code = -1; } else { - if(Curl_GetFTPResponse(&nread, conn, &ftp_code) != CURLE_OK) + if(Curl_GetFTPResponse(&nread, conn, &ftp_code)) ftp_code = -1; } @@ -147,20 +140,20 @@ static CURLcode socket_read(curl_socket_t fd, void *to, size_t len) { char *to_p = to; - CURLcode code; + CURLcode result; ssize_t nread; while(len > 0) { - code = Curl_read_plain(fd, to_p, len, &nread); - if(code == CURLE_OK) { + result = Curl_read_plain(fd, to_p, len, &nread); + if(!result) { len -= nread; to_p += nread; } else { /* FIXME: We are doing a busy wait */ - if(code == CURLE_AGAIN) + if(result == CURLE_AGAIN) continue; - return code; + return result; } } return CURLE_OK; @@ -175,20 +168,20 @@ socket_write(struct connectdata *conn, curl_socket_t fd, const void *to, size_t len) { const char *to_p = to; - CURLcode code; + CURLcode result; ssize_t written; while(len > 0) { - code = Curl_write_plain(conn, fd, to_p, len, &written); - if(code == CURLE_OK) { + result = Curl_write_plain(conn, fd, to_p, len, &written); + if(!result) { len -= written; to_p += written; } else { /* FIXME: We are doing a busy wait */ - if(code == CURLE_AGAIN) + if(result == CURLE_AGAIN) continue; - return code; + return result; } } return CURLE_OK; @@ -200,11 +193,11 @@ static CURLcode read_data(struct connectdata *conn, { int len; void* tmp; - CURLcode ret; + CURLcode result; - ret = socket_read(fd, &len, sizeof(len)); - if(ret != CURLE_OK) - return ret; + result = socket_read(fd, &len, sizeof(len)); + if(result) + return result; len = ntohl(len); tmp = realloc(buf->data, len); @@ -212,9 +205,9 @@ static CURLcode read_data(struct connectdata *conn, return CURLE_OUT_OF_MEMORY; buf->data = tmp; - ret = socket_read(fd, buf->data, len); - if(ret != CURLE_OK) - return ret; + result = socket_read(fd, buf->data, len); + if(result) + return result; buf->size = conn->mech->decode(conn->app_data, buf->data, len, conn->data_prot, conn); buf->index = 0; @@ -256,7 +249,7 @@ static ssize_t sec_recv(struct connectdata *conn, int sockindex, buffer += bytes_read; while(len > 0) { - if(read_data(conn, fd, &conn->in_buffer) != CURLE_OK) + if(read_data(conn, fd, &conn->in_buffer)) return -1; if(conn->in_buffer.size == 0) { if(bytes_read > 0) @@ -295,7 +288,7 @@ static void do_sec_send(struct connectdata *conn, curl_socket_t fd, prot_level = conn->command_prot; } bytes = conn->mech->encode(conn->app_data, from, length, prot_level, - (void**)&buffer, conn); + (void**)&buffer); if(!buffer || bytes <= 0) return; /* error */ @@ -332,7 +325,6 @@ static void do_sec_send(struct connectdata *conn, curl_socket_t fd, static ssize_t sec_write(struct connectdata *conn, curl_socket_t fd, const char *buffer, size_t length) { - /* FIXME: Check for overflow */ ssize_t tx = 0, len = conn->buffer_size; len -= conn->mech->overhead(conn->app_data, conn->data_prot, @@ -340,10 +332,9 @@ static ssize_t sec_write(struct connectdata *conn, curl_socket_t fd, if(len <= 0) len = length; while(length) { - if(len >= 0 || length < (size_t)len) { - /* FIXME: Check for overflow. */ + if(length < (size_t)len) len = length; - } + do_sec_send(conn, fd, buffer, curlx_sztosi(len)); length -= len; buffer += len; @@ -368,7 +359,7 @@ int Curl_sec_read_msg(struct connectdata *conn, char *buffer, int */ int decoded_len; char *buf; - int ret_code; + int ret_code = 0; size_t decoded_sz = 0; CURLcode error; @@ -397,13 +388,13 @@ int Curl_sec_read_msg(struct connectdata *conn, char *buffer, } buf[decoded_len] = '\0'; - DEBUGASSERT(decoded_len > 3); - if(buf[3] == '-') - ret_code = 0; - else { - /* Check for error? */ - sscanf(buf, "%d", &ret_code); - } + if(decoded_len <= 3) + /* suspiciously short */ + return 0; + + if(buf[3] != '-') + /* safe to ignore return code */ + (void)sscanf(buf, "%d", &ret_code); if(buf[decoded_len - 1] == '\n') buf[decoded_len - 1] = '\0'; @@ -446,8 +437,8 @@ static int sec_set_protection_level(struct connectdata *conn) pbsz = strstr(conn->data->state.buffer, "PBSZ="); if(pbsz) { - /* FIXME: Checks for errors in sscanf? */ - sscanf(pbsz, "PBSZ=%u", &buffer_size); + /* ignore return code, use default value if it fails */ + (void)sscanf(pbsz, "PBSZ=%u", &buffer_size); if(buffer_size < conn->buffer_size) conn->buffer_size = buffer_size; } @@ -486,72 +477,63 @@ static CURLcode choose_mech(struct connectdata *conn) { int ret; struct SessionHandle *data = conn->data; - const struct Curl_sec_client_mech * const *mech; void *tmp_allocation; - const char *mech_name; - - for(mech = mechs; (*mech); ++mech) { - mech_name = (*mech)->name; - /* We have no mechanism with a NULL name but keep this check */ - DEBUGASSERT(mech_name != NULL); - if(mech_name == NULL) { - infof(data, "Skipping mechanism with empty name (%p)\n", (void *)mech); - continue; - } - tmp_allocation = realloc(conn->app_data, (*mech)->size); - if(tmp_allocation == NULL) { - failf(data, "Failed realloc of size %u", (*mech)->size); - mech = NULL; - return CURLE_OUT_OF_MEMORY; - } - conn->app_data = tmp_allocation; + const struct Curl_sec_client_mech *mech = &Curl_krb5_client_mech; - if((*mech)->init) { - ret = (*mech)->init(conn->app_data); - if(ret != 0) { - infof(data, "Failed initialization for %s. Skipping it.\n", mech_name); - continue; - } + tmp_allocation = realloc(conn->app_data, mech->size); + if(tmp_allocation == NULL) { + failf(data, "Failed realloc of size %u", mech->size); + mech = NULL; + return CURLE_OUT_OF_MEMORY; + } + conn->app_data = tmp_allocation; + + if(mech->init) { + ret = mech->init(conn->app_data); + if(ret) { + infof(data, "Failed initialization for %s. Skipping it.\n", + mech->name); + return CURLE_FAILED_INIT; } + } - infof(data, "Trying mechanism %s...\n", mech_name); - ret = ftp_send_command(conn, "AUTH %s", mech_name); - if(ret < 0) - /* FIXME: This error is too generic but it is OK for now. */ - return CURLE_COULDNT_CONNECT; - - if(ret/100 != 3) { - switch(ret) { - case 504: - infof(data, "Mechanism %s is not supported by the server (server " - "returned ftp code: 504).\n", mech_name); - break; - case 534: - infof(data, "Mechanism %s was rejected by the server (server returned " - "ftp code: 534).\n", mech_name); - break; - default: - if(ret/100 == 5) { - infof(data, "server does not support the security extensions\n"); - return CURLE_USE_SSL_FAILED; - } - break; + infof(data, "Trying mechanism %s...\n", mech->name); + ret = ftp_send_command(conn, "AUTH %s", mech->name); + if(ret < 0) + /* FIXME: This error is too generic but it is OK for now. */ + return CURLE_COULDNT_CONNECT; + + if(ret/100 != 3) { + switch(ret) { + case 504: + infof(data, "Mechanism %s is not supported by the server (server " + "returned ftp code: 504).\n", mech->name); + break; + case 534: + infof(data, "Mechanism %s was rejected by the server (server returned " + "ftp code: 534).\n", mech->name); + break; + default: + if(ret/100 == 5) { + infof(data, "server does not support the security extensions\n"); + return CURLE_USE_SSL_FAILED; } - continue; + break; } + return CURLE_LOGIN_DENIED; + } - /* Authenticate */ - ret = (*mech)->auth(conn->app_data, conn); + /* Authenticate */ + ret = mech->auth(conn->app_data, conn); - if(ret == AUTH_CONTINUE) - continue; - else if(ret != AUTH_OK) { + if(ret != AUTH_CONTINUE) { + if(ret != AUTH_OK) { /* Mechanism has dumped the error to stderr, don't error here. */ return -1; } DEBUGASSERT(ret == AUTH_OK); - conn->mech = *mech; + conn->mech = mech; conn->sec_complete = 1; conn->recv[FIRSTSOCKET] = sec_recv; conn->send[FIRSTSOCKET] = sec_send; @@ -561,10 +543,9 @@ static CURLcode choose_mech(struct connectdata *conn) /* Set the requested protection level */ /* BLOCKING */ (void)sec_set_protection_level(conn); - break; } - return mech != NULL ? CURLE_OK : CURLE_FAILED_INIT; + return CURLE_OK; } CURLcode @@ -579,10 +560,8 @@ Curl_sec_end(struct connectdata *conn) { if(conn->mech != NULL && conn->mech->end) conn->mech->end(conn->app_data); - if(conn->app_data) { - free(conn->app_data); - conn->app_data = NULL; - } + free(conn->app_data); + conn->app_data = NULL; if(conn->in_buffer.data) { free(conn->in_buffer.data); conn->in_buffer.data = NULL; diff --git a/lib/select.c b/lib/select.c index bb9b8b0..24dc5fd 100644 --- a/lib/select.c +++ b/lib/select.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -39,6 +39,10 @@ #include /* delay() */ #endif +#ifdef __VXWORKS__ +#include /* bzero() in FD_SET */ +#endif + #include #include "urldata.h" @@ -155,7 +159,7 @@ int Curl_socket_check(curl_socket_t readfd0, /* two sockets to read from */ fd_set fds_err; curl_socket_t maxfd; #endif - struct timeval initial_tv = {0,0}; + struct timeval initial_tv = {0, 0}; int pending_ms = 0; int error; int r; @@ -389,7 +393,7 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms) fd_set fds_err; curl_socket_t maxfd; #endif - struct timeval initial_tv = {0,0}; + struct timeval initial_tv = {0, 0}; bool fds_none = TRUE; unsigned int i; int pending_ms = 0; @@ -569,6 +573,6 @@ int tpf_select_libcurl(int maxfds, fd_set* reads, fd_set* writes, rc = tpf_select_bsd(maxfds, reads, writes, excepts, tv); tpf_process_signals(); - return(rc); + return rc; } #endif /* TPF */ diff --git a/lib/sendf.c b/lib/sendf.c index 4a87c79..5f39d1f 100644 --- a/lib/sendf.c +++ b/lib/sendf.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -31,14 +31,11 @@ #include "ssh.h" #include "multiif.h" #include "non-ascii.h" - -#define _MPRINTF_REPLACE /* use the internal *printf() functions */ -#include - -#include "curl_memory.h" +#include "curl_printf.h" #include "strerror.h" -/* The last #include file should be: */ +/* The last #include files should be: */ +#include "curl_memory.h" #include "memdebug.h" #ifdef CURL_DO_LINEEND_CONV @@ -55,7 +52,7 @@ static size_t convert_lineends(struct SessionHandle *data, /* sanity check */ if((startPtr == NULL) || (size < 1)) { - return(size); + return size; } if(data->state.prev_block_had_trailing_cr) { @@ -117,9 +114,9 @@ static size_t convert_lineends(struct SessionHandle *data, /* tidy up by null terminating the now shorter data */ *outPtr = '\0'; - return(outPtr - startPtr); + return (outPtr - startPtr); } - return(size); + return size; } #endif /* CURL_DO_LINEEND_CONV */ @@ -174,7 +171,7 @@ CURLcode Curl_sendf(curl_socket_t sockfd, struct connectdata *conn, struct SessionHandle *data = conn->data; ssize_t bytes_written; size_t write_len; - CURLcode res = CURLE_OK; + CURLcode result = CURLE_OK; char *s; char *sptr; va_list ap; @@ -190,9 +187,9 @@ CURLcode Curl_sendf(curl_socket_t sockfd, struct connectdata *conn, for(;;) { /* Write the buffer to the socket */ - res = Curl_write(conn, sockfd, sptr, write_len, &bytes_written); + result = Curl_write(conn, sockfd, sptr, write_len, &bytes_written); - if(CURLE_OK != res) + if(result) break; if(data->set.verbose) @@ -210,7 +207,7 @@ CURLcode Curl_sendf(curl_socket_t sockfd, struct connectdata *conn, free(s); /* free the output string */ - return res; + return result; } /* @@ -227,10 +224,10 @@ CURLcode Curl_write(struct connectdata *conn, ssize_t *written) { ssize_t bytes_written; - CURLcode curlcode = CURLE_OK; + CURLcode result = CURLE_OK; int num = (sockfd == conn->sock[SECONDARYSOCKET]); - bytes_written = conn->send[num](conn, num, mem, len, &curlcode); + bytes_written = conn->send[num](conn, num, mem, len, &result); *written = bytes_written; if(bytes_written >= 0) @@ -238,7 +235,7 @@ CURLcode Curl_write(struct connectdata *conn, return CURLE_OK; /* handle CURLE_AGAIN or a send failure */ - switch(curlcode) { + switch(result) { case CURLE_AGAIN: *written = 0; return CURLE_OK; @@ -249,7 +246,7 @@ CURLcode Curl_write(struct connectdata *conn, default: /* we got a specific curlcode, forward it */ - return curlcode; + return result; } } @@ -300,14 +297,14 @@ CURLcode Curl_write_plain(struct connectdata *conn, ssize_t *written) { ssize_t bytes_written; - CURLcode retcode; + CURLcode result; int num = (sockfd == conn->sock[SECONDARYSOCKET]); - bytes_written = Curl_send_plain(conn, num, mem, len, &retcode); + bytes_written = Curl_send_plain(conn, num, mem, len, &result); *written = bytes_written; - return retcode; + return result; } ssize_t Curl_recv_plain(struct connectdata *conn, int num, char *buf, @@ -374,25 +371,21 @@ static CURLcode pausewrite(struct SessionHandle *data, } -/* Curl_client_write() sends data to the write callback(s) - - The bit pattern defines to what "streams" to write to. Body and/or header. - The defines are in sendf.h of course. - - If CURL_DO_LINEEND_CONV is enabled, data is converted IN PLACE to the - local character encoding. This is a problem and should be changed in - the future to leave the original data alone. +/* Curl_client_chop_write() writes chunks of data not larger than + * CURL_MAX_WRITE_SIZE via client write callback(s) and + * takes care of pause requests from the callbacks. */ -CURLcode Curl_client_write(struct connectdata *conn, - int type, - char *ptr, - size_t len) +CURLcode Curl_client_chop_write(struct connectdata *conn, + int type, + char * ptr, + size_t len) { struct SessionHandle *data = conn->data; - size_t wrote; + curl_write_callback writeheader = NULL; + curl_write_callback writebody = NULL; - if(0 == len) - len = strlen(ptr); + if(!len) + return CURLE_OK; /* If reading is actually paused, we're forced to append this chunk of data to the already held data, but only if it is the same type as otherwise it @@ -417,78 +410,107 @@ CURLcode Curl_client_write(struct connectdata *conn, /* update the pointer and the size */ data->state.tempwrite = newptr; data->state.tempwritesize = newlen; - return CURLE_OK; } - if(type & CLIENTWRITE_BODY) { - if((conn->handler->protocol&PROTO_FAMILY_FTP) && - conn->proto.ftpc.transfertype == 'A') { - /* convert from the network encoding */ - CURLcode rc = Curl_convert_from_network(data, ptr, len); - /* Curl_convert_from_network calls failf if unsuccessful */ - if(rc) - return rc; + /* Determine the callback(s) to use. */ + if(type & CLIENTWRITE_BODY) + writebody = data->set.fwrite_func; + if((type & CLIENTWRITE_HEADER) && + (data->set.fwrite_header || data->set.writeheader)) { + /* + * Write headers to the same callback or to the especially setup + * header callback function (added after version 7.7.1). + */ + writeheader = + data->set.fwrite_header? data->set.fwrite_header: data->set.fwrite_func; + } -#ifdef CURL_DO_LINEEND_CONV - /* convert end-of-line markers */ - len = convert_lineends(data, ptr, len); -#endif /* CURL_DO_LINEEND_CONV */ - } - /* If the previous block of data ended with CR and this block of data is - just a NL, then the length might be zero */ - if(len) { - wrote = data->set.fwrite_func(ptr, 1, len, data->set.out); - } - else { - wrote = len; - } + /* Chop data, write chunks. */ + while(len) { + size_t chunklen = len <= CURL_MAX_WRITE_SIZE? len: CURL_MAX_WRITE_SIZE; + + if(writebody) { + size_t wrote = writebody(ptr, 1, chunklen, data->set.out); - if(CURL_WRITEFUNC_PAUSE == wrote) { - if(conn->handler->flags & PROTOPT_NONETWORK) { - /* Protocols that work without network cannot be paused. This is - actually only FILE:// just now, and it can't pause since the - transfer isn't done using the "normal" procedure. */ - failf(data, "Write callback asked for PAUSE when not supported!"); + if(CURL_WRITEFUNC_PAUSE == wrote) { + if(conn->handler->flags & PROTOPT_NONETWORK) { + /* Protocols that work without network cannot be paused. This is + actually only FILE:// just now, and it can't pause since the + transfer isn't done using the "normal" procedure. */ + failf(data, "Write callback asked for PAUSE when not supported!"); + return CURLE_WRITE_ERROR; + } + else + return pausewrite(data, type, ptr, len); + } + else if(wrote != chunklen) { + failf(data, "Failed writing body (%zu != %zu)", wrote, chunklen); return CURLE_WRITE_ERROR; } - else - return pausewrite(data, type, ptr, len); } - else if(wrote != len) { - failf(data, "Failed writing body (%zu != %zu)", wrote, len); - return CURLE_WRITE_ERROR; - } - } - if((type & CLIENTWRITE_HEADER) && - (data->set.fwrite_header || data->set.writeheader) ) { - /* - * Write headers to the same callback or to the especially setup - * header callback function (added after version 7.7.1). - */ - curl_write_callback writeit= - data->set.fwrite_header?data->set.fwrite_header:data->set.fwrite_func; - - /* Note: The header is in the host encoding - regardless of the ftp transfer mode (ASCII/Image) */ - - wrote = writeit(ptr, 1, len, data->set.writeheader); - if(CURL_WRITEFUNC_PAUSE == wrote) - /* here we pass in the HEADER bit only since if this was body as well - then it was passed already and clearly that didn't trigger the pause, - so this is saved for later with the HEADER bit only */ - return pausewrite(data, CLIENTWRITE_HEADER, ptr, len); - - if(wrote != len) { - failf (data, "Failed writing header"); - return CURLE_WRITE_ERROR; + if(writeheader) { + size_t wrote = writeheader(ptr, 1, chunklen, data->set.writeheader); + + if(CURL_WRITEFUNC_PAUSE == wrote) + /* here we pass in the HEADER bit only since if this was body as well + then it was passed already and clearly that didn't trigger the + pause, so this is saved for later with the HEADER bit only */ + return pausewrite(data, CLIENTWRITE_HEADER, ptr, len); + + if(wrote != chunklen) { + failf (data, "Failed writing header"); + return CURLE_WRITE_ERROR; + } } + + ptr += chunklen; + len -= chunklen; } return CURLE_OK; } + +/* Curl_client_write() sends data to the write callback(s) + + The bit pattern defines to what "streams" to write to. Body and/or header. + The defines are in sendf.h of course. + + If CURL_DO_LINEEND_CONV is enabled, data is converted IN PLACE to the + local character encoding. This is a problem and should be changed in + the future to leave the original data alone. + */ +CURLcode Curl_client_write(struct connectdata *conn, + int type, + char *ptr, + size_t len) +{ + struct SessionHandle *data = conn->data; + + if(0 == len) + len = strlen(ptr); + + /* FTP data may need conversion. */ + if((type & CLIENTWRITE_BODY) && + (conn->handler->protocol & PROTO_FAMILY_FTP) && + conn->proto.ftpc.transfertype == 'A') { + /* convert from the network encoding */ + CURLcode result = Curl_convert_from_network(data, ptr, len); + /* Curl_convert_from_network calls failf if unsuccessful */ + if(result) + return result; + +#ifdef CURL_DO_LINEEND_CONV + /* convert end-of-line markers */ + len = convert_lineends(data, ptr, len); +#endif /* CURL_DO_LINEEND_CONV */ + } + + return Curl_client_chop_write(conn, type, ptr, len); +} + CURLcode Curl_read_plain(curl_socket_t sockfd, char *buf, size_t bytesfromsocket, @@ -525,11 +547,11 @@ CURLcode Curl_read(struct connectdata *conn, /* connection data */ size_t sizerequested, /* max amount to read */ ssize_t *n) /* amount bytes read */ { - CURLcode curlcode = CURLE_RECV_ERROR; + CURLcode result = CURLE_RECV_ERROR; ssize_t nread = 0; size_t bytesfromsocket = 0; char *buffertofill = NULL; - bool pipelining = Curl_multi_pipeline_enabled(conn->data->multi); + bool pipelining = Curl_pipeline_wanted(conn->data->multi, CURLPIPE_HTTP1); /* Set 'num' to 0 or 1, depending on which socket that has been sent here. If it is the second socket, we set num to 1. Otherwise to 0. This lets @@ -564,9 +586,9 @@ CURLcode Curl_read(struct connectdata *conn, /* connection data */ buffertofill = buf; } - nread = conn->recv[num](conn, num, buffertofill, bytesfromsocket, &curlcode); + nread = conn->recv[num](conn, num, buffertofill, bytesfromsocket, &result); if(nread < 0) - return curlcode; + return result; if(pipelining) { memcpy(buf, conn->master_buffer, nread); @@ -661,11 +683,13 @@ int Curl_debug(struct SessionHandle *data, curl_infotype type, switch (type) { case CURLINFO_HEADER_IN: w = "Header"; + /* FALLTHROUGH */ case CURLINFO_DATA_IN: t = "from"; break; case CURLINFO_HEADER_OUT: w = "Header"; + /* FALLTHROUGH */ case CURLINFO_DATA_OUT: t = "to"; break; diff --git a/lib/sendf.h b/lib/sendf.h index 39489e4..86f06cf 100644 --- a/lib/sendf.h +++ b/lib/sendf.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -51,8 +51,10 @@ void Curl_failf(struct SessionHandle *, const char *fmt, ...); #define CLIENTWRITE_HEADER (1<<1) #define CLIENTWRITE_BOTH (CLIENTWRITE_BODY|CLIENTWRITE_HEADER) +CURLcode Curl_client_chop_write(struct connectdata *conn, int type, char *ptr, + size_t len) WARN_UNUSED_RESULT; CURLcode Curl_client_write(struct connectdata *conn, int type, char *ptr, - size_t len); + size_t len) WARN_UNUSED_RESULT; /* internal read-function, does plain socket only */ CURLcode Curl_read_plain(curl_socket_t sockfd, diff --git a/lib/setup-os400.h b/lib/setup-os400.h index 0331464..fae8567 100644 --- a/lib/setup-os400.h +++ b/lib/setup-os400.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2013, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -37,7 +37,6 @@ typedef unsigned long u_int32_t; #include #include -#include #include #include #include @@ -57,21 +56,6 @@ extern int Curl_getnameinfo_a(const struct sockaddr * sa, #define getnameinfo Curl_getnameinfo_a -/* SSL wrappers. */ - -extern int Curl_SSL_Init_Application_a(SSLInitApp * init_app); -#define SSL_Init_Application Curl_SSL_Init_Application_a - - -extern int Curl_SSL_Init_a(SSLInit * init); -#define SSL_Init Curl_SSL_Init_a - - -extern char * Curl_SSL_Strerror_a(int sslreturnvalue, - SSLErrorMsg * serrmsgp); -#define SSL_Strerror Curl_SSL_Strerror_a - - /* GSKit wrappers. */ extern int Curl_gsk_environment_open(gsk_handle * my_env_handle); diff --git a/lib/setup-vms.h b/lib/setup-vms.h index f5eedf7..520a35d 100644 --- a/lib/setup-vms.h +++ b/lib/setup-vms.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2013, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -203,6 +203,19 @@ char * unix_path; #define CRYPTO_cleanup_all_ex_data CRYPTO_CLEANUP_ALL_EX_DATA #define CRYPTO_free CRYPTO_FREE #define CRYPTO_malloc CRYPTO_MALLOC +#define CONF_modules_load_file CONF_MODULES_LOAD_FILE +#ifdef __VAX +# ifdef VMS_OLD_SSL + /* Ancient OpenSSL on VAX/VMS missing this constant */ +# define CONF_MFLAGS_IGNORE_MISSING_FILE 0x10 +# undef CONF_modules_load_file + static int CONF_modules_load_file(const char *filename, + const char *appname, + unsigned long flags) { + return 1; + } +# endif +#endif #define DES_ecb_encrypt DES_ECB_ENCRYPT #define DES_set_key DES_SET_KEY #define DES_set_odd_parity DES_SET_ODD_PARITY @@ -228,6 +241,7 @@ char * unix_path; #define EVP_PKEY_free EVP_PKEY_FREE #define EVP_cleanup EVP_CLEANUP #define GENERAL_NAMES_free GENERAL_NAMES_FREE +#define i2d_X509_PUBKEY I2D_X509_PUBKEY #define MD4_Final MD4_FINAL #define MD4_Init MD4_INIT #define MD4_Update MD4_UPDATE @@ -235,6 +249,9 @@ char * unix_path; #define MD5_Init MD5_INIT #define MD5_Update MD5_UPDATE #define OPENSSL_add_all_algo_noconf OPENSSL_ADD_ALL_ALGO_NOCONF +#ifndef __VAX +#define OPENSSL_load_builtin_modules OPENSSL_LOAD_BUILTIN_MODULES +#endif #define PEM_read_X509 PEM_READ_X509 #define PEM_write_bio_X509 PEM_WRITE_BIO_X509 #define PKCS12_PBE_add PKCS12_PBE_ADD @@ -258,6 +275,7 @@ char * unix_path; #define SSL_CTX_set_cipher_list SSL_CTX_SET_CIPHER_LIST #define SSL_CTX_set_def_passwd_cb_ud SSL_CTX_SET_DEF_PASSWD_CB_UD #define SSL_CTX_set_default_passwd_cb SSL_CTX_SET_DEFAULT_PASSWD_CB +#define SSL_CTX_set_msg_callback SSL_CTX_SET_MSG_CALLBACK #define SSL_CTX_set_verify SSL_CTX_SET_VERIFY #define SSL_CTX_use_PrivateKey SSL_CTX_USE_PRIVATEKEY #define SSL_CTX_use_PrivateKey_file SSL_CTX_USE_PRIVATEKEY_FILE @@ -274,6 +292,7 @@ char * unix_path; #define SSL_get_peer_cert_chain SSL_GET_PEER_CERT_CHAIN #define SSL_get_peer_certificate SSL_GET_PEER_CERTIFICATE #define SSL_get_privatekey SSL_GET_PRIVATEKEY +#define SSL_get_session SSL_GET_SESSION #define SSL_get_shutdown SSL_GET_SHUTDOWN #define SSL_get_verify_result SSL_GET_VERIFY_RESULT #define SSL_library_init SSL_LIBRARY_INIT @@ -286,14 +305,32 @@ char * unix_path; #define SSL_set_fd SSL_SET_FD #define SSL_set_session SSL_SET_SESSION #define SSL_shutdown SSL_SHUTDOWN +#define SSL_version SSL_VERSION #define SSL_write SSL_WRITE #define SSLeay SSLEAY #define SSLv23_client_method SSLV23_CLIENT_METHOD #define SSLv3_client_method SSLV3_CLIENT_METHOD #define TLSv1_client_method TLSV1_CLIENT_METHOD +#define UI_create_method UI_CREATE_METHOD +#define UI_destroy_method UI_DESTROY_METHOD +#define UI_get0_user_data UI_GET0_USER_DATA +#define UI_get_input_flags UI_GET_INPUT_FLAGS +#define UI_get_string_type UI_GET_STRING_TYPE +#define UI_create_method UI_CREATE_METHOD +#define UI_destroy_method UI_DESTROY_METHOD +#define UI_method_get_closer UI_METHOD_GET_CLOSER +#define UI_method_get_opener UI_METHOD_GET_OPENER +#define UI_method_get_reader UI_METHOD_GET_READER +#define UI_method_get_writer UI_METHOD_GET_WRITER +#define UI_method_set_closer UI_METHOD_SET_CLOSER +#define UI_method_set_opener UI_METHOD_SET_OPENER +#define UI_method_set_reader UI_METHOD_SET_READER +#define UI_method_set_writer UI_METHOD_SET_WRITER #define UI_OpenSSL UI_OPENSSL +#define UI_set_result UI_SET_RESULT #define X509V3_EXT_print X509V3_EXT_PRINT #define X509_EXTENSION_get_critical X509_EXTENSION_GET_CRITICAL +#define X509_EXTENSION_get_data X509_EXTENSION_GET_DATA #define X509_EXTENSION_get_object X509_EXTENSION_GET_OBJECT #define X509_LOOKUP_file X509_LOOKUP_FILE #define X509_NAME_ENTRY_get_data X509_NAME_ENTRY_GET_DATA @@ -318,6 +355,12 @@ char * unix_path; #define sk_pop SK_POP #define sk_pop_free SK_POP_FREE #define sk_value SK_VALUE +#ifdef __VAX +#define OPENSSL_NO_SHA256 +#endif +#define SHA256_Final SHA256_FINAL +#define SHA256_Init SHA256_INIT +#define SHA256_Update SHA256_UPDATE #define USE_UPPERCASE_GSSAPI 1 #define gss_seal GSS_SEAL @@ -383,7 +426,7 @@ char * unix_path; static void des_ecb_encrypt(const_des_cblock *input, des_cblock *output, - des_key_schedule ks,int enc) { + des_key_schedule ks, int enc) { DES_ECB_ENCRYPT(input, output, ks, enc); } #endif diff --git a/lib/share.c b/lib/share.c index b8b6bee..1720248 100644 --- a/lib/share.c +++ b/lib/share.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2013, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -35,9 +35,15 @@ CURLSH * curl_share_init(void) { struct Curl_share *share = calloc(1, sizeof(struct Curl_share)); - if(share) + if(share) { share->specifier |= (1<hostcache)) { + free(share); + return NULL; + } + } + return share; } @@ -67,11 +73,6 @@ curl_share_setopt(CURLSH *sh, CURLSHoption option, ...) share->specifier |= (1<hostcache) { - share->hostcache = Curl_mk_dnscache(); - if(!share->hostcache) - res = CURLSHE_NOMEM; - } break; case CURL_LOCK_DATA_COOKIE: @@ -115,10 +116,6 @@ curl_share_setopt(CURLSH *sh, CURLSHoption option, ...) share->specifier &= ~(1<hostcache) { - Curl_hash_destroy(share->hostcache); - share->hostcache = NULL; - } break; case CURL_LOCK_DATA_COOKIE: @@ -192,14 +189,10 @@ curl_share_cleanup(CURLSH *sh) return CURLSHE_IN_USE; } - if(share->hostcache) { - Curl_hash_destroy(share->hostcache); - share->hostcache = NULL; - } + Curl_hash_destroy(&share->hostcache); #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES) - if(share->cookies) - Curl_cookie_cleanup(share->cookies); + Curl_cookie_cleanup(share->cookies); #endif #ifdef USE_SSL diff --git a/lib/share.h b/lib/share.h index 9a5128e..8e6629b 100644 --- a/lib/share.h +++ b/lib/share.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -44,7 +44,7 @@ struct Curl_share { curl_unlock_function unlockfunc; void *clientdata; - struct curl_hash *hostcache; + struct curl_hash hostcache; #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES) struct CookieInfo *cookies; #endif diff --git a/lib/slist.c b/lib/slist.c index 3cac6ca..9c0b2a5 100644 --- a/lib/slist.c +++ b/lib/slist.c @@ -22,10 +22,10 @@ #include "curl_setup.h" -#include "curl_memory.h" #include "slist.h" -/* The last #include file should be: */ +/* The last #include files should be: */ +#include "curl_memory.h" #include "memdebug.h" /* returns last node in linked list */ diff --git a/lib/smb.c b/lib/smb.c new file mode 100644 index 0000000..d461a71 --- /dev/null +++ b/lib/smb.c @@ -0,0 +1,976 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 2014, Bill Nagel , Exacq Technologies + * Copyright (C) 2015, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ + +#include "curl_setup.h" + +#if !defined(CURL_DISABLE_SMB) && defined(USE_NTLM) && \ + (CURL_SIZEOF_CURL_OFF_T > 4) + +#if !defined(USE_WINDOWS_SSPI) || defined(USE_WIN32_CRYPTO) + +#define BUILDING_CURL_SMB_C + +#ifdef HAVE_PROCESS_H +#include +#define getpid _getpid +#endif + +#include "smb.h" +#include "urldata.h" +#include "sendf.h" +#include "multiif.h" +#include "connect.h" +#include "progress.h" +#include "transfer.h" +#include "vtls/vtls.h" +#include "curl_ntlm_core.h" +#include "escape.h" +#include "curl_endian.h" + +/* The last #include files should be: */ +#include "curl_memory.h" +#include "memdebug.h" + +/* Local API functions */ +static CURLcode smb_setup_connection(struct connectdata *conn); +static CURLcode smb_connect(struct connectdata *conn, bool *done); +static CURLcode smb_connection_state(struct connectdata *conn, bool *done); +static CURLcode smb_request_state(struct connectdata *conn, bool *done); +static CURLcode smb_done(struct connectdata *conn, CURLcode status, + bool premature); +static CURLcode smb_disconnect(struct connectdata *conn, bool dead); +static int smb_getsock(struct connectdata *conn, curl_socket_t *socks, + int numsocks); +static CURLcode smb_parse_url_path(struct connectdata *conn); + +/* + * SMB handler interface + */ +const struct Curl_handler Curl_handler_smb = { + "SMB", /* scheme */ + smb_setup_connection, /* setup_connection */ + ZERO_NULL, /* do_it */ + smb_done, /* done */ + ZERO_NULL, /* do_more */ + smb_connect, /* connect_it */ + smb_connection_state, /* connecting */ + smb_request_state, /* doing */ + smb_getsock, /* proto_getsock */ + smb_getsock, /* doing_getsock */ + ZERO_NULL, /* domore_getsock */ + ZERO_NULL, /* perform_getsock */ + smb_disconnect, /* disconnect */ + ZERO_NULL, /* readwrite */ + PORT_SMB, /* defport */ + CURLPROTO_SMB, /* protocol */ + PROTOPT_NONE /* flags */ +}; + +#ifdef USE_SSL +/* + * SMBS handler interface + */ +const struct Curl_handler Curl_handler_smbs = { + "SMBS", /* scheme */ + smb_setup_connection, /* setup_connection */ + ZERO_NULL, /* do_it */ + smb_done, /* done */ + ZERO_NULL, /* do_more */ + smb_connect, /* connect_it */ + smb_connection_state, /* connecting */ + smb_request_state, /* doing */ + smb_getsock, /* proto_getsock */ + smb_getsock, /* doing_getsock */ + ZERO_NULL, /* domore_getsock */ + ZERO_NULL, /* perform_getsock */ + smb_disconnect, /* disconnect */ + ZERO_NULL, /* readwrite */ + PORT_SMBS, /* defport */ + CURLPROTO_SMBS, /* protocol */ + PROTOPT_SSL /* flags */ +}; +#endif + +#define MAX_PAYLOAD_SIZE 0x8000 +#define MAX_MESSAGE_SIZE (MAX_PAYLOAD_SIZE + 0x1000) +#define CLIENTNAME "curl" +#define SERVICENAME "?????" + +/* Append a string to an SMB message */ +#define MSGCAT(str) \ + strcpy(p, (str)); \ + p += strlen(str); + +/* Append a null-terminated string to an SMB message */ +#define MSGCATNULL(str) \ + strcpy(p, (str)); \ + p += strlen(str) + 1; + +/* SMB is mostly little endian */ +#if (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) || \ + defined(__OS400__) +static unsigned short smb_swap16(unsigned short x) +{ + return (x << 8) | ((x >> 8) & 0xff); +} + +static unsigned int smb_swap32(unsigned int x) +{ + return (x << 24) | ((x << 8) & 0xff0000) | ((x >> 8) & 0xff00) | + ((x >> 24) & 0xff); +} + +#ifdef HAVE_LONGLONG +static unsigned long long smb_swap64(unsigned long long x) +{ + return ((unsigned long long)smb_swap32(x) << 32) | smb_swap32(x >> 32); +} +#else +static unsigned __int64 smb_swap64(unsigned __int64 x) +{ + return ((unsigned __int64)smb_swap32(x) << 32) | smb_swap32(x >> 32); +} +#endif +#else +# define smb_swap16(x) (x) +# define smb_swap32(x) (x) +# define smb_swap64(x) (x) +#endif + +/* SMB request state */ +enum smb_req_state { + SMB_REQUESTING, + SMB_TREE_CONNECT, + SMB_OPEN, + SMB_DOWNLOAD, + SMB_UPLOAD, + SMB_CLOSE, + SMB_TREE_DISCONNECT, + SMB_DONE +}; + +/* SMB request data */ +struct smb_request { + enum smb_req_state state; + char *share; + char *path; + unsigned short tid; /* Even if we connect to the same tree as another */ + unsigned short fid; /* request, the tid will be different */ + CURLcode result; +}; + +static void conn_state(struct connectdata *conn, enum smb_conn_state newstate) +{ + struct smb_conn *smb = &conn->proto.smbc; +#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS) + /* For debug purposes */ + static const char * const names[] = { + "SMB_NOT_CONNECTED", + "SMB_CONNECTING", + "SMB_NEGOTIATE", + "SMB_SETUP", + "SMB_CONNECTED", + /* LAST */ + }; + + if(smb->state != newstate) + infof(conn->data, "SMB conn %p state change from %s to %s\n", + (void *)smb, names[smb->state], names[newstate]); +#endif + + smb->state = newstate; +} + +static void request_state(struct connectdata *conn, + enum smb_req_state newstate) +{ + struct smb_request *req = conn->data->req.protop; +#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS) + /* For debug purposes */ + static const char * const names[] = { + "SMB_REQUESTING", + "SMB_TREE_CONNECT", + "SMB_OPEN", + "SMB_DOWNLOAD", + "SMB_UPLOAD", + "SMB_CLOSE", + "SMB_TREE_DISCONNECT", + "SMB_DONE", + /* LAST */ + }; + + if(req->state != newstate) + infof(conn->data, "SMB request %p state change from %s to %s\n", + (void *)req, names[req->state], names[newstate]); +#endif + + req->state = newstate; +} + +static CURLcode smb_setup_connection(struct connectdata *conn) +{ + struct smb_request *req; + + /* Initialize the request state */ + conn->data->req.protop = req = calloc(1, sizeof(struct smb_request)); + if(!req) + return CURLE_OUT_OF_MEMORY; + + /* Parse the URL path */ + return smb_parse_url_path(conn); +} + +static CURLcode smb_connect(struct connectdata *conn, bool *done) +{ + struct smb_conn *smbc = &conn->proto.smbc; + char *slash; + + (void) done; + + /* Check we have a username and password to authenticate with */ + if(!conn->bits.user_passwd) + return CURLE_LOGIN_DENIED; + + /* Initialize the connection state */ + memset(smbc, 0, sizeof(*smbc)); + smbc->state = SMB_CONNECTING; + smbc->recv_buf = malloc(MAX_MESSAGE_SIZE); + if(!smbc->recv_buf) + return CURLE_OUT_OF_MEMORY; + + /* Multiple requests are allowed with this connection */ + connkeep(conn, "SMB default"); + + /* Parse the username, domain, and password */ + slash = strchr(conn->user, '/'); + if(!slash) + slash = strchr(conn->user, '\\'); + + if(slash) { + smbc->user = slash + 1; + smbc->domain = strdup(conn->user); + if(!smbc->domain) + return CURLE_OUT_OF_MEMORY; + smbc->domain[slash - conn->user] = 0; + } + else { + smbc->user = conn->user; + smbc->domain = strdup(conn->host.name); + if(!smbc->domain) + return CURLE_OUT_OF_MEMORY; + } + + return CURLE_OK; +} + +static CURLcode smb_recv_message(struct connectdata *conn, void **msg) +{ + struct smb_conn *smbc = &conn->proto.smbc; + char *buf = smbc->recv_buf; + ssize_t bytes_read; + size_t nbt_size; + size_t msg_size; + size_t len = MAX_MESSAGE_SIZE - smbc->got; + CURLcode result; + + result = Curl_read(conn, FIRSTSOCKET, buf + smbc->got, len, &bytes_read); + if(result) + return result; + + if(!bytes_read) + return CURLE_OK; + + smbc->got += bytes_read; + + /* Check for a 32-bit nbt header */ + if(smbc->got < sizeof(unsigned int)) + return CURLE_OK; + + nbt_size = Curl_read16_be((unsigned char *)(buf + sizeof(unsigned short))) + + sizeof(unsigned int); + if(smbc->got < nbt_size) + return CURLE_OK; + + msg_size = sizeof(struct smb_header); + if(nbt_size >= msg_size + 1) { + /* Add the word count */ + msg_size += 1 + ((unsigned char) buf[msg_size]) * sizeof(unsigned short); + if(nbt_size >= msg_size + sizeof(unsigned short)) { + /* Add the byte count */ + msg_size += sizeof(unsigned short) + + Curl_read16_le((unsigned char *)&buf[msg_size]); + if(nbt_size < msg_size) + return CURLE_READ_ERROR; + } + } + + *msg = buf; + + return CURLE_OK; +} + +static void smb_pop_message(struct connectdata *conn) +{ + struct smb_conn *smbc = &conn->proto.smbc; + + smbc->got = 0; +} + +static void smb_format_message(struct connectdata *conn, struct smb_header *h, + unsigned char cmd, size_t len) +{ + struct smb_conn *smbc = &conn->proto.smbc; + struct smb_request *req = conn->data->req.protop; + unsigned int pid; + + memset(h, 0, sizeof(*h)); + h->nbt_length = htons((unsigned short) (sizeof(*h) - sizeof(unsigned int) + + len)); + memcpy((char *)h->magic, "\xffSMB", 4); + h->command = cmd; + h->flags = SMB_FLAGS_CANONICAL_PATHNAMES | SMB_FLAGS_CASELESS_PATHNAMES; + h->flags2 = smb_swap16(SMB_FLAGS2_IS_LONG_NAME | SMB_FLAGS2_KNOWS_LONG_NAME); + h->uid = smb_swap16(smbc->uid); + h->tid = smb_swap16(req->tid); + pid = getpid(); + h->pid_high = smb_swap16((unsigned short)(pid >> 16)); + h->pid = smb_swap16((unsigned short) pid); +} + +static CURLcode smb_send(struct connectdata *conn, ssize_t len, + size_t upload_size) +{ + struct smb_conn *smbc = &conn->proto.smbc; + ssize_t bytes_written; + CURLcode result; + + result = Curl_write(conn, FIRSTSOCKET, conn->data->state.uploadbuffer, + len, &bytes_written); + if(result) + return result; + + if(bytes_written != len) { + smbc->send_size = len; + smbc->sent = bytes_written; + } + + smbc->upload_size = upload_size; + + return CURLE_OK; +} + +static CURLcode smb_flush(struct connectdata *conn) +{ + struct smb_conn *smbc = &conn->proto.smbc; + ssize_t bytes_written; + ssize_t len = smbc->send_size - smbc->sent; + CURLcode result; + + if(!smbc->send_size) + return CURLE_OK; + + result = Curl_write(conn, FIRSTSOCKET, + conn->data->state.uploadbuffer + smbc->sent, + len, &bytes_written); + if(result) + return result; + + if(bytes_written != len) + smbc->sent += bytes_written; + else + smbc->send_size = 0; + + return CURLE_OK; +} + +static CURLcode smb_send_message(struct connectdata *conn, unsigned char cmd, + const void *msg, size_t msg_len) +{ + smb_format_message(conn, (struct smb_header *)conn->data->state.uploadbuffer, + cmd, msg_len); + memcpy(conn->data->state.uploadbuffer + sizeof(struct smb_header), + msg, msg_len); + + return smb_send(conn, sizeof(struct smb_header) + msg_len, 0); +} + +static CURLcode smb_send_negotiate(struct connectdata *conn) +{ + const char *msg = "\x00\x0c\x00\x02NT LM 0.12"; + + return smb_send_message(conn, SMB_COM_NEGOTIATE, msg, 15); +} + +static CURLcode smb_send_setup(struct connectdata *conn) +{ + struct smb_conn *smbc = &conn->proto.smbc; + struct smb_setup msg; + char *p = msg.bytes; + unsigned char lm_hash[21]; + unsigned char lm[24]; + unsigned char nt_hash[21]; + unsigned char nt[24]; + + size_t byte_count = sizeof(lm) + sizeof(nt); + byte_count += strlen(smbc->user) + strlen(smbc->domain); + byte_count += strlen(OS) + strlen(CLIENTNAME) + 4; /* 4 null chars */ + if(byte_count > sizeof(msg.bytes)) + return CURLE_FILESIZE_EXCEEDED; + + Curl_ntlm_core_mk_lm_hash(conn->data, conn->passwd, lm_hash); + Curl_ntlm_core_lm_resp(lm_hash, smbc->challenge, lm); +#if USE_NTRESPONSES + Curl_ntlm_core_mk_nt_hash(conn->data, conn->passwd, nt_hash); + Curl_ntlm_core_lm_resp(nt_hash, smbc->challenge, nt); +#else + memset(nt, 0, sizeof(nt)); +#endif + + memset(&msg, 0, sizeof(msg)); + msg.word_count = SMB_WC_SETUP_ANDX; + msg.andx.command = SMB_COM_NO_ANDX_COMMAND; + msg.max_buffer_size = smb_swap16(MAX_MESSAGE_SIZE); + msg.max_mpx_count = smb_swap16(1); + msg.vc_number = smb_swap16(1); + msg.session_key = smb_swap32(smbc->session_key); + msg.capabilities = smb_swap32(SMB_CAP_LARGE_FILES); + msg.lengths[0] = smb_swap16(sizeof(lm)); + msg.lengths[1] = smb_swap16(sizeof(nt)); + memcpy(p, lm, sizeof(lm)); + p += sizeof(lm); + memcpy(p, nt, sizeof(nt)); + p += sizeof(nt); + MSGCATNULL(smbc->user); + MSGCATNULL(smbc->domain); + MSGCATNULL(OS); + MSGCATNULL(CLIENTNAME); + byte_count = p - msg.bytes; + msg.byte_count = smb_swap16((unsigned short)byte_count); + + return smb_send_message(conn, SMB_COM_SETUP_ANDX, &msg, + sizeof(msg) - sizeof(msg.bytes) + byte_count); +} + +static CURLcode smb_send_tree_connect(struct connectdata *conn) +{ + struct smb_request *req = conn->data->req.protop; + struct smb_tree_connect msg; + char *p = msg.bytes; + + size_t byte_count = strlen(conn->host.name) + strlen(req->share); + byte_count += strlen(SERVICENAME) + 5; /* 2 nulls and 3 backslashes */ + if(byte_count > sizeof(msg.bytes)) + return CURLE_FILESIZE_EXCEEDED; + + memset(&msg, 0, sizeof(msg)); + msg.word_count = SMB_WC_TREE_CONNECT_ANDX; + msg.andx.command = SMB_COM_NO_ANDX_COMMAND; + msg.pw_len = 0; + MSGCAT("\\\\"); + MSGCAT(conn->host.name); + MSGCAT("\\"); + MSGCATNULL(req->share); + MSGCATNULL(SERVICENAME); /* Match any type of service */ + byte_count = p - msg.bytes; + msg.byte_count = smb_swap16((unsigned short)byte_count); + + return smb_send_message(conn, SMB_COM_TREE_CONNECT_ANDX, &msg, + sizeof(msg) - sizeof(msg.bytes) + byte_count); +} + +static CURLcode smb_send_open(struct connectdata *conn) +{ + struct smb_request *req = conn->data->req.protop; + struct smb_nt_create msg; + size_t byte_count; + + if((strlen(req->path) + 1) > sizeof(msg.bytes)) + return CURLE_FILESIZE_EXCEEDED; + + memset(&msg, 0, sizeof(msg)); + msg.word_count = SMB_WC_NT_CREATE_ANDX; + msg.andx.command = SMB_COM_NO_ANDX_COMMAND; + byte_count = strlen(req->path); + msg.name_length = smb_swap16((unsigned short)byte_count); + msg.share_access = smb_swap32(SMB_FILE_SHARE_ALL); + if(conn->data->set.upload) { + msg.access = smb_swap32(SMB_GENERIC_READ | SMB_GENERIC_WRITE); + msg.create_disposition = smb_swap32(SMB_FILE_OVERWRITE_IF); + } + else { + msg.access = smb_swap32(SMB_GENERIC_READ); + msg.create_disposition = smb_swap32(SMB_FILE_OPEN); + } + msg.byte_count = smb_swap16((unsigned short) ++byte_count); + strcpy(msg.bytes, req->path); + + return smb_send_message(conn, SMB_COM_NT_CREATE_ANDX, &msg, + sizeof(msg) - sizeof(msg.bytes) + byte_count); +} + +static CURLcode smb_send_close(struct connectdata *conn) +{ + struct smb_request *req = conn->data->req.protop; + struct smb_close msg; + + memset(&msg, 0, sizeof(msg)); + msg.word_count = SMB_WC_CLOSE; + msg.fid = smb_swap16(req->fid); + + return smb_send_message(conn, SMB_COM_CLOSE, &msg, sizeof(msg)); +} + +static CURLcode smb_send_tree_disconnect(struct connectdata *conn) +{ + struct smb_tree_disconnect msg; + + memset(&msg, 0, sizeof(msg)); + + return smb_send_message(conn, SMB_COM_TREE_DISCONNECT, &msg, sizeof(msg)); +} + +static CURLcode smb_send_read(struct connectdata *conn) +{ + struct smb_request *req = conn->data->req.protop; + curl_off_t offset = conn->data->req.offset; + struct smb_read msg; + + memset(&msg, 0, sizeof(msg)); + msg.word_count = SMB_WC_READ_ANDX; + msg.andx.command = SMB_COM_NO_ANDX_COMMAND; + msg.fid = smb_swap16(req->fid); + msg.offset = smb_swap32((unsigned int) offset); + msg.offset_high = smb_swap32((unsigned int) (offset >> 32)); + msg.min_bytes = smb_swap16(MAX_PAYLOAD_SIZE); + msg.max_bytes = smb_swap16(MAX_PAYLOAD_SIZE); + + return smb_send_message(conn, SMB_COM_READ_ANDX, &msg, sizeof(msg)); +} + +static CURLcode smb_send_write(struct connectdata *conn) +{ + struct smb_write *msg = (struct smb_write *)conn->data->state.uploadbuffer; + struct smb_request *req = conn->data->req.protop; + curl_off_t offset = conn->data->req.offset; + + curl_off_t upload_size = conn->data->req.size - conn->data->req.bytecount; + if(upload_size >= MAX_PAYLOAD_SIZE - 1) /* There is one byte of padding */ + upload_size = MAX_PAYLOAD_SIZE - 1; + + memset(msg, 0, sizeof(*msg)); + msg->word_count = SMB_WC_WRITE_ANDX; + msg->andx.command = SMB_COM_NO_ANDX_COMMAND; + msg->fid = smb_swap16(req->fid); + msg->offset = smb_swap32((unsigned int) offset); + msg->offset_high = smb_swap32((unsigned int) (offset >> 32)); + msg->data_length = smb_swap16((unsigned short) upload_size); + msg->data_offset = smb_swap16(sizeof(*msg) - sizeof(unsigned int)); + msg->byte_count = smb_swap16((unsigned short) (upload_size + 1)); + + smb_format_message(conn, &msg->h, SMB_COM_WRITE_ANDX, + sizeof(*msg) - sizeof(msg->h) + (size_t) upload_size); + + return smb_send(conn, sizeof(*msg), (size_t) upload_size); +} + +static CURLcode smb_send_and_recv(struct connectdata *conn, void **msg) +{ + struct smb_conn *smbc = &conn->proto.smbc; + CURLcode result; + + /* Check if there is data in the transfer buffer */ + if(!smbc->send_size && smbc->upload_size) { + int nread = smbc->upload_size > BUFSIZE ? BUFSIZE : + (int) smbc->upload_size; + conn->data->req.upload_fromhere = conn->data->state.uploadbuffer; + result = Curl_fillreadbuffer(conn, nread, &nread); + if(result && result != CURLE_AGAIN) + return result; + if(!nread) + return CURLE_OK; + + smbc->upload_size -= nread; + smbc->send_size = nread; + smbc->sent = 0; + } + + /* Check if there is data to send */ + if(smbc->send_size) { + result = smb_flush(conn); + if(result) + return result; + } + + /* Check if there is still data to be sent */ + if(smbc->send_size || smbc->upload_size) + return CURLE_AGAIN; + + return smb_recv_message(conn, msg); +} + +static CURLcode smb_connection_state(struct connectdata *conn, bool *done) +{ + struct smb_conn *smbc = &conn->proto.smbc; + struct smb_negotiate_response *nrsp; + struct smb_header *h; + CURLcode result; + void *msg = NULL; + + if(smbc->state == SMB_CONNECTING) { +#ifdef USE_SSL + if((conn->handler->flags & PROTOPT_SSL)) { + bool ssl_done; + result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, &ssl_done); + if(result && result != CURLE_AGAIN) + return result; + if(!ssl_done) + return CURLE_OK; + } +#endif + + result = smb_send_negotiate(conn); + if(result) { + connclose(conn, "SMB: failed to send negotiate message"); + return result; + } + + conn_state(conn, SMB_NEGOTIATE); + } + + /* Send the previous message and check for a response */ + result = smb_send_and_recv(conn, &msg); + if(result && result != CURLE_AGAIN) { + connclose(conn, "SMB: failed to communicate"); + return result; + } + + if(!msg) + return CURLE_OK; + + h = msg; + + switch(smbc->state) { + case SMB_NEGOTIATE: + if(h->status) { + connclose(conn, "SMB: negotiation failed"); + return CURLE_COULDNT_CONNECT; + } + nrsp = msg; + memcpy(smbc->challenge, nrsp->bytes, sizeof(smbc->challenge)); + smbc->session_key = smb_swap32(nrsp->session_key); + result = smb_send_setup(conn); + if(result) { + connclose(conn, "SMB: failed to send setup message"); + return result; + } + conn_state(conn, SMB_SETUP); + break; + + case SMB_SETUP: + if(h->status) { + connclose(conn, "SMB: authentication failed"); + return CURLE_LOGIN_DENIED; + } + smbc->uid = smb_swap16(h->uid); + conn_state(conn, SMB_CONNECTED); + *done = true; + break; + + default: + smb_pop_message(conn); + return CURLE_OK; /* ignore */ + } + + smb_pop_message(conn); + + return CURLE_OK; +} + +static CURLcode smb_request_state(struct connectdata *conn, bool *done) +{ + struct smb_request *req = conn->data->req.protop; + struct smb_header *h; + enum smb_req_state next_state = SMB_DONE; + unsigned short len; + unsigned short off; + CURLcode result; + void *msg = NULL; + + /* Start the request */ + if(req->state == SMB_REQUESTING) { + result = smb_send_tree_connect(conn); + if(result) { + connclose(conn, "SMB: failed to send tree connect message"); + return result; + } + + request_state(conn, SMB_TREE_CONNECT); + } + + /* Send the previous message and check for a response */ + result = smb_send_and_recv(conn, &msg); + if(result && result != CURLE_AGAIN) { + connclose(conn, "SMB: failed to communicate"); + return result; + } + + if(!msg) + return CURLE_OK; + + h = msg; + + switch(req->state) { + case SMB_TREE_CONNECT: + if(h->status) { + req->result = CURLE_REMOTE_FILE_NOT_FOUND; + if(h->status == smb_swap32(SMB_ERR_NOACCESS)) + req->result = CURLE_REMOTE_ACCESS_DENIED; + break; + } + req->tid = smb_swap16(h->tid); + next_state = SMB_OPEN; + break; + + case SMB_OPEN: + if(h->status) { + req->result = CURLE_REMOTE_FILE_NOT_FOUND; + next_state = SMB_TREE_DISCONNECT; + break; + } + req->fid = smb_swap16(((struct smb_nt_create_response *)msg)->fid); + conn->data->req.offset = 0; + if(conn->data->set.upload) { + conn->data->req.size = conn->data->state.infilesize; + Curl_pgrsSetUploadSize(conn->data, conn->data->req.size); + next_state = SMB_UPLOAD; + } + else { + conn->data->req.size = + smb_swap64(((struct smb_nt_create_response *)msg)->end_of_file); + Curl_pgrsSetDownloadSize(conn->data, conn->data->req.size); + next_state = SMB_DOWNLOAD; + } + break; + + case SMB_DOWNLOAD: + if(h->status) { + req->result = CURLE_RECV_ERROR; + next_state = SMB_CLOSE; + break; + } + len = Curl_read16_le(((unsigned char *) msg) + + sizeof(struct smb_header) + 11); + off = Curl_read16_le(((unsigned char *) msg) + + sizeof(struct smb_header) + 13); + if(len > 0) { + struct smb_conn *smbc = &conn->proto.smbc; + if(off + sizeof(unsigned int) + len > smbc->got) { + failf(conn->data, "Invalid input packet"); + result = CURLE_RECV_ERROR; + } + else + result = Curl_client_write(conn, CLIENTWRITE_BODY, + (char *)msg + off + sizeof(unsigned int), + len); + if(result) { + req->result = result; + next_state = SMB_CLOSE; + break; + } + } + conn->data->req.bytecount += len; + conn->data->req.offset += len; + Curl_pgrsSetDownloadCounter(conn->data, conn->data->req.bytecount); + next_state = (len < MAX_PAYLOAD_SIZE) ? SMB_CLOSE : SMB_DOWNLOAD; + break; + + case SMB_UPLOAD: + if(h->status) { + req->result = CURLE_UPLOAD_FAILED; + next_state = SMB_CLOSE; + break; + } + len = Curl_read16_le(((unsigned char *) msg) + + sizeof(struct smb_header) + 5); + conn->data->req.bytecount += len; + conn->data->req.offset += len; + Curl_pgrsSetUploadCounter(conn->data, conn->data->req.bytecount); + if(conn->data->req.bytecount >= conn->data->req.size) + next_state = SMB_CLOSE; + else + next_state = SMB_UPLOAD; + break; + + case SMB_CLOSE: + /* We don't care if the close failed, proceed to tree disconnect anyway */ + next_state = SMB_TREE_DISCONNECT; + break; + + case SMB_TREE_DISCONNECT: + next_state = SMB_DONE; + break; + + default: + smb_pop_message(conn); + return CURLE_OK; /* ignore */ + } + + smb_pop_message(conn); + + switch(next_state) { + case SMB_OPEN: + result = smb_send_open(conn); + break; + + case SMB_DOWNLOAD: + result = smb_send_read(conn); + break; + + case SMB_UPLOAD: + result = smb_send_write(conn); + break; + + case SMB_CLOSE: + result = smb_send_close(conn); + break; + + case SMB_TREE_DISCONNECT: + result = smb_send_tree_disconnect(conn); + break; + + case SMB_DONE: + result = req->result; + *done = true; + break; + + default: + break; + } + + if(result) { + connclose(conn, "SMB: failed to send message"); + return result; + } + + request_state(conn, next_state); + + return CURLE_OK; +} + +static CURLcode smb_done(struct connectdata *conn, CURLcode status, + bool premature) +{ + struct smb_request *req = conn->data->req.protop; + + (void) premature; + + Curl_safefree(req->share); + Curl_safefree(conn->data->req.protop); + + return status; +} + +static CURLcode smb_disconnect(struct connectdata *conn, bool dead) +{ + struct smb_conn *smbc = &conn->proto.smbc; + struct smb_request *req = conn->data->req.protop; + + (void) dead; + + Curl_safefree(smbc->domain); + Curl_safefree(smbc->recv_buf); + + /* smb_done is not always called, so cleanup the request */ + if(req) { + Curl_safefree(req->share); + Curl_safefree(conn->data->req.protop); + } + + return CURLE_OK; +} + +static int smb_getsock(struct connectdata *conn, curl_socket_t *socks, + int numsocks) +{ + struct smb_conn *smbc = &conn->proto.smbc; + + if(!numsocks) + return GETSOCK_BLANK; + + socks[0] = conn->sock[FIRSTSOCKET]; + + if(smbc->send_size || smbc->upload_size) + return GETSOCK_WRITESOCK(0); + + return GETSOCK_READSOCK(0); +} + +static CURLcode smb_parse_url_path(struct connectdata *conn) +{ + CURLcode result = CURLE_OK; + struct SessionHandle *data = conn->data; + struct smb_request *req = data->req.protop; + char *path; + char *slash; + + /* URL decode the path */ + result = Curl_urldecode(data, data->state.path, 0, &path, NULL, TRUE); + if(result) + return result; + + /* Parse the path for the share */ + req->share = strdup((*path == '/' || *path == '\\') ? path + 1 : path); + if(!req->share) { + free(path); + + return CURLE_OUT_OF_MEMORY; + } + + slash = strchr(req->share, '/'); + if(!slash) + slash = strchr(req->share, '\\'); + + /* The share must be present */ + if(!slash) { + free(path); + + return CURLE_URL_MALFORMAT; + } + + /* Parse the path for the file path converting any forward slashes into + backslashes */ + *slash++ = 0; + req->path = slash; + for(; *slash; slash++) { + if(*slash == '/') + *slash = '\\'; + } + + free(path); + + return CURLE_OK; +} + +#endif /* !USE_WINDOWS_SSPI || USE_WIN32_CRYPTO */ + +#endif /* CURL_DISABLE_SMB && USE_NTLM && CURL_SIZEOF_CURL_OFF_T > 4 */ diff --git a/lib/smb.h b/lib/smb.h new file mode 100644 index 0000000..7852fa1 --- /dev/null +++ b/lib/smb.h @@ -0,0 +1,271 @@ +#ifndef HEADER_CURL_SMB_H +#define HEADER_CURL_SMB_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 2014, Bill Nagel , Exacq Technologies + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ + +enum smb_conn_state { + SMB_NOT_CONNECTED = 0, + SMB_CONNECTING, + SMB_NEGOTIATE, + SMB_SETUP, + SMB_CONNECTED +}; + +struct smb_conn { + enum smb_conn_state state; + char *user; + char *domain; + unsigned char challenge[8]; + unsigned int session_key; + unsigned short uid; + char *recv_buf; + size_t upload_size; + size_t send_size; + size_t sent; + size_t got; +}; + +/* + * Definitions for SMB protocol data structures + */ +#ifdef BUILDING_CURL_SMB_C + +#if defined(_MSC_VER) || defined(__ILEC400__) +# define PACK +# pragma pack(push) +# pragma pack(1) +#elif defined(__GNUC__) +# define PACK __attribute__((packed)) +#else +# define PACK +#endif + +#define SMB_COM_CLOSE 0x04 +#define SMB_COM_READ_ANDX 0x2e +#define SMB_COM_WRITE_ANDX 0x2f +#define SMB_COM_TREE_DISCONNECT 0x71 +#define SMB_COM_NEGOTIATE 0x72 +#define SMB_COM_SETUP_ANDX 0x73 +#define SMB_COM_TREE_CONNECT_ANDX 0x75 +#define SMB_COM_NT_CREATE_ANDX 0xa2 +#define SMB_COM_NO_ANDX_COMMAND 0xff + +#define SMB_WC_CLOSE 0x03 +#define SMB_WC_READ_ANDX 0x0c +#define SMB_WC_WRITE_ANDX 0x0e +#define SMB_WC_SETUP_ANDX 0x0d +#define SMB_WC_TREE_CONNECT_ANDX 0x04 +#define SMB_WC_NT_CREATE_ANDX 0x18 + +#define SMB_FLAGS_CANONICAL_PATHNAMES 0x10 +#define SMB_FLAGS_CASELESS_PATHNAMES 0x08 +#define SMB_FLAGS2_UNICODE_STRINGS 0x8000 +#define SMB_FLAGS2_IS_LONG_NAME 0x0040 +#define SMB_FLAGS2_KNOWS_LONG_NAME 0x0001 + +#define SMB_CAP_LARGE_FILES 0x08 +#define SMB_GENERIC_WRITE 0x40000000 +#define SMB_GENERIC_READ 0x80000000 +#define SMB_FILE_SHARE_ALL 0x07 +#define SMB_FILE_OPEN 0x01 +#define SMB_FILE_OVERWRITE_IF 0x05 + +#define SMB_ERR_NOACCESS 0x00050001 + +struct smb_header { + unsigned char nbt_type; + unsigned char nbt_flags; + unsigned short nbt_length; + unsigned char magic[4]; + unsigned char command; + unsigned int status; + unsigned char flags; + unsigned short flags2; + unsigned short pid_high; + unsigned char signature[8]; + unsigned short pad; + unsigned short tid; + unsigned short pid; + unsigned short uid; + unsigned short mid; +} PACK; + +struct smb_negotiate_response { + struct smb_header h; + unsigned char word_count; + unsigned short dialect_index; + unsigned char security_mode; + unsigned short max_mpx_count; + unsigned short max_number_vcs; + unsigned int max_buffer_size; + unsigned int max_raw_size; + unsigned int session_key; + unsigned int capabilities; + unsigned int system_time_low; + unsigned int system_time_high; + unsigned short server_time_zone; + unsigned char encryption_key_length; + unsigned short byte_count; + char bytes[1]; +} PACK; + +struct andx { + unsigned char command; + unsigned char pad; + unsigned short offset; +} PACK; + +struct smb_setup { + unsigned char word_count; + struct andx andx; + unsigned short max_buffer_size; + unsigned short max_mpx_count; + unsigned short vc_number; + unsigned int session_key; + unsigned short lengths[2]; + unsigned int pad; + unsigned int capabilities; + unsigned short byte_count; + char bytes[1024]; +} PACK; + +struct smb_tree_connect { + unsigned char word_count; + struct andx andx; + unsigned short flags; + unsigned short pw_len; + unsigned short byte_count; + char bytes[1024]; +} PACK; + +struct smb_nt_create { + unsigned char word_count; + struct andx andx; + unsigned char pad; + unsigned short name_length; + unsigned int flags; + unsigned int root_fid; + unsigned int access; +#ifdef HAVE_LONGLONG + unsigned long long allocation_size; +#else + unsigned __int64 allocation_size; +#endif + unsigned int ext_file_attributes; + unsigned int share_access; + unsigned int create_disposition; + unsigned int create_options; + unsigned int impersonation_level; + unsigned char security_flags; + unsigned short byte_count; + char bytes[1024]; +} PACK; + +struct smb_nt_create_response { + struct smb_header h; + unsigned char word_count; + struct andx andx; + unsigned char op_lock_level; + unsigned short fid; + unsigned int create_disposition; +#ifdef HAVE_LONGLONG + unsigned long long create_time; + unsigned long long last_access_time; + unsigned long long last_write_time; + unsigned long long last_change_time; +#else + unsigned __int64 create_time; + unsigned __int64 last_access_time; + unsigned __int64 last_write_time; + unsigned __int64 last_change_time; +#endif + unsigned int ext_file_attributes; +#ifdef HAVE_LONGLONG + unsigned long long allocation_size; + unsigned long long end_of_file; +#else + unsigned __int64 allocation_size; + unsigned __int64 end_of_file; +#endif +} PACK; + +struct smb_read { + unsigned char word_count; + struct andx andx; + unsigned short fid; + unsigned int offset; + unsigned short max_bytes; + unsigned short min_bytes; + unsigned int timeout; + unsigned short remaining; + unsigned int offset_high; + unsigned short byte_count; +} PACK; + +struct smb_write { + struct smb_header h; + unsigned char word_count; + struct andx andx; + unsigned short fid; + unsigned int offset; + unsigned int timeout; + unsigned short write_mode; + unsigned short remaining; + unsigned short pad; + unsigned short data_length; + unsigned short data_offset; + unsigned int offset_high; + unsigned short byte_count; + unsigned char pad2; +} PACK; + +struct smb_close { + unsigned char word_count; + unsigned short fid; + unsigned int last_mtime; + unsigned short byte_count; +} PACK; + +struct smb_tree_disconnect { + unsigned char word_count; + unsigned short byte_count; +} PACK; + +#if defined(_MSC_VER) || defined(__ILEC400__) +# pragma pack(pop) +#endif + +#endif /* BUILDING_CURL_SMB_C */ + +#if !defined(CURL_DISABLE_SMB) && defined(USE_NTLM) && \ + (CURL_SIZEOF_CURL_OFF_T > 4) + +#if !defined(USE_WINDOWS_SSPI) || defined(USE_WIN32_CRYPTO) + +extern const struct Curl_handler Curl_handler_smb; +extern const struct Curl_handler Curl_handler_smbs; + +#endif /* !USE_WINDOWS_SSPI || USE_WIN32_CRYPTO */ + +#endif /* CURL_DISABLE_SMB && USE_NTLM && CURL_SIZEOF_CURL_OFF_T > 4 */ + +#endif /* HEADER_CURL_SMB_H */ diff --git a/lib/smtp.c b/lib/smtp.c index 9aa8b15..dada087 100644 --- a/lib/smtp.c +++ b/lib/smtp.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -62,7 +62,6 @@ #include #include "urldata.h" #include "sendf.h" -#include "if2ip.h" #include "hostip.h" #include "progress.h" #include "transfer.h" @@ -83,10 +82,7 @@ #include "curl_gethostname.h" #include "curl_sasl.h" #include "warnless.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include - +#include "curl_printf.h" #include "curl_memory.h" /* The last #include file should be: */ #include "memdebug.h" @@ -106,10 +102,10 @@ static CURLcode smtp_setup_connection(struct connectdata *conn); static CURLcode smtp_parse_url_options(struct connectdata *conn); static CURLcode smtp_parse_url_path(struct connectdata *conn); static CURLcode smtp_parse_custom_request(struct connectdata *conn); -static CURLcode smtp_calc_sasl_details(struct connectdata *conn, - const char **mech, - char **initresp, size_t *len, - smtpstate *state1, smtpstate *state2); +static CURLcode smtp_perform_auth(struct connectdata *conn, const char *mech, + const char *initresp); +static CURLcode smtp_continue_auth(struct connectdata *conn, const char *resp); +static void smtp_get_message(char *buffer, char** outptr); /* * SMTP protocol handler. @@ -214,6 +210,17 @@ static const struct Curl_handler Curl_handler_smtps_proxy = { #endif #endif +/* SASL parameters for the smtp protocol */ +static const struct SASLproto saslsmtp = { + "smtp", /* The service name */ + 334, /* Code received when continuation is expected */ + 235, /* Code to receive upon authentication success */ + 512 - 8, /* Maximum initial response length (no max) */ + smtp_perform_auth, /* Send authentication command */ + smtp_continue_auth, /* Send authentication continuation */ + smtp_get_message /* Get SASL response message */ +}; + #ifdef USE_SSL static void smtp_to_smtps(struct connectdata *conn) { @@ -310,20 +317,7 @@ static void state(struct connectdata *conn, smtpstate newstate) "HELO", "STARTTLS", "UPGRADETLS", - "AUTH_PLAIN", - "AUTH_LOGIN", - "AUTH_LOGIN_PASSWD", - "AUTH_CRAMMD5", - "AUTH_DIGESTMD5", - "AUTH_DIGESTMD5_RESP", - "AUTH_NTLM", - "AUTH_NTLM_TYPE2MSG", - "AUTH_GSSAPI", - "AUTH_GSSAPI_TOKEN", - "AUTH_GSSAPI_NO_DATA", - "AUTH_XOAUTH2", - "AUTH_CANCEL", - "AUTH_FINAL", + "AUTH", "COMMAND", "MAIL", "RCPT", @@ -353,11 +347,11 @@ static CURLcode smtp_perform_ehlo(struct connectdata *conn) CURLcode result = CURLE_OK; struct smtp_conn *smtpc = &conn->proto.smtpc; - smtpc->authmechs = 0; /* No known authentication mechanisms yet */ - smtpc->authused = 0; /* Clear the authentication mechanism used - for esmtp connections */ - smtpc->tls_supported = FALSE; /* Clear the TLS capability */ - smtpc->auth_supported = FALSE; /* Clear the AUTH capability */ + smtpc->sasl.authmechs = SASL_AUTH_NONE; /* No known auth. mechanism yet */ + smtpc->sasl.authused = SASL_AUTH_NONE; /* Clear the authentication mechanism + used for esmtp connections */ + smtpc->tls_supported = FALSE; /* Clear the TLS capability */ + smtpc->auth_supported = FALSE; /* Clear the AUTH capability */ /* Send the EHLO command */ result = Curl_pp_sendf(&smtpc->pp, "EHLO %s", smtpc->domain); @@ -379,8 +373,8 @@ static CURLcode smtp_perform_helo(struct connectdata *conn) CURLcode result = CURLE_OK; struct smtp_conn *smtpc = &conn->proto.smtpc; - smtpc->authused = 0; /* No authentication mechanism used in smtp - connections */ + smtpc->sasl.authused = SASL_AUTH_NONE; /* No authentication mechanism used + in smtp connections */ /* Send the HELO command */ result = Curl_pp_sendf(&smtpc->pp, "HELO %s", smtpc->domain); @@ -446,25 +440,18 @@ static CURLcode smtp_perform_upgrade_tls(struct connectdata *conn) */ static CURLcode smtp_perform_auth(struct connectdata *conn, const char *mech, - const char *initresp, size_t len, - smtpstate state1, smtpstate state2) + const char *initresp) { CURLcode result = CURLE_OK; struct smtp_conn *smtpc = &conn->proto.smtpc; - if(initresp && 8 + strlen(mech) + len <= 512) { /* AUTH ... */ + if(initresp) { /* AUTH ... */ /* Send the AUTH command with the initial response */ result = Curl_pp_sendf(&smtpc->pp, "AUTH %s %s", mech, initresp); - - if(!result) - state(conn, state2); } else { /* Send the AUTH command */ result = Curl_pp_sendf(&smtpc->pp, "AUTH %s", mech); - - if(!result) - state(conn, state1); } return result; @@ -472,6 +459,19 @@ static CURLcode smtp_perform_auth(struct connectdata *conn, /*********************************************************************** * + * smtp_continue_auth() + * + * Sends SASL continuation data or cancellation. + */ +static CURLcode smtp_continue_auth(struct connectdata *conn, const char *resp) +{ + struct smtp_conn *smtpc = &conn->proto.smtpc; + + return Curl_pp_sendf(&smtpc->pp, "%s", resp); +} + +/*********************************************************************** + * * smtp_perform_authentication() * * Initiates the authentication sequence, with the appropriate SASL @@ -481,31 +481,22 @@ static CURLcode smtp_perform_authentication(struct connectdata *conn) { CURLcode result = CURLE_OK; struct smtp_conn *smtpc = &conn->proto.smtpc; - const char *mech = NULL; - char *initresp = NULL; - size_t len = 0; - smtpstate state1 = SMTP_STOP; - smtpstate state2 = SMTP_STOP; + saslprogress progress; - /* Check we have a username and password to authenticate with, and the + /* Check we have enough data to authenticate with, and the server supports authentiation, and end the connect phase if not */ - if(!conn->bits.user_passwd || !smtpc->auth_supported) { + if(!smtpc->auth_supported || + !Curl_sasl_can_authenticate(&smtpc->sasl, conn)) { state(conn, SMTP_STOP); - return result; } /* Calculate the SASL login details */ - result = smtp_calc_sasl_details(conn, &mech, &initresp, &len, &state1, - &state2); + result = Curl_sasl_start(&smtpc->sasl, conn, FALSE, &progress); if(!result) { - if(mech) { - /* Perform SASL based authentication */ - result = smtp_perform_auth(conn, mech, initresp, len, state1, state2); - - Curl_safefree(initresp); - } + if(progress == SASL_INPROGRESS) + state(conn, SMTP_AUTH); else { /* Other mechanisms not supported */ infof(conn->data, "No known authentication mechanisms supported!\n"); @@ -572,7 +563,7 @@ static CURLcode smtp_perform_mail(struct connectdata *conn) return CURLE_OUT_OF_MEMORY; /* Calculate the optional AUTH parameter */ - if(data->set.str[STRING_MAIL_AUTH] && conn->proto.smtpc.authused) { + if(data->set.str[STRING_MAIL_AUTH] && conn->proto.smtpc.sasl.authused) { if(data->set.str[STRING_MAIL_AUTH][0] != '\0') auth = aprintf("%s", data->set.str[STRING_MAIL_AUTH]); else @@ -580,7 +571,7 @@ static CURLcode smtp_perform_mail(struct connectdata *conn) auth = strdup("<>"); if(!auth) { - Curl_safefree(from); + free(from); return CURLE_OUT_OF_MEMORY; } @@ -591,8 +582,8 @@ static CURLcode smtp_perform_mail(struct connectdata *conn) size = aprintf("%" CURL_FORMAT_CURL_OFF_T, data->state.infilesize); if(!size) { - Curl_safefree(from); - Curl_safefree(auth); + free(from); + free(auth); return CURLE_OUT_OF_MEMORY; } @@ -612,9 +603,9 @@ static CURLcode smtp_perform_mail(struct connectdata *conn) result = Curl_pp_sendf(&conn->proto.smtpc.pp, "MAIL FROM:%s SIZE=%s", from, size); - Curl_safefree(from); - Curl_safefree(auth); - Curl_safefree(size); + free(from); + free(auth); + free(size); if(!result) state(conn, SMTP_MAIL); @@ -754,6 +745,9 @@ static CURLcode smtp_state_ehlo_resp(struct connectdata *conn, int smtpcode, /* Loop through the data line */ for(;;) { + size_t llen; + unsigned int mechbit; + while(len && (*line == ' ' || *line == '\t' || *line == '\r' || *line == '\n')) { @@ -772,22 +766,9 @@ static CURLcode smtp_state_ehlo_resp(struct connectdata *conn, int smtpcode, wordlen++; /* Test the word for a matching authentication mechanism */ - if(sasl_mech_equal(line, wordlen, SASL_MECH_STRING_LOGIN)) - smtpc->authmechs |= SASL_MECH_LOGIN; - else if(sasl_mech_equal(line, wordlen, SASL_MECH_STRING_PLAIN)) - smtpc->authmechs |= SASL_MECH_PLAIN; - else if(sasl_mech_equal(line, wordlen, SASL_MECH_STRING_CRAM_MD5)) - smtpc->authmechs |= SASL_MECH_CRAM_MD5; - else if(sasl_mech_equal(line, wordlen, SASL_MECH_STRING_DIGEST_MD5)) - smtpc->authmechs |= SASL_MECH_DIGEST_MD5; - else if(sasl_mech_equal(line, wordlen, SASL_MECH_STRING_GSSAPI)) - smtpc->authmechs |= SASL_MECH_GSSAPI; - else if(sasl_mech_equal(line, wordlen, SASL_MECH_STRING_EXTERNAL)) - smtpc->authmechs |= SASL_MECH_EXTERNAL; - else if(sasl_mech_equal(line, wordlen, SASL_MECH_STRING_NTLM)) - smtpc->authmechs |= SASL_MECH_NTLM; - else if(sasl_mech_equal(line, wordlen, SASL_MECH_STRING_XOAUTH2)) - smtpc->authmechs |= SASL_MECH_XOAUTH2; + if((mechbit = Curl_sasl_decode_mech(line, wordlen, &llen)) && + llen == wordlen) + smtpc->sasl.authmechs |= mechbit; line += wordlen; len -= wordlen; @@ -836,565 +817,31 @@ static CURLcode smtp_state_helo_resp(struct connectdata *conn, int smtpcode, return result; } -/* For AUTH PLAIN (without initial response) responses */ -static CURLcode smtp_state_auth_plain_resp(struct connectdata *conn, - int smtpcode, - smtpstate instate) -{ - CURLcode result = CURLE_OK; - struct SessionHandle *data = conn->data; - size_t len = 0; - char *plainauth = NULL; - - (void)instate; /* no use for this yet */ - - if(smtpcode != 334) { - failf(data, "Access denied: %d", smtpcode); - result = CURLE_LOGIN_DENIED; - } - else { - /* Create the authorisation message */ - result = Curl_sasl_create_plain_message(conn->data, conn->user, - conn->passwd, &plainauth, &len); - if(!result && plainauth) { - /* Send the message */ - result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s", plainauth); - - if(!result) - state(conn, SMTP_AUTH_FINAL); - } - } - - Curl_safefree(plainauth); - - return result; -} - -/* For AUTH LOGIN (without initial response) responses */ -static CURLcode smtp_state_auth_login_resp(struct connectdata *conn, - int smtpcode, - smtpstate instate) -{ - CURLcode result = CURLE_OK; - struct SessionHandle *data = conn->data; - size_t len = 0; - char *authuser = NULL; - - (void)instate; /* no use for this yet */ - - if(smtpcode != 334) { - failf(data, "Access denied: %d", smtpcode); - result = CURLE_LOGIN_DENIED; - } - else { - /* Create the user message */ - result = Curl_sasl_create_login_message(conn->data, conn->user, - &authuser, &len); - if(!result && authuser) { - /* Send the user */ - result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s", authuser); - - if(!result) - state(conn, SMTP_AUTH_LOGIN_PASSWD); - } - } - - Curl_safefree(authuser); - - return result; -} - -/* For AUTH LOGIN user entry responses */ -static CURLcode smtp_state_auth_login_password_resp(struct connectdata *conn, - int smtpcode, - smtpstate instate) -{ - CURLcode result = CURLE_OK; - struct SessionHandle *data = conn->data; - size_t len = 0; - char *authpasswd = NULL; - - (void)instate; /* no use for this yet */ - - if(smtpcode != 334) { - failf(data, "Access denied: %d", smtpcode); - result = CURLE_LOGIN_DENIED; - } - else { - /* Create the password message */ - result = Curl_sasl_create_login_message(conn->data, conn->passwd, - &authpasswd, &len); - if(!result && authpasswd) { - /* Send the password */ - result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s", authpasswd); - - if(!result) - state(conn, SMTP_AUTH_FINAL); - } - } - - Curl_safefree(authpasswd); - - return result; -} - -#ifndef CURL_DISABLE_CRYPTO_AUTH -/* For AUTH CRAM-MD5 responses */ -static CURLcode smtp_state_auth_cram_resp(struct connectdata *conn, - int smtpcode, - smtpstate instate) -{ - CURLcode result = CURLE_OK; - struct SessionHandle *data = conn->data; - char *chlg = NULL; - char *chlg64 = NULL; - char *rplyb64 = NULL; - size_t len = 0; - - (void)instate; /* no use for this yet */ - - if(smtpcode != 334) { - failf(data, "Access denied: %d", smtpcode); - return CURLE_LOGIN_DENIED; - } - - /* Get the challenge message */ - smtp_get_message(data->state.buffer, &chlg64); - - /* Decode the challenge message */ - result = Curl_sasl_decode_cram_md5_message(chlg64, &chlg, &len); - if(result) { - /* Send the cancellation */ - result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s", "*"); - - if(!result) - state(conn, SMTP_AUTH_CANCEL); - } - else { - /* Create the response message */ - result = Curl_sasl_create_cram_md5_message(data, chlg, conn->user, - conn->passwd, &rplyb64, &len); - if(!result && rplyb64) { - /* Send the response */ - result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s", rplyb64); - - if(!result) - state(conn, SMTP_AUTH_FINAL); - } - } - - Curl_safefree(chlg); - Curl_safefree(rplyb64); - - return result; -} - -/* For AUTH DIGEST-MD5 challenge responses */ -static CURLcode smtp_state_auth_digest_resp(struct connectdata *conn, - int smtpcode, - smtpstate instate) -{ - CURLcode result = CURLE_OK; - struct SessionHandle *data = conn->data; - char *chlg64 = NULL; - char *rplyb64 = NULL; - size_t len = 0; - - (void)instate; /* no use for this yet */ - - if(smtpcode != 334) { - failf(data, "Access denied: %d", smtpcode); - return CURLE_LOGIN_DENIED; - } - - /* Get the challenge message */ - smtp_get_message(data->state.buffer, &chlg64); - - /* Create the response message */ - result = Curl_sasl_create_digest_md5_message(data, chlg64, - conn->user, conn->passwd, - "smtp", &rplyb64, &len); - if(result) { - if(result == CURLE_BAD_CONTENT_ENCODING) { - /* Send the cancellation */ - result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s", "*"); - - if(!result) - state(conn, SMTP_AUTH_CANCEL); - } - } - else { - /* Send the response */ - result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s", rplyb64); - - if(!result) - state(conn, SMTP_AUTH_DIGESTMD5_RESP); - } - - Curl_safefree(rplyb64); - - return result; -} - -/* For AUTH DIGEST-MD5 challenge-response responses */ -static CURLcode smtp_state_auth_digest_resp_resp(struct connectdata *conn, - int smtpcode, - smtpstate instate) -{ - CURLcode result = CURLE_OK; - struct SessionHandle *data = conn->data; - - (void)instate; /* no use for this yet */ - - if(smtpcode != 334) { - failf(data, "Authentication failed: %d", smtpcode); - result = CURLE_LOGIN_DENIED; - } - else { - /* Send an empty response */ - result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s", ""); - - if(!result) - state(conn, SMTP_AUTH_FINAL); - } - - return result; -} - -#endif - -#ifdef USE_NTLM -/* For AUTH NTLM (without initial response) responses */ -static CURLcode smtp_state_auth_ntlm_resp(struct connectdata *conn, - int smtpcode, - smtpstate instate) -{ - CURLcode result = CURLE_OK; - struct SessionHandle *data = conn->data; - char *type1msg = NULL; - size_t len = 0; - - (void)instate; /* no use for this yet */ - - if(smtpcode != 334) { - failf(data, "Access denied: %d", smtpcode); - result = CURLE_LOGIN_DENIED; - } - else { - /* Create the type-1 message */ - result = Curl_sasl_create_ntlm_type1_message(conn->user, conn->passwd, - &conn->ntlm, - &type1msg, &len); - if(!result && type1msg) { - /* Send the message */ - result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s", type1msg); - - if(!result) - state(conn, SMTP_AUTH_NTLM_TYPE2MSG); - } - } - - Curl_safefree(type1msg); - - return result; -} - -/* For NTLM type-2 responses (sent in reponse to our type-1 message) */ -static CURLcode smtp_state_auth_ntlm_type2msg_resp(struct connectdata *conn, - int smtpcode, - smtpstate instate) -{ - CURLcode result = CURLE_OK; - struct SessionHandle *data = conn->data; - char *type2msg = NULL; - char *type3msg = NULL; - size_t len = 0; - - (void)instate; /* no use for this yet */ - - if(smtpcode != 334) { - failf(data, "Access denied: %d", smtpcode); - result = CURLE_LOGIN_DENIED; - } - else { - /* Get the type-2 message */ - smtp_get_message(data->state.buffer, &type2msg); - - /* Decode the type-2 message */ - result = Curl_sasl_decode_ntlm_type2_message(data, type2msg, &conn->ntlm); - if(result) { - /* Send the cancellation */ - result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s", "*"); - - if(!result) - state(conn, SMTP_AUTH_CANCEL); - } - else { - /* Create the type-3 message */ - result = Curl_sasl_create_ntlm_type3_message(data, conn->user, - conn->passwd, &conn->ntlm, - &type3msg, &len); - if(!result && type3msg) { - /* Send the message */ - result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s", type3msg); - - if(!result) - state(conn, SMTP_AUTH_FINAL); - } - } - } - - Curl_safefree(type3msg); - - return result; -} -#endif - -#if defined(USE_WINDOWS_SSPI) -/* For AUTH GSSAPI (without initial response) responses */ -static CURLcode smtp_state_auth_gssapi_resp(struct connectdata *conn, - int smtpcode, - smtpstate instate) -{ - CURLcode result = CURLE_OK; - struct SessionHandle *data = conn->data; - struct smtp_conn *smtpc = &conn->proto.smtpc; - char *respmsg = NULL; - size_t len = 0; - - (void)instate; /* no use for this yet */ - - if(smtpcode != 334) { - failf(data, "Access denied: %d", smtpcode); - result = CURLE_LOGIN_DENIED; - } - else { - /* Create the initial response message */ - result = Curl_sasl_create_gssapi_user_message(data, conn->user, - conn->passwd, "smtp", - smtpc->mutual_auth, NULL, - &conn->krb5, - &respmsg, &len); - if(!result && respmsg) { - /* Send the message */ - result = Curl_pp_sendf(&smtpc->pp, "%s", respmsg); - - if(!result) - state(conn, SMTP_AUTH_GSSAPI_TOKEN); - } - } - - Curl_safefree(respmsg); - - return result; -} - -/* For AUTH GSSAPI user token responses */ -static CURLcode smtp_state_auth_gssapi_token_resp(struct connectdata *conn, - int smtpcode, - smtpstate instate) -{ - CURLcode result = CURLE_OK; - struct SessionHandle *data = conn->data; - struct smtp_conn *smtpc = &conn->proto.smtpc; - char *chlgmsg = NULL; - char *respmsg = NULL; - size_t len = 0; - - (void)instate; /* no use for this yet */ - - if(smtpcode != 334) { - failf(data, "Access denied: %d", smtpcode); - result = CURLE_LOGIN_DENIED; - } - else { - /* Get the challenge message */ - smtp_get_message(data->state.buffer, &chlgmsg); - - if(smtpc->mutual_auth) - /* Decode the user token challenge and create the optional response - message */ - result = Curl_sasl_create_gssapi_user_message(data, NULL, NULL, NULL, - smtpc->mutual_auth, - chlgmsg, &conn->krb5, - &respmsg, &len); - else - /* Decode the security challenge and create the response message */ - result = Curl_sasl_create_gssapi_security_message(data, chlgmsg, - &conn->krb5, - &respmsg, &len); - - if(result) { - if(result == CURLE_BAD_CONTENT_ENCODING) { - /* Send the cancellation */ - result = Curl_pp_sendf(&smtpc->pp, "%s", "*"); - - if(!result) - state(conn, SMTP_AUTH_CANCEL); - } - } - else { - /* Send the response */ - if(respmsg) - result = Curl_pp_sendf(&smtpc->pp, "%s", respmsg); - else - result = Curl_pp_sendf(&smtpc->pp, "%s", ""); - - if(!result) - state(conn, (smtpc->mutual_auth ? SMTP_AUTH_GSSAPI_NO_DATA : - SMTP_AUTH_FINAL)); - } - } - - Curl_safefree(respmsg); - - return result; -} - -/* For AUTH GSSAPI no data responses */ -static CURLcode smtp_state_auth_gssapi_no_data_resp(struct connectdata *conn, - int smtpcode, - smtpstate instate) -{ - CURLcode result = CURLE_OK; - struct SessionHandle *data = conn->data; - char *chlgmsg = NULL; - char *respmsg = NULL; - size_t len = 0; - - (void)instate; /* no use for this yet */ - - if(smtpcode != 334) { - failf(data, "Access denied: %d", smtpcode); - result = CURLE_LOGIN_DENIED; - } - else { - /* Get the challenge message */ - smtp_get_message(data->state.buffer, &chlgmsg); - - /* Decode the security challenge and create the response message */ - result = Curl_sasl_create_gssapi_security_message(data, chlgmsg, - &conn->krb5, - &respmsg, &len); - if(result) { - if(result == CURLE_BAD_CONTENT_ENCODING) { - /* Send the cancellation */ - result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s", "*"); - - if(!result) - state(conn, SMTP_AUTH_CANCEL); - } - } - else { - /* Send the response */ - if(respmsg) { - result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s", respmsg); - - if(!result) - state(conn, SMTP_AUTH_FINAL); - } - } - } - - Curl_safefree(respmsg); - - return result; -} -#endif - -/* For AUTH XOAUTH2 (without initial response) responses */ -static CURLcode smtp_state_auth_xoauth2_resp(struct connectdata *conn, - int smtpcode, smtpstate instate) -{ - CURLcode result = CURLE_OK; - struct SessionHandle *data = conn->data; - size_t len = 0; - char *xoauth = NULL; - - (void)instate; /* no use for this yet */ - - if(smtpcode != 334) { - failf(data, "Access denied: %d", smtpcode); - result = CURLE_LOGIN_DENIED; - } - else { - /* Create the authorisation message */ - result = Curl_sasl_create_xoauth2_message(conn->data, conn->user, - conn->xoauth2_bearer, - &xoauth, &len); - if(!result && xoauth) { - /* Send the message */ - result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s", xoauth); - - if(!result) - state(conn, SMTP_AUTH_FINAL); - } - } - - Curl_safefree(xoauth); - - return result; -} - -/* For AUTH cancellation responses */ -static CURLcode smtp_state_auth_cancel_resp(struct connectdata *conn, - int smtpcode, - smtpstate instate) +/* For SASL authentication responses */ +static CURLcode smtp_state_auth_resp(struct connectdata *conn, + int smtpcode, + smtpstate instate) { CURLcode result = CURLE_OK; struct SessionHandle *data = conn->data; struct smtp_conn *smtpc = &conn->proto.smtpc; - const char *mech = NULL; - char *initresp = NULL; - size_t len = 0; - smtpstate state1 = SMTP_STOP; - smtpstate state2 = SMTP_STOP; + saslprogress progress; - (void)smtpcode; (void)instate; /* no use for this yet */ - /* Remove the offending mechanism from the supported list */ - smtpc->authmechs ^= smtpc->authused; - - /* Calculate alternative SASL login details */ - result = smtp_calc_sasl_details(conn, &mech, &initresp, &len, &state1, - &state2); - - if(!result) { - /* Do we have any mechanisms left? */ - if(mech) { - /* Retry SASL based authentication */ - result = smtp_perform_auth(conn, mech, initresp, len, state1, state2); - - Curl_safefree(initresp); - } - else { + result = Curl_sasl_continue(&smtpc->sasl, conn, smtpcode, &progress); + if(!result) + switch(progress) { + case SASL_DONE: + state(conn, SMTP_STOP); /* Authenticated */ + break; + case SASL_IDLE: /* No mechanism left after cancellation */ failf(data, "Authentication cancelled"); - result = CURLE_LOGIN_DENIED; + break; + default: + break; } - } - - return result; -} - -/* For final responses in the AUTH sequence */ -static CURLcode smtp_state_auth_final_resp(struct connectdata *conn, - int smtpcode, - smtpstate instate) -{ - CURLcode result = CURLE_OK; - struct SessionHandle *data = conn->data; - - (void)instate; /* no use for this yet */ - - if(smtpcode != 235) { - failf(data, "Authentication failed: %d", smtpcode); - result = CURLE_LOGIN_DENIED; - } - else - /* End of connect phase */ - state(conn, SMTP_STOP); return result; } @@ -1592,69 +1039,8 @@ static CURLcode smtp_statemach_act(struct connectdata *conn) result = smtp_state_starttls_resp(conn, smtpcode, smtpc->state); break; - case SMTP_AUTH_PLAIN: - result = smtp_state_auth_plain_resp(conn, smtpcode, smtpc->state); - break; - - case SMTP_AUTH_LOGIN: - result = smtp_state_auth_login_resp(conn, smtpcode, smtpc->state); - break; - - case SMTP_AUTH_LOGIN_PASSWD: - result = smtp_state_auth_login_password_resp(conn, smtpcode, - smtpc->state); - break; - -#ifndef CURL_DISABLE_CRYPTO_AUTH - case SMTP_AUTH_CRAMMD5: - result = smtp_state_auth_cram_resp(conn, smtpcode, smtpc->state); - break; - - case SMTP_AUTH_DIGESTMD5: - result = smtp_state_auth_digest_resp(conn, smtpcode, smtpc->state); - break; - - case SMTP_AUTH_DIGESTMD5_RESP: - result = smtp_state_auth_digest_resp_resp(conn, smtpcode, smtpc->state); - break; -#endif - -#ifdef USE_NTLM - case SMTP_AUTH_NTLM: - result = smtp_state_auth_ntlm_resp(conn, smtpcode, smtpc->state); - break; - - case SMTP_AUTH_NTLM_TYPE2MSG: - result = smtp_state_auth_ntlm_type2msg_resp(conn, smtpcode, - smtpc->state); - break; -#endif - -#if defined(USE_WINDOWS_SSPI) - case SMTP_AUTH_GSSAPI: - result = smtp_state_auth_gssapi_resp(conn, smtpcode, smtpc->state); - break; - - case SMTP_AUTH_GSSAPI_TOKEN: - result = smtp_state_auth_gssapi_token_resp(conn, smtpcode, smtpc->state); - break; - - case SMTP_AUTH_GSSAPI_NO_DATA: - result = smtp_state_auth_gssapi_no_data_resp(conn, smtpcode, - smtpc->state); - break; -#endif - - case SMTP_AUTH_XOAUTH2: - result = smtp_state_auth_xoauth2_resp(conn, smtpcode, smtpc->state); - break; - - case SMTP_AUTH_CANCEL: - result = smtp_state_auth_cancel_resp(conn, smtpcode, smtpc->state); - break; - - case SMTP_AUTH_FINAL: - result = smtp_state_auth_final_resp(conn, smtpcode, smtpc->state); + case SMTP_AUTH: + result = smtp_state_auth_resp(conn, smtpcode, smtpc->state); break; case SMTP_COMMAND: @@ -1767,8 +1153,8 @@ static CURLcode smtp_connect(struct connectdata *conn, bool *done) pp->endofresp = smtp_endofresp; pp->conn = conn; - /* Set the default preferred authentication mechanism */ - smtpc->prefmech = SASL_AUTH_ANY; + /* Initialize the SASL storage */ + Curl_sasl_init(&smtpc->sasl, &saslsmtp); /* Initialise the pingpong layer */ Curl_pp_init(pp); @@ -1807,7 +1193,7 @@ static CURLcode smtp_done(struct connectdata *conn, CURLcode status, struct SessionHandle *data = conn->data; struct SMTP *smtp = data->req.protop; struct pingpong *pp = &conn->proto.smtpc.pp; - const char *eob; + char *eob; ssize_t len; ssize_t bytes_written; @@ -1827,30 +1213,45 @@ static CURLcode smtp_done(struct connectdata *conn, CURLcode status, else if(!data->set.connect_only && data->set.upload && data->set.mail_rcpt) { /* Calculate the EOB taking into account any terminating CRLF from the previous line of the email or the CRLF of the DATA command when there - is "no mail data". RFC-5321, sect. 4.1.1.4. */ - eob = SMTP_EOB; - len = SMTP_EOB_LEN; + is "no mail data". RFC-5321, sect. 4.1.1.4. + + Note: As some SSL backends, such as OpenSSL, will cause Curl_write() to + fail when using a different pointer following a previous write, that + returned CURLE_AGAIN, we duplicate the EOB now rather than when the + bytes written doesn't equal len. */ if(smtp->trailing_crlf || !conn->data->state.infilesize) { - eob += 2; - len -= 2; + eob = strdup(SMTP_EOB + 2); + len = SMTP_EOB_LEN - 2; + } + else { + eob = strdup(SMTP_EOB); + len = SMTP_EOB_LEN; } + if(!eob) + return CURLE_OUT_OF_MEMORY; + /* Send the end of block data */ result = Curl_write(conn, conn->writesockfd, eob, len, &bytes_written); - if(result) + if(result) { + free(eob); return result; + } if(bytes_written != len) { /* The whole chunk was not sent so keep it around and adjust the pingpong structure accordingly */ - pp->sendthis = strdup(eob); + pp->sendthis = eob; pp->sendsize = len; pp->sendleft = len - bytes_written; } - else + else { /* Successfully sent so adjust the response timeout relative to now */ pp->response = Curl_tvnow(); + free(eob); + } + state(conn, SMTP_POSTDATA); /* Run the state-machine @@ -1971,7 +1372,7 @@ static CURLcode smtp_disconnect(struct connectdata *conn, bool dead_connection) Curl_pp_disconnect(&smtpc->pp); /* Cleanup the SASL module */ - Curl_sasl_cleanup(conn, smtpc->authused); + Curl_sasl_cleanup(conn, smtpc->sasl.authused); /* Cleanup our connection based variables */ Curl_safefree(smtpc->domain); @@ -2092,52 +1493,30 @@ static CURLcode smtp_parse_url_options(struct connectdata *conn) { CURLcode result = CURLE_OK; struct smtp_conn *smtpc = &conn->proto.smtpc; - const char *options = conn->options; - const char *ptr = options; - bool reset = TRUE; + const char *ptr = conn->options; - while(ptr && *ptr) { + smtpc->sasl.resetprefs = TRUE; + + while(!result && ptr && *ptr) { const char *key = ptr; + const char *value; while(*ptr && *ptr != '=') ptr++; - if(strnequal(key, "AUTH", 4)) { - size_t len = 0; - const char *value = ++ptr; - - if(reset) { - reset = FALSE; - smtpc->prefmech = SASL_AUTH_NONE; - } + value = ptr + 1; - while(*ptr && *ptr != ';') { - ptr++; - len++; - } + while(*ptr && *ptr != ';') + ptr++; - if(strnequal(value, "*", len)) - smtpc->prefmech = SASL_AUTH_ANY; - else if(strnequal(value, SASL_MECH_STRING_LOGIN, len)) - smtpc->prefmech |= SASL_MECH_LOGIN; - else if(strnequal(value, SASL_MECH_STRING_PLAIN, len)) - smtpc->prefmech |= SASL_MECH_PLAIN; - else if(strnequal(value, SASL_MECH_STRING_CRAM_MD5, len)) - smtpc->prefmech |= SASL_MECH_CRAM_MD5; - else if(strnequal(value, SASL_MECH_STRING_DIGEST_MD5, len)) - smtpc->prefmech |= SASL_MECH_DIGEST_MD5; - else if(strnequal(value, SASL_MECH_STRING_GSSAPI, len)) - smtpc->prefmech |= SASL_MECH_GSSAPI; - else if(strnequal(value, SASL_MECH_STRING_NTLM, len)) - smtpc->prefmech |= SASL_MECH_NTLM; - else if(strnequal(value, SASL_MECH_STRING_XOAUTH2, len)) - smtpc->prefmech |= SASL_MECH_XOAUTH2; - - if(*ptr == ';') - ptr++; - } + if(strnequal(key, "AUTH=", 5)) + result = Curl_sasl_parse_url_auth_option(&smtpc->sasl, + value, ptr - value); else result = CURLE_URL_MALFORMAT; + + if(*ptr == ';') + ptr++; } return result; @@ -2189,111 +1568,7 @@ static CURLcode smtp_parse_custom_request(struct connectdata *conn) return result; } -/*********************************************************************** - * - * smtp_calc_sasl_details() - * - * Calculate the required login details for SASL authentication. - */ -static CURLcode smtp_calc_sasl_details(struct connectdata *conn, - const char **mech, - char **initresp, size_t *len, - smtpstate *state1, smtpstate *state2) -{ - CURLcode result = CURLE_OK; - struct SessionHandle *data = conn->data; - struct smtp_conn *smtpc = &conn->proto.smtpc; - - /* Calculate the supported authentication mechanism, by decreasing order of - security, as well as the initial response where appropriate */ -#if defined(USE_WINDOWS_SSPI) - if((smtpc->authmechs & SASL_MECH_GSSAPI) && - (smtpc->prefmech & SASL_MECH_GSSAPI)) { - smtpc->mutual_auth = FALSE; /* TODO: Calculate mutual authentication */ - - *mech = SASL_MECH_STRING_GSSAPI; - *state1 = SMTP_AUTH_GSSAPI; - *state2 = SMTP_AUTH_GSSAPI_TOKEN; - smtpc->authused = SASL_MECH_GSSAPI; - - if(data->set.sasl_ir) - result = Curl_sasl_create_gssapi_user_message(data, conn->user, - conn->passwd, "smtp", - smtpc->mutual_auth, - NULL, &conn->krb5, - initresp, len); - } - else -#endif -#ifndef CURL_DISABLE_CRYPTO_AUTH - if((smtpc->authmechs & SASL_MECH_DIGEST_MD5) && - (smtpc->prefmech & SASL_MECH_DIGEST_MD5)) { - *mech = SASL_MECH_STRING_DIGEST_MD5; - *state1 = SMTP_AUTH_DIGESTMD5; - smtpc->authused = SASL_MECH_DIGEST_MD5; - } - else if((smtpc->authmechs & SASL_MECH_CRAM_MD5) && - (smtpc->prefmech & SASL_MECH_CRAM_MD5)) { - *mech = SASL_MECH_STRING_CRAM_MD5; - *state1 = SMTP_AUTH_CRAMMD5; - smtpc->authused = SASL_MECH_CRAM_MD5; - } - else -#endif -#ifdef USE_NTLM - if((smtpc->authmechs & SASL_MECH_NTLM) && - (smtpc->prefmech & SASL_MECH_NTLM)) { - *mech = SASL_MECH_STRING_NTLM; - *state1 = SMTP_AUTH_NTLM; - *state2 = SMTP_AUTH_NTLM_TYPE2MSG; - smtpc->authused = SASL_MECH_NTLM; - - if(data->set.sasl_ir) - result = Curl_sasl_create_ntlm_type1_message(conn->user, conn->passwd, - &conn->ntlm, - initresp, len); - } - else -#endif - if(((smtpc->authmechs & SASL_MECH_XOAUTH2) && - (smtpc->prefmech & SASL_MECH_XOAUTH2) && - (smtpc->prefmech != SASL_AUTH_ANY)) || conn->xoauth2_bearer) { - *mech = SASL_MECH_STRING_XOAUTH2; - *state1 = SMTP_AUTH_XOAUTH2; - *state2 = SMTP_AUTH_FINAL; - smtpc->authused = SASL_MECH_XOAUTH2; - - if(data->set.sasl_ir) - result = Curl_sasl_create_xoauth2_message(data, conn->user, - conn->xoauth2_bearer, - initresp, len); - } - else if((smtpc->authmechs & SASL_MECH_LOGIN) && - (smtpc->prefmech & SASL_MECH_LOGIN)) { - *mech = SASL_MECH_STRING_LOGIN; - *state1 = SMTP_AUTH_LOGIN; - *state2 = SMTP_AUTH_LOGIN_PASSWD; - smtpc->authused = SASL_MECH_LOGIN; - - if(data->set.sasl_ir) - result = Curl_sasl_create_login_message(data, conn->user, initresp, len); - } - else if((smtpc->authmechs & SASL_MECH_PLAIN) && - (smtpc->prefmech & SASL_MECH_PLAIN)) { - *mech = SASL_MECH_STRING_PLAIN; - *state1 = SMTP_AUTH_PLAIN; - *state2 = SMTP_AUTH_FINAL; - smtpc->authused = SASL_MECH_PLAIN; - - if(data->set.sasl_ir) - result = Curl_sasl_create_plain_message(data, conn->user, conn->passwd, - initresp, len); - } - - return result; -} - -CURLcode Curl_smtp_escape_eob(struct connectdata *conn, ssize_t nread) +CURLcode Curl_smtp_escape_eob(struct connectdata *conn, const ssize_t nread) { /* When sending a SMTP payload we must detect CRLF. sequences making sure they are sent as CRLF.. instead, as a . on the beginning of a line will @@ -2305,17 +1580,26 @@ CURLcode Curl_smtp_escape_eob(struct connectdata *conn, ssize_t nread) ssize_t si; struct SessionHandle *data = conn->data; struct SMTP *smtp = data->req.protop; + char *scratch = data->state.scratch; + char *newscratch = NULL; + char *oldscratch = NULL; + size_t eob_sent; + + /* Do we need to allocate a scratch buffer? */ + if(!scratch || data->set.crlf) { + oldscratch = scratch; - /* Do we need to allocate the scatch buffer? */ - if(!data->state.scratch) { - data->state.scratch = malloc(2 * BUFSIZE); + scratch = newscratch = malloc(2 * BUFSIZE); + if(!newscratch) { + failf(data, "Failed to alloc scratch buffer!"); - if(!data->state.scratch) { - failf (data, "Failed to alloc scratch buffer!"); return CURLE_OUT_OF_MEMORY; } } + /* Have we already sent part of the EOB? */ + eob_sent = smtp->eob; + /* This loop can be improved by some kind of Boyer-Moore style of approach but that is saved for later... */ for(i = 0, si = 0; i < nread; i++) { @@ -2330,8 +1614,8 @@ CURLcode Curl_smtp_escape_eob(struct connectdata *conn, ssize_t nread) } else if(smtp->eob) { /* A previous substring matched so output that first */ - memcpy(&data->state.scratch[si], SMTP_EOB, smtp->eob); - si += smtp->eob; + memcpy(&scratch[si], &SMTP_EOB[eob_sent], smtp->eob - eob_sent); + si += smtp->eob - eob_sent; /* Then compare the first byte */ if(SMTP_EOB[0] == data->req.upload_fromhere[i]) @@ -2339,6 +1623,8 @@ CURLcode Curl_smtp_escape_eob(struct connectdata *conn, ssize_t nread) else smtp->eob = 0; + eob_sent = 0; + /* Reset the trailing CRLF flag as there was more data */ smtp->trailing_crlf = FALSE; } @@ -2346,31 +1632,38 @@ CURLcode Curl_smtp_escape_eob(struct connectdata *conn, ssize_t nread) /* Do we have a match for CRLF. as per RFC-5321, sect. 4.5.2 */ if(SMTP_EOB_FIND_LEN == smtp->eob) { /* Copy the replacement data to the target buffer */ - memcpy(&data->state.scratch[si], SMTP_EOB_REPL, SMTP_EOB_REPL_LEN); - si += SMTP_EOB_REPL_LEN; + memcpy(&scratch[si], &SMTP_EOB_REPL[eob_sent], + SMTP_EOB_REPL_LEN - eob_sent); + si += SMTP_EOB_REPL_LEN - eob_sent; smtp->eob = 0; + eob_sent = 0; } else if(!smtp->eob) - data->state.scratch[si++] = data->req.upload_fromhere[i]; + scratch[si++] = data->req.upload_fromhere[i]; } - if(smtp->eob) { + if(smtp->eob - eob_sent) { /* A substring matched before processing ended so output that now */ - memcpy(&data->state.scratch[si], SMTP_EOB, smtp->eob); - si += smtp->eob; - smtp->eob = 0; + memcpy(&scratch[si], &SMTP_EOB[eob_sent], smtp->eob - eob_sent); + si += smtp->eob - eob_sent; } + /* Only use the new buffer if we replaced something */ if(si != nread) { - /* Only use the new buffer if we replaced something */ - nread = si; - /* Upload from the new (replaced) buffer instead */ - data->req.upload_fromhere = data->state.scratch; + data->req.upload_fromhere = scratch; + + /* Save the buffer so it can be freed later */ + data->state.scratch = scratch; + + /* Free the old scratch buffer */ + free(oldscratch); /* Set the new amount too */ - data->req.upload_present = nread; + data->req.upload_present = si; } + else + free(newscratch); return CURLE_OK; } diff --git a/lib/smtp.h b/lib/smtp.h index db1b1e6..9fbe0c5 100644 --- a/lib/smtp.h +++ b/lib/smtp.h @@ -23,6 +23,7 @@ ***************************************************************************/ #include "pingpong.h" +#include "curl_sasl.h" /**************************************************************************** * SMTP unique setup @@ -36,20 +37,7 @@ typedef enum { SMTP_STARTTLS, SMTP_UPGRADETLS, /* asynchronously upgrade the connection to SSL/TLS (multi mode only) */ - SMTP_AUTH_PLAIN, - SMTP_AUTH_LOGIN, - SMTP_AUTH_LOGIN_PASSWD, - SMTP_AUTH_CRAMMD5, - SMTP_AUTH_DIGESTMD5, - SMTP_AUTH_DIGESTMD5_RESP, - SMTP_AUTH_NTLM, - SMTP_AUTH_NTLM_TYPE2MSG, - SMTP_AUTH_GSSAPI, - SMTP_AUTH_GSSAPI_TOKEN, - SMTP_AUTH_GSSAPI_NO_DATA, - SMTP_AUTH_XOAUTH2, - SMTP_AUTH_CANCEL, - SMTP_AUTH_FINAL, + SMTP_AUTH, SMTP_COMMAND, /* VRFY, EXPN, NOOP, RSET and HELP */ SMTP_MAIL, /* MAIL FROM */ SMTP_RCPT, /* RCPT TO */ @@ -79,14 +67,11 @@ struct smtp_conn { smtpstate state; /* Always use smtp.c:state() to change state! */ bool ssldone; /* Is connect() over SSL done? */ char *domain; /* Client address/name to send in the EHLO */ - unsigned int authmechs; /* Accepted authentication mechanisms */ - unsigned int prefmech; /* Preferred authentication mechanism */ - unsigned int authused; /* Auth mechanism used for the connection */ + struct SASL sasl; /* SASL-related storage */ bool tls_supported; /* StartTLS capability supported by server */ bool size_supported; /* If server supports SIZE extension according to RFC 1870 */ bool auth_supported; /* AUTH capability supported by server */ - bool mutual_auth; /* Mutual authentication enabled (GSSAPI only) */ }; extern const struct Curl_handler Curl_handler_smtp; @@ -101,6 +86,6 @@ extern const struct Curl_handler Curl_handler_smtps; #define SMTP_EOB_REPL "\x0d\x0a\x2e\x2e" #define SMTP_EOB_REPL_LEN 4 -CURLcode Curl_smtp_escape_eob(struct connectdata *conn, ssize_t nread); +CURLcode Curl_smtp_escape_eob(struct connectdata *conn, const ssize_t nread); #endif /* HEADER_CURL_SMTP_H */ diff --git a/lib/socks.c b/lib/socks.c index 028475c..7d3f782 100644 --- a/lib/socks.c +++ b/lib/socks.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2013, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -127,7 +127,7 @@ CURLcode Curl_SOCKS4(const char *proxy_name, return CURLE_OPERATION_TIMEDOUT; } - curlx_nonblock(sock, FALSE); + (void)curlx_nonblock(sock, FALSE); infof(data, "SOCKS4 communication to %s:%d\n", hostname, remote_port); @@ -238,7 +238,7 @@ CURLcode Curl_SOCKS4(const char *proxy_name, code = Curl_write_plain(conn, sock, (char *)socksreq, packetsize + hostnamelen, &written); - if((code != CURLE_OK) || (written != packetsize + hostnamelen)) { + if(code || (written != packetsize + hostnamelen)) { failf(data, "Failed to send SOCKS4 connect request."); return CURLE_COULDNT_CONNECT; } @@ -247,7 +247,7 @@ CURLcode Curl_SOCKS4(const char *proxy_name, hostnamelen = (ssize_t)strlen(hostname) + 1; code = Curl_write_plain(conn, sock, (char *)hostname, hostnamelen, &written); - if((code != CURLE_OK) || (written != hostnamelen)) { + if(code || (written != hostnamelen)) { failf(data, "Failed to send SOCKS4 connect request."); return CURLE_COULDNT_CONNECT; } @@ -258,7 +258,7 @@ CURLcode Curl_SOCKS4(const char *proxy_name, /* Receive response */ result = Curl_blockread_all(conn, sock, (char *)socksreq, packetsize, &actualread); - if((result != CURLE_OK) || (actualread != packetsize)) { + if(result || (actualread != packetsize)) { failf(data, "Failed to receive SOCKS4 connect request ack."); return CURLE_COULDNT_CONNECT; } @@ -335,7 +335,7 @@ CURLcode Curl_SOCKS4(const char *proxy_name, } } - curlx_nonblock(sock, TRUE); + (void)curlx_nonblock(sock, TRUE); return CURLE_OK; /* Proxy was successful! */ } @@ -382,7 +382,7 @@ CURLcode Curl_SOCKS5(const char *proxy_name, /* RFC1928 chapter 5 specifies max 255 chars for domain name in packet */ if(!socks5_resolve_local && hostname_len > 255) { - infof(conn->data,"SOCKS5: server resolving disabled for hostnames of " + infof(conn->data, "SOCKS5: server resolving disabled for hostnames of " "length > 255 [actual len=%zu]\n", hostname_len); socks5_resolve_local = TRUE; } @@ -396,7 +396,7 @@ CURLcode Curl_SOCKS5(const char *proxy_name, return CURLE_OPERATION_TIMEDOUT; } - curlx_nonblock(sock, TRUE); + (void)curlx_nonblock(sock, TRUE); /* wait until socket gets connected */ result = Curl_socket_ready(CURL_SOCKET_BAD, sock, timeout); @@ -427,16 +427,16 @@ CURLcode Curl_SOCKS5(const char *proxy_name, socksreq[3] = 2; /* username/password */ #endif - curlx_nonblock(sock, FALSE); + (void)curlx_nonblock(sock, FALSE); code = Curl_write_plain(conn, sock, (char *)socksreq, (2 + (int)socksreq[1]), &written); - if((code != CURLE_OK) || (written != (2 + (int)socksreq[1]))) { + if(code || (written != (2 + (int)socksreq[1]))) { failf(data, "Unable to send initial SOCKS5 request."); return CURLE_COULDNT_CONNECT; } - curlx_nonblock(sock, TRUE); + (void)curlx_nonblock(sock, TRUE); result = Curl_socket_ready(sock, CURL_SOCKET_BAD, timeout); @@ -454,10 +454,10 @@ CURLcode Curl_SOCKS5(const char *proxy_name, return CURLE_RECV_ERROR; } - curlx_nonblock(sock, FALSE); + (void)curlx_nonblock(sock, FALSE); result=Curl_blockread_all(conn, sock, (char *)socksreq, 2, &actualread); - if((result != CURLE_OK) || (actualread != 2)) { + if(result || (actualread != 2)) { failf(data, "Unable to receive initial SOCKS5 response."); return CURLE_COULDNT_CONNECT; } @@ -473,7 +473,7 @@ CURLcode Curl_SOCKS5(const char *proxy_name, #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI) else if(socksreq[1] == 1) { code = Curl_SOCKS5_gssapi_negotiate(sockindex, conn); - if(code != CURLE_OK) { + if(code) { failf(data, "Unable to negotiate SOCKS5 GSS-API context."); return CURLE_COULDNT_CONNECT; } @@ -510,13 +510,13 @@ CURLcode Curl_SOCKS5(const char *proxy_name, len += proxy_password_len; code = Curl_write_plain(conn, sock, (char *)socksreq, len, &written); - if((code != CURLE_OK) || (len != written)) { + if(code || (len != written)) { failf(data, "Failed to send SOCKS5 sub-negotiation request."); return CURLE_COULDNT_CONNECT; } result=Curl_blockread_all(conn, sock, (char *)socksreq, 2, &actualread); - if((result != CURLE_OK) || (actualread != 2)) { + if(result || (actualread != 2)) { failf(data, "Unable to receive SOCKS5 sub-negotiation response."); return CURLE_COULDNT_CONNECT; } @@ -583,7 +583,7 @@ CURLcode Curl_SOCKS5(const char *proxy_name, if(rc == CURLRESOLV_PENDING) { /* this requires that we're in "wait for resolve" state */ code = Curl_resolver_wait_resolv(conn, &dns); - if(code != CURLE_OK) + if(code) return code; } @@ -642,7 +642,7 @@ CURLcode Curl_SOCKS5(const char *proxy_name, #endif code = Curl_write_plain(conn, sock, (char *)socksreq, len, &written); - if((code != CURLE_OK) || (len != written)) { + if(code || (len != written)) { failf(data, "Failed to send SOCKS5 connect request."); return CURLE_COULDNT_CONNECT; } @@ -658,7 +658,7 @@ CURLcode Curl_SOCKS5(const char *proxy_name, result = Curl_blockread_all(conn, sock, (char *)socksreq, len, &actualread); - if((result != CURLE_OK) || (len != actualread)) { + if(result || (len != actualread)) { failf(data, "Failed to receive SOCKS5 connect request ack."); return CURLE_COULDNT_CONNECT; } @@ -738,7 +738,7 @@ CURLcode Curl_SOCKS5(const char *proxy_name, len -= 10; result = Curl_blockread_all(conn, sock, (char *)&socksreq[10], len, &actualread); - if((result != CURLE_OK) || (len != actualread)) { + if(result || (len != actualread)) { failf(data, "Failed to receive SOCKS5 connect request ack."); return CURLE_COULDNT_CONNECT; } @@ -747,7 +747,7 @@ CURLcode Curl_SOCKS5(const char *proxy_name, } #endif - curlx_nonblock(sock, TRUE); + (void)curlx_nonblock(sock, TRUE); return CURLE_OK; /* Proxy was successful! */ } diff --git a/lib/socks_gssapi.c b/lib/socks_gssapi.c index 0eaa74c..8e575c2 100644 --- a/lib/socks_gssapi.c +++ b/lib/socks_gssapi.c @@ -6,7 +6,7 @@ * \___|\___/|_| \_\_____| * * Copyright (C) 2009, 2011, Markus Moeller, - * Copyright (C) 2012, Daniel Stenberg, , et al. + * Copyright (C) 2012 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -23,16 +23,7 @@ #include "curl_setup.h" -#ifndef CURL_DISABLE_PROXY - -#ifdef HAVE_GSSAPI -#ifdef HAVE_OLD_GSSMIT -#define GSS_C_NT_HOSTBASED_SERVICE gss_nt_service_name -#define NCOMPAT 1 -#endif -#ifndef gss_nt_service_name -#define gss_nt_service_name GSS_C_NT_HOSTBASED_SERVICE -#endif +#if defined(HAVE_GSSAPI) && !defined(CURL_DISABLE_PROXY) #include "curl_gssapi.h" #include "urldata.h" @@ -41,10 +32,7 @@ #include "timeval.h" #include "socks.h" #include "warnless.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include - +#include "curl_printf.h" #include "curl_memory.h" /* The last #include file should be: */ #include "memdebug.h" @@ -60,7 +48,7 @@ static int check_gss_err(struct SessionHandle *data, const char* function) { if(GSS_ERROR(major_status)) { - OM_uint32 maj_stat,min_stat; + OM_uint32 maj_stat, min_stat; OM_uint32 msg_ctx = 0; gss_buffer_desc status_string; char buf[1024]; @@ -104,10 +92,10 @@ static int check_gss_err(struct SessionHandle *data, gss_release_buffer(&min_stat, &status_string); } failf(data, "GSS-API error: %s failed:\n%s", function, buf); - return(1); + return 1; } - return(0); + return 0; } CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex, @@ -143,7 +131,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex, */ /* prepare service name */ - if(strchr(serviceptr,'/')) { + if(strchr(serviceptr, '/')) { service.value = malloc(strlen(serviceptr)); if(!service.value) return CURLE_OUT_OF_MEMORY; @@ -162,13 +150,13 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex, serviceptr, conn->proxy.name); gss_major_status = gss_import_name(&gss_minor_status, &service, - gss_nt_service_name, &server); + GSS_C_NT_HOSTBASED_SERVICE, &server); } gss_release_buffer(&gss_status, &service); /* clear allocated memory */ - if(check_gss_err(data,gss_major_status, - gss_minor_status,"gss_import_name()")) { + if(check_gss_err(data, gss_major_status, + gss_minor_status, "gss_import_name()")) { failf(data, "Failed to create service name."); gss_release_name(&gss_status, &server); return CURLE_COULDNT_CONNECT; @@ -185,12 +173,13 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex, NULL, gss_token, &gss_send_token, + TRUE, &gss_ret_flags); if(gss_token != GSS_C_NO_BUFFER) gss_release_buffer(&gss_status, &gss_recv_token); - if(check_gss_err(data,gss_major_status, - gss_minor_status,"gss_init_sec_context")) { + if(check_gss_err(data, gss_major_status, + gss_minor_status, "gss_init_sec_context")) { gss_release_name(&gss_status, &server); gss_release_buffer(&gss_status, &gss_recv_token); gss_release_buffer(&gss_status, &gss_send_token); @@ -203,10 +192,10 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex, socksreq[0] = 1; /* GSS-API subnegotiation version */ socksreq[1] = 1; /* authentication message type */ us_length = htons((short)gss_send_token.length); - memcpy(socksreq+2,&us_length,sizeof(short)); + memcpy(socksreq+2, &us_length, sizeof(short)); code = Curl_write_plain(conn, sock, (char *)socksreq, 4, &written); - if((code != CURLE_OK) || (4 != written)) { + if(code || (4 != written)) { failf(data, "Failed to send GSS-API authentication request."); gss_release_name(&gss_status, &server); gss_release_buffer(&gss_status, &gss_recv_token); @@ -218,7 +207,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex, code = Curl_write_plain(conn, sock, (char *)gss_send_token.value, gss_send_token.length, &written); - if((code != CURLE_OK) || ((ssize_t)gss_send_token.length != written)) { + if(code || ((ssize_t)gss_send_token.length != written)) { failf(data, "Failed to send GSS-API authentication token."); gss_release_name(&gss_status, &server); gss_release_buffer(&gss_status, &gss_recv_token); @@ -244,7 +233,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex, */ result=Curl_blockread_all(conn, sock, (char *)socksreq, 4, &actualread); - if(result != CURLE_OK || actualread != 4) { + if(result || (actualread != 4)) { failf(data, "Failed to receive GSS-API authentication response."); gss_release_name(&gss_status, &server); gss_delete_sec_context(&gss_status, &gss_context, NULL); @@ -285,7 +274,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex, result=Curl_blockread_all(conn, sock, (char *)gss_recv_token.value, gss_recv_token.length, &actualread); - if(result != CURLE_OK || actualread != us_length) { + if(result || (actualread != us_length)) { failf(data, "Failed to receive GSS-API authentication token."); gss_release_name(&gss_status, &server); gss_release_buffer(&gss_status, &gss_recv_token); @@ -302,8 +291,8 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex, gss_major_status = gss_inquire_context (&gss_minor_status, gss_context, &gss_client_name, NULL, NULL, NULL, NULL, NULL, NULL); - if(check_gss_err(data,gss_major_status, - gss_minor_status,"gss_inquire_context")) { + if(check_gss_err(data, gss_major_status, + gss_minor_status, "gss_inquire_context")) { gss_delete_sec_context(&gss_status, &gss_context, NULL); gss_release_name(&gss_status, &gss_client_name); failf(data, "Failed to determine user name."); @@ -311,8 +300,8 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex, } gss_major_status = gss_display_name(&gss_minor_status, gss_client_name, &gss_send_token, NULL); - if(check_gss_err(data,gss_major_status, - gss_minor_status,"gss_display_name")) { + if(check_gss_err(data, gss_major_status, + gss_minor_status, "gss_display_name")) { gss_delete_sec_context(&gss_status, &gss_context, NULL); gss_release_name(&gss_status, &gss_client_name); gss_release_buffer(&gss_status, &gss_send_token); @@ -383,7 +372,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex, */ if(data->set.socks5_gssapi_nec) { us_length = htons((short)1); - memcpy(socksreq+2,&us_length,sizeof(short)); + memcpy(socksreq+2, &us_length, sizeof(short)); } else { gss_send_token.length = 1; @@ -398,7 +387,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex, GSS_C_QOP_DEFAULT, &gss_send_token, &gss_conf_state, &gss_w_token); - if(check_gss_err(data,gss_major_status,gss_minor_status,"gss_wrap")) { + if(check_gss_err(data, gss_major_status, gss_minor_status, "gss_wrap")) { gss_release_buffer(&gss_status, &gss_send_token); gss_release_buffer(&gss_status, &gss_w_token); gss_delete_sec_context(&gss_status, &gss_context, NULL); @@ -408,11 +397,11 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex, gss_release_buffer(&gss_status, &gss_send_token); us_length = htons((short)gss_w_token.length); - memcpy(socksreq+2,&us_length,sizeof(short)); + memcpy(socksreq+2, &us_length, sizeof(short)); } code = Curl_write_plain(conn, sock, (char *)socksreq, 4, &written); - if((code != CURLE_OK) || (4 != written)) { + if(code || (4 != written)) { failf(data, "Failed to send GSS-API encryption request."); gss_release_buffer(&gss_status, &gss_w_token); gss_delete_sec_context(&gss_status, &gss_context, NULL); @@ -422,7 +411,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex, if(data->set.socks5_gssapi_nec) { memcpy(socksreq, &gss_enc, 1); code = Curl_write_plain(conn, sock, socksreq, 1, &written); - if((code != CURLE_OK) || ( 1 != written)) { + if(code || ( 1 != written)) { failf(data, "Failed to send GSS-API encryption type."); gss_delete_sec_context(&gss_status, &gss_context, NULL); return CURLE_COULDNT_CONNECT; @@ -431,7 +420,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex, else { code = Curl_write_plain(conn, sock, (char *)gss_w_token.value, gss_w_token.length, &written); - if((code != CURLE_OK) || ((ssize_t)gss_w_token.length != written)) { + if(code || ((ssize_t)gss_w_token.length != written)) { failf(data, "Failed to send GSS-API encryption type."); gss_release_buffer(&gss_status, &gss_w_token); gss_delete_sec_context(&gss_status, &gss_context, NULL); @@ -441,7 +430,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex, } result=Curl_blockread_all(conn, sock, (char *)socksreq, 4, &actualread); - if(result != CURLE_OK || actualread != 4) { + if(result || (actualread != 4)) { failf(data, "Failed to receive GSS-API encryption response."); gss_delete_sec_context(&gss_status, &gss_context, NULL); return CURLE_COULDNT_CONNECT; @@ -474,7 +463,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex, result=Curl_blockread_all(conn, sock, (char *)gss_recv_token.value, gss_recv_token.length, &actualread); - if(result != CURLE_OK || actualread != us_length) { + if(result || (actualread != us_length)) { failf(data, "Failed to receive GSS-API encryptrion type."); gss_release_buffer(&gss_status, &gss_recv_token); gss_delete_sec_context(&gss_status, &gss_context, NULL); @@ -486,7 +475,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex, &gss_recv_token, &gss_w_token, 0, GSS_C_QOP_DEFAULT); - if(check_gss_err(data,gss_major_status,gss_minor_status,"gss_unwrap")) { + if(check_gss_err(data, gss_major_status, gss_minor_status, "gss_unwrap")) { gss_release_buffer(&gss_status, &gss_recv_token); gss_release_buffer(&gss_status, &gss_w_token); gss_delete_sec_context(&gss_status, &gss_context, NULL); @@ -503,7 +492,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex, return CURLE_COULDNT_CONNECT; } - memcpy(socksreq,gss_w_token.value,gss_w_token.length); + memcpy(socksreq, gss_w_token.value, gss_w_token.length); gss_release_buffer(&gss_status, &gss_w_token); } else { @@ -515,7 +504,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex, return CURLE_COULDNT_CONNECT; } - memcpy(socksreq,gss_recv_token.value,gss_recv_token.length); + memcpy(socksreq, gss_recv_token.value, gss_recv_token.length); gss_release_buffer(&gss_status, &gss_recv_token); } @@ -529,6 +518,5 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex, return CURLE_OK; } -#endif -#endif /* CURL_DISABLE_PROXY */ +#endif /* HAVE_GSSAPI && !CURL_DISABLE_PROXY */ diff --git a/lib/socks_sspi.c b/lib/socks_sspi.c index 82684e0..a7708b2 100644 --- a/lib/socks_sspi.c +++ b/lib/socks_sspi.c @@ -5,8 +5,8 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * + * Copyright (C) 2012 - 2015, Daniel Stenberg, , et al. * Copyright (C) 2009, 2011, Markus Moeller, - * Copyright (C) 2012 - 2014, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -34,10 +34,7 @@ #include "curl_sspi.h" #include "curl_multibyte.h" #include "warnless.h" - -#define _MPRINTF_REPLACE /* use the internal *printf() functions */ -#include - +#include "curl_printf.h" #include "curl_memory.h" /* The last #include file should be: */ #include "memdebug.h" @@ -107,8 +104,8 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex, service_name = malloc(strlen(service) + strlen(conn->proxy.name) + 2); if(!service_name) return CURLE_OUT_OF_MEMORY; - snprintf(service_name,strlen(service) +strlen(conn->proxy.name)+2,"%s/%s", - service,conn->proxy.name); + snprintf(service_name, strlen(service) +strlen(conn->proxy.name)+2, + "%s/%s", service, conn->proxy.name); } input_desc.cBuffers = 1; @@ -146,7 +143,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex, if(check_sspi_err(conn, status, "AcquireCredentialsHandle")) { failf(data, "Failed to acquire credentials."); - Curl_safefree(service_name); + free(service_name); s_pSecFn->FreeCredentialsHandle(&cred_handle); return CURLE_COULDNT_CONNECT; } @@ -185,7 +182,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex, } if(check_sspi_err(conn, status, "InitializeSecurityContext")) { - Curl_safefree(service_name); + free(service_name); s_pSecFn->FreeCredentialsHandle(&cred_handle); s_pSecFn->DeleteSecurityContext(&sspi_context); if(sspi_recv_token.pvBuffer) @@ -201,9 +198,9 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex, memcpy(socksreq+2, &us_length, sizeof(short)); code = Curl_write_plain(conn, sock, (char *)socksreq, 4, &written); - if((code != CURLE_OK) || (4 != written)) { + if(code || (4 != written)) { failf(data, "Failed to send SSPI authentication request."); - Curl_safefree(service_name); + free(service_name); if(sspi_send_token.pvBuffer) s_pSecFn->FreeContextBuffer(sspi_send_token.pvBuffer); if(sspi_recv_token.pvBuffer) @@ -215,9 +212,9 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex, code = Curl_write_plain(conn, sock, (char *)sspi_send_token.pvBuffer, sspi_send_token.cbBuffer, &written); - if((code != CURLE_OK) || (sspi_send_token.cbBuffer != (size_t)written)) { + if(code || (sspi_send_token.cbBuffer != (size_t)written)) { failf(data, "Failed to send SSPI authentication token."); - Curl_safefree(service_name); + free(service_name); if(sspi_send_token.pvBuffer) s_pSecFn->FreeContextBuffer(sspi_send_token.pvBuffer); if(sspi_recv_token.pvBuffer) @@ -255,9 +252,9 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex, */ result = Curl_blockread_all(conn, sock, (char *)socksreq, 4, &actualread); - if(result != CURLE_OK || actualread != 4) { + if(result || (actualread != 4)) { failf(data, "Failed to receive SSPI authentication response."); - Curl_safefree(service_name); + free(service_name); s_pSecFn->FreeCredentialsHandle(&cred_handle); s_pSecFn->DeleteSecurityContext(&sspi_context); return CURLE_COULDNT_CONNECT; @@ -267,7 +264,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex, if(socksreq[1] == 255) { /* status / message type */ failf(data, "User was rejected by the SOCKS5 server (%u %u).", (unsigned int)socksreq[0], (unsigned int)socksreq[1]); - Curl_safefree(service_name); + free(service_name); s_pSecFn->FreeCredentialsHandle(&cred_handle); s_pSecFn->DeleteSecurityContext(&sspi_context); return CURLE_COULDNT_CONNECT; @@ -276,7 +273,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex, if(socksreq[1] != 1) { /* status / messgae type */ failf(data, "Invalid SSPI authentication response type (%u %u).", (unsigned int)socksreq[0], (unsigned int)socksreq[1]); - Curl_safefree(service_name); + free(service_name); s_pSecFn->FreeCredentialsHandle(&cred_handle); s_pSecFn->DeleteSecurityContext(&sspi_context); return CURLE_COULDNT_CONNECT; @@ -289,7 +286,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex, sspi_recv_token.pvBuffer = malloc(us_length); if(!sspi_recv_token.pvBuffer) { - Curl_safefree(service_name); + free(service_name); s_pSecFn->FreeCredentialsHandle(&cred_handle); s_pSecFn->DeleteSecurityContext(&sspi_context); return CURLE_OUT_OF_MEMORY; @@ -297,9 +294,9 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex, result = Curl_blockread_all(conn, sock, (char *)sspi_recv_token.pvBuffer, sspi_recv_token.cbBuffer, &actualread); - if(result != CURLE_OK || actualread != us_length) { + if(result || (actualread != us_length)) { failf(data, "Failed to receive SSPI authentication token."); - Curl_safefree(service_name); + free(service_name); if(sspi_recv_token.pvBuffer) s_pSecFn->FreeContextBuffer(sspi_recv_token.pvBuffer); s_pSecFn->FreeCredentialsHandle(&cred_handle); @@ -310,7 +307,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex, context_handle = &sspi_context; } - Curl_safefree(service_name); + free(service_name); /* Everything is good so far, user was authenticated! */ status = s_pSecFn->QueryCredentialsAttributes(&cred_handle, @@ -405,7 +402,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex, return CURLE_OUT_OF_MEMORY; } - memcpy(sspi_w_token[1].pvBuffer,&gss_enc,1); + memcpy(sspi_w_token[1].pvBuffer, &gss_enc, 1); sspi_w_token[2].BufferType = SECBUFFER_PADDING; sspi_w_token[2].cbBuffer = sspi_sizes.cbBlockSize; sspi_w_token[2].pvBuffer = malloc(sspi_sizes.cbBlockSize); @@ -459,11 +456,11 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex, sspi_w_token[2].cbBuffer = 0; us_length = htons((short)sspi_send_token.cbBuffer); - memcpy(socksreq+2,&us_length,sizeof(short)); + memcpy(socksreq+2, &us_length, sizeof(short)); } code = Curl_write_plain(conn, sock, (char *)socksreq, 4, &written); - if((code != CURLE_OK) || (4 != written)) { + if(code || (4 != written)) { failf(data, "Failed to send SSPI encryption request."); if(sspi_send_token.pvBuffer) s_pSecFn->FreeContextBuffer(sspi_send_token.pvBuffer); @@ -472,9 +469,9 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex, } if(data->set.socks5_gssapi_nec) { - memcpy(socksreq,&gss_enc,1); + memcpy(socksreq, &gss_enc, 1); code = Curl_write_plain(conn, sock, (char *)socksreq, 1, &written); - if((code != CURLE_OK) || (1 != written)) { + if(code || (1 != written)) { failf(data, "Failed to send SSPI encryption type."); s_pSecFn->DeleteSecurityContext(&sspi_context); return CURLE_COULDNT_CONNECT; @@ -483,7 +480,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex, else { code = Curl_write_plain(conn, sock, (char *)sspi_send_token.pvBuffer, sspi_send_token.cbBuffer, &written); - if((code != CURLE_OK) || (sspi_send_token.cbBuffer != (size_t)written)) { + if(code || (sspi_send_token.cbBuffer != (size_t)written)) { failf(data, "Failed to send SSPI encryption type."); if(sspi_send_token.pvBuffer) s_pSecFn->FreeContextBuffer(sspi_send_token.pvBuffer); @@ -495,7 +492,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex, } result = Curl_blockread_all(conn, sock, (char *)socksreq, 4, &actualread); - if(result != CURLE_OK || actualread != 4) { + if(result || (actualread != 4)) { failf(data, "Failed to receive SSPI encryption response."); s_pSecFn->DeleteSecurityContext(&sspi_context); return CURLE_COULDNT_CONNECT; @@ -529,7 +526,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex, result = Curl_blockread_all(conn, sock, (char *)sspi_w_token[0].pvBuffer, sspi_w_token[0].cbBuffer, &actualread); - if(result != CURLE_OK || actualread != us_length) { + if(result || (actualread != us_length)) { failf(data, "Failed to receive SSPI encryption type."); s_pSecFn->FreeContextBuffer(sspi_w_token[0].pvBuffer); s_pSecFn->DeleteSecurityContext(&sspi_context); @@ -570,7 +567,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex, return CURLE_COULDNT_CONNECT; } - memcpy(socksreq,sspi_w_token[1].pvBuffer,sspi_w_token[1].cbBuffer); + memcpy(socksreq, sspi_w_token[1].pvBuffer, sspi_w_token[1].cbBuffer); s_pSecFn->FreeContextBuffer(sspi_w_token[0].pvBuffer); s_pSecFn->FreeContextBuffer(sspi_w_token[1].pvBuffer); } @@ -582,7 +579,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex, s_pSecFn->DeleteSecurityContext(&sspi_context); return CURLE_COULDNT_CONNECT; } - memcpy(socksreq,sspi_w_token[0].pvBuffer,sspi_w_token[0].cbBuffer); + memcpy(socksreq, sspi_w_token[0].pvBuffer, sspi_w_token[0].cbBuffer); s_pSecFn->FreeContextBuffer(sspi_w_token[0].pvBuffer); } diff --git a/lib/splay.c b/lib/splay.c index 5bb7065..b87b6cf 100644 --- a/lib/splay.c +++ b/lib/splay.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1997 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1997 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -101,13 +101,13 @@ struct Curl_tree *Curl_splayinsert(struct timeval i, struct Curl_tree *t, struct Curl_tree *node) { - static const struct timeval KEY_NOTUSED = {-1,-1}; /* will *NEVER* appear */ + static const struct timeval KEY_NOTUSED = {-1, -1}; /* will *NEVER* appear */ if(node == NULL) return t; if(t != NULL) { - t = Curl_splay(i,t); + t = Curl_splay(i, t); if(compare(i, t->key)==0) { /* There already exists a node in the tree with the very same key. Build a linked list of nodes. We make the new 'node' struct the new master @@ -162,7 +162,7 @@ struct Curl_tree *Curl_splaygetbest(struct timeval i, return NULL; } - t = Curl_splay(i,t); + t = Curl_splay(i, t); if(compare(i, t->key) < 0) { /* too big node, try the smaller chain */ if(t->smaller) @@ -223,7 +223,7 @@ int Curl_splayremovebyaddr(struct Curl_tree *t, struct Curl_tree *removenode, struct Curl_tree **newroot) { - static const struct timeval KEY_NOTUSED = {-1,-1}; /* will *NEVER* appear */ + static const struct timeval KEY_NOTUSED = {-1, -1}; /* will *NEVER* appear */ struct Curl_tree *x; if(!t || !removenode) diff --git a/lib/ssh.c b/lib/ssh.c index 887e10f..94195a7 100644 --- a/lib/ssh.c +++ b/lib/ssh.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -83,10 +83,7 @@ #include "multiif.h" #include "select.h" #include "warnless.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include - +#include "curl_printf.h" #include "curl_memory.h" /* The last #include file should be: */ #include "memdebug.h" @@ -94,6 +91,9 @@ #ifdef WIN32 # undef PATH_MAX # define PATH_MAX MAX_PATH +# ifndef R_OK +# define R_OK 4 +# endif #endif #ifndef PATH_MAX @@ -543,6 +543,17 @@ static CURLcode ssh_knownhost(struct connectdata *conn) keybit = (keytype == LIBSSH2_HOSTKEY_TYPE_RSA)? LIBSSH2_KNOWNHOST_KEY_SSHRSA:LIBSSH2_KNOWNHOST_KEY_SSHDSS; +#ifdef HAVE_LIBSSH2_KNOWNHOST_CHECKP + keycheck = libssh2_knownhost_checkp(sshc->kh, + conn->host.name, + (conn->remote_port != PORT_SSH)? + conn->remote_port:-1, + remotekey, keylen, + LIBSSH2_KNOWNHOST_TYPE_PLAIN| + LIBSSH2_KNOWNHOST_KEYENC_RAW| + keybit, + &host); +#else keycheck = libssh2_knownhost_check(sshc->kh, conn->host.name, remotekey, keylen, @@ -550,6 +561,7 @@ static CURLcode ssh_knownhost(struct connectdata *conn) LIBSSH2_KNOWNHOST_KEYENC_RAW| keybit, &host); +#endif infof(data, "SSH host check: %d, key: %s\n", keycheck, (keycheck <= LIBSSH2_KNOWNHOST_CHECK_MISMATCH)? @@ -588,8 +600,10 @@ static CURLcode ssh_knownhost(struct connectdata *conn) switch(rc) { default: /* unknown return codes will equal reject */ + /* FALLTHROUGH */ case CURLKHSTAT_REJECT: state(conn, SSH_SESSION_FREE); + /* FALLTHROUGH */ case CURLKHSTAT_DEFER: /* DEFER means bail out but keep the SSH_HOSTKEY state */ result = sshc->actualcode = CURLE_PEER_FAILED_VERIFICATION; @@ -732,7 +746,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block) * whatever) is up to us. */ result = ssh_check_fingerprint(conn); - if(result == CURLE_OK) + if(!result) state(conn, SSH_AUTHLIST); /* ssh_check_fingerprint sets state appropriately on error */ break; @@ -786,7 +800,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block) if((data->set.ssh_auth_types & CURLSSH_AUTH_PUBLICKEY) && (strstr(sshc->authlist, "publickey") != NULL)) { char *home = NULL; - bool rsa_pub_empty_but_ok = FALSE; + bool out_of_memory = FALSE; sshc->rsa_pub = sshc->rsa = NULL; @@ -794,34 +808,55 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block) HOME environment variable etc? */ home = curl_getenv("HOME"); - if(data->set.str[STRING_SSH_PUBLIC_KEY] && - !*data->set.str[STRING_SSH_PUBLIC_KEY]) - rsa_pub_empty_but_ok = true; - else if(data->set.str[STRING_SSH_PUBLIC_KEY]) - sshc->rsa_pub = aprintf("%s", data->set.str[STRING_SSH_PUBLIC_KEY]); - else if(home) - sshc->rsa_pub = aprintf("%s/.ssh/id_dsa.pub", home); - else - /* as a final resort, try current dir! */ - sshc->rsa_pub = strdup("id_dsa.pub"); - - if(!rsa_pub_empty_but_ok && (sshc->rsa_pub == NULL)) { - Curl_safefree(home); - state(conn, SSH_SESSION_FREE); - sshc->actualcode = CURLE_OUT_OF_MEMORY; - break; + if(data->set.str[STRING_SSH_PRIVATE_KEY]) + sshc->rsa = strdup(data->set.str[STRING_SSH_PRIVATE_KEY]); + else { + /* If no private key file is specified, try some common paths. */ + if(home) { + /* Try ~/.ssh first. */ + sshc->rsa = aprintf("%s/.ssh/id_rsa", home); + if(!sshc->rsa) + out_of_memory = TRUE; + else if(access(sshc->rsa, R_OK) != 0) { + Curl_safefree(sshc->rsa); + sshc->rsa = aprintf("%s/.ssh/id_dsa", home); + if(!sshc->rsa) + out_of_memory = TRUE; + else if(access(sshc->rsa, R_OK) != 0) { + Curl_safefree(sshc->rsa); + } + } + } + if(!out_of_memory && !sshc->rsa) { + /* Nothing found; try the current dir. */ + sshc->rsa = strdup("id_rsa"); + if(sshc->rsa && access(sshc->rsa, R_OK) != 0) { + Curl_safefree(sshc->rsa); + sshc->rsa = strdup("id_dsa"); + if(sshc->rsa && access(sshc->rsa, R_OK) != 0) { + Curl_safefree(sshc->rsa); + /* Out of guesses. Set to the empty string to avoid + * surprising info messages. */ + sshc->rsa = strdup(""); + } + } + } } - if(data->set.str[STRING_SSH_PRIVATE_KEY]) - sshc->rsa = aprintf("%s", data->set.str[STRING_SSH_PRIVATE_KEY]); - else if(home) - sshc->rsa = aprintf("%s/.ssh/id_dsa", home); - else - /* as a final resort, try current dir! */ - sshc->rsa = strdup("id_dsa"); + /* + * Unless the user explicitly specifies a public key file, let + * libssh2 extract the public key from the private key file. + * This is done by simply passing sshc->rsa_pub = NULL. + */ + if(data->set.str[STRING_SSH_PUBLIC_KEY]) { + sshc->rsa_pub = strdup(data->set.str[STRING_SSH_PUBLIC_KEY]); + if(!sshc->rsa_pub) + out_of_memory = TRUE; + } - if(sshc->rsa == NULL) { - Curl_safefree(home); + if(out_of_memory || sshc->rsa == NULL) { + free(home); + Curl_safefree(sshc->rsa); Curl_safefree(sshc->rsa_pub); state(conn, SSH_SESSION_FREE); sshc->actualcode = CURLE_OUT_OF_MEMORY; @@ -832,10 +867,10 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block) if(!sshc->passphrase) sshc->passphrase = ""; - Curl_safefree(home); + free(home); - infof(data, "Using ssh public key file %s\n", sshc->rsa_pub); - infof(data, "Using ssh private key file %s\n", sshc->rsa); + infof(data, "Using SSH public key file '%s'\n", sshc->rsa_pub); + infof(data, "Using SSH private key file '%s'\n", sshc->rsa); state(conn, SSH_AUTH_PKEY); } @@ -900,6 +935,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block) } else { state(conn, SSH_AUTH_HOST_INIT); + rc = 0; /* clear rc and continue */ } break; @@ -984,11 +1020,11 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block) sshc->sshagent_identity); if(rc < 0) { - if(rc != LIBSSH2_ERROR_EAGAIN) { + if(rc != LIBSSH2_ERROR_EAGAIN) /* tried and failed? go to next identity */ sshc->sshagent_prev_identity = sshc->sshagent_identity; - } - break; + else + break; } } @@ -1002,8 +1038,10 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block) infof(data, "Agent based authentication successful\n"); state(conn, SSH_AUTH_DONE); } - else + else { state(conn, SSH_AUTH_KEY_INIT); + rc = 0; /* clear rc and continue */ + } #endif break; @@ -1702,8 +1740,8 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block) BUFSIZE : curlx_sotouz(data->state.resume_from - passed); size_t actuallyread = - conn->fread_func(data->state.buffer, 1, readthisamountnow, - conn->fread_in); + data->set.fread_func(data->state.buffer, 1, readthisamountnow, + data->set.in); passed += actuallyread; if((actuallyread == 0) || (actuallyread > readthisamountnow)) { @@ -1770,7 +1808,8 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block) break; case SSH_SFTP_CREATE_DIRS: - if((sshc->slash_pos = strchr(sshc->slash_pos, '/')) != NULL) { + sshc->slash_pos = strchr(sshc->slash_pos, '/'); + if(sshc->slash_pos) { *sshc->slash_pos = 0; infof(data, "Creating directory '%s'\n", sftp_scp->path); @@ -1882,7 +1921,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block) } result = Curl_client_write(conn, CLIENTWRITE_BODY, tmpLine, sshc->readdir_len+1); - Curl_safefree(tmpLine); + free(tmpLine); if(result) { state(conn, SSH_STOP); @@ -1998,7 +2037,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block) sshc->readdir_line, sshc->readdir_currLen); - if(result == CURLE_OK) { + if(!result) { /* output debug output if that is requested */ if(data->set.verbose) { @@ -2068,10 +2107,14 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block) if(rc == LIBSSH2_ERROR_EAGAIN) { break; } - else if(rc) { + else if(rc || + !(attrs.flags & LIBSSH2_SFTP_ATTR_SIZE) || + (attrs.filesize == 0)) { /* * libssh2_sftp_open() didn't return an error, so maybe the server * just doesn't support stat() + * OR the server doesn't return a file size with a stat() + * OR file size is 0 */ data->req.size = -1; data->req.maxdownload = -1; @@ -2101,7 +2144,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block) /* from is relative to end of file */ from += size; } - if(from >= size) { + if(from > size) { failf(data, "Offset (%" CURL_FORMAT_CURL_OFF_T ") was beyond file size (%" CURL_FORMAT_CURL_OFF_T ")", from, attrs.filesize); @@ -2202,7 +2245,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block) DEBUGF(infof(data, "SFTP DONE done\n")); /* Check if nextstate is set and move .nextstate could be POSTQUOTE_INIT - After nextstate is executed,the control should come back to + After nextstate is executed, the control should come back to SSH_SFTP_CLOSE to pass the correct result back */ if(sshc->nextstate != SSH_NO_STATE && sshc->nextstate != SSH_SFTP_CLOSE) { @@ -2691,7 +2734,7 @@ static CURLcode ssh_block_statemach(struct connectdata *conn, } #ifdef HAVE_LIBSSH2_SESSION_BLOCK_DIRECTION - if((CURLE_OK == result) && block) { + if(!result && block) { int dir = libssh2_session_block_directions(sshc->ssh_session); curl_socket_t sock = conn->sock[FIRSTSOCKET]; curl_socket_t fd_read = CURL_SOCKET_BAD; @@ -2863,7 +2906,7 @@ static CURLcode scp_doing(struct connectdata *conn, static CURLcode ssh_do(struct connectdata *conn, bool *done) { - CURLcode res; + CURLcode result; bool connected = 0; struct SessionHandle *data = conn->data; struct ssh_conn *sshc = &conn->proto.sshc; @@ -2882,11 +2925,11 @@ static CURLcode ssh_do(struct connectdata *conn, bool *done) Curl_pgrsSetDownloadSize(data, -1); if(conn->handler->protocol & CURLPROTO_SCP) - res = scp_perform(conn, &connected, done); + result = scp_perform(conn, &connected, done); else - res = sftp_perform(conn, &connected, done); + result = sftp_perform(conn, &connected, done); - return res; + return result; } /* BLOCKING, but the function is using the state machine so the only reason @@ -2918,7 +2961,7 @@ static CURLcode ssh_done(struct connectdata *conn, CURLcode status) CURLcode result = CURLE_OK; struct SSHPROTO *sftp_scp = conn->data->req.protop; - if(status == CURLE_OK) { + if(!status) { /* run the state-machine TODO: when the multi interface is used, this _really_ should be using @@ -2946,7 +2989,7 @@ static CURLcode scp_done(struct connectdata *conn, CURLcode status, { (void)premature; /* not used */ - if(status == CURLE_OK) + if(!status) state(conn, SSH_SCP_DONE); return ssh_done(conn, status); @@ -3044,8 +3087,7 @@ CURLcode sftp_perform(struct connectdata *conn, static CURLcode sftp_doing(struct connectdata *conn, bool *dophase_done) { - CURLcode result; - result = ssh_multi_statemach(conn, dophase_done); + CURLcode result = ssh_multi_statemach(conn, dophase_done); if(*dophase_done) { DEBUGF(infof(conn->data, "DO phase is complete\n")); @@ -3082,7 +3124,7 @@ static CURLcode sftp_done(struct connectdata *conn, CURLcode status, { struct ssh_conn *sshc = &conn->proto.sshc; - if(status == CURLE_OK) { + if(!status) { /* Post quote commands are executed after the SFTP_CLOSE state to avoid errors that could happen due to open file handles during POSTQUOTE operation */ @@ -3228,8 +3270,8 @@ get_pathname(const char **cpp, char **path) return CURLE_OK; fail: - Curl_safefree(*path); - return CURLE_QUOTE_ERROR; + Curl_safefree(*path); + return CURLE_QUOTE_ERROR; } diff --git a/lib/ssh.h b/lib/ssh.h index ff2e16b..b3cc54c 100644 --- a/lib/ssh.h +++ b/lib/ssh.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -44,9 +44,9 @@ typedef enum { SSH_AUTH_PKEY, SSH_AUTH_PASS_INIT, SSH_AUTH_PASS, - SSH_AUTH_AGENT_INIT,/* initialize then wait for connection to agent */ - SSH_AUTH_AGENT_LIST,/* ask for list then wait for entire list to come */ - SSH_AUTH_AGENT, /* attempt one key at a time */ + SSH_AUTH_AGENT_INIT, /* initialize then wait for connection to agent */ + SSH_AUTH_AGENT_LIST, /* ask for list then wait for entire list to come */ + SSH_AUTH_AGENT, /* attempt one key at a time */ SSH_AUTH_HOST_INIT, SSH_AUTH_HOST, SSH_AUTH_KEY_INIT, @@ -158,22 +158,34 @@ struct ssh_conn { #ifdef USE_LIBSSH2 +/* Feature detection based on version numbers to better work with + non-configure platforms */ + #if !defined(LIBSSH2_VERSION_NUM) || (LIBSSH2_VERSION_NUM < 0x001000) # error "SCP/SFTP protocols require libssh2 0.16 or later" #endif -#if defined(LIBSSH2_VERSION_NUM) && (LIBSSH2_VERSION_NUM >= 0x010000) -# define HAVE_LIBSSH2_SFTP_SEEK64 1 -#else -# undef HAVE_LIBSSH2_SFTP_SEEK64 +#if LIBSSH2_VERSION_NUM >= 0x010000 +#define HAVE_LIBSSH2_SFTP_SEEK64 1 +#endif + +#if LIBSSH2_VERSION_NUM >= 0x010100 +#define HAVE_LIBSSH2_VERSION 1 #endif -#if defined(LIBSSH2_VERSION_NUM) && (LIBSSH2_VERSION_NUM >= 0x010206) -# define HAVE_LIBSSH2_SCP_SEND64 1 -#else -# undef HAVE_LIBSSH2_SCP_SEND64 +#if LIBSSH2_VERSION_NUM >= 0x010205 +#define HAVE_LIBSSH2_INIT 1 +#define HAVE_LIBSSH2_EXIT 1 #endif +#if LIBSSH2_VERSION_NUM >= 0x010206 +#define HAVE_LIBSSH2_KNOWNHOST_CHECKP 1 +#define HAVE_LIBSSH2_SCP_SEND64 1 +#endif + +#if LIBSSH2_VERSION_NUM >= 0x010208 +#define HAVE_LIBSSH2_SESSION_HANDSHAKE 1 +#endif extern const struct Curl_handler Curl_handler_scp; extern const struct Curl_handler Curl_handler_sftp; diff --git a/lib/strdup.c b/lib/strdup.c index 3b776b1..5685b81 100644 --- a/lib/strdup.c +++ b/lib/strdup.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -19,12 +19,12 @@ * KIND, either express or implied. * ***************************************************************************/ -/* - * This file is 'mem-include-scan' clean. See test 1132. - */ #include "curl_setup.h" - #include "strdup.h" +#include "curl_memory.h" + +/* The last #include file should be: */ +#include "memdebug.h" #ifndef HAVE_STRDUP char *curlx_strdup(const char *str) @@ -44,9 +44,30 @@ char *curlx_strdup(const char *str) if(!newstr) return (char *)NULL; - memcpy(newstr,str,(len+1)*sizeof(char)); + memcpy(newstr, str, (len+1)*sizeof(char)); return newstr; } #endif + +/*************************************************************************** + * + * Curl_memdup(source, length) + * + * Copies the 'source' data to a newly allocated buffer (that is + * returned). Copies 'length' bytes. + * + * Returns the new pointer or NULL on failure. + * + ***************************************************************************/ +char *Curl_memdup(const char *src, size_t length) +{ + char *buffer = malloc(length); + if(!buffer) + return NULL; /* fail */ + + memcpy(buffer, src, length); + + return buffer; +} diff --git a/lib/strdup.h b/lib/strdup.h index 49af911..23a71f8 100644 --- a/lib/strdup.h +++ b/lib/strdup.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2010, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -26,5 +26,6 @@ #ifndef HAVE_STRDUP extern char *curlx_strdup(const char *str); #endif +char *Curl_memdup(const char *src, size_t buffer_length); #endif /* HEADER_CURL_STRDUP_H */ diff --git a/lib/strerror.c b/lib/strerror.c index 66033f2..5657141 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 2004 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 2004 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -40,10 +40,7 @@ #endif #include "strerror.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include - +#include "curl_printf.h" #include "curl_memory.h" /* The last #include file should be: */ #include "memdebug.h" @@ -298,6 +295,12 @@ curl_easy_strerror(CURLcode error) case CURLE_NO_CONNECTION_AVAILABLE: return "The max connection limit is reached"; + case CURLE_SSL_PINNEDPUBKEYNOTMATCH: + return "SSL public key does not match pinned public key"; + + case CURLE_SSL_INVALIDCERTSTATUS: + return "SSL server certificate status verification FAILED"; + /* error codes not used by current libcurl */ case CURLE_OBSOLETE20: case CURLE_OBSOLETE24: @@ -327,7 +330,7 @@ curl_easy_strerror(CURLcode error) */ return "Unknown error"; #else - if(error == CURLE_OK) + if(!error) return "No error"; else return "Error"; @@ -594,7 +597,7 @@ get_winsock_error (int err, char *buf, size_t len) return NULL; } #else - if(err == CURLE_OK) + if(!err) return NULL; else p = "error"; @@ -638,7 +641,7 @@ const char *Curl_strerror(struct connectdata *conn, int err) FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, LANG_NEUTRAL, wbuf, sizeof(wbuf)/sizeof(wchar_t), NULL); - wcstombs(buf,wbuf,max); + wcstombs(buf, wbuf, max); } #else /* 'sys_nerr' is the maximum errno number, it is not widely portable */ @@ -705,9 +708,9 @@ const char *Curl_strerror(struct connectdata *conn, int err) buf[max] = '\0'; /* make sure the string is zero terminated */ /* strip trailing '\r\n' or '\n'. */ - if((p = strrchr(buf,'\n')) != NULL && (p - buf) >= 2) + if((p = strrchr(buf, '\n')) != NULL && (p - buf) >= 2) *p = '\0'; - if((p = strrchr(buf,'\r')) != NULL && (p - buf) >= 1) + if((p = strrchr(buf, '\r')) != NULL && (p - buf) >= 1) *p = '\0'; if(old_errno != ERRNO) @@ -821,6 +824,9 @@ const char *Curl_sspi_strerror (struct connectdata *conn, int err) case SEC_E_OK: txt = "No error"; break; + case CRYPT_E_REVOKED: + txt = "CRYPT_E_REVOKED"; + break; case SEC_E_ALGORITHM_MISMATCH: txt = "SEC_E_ALGORITHM_MISMATCH"; break; @@ -1064,6 +1070,12 @@ const char *Curl_sspi_strerror (struct connectdata *conn, int err) if(err == SEC_E_OK) strncpy(outbuf, txt, outmax); + else if(err == SEC_E_ILLEGAL_MESSAGE) + snprintf(outbuf, outmax, + "SEC_E_ILLEGAL_MESSAGE (0x%04X%04X) - This error usually occurs " + "when a fatal SSL/TLS alert is received (e.g. handshake failed). " + "More detail may be available in the Windows System event log.", + (err >> 16) & 0xffff, err & 0xffff); else { str = txtbuf; snprintf(txtbuf, sizeof(txtbuf), "%s (0x%04X%04X)", @@ -1079,7 +1091,7 @@ const char *Curl_sspi_strerror (struct connectdata *conn, int err) FORMAT_MESSAGE_IGNORE_INSERTS, NULL, err, LANG_NEUTRAL, wbuf, sizeof(wbuf)/sizeof(wchar_t), NULL)) { - wcstombs(msgbuf,wbuf,sizeof(msgbuf)-1); + wcstombs(msgbuf, wbuf, sizeof(msgbuf)-1); msg_formatted = TRUE; } } @@ -1094,9 +1106,9 @@ const char *Curl_sspi_strerror (struct connectdata *conn, int err) if(msg_formatted) { msgbuf[sizeof(msgbuf)-1] = '\0'; /* strip trailing '\r\n' or '\n' */ - if((p = strrchr(msgbuf,'\n')) != NULL && (p - msgbuf) >= 2) + if((p = strrchr(msgbuf, '\n')) != NULL && (p - msgbuf) >= 2) *p = '\0'; - if((p = strrchr(msgbuf,'\r')) != NULL && (p - msgbuf) >= 1) + if((p = strrchr(msgbuf, '\r')) != NULL && (p - msgbuf) >= 1) *p = '\0'; msg = msgbuf; } diff --git a/lib/strtoofft.h b/lib/strtoofft.h index b812a67..75c73d4 100644 --- a/lib/strtoofft.h +++ b/lib/strtoofft.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2010, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -45,7 +45,14 @@ # define curlx_strtoofft strtoll # else # if defined(_MSC_VER) && (_MSC_VER >= 1300) && (_INTEGRAL_MAX_BITS >= 64) - _CRTIMP __int64 __cdecl _strtoi64(const char *, char **, int); +# if defined(_SAL_VERSION) + _Check_return_ _CRTIMP __int64 __cdecl _strtoi64( + _In_z_ const char *_String, + _Out_opt_ _Deref_post_z_ char **_EndPtr, _In_ int _Radix); +# else + _CRTIMP __int64 __cdecl _strtoi64(const char *_String, + char **_EndPtr, int _Radix); +# endif # define curlx_strtoofft _strtoi64 # else curl_off_t curlx_strtoll(const char *nptr, char **endptr, int base); diff --git a/lib/telnet.c b/lib/telnet.c index 1f03a00..aabf99d 100644 --- a/lib/telnet.c +++ b/lib/telnet.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -51,21 +51,19 @@ #include "telnet.h" #include "connect.h" #include "progress.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include +#include "curl_printf.h" #define TELOPTS #define TELCMDS #include "arpa_telnet.h" -#include "curl_memory.h" #include "select.h" #include "strequal.h" #include "rawstr.h" #include "warnless.h" -/* The last #include file should be: */ +/* The last #include files should be: */ +#include "curl_memory.h" #include "memdebug.h" #define SUBBUFSIZE 512 @@ -228,9 +226,9 @@ check_wsock2 ( struct SessionHandle *data ) if(LOBYTE(wsaData.wVersion) != LOBYTE(wVersionRequested) || HIBYTE(wsaData.wVersion) != HIBYTE(wVersionRequested)) { /* Our version isn't supported */ - failf(data,"insufficient winsock version to support " - "telnet"); - return CURLE_FAILED_INIT; + failf(data, "insufficient winsock version to support " + "telnet"); + return CURLE_FAILED_INIT; } /* Our version is supported */ @@ -710,7 +708,6 @@ static void printsub(struct SessionHandle *data, size_t length) /* length of suboption data */ { unsigned int i = 0; - unsigned short *pval; if(data->set.verbose) { if(direction) { @@ -763,9 +760,9 @@ static void printsub(struct SessionHandle *data, switch(pointer[0]) { case CURL_TELOPT_NAWS: - pval = (unsigned short*)(pointer+1); - infof(data, "Width: %hu ; Height: %hu", - ntohs(pval[0]), ntohs(pval[1])); + if(length > 4) + infof(data, "Width: %hu ; Height: %hu", (pointer[1]<<8) | pointer[2], + (pointer[3]<<8) | pointer[4]); break; default: switch(pointer[1]) { @@ -1076,7 +1073,7 @@ CURLcode telrcv(struct connectdata *conn, CLIENTWRITE_BODY, \ (char *)&inbuf[startwrite], \ in-startwrite); \ - if(result != CURLE_OK) \ + if(result) \ return result; \ } \ startwrite = -1 @@ -1177,7 +1174,7 @@ CURLcode telrcv(struct connectdata *conn, if(c == CURL_IAC) tn->telrcv_state = CURL_TS_SE; else - CURL_SB_ACCUM(tn,c); + CURL_SB_ACCUM(tn, c); break; case CURL_TS_SE: @@ -1202,7 +1199,7 @@ CURLcode telrcv(struct connectdata *conn, tn->telrcv_state = CURL_TS_IAC; goto process_iac; } - CURL_SB_ACCUM(tn,c); + CURL_SB_ACCUM(tn, c); tn->telrcv_state = CURL_TS_SB; } else @@ -1230,9 +1227,9 @@ static CURLcode send_telnet_data(struct connectdata *conn, unsigned char outbuf[2]; ssize_t bytes_written, total_written; int out_count; - CURLcode rc = CURLE_OK; + CURLcode result = CURLE_OK; - while(rc == CURLE_OK && nread--) { + while(!result && nread--) { outbuf[0] = *buffer++; out_count = 1; if(outbuf[0] == CURL_IAC) @@ -1247,19 +1244,20 @@ static CURLcode send_telnet_data(struct connectdata *conn, switch (Curl_poll(pfd, 1, -1)) { case -1: /* error, abort writing */ case 0: /* timeout (will never happen) */ - rc = CURLE_SEND_ERROR; + result = CURLE_SEND_ERROR; break; default: /* write! */ bytes_written = 0; - rc = Curl_write(conn, conn->sock[FIRSTSOCKET], outbuf+total_written, - out_count-total_written, &bytes_written); + result = Curl_write(conn, conn->sock[FIRSTSOCKET], + outbuf+total_written, out_count-total_written, + &bytes_written); total_written += bytes_written; break; } - /* handle partial write */ - } while(rc == CURLE_OK && total_written < out_count); + /* handle partial write */ + } while(!result && total_written < out_count); } - return rc; + return result; } static CURLcode telnet_done(struct connectdata *conn, @@ -1282,7 +1280,7 @@ static CURLcode telnet_done(struct connectdata *conn, static CURLcode telnet_do(struct connectdata *conn, bool *done) { - CURLcode code; + CURLcode result; struct SessionHandle *data = conn->data; curl_socket_t sockfd = conn->sock[FIRSTSOCKET]; #ifdef USE_WINSOCK @@ -1315,65 +1313,61 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done) *done = TRUE; /* unconditionally */ - code = init_telnet(conn); - if(code) - return code; + result = init_telnet(conn); + if(result) + return result; tn = (struct TELNET *)data->req.protop; - code = check_telnet_options(conn); - if(code) - return code; + result = check_telnet_options(conn); + if(result) + return result; #ifdef USE_WINSOCK /* ** This functionality only works with WinSock >= 2.0. So, ** make sure have it. */ - code = check_wsock2(data); - if(code) - return code; + result = check_wsock2(data); + if(result) + return result; /* OK, so we have WinSock 2.0. We need to dynamically */ /* load ws2_32.dll and get the function pointers we need. */ wsock2 = LoadLibrary(TEXT("WS2_32.DLL")); if(wsock2 == NULL) { - failf(data,"failed to load WS2_32.DLL (%d)", ERRNO); + failf(data, "failed to load WS2_32.DLL (%d)", ERRNO); return CURLE_FAILED_INIT; } /* Grab a pointer to WSACreateEvent */ - create_event_func = GetProcAddress(wsock2,"WSACreateEvent"); + create_event_func = GetProcAddress(wsock2, "WSACreateEvent"); if(create_event_func == NULL) { - failf(data,"failed to find WSACreateEvent function (%d)", - ERRNO); + failf(data, "failed to find WSACreateEvent function (%d)", ERRNO); FreeLibrary(wsock2); return CURLE_FAILED_INIT; } /* And WSACloseEvent */ - close_event_func = GetProcAddress(wsock2,"WSACloseEvent"); + close_event_func = GetProcAddress(wsock2, "WSACloseEvent"); if(close_event_func == NULL) { - failf(data,"failed to find WSACloseEvent function (%d)", - ERRNO); + failf(data, "failed to find WSACloseEvent function (%d)", ERRNO); FreeLibrary(wsock2); return CURLE_FAILED_INIT; } /* And WSAEventSelect */ - event_select_func = GetProcAddress(wsock2,"WSAEventSelect"); + event_select_func = GetProcAddress(wsock2, "WSAEventSelect"); if(event_select_func == NULL) { - failf(data,"failed to find WSAEventSelect function (%d)", - ERRNO); + failf(data, "failed to find WSAEventSelect function (%d)", ERRNO); FreeLibrary(wsock2); return CURLE_FAILED_INIT; } /* And WSAEnumNetworkEvents */ - enum_netevents_func = GetProcAddress(wsock2,"WSAEnumNetworkEvents"); + enum_netevents_func = GetProcAddress(wsock2, "WSAEnumNetworkEvents"); if(enum_netevents_func == NULL) { - failf(data,"failed to find WSAEnumNetworkEvents function (%d)", - ERRNO); + failf(data, "failed to find WSAEnumNetworkEvents function (%d)", ERRNO); FreeLibrary(wsock2); return CURLE_FAILED_INIT; } @@ -1386,7 +1380,7 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done) /* First, create a sockets event object */ event_handle = (WSAEVENT)create_event_func(); if(event_handle == WSA_INVALID_EVENT) { - failf(data,"WSACreateEvent failed (%d)", SOCKERRNO); + failf(data, "WSACreateEvent failed (%d)", SOCKERRNO); FreeLibrary(wsock2); return CURLE_FAILED_INIT; } @@ -1427,29 +1421,30 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done) case WAIT_TIMEOUT: { for(;;) { - if(obj_count == 1) { + if(data->set.is_fread_set) { /* read from user-supplied method */ - code = (int)conn->fread_func(buf, 1, BUFSIZE - 1, conn->fread_in); - if(code == CURL_READFUNC_ABORT) { + result = (int)data->set.fread_func(buf, 1, BUFSIZE - 1, + data->set.in); + if(result == CURL_READFUNC_ABORT) { keepon = FALSE; - code = CURLE_READ_ERROR; + result = CURLE_READ_ERROR; break; } - if(code == CURL_READFUNC_PAUSE) + if(result == CURL_READFUNC_PAUSE) break; - if(code == 0) /* no bytes */ + if(result == 0) /* no bytes */ break; - readfile_read = code; /* fall thru with number of bytes read */ + readfile_read = result; /* fall thru with number of bytes read */ } else { /* read from stdin */ if(!PeekNamedPipe(stdin_handle, NULL, 0, NULL, &readfile_read, NULL)) { keepon = FALSE; - code = CURLE_READ_ERROR; + result = CURLE_READ_ERROR; break; } @@ -1459,13 +1454,13 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done) if(!ReadFile(stdin_handle, buf, sizeof(data->state.buffer), &readfile_read, NULL)) { keepon = FALSE; - code = CURLE_READ_ERROR; + result = CURLE_READ_ERROR; break; } } - code = send_telnet_data(conn, buf, readfile_read); - if(code) { + result = send_telnet_data(conn, buf, readfile_read); + if(result) { keepon = FALSE; break; } @@ -1478,12 +1473,12 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done) if(!ReadFile(stdin_handle, buf, sizeof(data->state.buffer), &readfile_read, NULL)) { keepon = FALSE; - code = CURLE_READ_ERROR; + result = CURLE_READ_ERROR; break; } - code = send_telnet_data(conn, buf, readfile_read); - if(code) { + result = send_telnet_data(conn, buf, readfile_read); + if(result) { keepon = FALSE; break; } @@ -1495,20 +1490,20 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done) events.lNetworkEvents = 0; if(SOCKET_ERROR == enum_netevents_func(sockfd, event_handle, &events)) { if((err = SOCKERRNO) != EINPROGRESS) { - infof(data,"WSAEnumNetworkEvents failed (%d)", err); + infof(data, "WSAEnumNetworkEvents failed (%d)", err); keepon = FALSE; - code = CURLE_READ_ERROR; + result = CURLE_READ_ERROR; } break; } if(events.lNetworkEvents & FD_READ) { /* read data from network */ - code = Curl_read(conn, sockfd, buf, BUFSIZE - 1, &nread); + result = Curl_read(conn, sockfd, buf, BUFSIZE - 1, &nread); /* read would've blocked. Loop again */ - if(code == CURLE_AGAIN) + if(result == CURLE_AGAIN) break; /* returned not-zero, this an error */ - else if(code) { + else if(result) { keepon = FALSE; break; } @@ -1519,8 +1514,8 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done) break; } - code = telrcv(conn, (unsigned char *)buf, nread); - if(code) { + result = telrcv(conn, (unsigned char *) buf, nread); + if(result) { keepon = FALSE; break; } @@ -1544,7 +1539,7 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done) now = Curl_tvnow(); if(Curl_tvdiff(now, conn->created) >= data->set.timeout) { failf(data, "Time-out"); - code = CURLE_OPERATION_TIMEDOUT; + result = CURLE_OPERATION_TIMEDOUT; keepon = FALSE; } } @@ -1552,7 +1547,7 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done) /* We called WSACreateEvent, so call WSACloseEvent */ if(!close_event_func(event_handle)) { - infof(data,"WSACloseEvent failed (%d)", SOCKERRNO); + infof(data, "WSACloseEvent failed (%d)", SOCKERRNO); } /* "Forget" pointers into the library we're about to free */ @@ -1563,18 +1558,18 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done) /* We called LoadLibrary, so call FreeLibrary */ if(!FreeLibrary(wsock2)) - infof(data,"FreeLibrary(wsock2) failed (%d)", ERRNO); + infof(data, "FreeLibrary(wsock2) failed (%d)", ERRNO); #else pfd[0].fd = sockfd; pfd[0].events = POLLIN; - if(conn->fread_func != (curl_read_callback)fread) { + if(data->set.fread_func != (curl_read_callback)fread) { poll_cnt = 1; interval_ms = 100; /* poll user-supplied read function */ } else { /* really using fread, so infile is a FILE* */ - pfd[1].fd = fileno((FILE *)conn->fread_in); + pfd[1].fd = fileno((FILE *)data->set.in); pfd[1].events = POLLIN; poll_cnt = 2; interval_ms = 1 * 1000; @@ -1592,12 +1587,12 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done) default: /* read! */ if(pfd[0].revents & POLLIN) { /* read data from network */ - code = Curl_read(conn, sockfd, buf, BUFSIZE - 1, &nread); + result = Curl_read(conn, sockfd, buf, BUFSIZE - 1, &nread); /* read would've blocked. Loop again */ - if(code == CURLE_AGAIN) + if(result == CURLE_AGAIN) break; /* returned not-zero, this an error */ - else if(code) { + else if(result) { keepon = FALSE; break; } @@ -1610,8 +1605,8 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done) total_dl += nread; Curl_pgrsSetDownloadCounter(data, total_dl); - code = telrcv(conn, (unsigned char *)buf, nread); - if(code) { + result = telrcv(conn, (unsigned char *)buf, nread); + if(result) { keepon = FALSE; break; } @@ -1633,7 +1628,7 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done) } else { /* read from user-supplied method */ - nread = (int)conn->fread_func(buf, 1, BUFSIZE - 1, conn->fread_in); + nread = (int)data->set.fread_func(buf, 1, BUFSIZE - 1, data->set.in); if(nread == CURL_READFUNC_ABORT) { keepon = FALSE; break; @@ -1643,8 +1638,8 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done) } if(nread > 0) { - code = send_telnet_data(conn, buf, nread); - if(code) { + result = send_telnet_data(conn, buf, nread); + if(result) { keepon = FALSE; break; } @@ -1661,13 +1656,13 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done) now = Curl_tvnow(); if(Curl_tvdiff(now, conn->created) >= data->set.timeout) { failf(data, "Time-out"); - code = CURLE_OPERATION_TIMEDOUT; + result = CURLE_OPERATION_TIMEDOUT; keepon = FALSE; } } if(Curl_pgrsUpdate(conn)) { - code = CURLE_ABORTED_BY_CALLBACK; + result = CURLE_ABORTED_BY_CALLBACK; break; } } @@ -1675,6 +1670,6 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done) /* mark this as "no further transfer wanted" */ Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL); - return code; + return result; } #endif diff --git a/lib/tftp.c b/lib/tftp.c index e499c45..4c5796f 100644 --- a/lib/tftp.c +++ b/lib/tftp.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -57,14 +57,11 @@ #include "url.h" #include "rawstr.h" #include "speedcheck.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include - -#include "curl_memory.h" +#include "curl_printf.h" #include "select.h" -/* The last #include file should be: */ +/* The last #include files should be: */ +#include "curl_memory.h" #include "memdebug.h" /* RFC2348 allows the block size to be negotiated */ @@ -148,8 +145,8 @@ typedef struct tftp_state_data { /* Forward declarations */ -static CURLcode tftp_rx(tftp_state_data_t *state, tftp_event_t event) ; -static CURLcode tftp_tx(tftp_state_data_t *state, tftp_event_t event) ; +static CURLcode tftp_rx(tftp_state_data_t *state, tftp_event_t event); +static CURLcode tftp_tx(tftp_state_data_t *state, tftp_event_t event); static CURLcode tftp_connect(struct connectdata *conn, bool *done); static CURLcode tftp_disconnect(struct connectdata *conn, bool dead_connection); @@ -221,7 +218,7 @@ static CURLcode tftp_set_timeouts(tftp_state_data_t *state) state->max_time = state->start_time+maxtime; /* Set per-block timeout to total */ - timeout = maxtime ; + timeout = maxtime; /* Average restart after 5 seconds */ state->retry_max = (int)timeout/5; @@ -411,38 +408,38 @@ static size_t tftp_option_add(tftp_state_data_t *state, size_t csize, if(( strlen(option) + csize + 1 ) > (size_t)state->blksize) return 0; strcpy(buf, option); - return( strlen(option) + 1 ); + return strlen(option) + 1; } static CURLcode tftp_connect_for_tx(tftp_state_data_t *state, tftp_event_t event) { - CURLcode res; + CURLcode result; #ifndef CURL_DISABLE_VERBOSE_STRINGS struct SessionHandle *data = state->conn->data; infof(data, "%s\n", "Connected for transmit"); #endif state->state = TFTP_STATE_TX; - res = tftp_set_timeouts(state); - if(res != CURLE_OK) - return(res); + result = tftp_set_timeouts(state); + if(result) + return result; return tftp_tx(state, event); } static CURLcode tftp_connect_for_rx(tftp_state_data_t *state, tftp_event_t event) { - CURLcode res; + CURLcode result; #ifndef CURL_DISABLE_VERBOSE_STRINGS struct SessionHandle *data = state->conn->data; infof(data, "%s\n", "Connected for receive"); #endif state->state = TFTP_STATE_RX; - res = tftp_set_timeouts(state); - if(res != CURLE_OK) - return(res); + result = tftp_set_timeouts(state); + if(result) + return result; return tftp_rx(state, event); } @@ -454,7 +451,7 @@ static CURLcode tftp_send_first(tftp_state_data_t *state, tftp_event_t event) char *filename; char buf[64]; struct SessionHandle *data = state->conn->data; - CURLcode res = CURLE_OK; + CURLcode result = CURLE_OK; /* Set ascii mode if -B flag was used */ if(data->set.prefer_ascii) @@ -469,7 +466,7 @@ static CURLcode tftp_send_first(tftp_state_data_t *state, tftp_event_t event) if(state->retries>state->retry_max) { state->error = TFTP_ERR_NORESPONSE; state->state = TFTP_STATE_FIN; - return res; + return result; } if(data->set.upload) { @@ -534,24 +531,24 @@ static CURLcode tftp_send_first(tftp_state_data_t *state, tftp_event_t event) if(senddata != (ssize_t)sbytes) { failf(data, "%s", Curl_strerror(state->conn, SOCKERRNO)); } - Curl_safefree(filename); + free(filename); break; case TFTP_EVENT_OACK: if(data->set.upload) { - res = tftp_connect_for_tx(state, event); + result = tftp_connect_for_tx(state, event); } else { - res = tftp_connect_for_rx(state, event); + result = tftp_connect_for_rx(state, event); } break; case TFTP_EVENT_ACK: /* Connected for transmit */ - res = tftp_connect_for_tx(state, event); + result = tftp_connect_for_tx(state, event); break; case TFTP_EVENT_DATA: /* Connected for receive */ - res = tftp_connect_for_rx(state, event); + result = tftp_connect_for_rx(state, event); break; case TFTP_EVENT_ERROR: @@ -562,7 +559,8 @@ static CURLcode tftp_send_first(tftp_state_data_t *state, tftp_event_t event) failf(state->conn->data, "tftp_send_first: internal error"); break; } - return res; + + return result; } /* the next blocknum is x + 1 but it needs to wrap at an unsigned 16bit @@ -702,7 +700,7 @@ static CURLcode tftp_tx(tftp_state_data_t *state, tftp_event_t event) struct SessionHandle *data = state->conn->data; ssize_t sbytes; int rblock; - CURLcode res = CURLE_OK; + CURLcode result = CURLE_OK; struct SingleRequest *k = &data->req; switch(event) { @@ -728,7 +726,7 @@ static CURLcode tftp_tx(tftp_state_data_t *state, tftp_event_t event) if(state->retries>state->retry_max) { failf(data, "tftp_tx: giving up waiting for block %d ack", state->block); - res = CURLE_SEND_ERROR; + result = CURLE_SEND_ERROR; } else { /* Re-send the data packet */ @@ -739,10 +737,11 @@ static CURLcode tftp_tx(tftp_state_data_t *state, tftp_event_t event) /* Check all sbytes were sent */ if(sbytes<0) { failf(data, "%s", Curl_strerror(state->conn, SOCKERRNO)); - res = CURLE_SEND_ERROR; + result = CURLE_SEND_ERROR; } } - return res; + + return result; } /* This is the expected packet. Reset the counters and send the next block */ @@ -759,11 +758,13 @@ static CURLcode tftp_tx(tftp_state_data_t *state, tftp_event_t event) state->state = TFTP_STATE_FIN; return CURLE_OK; } - res = Curl_fillreadbuffer(state->conn, state->blksize, &state->sbytes); - if(res) - return res; - sbytes = sendto(state->sockfd, (void *)state->spacket.data, - 4+state->sbytes, SEND_4TH_ARG, + + result = Curl_fillreadbuffer(state->conn, state->blksize, &state->sbytes); + if(result) + return result; + + sbytes = sendto(state->sockfd, (void *) state->spacket.data, + 4 + state->sbytes, SEND_4TH_ARG, (struct sockaddr *)&state->remote_addr, state->remote_addrlen); /* Check all sbytes were sent */ @@ -819,7 +820,7 @@ static CURLcode tftp_tx(tftp_state_data_t *state, tftp_event_t event) break; } - return res; + return result; } /********************************************************** @@ -831,48 +832,47 @@ static CURLcode tftp_tx(tftp_state_data_t *state, tftp_event_t event) **********************************************************/ static CURLcode tftp_translate_code(tftp_error_t error) { - CURLcode code = CURLE_OK; + CURLcode result = CURLE_OK; if(error != TFTP_ERR_NONE) { switch(error) { case TFTP_ERR_NOTFOUND: - code = CURLE_TFTP_NOTFOUND; + result = CURLE_TFTP_NOTFOUND; break; case TFTP_ERR_PERM: - code = CURLE_TFTP_PERM; + result = CURLE_TFTP_PERM; break; case TFTP_ERR_DISKFULL: - code = CURLE_REMOTE_DISK_FULL; + result = CURLE_REMOTE_DISK_FULL; break; case TFTP_ERR_UNDEF: case TFTP_ERR_ILLEGAL: - code = CURLE_TFTP_ILLEGAL; + result = CURLE_TFTP_ILLEGAL; break; case TFTP_ERR_UNKNOWNID: - code = CURLE_TFTP_UNKNOWNID; + result = CURLE_TFTP_UNKNOWNID; break; case TFTP_ERR_EXISTS: - code = CURLE_REMOTE_FILE_EXISTS; + result = CURLE_REMOTE_FILE_EXISTS; break; case TFTP_ERR_NOSUCHUSER: - code = CURLE_TFTP_NOSUCHUSER; + result = CURLE_TFTP_NOSUCHUSER; break; case TFTP_ERR_TIMEOUT: - code = CURLE_OPERATION_TIMEDOUT; + result = CURLE_OPERATION_TIMEDOUT; break; case TFTP_ERR_NORESPONSE: - code = CURLE_COULDNT_CONNECT; + result = CURLE_COULDNT_CONNECT; break; default: - code= CURLE_ABORTED_BY_CALLBACK; + result = CURLE_ABORTED_BY_CALLBACK; break; } } - else { - code = CURLE_OK; - } + else + result = CURLE_OK; - return(code); + return result; } /********************************************************** @@ -885,20 +885,21 @@ static CURLcode tftp_translate_code(tftp_error_t error) static CURLcode tftp_state_machine(tftp_state_data_t *state, tftp_event_t event) { - CURLcode res = CURLE_OK; + CURLcode result = CURLE_OK; struct SessionHandle *data = state->conn->data; + switch(state->state) { case TFTP_STATE_START: DEBUGF(infof(data, "TFTP_STATE_START\n")); - res = tftp_send_first(state, event); + result = tftp_send_first(state, event); break; case TFTP_STATE_RX: DEBUGF(infof(data, "TFTP_STATE_RX\n")); - res = tftp_rx(state, event); + result = tftp_rx(state, event); break; case TFTP_STATE_TX: DEBUGF(infof(data, "TFTP_STATE_TX\n")); - res = tftp_tx(state, event); + result = tftp_tx(state, event); break; case TFTP_STATE_FIN: infof(data, "%s\n", "TFTP finished"); @@ -906,10 +907,11 @@ static CURLcode tftp_state_machine(tftp_state_data_t *state, default: DEBUGF(infof(data, "STATE: %d\n", state->state)); failf(data, "%s", "Internal state machine error"); - res = CURLE_TFTP_ILLEGAL; + result = CURLE_TFTP_ILLEGAL; break; } - return res; + + return result; } /********************************************************** @@ -943,7 +945,6 @@ static CURLcode tftp_disconnect(struct connectdata *conn, bool dead_connection) **********************************************************/ static CURLcode tftp_connect(struct connectdata *conn, bool *done) { - CURLcode code; tftp_state_data_t *state; int blksize, rc; @@ -1017,8 +1018,8 @@ static CURLcode tftp_connect(struct connectdata *conn, bool *done) Curl_pgrsStartNow(conn->data); *done = TRUE; - code = CURLE_OK; - return(code); + + return CURLE_OK; } /********************************************************** @@ -1031,7 +1032,7 @@ static CURLcode tftp_connect(struct connectdata *conn, bool *done) static CURLcode tftp_done(struct connectdata *conn, CURLcode status, bool premature) { - CURLcode code = CURLE_OK; + CURLcode result = CURLE_OK; tftp_state_data_t *state = (tftp_state_data_t *)conn->proto.tftpc; (void)status; /* unused */ @@ -1042,9 +1043,9 @@ static CURLcode tftp_done(struct connectdata *conn, CURLcode status, /* If we have encountered an error */ if(state) - code = tftp_translate_code(state->error); + result = tftp_translate_code(state->error); - return code; + return result; } /********************************************************** @@ -1208,8 +1209,8 @@ static CURLcode tftp_multi_statemach(struct connectdata *conn, bool *done) } else if(event != TFTP_EVENT_NONE) { result = tftp_state_machine(state, event); - if(result != CURLE_OK) - return(result); + if(result) + return result; *done = (state->state == TFTP_STATE_FIN) ? TRUE : FALSE; if(*done) /* Tell curl we're done */ @@ -1227,11 +1228,11 @@ static CURLcode tftp_multi_statemach(struct connectdata *conn, bool *done) } else if(rc != 0) { result = tftp_receive_packet(conn); - if(result != CURLE_OK) - return(result); + if(result) + return result; result = tftp_state_machine(state, state->event); - if(result != CURLE_OK) - return(result); + if(result) + return result; *done = (state->state == TFTP_STATE_FIN) ? TRUE : FALSE; if(*done) /* Tell curl we're done */ @@ -1286,8 +1287,8 @@ static CURLcode tftp_perform(struct connectdata *conn, bool *dophase_done) result = tftp_state_machine(state, TFTP_EVENT_INIT); - if(state->state == TFTP_STATE_FIN || result != CURLE_OK) - return(result); + if((state->state == TFTP_STATE_FIN) || result) + return result; tftp_multi_statemach(conn, dophase_done); @@ -1310,30 +1311,30 @@ static CURLcode tftp_perform(struct connectdata *conn, bool *dophase_done) static CURLcode tftp_do(struct connectdata *conn, bool *done) { - tftp_state_data_t *state; - CURLcode code; + tftp_state_data_t *state; + CURLcode result; *done = FALSE; if(!conn->proto.tftpc) { - code = tftp_connect(conn, done); - if(code) - return code; + result = tftp_connect(conn, done); + if(result) + return result; } state = (tftp_state_data_t *)conn->proto.tftpc; if(!state) return CURLE_BAD_CALLING_ORDER; - code = tftp_perform(conn, done); + result = tftp_perform(conn, done); /* If tftp_perform() returned an error, use that for return code. If it was OK, see if tftp_translate_code() has an error. */ - if(code == CURLE_OK) + if(!result) /* If we have encountered an internal tftp error, translate it. */ - code = tftp_translate_code(state->error); + result = tftp_translate_code(state->error); - return code; + return result; } static CURLcode tftp_setup_connection(struct connectdata * conn) diff --git a/lib/timeval.c b/lib/timeval.c index 2fd7201..45731ac 100644 --- a/lib/timeval.c +++ b/lib/timeval.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2008, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -32,9 +32,17 @@ struct timeval curlx_tvnow(void) ** increases monotonically and wraps once 49.7 days have elapsed. */ struct timeval now; +#if !defined(_WIN32_WINNT) || !defined(_WIN32_WINNT_VISTA) || \ + (_WIN32_WINNT < _WIN32_WINNT_VISTA) DWORD milliseconds = GetTickCount(); now.tv_sec = milliseconds / 1000; now.tv_usec = (milliseconds % 1000) * 1000; +#else + ULONGLONG milliseconds = GetTickCount64(); + now.tv_sec = (long) (milliseconds / 1000); + now.tv_usec = (long) (milliseconds % 1000) * 1000; +#endif + return now; } @@ -110,7 +118,7 @@ struct timeval curlx_tvnow(void) long curlx_tvdiff(struct timeval newer, struct timeval older) { return (newer.tv_sec-older.tv_sec)*1000+ - (newer.tv_usec-older.tv_usec)/1000; + (long)(newer.tv_usec-older.tv_usec)/1000; } /* diff --git a/lib/transfer.c b/lib/transfer.c index dc817a6..718139b 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -75,16 +75,14 @@ #include "curl_ntlm.h" #include "http_negotiate.h" #include "share.h" -#include "curl_memory.h" #include "select.h" #include "multiif.h" #include "connect.h" #include "non-ascii.h" +#include "curl_printf.h" -#define _MPRINTF_REPLACE /* use our functions only */ -#include - -/* The last #include file should be: */ +/* The last #include files should be: */ +#include "curl_memory.h" #include "memdebug.h" /* @@ -117,8 +115,8 @@ CURLcode Curl_fillreadbuffer(struct connectdata *conn, int bytes, int *nreadp) /* this function returns a size_t, so we typecast to int to prevent warnings with picky compilers */ - nread = (int)conn->fread_func(data->req.upload_fromhere, 1, - buffersize, conn->fread_in); + nread = (int)data->set.fread_func(data->req.upload_fromhere, 1, + buffersize, data->set.in); if(nread == CURL_READFUNC_ABORT) { failf(data, "operation aborted by callback"); @@ -203,7 +201,7 @@ CURLcode Curl_fillreadbuffer(struct connectdata *conn, int bytes, int *nreadp) strlen(endofline_network)); #ifdef CURL_DOES_CONVERSIONS - CURLcode res; + CURLcode result; int length; if(data->set.prefer_ascii) { /* translate the protocol and data */ @@ -213,10 +211,10 @@ CURLcode Curl_fillreadbuffer(struct connectdata *conn, int bytes, int *nreadp) /* just translate the protocol portion */ length = strlen(hexbuffer); } - res = Curl_convert_to_network(data, data->req.upload_fromhere, length); + result = Curl_convert_to_network(data, data->req.upload_fromhere, length); /* Curl_convert_to_network calls failf if unsuccessful */ - if(res) - return(res); + if(result) + return result; #endif /* CURL_DOES_CONVERSIONS */ if((nread - hexlen) == 0) @@ -227,11 +225,11 @@ CURLcode Curl_fillreadbuffer(struct connectdata *conn, int bytes, int *nreadp) } #ifdef CURL_DOES_CONVERSIONS else if((data->set.prefer_ascii) && (!sending_http_headers)) { - CURLcode res; - res = Curl_convert_to_network(data, data->req.upload_fromhere, nread); + CURLcode result; + result = Curl_convert_to_network(data, data->req.upload_fromhere, nread); /* Curl_convert_to_network calls failf if unsuccessful */ - if(res != CURLE_OK) - return(res); + if(result) + return result; } #endif /* CURL_DOES_CONVERSIONS */ @@ -319,8 +317,7 @@ static int data_pending(const struct connectdata *conn) TRUE. The thing is if we read everything, then http2_recv won't be called and we cannot signal the HTTP/2 stream has closed. As a workaround, we return nonzero here to call http2_recv. */ - ((conn->handler->protocol&PROTO_FAMILY_HTTP) && conn->httpversion == 20 && - conn->proto.httpc.closed); + ((conn->handler->protocol&PROTO_FAMILY_HTTP) && conn->httpversion == 20); #else Curl_ssl_data_pending(conn, FIRSTSOCKET); #endif @@ -435,6 +432,7 @@ static CURLcode readwrite_data(struct SessionHandle *data, else { /* read nothing but since we wanted nothing we consider this an OK situation to proceed from */ + DEBUGF(infof(data, "readwrite_data: we're done!\n")); nread = 0; } @@ -496,7 +494,7 @@ static CURLcode readwrite_data(struct SessionHandle *data, /* We've stopped dealing with input, get out of the do-while loop */ if(nread > 0) { - if(Curl_multi_pipeline_enabled(conn->data->multi)) { + if(Curl_pipeline_wanted(conn->data->multi, CURLPIPE_HTTP1)) { infof(data, "Rewinding stream by : %zd" " bytes on url %s (zero-length body)\n", @@ -547,6 +545,18 @@ static CURLcode readwrite_data(struct SessionHandle *data, if(data->state.resume_from && !k->content_range && (data->set.httpreq==HTTPREQ_GET) && !k->ignorebody) { + + if(k->size == data->state.resume_from) { + /* The resume point is at the end of file, consider this fine + even if it doesn't allow resume from here. */ + infof(data, "The entire document is already downloaded"); + connclose(conn, "already downloaded"); + /* Abort download */ + k->keepon &= ~KEEP_RECV; + *done = TRUE; + return CURLE_OK; + } + /* we wanted to resume a download, although the server doesn't * seem to support this and we did this with a GET (if it * wasn't a GET we did a POST or PUT resume) */ @@ -629,7 +639,7 @@ static CURLcode readwrite_data(struct SessionHandle *data, if(dataleft != 0) { infof(conn->data, "Leftovers after chunking: %zu bytes\n", dataleft); - if(Curl_multi_pipeline_enabled(conn->data->multi)) { + if(Curl_pipeline_wanted(conn->data->multi, CURLPIPE_HTTP1)) { /* only attempt the rewind if we truly are pipelining */ infof(conn->data, "Rewinding %zu bytes\n",dataleft); read_rewind(conn, dataleft); @@ -652,7 +662,7 @@ static CURLcode readwrite_data(struct SessionHandle *data, excess = (size_t)(k->bytecount + nread - k->maxdownload); if(excess > 0 && !k->ignorebody) { - if(Curl_multi_pipeline_enabled(conn->data->multi)) { + if(Curl_pipeline_wanted(conn->data->multi, CURLPIPE_HTTP1)) { /* The 'excess' amount below can't be more than BUFSIZE which always will fit in a size_t */ infof(data, @@ -746,7 +756,6 @@ static CURLcode readwrite_data(struct SessionHandle *data, result = Curl_unencode_gzip_write(conn, k, nread); break; - case COMPRESS: default: failf (data, "Unrecognized content encoding type. " "libcurl understands `identity', `deflate' and `gzip' " @@ -818,13 +827,6 @@ static CURLcode readwrite_upload(struct SessionHandle *data, *didwhat |= KEEP_SEND; - /* - * We loop here to do the READ and SEND loop until we run out of - * data to send or until we get EWOULDBLOCK back - * - * FIXME: above comment is misleading. Currently no looping is - * actually done in do-while loop below. - */ do { /* only read more data if there's no upload data already @@ -891,15 +893,6 @@ static CURLcode readwrite_upload(struct SessionHandle *data, /* store number of bytes available for upload */ data->req.upload_present = nread; -#ifndef CURL_DISABLE_SMTP - if(conn->handler->protocol & PROTO_FAMILY_SMTP) { - result = Curl_smtp_escape_eob(conn, nread); - if(result) - return result; - } - else -#endif /* CURL_DISABLE_SMTP */ - /* convert LF to CRLF if so asked */ if((!sending_http_headers) && ( #ifdef CURL_DO_LINEEND_CONV @@ -907,12 +900,16 @@ static CURLcode readwrite_upload(struct SessionHandle *data, (data->set.prefer_ascii) || #endif (data->set.crlf))) { - if(data->state.scratch == NULL) - data->state.scratch = malloc(2*BUFSIZE); - if(data->state.scratch == NULL) { - failf (data, "Failed to alloc scratch buffer!"); - return CURLE_OUT_OF_MEMORY; + /* Do we need to allocate a scratch buffer? */ + if(!data->state.scratch) { + data->state.scratch = malloc(2 * BUFSIZE); + if(!data->state.scratch) { + failf(data, "Failed to alloc scratch buffer!"); + + return CURLE_OUT_OF_MEMORY; + } } + /* * ASCII/EBCDIC Note: This is presumably a text (not binary) * transfer so the data should already be in ASCII. @@ -932,6 +929,7 @@ static CURLcode readwrite_upload(struct SessionHandle *data, else data->state.scratch[si] = data->req.upload_fromhere[i]; } + if(si != nread) { /* only perform the special operation if we really did replace anything */ @@ -944,6 +942,14 @@ static CURLcode readwrite_upload(struct SessionHandle *data, data->req.upload_present = nread; } } + +#ifndef CURL_DISABLE_SMTP + if(conn->handler->protocol & PROTO_FAMILY_SMTP) { + result = Curl_smtp_escape_eob(conn, nread); + if(result) + return result; + } +#endif /* CURL_DISABLE_SMTP */ } /* if 0 == data->req.upload_present */ else { /* We have a partial buffer left from a previous "round". Use @@ -1006,9 +1012,9 @@ static CURLcode readwrite_upload(struct SessionHandle *data, * be read and written to/from the connection. */ CURLcode Curl_readwrite(struct connectdata *conn, + struct SessionHandle *data, bool *done) { - struct SessionHandle *data = conn->data; struct SingleRequest *k = &data->req; CURLcode result; int didwhat=0; @@ -1032,6 +1038,11 @@ CURLcode Curl_readwrite(struct connectdata *conn, else fd_write = CURL_SOCKET_BAD; + if(conn->data->state.drain) { + select_res |= CURL_CSELECT_IN; + DEBUGF(infof(data, "Curl_readwrite: forcibly told to drain data\n")); + } + if(!select_res) /* Call for select()/poll() only, if read/write/error status is not known. */ select_res = Curl_socket_ready(fd_read, fd_write, 0); @@ -1202,10 +1213,10 @@ int Curl_single_getsock(const struct connectdata *conn, if((data->req.keepon & KEEP_SENDBITS) == KEEP_SEND) { if((conn->sockfd != conn->writesockfd) || - !(data->req.keepon & KEEP_RECV)) { - /* only if they are not the same socket or we didn't have a readable + bitmap == GETSOCK_BLANK) { + /* only if they are not the same socket and we have a readable one, we increase index */ - if(data->req.keepon & KEEP_RECV) + if(bitmap != GETSOCK_BLANK) sockindex++; /* increase index if we need two entries */ DEBUGASSERT(conn->writesockfd != CURL_SOCKET_BAD); @@ -1256,7 +1267,7 @@ long Curl_sleep_time(curl_off_t rate_bps, curl_off_t cur_rate_bps, * the next packet at the adjusted rate. We should wait * longer when using larger packets, for instance. */ - rv = ((curl_off_t)((pkt_size * 8) * 1000) / rate_bps); + rv = ((curl_off_t)(pkt_size * 1000) / rate_bps); /* Catch rounding errors and always slow down at least 1ms if * we are running too fast. @@ -1278,7 +1289,7 @@ long Curl_sleep_time(curl_off_t rate_bps, curl_off_t cur_rate_bps, */ CURLcode Curl_pretransfer(struct SessionHandle *data) { - CURLcode res; + CURLcode result; if(!data->change.url) { /* we can't do anything without URL */ failf(data, "No URL set!"); @@ -1288,32 +1299,35 @@ CURLcode Curl_pretransfer(struct SessionHandle *data) /* Init the SSL session ID cache here. We do it here since we want to do it after the *_setopt() calls (that could specify the size of the cache) but before any transfer takes place. */ - res = Curl_ssl_initsessions(data, data->set.ssl.max_ssl_sessions); - if(res) - return res; + result = Curl_ssl_initsessions(data, data->set.ssl.max_ssl_sessions); + if(result) + return result; data->set.followlocation=0; /* reset the location-follow counter */ data->state.this_is_a_follow = FALSE; /* reset this */ data->state.errorbuf = FALSE; /* no error has occurred */ data->state.httpversion = 0; /* don't assume any particular server version */ - data->state.ssl_connect_retry = FALSE; - data->state.authproblem = FALSE; data->state.authhost.want = data->set.httpauth; data->state.authproxy.want = data->set.proxyauth; Curl_safefree(data->info.wouldredirect); data->info.wouldredirect = NULL; + if(data->set.httpreq == HTTPREQ_PUT) + data->state.infilesize = data->set.filesize; + else + data->state.infilesize = data->set.postfieldsize; + /* If there is a list of cookie files to read, do it now! */ if(data->change.cookielist) Curl_cookie_loadfiles(data); /* If there is a list of host pairs to deal with */ if(data->change.resolve) - res = Curl_loadhostpairs(data); + result = Curl_loadhostpairs(data); - if(!res) { + if(!result) { /* Allow data->set.use_port to set which port to use. This needs to be * disabled for example when we follow Location: headers to URLs using * different ports! */ @@ -1328,6 +1342,7 @@ CURLcode Curl_pretransfer(struct SessionHandle *data) #endif Curl_initinfo(data); /* reset session-specific information "variables" */ + Curl_pgrsResetTimesSizes(data); Curl_pgrsStartNow(data); if(data->set.timeout) @@ -1343,7 +1358,7 @@ CURLcode Curl_pretransfer(struct SessionHandle *data) data->state.authproxy.picked &= data->state.authproxy.want; } - return res; + return result; } /* @@ -1619,7 +1634,7 @@ CURLcode Curl_follow(struct SessionHandle *data, if(type == FOLLOW_REDIR) { if((data->set.maxredirs != -1) && (data->set.followlocation >= data->set.maxredirs)) { - failf(data,"Maximum (%ld) redirects followed", data->set.maxredirs); + failf(data, "Maximum (%ld) redirects followed", data->set.maxredirs); return CURLE_TOO_MANY_REDIRECTS; } @@ -1828,13 +1843,13 @@ Curl_reconnect_request(struct connectdata **connp) * (again). Slight Lack of feedback in the report, but I don't think this * extra check can do much harm. */ - if((CURLE_OK == result) || (CURLE_SEND_ERROR == result)) { + if(!result || (CURLE_SEND_ERROR == result)) { bool async; bool protocol_done = TRUE; /* Now, redo the connect and get a new connection */ result = Curl_connect(data, connp, &async, &protocol_done); - if(CURLE_OK == result) { + if(!result) { /* We have connected or sent away a name resolve query fine */ conn = *connp; /* setup conn to again point to something nice */ @@ -1872,12 +1887,10 @@ CURLcode Curl_retry_request(struct connectdata *conn, !(conn->handler->protocol&(PROTO_FAMILY_HTTP|CURLPROTO_RTSP))) return CURLE_OK; - if(/* workaround for broken TLS servers */ data->state.ssl_connect_retry || - ((data->req.bytecount + - data->req.headerbytecount == 0) && - conn->bits.reuse && - !data->set.opt_no_body && - data->set.rtspreq != RTSPREQ_RECEIVE)) { + if((data->req.bytecount + data->req.headerbytecount == 0) && + conn->bits.reuse && + !data->set.opt_no_body && + (data->set.rtspreq != RTSPREQ_RECEIVE)) { /* We got no data, we attempted to re-use a connection and yet we want a "body". This might happen if the connection was left alive when we were done using it before, but that was closed when we wanted to read from diff --git a/lib/transfer.h b/lib/transfer.h index ad4a3ac..316aeae 100644 --- a/lib/transfer.h +++ b/lib/transfer.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2013, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -40,7 +40,8 @@ CURLcode Curl_follow(struct SessionHandle *data, char *newurl, followtype type); -CURLcode Curl_readwrite(struct connectdata *conn, bool *done); +CURLcode Curl_readwrite(struct connectdata *conn, + struct SessionHandle *data, bool *done); int Curl_single_getsock(const struct connectdata *conn, curl_socket_t *socks, int numsocks); diff --git a/lib/url.c b/lib/url.c index 67126ab..406c1f0 100644 --- a/lib/url.c +++ b/lib/url.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -47,6 +47,10 @@ #include #endif +#ifdef HAVE_SYS_UN_H +#include +#endif + #ifndef HAVE_SOCKET #error "We can't compile without socket() support!" #endif @@ -120,15 +124,12 @@ int curl_win32_idn_to_ascii(const char *in, char **out); #include "curl_rtmp.h" #include "gopher.h" #include "http_proxy.h" -#include "bundles.h" #include "conncache.h" #include "multihandle.h" #include "pipeline.h" #include "dotdot.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include - +#include "strdup.h" +#include "curl_printf.h" #include "curl_memory.h" /* The last #include file should be: */ #include "memdebug.h" @@ -141,7 +142,6 @@ find_oldest_idle_connection_in_bundle(struct SessionHandle *data, struct connectbundle *bundle); static void conn_free(struct connectdata *conn); static void signalPipeClose(struct curl_llist *pipeline, bool pipe_broke); -static CURLcode do_init(struct connectdata *conn); static CURLcode parse_url_login(struct SessionHandle *data, struct connectdata *conn, char **userptr, char **passwdptr, @@ -215,6 +215,15 @@ static const struct Curl_handler * const protocols[] = { #endif #endif +#if !defined(CURL_DISABLE_SMB) && defined(USE_NTLM) && \ + (CURL_SIZEOF_CURL_OFF_T > 4) && \ + (!defined(USE_WINDOWS_SSPI) || defined(USE_WIN32_CRYPTO)) + &Curl_handler_smb, +#ifdef USE_SSL + &Curl_handler_smbs, +#endif +#endif + #ifndef CURL_DISABLE_SMTP &Curl_handler_smtp, #ifdef USE_SSL @@ -270,8 +279,9 @@ void Curl_freeset(struct SessionHandle *data) { /* Free all dynamic strings stored in the data->set substructure. */ enum dupstring i; - for(i=(enum dupstring)0; i < STRING_LAST; i++) + for(i=(enum dupstring)0; i < STRING_LAST; i++) { Curl_safefree(data->set.str[i]); + } if(data->change.referer_alloc) { Curl_safefree(data->change.referer); @@ -345,7 +355,7 @@ static CURLcode setstropt_userpwd(char *option, char **userp, char **passwdp) CURLcode Curl_dupset(struct SessionHandle *dst, struct SessionHandle *src) { - CURLcode r = CURLE_OK; + CURLcode result = CURLE_OK; enum dupstring i; /* Copy src->set into dst->set first, then deal with the strings @@ -356,14 +366,25 @@ CURLcode Curl_dupset(struct SessionHandle *dst, struct SessionHandle *src) memset(dst->set.str, 0, STRING_LAST * sizeof(char *)); /* duplicate all strings */ - for(i=(enum dupstring)0; i< STRING_LAST; i++) { - r = setstropt(&dst->set.str[i], src->set.str[i]); - if(r != CURLE_OK) - break; + for(i=(enum dupstring)0; i< STRING_LASTZEROTERMINATED; i++) { + result = setstropt(&dst->set.str[i], src->set.str[i]); + if(result) + return result; + } + + /* duplicate memory areas pointed to */ + i = STRING_COPYPOSTFIELDS; + if(src->set.postfieldsize && src->set.str[i]) { + /* postfieldsize is curl_off_t, Curl_memdup() takes a size_t ... */ + dst->set.str[i] = Curl_memdup(src->set.str[i], + curlx_sotouz(src->set.postfieldsize)); + if(!dst->set.str[i]) + return CURLE_OUT_OF_MEMORY; + /* point to the new copy */ + dst->set.postfields = dst->set.str[i]; } - /* If a failure occurred, freeing has to be performed externally. */ - return r; + return CURLE_OK; } /* @@ -425,10 +446,8 @@ CURLcode Curl_close(struct SessionHandle *data) Curl_ssl_free_certinfo(data); /* Cleanup possible redirect junk */ - if(data->req.newurl) { - free(data->req.newurl); - data->req.newurl = NULL; - } + free(data->req.newurl); + data->req.newurl = NULL; if(data->change.referer_alloc) { Curl_safefree(data->change.referer); @@ -474,7 +493,7 @@ CURLcode Curl_close(struct SessionHandle *data) */ CURLcode Curl_init_userdefined(struct UserDefined *set) { - CURLcode res = CURLE_OK; + CURLcode result = CURLE_OK; set->out = stdout; /* default output to stdout */ set->in = stdin; /* default input from stdin */ @@ -540,8 +559,9 @@ CURLcode Curl_init_userdefined(struct UserDefined *set) define since we internally only use the lower 16 bits for the passed in bitmask to not conflict with the private bits */ set->allowed_protocols = CURLPROTO_ALL; - set->redir_protocols = - CURLPROTO_ALL & ~(CURLPROTO_FILE|CURLPROTO_SCP); /* not FILE or SCP */ + set->redir_protocols = CURLPROTO_ALL & /* All except FILE, SCP and SMB */ + ~(CURLPROTO_FILE | CURLPROTO_SCP | CURLPROTO_SMB | + CURLPROTO_SMBS); #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI) /* @@ -550,17 +570,34 @@ CURLcode Curl_init_userdefined(struct UserDefined *set) */ set->socks5_gssapi_nec = FALSE; /* set default GSS-API service name */ - res = setstropt(&set->str[STRING_SOCKS5_GSSAPI_SERVICE], - (char *) CURL_DEFAULT_SOCKS5_GSSAPI_SERVICE); - if(res != CURLE_OK) - return res; + result = setstropt(&set->str[STRING_SOCKS5_GSSAPI_SERVICE], + (char *) CURL_DEFAULT_SOCKS5_GSSAPI_SERVICE); + if(result) + return result; + + /* set default negotiate proxy service name */ + result = setstropt(&set->str[STRING_PROXY_SERVICE_NAME], + (char *) CURL_DEFAULT_PROXY_SERVICE_NAME); + if(result) + return result; + + /* set default negotiate service name */ + result = setstropt(&set->str[STRING_SERVICE_NAME], + (char *) CURL_DEFAULT_SERVICE_NAME); + if(result) + return result; #endif /* This is our preferred CA cert bundle/path since install time */ #if defined(CURL_CA_BUNDLE) - res = setstropt(&set->str[STRING_SSL_CAFILE], (char *) CURL_CA_BUNDLE); -#elif defined(CURL_CA_PATH) - res = setstropt(&set->str[STRING_SSL_CAPATH], (char *) CURL_CA_PATH); + result = setstropt(&set->str[STRING_SSL_CAFILE], (char *) CURL_CA_BUNDLE); + if(result) + return result; +#endif +#if defined(CURL_CA_PATH) + result = setstropt(&set->str[STRING_SSL_CAPATH], (char *) CURL_CA_PATH); + if(result) + return result; #endif set->wildcardmatch = FALSE; @@ -578,7 +615,8 @@ CURLcode Curl_init_userdefined(struct UserDefined *set) set->ssl_enable_alpn = TRUE; set->expect_100_timeout = 1000L; /* Wait for a second by default. */ - return res; + set->sep_headers = TRUE; /* separated header lists by default */ + return result; } /** @@ -591,9 +629,8 @@ CURLcode Curl_init_userdefined(struct UserDefined *set) CURLcode Curl_open(struct SessionHandle **curl) { - CURLcode res = CURLE_OK; + CURLcode result; struct SessionHandle *data; - CURLcode status; /* Very simple start-up: alloc the struct, init it with zeroes and return */ data = calloc(1, sizeof(struct SessionHandle)); @@ -605,11 +642,11 @@ CURLcode Curl_open(struct SessionHandle **curl) data->magic = CURLEASY_MAGIC_NUMBER; - status = Curl_resolver_init(&data->state.resolver); - if(status) { + result = Curl_resolver_init(&data->state.resolver); + if(result) { DEBUGF(fprintf(stderr, "Error: resolver_init failed\n")); free(data); - return status; + return result; } /* We do some initial setup here, all those fields that can't be just 0 */ @@ -617,10 +654,10 @@ CURLcode Curl_open(struct SessionHandle **curl) data->state.headerbuff = malloc(HEADERSIZE); if(!data->state.headerbuff) { DEBUGF(fprintf(stderr, "Error: malloc of headerbuff failed\n")); - res = CURLE_OUT_OF_MEMORY; + result = CURLE_OUT_OF_MEMORY; } else { - res = Curl_init_userdefined(&data->set); + result = Curl_init_userdefined(&data->set); data->state.headersize=HEADERSIZE; @@ -638,10 +675,9 @@ CURLcode Curl_open(struct SessionHandle **curl) data->set.maxconnects = DEFAULT_CONNCACHE_SIZE; /* for easy handles */ } - if(res) { + if(result) { Curl_resolver_cleanup(data->state.resolver); - if(data->state.headerbuff) - free(data->state.headerbuff); + free(data->state.headerbuff); Curl_freeset(data); free(data); data = NULL; @@ -649,7 +685,7 @@ CURLcode Curl_open(struct SessionHandle **curl) else *curl = data; - return res; + return result; } CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, @@ -744,7 +780,7 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, break; case CURLOPT_FAILONERROR: /* - * Don't output the >=300 error code HTML-page, but instead only + * Don't output the >=400 error code HTML-page, but instead only * return error. */ data->set.http_fail_on_error = (0 != va_arg(param, long))?TRUE:FALSE; @@ -867,7 +903,11 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, * Set explicit SSL version to try to connect with, as some SSL * implementations are lame. */ +#ifdef USE_SSL data->set.ssl.version = va_arg(param, long); +#else + result = CURLE_UNKNOWN_OPTION; +#endif break; #ifndef CURL_DISABLE_HTTP @@ -1139,6 +1179,8 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, /* * Set cookie file name to dump all cookies to when we're done. */ + { + struct CookieInfo *newcookies; result = setstropt(&data->set.str[STRING_COOKIEJAR], va_arg(param, char *)); @@ -1146,8 +1188,12 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, * Activate the cookie parser. This may or may not already * have been made. */ - data->cookies = Curl_cookie_init(data, NULL, data->cookies, - data->set.cookiesession); + newcookies = Curl_cookie_init(data, NULL, data->cookies, + data->set.cookiesession); + if(!newcookies) + result = CURLE_OUT_OF_MEMORY; + data->cookies = newcookies; + } break; case CURLOPT_COOKIESESSION: @@ -1191,14 +1237,20 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, /* flush cookies to file, takes care of the locking */ Curl_flush_cookies(data, 0); } + else if(Curl_raw_equal(argptr, "RELOAD")) { + /* reload cookies from file */ + Curl_cookie_loadfiles(data); + break; + } else { if(!data->cookies) /* if cookie engine was not running, activate it */ data->cookies = Curl_cookie_init(data, NULL, NULL, TRUE); argptr = strdup(argptr); - if(!argptr) { + if(!argptr || !data->cookies) { result = CURLE_OUT_OF_MEMORY; + free(argptr); } else { Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE); @@ -1431,12 +1483,29 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, va_arg(param, char *)); break; + case CURLOPT_PROXY_SERVICE_NAME: + /* + * Set negotiate proxy service name + */ + result = setstropt(&data->set.str[STRING_PROXY_SERVICE_NAME], + va_arg(param, char *)); + break; + case CURLOPT_SOCKS5_GSSAPI_NEC: /* * set flag for nec socks5 support */ data->set.socks5_gssapi_nec = (0 != va_arg(param, long))?TRUE:FALSE; break; + + case CURLOPT_SERVICE_NAME: + /* + * Set negotiate service identity + */ + result = setstropt(&data->set.str[STRING_SERVICE_NAME], + va_arg(param, char *)); + break; + #endif case CURLOPT_HEADERDATA: @@ -1959,30 +2028,63 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, data->set.ssl.verifyhost = (0 != arg)?TRUE:FALSE; break; -#ifdef USE_SSLEAY - /* since these two options are only possible to use on an OpenSSL- - powered libcurl we #ifdef them on this condition so that libcurls - built against other SSL libs will return a proper error when trying - to set this option! */ + case CURLOPT_SSL_VERIFYSTATUS: + /* + * Enable certificate status verifying. + */ + if(!Curl_ssl_cert_status_request()) { + result = CURLE_NOT_BUILT_IN; + break; + } + + data->set.ssl.verifystatus = (0 != va_arg(param, long))?TRUE:FALSE; + break; case CURLOPT_SSL_CTX_FUNCTION: +#ifdef have_curlssl_ssl_ctx /* * Set a SSL_CTX callback */ data->set.ssl.fsslctx = va_arg(param, curl_ssl_ctx_callback); +#else + result = CURLE_NOT_BUILT_IN; +#endif break; case CURLOPT_SSL_CTX_DATA: +#ifdef have_curlssl_ssl_ctx /* * Set a SSL_CTX callback parameter pointer */ data->set.ssl.fsslctxp = va_arg(param, void *); - break; +#else + result = CURLE_NOT_BUILT_IN; #endif -#if defined(USE_SSLEAY) || defined(USE_QSOSSL) || defined(USE_GSKIT) || \ - defined(USE_NSS) + break; + case CURLOPT_SSL_FALSESTART: + /* + * Enable TLS false start. + */ + if(!Curl_ssl_false_start()) { + result = CURLE_NOT_BUILT_IN; + break; + } + + data->set.ssl.falsestart = (0 != va_arg(param, long))?TRUE:FALSE; + break; case CURLOPT_CERTINFO: +#ifdef have_curlssl_certinfo data->set.ssl.certinfo = (0 != va_arg(param, long))?TRUE:FALSE; - break; +#else + result = CURLE_NOT_BUILT_IN; #endif + break; + case CURLOPT_PINNEDPUBLICKEY: + /* + * Set pinned public key for SSL connection. + * Specify file name of the public key in DER format. + */ + result = setstropt(&data->set.str[STRING_SSL_PINNEDPUBLICKEY], + va_arg(param, char *)); + break; case CURLOPT_CAINFO: /* * Set CA info for SSL connection. Specify file name of the CA certificate @@ -1991,6 +2093,7 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, va_arg(param, char *)); break; case CURLOPT_CAPATH: +#ifdef have_curlssl_ca_path /* not supported by all backends */ /* * Set CA path info for SSL connection. Specify directory name of the CA * certificates which have been prepared using openssl c_rehash utility. @@ -1998,6 +2101,9 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, /* This does not work on windows. */ result = setstropt(&data->set.str[STRING_SSL_CAPATH], va_arg(param, char *)); +#else + result = CURLE_NOT_BUILT_IN; +#endif break; case CURLOPT_CRLFILE: /* @@ -2079,16 +2185,15 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, data->share->dirty++; - if(data->share->hostcache) { + if(data->share->specifier & (1<< CURL_LOCK_DATA_DNS)) { /* use shared host cache */ - data->dns.hostcache = data->share->hostcache; + data->dns.hostcache = &data->share->hostcache; data->dns.hostcachetype = HCACHE_SHARED; } #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES) if(data->share->cookies) { /* use shared cookie list, first free own one if any */ - if(data->cookies) - Curl_cookie_cleanup(data->cookies); + Curl_cookie_cleanup(data->cookies); /* enable cookies since we now use a share that uses cookies! */ data->cookies = data->share->cookies; } @@ -2129,7 +2234,8 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, case CURLOPT_SSL_OPTIONS: arg = va_arg(param, long); - data->set.ssl_enable_beast = arg&CURLSSLOPT_ALLOW_BEAST?TRUE:FALSE; + data->set.ssl_enable_beast = !!(arg & CURLSSLOPT_ALLOW_BEAST); + data->set.ssl_no_revoke = !!(arg & CURLSSLOPT_NO_REVOKE); break; #endif @@ -2316,7 +2422,7 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, * know that an unsigned int will always hold the value so we blindly * typecast to this type */ - data->set.scope = curlx_sltoui(va_arg(param, long)); + data->set.scope_id = curlx_sltoui(va_arg(param, long)); break; case CURLOPT_PROTOCOLS: @@ -2533,6 +2639,19 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, data->set.ssl_enable_alpn = (0 != va_arg(param, long))?TRUE:FALSE; break; +#ifdef USE_UNIX_SOCKETS + case CURLOPT_UNIX_SOCKET_PATH: + result = setstropt(&data->set.str[STRING_UNIX_SOCKET_PATH], + va_arg(param, char *)); + break; +#endif + + case CURLOPT_PATH_AS_IS: + data->set.path_as_is = (0 != va_arg(param, long))?TRUE:FALSE; + break; + case CURLOPT_PIPEWAIT: + data->set.pipewait = (0 != va_arg(param, long))?TRUE:FALSE; + break; default: /* unknown tag and its companion, just ignore: */ result = CURLE_UNKNOWN_OPTION; @@ -2565,7 +2684,8 @@ static void conn_free(struct connectdata *conn) if(CURL_SOCKET_BAD != conn->tempsock[1]) Curl_closesocket(conn, conn->tempsock[1]); -#if defined(USE_NTLM) && defined(NTLM_WB_ENABLED) +#if !defined(CURL_DISABLE_HTTP) && defined(USE_NTLM) && \ + defined(NTLM_WB_ENABLED) Curl_ntlm_wb_cleanup(conn); #endif @@ -2631,8 +2751,10 @@ CURLcode Curl_disconnect(struct connectdata *conn, bool dead_connection) Curl_hostcache_prune(data); /* kill old DNS cache entries */ +#if !defined(CURL_DISABLE_HTTP) && defined(USE_NTLM) /* Cleanup NTLM connection-related data */ Curl_http_ntlm_cleanup(conn); +#endif if(conn->handler->disconnect) /* This is set if protocol-specific cleanups should be made */ @@ -2655,16 +2777,15 @@ CURLcode Curl_disconnect(struct connectdata *conn, bool dead_connection) free(conn->host.encalloc); /* encoded host name buffer, must be freed with idn_free() since this was allocated by curl_win32_idn_to_ascii */ - if(conn->proxy.encalloc) - free(conn->proxy.encalloc); /* encoded proxy name buffer, must be freed - with idn_free() since this was allocated by - curl_win32_idn_to_ascii */ + free(conn->proxy.encalloc); /* encoded proxy name buffer, must be freed + with idn_free() since this was allocated by + curl_win32_idn_to_ascii */ #endif Curl_ssl_close(conn, FIRSTSOCKET); /* Indicate to all handles on the pipe that we're dead */ - if(Curl_multi_pipeline_enabled(data->multi)) { + if(Curl_pipeline_wanted(data->multi, CURLPIPE_ANY)) { signalPipeClose(conn->send_pipe, TRUE); signalPipeClose(conn->recv_pipe, TRUE); } @@ -2692,32 +2813,31 @@ static bool SocketIsDead(curl_socket_t sock) return ret_val; } +/* + * IsPipeliningPossible() returns TRUE if the options set would allow + * pipelining/multiplexing and the connection is using a HTTP protocol. + */ static bool IsPipeliningPossible(const struct SessionHandle *handle, const struct connectdata *conn) { - if((conn->handler->protocol & PROTO_FAMILY_HTTP) && - Curl_multi_pipeline_enabled(handle->multi) && - (handle->set.httpreq == HTTPREQ_GET || - handle->set.httpreq == HTTPREQ_HEAD) && - handle->set.httpversion != CURL_HTTP_VERSION_1_0) - return TRUE; + /* If a HTTP protocol and pipelining is enabled */ + if(conn->handler->protocol & PROTO_FAMILY_HTTP) { + + if(Curl_pipeline_wanted(handle->multi, CURLPIPE_HTTP1) && + (handle->set.httpversion != CURL_HTTP_VERSION_1_0) && + (handle->set.httpreq == HTTPREQ_GET || + handle->set.httpreq == HTTPREQ_HEAD)) + /* didn't ask for HTTP/1.0 and a GET or HEAD */ + return TRUE; + if(Curl_pipeline_wanted(handle->multi, CURLPIPE_MULTIPLEX) && + (handle->set.httpversion == CURL_HTTP_VERSION_2_0)) + /* allows HTTP/2 */ + return TRUE; + } return FALSE; } -bool Curl_isPipeliningEnabled(const struct SessionHandle *handle) -{ - return Curl_multi_pipeline_enabled(handle->multi); -} - -CURLcode Curl_addHandleToPipeline(struct SessionHandle *data, - struct curl_llist *pipeline) -{ - if(!Curl_llist_insert_next(pipeline, pipeline->tail, data)) - return CURLE_OUT_OF_MEMORY; - return CURLE_OK; -} - int Curl_removeHandleFromPipeline(struct SessionHandle *handle, struct curl_llist *pipeline) { @@ -2765,15 +2885,14 @@ void Curl_getoff_all_pipelines(struct SessionHandle *data, struct connectdata *conn) { bool recv_head = (conn->readchannel_inuse && - (gethandleathead(conn->recv_pipe) == data)) ? TRUE : FALSE; - + Curl_recvpipe_head(data, conn)); bool send_head = (conn->writechannel_inuse && - (gethandleathead(conn->send_pipe) == data)) ? TRUE : FALSE; + Curl_sendpipe_head(data, conn)); if(Curl_removeHandleFromPipeline(data, conn->recv_pipe) && recv_head) - conn->readchannel_inuse = FALSE; + Curl_pipeline_leave_read(conn); if(Curl_removeHandleFromPipeline(data, conn->send_pipe) && send_head) - conn->writechannel_inuse = FALSE; + Curl_pipeline_leave_write(conn); } static void signalPipeClose(struct curl_llist *pipeline, bool pipe_broke) @@ -2825,7 +2944,7 @@ find_oldest_idle_connection(struct SessionHandle *data) now = Curl_tvnow(); - Curl_hash_start_iterate(bc->hash, &iter); + Curl_hash_start_iterate(&bc->hash, &iter); he = Curl_hash_next_element(&iter); while(he) { @@ -2959,6 +3078,13 @@ static void prune_dead_connections(struct SessionHandle *data) } } + +static size_t max_pipeline_length(struct Curl_multi *multi) +{ + return multi ? multi->max_pipeline_length : 0; +} + + /* * Given one filled in connection struct (named needle), this function should * detect if there already is one that has all the significant details @@ -2975,17 +3101,21 @@ static bool ConnectionExists(struct SessionHandle *data, struct connectdata *needle, struct connectdata **usethis, - bool *force_reuse) + bool *force_reuse, + bool *waitpipe) { struct connectdata *check; struct connectdata *chosen = 0; bool canPipeline = IsPipeliningPossible(data, needle); +#ifdef USE_NTLM bool wantNTLMhttp = ((data->state.authhost.want & CURLAUTH_NTLM) || (data->state.authhost.want & CURLAUTH_NTLM_WB)) && (needle->handler->protocol & PROTO_FAMILY_HTTP) ? TRUE : FALSE; +#endif struct connectbundle *bundle; *force_reuse = FALSE; + *waitpipe = FALSE; /* We can't pipe if the site is blacklisted */ if(canPipeline && Curl_pipeline_site_blacklisted(data, needle)) { @@ -2994,10 +3124,11 @@ ConnectionExists(struct SessionHandle *data, /* Look up the bundle with all the connections to this particular host */ - bundle = Curl_conncache_find_bundle(data->state.conn_cache, - needle->host.name); + bundle = Curl_conncache_find_bundle(needle, data->state.conn_cache); if(bundle) { - size_t max_pipe_len = Curl_multi_max_pipeline_length(data->multi); + /* Max pipe length is zero (unlimited) for multiplexed connections */ + size_t max_pipe_len = (bundle->multiuse != BUNDLE_MULTIPLEX)? + max_pipeline_length(data->multi):0; size_t best_pipe_len = max_pipe_len; struct curl_llist_element *curr; @@ -3005,15 +3136,25 @@ ConnectionExists(struct SessionHandle *data, needle->host.name, (void *)bundle); /* We can't pipe if we don't know anything about the server */ - if(canPipeline && !bundle->server_supports_pipelining) { - infof(data, "Server doesn't support pipelining\n"); - canPipeline = FALSE; + if(canPipeline) { + if(bundle->multiuse <= BUNDLE_UNKNOWN) { + if((bundle->multiuse == BUNDLE_UNKNOWN) && data->set.pipewait) { + infof(data, "Server doesn't support multi-use yet, wait\n"); + *waitpipe = TRUE; + return FALSE; /* no re-use */ + } + + infof(data, "Server doesn't support multi-use (yet)\n"); + canPipeline = FALSE; + } } curr = bundle->conn_list->head; while(curr) { bool match = FALSE; +#if defined(USE_NTLM) bool credentialsMatch = FALSE; +#endif size_t pipeLen; /* @@ -3029,16 +3170,19 @@ ConnectionExists(struct SessionHandle *data, pipeLen = check->send_pipe->size + check->recv_pipe->size; if(canPipeline) { - /* Make sure the pipe has only GET requests */ - struct SessionHandle* sh = gethandleathead(check->send_pipe); - struct SessionHandle* rh = gethandleathead(check->recv_pipe); - if(sh) { - if(!IsPipeliningPossible(sh, check)) - continue; - } - else if(rh) { - if(!IsPipeliningPossible(rh, check)) - continue; + + if(!check->bits.multiplex) { + /* If not multiplexing, make sure the pipe has only GET requests */ + struct SessionHandle* sh = gethandleathead(check->send_pipe); + struct SessionHandle* rh = gethandleathead(check->recv_pipe); + if(sh) { + if(!IsPipeliningPossible(sh, check)) + continue; + } + else if(rh) { + if(!IsPipeliningPossible(rh, check)) + continue; + } } } else { @@ -3118,8 +3262,11 @@ ConnectionExists(struct SessionHandle *data, continue; } - if((!(needle->handler->flags & PROTOPT_CREDSPERREQUEST)) || - wantNTLMhttp) { + if((!(needle->handler->flags & PROTOPT_CREDSPERREQUEST)) +#ifdef USE_NTLM + || (wantNTLMhttp || check->ntlm.state != NTLMSTATE_NONE) +#endif + ) { /* This protocol requires credentials per connection or is HTTP+NTLM, so verify that we're using the same name and password as well */ if(!strequal(needle->user, check->user) || @@ -3127,7 +3274,9 @@ ConnectionExists(struct SessionHandle *data, /* one of them was different */ continue; } +#if defined(USE_NTLM) credentialsMatch = TRUE; +#endif } if(!needle->bits.httpproxy || needle->handler->flags&PROTOPT_SSL || @@ -3179,6 +3328,7 @@ ConnectionExists(struct SessionHandle *data, } if(match) { +#if defined(USE_NTLM) /* If we are looking for an HTTP+NTLM connection, check if this is already authenticating with the right credentials. If not, keep looking so that we can reuse NTLM connections if @@ -3197,6 +3347,7 @@ ConnectionExists(struct SessionHandle *data, chosen = check; continue; } +#endif if(canPipeline) { /* We can pipeline if we want to. Let's continue looking for @@ -3210,19 +3361,42 @@ ConnectionExists(struct SessionHandle *data, } /* We can't use the connection if the pipe is full */ - if(pipeLen >= max_pipe_len) + if(max_pipe_len && (pipeLen >= max_pipe_len)) { + infof(data, "Pipe is full, skip (%zu)\n", pipeLen); continue; - + } +#ifdef USE_NGHTTP2 + /* If multiplexed, make sure we don't go over concurrency limit */ + if(check->bits.multiplex) { + /* Multiplexed connections can only be HTTP/2 for now */ + struct http_conn *httpc = &check->proto.httpc; + if(pipeLen >= httpc->settings.max_concurrent_streams) { + infof(data, "MAX_CONCURRENT_STREAMS reached, skip (%zu)\n", + pipeLen); + continue; + } + } +#endif /* We can't use the connection if the pipe is penalized */ - if(Curl_pipeline_penalized(data, check)) + if(Curl_pipeline_penalized(data, check)) { + infof(data, "Penalized, skip\n"); continue; + } - if(pipeLen < best_pipe_len) { - /* This connection has a shorter pipe so far. We'll pick this - and continue searching */ + if(max_pipe_len) { + if(pipeLen < best_pipe_len) { + /* This connection has a shorter pipe so far. We'll pick this + and continue searching */ + chosen = check; + best_pipe_len = pipeLen; + continue; + } + } + else { + /* When not pipelining (== multiplexed), we have a match here! */ chosen = check; - best_pipe_len = pipeLen; - continue; + infof(data, "Multiplexed connection found!\n"); + break; } } else { @@ -3274,20 +3448,6 @@ ConnectionDone(struct SessionHandle *data, struct connectdata *conn) return (conn_candidate == conn) ? FALSE : TRUE; } -/* - * The given input connection struct pointer is to be stored in the connection - * cache. If the cache is already full, least interesting existing connection - * (if any) gets closed. - * - * The given connection should be unique. That must've been checked prior to - * this call. - */ -static CURLcode ConnectionStore(struct SessionHandle *data, - struct connectdata *conn) -{ - return Curl_conncache_add_conn(data->state.conn_cache, conn); -} - /* after a TCP connection to the proxy has been verified, this function does the next magic step. @@ -3533,7 +3693,7 @@ static void fix_hostname(struct SessionHandle *data, host->dispname = host->name; len = strlen(host->name); - if(host->name[len-1] == '.') + if(len && (host->name[len-1] == '.')) /* strip off a single trailing dot if present, primarily for SNI but there's no use for it */ host->name[len-1]=0; @@ -3550,7 +3710,7 @@ static void fix_hostname(struct SessionHandle *data, stringprep_locale_charset ()); if(rc != IDNA_SUCCESS) infof(data, "Failed to convert %s to ACE; %s\n", - host->name, Curl_idn_strerror(conn,rc)); + host->name, Curl_idn_strerror(conn, rc)); else { /* tld_check_name() displays a warning if the host name contains "illegal" characters for this TLD */ @@ -3655,16 +3815,17 @@ static struct connectdata *allocate_conn(struct SessionHandle *data) conn->ip_version = data->set.ipver; -#if defined(USE_NTLM) && defined(NTLM_WB_ENABLED) +#if !defined(CURL_DISABLE_HTTP) && defined(USE_NTLM) && \ + defined(NTLM_WB_ENABLED) conn->ntlm_auth_hlpr_socket = CURL_SOCKET_BAD; conn->ntlm_auth_hlpr_pid = 0; conn->challenge_header = NULL; conn->response_header = NULL; #endif - if(Curl_multi_pipeline_enabled(data->multi) && - !conn->master_buffer) { - /* Allocate master_buffer to be used for pipelining */ + if(Curl_pipeline_wanted(data->multi, CURLPIPE_HTTP1) && + !conn->master_buffer) { + /* Allocate master_buffer to be used for HTTP/1 pipelining */ conn->master_buffer = calloc(BUFSIZE, sizeof (char)); if(!conn->master_buffer) goto error; @@ -3703,9 +3864,9 @@ static struct connectdata *allocate_conn(struct SessionHandle *data) conn->send_pipe = NULL; conn->recv_pipe = NULL; - Curl_safefree(conn->master_buffer); - Curl_safefree(conn->localdev); - Curl_safefree(conn); + free(conn->master_buffer); + free(conn->localdev); + free(conn); return NULL; } @@ -3772,6 +3933,13 @@ static CURLcode parseurlandfillconn(struct SessionHandle *data, *prot_missing = FALSE; + /* We might pass the entire URL into the request so we need to make sure + * there are no bad characters in there.*/ + if(strpbrk(data->change.url, "\r\n")) { + failf(data, "Illegal characters found in URL"); + return CURLE_URL_MALFORMAT; + } + /************************************************************* * Parse the URL. * @@ -3941,7 +4109,7 @@ static CURLcode parseurlandfillconn(struct SessionHandle *data, path[0] = '/'; rebuild_url = TRUE; } - else { + else if(!data->set.path_as_is) { /* sanitise paths and remove ../ and ./ sequences according to RFC3986 */ char *newp = Curl_dedotdotify(path); if(!newp) @@ -4003,7 +4171,7 @@ static CURLcode parseurlandfillconn(struct SessionHandle *data, * the host name */ result = parse_url_login(data, conn, userp, passwdp, optionsp); - if(result != CURLE_OK) + if(result) return result; if(conn->host.name[0] == '[') { @@ -4024,7 +4192,7 @@ static CURLcode parseurlandfillconn(struct SessionHandle *data, /* The address scope was well formed. Knock it out of the hostname. */ memmove(percent, endp, strlen(endp)+1); - conn->scope = (unsigned int)scope; + conn->scope_id = (unsigned int)scope; } else { /* Zone identifier is not numeric */ @@ -4046,11 +4214,11 @@ static CURLcode parseurlandfillconn(struct SessionHandle *data, } } if(scopeidx > 0) { + char *p = percent + identifier_offset + strlen(ifname); + /* Remove zone identifier from hostname */ - memmove(percent, - percent + identifier_offset + strlen(ifname), - identifier_offset + strlen(ifname)); - conn->scope = scopeidx; + memmove(percent, p, strlen(p) + 1); + conn->scope_id = scopeidx; } else #endif /* HAVE_NET_IF_H && IFNAMSIZ */ @@ -4059,9 +4227,9 @@ static CURLcode parseurlandfillconn(struct SessionHandle *data, } } - if(data->set.scope) + if(data->set.scope_id) /* Override any scope that was set above. */ - conn->scope = data->set.scope; + conn->scope_id = data->set.scope_id; /* Remove the fragment part of the path. Per RFC 2396, this is always the last part of the URI. We are looking for the first '#' so that we deal @@ -4153,7 +4321,7 @@ static CURLcode setup_connection_internals(struct connectdata *conn) if(p->setup_connection) { result = (*p->setup_connection)(conn); - if(result != CURLE_OK) + if(result) return result; p = conn->handler; /* May have changed. */ @@ -4327,9 +4495,8 @@ static char *detect_proxy(struct connectdata *conn) prox=curl_getenv(proxy_env); } - if(prox && *prox) { /* don't count "" strings */ + if(prox) proxy = prox; /* use this */ - } else { proxy = curl_getenv("all_proxy"); /* default proxy to use */ if(!proxy) @@ -4337,8 +4504,7 @@ static char *detect_proxy(struct connectdata *conn) } } /* if(!check_noproxy(conn->host.name, no_proxy)) - it wasn't specified non-proxy */ - if(no_proxy) - free(no_proxy); + free(no_proxy); #else /* !CURL_DISABLE_HTTP */ @@ -4352,7 +4518,6 @@ static char *detect_proxy(struct connectdata *conn) * If this is supposed to use a proxy, we need to figure out the proxy * host name, so that we can re-use an existing connection * that may exist registered to the same proxy host. - * proxy will be freed before this function returns. */ static CURLcode parse_proxy(struct SessionHandle *data, struct connectdata *conn, char *proxy) @@ -4389,13 +4554,12 @@ static CURLcode parse_proxy(struct SessionHandle *data, /* Is there a username and password given in this proxy url? */ atsign = strchr(proxyptr, '@'); if(atsign) { - CURLcode res = CURLE_OK; char *proxyuser = NULL; char *proxypasswd = NULL; - - res = parse_login_details(proxyptr, atsign - proxyptr, - &proxyuser, &proxypasswd, NULL); - if(!res) { + CURLcode result = + parse_login_details(proxyptr, atsign - proxyptr, + &proxyuser, &proxypasswd, NULL); + if(!result) { /* found user and password, rip them out. note that we are unescaping them, as there is otherwise no way to have a username or password with reserved characters like ':' in @@ -4407,7 +4571,7 @@ static CURLcode parse_proxy(struct SessionHandle *data, conn->proxyuser = strdup(""); if(!conn->proxyuser) - res = CURLE_OUT_OF_MEMORY; + result = CURLE_OUT_OF_MEMORY; else { Curl_safefree(conn->proxypasswd); if(proxypasswd && strlen(proxypasswd) < MAX_CURL_PASSWORD_LENGTH) @@ -4416,25 +4580,22 @@ static CURLcode parse_proxy(struct SessionHandle *data, conn->proxypasswd = strdup(""); if(!conn->proxypasswd) - res = CURLE_OUT_OF_MEMORY; + result = CURLE_OUT_OF_MEMORY; } - if(!res) { + if(!result) { conn->bits.proxy_user_passwd = TRUE; /* enable it */ atsign++; /* the right side of the @-letter */ - if(atsign) - proxyptr = atsign; /* now use this instead */ - else - res = CURLE_OUT_OF_MEMORY; + proxyptr = atsign; /* now use this instead */ } } - Curl_safefree(proxyuser); - Curl_safefree(proxypasswd); + free(proxyuser); + free(proxypasswd); - if(res) - return res; + if(result) + return result; } /* start scanning for port number at this point */ @@ -4595,7 +4756,7 @@ static CURLcode parse_url_login(struct SessionHandle *data, /* We could use the login information in the URL so extract it */ result = parse_login_details(login, ptr - login - 1, &userp, &passwdp, &optionsp); - if(result != CURLE_OK) + if(result) goto out; if(userp) { @@ -4643,9 +4804,9 @@ static CURLcode parse_url_login(struct SessionHandle *data, out: - Curl_safefree(userp); - Curl_safefree(passwdp); - Curl_safefree(optionsp); + free(userp); + free(passwdp); + free(optionsp); return result; } @@ -4733,7 +4894,7 @@ static CURLcode parse_login_details(const char *login, const size_t len, if(!result && passwdp && plen) { pbuf = malloc(plen + 1); if(!pbuf) { - Curl_safefree(ubuf); + free(ubuf); result = CURLE_OUT_OF_MEMORY; } } @@ -4742,8 +4903,8 @@ static CURLcode parse_login_details(const char *login, const size_t len, if(!result && optionsp && olen) { obuf = malloc(olen + 1); if(!obuf) { - Curl_safefree(pbuf); - Curl_safefree(ubuf); + free(pbuf); + free(ubuf); result = CURLE_OUT_OF_MEMORY; } } @@ -5022,6 +5183,32 @@ static CURLcode resolve_server(struct SessionHandle *data, /* set a pointer to the hostname we display */ fix_hostname(data, conn, &conn->host); +#ifdef USE_UNIX_SOCKETS + if(data->set.str[STRING_UNIX_SOCKET_PATH]) { + /* Unix domain sockets are local. The host gets ignored, just use the + * specified domain socket address. Do not cache "DNS entries". There is + * no DNS involved and we already have the filesystem path available */ + const char *path = data->set.str[STRING_UNIX_SOCKET_PATH]; + + hostaddr = calloc(1, sizeof(struct Curl_dns_entry)); + if(!hostaddr) + result = CURLE_OUT_OF_MEMORY; + else if((hostaddr->addr = Curl_unix2addr(path)) != NULL) + hostaddr->inuse++; + else { + /* Long paths are not supported for now */ + if(strlen(path) >= sizeof(((struct sockaddr_un *)0)->sun_path)) { + failf(data, "Unix socket path too long: '%s'", path); + result = CURLE_COULDNT_RESOLVE_HOST; + } + else + result = CURLE_OUT_OF_MEMORY; + free(hostaddr); + hostaddr = NULL; + } + } + else +#endif if(!conn->proxy.name || !*conn->proxy.name) { /* If not connecting via a proxy, extract the port from the URL, if it is * there, thus overriding any defaults that might have been set above. */ @@ -5079,8 +5266,7 @@ static CURLcode resolve_server(struct SessionHandle *data, static void reuse_conn(struct connectdata *old_conn, struct connectdata *conn) { - if(old_conn->proxy.rawalloc) - free(old_conn->proxy.rawalloc); + free(old_conn->proxy.rawalloc); /* free the SSL config struct from this connection struct as this was allocated in vain and is targeted for destruction */ @@ -5168,8 +5354,9 @@ static CURLcode create_conn(struct SessionHandle *data, bool reuse; char *proxy = NULL; bool prot_missing = FALSE; - bool no_connections_available = FALSE; + bool connections_available = TRUE; bool force_reuse = FALSE; + bool waitpipe = FALSE; size_t max_host_connections = Curl_multi_max_host_connections(data->multi); size_t max_total_connections = Curl_multi_max_total_connections(data->multi); @@ -5250,7 +5437,7 @@ static CURLcode create_conn(struct SessionHandle *data, result = parseurlandfillconn(data, conn, &prot_missing, &user, &passwd, &options); - if(result != CURLE_OK) + if(result) goto out; /************************************************************* @@ -5310,7 +5497,7 @@ static CURLcode create_conn(struct SessionHandle *data, *************************************************************/ if(conn->bits.proxy_user_passwd) { result = parse_proxy_auth(data, conn); - if(result != CURLE_OK) + if(result) goto out; } @@ -5329,14 +5516,19 @@ static CURLcode create_conn(struct SessionHandle *data, if(data->set.str[STRING_NOPROXY] && check_noproxy(conn->host.name, data->set.str[STRING_NOPROXY])) { - if(proxy) { - free(proxy); /* proxy is in exception list */ - proxy = NULL; - } + free(proxy); /* proxy is in exception list */ + proxy = NULL; } else if(!proxy) proxy = detect_proxy(conn); +#ifdef USE_UNIX_SOCKETS + if(proxy && data->set.str[STRING_UNIX_SOCKET_PATH]) { + free(proxy); /* Unix domain sockets cannot be proxied, so disable it */ + proxy = NULL; + } +#endif + if(proxy && (!*proxy || (conn->handler->flags & PROTOPT_NONETWORK))) { free(proxy); /* Don't bother with an empty proxy string or if the protocol doesn't work with network */ @@ -5351,7 +5543,8 @@ static CURLcode create_conn(struct SessionHandle *data, if(proxy) { result = parse_proxy(data, conn, proxy); - Curl_safefree(proxy); /* parse_proxy copies the proxy string */ + free(proxy); /* parse_proxy copies the proxy string */ + proxy = NULL; if(result) goto out; @@ -5372,8 +5565,10 @@ static CURLcode create_conn(struct SessionHandle *data, conn->bits.httpproxy = TRUE; #endif } - else + else { conn->bits.httpproxy = FALSE; /* not a HTTP proxy */ + conn->bits.tunnel_proxy = FALSE; /* no tunneling if not HTTP */ + } conn->bits.proxy = TRUE; } else { @@ -5397,16 +5592,16 @@ static CURLcode create_conn(struct SessionHandle *data, * Figure out the remote port number and fix it in the URL *************************************************************/ result = parse_remote_port(data, conn); - if(result != CURLE_OK) + if(result) goto out; /* Check for overridden login details and set them accordingly so they they are known when protocol->setup_connection is called! */ result = override_login(data, conn, &user, &passwd, &options); - if(result != CURLE_OK) + if(result) goto out; result = set_login(conn, user, passwd, options); - if(result != CURLE_OK) + if(result) goto out; /************************************************************* @@ -5414,7 +5609,7 @@ static CURLcode create_conn(struct SessionHandle *data, * we figured out what/if proxy to use. *************************************************************/ result = setup_connection_internals(conn); - if(result != CURLE_OK) + if(result) goto out; conn->recv[FIRSTSOCKET] = Curl_recv_plain; @@ -5434,11 +5629,11 @@ static CURLcode create_conn(struct SessionHandle *data, result = conn->handler->connect_it(conn, &done); /* Setup a "faked" transfer that'll do nothing */ - if(CURLE_OK == result) { + if(!result) { conn->data = data; conn->bits.tcpconnect[FIRSTSOCKET] = TRUE; /* we are "connected */ - ConnectionStore(data, conn); + Curl_conncache_add_conn(data->state.conn_cache, conn); /* * Setup whatever necessary for a resumed transfer @@ -5456,7 +5651,7 @@ static CURLcode create_conn(struct SessionHandle *data, } /* since we skip do_init() */ - do_init(conn); + Curl_init_do(data, conn); goto out; } @@ -5503,7 +5698,7 @@ static CURLcode create_conn(struct SessionHandle *data, if(data->set.reuse_fresh && !data->state.this_is_a_follow) reuse = FALSE; else - reuse = ConnectionExists(data, conn, &conn_temp, &force_reuse); + reuse = ConnectionExists(data, conn, &conn_temp, &force_reuse, &waitpipe); /* If we found a reusable connection, we may still want to open a new connection if we are pipelining. */ @@ -5540,18 +5735,24 @@ static CURLcode create_conn(struct SessionHandle *data, /* set a pointer to the hostname we display */ fix_hostname(data, conn, &conn->host); - infof(data, "Re-using existing connection! (#%ld) with host %s\n", + infof(data, "Re-using existing connection! (#%ld) with %s %s\n", conn->connection_id, + conn->bits.proxy?"proxy":"host", conn->proxy.name?conn->proxy.dispname:conn->host.dispname); } else { /* We have decided that we want a new connection. However, we may not be able to do that if we have reached the limit of how many connections we are allowed to open. */ - struct connectbundle *bundle; + struct connectbundle *bundle = NULL; + + if(waitpipe) + /* There is a connection that *might* become usable for pipelining + "soon", and we wait for that */ + connections_available = FALSE; + else + bundle = Curl_conncache_find_bundle(conn, data->state.conn_cache); - bundle = Curl_conncache_find_bundle(data->state.conn_cache, - conn->host.name); if(max_host_connections > 0 && bundle && (bundle->num_connections >= max_host_connections)) { struct connectdata *conn_candidate; @@ -5564,11 +5765,15 @@ static CURLcode create_conn(struct SessionHandle *data, conn_candidate->data = data; (void)Curl_disconnect(conn_candidate, /* dead_connection */ FALSE); } - else - no_connections_available = TRUE; + else { + infof(data, "No more connections allowed to host: %d\n", + max_host_connections); + connections_available = FALSE; + } } - if(max_total_connections > 0 && + if(connections_available && + (max_total_connections > 0) && (data->state.conn_cache->num_connections >= max_total_connections)) { struct connectdata *conn_candidate; @@ -5580,12 +5785,13 @@ static CURLcode create_conn(struct SessionHandle *data, conn_candidate->data = data; (void)Curl_disconnect(conn_candidate, /* dead_connection */ FALSE); } - else - no_connections_available = TRUE; + else { + infof(data, "No connections available in cache\n"); + connections_available = FALSE; + } } - - if(no_connections_available) { + if(!connections_available) { infof(data, "No connections available.\n"); conn_free(conn); @@ -5599,9 +5805,10 @@ static CURLcode create_conn(struct SessionHandle *data, * This is a brand new connection, so let's store it in the connection * cache of ours! */ - ConnectionStore(data, conn); + Curl_conncache_add_conn(data->state.conn_cache, conn); } +#if defined(USE_NTLM) /* If NTLM is requested in a part of this connection, make sure we don't assume the state is fine as this is a fresh connection and NTLM is connection based. */ @@ -5610,19 +5817,20 @@ static CURLcode create_conn(struct SessionHandle *data, infof(data, "NTLM picked AND auth done set, clear picked!\n"); data->state.authhost.picked = CURLAUTH_NONE; } + if((data->state.authproxy.picked & (CURLAUTH_NTLM | CURLAUTH_NTLM_WB)) && data->state.authproxy.done) { infof(data, "NTLM-proxy picked AND auth done set, clear picked!\n"); data->state.authproxy.picked = CURLAUTH_NONE; } - +#endif } /* Mark the connection as used */ conn->inuse = TRUE; /* Setup and init stuff before DO starts, in preparing for the transfer. */ - do_init(conn); + Curl_init_do(data, conn); /* * Setup whatever necessary for a resumed transfer @@ -5637,8 +5845,6 @@ static CURLcode create_conn(struct SessionHandle *data, * Inherit the proper values from the urldata struct AFTER we have arranged * the persistent connection stuff */ - conn->fread_func = data->set.fread_func; - conn->fread_in = data->set.in; conn->seek_func = data->set.seek_func; conn->seek_client = data->set.seek_client; @@ -5649,10 +5855,10 @@ static CURLcode create_conn(struct SessionHandle *data, out: - Curl_safefree(options); - Curl_safefree(passwd); - Curl_safefree(user); - Curl_safefree(proxy); + free(options); + free(passwd); + free(user); + free(proxy); return result; } @@ -5747,14 +5953,14 @@ CURLcode Curl_connect(struct SessionHandle *data, bool *asyncp, bool *protocol_done) { - CURLcode code; + CURLcode result; *asyncp = FALSE; /* assume synchronous resolves by default */ /* call the stuff that needs to be called */ - code = create_conn(data, in_connect, asyncp); + result = create_conn(data, in_connect, asyncp); - if(CURLE_OK == code) { + if(!result) { /* no error */ if((*in_connect)->send_pipe->size || (*in_connect)->recv_pipe->size) /* pipelining */ @@ -5763,23 +5969,23 @@ CURLcode Curl_connect(struct SessionHandle *data, /* DNS resolution is done: that's either because this is a reused connection, in which case DNS was unnecessary, or because DNS really did finish already (synch resolver/fast async resolve) */ - code = Curl_setup_conn(*in_connect, protocol_done); + result = Curl_setup_conn(*in_connect, protocol_done); } } - if(code == CURLE_NO_CONNECTION_AVAILABLE) { + if(result == CURLE_NO_CONNECTION_AVAILABLE) { *in_connect = NULL; - return code; + return result; } - if(code && *in_connect) { + if(result && *in_connect) { /* We're not allowed to return failure with memory left allocated in the connectdata struct, free those here */ Curl_disconnect(*in_connect, FALSE); /* close the connection */ *in_connect = NULL; /* return a NULL */ } - return code; + return result; } CURLcode Curl_done(struct connectdata **connp, @@ -5796,37 +6002,19 @@ CURLcode Curl_done(struct connectdata **connp, conn = *connp; data = conn->data; - if(conn->bits.done) + DEBUGF(infof(data, "Curl_done\n")); + + if(data->state.done) /* Stop if Curl_done() has already been called */ return CURLE_OK; Curl_getoff_all_pipelines(data, conn); - if((conn->send_pipe->size + conn->recv_pipe->size != 0 && - !data->set.reuse_forbid && - !conn->bits.close)) - /* Stop if pipeline is not empty and we do not have to close - connection. */ - return CURLE_OK; - - conn->bits.done = TRUE; /* called just now! */ - /* Cleanup possible redirect junk */ - if(data->req.newurl) { - free(data->req.newurl); - data->req.newurl = NULL; - } - if(data->req.location) { - free(data->req.location); - data->req.location = NULL; - } - - Curl_resolver_cancel(conn); - - if(conn->dns_entry) { - Curl_resolv_unlock(data, conn->dns_entry); /* done with this */ - conn->dns_entry = NULL; - } + free(data->req.newurl); + data->req.newurl = NULL; + free(data->req.location); + data->req.location = NULL; switch(status) { case CURLE_ABORTED_BY_CALLBACK: @@ -5850,12 +6038,27 @@ CURLcode Curl_done(struct connectdata **connp, if(!result && Curl_pgrsDone(conn)) result = CURLE_ABORTED_BY_CALLBACK; + if((conn->send_pipe->size + conn->recv_pipe->size != 0 && + !data->set.reuse_forbid && + !conn->bits.close)) { + /* Stop if pipeline is not empty and we do not have to close + connection. */ + DEBUGF(infof(data, "Connection still in use, no more Curl_done now!\n")); + return CURLE_OK; + } + + data->state.done = TRUE; /* called just now! */ + Curl_resolver_cancel(conn); + + if(conn->dns_entry) { + Curl_resolv_unlock(data, conn->dns_entry); /* done with this */ + conn->dns_entry = NULL; + } + /* if the transfer was completed in a paused state there can be buffered data left to write and then kill */ - if(data->state.tempwrite) { - free(data->state.tempwrite); - data->state.tempwrite = NULL; - } + free(data->state.tempwrite); + data->state.tempwrite = NULL; /* if data->set.reuse_forbid is TRUE, it means the libcurl client has forced us to close this connection. This is ignored for requests taking @@ -5872,9 +6075,12 @@ CURLcode Curl_done(struct connectdata **connp, but currently we have no such detail knowledge. */ - if((data->set.reuse_forbid && !(conn->ntlm.state == NTLMSTATE_TYPE2 || - conn->proxyntlm.state == NTLMSTATE_TYPE2)) - || conn->bits.close || premature) { + if((data->set.reuse_forbid +#if defined(USE_NTLM) + && !(conn->ntlm.state == NTLMSTATE_TYPE2 || + conn->proxyntlm.state == NTLMSTATE_TYPE2) +#endif + ) || conn->bits.close || premature) { CURLcode res2 = Curl_disconnect(conn, premature); /* close connection */ /* If we had an error already, make sure we return that one. But @@ -5906,20 +6112,24 @@ CURLcode Curl_done(struct connectdata **connp, } /* - * do_init() inits the readwrite session. This is inited each time (in the DO - * function before the protocol-specific DO functions are invoked) for a - * transfer, sometimes multiple times on the same SessionHandle. Make sure + * Curl_init_do() inits the readwrite session. This is inited each time (in + * the DO function before the protocol-specific DO functions are invoked) for + * a transfer, sometimes multiple times on the same SessionHandle. Make sure * nothing in here depends on stuff that are setup dynamically for the * transfer. + * + * Allow this function to get called with 'conn' set to NULL. */ -static CURLcode do_init(struct connectdata *conn) +CURLcode Curl_init_do(struct SessionHandle *data, struct connectdata *conn) { - struct SessionHandle *data = conn->data; struct SingleRequest *k = &data->req; - conn->bits.done = FALSE; /* Curl_done() is not called yet */ - conn->bits.do_more = FALSE; /* by default there's no curl_do_more() to use */ + if(conn) + conn->bits.do_more = FALSE; /* by default there's no curl_do_more() to + * use */ + + data->state.done = FALSE; /* Curl_done() is not called yet */ data->state.expect100header = FALSE; if(data->set.opt_no_body) @@ -5986,7 +6196,7 @@ CURLcode Curl_do(struct connectdata **connp, bool *done) if(!data->multi) { result = Curl_reconnect_request(connp); - if(result == CURLE_OK) { + if(!result) { /* ... finally back to actually retry the DO phase */ conn = *connp; /* re-assign conn since Curl_reconnect_request creates a new connection */ @@ -5997,7 +6207,7 @@ CURLcode Curl_do(struct connectdata **connp, bool *done) return result; } - if((result == CURLE_OK) && *done) + if(!result && *done) /* do_complete must be called after the protocol-specific DO function */ do_complete(conn); } diff --git a/lib/url.h b/lib/url.h index cd46a92..f9667cb 100644 --- a/lib/url.h +++ b/lib/url.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2013, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -27,6 +27,7 @@ * Prototypes for library-wide functions provided by url.c */ +CURLcode Curl_init_do(struct SessionHandle *data, struct connectdata *conn); CURLcode Curl_open(struct SessionHandle **curl); CURLcode Curl_init_userdefined(struct UserDefined *set); CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, @@ -69,6 +70,9 @@ void Curl_close_connections(struct SessionHandle *data); #define CURL_DEFAULT_PROXY_PORT 1080 /* default proxy port unless specified */ #define CURL_DEFAULT_SOCKS5_GSSAPI_SERVICE "rcmd" /* default socks5 gssapi service */ +#define CURL_DEFAULT_PROXY_SERVICE_NAME "HTTP" /* default negotiate proxy + service */ +#define CURL_DEFAULT_SERVICE_NAME "HTTP" /* default negotiate service */ CURLcode Curl_connected_proxy(struct connectdata *conn, int sockindex); diff --git a/lib/urldata.h b/lib/urldata.h index 8594c2f..b1c2056 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -40,6 +40,8 @@ #define PORT_IMAPS 993 #define PORT_POP3 110 #define PORT_POP3S 995 +#define PORT_SMB 445 +#define PORT_SMBS 445 #define PORT_SMTP 25 #define PORT_SMTPS 465 /* sometimes called SSMTP */ #define PORT_RTSP 554 @@ -64,6 +66,7 @@ #define PROTO_FAMILY_HTTP (CURLPROTO_HTTP|CURLPROTO_HTTPS) #define PROTO_FAMILY_FTP (CURLPROTO_FTP|CURLPROTO_FTPS) #define PROTO_FAMILY_POP3 (CURLPROTO_POP3|CURLPROTO_POP3S) +#define PROTO_FAMILY_SMB (CURLPROTO_SMB|CURLPROTO_SMBS) #define PROTO_FAMILY_SMTP (CURLPROTO_SMTP|CURLPROTO_SMTPS) #define DEFAULT_CONNCACHE_SIZE 5 @@ -79,38 +82,12 @@ #include "cookie.h" #include "formdata.h" -#ifdef USE_SSLEAY #ifdef USE_OPENSSL -#include -#include -#include -#include #include -#include #ifdef HAVE_OPENSSL_ENGINE_H #include #endif -#ifdef HAVE_OPENSSL_PKCS12_H -#include -#endif -#else /* SSLeay-style includes */ -#include -#include -#include -#include -#include -#include -#ifdef HAVE_OPENSSL_ENGINE_H -#include -#endif -#ifdef HAVE_OPENSSL_PKCS12_H -#include -#endif #endif /* USE_OPENSSL */ -#ifdef USE_GNUTLS -#error Configuration error; cannot use GnuTLS *and* OpenSSL. -#endif -#endif /* USE_SSLEAY */ #ifdef USE_GNUTLS #include @@ -138,15 +115,12 @@ #include #endif -#ifdef USE_QSOSSL -#include -#endif - #ifdef USE_GSKIT #include #endif #ifdef USE_AXTLS +#include #include #undef malloc #undef calloc @@ -195,6 +169,7 @@ #include "ssh.h" #include "http.h" #include "rtsp.h" +#include "smb.h" #include "wildcard.h" #include "multihandle.h" @@ -223,6 +198,8 @@ #define HEADERSIZE 256 #define CURLEASY_MAGIC_NUMBER 0xc0dedbadU +#define GOOD_EASY_HANDLE(x) \ + ((x) && (((struct SessionHandle *)(x))->magic == CURLEASY_MAGIC_NUMBER)) /* Some convenience macros to get the larger/smaller value out of two given. We prefix with CURL to prevent name collisions. */ @@ -288,13 +265,13 @@ struct ssl_connect_data { current state of the connection. */ bool use; ssl_connection_state state; -#ifdef USE_SSLEAY +#ifdef USE_OPENSSL /* these ones requires specific SSL-types */ SSL_CTX* ctx; SSL* handle; X509* server_cert; ssl_connect_state connecting_state; -#endif /* USE_SSLEAY */ +#endif /* USE_OPENSSL */ #ifdef USE_GNUTLS gnutls_session_t session; gnutls_certificate_credentials_t cred; @@ -328,9 +305,6 @@ struct ssl_connect_data { PK11GenericObject *obj_clicert; ssl_connect_state connecting_state; #endif /* USE_NSS */ -#ifdef USE_QSOSSL - SSLHandle *handle; -#endif /* USE_QSOSSL */ #ifdef USE_GSKIT gsk_handle handle; int iocport; @@ -350,6 +324,9 @@ struct ssl_connect_data { size_t encdata_offset, decdata_offset; unsigned char *encdata_buffer, *decdata_buffer; unsigned long req_flags, ret_flags; + CURLcode recv_unrecoverable_err; /* schannel_recv had an unrecoverable err */ + bool recv_sspi_close_notify; /* true if connection closed by close_notify */ + bool recv_connection_closed; /* true if connection closed, regardless how */ #endif /* USE_SCHANNEL */ #ifdef USE_DARWINSSL SSLContextRef ssl_ctx; @@ -366,6 +343,7 @@ struct ssl_config_data { bool verifypeer; /* set TRUE if this is desired */ bool verifyhost; /* set TRUE if CN/SAN must match hostname */ + bool verifystatus; /* set TRUE if certificate status must be checked */ char *CApath; /* certificate dir (doesn't work on windows) */ char *CAfile; /* certificate to verify peer against */ const char *CRLfile; /* CRL to check certificate revocation */ @@ -378,6 +356,7 @@ struct ssl_config_data { void *fsslctxp; /* parameter for call back */ bool sessionid; /* cache session IDs or not */ bool certinfo; /* gather lots of certificate info */ + bool falsestart; #ifdef USE_TLS_SRP char *username; /* TLS username (for, e.g., SRP) */ @@ -398,6 +377,10 @@ struct curl_ssl_session { /* Struct used for Digest challenge-response authentication */ struct digestdata { +#if defined(USE_WINDOWS_SSPI) + BYTE *input_token; + size_t input_token_len; +#else char *nonce; char *cnonce; char *realm; @@ -407,6 +390,7 @@ struct digestdata { char *qop; char *algorithm; int nc; /* nounce count */ +#endif }; typedef enum { @@ -426,8 +410,9 @@ typedef enum { #endif /* Struct used for GSSAPI (Kerberos V5) authentication */ -#if defined(USE_WINDOWS_SSPI) +#if defined(USE_KERBEROS5) struct kerberos5data { +#if defined(USE_WINDOWS_SSPI) CredHandle *credentials; CtxtHandle *context; TCHAR *spn; @@ -435,22 +420,26 @@ struct kerberos5data { SEC_WINNT_AUTH_IDENTITY *p_identity; size_t token_max; BYTE *output_token; +#else + gss_ctx_id_t context; + gss_name_t spn; +#endif }; #endif /* Struct used for NTLM challenge-response authentication */ +#if defined(USE_NTLM) struct ntlmdata { curlntlm state; #ifdef USE_WINDOWS_SSPI - CredHandle handle; - CtxtHandle c_handle; + CredHandle *credentials; + CtxtHandle *context; SEC_WINNT_AUTH_IDENTITY identity; SEC_WINNT_AUTH_IDENTITY *p_identity; - size_t max_token_length; + size_t token_max; BYTE *output_token; - int has_handles; - void *type_2; - unsigned long n_type_2; + BYTE *input_token; + size_t input_token_len; #else unsigned int flags; unsigned char nonce[8]; @@ -458,6 +447,7 @@ struct ntlmdata { unsigned int target_info_len; #endif }; +#endif #ifdef USE_SPNEGO struct negotiatedata { @@ -472,12 +462,12 @@ struct negotiatedata { #else #ifdef USE_WINDOWS_SSPI DWORD status; - CtxtHandle *context; CredHandle *credentials; + CtxtHandle *context; SEC_WINNT_AUTH_IDENTITY identity; SEC_WINNT_AUTH_IDENTITY *p_identity; TCHAR *server_name; - size_t max_token_length; + size_t token_max; BYTE *output_token; size_t output_token_length; #endif @@ -531,11 +521,6 @@ struct ConnectBits { requests */ bool netrc; /* name+password provided by netrc */ bool userpwd_in_url; /* name+password found in url */ - - bool done; /* set to FALSE when Curl_do() is called and set to TRUE - when Curl_done() is called, to prevent Curl_done() to - get invoked twice when the multi interface is - used. */ bool stream_was_rewound; /* Indicates that the stream was rewound after a request read past the end of its response byte boundary */ @@ -545,6 +530,7 @@ struct ConnectBits { bool bound; /* set true if bind() has already been done on this socket/ connection */ bool type_set; /* type= was used in the URL */ + bool multiplex; /* connection is multiplexed */ }; struct hostname { @@ -617,12 +603,6 @@ enum upgrade101 { UPGR101_WORKING /* talking upgraded protocol */ }; -enum negotiatenpn { - NPN_INIT, /* default state */ - NPN_HTTP1_1, /* HTTP/1.1 negotiated */ - NPN_HTTP2 /* HTTP2 (draft-xx) negotiated */ -}; - /* * Request specific data in the easy handle (SessionHandle). Previously, * these members were on the connectdata struct but since a conn struct may @@ -680,7 +660,6 @@ struct SingleRequest { #define IDENTITY 0 /* No encoding */ #define DEFLATE 1 /* zlib deflate [RFC 1950 & 1951] */ #define GZIP 2 /* gzip algorithm [RFC 1952] */ -#define COMPRESS 3 /* Not handled, added for completeness */ #ifdef HAVE_LIBZ zlibInitState zlib_init; /* possible zlib init state; @@ -883,7 +862,7 @@ struct connectdata { the ip_addr itself. */ char ip_addr_str[MAX_IPADR_LEN]; - unsigned int scope; /* address scope for IPv6 */ + unsigned int scope_id; /* Scope id for IPv6 */ int socktype; /* SOCK_STREAM or SOCK_DGRAM */ @@ -974,8 +953,8 @@ struct connectdata { char *te; /* TE: request header */ } allocptr; - int sec_complete; /* if kerberos is enabled for this connection */ #ifdef HAVE_GSSAPI + int sec_complete; /* if Kerberos is enabled for this connection */ enum protection_level command_prot; enum protection_level data_prot; enum protection_level request_data_prot; @@ -986,7 +965,7 @@ struct connectdata { struct sockaddr_in local_addr; #endif -#if defined(USE_WINDOWS_SSPI) /* Consider moving some of the above GSS-API */ +#if defined(USE_KERBEROS5) /* Consider moving some of the above GSS-API */ struct kerberos5data krb5; /* variables into the structure definition, */ #endif /* however, some of them are ftp specific. */ @@ -1013,22 +992,20 @@ struct connectdata { /*************** Request - specific items ************/ - /* previously this was in the urldata struct */ - curl_read_callback fread_func; /* function that reads the input */ - void *fread_in; /* pointer to pass to the fread() above */ - +#if defined(USE_NTLM) struct ntlmdata ntlm; /* NTLM differs from other authentication schemes because it authenticates connections, not single requests! */ struct ntlmdata proxyntlm; /* NTLM data for proxy */ -#if defined(USE_NTLM) && defined(NTLM_WB_ENABLED) +#if defined(NTLM_WB_ENABLED) /* used for communication with Samba's winbind daemon helper ntlm_auth */ curl_socket_t ntlm_auth_hlpr_socket; pid_t ntlm_auth_hlpr_pid; char* challenge_header; char* response_header; #endif +#endif char syserr_buf [256]; /* buffer for Curl_strerror() */ @@ -1051,6 +1028,7 @@ struct connectdata { struct pop3_conn pop3c; struct smtp_conn smtpc; struct rtsp_conn rtspc; + struct smb_conn smbc; void *generic; /* RTMP and LDAP use this */ } proto; @@ -1081,7 +1059,7 @@ struct connectdata { } tunnel_state[2]; /* two separate ones to allow FTP */ struct connectbundle *bundle; /* The bundle we are member of */ - enum negotiatenpn negnpn; + int negnpn; /* APLN or NPN TLS negotiated protocol, CURL_HTTP_VERSION* */ }; /* The end of connectdata. */ @@ -1279,9 +1257,9 @@ struct UrlState { void *resolver; /* resolver state, if it is used in the URL state - ares_channel f.e. */ -#if defined(USE_SSLEAY) && defined(HAVE_OPENSSL_ENGINE_H) +#if defined(USE_OPENSSL) && defined(HAVE_OPENSSL_ENGINE_H) ENGINE *engine; -#endif /* USE_SSLEAY */ +#endif /* USE_OPENSSL */ struct timeval expiretime; /* set this with Curl_expire() only */ struct Curl_tree timenode; /* for the splay stuff */ struct curl_llist *timeoutlist; /* list of pending timeouts */ @@ -1325,10 +1303,15 @@ struct UrlState { long rtsp_next_server_CSeq; /* the session's next server CSeq */ long rtsp_CSeq_recv; /* most recent CSeq received */ - /* if true, force SSL connection retry (workaround for certain servers) */ - bool ssl_connect_retry; curl_off_t infilesize; /* size of file to upload, -1 means unknown. Copied from set.filesize at start of operation */ + + int drain; /* Increased when this stream has data to read, even if its + socket not necessarily is readable. Decreased when + checked. */ + bool done; /* set to FALSE when Curl_do() is called and set to TRUE when + Curl_done() is called, to prevent Curl_done() to get invoked + twice when the multi interface is used. */ }; @@ -1378,13 +1361,13 @@ enum dupstring { STRING_KRB_LEVEL, /* krb security level */ STRING_NETRC_FILE, /* if not NULL, use this instead of trying to find $HOME/.netrc */ - STRING_COPYPOSTFIELDS, /* if POST, set the fields' values here */ STRING_PROXY, /* proxy to use */ STRING_SET_RANGE, /* range, if used */ STRING_SET_REFERER, /* custom string for the HTTP referer field */ STRING_SET_URL, /* what original URL to work on */ STRING_SSL_CAPATH, /* CA directory name (doesn't work on windows) */ STRING_SSL_CAFILE, /* certificate file to verify peer against */ + STRING_SSL_PINNEDPUBLICKEY, /* public key file to verify peer against */ STRING_SSL_CIPHER_LIST, /* list of ciphers to use */ STRING_SSL_EGDSOCKET, /* path to file containing the EGD daemon socket */ STRING_SSL_RANDOM_FILE, /* path to file containing "random" data */ @@ -1408,19 +1391,31 @@ enum dupstring { STRING_SSH_KNOWNHOSTS, /* file name of knownhosts file */ #endif #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI) - STRING_SOCKS5_GSSAPI_SERVICE, /* GSSAPI service name */ + STRING_SOCKS5_GSSAPI_SERVICE, /* GSSAPI service name */ + STRING_PROXY_SERVICE_NAME, /* Proxy service name */ + STRING_SERVICE_NAME, /* Service name */ #endif STRING_MAIL_FROM, STRING_MAIL_AUTH, #ifdef USE_TLS_SRP - STRING_TLSAUTH_USERNAME, /* TLS auth */ - STRING_TLSAUTH_PASSWORD, /* TLS auth */ + STRING_TLSAUTH_USERNAME, /* TLS auth */ + STRING_TLSAUTH_PASSWORD, /* TLS auth */ #endif + STRING_BEARER, /* , if used */ +#ifdef USE_UNIX_SOCKETS + STRING_UNIX_SOCKET_PATH, /* path to Unix socket, if used */ +#endif + + /* -- end of zero-terminated strings -- */ - STRING_BEARER, /* , if used */ + STRING_LASTZEROTERMINATED, + + /* -- below this are pointers to binary data that cannot be strdup'ed. + Each such pointer must be added manually to Curl_dupset() --- */ + + STRING_COPYPOSTFIELDS, /* if POST, set the fields' values here */ - /* -- end of strings -- */ STRING_LAST /* not used, just an end-of-list marker */ }; @@ -1431,8 +1426,8 @@ struct UserDefined { long proxyport; /* If non-zero, use this port number by default. If the proxy string features a ":[port]" that one will override this. */ - void *out; /* the fetched file goes here */ - void *in; /* the uploaded file is read from here */ + void *out; /* CURLOPT_WRITEDATA */ + void *in; /* CURLOPT_READDATA */ void *writeheader; /* write the header to this if non-NULL */ void *rtp_out; /* write RTP to this if non-NULL */ long use_port; /* which port to use (when not using default) */ @@ -1553,7 +1548,7 @@ struct UserDefined { bool ftp_list_only; /* switch FTP command for listing directories */ bool ftp_use_port; /* use the FTP PORT command */ bool hide_progress; /* don't use the progress meter */ - bool http_fail_on_error; /* fail on HTTP error codes >= 300 */ + bool http_fail_on_error; /* fail on HTTP error codes >= 400 */ bool http_follow_location; /* follow HTTP redirects */ bool http_transfer_encoding; /* request compressed HTTP transfer-encoding */ bool http_disable_hostname_check_before_authentication; @@ -1566,7 +1561,7 @@ struct UserDefined { enum CURL_NETRC_OPTION use_netrc; /* defined in include/curl.h */ bool verbose; /* output verbosity */ - bool krb; /* kerberos connection requested */ + bool krb; /* Kerberos connection requested */ bool reuse_forbid; /* forbidden to be reused, close after use */ bool reuse_fresh; /* do not re-use an existing connection */ bool ftp_use_epsv; /* if EPSV is to be attempted or not */ @@ -1586,6 +1581,7 @@ struct UserDefined { bool connect_only; /* make connection, let application use the socket */ bool ssl_enable_beast; /* especially allow this flaw for interoperability's sake*/ + bool ssl_no_revoke; /* disable SSL certificate revocation checks */ long ssh_auth_types; /* allowed SSH auth types */ bool http_te_skip; /* pass the raw body data to the user, even when transfer-encoded (chunked, compressed) */ @@ -1596,7 +1592,7 @@ struct UserDefined { bool proxy_transfer_mode; /* set transfer mode (;type=) when doing FTP via an HTTP proxy */ char *str[STRING_LAST]; /* array of strings, pointing to allocated memory */ - unsigned int scope; /* address scope for IPv6 */ + unsigned int scope_id; /* Scope id for IPv6 */ long allowed_protocols; long redir_protocols; #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI) @@ -1627,7 +1623,9 @@ struct UserDefined { bool ssl_enable_npn; /* TLS NPN extension? */ bool ssl_enable_alpn; /* TLS ALPN extension? */ - + bool path_as_is; /* allow dotdots? */ + bool pipewait; /* wait for pipe/multiplex status before starting a + new connection */ long expect_100_timeout; /* in milliseconds */ }; diff --git a/lib/version.c b/lib/version.c index 788f3e9..1727c5a 100644 --- a/lib/version.c +++ b/lib/version.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2013, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -26,9 +26,7 @@ #include "urldata.h" #include "vtls/vtls.h" #include "http2.h" - -#define _MPRINTF_REPLACE /* use the internal *printf() functions */ -#include +#include "curl_printf.h" #ifdef USE_ARES # if defined(CURL_STATICLIB) && !defined(CARES_STATICLIB) && \ @@ -216,6 +214,14 @@ static const char * const protocols[] = { #ifdef USE_LIBSSH2 "sftp", #endif +#if !defined(CURL_DISABLE_SMB) && defined(USE_NTLM) && \ + (CURL_SIZEOF_CURL_OFF_T > 4) && \ + (!defined(USE_WINDOWS_SSPI) || defined(USE_WIN32_CRYPTO)) + "smb", +# ifdef USE_SSL + "smbs", +# endif +#endif #ifndef CURL_DISABLE_SMTP "smtp", #endif @@ -247,12 +253,16 @@ static curl_version_info_data version_info = { #ifdef USE_NTLM | CURL_VERSION_NTLM #endif -#if defined(USE_NTLM) && defined(NTLM_WB_ENABLED) +#if !defined(CURL_DISABLE_HTTP) && defined(USE_NTLM) && \ + defined(NTLM_WB_ENABLED) | CURL_VERSION_NTLM_WB #endif #ifdef USE_SPNEGO | CURL_VERSION_SPNEGO #endif +#ifdef USE_KERBEROS5 + | CURL_VERSION_KERBEROS5 +#endif #ifdef HAVE_GSSAPI | CURL_VERSION_GSSAPI #endif @@ -284,6 +294,9 @@ static curl_version_info_data version_info = { #if defined(USE_NGHTTP2) | CURL_VERSION_HTTP2 #endif +#if defined(USE_UNIX_SOCKETS) + | CURL_VERSION_UNIX_SOCKETS +#endif , NULL, /* ssl_version */ 0, /* ssl_version_num, this is kept at zero */ diff --git a/lib/vtls/axtls.c b/lib/vtls/axtls.c index 1b577b1..1038432 100644 --- a/lib/vtls/axtls.c +++ b/lib/vtls/axtls.c @@ -6,7 +6,7 @@ * \___|\___/|_| \_\_____| * * Copyright (C) 2010, DirecTV, Contact: Eric Hu, . - * Copyright (C) 2010 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 2010 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -29,6 +29,7 @@ #include "curl_setup.h" #ifdef USE_AXTLS +#include #include #include "axtls.h" @@ -38,13 +39,13 @@ #include "parsedate.h" #include "connect.h" /* for the connect timeout */ #include "select.h" -#define _MPRINTF_REPLACE /* use our functions only */ -#include -#include "curl_memory.h" +#include "curl_printf.h" +#include "hostcheck.h" #include -/* The last #include file should be: */ + +/* The last #include files should be: */ +#include "curl_memory.h" #include "memdebug.h" -#include "hostcheck.h" /* Global axTLS init, called from Curl_ssl_init() */ @@ -463,9 +464,11 @@ Curl_axtls_connect(struct connectdata *conn, int sockindex) { + struct SessionHandle *data = conn->data; CURLcode conn_step = connect_prep(conn, sockindex); int ssl_fcn_return; SSL *ssl = conn->ssl[sockindex].ssl; + long timeout_ms; if(conn_step != CURLE_OK) { Curl_axtls_close(conn, sockindex); @@ -474,14 +477,23 @@ Curl_axtls_connect(struct connectdata *conn, /* Check to make sure handshake was ok. */ while(ssl_handshake_status(ssl) != SSL_OK) { + /* check allowed time left */ + timeout_ms = Curl_timeleft(data, NULL, TRUE); + + if(timeout_ms < 0) { + /* no need to continue if time already is up */ + failf(data, "SSL connection timeout"); + return CURLE_OPERATION_TIMEDOUT; + } + ssl_fcn_return = ssl_read(ssl, NULL); if(ssl_fcn_return < 0) { Curl_axtls_close(conn, sockindex); ssl_display_error(ssl_fcn_return); /* goes to stdout. */ return map_error_to_curl(ssl_fcn_return); } + /* TODO: avoid polling */ usleep(10000); - /* TODO: check for timeout as this could hang indefinitely otherwise */ } infof (conn->data, "handshake completed successfully\n"); @@ -515,12 +527,6 @@ static ssize_t axtls_send(struct connectdata *conn, return rc; } -void Curl_axtls_close_all(struct SessionHandle *data) -{ - (void)data; - infof(data, " Curl_axtls_close_all\n"); -} - void Curl_axtls_close(struct connectdata *conn, int sockindex) { struct ssl_connect_data *connssl = &conn->ssl[sockindex]; @@ -677,7 +683,7 @@ int Curl_axtls_random(struct SessionHandle *data, * race condition is that some global resources will leak. */ RNG_initialize(); } - get_random(length, entropy); + get_random((int)length, entropy); return 0; } diff --git a/lib/vtls/axtls.h b/lib/vtls/axtls.h index 0459cf2..223ecb8 100644 --- a/lib/vtls/axtls.h +++ b/lib/vtls/axtls.h @@ -7,8 +7,8 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 2010, DirecTV - * contact: Eric Hu + * Copyright (C) 2010, DirecTV, Contact: Eric Hu + * Copyright (C) 2010 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -35,10 +35,6 @@ CURLcode Curl_axtls_connect_nonblocking( int sockindex, bool *done); -/* tell axTLS to close down all open information regarding connections (and - thus session ID caching etc) */ -void Curl_axtls_close_all(struct SessionHandle *data); - /* close a SSL connection */ void Curl_axtls_close(struct connectdata *conn, int sockindex); @@ -50,23 +46,26 @@ int Curl_axtls_random(struct SessionHandle *data, unsigned char *entropy, size_t length); +/* Set the API backend definition to axTLS */ +#define CURL_SSL_BACKEND CURLSSLBACKEND_AXTLS + /* API setup for axTLS */ #define curlssl_init Curl_axtls_init #define curlssl_cleanup Curl_axtls_cleanup #define curlssl_connect Curl_axtls_connect #define curlssl_connect_nonblocking Curl_axtls_connect_nonblocking #define curlssl_session_free(x) Curl_axtls_session_free(x) -#define curlssl_close_all Curl_axtls_close_all +#define curlssl_close_all(x) ((void)x) #define curlssl_close Curl_axtls_close #define curlssl_shutdown(x,y) Curl_axtls_shutdown(x,y) -#define curlssl_set_engine(x,y) (x=x, y=y, CURLE_NOT_BUILT_IN) -#define curlssl_set_engine_default(x) (x=x, CURLE_NOT_BUILT_IN) -#define curlssl_engines_list(x) (x=x, (struct curl_slist *)NULL) +#define curlssl_set_engine(x,y) ((void)x, (void)y, CURLE_NOT_BUILT_IN) +#define curlssl_set_engine_default(x) ((void)x, CURLE_NOT_BUILT_IN) +#define curlssl_engines_list(x) ((void)x, (struct curl_slist *)NULL) #define curlssl_version Curl_axtls_version #define curlssl_check_cxn(x) Curl_axtls_check_cxn(x) -#define curlssl_data_pending(x,y) (x=x, y=y, 0) +#define curlssl_data_pending(x,y) ((void)x, (void)y, 0) #define curlssl_random(x,y,z) Curl_axtls_random(x,y,z) -#define CURL_SSL_BACKEND CURLSSLBACKEND_AXTLS + #endif /* USE_AXTLS */ #endif /* HEADER_CURL_AXTLS_H */ diff --git a/lib/vtls/cyassl.c b/lib/vtls/cyassl.c index 9b5c7c6..3ded7f1 100644 --- a/lib/vtls/cyassl.c +++ b/lib/vtls/cyassl.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -30,6 +30,20 @@ #ifdef USE_CYASSL +#define WOLFSSL_OPTIONS_IGNORE_SYS +/* CyaSSL's version.h, which should contain only the version, should come +before all other CyaSSL includes and be immediately followed by build config +aka options.h. http://curl.haxx.se/mail/lib-2015-04/0069.html */ +#include +#if defined(HAVE_CYASSL_OPTIONS_H) && (LIBCYASSL_VERSION_HEX > 0x03004008) +#if defined(CYASSL_API) || defined(WOLFSSL_API) +/* Safety measure. If either is defined some API include was already included +and that's a problem since options.h hasn't been included yet. */ +#error "CyaSSL API was included before the CyaSSL build options." +#endif +#include +#endif + #ifdef HAVE_LIMITS_H #include #endif @@ -43,10 +57,8 @@ #include "connect.h" /* for the connect timeout */ #include "select.h" #include "rawstr.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include -#include "curl_memory.h" +#include "x509asn1.h" +#include "curl_printf.h" #include #ifdef HAVE_CYASSL_ERROR_SSL_H @@ -55,10 +67,16 @@ #include #endif #include +#include -/* The last #include file should be: */ +/* The last #include files should be: */ +#include "curl_memory.h" #include "memdebug.h" +#if LIBCYASSL_VERSION_HEX < 0x02007002 /* < 2.7.2 */ +#define CYASSL_MAX_ERROR_SZ 80 +#endif + static Curl_recv cyassl_recv; static Curl_send cyassl_send; @@ -82,46 +100,58 @@ static CURLcode cyassl_connect_step1(struct connectdata *conn, int sockindex) { + char error_buffer[CYASSL_MAX_ERROR_SZ]; struct SessionHandle *data = conn->data; struct ssl_connect_data* conssl = &conn->ssl[sockindex]; SSL_METHOD* req_method = NULL; void* ssl_sessionid = NULL; curl_socket_t sockfd = conn->sock[sockindex]; +#ifdef HAVE_SNI + bool sni = FALSE; +#define use_sni(x) sni = (x) +#else +#define use_sni(x) Curl_nop_stmt +#endif if(conssl->state == ssl_connection_complete) return CURLE_OK; - /* CyaSSL doesn't support SSLv2 */ - if(data->set.ssl.version == CURL_SSLVERSION_SSLv2) { - failf(data, "CyaSSL does not support SSLv2"); - return CURLE_SSL_CONNECT_ERROR; - } - /* check to see if we've been told to use an explicit SSL/TLS version */ switch(data->set.ssl.version) { case CURL_SSLVERSION_DEFAULT: - /* we try to figure out version */ - req_method = SSLv23_client_method(); - break; case CURL_SSLVERSION_TLSv1: - infof(data, "CyaSSL cannot be configured to use TLS 1.0-1.2, " +#if LIBCYASSL_VERSION_HEX >= 0x03003000 /* >= 3.3.0 */ + /* minimum protocol version is set later after the CTX object is created */ + req_method = SSLv23_client_method(); +#else + infof(data, "CyaSSL <3.3.0 cannot be configured to use TLS 1.0-1.2, " "TLS 1.0 is used exclusively\n"); req_method = TLSv1_client_method(); +#endif + use_sni(TRUE); break; case CURL_SSLVERSION_TLSv1_0: req_method = TLSv1_client_method(); + use_sni(TRUE); break; case CURL_SSLVERSION_TLSv1_1: req_method = TLSv1_1_client_method(); + use_sni(TRUE); break; case CURL_SSLVERSION_TLSv1_2: req_method = TLSv1_2_client_method(); + use_sni(TRUE); break; case CURL_SSLVERSION_SSLv3: req_method = SSLv3_client_method(); + use_sni(FALSE); break; + case CURL_SSLVERSION_SSLv2: + failf(data, "CyaSSL does not support SSLv2"); + return CURLE_SSL_CONNECT_ERROR; default: - req_method = TLSv1_client_method(); + failf(data, "Unrecognized parameter passed via CURLOPT_SSLVERSION"); + return CURLE_SSL_CONNECT_ERROR; } if(!req_method) { @@ -138,15 +168,36 @@ cyassl_connect_step1(struct connectdata *conn, return CURLE_OUT_OF_MEMORY; } + switch(data->set.ssl.version) { + case CURL_SSLVERSION_DEFAULT: + case CURL_SSLVERSION_TLSv1: +#if LIBCYASSL_VERSION_HEX > 0x03004006 /* > 3.4.6 */ + /* Versions 3.3.0 to 3.4.6 we know the minimum protocol version is whatever + minimum version of TLS was built in and at least TLS 1.0. For later library + versions that could change (eg TLS 1.0 built in but defaults to TLS 1.1) so + we have this short circuit evaluation to find the minimum supported TLS + version. We use wolfSSL_CTX_SetMinVersion and not CyaSSL_SetMinVersion + because only the former will work before the user's CTX callback is called. + */ + if((wolfSSL_CTX_SetMinVersion(conssl->ctx, WOLFSSL_TLSV1) != 1) && + (wolfSSL_CTX_SetMinVersion(conssl->ctx, WOLFSSL_TLSV1_1) != 1) && + (wolfSSL_CTX_SetMinVersion(conssl->ctx, WOLFSSL_TLSV1_2) != 1)) { + failf(data, "SSL: couldn't set the minimum protocol version"); + return CURLE_SSL_CONNECT_ERROR; + } +#endif + break; + } + #ifndef NO_FILESYSTEM /* load trusted cacert */ if(data->set.str[STRING_SSL_CAFILE]) { - if(!SSL_CTX_load_verify_locations(conssl->ctx, - data->set.str[STRING_SSL_CAFILE], - data->set.str[STRING_SSL_CAPATH])) { + if(1 != SSL_CTX_load_verify_locations(conssl->ctx, + data->set.str[STRING_SSL_CAFILE], + data->set.str[STRING_SSL_CAPATH])) { if(data->set.ssl.verifypeer) { /* Fail if we insist on successfully verifying the server. */ - failf(data,"error setting certificate verify locations:\n" + failf(data, "error setting certificate verify locations:\n" " CAfile: %s\n CApath: %s", data->set.str[STRING_SSL_CAFILE]? data->set.str[STRING_SSL_CAFILE]: "none", @@ -192,11 +243,7 @@ cyassl_connect_step1(struct connectdata *conn, return CURLE_SSL_CONNECT_ERROR; } } -#else - if(CyaSSL_no_filesystem_verify(conssl->ctx)!= SSL_SUCCESS) { - return CURLE_SSL_CONNECT_ERROR; - } -#endif /* NO_FILESYSTEM */ +#endif /* !NO_FILESYSTEM */ /* SSL always tries to verify the peer, this only says whether it should * fail to connect if the verification fails, or if it should continue @@ -206,6 +253,46 @@ cyassl_connect_step1(struct connectdata *conn, data->set.ssl.verifypeer?SSL_VERIFY_PEER:SSL_VERIFY_NONE, NULL); +#ifdef HAVE_SNI + if(sni) { + struct in_addr addr4; +#ifdef ENABLE_IPV6 + struct in6_addr addr6; +#endif + size_t hostname_len = strlen(conn->host.name); + if((hostname_len < USHRT_MAX) && + (0 == Curl_inet_pton(AF_INET, conn->host.name, &addr4)) && +#ifdef ENABLE_IPV6 + (0 == Curl_inet_pton(AF_INET6, conn->host.name, &addr6)) && +#endif + (CyaSSL_CTX_UseSNI(conssl->ctx, CYASSL_SNI_HOST_NAME, conn->host.name, + (unsigned short)hostname_len) != 1)) { + infof(data, "WARNING: failed to configure server name indication (SNI) " + "TLS extension\n"); + } + } +#endif + + /* give application a chance to interfere with SSL set up. */ + if(data->set.ssl.fsslctx) { + CURLcode result = CURLE_OK; + result = (*data->set.ssl.fsslctx)(data, conssl->ctx, + data->set.ssl.fsslctxp); + if(result) { + failf(data, "error signaled by ssl ctx callback"); + return result; + } + } +#ifdef NO_FILESYSTEM + else if(data->set.ssl.verifypeer) { + failf(data, "SSL: Certificates couldn't be loaded because CyaSSL was built" + " with \"no filesystem\". Either disable peer verification" + " (insecure) or if you are building an application with libcurl you" + " can load certificates via CURLOPT_SSL_CTX_FUNCTION."); + return CURLE_SSL_CONNECT_ERROR; + } +#endif + /* Let's make an SSL structure */ if(conssl->handle) SSL_free(conssl->handle); @@ -220,7 +307,7 @@ cyassl_connect_step1(struct connectdata *conn, /* we got a session id, use it! */ if(!SSL_set_session(conssl->handle, ssl_sessionid)) { failf(data, "SSL: SSL_set_session failed: %s", - ERR_error_string(SSL_get_error(conssl->handle, 0),NULL)); + ERR_error_string(SSL_get_error(conssl->handle, 0), error_buffer)); return CURLE_SSL_CONNECT_ERROR; } /* Informational message */ @@ -246,9 +333,6 @@ cyassl_connect_step2(struct connectdata *conn, struct SessionHandle *data = conn->data; struct ssl_connect_data* conssl = &conn->ssl[sockindex]; - infof(data, "CyaSSL: Connecting to %s:%d\n", - conn->host.name, conn->remote_port); - conn->recv[sockindex] = cyassl_recv; conn->send[sockindex] = cyassl_send; @@ -261,7 +345,7 @@ cyassl_connect_step2(struct connectdata *conn, ret = SSL_connect(conssl->handle); if(ret != 1) { - char error_buffer[80]; + char error_buffer[CYASSL_MAX_ERROR_SZ]; int detail = SSL_get_error(conssl->handle, ret); if(SSL_ERROR_WANT_READ == detail) { @@ -321,6 +405,44 @@ cyassl_connect_step2(struct connectdata *conn, } } + if(data->set.str[STRING_SSL_PINNEDPUBLICKEY]) { + X509 *x509; + const char *x509_der; + int x509_der_len; + curl_X509certificate x509_parsed; + curl_asn1Element *pubkey; + CURLcode result; + + x509 = SSL_get_peer_certificate(conssl->handle); + if(!x509) { + failf(data, "SSL: failed retrieving server certificate"); + return CURLE_SSL_PINNEDPUBKEYNOTMATCH; + } + + x509_der = (const char *)CyaSSL_X509_get_der(x509, &x509_der_len); + if(!x509_der) { + failf(data, "SSL: failed retrieving ASN.1 server certificate"); + return CURLE_SSL_PINNEDPUBKEYNOTMATCH; + } + + memset(&x509_parsed, 0, sizeof x509_parsed); + Curl_parseX509(&x509_parsed, x509_der, x509_der + x509_der_len); + + pubkey = &x509_parsed.subjectPublicKeyInfo; + if(!pubkey->header || pubkey->end <= pubkey->header) { + failf(data, "SSL: failed retrieving public key from server certificate"); + return CURLE_SSL_PINNEDPUBKEYNOTMATCH; + } + + result = Curl_pin_peer_pubkey(data->set.str[STRING_SSL_PINNEDPUBLICKEY], + (const unsigned char *)pubkey->header, + (size_t)(pubkey->end - pubkey->header)); + if(result) { + failf(data, "SSL: public key does not match pinned public key!"); + return result; + } + } + conssl->connecting_state = ssl_connect_3; infof(data, "SSL connected\n"); @@ -332,11 +454,11 @@ static CURLcode cyassl_connect_step3(struct connectdata *conn, int sockindex) { - CURLcode retcode = CURLE_OK; + CURLcode result = CURLE_OK; void *old_ssl_sessionid=NULL; struct SessionHandle *data = conn->data; struct ssl_connect_data *connssl = &conn->ssl[sockindex]; - int incache; + bool incache; SSL_SESSION *our_ssl_sessionid; DEBUGASSERT(ssl_connect_3 == connssl->connecting_state); @@ -351,18 +473,19 @@ cyassl_connect_step3(struct connectdata *conn, incache = FALSE; } } + if(!incache) { - retcode = Curl_ssl_addsessionid(conn, our_ssl_sessionid, - 0 /* unknown size */); - if(retcode) { + result = Curl_ssl_addsessionid(conn, our_ssl_sessionid, + 0 /* unknown size */); + if(result) { failf(data, "failed to store ssl session"); - return retcode; + return result; } } connssl->connecting_state = ssl_connect_done; - return retcode; + return result; } @@ -372,7 +495,7 @@ static ssize_t cyassl_send(struct connectdata *conn, size_t len, CURLcode *curlcode) { - char error_buffer[80]; + char error_buffer[CYASSL_MAX_ERROR_SZ]; int memlen = (len > (size_t)INT_MAX) ? INT_MAX : (int)len; int rc = SSL_write(conn->ssl[sockindex].handle, mem, memlen); @@ -396,11 +519,6 @@ static ssize_t cyassl_send(struct connectdata *conn, return rc; } -void Curl_cyassl_close_all(struct SessionHandle *data) -{ - (void)data; -} - void Curl_cyassl_close(struct connectdata *conn, int sockindex) { struct ssl_connect_data *conssl = &conn->ssl[sockindex]; @@ -422,7 +540,7 @@ static ssize_t cyassl_recv(struct connectdata *conn, size_t buffersize, CURLcode *curlcode) { - char error_buffer[80]; + char error_buffer[CYASSL_MAX_ERROR_SZ]; int buffsize = (buffersize > (size_t)INT_MAX) ? INT_MAX : (int)buffersize; int nread = SSL_read(conn->ssl[num].handle, buf, buffsize); @@ -458,7 +576,9 @@ void Curl_cyassl_session_free(void *ptr) size_t Curl_cyassl_version(char *buffer, size_t size) { -#ifdef CYASSL_VERSION +#ifdef WOLFSSL_VERSION + return snprintf(buffer, size, "wolfSSL/%s", WOLFSSL_VERSION); +#elif defined(CYASSL_VERSION) return snprintf(buffer, size, "CyaSSL/%s", CYASSL_VERSION); #else return snprintf(buffer, size, "CyaSSL/%s", "<1.8.8"); @@ -468,10 +588,7 @@ size_t Curl_cyassl_version(char *buffer, size_t size) int Curl_cyassl_init(void) { - if(CyaSSL_Init() == 0) - return 1; - - return -1; + return (CyaSSL_Init() == SSL_SUCCESS); } @@ -507,7 +624,7 @@ cyassl_connect_common(struct connectdata *conn, bool nonblocking, bool *done) { - CURLcode retcode; + CURLcode result; struct SessionHandle *data = conn->data; struct ssl_connect_data *connssl = &conn->ssl[sockindex]; curl_socket_t sockfd = conn->sock[sockindex]; @@ -529,9 +646,10 @@ cyassl_connect_common(struct connectdata *conn, failf(data, "SSL connection timeout"); return CURLE_OPERATION_TIMEDOUT; } - retcode = cyassl_connect_step1(conn, sockindex); - if(retcode) - return retcode; + + result = cyassl_connect_step1(conn, sockindex); + if(result) + return result; } while(ssl_connect_2 == connssl->connecting_state || @@ -583,22 +701,21 @@ cyassl_connect_common(struct connectdata *conn, * ensuring that a client using select() or epoll() will always * have a valid fdset to wait on. */ - retcode = cyassl_connect_step2(conn, sockindex); - if(retcode || (nonblocking && - (ssl_connect_2 == connssl->connecting_state || - ssl_connect_2_reading == connssl->connecting_state || - ssl_connect_2_writing == connssl->connecting_state))) - return retcode; - + result = cyassl_connect_step2(conn, sockindex); + if(result || (nonblocking && + (ssl_connect_2 == connssl->connecting_state || + ssl_connect_2_reading == connssl->connecting_state || + ssl_connect_2_writing == connssl->connecting_state))) + return result; } /* repeat step2 until all transactions are done. */ - if(ssl_connect_3==connssl->connecting_state) { - retcode = cyassl_connect_step3(conn, sockindex); - if(retcode) - return retcode; + if(ssl_connect_3 == connssl->connecting_state) { + result = cyassl_connect_step3(conn, sockindex); + if(result) + return result; } - if(ssl_connect_done==connssl->connecting_state) { + if(ssl_connect_done == connssl->connecting_state) { connssl->state = ssl_connection_complete; conn->recv[sockindex] = cyassl_recv; conn->send[sockindex] = cyassl_send; @@ -627,12 +744,12 @@ CURLcode Curl_cyassl_connect(struct connectdata *conn, int sockindex) { - CURLcode retcode; + CURLcode result; bool done = FALSE; - retcode = cyassl_connect_common(conn, sockindex, FALSE, &done); - if(retcode) - return retcode; + result = cyassl_connect_common(conn, sockindex, FALSE, &done); + if(result) + return result; DEBUGASSERT(done); @@ -647,9 +764,23 @@ int Curl_cyassl_random(struct SessionHandle *data, (void)data; if(InitRng(&rng)) return 1; - if(RNG_GenerateBlock(&rng, entropy, length)) + if(length > UINT_MAX) + return 1; + if(RNG_GenerateBlock(&rng, entropy, (unsigned)length)) return 1; return 0; } +void Curl_cyassl_sha256sum(const unsigned char *tmp, /* input */ + size_t tmplen, + unsigned char *sha256sum /* output */, + size_t unused) +{ + Sha256 SHA256pw; + (void)unused; + InitSha256(&SHA256pw); + Sha256Update(&SHA256pw, tmp, tmplen); + Sha256Final(&SHA256pw, sha256sum); +} + #endif diff --git a/lib/vtls/cyassl.h b/lib/vtls/cyassl.h index b10b607..167de74 100644 --- a/lib/vtls/cyassl.h +++ b/lib/vtls/cyassl.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -26,13 +26,9 @@ #ifdef USE_CYASSL CURLcode Curl_cyassl_connect(struct connectdata *conn, int sockindex); -bool Curl_cyassl_data_pending(const struct connectdata* conn,int connindex); +bool Curl_cyassl_data_pending(const struct connectdata* conn, int connindex); int Curl_cyassl_shutdown(struct connectdata* conn, int sockindex); -/* tell CyaSSL to close down all open information regarding connections (and - thus session ID caching etc) */ -void Curl_cyassl_close_all(struct SessionHandle *data); - /* close a SSL connection */ void Curl_cyassl_close(struct connectdata *conn, int sockindex); @@ -46,6 +42,16 @@ CURLcode Curl_cyassl_connect_nonblocking(struct connectdata *conn, int Curl_cyassl_random(struct SessionHandle *data, unsigned char *entropy, size_t length); +void Curl_cyassl_sha256sum(const unsigned char *tmp, /* input */ + size_t tmplen, + unsigned char *sha256sum, /* output */ + size_t unused); + +/* Set the API backend definition to Schannel */ +#define CURL_SSL_BACKEND CURLSSLBACKEND_CYASSL + +/* this backend supports CURLOPT_SSL_CTX_* */ +#define have_curlssl_ssl_ctx 1 /* API setup for CyaSSL */ #define curlssl_init Curl_cyassl_init @@ -53,17 +59,17 @@ int Curl_cyassl_random(struct SessionHandle *data, #define curlssl_connect Curl_cyassl_connect #define curlssl_connect_nonblocking Curl_cyassl_connect_nonblocking #define curlssl_session_free(x) Curl_cyassl_session_free(x) -#define curlssl_close_all Curl_cyassl_close_all +#define curlssl_close_all(x) ((void)x) #define curlssl_close Curl_cyassl_close #define curlssl_shutdown(x,y) Curl_cyassl_shutdown(x,y) -#define curlssl_set_engine(x,y) (x=x, y=y, CURLE_NOT_BUILT_IN) -#define curlssl_set_engine_default(x) (x=x, CURLE_NOT_BUILT_IN) -#define curlssl_engines_list(x) (x=x, (struct curl_slist *)NULL) +#define curlssl_set_engine(x,y) ((void)x, (void)y, CURLE_NOT_BUILT_IN) +#define curlssl_set_engine_default(x) ((void)x, CURLE_NOT_BUILT_IN) +#define curlssl_engines_list(x) ((void)x, (struct curl_slist *)NULL) #define curlssl_version Curl_cyassl_version -#define curlssl_check_cxn(x) (x=x, -1) +#define curlssl_check_cxn(x) ((void)x, -1) #define curlssl_data_pending(x,y) Curl_cyassl_data_pending(x,y) #define curlssl_random(x,y,z) Curl_cyassl_random(x,y,z) -#define CURL_SSL_BACKEND CURLSSLBACKEND_CYASSL +#define curlssl_sha256sum(a,b,c,d) Curl_cyassl_sha256sum(a,b,c,d) #endif /* USE_CYASSL */ #endif /* HEADER_CURL_CYASSL_H */ diff --git a/lib/vtls/curl_darwinssl.c b/lib/vtls/darwinssl.c similarity index 96% rename from lib/vtls/curl_darwinssl.c rename to lib/vtls/darwinssl.c index f229c6f..03adcef 100644 --- a/lib/vtls/curl_darwinssl.c +++ b/lib/vtls/darwinssl.c @@ -6,7 +6,7 @@ * \___|\___/|_| \_\_____| * * Copyright (C) 2012 - 2014, Nick Zitzmann, . - * Copyright (C) 2012 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 2012 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -86,6 +86,7 @@ #define CURL_SUPPORT_MAC_10_6 0 #define CURL_SUPPORT_MAC_10_7 0 #define CURL_SUPPORT_MAC_10_8 0 +#define CURL_SUPPORT_MAC_10_9 0 #else #error "The darwinssl back-end requires iOS or OS X." @@ -101,10 +102,8 @@ #include "connect.h" #include "select.h" #include "vtls.h" -#include "curl_darwinssl.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include +#include "darwinssl.h" +#include "curl_printf.h" #include "curl_memory.h" /* The last #include file should be: */ @@ -1057,10 +1056,8 @@ static CURLcode darwinssl_connect_step1(struct connectdata *conn, #if CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS if(SSLSetProtocolVersionMax != NULL) { switch(data->set.ssl.version) { - case CURL_SSLVERSION_DEFAULT: default: - (void)SSLSetProtocolVersionMin(connssl->ssl_ctx, kSSLProtocol3); - (void)SSLSetProtocolVersionMax(connssl->ssl_ctx, kTLSProtocol12); - break; + default: + case CURL_SSLVERSION_DEFAULT: case CURL_SSLVERSION_TLSv1: (void)SSLSetProtocolVersionMin(connssl->ssl_ctx, kTLSProtocol1); (void)SSLSetProtocolVersionMax(connssl->ssl_ctx, kTLSProtocol12); @@ -1078,7 +1075,11 @@ static CURLcode darwinssl_connect_step1(struct connectdata *conn, (void)SSLSetProtocolVersionMax(connssl->ssl_ctx, kTLSProtocol12); break; case CURL_SSLVERSION_SSLv3: - (void)SSLSetProtocolVersionMin(connssl->ssl_ctx, kSSLProtocol3); + err = SSLSetProtocolVersionMin(connssl->ssl_ctx, kSSLProtocol3); + if(err != noErr) { + failf(data, "Your version of the OS does not support SSLv3"); + return CURLE_SSL_CONNECT_ERROR; + } (void)SSLSetProtocolVersionMax(connssl->ssl_ctx, kSSLProtocol3); break; case CURL_SSLVERSION_SSLv2: @@ -1096,20 +1097,8 @@ static CURLcode darwinssl_connect_step1(struct connectdata *conn, kSSLProtocolAll, false); switch (data->set.ssl.version) { - case CURL_SSLVERSION_DEFAULT: default: - (void)SSLSetProtocolVersionEnabled(connssl->ssl_ctx, - kSSLProtocol3, - true); - (void)SSLSetProtocolVersionEnabled(connssl->ssl_ctx, - kTLSProtocol1, - true); - (void)SSLSetProtocolVersionEnabled(connssl->ssl_ctx, - kTLSProtocol11, - true); - (void)SSLSetProtocolVersionEnabled(connssl->ssl_ctx, - kTLSProtocol12, - true); - break; + default: + case CURL_SSLVERSION_DEFAULT: case CURL_SSLVERSION_TLSv1: (void)SSLSetProtocolVersionEnabled(connssl->ssl_ctx, kTLSProtocol1, @@ -1137,9 +1126,13 @@ static CURLcode darwinssl_connect_step1(struct connectdata *conn, true); break; case CURL_SSLVERSION_SSLv3: - (void)SSLSetProtocolVersionEnabled(connssl->ssl_ctx, + err = SSLSetProtocolVersionEnabled(connssl->ssl_ctx, kSSLProtocol3, true); + if(err != noErr) { + failf(data, "Your version of the OS does not support SSLv3"); + return CURLE_SSL_CONNECT_ERROR; + } break; case CURL_SSLVERSION_SSLv2: err = SSLSetProtocolVersionEnabled(connssl->ssl_ctx, @@ -1158,13 +1151,6 @@ static CURLcode darwinssl_connect_step1(struct connectdata *conn, switch(data->set.ssl.version) { default: case CURL_SSLVERSION_DEFAULT: - (void)SSLSetProtocolVersionEnabled(connssl->ssl_ctx, - kSSLProtocol3, - true); - (void)SSLSetProtocolVersionEnabled(connssl->ssl_ctx, - kTLSProtocol1, - true); - break; case CURL_SSLVERSION_TLSv1: case CURL_SSLVERSION_TLSv1_0: (void)SSLSetProtocolVersionEnabled(connssl->ssl_ctx, @@ -1187,9 +1173,13 @@ static CURLcode darwinssl_connect_step1(struct connectdata *conn, } break; case CURL_SSLVERSION_SSLv3: - (void)SSLSetProtocolVersionEnabled(connssl->ssl_ctx, + err = SSLSetProtocolVersionEnabled(connssl->ssl_ctx, kSSLProtocol3, true); + if(err != noErr) { + failf(data, "Your version of the OS does not support SSLv3"); + return CURLE_SSL_CONNECT_ERROR; + } break; } #endif /* CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS */ @@ -1469,14 +1459,17 @@ static CURLcode darwinssl_connect_step1(struct connectdata *conn, #if CURL_BUILD_MAC_10_9 || CURL_BUILD_IOS_7 /* We want to enable 1/n-1 when using a CBC cipher unless the user specifically doesn't want us doing that: */ - if(SSLSetSessionOption != NULL) + if(SSLSetSessionOption != NULL) { SSLSetSessionOption(connssl->ssl_ctx, kSSLSessionOptionSendOneByteRecord, !data->set.ssl_enable_beast); + SSLSetSessionOption(connssl->ssl_ctx, kSSLSessionOptionFalseStart, + data->set.ssl.falsestart); /* false start support */ + } #endif /* CURL_BUILD_MAC_10_9 || CURL_BUILD_IOS_7 */ /* Check if there's a cached ID we can/should use here! */ if(!Curl_ssl_getsessionid(conn, (void **)&ssl_sessionid, - &ssl_sessionid_len)) { + &ssl_sessionid_len)) { /* we got a session id, use it! */ err = SSLSetPeerID(connssl->ssl_ctx, ssl_sessionid, ssl_sessionid_len); if(err != noErr) { @@ -1489,20 +1482,23 @@ static CURLcode darwinssl_connect_step1(struct connectdata *conn, /* If there isn't one, then let's make one up! This has to be done prior to starting the handshake. */ else { - CURLcode retcode; + CURLcode result; + ssl_sessionid = + aprintf("%s:%d:%d:%s:%hu", data->set.str[STRING_SSL_CAFILE], + data->set.ssl.verifypeer, data->set.ssl.verifyhost, + conn->host.name, conn->remote_port); + ssl_sessionid_len = strlen(ssl_sessionid); - ssl_sessionid = malloc(256*sizeof(char)); - ssl_sessionid_len = snprintf(ssl_sessionid, 256, "curl:%s:%hu", - conn->host.name, conn->remote_port); err = SSLSetPeerID(connssl->ssl_ctx, ssl_sessionid, ssl_sessionid_len); if(err != noErr) { failf(data, "SSL: SSLSetPeerID() failed: OSStatus %d", err); return CURLE_SSL_CONNECT_ERROR; } - retcode = Curl_ssl_addsessionid(conn, ssl_sessionid, ssl_sessionid_len); - if(retcode!= CURLE_OK) { + + result = Curl_ssl_addsessionid(conn, ssl_sessionid, ssl_sessionid_len); + if(result) { failf(data, "failed to store ssl session"); - return retcode; + return result; } } @@ -2081,7 +2077,7 @@ darwinssl_connect_common(struct connectdata *conn, bool nonblocking, bool *done) { - CURLcode retcode; + CURLcode result; struct SessionHandle *data = conn->data; struct ssl_connect_data *connssl = &conn->ssl[sockindex]; curl_socket_t sockfd = conn->sock[sockindex]; @@ -2103,9 +2099,10 @@ darwinssl_connect_common(struct connectdata *conn, failf(data, "SSL connection timeout"); return CURLE_OPERATION_TIMEDOUT; } - retcode = darwinssl_connect_step1(conn, sockindex); - if(retcode) - return retcode; + + result = darwinssl_connect_step1(conn, sockindex); + if(result) + return result; } while(ssl_connect_2 == connssl->connecting_state || @@ -2122,8 +2119,8 @@ darwinssl_connect_common(struct connectdata *conn, } /* if ssl is expecting something, check if it's available. */ - if(connssl->connecting_state == ssl_connect_2_reading - || connssl->connecting_state == ssl_connect_2_writing) { + if(connssl->connecting_state == ssl_connect_2_reading || + connssl->connecting_state == ssl_connect_2_writing) { curl_socket_t writefd = ssl_connect_2_writing == connssl->connecting_state?sockfd:CURL_SOCKET_BAD; @@ -2156,23 +2153,23 @@ darwinssl_connect_common(struct connectdata *conn, * before step2 has completed while ensuring that a client using select() * or epoll() will always have a valid fdset to wait on. */ - retcode = darwinssl_connect_step2(conn, sockindex); - if(retcode || (nonblocking && - (ssl_connect_2 == connssl->connecting_state || - ssl_connect_2_reading == connssl->connecting_state || - ssl_connect_2_writing == connssl->connecting_state))) - return retcode; + result = darwinssl_connect_step2(conn, sockindex); + if(result || (nonblocking && + (ssl_connect_2 == connssl->connecting_state || + ssl_connect_2_reading == connssl->connecting_state || + ssl_connect_2_writing == connssl->connecting_state))) + return result; } /* repeat step2 until all transactions are done. */ - if(ssl_connect_3==connssl->connecting_state) { - retcode = darwinssl_connect_step3(conn, sockindex); - if(retcode) - return retcode; + if(ssl_connect_3 == connssl->connecting_state) { + result = darwinssl_connect_step3(conn, sockindex); + if(result) + return result; } - if(ssl_connect_done==connssl->connecting_state) { + if(ssl_connect_done == connssl->connecting_state) { connssl->state = ssl_connection_complete; conn->recv[sockindex] = darwinssl_recv; conn->send[sockindex] = darwinssl_send; @@ -2199,13 +2196,13 @@ CURLcode Curl_darwinssl_connect(struct connectdata *conn, int sockindex) { - CURLcode retcode; + CURLcode result; bool done = FALSE; - retcode = darwinssl_connect_common(conn, sockindex, FALSE, &done); + result = darwinssl_connect_common(conn, sockindex, FALSE, &done); - if(retcode) - return retcode; + if(result) + return result; DEBUGASSERT(done); @@ -2233,12 +2230,6 @@ void Curl_darwinssl_close(struct connectdata *conn, int sockindex) connssl->ssl_sockfd = 0; } -void Curl_darwinssl_close_all(struct SessionHandle *data) -{ - /* SecureTransport doesn't separate sessions from contexts, so... */ - (void)data; -} - int Curl_darwinssl_shutdown(struct connectdata *conn, int sockindex) { struct ssl_connect_data *connssl = &conn->ssl[sockindex]; @@ -2376,6 +2367,14 @@ void Curl_darwinssl_md5sum(unsigned char *tmp, /* input */ (void)CC_MD5(tmp, (CC_LONG)tmplen, md5sum); } +bool Curl_darwinssl_false_start(void) { +#if CURL_BUILD_MAC_10_9 || CURL_BUILD_IOS_7 + if(SSLSetSessionOption != NULL) + return TRUE; +#endif + return FALSE; +} + static ssize_t darwinssl_send(struct connectdata *conn, int sockindex, const void *mem, diff --git a/lib/vtls/curl_darwinssl.h b/lib/vtls/darwinssl.h similarity index 83% rename from lib/vtls/curl_darwinssl.h rename to lib/vtls/darwinssl.h index f5c03d8..3bb69c0 100644 --- a/lib/vtls/curl_darwinssl.h +++ b/lib/vtls/darwinssl.h @@ -8,6 +8,7 @@ * \___|\___/|_| \_\_____| * * Copyright (C) 2012 - 2014, Nick Zitzmann, . + * Copyright (C) 2012 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -31,9 +32,6 @@ CURLcode Curl_darwinssl_connect_nonblocking(struct connectdata *conn, int sockindex, bool *done); -/* this function doesn't actually do anything */ -void Curl_darwinssl_close_all(struct SessionHandle *data); - /* close a SSL connection */ void Curl_darwinssl_close(struct connectdata *conn, int sockindex); @@ -50,9 +48,10 @@ void Curl_darwinssl_md5sum(unsigned char *tmp, /* input */ size_t tmplen, unsigned char *md5sum, /* output */ size_t md5len); +bool Curl_darwinssl_false_start(void); -/* this backend provides these functions: */ -#define have_curlssl_md5sum 1 +/* Set the API backend definition to SecureTransport */ +#define CURL_SSL_BACKEND CURLSSLBACKEND_DARWINSSL /* API setup for SecureTransport */ #define curlssl_init() (1) @@ -60,18 +59,18 @@ void Curl_darwinssl_md5sum(unsigned char *tmp, /* input */ #define curlssl_connect Curl_darwinssl_connect #define curlssl_connect_nonblocking Curl_darwinssl_connect_nonblocking #define curlssl_session_free(x) Curl_darwinssl_session_free(x) -#define curlssl_close_all Curl_darwinssl_close_all +#define curlssl_close_all(x) ((void)x) #define curlssl_close Curl_darwinssl_close #define curlssl_shutdown(x,y) 0 -#define curlssl_set_engine(x,y) (x=x, y=y, CURLE_NOT_BUILT_IN) -#define curlssl_set_engine_default(x) (x=x, CURLE_NOT_BUILT_IN) -#define curlssl_engines_list(x) (x=x, (struct curl_slist *)NULL) +#define curlssl_set_engine(x,y) ((void)x, (void)y, CURLE_NOT_BUILT_IN) +#define curlssl_set_engine_default(x) ((void)x, CURLE_NOT_BUILT_IN) +#define curlssl_engines_list(x) ((void)x, (struct curl_slist *)NULL) #define curlssl_version Curl_darwinssl_version #define curlssl_check_cxn Curl_darwinssl_check_cxn #define curlssl_data_pending(x,y) Curl_darwinssl_data_pending(x, y) -#define curlssl_random(x,y,z) Curl_darwinssl_random(y,z) +#define curlssl_random(x,y,z) ((void)x, Curl_darwinssl_random(y,z)) #define curlssl_md5sum(a,b,c,d) Curl_darwinssl_md5sum(a,b,c,d) -#define CURL_SSL_BACKEND CURLSSLBACKEND_DARWINSSL +#define curlssl_false_start() Curl_darwinssl_false_start() #endif /* USE_DARWINSSL */ #endif /* HEADER_CURL_DARWINSSL_H */ diff --git a/lib/vtls/gskit.c b/lib/vtls/gskit.c index 0f8b08f..d884bd4 100644 --- a/lib/vtls/gskit.c +++ b/lib/vtls/gskit.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2013, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -74,9 +74,7 @@ #include "select.h" #include "strequal.h" #include "x509asn1.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include +#include "curl_printf.h" #include "curl_memory.h" /* The last #include file should be: */ @@ -134,8 +132,12 @@ static const gskit_cipher ciphertable[] = { CURL_GSKPROTO_TLSV10_MASK | CURL_GSKPROTO_TLSV11_MASK | CURL_GSKPROTO_TLSV12_MASK }, { "null-sha256", "3B", CURL_GSKPROTO_TLSV12_MASK }, - { "aes128-sha256", "3D", CURL_GSKPROTO_TLSV12_MASK }, + { "aes128-sha256", "3C", CURL_GSKPROTO_TLSV12_MASK }, { "aes256-sha256", "3D", CURL_GSKPROTO_TLSV12_MASK }, + { "aes128-gcm-sha256", + "9C", CURL_GSKPROTO_TLSV12_MASK }, + { "aes256-gcm-sha384", + "9D", CURL_GSKPROTO_TLSV12_MASK }, { "rc4-md5", "1", CURL_GSKPROTO_SSLV2_MASK }, { "exp-rc4-md5", "2", CURL_GSKPROTO_SSLV2_MASK }, { "rc2-md5", "3", CURL_GSKPROTO_SSLV2_MASK }, @@ -164,8 +166,6 @@ static bool is_separator(char c) static CURLcode gskit_status(struct SessionHandle *data, int rc, const char *procname, CURLcode defcode) { - CURLcode cc; - /* Process GSKit status and map it to a CURLcode. */ switch (rc) { case GSK_OK: @@ -298,7 +298,7 @@ static CURLcode set_ciphers(struct SessionHandle *data, int i; int l; bool unsupported; - CURLcode cc; + CURLcode result; struct { char *buf; char *ptr; @@ -331,7 +331,7 @@ static CURLcode set_ciphers(struct SessionHandle *data, /* Process each cipher in input string. */ unsupported = FALSE; - cc = CURLE_OK; + result = CURLE_OK; for(;;) { for(clp = cipherlist; *cipherlist && !is_separator(*cipherlist);) cipherlist++; @@ -344,7 +344,7 @@ static CURLcode set_ciphers(struct SessionHandle *data, break; if(!ctp->name) { failf(data, "Unknown cipher %.*s", l, clp); - cc = CURLE_SSL_CIPHER; + result = CURLE_SSL_CIPHER; } else { unsupported |= !(ctp->versions & (CURL_GSKPROTO_SSLV2_MASK | @@ -372,53 +372,53 @@ static CURLcode set_ciphers(struct SessionHandle *data, /* Try to set-up TLSv1.1 and TLSv2.1 ciphers. */ if(*protoflags & CURL_GSKPROTO_TLSV11_MASK) { - cc = set_buffer(data, h, GSK_TLSV11_CIPHER_SPECS, - ciphers[CURL_GSKPROTO_TLSV11].buf, TRUE); - if(cc == CURLE_UNSUPPORTED_PROTOCOL) { - cc = CURLE_OK; + result = set_buffer(data, h, GSK_TLSV11_CIPHER_SPECS, + ciphers[CURL_GSKPROTO_TLSV11].buf, TRUE); + if(result == CURLE_UNSUPPORTED_PROTOCOL) { + result = CURLE_OK; if(unsupported) { failf(data, "TLSv1.1-only ciphers are not yet supported"); - cc = CURLE_SSL_CIPHER; + result = CURLE_SSL_CIPHER; } } } - if(cc == CURLE_OK && (*protoflags & CURL_GSKPROTO_TLSV12_MASK)) { - cc = set_buffer(data, h, GSK_TLSV12_CIPHER_SPECS, - ciphers[CURL_GSKPROTO_TLSV12].buf, TRUE); - if(cc == CURLE_UNSUPPORTED_PROTOCOL) { - cc = CURLE_OK; + if(!result && (*protoflags & CURL_GSKPROTO_TLSV12_MASK)) { + result = set_buffer(data, h, GSK_TLSV12_CIPHER_SPECS, + ciphers[CURL_GSKPROTO_TLSV12].buf, TRUE); + if(result == CURLE_UNSUPPORTED_PROTOCOL) { + result = CURLE_OK; if(unsupported) { failf(data, "TLSv1.2-only ciphers are not yet supported"); - cc = CURLE_SSL_CIPHER; + result = CURLE_SSL_CIPHER; } } } /* Try to set-up TLSv1.0 ciphers. If not successful, concatenate them to the SSLv3 ciphers. OS/400 prior to version 7.1 will understand it. */ - if(cc == CURLE_OK && (*protoflags & CURL_GSKPROTO_TLSV10_MASK)) { - cc = set_buffer(data, h, GSK_TLSV10_CIPHER_SPECS, - ciphers[CURL_GSKPROTO_TLSV10].buf, TRUE); - if(cc == CURLE_UNSUPPORTED_PROTOCOL) { - cc = CURLE_OK; + if(!result && (*protoflags & CURL_GSKPROTO_TLSV10_MASK)) { + result = set_buffer(data, h, GSK_TLSV10_CIPHER_SPECS, + ciphers[CURL_GSKPROTO_TLSV10].buf, TRUE); + if(result == CURLE_UNSUPPORTED_PROTOCOL) { + result = CURLE_OK; strcpy(ciphers[CURL_GSKPROTO_SSLV3].ptr, ciphers[CURL_GSKPROTO_TLSV10].ptr); } } /* Set-up other ciphers. */ - if(cc == CURLE_OK && (*protoflags & CURL_GSKPROTO_SSLV3_MASK)) - cc = set_buffer(data, h, GSK_V3_CIPHER_SPECS, - ciphers[CURL_GSKPROTO_SSLV3].buf, FALSE); - if(cc == CURLE_OK && (*protoflags & CURL_GSKPROTO_SSLV2_MASK)) - cc = set_buffer(data, h, GSK_V2_CIPHER_SPECS, - ciphers[CURL_GSKPROTO_SSLV2].buf, FALSE); + if(!result && (*protoflags & CURL_GSKPROTO_SSLV3_MASK)) + result = set_buffer(data, h, GSK_V3_CIPHER_SPECS, + ciphers[CURL_GSKPROTO_SSLV3].buf, FALSE); + if(!result && (*protoflags & CURL_GSKPROTO_SSLV2_MASK)) + result = set_buffer(data, h, GSK_V2_CIPHER_SPECS, + ciphers[CURL_GSKPROTO_SSLV2].buf, FALSE); /* Clean-up. */ for(i = 0; i < CURL_GSKPROTO_LAST; i++) free(ciphers[i].buf); - return cc; + return result; } @@ -442,7 +442,7 @@ static CURLcode init_environment(struct SessionHandle *data, const char *password) { int rc; - CURLcode c; + CURLcode result; gsk_handle h; /* Creates the GSKit environment. */ @@ -458,29 +458,29 @@ static CURLcode init_environment(struct SessionHandle *data, return CURLE_SSL_CONNECT_ERROR; } - c = set_enum(data, h, GSK_SESSION_TYPE, GSK_CLIENT_SESSION, FALSE); - if(c == CURLE_OK && appid) - c = set_buffer(data, h, GSK_OS400_APPLICATION_ID, appid, FALSE); - if(c == CURLE_OK && file) - c = set_buffer(data, h, GSK_KEYRING_FILE, file, FALSE); - if(c == CURLE_OK && label) - c = set_buffer(data, h, GSK_KEYRING_LABEL, label, FALSE); - if(c == CURLE_OK && password) - c = set_buffer(data, h, GSK_KEYRING_PW, password, FALSE); - - if(c == CURLE_OK) { + result = set_enum(data, h, GSK_SESSION_TYPE, GSK_CLIENT_SESSION, FALSE); + if(!result && appid) + result = set_buffer(data, h, GSK_OS400_APPLICATION_ID, appid, FALSE); + if(!result && file) + result = set_buffer(data, h, GSK_KEYRING_FILE, file, FALSE); + if(!result && label) + result = set_buffer(data, h, GSK_KEYRING_LABEL, label, FALSE); + if(!result && password) + result = set_buffer(data, h, GSK_KEYRING_PW, password, FALSE); + + if(!result) { /* Locate CAs, Client certificate and key according to our settings. Note: this call may be blocking for some tenths of seconds. */ - c = gskit_status(data, gsk_environment_init(h), - "gsk_environment_init()", CURLE_SSL_CERTPROBLEM); - if(c == CURLE_OK) { + result = gskit_status(data, gsk_environment_init(h), + "gsk_environment_init()", CURLE_SSL_CERTPROBLEM); + if(!result) { *envir = h; - return c; + return result; } } /* Error: rollback. */ gsk_environment_close(&h); - return c; + return result; } @@ -558,7 +558,7 @@ static CURLcode gskit_connect_step1(struct connectdata *conn, int sockindex) struct SessionHandle *data = conn->data; struct ssl_connect_data *connssl = &conn->ssl[sockindex]; gsk_handle envir; - CURLcode cc; + CURLcode result; int rc; char *keyringfile; char *keyringpwd; @@ -600,22 +600,22 @@ static CURLcode gskit_connect_step1(struct connectdata *conn, int sockindex) if(!envir) { /* Use keyring mode. */ - cc = init_environment(data, &envir, (const char *) NULL, - keyringfile, keyringlabel, keyringpwd); - if(cc != CURLE_OK) - return cc; + result = init_environment(data, &envir, (const char *) NULL, + keyringfile, keyringlabel, keyringpwd); + if(result) + return result; } /* Create secure session. */ - cc = gskit_status(data, gsk_secure_soc_open(envir, &connssl->handle), - "gsk_secure_soc_open()", CURLE_SSL_CONNECT_ERROR); + result = gskit_status(data, gsk_secure_soc_open(envir, &connssl->handle), + "gsk_secure_soc_open()", CURLE_SSL_CONNECT_ERROR); gsk_environment_close(&envir); - if(cc != CURLE_OK) - return cc; + if(result) + return result; /* Determine which SSL/TLS version should be enabled. */ - protoflags = CURL_GSKPROTO_SSLV3_MASK | CURL_GSKPROTO_TLSV10_MASK | - CURL_GSKPROTO_TLSV11_MASK | CURL_GSKPROTO_TLSV12_MASK; + protoflags = CURL_GSKPROTO_TLSV10_MASK | CURL_GSKPROTO_TLSV11_MASK | + CURL_GSKPROTO_TLSV12_MASK; sni = conn->host.name; switch (data->set.ssl.version) { case CURL_SSLVERSION_SSLv2: @@ -623,7 +623,7 @@ static CURLcode gskit_connect_step1(struct connectdata *conn, int sockindex) sni = (char *) NULL; break; case CURL_SSLVERSION_SSLv3: - protoflags = CURL_GSKPROTO_SSLV2_MASK; + protoflags = CURL_GSKPROTO_SSLV3_MASK; sni = (char *) NULL; break; case CURL_SSLVERSION_TLSv1: @@ -643,81 +643,84 @@ static CURLcode gskit_connect_step1(struct connectdata *conn, int sockindex) /* Process SNI. Ignore if not supported (on OS400 < V7R1). */ if(sni) { - cc = set_buffer(data, connssl->handle, - GSK_SSL_EXTN_SERVERNAME_REQUEST, sni, TRUE); - if(cc == CURLE_UNSUPPORTED_PROTOCOL) - cc = CURLE_OK; + result = set_buffer(data, connssl->handle, + GSK_SSL_EXTN_SERVERNAME_REQUEST, sni, TRUE); + if(result == CURLE_UNSUPPORTED_PROTOCOL) + result = CURLE_OK; } /* Set session parameters. */ - if(cc == CURLE_OK) { + if(!result) { /* Compute the handshake timeout. Since GSKit granularity is 1 second, we round up the required value. */ timeout = Curl_timeleft(data, NULL, TRUE); if(timeout < 0) - cc = CURLE_OPERATION_TIMEDOUT; + result = CURLE_OPERATION_TIMEDOUT; else - cc = set_numeric(data, connssl->handle, GSK_HANDSHAKE_TIMEOUT, - (timeout + 999) / 1000); + result = set_numeric(data, connssl->handle, GSK_HANDSHAKE_TIMEOUT, + (timeout + 999) / 1000); } - if(cc == CURLE_OK) - cc = set_numeric(data, connssl->handle, GSK_FD, conn->sock[sockindex]); - if(cc == CURLE_OK) - cc = set_ciphers(data, connssl->handle, &protoflags); + if(!result) + result = set_numeric(data, connssl->handle, GSK_FD, conn->sock[sockindex]); + if(!result) + result = set_ciphers(data, connssl->handle, &protoflags); if(!protoflags) { failf(data, "No SSL protocol/cipher combination enabled"); - cc = CURLE_SSL_CIPHER; + result = CURLE_SSL_CIPHER; } - if(cc == CURLE_OK) - cc = set_enum(data, connssl->handle, GSK_PROTOCOL_SSLV2, - (protoflags & CURL_GSKPROTO_SSLV2_MASK)? - GSK_PROTOCOL_SSLV2_ON: GSK_PROTOCOL_SSLV2_OFF, FALSE); - if(cc == CURLE_OK) - cc = set_enum(data, connssl->handle, GSK_PROTOCOL_SSLV3, - (protoflags & CURL_GSKPROTO_SSLV3_MASK)? - GSK_PROTOCOL_SSLV3_ON: GSK_PROTOCOL_SSLV3_OFF, FALSE); - if(cc == CURLE_OK) - cc = set_enum(data, connssl->handle, GSK_PROTOCOL_TLSV1, - (protoflags & CURL_GSKPROTO_TLSV10_MASK)? - GSK_PROTOCOL_TLSV1_ON: GSK_PROTOCOL_TLSV1_OFF, FALSE); - if(cc == CURLE_OK) { - cc = set_enum(data, connssl->handle, GSK_PROTOCOL_TLSV11, - (protoflags & CURL_GSKPROTO_TLSV11_MASK)? - GSK_TRUE: GSK_FALSE, TRUE); - if(cc == CURLE_UNSUPPORTED_PROTOCOL) { - cc = CURLE_OK; + if(!result) + result = set_enum(data, connssl->handle, GSK_PROTOCOL_SSLV2, + (protoflags & CURL_GSKPROTO_SSLV2_MASK)? + GSK_PROTOCOL_SSLV2_ON: GSK_PROTOCOL_SSLV2_OFF, FALSE); + if(!result) + result = set_enum(data, connssl->handle, GSK_PROTOCOL_SSLV3, + (protoflags & CURL_GSKPROTO_SSLV3_MASK)? + GSK_PROTOCOL_SSLV3_ON: GSK_PROTOCOL_SSLV3_OFF, FALSE); + if(!result) + result = set_enum(data, connssl->handle, GSK_PROTOCOL_TLSV1, + (protoflags & CURL_GSKPROTO_TLSV10_MASK)? + GSK_PROTOCOL_TLSV1_ON: GSK_PROTOCOL_TLSV1_OFF, FALSE); + if(!result) { + result = set_enum(data, connssl->handle, GSK_PROTOCOL_TLSV11, + (protoflags & CURL_GSKPROTO_TLSV11_MASK)? + GSK_TRUE: GSK_FALSE, TRUE); + if(result == CURLE_UNSUPPORTED_PROTOCOL) { + result = CURLE_OK; if(protoflags == CURL_GSKPROTO_TLSV11_MASK) { failf(data, "TLS 1.1 not yet supported"); - cc = CURLE_SSL_CIPHER; + result = CURLE_SSL_CIPHER; } } } - if(cc == CURLE_OK) { - cc = set_enum(data, connssl->handle, GSK_PROTOCOL_TLSV12, - (protoflags & CURL_GSKPROTO_TLSV12_MASK)? - GSK_TRUE: GSK_FALSE, TRUE); - if(cc == CURLE_UNSUPPORTED_PROTOCOL) { - cc = CURLE_OK; + if(!result) { + result = set_enum(data, connssl->handle, GSK_PROTOCOL_TLSV12, + (protoflags & CURL_GSKPROTO_TLSV12_MASK)? + GSK_TRUE: GSK_FALSE, TRUE); + if(result == CURLE_UNSUPPORTED_PROTOCOL) { + result = CURLE_OK; if(protoflags == CURL_GSKPROTO_TLSV12_MASK) { failf(data, "TLS 1.2 not yet supported"); - cc = CURLE_SSL_CIPHER; + result = CURLE_SSL_CIPHER; } } } - if(cc == CURLE_OK) - cc = set_enum(data, connssl->handle, GSK_SERVER_AUTH_TYPE, - data->set.ssl.verifypeer? GSK_SERVER_AUTH_FULL: - GSK_SERVER_AUTH_PASSTHRU, FALSE); + if(!result) + result = set_enum(data, connssl->handle, GSK_SERVER_AUTH_TYPE, + data->set.ssl.verifypeer? GSK_SERVER_AUTH_FULL: + GSK_SERVER_AUTH_PASSTHRU, FALSE); - if(cc == CURLE_OK) { + if(!result) { /* Start handshake. Try asynchronous first. */ memset(&commarea, 0, sizeof commarea); connssl->iocport = QsoCreateIOCompletionPort(); if(connssl->iocport != -1) { - cc = gskit_status(data, gsk_secure_soc_startInit(connssl->handle, - connssl->iocport, &commarea), - "gsk_secure_soc_startInit()", CURLE_SSL_CONNECT_ERROR); - if(cc == CURLE_OK) { + result = gskit_status(data, + gsk_secure_soc_startInit(connssl->handle, + connssl->iocport, + &commarea), + "gsk_secure_soc_startInit()", + CURLE_SSL_CONNECT_ERROR); + if(!result) { connssl->connecting_state = ssl_connect_2; return CURLE_OK; } @@ -725,12 +728,13 @@ static CURLcode gskit_connect_step1(struct connectdata *conn, int sockindex) close_async_handshake(connssl); } else if(errno != ENOBUFS) - cc = gskit_status(data, GSK_ERROR_IO, "QsoCreateIOCompletionPort()", 0); + result = gskit_status(data, GSK_ERROR_IO, + "QsoCreateIOCompletionPort()", 0); else { /* No more completion port available. Use synchronous IO. */ - cc = gskit_status(data, gsk_secure_soc_init(connssl->handle), - "gsk_secure_soc_init()", CURLE_SSL_CONNECT_ERROR); - if(cc == CURLE_OK) { + result = gskit_status(data, gsk_secure_soc_init(connssl->handle), + "gsk_secure_soc_init()", CURLE_SSL_CONNECT_ERROR); + if(!result) { connssl->connecting_state = ssl_connect_3; return CURLE_OK; } @@ -739,7 +743,7 @@ static CURLcode gskit_connect_step1(struct connectdata *conn, int sockindex) /* Error: rollback. */ close_one(connssl, data); - return cc; + return result; } @@ -751,7 +755,7 @@ static CURLcode gskit_connect_step2(struct connectdata *conn, int sockindex, Qso_OverlappedIO_t cstat; long timeout_ms; struct timeval stmv; - CURLcode cc; + CURLcode result; /* Poll or wait for end of SSL asynchronous handshake. */ @@ -786,12 +790,12 @@ static CURLcode gskit_connect_step2(struct connectdata *conn, int sockindex, } break; } - cc = gskit_status(data, cstat.returnValue, "SSL handshake", - CURLE_SSL_CONNECT_ERROR); - if(cc == CURLE_OK) + result = gskit_status(data, cstat.returnValue, "SSL handshake", + CURLE_SSL_CONNECT_ERROR); + if(!result) connssl->connecting_state = ssl_connect_3; close_async_handshake(connssl); - return cc; + return result; } @@ -804,8 +808,9 @@ static CURLcode gskit_connect_step3(struct connectdata *conn, int sockindex) const gsk_cert_data_elem *p; const char *cert = (const char *) NULL; const char *certend; + const char *ptr; int i; - CURLcode cc; + CURLcode result; /* SSL handshake done: gather certificate info and verify host. */ @@ -838,9 +843,9 @@ static CURLcode gskit_connect_step3(struct connectdata *conn, int sockindex) } /* Verify host. */ - cc = Curl_verifyhost(conn, cert, certend); - if(cc != CURLE_OK) - return cc; + result = Curl_verifyhost(conn, cert, certend); + if(result) + return result; /* The only place GSKit can get the whole CA chain is a validation callback where no user data pointer is available. Therefore it's not @@ -848,12 +853,31 @@ static CURLcode gskit_connect_step3(struct connectdata *conn, int sockindex) However the server certificate may be available, thus we can return info about it. */ if(data->set.ssl.certinfo) { - if(Curl_ssl_init_certinfo(data, 1)) - return CURLE_OUT_OF_MEMORY; + result = Curl_ssl_init_certinfo(data, 1); + if(result) + return result; + if(cert) { - cc = Curl_extract_certinfo(conn, 0, cert, certend); - if(cc != CURLE_OK) - return cc; + result = Curl_extract_certinfo(conn, 0, cert, certend); + if(result) + return result; + } + } + + /* Check pinned public key. */ + ptr = data->set.str[STRING_SSL_PINNEDPUBLICKEY]; + if(!result && ptr) { + curl_X509certificate x509; + curl_asn1Element *p; + + if(!cert) + return CURLE_SSL_PINNEDPUBKEYNOTMATCH; + Curl_parseX509(&x509, cert, certend); + p = &x509.subjectPublicKeyInfo; + result = Curl_pin_peer_pubkey(ptr, p->header, p->end - p->header); + if(result) { + failf(data, "SSL: public key does not match pinned public key!"); + return result; } } @@ -869,7 +893,7 @@ static CURLcode gskit_connect_common(struct connectdata *conn, int sockindex, struct ssl_connect_data *connssl = &conn->ssl[sockindex]; long timeout_ms; Qso_OverlappedIO_t cstat; - CURLcode cc = CURLE_OK; + CURLcode result = CURLE_OK; *done = connssl->state == ssl_connection_complete; if(*done) @@ -883,31 +907,31 @@ static CURLcode gskit_connect_common(struct connectdata *conn, int sockindex, if(timeout_ms < 0) { /* no need to continue if time already is up */ failf(data, "SSL connection timeout"); - cc = CURLE_OPERATION_TIMEDOUT; + result = CURLE_OPERATION_TIMEDOUT; } else - cc = gskit_connect_step1(conn, sockindex); + result = gskit_connect_step1(conn, sockindex); } /* Step 2: check if handshake is over. */ - if(cc == CURLE_OK && connssl->connecting_state == ssl_connect_2) { + if(!result && connssl->connecting_state == ssl_connect_2) { /* check allowed time left */ timeout_ms = Curl_timeleft(data, NULL, TRUE); if(timeout_ms < 0) { /* no need to continue if time already is up */ failf(data, "SSL connection timeout"); - cc = CURLE_OPERATION_TIMEDOUT; + result = CURLE_OPERATION_TIMEDOUT; } else - cc = gskit_connect_step2(conn, sockindex, nonblocking); + result = gskit_connect_step2(conn, sockindex, nonblocking); } /* Step 3: gather certificate info, verify host. */ - if(cc == CURLE_OK && connssl->connecting_state == ssl_connect_3) - cc = gskit_connect_step3(conn, sockindex); + if(!result && connssl->connecting_state == ssl_connect_3) + result = gskit_connect_step3(conn, sockindex); - if(cc != CURLE_OK) + if(result) close_one(connssl, data); else if(connssl->connecting_state == ssl_connect_done) { connssl->state = ssl_connection_complete; @@ -917,7 +941,7 @@ static CURLcode gskit_connect_common(struct connectdata *conn, int sockindex, *done = TRUE; } - return cc; + return result; } @@ -925,24 +949,24 @@ CURLcode Curl_gskit_connect_nonblocking(struct connectdata *conn, int sockindex, bool *done) { - CURLcode cc; + CURLcode result; - cc = gskit_connect_common(conn, sockindex, TRUE, done); - if(*done || cc != CURLE_OK) + result = gskit_connect_common(conn, sockindex, TRUE, done); + if(*done || result) conn->ssl[sockindex].connecting_state = ssl_connect_1; - return cc; + return result; } CURLcode Curl_gskit_connect(struct connectdata *conn, int sockindex) { - CURLcode retcode; + CURLcode result; bool done; conn->ssl[sockindex].connecting_state = ssl_connect_1; - retcode = gskit_connect_common(conn, sockindex, FALSE, &done); - if(retcode) - return retcode; + result = gskit_connect_common(conn, sockindex, FALSE, &done); + if(result) + return result; DEBUGASSERT(done); @@ -960,14 +984,6 @@ void Curl_gskit_close(struct connectdata *conn, int sockindex) } -int Curl_gskit_close_all(struct SessionHandle *data) -{ - /* Unimplemented. */ - (void) data; - return 0; -} - - int Curl_gskit_shutdown(struct connectdata *conn, int sockindex) { struct ssl_connect_data *connssl = &conn->ssl[sockindex]; diff --git a/lib/vtls/gskit.h b/lib/vtls/gskit.h index a4caa6f..af31faf 100644 --- a/lib/vtls/gskit.h +++ b/lib/vtls/gskit.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -32,15 +32,20 @@ #ifdef USE_GSKIT int Curl_gskit_init(void); void Curl_gskit_cleanup(void); -CURLcode Curl_gskit_connect(struct connectdata * conn, int sockindex); -CURLcode Curl_gskit_connect_nonblocking(struct connectdata * conn, - int sockindex, bool * done); +CURLcode Curl_gskit_connect(struct connectdata *conn, int sockindex); +CURLcode Curl_gskit_connect_nonblocking(struct connectdata *conn, + int sockindex, bool *done); void Curl_gskit_close(struct connectdata *conn, int sockindex); -int Curl_gskit_close_all(struct SessionHandle * data); -int Curl_gskit_shutdown(struct connectdata * conn, int sockindex); +int Curl_gskit_shutdown(struct connectdata *conn, int sockindex); -size_t Curl_gskit_version(char * buffer, size_t size); -int Curl_gskit_check_cxn(struct connectdata * cxn); +size_t Curl_gskit_version(char *buffer, size_t size); +int Curl_gskit_check_cxn(struct connectdata *cxn); + +/* Set the API backend definition to GSKit */ +#define CURL_SSL_BACKEND CURLSSLBACKEND_GSKIT + +/* this backend supports CURLOPT_CERTINFO */ +#define have_curlssl_certinfo 1 /* API setup for GSKit */ #define curlssl_init Curl_gskit_init @@ -50,7 +55,7 @@ int Curl_gskit_check_cxn(struct connectdata * cxn); /* No session handling for GSKit */ #define curlssl_session_free(x) Curl_nop_stmt -#define curlssl_close_all Curl_gskit_close_all +#define curlssl_close_all(x) ((void)x) #define curlssl_close Curl_gskit_close #define curlssl_shutdown(x,y) Curl_gskit_shutdown(x,y) #define curlssl_set_engine(x,y) CURLE_NOT_BUILT_IN @@ -59,7 +64,8 @@ int Curl_gskit_check_cxn(struct connectdata * cxn); #define curlssl_version Curl_gskit_version #define curlssl_check_cxn(x) Curl_gskit_check_cxn(x) #define curlssl_data_pending(x,y) 0 -#define CURL_SSL_BACKEND CURLSSLBACKEND_GSKIT +#define curlssl_random(x,y,z) -1 + #endif /* USE_GSKIT */ #endif /* HEADER_CURL_GSKIT_H */ diff --git a/lib/vtls/gtls.c b/lib/vtls/gtls.c index d64f95d..c54dfc1 100644 --- a/lib/vtls/gtls.c +++ b/lib/vtls/gtls.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -32,12 +32,14 @@ #ifdef USE_GNUTLS +#include #include #include #ifdef USE_GNUTLS_NETTLE #include #include +#include #else #include #endif @@ -52,9 +54,8 @@ #include "select.h" #include "rawstr.h" #include "warnless.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include +#include "x509asn1.h" +#include "curl_printf.h" #include "curl_memory.h" /* The last #include file should be: */ #include "memdebug.h" @@ -91,14 +92,23 @@ static bool gtls_inited = FALSE; # define GNUTLS_MAPS_WINSOCK_ERRORS 1 # endif -# ifdef USE_NGHTTP2 -# undef HAS_ALPN -# if (GNUTLS_VERSION_NUMBER >= 0x030200) -# define HAS_ALPN -# endif +# if (GNUTLS_VERSION_NUMBER >= 0x030200) +# define HAS_ALPN +# endif + +# if (GNUTLS_VERSION_NUMBER >= 0x03020d) +# define HAS_OCSP +# endif + +# if (GNUTLS_VERSION_NUMBER >= 0x030306) +# define HAS_CAPATH # endif #endif +#ifdef HAS_OCSP +# include +#endif + /* * Custom push and pull callback functions used by GNU TLS to read and write * to the socket. These functions are simple wrappers to send() and recv() @@ -203,7 +213,7 @@ static void showtime(struct SessionHandle *data, snprintf(data->state.buffer, BUFSIZE, - "\t %s: %s, %02d %s %4d %02d:%02d:%02d GMT\n", + "\t %s: %s, %02d %s %4d %02d:%02d:%02d GMT", text, Curl_wkday[tm->tm_wday?tm->tm_wday-1:6], tm->tm_mday, @@ -222,7 +232,7 @@ static gnutls_datum_t load_file (const char *file) long filelen; void *ptr; - if(!(f = fopen(file, "r"))) + if(!(f = fopen(file, "rb"))) return loaded_file; if(fseek(f, 0, SEEK_END) != 0 || (filelen = ftell(f)) < 0 @@ -306,8 +316,6 @@ static CURLcode handshake(struct connectdata *conn, gnutls_record_get_direction(session)? ssl_connect_2_writing:ssl_connect_2_reading; continue; - if(nonblocking) - return CURLE_OK; } else if((rc < 0) && !gnutls_error_is_fatal(rc)) { const char *strerr = NULL; @@ -320,7 +328,8 @@ static CURLcode handshake(struct connectdata *conn, if(strerr == NULL) strerr = gnutls_strerror(rc); - failf(data, "gnutls_handshake() warning: %s", strerr); + infof(data, "gnutls_handshake() warning: %s\n", strerr); + continue; } else if(rc < 0) { const char *strerr = NULL; @@ -393,10 +402,6 @@ gtls_connect_step1(struct connectdata *conn, const char* prioritylist; const char *err = NULL; #endif -#ifdef HAS_ALPN - int protocols_size = 2; - gnutls_datum_t protocols[2]; -#endif if(conn->ssl[sockindex].state == ssl_connection_complete) /* to make us tolerant against being called more than once for the @@ -464,6 +469,24 @@ gtls_connect_step1(struct connectdata *conn, rc, data->set.ssl.CAfile); } +#ifdef HAS_CAPATH + if(data->set.ssl.CApath) { + /* set the trusted CA cert directory */ + rc = gnutls_certificate_set_x509_trust_dir(conn->ssl[sockindex].cred, + data->set.ssl.CApath, + GNUTLS_X509_FMT_PEM); + if(rc < 0) { + infof(data, "error reading ca cert file %s (%s)\n", + data->set.ssl.CAfile, gnutls_strerror(rc)); + if(data->set.ssl.verifypeer) + return CURLE_SSL_CACERT_BADFILE; + } + else + infof(data, "found %d certificates in %s\n", + rc, data->set.ssl.CApath); + } +#endif + if(data->set.ssl.CRLfile) { /* set the CRL list file */ rc = gnutls_certificate_set_x509_crl_file(conn->ssl[sockindex].cred, @@ -610,19 +633,25 @@ gtls_connect_step1(struct connectdata *conn, #endif #ifdef HAS_ALPN - if(data->set.httpversion == CURL_HTTP_VERSION_2_0) { - if(data->set.ssl_enable_alpn) { - protocols[0].data = NGHTTP2_PROTO_VERSION_ID; - protocols[0].size = NGHTTP2_PROTO_VERSION_ID_LEN; - protocols[1].data = ALPN_HTTP_1_1; - protocols[1].size = ALPN_HTTP_1_1_LENGTH; - gnutls_alpn_set_protocols(session, protocols, protocols_size, 0); - infof(data, "ALPN, offering %s, %s\n", NGHTTP2_PROTO_VERSION_ID, - ALPN_HTTP_1_1); - } - else { - infof(data, "SSL, can't negotiate HTTP/2.0 without ALPN\n"); + if(data->set.ssl_enable_alpn) { + int cur = 0; + gnutls_datum_t protocols[2]; + +#ifdef USE_NGHTTP2 + if(data->set.httpversion == CURL_HTTP_VERSION_2_0) { + protocols[cur].data = (unsigned char *)NGHTTP2_PROTO_VERSION_ID; + protocols[cur].size = NGHTTP2_PROTO_VERSION_ID_LEN; + cur++; + infof(data, "ALPN, offering %s\n", NGHTTP2_PROTO_VERSION_ID); } +#endif + + protocols[cur].data = (unsigned char *)ALPN_HTTP_1_1; + protocols[cur].size = ALPN_HTTP_1_1_LENGTH; + cur++; + infof(data, "ALPN, offering %s\n", ALPN_HTTP_1_1); + + gnutls_alpn_set_protocols(session, protocols, cur, 0); } #endif @@ -644,13 +673,21 @@ gtls_connect_step1(struct connectdata *conn, if(data->set.ssl.authtype == CURL_TLSAUTH_SRP) { rc = gnutls_credentials_set(session, GNUTLS_CRD_SRP, conn->ssl[sockindex].srp_client_cred); - if(rc != GNUTLS_E_SUCCESS) + if(rc != GNUTLS_E_SUCCESS) { failf(data, "gnutls_credentials_set() failed: %s", gnutls_strerror(rc)); + return CURLE_SSL_CONNECT_ERROR; + } } else #endif + { rc = gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, conn->ssl[sockindex].cred); + if(rc != GNUTLS_E_SUCCESS) { + failf(data, "gnutls_credentials_set() failed: %s", gnutls_strerror(rc)); + return CURLE_SSL_CONNECT_ERROR; + } + } /* set the connection handle (file descriptor for the socket) */ gnutls_transport_set_ptr(session, @@ -663,6 +700,16 @@ gtls_connect_step1(struct connectdata *conn, /* lowat must be set to zero when using custom push and pull functions. */ gnutls_transport_set_lowat(session, 0); +#ifdef HAS_OCSP + if(data->set.ssl.verifystatus) { + rc = gnutls_ocsp_status_request_enable_client(session, NULL, 0, NULL); + if(rc != GNUTLS_E_SUCCESS) { + failf(data, "gnutls_ocsp_status_request_enable_client() failed: %d", rc); + return CURLE_SSL_CONNECT_ERROR; + } + } +#endif + /* This might be a reconnect, so we check for a session ID in the cache to speed up things */ @@ -677,6 +724,62 @@ gtls_connect_step1(struct connectdata *conn, return CURLE_OK; } +static CURLcode pkp_pin_peer_pubkey(gnutls_x509_crt_t cert, + const char *pinnedpubkey) +{ + /* Scratch */ + size_t len1 = 0, len2 = 0; + unsigned char *buff1 = NULL; + + gnutls_pubkey_t key = NULL; + + /* Result is returned to caller */ + int ret = 0; + CURLcode result = CURLE_SSL_PINNEDPUBKEYNOTMATCH; + + /* if a path wasn't specified, don't pin */ + if(NULL == pinnedpubkey) + return CURLE_OK; + + if(NULL == cert) + return result; + + do { + /* Begin Gyrations to get the public key */ + gnutls_pubkey_init(&key); + + ret = gnutls_pubkey_import_x509(key, cert, 0); + if(ret < 0) + break; /* failed */ + + ret = gnutls_pubkey_export(key, GNUTLS_X509_FMT_DER, NULL, &len1); + if(ret != GNUTLS_E_SHORT_MEMORY_BUFFER || len1 == 0) + break; /* failed */ + + buff1 = malloc(len1); + if(NULL == buff1) + break; /* failed */ + + len2 = len1; + + ret = gnutls_pubkey_export(key, GNUTLS_X509_FMT_DER, buff1, &len2); + if(ret < 0 || len1 != len2) + break; /* failed */ + + /* End Gyrations */ + + /* The one good exit point */ + result = Curl_pin_peer_pubkey(pinnedpubkey, buff1, len1); + } while(0); + + if(NULL != key) + gnutls_pubkey_deinit(key); + + Curl_safefree(buff1); + + return result; +} + static Curl_recv gtls_recv; static Curl_send gtls_send; @@ -686,8 +789,8 @@ gtls_connect_step3(struct connectdata *conn, { unsigned int cert_list_size; const gnutls_datum_t *chainp; - unsigned int verify_status; - gnutls_x509_crt_t x509_cert,x509_issuer; + unsigned int verify_status = 0; + gnutls_x509_crt_t x509_cert, x509_issuer; gnutls_datum_t issuerp; char certbuf[256] = ""; /* big enough? */ size_t size; @@ -698,13 +801,23 @@ gtls_connect_step3(struct connectdata *conn, struct SessionHandle *data = conn->data; gnutls_session_t session = conn->ssl[sockindex].session; int rc; - int incache; + bool incache; void *ssl_sessionid; #ifdef HAS_ALPN gnutls_datum_t proto; #endif CURLcode result = CURLE_OK; + gnutls_protocol_t version = gnutls_protocol_get_version(session); + + /* the name of the cipher suite used, e.g. ECDHE_RSA_AES_256_GCM_SHA384. */ + ptr = gnutls_cipher_suite_get_name(gnutls_kx_get(session), + gnutls_cipher_get(session), + gnutls_mac_get(session)); + + infof(data, "SSL connection using %s / %s\n", + gnutls_protocol_get_name(version), ptr); + /* This function will return the peer's raw certificate (chain) as sent by the peer. These certificates are in raw format (DER encoded for X.509). In case of a X.509 then a certificate list may be present. The @@ -735,6 +848,23 @@ gtls_connect_step3(struct connectdata *conn, infof(data, "\t common name: WARNING couldn't obtain\n"); } + if(data->set.ssl.certinfo && chainp) { + unsigned int i; + + result = Curl_ssl_init_certinfo(data, cert_list_size); + if(result) + return result; + + for(i = 0; i < cert_list_size; i++) { + const char *beg = (const char *) chainp[i].data; + const char *end = beg + chainp[i].size; + + result = Curl_extract_certinfo(conn, i, beg, end); + if(result) + return result; + } + } + if(data->set.ssl.verifypeer) { /* This function will try to verify the peer's certificate and return its status (trusted, invalid etc.). The value of status should be one or @@ -766,6 +896,111 @@ gtls_connect_step3(struct connectdata *conn, else infof(data, "\t server certificate verification SKIPPED\n"); +#ifdef HAS_OCSP + if(data->set.ssl.verifystatus) { + if(gnutls_ocsp_status_request_is_checked(session, 0) == 0) { + gnutls_datum_t status_request; + gnutls_ocsp_resp_t ocsp_resp; + + gnutls_ocsp_cert_status_t status; + gnutls_x509_crl_reason_t reason; + + rc = gnutls_ocsp_status_request_get(session, &status_request); + + infof(data, "\t server certificate status verification FAILED\n"); + + if(rc == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE) { + failf(data, "No OCSP response received"); + return CURLE_SSL_INVALIDCERTSTATUS; + } + + if(rc < 0) { + failf(data, "Invalid OCSP response received"); + return CURLE_SSL_INVALIDCERTSTATUS; + } + + gnutls_ocsp_resp_init(&ocsp_resp); + + rc = gnutls_ocsp_resp_import(ocsp_resp, &status_request); + if(rc < 0) { + failf(data, "Invalid OCSP response received"); + return CURLE_SSL_INVALIDCERTSTATUS; + } + + rc = gnutls_ocsp_resp_get_single(ocsp_resp, 0, NULL, NULL, NULL, NULL, + &status, NULL, NULL, NULL, &reason); + + switch(status) { + case GNUTLS_OCSP_CERT_GOOD: + break; + + case GNUTLS_OCSP_CERT_REVOKED: { + const char *crl_reason; + + switch(reason) { + default: + case GNUTLS_X509_CRLREASON_UNSPECIFIED: + crl_reason = "unspecified reason"; + break; + + case GNUTLS_X509_CRLREASON_KEYCOMPROMISE: + crl_reason = "private key compromised"; + break; + + case GNUTLS_X509_CRLREASON_CACOMPROMISE: + crl_reason = "CA compromised"; + break; + + case GNUTLS_X509_CRLREASON_AFFILIATIONCHANGED: + crl_reason = "affiliation has changed"; + break; + + case GNUTLS_X509_CRLREASON_SUPERSEDED: + crl_reason = "certificate superseded"; + break; + + case GNUTLS_X509_CRLREASON_CESSATIONOFOPERATION: + crl_reason = "operation has ceased"; + break; + + case GNUTLS_X509_CRLREASON_CERTIFICATEHOLD: + crl_reason = "certificate is on hold"; + break; + + case GNUTLS_X509_CRLREASON_REMOVEFROMCRL: + crl_reason = "will be removed from delta CRL"; + break; + + case GNUTLS_X509_CRLREASON_PRIVILEGEWITHDRAWN: + crl_reason = "privilege withdrawn"; + break; + + case GNUTLS_X509_CRLREASON_AACOMPROMISE: + crl_reason = "AA compromised"; + break; + } + + failf(data, "Server certificate was revoked: %s", crl_reason); + break; + } + + default: + case GNUTLS_OCSP_CERT_UNKNOWN: + failf(data, "Server certificate status is unknown"); + break; + } + + gnutls_ocsp_resp_deinit(ocsp_resp); + + return CURLE_SSL_INVALIDCERTSTATUS; + } + else + infof(data, "\t server certificate status verification OK\n"); + } + else + infof(data, "\t server certificate status verification SKIPPED\n"); +#endif + /* initialize an X.509 certificate structure. */ gnutls_x509_crt_init(&x509_cert); @@ -778,14 +1013,16 @@ gtls_connect_step3(struct connectdata *conn, gnutls_x509_crt_init(&x509_issuer); issuerp = load_file(data->set.ssl.issuercert); gnutls_x509_crt_import(x509_issuer, &issuerp, GNUTLS_X509_FMT_PEM); - rc = gnutls_x509_crt_check_issuer(x509_cert,x509_issuer); + rc = gnutls_x509_crt_check_issuer(x509_cert, x509_issuer); + gnutls_x509_crt_deinit(x509_issuer); unload_file(issuerp); if(rc <= 0) { failf(data, "server certificate issuer check failed (IssuerCert: %s)", data->set.ssl.issuercert?data->set.ssl.issuercert:"none"); + gnutls_x509_crt_deinit(x509_cert); return CURLE_SSL_ISSUER_ERROR; } - infof(data,"\t server certificate issuer check OK (Issuer Cert: %s)\n", + infof(data, "\t server certificate issuer check OK (Issuer Cert: %s)\n", data->set.ssl.issuercert?data->set.ssl.issuercert:"none"); } @@ -868,6 +1105,7 @@ gtls_connect_step3(struct connectdata *conn, if(certclock == (time_t)-1) { if(data->set.ssl.verifypeer) { failf(data, "server cert expiration date verify failed"); + gnutls_x509_crt_deinit(x509_cert); return CURLE_SSL_CONNECT_ERROR; } else @@ -877,6 +1115,7 @@ gtls_connect_step3(struct connectdata *conn, if(certclock < time(NULL)) { if(data->set.ssl.verifypeer) { failf(data, "server certificate expiration date has passed."); + gnutls_x509_crt_deinit(x509_cert); return CURLE_PEER_FAILED_VERIFICATION; } else @@ -891,6 +1130,7 @@ gtls_connect_step3(struct connectdata *conn, if(certclock == (time_t)-1) { if(data->set.ssl.verifypeer) { failf(data, "server cert activation date verify failed"); + gnutls_x509_crt_deinit(x509_cert); return CURLE_SSL_CONNECT_ERROR; } else @@ -900,6 +1140,7 @@ gtls_connect_step3(struct connectdata *conn, if(certclock > time(NULL)) { if(data->set.ssl.verifypeer) { failf(data, "server certificate not activated yet."); + gnutls_x509_crt_deinit(x509_cert); return CURLE_PEER_FAILED_VERIFICATION; } else @@ -909,9 +1150,18 @@ gtls_connect_step3(struct connectdata *conn, infof(data, "\t server certificate activation date OK\n"); } + ptr = data->set.str[STRING_SSL_PINNEDPUBLICKEY]; + if(ptr) { + result = pkp_pin_peer_pubkey(x509_cert, ptr); + if(result != CURLE_OK) { + failf(data, "SSL: public key does not match pinned public key!"); + gnutls_x509_crt_deinit(x509_cert); + return result; + } + } + /* Show: - - ciphers used - subject - start date - expire date @@ -951,14 +1201,6 @@ gtls_connect_step3(struct connectdata *conn, /* the *_get_name() says "NULL" if GNUTLS_COMP_NULL is returned */ infof(data, "\t compression: %s\n", ptr); - /* the name of the cipher used. ie 3DES. */ - ptr = gnutls_cipher_get_name(gnutls_cipher_get(session)); - infof(data, "\t cipher: %s\n", ptr); - - /* the MAC algorithms name. ie SHA1 */ - ptr = gnutls_mac_get_name(gnutls_mac_get(session)); - infof(data, "\t MAC: %s\n", ptr); - #ifdef HAS_ALPN if(data->set.ssl_enable_alpn) { rc = gnutls_alpn_get_selected_protocol(session, &proto); @@ -966,19 +1208,21 @@ gtls_connect_step3(struct connectdata *conn, infof(data, "ALPN, server accepted to use %.*s\n", proto.size, proto.data); +#ifdef USE_NGHTTP2 if(proto.size == NGHTTP2_PROTO_VERSION_ID_LEN && - memcmp(NGHTTP2_PROTO_VERSION_ID, proto.data, - NGHTTP2_PROTO_VERSION_ID_LEN) == 0) { - conn->negnpn = NPN_HTTP2; + !memcmp(NGHTTP2_PROTO_VERSION_ID, proto.data, + NGHTTP2_PROTO_VERSION_ID_LEN)) { + conn->negnpn = CURL_HTTP_VERSION_2_0; } - else if(proto.size == ALPN_HTTP_1_1_LENGTH && memcmp(ALPN_HTTP_1_1, - proto.data, ALPN_HTTP_1_1_LENGTH) == 0) { - conn->negnpn = NPN_HTTP1_1; + else +#endif + if(proto.size == ALPN_HTTP_1_1_LENGTH && + !memcmp(ALPN_HTTP_1_1, proto.data, ALPN_HTTP_1_1_LENGTH)) { + conn->negnpn = CURL_HTTP_VERSION_1_1; } } - else { + else infof(data, "ALPN, server did not agree to a protocol\n"); - } } #endif @@ -1079,12 +1323,12 @@ Curl_gtls_connect(struct connectdata *conn, int sockindex) { - CURLcode retcode; + CURLcode result; bool done = FALSE; - retcode = gtls_connect_common(conn, sockindex, FALSE, &done); - if(retcode) - return retcode; + result = gtls_connect_common(conn, sockindex, FALSE, &done); + if(result) + return result; DEBUGASSERT(done); @@ -1110,12 +1354,6 @@ static ssize_t gtls_send(struct connectdata *conn, return rc; } -void Curl_gtls_close_all(struct SessionHandle *data) -{ - /* FIX: make the OpenSSL code more generic and use parts of it here */ - (void)data; -} - static void close_one(struct connectdata *conn, int idx) { @@ -1232,10 +1470,10 @@ static ssize_t gtls_recv(struct connectdata *conn, /* connection data */ if(ret == GNUTLS_E_REHANDSHAKE) { /* BLOCKING call, this is bad but a work-around for now. Fixing this "the proper way" takes a whole lot of work. */ - CURLcode rc = handshake(conn, num, FALSE, FALSE); - if(rc) + CURLcode result = handshake(conn, num, FALSE, FALSE); + if(result) /* handshake() writes error message on its own */ - *curlcode = rc; + *curlcode = result; else *curlcode = CURLE_AGAIN; /* then return as if this was a wouldblock */ return -1; @@ -1320,4 +1558,32 @@ void Curl_gtls_md5sum(unsigned char *tmp, /* input */ #endif } +void Curl_gtls_sha256sum(const unsigned char *tmp, /* input */ + size_t tmplen, + unsigned char *sha256sum, /* output */ + size_t sha256len) +{ +#if defined(USE_GNUTLS_NETTLE) + struct sha256_ctx SHA256pw; + sha256_init(&SHA256pw); + sha256_update(&SHA256pw, (unsigned int)tmplen, tmp); + sha256_digest(&SHA256pw, (unsigned int)sha256len, sha256sum); +#elif defined(USE_GNUTLS) + gcry_md_hd_t SHA256pw; + gcry_md_open(&SHA256pw, GCRY_MD_SHA256, 0); + gcry_md_write(SHA256pw, tmp, tmplen); + memcpy(sha256sum, gcry_md_read (SHA256pw, 0), sha256len); + gcry_md_close(SHA256pw); +#endif +} + +bool Curl_gtls_cert_status_request(void) +{ +#ifdef HAS_OCSP + return TRUE; +#else + return FALSE; +#endif +} + #endif /* USE_GNUTLS */ diff --git a/lib/vtls/gtls.h b/lib/vtls/gtls.h index cd6152c..0afd9b9 100644 --- a/lib/vtls/gtls.h +++ b/lib/vtls/gtls.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -35,10 +35,6 @@ CURLcode Curl_gtls_connect_nonblocking(struct connectdata *conn, int sockindex, bool *done); -/* tell GnuTLS to close down all open information regarding connections (and - thus session ID caching etc) */ -void Curl_gtls_close_all(struct SessionHandle *data); - /* close a SSL connection */ void Curl_gtls_close(struct connectdata *conn, int sockindex); @@ -52,9 +48,21 @@ void Curl_gtls_md5sum(unsigned char *tmp, /* input */ size_t tmplen, unsigned char *md5sum, /* output */ size_t md5len); +void Curl_gtls_sha256sum(const unsigned char *tmp, /* input */ + size_t tmplen, + unsigned char *sha256sum, /* output */ + size_t sha256len); -/* this backend provides these functions: */ -#define have_curlssl_md5sum 1 +bool Curl_gtls_cert_status_request(void); + +/* Set the API backend definition to GnuTLS */ +#define CURL_SSL_BACKEND CURLSSLBACKEND_GNUTLS + +/* this backend supports the CAPATH option */ +#define have_curlssl_ca_path 1 + +/* this backend supports CURLOPT_CERTINFO */ +#define have_curlssl_certinfo 1 /* API setup for GnuTLS */ #define curlssl_init Curl_gtls_init @@ -62,18 +70,19 @@ void Curl_gtls_md5sum(unsigned char *tmp, /* input */ #define curlssl_connect Curl_gtls_connect #define curlssl_connect_nonblocking Curl_gtls_connect_nonblocking #define curlssl_session_free(x) Curl_gtls_session_free(x) -#define curlssl_close_all Curl_gtls_close_all +#define curlssl_close_all(x) ((void)x) #define curlssl_close Curl_gtls_close #define curlssl_shutdown(x,y) Curl_gtls_shutdown(x,y) -#define curlssl_set_engine(x,y) (x=x, y=y, CURLE_NOT_BUILT_IN) -#define curlssl_set_engine_default(x) (x=x, CURLE_NOT_BUILT_IN) -#define curlssl_engines_list(x) (x=x, (struct curl_slist *)NULL) +#define curlssl_set_engine(x,y) ((void)x, (void)y, CURLE_NOT_BUILT_IN) +#define curlssl_set_engine_default(x) ((void)x, CURLE_NOT_BUILT_IN) +#define curlssl_engines_list(x) ((void)x, (struct curl_slist *)NULL) #define curlssl_version Curl_gtls_version -#define curlssl_check_cxn(x) (x=x, -1) -#define curlssl_data_pending(x,y) (x=x, y=y, 0) +#define curlssl_check_cxn(x) ((void)x, -1) +#define curlssl_data_pending(x,y) ((void)x, (void)y, 0) #define curlssl_random(x,y,z) Curl_gtls_random(x,y,z) #define curlssl_md5sum(a,b,c,d) Curl_gtls_md5sum(a,b,c,d) -#define CURL_SSL_BACKEND CURLSSLBACKEND_GNUTLS +#define curlssl_sha256sum(a,b,c,d) Curl_gtls_sha256sum(a,b,c,d) +#define curlssl_cert_status_request() Curl_gtls_cert_status_request() #endif /* USE_GNUTLS */ #endif /* HEADER_CURL_GTLS_H */ diff --git a/lib/vtls/nss.c b/lib/vtls/nss.c index 83b3e32..91727c7 100644 --- a/lib/vtls/nss.c +++ b/lib/vtls/nss.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -38,10 +38,7 @@ #include "select.h" #include "vtls.h" #include "llist.h" - -#define _MPRINTF_REPLACE /* use the internal *printf() functions */ -#include - +#include "curl_printf.h" #include "nssg.h" #include #include @@ -59,13 +56,20 @@ #include #include #include +#include /* for SECKEY_DestroyPublicKey() */ + +#define NSSVERNUM ((NSS_VMAJOR<<16)|(NSS_VMINOR<<8)|NSS_VPATCH) + +#if NSSVERNUM >= 0x030f00 /* 3.15.0 */ +#include +#endif -#include "curl_memory.h" #include "rawstr.h" #include "warnless.h" #include "x509asn1.h" -/* The last #include file should be: */ +/* The last #include files should be: */ +#include "curl_memory.h" #include "memdebug.h" #define SSL_DIR "/etc/pki/nssdb" @@ -343,7 +347,7 @@ static CURLcode nss_create_object(struct ssl_connect_data *ssl, CK_BBOOL ckfalse = CK_FALSE; CK_ATTRIBUTE attrs[/* max count of attributes */ 4]; int attr_cnt = 0; - CURLcode err = (cacert) + CURLcode result = (cacert) ? CURLE_SSL_CACERT_BADFILE : CURLE_SSL_CERTPROBLEM; @@ -355,7 +359,7 @@ static CURLcode nss_create_object(struct ssl_connect_data *ssl, slot = PK11_FindSlotByName(slot_name); free(slot_name); if(!slot) - return err; + return result; PK11_SETATTRS(attrs, attr_cnt, CKA_CLASS, &obj_class, sizeof(obj_class)); PK11_SETATTRS(attrs, attr_cnt, CKA_TOKEN, &cktrue, sizeof(CK_BBOOL)); @@ -370,7 +374,7 @@ static CURLcode nss_create_object(struct ssl_connect_data *ssl, obj = PK11_CreateGenericObject(slot, attrs, attr_cnt, PR_FALSE); PK11_FreeSlot(slot); if(!obj) - return err; + return result; if(!Curl_llist_insert_next(ssl->obj_list, ssl->obj_list->tail, obj)) { PK11_DestroyGenericObject(obj); @@ -405,16 +409,16 @@ static void nss_destroy_crl_item(void *user, void *ptr) static CURLcode nss_load_cert(struct ssl_connect_data *ssl, const char *filename, PRBool cacert) { - CURLcode err = (cacert) + CURLcode result = (cacert) ? CURLE_SSL_CACERT_BADFILE : CURLE_SSL_CERTPROBLEM; /* libnsspem.so leaks memory if the requested file does not exist. For more * details, go to . */ if(is_file(filename)) - err = nss_create_object(ssl, CKO_CERTIFICATE, filename, cacert); + result = nss_create_object(ssl, CKO_CERTIFICATE, filename, cacert); - if(CURLE_OK == err && !cacert) { + if(!result && !cacert) { /* we have successfully loaded a client certificate */ CERTCertificate *cert; char *nickname = NULL; @@ -436,7 +440,7 @@ static CURLcode nss_load_cert(struct ssl_connect_data *ssl, } } - return err; + return result; } /* add given CRL to cache if it is not already there */ @@ -448,7 +452,7 @@ static CURLcode nss_cache_crl(SECItem *crl_der) /* CRL already cached */ SEC_DestroyCrl(crl); SECITEM_FreeItem(crl_der, PR_TRUE); - return CURLE_SSL_CRL_BADFILE; + return CURLE_OK; } /* acquire lock before call of CERT_CacheCRL() and accessing nss_crl_list */ @@ -542,14 +546,15 @@ static CURLcode nss_load_key(struct connectdata *conn, int sockindex, { PK11SlotInfo *slot; SECStatus status; - CURLcode rv; + CURLcode result; struct ssl_connect_data *ssl = conn->ssl; + (void)sockindex; /* unused */ - rv = nss_create_object(ssl, CKO_PRIVATE_KEY, key_file, FALSE); - if(CURLE_OK != rv) { + result = nss_create_object(ssl, CKO_PRIVATE_KEY, key_file, FALSE); + if(result) { PR_SetError(SEC_ERROR_BAD_KEY, 0); - return rv; + return result; } slot = PK11_FindSlotByName("PEM Token #1"); @@ -563,9 +568,8 @@ static CURLcode nss_load_key(struct connectdata *conn, int sockindex, status = PK11_Authenticate(slot, PR_TRUE, conn->data->set.str[STRING_KEY_PASSWD]); PK11_FreeSlot(slot); - return (SECSuccess == status) - ? CURLE_OK - : CURLE_SSL_CERTPROBLEM; + + return (SECSuccess == status) ? CURLE_OK : CURLE_SSL_CERTPROBLEM; } static int display_error(struct connectdata *conn, PRInt32 err, @@ -588,35 +592,35 @@ static CURLcode cert_stuff(struct connectdata *conn, int sockindex, char *cert_file, char *key_file) { struct SessionHandle *data = conn->data; - CURLcode rv; + CURLcode result; if(cert_file) { - rv = nss_load_cert(&conn->ssl[sockindex], cert_file, PR_FALSE); - if(CURLE_OK != rv) { + result = nss_load_cert(&conn->ssl[sockindex], cert_file, PR_FALSE); + if(result) { const PRErrorCode err = PR_GetError(); if(!display_error(conn, err, cert_file)) { const char *err_name = nss_error_to_name(err); failf(data, "unable to load client cert: %d (%s)", err, err_name); } - return rv; + return result; } } if(key_file || (is_file(cert_file))) { if(key_file) - rv = nss_load_key(conn, sockindex, key_file); + result = nss_load_key(conn, sockindex, key_file); else /* In case the cert file also has the key */ - rv = nss_load_key(conn, sockindex, cert_file); - if(CURLE_OK != rv) { + result = nss_load_key(conn, sockindex, cert_file); + if(result) { const PRErrorCode err = PR_GetError(); if(!display_error(conn, err, key_file)) { const char *err_name = nss_error_to_name(err); failf(data, "unable to load client key: %d (%s)", err, err_name); } - return rv; + return result; } } @@ -626,6 +630,7 @@ static CURLcode cert_stuff(struct connectdata *conn, int sockindex, static char * nss_get_password(PK11SlotInfo * slot, PRBool retry, void *arg) { (void)slot; /* unused */ + if(retry || NULL == arg) return NULL; else @@ -638,6 +643,34 @@ static SECStatus nss_auth_cert_hook(void *arg, PRFileDesc *fd, PRBool checksig, PRBool isServer) { struct connectdata *conn = (struct connectdata *)arg; + +#ifdef SSL_ENABLE_OCSP_STAPLING + if(conn->data->set.ssl.verifystatus) { + SECStatus cacheResult; + + const SECItemArray *csa = SSL_PeerStapledOCSPResponses(fd); + if(!csa) { + failf(conn->data, "Invalid OCSP response"); + return SECFailure; + } + + if(csa->len == 0) { + failf(conn->data, "No OCSP response received"); + return SECFailure; + } + + cacheResult = CERT_CacheOCSPResponseFromSideChannel( + CERT_GetDefaultCertDB(), SSL_PeerCertificate(fd), + PR_Now(), &csa->items[0], arg + ); + + if(cacheResult != SECSuccess) { + failf(conn->data, "Invalid OCSP response"); + return cacheResult; + } + } +#endif + if(!conn->data->set.ssl.verifypeer) { infof(conn->data, "skipping SSL peer certificate verification\n"); return SECSuccess; @@ -651,7 +684,6 @@ static SECStatus nss_auth_cert_hook(void *arg, PRFileDesc *fd, PRBool checksig, */ static void HandshakeCallback(PRFileDesc *sock, void *arg) { -#ifdef USE_NGHTTP2 struct connectdata *conn = (struct connectdata*) arg; unsigned int buflenmax = 50; unsigned char buf[50]; @@ -665,36 +697,94 @@ static void HandshakeCallback(PRFileDesc *sock, void *arg) if(SSL_GetNextProto(sock, &state, buf, &buflen, buflenmax) == SECSuccess) { switch(state) { - case SSL_NEXT_PROTO_NO_SUPPORT: - case SSL_NEXT_PROTO_NO_OVERLAP: - infof(conn->data, "TLS, neither ALPN nor NPN succeeded\n"); - return; + case SSL_NEXT_PROTO_NO_SUPPORT: + case SSL_NEXT_PROTO_NO_OVERLAP: + infof(conn->data, "ALPN/NPN, server did not agree to a protocol\n"); + return; #ifdef SSL_ENABLE_ALPN - case SSL_NEXT_PROTO_SELECTED: - infof(conn->data, "ALPN, server accepted to use %.*s\n", buflen, buf); - break; + case SSL_NEXT_PROTO_SELECTED: + infof(conn->data, "ALPN, server accepted to use %.*s\n", buflen, buf); + break; #endif - case SSL_NEXT_PROTO_NEGOTIATED: - infof(conn->data, "NPN, server accepted to use %.*s\n", buflen, buf); - break; + case SSL_NEXT_PROTO_NEGOTIATED: + infof(conn->data, "NPN, server accepted to use %.*s\n", buflen, buf); + break; } +#ifdef USE_NGHTTP2 if(buflen == NGHTTP2_PROTO_VERSION_ID_LEN && - memcmp(NGHTTP2_PROTO_VERSION_ID, buf, NGHTTP2_PROTO_VERSION_ID_LEN) - == 0) { - conn->negnpn = NPN_HTTP2; + !memcmp(NGHTTP2_PROTO_VERSION_ID, buf, NGHTTP2_PROTO_VERSION_ID_LEN)) { + conn->negnpn = CURL_HTTP_VERSION_2_0; } - else if(buflen == ALPN_HTTP_1_1_LENGTH && memcmp(ALPN_HTTP_1_1, buf, - ALPN_HTTP_1_1_LENGTH)) { - conn->negnpn = NPN_HTTP1_1; + else +#endif + if(buflen == ALPN_HTTP_1_1_LENGTH && + !memcmp(ALPN_HTTP_1_1, buf, ALPN_HTTP_1_1_LENGTH)) { + conn->negnpn = CURL_HTTP_VERSION_1_1; } } -#else - (void)sock; - (void)arg; -#endif } +#if NSSVERNUM >= 0x030f04 /* 3.15.4 */ +static SECStatus CanFalseStartCallback(PRFileDesc *sock, void *client_data, + PRBool *canFalseStart) +{ + struct connectdata *conn = client_data; + struct SessionHandle *data = conn->data; + + SSLChannelInfo channelInfo; + SSLCipherSuiteInfo cipherInfo; + + SECStatus rv; + PRBool negotiatedExtension; + + *canFalseStart = PR_FALSE; + + if(SSL_GetChannelInfo(sock, &channelInfo, sizeof(channelInfo)) != SECSuccess) + return SECFailure; + + if(SSL_GetCipherSuiteInfo(channelInfo.cipherSuite, &cipherInfo, + sizeof(cipherInfo)) != SECSuccess) + return SECFailure; + + /* Prevent version downgrade attacks from TLS 1.2, and avoid False Start for + * TLS 1.3 and later. See https://bugzilla.mozilla.org/show_bug.cgi?id=861310 + */ + if(channelInfo.protocolVersion != SSL_LIBRARY_VERSION_TLS_1_2) + goto end; + + /* Only allow ECDHE key exchange algorithm. + * See https://bugzilla.mozilla.org/show_bug.cgi?id=952863 */ + if(cipherInfo.keaType != ssl_kea_ecdh) + goto end; + + /* Prevent downgrade attacks on the symmetric cipher. We do not allow CBC + * mode due to BEAST, POODLE, and other attacks on the MAC-then-Encrypt + * design. See https://bugzilla.mozilla.org/show_bug.cgi?id=1109766 */ + if(cipherInfo.symCipher != ssl_calg_aes_gcm) + goto end; + + /* Enforce ALPN or NPN to do False Start, as an indicator of server + * compatibility. */ + rv = SSL_HandshakeNegotiatedExtension(sock, ssl_app_layer_protocol_xtn, + &negotiatedExtension); + if(rv != SECSuccess || !negotiatedExtension) { + rv = SSL_HandshakeNegotiatedExtension(sock, ssl_next_proto_nego_xtn, + &negotiatedExtension); + } + + if(rv != SECSuccess || !negotiatedExtension) + goto end; + + *canFalseStart = PR_TRUE; + + infof(data, "Trying TLS False Start\n"); + +end: + return SECSuccess; +} +#endif + static void display_cert_info(struct SessionHandle *data, CERTCertificate *cert) { @@ -723,8 +813,9 @@ static void display_cert_info(struct SessionHandle *data, PR_Free(common_name); } -static void display_conn_info(struct connectdata *conn, PRFileDesc *sock) +static CURLcode display_conn_info(struct connectdata *conn, PRFileDesc *sock) { + CURLcode result = CURLE_OK; SSLChannelInfo channel; SSLCipherSuiteInfo suite; CERTCertificate *cert; @@ -743,7 +834,6 @@ static void display_conn_info(struct connectdata *conn, PRFileDesc *sock) } cert = SSL_PeerCertificate(sock); - if(cert) { infof(conn->data, "Server certificate:\n"); @@ -768,21 +858,29 @@ static void display_conn_info(struct connectdata *conn, PRFileDesc *sock) cert2 = cert3; } } - Curl_ssl_init_certinfo(conn->data, i); - for(i = 0; cert; cert = cert2) { - Curl_extract_certinfo(conn, i++, (char *)cert->derCert.data, - (char *)cert->derCert.data + cert->derCert.len); - if(cert->isRoot) { + + result = Curl_ssl_init_certinfo(conn->data, i); + if(!result) { + for(i = 0; cert; cert = cert2) { + result = Curl_extract_certinfo(conn, i++, (char *)cert->derCert.data, + (char *)cert->derCert.data + + cert->derCert.len); + if(result) + break; + + if(cert->isRoot) { + CERT_DestroyCertificate(cert); + break; + } + + cert2 = CERT_FindCertIssuer(cert, now, certUsageSSLCA); CERT_DestroyCertificate(cert); - break; } - cert2 = CERT_FindCertIssuer(cert, now, certUsageSSLCA); - CERT_DestroyCertificate(cert); } } } - return; + return result; } static SECStatus BadCertHandler(void *arg, PRFileDesc *sock) @@ -820,7 +918,7 @@ static SECStatus BadCertHandler(void *arg, PRFileDesc *sock) static SECStatus check_issuer_cert(PRFileDesc *sock, char *issuer_nickname) { - CERTCertificate *cert,*cert_issuer,*issuer; + CERTCertificate *cert, *cert_issuer, *issuer; SECStatus res=SECSuccess; void *proto_win = NULL; @@ -831,7 +929,7 @@ static SECStatus check_issuer_cert(PRFileDesc *sock, */ cert = SSL_PeerCertificate(sock); - cert_issuer = CERT_FindCertIssuer(cert,PR_Now(),certUsageObjectSigner); + cert_issuer = CERT_FindCertIssuer(cert, PR_Now(), certUsageObjectSigner); proto_win = SSL_RevealPinArg(sock); issuer = PK11_FindCertFromNickname(issuer_nickname, proto_win); @@ -848,6 +946,53 @@ static SECStatus check_issuer_cert(PRFileDesc *sock, return res; } +static CURLcode cmp_peer_pubkey(struct ssl_connect_data *connssl, + const char *pinnedpubkey) +{ + CURLcode result = CURLE_SSL_PINNEDPUBKEYNOTMATCH; + struct SessionHandle *data = connssl->data; + CERTCertificate *cert; + + if(!pinnedpubkey) + /* no pinned public key specified */ + return CURLE_OK; + + /* get peer certificate */ + cert = SSL_PeerCertificate(connssl->handle); + if(cert) { + /* extract public key from peer certificate */ + SECKEYPublicKey *pubkey = CERT_ExtractPublicKey(cert); + if(pubkey) { + /* encode the public key as DER */ + SECItem *cert_der = PK11_DEREncodePublicKey(pubkey); + if(cert_der) { + /* compare the public key with the pinned public key */ + result = Curl_pin_peer_pubkey(pinnedpubkey, + cert_der->data, + cert_der->len); + SECITEM_FreeItem(cert_der, PR_TRUE); + } + SECKEY_DestroyPublicKey(pubkey); + } + CERT_DestroyCertificate(cert); + } + + /* report the resulting status */ + switch(result) { + case CURLE_OK: + infof(data, "pinned public key verified successfully!\n"); + break; + case CURLE_SSL_PINNEDPUBKEYNOTMATCH: + failf(data, "failed to verify pinned public key"); + break; + default: + /* OOM, etc. */ + break; + } + + return result; +} + /** * * Callback to pick the SSL client certificate. @@ -935,36 +1080,6 @@ static SECStatus SelectClientCert(void *arg, PRFileDesc *sock, return SECSuccess; } -/* This function is supposed to decide, which error codes should be used - * to conclude server is TLS intolerant. - * - * taken from xulrunner - nsNSSIOLayer.cpp - */ -static PRBool -isTLSIntoleranceError(PRInt32 err) -{ - switch (err) { - case SSL_ERROR_BAD_MAC_ALERT: - case SSL_ERROR_BAD_MAC_READ: - case SSL_ERROR_HANDSHAKE_FAILURE_ALERT: - case SSL_ERROR_HANDSHAKE_UNEXPECTED_ALERT: - case SSL_ERROR_CLIENT_KEY_EXCHANGE_FAILURE: - case SSL_ERROR_ILLEGAL_PARAMETER_ALERT: - case SSL_ERROR_NO_CYPHER_OVERLAP: - case SSL_ERROR_BAD_SERVER: - case SSL_ERROR_BAD_BLOCK_PADDING: - case SSL_ERROR_UNSUPPORTED_VERSION: - case SSL_ERROR_PROTOCOL_VERSION_ALERT: - case SSL_ERROR_RX_MALFORMED_FINISHED: - case SSL_ERROR_BAD_HANDSHAKE_HASH_VALUE: - case SSL_ERROR_DECODE_ERROR_ALERT: - case SSL_ERROR_RX_UNKNOWN_ALERT: - return PR_TRUE; - default: - return PR_FALSE; - } -} - /* update blocking direction in case of PR_WOULD_BLOCK_ERROR */ static void nss_update_connecting_state(ssl_connect_state state, void *secret) { @@ -1019,6 +1134,7 @@ static PRStatus nspr_io_close(PRFileDesc *fd) return close_fn(fd); } +/* data might be NULL */ static CURLcode nss_init_core(struct SessionHandle *data, const char *cert_dir) { NSSInitParameters initparams; @@ -1056,11 +1172,12 @@ static CURLcode nss_init_core(struct SessionHandle *data, const char *cert_dir) return CURLE_SSL_CACERT_BADFILE; } +/* data might be NULL */ static CURLcode nss_init(struct SessionHandle *data) { char *cert_dir; struct_stat st; - CURLcode rv; + CURLcode result; if(initialized) return CURLE_OK; @@ -1102,14 +1219,15 @@ static CURLcode nss_init(struct SessionHandle *data) nspr_io_methods.close = nspr_io_close; } - rv = nss_init_core(data, cert_dir); - if(rv) - return rv; + result = nss_init_core(data, cert_dir); + if(result) + return result; if(num_enabled_ciphers() == 0) NSS_SetDomesticPolicy(); initialized = 1; + return CURLE_OK; } @@ -1133,20 +1251,22 @@ int Curl_nss_init(void) return 1; } +/* data might be NULL */ CURLcode Curl_nss_force_init(struct SessionHandle *data) { - CURLcode rv; + CURLcode result; if(!nss_initlock) { - failf(data, - "unable to initialize NSS, curl_global_init() should have been " - "called with CURL_GLOBAL_SSL or CURL_GLOBAL_ALL"); + if(data) + failf(data, "unable to initialize NSS, curl_global_init() should have " + "been called with CURL_GLOBAL_SSL or CURL_GLOBAL_ALL"); return CURLE_FAILED_INIT; } PR_Lock(nss_initlock); - rv = nss_init(data); + result = nss_init(data); PR_Unlock(nss_initlock); - return rv; + + return result; } /* Global cleanup */ @@ -1229,10 +1349,8 @@ void Curl_nss_close(struct connectdata *conn, int sockindex) * authentication data from a previous connection. */ SSL_InvalidateSession(connssl->handle); - if(connssl->client_nickname != NULL) { - free(connssl->client_nickname); - connssl->client_nickname = NULL; - } + free(connssl->client_nickname); + connssl->client_nickname = NULL; /* destroy all NSS objects in order to avoid failure of NSS shutdown */ Curl_llist_destroy(connssl->obj_list, NULL); connssl->obj_list = NULL; @@ -1243,16 +1361,6 @@ void Curl_nss_close(struct connectdata *conn, int sockindex) } } -/* - * This function is called when the 'data' struct is going away. Close - * down everything and free all resources! - */ -int Curl_nss_close_all(struct SessionHandle *data) -{ - (void)data; - return 0; -} - /* return true if NSS can provide error code (and possibly msg) for the error */ static bool is_nss_error(CURLcode err) @@ -1295,9 +1403,9 @@ static CURLcode nss_load_ca_certificates(struct connectdata *conn, const char *capath = data->set.ssl.CApath; if(cafile) { - CURLcode rv = nss_load_cert(&conn->ssl[sockindex], cafile, PR_TRUE); - if(CURLE_OK != rv) - return rv; + CURLcode result = nss_load_cert(&conn->ssl[sockindex], cafile, PR_TRUE); + if(result) + return result; } if(capath) { @@ -1342,18 +1450,11 @@ static CURLcode nss_load_ca_certificates(struct connectdata *conn, static CURLcode nss_init_sslver(SSLVersionRange *sslver, struct SessionHandle *data) { - switch (data->set.ssl.version) { + switch(data->set.ssl.version) { default: case CURL_SSLVERSION_DEFAULT: - sslver->min = SSL_LIBRARY_VERSION_3_0; - if(data->state.ssl_connect_retry) { - infof(data, "TLS disabled due to previous handshake failure\n"); - sslver->max = SSL_LIBRARY_VERSION_3_0; - return CURLE_OK; - } - /* intentional fall-through to default to highest TLS version if possible */ - case CURL_SSLVERSION_TLSv1: + sslver->min = SSL_LIBRARY_VERSION_TLS_1_0; #ifdef SSL_LIBRARY_VERSION_TLS_1_2 sslver->max = SSL_LIBRARY_VERSION_TLS_1_2; #elif defined SSL_LIBRARY_VERSION_TLS_1_1 @@ -1403,12 +1504,8 @@ static CURLcode nss_fail_connect(struct ssl_connect_data *connssl, struct SessionHandle *data, CURLcode curlerr) { - SSLVersionRange sslver; PRErrorCode err = 0; - /* reset the flag to avoid an infinite loop */ - data->state.ssl_connect_retry = FALSE; - if(is_nss_error(curlerr)) { /* read NSPR error code */ err = PR_GetError(); @@ -1426,17 +1523,6 @@ static CURLcode nss_fail_connect(struct ssl_connect_data *connssl, Curl_llist_destroy(connssl->obj_list, NULL); connssl->obj_list = NULL; - if(connssl->handle - && (SSL_VersionRangeGet(connssl->handle, &sslver) == SECSuccess) - && (sslver.min == SSL_LIBRARY_VERSION_3_0) - && (sslver.max != SSL_LIBRARY_VERSION_3_0) - && isTLSIntoleranceError(err)) { - /* schedule reconnect through Curl_retry_request() */ - data->state.ssl_connect_retry = TRUE; - infof(data, "Error in TLS handshake, trying SSLv3...\n"); - return CURLE_OK; - } - return curlerr; } @@ -1464,27 +1550,13 @@ static CURLcode nss_setup_connect(struct connectdata *conn, int sockindex) struct SessionHandle *data = conn->data; curl_socket_t sockfd = conn->sock[sockindex]; struct ssl_connect_data *connssl = &conn->ssl[sockindex]; - CURLcode curlerr; + CURLcode result; SSLVersionRange sslver = { SSL_LIBRARY_VERSION_TLS_1_0, /* min */ SSL_LIBRARY_VERSION_TLS_1_0 /* max */ }; -#ifdef USE_NGHTTP2 -#if defined(SSL_ENABLE_NPN) || defined(SSL_ENABLE_ALPN) - unsigned int alpn_protos_len = NGHTTP2_PROTO_VERSION_ID_LEN + - ALPN_HTTP_1_1_LENGTH + 2; - unsigned char alpn_protos[NGHTTP2_PROTO_VERSION_ID_LEN + ALPN_HTTP_1_1_LENGTH - + 2]; - int cur = 0; -#endif -#endif - - - if(connssl->state == ssl_connection_complete) - return CURLE_OK; - connssl->data = data; /* list of all NSS objects we need to destroy in Curl_nss_close() */ @@ -1494,13 +1566,13 @@ static CURLcode nss_setup_connect(struct connectdata *conn, int sockindex) /* FIXME. NSS doesn't support multiple databases open at the same time. */ PR_Lock(nss_initlock); - curlerr = nss_init(conn->data); - if(CURLE_OK != curlerr) { + result = nss_init(conn->data); + if(result) { PR_Unlock(nss_initlock); goto error; } - curlerr = CURLE_SSL_CONNECT_ERROR; + result = CURLE_SSL_CONNECT_ERROR; if(!mod) { char *configstring = aprintf("library=%s name=PEM", pem_library); @@ -1517,7 +1589,7 @@ static CURLcode nss_setup_connect(struct connectdata *conn, int sockindex) mod = NULL; } infof(data, "WARNING: failed to load NSS PEM library %s. Using " - "OpenSSL PEM certificates will not work.\n", pem_library); + "OpenSSL PEM certificates will not work.\n", pem_library); } } @@ -1560,12 +1632,9 @@ static CURLcode nss_setup_connect(struct connectdata *conn, int sockindex) infof(data, "warning: support for SSL_CBC_RANDOM_IV not compiled in\n"); #endif - /* reset the flag to avoid an infinite loop */ - data->state.ssl_connect_retry = FALSE; - if(data->set.ssl.cipher_list) { if(set_ciphers(data, model, data->set.ssl.cipher_list) != SECSuccess) { - curlerr = CURLE_SSL_CIPHER; + result = CURLE_SSL_CIPHER; goto error; } } @@ -1587,16 +1656,16 @@ static CURLcode nss_setup_connect(struct connectdata *conn, int sockindex) if(data->set.ssl.verifypeer) { const CURLcode rv = nss_load_ca_certificates(conn, sockindex); - if(CURLE_OK != rv) { - curlerr = rv; + if(rv) { + result = rv; goto error; } } if(data->set.ssl.CRLfile) { const CURLcode rv = nss_load_crl(data->set.ssl.CRLfile); - if(CURLE_OK != rv) { - curlerr = rv; + if(rv) { + result = rv; goto error; } infof(data, " CRLfile: %s\n", data->set.ssl.CRLfile); @@ -1611,9 +1680,9 @@ static CURLcode nss_setup_connect(struct connectdata *conn, int sockindex) else { CURLcode rv = cert_stuff(conn, sockindex, data->set.str[STRING_CERT], data->set.str[STRING_KEY]); - if(CURLE_OK != rv) { + if(rv) { /* failf() is already done in cert_stuff() */ - curlerr = rv; + result = rv; goto error; } } @@ -1626,7 +1695,7 @@ static CURLcode nss_setup_connect(struct connectdata *conn, int sockindex) if(SSL_GetClientAuthDataHook(model, SelectClientCert, (void *)connssl) != SECSuccess) { - curlerr = CURLE_SSL_CERTPROBLEM; + result = CURLE_SSL_CERTPROBLEM; goto error; } @@ -1667,42 +1736,57 @@ static CURLcode nss_setup_connect(struct connectdata *conn, int sockindex) SSL_SetPKCS11PinArg(connssl->handle, data->set.str[STRING_KEY_PASSWD]); } -#ifdef USE_NGHTTP2 - if(data->set.httpversion == CURL_HTTP_VERSION_2_0) { +#ifdef SSL_ENABLE_OCSP_STAPLING + if(data->set.ssl.verifystatus) { + if(SSL_OptionSet(connssl->handle, SSL_ENABLE_OCSP_STAPLING, PR_TRUE) + != SECSuccess) + goto error; + } +#endif + #ifdef SSL_ENABLE_NPN - if(data->set.ssl_enable_npn) { - if(SSL_OptionSet(connssl->handle, SSL_ENABLE_NPN, PR_TRUE) != SECSuccess) - goto error; - } + if(SSL_OptionSet(connssl->handle, SSL_ENABLE_NPN, data->set.ssl_enable_npn + ? PR_TRUE : PR_FALSE) != SECSuccess) + goto error; #endif #ifdef SSL_ENABLE_ALPN - if(data->set.ssl_enable_alpn) { - if(SSL_OptionSet(connssl->handle, SSL_ENABLE_ALPN, PR_TRUE) - != SECSuccess) - goto error; - } + if(SSL_OptionSet(connssl->handle, SSL_ENABLE_ALPN, data->set.ssl_enable_alpn + ? PR_TRUE : PR_FALSE) != SECSuccess) + goto error; +#endif + +#if NSSVERNUM >= 0x030f04 /* 3.15.4 */ + if(data->set.ssl.falsestart) { + if(SSL_OptionSet(connssl->handle, SSL_ENABLE_FALSE_START, PR_TRUE) + != SECSuccess) + goto error; + + if(SSL_SetCanFalseStartCallback(connssl->handle, CanFalseStartCallback, + conn) != SECSuccess) + goto error; + } #endif #if defined(SSL_ENABLE_NPN) || defined(SSL_ENABLE_ALPN) - if(data->set.ssl_enable_npn || data->set.ssl_enable_alpn) { - alpn_protos[cur] = NGHTTP2_PROTO_VERSION_ID_LEN; - cur++; - memcpy(&alpn_protos[cur], NGHTTP2_PROTO_VERSION_ID, + if(data->set.ssl_enable_npn || data->set.ssl_enable_alpn) { + int cur = 0; + unsigned char protocols[128]; + +#ifdef USE_NGHTTP2 + if(data->set.httpversion == CURL_HTTP_VERSION_2_0) { + protocols[cur++] = NGHTTP2_PROTO_VERSION_ID_LEN; + memcpy(&protocols[cur], NGHTTP2_PROTO_VERSION_ID, NGHTTP2_PROTO_VERSION_ID_LEN); cur += NGHTTP2_PROTO_VERSION_ID_LEN; - alpn_protos[cur] = ALPN_HTTP_1_1_LENGTH; - cur++; - memcpy(&alpn_protos[cur], ALPN_HTTP_1_1, ALPN_HTTP_1_1_LENGTH); - - if(SSL_SetNextProtoNego(connssl->handle, alpn_protos, alpn_protos_len) - != SECSuccess) - goto error; - } - else { - infof(data, "SSL, can't negotiate HTTP/2.0 with neither NPN nor ALPN\n"); } #endif + protocols[cur++] = ALPN_HTTP_1_1_LENGTH; + memcpy(&protocols[cur], ALPN_HTTP_1_1, ALPN_HTTP_1_1_LENGTH); + cur += ALPN_HTTP_1_1_LENGTH; + + if(SSL_SetNextProtoNego(connssl->handle, protocols, cur) != SECSuccess) + goto error; } #endif @@ -1718,21 +1802,21 @@ error: if(model) PR_Close(model); - return nss_fail_connect(connssl, data, curlerr); + return nss_fail_connect(connssl, data, result); } static CURLcode nss_do_connect(struct connectdata *conn, int sockindex) { struct ssl_connect_data *connssl = &conn->ssl[sockindex]; struct SessionHandle *data = conn->data; - CURLcode curlerr = CURLE_SSL_CONNECT_ERROR; + CURLcode result = CURLE_SSL_CONNECT_ERROR; PRUint32 timeout; /* check timeout situation */ const long time_left = Curl_timeleft(data, NULL, TRUE); if(time_left < 0L) { failf(data, "timed out before SSL handshake"); - curlerr = CURLE_OPERATION_TIMEDOUT; + result = CURLE_OPERATION_TIMEDOUT; goto error; } @@ -1743,17 +1827,15 @@ static CURLcode nss_do_connect(struct connectdata *conn, int sockindex) /* blocking direction is updated by nss_update_connecting_state() */ return CURLE_AGAIN; else if(conn->data->set.ssl.certverifyresult == SSL_ERROR_BAD_CERT_DOMAIN) - curlerr = CURLE_PEER_FAILED_VERIFICATION; + result = CURLE_PEER_FAILED_VERIFICATION; else if(conn->data->set.ssl.certverifyresult!=0) - curlerr = CURLE_SSL_CACERT; + result = CURLE_SSL_CACERT; goto error; } - connssl->state = ssl_connection_complete; - conn->recv[sockindex] = nss_recv; - conn->send[sockindex] = nss_send; - - display_conn_info(conn, connssl->handle); + result = display_conn_info(conn, connssl->handle); + if(result) + goto error; if(data->set.str[STRING_SSL_ISSUERCERT]) { SECStatus ret = SECFailure; @@ -1765,8 +1847,8 @@ static CURLcode nss_do_connect(struct connectdata *conn, int sockindex) } if(SECFailure == ret) { - infof(data,"SSL certificate issuer check failed\n"); - curlerr = CURLE_SSL_ISSUER_ERROR; + infof(data, "SSL certificate issuer check failed\n"); + result = CURLE_SSL_ISSUER_ERROR; goto error; } else { @@ -1774,10 +1856,15 @@ static CURLcode nss_do_connect(struct connectdata *conn, int sockindex) } } + result = cmp_peer_pubkey(connssl, data->set.str[STRING_SSL_PINNEDPUBLICKEY]); + if(result) + /* status already printed */ + goto error; + return CURLE_OK; error: - return nss_fail_connect(connssl, data, curlerr); + return nss_fail_connect(connssl, data, result); } static CURLcode nss_connect_common(struct connectdata *conn, int sockindex, @@ -1786,26 +1873,29 @@ static CURLcode nss_connect_common(struct connectdata *conn, int sockindex, struct ssl_connect_data *connssl = &conn->ssl[sockindex]; struct SessionHandle *data = conn->data; const bool blocking = (done == NULL); - CURLcode rv; + CURLcode result; + + if(connssl->state == ssl_connection_complete) + return CURLE_OK; if(connssl->connecting_state == ssl_connect_1) { - rv = nss_setup_connect(conn, sockindex); - if(rv) + result = nss_setup_connect(conn, sockindex); + if(result) /* we do not expect CURLE_AGAIN from nss_setup_connect() */ - return rv; + return result; if(!blocking) { /* in non-blocking mode, set NSS non-blocking mode before handshake */ - rv = nss_set_nonblock(connssl, data); - if(rv) - return rv; + result = nss_set_nonblock(connssl, data); + if(result) + return result; } connssl->connecting_state = ssl_connect_2; } - rv = nss_do_connect(conn, sockindex); - switch(rv) { + result = nss_do_connect(conn, sockindex); + switch(result) { case CURLE_OK: break; case CURLE_AGAIN: @@ -1814,20 +1904,26 @@ static CURLcode nss_connect_common(struct connectdata *conn, int sockindex, return CURLE_OK; /* fall through */ default: - return rv; + return result; } if(blocking) { /* in blocking mode, set NSS non-blocking mode _after_ SSL handshake */ - rv = nss_set_nonblock(connssl, data); - if(rv) - return rv; + result = nss_set_nonblock(connssl, data); + if(result) + return result; } else /* signal completed SSL handshake */ *done = TRUE; - connssl->connecting_state = ssl_connect_done; + connssl->state = ssl_connection_complete; + conn->recv[sockindex] = nss_recv; + conn->send[sockindex] = nss_send; + + /* ssl_connect_done is never used outside, go back to the initial state */ + connssl->connecting_state = ssl_connect_1; + return CURLE_OK; } @@ -1866,8 +1962,10 @@ static ssize_t nss_send(struct connectdata *conn, /* connection data */ ? CURLE_SSL_CERTPROBLEM : CURLE_SEND_ERROR; } + return -1; } + return rc; /* number of bytes */ } @@ -1897,8 +1995,10 @@ static ssize_t nss_recv(struct connectdata * conn, /* connection data */ ? CURLE_SSL_CERTPROBLEM : CURLE_RECV_ERROR; } + return -1; } + return nread; } @@ -1907,6 +2007,7 @@ size_t Curl_nss_version(char *buffer, size_t size) return snprintf(buffer, size, "NSS/%s", NSS_VERSION); } +/* data might be NULL */ int Curl_nss_seed(struct SessionHandle *data) { /* make sure that NSS is initialized */ @@ -1918,13 +2019,12 @@ int Curl_nss_random(struct SessionHandle *data, unsigned char *entropy, size_t length) { - if(data) - Curl_nss_seed(data); /* Initiate the seed if not already done */ - if(SECSuccess != PK11_GenerateRandom(entropy, curlx_uztosi(length))) { - /* no way to signal a failure from here, we have to abort */ - failf(data, "PK11_GenerateRandom() failed, calling abort()..."); - abort(); - } + Curl_nss_seed(data); /* Initiate the seed if not already done */ + + if(SECSuccess != PK11_GenerateRandom(entropy, curlx_uztosi(length))) + /* signal a failure */ + return -1; + return 0; } @@ -1935,9 +2035,40 @@ void Curl_nss_md5sum(unsigned char *tmp, /* input */ { PK11Context *MD5pw = PK11_CreateDigestContext(SEC_OID_MD5); unsigned int MD5out; + PK11_DigestOp(MD5pw, tmp, curlx_uztoui(tmplen)); PK11_DigestFinal(MD5pw, md5sum, &MD5out, curlx_uztoui(md5len)); PK11_DestroyContext(MD5pw, PR_TRUE); } +void Curl_nss_sha256sum(const unsigned char *tmp, /* input */ + size_t tmplen, + unsigned char *sha256sum, /* output */ + size_t sha256len) +{ + PK11Context *SHA256pw = PK11_CreateDigestContext(SEC_OID_SHA256); + unsigned int SHA256out; + + PK11_DigestOp(SHA256pw, tmp, curlx_uztoui(tmplen)); + PK11_DigestFinal(SHA256pw, sha256sum, &SHA256out, curlx_uztoui(sha256len)); + PK11_DestroyContext(SHA256pw, PR_TRUE); +} + +bool Curl_nss_cert_status_request(void) +{ +#ifdef SSL_ENABLE_OCSP_STAPLING + return TRUE; +#else + return FALSE; +#endif +} + +bool Curl_nss_false_start(void) { +#if NSSVERNUM >= 0x030f04 /* 3.15.4 */ + return TRUE; +#else + return FALSE; +#endif +} + #endif /* USE_NSS */ diff --git a/lib/vtls/nssg.h b/lib/vtls/nssg.h index 311f873..5fd7275 100644 --- a/lib/vtls/nssg.h +++ b/lib/vtls/nssg.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -37,10 +37,6 @@ CURLcode Curl_nss_connect_nonblocking(struct connectdata *conn, /* close a SSL connection */ void Curl_nss_close(struct connectdata *conn, int sockindex); -/* tell NSS to close down all open information regarding connections (and - thus session ID caching etc) */ -int Curl_nss_close_all(struct SessionHandle *data); - int Curl_nss_init(void); void Curl_nss_cleanup(void); @@ -60,8 +56,23 @@ void Curl_nss_md5sum(unsigned char *tmp, /* input */ unsigned char *md5sum, /* output */ size_t md5len); -/* this backend provides these functions: */ -#define have_curlssl_md5sum 1 +void Curl_nss_sha256sum(const unsigned char *tmp, /* input */ + size_t tmplen, + unsigned char *sha256sum, /* output */ + size_t sha256len); + +bool Curl_nss_cert_status_request(void); + +bool Curl_nss_false_start(void); + +/* Set the API backend definition to NSS */ +#define CURL_SSL_BACKEND CURLSSLBACKEND_NSS + +/* this backend supports the CAPATH option */ +#define have_curlssl_ca_path 1 + +/* this backend supports CURLOPT_CERTINFO */ +#define have_curlssl_certinfo 1 /* API setup for NSS */ #define curlssl_init Curl_nss_init @@ -71,19 +82,21 @@ void Curl_nss_md5sum(unsigned char *tmp, /* input */ /* NSS has its own session ID cache */ #define curlssl_session_free(x) Curl_nop_stmt -#define curlssl_close_all Curl_nss_close_all +#define curlssl_close_all(x) ((void)x) #define curlssl_close Curl_nss_close /* NSS has no shutdown function provided and thus always fail */ -#define curlssl_shutdown(x,y) (x=x, y=y, 1) -#define curlssl_set_engine(x,y) (x=x, y=y, CURLE_NOT_BUILT_IN) -#define curlssl_set_engine_default(x) (x=x, CURLE_NOT_BUILT_IN) -#define curlssl_engines_list(x) (x=x, (struct curl_slist *)NULL) +#define curlssl_shutdown(x,y) ((void)x, (void)y, 1) +#define curlssl_set_engine(x,y) ((void)x, (void)y, CURLE_NOT_BUILT_IN) +#define curlssl_set_engine_default(x) ((void)x, CURLE_NOT_BUILT_IN) +#define curlssl_engines_list(x) ((void)x, (struct curl_slist *)NULL) #define curlssl_version Curl_nss_version #define curlssl_check_cxn(x) Curl_nss_check_cxn(x) -#define curlssl_data_pending(x,y) (x=x, y=y, 0) +#define curlssl_data_pending(x,y) ((void)x, (void)y, 0) #define curlssl_random(x,y,z) Curl_nss_random(x,y,z) #define curlssl_md5sum(a,b,c,d) Curl_nss_md5sum(a,b,c,d) -#define CURL_SSL_BACKEND CURLSSLBACKEND_NSS +#define curlssl_sha256sum(a,b,c,d) Curl_nss_sha256sum(a,b,c,d) +#define curlssl_cert_status_request() Curl_nss_cert_status_request() +#define curlssl_false_start() Curl_nss_false_start() #endif /* USE_NSS */ #endif /* HEADER_CURL_NSSG_H */ diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c index da92854..90e4c2b 100644 --- a/lib/vtls/openssl.c +++ b/lib/vtls/openssl.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -32,6 +32,8 @@ #include "curl_setup.h" +#ifdef USE_OPENSSL + #ifdef HAVE_LIMITS_H #include #endif @@ -49,13 +51,9 @@ #include "vtls.h" #include "rawstr.h" #include "hostcheck.h" +#include "curl_printf.h" -#define _MPRINTF_REPLACE /* use the internal *printf() functions */ -#include - -#ifdef USE_SSLEAY - -#ifdef USE_OPENSSL +#include #include #include #include @@ -63,36 +61,29 @@ #include #include #include -#else -#include -#include -#include +#include +#include + +#ifdef HAVE_OPENSSL_PKCS12_H +#include +#endif + +#if (OPENSSL_VERSION_NUMBER >= 0x0090808fL) && !defined(OPENSSL_IS_BORINGSSL) +#include #endif #include "warnless.h" -#include "curl_memory.h" #include "non-ascii.h" /* for Curl_convert_from_utf8 prototype */ -/* The last #include file should be: */ +/* The last #include files should be: */ +#include "curl_memory.h" #include "memdebug.h" #ifndef OPENSSL_VERSION_NUMBER #error "OPENSSL_VERSION_NUMBER not defined" #endif -#if OPENSSL_VERSION_NUMBER >= 0x0090581fL -#define HAVE_SSL_GET1_SESSION 1 -#else -#undef HAVE_SSL_GET1_SESSION -#endif - -#if OPENSSL_VERSION_NUMBER >= 0x00904100L -#define HAVE_USERDATA_IN_PWD_CALLBACK 1 -#else -#undef HAVE_USERDATA_IN_PWD_CALLBACK -#endif - -#if OPENSSL_VERSION_NUMBER >= 0x00907001L +#if OPENSSL_VERSION_NUMBER >= 0x00907001L && !defined(OPENSSL_IS_BORINGSSL) /* ENGINE_load_private_key() takes four arguments */ #define HAVE_ENGINE_LOAD_FOUR_ARGS #include @@ -101,18 +92,16 @@ #undef HAVE_ENGINE_LOAD_FOUR_ARGS #endif -#if (OPENSSL_VERSION_NUMBER >= 0x00903001L) && defined(HAVE_OPENSSL_PKCS12_H) -/* OpenSSL has PKCS 12 support */ +#if (OPENSSL_VERSION_NUMBER >= 0x00903001L) && \ + defined(HAVE_OPENSSL_PKCS12_H) && \ + !defined(OPENSSL_IS_BORINGSSL) +/* OpenSSL has PKCS 12 support, BoringSSL does not */ #define HAVE_PKCS12_SUPPORT #else -/* OpenSSL/SSLEay does not have PKCS12 support */ +/* OpenSSL does not have PKCS12 support */ #undef HAVE_PKCS12_SUPPORT #endif -#if OPENSSL_VERSION_NUMBER >= 0x00906001L -#define HAVE_ERR_ERROR_STRING_N 1 -#endif - #if OPENSSL_VERSION_NUMBER >= 0x00909000L #define SSL_METHOD_QUAL const #else @@ -126,15 +115,32 @@ #define X509_STORE_set_flags(x,y) Curl_nop_stmt #endif -#if OPENSSL_VERSION_NUMBER >= 0x10000000L +#ifdef OPENSSL_IS_BORINGSSL +/* BoringSSL has no ERR_remove_state() */ +#define ERR_remove_state(x) +#elif (OPENSSL_VERSION_NUMBER >= 0x10000000L) #define HAVE_ERR_REMOVE_THREAD_STATE 1 #endif -#ifndef HAVE_SSLV2_CLIENT_METHOD +#if !defined(HAVE_SSLV2_CLIENT_METHOD) || \ + OPENSSL_VERSION_NUMBER >= 0x10100000L /* 1.1.0+ has no SSLv2 */ #undef OPENSSL_NO_SSL2 /* undef first to avoid compiler warnings */ #define OPENSSL_NO_SSL2 #endif +#if defined(OPENSSL_IS_BORINGSSL) +#define NO_RAND_SEED 1 +/* In BoringSSL OpenSSL_add_all_algorithms does nothing */ +#define OpenSSL_add_all_algorithms() +/* BoringSSL does not have CONF_modules_load_file */ +#define CONF_modules_load_file(a,b,c) +#endif + +#if (OPENSSL_VERSION_NUMBER < 0x0090808fL) || defined(OPENSSL_IS_BORINGSSL) +/* not present in BoringSSL or older OpenSSL */ +#define OPENSSL_load_builtin_modules(x) +#endif + /* * Number of bytes to read from the random number seed file. This must be * a finite value (because some entropy "files" like /dev/urandom have @@ -143,18 +149,8 @@ */ #define RAND_LOAD_LENGTH 1024 -#ifndef HAVE_USERDATA_IN_PWD_CALLBACK -static char global_passwd[64]; -#endif - -static int passwd_callback(char *buf, int num, int encrypting -#ifdef HAVE_USERDATA_IN_PWD_CALLBACK - /* This was introduced in 0.9.4, we can set this - using SSL_CTX_set_default_passwd_cb_userdata() - */ - , void *global_passwd -#endif - ) +static int passwd_callback(char *buf, int num, int encrypting, + void *global_passwd) { DEBUGASSERT(0 == encrypting); @@ -175,6 +171,7 @@ static int passwd_callback(char *buf, int num, int encrypting * pass in an argument that is never used. */ +#ifndef NO_RAND_SEED #ifdef HAVE_RAND_STATUS #define seed_enough(x) rand_enough() static bool rand_enough(void) @@ -259,7 +256,7 @@ static int ossl_seed(struct SessionHandle *data) return nread; } -static int Curl_ossl_seed(struct SessionHandle *data) +static void Curl_ossl_seed(struct SessionHandle *data) { /* we have the "SSL is seeded" boolean static to prevent multiple time-consuming seedings in vain */ @@ -270,8 +267,11 @@ static int Curl_ossl_seed(struct SessionHandle *data) ossl_seed(data); ssl_seeded = TRUE; } - return 0; } +#else +/* BoringSSL needs no seeding */ +#define Curl_ossl_seed(x) +#endif #ifndef SSL_FILETYPE_ENGINE @@ -308,8 +308,7 @@ static int ssl_ui_reader(UI *ui, UI_STRING *uis) case UIT_PROMPT: case UIT_VERIFY: password = (const char*)UI_get0_user_data(ui); - if(NULL != password && - UI_get_input_flags(uis) & UI_INPUT_FLAG_DEFAULT_PWD) { + if(password && (UI_get_input_flags(uis) & UI_INPUT_FLAG_DEFAULT_PWD)) { UI_set_result(ui, uis, password); return 1; } @@ -327,8 +326,8 @@ static int ssl_ui_writer(UI *ui, UI_STRING *uis) switch(UI_get_string_type(uis)) { case UIT_PROMPT: case UIT_VERIFY: - if(NULL != UI_get0_user_data(ui) && - UI_get_input_flags(uis) & UI_INPUT_FLAG_DEFAULT_PWD) { + if(UI_get0_user_data(ui) && + (UI_get_input_flags(uis) & UI_INPUT_FLAG_DEFAULT_PWD)) { return 1; } default: @@ -350,43 +349,29 @@ int cert_stuff(struct connectdata *conn, int file_type = do_file_type(cert_type); - if(cert_file != NULL || file_type == SSL_FILETYPE_ENGINE) { + if(cert_file || (file_type == SSL_FILETYPE_ENGINE)) { SSL *ssl; X509 *x509; int cert_done = 0; if(data->set.str[STRING_KEY_PASSWD]) { -#ifndef HAVE_USERDATA_IN_PWD_CALLBACK - /* - * If password has been given, we store that in the global - * area (*shudder*) for a while: - */ - size_t len = strlen(data->set.str[STRING_KEY_PASSWD]); - if(len < sizeof(global_passwd)) - memcpy(global_passwd, data->set.str[STRING_KEY_PASSWD], len+1); - else - global_passwd[0] = '\0'; -#else - /* - * We set the password in the callback userdata - */ + /* set the password in the callback userdata */ SSL_CTX_set_default_passwd_cb_userdata(ctx, data->set.str[STRING_KEY_PASSWD]); -#endif /* Set passwd callback: */ SSL_CTX_set_default_passwd_cb(ctx, passwd_callback); } -#define SSL_CLIENT_CERT_ERR \ - "unable to use client certificate (no key found or wrong pass phrase?)" - switch(file_type) { case SSL_FILETYPE_PEM: /* SSL_CTX_use_certificate_chain_file() only works on PEM files */ if(SSL_CTX_use_certificate_chain_file(ctx, cert_file) != 1) { - failf(data, SSL_CLIENT_CERT_ERR); + failf(data, + "could not load PEM client certificate, OpenSSL error %s, " + "(no key found, wrong pass phrase, or wrong file format?)", + ERR_error_string(ERR_get_error(), NULL) ); return 0; } break; @@ -398,7 +383,10 @@ int cert_stuff(struct connectdata *conn, if(SSL_CTX_use_certificate_file(ctx, cert_file, file_type) != 1) { - failf(data, SSL_CLIENT_CERT_ERR); + failf(data, + "could not load ASN1 client certificate, OpenSSL error %s, " + "(no key found, wrong pass phrase, or wrong file format?)", + ERR_error_string(ERR_get_error(), NULL) ); return 0; } break; @@ -464,7 +452,7 @@ int cert_stuff(struct connectdata *conn, STACK_OF(X509) *ca = NULL; int i; - f = fopen(cert_file,"rb"); + f = fopen(cert_file, "rb"); if(!f) { failf(data, "could not open PKCS12 file '%s'", cert_file); return 0; @@ -473,7 +461,7 @@ int cert_stuff(struct connectdata *conn, fclose(f); if(!p12) { - failf(data, "error reading PKCS12 file '%s'", cert_file ); + failf(data, "error reading PKCS12 file '%s'", cert_file); return 0; } @@ -491,7 +479,9 @@ int cert_stuff(struct connectdata *conn, PKCS12_free(p12); if(SSL_CTX_use_certificate(ctx, x509) != 1) { - failf(data, SSL_CLIENT_CERT_ERR); + failf(data, + "could not load PKCS12 client certificate, OpenSSL error %s", + ERR_error_string(ERR_get_error(), NULL) ); goto fail; } @@ -556,7 +546,7 @@ int cert_stuff(struct connectdata *conn, case SSL_FILETYPE_PEM: if(cert_done) break; - if(key_file == NULL) + if(!key_file) /* cert & key can only be in PEM case in the same file */ key_file=cert_file; case SSL_FILETYPE_ASN1: @@ -574,7 +564,7 @@ int cert_stuff(struct connectdata *conn, #ifdef HAVE_ENGINE_LOAD_FOUR_ARGS UI_METHOD *ui_method = UI_create_method((char *)"cURL user interface"); - if(NULL == ui_method) { + if(!ui_method) { failf(data, "unable do create OpenSSL user-interface method"); return 0; } @@ -585,7 +575,7 @@ int cert_stuff(struct connectdata *conn, #endif /* the typecast below was added to please mingw32 */ priv_key = (EVP_PKEY *) - ENGINE_load_private_key(data->state.engine,key_file, + ENGINE_load_private_key(data->state.engine, key_file, #ifdef HAVE_ENGINE_LOAD_FOUR_ARGS ui_method, #endif @@ -626,8 +616,8 @@ int cert_stuff(struct connectdata *conn, } ssl=SSL_new(ctx); - if(NULL == ssl) { - failf(data,"unable to create an SSL structure"); + if(!ssl) { + failf(data, "unable to create an SSL structure"); return 0; } @@ -635,9 +625,9 @@ int cert_stuff(struct connectdata *conn, /* This version was provided by Evan Jordan and is supposed to not leak memory as the previous version: */ - if(x509 != NULL) { + if(x509) { EVP_PKEY *pktmp = X509_get_pubkey(x509); - EVP_PKEY_copy_parameters(pktmp,SSL_get_privatekey(ssl)); + EVP_PKEY_copy_parameters(pktmp, SSL_get_privatekey(ssl)); EVP_PKEY_free(pktmp); } @@ -653,10 +643,6 @@ int cert_stuff(struct connectdata *conn, failf(data, "Private key does not match the certificate public key"); return 0; } -#ifndef HAVE_USERDATA_IN_PWD_CALLBACK - /* erase it now */ - memset(global_passwd, 0, sizeof(global_passwd)); -#endif } return 1; } @@ -691,36 +677,17 @@ static int x509_name_oneline(X509_NAME *a, char *buf, size_t size) #endif } -static -int cert_verify_callback(int ok, X509_STORE_CTX *ctx) -{ - X509 *err_cert; - char buf[256]; - - err_cert=X509_STORE_CTX_get_current_cert(ctx); - (void)x509_name_oneline(X509_get_subject_name(err_cert), buf, sizeof(buf)); - return ok; -} - /* Return error string for last OpenSSL error */ static char *SSL_strerror(unsigned long error, char *buf, size_t size) { -#ifdef HAVE_ERR_ERROR_STRING_N /* OpenSSL 0.9.6 and later has a function named - ERRO_error_string_n() that takes the size of the buffer as a + ERR_error_string_n() that takes the size of the buffer as a third argument */ ERR_error_string_n(error, buf, size); -#else - (void) size; - ERR_error_string(error, buf); -#endif return buf; } -#endif /* USE_SSLEAY */ - -#ifdef USE_SSLEAY /** * Global SSL init * @@ -729,6 +696,8 @@ static char *SSL_strerror(unsigned long error, char *buf, size_t size) */ int Curl_ossl_init(void) { + OPENSSL_load_builtin_modules(); + #ifdef HAVE_ENGINE_LOAD_BUILTIN_ENGINES ENGINE_load_builtin_engines(); #endif @@ -749,17 +718,19 @@ int Curl_ossl_init(void) calls CONF_modules_load_file() and we use that instead and we ignore its return code! */ - (void)CONF_modules_load_file(NULL, NULL, - CONF_MFLAGS_DEFAULT_SECTION| - CONF_MFLAGS_IGNORE_MISSING_FILE); + /* CONF_MFLAGS_DEFAULT_SECTION introduced some time between 0.9.8b and + 0.9.8e */ +#ifndef CONF_MFLAGS_DEFAULT_SECTION +#define CONF_MFLAGS_DEFAULT_SECTION 0x0 +#endif + + CONF_modules_load_file(NULL, NULL, + CONF_MFLAGS_DEFAULT_SECTION| + CONF_MFLAGS_IGNORE_MISSING_FILE); return 1; } -#endif /* USE_SSLEAY */ - -#ifdef USE_SSLEAY - /* Global cleanup */ void Curl_ossl_cleanup(void) { @@ -814,7 +785,7 @@ int Curl_ossl_check_cxn(struct connectdata *conn) */ CURLcode Curl_ossl_set_engine(struct SessionHandle *data, const char *engine) { -#if defined(USE_SSLEAY) && defined(HAVE_OPENSSL_ENGINE_H) +#if defined(USE_OPENSSL) && defined(HAVE_OPENSSL_ENGINE_H) ENGINE *e; #if OPENSSL_VERSION_NUMBER >= 0x00909000L @@ -862,7 +833,7 @@ CURLcode Curl_ossl_set_engine_default(struct SessionHandle *data) #ifdef HAVE_OPENSSL_ENGINE_H if(data->state.engine) { if(ENGINE_set_default(data->state.engine, ENGINE_METHOD_ALL) > 0) { - infof(data,"set default crypto engine '%s'\n", + infof(data, "set default crypto engine '%s'\n", ENGINE_get_id(data->state.engine)); } else { @@ -882,7 +853,7 @@ CURLcode Curl_ossl_set_engine_default(struct SessionHandle *data) struct curl_slist *Curl_ossl_engines_list(struct SessionHandle *data) { struct curl_slist *list = NULL; -#if defined(USE_SSLEAY) && defined(HAVE_OPENSSL_ENGINE_H) +#if defined(USE_OPENSSL) && defined(HAVE_OPENSSL_ENGINE_H) struct curl_slist *beg; ENGINE *e; @@ -1031,7 +1002,7 @@ void Curl_ossl_session_free(void *ptr) * This function is called when the 'data' struct is going away. Close * down everything and free all resources! */ -int Curl_ossl_close_all(struct SessionHandle *data) +void Curl_ossl_close_all(struct SessionHandle *data) { #ifdef HAVE_OPENSSL_ENGINE_H if(data->state.engine) { @@ -1042,7 +1013,6 @@ int Curl_ossl_close_all(struct SessionHandle *data) #else (void)data; #endif - return 0; } static int asn1_output(const ASN1_UTCTIME *tm, @@ -1052,7 +1022,7 @@ static int asn1_output(const ASN1_UTCTIME *tm, const char *asn1_string; int gmt=FALSE; int i; - int year=0,month=0,day=0,hour=0,minute=0,second=0; + int year=0, month=0, day=0, hour=0, minute=0, second=0; i=tm->length; asn1_string=(const char *)tm->data; @@ -1112,8 +1082,7 @@ static int asn1_output(const ASN1_UTCTIME *tm, in the certificate and must exactly match the IP in the URI. */ -static CURLcode verifyhost(struct connectdata *conn, - X509 *server_cert) +static CURLcode verifyhost(struct connectdata *conn, X509 *server_cert) { int matched = -1; /* -1 is no alternative match yet, 1 means match and 0 means mismatch */ @@ -1126,7 +1095,7 @@ static CURLcode verifyhost(struct connectdata *conn, #else struct in_addr addr; #endif - CURLcode res = CURLE_OK; + CURLcode result = CURLE_OK; #ifdef ENABLE_IPV6 if(conn->bits.ipv6_ip && @@ -1207,19 +1176,19 @@ static CURLcode verifyhost(struct connectdata *conn, infof(data, "\t subjectAltName does not match %s\n", conn->host.dispname); failf(data, "SSL: no alternative certificate subject name matches " "target host name '%s'", conn->host.dispname); - res = CURLE_PEER_FAILED_VERIFICATION; + result = CURLE_PEER_FAILED_VERIFICATION; } else { /* we have to look to the last occurrence of a commonName in the distinguished one to get the most significant one. */ - int j,i=-1 ; + int j, i=-1; /* The following is done because of a bug in 0.9.6b */ unsigned char *nulstr = (unsigned char *)""; unsigned char *peer_CN = nulstr; - X509_NAME *name = X509_get_subject_name(server_cert) ; + X509_NAME *name = X509_get_subject_name(server_cert); if(name) while((j = X509_NAME_get_index_by_NID(name, NID_commonName, i))>=0) i=j; @@ -1229,7 +1198,8 @@ static CURLcode verifyhost(struct connectdata *conn, UTF8 etc. */ if(i>=0) { - ASN1_STRING *tmp = X509_NAME_ENTRY_get_data(X509_NAME_get_entry(name,i)); + ASN1_STRING *tmp = + X509_NAME_ENTRY_get_data(X509_NAME_get_entry(name, i)); /* In OpenSSL 0.9.7d and earlier, ASN1_STRING_to_UTF8 fails if the input is already UTF-8 encoded. We check for this case and copy the raw @@ -1254,7 +1224,7 @@ static CURLcode verifyhost(struct connectdata *conn, /* there was a terminating zero before the end of string, this cannot match and we return failure! */ failf(data, "SSL: illegal cert name field"); - res = CURLE_PEER_FAILED_VERIFICATION; + result = CURLE_PEER_FAILED_VERIFICATION; } } } @@ -1271,18 +1241,18 @@ static CURLcode verifyhost(struct connectdata *conn, } } - if(res) + if(result) /* error already detected, pass through */ ; else if(!peer_CN) { failf(data, "SSL: unable to obtain common name from peer certificate"); - res = CURLE_PEER_FAILED_VERIFICATION; + result = CURLE_PEER_FAILED_VERIFICATION; } else if(!Curl_cert_hostcheck((const char *)peer_CN, conn->host.name)) { failf(data, "SSL: certificate subject name '%s' does not match " "target host name '%s'", peer_CN, conn->host.dispname); - res = CURLE_PEER_FAILED_VERIFICATION; + result = CURLE_PEER_FAILED_VERIFICATION; } else { infof(data, "\t common name: %s (matched)\n", peer_CN); @@ -1290,9 +1260,138 @@ static CURLcode verifyhost(struct connectdata *conn, if(peer_CN) OPENSSL_free(peer_CN); } - return res; + + return result; +} + +#if (OPENSSL_VERSION_NUMBER >= 0x0090808fL) && !defined(OPENSSL_NO_TLSEXT) && \ + !defined(OPENSSL_IS_BORINGSSL) +static CURLcode verifystatus(struct connectdata *conn, + struct ssl_connect_data *connssl) +{ + int i, ocsp_status; + const unsigned char *p; + CURLcode result = CURLE_OK; + struct SessionHandle *data = conn->data; + + OCSP_RESPONSE *rsp = NULL; + OCSP_BASICRESP *br = NULL; + X509_STORE *st = NULL; + STACK_OF(X509) *ch = NULL; + + long len = SSL_get_tlsext_status_ocsp_resp(connssl->handle, &p); + + if(!p) { + failf(data, "No OCSP response received"); + result = CURLE_SSL_INVALIDCERTSTATUS; + goto end; + } + + rsp = d2i_OCSP_RESPONSE(NULL, &p, len); + if(!rsp) { + failf(data, "Invalid OCSP response"); + result = CURLE_SSL_INVALIDCERTSTATUS; + goto end; + } + + ocsp_status = OCSP_response_status(rsp); + if(ocsp_status != OCSP_RESPONSE_STATUS_SUCCESSFUL) { + failf(data, "Invalid OCSP response status: %s (%d)", + OCSP_response_status_str(ocsp_status), ocsp_status); + result = CURLE_SSL_INVALIDCERTSTATUS; + goto end; + } + + br = OCSP_response_get1_basic(rsp); + if(!br) { + failf(data, "Invalid OCSP response"); + result = CURLE_SSL_INVALIDCERTSTATUS; + goto end; + } + + ch = SSL_get_peer_cert_chain(connssl->handle); + st = SSL_CTX_get_cert_store(connssl->ctx); + +#if ((OPENSSL_VERSION_NUMBER <= 0x1000201fL) /* Fixed after 1.0.2a */ || \ + defined(LIBRESSL_VERSION_NUMBER)) + /* The authorized responder cert in the OCSP response MUST be signed by the + peer cert's issuer (see RFC6960 section 4.2.2.2). If that's a root cert, + no problem, but if it's an intermediate cert OpenSSL has a bug where it + expects this issuer to be present in the chain embedded in the OCSP + response. So we add it if necessary. */ + + /* First make sure the peer cert chain includes both a peer and an issuer, + and the OCSP response contains a responder cert. */ + if(sk_X509_num(ch) >= 2 && sk_X509_num(br->certs) >= 1) { + X509 *responder = sk_X509_value(br->certs, sk_X509_num(br->certs) - 1); + + /* Find issuer of responder cert and add it to the OCSP response chain */ + for(i = 0; i < sk_X509_num(ch); i++) { + X509 *issuer = sk_X509_value(ch, i); + if(X509_check_issued(issuer, responder) == X509_V_OK) { + if(!OCSP_basic_add1_cert(br, issuer)) { + failf(data, "Could not add issuer cert to OCSP response"); + result = CURLE_SSL_INVALIDCERTSTATUS; + goto end; + } + } + } + } +#endif + + if(OCSP_basic_verify(br, ch, st, 0) <= 0) { + failf(data, "OCSP response verification failed"); + result = CURLE_SSL_INVALIDCERTSTATUS; + goto end; + } + + for(i = 0; i < OCSP_resp_count(br); i++) { + int cert_status, crl_reason; + OCSP_SINGLERESP *single = NULL; + + ASN1_GENERALIZEDTIME *rev, *thisupd, *nextupd; + + if(!(single = OCSP_resp_get0(br, i))) + continue; + + cert_status = OCSP_single_get0_status(single, &crl_reason, &rev, + &thisupd, &nextupd); + + if(!OCSP_check_validity(thisupd, nextupd, 300L, -1L)) { + failf(data, "OCSP response has expired"); + result = CURLE_SSL_INVALIDCERTSTATUS; + goto end; + } + + infof(data, "SSL certificate status: %s (%d)\n", + OCSP_cert_status_str(cert_status), cert_status); + + switch(cert_status) { + case V_OCSP_CERTSTATUS_GOOD: + break; + + case V_OCSP_CERTSTATUS_REVOKED: + result = CURLE_SSL_INVALIDCERTSTATUS; + + failf(data, "SSL certificate revocation reason: %s (%d)", + OCSP_crl_reason_str(crl_reason), crl_reason); + goto end; + + case V_OCSP_CERTSTATUS_UNKNOWN: + result = CURLE_SSL_INVALIDCERTSTATUS; + goto end; + } + } + +end: + if(br) OCSP_BASICRESP_free(br); + OCSP_RESPONSE_free(rsp); + + return result; } -#endif /* USE_SSLEAY */ +#endif + +#endif /* USE_OPENSSL */ /* The SSL_CTRL_SET_MSG_CALLBACK doesn't exist in ancient OpenSSL versions and thus this cannot be done there. */ @@ -1300,6 +1399,7 @@ static CURLcode verifyhost(struct connectdata *conn, static const char *ssl_msg_type(int ssl_ver, int msg) { +#ifdef SSL2_VERSION_MAJOR if(ssl_ver == SSL2_VERSION_MAJOR) { switch (msg) { case SSL2_MT_ERROR: @@ -1322,7 +1422,9 @@ static const char *ssl_msg_type(int ssl_ver, int msg) return "Client CERT"; } } - else if(ssl_ver == SSL3_VERSION_MAJOR) { + else +#endif + if(ssl_ver == SSL3_VERSION_MAJOR) { switch (msg) { case SSL3_MT_HELLO_REQUEST: return "Hello request"; @@ -1330,8 +1432,12 @@ static const char *ssl_msg_type(int ssl_ver, int msg) return "Client hello"; case SSL3_MT_SERVER_HELLO: return "Server hello"; +#ifdef SSL3_MT_NEWSESSION_TICKET + case SSL3_MT_NEWSESSION_TICKET: + return "Newsession Ticket"; +#endif case SSL3_MT_CERTIFICATE: - return "CERT"; + return "Certificate"; case SSL3_MT_SERVER_KEY_EXCHANGE: return "Server key exchange"; case SSL3_MT_CLIENT_KEY_EXCHANGE: @@ -1344,6 +1450,10 @@ static const char *ssl_msg_type(int ssl_ver, int msg) return "CERT verify"; case SSL3_MT_FINISHED: return "Finished"; +#ifdef SSL3_MT_CERTIFICATE_STATUS + case SSL3_MT_CERTIFICATE_STATUS: + return "Certificate Status"; +#endif } } return "Unknown"; @@ -1351,12 +1461,22 @@ static const char *ssl_msg_type(int ssl_ver, int msg) static const char *tls_rt_type(int type) { - return ( - type == SSL3_RT_CHANGE_CIPHER_SPEC ? "TLS change cipher, " : - type == SSL3_RT_ALERT ? "TLS alert, " : - type == SSL3_RT_HANDSHAKE ? "TLS handshake, " : - type == SSL3_RT_APPLICATION_DATA ? "TLS app data, " : - "TLS Unknown, "); + switch(type) { +#ifdef SSL3_RT_HEADER + case SSL3_RT_HEADER: + return "TLS header"; +#endif + case SSL3_RT_CHANGE_CIPHER_SPEC: + return "TLS change cipher"; + case SSL3_RT_ALERT: + return "TLS alert"; + case SSL3_RT_HANDSHAKE: + return "TLS handshake"; + case SSL3_RT_APPLICATION_DATA: + return "TLS app data"; + default: + return "TLS Unknown"; + } } @@ -1364,38 +1484,77 @@ static const char *tls_rt_type(int type) * Our callback from the SSL/TLS layers. */ static void ssl_tls_trace(int direction, int ssl_ver, int content_type, - const void *buf, size_t len, const SSL *ssl, - struct connectdata *conn) + const void *buf, size_t len, SSL *ssl, + void *userp) { struct SessionHandle *data; const char *msg_name, *tls_rt_name; char ssl_buf[1024]; - int ver, msg_type, txt_len; + char unknown[32]; + int msg_type, txt_len; + const char *verstr = NULL; + struct connectdata *conn = userp; if(!conn || !conn->data || !conn->data->set.fdebug || (direction != 0 && direction != 1)) return; data = conn->data; - ssl_ver >>= 8; - ver = (ssl_ver == SSL2_VERSION_MAJOR ? '2' : - ssl_ver == SSL3_VERSION_MAJOR ? '3' : '?'); - /* SSLv2 doesn't seem to have TLS record-type headers, so OpenSSL - * always pass-up content-type as 0. But the interesting message-type - * is at 'buf[0]'. - */ - if(ssl_ver == SSL3_VERSION_MAJOR && content_type != 0) - tls_rt_name = tls_rt_type(content_type); - else - tls_rt_name = ""; + switch(ssl_ver) { +#ifdef SSL2_VERSION /* removed in recent versions */ + case SSL2_VERSION: + verstr = "SSLv2"; + break; +#endif +#ifdef SSL3_VERSION + case SSL3_VERSION: + verstr = "SSLv3"; + break; +#endif + case TLS1_VERSION: + verstr = "TLSv1.0"; + break; +#ifdef TLS1_1_VERSION + case TLS1_1_VERSION: + verstr = "TLSv1.1"; + break; +#endif +#ifdef TLS1_2_VERSION + case TLS1_2_VERSION: + verstr = "TLSv1.2"; + break; +#endif + case 0: + break; + default: + snprintf(unknown, sizeof(unknown), "(%x)", ssl_ver); + verstr = unknown; + break; + } + + if(ssl_ver) { + /* the info given when the version is zero is not that useful for us */ + + ssl_ver >>= 8; /* check the upper 8 bits only below */ - msg_type = *(char*)buf; - msg_name = ssl_msg_type(ssl_ver, msg_type); + /* SSLv2 doesn't seem to have TLS record-type headers, so OpenSSL + * always pass-up content-type as 0. But the interesting message-type + * is at 'buf[0]'. + */ + if(ssl_ver == SSL3_VERSION_MAJOR && content_type) + tls_rt_name = tls_rt_type(content_type); + else + tls_rt_name = ""; - txt_len = snprintf(ssl_buf, sizeof(ssl_buf), "SSLv%c, %s%s (%d):\n", - ver, tls_rt_name, msg_name, msg_type); - Curl_debug(data, CURLINFO_TEXT, ssl_buf, (size_t)txt_len, NULL); + msg_type = *(char*)buf; + msg_name = ssl_msg_type(ssl_ver, msg_type); + + txt_len = snprintf(ssl_buf, sizeof(ssl_buf), "%s (%s), %s, %s (%d):\n", + verstr, direction?"OUT":"IN", + tls_rt_name, msg_name, msg_type); + Curl_debug(data, CURLINFO_TEXT, ssl_buf, (size_t)txt_len, NULL); + } Curl_debug(data, (direction == 1) ? CURLINFO_SSL_DATA_OUT : CURLINFO_SSL_DATA_IN, (char *)buf, len, NULL); @@ -1403,7 +1562,7 @@ static void ssl_tls_trace(int direction, int ssl_ver, int content_type, } #endif -#ifdef USE_SSLEAY +#ifdef USE_OPENSSL /* ====================================================== */ #ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME @@ -1412,26 +1571,44 @@ static void ssl_tls_trace(int direction, int ssl_ver, int content_type, # define use_sni(x) Curl_nop_stmt #endif -#ifdef USE_NGHTTP2 - +/* Check for OpenSSL 1.0.2 which has ALPN support. */ #undef HAS_ALPN -#if defined(HAVE_SSL_CTX_SET_ALPN_PROTOS) && \ - defined(HAVE_SSL_CTX_SET_ALPN_SELECT_CB) +#if OPENSSL_VERSION_NUMBER >= 0x10002000L \ + && !defined(OPENSSL_NO_TLSEXT) # define HAS_ALPN 1 #endif -#if !defined(HAVE_SSL_CTX_SET_NEXT_PROTO_SELECT_CB) || \ - defined(OPENSSL_NO_NEXTPROTONEG) -# if !defined(HAS_ALPN) -# error http2 builds require OpenSSL with NPN or ALPN support -# endif +/* Check for OpenSSL 1.0.1 which has NPN support. */ +#undef HAS_NPN +#if OPENSSL_VERSION_NUMBER >= 0x10001000L \ + && !defined(OPENSSL_NO_TLSEXT) \ + && !defined(OPENSSL_NO_NEXTPROTONEG) +# define HAS_NPN 1 #endif +#ifdef HAS_NPN /* * in is a list of lenght prefixed strings. this function has to select * the protocol we want to use from the list and write its string into out. */ + +static int +select_next_protocol(unsigned char **out, unsigned char *outlen, + const unsigned char *in, unsigned int inlen, + const char *key, unsigned int keylen) +{ + unsigned int i; + for(i = 0; i + keylen <= inlen; i += in[i] + 1) { + if(memcmp(&in[i + 1], key, keylen) == 0) { + *out = (unsigned char *) &in[i + 1]; + *outlen = in[i]; + return 0; + } + } + return -1; +} + static int select_next_proto_cb(SSL *ssl, unsigned char **out, unsigned char *outlen, @@ -1439,37 +1616,43 @@ select_next_proto_cb(SSL *ssl, void *arg) { struct connectdata *conn = (struct connectdata*) arg; - int retval = nghttp2_select_next_protocol(out, outlen, in, inlen); + (void)ssl; - if(retval == 1) { +#ifdef USE_NGHTTP2 + if(conn->data->set.httpversion == CURL_HTTP_VERSION_2_0 && + !select_next_protocol(out, outlen, in, inlen, NGHTTP2_PROTO_VERSION_ID, + NGHTTP2_PROTO_VERSION_ID_LEN)) { infof(conn->data, "NPN, negotiated HTTP2 (%s)\n", NGHTTP2_PROTO_VERSION_ID); - conn->negnpn = NPN_HTTP2; + conn->negnpn = CURL_HTTP_VERSION_2_0; + return SSL_TLSEXT_ERR_OK; } - else if(retval == 0) { +#endif + + if(!select_next_protocol(out, outlen, in, inlen, ALPN_HTTP_1_1, + ALPN_HTTP_1_1_LENGTH)) { infof(conn->data, "NPN, negotiated HTTP1.1\n"); - conn->negnpn = NPN_HTTP1_1; - } - else { - infof(conn->data, "NPN, no overlap, use HTTP1.1\n", - NGHTTP2_PROTO_VERSION_ID); - *out = (unsigned char*)"http/1.1"; - *outlen = sizeof("http/1.1") - 1; - conn->negnpn = NPN_HTTP1_1; + conn->negnpn = CURL_HTTP_VERSION_1_1; + return SSL_TLSEXT_ERR_OK; } + infof(conn->data, "NPN, no overlap, use HTTP1.1\n"); + *out = (unsigned char *)ALPN_HTTP_1_1; + *outlen = ALPN_HTTP_1_1_LENGTH; + conn->negnpn = CURL_HTTP_VERSION_1_1; + return SSL_TLSEXT_ERR_OK; } -#endif +#endif /* HAS_NPN */ static const char * -get_ssl_version_txt(SSL_SESSION *session) +get_ssl_version_txt(SSL *ssl) { - if(NULL == session) + if(!ssl) return ""; - switch(session->ssl_version) { + switch(SSL_version(ssl)) { #if OPENSSL_VERSION_NUMBER >= 0x1000100FL case TLS1_2_VERSION: return "TLSv1.2"; @@ -1486,17 +1669,14 @@ get_ssl_version_txt(SSL_SESSION *session) return "unknown"; } - -static CURLcode -ossl_connect_step1(struct connectdata *conn, - int sockindex) +static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex) { - CURLcode retcode = CURLE_OK; + CURLcode result = CURLE_OK; char *ciphers; struct SessionHandle *data = conn->data; - SSL_METHOD_QUAL SSL_METHOD *req_method=NULL; - void *ssl_sessionid=NULL; - X509_LOOKUP *lookup=NULL; + SSL_METHOD_QUAL SSL_METHOD *req_method = NULL; + void *ssl_sessionid = NULL; + X509_LOOKUP *lookup = NULL; curl_socket_t sockfd = conn->sock[sockindex]; struct ssl_connect_data *connssl = &conn->ssl[sockindex]; long ctx_options; @@ -1508,9 +1688,6 @@ ossl_connect_step1(struct connectdata *conn, struct in_addr addr; #endif #endif -#ifdef HAS_ALPN - unsigned char protocols[128]; -#endif DEBUGASSERT(ssl_connect_1 == connssl->connecting_state); @@ -1529,7 +1706,12 @@ ossl_connect_step1(struct connectdata *conn, case CURL_SSLVERSION_TLSv1_1: case CURL_SSLVERSION_TLSv1_2: /* it will be handled later with the context options */ +#if (OPENSSL_VERSION_NUMBER >= 0x10100000L) && \ + !defined(LIBRESSL_VERSION_NUMBER) && !defined(OPENSSL_IS_BORINGSSL) + req_method = TLS_client_method(); +#else req_method = SSLv23_client_method(); +#endif use_sni(TRUE); break; case CURL_SSLVERSION_SSLv2: @@ -1546,6 +1728,10 @@ ossl_connect_step1(struct connectdata *conn, break; #endif case CURL_SSLVERSION_SSLv3: +#ifdef OPENSSL_NO_SSL3_METHOD + failf(data, "OpenSSL was built without SSLv3 support"); + return CURLE_NOT_BUILT_IN; +#else #ifdef USE_TLS_SRP if(data->set.ssl.authtype == CURL_TLSAUTH_SRP) return CURLE_SSL_CONNECT_ERROR; @@ -1553,6 +1739,7 @@ ossl_connect_step1(struct connectdata *conn, req_method = SSLv3_client_method(); use_sni(FALSE); break; +#endif } if(connssl->ctx) @@ -1571,16 +1758,9 @@ ossl_connect_step1(struct connectdata *conn, #ifdef SSL_CTRL_SET_MSG_CALLBACK if(data->set.fdebug && data->set.verbose) { - /* the SSL trace callback is only used for verbose logging so we only - inform about failures of setting it */ - if(!SSL_CTX_callback_ctrl(connssl->ctx, SSL_CTRL_SET_MSG_CALLBACK, - (void (*)(void))ssl_tls_trace)) { - infof(data, "SSL: couldn't set callback!\n"); - } - else if(!SSL_CTX_ctrl(connssl->ctx, SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, - conn)) { - infof(data, "SSL: couldn't set callback argument!\n"); - } + /* the SSL trace callback is only used for verbose logging */ + SSL_CTX_set_msg_callback(connssl->ctx, ssl_tls_trace); + SSL_CTX_set_msg_callback_arg(connssl->ctx, conn); } #endif @@ -1593,7 +1773,7 @@ ossl_connect_step1(struct connectdata *conn, The "-no_ticket" option was introduced in Openssl0.9.8j. It's a flag to disable "rfc4507bis session ticket support". rfc4507bis was later turned - into the proper RFC5077 it seems: http://tools.ietf.org/html/rfc5077 + into the proper RFC5077 it seems: https://tools.ietf.org/html/rfc5077 The enabled extension concerns the session management. I wonder how often libcurl stops a connection and then resumes a TLS session. also, sending @@ -1613,7 +1793,7 @@ ossl_connect_step1(struct connectdata *conn, this option regardless of OpenSSL version and SSL_OP_ALL definition. OpenSSL added a work-around for a SSL 3.0/TLS 1.0 CBC vulnerability - (http://www.openssl.org/~bodo/tls-cbc.txt). In 0.9.6e they added a bit to + (https://www.openssl.org/~bodo/tls-cbc.txt). In 0.9.6e they added a bit to SSL_OP_ALL that _disables_ that work-around despite the fact that SSL_OP_ALL is documented to do "rather harmless" workarounds. In order to keep the secure work-around, the SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS bit @@ -1643,17 +1823,12 @@ ossl_connect_step1(struct connectdata *conn, #endif switch(data->set.ssl.version) { - case CURL_SSLVERSION_DEFAULT: - ctx_options |= SSL_OP_NO_SSLv2; + case CURL_SSLVERSION_SSLv3: #ifdef USE_TLS_SRP if(data->set.ssl.authtype == CURL_TLSAUTH_SRP) { infof(data, "Set version TLSv1.x for SRP authorisation\n"); - ctx_options |= SSL_OP_NO_SSLv3; } #endif - break; - - case CURL_SSLVERSION_SSLv3: ctx_options |= SSL_OP_NO_SSLv2; ctx_options |= SSL_OP_NO_TLSv1; #if OPENSSL_VERSION_NUMBER >= 0x1000100FL @@ -1662,6 +1837,7 @@ ossl_connect_step1(struct connectdata *conn, #endif break; + case CURL_SSLVERSION_DEFAULT: case CURL_SSLVERSION_TLSv1: ctx_options |= SSL_OP_NO_SSLv2; ctx_options |= SSL_OP_NO_SSLv3; @@ -1710,33 +1886,36 @@ ossl_connect_step1(struct connectdata *conn, SSL_CTX_set_options(connssl->ctx, ctx_options); -#ifdef USE_NGHTTP2 - if(data->set.httpversion == CURL_HTTP_VERSION_2_0) { - if(data->set.ssl_enable_npn) { - SSL_CTX_set_next_proto_select_cb(connssl->ctx, select_next_proto_cb, - conn); - } +#ifdef HAS_NPN + if(data->set.ssl_enable_npn) + SSL_CTX_set_next_proto_select_cb(connssl->ctx, select_next_proto_cb, conn); +#endif #ifdef HAS_ALPN - if(data->set.ssl_enable_alpn) { - protocols[0] = NGHTTP2_PROTO_VERSION_ID_LEN; - memcpy(&protocols[1], NGHTTP2_PROTO_VERSION_ID, - NGHTTP2_PROTO_VERSION_ID_LEN); + if(data->set.ssl_enable_alpn) { + int cur = 0; + unsigned char protocols[128]; - protocols[NGHTTP2_PROTO_VERSION_ID_LEN+1] = ALPN_HTTP_1_1_LENGTH; - memcpy(&protocols[NGHTTP2_PROTO_VERSION_ID_LEN+2], ALPN_HTTP_1_1, - ALPN_HTTP_1_1_LENGTH); - - /* expects length prefixed preference ordered list of protocols in wire - * format - */ - SSL_CTX_set_alpn_protos(connssl->ctx, protocols, - NGHTTP2_PROTO_VERSION_ID_LEN + ALPN_HTTP_1_1_LENGTH + 2); +#ifdef USE_NGHTTP2 + if(data->set.httpversion == CURL_HTTP_VERSION_2_0) { + protocols[cur++] = NGHTTP2_PROTO_VERSION_ID_LEN; - infof(data, "ALPN, offering %s, %s\n", NGHTTP2_PROTO_VERSION_ID, - ALPN_HTTP_1_1); + memcpy(&protocols[cur], NGHTTP2_PROTO_VERSION_ID, + NGHTTP2_PROTO_VERSION_ID_LEN); + cur += NGHTTP2_PROTO_VERSION_ID_LEN; + infof(data, "ALPN, offering %s\n", NGHTTP2_PROTO_VERSION_ID); } #endif + + protocols[cur++] = ALPN_HTTP_1_1_LENGTH; + memcpy(&protocols[cur], ALPN_HTTP_1_1, ALPN_HTTP_1_1_LENGTH); + cur += ALPN_HTTP_1_1_LENGTH; + infof(data, "ALPN, offering %s\n", ALPN_HTTP_1_1); + + /* expects length prefixed preference ordered list of protocols in wire + * format + */ + SSL_CTX_set_alpn_protos(connssl->ctx, protocols, cur); } #endif @@ -1759,6 +1938,7 @@ ossl_connect_step1(struct connectdata *conn, failf(data, "failed setting cipher list: %s", ciphers); return CURLE_SSL_CIPHER; } + infof(data, "Cipher selection: %s\n", ciphers); #ifdef USE_TLS_SRP if(data->set.ssl.authtype == CURL_TLSAUTH_SRP) { @@ -1768,7 +1948,7 @@ ossl_connect_step1(struct connectdata *conn, failf(data, "Unable to set SRP user name"); return CURLE_BAD_FUNCTION_ARGUMENT; } - if(!SSL_CTX_set_srp_password(connssl->ctx,data->set.ssl.password)) { + if(!SSL_CTX_set_srp_password(connssl->ctx, data->set.ssl.password)) { failf(data, "failed setting SRP password"); return CURLE_BAD_FUNCTION_ARGUMENT; } @@ -1790,7 +1970,7 @@ ossl_connect_step1(struct connectdata *conn, data->set.str[STRING_SSL_CAPATH])) { if(data->set.ssl.verifypeer) { /* Fail if we insist on successfully verifying the server. */ - failf(data,"error setting certificate verify locations:\n" + failf(data, "error setting certificate verify locations:\n" " CAfile: %s\n CApath: %s", data->set.str[STRING_SSL_CAFILE]? data->set.str[STRING_SSL_CAFILE]: "none", @@ -1824,9 +2004,9 @@ ossl_connect_step1(struct connectdata *conn, lookup=X509_STORE_add_lookup(SSL_CTX_get_cert_store(connssl->ctx), X509_LOOKUP_file()); if(!lookup || - (!X509_load_crl_file(lookup,data->set.str[STRING_SSL_CRLFILE], + (!X509_load_crl_file(lookup, data->set.str[STRING_SSL_CRLFILE], X509_FILETYPE_PEM)) ) { - failf(data,"error loading CRL file: %s", + failf(data, "error loading CRL file: %s", data->set.str[STRING_SSL_CRLFILE]); return CURLE_SSL_CRL_BADFILE; } @@ -1841,21 +2021,35 @@ ossl_connect_step1(struct connectdata *conn, data->set.str[STRING_SSL_CRLFILE]: "none"); } + /* Try building a chain using issuers in the trusted store first to avoid + problems with server-sent legacy intermediates. + Newer versions of OpenSSL do alternate chain checking by default which + gives us the same fix without as much of a performance hit (slight), so we + prefer that if available. + https://rt.openssl.org/Ticket/Display.html?id=3621&user=guest&pass=guest + */ +#if defined(X509_V_FLAG_TRUSTED_FIRST) && !defined(X509_V_FLAG_NO_ALT_CHAINS) + if(data->set.ssl.verifypeer) { + X509_STORE_set_flags(SSL_CTX_get_cert_store(connssl->ctx), + X509_V_FLAG_TRUSTED_FIRST); + } +#endif + /* SSL always tries to verify the peer, this only says whether it should * fail to connect if the verification fails, or if it should continue * anyway. In the latter case the result of the verification is checked with * SSL_get_verify_result() below. */ SSL_CTX_set_verify(connssl->ctx, data->set.ssl.verifypeer?SSL_VERIFY_PEER:SSL_VERIFY_NONE, - cert_verify_callback); + NULL); /* give application a chance to interfere with SSL set up. */ if(data->set.ssl.fsslctx) { - retcode = (*data->set.ssl.fsslctx)(data, connssl->ctx, - data->set.ssl.fsslctxp); - if(retcode) { - failf(data,"error signaled by ssl ctx callback"); - return retcode; + result = (*data->set.ssl.fsslctx)(data, connssl->ctx, + data->set.ssl.fsslctxp); + if(result) { + failf(data, "error signaled by ssl ctx callback"); + return result; } } @@ -1867,6 +2061,13 @@ ossl_connect_step1(struct connectdata *conn, failf(data, "SSL: couldn't create a context (handle)!"); return CURLE_OUT_OF_MEMORY; } + +#if (OPENSSL_VERSION_NUMBER >= 0x0090808fL) && !defined(OPENSSL_NO_TLSEXT) && \ + !defined(OPENSSL_IS_BORINGSSL) + if(data->set.ssl.verifystatus) + SSL_set_tlsext_status_type(connssl->handle, TLSEXT_STATUSTYPE_ocsp); +#endif + SSL_set_connect_state(connssl->handle); connssl->server_cert = 0x0; @@ -1887,7 +2088,7 @@ ossl_connect_step1(struct connectdata *conn, /* we got a session id, use it! */ if(!SSL_set_session(connssl->handle, ssl_sessionid)) { failf(data, "SSL: SSL_set_session failed: %s", - ERR_error_string(ERR_get_error(),NULL)); + ERR_error_string(ERR_get_error(), NULL)); return CURLE_SSL_CONNECT_ERROR; } /* Informational message */ @@ -1897,16 +2098,16 @@ ossl_connect_step1(struct connectdata *conn, /* pass the raw socket into the SSL layers */ if(!SSL_set_fd(connssl->handle, (int)sockfd)) { failf(data, "SSL: SSL_set_fd failed: %s", - ERR_error_string(ERR_get_error(),NULL)); + ERR_error_string(ERR_get_error(), NULL)); return CURLE_SSL_CONNECT_ERROR; } connssl->connecting_state = ssl_connect_2; + return CURLE_OK; } -static CURLcode -ossl_connect_step2(struct connectdata *conn, int sockindex) +static CURLcode ossl_connect_step2(struct connectdata *conn, int sockindex) { struct SessionHandle *data = conn->data; int err; @@ -1936,10 +2137,9 @@ ossl_connect_step2(struct connectdata *conn, int sockindex) else { /* untreated error */ unsigned long errdetail; - char error_buffer[256]; /* OpenSSL documents that this must be at least - 256 bytes long. */ - CURLcode rc; - const char *cert_problem = NULL; + char error_buffer[256]=""; /* OpenSSL documents that this must be at + least 256 bytes long. */ + CURLcode result; long lerr; connssl->connecting_state = ssl_connect_2; /* the connection failed, @@ -1962,7 +2162,7 @@ ossl_connect_step2(struct connectdata *conn, int sockindex) SSL routines: SSL3_GET_SERVER_CERTIFICATE: certificate verify failed */ - rc = CURLE_SSL_CACERT; + result = CURLE_SSL_CACERT; lerr = SSL_get_verify_result(connssl->handle); if(lerr != X509_V_OK) { @@ -1971,12 +2171,13 @@ ossl_connect_step2(struct connectdata *conn, int sockindex) X509_verify_cert_error_string(lerr)); } else - cert_problem = "SSL certificate problem, verify that the CA cert is" - " OK."; - + /* strcpy() is fine here as long as the string fits within + error_buffer */ + strcpy(error_buffer, + "SSL certificate problem, check your CA cert"); break; default: - rc = CURLE_SSL_CONNECT_ERROR; + result = CURLE_SSL_CONNECT_ERROR; SSL_strerror(errdetail, error_buffer, sizeof(error_buffer)); break; } @@ -1987,15 +2188,16 @@ ossl_connect_step2(struct connectdata *conn, int sockindex) * (RST connection etc.), OpenSSL gives no explanation whatsoever and * the SO_ERROR is also lost. */ - if(CURLE_SSL_CONNECT_ERROR == rc && errdetail == 0) { + if(CURLE_SSL_CONNECT_ERROR == result && errdetail == 0) { failf(data, "Unknown SSL protocol error in connection to %s:%ld ", conn->host.name, conn->remote_port); - return rc; + return result; } + /* Could be a CERT problem */ + failf(data, "%s", error_buffer); - failf(data, "%s%s", cert_problem ? cert_problem : "", error_buffer); - return rc; + return result; } } else { @@ -2003,9 +2205,9 @@ ossl_connect_step2(struct connectdata *conn, int sockindex) connssl->connecting_state = ssl_connect_3; /* Informational message */ - infof (data, "SSL connection using %s / %s\n", - get_ssl_version_txt(SSL_get_session(connssl->handle)), - SSL_get_cipher(connssl->handle)); + infof(data, "SSL connection using %s / %s\n", + get_ssl_version_txt(connssl->handle), + SSL_get_cipher(connssl->handle)); #ifdef HAS_ALPN /* Sets data and len to negotiated protocol, len is 0 if no protocol was @@ -2018,18 +2220,20 @@ ossl_connect_step2(struct connectdata *conn, int sockindex) if(len != 0) { infof(data, "ALPN, server accepted to use %.*s\n", len, neg_protocol); +#ifdef USE_NGHTTP2 if(len == NGHTTP2_PROTO_VERSION_ID_LEN && - memcmp(NGHTTP2_PROTO_VERSION_ID, neg_protocol, len) == 0) { - conn->negnpn = NPN_HTTP2; + !memcmp(NGHTTP2_PROTO_VERSION_ID, neg_protocol, len)) { + conn->negnpn = CURL_HTTP_VERSION_2_0; } - else if(len == ALPN_HTTP_1_1_LENGTH && memcmp(ALPN_HTTP_1_1, - neg_protocol, ALPN_HTTP_1_1_LENGTH) == 0) { - conn->negnpn = NPN_HTTP1_1; + else +#endif + if(len == ALPN_HTTP_1_1_LENGTH && + !memcmp(ALPN_HTTP_1_1, neg_protocol, ALPN_HTTP_1_1_LENGTH)) { + conn->negnpn = CURL_HTTP_VERSION_1_1; } } - else { + else infof(data, "ALPN, server did not agree to a protocol\n"); - } } #endif @@ -2082,7 +2286,7 @@ static void pubkey_show(struct SessionHandle *data, #define print_pubkey_BN(_type, _name, _num) \ do { \ - if(pubkey->pkey._type->_name != NULL) { \ + if(pubkey->pkey._type->_name) { \ int len = BN_num_bytes(pubkey->pkey._type->_name); \ if(len < CERTBUFFERSIZE) { \ BN_bn2bin(pubkey->pkey._type->_name, (unsigned char*)bufp); \ @@ -2123,7 +2327,7 @@ static int X509V3_ext(struct SessionHandle *data, X509_EXTENSION_get_critical(ext)?"(critical)":""); if(!X509V3_EXT_print(bio_out, ext, 0, 0)) - M_ASN1_OCTET_STRING_print(bio_out, ext->value); + ASN1_STRING_print(bio_out, (ASN1_STRING *)X509_EXTENSION_get_data(ext)); BIO_get_mem_ptr(bio_out, &biomem); @@ -2160,6 +2364,7 @@ static void X509_signature(struct SessionHandle *data, char buf[1024]; char *ptr = buf; int i; + for(i=0; ilength; i++) ptr+=snprintf(ptr, sizeof(buf)-(ptr-buf), "%02x:", sig->data[i]); @@ -2182,7 +2387,6 @@ static void dumpcert(struct SessionHandle *data, X509 *x, int numcert) "Cert", biomem->data, biomem->length); BIO_free(bio_out); - } /* @@ -2196,6 +2400,7 @@ static CURLcode get_cert_chain(struct connectdata *conn, struct ssl_connect_data *connssl) { + CURLcode result; STACK_OF(X509) *sk; int i; char *bufp; @@ -2213,9 +2418,11 @@ static CURLcode get_cert_chain(struct connectdata *conn, } numcerts = sk_X509_num(sk); - if(Curl_ssl_init_certinfo(data, numcerts)) { + + result = Curl_ssl_init_certinfo(data, numcerts); + if(result) { free(bufp); - return CURLE_OUT_OF_MEMORY; + return result; } infof(data, "--- Certificate chain\n"); @@ -2250,28 +2457,22 @@ static CURLcode get_cert_chain(struct connectdata *conn, Curl_ssl_push_certinfo(data, i, "Version", bufp); /* hex */ num=X509_get_serialNumber(x); - if(num->length <= 4) { - value = ASN1_INTEGER_get(num); - infof(data," Serial Number: %ld (0x%lx)\n", value, value); - snprintf(bufp, CERTBUFFERSIZE, "%lx", value); - } - else { + { int left = CERTBUFFERSIZE; ptr = bufp; - *ptr++ = 0; - if(num->type == V_ASN1_NEG_INTEGER) + if(num->type == V_ASN1_NEG_INTEGER) { *ptr++='-'; + left--; + } - for(j=0; (jlength) && (left>=4); j++) { - /* TODO: length restrictions */ - snprintf(ptr, 3, "%02x%c",num->data[j], - ((j+1 == num->length)?'\n':':')); - ptr += 3; - left-=4; + for(j=0; (jlength) && (left>=3); j++) { + snprintf(ptr, left, "%02x", num->data[j]); + ptr += 2; + left -= 2; } if(num->length) - infof(data," Serial Number: %s\n", bufp); + infof(data, " Serial Number: %s\n", bufp); else bufp[0]=0; } @@ -2357,6 +2558,65 @@ static CURLcode get_cert_chain(struct connectdata *conn, } /* + * Heavily modified from: + * https://www.owasp.org/index.php/Certificate_and_Public_Key_Pinning#OpenSSL + */ +static CURLcode pkp_pin_peer_pubkey(X509* cert, const char *pinnedpubkey) +{ + /* Scratch */ + int len1 = 0, len2 = 0; + unsigned char *buff1 = NULL, *temp = NULL; + + /* Result is returned to caller */ + CURLcode result = CURLE_SSL_PINNEDPUBKEYNOTMATCH; + + /* if a path wasn't specified, don't pin */ + if(!pinnedpubkey) + return CURLE_OK; + + if(!cert) + return result; + + do { + /* Begin Gyrations to get the subjectPublicKeyInfo */ + /* Thanks to Viktor Dukhovni on the OpenSSL mailing list */ + + /* https://groups.google.com/group/mailing.openssl.users/browse_thread + /thread/d61858dae102c6c7 */ + len1 = i2d_X509_PUBKEY(X509_get_X509_PUBKEY(cert), NULL); + if(len1 < 1) + break; /* failed */ + + /* https://www.openssl.org/docs/crypto/buffer.html */ + buff1 = temp = OPENSSL_malloc(len1); + if(!buff1) + break; /* failed */ + + /* https://www.openssl.org/docs/crypto/d2i_X509.html */ + len2 = i2d_X509_PUBKEY(X509_get_X509_PUBKEY(cert), &temp); + + /* + * These checks are verifying we got back the same values as when we + * sized the buffer. It's pretty weak since they should always be the + * same. But it gives us something to test. + */ + if((len1 != len2) || !temp || ((temp - buff1) != len1)) + break; /* failed */ + + /* End Gyrations */ + + /* The one good exit point */ + result = Curl_pin_peer_pubkey(pinnedpubkey, buff1, len1); + } while(0); + + /* https://www.openssl.org/docs/crypto/buffer.html */ + if(buff1) + OPENSSL_free(buff1); + + return result; +} + +/* * Get the server cert, verify it and show it etc, only call failf() if the * 'strict' argument is TRUE as otherwise all this is for informational * purposes only! @@ -2368,7 +2628,7 @@ static CURLcode servercert(struct connectdata *conn, struct ssl_connect_data *connssl, bool strict) { - CURLcode retcode = CURLE_OK; + CURLcode result = CURLE_OK; int rc; long lerr; ASN1_TIME *certdate; @@ -2376,6 +2636,7 @@ static CURLcode servercert(struct connectdata *conn, X509 *issuer; FILE *fp; char *buffer = data->state.buffer; + const char *ptr; if(data->set.ssl.certinfo) /* we've been asked to gather certificate info! */ @@ -2387,7 +2648,8 @@ static CURLcode servercert(struct connectdata *conn, failf(data, "SSL: couldn't get peer certificate!"); return CURLE_PEER_FAILED_VERIFICATION; } - infof (data, "Server certificate:\n"); + + infof(data, "Server certificate:\n"); rc = x509_name_oneline(X509_get_subject_name(connssl->server_cert), buffer, BUFSIZE); @@ -2402,11 +2664,11 @@ static CURLcode servercert(struct connectdata *conn, infof(data, "\t expire date: %s\n", buffer); if(data->set.ssl.verifyhost) { - retcode = verifyhost(conn, connssl->server_cert); - if(retcode) { + result = verifyhost(conn, connssl->server_cert); + if(result) { X509_free(connssl->server_cert); connssl->server_cert = NULL; - return retcode; + return result; } } @@ -2415,7 +2677,7 @@ static CURLcode servercert(struct connectdata *conn, if(rc) { if(strict) failf(data, "SSL: couldn't get X509-issuer name!"); - retcode = CURLE_SSL_CONNECT_ERROR; + result = CURLE_SSL_CONNECT_ERROR; } else { infof(data, "\t issuer: %s\n", buffer); @@ -2425,7 +2687,7 @@ static CURLcode servercert(struct connectdata *conn, /* e.g. match issuer name with provided issuer certificate */ if(data->set.str[STRING_SSL_ISSUERCERT]) { - fp=fopen(data->set.str[STRING_SSL_ISSUERCERT],"r"); + fp = fopen(data->set.str[STRING_SSL_ISSUERCERT], FOPEN_READTEXT); if(!fp) { if(strict) failf(data, "SSL: Unable to open issuer cert (%s)", @@ -2434,7 +2696,8 @@ static CURLcode servercert(struct connectdata *conn, connssl->server_cert = NULL; return CURLE_SSL_ISSUER_ERROR; } - issuer = PEM_read_X509(fp,NULL,ZERO_NULL,NULL); + + issuer = PEM_read_X509(fp, NULL, ZERO_NULL, NULL); if(!issuer) { if(strict) failf(data, "SSL: Unable to read issuer cert (%s)", @@ -2444,8 +2707,10 @@ static CURLcode servercert(struct connectdata *conn, fclose(fp); return CURLE_SSL_ISSUER_ERROR; } + fclose(fp); - if(X509_check_issued(issuer,connssl->server_cert) != X509_V_OK) { + + if(X509_check_issued(issuer, connssl->server_cert) != X509_V_OK) { if(strict) failf(data, "SSL: Certificate issuer check failed (%s)", data->set.str[STRING_SSL_ISSUERCERT]); @@ -2454,13 +2719,15 @@ static CURLcode servercert(struct connectdata *conn, connssl->server_cert = NULL; return CURLE_SSL_ISSUER_ERROR; } + infof(data, "\t SSL certificate issuer check ok (%s)\n", data->set.str[STRING_SSL_ISSUERCERT]); X509_free(issuer); } - lerr = data->set.ssl.certverifyresult= + lerr = data->set.ssl.certverifyresult = SSL_get_verify_result(connssl->handle); + if(data->set.ssl.certverifyresult != X509_V_OK) { if(data->set.ssl.verifypeer) { /* We probably never reach this, because SSL_connect() will fail @@ -2468,7 +2735,7 @@ static CURLcode servercert(struct connectdata *conn, if(strict) failf(data, "SSL certificate verify result: %s (%ld)", X509_verify_cert_error_string(lerr), lerr); - retcode = CURLE_PEER_FAILED_VERIFICATION; + result = CURLE_PEER_FAILED_VERIFICATION; } else infof(data, "\t SSL certificate verify result: %s (%ld)," @@ -2479,46 +2746,52 @@ static CURLcode servercert(struct connectdata *conn, infof(data, "\t SSL certificate verify ok.\n"); } +#if (OPENSSL_VERSION_NUMBER >= 0x0090808fL) && !defined(OPENSSL_NO_TLSEXT) && \ + !defined(OPENSSL_IS_BORINGSSL) + if(data->set.ssl.verifystatus) { + result = verifystatus(conn, connssl); + if(result) { + X509_free(connssl->server_cert); + connssl->server_cert = NULL; + return result; + } + } +#endif + + if(!strict) + /* when not strict, we don't bother about the verify cert problems */ + result = CURLE_OK; + + ptr = data->set.str[STRING_SSL_PINNEDPUBLICKEY]; + if(!result && ptr) { + result = pkp_pin_peer_pubkey(connssl->server_cert, ptr); + if(result) + failf(data, "SSL: public key does not match pinned public key!"); + } + X509_free(connssl->server_cert); connssl->server_cert = NULL; connssl->connecting_state = ssl_connect_done; - return retcode; + return result; } - -static CURLcode -ossl_connect_step3(struct connectdata *conn, - int sockindex) +static CURLcode ossl_connect_step3(struct connectdata *conn, int sockindex) { - CURLcode retcode = CURLE_OK; - void *old_ssl_sessionid=NULL; + CURLcode result = CURLE_OK; + void *old_ssl_sessionid = NULL; struct SessionHandle *data = conn->data; struct ssl_connect_data *connssl = &conn->ssl[sockindex]; - int incache; + bool incache; SSL_SESSION *our_ssl_sessionid; DEBUGASSERT(ssl_connect_3 == connssl->connecting_state); -#ifdef HAVE_SSL_GET1_SESSION our_ssl_sessionid = SSL_get1_session(connssl->handle); - /* SSL_get1_session() will increment the reference - count and the session will stay in memory until explicitly freed with - SSL_SESSION_free(3), regardless of its state. - This function was introduced in openssl 0.9.5a. */ -#else - our_ssl_sessionid = SSL_get_session(connssl->handle); - - /* if SSL_get1_session() is unavailable, use SSL_get_session(). - This is an inferior option because the session can be flushed - at any time by openssl. It is included only so curl compiles - under versions of openssl < 0.9.5a. - - WARNING: How curl behaves if it's session is flushed is - untested. - */ -#endif + /* SSL_get1_session() will increment the reference count and the session + will stay in memory until explicitly freed with SSL_SESSION_free(3), + regardless of its state. */ incache = !(Curl_ssl_getsessionid(conn, &old_ssl_sessionid, NULL)); if(incache) { @@ -2528,15 +2801,15 @@ ossl_connect_step3(struct connectdata *conn, incache = FALSE; } } + if(!incache) { - retcode = Curl_ssl_addsessionid(conn, our_ssl_sessionid, - 0 /* unknown size */); - if(retcode) { + result = Curl_ssl_addsessionid(conn, our_ssl_sessionid, + 0 /* unknown size */); + if(result) { failf(data, "failed to store ssl session"); - return retcode; + return result; } } -#ifdef HAVE_SSL_GET1_SESSION else { /* Session was incache, so refcount already incremented earlier. * Avoid further increments with each SSL_get1_session() call. @@ -2544,7 +2817,6 @@ ossl_connect_step3(struct connectdata *conn, */ SSL_SESSION_free(our_ssl_sessionid); } -#endif /* * We check certificates to authenticate the server; otherwise we risk @@ -2553,26 +2825,24 @@ ossl_connect_step3(struct connectdata *conn, * operations. */ - if(!data->set.ssl.verifypeer && !data->set.ssl.verifyhost) - (void)servercert(conn, connssl, FALSE); - else - retcode = servercert(conn, connssl, TRUE); + result = servercert(conn, connssl, + (data->set.ssl.verifypeer || data->set.ssl.verifyhost)); - if(CURLE_OK == retcode) + if(!result) connssl->connecting_state = ssl_connect_done; - return retcode; + + return result; } static Curl_recv ossl_recv; static Curl_send ossl_send; -static CURLcode -ossl_connect_common(struct connectdata *conn, - int sockindex, - bool nonblocking, - bool *done) +static CURLcode ossl_connect_common(struct connectdata *conn, + int sockindex, + bool nonblocking, + bool *done) { - CURLcode retcode; + CURLcode result; struct SessionHandle *data = conn->data; struct ssl_connect_data *connssl = &conn->ssl[sockindex]; curl_socket_t sockfd = conn->sock[sockindex]; @@ -2585,7 +2855,7 @@ ossl_connect_common(struct connectdata *conn, return CURLE_OK; } - if(ssl_connect_1==connssl->connecting_state) { + if(ssl_connect_1 == connssl->connecting_state) { /* Find out how much more time we're allowed */ timeout_ms = Curl_timeleft(data, NULL, TRUE); @@ -2594,9 +2864,10 @@ ossl_connect_common(struct connectdata *conn, failf(data, "SSL connection timeout"); return CURLE_OPERATION_TIMEDOUT; } - retcode = ossl_connect_step1(conn, sockindex); - if(retcode) - return retcode; + + result = ossl_connect_step1(conn, sockindex); + if(result) + return result; } while(ssl_connect_2 == connssl->connecting_state || @@ -2613,8 +2884,8 @@ ossl_connect_common(struct connectdata *conn, } /* if ssl is expecting something, check if it's available. */ - if(connssl->connecting_state == ssl_connect_2_reading - || connssl->connecting_state == ssl_connect_2_writing) { + if(connssl->connecting_state == ssl_connect_2_reading || + connssl->connecting_state == ssl_connect_2_writing) { curl_socket_t writefd = ssl_connect_2_writing== connssl->connecting_state?sockfd:CURL_SOCKET_BAD; @@ -2647,23 +2918,22 @@ ossl_connect_common(struct connectdata *conn, * before step2 has completed while ensuring that a client using select() * or epoll() will always have a valid fdset to wait on. */ - retcode = ossl_connect_step2(conn, sockindex); - if(retcode || (nonblocking && - (ssl_connect_2 == connssl->connecting_state || - ssl_connect_2_reading == connssl->connecting_state || - ssl_connect_2_writing == connssl->connecting_state))) - return retcode; + result = ossl_connect_step2(conn, sockindex); + if(result || (nonblocking && + (ssl_connect_2 == connssl->connecting_state || + ssl_connect_2_reading == connssl->connecting_state || + ssl_connect_2_writing == connssl->connecting_state))) + return result; } /* repeat step2 until all transactions are done. */ - - if(ssl_connect_3==connssl->connecting_state) { - retcode = ossl_connect_step3(conn, sockindex); - if(retcode) - return retcode; + if(ssl_connect_3 == connssl->connecting_state) { + result = ossl_connect_step3(conn, sockindex); + if(result) + return result; } - if(ssl_connect_done==connssl->connecting_state) { + if(ssl_connect_done == connssl->connecting_state) { connssl->state = ssl_connection_complete; conn->recv[sockindex] = ossl_recv; conn->send[sockindex] = ossl_send; @@ -2678,32 +2948,28 @@ ossl_connect_common(struct connectdata *conn, return CURLE_OK; } -CURLcode -Curl_ossl_connect_nonblocking(struct connectdata *conn, - int sockindex, - bool *done) +CURLcode Curl_ossl_connect_nonblocking(struct connectdata *conn, + int sockindex, + bool *done) { return ossl_connect_common(conn, sockindex, TRUE, done); } -CURLcode -Curl_ossl_connect(struct connectdata *conn, - int sockindex) +CURLcode Curl_ossl_connect(struct connectdata *conn, int sockindex) { - CURLcode retcode; + CURLcode result; bool done = FALSE; - retcode = ossl_connect_common(conn, sockindex, FALSE, &done); - if(retcode) - return retcode; + result = ossl_connect_common(conn, sockindex, FALSE, &done); + if(result) + return result; DEBUGASSERT(done); return CURLE_OK; } -bool Curl_ossl_data_pending(const struct connectdata *conn, - int connindex) +bool Curl_ossl_data_pending(const struct connectdata *conn, int connindex) { if(conn->ssl[connindex].handle) /* SSL is in use */ @@ -2798,7 +3064,7 @@ static ssize_t ossl_recv(struct connectdata *conn, /* connection data */ default: /* openssl/ssl.h for SSL_ERROR_SYSCALL says "look at error stack/return value/errno" */ - /* http://www.openssl.org/docs/crypto/ERR_get_error.html */ + /* https://www.openssl.org/docs/crypto/ERR_get_error.html */ sslerror = ERR_get_error(); if((nread < 0) || sslerror) { /* If the return code was negative or there actually is an error in the @@ -2821,8 +3087,11 @@ size_t Curl_ossl_version(char *buffer, size_t size) to OpenSSL in all other aspects */ return snprintf(buffer, size, "yassl/%s", YASSL_VERSION); #else /* YASSL_VERSION */ +#ifdef OPENSSL_IS_BORINGSSL + return snprintf(buffer, size, "BoringSSL"); +#else /* OPENSSL_IS_BORINGSSL */ -#if(SSLEAY_VERSION_NUMBER >= 0x905000) +#if(OPENSSL_VERSION_NUMBER >= 0x905000) { char sub[3]; unsigned long ssleay_value; @@ -2850,47 +3119,44 @@ size_t Curl_ossl_version(char *buffer, size_t size) } return snprintf(buffer, size, "%s/%lx.%lx.%lx%s", -#ifdef OPENSSL_IS_BORINGSSL - "BoringSSL" -#else #ifdef LIBRESSL_VERSION_NUMBER "LibreSSL" #else "OpenSSL" #endif -#endif , (ssleay_value>>28)&0xf, (ssleay_value>>20)&0xff, (ssleay_value>>12)&0xff, sub); } -#else /* SSLEAY_VERSION_NUMBER is less than 0.9.5 */ +#else /* OPENSSL_VERSION_NUMBER is less than 0.9.5 */ -#if(SSLEAY_VERSION_NUMBER >= 0x900000) +#if(OPENSSL_VERSION_NUMBER >= 0x900000) return snprintf(buffer, size, "OpenSSL/%lx.%lx.%lx", - (SSLEAY_VERSION_NUMBER>>28)&0xff, - (SSLEAY_VERSION_NUMBER>>20)&0xff, - (SSLEAY_VERSION_NUMBER>>12)&0xf); + (OPENSSL_VERSION_NUMBER>>28)&0xff, + (OPENSSL_VERSION_NUMBER>>20)&0xff, + (OPENSSL_VERSION_NUMBER>>12)&0xf); -#else /* (SSLEAY_VERSION_NUMBER >= 0x900000) */ +#else /* (OPENSSL_VERSION_NUMBER >= 0x900000) */ { char sub[2]; sub[1]='\0'; - if(SSLEAY_VERSION_NUMBER&0x0f) { - sub[0]=(SSLEAY_VERSION_NUMBER&0x0f) + 'a' -1; + if(OPENSSL_VERSION_NUMBER&0x0f) { + sub[0]=(OPENSSL_VERSION_NUMBER&0x0f) + 'a' -1; } else sub[0]='\0'; return snprintf(buffer, size, "SSL/%x.%x.%x%s", - (SSLEAY_VERSION_NUMBER>>12)&0xff, - (SSLEAY_VERSION_NUMBER>>8)&0xf, - (SSLEAY_VERSION_NUMBER>>4)&0xf, sub); + (OPENSSL_VERSION_NUMBER>>12)&0xff, + (OPENSSL_VERSION_NUMBER>>8)&0xf, + (OPENSSL_VERSION_NUMBER>>4)&0xf, sub); } -#endif /* (SSLEAY_VERSION_NUMBER >= 0x900000) */ -#endif /* SSLEAY_VERSION_NUMBER is less than 0.9.5 */ +#endif /* (OPENSSL_VERSION_NUMBER >= 0x900000) */ +#endif /* OPENSSL_VERSION_NUMBER is less than 0.9.5 */ +#endif /* OPENSSL_IS_BORINGSSL */ #endif /* YASSL_VERSION */ } @@ -2898,8 +3164,9 @@ size_t Curl_ossl_version(char *buffer, size_t size) int Curl_ossl_random(struct SessionHandle *data, unsigned char *entropy, size_t length) { - if(data) + if(data) { Curl_ossl_seed(data); /* Initiate the seed if not already done */ + } RAND_bytes(entropy, curlx_uztosi(length)); return 0; /* 0 as in no problem */ } @@ -2915,4 +3182,28 @@ void Curl_ossl_md5sum(unsigned char *tmp, /* input */ MD5_Update(&MD5pw, tmp, tmplen); MD5_Final(md5sum, &MD5pw); } -#endif /* USE_SSLEAY */ + +#ifndef OPENSSL_NO_SHA256 +void Curl_ossl_sha256sum(const unsigned char *tmp, /* input */ + size_t tmplen, + unsigned char *sha256sum /* output */, + size_t unused) +{ + SHA256_CTX SHA256pw; + (void)unused; + SHA256_Init(&SHA256pw); + SHA256_Update(&SHA256pw, tmp, tmplen); + SHA256_Final(sha256sum, &SHA256pw); +} +#endif + +bool Curl_ossl_cert_status_request(void) +{ +#if (OPENSSL_VERSION_NUMBER >= 0x0090808fL) && !defined(OPENSSL_NO_TLSEXT) && \ + !defined(OPENSSL_IS_BORINGSSL) + return TRUE; +#else + return FALSE; +#endif +} +#endif /* USE_OPENSSL */ diff --git a/lib/vtls/openssl.h b/lib/vtls/openssl.h index 1a55ffc..a1f347a 100644 --- a/lib/vtls/openssl.h +++ b/lib/vtls/openssl.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -24,7 +24,7 @@ #include "curl_setup.h" -#ifdef USE_SSLEAY +#ifdef USE_OPENSSL /* * This header should only be needed to get included by vtls.c and openssl.c */ @@ -41,7 +41,7 @@ void Curl_ossl_close(struct connectdata *conn, int sockindex); /* tell OpenSSL to close down all open information regarding connections (and thus session ID caching etc) */ -int Curl_ossl_close_all(struct SessionHandle *data); +void Curl_ossl_close_all(struct SessionHandle *data); /* Sets an OpenSSL engine */ CURLcode Curl_ossl_set_engine(struct SessionHandle *data, const char *engine); @@ -72,9 +72,24 @@ void Curl_ossl_md5sum(unsigned char *tmp, /* input */ size_t tmplen, unsigned char *md5sum /* output */, size_t unused); +void Curl_ossl_sha256sum(const unsigned char *tmp, /* input */ + size_t tmplen, + unsigned char *sha256sum /* output */, + size_t unused); + +bool Curl_ossl_cert_status_request(void); + +/* Set the API backend definition to OpenSSL */ +#define CURL_SSL_BACKEND CURLSSLBACKEND_OPENSSL + +/* this backend supports the CAPATH option */ +#define have_curlssl_ca_path 1 -/* this backend provides these functions: */ -#define have_curlssl_md5sum 1 +/* this backend supports CURLOPT_CERTINFO */ +#define have_curlssl_certinfo 1 + +/* this backend suppots CURLOPT_SSL_CTX_* */ +#define have_curlssl_ssl_ctx 1 /* API setup for OpenSSL */ #define curlssl_init Curl_ossl_init @@ -93,9 +108,13 @@ void Curl_ossl_md5sum(unsigned char *tmp, /* input */ #define curlssl_data_pending(x,y) Curl_ossl_data_pending(x,y) #define curlssl_random(x,y,z) Curl_ossl_random(x,y,z) #define curlssl_md5sum(a,b,c,d) Curl_ossl_md5sum(a,b,c,d) -#define CURL_SSL_BACKEND CURLSSLBACKEND_OPENSSL +#ifndef OPENSSL_NO_SHA256 +#define curlssl_sha256sum(a,b,c,d) Curl_ossl_sha256sum(a,b,c,d) +#endif +#define curlssl_cert_status_request() Curl_ossl_cert_status_request() -#define DEFAULT_CIPHER_SELECTION "ALL!EXPORT!EXPORT40!EXPORT56!aNULL!LOW!RC4" +#define DEFAULT_CIPHER_SELECTION \ + "ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH" -#endif /* USE_SSLEAY */ +#endif /* USE_OPENSSL */ #endif /* HEADER_CURL_SSLUSE_H */ diff --git a/lib/vtls/polarssl.c b/lib/vtls/polarssl.c index 5332b92..066c055 100644 --- a/lib/vtls/polarssl.c +++ b/lib/vtls/polarssl.c @@ -6,7 +6,7 @@ * \___|\___/|_| \_\_____| * * Copyright (C) 2010 - 2011, Hoi-Ho Chan, - * Copyright (C) 2012 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 2012 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -55,9 +55,7 @@ #include "select.h" #include "rawstr.h" #include "polarssl_threadlock.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include +#include "curl_printf.h" #include "curl_memory.h" /* The last #include file should be: */ #include "memdebug.h" @@ -120,11 +118,8 @@ static void polarssl_debug(void *context, int level, const char *line) #endif /* ALPN for http2? */ -#ifdef USE_NGHTTP2 -# undef HAS_ALPN -# ifdef POLARSSL_SSL_ALPN -# define HAS_ALPN -# endif +#ifdef POLARSSL_SSL_ALPN +# define HAS_ALPN #endif static Curl_recv polarssl_recv; @@ -287,24 +282,38 @@ polarssl_connect_step1(struct connectdata *conn, } switch(data->set.ssl.version) { + default: + case CURL_SSLVERSION_DEFAULT: + case CURL_SSLVERSION_TLSv1: + ssl_set_min_version(&connssl->ssl, SSL_MAJOR_VERSION_3, + SSL_MINOR_VERSION_1); + break; case CURL_SSLVERSION_SSLv3: ssl_set_min_version(&connssl->ssl, SSL_MAJOR_VERSION_3, SSL_MINOR_VERSION_0); + ssl_set_max_version(&connssl->ssl, SSL_MAJOR_VERSION_3, + SSL_MINOR_VERSION_0); infof(data, "PolarSSL: Forced min. SSL Version to be SSLv3\n"); break; case CURL_SSLVERSION_TLSv1_0: ssl_set_min_version(&connssl->ssl, SSL_MAJOR_VERSION_3, SSL_MINOR_VERSION_1); + ssl_set_max_version(&connssl->ssl, SSL_MAJOR_VERSION_3, + SSL_MINOR_VERSION_1); infof(data, "PolarSSL: Forced min. SSL Version to be TLS 1.0\n"); break; case CURL_SSLVERSION_TLSv1_1: ssl_set_min_version(&connssl->ssl, SSL_MAJOR_VERSION_3, SSL_MINOR_VERSION_2); + ssl_set_max_version(&connssl->ssl, SSL_MAJOR_VERSION_3, + SSL_MINOR_VERSION_2); infof(data, "PolarSSL: Forced min. SSL Version to be TLS 1.1\n"); break; case CURL_SSLVERSION_TLSv1_2: ssl_set_min_version(&connssl->ssl, SSL_MAJOR_VERSION_3, SSL_MINOR_VERSION_3); + ssl_set_max_version(&connssl->ssl, SSL_MAJOR_VERSION_3, + SSL_MINOR_VERSION_3); infof(data, "PolarSSL: Forced min. SSL Version to be TLS 1.2\n"); break; } @@ -345,15 +354,23 @@ polarssl_connect_step1(struct connectdata *conn, } #ifdef HAS_ALPN - if(data->set.httpversion == CURL_HTTP_VERSION_2_0) { - if(data->set.ssl_enable_alpn) { - static const char* protocols[] = { - NGHTTP2_PROTO_VERSION_ID, ALPN_HTTP_1_1, NULL - }; - ssl_set_alpn_protocols(&connssl->ssl, protocols); - infof(data, "ALPN, offering %s, %s\n", protocols[0], - protocols[1]); + if(data->set.ssl_enable_alpn) { + static const char* protocols[3]; + int cur = 0; + +#ifdef USE_NGHTTP2 + if(data->set.httpversion == CURL_HTTP_VERSION_2_0) { + protocols[cur++] = NGHTTP2_PROTO_VERSION_ID; + infof(data, "ALPN, offering %s\n", NGHTTP2_PROTO_VERSION_ID); } +#endif + + protocols[cur++] = ALPN_HTTP_1_1; + infof(data, "ALPN, offering %s\n", ALPN_HTTP_1_1); + + protocols[cur] = NULL; + + ssl_set_alpn_protocols(&connssl->ssl, protocols); } #endif @@ -375,47 +392,37 @@ polarssl_connect_step2(struct connectdata *conn, struct ssl_connect_data* connssl = &conn->ssl[sockindex]; char buffer[1024]; -#ifdef HAS_ALPN - const char* next_protocol; -#endif - char errorbuf[128]; errorbuf[0] = 0; conn->recv[sockindex] = polarssl_recv; conn->send[sockindex] = polarssl_send; - for(;;) { - if(!(ret = ssl_handshake(&connssl->ssl))) - break; - else if(ret != POLARSSL_ERR_NET_WANT_READ && - ret != POLARSSL_ERR_NET_WANT_WRITE) { -#ifdef POLARSSL_ERROR_C - error_strerror(ret, errorbuf, sizeof(errorbuf)); -#endif /* POLARSSL_ERROR_C */ - failf(data, "ssl_handshake returned - PolarSSL: (-0x%04X) %s", - -ret, errorbuf); + ret = ssl_handshake(&connssl->ssl); - return CURLE_SSL_CONNECT_ERROR; - } - else { - if(ret == POLARSSL_ERR_NET_WANT_READ) { - connssl->connecting_state = ssl_connect_2_reading; - return CURLE_OK; - } - if(ret == POLARSSL_ERR_NET_WANT_WRITE) { - connssl->connecting_state = ssl_connect_2_writing; - return CURLE_OK; - } - failf(data, "SSL_connect failed with error %d.", ret); - return CURLE_SSL_CONNECT_ERROR; + switch(ret) { + case 0: + break; - } + case POLARSSL_ERR_NET_WANT_READ: + connssl->connecting_state = ssl_connect_2_reading; + return CURLE_OK; + + case POLARSSL_ERR_NET_WANT_WRITE: + connssl->connecting_state = ssl_connect_2_writing; + return CURLE_OK; + + default: +#ifdef POLARSSL_ERROR_C + error_strerror(ret, errorbuf, sizeof(errorbuf)); +#endif /* POLARSSL_ERROR_C */ + failf(data, "ssl_handshake returned - PolarSSL: (-0x%04X) %s", + -ret, errorbuf); + return CURLE_SSL_CONNECT_ERROR; } infof(data, "PolarSSL: Handshake complete, cipher is %s\n", - ssl_get_ciphersuite(&conn->ssl[sockindex].ssl) - ); + ssl_get_ciphersuite(&conn->ssl[sockindex].ssl) ); ret = ssl_get_verify_result(&conn->ssl[sockindex].ssl); @@ -448,22 +455,24 @@ polarssl_connect_step2(struct connectdata *conn, #ifdef HAS_ALPN if(data->set.ssl_enable_alpn) { - next_protocol = ssl_get_alpn_protocol(&connssl->ssl); + const char *next_protocol = ssl_get_alpn_protocol(&connssl->ssl); if(next_protocol != NULL) { infof(data, "ALPN, server accepted to use %s\n", next_protocol); - if(strncmp(next_protocol, NGHTTP2_PROTO_VERSION_ID, +#ifdef USE_NGHTTP2 + if(!strncmp(next_protocol, NGHTTP2_PROTO_VERSION_ID, NGHTTP2_PROTO_VERSION_ID_LEN)) { - conn->negnpn = NPN_HTTP2; + conn->negnpn = CURL_HTTP_VERSION_2_0; } - else if(strncmp(next_protocol, ALPN_HTTP_1_1, ALPN_HTTP_1_1_LENGTH)) { - conn->negnpn = NPN_HTTP1_1; + else +#endif + if(!strncmp(next_protocol, ALPN_HTTP_1_1, ALPN_HTTP_1_1_LENGTH)) { + conn->negnpn = CURL_HTTP_VERSION_1_1; } } - else { + else infof(data, "ALPN, server did not agree to a protocol\n"); - } } #endif @@ -477,12 +486,12 @@ static CURLcode polarssl_connect_step3(struct connectdata *conn, int sockindex) { - CURLcode retcode = CURLE_OK; + CURLcode result = CURLE_OK; struct ssl_connect_data *connssl = &conn->ssl[sockindex]; struct SessionHandle *data = conn->data; void *old_ssl_sessionid = NULL; - ssl_session *our_ssl_sessionid = &conn->ssl[sockindex].ssn ; - int incache; + ssl_session *our_ssl_sessionid = &conn->ssl[sockindex].ssn; + bool incache; DEBUGASSERT(ssl_connect_3 == connssl->connecting_state); @@ -495,23 +504,21 @@ polarssl_connect_step3(struct connectdata *conn, incache = FALSE; } } + if(!incache) { void *new_session = malloc(sizeof(ssl_session)); if(new_session) { - memcpy(new_session, our_ssl_sessionid, - sizeof(ssl_session)); + memcpy(new_session, our_ssl_sessionid, sizeof(ssl_session)); - retcode = Curl_ssl_addsessionid(conn, new_session, - sizeof(ssl_session)); - } - else { - retcode = CURLE_OUT_OF_MEMORY; + result = Curl_ssl_addsessionid(conn, new_session, sizeof(ssl_session)); } + else + result = CURLE_OUT_OF_MEMORY; - if(retcode) { + if(result) { failf(data, "failed to store ssl session"); - return retcode; + return result; } } @@ -540,11 +547,6 @@ static ssize_t polarssl_send(struct connectdata *conn, return ret; } -void Curl_polarssl_close_all(struct SessionHandle *data) -{ - (void)data; -} - void Curl_polarssl_close(struct connectdata *conn, int sockindex) { rsa_free(&conn->ssl[sockindex].rsa); @@ -585,11 +587,15 @@ void Curl_polarssl_session_free(void *ptr) free(ptr); } +/* 1.3.10 was the first rebranded version. All new releases (in 1.3 branch and + higher) will be mbed TLS branded.. */ + size_t Curl_polarssl_version(char *buffer, size_t size) { unsigned int version = version_get_number(); - return snprintf(buffer, size, "PolarSSL/%d.%d.%d", version>>24, - (version>>16)&0xff, (version>>8)&0xff); + return snprintf(buffer, size, "%s/%d.%d.%d", + version >= 0x01030A00?"mbedTLS":"PolarSSL", + version>>24, (version>>16)&0xff, (version>>8)&0xff); } static CURLcode @@ -598,7 +604,7 @@ polarssl_connect_common(struct connectdata *conn, bool nonblocking, bool *done) { - CURLcode retcode; + CURLcode result; struct SessionHandle *data = conn->data; struct ssl_connect_data *connssl = &conn->ssl[sockindex]; curl_socket_t sockfd = conn->sock[sockindex]; @@ -611,7 +617,7 @@ polarssl_connect_common(struct connectdata *conn, return CURLE_OK; } - if(ssl_connect_1==connssl->connecting_state) { + if(ssl_connect_1 == connssl->connecting_state) { /* Find out how much more time we're allowed */ timeout_ms = Curl_timeleft(data, NULL, TRUE); @@ -620,9 +626,10 @@ polarssl_connect_common(struct connectdata *conn, failf(data, "SSL connection timeout"); return CURLE_OPERATION_TIMEDOUT; } - retcode = polarssl_connect_step1(conn, sockindex); - if(retcode) - return retcode; + + result = polarssl_connect_step1(conn, sockindex); + if(result) + return result; } while(ssl_connect_2 == connssl->connecting_state || @@ -639,8 +646,8 @@ polarssl_connect_common(struct connectdata *conn, } /* if ssl is expecting something, check if it's available. */ - if(connssl->connecting_state == ssl_connect_2_reading - || connssl->connecting_state == ssl_connect_2_writing) { + if(connssl->connecting_state == ssl_connect_2_reading || + connssl->connecting_state == ssl_connect_2_writing) { curl_socket_t writefd = ssl_connect_2_writing== connssl->connecting_state?sockfd:CURL_SOCKET_BAD; @@ -674,22 +681,22 @@ polarssl_connect_common(struct connectdata *conn, * ensuring that a client using select() or epoll() will always * have a valid fdset to wait on. */ - retcode = polarssl_connect_step2(conn, sockindex); - if(retcode || (nonblocking && - (ssl_connect_2 == connssl->connecting_state || - ssl_connect_2_reading == connssl->connecting_state || - ssl_connect_2_writing == connssl->connecting_state))) - return retcode; + result = polarssl_connect_step2(conn, sockindex); + if(result || (nonblocking && + (ssl_connect_2 == connssl->connecting_state || + ssl_connect_2_reading == connssl->connecting_state || + ssl_connect_2_writing == connssl->connecting_state))) + return result; } /* repeat step2 until all transactions are done. */ - if(ssl_connect_3==connssl->connecting_state) { - retcode = polarssl_connect_step3(conn, sockindex); - if(retcode) - return retcode; + if(ssl_connect_3 == connssl->connecting_state) { + result = polarssl_connect_step3(conn, sockindex); + if(result) + return result; } - if(ssl_connect_done==connssl->connecting_state) { + if(ssl_connect_done == connssl->connecting_state) { connssl->state = ssl_connection_complete; conn->recv[sockindex] = polarssl_recv; conn->send[sockindex] = polarssl_send; @@ -717,12 +724,12 @@ CURLcode Curl_polarssl_connect(struct connectdata *conn, int sockindex) { - CURLcode retcode; + CURLcode result; bool done = FALSE; - retcode = polarssl_connect_common(conn, sockindex, FALSE, &done); - if(retcode) - return retcode; + result = polarssl_connect_common(conn, sockindex, FALSE, &done); + if(result) + return result; DEBUGASSERT(done); diff --git a/lib/vtls/polarssl.h b/lib/vtls/polarssl.h index 9ab7e47..f980dbb 100644 --- a/lib/vtls/polarssl.h +++ b/lib/vtls/polarssl.h @@ -8,6 +8,7 @@ * \___|\___/|_| \_\_____| * * Copyright (C) 2010, Hoi-Ho Chan, + * Copyright (C) 2012 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -36,10 +37,6 @@ CURLcode Curl_polarssl_connect_nonblocking(struct connectdata *conn, int sockindex, bool *done); -/* tell PolarSSL to close down all open information regarding connections (and - thus session ID caching etc) */ -void Curl_polarssl_close_all(struct SessionHandle *data); - /* close a SSL connection */ void Curl_polarssl_close(struct connectdata *conn, int sockindex); @@ -47,27 +44,32 @@ void Curl_polarssl_session_free(void *ptr); size_t Curl_polarssl_version(char *buffer, size_t size); int Curl_polarssl_shutdown(struct connectdata *conn, int sockindex); +/* Set the API backend definition to PolarSSL */ +#define CURL_SSL_BACKEND CURLSSLBACKEND_POLARSSL + +/* this backend supports the CAPATH option */ +#define have_curlssl_ca_path 1 + /* API setup for PolarSSL */ #define curlssl_init() polarssl_init() #define curlssl_cleanup() polarssl_cleanup() #define curlssl_connect Curl_polarssl_connect #define curlssl_connect_nonblocking Curl_polarssl_connect_nonblocking #define curlssl_session_free(x) Curl_polarssl_session_free(x) -#define curlssl_close_all Curl_polarssl_close_all +#define curlssl_close_all(x) ((void)x) #define curlssl_close Curl_polarssl_close #define curlssl_shutdown(x,y) 0 -#define curlssl_set_engine(x,y) (x=x, y=y, CURLE_NOT_BUILT_IN) -#define curlssl_set_engine_default(x) (x=x, CURLE_NOT_BUILT_IN) -#define curlssl_engines_list(x) (x=x, (struct curl_slist *)NULL) +#define curlssl_set_engine(x,y) ((void)x, (void)y, CURLE_NOT_BUILT_IN) +#define curlssl_set_engine_default(x) ((void)x, CURLE_NOT_BUILT_IN) +#define curlssl_engines_list(x) ((void)x, (struct curl_slist *)NULL) #define curlssl_version Curl_polarssl_version -#define curlssl_check_cxn(x) (x=x, -1) -#define curlssl_data_pending(x,y) (x=x, y=y, 0) -#define CURL_SSL_BACKEND CURLSSLBACKEND_POLARSSL +#define curlssl_check_cxn(x) ((void)x, -1) +#define curlssl_data_pending(x,y) ((void)x, (void)y, 0) /* This might cause libcurl to use a weeker random! TODO: implement proper use of Polarssl's CTR-DRBG or HMAC-DRBG and use that */ -#define curlssl_random(x,y,z) (x=x, y=y, z=z, CURLE_NOT_BUILT_IN) +#define curlssl_random(x,y,z) ((void)x, (void)y, (void)z, CURLE_NOT_BUILT_IN) #endif /* USE_POLARSSL */ #endif /* HEADER_CURL_POLARSSL_H */ diff --git a/lib/vtls/polarssl_threadlock.c b/lib/vtls/polarssl_threadlock.c index ad18715..62abf43 100644 --- a/lib/vtls/polarssl_threadlock.c +++ b/lib/vtls/polarssl_threadlock.c @@ -36,10 +36,7 @@ #endif #include "polarssl_threadlock.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include - +#include "curl_printf.h" #include "curl_memory.h" /* The last #include file should be: */ #include "memdebug.h" diff --git a/lib/vtls/qssl.c b/lib/vtls/qssl.c deleted file mode 100644 index 4c32053..0000000 --- a/lib/vtls/qssl.c +++ /dev/null @@ -1,527 +0,0 @@ -/*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - * Copyright (C) 1998 - 2013, Daniel Stenberg, , et al. - * - * This software is licensed as described in the file COPYING, which - * you should have received as part of this distribution. The terms - * are also available at http://curl.haxx.se/docs/copyright.html. - * - * You may opt to use, copy, modify, merge, publish, distribute and/or sell - * copies of the Software, and permit persons to whom the Software is - * furnished to do so, under the terms of the COPYING file. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ***************************************************************************/ - -#include "curl_setup.h" - -#ifdef USE_QSOSSL - -#include - -#ifdef HAVE_LIMITS_H -# include -#endif - -#include -#include "urldata.h" -#include "sendf.h" -#include "qssl.h" -#include "vtls.h" -#include "connect.h" /* for the connect timeout */ -#include "select.h" -#include "x509asn1.h" -#include "curl_memory.h" -/* The last #include file should be: */ -#include "memdebug.h" - - -int Curl_qsossl_init(void) - -{ - /* Nothing to do here. We must have connection data to initialize ssl, so - * defer. - */ - - return 1; -} - - -void Curl_qsossl_cleanup(void) - -{ - /* Nothing to do. */ -} - - -static CURLcode Curl_qsossl_init_session(struct SessionHandle * data) - -{ - int rc; - char * certname; - SSLInit initstr; - SSLInitApp initappstr; - - /* Initialize the job for SSL according to the current parameters. - * QsoSSL offers two ways to do it: SSL_Init_Application() that uses an - * application identifier to select certificates in the main certificate - * store, and SSL_Init() that uses named keyring files and a password. - * It is not possible to have different keyrings for the CAs and the - * local certificate. We thus use the certificate name to identify the - * keyring if given, else the CA file name. - * If the key file name is given, it is taken as the password for the - * keyring in certificate file. - * We first try to SSL_Init_Application(), then SSL_Init() if it failed. - */ - - certname = data->set.str[STRING_CERT]; - - if(!certname) { - certname = data->set.str[STRING_SSL_CAFILE]; - - if(!certname) - return CURLE_OK; /* Use previous setup. */ - } - - memset((char *) &initappstr, 0, sizeof initappstr); - initappstr.applicationID = certname; - initappstr.applicationIDLen = strlen(certname); - initappstr.protocol = SSL_VERSION_CURRENT; /* TLSV1 compat. SSLV[23]. */ - initappstr.sessionType = SSL_REGISTERED_AS_CLIENT; - rc = SSL_Init_Application(&initappstr); - - if(rc == SSL_ERROR_NOT_REGISTERED) { - initstr.keyringFileName = certname; - initstr.keyringPassword = data->set.str[STRING_KEY]; - initstr.cipherSuiteList = NULL; /* Use default. */ - initstr.cipherSuiteListLen = 0; - rc = SSL_Init(&initstr); - } - - switch (rc) { - - case 0: /* No error. */ - break; - - case SSL_ERROR_IO: - failf(data, "SSL_Init() I/O error: %s", strerror(errno)); - return CURLE_SSL_CONNECT_ERROR; - - case SSL_ERROR_BAD_CIPHER_SUITE: - return CURLE_SSL_CIPHER; - - case SSL_ERROR_KEYPASSWORD_EXPIRED: - case SSL_ERROR_NOT_REGISTERED: - return CURLE_SSL_CONNECT_ERROR; - - case SSL_ERROR_NO_KEYRING: - return CURLE_SSL_CACERT; - - case SSL_ERROR_CERT_EXPIRED: - return CURLE_SSL_CERTPROBLEM; - - default: - failf(data, "SSL_Init(): %s", SSL_Strerror(rc, NULL)); - return CURLE_SSL_CONNECT_ERROR; - } - - return CURLE_OK; -} - - -static CURLcode Curl_qsossl_create(struct connectdata * conn, int sockindex) - -{ - SSLHandle * h; - struct ssl_connect_data * connssl = &conn->ssl[sockindex]; - - h = SSL_Create(conn->sock[sockindex], SSL_ENCRYPT); - - if(!h) { - failf(conn->data, "SSL_Create() I/O error: %s", strerror(errno)); - return CURLE_SSL_CONNECT_ERROR; - } - - connssl->handle = h; - return CURLE_OK; -} - - -static int Curl_qsossl_trap_cert(SSLHandle * h) - -{ - return 1; /* Accept certificate. */ -} - - -static CURLcode Curl_qsossl_handshake(struct connectdata * conn, int sockindex) - -{ - int rc; - struct SessionHandle * data = conn->data; - struct ssl_connect_data * connssl = &conn->ssl[sockindex]; - SSLHandle * h = connssl->handle; - long timeout_ms; - - h->exitPgm = data->set.ssl.verifypeer? NULL: Curl_qsossl_trap_cert; - - /* figure out how long time we should wait at maximum */ - timeout_ms = Curl_timeleft(data, NULL, TRUE); - - if(timeout_ms < 0) { - /* time-out, bail out, go home */ - failf(data, "Connection time-out"); - return CURLE_OPERATION_TIMEDOUT; - } - - /* SSL_Handshake() timeout resolution is second, so round up. */ - h->timeout = (timeout_ms + 1000 - 1) / 1000; - - /* Set-up protocol. */ - - switch (data->set.ssl.version) { - - default: - case CURL_SSLVERSION_DEFAULT: - h->protocol = SSL_VERSION_CURRENT; /* TLSV1 compat. SSLV[23]. */ - break; - - case CURL_SSLVERSION_TLSv1: - h->protocol = TLS_VERSION_1; - break; - - case CURL_SSLVERSION_SSLv2: - h->protocol = SSL_VERSION_2; - break; - - case CURL_SSLVERSION_SSLv3: - h->protocol = SSL_VERSION_3; - break; - - case CURL_SSLVERSION_TLSv1_0: - case CURL_SSLVERSION_TLSv1_1: - case CURL_SSLVERSION_TLSv1_2: - failf(data, "TLS minor version cannot be set"); - return CURLE_SSL_CONNECT_ERROR; - } - - h->peerCert = NULL; - h->peerCertLen = 0; - rc = SSL_Handshake(h, SSL_HANDSHAKE_AS_CLIENT); - - switch (rc) { - - case 0: /* No error. */ - break; - - case SSL_ERROR_BAD_CERTIFICATE: - case SSL_ERROR_BAD_CERT_SIG: - case SSL_ERROR_NOT_TRUSTED_ROOT: - return CURLE_PEER_FAILED_VERIFICATION; - - case SSL_ERROR_BAD_CIPHER_SUITE: - case SSL_ERROR_NO_CIPHERS: - return CURLE_SSL_CIPHER; - - case SSL_ERROR_CERTIFICATE_REJECTED: - case SSL_ERROR_CERT_EXPIRED: - case SSL_ERROR_NO_CERTIFICATE: - return CURLE_SSL_CERTPROBLEM; - - case SSL_ERROR_IO: - failf(data, "SSL_Handshake() I/O error: %s", strerror(errno)); - return CURLE_SSL_CONNECT_ERROR; - - default: - failf(data, "SSL_Handshake(): %s", SSL_Strerror(rc, NULL)); - return CURLE_SSL_CONNECT_ERROR; - } - - /* Verify host. */ - rc = Curl_verifyhost(conn, h->peerCert, h->peerCert + h->peerCertLen); - if(rc != CURLE_OK) - return rc; - - /* Gather certificate info. */ - if(data->set.ssl.certinfo) { - if(Curl_ssl_init_certinfo(data, 1)) - return CURLE_OUT_OF_MEMORY; - if(h->peerCert) { - rc = Curl_extract_certinfo(conn, 0, h->peerCert, - h->peerCert + h->peerCertLen); - if(rc != CURLE_OK) - return rc; - } - } - - return CURLE_OK; -} - - -static Curl_recv qsossl_recv; -static Curl_send qsossl_send; - -CURLcode Curl_qsossl_connect(struct connectdata * conn, int sockindex) - -{ - struct SessionHandle * data = conn->data; - struct ssl_connect_data * connssl = &conn->ssl[sockindex]; - int rc; - - rc = Curl_qsossl_init_session(data); - - if(rc == CURLE_OK) { - rc = Curl_qsossl_create(conn, sockindex); - - if(rc == CURLE_OK) { - rc = Curl_qsossl_handshake(conn, sockindex); - if(rc != CURLE_OK) - SSL_Destroy(connssl->handle); - } - } - - if(rc == CURLE_OK) { - conn->recv[sockindex] = qsossl_recv; - conn->send[sockindex] = qsossl_send; - connssl->state = ssl_connection_complete; - } - else { - connssl->handle = NULL; - connssl->use = FALSE; - connssl->state = ssl_connection_none; - } - - return rc; -} - - -static int Curl_qsossl_close_one(struct ssl_connect_data * conn, - struct SessionHandle * data) - -{ - int rc; - - if(!conn->handle) - return 0; - - rc = SSL_Destroy(conn->handle); - - if(rc) { - if(rc == SSL_ERROR_IO) { - failf(data, "SSL_Destroy() I/O error: %s", strerror(errno)); - return -1; - } - - /* An SSL error. */ - failf(data, "SSL_Destroy() returned error %s", SSL_Strerror(rc, NULL)); - return -1; - } - - conn->handle = NULL; - return 0; -} - - -void Curl_qsossl_close(struct connectdata *conn, int sockindex) - -{ - struct SessionHandle *data = conn->data; - struct ssl_connect_data *connssl = &conn->ssl[sockindex]; - - if(connssl->use) - (void) Curl_qsossl_close_one(connssl, data); -} - - -int Curl_qsossl_close_all(struct SessionHandle * data) - -{ - /* Unimplemented. */ - (void) data; - return 0; -} - - -int Curl_qsossl_shutdown(struct connectdata * conn, int sockindex) - -{ - struct ssl_connect_data * connssl = &conn->ssl[sockindex]; - struct SessionHandle *data = conn->data; - ssize_t nread; - int what; - int rc; - char buf[120]; - - if(!connssl->handle) - return 0; - - if(data->set.ftp_ccc != CURLFTPSSL_CCC_ACTIVE) - return 0; - - if(Curl_qsossl_close_one(connssl, data)) - return -1; - - rc = 0; - - what = Curl_socket_ready(conn->sock[sockindex], - CURL_SOCKET_BAD, SSL_SHUTDOWN_TIMEOUT); - - for(;;) { - if(what < 0) { - /* anything that gets here is fatally bad */ - failf(data, "select/poll on SSL socket, errno: %d", SOCKERRNO); - rc = -1; - break; - } - - if(!what) { /* timeout */ - failf(data, "SSL shutdown timeout"); - break; - } - - /* Something to read, let's do it and hope that it is the close - notify alert from the server. No way to SSL_Read now, so use read(). */ - - nread = read(conn->sock[sockindex], buf, sizeof(buf)); - - if(nread < 0) { - failf(data, "read: %s", strerror(errno)); - rc = -1; - } - - if(nread <= 0) - break; - - what = Curl_socket_ready(conn->sock[sockindex], CURL_SOCKET_BAD, 0); - } - - return rc; -} - - -static ssize_t qsossl_send(struct connectdata * conn, int sockindex, - const void * mem, size_t len, CURLcode * curlcode) - -{ - /* SSL_Write() is said to return 'int' while write() and send() returns - 'size_t' */ - int rc; - - rc = SSL_Write(conn->ssl[sockindex].handle, (void *) mem, (int) len); - - if(rc < 0) { - switch(rc) { - - case SSL_ERROR_BAD_STATE: - /* The operation did not complete; the same SSL I/O function - should be called again later. This is basically an EWOULDBLOCK - equivalent. */ - *curlcode = CURLE_AGAIN; - return -1; - - case SSL_ERROR_IO: - switch (errno) { - case EWOULDBLOCK: - case EINTR: - *curlcode = CURLE_AGAIN; - return -1; - } - - failf(conn->data, "SSL_Write() I/O error: %s", strerror(errno)); - *curlcode = CURLE_SEND_ERROR; - return -1; - } - - /* An SSL error. */ - failf(conn->data, "SSL_Write() returned error %s", - SSL_Strerror(rc, NULL)); - *curlcode = CURLE_SEND_ERROR; - return -1; - } - - return (ssize_t) rc; /* number of bytes */ -} - - -static ssize_t qsossl_recv(struct connectdata * conn, int num, char * buf, - size_t buffersize, CURLcode * curlcode) - -{ - char error_buffer[120]; /* OpenSSL documents that this must be at - least 120 bytes long. */ - unsigned long sslerror; - int buffsize; - int nread; - - buffsize = (buffersize > (size_t)INT_MAX) ? INT_MAX : (int)buffersize; - nread = SSL_Read(conn->ssl[num].handle, buf, buffsize); - - if(nread < 0) { - /* failed SSL_read */ - - switch (nread) { - - case SSL_ERROR_BAD_STATE: - /* there's data pending, re-invoke SSL_Read(). */ - *curlcode = CURLE_AGAIN; - return -1; - - case SSL_ERROR_IO: - switch (errno) { - case EWOULDBLOCK: - *curlcode = CURLE_AGAIN; - return -1; - } - - failf(conn->data, "SSL_Read() I/O error: %s", strerror(errno)); - *curlcode = CURLE_RECV_ERROR; - return -1; - - default: - failf(conn->data, "SSL read error: %s", SSL_Strerror(nread, NULL)); - *curlcode = CURLE_RECV_ERROR; - return -1; - } - } - return (ssize_t) nread; -} - - -size_t Curl_qsossl_version(char * buffer, size_t size) - -{ - strncpy(buffer, "IBM OS/400 SSL", size); - return strlen(buffer); -} - - -int Curl_qsossl_check_cxn(struct connectdata * cxn) - -{ - int err; - int errlen; - - /* The only thing that can be tested here is at the socket level. */ - - if(!cxn->ssl[FIRSTSOCKET].handle) - return 0; /* connection has been closed */ - - err = 0; - errlen = sizeof err; - - if(getsockopt(cxn->sock[FIRSTSOCKET], SOL_SOCKET, SO_ERROR, - (unsigned char *) &err, &errlen) || - errlen != sizeof err || err) - return 0; /* connection has been closed */ - - return -1; /* connection status unknown */ -} - -#endif /* USE_QSOSSL */ diff --git a/lib/vtls/qssl.h b/lib/vtls/qssl.h deleted file mode 100644 index 9764eec..0000000 --- a/lib/vtls/qssl.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef HEADER_CURL_QSSL_H -#define HEADER_CURL_QSSL_H -/*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. - * - * This software is licensed as described in the file COPYING, which - * you should have received as part of this distribution. The terms - * are also available at http://curl.haxx.se/docs/copyright.html. - * - * You may opt to use, copy, modify, merge, publish, distribute and/or sell - * copies of the Software, and permit persons to whom the Software is - * furnished to do so, under the terms of the COPYING file. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ***************************************************************************/ -#include "curl_setup.h" - -/* - * This header should only be needed to get included by vtls.c and qssl.c - */ - -#include "urldata.h" - -#ifdef USE_QSOSSL -int Curl_qsossl_init(void); -void Curl_qsossl_cleanup(void); -CURLcode Curl_qsossl_connect(struct connectdata * conn, int sockindex); -void Curl_qsossl_close(struct connectdata *conn, int sockindex); -int Curl_qsossl_close_all(struct SessionHandle * data); -int Curl_qsossl_shutdown(struct connectdata * conn, int sockindex); - -size_t Curl_qsossl_version(char * buffer, size_t size); -int Curl_qsossl_check_cxn(struct connectdata * cxn); - -/* API setup for QsoSSL */ -#define curlssl_init Curl_qsossl_init -#define curlssl_cleanup Curl_qsossl_cleanup -#define curlssl_connect Curl_qsossl_connect - -/* No session handling for QsoSSL */ -#define curlssl_session_free(x) Curl_nop_stmt -#define curlssl_close_all Curl_qsossl_close_all -#define curlssl_close Curl_qsossl_close -#define curlssl_shutdown(x,y) Curl_qsossl_shutdown(x,y) -#define curlssl_set_engine(x,y) CURLE_NOT_BUILT_IN -#define curlssl_set_engine_default(x) CURLE_NOT_BUILT_IN -#define curlssl_engines_list(x) NULL -#define curlssl_version Curl_qsossl_version -#define curlssl_check_cxn(x) Curl_qsossl_check_cxn(x) -#define curlssl_data_pending(x,y) 0 -#define CURL_SSL_BACKEND CURLSSLBACKEND_QSOSSL -#endif /* USE_QSOSSL */ - -#endif /* HEADER_CURL_QSSL_H */ diff --git a/lib/vtls/curl_schannel.c b/lib/vtls/schannel.c similarity index 64% rename from lib/vtls/curl_schannel.c rename to lib/vtls/schannel.c index e4e595e..2174e21 100644 --- a/lib/vtls/curl_schannel.c +++ b/lib/vtls/schannel.c @@ -5,9 +5,9 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 2012 - 2014, Marc Hoersken, + * Copyright (C) 2012 - 2015, Marc Hoersken, * Copyright (C) 2012, Mark Salisbury, - * Copyright (C) 2012 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 2012 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -38,19 +38,6 @@ * Thanks for code and inspiration! */ -/* - * TODO list for TLS/SSL implementation: - * - implement client certificate authentication - * - implement custom server certificate validation - * - implement cipher/algorithm option - * - * Related articles on MSDN: - * - Getting a Certificate for Schannel - * http://msdn.microsoft.com/en-us/library/windows/desktop/aa375447.aspx - * - Specifying Schannel Ciphers and Cipher Strengths - * http://msdn.microsoft.com/en-us/library/windows/desktop/aa380161.aspx - */ - #include "curl_setup.h" #ifdef USE_SCHANNEL @@ -60,7 +47,7 @@ #endif #include "curl_sspi.h" -#include "curl_schannel.h" +#include "schannel.h" #include "vtls.h" #include "sendf.h" #include "connect.h" /* for the connect timeout */ @@ -69,10 +56,7 @@ #include "inet_pton.h" /* for IP addr SNI check */ #include "curl_multibyte.h" #include "warnless.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include - +#include "curl_printf.h" #include "curl_memory.h" /* The last #include file should be: */ #include "memdebug.h" @@ -121,13 +105,13 @@ schannel_connect_step1(struct connectdata *conn, int sockindex) struct in6_addr addr6; #endif TCHAR *host_name; - CURLcode code; + CURLcode result; infof(data, "schannel: SSL/TLS connection with %s port %hu (step 1/3)\n", conn->host.name, conn->remote_port); /* check for an existing re-usable credential handle */ - if(!Curl_ssl_getsessionid(conn, (void**)&old_cred, NULL)) { + if(!Curl_ssl_getsessionid(conn, (void **)&old_cred, NULL)) { connssl->cred = old_cred; infof(data, "schannel: re-using existing credential handle\n"); } @@ -141,60 +125,64 @@ schannel_connect_step1(struct connectdata *conn, int sockindex) /* certificate validation on CE doesn't seem to work right; we'll do it following a more manual process. */ schannel_cred.dwFlags = SCH_CRED_MANUAL_CRED_VALIDATION | - SCH_CRED_IGNORE_NO_REVOCATION_CHECK | - SCH_CRED_IGNORE_REVOCATION_OFFLINE; + SCH_CRED_IGNORE_NO_REVOCATION_CHECK | + SCH_CRED_IGNORE_REVOCATION_OFFLINE; #else - schannel_cred.dwFlags = SCH_CRED_AUTO_CRED_VALIDATION | - SCH_CRED_REVOCATION_CHECK_CHAIN; + schannel_cred.dwFlags = SCH_CRED_AUTO_CRED_VALIDATION; + if(data->set.ssl_no_revoke) + schannel_cred.dwFlags |= SCH_CRED_IGNORE_NO_REVOCATION_CHECK | + SCH_CRED_IGNORE_REVOCATION_OFFLINE; + else + schannel_cred.dwFlags |= SCH_CRED_REVOCATION_CHECK_CHAIN; #endif - infof(data, "schannel: checking server certificate revocation\n"); + if(data->set.ssl_no_revoke) + infof(data, "schannel: disabled server certificate revocation " + "checks\n"); + else + infof(data, "schannel: checking server certificate revocation\n"); } else { schannel_cred.dwFlags = SCH_CRED_MANUAL_CRED_VALIDATION | - SCH_CRED_IGNORE_NO_REVOCATION_CHECK | - SCH_CRED_IGNORE_REVOCATION_OFFLINE; - infof(data, "schannel: disable server certificate revocation checks\n"); + SCH_CRED_IGNORE_NO_REVOCATION_CHECK | + SCH_CRED_IGNORE_REVOCATION_OFFLINE; + infof(data, "schannel: disabled server certificate revocation checks\n"); } if(!data->set.ssl.verifyhost) { schannel_cred.dwFlags |= SCH_CRED_NO_SERVERNAME_CHECK; infof(data, "schannel: verifyhost setting prevents Schannel from " - "comparing the supplied target name with the subject " - "names in server certificates. Also disables SNI.\n"); + "comparing the supplied target name with the subject " + "names in server certificates. Also disables SNI.\n"); } switch(data->set.ssl.version) { - case CURL_SSLVERSION_TLSv1: - schannel_cred.grbitEnabledProtocols = SP_PROT_TLS1_0_CLIENT | - SP_PROT_TLS1_1_CLIENT | - SP_PROT_TLS1_2_CLIENT; - break; - case CURL_SSLVERSION_TLSv1_0: - schannel_cred.grbitEnabledProtocols = SP_PROT_TLS1_0_CLIENT; - break; - case CURL_SSLVERSION_TLSv1_1: - schannel_cred.grbitEnabledProtocols = SP_PROT_TLS1_1_CLIENT; - break; - case CURL_SSLVERSION_TLSv1_2: - schannel_cred.grbitEnabledProtocols = SP_PROT_TLS1_2_CLIENT; - break; - case CURL_SSLVERSION_SSLv3: - schannel_cred.grbitEnabledProtocols = SP_PROT_SSL3_CLIENT; - break; - case CURL_SSLVERSION_SSLv2: - schannel_cred.grbitEnabledProtocols = SP_PROT_SSL2_CLIENT; - break; - default: - schannel_cred.grbitEnabledProtocols = SP_PROT_TLS1_0_CLIENT | - SP_PROT_TLS1_1_CLIENT | - SP_PROT_TLS1_2_CLIENT | - SP_PROT_SSL3_CLIENT; - break; + default: + case CURL_SSLVERSION_DEFAULT: + case CURL_SSLVERSION_TLSv1: + schannel_cred.grbitEnabledProtocols = SP_PROT_TLS1_0_CLIENT | + SP_PROT_TLS1_1_CLIENT | + SP_PROT_TLS1_2_CLIENT; + break; + case CURL_SSLVERSION_TLSv1_0: + schannel_cred.grbitEnabledProtocols = SP_PROT_TLS1_0_CLIENT; + break; + case CURL_SSLVERSION_TLSv1_1: + schannel_cred.grbitEnabledProtocols = SP_PROT_TLS1_1_CLIENT; + break; + case CURL_SSLVERSION_TLSv1_2: + schannel_cred.grbitEnabledProtocols = SP_PROT_TLS1_2_CLIENT; + break; + case CURL_SSLVERSION_SSLv3: + schannel_cred.grbitEnabledProtocols = SP_PROT_SSL3_CLIENT; + break; + case CURL_SSLVERSION_SSLv2: + schannel_cred.grbitEnabledProtocols = SP_PROT_SSL2_CLIENT; + break; } /* allocate memory for the re-usable credential handle */ connssl->cred = (struct curl_schannel_cred *) - malloc(sizeof(struct curl_schannel_cred)); + malloc(sizeof(struct curl_schannel_cred)); if(!connssl->cred) { failf(data, "schannel: unable to allocate memory"); return CURLE_OUT_OF_MEMORY; @@ -202,9 +190,12 @@ schannel_connect_step1(struct connectdata *conn, int sockindex) memset(connssl->cred, 0, sizeof(struct curl_schannel_cred)); /* http://msdn.microsoft.com/en-us/library/windows/desktop/aa374716.aspx */ - sspi_status = s_pSecFn->AcquireCredentialsHandle(NULL, (TCHAR *)UNISP_NAME, - SECPKG_CRED_OUTBOUND, NULL, &schannel_cred, NULL, NULL, - &connssl->cred->cred_handle, &connssl->cred->time_stamp); + sspi_status = + s_pSecFn->AcquireCredentialsHandle(NULL, (TCHAR *)UNISP_NAME, + SECPKG_CRED_OUTBOUND, NULL, + &schannel_cred, NULL, NULL, + &connssl->cred->cred_handle, + &connssl->cred->time_stamp); if(sspi_status != SEC_E_OK) { if(sspi_status == SEC_E_WRONG_PRINCIPAL) @@ -233,12 +224,12 @@ schannel_connect_step1(struct connectdata *conn, int sockindex) /* setup request flags */ connssl->req_flags = ISC_REQ_SEQUENCE_DETECT | ISC_REQ_REPLAY_DETECT | - ISC_REQ_CONFIDENTIALITY | ISC_REQ_ALLOCATE_MEMORY | - ISC_REQ_STREAM; + ISC_REQ_CONFIDENTIALITY | ISC_REQ_ALLOCATE_MEMORY | + ISC_REQ_STREAM; /* allocate memory for the security context handle */ connssl->ctxt = (struct curl_schannel_ctxt *) - malloc(sizeof(struct curl_schannel_ctxt)); + malloc(sizeof(struct curl_schannel_ctxt)); if(!connssl->ctxt) { failf(data, "schannel: unable to allocate memory"); return CURLE_OUT_OF_MEMORY; @@ -273,10 +264,10 @@ schannel_connect_step1(struct connectdata *conn, int sockindex) "sending %lu bytes...\n", outbuf.cbBuffer); /* send initial handshake data which is now stored in output buffer */ - code = Curl_write_plain(conn, conn->sock[sockindex], outbuf.pvBuffer, - outbuf.cbBuffer, &written); + result = Curl_write_plain(conn, conn->sock[sockindex], outbuf.pvBuffer, + outbuf.cbBuffer, &written); s_pSecFn->FreeContextBuffer(outbuf.pvBuffer); - if((code != CURLE_OK) || (outbuf.cbBuffer != (size_t)written)) { + if((result != CURLE_OK) || (outbuf.cbBuffer != (size_t) written)) { failf(data, "schannel: failed to send initial handshake data: " "sent %zd of %lu bytes", written, outbuf.cbBuffer); return CURLE_SSL_CONNECT_ERROR; @@ -285,6 +276,10 @@ schannel_connect_step1(struct connectdata *conn, int sockindex) infof(data, "schannel: sent initial handshake data: " "sent %zd bytes\n", written); + connssl->recv_unrecoverable_err = CURLE_OK; + connssl->recv_sspi_close_notify = false; + connssl->recv_connection_closed = false; + /* continue to second handshake step */ connssl->connecting_state = ssl_connect_2; @@ -298,13 +293,15 @@ schannel_connect_step2(struct connectdata *conn, int sockindex) ssize_t nread = -1, written = -1; struct SessionHandle *data = conn->data; struct ssl_connect_data *connssl = &conn->ssl[sockindex]; - SecBuffer outbuf[2]; + unsigned char *reallocated_buffer; + size_t reallocated_length; + SecBuffer outbuf[3]; SecBufferDesc outbuf_desc; SecBuffer inbuf[2]; SecBufferDesc inbuf_desc; SECURITY_STATUS sspi_status = SEC_E_OK; TCHAR *host_name; - CURLcode code; + CURLcode result; bool doread; doread = (connssl->connecting_state != ssl_connect_2_writing) ? TRUE : FALSE; @@ -315,6 +312,17 @@ schannel_connect_step2(struct connectdata *conn, int sockindex) if(!connssl->cred || !connssl->ctxt) return CURLE_SSL_CONNECT_ERROR; + /* buffer to store previously received and decrypted data */ + if(connssl->decdata_buffer == NULL) { + connssl->decdata_offset = 0; + connssl->decdata_length = CURL_SCHANNEL_BUFFER_INIT_SIZE; + connssl->decdata_buffer = malloc(connssl->decdata_length); + if(connssl->decdata_buffer == NULL) { + failf(data, "schannel: unable to allocate memory"); + return CURLE_OUT_OF_MEMORY; + } + } + /* buffer to store previously received and encrypted data */ if(connssl->encdata_buffer == NULL) { connssl->encdata_offset = 0; @@ -330,31 +338,38 @@ schannel_connect_step2(struct connectdata *conn, int sockindex) if(connssl->encdata_length - connssl->encdata_offset < CURL_SCHANNEL_BUFFER_FREE_SIZE) { /* increase internal encrypted data buffer */ - connssl->encdata_length *= CURL_SCHANNEL_BUFFER_STEP_FACTOR; - connssl->encdata_buffer = realloc(connssl->encdata_buffer, - connssl->encdata_length); + reallocated_length = connssl->encdata_offset + + CURL_SCHANNEL_BUFFER_FREE_SIZE; + reallocated_buffer = realloc(connssl->encdata_buffer, + reallocated_length); - if(connssl->encdata_buffer == NULL) { + if(reallocated_buffer == NULL) { failf(data, "schannel: unable to re-allocate memory"); return CURLE_OUT_OF_MEMORY; } + else { + connssl->encdata_buffer = reallocated_buffer; + connssl->encdata_length = reallocated_length; + } } for(;;) { if(doread) { /* read encrypted handshake data from socket */ - code = Curl_read_plain(conn->sock[sockindex], - (char *) (connssl->encdata_buffer + connssl->encdata_offset), - connssl->encdata_length - connssl->encdata_offset, - &nread); - if(code == CURLE_AGAIN) { + result = Curl_read_plain(conn->sock[sockindex], + (char *) (connssl->encdata_buffer + + connssl->encdata_offset), + connssl->encdata_length - + connssl->encdata_offset, + &nread); + if(result == CURLE_AGAIN) { if(connssl->connecting_state != ssl_connect_2_writing) connssl->connecting_state = ssl_connect_2_reading; infof(data, "schannel: failed to receive handshake, " "need more data\n"); return CURLE_OK; } - else if((code != CURLE_OK) || (nread == 0)) { + else if((result != CURLE_OK) || (nread == 0)) { failf(data, "schannel: failed to receive handshake, " "SSL/TLS connection failed"); return CURLE_SSL_CONNECT_ERROR; @@ -365,7 +380,7 @@ schannel_connect_step2(struct connectdata *conn, int sockindex) } infof(data, "schannel: encrypted data buffer: offset %zu length %zu\n", - connssl->encdata_offset, connssl->encdata_length); + connssl->encdata_offset, connssl->encdata_length); /* setup input buffers */ InitSecBuffer(&inbuf[0], SECBUFFER_TOKEN, malloc(connssl->encdata_offset), @@ -376,7 +391,8 @@ schannel_connect_step2(struct connectdata *conn, int sockindex) /* setup output buffers */ InitSecBuffer(&outbuf[0], SECBUFFER_TOKEN, NULL, 0); InitSecBuffer(&outbuf[1], SECBUFFER_ALERT, NULL, 0); - InitSecBufferDesc(&outbuf_desc, outbuf, 2); + InitSecBuffer(&outbuf[2], SECBUFFER_EMPTY, NULL, 0); + InitSecBufferDesc(&outbuf_desc, outbuf, 3); if(inbuf[0].pvBuffer == NULL) { failf(data, "schannel: unable to allocate memory"); @@ -410,19 +426,31 @@ schannel_connect_step2(struct connectdata *conn, int sockindex) return CURLE_OK; } + /* If the server has requested a client certificate, attempt to continue + the handshake without one. This will allow connections to servers which + request a client certificate but do not require it. */ + if(sspi_status == SEC_I_INCOMPLETE_CREDENTIALS && + !(connssl->req_flags & ISC_REQ_USE_SUPPLIED_CREDS)) { + connssl->req_flags |= ISC_REQ_USE_SUPPLIED_CREDS; + connssl->connecting_state = ssl_connect_2_writing; + infof(data, "schannel: a client certificate has been requested\n"); + return CURLE_OK; + } + /* check if the handshake needs to be continued */ if(sspi_status == SEC_I_CONTINUE_NEEDED || sspi_status == SEC_E_OK) { - for(i = 0; i < 2; i++) { + for(i = 0; i < 3; i++) { /* search for handshake tokens that need to be send */ if(outbuf[i].BufferType == SECBUFFER_TOKEN && outbuf[i].cbBuffer > 0) { infof(data, "schannel: sending next handshake data: " "sending %lu bytes...\n", outbuf[i].cbBuffer); /* send handshake token to server */ - code = Curl_write_plain(conn, conn->sock[sockindex], - outbuf[i].pvBuffer, outbuf[i].cbBuffer, - &written); - if((code != CURLE_OK) || (outbuf[i].cbBuffer != (size_t)written)) { + result = Curl_write_plain(conn, conn->sock[sockindex], + outbuf[i].pvBuffer, outbuf[i].cbBuffer, + &written); + if((result != CURLE_OK) || + (outbuf[i].cbBuffer != (size_t) written)) { failf(data, "schannel: failed to send next handshake data: " "sent %zd of %lu bytes", written, outbuf[i].cbBuffer); return CURLE_SSL_CONNECT_ERROR; @@ -449,21 +477,21 @@ schannel_connect_step2(struct connectdata *conn, int sockindex) if(inbuf[1].BufferType == SECBUFFER_EXTRA && inbuf[1].cbBuffer > 0) { infof(data, "schannel: encrypted data length: %lu\n", inbuf[1].cbBuffer); /* - There are two cases where we could be getting extra data here: - 1) If we're renegotiating a connection and the handshake is already - complete (from the server perspective), it can encrypted app data - (not handshake data) in an extra buffer at this point. - 2) (sspi_status == SEC_I_CONTINUE_NEEDED) We are negotiating a - connection and this extra data is part of the handshake. - We should process the data immediately; waiting for the socket to - be ready may fail since the server is done sending handshake data. - */ + There are two cases where we could be getting extra data here: + 1) If we're renegotiating a connection and the handshake is already + complete (from the server perspective), it can encrypted app data + (not handshake data) in an extra buffer at this point. + 2) (sspi_status == SEC_I_CONTINUE_NEEDED) We are negotiating a + connection and this extra data is part of the handshake. + We should process the data immediately; waiting for the socket to + be ready may fail since the server is done sending handshake data. + */ /* check if the remaining data is less than the total amount and therefore begins after the already processed data */ if(connssl->encdata_offset > inbuf[1].cbBuffer) { memmove(connssl->encdata_buffer, (connssl->encdata_buffer + connssl->encdata_offset) - - inbuf[1].cbBuffer, inbuf[1].cbBuffer); + inbuf[1].cbBuffer, inbuf[1].cbBuffer); connssl->encdata_offset = inbuf[1].cbBuffer; if(sspi_status == SEC_I_CONTINUE_NEEDED) { doread = FALSE; @@ -502,11 +530,11 @@ schannel_connect_step2(struct connectdata *conn, int sockindex) static CURLcode schannel_connect_step3(struct connectdata *conn, int sockindex) { - CURLcode retcode = CURLE_OK; + CURLcode result = CURLE_OK; struct SessionHandle *data = conn->data; struct ssl_connect_data *connssl = &conn->ssl[sockindex]; struct curl_schannel_cred *old_cred = NULL; - int incache; + bool incache; DEBUGASSERT(ssl_connect_3 == connssl->connecting_state); @@ -539,20 +567,21 @@ schannel_connect_step3(struct connectdata *conn, int sockindex) } /* save the current session data for possible re-use */ - incache = !(Curl_ssl_getsessionid(conn, (void**)&old_cred, NULL)); + incache = !(Curl_ssl_getsessionid(conn, (void **)&old_cred, NULL)); if(incache) { if(old_cred != connssl->cred) { infof(data, "schannel: old credential handle is stale, removing\n"); - Curl_ssl_delsessionid(conn, (void*)old_cred); + Curl_ssl_delsessionid(conn, (void *)old_cred); incache = FALSE; } } + if(!incache) { - retcode = Curl_ssl_addsessionid(conn, (void*)connssl->cred, - sizeof(struct curl_schannel_cred)); - if(retcode) { + result = Curl_ssl_addsessionid(conn, (void *)connssl->cred, + sizeof(struct curl_schannel_cred)); + if(result) { failf(data, "schannel: failed to store credential handle"); - return retcode; + return result; } else { connssl->cred->cached = TRUE; @@ -569,7 +598,7 @@ static CURLcode schannel_connect_common(struct connectdata *conn, int sockindex, bool nonblocking, bool *done) { - CURLcode retcode; + CURLcode result; struct SessionHandle *data = conn->data; struct ssl_connect_data *connssl = &conn->ssl[sockindex]; curl_socket_t sockfd = conn->sock[sockindex]; @@ -592,9 +621,9 @@ schannel_connect_common(struct connectdata *conn, int sockindex, return CURLE_OPERATION_TIMEDOUT; } - retcode = schannel_connect_step1(conn, sockindex); - if(retcode) - return retcode; + result = schannel_connect_step1(conn, sockindex); + if(result) + return result; } while(ssl_connect_2 == connssl->connecting_state || @@ -646,19 +675,19 @@ schannel_connect_common(struct connectdata *conn, int sockindex, * ensuring that a client using select() or epoll() will always * have a valid fdset to wait on. */ - retcode = schannel_connect_step2(conn, sockindex); - if(retcode || (nonblocking && - (ssl_connect_2 == connssl->connecting_state || - ssl_connect_2_reading == connssl->connecting_state || - ssl_connect_2_writing == connssl->connecting_state))) - return retcode; + result = schannel_connect_step2(conn, sockindex); + if(result || (nonblocking && + (ssl_connect_2 == connssl->connecting_state || + ssl_connect_2_reading == connssl->connecting_state || + ssl_connect_2_writing == connssl->connecting_state))) + return result; } /* repeat step2 until all transactions are done. */ if(ssl_connect_3 == connssl->connecting_state) { - retcode = schannel_connect_step3(conn, sockindex); - if(retcode) - return retcode; + result = schannel_connect_step3(conn, sockindex); + if(result) + return result; } if(ssl_connect_done == connssl->connecting_state) { @@ -687,14 +716,14 @@ schannel_send(struct connectdata *conn, int sockindex, SecBuffer outbuf[4]; SecBufferDesc outbuf_desc; SECURITY_STATUS sspi_status = SEC_E_OK; - CURLcode code; + CURLcode result; /* check if the maximum stream sizes were queried */ if(connssl->stream_sizes.cbMaximumMessage == 0) { sspi_status = s_pSecFn->QueryContextAttributes( - &connssl->ctxt->ctxt_handle, - SECPKG_ATTR_STREAM_SIZES, - &connssl->stream_sizes); + &connssl->ctxt->ctxt_handle, + SECPKG_ATTR_STREAM_SIZES, + &connssl->stream_sizes); if(sspi_status != SEC_E_OK) { *err = CURLE_SEND_ERROR; return -1; @@ -709,8 +738,8 @@ schannel_send(struct connectdata *conn, int sockindex, /* calculate the complete message length and allocate a buffer for it */ data_len = connssl->stream_sizes.cbHeader + len + - connssl->stream_sizes.cbTrailer; - data = (unsigned char*) malloc(data_len); + connssl->stream_sizes.cbTrailer; + data = (unsigned char *) malloc(data_len); if(data == NULL) { *err = CURLE_OUT_OF_MEMORY; return -1; @@ -742,19 +771,19 @@ schannel_send(struct connectdata *conn, int sockindex, len = outbuf[0].cbBuffer + outbuf[1].cbBuffer + outbuf[2].cbBuffer; /* - It's important to send the full message which includes the header, - encrypted payload, and trailer. Until the client receives all the - data a coherent message has not been delivered and the client - can't read any of it. - - If we wanted to buffer the unwritten encrypted bytes, we would - tell the client that all data it has requested to be sent has been - sent. The unwritten encrypted bytes would be the first bytes to - send on the next invocation. - Here's the catch with this - if we tell the client that all the - bytes have been sent, will the client call this method again to - send the buffered data? Looking at who calls this function, it - seems the answer is NO. + It's important to send the full message which includes the header, + encrypted payload, and trailer. Until the client receives all the + data a coherent message has not been delivered and the client + can't read any of it. + + If we wanted to buffer the unwritten encrypted bytes, we would + tell the client that all data it has requested to be sent has been + sent. The unwritten encrypted bytes would be the first bytes to + send on the next invocation. + Here's the catch with this - if we tell the client that all the + bytes have been sent, will the client call this method again to + send the buffered data? Looking at who calls this function, it + seems the answer is NO. */ /* send entire message or fail */ @@ -793,12 +822,12 @@ schannel_send(struct connectdata *conn, int sockindex, } /* socket is writable */ - code = Curl_write_plain(conn, conn->sock[sockindex], data + written, - len - written, &this_write); - if(code == CURLE_AGAIN) + result = Curl_write_plain(conn, conn->sock[sockindex], data + written, + len - written, &this_write); + if(result == CURLE_AGAIN) continue; - else if(code != CURLE_OK) { - *err = code; + else if(result != CURLE_OK) { + *err = result; written = -1; break; } @@ -828,71 +857,112 @@ schannel_recv(struct connectdata *conn, int sockindex, char *buf, size_t len, CURLcode *err) { size_t size = 0; - ssize_t nread = 0, ret = -1; - CURLcode retcode; + ssize_t nread = -1; struct SessionHandle *data = conn->data; struct ssl_connect_data *connssl = &conn->ssl[sockindex]; + unsigned char *reallocated_buffer; + size_t reallocated_length; bool done = FALSE; SecBuffer inbuf[4]; SecBufferDesc inbuf_desc; SECURITY_STATUS sspi_status = SEC_E_OK; + /* we want the length of the encrypted buffer to be at least large enough + that it can hold all the bytes requested and some TLS record overhead. */ + size_t min_encdata_length = len + CURL_SCHANNEL_BUFFER_FREE_SIZE; + + /**************************************************************************** + * Don't return or set connssl->recv_unrecoverable_err unless in the cleanup. + * The pattern for return error is set *err, optional infof, goto cleanup. + * + * Our priority is to always return as much decrypted data to the caller as + * possible, even if an error occurs. The state of the decrypted buffer must + * always be valid. Transfer of decrypted data to the caller's buffer is + * handled in the cleanup. + */ infof(data, "schannel: client wants to read %zu bytes\n", len); *err = CURLE_OK; - /* buffer to store previously received and decrypted data */ - if(connssl->decdata_buffer == NULL) { - connssl->decdata_offset = 0; - connssl->decdata_length = CURL_SCHANNEL_BUFFER_INIT_SIZE; - connssl->decdata_buffer = malloc(connssl->decdata_length); - if(connssl->decdata_buffer == NULL) { - failf(data, "schannel: unable to allocate memory"); - *err = CURLE_OUT_OF_MEMORY; - return -1; - } + if(len && len <= connssl->decdata_offset) { + infof(data, "schannel: enough decrypted data is already available\n"); + goto cleanup; } + else if(connssl->recv_unrecoverable_err) { + *err = connssl->recv_unrecoverable_err; + infof(data, "schannel: an unrecoverable error occurred in a prior call\n"); + goto cleanup; + } + else if(connssl->recv_sspi_close_notify) { + /* once a server has indicated shutdown there is no more encrypted data */ + infof(data, "schannel: server indicated shutdown in a prior call\n"); + goto cleanup; + } + else if(!len) { + /* It's debatable what to return when !len. Regardless we can't return + immediately because there may be data to decrypt (in the case we want to + decrypt all encrypted cached data) so handle !len later in cleanup. + */ + ; /* do nothing */ + } + else if(!connssl->recv_connection_closed) { + /* increase enc buffer in order to fit the requested amount of data */ + size = connssl->encdata_length - connssl->encdata_offset; + if(size < CURL_SCHANNEL_BUFFER_FREE_SIZE || + connssl->encdata_length < min_encdata_length) { + reallocated_length = connssl->encdata_offset + + CURL_SCHANNEL_BUFFER_FREE_SIZE; + if(reallocated_length < min_encdata_length) { + reallocated_length = min_encdata_length; + } + reallocated_buffer = realloc(connssl->encdata_buffer, + reallocated_length); + if(reallocated_buffer == NULL) { + *err = CURLE_OUT_OF_MEMORY; + failf(data, "schannel: unable to re-allocate memory"); + goto cleanup; + } - /* increase buffer in order to fit the requested amount of data */ - while(connssl->encdata_length - connssl->encdata_offset < - CURL_SCHANNEL_BUFFER_FREE_SIZE || connssl->encdata_length < len) { - /* increase internal encrypted data buffer */ - connssl->encdata_length *= CURL_SCHANNEL_BUFFER_STEP_FACTOR; - connssl->encdata_buffer = realloc(connssl->encdata_buffer, - connssl->encdata_length); - - if(connssl->encdata_buffer == NULL) { - failf(data, "schannel: unable to re-allocate memory"); - *err = CURLE_OUT_OF_MEMORY; - return -1; + connssl->encdata_buffer = reallocated_buffer; + connssl->encdata_length = reallocated_length; + size = connssl->encdata_length - connssl->encdata_offset; + infof(data, "schannel: encdata_buffer resized %zu\n", + connssl->encdata_length); } - } - /* read encrypted data from socket */ - infof(data, "schannel: encrypted data buffer: offset %zu length %zu\n", - connssl->encdata_offset, connssl->encdata_length); - size = connssl->encdata_length - connssl->encdata_offset; - if(size > 0) { + infof(data, "schannel: encrypted data buffer: offset %zu length %zu\n", + connssl->encdata_offset, connssl->encdata_length); + + /* read encrypted data from socket */ *err = Curl_read_plain(conn->sock[sockindex], - (char *) (connssl->encdata_buffer + connssl->encdata_offset), + (char *)(connssl->encdata_buffer + + connssl->encdata_offset), size, &nread); - /* check for received data */ - if(*err != CURLE_OK) - ret = -1; - else { - if(nread > 0) - /* increase encrypted data buffer offset */ - connssl->encdata_offset += nread; - ret = nread; + if(*err) { + nread = -1; + if(*err == CURLE_AGAIN) + infof(data, "schannel: Curl_read_plain returned CURLE_AGAIN\n"); + else if(*err == CURLE_RECV_ERROR) + infof(data, "schannel: Curl_read_plain returned CURLE_RECV_ERROR\n"); + else + infof(data, "schannel: Curl_read_plain returned error %d\n", *err); + } + else if(nread == 0) { + connssl->recv_connection_closed = true; + infof(data, "schannel: server closed the connection\n"); + } + else if(nread > 0) { + connssl->encdata_offset += (size_t)nread; + infof(data, "schannel: encrypted data got %zd\n", nread); } - infof(data, "schannel: encrypted data got %zd\n", ret); } infof(data, "schannel: encrypted data buffer: offset %zu length %zu\n", connssl->encdata_offset, connssl->encdata_length); - /* check if we still have some data in our buffers */ + /* decrypt loop */ while(connssl->encdata_offset > 0 && sspi_status == SEC_E_OK && - connssl->decdata_offset < len) { + (!len || connssl->decdata_offset < len || + connssl->recv_connection_closed)) { /* prepare data buffer for DecryptMessage call */ InitSecBuffer(&inbuf[0], SECBUFFER_DATA, connssl->encdata_buffer, curlx_uztoul(connssl->encdata_offset)); @@ -901,25 +971,18 @@ schannel_recv(struct connectdata *conn, int sockindex, InitSecBuffer(&inbuf[1], SECBUFFER_EMPTY, NULL, 0); InitSecBuffer(&inbuf[2], SECBUFFER_EMPTY, NULL, 0); InitSecBuffer(&inbuf[3], SECBUFFER_EMPTY, NULL, 0); - InitSecBufferDesc(&inbuf_desc, inbuf, 4); /* http://msdn.microsoft.com/en-us/library/windows/desktop/aa375348.aspx */ sspi_status = s_pSecFn->DecryptMessage(&connssl->ctxt->ctxt_handle, &inbuf_desc, 0, NULL); - /* check if we need more data */ - if(sspi_status == SEC_E_INCOMPLETE_MESSAGE) { - infof(data, "schannel: failed to decrypt data, need more data\n"); - *err = CURLE_AGAIN; - return -1; - } - /* check if everything went fine (server may want to renegotiate - context) */ + or shutdown the connection context) */ if(sspi_status == SEC_E_OK || sspi_status == SEC_I_RENEGOTIATE || - sspi_status == SEC_I_CONTEXT_EXPIRED) { - /* check for successfully decrypted data */ + sspi_status == SEC_I_CONTEXT_EXPIRED) { + /* check for successfully decrypted data, even before actual + renegotiation or shutdown of the connection context */ if(inbuf[1].BufferType == SECBUFFER_DATA) { infof(data, "schannel: decrypted data length: %lu\n", inbuf[1].cbBuffer); @@ -927,23 +990,28 @@ schannel_recv(struct connectdata *conn, int sockindex, /* increase buffer in order to fit the received amount of data */ size = inbuf[1].cbBuffer > CURL_SCHANNEL_BUFFER_FREE_SIZE ? inbuf[1].cbBuffer : CURL_SCHANNEL_BUFFER_FREE_SIZE; - while(connssl->decdata_length - connssl->decdata_offset < size || - connssl->decdata_length < len) { + if(connssl->decdata_length - connssl->decdata_offset < size || + connssl->decdata_length < len) { /* increase internal decrypted data buffer */ - connssl->decdata_length *= CURL_SCHANNEL_BUFFER_STEP_FACTOR; - connssl->decdata_buffer = realloc(connssl->decdata_buffer, - connssl->decdata_length); - - if(connssl->decdata_buffer == NULL) { - failf(data, "schannel: unable to re-allocate memory"); + reallocated_length = connssl->decdata_offset + size; + /* make sure that the requested amount of data fits */ + if(reallocated_length < len) { + reallocated_length = len; + } + reallocated_buffer = realloc(connssl->decdata_buffer, + reallocated_length); + if(reallocated_buffer == NULL) { *err = CURLE_OUT_OF_MEMORY; - return -1; + failf(data, "schannel: unable to re-allocate memory"); + goto cleanup; } + connssl->decdata_buffer = reallocated_buffer; + connssl->decdata_length = reallocated_length; } /* copy decrypted data to internal buffer */ size = inbuf[1].cbBuffer; - if(size > 0) { + if(size) { memcpy(connssl->decdata_buffer + connssl->decdata_offset, inbuf[1].pvBuffer, size); connssl->decdata_offset += size; @@ -961,81 +1029,151 @@ schannel_recv(struct connectdata *conn, int sockindex, /* check if the remaining data is less than the total amount * and therefore begins after the already processed data - */ + */ if(connssl->encdata_offset > inbuf[3].cbBuffer) { /* move remaining encrypted data forward to the beginning of buffer */ memmove(connssl->encdata_buffer, (connssl->encdata_buffer + connssl->encdata_offset) - - inbuf[3].cbBuffer, inbuf[3].cbBuffer); + inbuf[3].cbBuffer, inbuf[3].cbBuffer); connssl->encdata_offset = inbuf[3].cbBuffer; } infof(data, "schannel: encrypted data cached: offset %zu length %zu\n", connssl->encdata_offset, connssl->encdata_length); } - else{ + else { /* reset encrypted buffer offset, because there is no data remaining */ connssl->encdata_offset = 0; } - } - /* check if server wants to renegotiate the connection context */ - if(sspi_status == SEC_I_RENEGOTIATE) { - infof(data, "schannel: remote party requests SSL/TLS renegotiation\n"); - - /* begin renegotiation */ - infof(data, "schannel: renegotiating SSL/TLS connection\n"); - connssl->state = ssl_connection_negotiating; - connssl->connecting_state = ssl_connect_2_writing; - retcode = schannel_connect_common(conn, sockindex, FALSE, &done); - if(retcode) - *err = retcode; - else { - infof(data, "schannel: SSL/TLS connection renegotiated\n"); + /* check if server wants to renegotiate the connection context */ + if(sspi_status == SEC_I_RENEGOTIATE) { + infof(data, "schannel: remote party requests renegotiation\n"); + if(*err && *err != CURLE_AGAIN) { + infof(data, "schannel: can't renogotiate, an error is pending\n"); + goto cleanup; + } + if(connssl->encdata_offset) { + *err = CURLE_RECV_ERROR; + infof(data, "schannel: can't renogotiate, " + "encrypted data available\n"); + goto cleanup; + } + /* begin renegotiation */ + infof(data, "schannel: renegotiating SSL/TLS connection\n"); + connssl->state = ssl_connection_negotiating; + connssl->connecting_state = ssl_connect_2_writing; + *err = schannel_connect_common(conn, sockindex, FALSE, &done); + if(*err) { + infof(data, "schannel: renegotiation failed\n"); + goto cleanup; + } /* now retry receiving data */ - return schannel_recv(conn, sockindex, buf, len, err); + sspi_status = SEC_E_OK; + infof(data, "schannel: SSL/TLS connection renegotiated\n"); + continue; } + /* check if the server closed the connection */ + else if(sspi_status == SEC_I_CONTEXT_EXPIRED) { + /* In Windows 2000 SEC_I_CONTEXT_EXPIRED (close_notify) is not + returned so we have to work around that in cleanup. */ + connssl->recv_sspi_close_notify = true; + if(!connssl->recv_connection_closed) { + connssl->recv_connection_closed = true; + infof(data, "schannel: server closed the connection\n"); + } + goto cleanup; + } + } + else if(sspi_status == SEC_E_INCOMPLETE_MESSAGE) { + if(!*err) + *err = CURLE_AGAIN; + infof(data, "schannel: failed to decrypt data, need more data\n"); + goto cleanup; + } + else { + *err = CURLE_RECV_ERROR; + infof(data, "schannel: failed to read data from server: %s\n", + Curl_sspi_strerror(conn, sspi_status)); + goto cleanup; } } + infof(data, "schannel: encrypted data buffer: offset %zu length %zu\n", + connssl->encdata_offset, connssl->encdata_length); + infof(data, "schannel: decrypted data buffer: offset %zu length %zu\n", connssl->decdata_offset, connssl->decdata_length); - /* copy requested decrypted data to supplied buffer */ +cleanup: + /* Warning- there is no guarantee the encdata state is valid at this point */ + infof(data, "schannel: schannel_recv cleanup\n"); + + /* Error if the connection has closed without a close_notify. + Behavior here is a matter of debate. We don't want to be vulnerable to a + truncation attack however there's some browser precedent for ignoring the + close_notify for compatibility reasons. + Additionally, Windows 2000 (v5.0) is a special case since it seems it doesn't + return close_notify. In that case if the connection was closed we assume it + was graceful (close_notify) since there doesn't seem to be a way to tell. + */ + if(len && !connssl->decdata_offset && connssl->recv_connection_closed && + !connssl->recv_sspi_close_notify) { + BOOL isWin2k; + ULONGLONG cm; + OSVERSIONINFOEX osver; + + memset(&osver, 0, sizeof(osver)); + osver.dwOSVersionInfoSize = sizeof(osver); + osver.dwMajorVersion = 5; + + cm = VerSetConditionMask(0, VER_MAJORVERSION, VER_EQUAL); + cm = VerSetConditionMask(cm, VER_MINORVERSION, VER_EQUAL); + cm = VerSetConditionMask(cm, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL); + cm = VerSetConditionMask(cm, VER_SERVICEPACKMINOR, VER_GREATER_EQUAL); + + isWin2k = VerifyVersionInfo(&osver, + (VER_MAJORVERSION | VER_MINORVERSION | + VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR), + cm); + + if(isWin2k && sspi_status == SEC_E_OK) + connssl->recv_sspi_close_notify = true; + else { + *err = CURLE_RECV_ERROR; + infof(data, "schannel: server closed abruptly (missing close_notify)\n"); + } + } + + /* Any error other than CURLE_AGAIN is an unrecoverable error. */ + if(*err && *err != CURLE_AGAIN) + connssl->recv_unrecoverable_err = *err; + size = len < connssl->decdata_offset ? len : connssl->decdata_offset; - if(size > 0) { + if(size) { memcpy(buf, connssl->decdata_buffer, size); - ret = size; - - /* move remaining decrypted data forward to the beginning of buffer */ memmove(connssl->decdata_buffer, connssl->decdata_buffer + size, connssl->decdata_offset - size); connssl->decdata_offset -= size; - infof(data, "schannel: decrypted data returned %zd\n", size); + infof(data, "schannel: decrypted data returned %zu\n", size); infof(data, "schannel: decrypted data buffer: offset %zu length %zu\n", connssl->decdata_offset, connssl->decdata_length); - } - - /* check if the server closed the connection */ - if(ret <= 0 && ( /* special check for Windows 2000 Professional */ - sspi_status == SEC_I_CONTEXT_EXPIRED || (sspi_status == SEC_E_OK && - connssl->encdata_offset > 0 && connssl->encdata_buffer[0] == 0x15))) { - infof(data, "schannel: server closed the connection\n"); *err = CURLE_OK; - return 0; + return (ssize_t)size; } - /* check if something went wrong and we need to return an error */ - if(ret < 0 && sspi_status != SEC_E_OK) { - infof(data, "schannel: failed to read data from server: %s\n", - Curl_sspi_strerror(conn, sspi_status)); - *err = CURLE_RECV_ERROR; - return -1; - } + if(!*err && !connssl->recv_connection_closed) + *err = CURLE_AGAIN; + + /* It's debatable what to return when !len. We could return whatever error we + got from decryption but instead we override here so the return is consistent. + */ + if(!len) + *err = CURLE_OK; - return ret; + return *err ? -1 : 0; } CURLcode @@ -1048,12 +1186,12 @@ Curl_schannel_connect_nonblocking(struct connectdata *conn, int sockindex, CURLcode Curl_schannel_connect(struct connectdata *conn, int sockindex) { - CURLcode retcode; + CURLcode result; bool done = FALSE; - retcode = schannel_connect_common(conn, sockindex, FALSE, &done); - if(retcode) - return retcode; + result = schannel_connect_common(conn, sockindex, FALSE, &done); + if(result) + return result; DEBUGASSERT(done); @@ -1095,7 +1233,7 @@ int Curl_schannel_shutdown(struct connectdata *conn, int sockindex) SECURITY_STATUS sspi_status; SecBuffer outbuf; SecBufferDesc outbuf_desc; - CURLcode code; + CURLcode result; TCHAR *host_name; DWORD dwshut = SCHANNEL_SHUTDOWN; @@ -1118,56 +1256,56 @@ int Curl_schannel_shutdown(struct connectdata *conn, int sockindex) InitSecBufferDesc(&outbuf_desc, &outbuf, 1); sspi_status = s_pSecFn->InitializeSecurityContext( - &connssl->cred->cred_handle, - &connssl->ctxt->ctxt_handle, - host_name, - connssl->req_flags, - 0, - 0, - NULL, - 0, - &connssl->ctxt->ctxt_handle, - &outbuf_desc, - &connssl->ret_flags, - &connssl->ctxt->time_stamp); + &connssl->cred->cred_handle, + &connssl->ctxt->ctxt_handle, + host_name, + connssl->req_flags, + 0, + 0, + NULL, + 0, + &connssl->ctxt->ctxt_handle, + &outbuf_desc, + &connssl->ret_flags, + &connssl->ctxt->time_stamp); Curl_unicodefree(host_name); if((sspi_status == SEC_E_OK) || (sspi_status == SEC_I_CONTEXT_EXPIRED)) { /* send close message which is in output buffer */ ssize_t written; - code = Curl_write_plain(conn, conn->sock[sockindex], outbuf.pvBuffer, - outbuf.cbBuffer, &written); + result = Curl_write_plain(conn, conn->sock[sockindex], outbuf.pvBuffer, + outbuf.cbBuffer, &written); s_pSecFn->FreeContextBuffer(outbuf.pvBuffer); - if((code != CURLE_OK) || (outbuf.cbBuffer != (size_t)written)) { + if((result != CURLE_OK) || (outbuf.cbBuffer != (size_t) written)) { infof(data, "schannel: failed to send close msg: %s" - " (bytes written: %zd)\n", curl_easy_strerror(code), written); + " (bytes written: %zd)\n", curl_easy_strerror(result), written); } } + } - /* free SSPI Schannel API security context handle */ - if(connssl->ctxt) { - infof(data, "schannel: clear security context handle\n"); - s_pSecFn->DeleteSecurityContext(&connssl->ctxt->ctxt_handle); - Curl_safefree(connssl->ctxt); - } + /* free SSPI Schannel API security context handle */ + if(connssl->ctxt) { + infof(data, "schannel: clear security context handle\n"); + s_pSecFn->DeleteSecurityContext(&connssl->ctxt->ctxt_handle); + Curl_safefree(connssl->ctxt); + } - /* free SSPI Schannel API credential handle */ - if(connssl->cred) { - /* decrement the reference counter of the credential/session handle */ - if(connssl->cred->refcount > 0) { - connssl->cred->refcount--; - infof(data, "schannel: decremented credential handle refcount = %d\n", - connssl->cred->refcount); - } + /* free SSPI Schannel API credential handle */ + if(connssl->cred) { + /* decrement the reference counter of the credential/session handle */ + if(connssl->cred->refcount > 0) { + connssl->cred->refcount--; + infof(data, "schannel: decremented credential handle refcount = %d\n", + connssl->cred->refcount); + } - /* if the handle was not cached and the refcount is zero */ - if(!connssl->cred->cached && connssl->cred->refcount == 0) { - infof(data, "schannel: clear credential handle\n"); - s_pSecFn->FreeCredentialsHandle(&connssl->cred->cred_handle); - Curl_safefree(connssl->cred); - } + /* if the handle was not cached and the refcount is zero */ + if(!connssl->cred->cached && connssl->cred->refcount == 0) { + infof(data, "schannel: clear credential handle\n"); + s_pSecFn->FreeCredentialsHandle(&connssl->cred->cred_handle); + Curl_safefree(connssl->cred); } } @@ -1192,9 +1330,14 @@ void Curl_schannel_session_free(void *ptr) { struct curl_schannel_cred *cred = ptr; - if(cred && cred->cached && cred->refcount == 0) { - s_pSecFn->FreeCredentialsHandle(&cred->cred_handle); - Curl_safefree(cred); + if(cred && cred->cached) { + if(cred->refcount == 0) { + s_pSecFn->FreeCredentialsHandle(&cred->cred_handle); + Curl_safefree(cred); + } + else { + cred->cached = FALSE; + } } } @@ -1262,7 +1405,8 @@ static CURLcode verify_certificate(struct connectdata *conn, int sockindex) NULL, pCertContextServer->hCertStore, &ChainPara, - 0, + (data->set.ssl_no_revoke ? 0 : + CERT_CHAIN_REVOCATION_CHECK_CHAIN), NULL, &pChainContext)) { failf(data, "schannel: CertGetCertificateChain failed: %s", @@ -1273,21 +1417,24 @@ static CURLcode verify_certificate(struct connectdata *conn, int sockindex) if(result == CURLE_OK) { CERT_SIMPLE_CHAIN *pSimpleChain = pChainContext->rgpChain[0]; - DWORD dwTrustErrorMask = ~(DWORD)(CERT_TRUST_IS_NOT_TIME_NESTED| - CERT_TRUST_REVOCATION_STATUS_UNKNOWN); + DWORD dwTrustErrorMask = ~(DWORD)(CERT_TRUST_IS_NOT_TIME_NESTED); dwTrustErrorMask &= pSimpleChain->TrustStatus.dwErrorStatus; if(dwTrustErrorMask) { - if(dwTrustErrorMask & CERT_TRUST_IS_PARTIAL_CHAIN) + if(dwTrustErrorMask & CERT_TRUST_IS_REVOKED) + failf(data, "schannel: CertGetCertificateChain trust error" + " CERT_TRUST_IS_REVOKED"); + else if(dwTrustErrorMask & CERT_TRUST_IS_PARTIAL_CHAIN) failf(data, "schannel: CertGetCertificateChain trust error" - " CERT_TRUST_IS_PARTIAL_CHAIN"); - if(dwTrustErrorMask & CERT_TRUST_IS_UNTRUSTED_ROOT) + " CERT_TRUST_IS_PARTIAL_CHAIN"); + else if(dwTrustErrorMask & CERT_TRUST_IS_UNTRUSTED_ROOT) failf(data, "schannel: CertGetCertificateChain trust error" - " CERT_TRUST_IS_UNTRUSTED_ROOT"); - if(dwTrustErrorMask & CERT_TRUST_IS_NOT_TIME_VALID) + " CERT_TRUST_IS_UNTRUSTED_ROOT"); + else if(dwTrustErrorMask & CERT_TRUST_IS_NOT_TIME_VALID) failf(data, "schannel: CertGetCertificateChain trust error" - " CERT_TRUST_IS_NOT_TIME_VALID"); - failf(data, "schannel: CertGetCertificateChain error mask: 0x%08x", - dwTrustErrorMask); + " CERT_TRUST_IS_NOT_TIME_VALID"); + else + failf(data, "schannel: CertGetCertificateChain error mask: 0x%08x", + dwTrustErrorMask); result = CURLE_PEER_FAILED_VERIFICATION; } } @@ -1303,6 +1450,14 @@ static CURLcode verify_certificate(struct connectdata *conn, int sockindex) cert_hostname.const_tchar_ptr = cert_hostname_buff; hostname.tchar_ptr = Curl_convert_UTF8_to_tchar(conn->host.name); + /* TODO: Fix this for certificates with multiple alternative names. + Right now we're only asking for the first preferred alternative name. + Instead we'd need to do all via CERT_NAME_SEARCH_ALL_NAMES_FLAG + (if WinCE supports that?) and run this section in a loop for each. + https://msdn.microsoft.com/en-us/library/windows/desktop/aa376086.aspx + curl: (51) schannel: CertGetNameString() certificate hostname + (.google.com) did not match connection (google.com) + */ len = CertGetNameString(pCertContextServer, CERT_NAME_DNS_TYPE, 0, diff --git a/lib/vtls/curl_schannel.h b/lib/vtls/schannel.h similarity index 80% rename from lib/vtls/curl_schannel.h rename to lib/vtls/schannel.h index 700516b..5329584 100644 --- a/lib/vtls/curl_schannel.h +++ b/lib/vtls/schannel.h @@ -8,7 +8,7 @@ * \___|\___/|_| \_\_____| * * Copyright (C) 2012, Marc Hoersken, , et al. - * Copyright (C) 2012 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 2012 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -72,30 +72,9 @@ #define SECBUFFER_ALERT 17 #endif -#ifndef ISC_RET_REPLAY_DETECT -#define ISC_RET_REPLAY_DETECT 0x00000004 -#endif - -#ifndef ISC_RET_SEQUENCE_DETECT -#define ISC_RET_SEQUENCE_DETECT 0x00000008 -#endif - -#ifndef ISC_RET_CONFIDENTIALITY -#define ISC_RET_CONFIDENTIALITY 0x00000010 -#endif - -#ifndef ISC_RET_ALLOCATED_MEMORY -#define ISC_RET_ALLOCATED_MEMORY 0x00000100 -#endif - -#ifndef ISC_RET_STREAM -#define ISC_RET_STREAM 0x00008000 -#endif - - +/* Both schannel buffer sizes must be > 0 */ #define CURL_SCHANNEL_BUFFER_INIT_SIZE 4096 #define CURL_SCHANNEL_BUFFER_FREE_SIZE 1024 -#define CURL_SCHANNEL_BUFFER_STEP_FACTOR 2 CURLcode Curl_schannel_connect(struct connectdata *conn, int sockindex); @@ -115,22 +94,24 @@ size_t Curl_schannel_version(char *buffer, size_t size); int Curl_schannel_random(unsigned char *entropy, size_t length); +/* Set the API backend definition to Schannel */ +#define CURL_SSL_BACKEND CURLSSLBACKEND_SCHANNEL + /* API setup for Schannel */ #define curlssl_init Curl_schannel_init #define curlssl_cleanup Curl_schannel_cleanup #define curlssl_connect Curl_schannel_connect #define curlssl_connect_nonblocking Curl_schannel_connect_nonblocking #define curlssl_session_free Curl_schannel_session_free -#define curlssl_close_all(x) (x=x, CURLE_NOT_BUILT_IN) +#define curlssl_close_all(x) ((void)x) #define curlssl_close Curl_schannel_close #define curlssl_shutdown Curl_schannel_shutdown -#define curlssl_set_engine(x,y) (x=x, y=y, CURLE_NOT_BUILT_IN) -#define curlssl_set_engine_default(x) (x=x, CURLE_NOT_BUILT_IN) -#define curlssl_engines_list(x) (x=x, (struct curl_slist *)NULL) +#define curlssl_set_engine(x,y) ((void)x, (void)y, CURLE_NOT_BUILT_IN) +#define curlssl_set_engine_default(x) ((void)x, CURLE_NOT_BUILT_IN) +#define curlssl_engines_list(x) ((void)x, (struct curl_slist *)NULL) #define curlssl_version Curl_schannel_version -#define curlssl_check_cxn(x) (x=x, -1) +#define curlssl_check_cxn(x) ((void)x, -1) #define curlssl_data_pending Curl_schannel_data_pending -#define CURL_SSL_BACKEND CURLSSLBACKEND_SCHANNEL #define curlssl_random(x,y,z) ((void)x, Curl_schannel_random(y,z)) #endif /* USE_SCHANNEL */ diff --git a/lib/vtls/vtls.c b/lib/vtls/vtls.c index 88511b8..01bbc61 100644 --- a/lib/vtls/vtls.c +++ b/lib/vtls/vtls.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -31,7 +31,6 @@ Curl_ossl_ - prefix for OpenSSL ones Curl_gtls_ - prefix for GnuTLS ones Curl_nss_ - prefix for NSS ones - Curl_qssl_ - prefix for QsoSSL ones Curl_gskit_ - prefix for GSKit ones Curl_polarssl_ - prefix for PolarSSL ones Curl_cyassl_ - prefix for CyaSSL ones @@ -60,29 +59,20 @@ #include "urldata.h" #include "vtls.h" /* generic SSL protos etc */ -#include "openssl.h" /* OpenSSL versions */ -#include "gtls.h" /* GnuTLS versions */ -#include "nssg.h" /* NSS versions */ -#include "qssl.h" /* QSOSSL versions */ -#include "gskit.h" /* Global Secure ToolKit versions */ -#include "polarssl.h" /* PolarSSL versions */ -#include "axtls.h" /* axTLS versions */ -#include "cyassl.h" /* CyaSSL versions */ -#include "curl_schannel.h" /* Schannel SSPI version */ -#include "curl_darwinssl.h" /* SecureTransport (Darwin) version */ #include "slist.h" #include "sendf.h" #include "rawstr.h" #include "url.h" -#include "curl_memory.h" #include "progress.h" #include "share.h" #include "timeval.h" +#include "curl_md5.h" +#include "warnless.h" +#include "curl_base64.h" +#include "curl_printf.h" -#define _MPRINTF_REPLACE /* use our functions only */ -#include - -/* The last #include file should be: */ +/* The last #include files should be: */ +#include "curl_memory.h" #include "memdebug.h" /* convenience macro to check if this handle is using a shared SSL session */ @@ -193,7 +183,7 @@ void Curl_free_ssl_config(struct ssl_config_data* sslc) unsigned int Curl_rand(struct SessionHandle *data) { - unsigned int r; + unsigned int r = 0; static unsigned int randseed; static bool seeded = FALSE; @@ -286,47 +276,66 @@ void Curl_ssl_cleanup(void) } } +static bool ssl_prefs_check(struct SessionHandle *data) +{ + /* check for CURLOPT_SSLVERSION invalid parameter value */ + if((data->set.ssl.version < 0) + || (data->set.ssl.version >= CURL_SSLVERSION_LAST)) { + failf(data, "Unrecognized parameter value passed via CURLOPT_SSLVERSION"); + return FALSE; + } + return TRUE; +} + CURLcode Curl_ssl_connect(struct connectdata *conn, int sockindex) { - CURLcode res; + CURLcode result; + + if(!ssl_prefs_check(conn->data)) + return CURLE_SSL_CONNECT_ERROR; + /* mark this is being ssl-enabled from here on. */ conn->ssl[sockindex].use = TRUE; conn->ssl[sockindex].state = ssl_connection_negotiating; - res = curlssl_connect(conn, sockindex); + result = curlssl_connect(conn, sockindex); - if(!res) + if(!result) Curl_pgrsTime(conn->data, TIMER_APPCONNECT); /* SSL is connected */ - return res; + return result; } CURLcode Curl_ssl_connect_nonblocking(struct connectdata *conn, int sockindex, bool *done) { - CURLcode res; + CURLcode result; + + if(!ssl_prefs_check(conn->data)) + return CURLE_SSL_CONNECT_ERROR; + /* mark this is being ssl requested from here on. */ conn->ssl[sockindex].use = TRUE; #ifdef curlssl_connect_nonblocking - res = curlssl_connect_nonblocking(conn, sockindex, done); + result = curlssl_connect_nonblocking(conn, sockindex, done); #else *done = TRUE; /* fallback to BLOCKING */ - res = curlssl_connect(conn, sockindex); + result = curlssl_connect(conn, sockindex); #endif /* non-blocking connect support */ - if(!res && *done) + if(!result && *done) Curl_pgrsTime(conn->data, TIMER_APPCONNECT); /* SSL is connected */ - return res; + return result; } /* * Check if there's a session ID for the given connection in the cache, and if * there's one suitable, it is provided. Returns TRUE when no entry matched. */ -int Curl_ssl_getsessionid(struct connectdata *conn, - void **ssl_sessionid, - size_t *idsize) /* set 0 if unknown */ +bool Curl_ssl_getsessionid(struct connectdata *conn, + void **ssl_sessionid, + size_t *idsize) /* set 0 if unknown */ { struct curl_ssl_session *check; struct SessionHandle *data = conn->data; @@ -473,9 +482,8 @@ CURLcode Curl_ssl_addsessionid(struct connectdata *conn, store->sessionid = ssl_sessionid; store->idsize = idsize; store->age = *general_age; /* set current age */ - if(store->name) /* free it if there's one already present */ - free(store->name); + free(store->name); store->name = clone_host; /* clone host name */ store->remote_port = conn->remote_port; /* port number */ @@ -601,34 +609,37 @@ void Curl_ssl_free_certinfo(struct SessionHandle *data) { int i; struct curl_certinfo *ci = &data->info.certs; + if(ci->num_of_certs) { /* free all individual lists used */ for(i=0; inum_of_certs; i++) { curl_slist_free_all(ci->certinfo[i]); ci->certinfo[i] = NULL; } + free(ci->certinfo); /* free the actual array too */ ci->certinfo = NULL; ci->num_of_certs = 0; } } -int Curl_ssl_init_certinfo(struct SessionHandle * data, - int num) +CURLcode Curl_ssl_init_certinfo(struct SessionHandle *data, int num) { - struct curl_certinfo * ci = &data->info.certs; - struct curl_slist * * table; + struct curl_certinfo *ci = &data->info.certs; + struct curl_slist **table; - /* Initialize the certificate information structures. Return 0 if OK, else 1. - */ + /* Free any previous certificate information structures */ Curl_ssl_free_certinfo(data); - ci->num_of_certs = num; + + /* Allocate the required certificate information structures */ table = calloc((size_t) num, sizeof(struct curl_slist *)); if(!table) - return 1; + return CURLE_OUT_OF_MEMORY; + ci->num_of_certs = num; ci->certinfo = table; - return 0; + + return CURLE_OK; } /* @@ -643,7 +654,7 @@ CURLcode Curl_ssl_push_certinfo_len(struct SessionHandle *data, struct curl_certinfo * ci = &data->info.certs; char * output; struct curl_slist * nl; - CURLcode res = CURLE_OK; + CURLcode result = CURLE_OK; size_t labellen = strlen(label); size_t outlen = labellen + 1 + valuelen + 1; /* label:value\0 */ @@ -664,11 +675,11 @@ CURLcode Curl_ssl_push_certinfo_len(struct SessionHandle *data, if(!nl) { free(output); curl_slist_free_all(ci->certinfo[certnum]); - res = CURLE_OUT_OF_MEMORY; + result = CURLE_OUT_OF_MEMORY; } ci->certinfo[certnum] = nl; - return res; + return result; } /* @@ -692,14 +703,260 @@ int Curl_ssl_random(struct SessionHandle *data, return curlssl_random(data, entropy, length); } -#ifdef have_curlssl_md5sum -void Curl_ssl_md5sum(unsigned char *tmp, /* input */ - size_t tmplen, - unsigned char *md5sum, /* output */ - size_t md5len) +/* + * Public key pem to der conversion + */ + +static CURLcode pubkey_pem_to_der(const char *pem, + unsigned char **der, size_t *der_len) +{ + char *stripped_pem, *begin_pos, *end_pos; + size_t pem_count, stripped_pem_count = 0, pem_len; + CURLcode result; + + /* if no pem, exit. */ + if(!pem) + return CURLE_BAD_CONTENT_ENCODING; + + begin_pos = strstr(pem, "-----BEGIN PUBLIC KEY-----"); + if(!begin_pos) + return CURLE_BAD_CONTENT_ENCODING; + + pem_count = begin_pos - pem; + /* Invalid if not at beginning AND not directly following \n */ + if(0 != pem_count && '\n' != pem[pem_count - 1]) + return CURLE_BAD_CONTENT_ENCODING; + + /* 26 is length of "-----BEGIN PUBLIC KEY-----" */ + pem_count += 26; + + /* Invalid if not directly following \n */ + end_pos = strstr(pem + pem_count, "\n-----END PUBLIC KEY-----"); + if(!end_pos) + return CURLE_BAD_CONTENT_ENCODING; + + pem_len = end_pos - pem; + + stripped_pem = malloc(pem_len - pem_count + 1); + if(!stripped_pem) + return CURLE_OUT_OF_MEMORY; + + /* + * Here we loop through the pem array one character at a time between the + * correct indices, and place each character that is not '\n' or '\r' + * into the stripped_pem array, which should represent the raw base64 string + */ + while(pem_count < pem_len) { + if('\n' != pem[pem_count] && '\r' != pem[pem_count]) + stripped_pem[stripped_pem_count++] = pem[pem_count]; + ++pem_count; + } + /* Place the null terminator in the correct place */ + stripped_pem[stripped_pem_count] = '\0'; + + result = Curl_base64_decode(stripped_pem, der, der_len); + + Curl_safefree(stripped_pem); + + return result; +} + +/* + * Generic pinned public key check. + */ + +CURLcode Curl_pin_peer_pubkey(const char *pinnedpubkey, + const unsigned char *pubkey, size_t pubkeylen) { + FILE *fp; + unsigned char *buf = NULL, *pem_ptr = NULL; + long filesize; + size_t size, pem_len; + CURLcode pem_read; + CURLcode result = CURLE_SSL_PINNEDPUBKEYNOTMATCH; +#ifdef curlssl_sha256sum + size_t pinkeylen; + char *pinkeycopy, *begin_pos, *end_pos; + unsigned char *sha256sumdigest = NULL, *expectedsha256sumdigest = NULL; +#endif + + /* if a path wasn't specified, don't pin */ + if(!pinnedpubkey) + return CURLE_OK; + if(!pubkey || !pubkeylen) + return result; + +#ifdef curlssl_sha256sum + /* only do this if pinnedpubkey starts with "sha256//", length 8 */ + if(strncmp(pinnedpubkey, "sha256//", 8) == 0) { + /* compute sha256sum of public key */ + sha256sumdigest = malloc(SHA256_DIGEST_LENGTH); + if(!sha256sumdigest) + return CURLE_OUT_OF_MEMORY; + curlssl_sha256sum(pubkey, pubkeylen, + sha256sumdigest, SHA256_DIGEST_LENGTH); + + /* it starts with sha256//, copy so we can modify it */ + pinkeylen = strlen(pinnedpubkey) + 1; + pinkeycopy = malloc(pinkeylen); + if(!pinkeycopy) { + Curl_safefree(sha256sumdigest); + return CURLE_OUT_OF_MEMORY; + } + memcpy(pinkeycopy, pinnedpubkey, pinkeylen); + /* point begin_pos to the copy, and start extracting keys */ + begin_pos = pinkeycopy; + do { + end_pos = strstr(begin_pos, ";sha256//"); + /* + * if there is an end_pos, null terminate, + * otherwise it'll go to the end of the original string + */ + if(end_pos) + end_pos[0] = '\0'; + + /* decode base64 pinnedpubkey, 8 is length of "sha256//" */ + pem_read = Curl_base64_decode(begin_pos + 8, + &expectedsha256sumdigest, &size); + /* if not valid base64, don't bother comparing or freeing */ + if(!pem_read) { + /* compare sha256 digests directly */ + if(SHA256_DIGEST_LENGTH == size && + !memcmp(sha256sumdigest, expectedsha256sumdigest, + SHA256_DIGEST_LENGTH)) { + result = CURLE_OK; + Curl_safefree(expectedsha256sumdigest); + break; + } + Curl_safefree(expectedsha256sumdigest); + } + + /* + * change back the null-terminator we changed earlier, + * and look for next begin + */ + if(end_pos) { + end_pos[0] = ';'; + begin_pos = strstr(end_pos, "sha256//"); + } + } while(end_pos && begin_pos); + Curl_safefree(sha256sumdigest); + Curl_safefree(pinkeycopy); + return result; + } +#endif + + fp = fopen(pinnedpubkey, "rb"); + if(!fp) + return result; + + do { + /* Determine the file's size */ + if(fseek(fp, 0, SEEK_END)) + break; + filesize = ftell(fp); + if(fseek(fp, 0, SEEK_SET)) + break; + if(filesize < 0 || filesize > MAX_PINNED_PUBKEY_SIZE) + break; + + /* + * if the size of our certificate is bigger than the file + * size then it can't match + */ + size = curlx_sotouz((curl_off_t) filesize); + if(pubkeylen > size) + break; + + /* + * Allocate buffer for the pinned key + * With 1 additional byte for null terminator in case of PEM key + */ + buf = malloc(size + 1); + if(!buf) + break; + + /* Returns number of elements read, which should be 1 */ + if((int) fread(buf, size, 1, fp) != 1) + break; + + /* If the sizes are the same, it can't be base64 encoded, must be der */ + if(pubkeylen == size) { + if(!memcmp(pubkey, buf, pubkeylen)) + result = CURLE_OK; + break; + } + + /* + * Otherwise we will assume it's PEM and try to decode it + * after placing null terminator + */ + buf[size] = '\0'; + pem_read = pubkey_pem_to_der((const char *)buf, &pem_ptr, &pem_len); + /* if it wasn't read successfully, exit */ + if(pem_read) + break; + + /* + * if the size of our certificate doesn't match the size of + * the decoded file, they can't be the same, otherwise compare + */ + if(pubkeylen == pem_len && !memcmp(pubkey, pem_ptr, pubkeylen)) + result = CURLE_OK; + } while(0); + + Curl_safefree(buf); + Curl_safefree(pem_ptr); + fclose(fp); + + return result; +} + +#ifndef CURL_DISABLE_CRYPTO_AUTH +CURLcode Curl_ssl_md5sum(unsigned char *tmp, /* input */ + size_t tmplen, + unsigned char *md5sum, /* output */ + size_t md5len) +{ +#ifdef curlssl_md5sum curlssl_md5sum(tmp, tmplen, md5sum, md5len); +#else + MD5_context *MD5pw; + + (void) md5len; + + MD5pw = Curl_MD5_init(Curl_DIGEST_MD5); + if(!MD5pw) + return CURLE_OUT_OF_MEMORY; + Curl_MD5_update(MD5pw, tmp, curlx_uztoui(tmplen)); + Curl_MD5_final(MD5pw, md5sum); +#endif + return CURLE_OK; +} +#endif + +/* + * Check whether the SSL backend supports the status_request extension. + */ +bool Curl_ssl_cert_status_request(void) +{ +#ifdef curlssl_cert_status_request + return curlssl_cert_status_request(); +#else + return FALSE; +#endif } + +/* + * Check whether the SSL backend supports false start. + */ +bool Curl_ssl_false_start(void) +{ +#ifdef curlssl_false_start + return curlssl_false_start(); +#else + return FALSE; #endif +} #endif /* USE_SSL */ diff --git a/lib/vtls/vtls.h b/lib/vtls/vtls.h index e21fdef..2349e5b 100644 --- a/lib/vtls/vtls.h +++ b/lib/vtls/vtls.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -23,10 +23,28 @@ ***************************************************************************/ #include "curl_setup.h" +#include "openssl.h" /* OpenSSL versions */ +#include "gtls.h" /* GnuTLS versions */ +#include "nssg.h" /* NSS versions */ +#include "gskit.h" /* Global Secure ToolKit versions */ +#include "polarssl.h" /* PolarSSL versions */ +#include "axtls.h" /* axTLS versions */ +#include "cyassl.h" /* CyaSSL versions */ +#include "schannel.h" /* Schannel SSPI version */ +#include "darwinssl.h" /* SecureTransport (Darwin) version */ + +#ifndef MAX_PINNED_PUBKEY_SIZE +#define MAX_PINNED_PUBKEY_SIZE 1048576 /* 1MB */ +#endif + #ifndef MD5_DIGEST_LENGTH #define MD5_DIGEST_LENGTH 16 /* fixed size */ #endif +#ifndef SHA256_DIGEST_LENGTH +#define SHA256_DIGEST_LENGTH 32 /* fixed size */ +#endif + /* see http://tools.ietf.org/html/draft-ietf-tls-applayerprotoneg-04 */ #define ALPN_HTTP_1_1_LENGTH 8 #define ALPN_HTTP_1_1 "http/1.1" @@ -68,7 +86,7 @@ int Curl_ssl_check_cxn(struct connectdata *conn); /* Certificate information list handling. */ void Curl_ssl_free_certinfo(struct SessionHandle *data); -int Curl_ssl_init_certinfo(struct SessionHandle * data, int num); +CURLcode Curl_ssl_init_certinfo(struct SessionHandle * data, int num); CURLcode Curl_ssl_push_certinfo_len(struct SessionHandle * data, int certnum, const char * label, const char * value, size_t valuelen); @@ -78,9 +96,9 @@ CURLcode Curl_ssl_push_certinfo(struct SessionHandle * data, int certnum, /* Functions to be used by SSL library adaptation functions */ /* extract a session ID */ -int Curl_ssl_getsessionid(struct connectdata *conn, - void **ssl_sessionid, - size_t *idsize) /* set 0 if unknown */; +bool Curl_ssl_getsessionid(struct connectdata *conn, + void **ssl_sessionid, + size_t *idsize) /* set 0 if unknown */; /* add a new session ID */ CURLcode Curl_ssl_addsessionid(struct connectdata *conn, void *ssl_sessionid, @@ -94,18 +112,24 @@ void Curl_ssl_delsessionid(struct connectdata *conn, void *ssl_sessionid); in */ int Curl_ssl_random(struct SessionHandle *data, unsigned char *buffer, size_t length); -void Curl_ssl_md5sum(unsigned char *tmp, /* input */ - size_t tmplen, - unsigned char *md5sum, /* output */ - size_t md5len); +CURLcode Curl_ssl_md5sum(unsigned char *tmp, /* input */ + size_t tmplen, + unsigned char *md5sum, /* output */ + size_t md5len); +/* Check pinned public key. */ +CURLcode Curl_pin_peer_pubkey(const char *pinnedpubkey, + const unsigned char *pubkey, size_t pubkeylen); -#define SSL_SHUTDOWN_TIMEOUT 10000 /* ms */ +bool Curl_ssl_cert_status_request(void); -#ifdef have_curlssl_md5sum -#define HAVE_CURL_SSL_MD5SUM -#endif +bool Curl_ssl_false_start(void); + +#define SSL_SHUTDOWN_TIMEOUT 10000 /* ms */ #else +/* Set the API backend definition to none */ +#define CURL_SSL_BACKEND CURLSSLBACKEND_NONE + /* When SSL support is not present, just define away these function calls */ #define Curl_ssl_init() 1 #define Curl_ssl_cleanup() Curl_nop_stmt @@ -125,8 +149,9 @@ void Curl_ssl_md5sum(unsigned char *tmp, /* input */ #define Curl_ssl_free_certinfo(x) Curl_nop_stmt #define Curl_ssl_connect_nonblocking(x,y,z) CURLE_NOT_BUILT_IN #define Curl_ssl_kill_session(x) Curl_nop_stmt -#define Curl_ssl_random(x,y,z) CURLE_NOT_BUILT_IN -#define CURL_SSL_BACKEND CURLSSLBACKEND_NONE +#define Curl_ssl_random(x,y,z) ((void)x, CURLE_NOT_BUILT_IN) +#define Curl_ssl_cert_status_request() FALSE +#define Curl_ssl_false_start() FALSE #endif #endif /* HEADER_CURL_VTLS_H */ diff --git a/lib/wildcard.c b/lib/wildcard.c index 7130d5e..6f55839 100644 --- a/lib/wildcard.c +++ b/lib/wildcard.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2010, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -25,10 +25,7 @@ #include "wildcard.h" #include "llist.h" #include "fileinfo.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include - +#include "curl_printf.h" #include "curl_memory.h" /* The last #include file should be: */ #include "memdebug.h" @@ -62,15 +59,10 @@ void Curl_wildcard_dtor(struct WildcardData *wc) wc->filelist = NULL; } - if(wc->path) { - free(wc->path); - wc->path = NULL; - } - - if(wc->pattern) { - free(wc->pattern); - wc->pattern = NULL; - } + free(wc->path); + wc->path = NULL; + free(wc->pattern); + wc->pattern = NULL; wc->customptr = NULL; wc->state = CURLWC_INIT; diff --git a/lib/x509asn1.c b/lib/x509asn1.c index 1f87155..a3dfd64 100644 --- a/lib/x509asn1.c +++ b/lib/x509asn1.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -22,7 +22,8 @@ #include "curl_setup.h" -#if defined(USE_QSOSSL) || defined(USE_GSKIT) || defined(USE_NSS) +#if defined(USE_GSKIT) || defined(USE_NSS) || defined(USE_GNUTLS) || \ + defined(USE_CYASSL) #include #include "urldata.h" @@ -33,10 +34,7 @@ #include "inet_pton.h" #include "curl_base64.h" #include "x509asn1.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include - +#include "curl_printf.h" #include "curl_memory.h" /* The last #include file should be: */ #include "memdebug.h" @@ -122,6 +120,7 @@ const char * Curl_getASN1Element(curl_asn1Element * elem, return (const char *) NULL; /* Process header byte. */ + elem->header = beg; b = (unsigned char) *beg++; elem->constructed = (b & 0x20) != 0; elem->class = (b >> 6) & 3; @@ -211,7 +210,6 @@ static const char * octet2str(const char * beg, const char * end) } static const char * bit2str(const char * beg, const char * end) - { /* Convert an ASN.1 bit string to a printable string. Return the dynamically allocated string, or NULL if an error occurs. */ @@ -300,8 +298,10 @@ utf8asn1str(char * * to, int type, const char * from, const char * end) case 4: wc = (wc << 8) | *(const unsigned char *) from++; wc = (wc << 8) | *(const unsigned char *) from++; + /* fallthrough */ case 2: wc = (wc << 8) | *(const unsigned char *) from++; + /* fallthrough */ default: /* case 1: */ wc = (wc << 8) | *(const unsigned char *) from++; } @@ -539,8 +539,6 @@ static const char * UTime2str(const char * beg, const char * end) const char * Curl_ASN1tostr(curl_asn1Element * elem, int type) { - static const char zero = '\0'; - /* Convert an ASN.1 element to a printable string. Return the dynamically allocated string, or NULL if an error occurs. */ @@ -561,7 +559,7 @@ const char * Curl_ASN1tostr(curl_asn1Element * elem, int type) case CURL_ASN1_OCTET_STRING: return octet2str(elem->beg, elem->end); case CURL_ASN1_NULL: - return strdup(&zero); + return strdup(""); case CURL_ASN1_OBJECT_IDENTIFIER: return OID2str(elem->beg, elem->end, TRUE); case CURL_ASN1_UTC_TIME: @@ -682,6 +680,7 @@ void Curl_parseX509(curl_X509certificate * cert, Syntax is assumed to have already been checked by the SSL backend. See RFC 5280. */ + cert->certificate.header = NULL; cert->certificate.beg = beg; cert->certificate.end = end; @@ -701,6 +700,7 @@ void Curl_parseX509(curl_X509certificate * cert, beg = tbsCertificate.beg; end = tbsCertificate.end; /* Get optional version, get serialNumber. */ + cert->version.header = NULL; cert->version.beg = &defaultVersion; cert->version.end = &defaultVersion + sizeof defaultVersion;; beg = Curl_getASN1Element(&elem, beg, end); @@ -720,15 +720,19 @@ void Curl_parseX509(curl_X509certificate * cert, /* Get subject. */ beg = Curl_getASN1Element(&cert->subject, beg, end); /* Get subjectPublicKeyAlgorithm and subjectPublicKey. */ - beg = Curl_getASN1Element(&elem, beg, end); + beg = Curl_getASN1Element(&cert->subjectPublicKeyInfo, beg, end); ccp = Curl_getASN1Element(&cert->subjectPublicKeyAlgorithm, - elem.beg, elem.end); - Curl_getASN1Element(&cert->subjectPublicKey, ccp, elem.end); + cert->subjectPublicKeyInfo.beg, + cert->subjectPublicKeyInfo.end); + Curl_getASN1Element(&cert->subjectPublicKey, ccp, + cert->subjectPublicKeyInfo.end); /* Get optional issuerUiqueID, subjectUniqueID and extensions. */ cert->issuerUniqueID.tag = cert->subjectUniqueID.tag = 0; cert->extensions.tag = elem.tag = 0; + cert->issuerUniqueID.header = cert->subjectUniqueID.header = NULL; cert->issuerUniqueID.beg = cert->issuerUniqueID.end = ""; cert->subjectUniqueID.beg = cert->subjectUniqueID.end = ""; + cert->extensions.header = NULL; cert->extensions.beg = cert->extensions.end = ""; if(beg < end) beg = Curl_getASN1Element(&elem, beg, end); @@ -771,6 +775,7 @@ static const char * dumpAlgo(curl_asn1Element * param, /* Get algorithm parameters and return algorithm name. */ beg = Curl_getASN1Element(&oid, beg, end); + param->header = NULL; param->tag = 0; param->beg = param->end = end; if(beg < end) @@ -816,7 +821,7 @@ static void do_pubkey(struct SessionHandle * data, int certnum, /* Compute key length. */ for(q = elem.beg; !*q && q < elem.end; q++) ; - len = (elem.end - q) * 8; + len = (unsigned long)((elem.end - q) * 8); if(len) for(i = *(unsigned char *) q; !(i & 0x80); i <<= 1) len--; @@ -871,7 +876,7 @@ CURLcode Curl_extract_certinfo(struct connectdata * conn, char * cp1; size_t cl1; char * cp2; - CURLcode cc; + CURLcode result; unsigned long version; size_t i; size_t j; @@ -985,11 +990,11 @@ CURLcode Curl_extract_certinfo(struct connectdata * conn, free((char *) ccp); /* Generate PEM certificate. */ - cc = Curl_base64_encode(data, cert.certificate.beg, - cert.certificate.end - cert.certificate.beg, - &cp1, &cl1); - if(cc != CURLE_OK) - return cc; + result = Curl_base64_encode(data, cert.certificate.beg, + cert.certificate.end - cert.certificate.beg, + &cp1, &cl1); + if(result) + return result; /* Compute the number of characters in final certificate string. Format is: -----BEGIN CERTIFICATE-----\n \n @@ -1019,9 +1024,9 @@ CURLcode Curl_extract_certinfo(struct connectdata * conn, return CURLE_OK; } -#endif /* USE_QSOSSL or USE_GSKIT or USE_NSS */ +#endif /* USE_GSKIT or USE_NSS or USE_GNUTLS or USE_CYASSL */ -#if defined(USE_QSOSSL) || defined(USE_GSKIT) +#if defined(USE_GSKIT) static const char * checkOID(const char * beg, const char * end, const char * oid) @@ -1111,8 +1116,7 @@ CURLcode Curl_verifyhost(struct connectdata * conn, if(len > 0) if(strlen(dnsname) == (size_t) len) i = Curl_cert_hostcheck((const char *) dnsname, conn->host.name); - if(dnsname) - free(dnsname); + free(dnsname); if(!i) return CURLE_PEER_FAILED_VERIFICATION; matched = i; @@ -1140,6 +1144,7 @@ CURLcode Curl_verifyhost(struct connectdata * conn, } /* Process subject. */ + name.header = NULL; name.beg = name.end = ""; q = cert.subject.beg; /* we have to look to the last occurrence of a commonName in the @@ -1180,4 +1185,4 @@ CURLcode Curl_verifyhost(struct connectdata * conn, return CURLE_PEER_FAILED_VERIFICATION; } -#endif /* USE_QSOSSL or USE_GSKIT */ +#endif /* USE_GSKIT */ diff --git a/lib/x509asn1.h b/lib/x509asn1.h index 1741d6d..eb23e50 100644 --- a/lib/x509asn1.h +++ b/lib/x509asn1.h @@ -8,7 +8,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2013, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -25,7 +25,8 @@ #include "curl_setup.h" -#if defined(USE_QSOSSL) || defined(USE_GSKIT) || defined(USE_NSS) +#if defined(USE_GSKIT) || defined(USE_NSS) || defined(USE_GNUTLS) || \ + defined(USE_CYASSL) #include "urldata.h" @@ -76,8 +77,9 @@ /* ASN.1 parsed element. */ typedef struct { + const char * header; /* Pointer to header byte. */ const char * beg; /* Pointer to element data. */ - const char * end; /* Pointer to 1st byte after element data. */ + const char * end; /* Pointer to 1st byte after element. */ unsigned char class; /* ASN.1 element class. */ unsigned char tag; /* ASN.1 element tag. */ bool constructed; /* Element is constructed. */ @@ -102,6 +104,7 @@ typedef struct { curl_asn1Element notBefore; curl_asn1Element notAfter; curl_asn1Element subject; + curl_asn1Element subjectPublicKeyInfo; curl_asn1Element subjectPublicKeyAlgorithm; curl_asn1Element subjectPublicKey; curl_asn1Element issuerUniqueID; @@ -125,5 +128,5 @@ CURLcode Curl_extract_certinfo(struct connectdata * conn, int certnum, CURLcode Curl_verifyhost(struct connectdata * conn, const char * beg, const char * end); -#endif /* USE_QSOSSL or USE_GSKIT or USE_NSS */ +#endif /* USE_GSKIT or USE_NSS or USE_GNUTLS or USE_CYASSL */ #endif /* HEADER_CURL_X509ASN1_H */ ----------------------------------------------------------------------- Summary of changes: Source/cmCurl.cxx | 2 +- .../cmcurl/CMake/CurlCheckCSourceCompiles.cmake | 71 -- Utilities/cmcurl/CMake/CurlCheckCSourceRuns.cmake | 83 -- Utilities/cmcurl/CMake/CurlTests.c | 316 ++---- Utilities/cmcurl/CMake/FindGSS.cmake | 289 +++++ Utilities/cmcurl/CMake/Macros.cmake | 8 +- Utilities/cmcurl/CMake/OtherTests.cmake | 200 ++-- .../cmcurl/CMake/Platforms/WindowsCache.cmake | 2 +- Utilities/cmcurl/CMakeLists.txt | 508 ++++++--- Utilities/cmcurl/COPYING | 2 +- Utilities/cmcurl/README-CMake.txt | 8 +- Utilities/cmcurl/include/curl/curl.h | 94 +- Utilities/cmcurl/include/curl/curlver.h | 18 +- Utilities/cmcurl/include/curl/mprintf.h | 9 +- Utilities/cmcurl/include/curl/multi.h | 38 +- Utilities/cmcurl/include/curl/typecheck-gcc.h | 2 + Utilities/cmcurl/lib/CMakeLists.txt | 28 +- Utilities/cmcurl/lib/Makefile.inc | 86 +- Utilities/cmcurl/lib/amigaos.c | 4 +- Utilities/cmcurl/lib/asyn-ares.c | 37 +- Utilities/cmcurl/lib/asyn-thread.c | 45 +- Utilities/cmcurl/lib/base64.c | 23 +- Utilities/cmcurl/lib/bundles.c | 110 -- Utilities/cmcurl/lib/bundles.h | 45 - Utilities/cmcurl/lib/conncache.c | 179 ++- Utilities/cmcurl/lib/conncache.h | 21 +- Utilities/cmcurl/lib/connect.c | 227 ++-- Utilities/cmcurl/lib/connect.h | 2 +- Utilities/cmcurl/lib/cookie.c | 208 ++-- Utilities/cmcurl/lib/curl_addrinfo.c | 59 +- Utilities/cmcurl/lib/curl_addrinfo.h | 4 + Utilities/cmcurl/lib/curl_config.h.cmake | 12 +- Utilities/cmcurl/lib/curl_des.c | 63 ++ Utilities/cmcurl/lib/{amigaos.h => curl_des.h} | 23 +- Utilities/cmcurl/lib/curl_endian.c | 236 ++++ Utilities/cmcurl/lib/curl_endian.h | 70 ++ Utilities/cmcurl/lib/curl_fnmatch.c | 7 +- Utilities/cmcurl/lib/curl_gssapi.c | 53 +- Utilities/cmcurl/lib/curl_gssapi.h | 19 +- Utilities/cmcurl/lib/curl_md4.h | 12 +- Utilities/cmcurl/lib/curl_memory.h | 3 + Utilities/cmcurl/lib/curl_memrchr.c | 8 +- Utilities/cmcurl/lib/curl_multibyte.c | 18 +- Utilities/cmcurl/lib/curl_multibyte.h | 12 +- Utilities/cmcurl/lib/curl_ntlm.c | 79 +- Utilities/cmcurl/lib/curl_ntlm.h | 10 +- Utilities/cmcurl/lib/curl_ntlm_core.c | 292 +++-- Utilities/cmcurl/lib/curl_ntlm_core.h | 59 +- Utilities/cmcurl/lib/curl_ntlm_msgs.c | 461 +++----- Utilities/cmcurl/lib/curl_ntlm_msgs.h | 34 - Utilities/cmcurl/lib/curl_ntlm_wb.c | 46 +- Utilities/cmcurl/lib/curl_ntlm_wb.h | 7 +- .../cmcurl/lib/{curl_memrchr.c => curl_printf.h} | 68 +- Utilities/cmcurl/lib/curl_rtmp.c | 27 +- Utilities/cmcurl/lib/curl_sasl.c | 1158 +++++++++++++++++-- Utilities/cmcurl/lib/curl_sasl.h | 164 ++- Utilities/cmcurl/lib/curl_sasl_gssapi.c | 392 +++++++ Utilities/cmcurl/lib/curl_sasl_sspi.c | 861 +++++++++++--- Utilities/cmcurl/lib/curl_sec.h | 4 +- Utilities/cmcurl/lib/curl_setup.h | 53 +- Utilities/cmcurl/lib/curl_sspi.c | 30 +- Utilities/cmcurl/lib/curl_sspi.h | 191 ++-- Utilities/cmcurl/lib/curl_threads.c | 15 +- Utilities/cmcurl/lib/curl_threads.h | 9 +- Utilities/cmcurl/lib/curlx.h | 5 +- Utilities/cmcurl/lib/dict.c | 16 +- Utilities/cmcurl/lib/easy.c | 180 ++- Utilities/cmcurl/lib/escape.c | 28 +- Utilities/cmcurl/lib/file.c | 63 +- Utilities/cmcurl/lib/fileinfo.c | 6 +- Utilities/cmcurl/lib/formdata.c | 127 +-- Utilities/cmcurl/lib/ftp.c | 305 ++--- Utilities/cmcurl/lib/ftp.h | 11 +- Utilities/cmcurl/lib/ftplistparser.c | 57 +- Utilities/cmcurl/lib/getinfo.c | 55 +- Utilities/cmcurl/lib/gopher.c | 16 +- Utilities/cmcurl/lib/hash.c | 72 +- Utilities/cmcurl/lib/hash.h | 10 +- Utilities/cmcurl/lib/hmac.c | 6 +- Utilities/cmcurl/lib/hostasyn.c | 24 +- Utilities/cmcurl/lib/hostcheck.c | 7 +- Utilities/cmcurl/lib/hostip.c | 287 ++--- Utilities/cmcurl/lib/hostip.h | 22 +- Utilities/cmcurl/lib/hostip4.c | 15 +- Utilities/cmcurl/lib/hostip6.c | 17 +- Utilities/cmcurl/lib/hostsyn.c | 6 +- Utilities/cmcurl/lib/http.c | 378 ++++--- Utilities/cmcurl/lib/http.h | 64 +- Utilities/cmcurl/lib/http2.c | 1184 ++++++++++++++------ Utilities/cmcurl/lib/http2.h | 17 +- Utilities/cmcurl/lib/http_chunks.c | 12 +- Utilities/cmcurl/lib/http_digest.c | 549 ++------- Utilities/cmcurl/lib/http_digest.h | 21 +- Utilities/cmcurl/lib/http_negotiate.c | 163 ++- Utilities/cmcurl/lib/http_negotiate.h | 6 +- Utilities/cmcurl/lib/http_negotiate_sspi.c | 118 +- Utilities/cmcurl/lib/http_proxy.c | 64 +- Utilities/cmcurl/lib/http_proxy.h | 7 +- Utilities/cmcurl/lib/idn_win32.c | 29 +- Utilities/cmcurl/lib/if2ip.c | 87 +- Utilities/cmcurl/lib/if2ip.h | 13 +- Utilities/cmcurl/lib/imap.c | 989 ++-------------- Utilities/cmcurl/lib/imap.h | 23 +- Utilities/cmcurl/lib/inet_ntop.c | 3 +- Utilities/cmcurl/lib/inet_ntop.h | 4 +- Utilities/cmcurl/lib/krb5.c | 36 +- Utilities/cmcurl/lib/ldap.c | 622 +++++++--- Utilities/cmcurl/lib/md4.c | 502 +++++---- Utilities/cmcurl/lib/md5.c | 579 +++++----- Utilities/cmcurl/lib/memdebug.c | 39 +- Utilities/cmcurl/lib/memdebug.h | 20 +- Utilities/cmcurl/lib/multi.c | 819 +++++++------- Utilities/cmcurl/lib/multihandle.h | 52 +- Utilities/cmcurl/lib/multiif.h | 22 +- Utilities/cmcurl/lib/netrc.c | 20 +- Utilities/cmcurl/lib/non-ascii.c | 55 +- Utilities/cmcurl/lib/nwlib.c | 8 +- Utilities/cmcurl/lib/openldap.c | 142 ++- Utilities/cmcurl/lib/parsedate.c | 2 +- Utilities/cmcurl/lib/pingpong.c | 56 +- Utilities/cmcurl/lib/pipeline.c | 119 +- Utilities/cmcurl/lib/pipeline.h | 12 + Utilities/cmcurl/lib/pop3.c | 972 ++-------------- Utilities/cmcurl/lib/pop3.h | 23 +- Utilities/cmcurl/lib/progress.c | 6 +- Utilities/cmcurl/lib/rtsp.c | 24 +- Utilities/cmcurl/lib/security.c | 187 ++-- Utilities/cmcurl/lib/select.c | 12 +- Utilities/cmcurl/lib/sendf.c | 218 ++-- Utilities/cmcurl/lib/sendf.h | 6 +- Utilities/cmcurl/lib/setup-os400.h | 18 +- Utilities/cmcurl/lib/setup-vms.h | 47 +- Utilities/cmcurl/lib/share.c | 27 +- Utilities/cmcurl/lib/share.h | 4 +- Utilities/cmcurl/lib/slist.c | 4 +- Utilities/cmcurl/lib/smb.c | 976 ++++++++++++++++ Utilities/cmcurl/lib/smb.h | 271 +++++ Utilities/cmcurl/lib/smtp.c | 1019 +++-------------- Utilities/cmcurl/lib/smtp.h | 23 +- Utilities/cmcurl/lib/socks.c | 42 +- Utilities/cmcurl/lib/socks_gssapi.c | 80 +- Utilities/cmcurl/lib/socks_sspi.c | 59 +- Utilities/cmcurl/lib/splay.c | 10 +- Utilities/cmcurl/lib/ssh.c | 160 ++- Utilities/cmcurl/lib/ssh.h | 36 +- Utilities/cmcurl/lib/strdup.c | 33 +- Utilities/cmcurl/lib/strdup.h | 3 +- Utilities/cmcurl/lib/strerror.c | 38 +- Utilities/cmcurl/lib/strtoofft.h | 11 +- Utilities/cmcurl/lib/telnet.c | 165 ++- Utilities/cmcurl/lib/tftp.c | 163 +-- Utilities/cmcurl/lib/timeval.c | 12 +- Utilities/cmcurl/lib/transfer.c | 145 +-- Utilities/cmcurl/lib/transfer.h | 5 +- Utilities/cmcurl/lib/url.c | 744 +++++++----- Utilities/cmcurl/lib/url.h | 6 +- Utilities/cmcurl/lib/urldata.h | 162 ++- Utilities/cmcurl/lib/version.c | 23 +- Utilities/cmcurl/lib/vtls/axtls.c | 34 +- Utilities/cmcurl/lib/vtls/axtls.h | 23 +- Utilities/cmcurl/lib/vtls/cyassl.c | 273 +++-- Utilities/cmcurl/lib/vtls/cyassl.h | 30 +- .../lib/vtls/{curl_darwinssl.c => darwinssl.c} | 137 ++- .../lib/vtls/{curl_darwinssl.h => darwinssl.h} | 21 +- Utilities/cmcurl/lib/vtls/gskit.c | 326 +++--- Utilities/cmcurl/lib/vtls/gskit.h | 26 +- Utilities/cmcurl/lib/vtls/gtls.c | 398 +++++-- Utilities/cmcurl/lib/vtls/gtls.h | 37 +- Utilities/cmcurl/lib/vtls/nss.c | 599 ++++++---- Utilities/cmcurl/lib/vtls/nssg.h | 41 +- Utilities/cmcurl/lib/vtls/openssl.c | 1091 +++++++++++------- Utilities/cmcurl/lib/vtls/openssl.h | 35 +- Utilities/cmcurl/lib/vtls/polarssl.c | 197 ++-- Utilities/cmcurl/lib/vtls/polarssl.h | 26 +- Utilities/cmcurl/lib/vtls/polarssl_threadlock.c | 5 +- Utilities/cmcurl/lib/vtls/qssl.c | 527 --------- Utilities/cmcurl/lib/vtls/qssl.h | 62 - .../lib/vtls/{curl_schannel.c => schannel.c} | 755 ++++++++----- .../lib/vtls/{curl_schannel.h => schannel.h} | 39 +- Utilities/cmcurl/lib/vtls/vtls.c | 355 +++++- Utilities/cmcurl/lib/vtls/vtls.h | 55 +- Utilities/cmcurl/lib/wildcard.c | 20 +- Utilities/cmcurl/lib/x509asn1.c | 55 +- Utilities/cmcurl/lib/x509asn1.h | 11 +- 184 files changed, 14806 insertions(+), 11501 deletions(-) delete mode 100644 Utilities/cmcurl/CMake/CurlCheckCSourceCompiles.cmake delete mode 100644 Utilities/cmcurl/CMake/CurlCheckCSourceRuns.cmake create mode 100644 Utilities/cmcurl/CMake/FindGSS.cmake delete mode 100644 Utilities/cmcurl/lib/bundles.c delete mode 100644 Utilities/cmcurl/lib/bundles.h create mode 100644 Utilities/cmcurl/lib/curl_des.c copy Utilities/cmcurl/lib/{amigaos.h => curl_des.h} (71%) create mode 100644 Utilities/cmcurl/lib/curl_endian.c create mode 100644 Utilities/cmcurl/lib/curl_endian.h copy Utilities/cmcurl/lib/{curl_memrchr.c => curl_printf.h} (53%) create mode 100644 Utilities/cmcurl/lib/curl_sasl_gssapi.c create mode 100644 Utilities/cmcurl/lib/smb.c create mode 100644 Utilities/cmcurl/lib/smb.h rename Utilities/cmcurl/lib/vtls/{curl_darwinssl.c => darwinssl.c} (96%) rename Utilities/cmcurl/lib/vtls/{curl_darwinssl.h => darwinssl.h} (83%) delete mode 100644 Utilities/cmcurl/lib/vtls/qssl.c delete mode 100644 Utilities/cmcurl/lib/vtls/qssl.h rename Utilities/cmcurl/lib/vtls/{curl_schannel.c => schannel.c} (64%) rename Utilities/cmcurl/lib/vtls/{curl_schannel.h => schannel.h} (80%) hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 13 09:15:40 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 13 Aug 2015 09:15:40 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2187-g6d10c61 Message-ID: <20150813131540.DB515B09EA@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 6d10c61fbcee0fd1aaa91c571594708261041337 (commit) via a0b32a348d34d387b9b60da43f6f146cbd07ca6a (commit) from 3fb42748e4361c2cbd2ccd2e67251c703b1caf25 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6d10c61fbcee0fd1aaa91c571594708261041337 commit 6d10c61fbcee0fd1aaa91c571594708261041337 Merge: 3fb4274 a0b32a3 Author: Brad King AuthorDate: Thu Aug 13 09:15:30 2015 -0400 Commit: Brad King CommitDate: Thu Aug 13 09:15:30 2015 -0400 Merge branch 'master' into next ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 13 09:17:51 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 13 Aug 2015 09:17:51 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-827-g37ab2f3 Message-ID: <20150813131751.A0508B0F73@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 37ab2f38aea33cd217f0d9f6982804129c35d81c (commit) via bcd8fc58a03b6bd0cb0744d1f61dd0a1277640e1 (commit) via c645590152be678a10dfae4bb9fde136a79a2c44 (commit) via bcba0d30992eb326f9c561b2fd86c784bf358302 (commit) via 59f4d9e85cfae752ccf99a8e9600aca301529f3c (commit) from a0b32a348d34d387b9b60da43f6f146cbd07ca6a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 13 09:17:51 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 13 Aug 2015 09:17:51 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2193-gafb0e7d Message-ID: <20150813131751.DD73AB0FAA@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via afb0e7d7faa79e71049a2e9c52fe92f89b173f3e (commit) via 37ab2f38aea33cd217f0d9f6982804129c35d81c (commit) via bcd8fc58a03b6bd0cb0744d1f61dd0a1277640e1 (commit) via c645590152be678a10dfae4bb9fde136a79a2c44 (commit) via bcba0d30992eb326f9c561b2fd86c784bf358302 (commit) via 59f4d9e85cfae752ccf99a8e9600aca301529f3c (commit) from 6d10c61fbcee0fd1aaa91c571594708261041337 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=afb0e7d7faa79e71049a2e9c52fe92f89b173f3e commit afb0e7d7faa79e71049a2e9c52fe92f89b173f3e Merge: 6d10c61 37ab2f3 Author: Brad King AuthorDate: Thu Aug 13 09:17:42 2015 -0400 Commit: Brad King CommitDate: Thu Aug 13 09:17:42 2015 -0400 Merge branch 'master' into next ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 13 09:17:52 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 13 Aug 2015 09:17:52 -0400 (EDT) Subject: [Cmake-commits] CMake branch, release, updated. v3.3.0-8-gbcd8fc5 Message-ID: <20150813131752.53A91B0FAE@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, release has been updated via bcd8fc58a03b6bd0cb0744d1f61dd0a1277640e1 (commit) via f0609182cc2bbce7f6af557d6352e0c434e7acc2 (commit) via c645590152be678a10dfae4bb9fde136a79a2c44 (commit) via c4d2f64f3c9dea3a5fcd8af5bb389db00ccd64df (commit) via bcba0d30992eb326f9c561b2fd86c784bf358302 (commit) via f7a9ed7e90cd2661b279d0bcd44d43620b8eeda1 (commit) via 59f4d9e85cfae752ccf99a8e9600aca301529f3c (commit) via 64821e8a40cf1add0cf3fd99b0860378754c64cf (commit) from 3a0db0223b8c10cfaa6984253d794ab97425adf9 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- ----------------------------------------------------------------------- Summary of changes: Modules/CMakeFortranCompiler.cmake.in | 1 + Source/CTest/cmCTestTestHandler.cxx | 2 +- Source/cmMakefile.cxx | 4 ++-- Source/cmXCodeObject.cxx | 2 +- Tests/RunCMake/CMakeLists.txt | 1 + Tests/RunCMake/{CMP0057 => add_subdirectory}/CMakeLists.txt | 0 .../DoesNotExist-result.txt} | 0 Tests/RunCMake/add_subdirectory/DoesNotExist-stderr.txt | 5 +++++ Tests/RunCMake/add_subdirectory/DoesNotExist.cmake | 1 + .../Missing-result.txt} | 0 Tests/RunCMake/add_subdirectory/Missing-stderr.txt | 8 ++++++++ Tests/RunCMake/add_subdirectory/Missing.cmake | 1 + .../RunCMake/add_subdirectory/Missing/Missing.txt | 0 Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake | 4 ++++ 14 files changed, 25 insertions(+), 4 deletions(-) copy Tests/RunCMake/{CMP0057 => add_subdirectory}/CMakeLists.txt (100%) copy Tests/RunCMake/{CMP0004/CMP0004-NEW-result.txt => add_subdirectory/DoesNotExist-result.txt} (100%) create mode 100644 Tests/RunCMake/add_subdirectory/DoesNotExist-stderr.txt create mode 100644 Tests/RunCMake/add_subdirectory/DoesNotExist.cmake copy Tests/RunCMake/{CMP0004/CMP0004-NEW-result.txt => add_subdirectory/Missing-result.txt} (100%) create mode 100644 Tests/RunCMake/add_subdirectory/Missing-stderr.txt create mode 100644 Tests/RunCMake/add_subdirectory/Missing.cmake copy Modules/IntelVSImplicitPath/hello.f => Tests/RunCMake/add_subdirectory/Missing/Missing.txt (100%) create mode 100644 Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 13 09:19:18 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 13 Aug 2015 09:19:18 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2196-g1e6b6f4 Message-ID: <20150813131918.3A316B1133@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 1e6b6f4760f83ea4e62b44975bec2fed2940068b (commit) via 609ea96766d11e143fa1fa5d08efe756fc6eec5e (commit) via 4a6fe0290880bd56dd5141f06c9fa2b9e310162e (commit) from afb0e7d7faa79e71049a2e9c52fe92f89b173f3e (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1e6b6f4760f83ea4e62b44975bec2fed2940068b commit 1e6b6f4760f83ea4e62b44975bec2fed2940068b Merge: afb0e7d 609ea96 Author: Brad King AuthorDate: Thu Aug 13 09:19:17 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 13 09:19:17 2015 -0400 Merge topic 'test-release' into next 609ea967 Merge branch 'release' into test-release 4a6fe029 CMake 3.3.1 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=609ea96766d11e143fa1fa5d08efe756fc6eec5e commit 609ea96766d11e143fa1fa5d08efe756fc6eec5e Merge: 37ab2f3 4a6fe02 Author: Brad King AuthorDate: Thu Aug 13 09:18:12 2015 -0400 Commit: Brad King CommitDate: Thu Aug 13 09:18:12 2015 -0400 Merge branch 'release' into test-release http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4a6fe0290880bd56dd5141f06c9fa2b9e310162e commit 4a6fe0290880bd56dd5141f06c9fa2b9e310162e Author: Brad King AuthorDate: Thu Aug 13 09:17:06 2015 -0400 Commit: Brad King CommitDate: Thu Aug 13 09:17:06 2015 -0400 CMake 3.3.1 diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 508efbc..e1bffac 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 0) +set(CMake_VERSION_PATCH 1) #set(CMake_VERSION_RC 0) ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 13 09:29:53 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 13 Aug 2015 09:29:53 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2198-g2f3b67c Message-ID: <20150813132953.9EBACB1599@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 2f3b67c8eaa170d65fb27a3a55e7b7cc4d944f18 (commit) via 0b1ee3f37d9e25a3408f8a25b655dc1e3a6e84ce (commit) from 1e6b6f4760f83ea4e62b44975bec2fed2940068b (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2f3b67c8eaa170d65fb27a3a55e7b7cc4d944f18 commit 2f3b67c8eaa170d65fb27a3a55e7b7cc4d944f18 Merge: 1e6b6f4 0b1ee3f Author: Brad King AuthorDate: Thu Aug 13 09:29:52 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 13 09:29:52 2015 -0400 Merge topic 'java-updates' into next 0b1ee3f3 fixup! UseJava: Add support for javah tool http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0b1ee3f37d9e25a3408f8a25b655dc1e3a6e84ce commit 0b1ee3f37d9e25a3408f8a25b655dc1e3a6e84ce Author: Brad King AuthorDate: Thu Aug 13 09:29:22 2015 -0400 Commit: Brad King CommitDate: Thu Aug 13 09:29:22 2015 -0400 fixup! UseJava: Add support for javah tool diff --git a/Tests/JavaJavah/CMakeLists.txt b/Tests/JavaJavah/CMakeLists.txt index bc803a1..83b0ad0 100644 --- a/Tests/JavaJavah/CMakeLists.txt +++ b/Tests/JavaJavah/CMakeLists.txt @@ -12,7 +12,7 @@ find_package(JNI) add_jar(hello3 B.java HelloWorld2.java) create_javah(TARGET B_javah CLASSES B CLASSPATH hello3) -add_library(B MODULE B.cpp) +add_library(B SHARED B.cpp) add_dependencies(B B_javah) target_include_directories(B PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ----------------------------------------------------------------------- Summary of changes: Tests/JavaJavah/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 13 09:30:28 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 13 Aug 2015 09:30:28 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2200-gdbbcde6 Message-ID: <20150813133028.DE6D5B15C9@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via dbbcde63a4027122f1456969040132263a75ddf4 (commit) via 171a295d6eb9dfcfd2e2262bded0df0a804c944f (commit) from 2f3b67c8eaa170d65fb27a3a55e7b7cc4d944f18 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=dbbcde63a4027122f1456969040132263a75ddf4 commit dbbcde63a4027122f1456969040132263a75ddf4 Merge: 2f3b67c 171a295 Author: Brad King AuthorDate: Thu Aug 13 09:30:28 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 13 09:30:28 2015 -0400 Merge topic 'java-updates' into next 171a295d UseJava: Add support for javah tool http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=171a295d6eb9dfcfd2e2262bded0df0a804c944f commit 171a295d6eb9dfcfd2e2262bded0df0a804c944f Author: Marc Chevrier AuthorDate: Wed Aug 5 07:46:02 2015 +0000 Commit: Brad King CommitDate: Thu Aug 13 09:30:09 2015 -0400 UseJava: Add support for javah tool Add a `create_javah` API. diff --git a/Help/release/dev/java-updates.rst b/Help/release/dev/java-updates.rst index b777807..8fd4ed6 100644 --- a/Help/release/dev/java-updates.rst +++ b/Help/release/dev/java-updates.rst @@ -11,3 +11,6 @@ java-updates * The :module:`UseJava` module ``install_jar`` function learned new ``DESTINATION`` and ``COMPONENT`` options to specify the corresponding :command:`install` command options. + +* The :module:`UseJava` module gained a new ``create_javah`` + function to create C headers from Java classes. diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake index c61591d..dced6ec 100644 --- a/Modules/UseJava.cmake +++ b/Modules/UseJava.cmake @@ -309,6 +309,65 @@ # # # if you don't set the INSTALLPATH. +# +# :: +# +# create_javah(TARGET +# GENERATED_FILES +# CLASSES ... +# [CLASSPATH ...] +# [DEPENDS ...] +# [OUTPUT_NAME |OUTPUT_DIR ] +# ) +# +# Create C header files from java classes. These files provide the connective glue +# that allow your Java and C code to interact. +# +# There are two main signatures for create_javah. The first signature +# returns generated files throught variable specified by GENERATED_FILES option: +# +# :: +# +# Example: +# Create_javah(GENERATED_FILES files_headers +# CLASSES org.cmake.HelloWorld +# CLASSPATH hello.jar +# ) +# +# +# +# The second signature for create_javah creates a target which encapsulates +# header files generation. +# +# :: +# +# Example: +# Create_javah(TARGET target_headers +# CLASSES org.cmake.HelloWorld +# CLASSPATH hello.jar +# ) +# +# +# +# Both signatures share same options. +# +# ``CLASSES ...`` +# Specifies Java classes used to generate headers. +# +# ``CLASSPATH ...`` +# Specifies various paths to look up classes. Here .class files, jar files or targets +# created by command add_jar can be used. +# +# ``DEPENDS ...`` +# Targets on which the javah target depends +# +# ``OUTPUT_NAME `` +# Concatenates the resulting header files for all the classes listed by option CLASSES +# into . Same behavior as option '-o' of javah tool. +# +# ``OUTPUT_DIR `` +# Sets the directory where the header files will be generated. Same behavior as option +# '-d' of javah tool. If not specified, ${CMAKE_CURRENT_BINARY_DIR} is used as output directory. #============================================================================= # Copyright 2013 OpenGamma Ltd. @@ -1131,3 +1190,101 @@ function(create_javadoc _target) DESTINATION ${_javadoc_installpath} ) endfunction() + +function (create_javah) + cmake_parse_arguments(_create_javah + "" + "TARGET;GENERATED_FILES;OUTPUT_NAME;OUTPUT_DIR" + "CLASSES;CLASSPATH;DEPENDS" + ${ARGN}) + + # ckeck parameters + if (NOT _create_javah_TARGET AND NOT _create_javah_GENERATED_FILES) + message (FATAL_ERROR "create_javah: TARGET or GENERATED_FILES must be specified.") + endif() + if (_create_javah_OUTPUT_NAME AND _create_javah_OUTPUT_DIR) + message (FATAL_ERROR "create_javah: OUTPUT_NAME and OUTPUT_DIR are mutually exclusive.") + endif() + + if (NOT _create_javah_CLASSES) + message (FATAL_ERROR "create_javah: CLASSES is a required parameter.") + endif() + + set (_output_files) + if (WIN32 AND NOT CYGWIN AND CMAKE_HOST_SYSTEM_NAME MATCHES "Windows") + set(_classpath_sep ";") + else () + set(_classpath_sep ":") + endif() + + # handle javah options + set (_javah_options) + + if (_create_javah_CLASSPATH) + # CLASSPATH can specify directories, jar files or targets created with add_jar command + set (_classpath) + foreach (_path IN LISTS _create_javah_CLASSPATH) + if (TARGET ${_path}) + get_target_property (_jar_path ${_path} JAR_FILE) + if (_jar_path) + list (APPEND _classpath "${_jar_path}") + list (APPEND _create_javah_DEPENDS "${_path}") + else() + message(SEND_ERROR "create_javah: CLASSPATH target ${_path} is not a jar.") + endif() + elseif (EXISTS "${_path}") + list (APPEND _classpath "${_path}") + if (NOT IS_DIRECTORY "${_path}") + list (APPEND _create_javah_DEPENDS "${_path}") + endif() + else() + message(SEND_ERROR "create_javah: CLASSPATH entry ${_path} does not exist.") + endif() + endforeach() + string (REPLACE ";" "${_classpath_sep}" _classpath "${_classpath}") + list (APPEND _javah_options -classpath ${_classpath}) + endif() + + if (_create_javah_OUTPUT_DIR) + list (APPEND _javah_options -d "${_create_javah_OUTPUT_DIR}") + endif() + + if (_create_javah_OUTPUT_NAME) + list (APPEND _javah_options -o "${_create_javah_OUTPUT_NAME}") + set (_output_files "${_create_javah_OUTPUT_NAME}") + + get_filename_component (_create_javah_OUTPUT_DIR "${_create_javah_OUTPUT_NAME}" DIRECTORY) + get_filename_component (_create_javah_OUTPUT_DIR "${_create_javah_OUTPUT_DIR}" ABSOLUTE) + endif() + + if (NOT _create_javah_OUTPUT_DIR) + set (_create_javah_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}") + endif() + + if (NOT _create_javah_OUTPUT_NAME) + # compute output names + foreach (_class IN LISTS _create_javah_CLASSES) + string (REPLACE "." "_" _c_header "${_class}") + set (_c_header "${_create_javah_OUTPUT_DIR}/${_c_header}.h") + list (APPEND _output_files "${_c_header}") + endforeach() + endif() + + # finalize custom command arguments + if (_create_javah_DEPENDS) + list (INSERT _create_javah_DEPENDS 0 DEPENDS) + endif() + + add_custom_command (OUTPUT ${_output_files} + COMMAND "${Java_JAVAH_EXECUTABLE}" ${_javah_options} -jni ${_create_javah_CLASSES} + ${_create_javah_DEPENDS} + WORKING_DIRECTORY ${_create_javah_OUTPUT_DIR} + COMMENT "Building C header files from classes...") + + if (_create_javah_TARGET) + add_custom_target (${_create_javah_TARGET} ALL DEPENDS ${_output_files}) + endif() + if (_create_javah_GENERATED_FILES) + set (${_create_javah_GENERATED_FILES} ${_output_files} PARENT_SCOPE) + endif() +endfunction() diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 5781a9e..f01a983 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -3032,6 +3032,31 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release --build-options ${build_options} --test-command ${JAVA_RUNTIME} -classpath hello2.jar HelloWorld) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJarSourceList") + + # For next test, java tool must have same architecture as toolchain + math(EXPR _object_mode "${CMAKE_SIZEOF_VOID_P} * 8") + execute_process( + COMMAND "${Java_JAVA_EXECUTABLE}" -d${_object_mode} -version + OUTPUT_QUIET ERROR_QUIET RESULT_VARIABLE _result + ) + if(_result EQUAL 0) + if(CMAKE_CONFIGURATION_TYPES) + set (JAVAH_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaJavah/$) + else() + set (JAVAH_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaJavah) + endif() + add_test(NAME Java.Javah COMMAND ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/JavaJavah" + "${CMake_BINARY_DIR}/Tests/JavaJavah" + ${build_generator_args} + --build-project helloJavah + --build-two-config + --build-run-dir "${CMake_BINARY_DIR}/Tests/JavaJavah/" + --build-options ${build_options} + --test-command ${JAVA_RUNTIME} -Djava.library.path=${JAVAH_LIBRARY_PATH} -classpath hello3.jar HelloWorld2) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJavah") + endif() endif() endif() endif() diff --git a/Tests/JavaJavah/B.cpp b/Tests/JavaJavah/B.cpp new file mode 100644 index 0000000..2666757 --- /dev/null +++ b/Tests/JavaJavah/B.cpp @@ -0,0 +1,10 @@ + +#include +#include + +#include "B.h" + +JNIEXPORT void JNICALL Java_B_printName(JNIEnv *, jobject) +{ + printf("B\n"); +} diff --git a/Tests/JavaJavah/B.java b/Tests/JavaJavah/B.java new file mode 100644 index 0000000..d731f39 --- /dev/null +++ b/Tests/JavaJavah/B.java @@ -0,0 +1,19 @@ +class B +{ + public B() + { + } + + public native void printName(); + + static { + try { + + System.loadLibrary("B"); + + } catch (UnsatisfiedLinkError e) { + System.err.println("Native code library failed to load.\n" + e); + System.exit(1); + } + } +} diff --git a/Tests/JavaJavah/CMakeLists.txt b/Tests/JavaJavah/CMakeLists.txt new file mode 100644 index 0000000..83b0ad0 --- /dev/null +++ b/Tests/JavaJavah/CMakeLists.txt @@ -0,0 +1,20 @@ +project(helloJavah Java CXX) + +cmake_minimum_required (VERSION 2.6) +set(CMAKE_VERBOSE_MAKEFILE 1) + +find_package(Java COMPONENTS Development) +include (UseJava) + +# JNI support +find_package(JNI) + +add_jar(hello3 B.java HelloWorld2.java) +create_javah(TARGET B_javah CLASSES B CLASSPATH hello3) + +add_library(B SHARED B.cpp) +add_dependencies(B B_javah) + +target_include_directories(B PRIVATE ${CMAKE_CURRENT_BINARY_DIR} + ${JAVA_INCLUDE_PATH} + ${JAVA_INCLUDE_PATH2}) diff --git a/Tests/JavaJavah/HelloWorld2.java b/Tests/JavaJavah/HelloWorld2.java new file mode 100644 index 0000000..faf7277 --- /dev/null +++ b/Tests/JavaJavah/HelloWorld2.java @@ -0,0 +1,10 @@ +class HelloWorld2 +{ + public static void main(String args[]) + { + B b; + b = new B(); + b.printName(); + System.out.println("Hello World!"); + } +} ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 13 10:25:40 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 13 Aug 2015 10:25:40 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2202-g132099e Message-ID: <20150813142540.1BAAAB1236@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 132099ec2612bee91c6202f831f6164dd78a437b (commit) via 9b449e9c5d79465a807c052c6707e83a1df9efbc (commit) from dbbcde63a4027122f1456969040132263a75ddf4 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=132099ec2612bee91c6202f831f6164dd78a437b commit 132099ec2612bee91c6202f831f6164dd78a437b Merge: dbbcde6 9b449e9 Author: Brad King AuthorDate: Thu Aug 13 10:25:39 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 13 10:25:39 2015 -0400 Merge topic 'use-generator-target' into next 9b449e9c cmComputeLinkInformation: Lookup a target only if we have one http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9b449e9c5d79465a807c052c6707e83a1df9efbc commit 9b449e9c5d79465a807c052c6707e83a1df9efbc Author: Brad King AuthorDate: Thu Aug 13 09:56:54 2015 -0400 Commit: Brad King CommitDate: Thu Aug 13 10:24:10 2015 -0400 cmComputeLinkInformation: Lookup a target only if we have one The change in commit 27252b24 (cmComputeLinkInformation: Simplify generator object access, 2015-08-02) broke the conditional use of a target introduced in commit 41abdc17 (cmGeneratorTarget: Move GetSOName from cmTarget, 2015-08-04). Restore the conditional lookup. Add a test case that hacks platform information variables to trigger this code everywhere. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index c16472e..32f5d68 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -760,7 +760,7 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, return; } - cmGeneratorTarget *gtgt = this->GlobalGenerator->GetGeneratorTarget(tgt); + cmGeneratorTarget *gtgt = 0; // Get a full path to the dependent shared library. // Add it to the runtime path computation so that the target being diff --git a/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake b/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake index 533c6a1..8307607 100644 --- a/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake +++ b/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake @@ -7,3 +7,4 @@ run_cmake(CMP0023-NEW-2) run_cmake(MixedSignature) run_cmake(Separate-PRIVATE-LINK_PRIVATE-uses) run_cmake(SubDirTarget) +run_cmake(SharedDepNotTarget) diff --git a/Tests/RunCMake/target_link_libraries/SharedDepNotTarget.cmake b/Tests/RunCMake/target_link_libraries/SharedDepNotTarget.cmake new file mode 100644 index 0000000..bab537e --- /dev/null +++ b/Tests/RunCMake/target_link_libraries/SharedDepNotTarget.cmake @@ -0,0 +1,10 @@ +enable_language(C) +set(CMAKE_LINK_DEPENDENT_LIBRARY_DIRS 1) +set(CMAKE_SHARED_LIBRARY_SUFFIX ".so") +add_library(imported SHARED IMPORTED) +set_target_properties(imported PROPERTIES + IMPORTED_LOCATION "imported" + IMPORTED_LINK_DEPENDENT_LIBRARIES "/path/to/libSharedDep.so" + ) +add_executable(empty empty.c) +target_link_libraries(empty imported) ----------------------------------------------------------------------- Summary of changes: Source/cmComputeLinkInformation.cxx | 2 +- Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake | 1 + .../RunCMake/target_link_libraries/SharedDepNotTarget.cmake | 10 ++++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 Tests/RunCMake/target_link_libraries/SharedDepNotTarget.cmake hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 13 10:34:19 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 13 Aug 2015 10:34:19 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-829-g7a7922e Message-ID: <20150813143419.D39FCB167C@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 7a7922e0201fee6a6f45c702f96ca57a295c68fe (commit) via dc64d8250b686c26a557f58dfad46a0a2101299e (commit) from 37ab2f38aea33cd217f0d9f6982804129c35d81c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7a7922e0201fee6a6f45c702f96ca57a295c68fe commit 7a7922e0201fee6a6f45c702f96ca57a295c68fe Merge: 37ab2f3 dc64d82 Author: Brad King AuthorDate: Thu Aug 13 10:34:18 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 13 10:34:18 2015 -0400 Merge topic 'fix-hpux-link-search-shared-flags' dc64d825 HP-UX: Fix linker search type flags for C shared libs on HP-UX ----------------------------------------------------------------------- Summary of changes: Modules/Platform/HP-UX.cmake | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 13 10:34:34 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 13 Aug 2015 10:34:34 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2204-g6020a97 Message-ID: <20150813143434.C0FF7B167D@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 6020a97deeab6dcb2cbac14fde0a10f9d511a974 (commit) via 7a7922e0201fee6a6f45c702f96ca57a295c68fe (commit) from 132099ec2612bee91c6202f831f6164dd78a437b (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6020a97deeab6dcb2cbac14fde0a10f9d511a974 commit 6020a97deeab6dcb2cbac14fde0a10f9d511a974 Merge: 132099e 7a7922e Author: Brad King AuthorDate: Thu Aug 13 10:34:29 2015 -0400 Commit: Brad King CommitDate: Thu Aug 13 10:34:29 2015 -0400 Merge branch 'master' into next ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 13 10:34:54 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 13 Aug 2015 10:34:54 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2206-g4ecece7 Message-ID: <20150813143454.E61F5B167E@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 4ecece742b6941e3d98288254e2e6eeabef22233 (commit) via 675ef165f213a6db1f9d0dfbebf6a0afc5469494 (commit) from 6020a97deeab6dcb2cbac14fde0a10f9d511a974 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4ecece742b6941e3d98288254e2e6eeabef22233 commit 4ecece742b6941e3d98288254e2e6eeabef22233 Merge: 6020a97 675ef16 Author: Brad King AuthorDate: Thu Aug 13 10:34:54 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 13 10:34:54 2015 -0400 Merge topic 'add-link-search-static-properties-defaults' into next 675ef165 Allow LINK_SEARCH_{START,END}_STATIC props to have default values. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=675ef165f213a6db1f9d0dfbebf6a0afc5469494 commit 675ef165f213a6db1f9d0dfbebf6a0afc5469494 Author: Chuck Atkins AuthorDate: Fri Aug 7 15:11:57 2015 -0400 Commit: Brad King CommitDate: Thu Aug 13 10:34:44 2015 -0400 Allow LINK_SEARCH_{START,END}_STATIC props to have default values. Use the CMAKE_LINK_SEARCH_START_STATIC and CMAKE_LINK_SEARCH_END_STATIC variables to initialize the LINK_SEARCH_START_STATIC and LINK_SEARCH_END_STATIC target properties respectively. diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 9066d97..e0dbdeb 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -47,6 +47,8 @@ Variables that Provide Information /variable/CMAKE_JOB_POOL_COMPILE /variable/CMAKE_JOB_POOL_LINK /variable/CMAKE_LINK_LIBRARY_SUFFIX + /variable/CMAKE_LINK_SEARCH_END_STATIC + /variable/CMAKE_LINK_SEARCH_START_STATIC /variable/CMAKE_MAJOR_VERSION /variable/CMAKE_MAKE_PROGRAM /variable/CMAKE_MATCH_COUNT diff --git a/Help/prop_tgt/LINK_SEARCH_END_STATIC.rst b/Help/prop_tgt/LINK_SEARCH_END_STATIC.rst index fe105bd..cf9c871 100644 --- a/Help/prop_tgt/LINK_SEARCH_END_STATIC.rst +++ b/Help/prop_tgt/LINK_SEARCH_END_STATIC.rst @@ -10,5 +10,9 @@ paths are not known or (in some cases) are in implicit link directories for the platform. By default CMake adds an option at the end of the library list (if necessary) to set the linker search type back to its starting type. This property switches the final linker -search type to -Bstatic regardless of how it started. See also -LINK_SEARCH_START_STATIC. +search type to -Bstatic regardless of how it started. + +This property is initialized by the value of the variable +CMAKE_LINK_SEARCH_END_STATIC if it is set when a target is created. + +See also LINK_SEARCH_START_STATIC. diff --git a/Help/prop_tgt/LINK_SEARCH_START_STATIC.rst b/Help/prop_tgt/LINK_SEARCH_START_STATIC.rst index ca899fe..2e0f9bd 100644 --- a/Help/prop_tgt/LINK_SEARCH_START_STATIC.rst +++ b/Help/prop_tgt/LINK_SEARCH_START_STATIC.rst @@ -11,4 +11,9 @@ directories for the platform. By default the linker search type is assumed to be -Bdynamic at the beginning of the library list. This property switches the assumption to -Bstatic. It is intended for use when linking an executable statically (e.g. with the GNU -static -option). See also LINK_SEARCH_END_STATIC. +option). + +This property is initialized by the value of the variable +CMAKE_LINK_SEARCH_START_STATIC if it is set when a target is created. + +See also LINK_SEARCH_END_STATIC. diff --git a/Help/prop_tgt/LINK_SEARCH_END_STATIC.rst b/Help/variable/CMAKE_LINK_SEARCH_END_STATIC.rst similarity index 68% copy from Help/prop_tgt/LINK_SEARCH_END_STATIC.rst copy to Help/variable/CMAKE_LINK_SEARCH_END_STATIC.rst index fe105bd..8a9951d 100644 --- a/Help/prop_tgt/LINK_SEARCH_END_STATIC.rst +++ b/Help/variable/CMAKE_LINK_SEARCH_END_STATIC.rst @@ -1,5 +1,5 @@ -LINK_SEARCH_END_STATIC ----------------------- +CMAKE_LINK_SEARCH_END_STATIC +---------------------------- End a link line such that static system libraries are used. @@ -10,5 +10,9 @@ paths are not known or (in some cases) are in implicit link directories for the platform. By default CMake adds an option at the end of the library list (if necessary) to set the linker search type back to its starting type. This property switches the final linker -search type to -Bstatic regardless of how it started. See also -LINK_SEARCH_START_STATIC. +search type to -Bstatic regardless of how it started. + +This variable is used to initialize the target property +LINK_SEARCH_END_STATIC for all targets. + +See also CMAKE_LINK_SEARCH_START_STATIC. diff --git a/Help/prop_tgt/LINK_SEARCH_START_STATIC.rst b/Help/variable/CMAKE_LINK_SEARCH_START_STATIC.rst similarity index 73% copy from Help/prop_tgt/LINK_SEARCH_START_STATIC.rst copy to Help/variable/CMAKE_LINK_SEARCH_START_STATIC.rst index ca899fe..715db4b 100644 --- a/Help/prop_tgt/LINK_SEARCH_START_STATIC.rst +++ b/Help/variable/CMAKE_LINK_SEARCH_START_STATIC.rst @@ -1,5 +1,5 @@ -LINK_SEARCH_START_STATIC ------------------------- +CMAKE_LINK_SEARCH_START_STATIC +------------------------------ Assume the linker looks for static libraries by default. @@ -11,4 +11,9 @@ directories for the platform. By default the linker search type is assumed to be -Bdynamic at the beginning of the library list. This property switches the assumption to -Bstatic. It is intended for use when linking an executable statically (e.g. with the GNU -static -option). See also LINK_SEARCH_END_STATIC. +option). + +This variable is used to initialize the target property +LINK_SEARCH_START_STATIC for all targets. + +See also CMAKE_LINK_SEARCH_END_STATIC. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index c16472e..12dddd2 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -522,9 +522,10 @@ bool cmComputeLinkInformation::Compute() // libraries are found. const char* lss = this->Target->Target->GetProperty("LINK_SEARCH_END_STATIC"); - if(cmSystemTools::IsOn(lss)) + if(lss) { - this->SetCurrentLinkType(LinkStatic); + this->SetCurrentLinkType( + cmSystemTools::IsOn(lss) ? LinkStatic : LinkShared); } else { @@ -862,7 +863,8 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo() const char* lss = this->Target->Target->GetProperty("LINK_SEARCH_START_STATIC"); this->StartLinkType = cmSystemTools::IsOn(lss)? LinkStatic : LinkShared; - this->CurrentLinkType = this->StartLinkType; + this->CurrentLinkType = LinkUnknown; + this->SetCurrentLinkType(this->StartLinkType); } //---------------------------------------------------------------------------- diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 316d85c..59d4da0 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -306,6 +306,8 @@ void cmTarget::SetMakefile(cmMakefile* mf) this->SetPropertyDefault("CXX_STANDARD", 0); this->SetPropertyDefault("CXX_STANDARD_REQUIRED", 0); this->SetPropertyDefault("CXX_EXTENSIONS", 0); + this->SetPropertyDefault("LINK_SEARCH_START_STATIC", 0); + this->SetPropertyDefault("LINK_SEARCH_END_STATIC", 0); } // Collect the set of configuration types. diff --git a/Tests/RunCMake/set_property/LINK_SEARCH_STATIC.cmake b/Tests/RunCMake/set_property/LINK_SEARCH_STATIC.cmake new file mode 100644 index 0000000..70d2fee --- /dev/null +++ b/Tests/RunCMake/set_property/LINK_SEARCH_STATIC.cmake @@ -0,0 +1,73 @@ +project(LinkSearchStatic) + +set(CMAKE_LINK_SEARCH_START_STATIC ON) +add_executable(LinkSearchStartStaticInit1 LinkStatic.c) +get_target_property(LSSS LinkSearchStartStaticInit1 + LINK_SEARCH_START_STATIC) +if(NOT LSSS) + message(FATAL_ERROR "Failed to correctly initialize LINK_SEARCH_START_STATIC") +endif() +unset(CMAKE_LINK_SEARCH_START_STATIC) + +add_executable(LinkSearchStartStaticSet1 LinkStatic.c) +set_target_properties(LinkSearchStartStaticSet1 PROPERTIES + LINK_SEARCH_START_STATIC ON) +get_target_property(LSSS LinkSearchStartStaticSet1 + LINK_SEARCH_START_STATIC) +if(NOT LSSS) + message(FATAL_ERROR "Failed to correctly set LINK_SEARCH_START_STATIC") +endif() + +set(CMAKE_LINK_SEARCH_START_STATIC OFF) +add_executable(LinkSearchStartStaticInit2 LinkStatic.c) +get_target_property(LSSS LinkSearchStartStaticInit2 + LINK_SEARCH_START_STATIC) +if(LSSS) + message(FATAL_ERROR "Failed to correctly initialize LINK_SEARCH_START_STATIC") +endif() +unset(CMAKE_LINK_SEARCH_START_STATIC) + +add_executable(LinkSearchStartStaticSet2 LinkStatic.c) +set_target_properties(LinkSearchStartStaticSet2 PROPERTIES + LINK_SEARCH_START_STATIC OFF) +get_target_property(LSSS LinkSearchStartStaticSet2 + LINK_SEARCH_START_STATIC) +if(LSSS) + message(FATAL_ERROR "Failed to correctly set LINK_SEARCH_START_STATIC") +endif() + +set(CMAKE_LINK_SEARCH_END_STATIC ON) +add_executable(LinkSearchEndStaticInit1 LinkStatic.c) +get_target_property(LSES LinkSearchEndStaticInit1 + LINK_SEARCH_END_STATIC) +if(NOT LSES) + message(FATAL_ERROR "Failed to correctly initialize LINK_SEARCH_END_STATIC") +endif() +unset(CMAKE_LINK_SEARCH_END_STATIC) + +add_executable(LinkSearchEndStaticSet1 LinkStatic.c) +set_target_properties(LinkSearchEndStaticSet1 PROPERTIES + LINK_SEARCH_END_STATIC ON) +get_target_property(LSSS LinkSearchEndStaticSet1 + LINK_SEARCH_END_STATIC) +if(NOT LSSS) + message(FATAL_ERROR "Failed to correctly set LINK_SEARCH_END_STATIC") +endif() + +set(CMAKE_LINK_SEARCH_END_STATIC OFF) +add_executable(LinkSearchEndStaticInit2 LinkStatic.c) +get_target_property(LSES LinkSearchEndStaticInit2 + LINK_SEARCH_END_STATIC) +if(LSES) + message(FATAL_ERROR "Failed to correctly initialize LINK_SEARCH_END_STATIC") +endif() +unset(CMAKE_LINK_SEARCH_END_STATIC) + +add_executable(LinkSearchEndStaticSet2 LinkStatic.c) +set_target_properties(LinkSearchEndStaticSet2 PROPERTIES + LINK_SEARCH_END_STATIC ON) +get_target_property(LSSS LinkSearchEndStaticSet2 + LINK_SEARCH_END_STATIC) +if(NOT LSSS) + message(FATAL_ERROR "Failed to correctly set LINK_SEARCH_END_STATIC") +endif() diff --git a/Tests/RunCMake/set_property/LinkStatic.c b/Tests/RunCMake/set_property/LinkStatic.c new file mode 100644 index 0000000..3600977 --- /dev/null +++ b/Tests/RunCMake/set_property/LinkStatic.c @@ -0,0 +1,5 @@ +#include +int main(void) +{ + return (int)sin(0); +} diff --git a/Tests/RunCMake/set_property/RunCMakeTest.cmake b/Tests/RunCMake/set_property/RunCMakeTest.cmake index 54e63f7..ada8804 100644 --- a/Tests/RunCMake/set_property/RunCMakeTest.cmake +++ b/Tests/RunCMake/set_property/RunCMakeTest.cmake @@ -1,3 +1,4 @@ include(RunCMake) run_cmake(LINK_LIBRARIES) +run_cmake(LINK_SEARCH_STATIC) ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 13 10:35:14 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 13 Aug 2015 10:35:14 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-831-gd427b5e Message-ID: <20150813143514.D5B1BB1692@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via d427b5ec7121255a4cb9bee961e93fc445f15d19 (commit) via 675ef165f213a6db1f9d0dfbebf6a0afc5469494 (commit) from 7a7922e0201fee6a6f45c702f96ca57a295c68fe (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d427b5ec7121255a4cb9bee961e93fc445f15d19 commit d427b5ec7121255a4cb9bee961e93fc445f15d19 Merge: 7a7922e 675ef16 Author: Brad King AuthorDate: Thu Aug 13 10:35:13 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 13 10:35:13 2015 -0400 Merge topic 'add-link-search-static-properties-defaults' 675ef165 Allow LINK_SEARCH_{START,END}_STATIC props to have default values. ----------------------------------------------------------------------- Summary of changes: Help/manual/cmake-variables.7.rst | 2 + Help/prop_tgt/LINK_SEARCH_END_STATIC.rst | 8 ++- Help/prop_tgt/LINK_SEARCH_START_STATIC.rst | 7 +- .../CMAKE_LINK_SEARCH_END_STATIC.rst} | 12 ++-- .../CMAKE_LINK_SEARCH_START_STATIC.rst} | 11 ++- Source/cmComputeLinkInformation.cxx | 8 ++- Source/cmTarget.cxx | 2 + .../RunCMake/set_property/LINK_SEARCH_STATIC.cmake | 73 ++++++++++++++++++++ .../set_property}/LinkStatic.c | 0 Tests/RunCMake/set_property/RunCMakeTest.cmake | 1 + 10 files changed, 111 insertions(+), 13 deletions(-) copy Help/{prop_tgt/LINK_SEARCH_END_STATIC.rst => variable/CMAKE_LINK_SEARCH_END_STATIC.rst} (68%) copy Help/{prop_tgt/LINK_SEARCH_START_STATIC.rst => variable/CMAKE_LINK_SEARCH_START_STATIC.rst} (73%) create mode 100644 Tests/RunCMake/set_property/LINK_SEARCH_STATIC.cmake copy Tests/{LinkStatic => RunCMake/set_property}/LinkStatic.c (100%) hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 13 10:38:47 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 13 Aug 2015 10:38:47 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-833-g0576aa6 Message-ID: <20150813143847.BE20AB16DD@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 0576aa6085823744c1cd594649e071688b207d5a (commit) via 50c9f521e2debce5beb538050fd12d802964a4b1 (commit) from d427b5ec7121255a4cb9bee961e93fc445f15d19 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0576aa6085823744c1cd594649e071688b207d5a commit 0576aa6085823744c1cd594649e071688b207d5a Merge: d427b5e 50c9f52 Author: Brad King AuthorDate: Thu Aug 13 10:38:46 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 13 10:38:46 2015 -0400 Merge topic 'FindPkgConfig-capital-messages' 50c9f521 FindPkgConfig: Capitalize first letter of all message()s ----------------------------------------------------------------------- Summary of changes: Modules/FindPkgConfig.cmake | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 13 10:38:55 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 13 Aug 2015 10:38:55 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-836-ga07d160 Message-ID: <20150813143855.EF6B3B16D3@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via a07d16085b14e7257254d824b3e800406bc63873 (commit) via d25819bc2623b5144ffc57b694500993ac5759b4 (commit) via e36a05fd7f7d008c4c1e75ebf46eac3072ef71b1 (commit) from 0576aa6085823744c1cd594649e071688b207d5a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a07d16085b14e7257254d824b3e800406bc63873 commit a07d16085b14e7257254d824b3e800406bc63873 Merge: 0576aa6 d25819b Author: Brad King AuthorDate: Thu Aug 13 10:38:54 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 13 10:38:54 2015 -0400 Merge topic 'OUTPUT_DIRECTORY-genex' d25819bc Add generator expression support to OUTPUT_DIRECTORY target properties e36a05fd cmTarget: Detect and diagnose recursion in GetOutputInfo ----------------------------------------------------------------------- Summary of changes: Help/prop_tgt/ARCHIVE_OUTPUT_DIRECTORY_CONFIG.rst | 3 ++ Help/prop_tgt/LIBRARY_OUTPUT_DIRECTORY_CONFIG.rst | 3 ++ Help/prop_tgt/RUNTIME_OUTPUT_DIRECTORY_CONFIG.rst | 3 ++ Help/prop_tgt/XXX_OUTPUT_DIRECTORY.txt | 7 +++- Help/release/dev/OUTPUT_DIRECTORY-genex.rst | 7 ++++ Source/cmTarget.cxx | 41 +++++++++++++++++--- Tests/ExportImport/Export/CMakeLists.txt | 17 +++++++- .../ExportImport/Export/{testExe3.c => testExe4.c} | 2 +- Tests/ExportImport/Import/A/CMakeLists.txt | 12 ++++++ Tests/ExportImport/Import/A/imp_testExe1.c | 3 +- .../GeneratorExpression/RunCMakeTest.cmake | 1 + .../TARGET_FILE-recursion-result.txt} | 0 .../TARGET_FILE-recursion-stderr.txt | 4 ++ .../TARGET_FILE-recursion.cmake | 3 ++ 14 files changed, 95 insertions(+), 11 deletions(-) create mode 100644 Help/release/dev/OUTPUT_DIRECTORY-genex.rst copy Tests/ExportImport/Export/{testExe3.c => testExe4.c} (84%) copy Tests/RunCMake/{CMP0004/CMP0004-NEW-result.txt => GeneratorExpression/TARGET_FILE-recursion-result.txt} (100%) create mode 100644 Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion-stderr.txt create mode 100644 Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion.cmake hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 13 10:42:55 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 13 Aug 2015 10:42:55 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2208-g838f8b2 Message-ID: <20150813144255.B645BB03D4@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 838f8b25efd85267613ab3ff1e18d6206f6127c5 (commit) via 970a741f7db74e67d6b33dc80b39ac2f3cd8b855 (commit) from 4ecece742b6941e3d98288254e2e6eeabef22233 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=838f8b25efd85267613ab3ff1e18d6206f6127c5 commit 838f8b25efd85267613ab3ff1e18d6206f6127c5 Merge: 4ecece7 970a741 Author: Brad King AuthorDate: Thu Aug 13 10:42:54 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 13 10:42:54 2015 -0400 Merge topic 'add-link-search-static-properties-defaults' into next 970a741f Help: Add notes for topic 'add-link-search-static-properties-defaults' http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=970a741f7db74e67d6b33dc80b39ac2f3cd8b855 commit 970a741f7db74e67d6b33dc80b39ac2f3cd8b855 Author: Brad King AuthorDate: Thu Aug 13 10:42:38 2015 -0400 Commit: Brad King CommitDate: Thu Aug 13 10:42:38 2015 -0400 Help: Add notes for topic 'add-link-search-static-properties-defaults' diff --git a/Help/release/dev/add-link-search-static-properties-defaults.rst b/Help/release/dev/add-link-search-static-properties-defaults.rst new file mode 100644 index 0000000..98dda30 --- /dev/null +++ b/Help/release/dev/add-link-search-static-properties-defaults.rst @@ -0,0 +1,9 @@ +add-link-search-static-properties-defaults +------------------------------------------ + +* New :variable:`CMAKE_LINK_SEARCH_START_STATIC` and + :variable:`CMAKE_LINK_SEARCH_END_STATIC` variables were + introduced to initialize the + :prop_tgt:`LINK_SEARCH_START_STATIC` and + :prop_tgt:`LINK_SEARCH_END_STATIC` target properties, + respectively. ----------------------------------------------------------------------- Summary of changes: .../dev/add-link-search-static-properties-defaults.rst | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 Help/release/dev/add-link-search-static-properties-defaults.rst hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 13 10:43:15 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 13 Aug 2015 10:43:15 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-838-gfb3035a Message-ID: <20150813144315.DE3EFB0440@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via fb3035a92c9c7038d0c5fdc3fd8268ac371d673b (commit) via 970a741f7db74e67d6b33dc80b39ac2f3cd8b855 (commit) from a07d16085b14e7257254d824b3e800406bc63873 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fb3035a92c9c7038d0c5fdc3fd8268ac371d673b commit fb3035a92c9c7038d0c5fdc3fd8268ac371d673b Merge: a07d160 970a741 Author: Brad King AuthorDate: Thu Aug 13 10:43:14 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 13 10:43:14 2015 -0400 Merge topic 'add-link-search-static-properties-defaults' 970a741f Help: Add notes for topic 'add-link-search-static-properties-defaults' ----------------------------------------------------------------------- Summary of changes: .../dev/add-link-search-static-properties-defaults.rst | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 Help/release/dev/add-link-search-static-properties-defaults.rst hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 13 10:43:32 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 13 Aug 2015 10:43:32 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2213-g886e5bb Message-ID: <20150813144332.4C400B0490@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 886e5bb6027951150f08192923d9b9925b69d2f4 (commit) via fb3035a92c9c7038d0c5fdc3fd8268ac371d673b (commit) via a07d16085b14e7257254d824b3e800406bc63873 (commit) via 0576aa6085823744c1cd594649e071688b207d5a (commit) via d427b5ec7121255a4cb9bee961e93fc445f15d19 (commit) from 838f8b25efd85267613ab3ff1e18d6206f6127c5 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=886e5bb6027951150f08192923d9b9925b69d2f4 commit 886e5bb6027951150f08192923d9b9925b69d2f4 Merge: 838f8b2 fb3035a Author: Brad King AuthorDate: Thu Aug 13 10:43:25 2015 -0400 Commit: Brad King CommitDate: Thu Aug 13 10:43:25 2015 -0400 Merge branch 'master' into next ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 13 11:01:53 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 13 Aug 2015 11:01:53 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2216-g8f32935 Message-ID: <20150813150153.7BA36B15ED@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 8f32935592cb7012f491b7e3467f567abfb287f1 (commit) via 75e3a8e811b290cb9921887f2b086377af90880f (commit) via 79a364376ca7b4b598b4827031a7515ffd497f24 (commit) from 886e5bb6027951150f08192923d9b9925b69d2f4 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8f32935592cb7012f491b7e3467f567abfb287f1 commit 8f32935592cb7012f491b7e3467f567abfb287f1 Merge: 886e5bb 75e3a8e Author: Brad King AuthorDate: Thu Aug 13 11:01:52 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 13 11:01:52 2015 -0400 Merge topic 'FindOpenSSL-imported-targets' into next 75e3a8e8 FindOpenSSL: Provide imported targets OpenSSL::{SSL,Crypto} 79a36437 FindOpenSSL: Revise and format module documentation http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=75e3a8e811b290cb9921887f2b086377af90880f commit 75e3a8e811b290cb9921887f2b086377af90880f Author: Konstantin Podsvirov AuthorDate: Fri Aug 7 14:13:33 2015 +0300 Commit: Brad King CommitDate: Thu Aug 13 10:58:40 2015 -0400 FindOpenSSL: Provide imported targets OpenSSL::{SSL,Crypto} diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake index a334354..434ef58 100644 --- a/Modules/FindOpenSSL.cmake +++ b/Modules/FindOpenSSL.cmake @@ -4,6 +4,16 @@ # # Find the OpenSSL encryption library. # +# Imported Targets +# ^^^^^^^^^^^^^^^^ +# +# This module defines the following :prop_tgt:`IMPORTED` targets: +# +# ``OpenSSL::SSL`` +# The OpenSSL ``ssl`` library, if found. +# ``OpenSSL::Crypto`` +# The OpenSSL ``crypto`` library, if found. +# # Result Variables # ^^^^^^^^^^^^^^^^ # @@ -341,3 +351,66 @@ else () endif () mark_as_advanced(OPENSSL_INCLUDE_DIR OPENSSL_LIBRARIES) + +if(OPENSSL_FOUND) + if(NOT TARGET OpenSSL::Crypto AND + (EXISTS "${OPENSSL_CRYPTO_LIBRARY}" OR + EXISTS "${LIB_EAY_LIBRARY_DEBUG}" OR + EXISTS "${LIB_EAY_LIBRARY_RELEASE}") + ) + add_library(OpenSSL::Crypto UNKNOWN IMPORTED) + set_target_properties(OpenSSL::Crypto PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${OPENSSL_INCLUDE_DIR}") + if(EXISTS "${OPENSSL_CRYPTO_LIBRARY}") + set_target_properties(OpenSSL::Crypto PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${OPENSSL_CRYPTO_LIBRARY}") + endif() + if(EXISTS "${LIB_EAY_LIBRARY_DEBUG}") + set_property(TARGET OpenSSL::Crypto APPEND PROPERTY + IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties(OpenSSL::Crypto PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C" + IMPORTED_LOCATION_DEBUG "${LIB_EAY_LIBRARY_DEBUG}") + endif() + if(EXISTS "${LIB_EAY_LIBRARY_RELEASE}") + set_property(TARGET OpenSSL::Crypto APPEND PROPERTY + IMPORTED_CONFIGURATIONS RELEASE) + set_target_properties(OpenSSL::Crypto PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C" + IMPORTED_LOCATION_RELEASE "${LIB_EAY_LIBRARY_RELEASE}") + endif() + endif() + if(NOT TARGET OpenSSL::SSL AND + (EXISTS "${OPENSSL_SSL_LIBRARY}" OR + EXISTS "${SSL_EAY_LIBRARY_DEBUG}" OR + EXISTS "${SSL_EAY_LIBRARY_RELEASE}") + ) + add_library(OpenSSL::SSL UNKNOWN IMPORTED) + set_target_properties(OpenSSL::SSL PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${OPENSSL_INCLUDE_DIR}") + if(EXISTS "${OPENSSL_SSL_LIBRARY}") + set_target_properties(OpenSSL::SSL PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${OPENSSL_SSL_LIBRARY}") + endif() + if(EXISTS "${SSL_EAY_LIBRARY_DEBUG}") + set_property(TARGET OpenSSL::SSL APPEND PROPERTY + IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties(OpenSSL::SSL PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C" + IMPORTED_LOCATION_DEBUG "${SSL_EAY_LIBRARY_DEBUG}") + endif() + if(EXISTS "${SSL_EAY_LIBRARY_RELEASE}") + set_property(TARGET OpenSSL::SSL APPEND PROPERTY + IMPORTED_CONFIGURATIONS RELEASE) + set_target_properties(OpenSSL::SSL PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C" + IMPORTED_LOCATION_RELEASE "${SSL_EAY_LIBRARY_RELEASE}") + endif() + if(TARGET OpenSSL::Crypto) + set_target_properties(OpenSSL::SSL PROPERTIES + INTERFACE_LINK_LIBRARIES OpenSSL::Crypto) + endif() + endif() +endif() diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 5781a9e..35b29bf 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1333,6 +1333,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release add_subdirectory(FindJsonCpp) endif() + if(CMake_TEST_FindOpenSSL) + add_subdirectory(FindOpenSSL) + endif() + # Matlab module if(CMake_TEST_FindMatlab) ADD_TEST_MACRO(FindMatlab.basic_checks ${CMAKE_CTEST_COMMAND} -C $) diff --git a/Tests/FindOpenSSL/CMakeLists.txt b/Tests/FindOpenSSL/CMakeLists.txt new file mode 100644 index 0000000..66b3fb2 --- /dev/null +++ b/Tests/FindOpenSSL/CMakeLists.txt @@ -0,0 +1,9 @@ +add_test(NAME FindOpenSSL.rand COMMAND ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindOpenSSL/rand" + "${CMake_BINARY_DIR}/Tests/FindOpenSSL/rand" + ${build_generator_args} + --build-project FindOpenSSL_rand + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V + ) diff --git a/Tests/FindOpenSSL/rand/CMakeLists.txt b/Tests/FindOpenSSL/rand/CMakeLists.txt new file mode 100644 index 0000000..520d5d2 --- /dev/null +++ b/Tests/FindOpenSSL/rand/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.0) +project(FindOpenSSL_rand CXX) +include(CTest) + +find_package(OpenSSL REQUIRED) + +add_executable(tstopensslrand_tgt main.cc) +target_link_libraries(tstopensslrand_tgt OpenSSL::SSL) +add_test(NAME tstopensslrand_tgt COMMAND tstopensslrand_tgt) + +add_executable(tstopensslrand_var main.cc) +target_link_libraries(tstopensslrand_var ${OPENSSL_LIBRARIES}) +target_include_directories(tstopensslrand_var PRIVATE ${OPENSSL_INCLUDE_DIR}) +add_test(NAME tstopensslrand_var COMMAND tstopensslrand_var) diff --git a/Tests/FindOpenSSL/rand/main.cc b/Tests/FindOpenSSL/rand/main.cc new file mode 100644 index 0000000..a5d1ac0 --- /dev/null +++ b/Tests/FindOpenSSL/rand/main.cc @@ -0,0 +1,22 @@ +#include + +int main() +{ + // return value + int retval = 1; + + // bytes buffer + unsigned char buf[1024]; + + // random bytes + int rezval = RAND_bytes(buf, sizeof(buf)); /* 1 succes, 0 otherwise */ + + // check result + if(rezval == 1) + { + retval = 0; + } + + // return code + return retval; +} http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=79a364376ca7b4b598b4827031a7515ffd497f24 commit 79a364376ca7b4b598b4827031a7515ffd497f24 Author: Brad King AuthorDate: Thu Aug 13 10:53:08 2015 -0400 Commit: Brad King CommitDate: Thu Aug 13 10:53:08 2015 -0400 FindOpenSSL: Revise and format module documentation Improve reStructuredText formatting and add section headers. diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake index 7545d94..a334354 100644 --- a/Modules/FindOpenSSL.cmake +++ b/Modules/FindOpenSSL.cmake @@ -2,26 +2,30 @@ # FindOpenSSL # ----------- # -# Try to find the OpenSSL encryption library +# Find the OpenSSL encryption library. # -# Once done this will define +# Result Variables +# ^^^^^^^^^^^^^^^^ # -# :: +# This module will set the following variables in your project: # -# OPENSSL_ROOT_DIR - Set this variable to the root installation of OpenSSL +# ``OPENSSL_FOUND`` +# System has the OpenSSL library. +# ``OPENSSL_INCLUDE_DIR`` +# The OpenSSL include directory. +# ``OPENSSL_CRYPTO_LIBRARY`` +# The OpenSSL crypto library. +# ``OPENSSL_SSL_LIBRARY`` +# The OpenSSL SSL library. +# ``OPENSSL_LIBRARIES`` +# All OpenSSL libraries. +# ``OPENSSL_VERSION`` +# This is set to ``$major.$minor.$revision$patch`` (e.g. ``0.9.8s``). # +# Hints +# ^^^^^ # -# -# Read-Only variables: -# -# :: -# -# OPENSSL_FOUND - System has the OpenSSL library -# OPENSSL_INCLUDE_DIR - The OpenSSL include directory -# OPENSSL_CRYPTO_LIBRARY - The OpenSSL crypto library -# OPENSSL_SSL_LIBRARY - The OpenSSL SSL library -# OPENSSL_LIBRARIES - All OpenSSL libraries -# OPENSSL_VERSION - This is set to $major.$minor.$revision$patch (eg. 0.9.8s) +# Set ``OPENSSL_ROOT_DIR`` to the root directory of an OpenSSL installation. #============================================================================= # Copyright 2006-2009 Kitware, Inc. ----------------------------------------------------------------------- Summary of changes: Modules/FindOpenSSL.cmake | 101 +++++++++++++++++++++++++++++---- Tests/CMakeLists.txt | 4 ++ Tests/FindOpenSSL/CMakeLists.txt | 9 +++ Tests/FindOpenSSL/rand/CMakeLists.txt | 14 +++++ Tests/FindOpenSSL/rand/main.cc | 22 +++++++ 5 files changed, 138 insertions(+), 12 deletions(-) create mode 100644 Tests/FindOpenSSL/CMakeLists.txt create mode 100644 Tests/FindOpenSSL/rand/CMakeLists.txt create mode 100644 Tests/FindOpenSSL/rand/main.cc hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 13 11:08:22 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 13 Aug 2015 11:08:22 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2218-g8b8e175 Message-ID: <20150813150822.6BDE5B16FD@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 8b8e175c162944513de1bf722dcf0b03abe27258 (commit) via 6699834d6298eabe53f2c15d051fbe16cc9014c3 (commit) from 8f32935592cb7012f491b7e3467f567abfb287f1 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8b8e175c162944513de1bf722dcf0b03abe27258 commit 8b8e175c162944513de1bf722dcf0b03abe27258 Merge: 8f32935 6699834 Author: Brad King AuthorDate: Thu Aug 13 11:08:21 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 13 11:08:21 2015 -0400 Merge topic 'compiler-id-ancient-gcc-version' into next 6699834d GNU-DetermineCompiler: Add support for very old versions of GCC http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6699834d6298eabe53f2c15d051fbe16cc9014c3 commit 6699834d6298eabe53f2c15d051fbe16cc9014c3 Author: Kars de Jong AuthorDate: Thu Aug 13 13:33:37 2015 +0200 Commit: Brad King CommitDate: Thu Aug 13 11:07:03 2015 -0400 GNU-DetermineCompiler: Add support for very old versions of GCC Very old versions of gcc (2.3.1) do not define __GNUC_MINOR__. Signed-off-by: Kars de Jong diff --git a/Modules/Compiler/GNU-DetermineCompiler.cmake b/Modules/Compiler/GNU-DetermineCompiler.cmake index 261f148..6ddc566 100644 --- a/Modules/Compiler/GNU-DetermineCompiler.cmake +++ b/Modules/Compiler/GNU-DetermineCompiler.cmake @@ -3,7 +3,9 @@ set(_compiler_id_pp_test "defined(__GNUC__)") set(_compiler_id_version_compute " # define @PREFIX at COMPILER_VERSION_MAJOR @MACRO_DEC@(__GNUC__) -# define @PREFIX at COMPILER_VERSION_MINOR @MACRO_DEC@(__GNUC_MINOR__) +# if defined(__GNUC_MINOR__) +# define @PREFIX at COMPILER_VERSION_MINOR @MACRO_DEC@(__GNUC_MINOR__) +# endif # if defined(__GNUC_PATCHLEVEL__) # define @PREFIX at COMPILER_VERSION_PATCH @MACRO_DEC@(__GNUC_PATCHLEVEL__) # endif") ----------------------------------------------------------------------- Summary of changes: Modules/Compiler/GNU-DetermineCompiler.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 13 14:41:19 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 13 Aug 2015 14:41:19 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-840-g72250e6 Message-ID: <20150813184119.48BE4B00B1@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 72250e68db07969675661ccb2eab791c8de034f7 (commit) via 4a6fe0290880bd56dd5141f06c9fa2b9e310162e (commit) from fb3035a92c9c7038d0c5fdc3fd8268ac371d673b (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 13 14:41:19 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 13 Aug 2015 14:41:19 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2220-gf4ee08f Message-ID: <20150813184119.7F737B0149@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via f4ee08f7a1a82f955741bac5d8bf94c484e89f22 (commit) via 72250e68db07969675661ccb2eab791c8de034f7 (commit) from 8b8e175c162944513de1bf722dcf0b03abe27258 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f4ee08f7a1a82f955741bac5d8bf94c484e89f22 commit f4ee08f7a1a82f955741bac5d8bf94c484e89f22 Merge: 8b8e175 72250e6 Author: Brad King AuthorDate: Thu Aug 13 14:40:57 2015 -0400 Commit: Brad King CommitDate: Thu Aug 13 14:40:57 2015 -0400 Merge branch 'master' into next ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 13 14:41:19 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 13 Aug 2015 14:41:19 -0400 (EDT) Subject: [Cmake-commits] CMake branch, release, updated. v3.3.0-9-g4a6fe02 Message-ID: <20150813184119.93FBBB01FF@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, release has been updated via 4a6fe0290880bd56dd5141f06c9fa2b9e310162e (commit) from bcd8fc58a03b6bd0cb0744d1f61dd0a1277640e1 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Fri Aug 14 00:01:10 2015 From: kwrobot at kitware.com (Kitware Robot) Date: Fri, 14 Aug 2015 00:01:10 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-841-g17ecfd8 Message-ID: <20150814040110.796D2B13E9@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 17ecfd8210b4db74753c4565b10a2b75dfa4c480 (commit) from 72250e68db07969675661ccb2eab791c8de034f7 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=17ecfd8210b4db74753c4565b10a2b75dfa4c480 commit 17ecfd8210b4db74753c4565b10a2b75dfa4c480 Author: Kitware Robot AuthorDate: Fri Aug 14 00:01:08 2015 -0400 Commit: Kitware Robot CommitDate: Fri Aug 14 00:01:08 2015 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 620e3e3..c32856d 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150813) +set(CMake_VERSION_PATCH 20150814) #set(CMake_VERSION_RC 1) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Fri Aug 14 09:24:55 2015 From: brad.king at kitware.com (Brad King) Date: Fri, 14 Aug 2015 09:24:55 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2222-gcdaed8a Message-ID: <20150814132455.75ADDB1590@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via cdaed8a166e4ea74d1ca9ca3435bb00edbf63bbc (commit) via dcbfac8bc394d307386069c84d6ac7282b88bc8e (commit) from f4ee08f7a1a82f955741bac5d8bf94c484e89f22 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cdaed8a166e4ea74d1ca9ca3435bb00edbf63bbc commit cdaed8a166e4ea74d1ca9ca3435bb00edbf63bbc Merge: f4ee08f dcbfac8 Author: Brad King AuthorDate: Fri Aug 14 09:24:54 2015 -0400 Commit: CMake Topic Stage CommitDate: Fri Aug 14 09:24:54 2015 -0400 Merge topic 'update-curl' into next dcbfac8b curl: Fix check for gethostbyname_r with 5 arguments http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=dcbfac8bc394d307386069c84d6ac7282b88bc8e commit dcbfac8bc394d307386069c84d6ac7282b88bc8e Author: Brad King AuthorDate: Fri Aug 14 09:14:55 2015 -0400 Commit: Brad King CommitDate: Fri Aug 14 09:23:51 2015 -0400 curl: Fix check for gethostbyname_r with 5 arguments Fix the check code to pass 5 arguments instead of 6. This typo was introduced in curl 7.39 but was not noticed because the result of this check is used only if ENABLE_IPV6 is OFF. diff --git a/Utilities/cmcurl/CMake/CurlTests.c b/Utilities/cmcurl/CMake/CurlTests.c index 04d5e7e..3c71232 100644 --- a/Utilities/cmcurl/CMake/CurlTests.c +++ b/Utilities/cmcurl/CMake/CurlTests.c @@ -139,7 +139,7 @@ int main(void) rc = gethostbyname_r(address, &h, &hdata); #elif defined(HAVE_GETHOSTBYNAME_R_5) || \ defined(HAVE_GETHOSTBYNAME_R_5_REENTRANT) - rc = gethostbyname_r(address, &h, buffer, 8192, 0, &h_errnop); + rc = gethostbyname_r(address, &h, buffer, 8192, &h_errnop); (void)hp; /* not used for test */ #elif defined(HAVE_GETHOSTBYNAME_R_6) || \ defined(HAVE_GETHOSTBYNAME_R_6_REENTRANT) ----------------------------------------------------------------------- Summary of changes: Utilities/cmcurl/CMake/CurlTests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Fri Aug 14 09:54:03 2015 From: brad.king at kitware.com (Brad King) Date: Fri, 14 Aug 2015 09:54:03 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2225-ge3e1e3d Message-ID: <20150814135403.01EC9B138F@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via e3e1e3d47072b631f0a857079a6b6e362f31d9a7 (commit) via 724fa682705a17bef0c74b9dcf09bc9cf1761dde (commit) via 17ecfd8210b4db74753c4565b10a2b75dfa4c480 (commit) from cdaed8a166e4ea74d1ca9ca3435bb00edbf63bbc (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e3e1e3d47072b631f0a857079a6b6e362f31d9a7 commit e3e1e3d47072b631f0a857079a6b6e362f31d9a7 Merge: cdaed8a 724fa68 Author: Brad King AuthorDate: Fri Aug 14 09:54:02 2015 -0400 Commit: CMake Topic Stage CommitDate: Fri Aug 14 09:54:02 2015 -0400 Merge topic 'FindTIFF-updates' into next 724fa682 FindTIFF: Find debug and release libraries separately 17ecfd82 CMake Nightly Date Stamp http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=724fa682705a17bef0c74b9dcf09bc9cf1761dde commit 724fa682705a17bef0c74b9dcf09bc9cf1761dde Author: Roger Leigh AuthorDate: Fri Aug 7 13:51:42 2015 +0000 Commit: Brad King CommitDate: Fri Aug 14 09:49:46 2015 -0400 FindTIFF: Find debug and release libraries separately diff --git a/Help/release/dev/FindTIFF-updates.rst b/Help/release/dev/FindTIFF-updates.rst new file mode 100644 index 0000000..083e40f --- /dev/null +++ b/Help/release/dev/FindTIFF-updates.rst @@ -0,0 +1,5 @@ +FindTIFF-updates +---------------- + +* The :module:`FindTIFF` module learned to search separately for + debug and release variants. diff --git a/Modules/FindTIFF.cmake b/Modules/FindTIFF.cmake index a67d24d..ed092ea 100644 --- a/Modules/FindTIFF.cmake +++ b/Modules/FindTIFF.cmake @@ -34,7 +34,19 @@ find_path(TIFF_INCLUDE_DIR tiff.h) set(TIFF_NAMES ${TIFF_NAMES} tiff libtiff tiff3 libtiff3) -find_library(TIFF_LIBRARY NAMES ${TIFF_NAMES} ) +foreach(name ${TIFF_NAMES}) + list(APPEND TIFF_NAMES_DEBUG "${name}d") +endforeach() + +if(NOT TIFF_LIBRARY) + find_library(TIFF_LIBRARY_RELEASE NAMES ${TIFF_NAMES}) + find_library(TIFF_LIBRARY_DEBUG NAMES ${TIFF_NAMES_DEBUG}) + include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) + select_library_configurations(TIFF) + mark_as_advanced(TIFF_LIBRARY_RELEASE TIFF_LIBRARY_DEBUG) +endif() +unset(TIFF_NAMES) +unset(TIFF_NAMES_DEBUG) if(TIFF_INCLUDE_DIR AND EXISTS "${TIFF_INCLUDE_DIR}/tiffvers.h") file(STRINGS "${TIFF_INCLUDE_DIR}/tiffvers.h" tiff_version_str ----------------------------------------------------------------------- Summary of changes: Help/release/dev/FindTIFF-updates.rst | 5 +++++ Modules/FindTIFF.cmake | 14 +++++++++++++- Source/CMakeVersion.cmake | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 Help/release/dev/FindTIFF-updates.rst hooks/post-receive -- CMake From brad.king at kitware.com Fri Aug 14 09:54:07 2015 From: brad.king at kitware.com (Brad King) Date: Fri, 14 Aug 2015 09:54:07 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2228-g3a4935a Message-ID: <20150814135407.74327B1398@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 3a4935a1dccd4886c8f7a4c03d416157d1937f81 (commit) via db292564293ce6899728fa172614d4eec59b429f (commit) via 021bf871a6ffa51b6bd0f5834e8a5049c54f8b30 (commit) from e3e1e3d47072b631f0a857079a6b6e362f31d9a7 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3a4935a1dccd4886c8f7a4c03d416157d1937f81 commit 3a4935a1dccd4886c8f7a4c03d416157d1937f81 Merge: e3e1e3d db29256 Author: Brad King AuthorDate: Fri Aug 14 09:54:06 2015 -0400 Commit: CMake Topic Stage CommitDate: Fri Aug 14 09:54:06 2015 -0400 Merge topic 'FindXercesC-updates' into next db292564 FindXercesC: Add support for 3D_1 variant of the library 021bf871 FindXercesC: Find debug and release libraries separately http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=db292564293ce6899728fa172614d4eec59b429f commit db292564293ce6899728fa172614d4eec59b429f Author: Roger Leigh AuthorDate: Thu Aug 13 15:37:41 2015 +0000 Commit: Brad King CommitDate: Fri Aug 14 09:52:48 2015 -0400 FindXercesC: Add support for 3D_1 variant of the library This version is generated by the Windows Visual Studio project files for unknown reasons, but is required to pick up the debug version of the library created by current versions of Xerces-C. diff --git a/Modules/FindXercesC.cmake b/Modules/FindXercesC.cmake index 23919c7..cf84826 100644 --- a/Modules/FindXercesC.cmake +++ b/Modules/FindXercesC.cmake @@ -67,7 +67,7 @@ if(NOT XercesC_LIBRARY) NAMES "xerces-c" "xerces-c_3" DOC "Xerces-C++ libraries (release)") find_library(XercesC_LIBRARY_DEBUG - NAMES "xerces-cd" "xerces-c_3D" + NAMES "xerces-cd" "xerces-c_3D" "xerces-c_3_1D" DOC "Xerces-C++ libraries (debug)") include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) select_library_configurations(XercesC) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=021bf871a6ffa51b6bd0f5834e8a5049c54f8b30 commit 021bf871a6ffa51b6bd0f5834e8a5049c54f8b30 Author: Roger Leigh AuthorDate: Fri Aug 7 13:54:34 2015 +0000 Commit: Brad King CommitDate: Fri Aug 14 09:52:36 2015 -0400 FindXercesC: Find debug and release libraries separately diff --git a/Help/release/dev/FindXercesC-updates.rst b/Help/release/dev/FindXercesC-updates.rst new file mode 100644 index 0000000..47a8ada --- /dev/null +++ b/Help/release/dev/FindXercesC-updates.rst @@ -0,0 +1,5 @@ +FindXercesC-updates +------------------- + +* The :module:`FindXercesC` module learned to search separately for + debug and release variants. diff --git a/Modules/FindXercesC.cmake b/Modules/FindXercesC.cmake index fd0b992..23919c7 100644 --- a/Modules/FindXercesC.cmake +++ b/Modules/FindXercesC.cmake @@ -61,10 +61,18 @@ find_path(XercesC_INCLUDE_DIR DOC "Xerces-C++ include directory") mark_as_advanced(XercesC_INCLUDE_DIR) -# Find all XercesC libraries -find_library(XercesC_LIBRARY NAMES "xerces-c" "xerces-c_3" "xerces-c_2" - DOC "Xerces-C++ libraries") -mark_as_advanced(XercesC_LIBRARY) +if(NOT XercesC_LIBRARY) + # Find all XercesC libraries + find_library(XercesC_LIBRARY_RELEASE + NAMES "xerces-c" "xerces-c_3" + DOC "Xerces-C++ libraries (release)") + find_library(XercesC_LIBRARY_DEBUG + NAMES "xerces-cd" "xerces-c_3D" + DOC "Xerces-C++ libraries (debug)") + include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) + select_library_configurations(XercesC) + mark_as_advanced(XercesC_LIBRARY_RELEASE XercesC_LIBRARY_DEBUG) +endif() if(XercesC_INCLUDE_DIR) _XercesC_GET_VERSION("${XercesC_INCLUDE_DIR}/xercesc/util/XercesVersion.hpp") ----------------------------------------------------------------------- Summary of changes: Help/release/dev/FindXercesC-updates.rst | 5 +++++ Modules/FindXercesC.cmake | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 Help/release/dev/FindXercesC-updates.rst hooks/post-receive -- CMake From brad.king at kitware.com Fri Aug 14 09:55:32 2015 From: brad.king at kitware.com (Brad King) Date: Fri, 14 Aug 2015 09:55:32 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2230-g027d00e Message-ID: <20150814135532.B46B9B1421@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 027d00e82a294652a3fb73c04510da8f15bfaacc (commit) via ff5bb2efbe9f7bb4a1824b0ad727713fcd6bc54a (commit) from 3a4935a1dccd4886c8f7a4c03d416157d1937f81 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=027d00e82a294652a3fb73c04510da8f15bfaacc commit 027d00e82a294652a3fb73c04510da8f15bfaacc Merge: 3a4935a ff5bb2e Author: Brad King AuthorDate: Fri Aug 14 09:55:32 2015 -0400 Commit: CMake Topic Stage CommitDate: Fri Aug 14 09:55:32 2015 -0400 Merge topic 'FindBoost-1.59' into next ff5bb2ef FindBoost: Add support for Boost 1.59 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ff5bb2efbe9f7bb4a1824b0ad727713fcd6bc54a commit ff5bb2efbe9f7bb4a1824b0ad727713fcd6bc54a Author: Roger Leigh AuthorDate: Thu Aug 13 23:34:39 2015 +0100 Commit: Brad King CommitDate: Fri Aug 14 09:55:07 2015 -0400 FindBoost: Add support for Boost 1.59 diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index 05b552a..33e6a49 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -512,13 +512,15 @@ else() # The user has not requested an exact version. Among known # versions, find those that are acceptable to the user request. set(_Boost_KNOWN_VERSIONS ${Boost_ADDITIONAL_VERSIONS} - "1.58.0" "1.58" "1.57.0" "1.57" "1.56.0" "1.56" "1.55.0" "1.55" "1.54.0" "1.54" - "1.53.0" "1.53" "1.52.0" "1.52" "1.51.0" "1.51" + + "1.59.0" "1.59" "1.58.0" "1.58" "1.57.0" "1.57" "1.56.0" "1.56" "1.55.0" "1.55" + "1.54.0" "1.54" "1.53.0" "1.53" "1.52.0" "1.52" "1.51.0" "1.51" "1.50.0" "1.50" "1.49.0" "1.49" "1.48.0" "1.48" "1.47.0" "1.47" "1.46.1" "1.46.0" "1.46" "1.45.0" "1.45" "1.44.0" "1.44" "1.43.0" "1.43" "1.42.0" "1.42" "1.41.0" "1.41" "1.40.0" "1.40" "1.39.0" "1.39" "1.38.0" "1.38" "1.37.0" "1.37" "1.36.1" "1.36.0" "1.36" "1.35.1" "1.35.0" "1.35" "1.34.1" "1.34.0" "1.34" "1.33.1" "1.33.0" "1.33") + set(_boost_TEST_VERSIONS) if(Boost_FIND_VERSION) set(_Boost_FIND_VERSION_SHORT "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}") ----------------------------------------------------------------------- Summary of changes: Modules/FindBoost.cmake | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Fri Aug 14 10:48:50 2015 From: brad.king at kitware.com (Brad King) Date: Fri, 14 Aug 2015 10:48:50 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2233-g6428e16 Message-ID: <20150814144850.EED57B0E8B@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 6428e163380112586eff21c301f4d4b19d7d0a15 (commit) via 64e6bc5ca3bf15239829f18a71511df2f04181b3 (commit) via 758664b7ad018aa19072fe5c359a702c472faae2 (commit) from 027d00e82a294652a3fb73c04510da8f15bfaacc (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6428e163380112586eff21c301f4d4b19d7d0a15 commit 6428e163380112586eff21c301f4d4b19d7d0a15 Merge: 027d00e 64e6bc5 Author: Brad King AuthorDate: Fri Aug 14 10:48:50 2015 -0400 Commit: CMake Topic Stage CommitDate: Fri Aug 14 10:48:50 2015 -0400 Merge topic 'emacs-mode-font-lock' into next 64e6bc5c cmake-mode.el: Refine variable font-lock 758664b7 cmake-mode.el: Fix function name font-lock http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=64e6bc5ca3bf15239829f18a71511df2f04181b3 commit 64e6bc5ca3bf15239829f18a71511df2f04181b3 Author: Roy Crihfield AuthorDate: Thu Aug 13 10:54:27 2015 -0500 Commit: Brad King CommitDate: Fri Aug 14 10:16:22 2015 -0400 cmake-mode.el: Refine variable font-lock Simplify regexp for variable names, and allow more legal characters. Remove `$ *` as legal chars, and allow `- + / .` in names. diff --git a/Auxiliary/cmake-mode.el b/Auxiliary/cmake-mode.el index cf82d09..11e33b3 100644 --- a/Auxiliary/cmake-mode.el +++ b/Auxiliary/cmake-mode.el @@ -200,7 +200,7 @@ the indentation. Otherwise it retains the same position on the line" . font-lock-keyword-face) (,(rx symbol-start (group (+ (or word (syntax symbol)))) (* blank) ?\() 1 font-lock-function-name-face) - ("\\${?\\([[:alpha:]_][[:alnum:]_]*\\|[0-9]+\\|[$*_]\\)" + (,(rx "${" (group (+(any alnum "-_+/."))) "}") 1 font-lock-variable-name-face t) ) "Highlighting expressions for CMake mode.") http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=758664b7ad018aa19072fe5c359a702c472faae2 commit 758664b7ad018aa19072fe5c359a702c472faae2 Author: Roy Crihfield AuthorDate: Thu Aug 13 10:23:34 2015 -0500 Commit: Brad King CommitDate: Thu Aug 13 15:24:18 2015 -0400 cmake-mode.el: Fix function name font-lock Allow space separating name and opening parenthesis. diff --git a/Auxiliary/cmake-mode.el b/Auxiliary/cmake-mode.el index 02f0385..cf82d09 100644 --- a/Auxiliary/cmake-mode.el +++ b/Auxiliary/cmake-mode.el @@ -198,7 +198,7 @@ the indentation. Otherwise it retains the same position on the line" ,@(mapcar #'downcase cmake-keywords)) symbol-end)) . font-lock-keyword-face) - (,(rx symbol-start (group (+ (or word (syntax symbol)))) ?\() + (,(rx symbol-start (group (+ (or word (syntax symbol)))) (* blank) ?\() 1 font-lock-function-name-face) ("\\${?\\([[:alpha:]_][[:alnum:]_]*\\|[0-9]+\\|[$*_]\\)" 1 font-lock-variable-name-face t) ----------------------------------------------------------------------- Summary of changes: Auxiliary/cmake-mode.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) hooks/post-receive -- CMake From chuck.atkins at kitware.com Fri Aug 14 12:05:16 2015 From: chuck.atkins at kitware.com (Chuck Atkins) Date: Fri, 14 Aug 2015 12:05:16 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2236-gb5cc08f Message-ID: <20150814160516.430ACB1609@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via b5cc08fa9acd1678a671b7a4cefaa9c901bb15b7 (commit) via 7f0b83e0185f4e131110a61d898cec4a96bd9a7d (commit) via fb77c2c54bc341e76a83f646e6d75662c44179fc (commit) from 6428e163380112586eff21c301f4d4b19d7d0a15 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b5cc08fa9acd1678a671b7a4cefaa9c901bb15b7 commit b5cc08fa9acd1678a671b7a4cefaa9c901bb15b7 Merge: 6428e16 7f0b83e Author: Chuck Atkins AuthorDate: Fri Aug 14 12:05:15 2015 -0400 Commit: CMake Topic Stage CommitDate: Fri Aug 14 12:05:15 2015 -0400 Merge topic 'propagate-link-search-to-try_compile' into next 7f0b83e0 try_compile: Update documentation for other propagated variables fb77c2c5 try_compile: Propogate the CMAKE_LINK_SEARCH_ variables http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7f0b83e0185f4e131110a61d898cec4a96bd9a7d commit 7f0b83e0185f4e131110a61d898cec4a96bd9a7d Author: Chuck Atkins AuthorDate: Fri Aug 14 11:48:54 2015 -0400 Commit: Chuck Atkins CommitDate: Fri Aug 14 11:48:54 2015 -0400 try_compile: Update documentation for other propagated variables diff --git a/Help/command/try_compile.rst b/Help/command/try_compile.rst index 23c26ad..1ed24df 100644 --- a/Help/command/try_compile.rst +++ b/Help/command/try_compile.rst @@ -102,6 +102,10 @@ default values: * :variable:`CMAKE_LINK_SEARCH_START_STATIC` * :variable:`CMAKE_LINK_SEARCH_END_STATIC` +* :variable:`CMAKE_POSITION_INDEPENDENT_CODE` + +If :policy:`CMP0056` is set to ``NEW``, then +:variable:`CMAKE_EXE_LINKER_FLAGS` is passed in as well. Set the :variable:`CMAKE_TRY_COMPILE_CONFIGURATION` variable to choose a build configuration. diff --git a/Help/variable/CMAKE_POSITION_INDEPENDENT_CODE.rst b/Help/variable/CMAKE_POSITION_INDEPENDENT_CODE.rst index 5e71665..43b1397 100644 --- a/Help/variable/CMAKE_POSITION_INDEPENDENT_CODE.rst +++ b/Help/variable/CMAKE_POSITION_INDEPENDENT_CODE.rst @@ -1,8 +1,9 @@ CMAKE_POSITION_INDEPENDENT_CODE ------------------------------- -Default value for POSITION_INDEPENDENT_CODE of targets. +Default value for :prop_tgt:`POSITION_INDEPENDENT_CODE` of targets. -This variable is used to initialize the POSITION_INDEPENDENT_CODE -property on all the targets. See that target property for additional -information. +This variable is used to initialize the +:prop_tgt:`POSITION_INDEPENDENT_CODE` property on all the targets. +See that target property for additional information. If set, it's +value is also used by the :command:`try_compile` command. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fb77c2c54bc341e76a83f646e6d75662c44179fc commit fb77c2c54bc341e76a83f646e6d75662c44179fc Author: Chuck Atkins AuthorDate: Fri Aug 14 11:48:01 2015 -0400 Commit: Chuck Atkins CommitDate: Fri Aug 14 11:48:01 2015 -0400 try_compile: Propogate the CMAKE_LINK_SEARCH_ variables diff --git a/Help/command/try_compile.rst b/Help/command/try_compile.rst index 9a70885..23c26ad 100644 --- a/Help/command/try_compile.rst +++ b/Help/command/try_compile.rst @@ -96,5 +96,12 @@ the try_compile call of interest, and then re-run cmake again with Other Behavior Settings ^^^^^^^^^^^^^^^^^^^^^^^ +If set, the following variables are passed in to the generated +try_compile CMakeLists.txt to initialize compile target properties with +default values: + +* :variable:`CMAKE_LINK_SEARCH_START_STATIC` +* :variable:`CMAKE_LINK_SEARCH_END_STATIC` + Set the :variable:`CMAKE_TRY_COMPILE_CONFIGURATION` variable to choose a build configuration. diff --git a/Help/variable/CMAKE_LINK_SEARCH_END_STATIC.rst b/Help/variable/CMAKE_LINK_SEARCH_END_STATIC.rst index 8a9951d..673f5d8 100644 --- a/Help/variable/CMAKE_LINK_SEARCH_END_STATIC.rst +++ b/Help/variable/CMAKE_LINK_SEARCH_END_STATIC.rst @@ -13,6 +13,7 @@ back to its starting type. This property switches the final linker search type to -Bstatic regardless of how it started. This variable is used to initialize the target property -LINK_SEARCH_END_STATIC for all targets. +:prop_tgt:`LINK_SEARCH_END_STATIC` for all targets. If set, it's +value is also used by the :command:`try_compile` command. -See also CMAKE_LINK_SEARCH_START_STATIC. +See also :variable:`CMAKE_LINK_SEARCH_START_STATIC`. diff --git a/Help/variable/CMAKE_LINK_SEARCH_START_STATIC.rst b/Help/variable/CMAKE_LINK_SEARCH_START_STATIC.rst index 715db4b..223702c 100644 --- a/Help/variable/CMAKE_LINK_SEARCH_START_STATIC.rst +++ b/Help/variable/CMAKE_LINK_SEARCH_START_STATIC.rst @@ -14,6 +14,7 @@ when linking an executable statically (e.g. with the GNU -static option). This variable is used to initialize the target property -LINK_SEARCH_START_STATIC for all targets. +:prop_tgt:`LINK_SEARCH_START_STATIC` for all targets. If set, it's +value is also used by the :command:`try_compile` command. -See also CMAKE_LINK_SEARCH_END_STATIC. +See also :variable:`CMAKE_LINK_SEARCH_END_STATIC`. diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index ffb349e..9411555 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -470,6 +470,16 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) { fprintf(fout, "set(CMAKE_POSITION_INDEPENDENT_CODE \"ON\")\n"); } + if (const char *lssDef = this->Makefile->GetDefinition( + "CMAKE_LINK_SEARCH_START_STATIC")) + { + fprintf(fout, "set(CMAKE_LINK_SEARCH_START_STATIC \"%s\")\n", lssDef); + } + if (const char *lssDef = this->Makefile->GetDefinition( + "CMAKE_LINK_SEARCH_END_STATIC")) + { + fprintf(fout, "set(CMAKE_LINK_SEARCH_END_STATIC \"%s\")\n", lssDef); + } /* Put the executable at a known location (for COPY_FILE). */ fprintf(fout, "set(CMAKE_RUNTIME_OUTPUT_DIRECTORY \"%s\")\n", ----------------------------------------------------------------------- Summary of changes: Help/command/try_compile.rst | 11 +++++++++++ Help/variable/CMAKE_LINK_SEARCH_END_STATIC.rst | 5 +++-- Help/variable/CMAKE_LINK_SEARCH_START_STATIC.rst | 5 +++-- Help/variable/CMAKE_POSITION_INDEPENDENT_CODE.rst | 9 +++++---- Source/cmCoreTryCompile.cxx | 10 ++++++++++ 5 files changed, 32 insertions(+), 8 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Sat Aug 15 00:01:13 2015 From: kwrobot at kitware.com (Kitware Robot) Date: Sat, 15 Aug 2015 00:01:13 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-842-g1628a8a Message-ID: <20150815040115.C5918B1301@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 1628a8af77b74a279d778b7f15959f7d96fec2ef (commit) from 17ecfd8210b4db74753c4565b10a2b75dfa4c480 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1628a8af77b74a279d778b7f15959f7d96fec2ef commit 1628a8af77b74a279d778b7f15959f7d96fec2ef Author: Kitware Robot AuthorDate: Sat Aug 15 00:01:09 2015 -0400 Commit: Kitware Robot CommitDate: Sat Aug 15 00:01:09 2015 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index c32856d..dc9119a 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150814) +set(CMake_VERSION_PATCH 20150815) #set(CMake_VERSION_RC 1) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From clinton at elemtech.com Sat Aug 15 00:59:50 2015 From: clinton at elemtech.com (Clinton Stimpson) Date: Sat, 15 Aug 2015 00:59:50 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2238-g2d83690 Message-ID: <20150815045950.86793B1373@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 2d83690fe2c785b5cda0fb6c0822b879071a649d (commit) via ba1065ab7b3c293245b3bbe733f8f062b9aa7ac9 (commit) from b5cc08fa9acd1678a671b7a4cefaa9c901bb15b7 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2d83690fe2c785b5cda0fb6c0822b879071a649d commit 2d83690fe2c785b5cda0fb6c0822b879071a649d Merge: b5cc08f ba1065a Author: Clinton Stimpson AuthorDate: Sat Aug 15 00:59:49 2015 -0400 Commit: CMake Topic Stage CommitDate: Sat Aug 15 00:59:49 2015 -0400 Merge topic 'build-subdir' into next ba1065ab cmake: Add support for "--build ." in subdirectory (#15696) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ba1065ab7b3c293245b3bbe733f8f062b9aa7ac9 commit ba1065ab7b3c293245b3bbe733f8f062b9aa7ac9 Author: Clinton Stimpson AuthorDate: Fri Aug 14 22:45:53 2015 -0600 Commit: Clinton Stimpson CommitDate: Fri Aug 14 22:46:53 2015 -0600 cmake: Add support for "--build ." in subdirectory (#15696) diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 2855329..62b3f83 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -2745,6 +2745,25 @@ int cmake::Build(const std::string& dir, } std::string cachePath = dir; cmSystemTools::ConvertToUnixSlashes(cachePath); + std::string cacheFile = cachePath; + cacheFile += "/CMakeCache.txt"; + if(!cmSystemTools::FileExists(cacheFile.c_str())) + { + // search in parent directories for cache + std::string cmakeFiles = cachePath; + cmakeFiles += "/CMakeFiles"; + if(cmSystemTools::FileExists(cmakeFiles.c_str())) + { + std::string cachePathFound = + cmSystemTools::FileExistsInParentDirectories( + "CMakeCache.txt", cachePath.c_str(), "/"); + if(!cachePathFound.empty()) + { + cachePath = cmSystemTools::GetFilenamePath(cachePathFound); + } + } + } + if(!this->LoadCache(cachePath)) { std::cerr << "Error: could not load cache\n"; ----------------------------------------------------------------------- Summary of changes: Source/cmake.cxx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) hooks/post-receive -- CMake From clinton at elemtech.com Sat Aug 15 01:16:52 2015 From: clinton at elemtech.com (Clinton Stimpson) Date: Sat, 15 Aug 2015 01:16:52 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.0-2240-g61a0fe4 Message-ID: <20150815051652.D636EB15EE@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 61a0fe4648d7e2c65c1fb62641f6c6e3dea2afb3 (commit) via e06ea8373f434fa581cc7c88366fa483b741aebd (commit) from 2d83690fe2c785b5cda0fb6c0822b879071a649d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=61a0fe4648d7e2c65c1fb62641f6c6e3dea2afb3 commit 61a0fe4648d7e2c65c1fb62641f6c6e3dea2afb3 Merge: 2d83690 e06ea83 Author: Clinton Stimpson AuthorDate: Sat Aug 15 01:16:52 2015 -0400 Commit: CMake Topic Stage CommitDate: Sat Aug 15 01:16:52 2015 -0400 Merge topic 'extended-length-paths' into next e06ea837 cmSystemTools: Use extended length paths for Windows apis. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e06ea8373f434fa581cc7c88366fa483b741aebd commit e06ea8373f434fa581cc7c88366fa483b741aebd Author: Clinton Stimpson AuthorDate: Fri Aug 14 23:14:06 2015 -0600 Commit: Clinton Stimpson CommitDate: Fri Aug 14 23:14:06 2015 -0600 cmSystemTools: Use extended length paths for Windows apis. diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 2543e68..a117238 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -950,8 +950,9 @@ bool cmSystemTools::RenameFile(const char* oldname, const char* newname) Try multiple times since we may be racing against another process creating/opening the destination file just before our MoveFileEx. */ WindowsFileRetry retry = cmSystemTools::GetWindowsFileRetry(); - while(!MoveFileExW(cmsys::Encoding::ToWide(oldname).c_str(), - cmsys::Encoding::ToWide(newname).c_str(), + while(!MoveFileExW( + SystemTools::ConvertToWindowsExtendedPath(oldname).c_str(), + SystemTools::ConvertToWindowsExtendedPath(newname).c_str(), MOVEFILE_REPLACE_EXISTING) && --retry.Count) { DWORD last_error = GetLastError(); @@ -962,12 +963,14 @@ bool cmSystemTools::RenameFile(const char* oldname, const char* newname) return false; } DWORD attrs = - GetFileAttributesW(cmsys::Encoding::ToWide(newname).c_str()); + GetFileAttributesW( + SystemTools::ConvertToWindowsExtendedPath(newname).c_str()); if((attrs != INVALID_FILE_ATTRIBUTES) && (attrs & FILE_ATTRIBUTE_READONLY)) { // Remove the read-only attribute from the destination file. - SetFileAttributesW(cmsys::Encoding::ToWide(newname).c_str(), + SetFileAttributesW( + SystemTools::ConvertToWindowsExtendedPath(newname).c_str(), attrs & ~FILE_ATTRIBUTE_READONLY); } else @@ -1956,11 +1959,11 @@ bool cmSystemTools::CopyFileTime(const char* fromFile, const char* toFile) { #if defined(_WIN32) && !defined(__CYGWIN__) cmSystemToolsWindowsHandle hFrom = - CreateFileW(cmsys::Encoding::ToWide(fromFile).c_str(), + CreateFileW(SystemTools::ConvertToWindowsExtendedPath(fromFile).c_str(), GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0); cmSystemToolsWindowsHandle hTo = - CreateFileW(cmsys::Encoding::ToWide(toFile).c_str(), + CreateFileW(SystemTools::ConvertToWindowsExtendedPath(toFile).c_str(), GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0); if(!hFrom || !hTo) { @@ -2012,7 +2015,7 @@ bool cmSystemTools::FileTimeGet(const char* fname, cmSystemToolsFileTime* t) { #if defined(_WIN32) && !defined(__CYGWIN__) cmSystemToolsWindowsHandle h = - CreateFileW(cmsys::Encoding::ToWide(fname).c_str(), + CreateFileW(SystemTools::ConvertToWindowsExtendedPath(fname).c_str(), GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0); if(!h) { @@ -2039,7 +2042,7 @@ bool cmSystemTools::FileTimeSet(const char* fname, cmSystemToolsFileTime* t) { #if defined(_WIN32) && !defined(__CYGWIN__) cmSystemToolsWindowsHandle h = - CreateFileW(cmsys::Encoding::ToWide(fname).c_str(), + CreateFileW(SystemTools::ConvertToWindowsExtendedPath(fname).c_str(), GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0); if(!h) { ----------------------------------------------------------------------- Summary of changes: Source/cmSystemTools.cxx | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Sun Aug 16 00:01:07 2015 From: kwrobot at kitware.com (Kitware Robot) Date: Sun, 16 Aug 2015 00:01:07 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-843-g5c8e1ca Message-ID: <20150816040107.BCDF2B161A@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 5c8e1ca283421e1be8005e3b31adb8867d5fc652 (commit) from 1628a8af77b74a279d778b7f15959f7d96fec2ef (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5c8e1ca283421e1be8005e3b31adb8867d5fc652 commit 5c8e1ca283421e1be8005e3b31adb8867d5fc652 Author: Kitware Robot AuthorDate: Sun Aug 16 00:01:05 2015 -0400 Commit: Kitware Robot CommitDate: Sun Aug 16 00:01:05 2015 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index dc9119a..d85bae4 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150815) +set(CMake_VERSION_PATCH 20150816) #set(CMake_VERSION_RC 1) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Mon Aug 17 00:01:08 2015 From: kwrobot at kitware.com (Kitware Robot) Date: Mon, 17 Aug 2015 00:01:08 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.0-844-g0f27bcc Message-ID: <20150817040108.0B587B152A@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 0f27bcc9ecc9e713adc0d64a8354e85efa97ae9c (commit) from 5c8e1ca283421e1be8005e3b31adb8867d5fc652 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0f27bcc9ecc9e713adc0d64a8354e85efa97ae9c commit 0f27bcc9ecc9e713adc0d64a8354e85efa97ae9c Author: Kitware Robot AuthorDate: Mon Aug 17 00:01:05 2015 -0400 Commit: Kitware Robot CommitDate: Mon Aug 17 00:01:05 2015 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index d85bae4..24b8f24 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150816) +set(CMake_VERSION_PATCH 20150817) #set(CMake_VERSION_RC 1) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 17 10:14:44 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 17 Aug 2015 10:14:44 -0400 (EDT) Subject: [Cmake-commits] CMake annotated tag, v3.3.1, created. v3.3.1 Message-ID: <20150817141444.83810B15D9@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The annotated tag, v3.3.1 has been created at ffb07a50b7e2361a3eee1b50c9f26a94a0a61601 (tag) tagging 4a6fe0290880bd56dd5141f06c9fa2b9e310162e (commit) replaces v3.3.0 tagged by Brad King on Thu Aug 13 14:47:37 2015 -0400 - Log ----------------------------------------------------------------- CMake 3.3.1 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAABAgAGBQJVzOZKAAoJEC0s7xA0khaE+44P/2vvRZ1Q6hizl2Rj+vBHObQS HreuayR9LkRSxmuR6Wm9U6nwIx0DpOta+7etNp5U0cEN+AJpn1V7/cXkAECLXthr uA64W3stDuKNgmv/0q4iN+NaAAAuUVtmt9IOjbHMdQFg6ju27pvcYSQiovq++Vtx Ym2KLuL+kREqoOPgQPogCEcsT7SxHRF5ii8G+WG5IqvpRbwg0QgJWgWEbCA0+qYD zfkYmJU04EqL4fY1R3ShTH2iMsylE9Kz0e+JSWWqZU9FfvPyFkUokIelnCobhHJ8 5sRu6/KLTfrgQEdGmBkY9Js9Sjevquojq9Q15KWwwFPG1JC5S2ewe1Z4/p4If1Jm hRrq2WOGQBiobib2omFxJccpIbarIiBImofEw/ikvQa27QYuWKucjY0IH9buYV9r m4HCMPSv+nzrwSwuxNAVi/919gIuXcGM2b+TK4iFVUjnmD/xRbF5iEkkG7dUg7AG fdwTx8ieFUhQsxEOqwG6Rzul1V8cnxIRrt8MWUyVgv5YTJ0GGxdEZH8GLkgXYQeG oHCHjTWHk+EDVrphvo78KNdciEfgswAoqmdMaRPUCDc8JZ5mF810v9YcUiYFEU8Y h92FQe37SqQR6OU/GHdJXtpK8FxhIc2pxxdsYGWEB9q3FDjDt2v2J7eB81icZrAN rPVZxgQgVo26V8qEdwLf =2ZON -----END PGP SIGNATURE----- Ben Boeckel (1): ctest: fix add_subdirectory() crash Brad King (7): Merge branch 'ctest-add_subdirectory-crash' into release Merge branch 'fix-xcode-quoting' into release add_subdirectory: Fix error message on missing CMakeLists.txt (#15680) Merge branch 'fix-missing-subdir-error' into release Fortran: Store detected compiler version persistently (#15684) Merge branch 'compiler-version-Fortran' into release CMake 3.3.1 Gregor Jasny (1): Xcode: Quote strings containing a tilde (#15672) ----------------------------------------------------------------------- hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 17 10:15:46 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 17 Aug 2015 10:15:46 -0400 (EDT) Subject: [Cmake-commits] CMake branch, maint, updated. v3.3.1 Message-ID: <20150817141546.27AB0B17BB@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, maint has been updated via 4a6fe0290880bd56dd5141f06c9fa2b9e310162e (commit) via bcd8fc58a03b6bd0cb0744d1f61dd0a1277640e1 (commit) via f0609182cc2bbce7f6af557d6352e0c434e7acc2 (commit) via c645590152be678a10dfae4bb9fde136a79a2c44 (commit) via c4d2f64f3c9dea3a5fcd8af5bb389db00ccd64df (commit) via bcba0d30992eb326f9c561b2fd86c784bf358302 (commit) via f7a9ed7e90cd2661b279d0bcd44d43620b8eeda1 (commit) via 59f4d9e85cfae752ccf99a8e9600aca301529f3c (commit) via 64821e8a40cf1add0cf3fd99b0860378754c64cf (commit) from 3a0db0223b8c10cfaa6984253d794ab97425adf9 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- ----------------------------------------------------------------------- Summary of changes: Modules/CMakeFortranCompiler.cmake.in | 1 + Source/CMakeVersion.cmake | 2 +- Source/CTest/cmCTestTestHandler.cxx | 2 +- Source/cmMakefile.cxx | 4 ++-- Source/cmXCodeObject.cxx | 2 +- Tests/RunCMake/CMakeLists.txt | 1 + Tests/RunCMake/{CMP0057 => add_subdirectory}/CMakeLists.txt | 0 .../DoesNotExist-result.txt} | 0 Tests/RunCMake/add_subdirectory/DoesNotExist-stderr.txt | 5 +++++ Tests/RunCMake/add_subdirectory/DoesNotExist.cmake | 1 + .../Missing-result.txt} | 0 Tests/RunCMake/add_subdirectory/Missing-stderr.txt | 8 ++++++++ Tests/RunCMake/add_subdirectory/Missing.cmake | 1 + .../RunCMake/add_subdirectory/Missing/Missing.txt | 0 Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake | 4 ++++ 15 files changed, 26 insertions(+), 5 deletions(-) copy Tests/RunCMake/{CMP0057 => add_subdirectory}/CMakeLists.txt (100%) copy Tests/RunCMake/{CMP0004/CMP0004-NEW-result.txt => add_subdirectory/DoesNotExist-result.txt} (100%) create mode 100644 Tests/RunCMake/add_subdirectory/DoesNotExist-stderr.txt create mode 100644 Tests/RunCMake/add_subdirectory/DoesNotExist.cmake copy Tests/RunCMake/{CMP0004/CMP0004-NEW-result.txt => add_subdirectory/Missing-result.txt} (100%) create mode 100644 Tests/RunCMake/add_subdirectory/Missing-stderr.txt create mode 100644 Tests/RunCMake/add_subdirectory/Missing.cmake copy Modules/IntelVSImplicitPath/hello.f => Tests/RunCMake/add_subdirectory/Missing/Missing.txt (100%) create mode 100644 Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 17 10:18:24 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 17 Aug 2015 10:18:24 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2235-geef231c Message-ID: <20150817141824.74066B18E4@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via eef231cab61ba3511d7c2b6d63b5de9003c8ee78 (commit) via 4071a7470723f98eac1e5f412f1d1bc27c882a36 (commit) via 7727d485d39cdc63539d5645b4e977109ca1ffed (commit) via 3f2f1a949c5e262ba7cb6d2d3eaaaf67394b6fdf (commit) from 61a0fe4648d7e2c65c1fb62641f6c6e3dea2afb3 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=eef231cab61ba3511d7c2b6d63b5de9003c8ee78 commit eef231cab61ba3511d7c2b6d63b5de9003c8ee78 Merge: 61a0fe4 4071a74 Author: Brad King AuthorDate: Mon Aug 17 10:18:23 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 17 10:18:23 2015 -0400 Merge topic 'update-curl' into next 4071a747 curl: Update README-CMake.txt for new snapshot 7727d485 curl: Update configuration of build within CMake 3f2f1a94 curl: Fix check for gethostbyname_r with 5 arguments http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4071a7470723f98eac1e5f412f1d1bc27c882a36 commit 4071a7470723f98eac1e5f412f1d1bc27c882a36 Author: Brad King AuthorDate: Wed Aug 12 15:05:28 2015 -0400 Commit: Brad King CommitDate: Mon Aug 17 10:17:51 2015 -0400 curl: Update README-CMake.txt for new snapshot diff --git a/Utilities/cmcurl/README-CMake.txt b/Utilities/cmcurl/README-CMake.txt index 3f053d8..1e75672 100644 --- a/Utilities/cmcurl/README-CMake.txt +++ b/Utilities/cmcurl/README-CMake.txt @@ -11,7 +11,7 @@ branch, but it is merged into our history. Update curl from upstream as follows. Create a local branch to explicitly reference the upstream snapshot branch head: - git branch curl-upstream 3fe5d9bf + git branch curl-upstream 70654261 Use a temporary directory to checkout the branch: @@ -24,7 +24,7 @@ Use a temporary directory to checkout the branch: Now place the (reduced) curl content in this directory. See instructions shown by - git log 3fe5d9bf + git log 70654261 for help extracting the content from the upstream repo. Then run the following commands to commit the new version. Substitute the @@ -34,8 +34,8 @@ appropriate date and version number: GIT_AUTHOR_NAME='Curl Upstream' \ GIT_AUTHOR_EMAIL='curl-library at cool.haxx.se' \ - GIT_AUTHOR_DATE='Wed Sep 10 08:07:58 2014 +0200' \ - git commit -m 'curl 7.38.0 (reduced)' && + GIT_AUTHOR_DATE='Tue Aug 11 20:13:01 2015 +0200' \ + git commit -m 'curl 7.44.0 (reduced)' && git commit --amend Edit the commit message to describe the procedure used to obtain the http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7727d485d39cdc63539d5645b4e977109ca1ffed commit 7727d485d39cdc63539d5645b4e977109ca1ffed Author: Brad King AuthorDate: Wed Aug 12 15:04:21 2015 -0400 Commit: Brad King CommitDate: Mon Aug 17 10:17:51 2015 -0400 curl: Update configuration of build within CMake Update our curl build option settings as needed for CMake to account for differences in curl options from 7.38 to 7.44. diff --git a/Utilities/cmcurl/CMakeLists.txt b/Utilities/cmcurl/CMakeLists.txt index 6b01be9..d12c73f 100644 --- a/Utilities/cmcurl/CMakeLists.txt +++ b/Utilities/cmcurl/CMakeLists.txt @@ -3,6 +3,7 @@ set(BUILD_CURL_EXE OFF CACHE INTERNAL "No curl exe") set(BUILD_CURL_TESTS OFF CACHE INTERNAL "No curl tests") set(BUILD_DASHBOARD_REPORTS OFF CACHE INTERNAL "No curl dashboard reports") set(BUILD_RELEASE_DEBUG_DIRS OFF CACHE INTERNAL "No curl release/debug dirs") +set(CMAKE_USE_GSSAPI OFF CACHE INTERNAL "Disable curl gssapi") set(CMAKE_USE_LIBSSH2 OFF CACHE INTERNAL "Disable curl libssh2") set(CMAKE_USE_OPENLDAP OFF CACHE INTERNAL "No curl OpenLDAP") set(CURL_DISABLE_COOKIES OFF CACHE INTERNAL "Do not disable curl cookie support") @@ -16,18 +17,24 @@ set(CURL_DISABLE_IMAP ON CACHE INTERNAL "Disable curl imap protocol?") set(CURL_DISABLE_LDAP ON CACHE INTERNAL "Disable curl ldap protocol?") set(CURL_DISABLE_LDAPS ON CACHE INTERNAL "Disable curl ldaps protocol?") set(CURL_DISABLE_POP3 ON CACHE INTERNAL "Disable curl pop3 protocol?") +set(CURL_DISABLE_PROXY OFF CACHE INTERNAL "Do not disable curl proxy") set(CURL_DISABLE_RTSP ON CACHE INTERNAL "Disable curl rtsp protocol?") set(CURL_DISABLE_SMTP ON CACHE INTERNAL "Disable curl smtp protocol?") set(CURL_DISABLE_TELNET ON CACHE INTERNAL "Disable curl telnet protocol?") set(CURL_DISABLE_TFTP ON CACHE INTERNAL "Disable curl tftp protocol?") -set(CURL_DISABLE_VERBOSE_STRING OFF CACHE INTERNAL "Do not disable curl verbosity") +set(CURL_DISABLE_VERBOSE_STRINGS OFF CACHE INTERNAL "Do not disable curl verbosity") set(CURL_HIDDEN_SYMBOLS OFF CACHE INTERNAL "No curl hidden symbols") -set(CURL_LDAP_WIN OFF CACHE INTERNAL "No curl Windows LDAP") set(CURL_STATICLIB ON CACHE INTERNAL "Static curl") -set(CURL_USE_ARES OFF CACHE INTERNAL "No curl c-ares support") set(DISABLED_THREADSAFE OFF CACHE INTERNAL "Curl can use thread-safe functions") -set(ENABLE_IPV6 OFF CACHE INTERNAL "Curl IPv6 support") +set(ENABLE_ARES OFF CACHE INTERNAL "No curl c-ares support") +set(ENABLE_CURLDEBUG OFF CACHE INTERNAL "No curl TrackMemory features") +set(ENABLE_DEBUG OFF CACHE INTERNAL "No curl debug features") +set(ENABLE_IPV6 OFF CACHE INTERNAL "No curl IPv6 support") +set(ENABLE_MANUAL OFF CACHE INTERNAL "No curl built-in manual") +set(ENABLE_THREADED_RESOLVER OFF CACHE INTERNAL "No curl POSIX threaded DNS lookup") +set(ENABLE_UNIX_SOCKETS OFF CACHE INTERNAL "No curl Unix domain sockets support") set(HTTP_ONLY OFF CACHE INTERNAL "Curl is not http-only") +set(USE_WIN32_LDAP OFF CACHE INTERNAL "No curl Windows LDAP") # Windows Vista and above have inet_pton, but this will link on # older versions and then the executable will fail to launch at http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3f2f1a949c5e262ba7cb6d2d3eaaaf67394b6fdf commit 3f2f1a949c5e262ba7cb6d2d3eaaaf67394b6fdf Author: Brad King AuthorDate: Fri Aug 14 09:14:55 2015 -0400 Commit: Brad King CommitDate: Mon Aug 17 10:17:50 2015 -0400 curl: Fix check for gethostbyname_r with 5 arguments Fix the check code to pass 5 arguments instead of 6. This typo was introduced in curl 7.39 but was not noticed because the result of this check is used only if ENABLE_IPV6 is OFF. diff --git a/Utilities/cmcurl/CMake/CurlTests.c b/Utilities/cmcurl/CMake/CurlTests.c index 04d5e7e..3c71232 100644 --- a/Utilities/cmcurl/CMake/CurlTests.c +++ b/Utilities/cmcurl/CMake/CurlTests.c @@ -139,7 +139,7 @@ int main(void) rc = gethostbyname_r(address, &h, &hdata); #elif defined(HAVE_GETHOSTBYNAME_R_5) || \ defined(HAVE_GETHOSTBYNAME_R_5_REENTRANT) - rc = gethostbyname_r(address, &h, buffer, 8192, 0, &h_errnop); + rc = gethostbyname_r(address, &h, buffer, 8192, &h_errnop); (void)hp; /* not used for test */ #elif defined(HAVE_GETHOSTBYNAME_R_6) || \ defined(HAVE_GETHOSTBYNAME_R_6_REENTRANT) ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 17 10:24:44 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 17 Aug 2015 10:24:44 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-837-gcb99eff Message-ID: <20150817142444.3F37AB1D06@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via cb99eff642e44bd2617d323261e996aadfafe4de (commit) via 9b449e9c5d79465a807c052c6707e83a1df9efbc (commit) from 0f27bcc9ecc9e713adc0d64a8354e85efa97ae9c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cb99eff642e44bd2617d323261e996aadfafe4de commit cb99eff642e44bd2617d323261e996aadfafe4de Merge: 0f27bcc 9b449e9 Author: Brad King AuthorDate: Mon Aug 17 10:24:42 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 17 10:24:42 2015 -0400 Merge topic 'use-generator-target' 9b449e9c cmComputeLinkInformation: Lookup a target only if we have one ----------------------------------------------------------------------- Summary of changes: Source/cmComputeLinkInformation.cxx | 2 +- Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake | 1 + .../RunCMake/target_link_libraries/SharedDepNotTarget.cmake | 10 ++++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 Tests/RunCMake/target_link_libraries/SharedDepNotTarget.cmake hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 17 10:24:46 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 17 Aug 2015 10:24:46 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-840-ga0dab7b Message-ID: <20150817142446.888BBB1D0C@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via a0dab7b774d5b7a619fd26926c2faf11f9d70309 (commit) via 75e3a8e811b290cb9921887f2b086377af90880f (commit) via 79a364376ca7b4b598b4827031a7515ffd497f24 (commit) from cb99eff642e44bd2617d323261e996aadfafe4de (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a0dab7b774d5b7a619fd26926c2faf11f9d70309 commit a0dab7b774d5b7a619fd26926c2faf11f9d70309 Merge: cb99eff 75e3a8e Author: Brad King AuthorDate: Mon Aug 17 10:24:45 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 17 10:24:45 2015 -0400 Merge topic 'FindOpenSSL-imported-targets' 75e3a8e8 FindOpenSSL: Provide imported targets OpenSSL::{SSL,Crypto} 79a36437 FindOpenSSL: Revise and format module documentation ----------------------------------------------------------------------- Summary of changes: Modules/FindOpenSSL.cmake | 101 +++++++++++++++++++++++++++++---- Tests/CMakeLists.txt | 4 ++ Tests/FindOpenSSL/CMakeLists.txt | 9 +++ Tests/FindOpenSSL/rand/CMakeLists.txt | 14 +++++ Tests/FindOpenSSL/rand/main.cc | 22 +++++++ 5 files changed, 138 insertions(+), 12 deletions(-) create mode 100644 Tests/FindOpenSSL/CMakeLists.txt create mode 100644 Tests/FindOpenSSL/rand/CMakeLists.txt create mode 100644 Tests/FindOpenSSL/rand/main.cc hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 17 10:24:48 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 17 Aug 2015 10:24:48 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-842-gda3b62c Message-ID: <20150817142448.9F59CB1D7E@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via da3b62cffd5a33a23d963beecc92305055c1bfee (commit) via 6699834d6298eabe53f2c15d051fbe16cc9014c3 (commit) from a0dab7b774d5b7a619fd26926c2faf11f9d70309 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=da3b62cffd5a33a23d963beecc92305055c1bfee commit da3b62cffd5a33a23d963beecc92305055c1bfee Merge: a0dab7b 6699834 Author: Brad King AuthorDate: Mon Aug 17 10:24:47 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 17 10:24:47 2015 -0400 Merge topic 'compiler-id-ancient-gcc-version' 6699834d GNU-DetermineCompiler: Add support for very old versions of GCC ----------------------------------------------------------------------- Summary of changes: Modules/Compiler/GNU-DetermineCompiler.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 17 10:24:51 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 17 Aug 2015 10:24:51 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-849-g89b483f Message-ID: <20150817142451.D76EFB1D84@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 89b483f2b6f136509168ea4764072bae119ef618 (commit) via 4071a7470723f98eac1e5f412f1d1bc27c882a36 (commit) via 7727d485d39cdc63539d5645b4e977109ca1ffed (commit) via 3f2f1a949c5e262ba7cb6d2d3eaaaf67394b6fdf (commit) via 91e8d35ab8ec2d62478a42eff10af88713497fad (commit) via 602cdc06a01b7c5c0eb444111382b09040f677ee (commit) via 706542615828488a5ad197d0ef3dd5e42eb739c4 (commit) from da3b62cffd5a33a23d963beecc92305055c1bfee (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=89b483f2b6f136509168ea4764072bae119ef618 commit 89b483f2b6f136509168ea4764072bae119ef618 Merge: da3b62c 4071a74 Author: Brad King AuthorDate: Mon Aug 17 10:24:49 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 17 10:24:49 2015 -0400 Merge topic 'update-curl' 4071a747 curl: Update README-CMake.txt for new snapshot 7727d485 curl: Update configuration of build within CMake 3f2f1a94 curl: Fix check for gethostbyname_r with 5 arguments 91e8d35a Merge branch 'curl-upstream' into update-curl 602cdc06 cmCurl: Tolerate lack of CURLOPT_CAPATH support 70654261 curl 7.44.0 (reduced) ----------------------------------------------------------------------- Summary of changes: Source/cmCurl.cxx | 2 +- .../cmcurl/CMake/CurlCheckCSourceCompiles.cmake | 71 -- Utilities/cmcurl/CMake/CurlCheckCSourceRuns.cmake | 83 -- Utilities/cmcurl/CMake/CurlTests.c | 316 ++---- Utilities/cmcurl/CMake/FindGSS.cmake | 289 +++++ Utilities/cmcurl/CMake/Macros.cmake | 8 +- Utilities/cmcurl/CMake/OtherTests.cmake | 200 ++-- .../cmcurl/CMake/Platforms/WindowsCache.cmake | 2 +- Utilities/cmcurl/CMakeLists.txt | 508 ++++++--- Utilities/cmcurl/COPYING | 2 +- Utilities/cmcurl/README-CMake.txt | 8 +- Utilities/cmcurl/include/curl/curl.h | 94 +- Utilities/cmcurl/include/curl/curlver.h | 18 +- Utilities/cmcurl/include/curl/mprintf.h | 9 +- Utilities/cmcurl/include/curl/multi.h | 38 +- Utilities/cmcurl/include/curl/typecheck-gcc.h | 2 + Utilities/cmcurl/lib/CMakeLists.txt | 28 +- Utilities/cmcurl/lib/Makefile.inc | 86 +- Utilities/cmcurl/lib/amigaos.c | 4 +- Utilities/cmcurl/lib/asyn-ares.c | 37 +- Utilities/cmcurl/lib/asyn-thread.c | 45 +- Utilities/cmcurl/lib/base64.c | 23 +- Utilities/cmcurl/lib/bundles.c | 110 -- Utilities/cmcurl/lib/bundles.h | 45 - Utilities/cmcurl/lib/conncache.c | 179 ++- Utilities/cmcurl/lib/conncache.h | 21 +- Utilities/cmcurl/lib/connect.c | 227 ++-- Utilities/cmcurl/lib/connect.h | 2 +- Utilities/cmcurl/lib/cookie.c | 208 ++-- Utilities/cmcurl/lib/curl_addrinfo.c | 59 +- Utilities/cmcurl/lib/curl_addrinfo.h | 4 + Utilities/cmcurl/lib/curl_config.h.cmake | 12 +- Utilities/cmcurl/lib/curl_des.c | 63 ++ Utilities/cmcurl/lib/{amigaos.h => curl_des.h} | 23 +- Utilities/cmcurl/lib/curl_endian.c | 236 ++++ Utilities/cmcurl/lib/curl_endian.h | 70 ++ Utilities/cmcurl/lib/curl_fnmatch.c | 7 +- Utilities/cmcurl/lib/curl_gssapi.c | 53 +- Utilities/cmcurl/lib/curl_gssapi.h | 19 +- Utilities/cmcurl/lib/curl_md4.h | 12 +- Utilities/cmcurl/lib/curl_memory.h | 3 + Utilities/cmcurl/lib/curl_memrchr.c | 8 +- Utilities/cmcurl/lib/curl_multibyte.c | 18 +- Utilities/cmcurl/lib/curl_multibyte.h | 12 +- Utilities/cmcurl/lib/curl_ntlm.c | 79 +- Utilities/cmcurl/lib/curl_ntlm.h | 10 +- Utilities/cmcurl/lib/curl_ntlm_core.c | 292 +++-- Utilities/cmcurl/lib/curl_ntlm_core.h | 59 +- Utilities/cmcurl/lib/curl_ntlm_msgs.c | 461 +++----- Utilities/cmcurl/lib/curl_ntlm_msgs.h | 34 - Utilities/cmcurl/lib/curl_ntlm_wb.c | 46 +- Utilities/cmcurl/lib/curl_ntlm_wb.h | 7 +- .../cmcurl/lib/{curl_memrchr.c => curl_printf.h} | 68 +- Utilities/cmcurl/lib/curl_rtmp.c | 27 +- Utilities/cmcurl/lib/curl_sasl.c | 1158 +++++++++++++++++-- Utilities/cmcurl/lib/curl_sasl.h | 164 ++- Utilities/cmcurl/lib/curl_sasl_gssapi.c | 392 +++++++ Utilities/cmcurl/lib/curl_sasl_sspi.c | 861 +++++++++++--- Utilities/cmcurl/lib/curl_sec.h | 4 +- Utilities/cmcurl/lib/curl_setup.h | 53 +- Utilities/cmcurl/lib/curl_sspi.c | 30 +- Utilities/cmcurl/lib/curl_sspi.h | 191 ++-- Utilities/cmcurl/lib/curl_threads.c | 15 +- Utilities/cmcurl/lib/curl_threads.h | 9 +- Utilities/cmcurl/lib/curlx.h | 5 +- Utilities/cmcurl/lib/dict.c | 16 +- Utilities/cmcurl/lib/easy.c | 180 ++- Utilities/cmcurl/lib/escape.c | 28 +- Utilities/cmcurl/lib/file.c | 63 +- Utilities/cmcurl/lib/fileinfo.c | 6 +- Utilities/cmcurl/lib/formdata.c | 127 +-- Utilities/cmcurl/lib/ftp.c | 305 ++--- Utilities/cmcurl/lib/ftp.h | 11 +- Utilities/cmcurl/lib/ftplistparser.c | 57 +- Utilities/cmcurl/lib/getinfo.c | 55 +- Utilities/cmcurl/lib/gopher.c | 16 +- Utilities/cmcurl/lib/hash.c | 72 +- Utilities/cmcurl/lib/hash.h | 10 +- Utilities/cmcurl/lib/hmac.c | 6 +- Utilities/cmcurl/lib/hostasyn.c | 24 +- Utilities/cmcurl/lib/hostcheck.c | 7 +- Utilities/cmcurl/lib/hostip.c | 287 ++--- Utilities/cmcurl/lib/hostip.h | 22 +- Utilities/cmcurl/lib/hostip4.c | 15 +- Utilities/cmcurl/lib/hostip6.c | 17 +- Utilities/cmcurl/lib/hostsyn.c | 6 +- Utilities/cmcurl/lib/http.c | 378 ++++--- Utilities/cmcurl/lib/http.h | 64 +- Utilities/cmcurl/lib/http2.c | 1184 ++++++++++++++------ Utilities/cmcurl/lib/http2.h | 17 +- Utilities/cmcurl/lib/http_chunks.c | 12 +- Utilities/cmcurl/lib/http_digest.c | 549 ++------- Utilities/cmcurl/lib/http_digest.h | 21 +- Utilities/cmcurl/lib/http_negotiate.c | 163 ++- Utilities/cmcurl/lib/http_negotiate.h | 6 +- Utilities/cmcurl/lib/http_negotiate_sspi.c | 118 +- Utilities/cmcurl/lib/http_proxy.c | 64 +- Utilities/cmcurl/lib/http_proxy.h | 7 +- Utilities/cmcurl/lib/idn_win32.c | 29 +- Utilities/cmcurl/lib/if2ip.c | 87 +- Utilities/cmcurl/lib/if2ip.h | 13 +- Utilities/cmcurl/lib/imap.c | 989 ++-------------- Utilities/cmcurl/lib/imap.h | 23 +- Utilities/cmcurl/lib/inet_ntop.c | 3 +- Utilities/cmcurl/lib/inet_ntop.h | 4 +- Utilities/cmcurl/lib/krb5.c | 36 +- Utilities/cmcurl/lib/ldap.c | 622 +++++++--- Utilities/cmcurl/lib/md4.c | 502 +++++---- Utilities/cmcurl/lib/md5.c | 579 +++++----- Utilities/cmcurl/lib/memdebug.c | 39 +- Utilities/cmcurl/lib/memdebug.h | 20 +- Utilities/cmcurl/lib/multi.c | 819 +++++++------- Utilities/cmcurl/lib/multihandle.h | 52 +- Utilities/cmcurl/lib/multiif.h | 22 +- Utilities/cmcurl/lib/netrc.c | 20 +- Utilities/cmcurl/lib/non-ascii.c | 55 +- Utilities/cmcurl/lib/nwlib.c | 8 +- Utilities/cmcurl/lib/openldap.c | 142 ++- Utilities/cmcurl/lib/parsedate.c | 2 +- Utilities/cmcurl/lib/pingpong.c | 56 +- Utilities/cmcurl/lib/pipeline.c | 119 +- Utilities/cmcurl/lib/pipeline.h | 12 + Utilities/cmcurl/lib/pop3.c | 972 ++-------------- Utilities/cmcurl/lib/pop3.h | 23 +- Utilities/cmcurl/lib/progress.c | 6 +- Utilities/cmcurl/lib/rtsp.c | 24 +- Utilities/cmcurl/lib/security.c | 187 ++-- Utilities/cmcurl/lib/select.c | 12 +- Utilities/cmcurl/lib/sendf.c | 218 ++-- Utilities/cmcurl/lib/sendf.h | 6 +- Utilities/cmcurl/lib/setup-os400.h | 18 +- Utilities/cmcurl/lib/setup-vms.h | 47 +- Utilities/cmcurl/lib/share.c | 27 +- Utilities/cmcurl/lib/share.h | 4 +- Utilities/cmcurl/lib/slist.c | 4 +- Utilities/cmcurl/lib/smb.c | 976 ++++++++++++++++ Utilities/cmcurl/lib/smb.h | 271 +++++ Utilities/cmcurl/lib/smtp.c | 1019 +++-------------- Utilities/cmcurl/lib/smtp.h | 23 +- Utilities/cmcurl/lib/socks.c | 42 +- Utilities/cmcurl/lib/socks_gssapi.c | 80 +- Utilities/cmcurl/lib/socks_sspi.c | 59 +- Utilities/cmcurl/lib/splay.c | 10 +- Utilities/cmcurl/lib/ssh.c | 160 ++- Utilities/cmcurl/lib/ssh.h | 36 +- Utilities/cmcurl/lib/strdup.c | 33 +- Utilities/cmcurl/lib/strdup.h | 3 +- Utilities/cmcurl/lib/strerror.c | 38 +- Utilities/cmcurl/lib/strtoofft.h | 11 +- Utilities/cmcurl/lib/telnet.c | 165 ++- Utilities/cmcurl/lib/tftp.c | 163 +-- Utilities/cmcurl/lib/timeval.c | 12 +- Utilities/cmcurl/lib/transfer.c | 145 +-- Utilities/cmcurl/lib/transfer.h | 5 +- Utilities/cmcurl/lib/url.c | 744 +++++++----- Utilities/cmcurl/lib/url.h | 6 +- Utilities/cmcurl/lib/urldata.h | 162 ++- Utilities/cmcurl/lib/version.c | 23 +- Utilities/cmcurl/lib/vtls/axtls.c | 34 +- Utilities/cmcurl/lib/vtls/axtls.h | 23 +- Utilities/cmcurl/lib/vtls/cyassl.c | 273 +++-- Utilities/cmcurl/lib/vtls/cyassl.h | 30 +- .../lib/vtls/{curl_darwinssl.c => darwinssl.c} | 137 ++- .../lib/vtls/{curl_darwinssl.h => darwinssl.h} | 21 +- Utilities/cmcurl/lib/vtls/gskit.c | 326 +++--- Utilities/cmcurl/lib/vtls/gskit.h | 26 +- Utilities/cmcurl/lib/vtls/gtls.c | 398 +++++-- Utilities/cmcurl/lib/vtls/gtls.h | 37 +- Utilities/cmcurl/lib/vtls/nss.c | 599 ++++++---- Utilities/cmcurl/lib/vtls/nssg.h | 41 +- Utilities/cmcurl/lib/vtls/openssl.c | 1091 +++++++++++------- Utilities/cmcurl/lib/vtls/openssl.h | 35 +- Utilities/cmcurl/lib/vtls/polarssl.c | 197 ++-- Utilities/cmcurl/lib/vtls/polarssl.h | 26 +- Utilities/cmcurl/lib/vtls/polarssl_threadlock.c | 5 +- Utilities/cmcurl/lib/vtls/qssl.c | 527 --------- Utilities/cmcurl/lib/vtls/qssl.h | 62 - .../lib/vtls/{curl_schannel.c => schannel.c} | 755 ++++++++----- .../lib/vtls/{curl_schannel.h => schannel.h} | 39 +- Utilities/cmcurl/lib/vtls/vtls.c | 355 +++++- Utilities/cmcurl/lib/vtls/vtls.h | 55 +- Utilities/cmcurl/lib/wildcard.c | 20 +- Utilities/cmcurl/lib/x509asn1.c | 55 +- Utilities/cmcurl/lib/x509asn1.h | 11 +- 184 files changed, 14806 insertions(+), 11501 deletions(-) delete mode 100644 Utilities/cmcurl/CMake/CurlCheckCSourceCompiles.cmake delete mode 100644 Utilities/cmcurl/CMake/CurlCheckCSourceRuns.cmake create mode 100644 Utilities/cmcurl/CMake/FindGSS.cmake delete mode 100644 Utilities/cmcurl/lib/bundles.c delete mode 100644 Utilities/cmcurl/lib/bundles.h create mode 100644 Utilities/cmcurl/lib/curl_des.c copy Utilities/cmcurl/lib/{amigaos.h => curl_des.h} (71%) create mode 100644 Utilities/cmcurl/lib/curl_endian.c create mode 100644 Utilities/cmcurl/lib/curl_endian.h copy Utilities/cmcurl/lib/{curl_memrchr.c => curl_printf.h} (53%) create mode 100644 Utilities/cmcurl/lib/curl_sasl_gssapi.c create mode 100644 Utilities/cmcurl/lib/smb.c create mode 100644 Utilities/cmcurl/lib/smb.h rename Utilities/cmcurl/lib/vtls/{curl_darwinssl.c => darwinssl.c} (96%) rename Utilities/cmcurl/lib/vtls/{curl_darwinssl.h => darwinssl.h} (83%) delete mode 100644 Utilities/cmcurl/lib/vtls/qssl.c delete mode 100644 Utilities/cmcurl/lib/vtls/qssl.h rename Utilities/cmcurl/lib/vtls/{curl_schannel.c => schannel.c} (64%) rename Utilities/cmcurl/lib/vtls/{curl_schannel.h => schannel.h} (80%) hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 17 10:24:54 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 17 Aug 2015 10:24:54 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-851-g8ca1c2b Message-ID: <20150817142454.9F11CB1D84@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 8ca1c2b2b351ee7c600a041cc31d36cfe9d16d30 (commit) via 724fa682705a17bef0c74b9dcf09bc9cf1761dde (commit) from 89b483f2b6f136509168ea4764072bae119ef618 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8ca1c2b2b351ee7c600a041cc31d36cfe9d16d30 commit 8ca1c2b2b351ee7c600a041cc31d36cfe9d16d30 Merge: 89b483f 724fa68 Author: Brad King AuthorDate: Mon Aug 17 10:24:53 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 17 10:24:53 2015 -0400 Merge topic 'FindTIFF-updates' 724fa682 FindTIFF: Find debug and release libraries separately ----------------------------------------------------------------------- Summary of changes: Help/release/dev/FindTIFF-updates.rst | 5 +++++ Modules/FindTIFF.cmake | 14 +++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 Help/release/dev/FindTIFF-updates.rst hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 17 10:24:57 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 17 Aug 2015 10:24:57 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-854-g9cba05c Message-ID: <20150817142457.15A77B1D87@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 9cba05c6845ececd68f3f57c50c1953658ba48be (commit) via db292564293ce6899728fa172614d4eec59b429f (commit) via 021bf871a6ffa51b6bd0f5834e8a5049c54f8b30 (commit) from 8ca1c2b2b351ee7c600a041cc31d36cfe9d16d30 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9cba05c6845ececd68f3f57c50c1953658ba48be commit 9cba05c6845ececd68f3f57c50c1953658ba48be Merge: 8ca1c2b db29256 Author: Brad King AuthorDate: Mon Aug 17 10:24:55 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 17 10:24:55 2015 -0400 Merge topic 'FindXercesC-updates' db292564 FindXercesC: Add support for 3D_1 variant of the library 021bf871 FindXercesC: Find debug and release libraries separately ----------------------------------------------------------------------- Summary of changes: Help/release/dev/FindXercesC-updates.rst | 5 +++++ Modules/FindXercesC.cmake | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 Help/release/dev/FindXercesC-updates.rst hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 17 10:24:59 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 17 Aug 2015 10:24:59 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-856-gf4885a9 Message-ID: <20150817142459.4B120B1D86@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via f4885a94ed20daca102bdca8acebd10084a034b2 (commit) via ff5bb2efbe9f7bb4a1824b0ad727713fcd6bc54a (commit) from 9cba05c6845ececd68f3f57c50c1953658ba48be (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f4885a94ed20daca102bdca8acebd10084a034b2 commit f4885a94ed20daca102bdca8acebd10084a034b2 Merge: 9cba05c ff5bb2e Author: Brad King AuthorDate: Mon Aug 17 10:24:57 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 17 10:24:57 2015 -0400 Merge topic 'FindBoost-1.59' ff5bb2ef FindBoost: Add support for Boost 1.59 ----------------------------------------------------------------------- Summary of changes: Modules/FindBoost.cmake | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 17 10:25:01 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 17 Aug 2015 10:25:01 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-859-g581379c Message-ID: <20150817142501.762D7B1D86@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 581379cadf87c78af48c57a61b0abd89f4c99d92 (commit) via 64e6bc5ca3bf15239829f18a71511df2f04181b3 (commit) via 758664b7ad018aa19072fe5c359a702c472faae2 (commit) from f4885a94ed20daca102bdca8acebd10084a034b2 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=581379cadf87c78af48c57a61b0abd89f4c99d92 commit 581379cadf87c78af48c57a61b0abd89f4c99d92 Merge: f4885a9 64e6bc5 Author: Brad King AuthorDate: Mon Aug 17 10:25:00 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 17 10:25:00 2015 -0400 Merge topic 'emacs-mode-font-lock' 64e6bc5c cmake-mode.el: Refine variable font-lock 758664b7 cmake-mode.el: Fix function name font-lock ----------------------------------------------------------------------- Summary of changes: Auxiliary/cmake-mode.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 17 10:25:03 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 17 Aug 2015 10:25:03 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-861-gbc9103e Message-ID: <20150817142503.C7D06B1D8C@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via bc9103ed5b326b480140b43934bb762f9c9ec5f5 (commit) via e06ea8373f434fa581cc7c88366fa483b741aebd (commit) from 581379cadf87c78af48c57a61b0abd89f4c99d92 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bc9103ed5b326b480140b43934bb762f9c9ec5f5 commit bc9103ed5b326b480140b43934bb762f9c9ec5f5 Merge: 581379c e06ea83 Author: Brad King AuthorDate: Mon Aug 17 10:25:02 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 17 10:25:02 2015 -0400 Merge topic 'extended-length-paths' e06ea837 cmSystemTools: Use extended length paths for Windows apis. ----------------------------------------------------------------------- Summary of changes: Source/cmSystemTools.cxx | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 17 10:25:05 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 17 Aug 2015 10:25:05 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-864-ga38ea31 Message-ID: <20150817142505.F31D7B1D8E@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via a38ea312c02eec6e4ee61015f70920999bf79ff9 (commit) via 7f0b83e0185f4e131110a61d898cec4a96bd9a7d (commit) via fb77c2c54bc341e76a83f646e6d75662c44179fc (commit) from bc9103ed5b326b480140b43934bb762f9c9ec5f5 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a38ea312c02eec6e4ee61015f70920999bf79ff9 commit a38ea312c02eec6e4ee61015f70920999bf79ff9 Merge: bc9103e 7f0b83e Author: Brad King AuthorDate: Mon Aug 17 10:25:04 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 17 10:25:04 2015 -0400 Merge topic 'propagate-link-search-to-try_compile' 7f0b83e0 try_compile: Update documentation for other propagated variables fb77c2c5 try_compile: Propogate the CMAKE_LINK_SEARCH_ variables ----------------------------------------------------------------------- Summary of changes: Help/command/try_compile.rst | 11 +++++++++++ Help/variable/CMAKE_LINK_SEARCH_END_STATIC.rst | 5 +++-- Help/variable/CMAKE_LINK_SEARCH_START_STATIC.rst | 5 +++-- Help/variable/CMAKE_POSITION_INDEPENDENT_CODE.rst | 9 +++++---- Source/cmCoreTryCompile.cxx | 10 ++++++++++ 5 files changed, 32 insertions(+), 8 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 17 10:26:47 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 17 Aug 2015 10:26:47 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2249-g4bec7bd Message-ID: <20150817142647.3A676B1DDD@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 4bec7bd580c9d127ce08172cd5ae0b36a585725a (commit) via a38ea312c02eec6e4ee61015f70920999bf79ff9 (commit) via bc9103ed5b326b480140b43934bb762f9c9ec5f5 (commit) via 581379cadf87c78af48c57a61b0abd89f4c99d92 (commit) via f4885a94ed20daca102bdca8acebd10084a034b2 (commit) via 9cba05c6845ececd68f3f57c50c1953658ba48be (commit) via 8ca1c2b2b351ee7c600a041cc31d36cfe9d16d30 (commit) via 89b483f2b6f136509168ea4764072bae119ef618 (commit) via da3b62cffd5a33a23d963beecc92305055c1bfee (commit) via a0dab7b774d5b7a619fd26926c2faf11f9d70309 (commit) via cb99eff642e44bd2617d323261e996aadfafe4de (commit) via 0f27bcc9ecc9e713adc0d64a8354e85efa97ae9c (commit) via 5c8e1ca283421e1be8005e3b31adb8867d5fc652 (commit) via 1628a8af77b74a279d778b7f15959f7d96fec2ef (commit) from eef231cab61ba3511d7c2b6d63b5de9003c8ee78 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4bec7bd580c9d127ce08172cd5ae0b36a585725a commit 4bec7bd580c9d127ce08172cd5ae0b36a585725a Merge: eef231c a38ea31 Author: Brad King AuthorDate: Mon Aug 17 10:26:37 2015 -0400 Commit: Brad King CommitDate: Mon Aug 17 10:26:37 2015 -0400 Merge branch 'master' into next ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 17 10:33:37 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 17 Aug 2015 10:33:37 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2251-g9fe5cfd Message-ID: <20150817143337.9145CB1F2C@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 9fe5cfd082e84c09aa63aea6aff4bad407e22033 (commit) via 462fbd1ecac6968f6c0695737c8e432c9660121c (commit) from 4bec7bd580c9d127ce08172cd5ae0b36a585725a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9fe5cfd082e84c09aa63aea6aff4bad407e22033 commit 9fe5cfd082e84c09aa63aea6aff4bad407e22033 Merge: 4bec7bd 462fbd1 Author: Brad King AuthorDate: Mon Aug 17 10:33:36 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 17 10:33:36 2015 -0400 Merge topic 'add-ARTOS-platform-module' into next 462fbd1e Add support for ARTOS platform using GNU C with ac compiler driver http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=462fbd1ecac6968f6c0695737c8e432c9660121c commit 462fbd1ecac6968f6c0695737c8e432c9660121c Author: Kars de Jong AuthorDate: Thu Aug 13 13:37:53 2015 +0200 Commit: Brad King CommitDate: Mon Aug 17 10:32:50 2015 -0400 Add support for ARTOS platform using GNU C with ac compiler driver Add platform and compiler descriptions for ARTOS RTOS (locamation.com). Signed-off-by: Kars de Jong diff --git a/Modules/Platform/ARTOS-GNU-C.cmake b/Modules/Platform/ARTOS-GNU-C.cmake new file mode 100644 index 0000000..967d0e7 --- /dev/null +++ b/Modules/Platform/ARTOS-GNU-C.cmake @@ -0,0 +1,9 @@ +# Define ARTOS to select proper behaviour and tell preprocessor to accept C++ style comments. +set(CMAKE_C_FLAGS_INIT "-DARTOS -Xp -+") +# ac doesn't support -g properly and doesn't support the normal gcc optimization options. Just use the defaults set by ac. +set(CMAKE_C_FLAGS_DEBUG_INIT "") +set(CMAKE_C_FLAGS_MINSIZEREL_INIT "-DNDEBUG") +set(CMAKE_C_FLAGS_RELEASE_INIT "-DNDEBUG") +set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-DNDEBUG") +# Most projects expect the stdio functions to be available. +set(CMAKE_C_STANDARD_LIBRARIES_INIT "stdio.a") diff --git a/Modules/Platform/ARTOS.cmake b/Modules/Platform/ARTOS.cmake new file mode 100644 index 0000000..f9365d6 --- /dev/null +++ b/Modules/Platform/ARTOS.cmake @@ -0,0 +1,17 @@ +# Support for ARTOS RTOS (locamation.com) +set(CMAKE_LINK_LIBRARY_SUFFIX "") +set(CMAKE_STATIC_LIBRARY_PREFIX "") +set(CMAKE_STATIC_LIBRARY_SUFFIX ".a") +set(CMAKE_SHARED_LIBRARY_PREFIX "") +set(CMAKE_SHARED_LIBRARY_SUFFIX ".a") +set(CMAKE_EXECUTABLE_SUFFIX ".x") +set(CMAKE_DL_LIBS "") + +set(CMAKE_FIND_LIBRARY_PREFIXES "") +set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") + +# ARTOS does not support shared libs +set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE) + +set(CMAKE_C_LINK_SHARED_LIBRARY ) +set(CMAKE_C_LINK_MODULE_LIBRARY ) ----------------------------------------------------------------------- Summary of changes: Modules/Platform/ARTOS-GNU-C.cmake | 9 +++++++++ Modules/Platform/ARTOS.cmake | 17 +++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 Modules/Platform/ARTOS-GNU-C.cmake create mode 100644 Modules/Platform/ARTOS.cmake hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 17 10:55:40 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 17 Aug 2015 10:55:40 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2253-gc9b7376 Message-ID: <20150817145540.09698B1548@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via c9b737643982b4db614a73518fd5c3773cab6be3 (commit) via e66a7d6973fa58bb3bf37b540f67e2c33bb9fae2 (commit) from 9fe5cfd082e84c09aa63aea6aff4bad407e22033 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c9b737643982b4db614a73518fd5c3773cab6be3 commit c9b737643982b4db614a73518fd5c3773cab6be3 Merge: 9fe5cfd e66a7d6 Author: Brad King AuthorDate: Mon Aug 17 10:55:39 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 17 10:55:39 2015 -0400 Merge topic 'OUTPUT_NAME-genex-no-recursion' into next e66a7d69 cmGeneratorTarget: Avoid recursion in GetOutputName method http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e66a7d6973fa58bb3bf37b540f67e2c33bb9fae2 commit e66a7d6973fa58bb3bf37b540f67e2c33bb9fae2 Author: Robert Goulet AuthorDate: Fri Aug 14 20:35:58 2015 +0000 Commit: Brad King CommitDate: Mon Aug 17 10:43:08 2015 -0400 cmGeneratorTarget: Avoid recursion in GetOutputName method Since support for generator expressions was added to OUTPUT_NAME it is possible for project code to cause recursion in this method by using a $ genex. Detect and reject such cases. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 299c112..7d4bb67 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -270,48 +270,70 @@ const char *cmGeneratorTarget::GetProperty(const std::string& prop) const std::string cmGeneratorTarget::GetOutputName(const std::string& config, bool implib) const { - std::vector props; - std::string type = this->Target->GetOutputTargetType(implib); - std::string configUpper = cmSystemTools::UpperCase(config); - if(!type.empty() && !configUpper.empty()) - { - // _OUTPUT_NAME_ - props.push_back(type + "_OUTPUT_NAME_" + configUpper); - } - if(!type.empty()) + // Lookup/compute/cache the output name for this configuration. + cmGeneratorTarget::OutputNameMapType::iterator i = + this->OutputNameMap.find(config); + if(i == this->OutputNameMap.end()) { - // _OUTPUT_NAME - props.push_back(type + "_OUTPUT_NAME"); - } - if(!configUpper.empty()) - { - // OUTPUT_NAME_ - props.push_back("OUTPUT_NAME_" + configUpper); - // _OUTPUT_NAME - props.push_back(configUpper + "_OUTPUT_NAME"); - } - // OUTPUT_NAME - props.push_back("OUTPUT_NAME"); + // Add empty name in map to detect potential recursion. + OutputNameMapType::value_type entry(config, ""); + i = this->OutputNameMap.insert(entry).first; - std::string outName; - for(std::vector::const_iterator i = props.begin(); - i != props.end(); ++i) - { - if (const char* outNameProp = this->Target->GetProperty(*i)) + // Compute output name. + std::vector props; + std::string type = this->Target->GetOutputTargetType(implib); + std::string configUpper = cmSystemTools::UpperCase(config); + if(!type.empty() && !configUpper.empty()) { - outName = outNameProp; - break; + // _OUTPUT_NAME_ + props.push_back(type + "_OUTPUT_NAME_" + configUpper); + } + if(!type.empty()) + { + // _OUTPUT_NAME + props.push_back(type + "_OUTPUT_NAME"); + } + if(!configUpper.empty()) + { + // OUTPUT_NAME_ + props.push_back("OUTPUT_NAME_" + configUpper); + // _OUTPUT_NAME + props.push_back(configUpper + "_OUTPUT_NAME"); + } + // OUTPUT_NAME + props.push_back("OUTPUT_NAME"); + + std::string outName; + for(std::vector::const_iterator it = props.begin(); + it != props.end(); ++it) + { + if (const char* outNameProp = this->Target->GetProperty(*it)) + { + outName = outNameProp; + break; + } } - } - if (outName.empty()) + if(outName.empty()) + { + outName = this->GetName(); + } + + // Now evaluate genex and update the previously-prepared map entry. + cmGeneratorExpression ge; + cmsys::auto_ptr cge = ge.Parse(outName); + i->second = cge->Evaluate(this->Makefile, config); + } + else if(i->second.empty()) { - outName = this->GetName(); + // An empty map entry indicates we have been called recursively + // from the above block. + this->Makefile->GetCMakeInstance()->IssueMessage( + cmake::FATAL_ERROR, + "Target '" + this->GetName() + "' OUTPUT_NAME depends on itself.", + this->Target->GetBacktrace()); } - - cmGeneratorExpression ge; - cmsys::auto_ptr cge = ge.Parse(outName); - return cge->Evaluate(this->Makefile, config); + return i->second; } //---------------------------------------------------------------------------- diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 68e7a8a..a603975 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -375,6 +375,9 @@ private: }; mutable std::map LinkImplClosureMap; + typedef std::map OutputNameMapType; + mutable OutputNameMapType OutputNameMap; + public: std::vector const& GetLinkImplementationClosure(const std::string& config) const; diff --git a/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion-result.txt b/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion-stderr.txt b/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion-stderr.txt new file mode 100644 index 0000000..bf592e7 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at OUTPUT_NAME-recursion.cmake:[0-9]+ \(add_executable\): + Target 'empty1' OUTPUT_NAME depends on itself. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion.cmake b/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion.cmake new file mode 100644 index 0000000..5cb8050 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion.cmake @@ -0,0 +1,3 @@ +enable_language(C) +add_executable(empty1 empty.c) +set_property(TARGET empty1 PROPERTY OUTPUT_NAME $) diff --git a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake index 21fc851..0679024 100644 --- a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake @@ -26,6 +26,7 @@ run_cmake(COMPILE_LANGUAGE-add_library) run_cmake(COMPILE_LANGUAGE-add_test) run_cmake(COMPILE_LANGUAGE-unknown-lang) run_cmake(TARGET_FILE-recursion) +run_cmake(OUTPUT_NAME-recursion) run_cmake(ImportedTarget-TARGET_PDB_FILE) if(LINKER_SUPPORTS_PDB) diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion.cmake index 7633be1..e780103 100644 --- a/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion.cmake +++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion.cmake @@ -1,3 +1,4 @@ enable_language(C) add_executable(empty1 empty.c) +set_property(TARGET empty1 PROPERTY OUTPUT_NAME $) set_property(TARGET empty1 PROPERTY RUNTIME_OUTPUT_DIRECTORY $) ----------------------------------------------------------------------- Summary of changes: Source/cmGeneratorTarget.cxx | 92 ++++++++++++-------- Source/cmGeneratorTarget.h | 3 + .../OUTPUT_NAME-recursion-result.txt} | 0 .../OUTPUT_NAME-recursion-stderr.txt | 4 + .../OUTPUT_NAME-recursion.cmake | 3 + .../GeneratorExpression/RunCMakeTest.cmake | 1 + .../TARGET_FILE-recursion.cmake | 1 + 7 files changed, 69 insertions(+), 35 deletions(-) copy Tests/RunCMake/{CMP0004/CMP0004-NEW-result.txt => GeneratorExpression/OUTPUT_NAME-recursion-result.txt} (100%) create mode 100644 Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion-stderr.txt create mode 100644 Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion.cmake hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 17 11:37:41 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 17 Aug 2015 11:37:41 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2255-gf55e338 Message-ID: <20150817153741.385BCB1A16@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via f55e338e34017b32301a081a4ccc5967ecfbf0e3 (commit) via a41ebd4ee5b01c92958a28ca2e57b2b6446bf334 (commit) from c9b737643982b4db614a73518fd5c3773cab6be3 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f55e338e34017b32301a081a4ccc5967ecfbf0e3 commit f55e338e34017b32301a081a4ccc5967ecfbf0e3 Merge: c9b7376 a41ebd4 Author: Brad King AuthorDate: Mon Aug 17 11:37:40 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 17 11:37:40 2015 -0400 Merge topic 'cmake-gui-high-resolution' into next a41ebd4e cmake-gui: Add support for HiDPI (Retina) screens on OS X http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a41ebd4ee5b01c92958a28ca2e57b2b6446bf334 commit a41ebd4ee5b01c92958a28ca2e57b2b6446bf334 Author: Francois Best AuthorDate: Mon Aug 17 11:39:16 2015 +0200 Commit: Brad King CommitDate: Mon Aug 17 11:36:42 2015 -0400 cmake-gui: Add support for HiDPI (Retina) screens on OS X diff --git a/Source/QtDialog/Info.plist.in b/Source/QtDialog/Info.plist.in index b9c4af5..00a27c3 100644 --- a/Source/QtDialog/Info.plist.in +++ b/Source/QtDialog/Info.plist.in @@ -28,5 +28,7 @@ public.app-category.developer-tools NSHumanReadableCopyright ${MACOSX_BUNDLE_COPYRIGHT} + NSHighResolutionCapable + ----------------------------------------------------------------------- Summary of changes: Source/QtDialog/Info.plist.in | 2 ++ 1 file changed, 2 insertions(+) hooks/post-receive -- CMake From johnstonj.public at codenest.com Mon Aug 17 23:57:24 2015 From: johnstonj.public at codenest.com (James Johnston) Date: Mon, 17 Aug 2015 23:57:24 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2257-g788a368 Message-ID: <20150818035724.5964CB157A@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 788a368bb48a56e2ea91a9ab6aaeb717ef8c3615 (commit) via e89ea3d190492e41b37425ff021311c2b471f1b9 (commit) from f55e338e34017b32301a081a4ccc5967ecfbf0e3 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=788a368bb48a56e2ea91a9ab6aaeb717ef8c3615 commit 788a368bb48a56e2ea91a9ab6aaeb717ef8c3615 Merge: f55e338 e89ea3d Author: James Johnston AuthorDate: Mon Aug 17 23:57:23 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 17 23:57:23 2015 -0400 Merge topic 'get-filename-component-base-dir' into next e89ea3d1 get_filename_component: Teach new BASE_DIR parameter. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e89ea3d190492e41b37425ff021311c2b471f1b9 commit e89ea3d190492e41b37425ff021311c2b471f1b9 Author: James Johnston AuthorDate: Mon Aug 17 23:55:38 2015 -0400 Commit: James Johnston CommitDate: Mon Aug 17 23:55:38 2015 -0400 get_filename_component: Teach new BASE_DIR parameter. In the get_filename_component command, add a new BASE_DIR parameter to use with the ABSOLUTE and REALPATH options. This will be used when finding an absolute path from a relative path. diff --git a/Help/command/get_filename_component.rst b/Help/command/get_filename_component.rst index 60488da..82f9120 100644 --- a/Help/command/get_filename_component.rst +++ b/Help/command/get_filename_component.rst @@ -3,6 +3,8 @@ get_filename_component Get a specific component of a full filename. +------------------------------------------------------------------------------ + :: get_filename_component( [CACHE]) @@ -15,8 +17,6 @@ Set ```` to a component of ````, where ```` is one of: NAME = File name without directory EXT = File name longest extension (.b.c from d/a.b.c) NAME_WE = File name without directory or longest extension - ABSOLUTE = Full path to file - REALPATH = Full path to existing file with symlinks resolved PATH = Legacy alias for DIRECTORY (use for CMake <= 2.8.11) Paths are returned with forward slashes and have no trailing slahes. @@ -24,14 +24,41 @@ The longest file extension is always considered. If the optional ``CACHE`` argument is specified, the result variable is added to the cache. +------------------------------------------------------------------------------ + +:: + + get_filename_component( + [BASE_DIR ] + [CACHE]) + +Set ```` to the absolute path of ````, where ```` is one +of: + +:: + + ABSOLUTE = Full path to file + REALPATH = Full path to existing file with symlinks resolved + +If the provided ```` is a relative path, it is evaluated relative +to the given base directory ````. If no base directory is +provided, the default base directory will be +:variable:`CMAKE_CURRENT_SOURCE_DIR`. + +Paths are returned with forward slashes and have no trailing slahes. If the +optional ``CACHE`` argument is specified, the result variable is added to the +cache. + +------------------------------------------------------------------------------ + :: - get_filename_component( FileName + get_filename_component( PROGRAM [PROGRAM_ARGS ] [CACHE]) -The program in ``FileName`` will be found in the system search path or +The program in ```` will be found in the system search path or left as a full path. If ``PROGRAM_ARGS`` is present with ``PROGRAM``, then -any command-line arguments present in the ``FileName`` string are split +any command-line arguments present in the ```` string are split from the program name and stored in ````. This is used to separate a program name from its arguments in a command line string. diff --git a/Help/release/dev/get-filename-component-base-dir.rst b/Help/release/dev/get-filename-component-base-dir.rst new file mode 100644 index 0000000..c0df759 --- /dev/null +++ b/Help/release/dev/get-filename-component-base-dir.rst @@ -0,0 +1,6 @@ +get-filename-component-base-dir +------------------------------- + +* The :command:`get_filename_component` command learned a new ``BASE_DIR`` + subcommand. This is used to specify a base directory when calculating an + absolute path from a relative path. diff --git a/Source/cmGetFilenameComponentCommand.cxx b/Source/cmGetFilenameComponentCommand.cxx index 13a9afb..0f56c8e 100644 --- a/Source/cmGetFilenameComponentCommand.cxx +++ b/Source/cmGetFilenameComponentCommand.cxx @@ -93,11 +93,23 @@ bool cmGetFilenameComponentCommand else if (args[2] == "ABSOLUTE" || args[2] == "REALPATH") { + // If the path given is relative, evaluate it relative to the + // current source directory unless the user passes a different + // base directory. + std::string baseDir = this->Makefile->GetCurrentSourceDirectory(); + for(unsigned int i=3; i < args.size(); ++i) + { + if(args[i] == "BASE_DIR") + { + ++i; + if(i < args.size()) + { + baseDir = args[i]; + } + } + } // Collapse the path to its simplest form. - // If the path given is relative evaluate it relative to the - // current source directory. - result = cmSystemTools::CollapseFullPath( - filename, this->Makefile->GetCurrentSourceDirectory()); + result = cmSystemTools::CollapseFullPath(filename, baseDir); if(args[2] == "REALPATH") { // Resolve symlinks if possible diff --git a/Tests/RunCMake/get_filename_component/KnownComponents.cmake b/Tests/RunCMake/get_filename_component/KnownComponents.cmake index 386109f..d822258 100644 --- a/Tests/RunCMake/get_filename_component/KnownComponents.cmake +++ b/Tests/RunCMake/get_filename_component/KnownComponents.cmake @@ -38,6 +38,39 @@ check("ABSOLUTE .. in windows root" "${test_absolute}" "c:/path/to/filename.ext. list(APPEND non_cache_vars test_absolute) +# Test finding absolute paths from various base directories. + +get_filename_component(test_abs_base "testdir1" ABSOLUTE) +check("ABSOLUTE .. from default base" "${test_abs_base}" + "${CMAKE_CURRENT_SOURCE_DIR}/testdir1") + +get_filename_component(test_abs_base "../testdir2" ABSOLUTE + BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/dummydir") +check("ABSOLUTE .. from dummy base to parent" "${test_abs_base}" + "${CMAKE_CURRENT_SOURCE_DIR}/testdir2") + +get_filename_component(test_abs_base "testdir3" ABSOLUTE + BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/dummydir") +check("ABSOLUTE .. from dummy base to child" "${test_abs_base}" + "${CMAKE_CURRENT_SOURCE_DIR}/dummydir/testdir3") + +list(APPEND non_cache_vars test_abs_base) + +# Test finding absolute paths with CACHE parameter. (Note that more +# rigorous testing of the CACHE parameter comes later with PROGRAM). + +get_filename_component(test_abs_base_1 "testdir4" ABSOLUTE CACHE) +check("ABSOLUTE CACHE 1" "${test_abs_base_1}" + "${CMAKE_CURRENT_SOURCE_DIR}/testdir4") +list(APPEND cache_vars test_abs_base_1) + +get_filename_component(test_abs_base_2 "testdir5" ABSOLUTE + BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/dummydir" + CACHE) +check("ABSOLUTE CACHE 2" "${test_abs_base_2}" + "${CMAKE_CURRENT_SOURCE_DIR}/dummydir/testdir5") +list(APPEND cache_vars test_abs_base_2) + # Test the PROGRAM component type. get_filename_component(test_program_name "/ arg1 arg2" PROGRAM) check("PROGRAM with no args output" "${test_program_name}" "/") ----------------------------------------------------------------------- Summary of changes: Help/command/get_filename_component.rst | 37 +++++++++++++++++--- .../dev/get-filename-component-base-dir.rst | 6 ++++ Source/cmGetFilenameComponentCommand.cxx | 20 ++++++++--- .../get_filename_component/KnownComponents.cmake | 33 +++++++++++++++++ 4 files changed, 87 insertions(+), 9 deletions(-) create mode 100644 Help/release/dev/get-filename-component-base-dir.rst hooks/post-receive -- CMake From kwrobot at kitware.com Tue Aug 18 00:01:10 2015 From: kwrobot at kitware.com (Kitware Robot) Date: Tue, 18 Aug 2015 00:01:10 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-865-g76a54a4 Message-ID: <20150818040110.5793DB190E@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 76a54a4486e26b893644447a81da11f864c2cc80 (commit) from a38ea312c02eec6e4ee61015f70920999bf79ff9 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=76a54a4486e26b893644447a81da11f864c2cc80 commit 76a54a4486e26b893644447a81da11f864c2cc80 Author: Kitware Robot AuthorDate: Tue Aug 18 00:01:08 2015 -0400 Commit: Kitware Robot CommitDate: Tue Aug 18 00:01:08 2015 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 24b8f24..50ba1cf 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150817) +set(CMake_VERSION_PATCH 20150818) #set(CMake_VERSION_RC 1) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From eike at sf-mail.de Tue Aug 18 06:18:32 2015 From: eike at sf-mail.de (Rolf Eike Beer) Date: Tue, 18 Aug 2015 06:18:32 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2260-gb2a7e6d Message-ID: <20150818101832.35661B0E0D@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via b2a7e6d6957d6def858382c1370feafac5371987 (commit) via b9ec9392da21a3421e48c6961976060d872faffb (commit) via 76a54a4486e26b893644447a81da11f864c2cc80 (commit) from 788a368bb48a56e2ea91a9ab6aaeb717ef8c3615 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b2a7e6d6957d6def858382c1370feafac5371987 commit b2a7e6d6957d6def858382c1370feafac5371987 Merge: 788a368 b9ec939 Author: Rolf Eike Beer AuthorDate: Tue Aug 18 06:18:31 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 18 06:18:31 2015 -0400 Merge topic 'finpkgconfig-if-deref' into next b9ec9392 FindPkgConfig: remove variable dereference 76a54a44 CMake Nightly Date Stamp http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b9ec9392da21a3421e48c6961976060d872faffb commit b9ec9392da21a3421e48c6961976060d872faffb Author: Rolf Eike Beer AuthorDate: Tue Aug 18 12:14:43 2015 +0200 Commit: Rolf Eike Beer CommitDate: Tue Aug 18 12:14:43 2015 +0200 FindPkgConfig: remove variable dereference If CMAKE_MINIMUM_REQUIRED_VERSION is not set because no cmake_minimum_required() call is present this line can lead to an error as that string is empty so too few arguments are passed to if(): See also "/var/tmp/paludis/build/kde-krdc-15.08.0/work/build/CMakeFiles/CMakeOutput.log". See also "/var/tmp/paludis/build/kde-krdc-15.08.0/work/build/CMakeFiles/CMakeError.log". CMake Error at /usr/share/cmake/Modules/FindPkgConfig.cmake:112 (elseif): given arguments: "VERSION_LESS" "3.1" Unknown arguments specified Call Stack (most recent call first): /usr/share/cmake/Modules/FindPkgConfig.cmake:501 (_pkgconfig_parse_options) /usr/share/cmake/Modules/FindOpenSSL.cmake:43 (pkg_check_modules) diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake index 526a62e..ae6903e 100644 --- a/Modules/FindPkgConfig.cmake +++ b/Modules/FindPkgConfig.cmake @@ -109,7 +109,7 @@ macro(_pkgconfig_parse_options _result _is_req _is_silent _no_cmake_path _no_cma set(${_no_cmake_path} 1) set(${_no_cmake_environment_path} 1) endif() - elseif(${CMAKE_MINIMUM_REQUIRED_VERSION} VERSION_LESS 3.1) + elseif(CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 3.1) set(${_no_cmake_path} 1) set(${_no_cmake_environment_path} 1) endif() ----------------------------------------------------------------------- Summary of changes: Modules/FindPkgConfig.cmake | 2 +- Source/CMakeVersion.cmake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Tue Aug 18 10:07:54 2015 From: brad.king at kitware.com (Brad King) Date: Tue, 18 Aug 2015 10:07:54 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2262-ga420708 Message-ID: <20150818140755.019F5B1808@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via a420708f5280718f95507b6262b430d7594979bd (commit) via 49cdbc8e6bc079daa593e557a93a928dd01e7638 (commit) from b2a7e6d6957d6def858382c1370feafac5371987 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a420708f5280718f95507b6262b430d7594979bd commit a420708f5280718f95507b6262b430d7594979bd Merge: b2a7e6d 49cdbc8 Author: Brad King AuthorDate: Tue Aug 18 10:07:54 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 18 10:07:54 2015 -0400 Merge topic 'OUTPUT_NAME-genex-no-recursion' into next 49cdbc8e Revert "cmGeneratorTarget: Avoid recursion in GetOutputName method" http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=49cdbc8e6bc079daa593e557a93a928dd01e7638 commit 49cdbc8e6bc079daa593e557a93a928dd01e7638 Author: Brad King AuthorDate: Tue Aug 18 10:07:16 2015 -0400 Commit: Brad King CommitDate: Tue Aug 18 10:07:21 2015 -0400 Revert "cmGeneratorTarget: Avoid recursion in GetOutputName method" This reverts commit e66a7d6973fa58bb3bf37b540f67e2c33bb9fae2. We need a separate map for primary and implib output names. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 7d4bb67..299c112 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -270,70 +270,48 @@ const char *cmGeneratorTarget::GetProperty(const std::string& prop) const std::string cmGeneratorTarget::GetOutputName(const std::string& config, bool implib) const { - // Lookup/compute/cache the output name for this configuration. - cmGeneratorTarget::OutputNameMapType::iterator i = - this->OutputNameMap.find(config); - if(i == this->OutputNameMap.end()) + std::vector props; + std::string type = this->Target->GetOutputTargetType(implib); + std::string configUpper = cmSystemTools::UpperCase(config); + if(!type.empty() && !configUpper.empty()) { - // Add empty name in map to detect potential recursion. - OutputNameMapType::value_type entry(config, ""); - i = this->OutputNameMap.insert(entry).first; - - // Compute output name. - std::vector props; - std::string type = this->Target->GetOutputTargetType(implib); - std::string configUpper = cmSystemTools::UpperCase(config); - if(!type.empty() && !configUpper.empty()) - { - // _OUTPUT_NAME_ - props.push_back(type + "_OUTPUT_NAME_" + configUpper); - } - if(!type.empty()) - { - // _OUTPUT_NAME - props.push_back(type + "_OUTPUT_NAME"); - } - if(!configUpper.empty()) - { - // OUTPUT_NAME_ - props.push_back("OUTPUT_NAME_" + configUpper); - // _OUTPUT_NAME - props.push_back(configUpper + "_OUTPUT_NAME"); - } - // OUTPUT_NAME - props.push_back("OUTPUT_NAME"); - - std::string outName; - for(std::vector::const_iterator it = props.begin(); - it != props.end(); ++it) - { - if (const char* outNameProp = this->Target->GetProperty(*it)) - { - outName = outNameProp; - break; - } - } + // _OUTPUT_NAME_ + props.push_back(type + "_OUTPUT_NAME_" + configUpper); + } + if(!type.empty()) + { + // _OUTPUT_NAME + props.push_back(type + "_OUTPUT_NAME"); + } + if(!configUpper.empty()) + { + // OUTPUT_NAME_ + props.push_back("OUTPUT_NAME_" + configUpper); + // _OUTPUT_NAME + props.push_back(configUpper + "_OUTPUT_NAME"); + } + // OUTPUT_NAME + props.push_back("OUTPUT_NAME"); - if(outName.empty()) + std::string outName; + for(std::vector::const_iterator i = props.begin(); + i != props.end(); ++i) + { + if (const char* outNameProp = this->Target->GetProperty(*i)) { - outName = this->GetName(); + outName = outNameProp; + break; } - - // Now evaluate genex and update the previously-prepared map entry. - cmGeneratorExpression ge; - cmsys::auto_ptr cge = ge.Parse(outName); - i->second = cge->Evaluate(this->Makefile, config); } - else if(i->second.empty()) + + if (outName.empty()) { - // An empty map entry indicates we have been called recursively - // from the above block. - this->Makefile->GetCMakeInstance()->IssueMessage( - cmake::FATAL_ERROR, - "Target '" + this->GetName() + "' OUTPUT_NAME depends on itself.", - this->Target->GetBacktrace()); + outName = this->GetName(); } - return i->second; + + cmGeneratorExpression ge; + cmsys::auto_ptr cge = ge.Parse(outName); + return cge->Evaluate(this->Makefile, config); } //---------------------------------------------------------------------------- diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index a603975..68e7a8a 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -375,9 +375,6 @@ private: }; mutable std::map LinkImplClosureMap; - typedef std::map OutputNameMapType; - mutable OutputNameMapType OutputNameMap; - public: std::vector const& GetLinkImplementationClosure(const std::string& config) const; diff --git a/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion-result.txt b/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion-result.txt deleted file mode 100644 index d00491f..0000000 --- a/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion-stderr.txt b/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion-stderr.txt deleted file mode 100644 index bf592e7..0000000 --- a/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion-stderr.txt +++ /dev/null @@ -1,4 +0,0 @@ -CMake Error at OUTPUT_NAME-recursion.cmake:[0-9]+ \(add_executable\): - Target 'empty1' OUTPUT_NAME depends on itself. -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion.cmake b/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion.cmake deleted file mode 100644 index 5cb8050..0000000 --- a/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion.cmake +++ /dev/null @@ -1,3 +0,0 @@ -enable_language(C) -add_executable(empty1 empty.c) -set_property(TARGET empty1 PROPERTY OUTPUT_NAME $) diff --git a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake index 0679024..21fc851 100644 --- a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake @@ -26,7 +26,6 @@ run_cmake(COMPILE_LANGUAGE-add_library) run_cmake(COMPILE_LANGUAGE-add_test) run_cmake(COMPILE_LANGUAGE-unknown-lang) run_cmake(TARGET_FILE-recursion) -run_cmake(OUTPUT_NAME-recursion) run_cmake(ImportedTarget-TARGET_PDB_FILE) if(LINKER_SUPPORTS_PDB) diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion.cmake index e780103..7633be1 100644 --- a/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion.cmake +++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion.cmake @@ -1,4 +1,3 @@ enable_language(C) add_executable(empty1 empty.c) -set_property(TARGET empty1 PROPERTY OUTPUT_NAME $) set_property(TARGET empty1 PROPERTY RUNTIME_OUTPUT_DIRECTORY $) ----------------------------------------------------------------------- Summary of changes: Source/cmGeneratorTarget.cxx | 92 ++++++++------------ Source/cmGeneratorTarget.h | 3 - .../OUTPUT_NAME-recursion-result.txt | 1 - .../OUTPUT_NAME-recursion-stderr.txt | 4 - .../OUTPUT_NAME-recursion.cmake | 3 - .../GeneratorExpression/RunCMakeTest.cmake | 1 - .../TARGET_FILE-recursion.cmake | 1 - 7 files changed, 35 insertions(+), 70 deletions(-) delete mode 100644 Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion-result.txt delete mode 100644 Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion-stderr.txt delete mode 100644 Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion.cmake hooks/post-receive -- CMake From brad.king at kitware.com Tue Aug 18 10:12:00 2015 From: brad.king at kitware.com (Brad King) Date: Tue, 18 Aug 2015 10:12:00 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-867-gfb329c0 Message-ID: <20150818141200.42606B03C5@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via fb329c0bc130e0afef086d6d154890bdde773e40 (commit) via ba1065ab7b3c293245b3bbe733f8f062b9aa7ac9 (commit) from 76a54a4486e26b893644447a81da11f864c2cc80 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fb329c0bc130e0afef086d6d154890bdde773e40 commit fb329c0bc130e0afef086d6d154890bdde773e40 Merge: 76a54a4 ba1065a Author: Brad King AuthorDate: Tue Aug 18 10:11:58 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 18 10:11:58 2015 -0400 Merge topic 'build-subdir' ba1065ab cmake: Add support for "--build ." in subdirectory (#15696) ----------------------------------------------------------------------- Summary of changes: Source/cmake.cxx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) hooks/post-receive -- CMake From brad.king at kitware.com Tue Aug 18 10:12:02 2015 From: brad.king at kitware.com (Brad King) Date: Tue, 18 Aug 2015 10:12:02 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-869-g868be9c Message-ID: <20150818141202.ACD02B03DD@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 868be9c6403e6221096e03763eb1944c487b3c9e (commit) via a41ebd4ee5b01c92958a28ca2e57b2b6446bf334 (commit) from fb329c0bc130e0afef086d6d154890bdde773e40 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=868be9c6403e6221096e03763eb1944c487b3c9e commit 868be9c6403e6221096e03763eb1944c487b3c9e Merge: fb329c0 a41ebd4 Author: Brad King AuthorDate: Tue Aug 18 10:12:01 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 18 10:12:01 2015 -0400 Merge topic 'cmake-gui-high-resolution' a41ebd4e cmake-gui: Add support for HiDPI (Retina) screens on OS X ----------------------------------------------------------------------- Summary of changes: Source/QtDialog/Info.plist.in | 2 ++ 1 file changed, 2 insertions(+) hooks/post-receive -- CMake From brad.king at kitware.com Tue Aug 18 10:12:04 2015 From: brad.king at kitware.com (Brad King) Date: Tue, 18 Aug 2015 10:12:04 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-871-gf1d08e5 Message-ID: <20150818141204.F355CB03EB@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via f1d08e59239339103abc88f499f1c0fa427174b7 (commit) via 462fbd1ecac6968f6c0695737c8e432c9660121c (commit) from 868be9c6403e6221096e03763eb1944c487b3c9e (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f1d08e59239339103abc88f499f1c0fa427174b7 commit f1d08e59239339103abc88f499f1c0fa427174b7 Merge: 868be9c 462fbd1 Author: Brad King AuthorDate: Tue Aug 18 10:12:03 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 18 10:12:03 2015 -0400 Merge topic 'add-ARTOS-platform-module' 462fbd1e Add support for ARTOS platform using GNU C with ac compiler driver ----------------------------------------------------------------------- Summary of changes: Modules/Platform/ARTOS-GNU-C.cmake | 9 +++++++++ Modules/Platform/ARTOS.cmake | 17 +++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 Modules/Platform/ARTOS-GNU-C.cmake create mode 100644 Modules/Platform/ARTOS.cmake hooks/post-receive -- CMake From brad.king at kitware.com Tue Aug 18 10:12:07 2015 From: brad.king at kitware.com (Brad King) Date: Tue, 18 Aug 2015 10:12:07 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-873-ga712575 Message-ID: <20150818141207.08BF5B04BC@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via a712575da1a0e6117c4682100e3b9df72b964b2a (commit) via b9ec9392da21a3421e48c6961976060d872faffb (commit) from f1d08e59239339103abc88f499f1c0fa427174b7 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a712575da1a0e6117c4682100e3b9df72b964b2a commit a712575da1a0e6117c4682100e3b9df72b964b2a Merge: f1d08e5 b9ec939 Author: Brad King AuthorDate: Tue Aug 18 10:12:05 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 18 10:12:05 2015 -0400 Merge topic 'finpkgconfig-if-deref' b9ec9392 FindPkgConfig: remove variable dereference ----------------------------------------------------------------------- Summary of changes: Modules/FindPkgConfig.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Tue Aug 18 10:13:07 2015 From: brad.king at kitware.com (Brad King) Date: Tue, 18 Aug 2015 10:13:07 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2267-ga3443d2 Message-ID: <20150818141307.579F2B0587@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via a3443d29fec62f29990eda358e1d8dd16cff811c (commit) via a712575da1a0e6117c4682100e3b9df72b964b2a (commit) via f1d08e59239339103abc88f499f1c0fa427174b7 (commit) via 868be9c6403e6221096e03763eb1944c487b3c9e (commit) via fb329c0bc130e0afef086d6d154890bdde773e40 (commit) from a420708f5280718f95507b6262b430d7594979bd (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a3443d29fec62f29990eda358e1d8dd16cff811c commit a3443d29fec62f29990eda358e1d8dd16cff811c Merge: a420708 a712575 Author: Brad King AuthorDate: Tue Aug 18 10:13:00 2015 -0400 Commit: Brad King CommitDate: Tue Aug 18 10:13:00 2015 -0400 Merge branch 'master' into next ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From kwrobot at kitware.com Wed Aug 19 00:01:13 2015 From: kwrobot at kitware.com (Kitware Robot) Date: Wed, 19 Aug 2015 00:01:13 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-874-g404d16e Message-ID: <20150819040113.118ECB14C2@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 404d16e7bc1b18027f719cd8642d0a90c679c396 (commit) from a712575da1a0e6117c4682100e3b9df72b964b2a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=404d16e7bc1b18027f719cd8642d0a90c679c396 commit 404d16e7bc1b18027f719cd8642d0a90c679c396 Author: Kitware Robot AuthorDate: Wed Aug 19 00:01:08 2015 -0400 Commit: Kitware Robot CommitDate: Wed Aug 19 00:01:08 2015 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 50ba1cf..f0a7cbd 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150818) +set(CMake_VERSION_PATCH 20150819) #set(CMake_VERSION_RC 1) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From matt.mccormick at kitware.com Wed Aug 19 08:42:13 2015 From: matt.mccormick at kitware.com (Matt McCormick) Date: Wed, 19 Aug 2015 08:42:13 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2269-g80267fb Message-ID: <20150819124213.854E7B0561@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 80267fb9587aec657286305580fee4fc390c3cb9 (commit) via 306c9361ce1fffc85b2ffe88132885cf5955f1ba (commit) from a3443d29fec62f29990eda358e1d8dd16cff811c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=80267fb9587aec657286305580fee4fc390c3cb9 commit 80267fb9587aec657286305580fee4fc390c3cb9 Merge: a3443d2 306c936 Author: Matt McCormick AuthorDate: Wed Aug 19 08:42:12 2015 -0400 Commit: CMake Topic Stage CommitDate: Wed Aug 19 08:42:12 2015 -0400 Merge topic 'MSVC-quote-for-release' into next 306c9361 CMake: Silence CMP0054 warning with separate project, enable_language calls. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=306c9361ce1fffc85b2ffe88132885cf5955f1ba commit 306c9361ce1fffc85b2ffe88132885cf5955f1ba Author: Matt McCormick AuthorDate: Sun Aug 16 15:42:23 2015 -0400 Commit: Matt McCormick CommitDate: Sun Aug 16 15:42:23 2015 -0400 CMake: Silence CMP0054 warning with separate project, enable_language calls. This addresses the warning: -- The CXX compiler identification is MSVC 18.0.31101.0 CMake Warning (dev) at C:/Program Files (x86)/CMake/share/cmake-3.3/Modules/CMakeDetermineCXXCompiler.cmake:106 (if): Policy CMP0054 is not set: Only interpret if() arguments as variables or keywords when unquoted. Run "cmake --help-policy CMP0054" for policy details. Use the cmake_policy command to set the policy and suppress this warning. Quoted variables like "MSVC" will no longer be dereferenced when the policy is set to NEW. Since the policy is not set the OLD behavior will be used. Call Stack (most recent call first): CMakeLists.txt:23 (enable_language) That occurs with MSVC / Ninja with the following CMakeLists.txt: cmake_minimum_required(VERSION 2.8.9 FATAL_ERROR) project(MyProj NONE) enable_language(C) enable_language(CXX) diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index 893c454..7e6d8dc 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -103,14 +103,17 @@ if(NOT CMAKE_CXX_COMPILER_ID_RUN) CMAKE_DETERMINE_COMPILER_ID(CXX CXXFLAGS CMakeCXXCompilerId.cpp) # Set old compiler and platform id variables. - if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") - set(CMAKE_COMPILER_IS_GNUCXX 1) - endif() - if("${CMAKE_CXX_PLATFORM_ID}" MATCHES "MinGW") - set(CMAKE_COMPILER_IS_MINGW 1) - elseif("${CMAKE_CXX_PLATFORM_ID}" MATCHES "Cygwin") - set(CMAKE_COMPILER_IS_CYGWIN 1) - endif() + cmake_policy(PUSH) + cmake_policy(SET CMP0054 NEW) + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") + set(CMAKE_COMPILER_IS_GNUCXX 1) + endif() + if("${CMAKE_CXX_PLATFORM_ID}" MATCHES "MinGW") + set(CMAKE_COMPILER_IS_MINGW 1) + elseif("${CMAKE_CXX_PLATFORM_ID}" MATCHES "Cygwin") + set(CMAKE_COMPILER_IS_CYGWIN 1) + endif() + cmake_policy(POP) endif() if (NOT _CMAKE_TOOLCHAIN_LOCATION) ----------------------------------------------------------------------- Summary of changes: Modules/CMakeDetermineCXXCompiler.cmake | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) hooks/post-receive -- CMake From johnstonj.public at codenest.com Wed Aug 19 23:50:01 2015 From: johnstonj.public at codenest.com (James Johnston) Date: Wed, 19 Aug 2015 23:50:01 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2272-g4527e18 Message-ID: <20150820035001.50BC0B11F9@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 4527e186cb891f4dfe7c025066566a4f7d1a4346 (commit) via f4b24bc49a0679983a5640c03aa49b636f31efda (commit) via 404d16e7bc1b18027f719cd8642d0a90c679c396 (commit) from 80267fb9587aec657286305580fee4fc390c3cb9 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4527e186cb891f4dfe7c025066566a4f7d1a4346 commit 4527e186cb891f4dfe7c025066566a4f7d1a4346 Merge: 80267fb f4b24bc Author: James Johnston AuthorDate: Wed Aug 19 23:49:58 2015 -0400 Commit: CMake Topic Stage CommitDate: Wed Aug 19 23:49:58 2015 -0400 Merge topic 'improve-variable-help-formatting' into next f4b24bc4 Help: Improve formatting of variable topics. 404d16e7 CMake Nightly Date Stamp http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f4b24bc49a0679983a5640c03aa49b636f31efda commit f4b24bc49a0679983a5640c03aa49b636f31efda Author: James Johnston AuthorDate: Tue Aug 18 01:34:01 2015 -0400 Commit: James Johnston CommitDate: Wed Aug 19 23:48:26 2015 -0400 Help: Improve formatting of variable topics. Improve formatting, primarily by: * Adding links to relevant commands, properties, generators, and so on. * Converting code, symbols, paths, and so on to fixed-width fonts. * Hard wrapping lines to 80 characters or less. diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst index 9ce4971..dac16bf 100644 --- a/Help/manual/cmake.1.rst +++ b/Help/manual/cmake.1.rst @@ -27,6 +27,8 @@ in each directory of a source tree with the name CMakeLists.txt. Users build a project by using CMake to generate a build system for a native tool on their platform. +.. _`CMake Options`: + Options ======= diff --git a/Help/variable/APPLE.rst b/Help/variable/APPLE.rst index 3afdee8..a8d2429 100644 --- a/Help/variable/APPLE.rst +++ b/Help/variable/APPLE.rst @@ -1,6 +1,6 @@ APPLE ----- -True if running on Mac OS X. +``True`` if running on Mac OS X. -Set to true on Mac OS X. +Set to ``true`` on Mac OS X. diff --git a/Help/variable/BORLAND.rst b/Help/variable/BORLAND.rst index 4af6085..badb733 100644 --- a/Help/variable/BORLAND.rst +++ b/Help/variable/BORLAND.rst @@ -1,6 +1,6 @@ BORLAND ------- -True if the Borland compiler is being used. +``True`` if the Borland compiler is being used. -This is set to true if the Borland compiler is being used. +This is set to ``true`` if the Borland compiler is being used. diff --git a/Help/variable/BUILD_SHARED_LIBS.rst b/Help/variable/BUILD_SHARED_LIBS.rst index 6f30efb..53087b2 100644 --- a/Help/variable/BUILD_SHARED_LIBS.rst +++ b/Help/variable/BUILD_SHARED_LIBS.rst @@ -1,10 +1,10 @@ BUILD_SHARED_LIBS ----------------- -Global flag to cause add_library to create shared libraries if on. +Global flag to cause :command:`add_library` to create shared libraries if on. If present and true, this will cause all libraries to be built shared unless the library was explicitly added as a static library. This -variable is often added to projects as an OPTION so that each user of -a project can decide if they want to build the project using shared or +variable is often added to projects as an :command:`option` so that each user +of a project can decide if they want to build the project using shared or static libraries. diff --git a/Help/variable/CMAKE_ABSOLUTE_DESTINATION_FILES.rst b/Help/variable/CMAKE_ABSOLUTE_DESTINATION_FILES.rst index 3691453..b6d0054 100644 --- a/Help/variable/CMAKE_ABSOLUTE_DESTINATION_FILES.rst +++ b/Help/variable/CMAKE_ABSOLUTE_DESTINATION_FILES.rst @@ -1,9 +1,9 @@ CMAKE_ABSOLUTE_DESTINATION_FILES -------------------------------- -List of files which have been installed using an ABSOLUTE DESTINATION path. +List of files which have been installed using an ``ABSOLUTE DESTINATION`` path. -This variable is defined by CMake-generated cmake_install.cmake +This variable is defined by CMake-generated ``cmake_install.cmake`` scripts. It can be used (read-only) by programs or scripts that source those install scripts. This is used by some CPack generators (e.g. RPM). diff --git a/Help/variable/CMAKE_ANDROID_NATIVE_LIB_DEPENDENCIES.rst b/Help/variable/CMAKE_ANDROID_NATIVE_LIB_DEPENDENCIES.rst index 52e60b1..4191907 100644 --- a/Help/variable/CMAKE_ANDROID_NATIVE_LIB_DEPENDENCIES.rst +++ b/Help/variable/CMAKE_ANDROID_NATIVE_LIB_DEPENDENCIES.rst @@ -1,5 +1,5 @@ CMAKE_ANDROID_NATIVE_LIB_DEPENDENCIES ------------------------------------- -Default value for the :prop_tgt:`ANDROID_NATIVE_LIB_DEPENDENCIES` target property. -See that target property for additional information. +Default value for the :prop_tgt:`ANDROID_NATIVE_LIB_DEPENDENCIES` target +property. See that target property for additional information. diff --git a/Help/variable/CMAKE_ANDROID_NATIVE_LIB_DIRECTORIES.rst b/Help/variable/CMAKE_ANDROID_NATIVE_LIB_DIRECTORIES.rst index 8480575..7cb9527 100644 --- a/Help/variable/CMAKE_ANDROID_NATIVE_LIB_DIRECTORIES.rst +++ b/Help/variable/CMAKE_ANDROID_NATIVE_LIB_DIRECTORIES.rst @@ -1,5 +1,5 @@ CMAKE_ANDROID_NATIVE_LIB_DIRECTORIES ------------------------------------ -Default value for the :prop_tgt:`ANDROID_NATIVE_LIB_DIRECTORIES` target property. -See that target property for additional information. +Default value for the :prop_tgt:`ANDROID_NATIVE_LIB_DIRECTORIES` target +property. See that target property for additional information. diff --git a/Help/variable/CMAKE_ARGC.rst b/Help/variable/CMAKE_ARGC.rst index be120b8..aec9711 100644 --- a/Help/variable/CMAKE_ARGC.rst +++ b/Help/variable/CMAKE_ARGC.rst @@ -3,5 +3,6 @@ CMAKE_ARGC Number of command line arguments passed to CMake in script mode. -When run in -P script mode, CMake sets this variable to the number of -command line arguments. See also CMAKE_ARGV0, 1, 2 ... +When run in :ref:`-P ` script mode, CMake sets this variable to +the number of command line arguments. See also :variable:`CMAKE_ARGV0`, +``1``, ``2`` ... diff --git a/Help/variable/CMAKE_ARGV0.rst b/Help/variable/CMAKE_ARGV0.rst index e5ed419..8b1ecb7 100644 --- a/Help/variable/CMAKE_ARGV0.rst +++ b/Help/variable/CMAKE_ARGV0.rst @@ -3,7 +3,7 @@ CMAKE_ARGV0 Command line argument passed to CMake in script mode. -When run in -P script mode, CMake sets this variable to the first -command line argument. It then also sets CMAKE_ARGV1, CMAKE_ARGV2, -... and so on, up to the number of command line arguments given. See -also CMAKE_ARGC. +When run in :ref:`-P ` script mode, CMake sets this variable to +the first command line argument. It then also sets ``CMAKE_ARGV1``, +``CMAKE_ARGV2``, ... and so on, up to the number of command line arguments +given. See also :variable:`CMAKE_ARGC`. diff --git a/Help/variable/CMAKE_AUTOMOC_RELAXED_MODE.rst b/Help/variable/CMAKE_AUTOMOC_RELAXED_MODE.rst index a814d40..addc62d 100644 --- a/Help/variable/CMAKE_AUTOMOC_RELAXED_MODE.rst +++ b/Help/variable/CMAKE_AUTOMOC_RELAXED_MODE.rst @@ -3,11 +3,11 @@ CMAKE_AUTOMOC_RELAXED_MODE Switch between strict and relaxed automoc mode. -By default, :prop_tgt:`AUTOMOC` behaves exactly as described in the documentation -of the :prop_tgt:`AUTOMOC` target property. When set to ``TRUE``, it accepts more -input and tries to find the correct input file for ``moc`` even if it -differs from the documented behaviour. In this mode it e.g. also -checks whether a header file is intended to be processed by moc when a -``"foo.moc"`` file has been included. +By default, :prop_tgt:`AUTOMOC` behaves exactly as described in the +documentation of the :prop_tgt:`AUTOMOC` target property. When set to +``TRUE``, it accepts more input and tries to find the correct input file for +``moc`` even if it differs from the documented behaviour. In this mode it +e.g. also checks whether a header file is intended to be processed by moc +when a ``"foo.moc"`` file has been included. Relaxed mode has to be enabled for KDE4 compatibility. diff --git a/Help/variable/CMAKE_AUTORCC.rst b/Help/variable/CMAKE_AUTORCC.rst index 067f766..7426105 100644 --- a/Help/variable/CMAKE_AUTORCC.rst +++ b/Help/variable/CMAKE_AUTORCC.rst @@ -3,5 +3,5 @@ CMAKE_AUTORCC Whether to handle ``rcc`` automatically for Qt targets. -This variable is used to initialize the :prop_tgt:`AUTORCC` property on all the targets. -See that target property for additional information. +This variable is used to initialize the :prop_tgt:`AUTORCC` property on all +the targets. See that target property for additional information. diff --git a/Help/variable/CMAKE_AUTOUIC.rst b/Help/variable/CMAKE_AUTOUIC.rst index 0beb555..5abefaa 100644 --- a/Help/variable/CMAKE_AUTOUIC.rst +++ b/Help/variable/CMAKE_AUTOUIC.rst @@ -3,5 +3,5 @@ CMAKE_AUTOUIC Whether to handle ``uic`` automatically for Qt targets. -This variable is used to initialize the :prop_tgt:`AUTOUIC` property on all the targets. -See that target property for additional information. +This variable is used to initialize the :prop_tgt:`AUTOUIC` property on all +the targets. See that target property for additional information. diff --git a/Help/variable/CMAKE_BINARY_DIR.rst b/Help/variable/CMAKE_BINARY_DIR.rst index 703bb58..f8dd8ab 100644 --- a/Help/variable/CMAKE_BINARY_DIR.rst +++ b/Help/variable/CMAKE_BINARY_DIR.rst @@ -5,4 +5,4 @@ The path to the top level of the build tree. This is the full path to the top level of the current CMake build tree. For an in-source build, this would be the same as -CMAKE_SOURCE_DIR. +:variable:`CMAKE_SOURCE_DIR`. diff --git a/Help/variable/CMAKE_BUILD_TYPE.rst b/Help/variable/CMAKE_BUILD_TYPE.rst index 68f08ba..2d54d60 100644 --- a/Help/variable/CMAKE_BUILD_TYPE.rst +++ b/Help/variable/CMAKE_BUILD_TYPE.rst @@ -4,16 +4,17 @@ CMAKE_BUILD_TYPE Specifies the build type on single-configuration generators. This statically specifies what build type (configuration) will be -built in this build tree. Possible values are empty, Debug, Release, -RelWithDebInfo and MinSizeRel. This variable is only meaningful to -single-configuration generators (such as make and Ninja) i.e. those -which choose a single configuration when CMake runs to generate a -build tree as opposed to multi-configuration generators which offer -selection of the build configuration within the generated build +built in this build tree. Possible values are empty, ``Debug``, ``Release``, +``RelWithDebInfo`` and ``MinSizeRel``. This variable is only meaningful to +single-configuration generators (such as :ref:`Makefile Generators` and +:generator:`Ninja`) i.e. those which choose a single configuration when CMake +runs to generate a build tree as opposed to multi-configuration generators +which offer selection of the build configuration within the generated build environment. There are many per-config properties and variables -(usually following clean SOME_VAR_ order conventions), such as -CMAKE_C_FLAGS_, specified as uppercase: -CMAKE_C_FLAGS_[DEBUG|RELEASE|RELWITHDEBINFO|MINSIZEREL]. For example, -in a build tree configured to build type Debug, CMake will see to -having CMAKE_C_FLAGS_DEBUG settings get added to the CMAKE_C_FLAGS -settings. See also CMAKE_CONFIGURATION_TYPES. +(usually following clean ``SOME_VAR_`` order conventions), such as +``CMAKE_C_FLAGS_``, specified as uppercase: +``CMAKE_C_FLAGS_[DEBUG|RELEASE|RELWITHDEBINFO|MINSIZEREL]``. For example, +in a build tree configured to build type ``Debug``, CMake will see to +having :variable:`CMAKE_C_FLAGS_DEBUG _FLAGS_DEBUG>` settings get +added to the :variable:`CMAKE_C_FLAGS _FLAGS>` settings. See +also :variable:`CMAKE_CONFIGURATION_TYPES`. diff --git a/Help/variable/CMAKE_BUILD_WITH_INSTALL_RPATH.rst b/Help/variable/CMAKE_BUILD_WITH_INSTALL_RPATH.rst index 6875da6..5b59a6e 100644 --- a/Help/variable/CMAKE_BUILD_WITH_INSTALL_RPATH.rst +++ b/Help/variable/CMAKE_BUILD_WITH_INSTALL_RPATH.rst @@ -1,11 +1,11 @@ CMAKE_BUILD_WITH_INSTALL_RPATH ------------------------------ -Use the install path for the RPATH +Use the install path for the ``RPATH``. -Normally CMake uses the build tree for the RPATH when building -executables etc on systems that use RPATH. When the software is +Normally CMake uses the build tree for the ``RPATH`` when building +executables etc on systems that use ``RPATH``. When the software is installed the executables etc are relinked by CMake to have the -install RPATH. If this variable is set to true then the software is -always built with the install path for the RPATH and does not need to +install ``RPATH``. If this variable is set to true then the software is +always built with the install path for the ``RPATH`` and does not need to be relinked when installed. diff --git a/Help/variable/CMAKE_CACHEFILE_DIR.rst b/Help/variable/CMAKE_CACHEFILE_DIR.rst index 78c7d93..8604d0e 100644 --- a/Help/variable/CMAKE_CACHEFILE_DIR.rst +++ b/Help/variable/CMAKE_CACHEFILE_DIR.rst @@ -1,7 +1,7 @@ CMAKE_CACHEFILE_DIR ------------------- -The directory with the CMakeCache.txt file. +The directory with the ``CMakeCache.txt`` file. -This is the full path to the directory that has the CMakeCache.txt -file in it. This is the same as CMAKE_BINARY_DIR. +This is the full path to the directory that has the ``CMakeCache.txt`` +file in it. This is the same as :variable:`CMAKE_BINARY_DIR`. diff --git a/Help/variable/CMAKE_CACHE_MAJOR_VERSION.rst b/Help/variable/CMAKE_CACHE_MAJOR_VERSION.rst index e6887d9..1e53ed6 100644 --- a/Help/variable/CMAKE_CACHE_MAJOR_VERSION.rst +++ b/Help/variable/CMAKE_CACHE_MAJOR_VERSION.rst @@ -1,7 +1,7 @@ CMAKE_CACHE_MAJOR_VERSION ------------------------- -Major version of CMake used to create the CMakeCache.txt file +Major version of CMake used to create the ``CMakeCache.txt`` file This stores the major version of CMake used to write a CMake cache file. It is only different when a different version of CMake is run diff --git a/Help/variable/CMAKE_CACHE_MINOR_VERSION.rst b/Help/variable/CMAKE_CACHE_MINOR_VERSION.rst index 799f0a9..5d174a3 100644 --- a/Help/variable/CMAKE_CACHE_MINOR_VERSION.rst +++ b/Help/variable/CMAKE_CACHE_MINOR_VERSION.rst @@ -1,7 +1,7 @@ CMAKE_CACHE_MINOR_VERSION ------------------------- -Minor version of CMake used to create the CMakeCache.txt file +Minor version of CMake used to create the ``CMakeCache.txt`` file This stores the minor version of CMake used to write a CMake cache file. It is only different when a different version of CMake is run diff --git a/Help/variable/CMAKE_CACHE_PATCH_VERSION.rst b/Help/variable/CMAKE_CACHE_PATCH_VERSION.rst index e67d544..22d267c 100644 --- a/Help/variable/CMAKE_CACHE_PATCH_VERSION.rst +++ b/Help/variable/CMAKE_CACHE_PATCH_VERSION.rst @@ -1,7 +1,7 @@ CMAKE_CACHE_PATCH_VERSION ------------------------- -Patch version of CMake used to create the CMakeCache.txt file +Patch version of CMake used to create the ``CMakeCache.txt`` file This stores the patch version of CMake used to write a CMake cache file. It is only different when a different version of CMake is run diff --git a/Help/variable/CMAKE_CFG_INTDIR.rst b/Help/variable/CMAKE_CFG_INTDIR.rst index 55f7b01..dcc1aed 100644 --- a/Help/variable/CMAKE_CFG_INTDIR.rst +++ b/Help/variable/CMAKE_CFG_INTDIR.rst @@ -4,11 +4,11 @@ CMAKE_CFG_INTDIR Build-time reference to per-configuration output subdirectory. For native build systems supporting multiple configurations in the -build tree (such as Visual Studio and Xcode), the value is a reference -to a build-time variable specifying the name of the per-configuration -output subdirectory. On Makefile generators this evaluates to "." -because there is only one configuration in a build tree. Example -values: +build tree (such as :ref:`Visual Studio Generators` and :generator:`Xcode`), +the value is a reference to a build-time variable specifying the name +of the per-configuration output subdirectory. On :ref:`Makefile Generators` +this evaluates to `.` because there is only one configuration in a build tree. +Example values: :: @@ -33,13 +33,14 @@ evaluated at build time. Example of intended usage: ) add_custom_target(drive ALL DEPENDS out.txt) -Note that CMAKE_CFG_INTDIR is no longer necessary for this purpose but +Note that ``CMAKE_CFG_INTDIR`` is no longer necessary for this purpose but has been left for compatibility with existing projects. Instead -add_custom_command() recognizes executable target names in its COMMAND -option, so "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/mytool" -can be replaced by just "mytool". +:command:`add_custom_command` recognizes executable target names in its +``COMMAND`` option, so +``${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/mytool`` can be replaced +by just ``mytool``. This variable is read-only. Setting it is undefined behavior. In multi-configuration build systems the value of this variable is passed -as the value of preprocessor symbol "CMAKE_INTDIR" to the compilation +as the value of preprocessor symbol ``CMAKE_INTDIR`` to the compilation of all source files. diff --git a/Help/variable/CMAKE_CL_64.rst b/Help/variable/CMAKE_CL_64.rst index 5096829..a1e86a5 100644 --- a/Help/variable/CMAKE_CL_64.rst +++ b/Help/variable/CMAKE_CL_64.rst @@ -1,6 +1,6 @@ CMAKE_CL_64 ----------- -Using the 64 bit compiler from Microsoft +Using the 64-bit compiler from Microsoft -Set to true when using the 64 bit cl compiler from Microsoft. +Set to ``true`` when using the 64-bit ``cl`` compiler from Microsoft. diff --git a/Help/variable/CMAKE_COLOR_MAKEFILE.rst b/Help/variable/CMAKE_COLOR_MAKEFILE.rst index 170baf3..bb86ecc 100644 --- a/Help/variable/CMAKE_COLOR_MAKEFILE.rst +++ b/Help/variable/CMAKE_COLOR_MAKEFILE.rst @@ -1,7 +1,7 @@ CMAKE_COLOR_MAKEFILE -------------------- -Enables color output when using the Makefile generator. +Enables color output when using the :ref:`Makefile Generators`. When enabled, the generated Makefiles will produce colored output. -Default is ON. +Default is ``ON``. diff --git a/Help/variable/CMAKE_COMMAND.rst b/Help/variable/CMAKE_COMMAND.rst index f4e5f1e..f80b46c 100644 --- a/Help/variable/CMAKE_COMMAND.rst +++ b/Help/variable/CMAKE_COMMAND.rst @@ -1,8 +1,8 @@ CMAKE_COMMAND ------------- -The full path to the cmake executable. +The full path to the :manual:`cmake(1)` executable. -This is the full path to the CMake executable cmake which is useful -from custom commands that want to use the cmake -E option for portable -system commands. (e.g. /usr/local/bin/cmake +This is the full path to the CMake executable :manual:`cmake(1)` which is +useful from custom commands that want to use the ``cmake -E`` option for +portable system commands. (e.g. ``/usr/local/bin/cmake``) diff --git a/Help/variable/CMAKE_COMPILER_IS_GNULANG.rst b/Help/variable/CMAKE_COMPILER_IS_GNULANG.rst index bc5652f..4b652c0 100644 --- a/Help/variable/CMAKE_COMPILER_IS_GNULANG.rst +++ b/Help/variable/CMAKE_COMPILER_IS_GNULANG.rst @@ -3,10 +3,10 @@ CMAKE_COMPILER_IS_GNU True if the compiler is GNU. -If the selected compiler is the GNU compiler then this is TRUE, -if not it is FALSE. Unlike the other per-language variables, this +If the selected ```` compiler is the GNU compiler then this is ``TRUE``, +if not it is ``FALSE``. Unlike the other per-language variables, this uses the GNU syntax for identifying languages instead of the CMake -syntax. Recognized values of the suffix are: +syntax. Recognized values of the ```` suffix are: :: diff --git a/Help/variable/CMAKE_CONFIGURATION_TYPES.rst b/Help/variable/CMAKE_CONFIGURATION_TYPES.rst index 986b969..34e99eb 100644 --- a/Help/variable/CMAKE_CONFIGURATION_TYPES.rst +++ b/Help/variable/CMAKE_CONFIGURATION_TYPES.rst @@ -4,7 +4,7 @@ CMAKE_CONFIGURATION_TYPES Specifies the available build types on multi-config generators. This specifies what build types (configurations) will be available -such as Debug, Release, RelWithDebInfo etc. This has reasonable +such as ``Debug``, ``Release``, ``RelWithDebInfo`` etc. This has reasonable defaults on most platforms, but can be extended to provide other build -types. See also CMAKE_BUILD_TYPE for details of managing -configuration data, and CMAKE_CFG_INTDIR. +types. See also :variable:`CMAKE_BUILD_TYPE` for details of managing +configuration data, and :variable:`CMAKE_CFG_INTDIR`. diff --git a/Help/variable/CMAKE_CONFIG_POSTFIX.rst b/Help/variable/CMAKE_CONFIG_POSTFIX.rst index af38bed..e686a43 100644 --- a/Help/variable/CMAKE_CONFIG_POSTFIX.rst +++ b/Help/variable/CMAKE_CONFIG_POSTFIX.rst @@ -1,7 +1,7 @@ CMAKE__POSTFIX ---------------------- -Default filename postfix for libraries under configuration . +Default filename postfix for libraries under configuration ````. -When a non-executable target is created its _POSTFIX target -property is initialized with the value of this variable if it is set. +When a non-executable target is created its :prop_tgt:`_POSTFIX` +target property is initialized with the value of this variable if it is set. diff --git a/Help/variable/CMAKE_CTEST_COMMAND.rst b/Help/variable/CMAKE_CTEST_COMMAND.rst index d5dd2c3..b2942e2 100644 --- a/Help/variable/CMAKE_CTEST_COMMAND.rst +++ b/Help/variable/CMAKE_CTEST_COMMAND.rst @@ -1,8 +1,8 @@ CMAKE_CTEST_COMMAND ------------------- -Full path to ctest command installed with cmake. +Full path to :manual:`ctest(1)` command installed with CMake. -This is the full path to the CTest executable ctest which is useful -from custom commands that want to use the cmake -E option for portable -system commands. +This is the full path to the CTest executable :manual:`ctest(1)` which is +useful from custom commands that want to use the :manual:`cmake(1)` ``-E`` +option for portable system commands. diff --git a/Help/variable/CMAKE_CURRENT_BINARY_DIR.rst b/Help/variable/CMAKE_CURRENT_BINARY_DIR.rst index fb55a11..cc3b639 100644 --- a/Help/variable/CMAKE_CURRENT_BINARY_DIR.rst +++ b/Help/variable/CMAKE_CURRENT_BINARY_DIR.rst @@ -4,7 +4,7 @@ CMAKE_CURRENT_BINARY_DIR The path to the binary directory currently being processed. This the full path to the build directory that is currently being -processed by cmake. Each directory added by add_subdirectory will +processed by cmake. Each directory added by :command:`add_subdirectory` will create a binary directory in the build tree, and as it is being processed this variable will be set. For in-source builds this is the current source directory being processed. diff --git a/Help/variable/CMAKE_CURRENT_LIST_DIR.rst b/Help/variable/CMAKE_CURRENT_LIST_DIR.rst index b816821..ebc3ab9 100644 --- a/Help/variable/CMAKE_CURRENT_LIST_DIR.rst +++ b/Help/variable/CMAKE_CURRENT_LIST_DIR.rst @@ -5,8 +5,8 @@ Full directory of the listfile currently being processed. As CMake processes the listfiles in your project this variable will always be set to the directory where the listfile which is currently -being processed (CMAKE_CURRENT_LIST_FILE) is located. The value has -dynamic scope. When CMake starts processing commands in a source file +being processed (:variable:`CMAKE_CURRENT_LIST_FILE`) is located. The value +has dynamic scope. When CMake starts processing commands in a source file it sets this variable to the directory where this file is located. When CMake finishes processing commands from the file it restores the previous value. Therefore the value of the variable inside a macro or @@ -14,4 +14,4 @@ function is the directory of the file invoking the bottom-most entry on the call stack, not the directory of the file containing the macro or function definition. -See also CMAKE_CURRENT_LIST_FILE. +See also :variable:`CMAKE_CURRENT_LIST_FILE`. diff --git a/Help/variable/CMAKE_CURRENT_LIST_FILE.rst b/Help/variable/CMAKE_CURRENT_LIST_FILE.rst index 910d7b4..84b0eee 100644 --- a/Help/variable/CMAKE_CURRENT_LIST_FILE.rst +++ b/Help/variable/CMAKE_CURRENT_LIST_FILE.rst @@ -12,4 +12,4 @@ value. Therefore the value of the variable inside a macro or function is the file invoking the bottom-most entry on the call stack, not the file containing the macro or function definition. -See also CMAKE_PARENT_LIST_FILE. +See also :variable:`CMAKE_PARENT_LIST_FILE`. diff --git a/Help/variable/CMAKE_CXX_COMPILE_FEATURES.rst b/Help/variable/CMAKE_CXX_COMPILE_FEATURES.rst index f003227..5c59f95 100644 --- a/Help/variable/CMAKE_CXX_COMPILE_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_COMPILE_FEATURES.rst @@ -4,8 +4,8 @@ CMAKE_CXX_COMPILE_FEATURES List of features known to the C++ compiler These features are known to be available for use with the C++ compiler. This -list is a subset of the features listed in the :prop_gbl:`CMAKE_CXX_KNOWN_FEATURES` -global property. +list is a subset of the features listed in the +:prop_gbl:`CMAKE_CXX_KNOWN_FEATURES` global property. See the :manual:`cmake-compile-features(7)` manual for information on compile features and a list of supported compilers. diff --git a/Help/variable/CMAKE_CXX_EXTENSIONS.rst b/Help/variable/CMAKE_CXX_EXTENSIONS.rst index b14d753..4a92425 100644 --- a/Help/variable/CMAKE_CXX_EXTENSIONS.rst +++ b/Help/variable/CMAKE_CXX_EXTENSIONS.rst @@ -1,7 +1,7 @@ CMAKE_CXX_EXTENSIONS -------------------- -Default value for ``CXX_EXTENSIONS`` property of targets. +Default value for :prop_tgt:`CXX_EXTENSIONS` property of targets. This variable is used to initialize the :prop_tgt:`CXX_EXTENSIONS` property on all targets. See that target property for additional diff --git a/Help/variable/CMAKE_CXX_STANDARD.rst b/Help/variable/CMAKE_CXX_STANDARD.rst index 2bc4525..8a8bdff 100644 --- a/Help/variable/CMAKE_CXX_STANDARD.rst +++ b/Help/variable/CMAKE_CXX_STANDARD.rst @@ -1,7 +1,7 @@ CMAKE_CXX_STANDARD ------------------ -Default value for ``CXX_STANDARD`` property of targets. +Default value for :prop_tgt:`CXX_STANDARD` property of targets. This variable is used to initialize the :prop_tgt:`CXX_STANDARD` property on all targets. See that target property for additional diff --git a/Help/variable/CMAKE_CXX_STANDARD_REQUIRED.rst b/Help/variable/CMAKE_CXX_STANDARD_REQUIRED.rst index 14ffcd1..4c71058 100644 --- a/Help/variable/CMAKE_CXX_STANDARD_REQUIRED.rst +++ b/Help/variable/CMAKE_CXX_STANDARD_REQUIRED.rst @@ -1,7 +1,7 @@ CMAKE_CXX_STANDARD_REQUIRED --------------------------- -Default value for ``CXX_STANDARD_REQUIRED`` property of targets. +Default value for :prop_tgt:`CXX_STANDARD_REQUIRED` property of targets. This variable is used to initialize the :prop_tgt:`CXX_STANDARD_REQUIRED` property on all targets. See that target property for additional diff --git a/Help/variable/CMAKE_C_COMPILE_FEATURES.rst b/Help/variable/CMAKE_C_COMPILE_FEATURES.rst index df66eae..8d1eca0 100644 --- a/Help/variable/CMAKE_C_COMPILE_FEATURES.rst +++ b/Help/variable/CMAKE_C_COMPILE_FEATURES.rst @@ -4,8 +4,8 @@ CMAKE_C_COMPILE_FEATURES List of features known to the C compiler These features are known to be available for use with the C compiler. This -list is a subset of the features listed in the :prop_gbl:`CMAKE_C_KNOWN_FEATURES` -global property. +list is a subset of the features listed in the +:prop_gbl:`CMAKE_C_KNOWN_FEATURES` global property. See the :manual:`cmake-compile-features(7)` manual for information on compile features and a list of supported compilers. diff --git a/Help/variable/CMAKE_C_EXTENSIONS.rst b/Help/variable/CMAKE_C_EXTENSIONS.rst index 25bec12..fa510d4 100644 --- a/Help/variable/CMAKE_C_EXTENSIONS.rst +++ b/Help/variable/CMAKE_C_EXTENSIONS.rst @@ -1,7 +1,7 @@ CMAKE_C_EXTENSIONS ------------------ -Default value for ``C_EXTENSIONS`` property of targets. +Default value for :prop_tgt:`C_EXTENSIONS` property of targets. This variable is used to initialize the :prop_tgt:`C_EXTENSIONS` property on all targets. See that target property for additional diff --git a/Help/variable/CMAKE_C_STANDARD.rst b/Help/variable/CMAKE_C_STANDARD.rst index 2eb4e43..b55e00c 100644 --- a/Help/variable/CMAKE_C_STANDARD.rst +++ b/Help/variable/CMAKE_C_STANDARD.rst @@ -1,7 +1,7 @@ CMAKE_C_STANDARD ---------------- -Default value for ``C_STANDARD`` property of targets. +Default value for :prop_tgt:`C_STANDARD` property of targets. This variable is used to initialize the :prop_tgt:`C_STANDARD` property on all targets. See that target property for additional diff --git a/Help/variable/CMAKE_C_STANDARD_REQUIRED.rst b/Help/variable/CMAKE_C_STANDARD_REQUIRED.rst index 5e415da..7f70f6e 100644 --- a/Help/variable/CMAKE_C_STANDARD_REQUIRED.rst +++ b/Help/variable/CMAKE_C_STANDARD_REQUIRED.rst @@ -1,7 +1,7 @@ CMAKE_C_STANDARD_REQUIRED ------------------------- -Default value for ``C_STANDARD_REQUIRED`` property of targets. +Default value for :prop_tgt:`C_STANDARD_REQUIRED` property of targets. This variable is used to initialize the :prop_tgt:`C_STANDARD_REQUIRED` property on all targets. See that target property for additional diff --git a/Help/variable/CMAKE_DEBUG_POSTFIX.rst b/Help/variable/CMAKE_DEBUG_POSTFIX.rst index fde24b2..08577a5 100644 --- a/Help/variable/CMAKE_DEBUG_POSTFIX.rst +++ b/Help/variable/CMAKE_DEBUG_POSTFIX.rst @@ -1,7 +1,7 @@ CMAKE_DEBUG_POSTFIX ------------------- -See variable CMAKE__POSTFIX. +See variable :variable:`CMAKE__POSTFIX`. This variable is a special case of the more-general -CMAKE__POSTFIX variable for the DEBUG configuration. +:variable:`CMAKE__POSTFIX` variable for the `DEBUG` configuration. diff --git a/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst b/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst index e200b86..513276e 100644 --- a/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst +++ b/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst @@ -9,6 +9,6 @@ only be used when evaluating the :prop_tgt:`INCLUDE_DIRECTORIES`, :prop_tgt:`COMPILE_DEFINITIONS`, :prop_tgt:`COMPILE_OPTIONS`, :prop_tgt:`AUTOUIC_OPTIONS`, :prop_tgt:`SOURCES`, :prop_tgt:`COMPILE_FEATURES`, :prop_tgt:`POSITION_INDEPENDENT_CODE` target properties and any other property -listed in :prop_tgt:`COMPATIBLE_INTERFACE_STRING` and other ``COMPATIBLE_INTERFACE_`` -properties. It outputs an origin for each entry in the target property. -Default is unset. +listed in :prop_tgt:`COMPATIBLE_INTERFACE_STRING` and other +``COMPATIBLE_INTERFACE_`` properties. It outputs an origin for each entry in +the target property. Default is unset. diff --git a/Help/variable/CMAKE_DISABLE_FIND_PACKAGE_PackageName.rst b/Help/variable/CMAKE_DISABLE_FIND_PACKAGE_PackageName.rst index bcb277c..ed60020 100644 --- a/Help/variable/CMAKE_DISABLE_FIND_PACKAGE_PackageName.rst +++ b/Help/variable/CMAKE_DISABLE_FIND_PACKAGE_PackageName.rst @@ -1,10 +1,11 @@ CMAKE_DISABLE_FIND_PACKAGE_ ---------------------------------------- -Variable for disabling find_package() calls. +Variable for disabling :command:`find_package` calls. -Every non-REQUIRED find_package() call in a project can be disabled by -setting the variable CMAKE_DISABLE_FIND_PACKAGE_ to TRUE. +Every non-``REQUIRED`` :command:`find_package` call in a project can be +disabled by setting the variable +``CMAKE_DISABLE_FIND_PACKAGE_`` to ``TRUE``. This can be used to build a project without an optional package, although that package is installed. @@ -12,4 +13,4 @@ This switch should be used during the initial CMake run. Otherwise if the package has already been found in a previous CMake run, the variables which have been stored in the cache will still be there. In that case it is recommended to remove the cache variables for this -package from the cache using the cache editor or cmake -U +package from the cache using the cache editor or :manual:`cmake(1)` ``-U`` diff --git a/Help/variable/CMAKE_DL_LIBS.rst b/Help/variable/CMAKE_DL_LIBS.rst index cae4565..1fe7641 100644 --- a/Help/variable/CMAKE_DL_LIBS.rst +++ b/Help/variable/CMAKE_DL_LIBS.rst @@ -1,7 +1,7 @@ CMAKE_DL_LIBS ------------- -Name of library containing dlopen and dlcose. +Name of library containing ``dlopen`` and ``dlcose``. -The name of the library that has dlopen and dlclose in it, usually --ldl on most UNIX machines. +The name of the library that has ``dlopen`` and ``dlclose`` in it, usually +``-ldl`` on most UNIX machines. diff --git a/Help/variable/CMAKE_EDIT_COMMAND.rst b/Help/variable/CMAKE_EDIT_COMMAND.rst index 562aa0b..2f4ab1f 100644 --- a/Help/variable/CMAKE_EDIT_COMMAND.rst +++ b/Help/variable/CMAKE_EDIT_COMMAND.rst @@ -1,8 +1,8 @@ CMAKE_EDIT_COMMAND ------------------ -Full path to cmake-gui or ccmake. Defined only for Makefile generators -when not using an "extra" generator for an IDE. +Full path to :manual:`cmake-gui(1)` or :manual:`ccmake(1)`. Defined only for +:ref:`Makefile Generators` when not using an "extra" generator for an IDE. This is the full path to the CMake executable that can graphically -edit the cache. For example, cmake-gui or ccmake. +edit the cache. For example, :manual:`cmake-gui(1)` or :manual:`ccmake(1)`. diff --git a/Help/variable/CMAKE_ERROR_DEPRECATED.rst b/Help/variable/CMAKE_ERROR_DEPRECATED.rst index 68befc2..39dc4a8 100644 --- a/Help/variable/CMAKE_ERROR_DEPRECATED.rst +++ b/Help/variable/CMAKE_ERROR_DEPRECATED.rst @@ -3,9 +3,9 @@ CMAKE_ERROR_DEPRECATED Whether to issue deprecation errors for macros and functions. -If TRUE, this can be used by macros and functions to issue fatal +If ``TRUE``, this can be used by macros and functions to issue fatal errors when deprecated macros or functions are used. This variable is -FALSE by default. +``FALSE`` by default. These errors can be enabled with the ``-Werror=deprecated`` option, or disabled with the ``-Wno-error=deprecated`` option, when running diff --git a/Help/variable/CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION.rst b/Help/variable/CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION.rst index 651d68d..38e9b7b 100644 --- a/Help/variable/CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION.rst +++ b/Help/variable/CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION.rst @@ -1,9 +1,10 @@ CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION ------------------------------------------- -Ask cmake_install.cmake script to error out as soon as a file with absolute INSTALL DESTINATION is encountered. +Ask ``cmake_install.cmake`` script to error out as soon as a file with +absolute ``INSTALL DESTINATION`` is encountered. The fatal error is emitted before the installation of the offending file takes place. This variable is used by CMake-generated -cmake_install.cmake scripts. If one sets this variable to ON while +``cmake_install.cmake`` scripts. If one sets this variable to ``ON`` while running the script, it may get fatal error messages from the script. diff --git a/Help/variable/CMAKE_EXECUTABLE_SUFFIX.rst b/Help/variable/CMAKE_EXECUTABLE_SUFFIX.rst index 45c313c..356590f 100644 --- a/Help/variable/CMAKE_EXECUTABLE_SUFFIX.rst +++ b/Help/variable/CMAKE_EXECUTABLE_SUFFIX.rst @@ -3,7 +3,7 @@ CMAKE_EXECUTABLE_SUFFIX The suffix for executables on this platform. -The suffix to use for the end of an executable filename if any, .exe +The suffix to use for the end of an executable filename if any, ``.exe`` on Windows. -CMAKE_EXECUTABLE_SUFFIX_ overrides this for language . +``CMAKE_EXECUTABLE_SUFFIX_`` overrides this for language ````. diff --git a/Help/variable/CMAKE_EXE_LINKER_FLAGS_CONFIG.rst b/Help/variable/CMAKE_EXE_LINKER_FLAGS_CONFIG.rst index dcaf300..0cd8113 100644 --- a/Help/variable/CMAKE_EXE_LINKER_FLAGS_CONFIG.rst +++ b/Help/variable/CMAKE_EXE_LINKER_FLAGS_CONFIG.rst @@ -3,5 +3,5 @@ CMAKE_EXE_LINKER_FLAGS_ Flags to be used when linking an executable. -Same as CMAKE_C_FLAGS_* but used by the linker when creating +Same as ``CMAKE_C_FLAGS_*`` but used by the linker when creating executables. diff --git a/Help/variable/CMAKE_EXTRA_GENERATOR.rst b/Help/variable/CMAKE_EXTRA_GENERATOR.rst index 71aec92..4d513e4 100644 --- a/Help/variable/CMAKE_EXTRA_GENERATOR.rst +++ b/Help/variable/CMAKE_EXTRA_GENERATOR.rst @@ -1,9 +1,10 @@ CMAKE_EXTRA_GENERATOR --------------------- -The extra generator used to build the project. +The extra generator used to build the project. See +:manual:`cmake-generators(7)`. When using the Eclipse, CodeBlocks or KDevelop generators, CMake -generates Makefiles (CMAKE_GENERATOR) and additionally project files -for the respective IDE. This IDE project file generator is stored in -CMAKE_EXTRA_GENERATOR (e.g. "Eclipse CDT4"). +generates Makefiles (:variable:`CMAKE_GENERATOR`) and additionally project +files for the respective IDE. This IDE project file generator is stored in +``CMAKE_EXTRA_GENERATOR`` (e.g. ``Eclipse CDT4``). diff --git a/Help/variable/CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES.rst b/Help/variable/CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES.rst index 6187a7a..a130adb 100644 --- a/Help/variable/CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES.rst +++ b/Help/variable/CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES.rst @@ -4,6 +4,6 @@ CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES Additional suffixes for shared libraries. Extensions for shared libraries other than that specified by -CMAKE_SHARED_LIBRARY_SUFFIX, if any. CMake uses this to recognize +:variable:`CMAKE_SHARED_LIBRARY_SUFFIX`, if any. CMake uses this to recognize external shared library files during analysis of libraries linked by a target. diff --git a/Help/variable/CMAKE_FIND_LIBRARY_PREFIXES.rst b/Help/variable/CMAKE_FIND_LIBRARY_PREFIXES.rst index 1a9e7ce..58354b2 100644 --- a/Help/variable/CMAKE_FIND_LIBRARY_PREFIXES.rst +++ b/Help/variable/CMAKE_FIND_LIBRARY_PREFIXES.rst @@ -4,6 +4,6 @@ CMAKE_FIND_LIBRARY_PREFIXES Prefixes to prepend when looking for libraries. This specifies what prefixes to add to library names when the -find_library command looks for libraries. On UNIX systems this is -typically lib, meaning that when trying to find the foo library it -will look for libfoo. +:command:`find_library` command looks for libraries. On UNIX systems this is +typically ``lib``, meaning that when trying to find the ``foo`` library it +will look for ``libfoo``. diff --git a/Help/variable/CMAKE_FIND_LIBRARY_SUFFIXES.rst b/Help/variable/CMAKE_FIND_LIBRARY_SUFFIXES.rst index c533909..4a64e33 100644 --- a/Help/variable/CMAKE_FIND_LIBRARY_SUFFIXES.rst +++ b/Help/variable/CMAKE_FIND_LIBRARY_SUFFIXES.rst @@ -4,6 +4,6 @@ CMAKE_FIND_LIBRARY_SUFFIXES Suffixes to append when looking for libraries. This specifies what suffixes to add to library names when the -find_library command looks for libraries. On Windows systems this is -typically .lib and .dll, meaning that when trying to find the foo -library it will look for foo.dll etc. +:command:`find_library` command looks for libraries. On Windows systems this +is typically ``.lib`` and ``.dll``, meaning that when trying to find the +``foo`` library it will look for ``foo.dll`` etc. diff --git a/Help/variable/CMAKE_FIND_NO_INSTALL_PREFIX.rst b/Help/variable/CMAKE_FIND_NO_INSTALL_PREFIX.rst index 70d920b..c49d264 100644 --- a/Help/variable/CMAKE_FIND_NO_INSTALL_PREFIX.rst +++ b/Help/variable/CMAKE_FIND_NO_INSTALL_PREFIX.rst @@ -8,8 +8,8 @@ CMake adds the :variable:`CMAKE_INSTALL_PREFIX` and the :variable:`CMAKE_SYSTEM_PREFIX_PATH` by default. This variable may be set on the command line to control that behavior. -Set :variable:`CMAKE_FIND_NO_INSTALL_PREFIX` to TRUE to tell find_package not -to search in the :variable:`CMAKE_INSTALL_PREFIX` or -:variable:`CMAKE_STAGING_PREFIX` by default. Note that the +Set ``CMAKE_FIND_NO_INSTALL_PREFIX`` to ``TRUE`` to tell +:command:`find_package` not to search in the :variable:`CMAKE_INSTALL_PREFIX` +or :variable:`CMAKE_STAGING_PREFIX` by default. Note that the prefix may still be searched for other reasons, such as being the same prefix as the CMake installation, or for being a built-in system prefix. diff --git a/Help/variable/CMAKE_FIND_PACKAGE_WARN_NO_MODULE.rst b/Help/variable/CMAKE_FIND_PACKAGE_WARN_NO_MODULE.rst index 5d7599c..f1116bb 100644 --- a/Help/variable/CMAKE_FIND_PACKAGE_WARN_NO_MODULE.rst +++ b/Help/variable/CMAKE_FIND_PACKAGE_WARN_NO_MODULE.rst @@ -1,19 +1,19 @@ CMAKE_FIND_PACKAGE_WARN_NO_MODULE --------------------------------- -Tell find_package to warn if called without an explicit mode. +Tell :command:`find_package` to warn if called without an explicit mode. -If find_package is called without an explicit mode option (MODULE, -CONFIG or NO_MODULE) and no Find.cmake module is in -CMAKE_MODULE_PATH then CMake implicitly assumes that the caller -intends to search for a package configuration file. If no package +If :command:`find_package` is called without an explicit mode option +(``MODULE``, ``CONFIG``, or ``NO_MODULE``) and no ``Find.cmake`` module +is in :variable:`CMAKE_MODULE_PATH` then CMake implicitly assumes that the +caller intends to search for a package configuration file. If no package configuration file is found then the wording of the failure message must account for both the case that the package is really missing and the case that the project has a bug and failed to provide the intended Find module. If instead the caller specifies an explicit mode option then the failure message can be more specific. -Set CMAKE_FIND_PACKAGE_WARN_NO_MODULE to TRUE to tell find_package to -warn when it implicitly assumes Config mode. This helps developers -enforce use of an explicit mode in all calls to find_package within a -project. +Set ``CMAKE_FIND_PACKAGE_WARN_NO_MODULE`` to ``TRUE`` to tell +:command:`find_package` to warn when it implicitly assumes Config mode. This +helps developers enforce use of an explicit mode in all calls to +:command:`find_package` within a project. diff --git a/Help/variable/CMAKE_FIND_ROOT_PATH.rst b/Help/variable/CMAKE_FIND_ROOT_PATH.rst index ccf5234..ba2cf31 100644 --- a/Help/variable/CMAKE_FIND_ROOT_PATH.rst +++ b/Help/variable/CMAKE_FIND_ROOT_PATH.rst @@ -4,5 +4,5 @@ CMAKE_FIND_ROOT_PATH :ref:`;-list ` of root paths to search on the filesystem. This variable is most useful when cross-compiling. CMake uses the paths in -this list as alternative roots to find filesystem items with :command:`find_package`, -:command:`find_library` etc. +this list as alternative roots to find filesystem items with +:command:`find_package`, :command:`find_library` etc. diff --git a/Help/variable/CMAKE_Fortran_FORMAT.rst b/Help/variable/CMAKE_Fortran_FORMAT.rst index c0e971c..1406e59 100644 --- a/Help/variable/CMAKE_Fortran_FORMAT.rst +++ b/Help/variable/CMAKE_Fortran_FORMAT.rst @@ -1,7 +1,7 @@ CMAKE_Fortran_FORMAT -------------------- -Set to FIXED or FREE to indicate the Fortran source layout. +Set to ``FIXED`` or ``FREE`` to indicate the Fortran source layout. -This variable is used to initialize the Fortran_FORMAT property on all -the targets. See that target property for additional information. +This variable is used to initialize the :prop_tgt:`Fortran_FORMAT` property on +all the targets. See that target property for additional information. diff --git a/Help/variable/CMAKE_Fortran_MODDIR_DEFAULT.rst b/Help/variable/CMAKE_Fortran_MODDIR_DEFAULT.rst index a8dfcdf..5aeab07 100644 --- a/Help/variable/CMAKE_Fortran_MODDIR_DEFAULT.rst +++ b/Help/variable/CMAKE_Fortran_MODDIR_DEFAULT.rst @@ -3,6 +3,6 @@ CMAKE_Fortran_MODDIR_DEFAULT Fortran default module output directory. -Most Fortran compilers write .mod files to the current working -directory. For those that do not, this is set to "." and used when -the Fortran_MODULE_DIRECTORY target property is not set. +Most Fortran compilers write ``.mod`` files to the current working +directory. For those that do not, this is set to ``.`` and used when +the :prop_tgt:`Fortran_MODULE_DIRECTORY` target property is not set. diff --git a/Help/variable/CMAKE_Fortran_MODDIR_FLAG.rst b/Help/variable/CMAKE_Fortran_MODDIR_FLAG.rst index 4b32df3..1da55ca 100644 --- a/Help/variable/CMAKE_Fortran_MODDIR_FLAG.rst +++ b/Help/variable/CMAKE_Fortran_MODDIR_FLAG.rst @@ -4,4 +4,4 @@ CMAKE_Fortran_MODDIR_FLAG Fortran flag for module output directory. This stores the flag needed to pass the value of the -Fortran_MODULE_DIRECTORY target property to the compiler. +:prop_tgt:`Fortran_MODULE_DIRECTORY` target property to the compiler. diff --git a/Help/variable/CMAKE_Fortran_MODOUT_FLAG.rst b/Help/variable/CMAKE_Fortran_MODOUT_FLAG.rst index a232213..2f83880 100644 --- a/Help/variable/CMAKE_Fortran_MODOUT_FLAG.rst +++ b/Help/variable/CMAKE_Fortran_MODOUT_FLAG.rst @@ -3,5 +3,5 @@ CMAKE_Fortran_MODOUT_FLAG Fortran flag to enable module output. -Most Fortran compilers write .mod files out by default. For others, +Most Fortran compilers write ``.mod`` files out by default. For others, this stores the flag needed to enable module output. diff --git a/Help/variable/CMAKE_Fortran_MODULE_DIRECTORY.rst b/Help/variable/CMAKE_Fortran_MODULE_DIRECTORY.rst index b1d49d8..3c7edc1 100644 --- a/Help/variable/CMAKE_Fortran_MODULE_DIRECTORY.rst +++ b/Help/variable/CMAKE_Fortran_MODULE_DIRECTORY.rst @@ -3,6 +3,6 @@ CMAKE_Fortran_MODULE_DIRECTORY Fortran module output directory. -This variable is used to initialize the Fortran_MODULE_DIRECTORY +This variable is used to initialize the :prop_tgt:`Fortran_MODULE_DIRECTORY` property on all the targets. See that target property for additional information. diff --git a/Help/variable/CMAKE_GENERATOR.rst b/Help/variable/CMAKE_GENERATOR.rst index a4e70a5..3f6ebc1 100644 --- a/Help/variable/CMAKE_GENERATOR.rst +++ b/Help/variable/CMAKE_GENERATOR.rst @@ -1,7 +1,7 @@ CMAKE_GENERATOR --------------- -The generator used to build the project. +The generator used to build the project. See :manual:`cmake-generators(7)`. The name of the generator that is being used to generate the build -files. (e.g. "Unix Makefiles", "Visual Studio 6", etc.) +files. (e.g. ``Unix Makefiles``, ``Visual Studio 6``, etc.) diff --git a/Help/variable/CMAKE_GENERATOR_PLATFORM.rst b/Help/variable/CMAKE_GENERATOR_PLATFORM.rst index 5559eb7..a5c284a 100644 --- a/Help/variable/CMAKE_GENERATOR_PLATFORM.rst +++ b/Help/variable/CMAKE_GENERATOR_PLATFORM.rst @@ -5,8 +5,8 @@ Generator-specific target platform name specified by user. Some CMake generators support a target platform name to be given to the native build system to choose a compiler toolchain. -If the user specifies a platform name (e.g. via the cmake -A option) -the value will be available in this variable. +If the user specifies a platform name (e.g. via the :manual:`cmake(1)` ``-A`` +option) the value will be available in this variable. The value of this variable should never be modified by project code. A toolchain file specified by the :variable:`CMAKE_TOOLCHAIN_FILE` diff --git a/Help/variable/CMAKE_GENERATOR_TOOLSET.rst b/Help/variable/CMAKE_GENERATOR_TOOLSET.rst index 9ccc8b3..89abe54 100644 --- a/Help/variable/CMAKE_GENERATOR_TOOLSET.rst +++ b/Help/variable/CMAKE_GENERATOR_TOOLSET.rst @@ -5,8 +5,8 @@ Native build system toolset name specified by user. Some CMake generators support a toolset name to be given to the native build system to choose a compiler. If the user specifies a toolset -name (e.g. via the cmake -T option) the value will be available in -this variable. +name (e.g. via the :manual:`cmake(1)` ``-T`` option) the value will be +available in this variable. The value of this variable should never be modified by project code. A toolchain file specified by the :variable:`CMAKE_TOOLCHAIN_FILE` diff --git a/Help/variable/CMAKE_GNUtoMS.rst b/Help/variable/CMAKE_GNUtoMS.rst index e253f59..9c0f59e 100644 --- a/Help/variable/CMAKE_GNUtoMS.rst +++ b/Help/variable/CMAKE_GNUtoMS.rst @@ -1,8 +1,8 @@ CMAKE_GNUtoMS ------------- -Convert GNU import libraries (.dll.a) to MS format (.lib). +Convert GNU import libraries (``.dll.a``) to MS format (``.lib``). -This variable is used to initialize the GNUtoMS property on targets -when they are created. See that target property for additional +This variable is used to initialize the :prop_tgt:`GNUtoMS` property on +targets when they are created. See that target property for additional information. diff --git a/Help/variable/CMAKE_HOST_APPLE.rst b/Help/variable/CMAKE_HOST_APPLE.rst index d4b8483..ac7b030 100644 --- a/Help/variable/CMAKE_HOST_APPLE.rst +++ b/Help/variable/CMAKE_HOST_APPLE.rst @@ -1,6 +1,6 @@ CMAKE_HOST_APPLE ---------------- -True for Apple OS X operating systems. +``True`` for Apple OS X operating systems. -Set to true when the host system is Apple OS X. +Set to ``true`` when the host system is Apple OS X. diff --git a/Help/variable/CMAKE_HOST_SYSTEM_NAME.rst b/Help/variable/CMAKE_HOST_SYSTEM_NAME.rst index a221de9..e5e6f67 100644 --- a/Help/variable/CMAKE_HOST_SYSTEM_NAME.rst +++ b/Help/variable/CMAKE_HOST_SYSTEM_NAME.rst @@ -4,5 +4,5 @@ CMAKE_HOST_SYSTEM_NAME Name of the OS CMake is running on. On systems that have the uname command, this variable is set to the -output of uname -s. ``Linux``, ``Windows``, and ``Darwin`` for Mac OS X +output of ``uname -s``. ``Linux``, ``Windows``, and ``Darwin`` for Mac OS X are the values found on the big three operating systems. diff --git a/Help/variable/CMAKE_HOST_SYSTEM_PROCESSOR.rst b/Help/variable/CMAKE_HOST_SYSTEM_PROCESSOR.rst index 790565a..ba8a850 100644 --- a/Help/variable/CMAKE_HOST_SYSTEM_PROCESSOR.rst +++ b/Help/variable/CMAKE_HOST_SYSTEM_PROCESSOR.rst @@ -3,6 +3,6 @@ CMAKE_HOST_SYSTEM_PROCESSOR The name of the CPU CMake is running on. -On systems that support uname, this variable is set to the output of -uname -p, on windows it is set to the value of the environment variable +On systems that support ``uname``, this variable is set to the output of +``uname -p``. On Windows it is set to the value of the environment variable ``PROCESSOR_ARCHITECTURE``. diff --git a/Help/variable/CMAKE_HOST_SYSTEM_VERSION.rst b/Help/variable/CMAKE_HOST_SYSTEM_VERSION.rst index e7e0052..ed23070 100644 --- a/Help/variable/CMAKE_HOST_SYSTEM_VERSION.rst +++ b/Help/variable/CMAKE_HOST_SYSTEM_VERSION.rst @@ -4,5 +4,5 @@ CMAKE_HOST_SYSTEM_VERSION The OS version CMake is running on. A numeric version string for the system. On systems that support -uname, this variable is set to the output of uname -r. On other +``uname``, this variable is set to the output of ``uname -r``. On other systems this is set to major-minor version numbers. diff --git a/Help/variable/CMAKE_HOST_UNIX.rst b/Help/variable/CMAKE_HOST_UNIX.rst index bbefba7..817a957 100644 --- a/Help/variable/CMAKE_HOST_UNIX.rst +++ b/Help/variable/CMAKE_HOST_UNIX.rst @@ -1,7 +1,7 @@ CMAKE_HOST_UNIX --------------- -True for UNIX and UNIX like operating systems. +``True`` for UNIX and UNIX like operating systems. -Set to true when the host system is UNIX or UNIX like (i.e. APPLE and +Set to ``true`` when the host system is UNIX or UNIX like (i.e. APPLE and CYGWIN). diff --git a/Help/variable/CMAKE_HOST_WIN32.rst b/Help/variable/CMAKE_HOST_WIN32.rst index 92ee456..0e4c891 100644 --- a/Help/variable/CMAKE_HOST_WIN32.rst +++ b/Help/variable/CMAKE_HOST_WIN32.rst @@ -1,6 +1,6 @@ CMAKE_HOST_WIN32 ---------------- -True on windows systems, including win64. +``True`` on Windows systems, including Win64. -Set to true when the host system is Windows and on Cygwin. +Set to ``true`` when the host system is Windows and on Cygwin. diff --git a/Help/variable/CMAKE_IMPORT_LIBRARY_PREFIX.rst b/Help/variable/CMAKE_IMPORT_LIBRARY_PREFIX.rst index 1d16a37..1561a1d 100644 --- a/Help/variable/CMAKE_IMPORT_LIBRARY_PREFIX.rst +++ b/Help/variable/CMAKE_IMPORT_LIBRARY_PREFIX.rst @@ -6,4 +6,4 @@ The prefix for import libraries that you link to. The prefix to use for the name of an import library if used on this platform. -CMAKE_IMPORT_LIBRARY_PREFIX_ overrides this for language . +``CMAKE_IMPORT_LIBRARY_PREFIX_`` overrides this for language ````. diff --git a/Help/variable/CMAKE_IMPORT_LIBRARY_SUFFIX.rst b/Help/variable/CMAKE_IMPORT_LIBRARY_SUFFIX.rst index c16825e..11aeab7 100644 --- a/Help/variable/CMAKE_IMPORT_LIBRARY_SUFFIX.rst +++ b/Help/variable/CMAKE_IMPORT_LIBRARY_SUFFIX.rst @@ -6,4 +6,4 @@ The suffix for import libraries that you link to. The suffix to use for the end of an import library filename if used on this platform. -CMAKE_IMPORT_LIBRARY_SUFFIX_ overrides this for language . +``CMAKE_IMPORT_LIBRARY_SUFFIX_`` overrides this for language ````. diff --git a/Help/variable/CMAKE_INCLUDE_CURRENT_DIR.rst b/Help/variable/CMAKE_INCLUDE_CURRENT_DIR.rst index 79f3952..6eea322 100644 --- a/Help/variable/CMAKE_INCLUDE_CURRENT_DIR.rst +++ b/Help/variable/CMAKE_INCLUDE_CURRENT_DIR.rst @@ -3,11 +3,11 @@ CMAKE_INCLUDE_CURRENT_DIR Automatically add the current source- and build directories to the include path. -If this variable is enabled, CMake automatically adds in each -directory ${CMAKE_CURRENT_SOURCE_DIR} and ${CMAKE_CURRENT_BINARY_DIR} -to the include path for this directory. These additional include +If this variable is enabled, CMake automatically adds +:variable:`CMAKE_CURRENT_SOURCE_DIR` and :variable:`CMAKE_CURRENT_BINARY_DIR` +to the include path for each directory. These additional include directories do not propagate down to subdirectories. This is useful mainly for out-of-source builds, where files generated into the build tree are included by files located in the source tree. -By default CMAKE_INCLUDE_CURRENT_DIR is OFF. +By default ``CMAKE_INCLUDE_CURRENT_DIR`` is ``OFF``. diff --git a/Help/variable/CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE.rst b/Help/variable/CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE.rst index 948db50..5fc95f0 100644 --- a/Help/variable/CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE.rst +++ b/Help/variable/CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE.rst @@ -1,10 +1,12 @@ CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE -------------------------------------- -Automatically add the current source- and build directories to the INTERFACE_INCLUDE_DIRECTORIES. +Automatically add the current source- and build directories to the +:prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` target property. If this variable is enabled, CMake automatically adds for each shared library target, static library target, module target and executable -target, ${CMAKE_CURRENT_SOURCE_DIR} and ${CMAKE_CURRENT_BINARY_DIR} to -the INTERFACE_INCLUDE_DIRECTORIES.By default -CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE is OFF. +target, :variable:`CMAKE_CURRENT_SOURCE_DIR` and +:variable:`CMAKE_CURRENT_BINARY_DIR` to +the :prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` target property. By default +``CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE`` is ``OFF``. diff --git a/Help/variable/CMAKE_INCLUDE_DIRECTORIES_BEFORE.rst b/Help/variable/CMAKE_INCLUDE_DIRECTORIES_BEFORE.rst index 3c1fbcf..e0f2a2e 100644 --- a/Help/variable/CMAKE_INCLUDE_DIRECTORIES_BEFORE.rst +++ b/Help/variable/CMAKE_INCLUDE_DIRECTORIES_BEFORE.rst @@ -1,8 +1,9 @@ CMAKE_INCLUDE_DIRECTORIES_BEFORE -------------------------------- -Whether to append or prepend directories by default in :command:`include_directories`. +Whether to append or prepend directories by default in +:command:`include_directories`. This variable affects the default behavior of the :command:`include_directories` -command. Setting this variable to 'ON' is equivalent to using the BEFORE option -in all uses of that command. +command. Setting this variable to ``ON`` is equivalent to using the ``BEFORE`` +option in all uses of that command. diff --git a/Help/variable/CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE.rst b/Help/variable/CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE.rst index cbd04d7..37d0a3d 100644 --- a/Help/variable/CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE.rst +++ b/Help/variable/CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE.rst @@ -4,5 +4,5 @@ CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE Whether to force prepending of project include directories. This variable affects the order of include directories generated in compiler -command lines. If set to 'ON', it causes the :variable:`CMAKE_SOURCE_DIR` and -the :variable:`CMAKE_BINARY_DIR` to appear first. +command lines. If set to ``ON``, it causes the :variable:`CMAKE_SOURCE_DIR` +and the :variable:`CMAKE_BINARY_DIR` to appear first. diff --git a/Help/variable/CMAKE_INSTALL_DEFAULT_COMPONENT_NAME.rst b/Help/variable/CMAKE_INSTALL_DEFAULT_COMPONENT_NAME.rst index 2ad0689..57160f1 100644 --- a/Help/variable/CMAKE_INSTALL_DEFAULT_COMPONENT_NAME.rst +++ b/Help/variable/CMAKE_INSTALL_DEFAULT_COMPONENT_NAME.rst @@ -1,9 +1,9 @@ CMAKE_INSTALL_DEFAULT_COMPONENT_NAME ------------------------------------ -Default component used in install() commands. +Default component used in :command:`install` commands. -If an install() command is used without the COMPONENT argument, these -files will be grouped into a default component. The name of this +If an :command:`install` command is used without the ``COMPONENT`` argument, +these files will be grouped into a default component. The name of this default install component will be taken from this variable. It -defaults to "Unspecified". +defaults to ``Unspecified``. diff --git a/Help/variable/CMAKE_INSTALL_NAME_DIR.rst b/Help/variable/CMAKE_INSTALL_NAME_DIR.rst index 540df6b..961d712 100644 --- a/Help/variable/CMAKE_INSTALL_NAME_DIR.rst +++ b/Help/variable/CMAKE_INSTALL_NAME_DIR.rst @@ -3,6 +3,6 @@ CMAKE_INSTALL_NAME_DIR Mac OS X directory name for installed targets. -CMAKE_INSTALL_NAME_DIR is used to initialize the INSTALL_NAME_DIR -property on all targets. See that target property for more -information. +``CMAKE_INSTALL_NAME_DIR`` is used to initialize the +:prop_tgt:`INSTALL_NAME_DIR` property on all targets. See that target +property for more information. diff --git a/Help/variable/CMAKE_INSTALL_PREFIX.rst b/Help/variable/CMAKE_INSTALL_PREFIX.rst index ee9b615..3f3347f 100644 --- a/Help/variable/CMAKE_INSTALL_PREFIX.rst +++ b/Help/variable/CMAKE_INSTALL_PREFIX.rst @@ -1,14 +1,14 @@ CMAKE_INSTALL_PREFIX -------------------- -Install directory used by install. +Install directory used by :command:`install`. -If "make install" is invoked or INSTALL is built, this directory is +If ``make install`` is invoked or ``INSTALL`` is built, this directory is prepended onto all install directories. This variable defaults to -/usr/local on UNIX and c:/Program Files on Windows. +``/usr/local`` on UNIX and ``c:/Program Files`` on Windows. -On UNIX one can use the DESTDIR mechanism in order to relocate the -whole installation. DESTDIR means DESTination DIRectory. It is +On UNIX one can use the ``DESTDIR`` mechanism in order to relocate the +whole installation. ``DESTDIR`` means DESTination DIRectory. It is commonly used by makefile users in order to install software at non-default location. It is usually invoked like this: @@ -17,16 +17,17 @@ non-default location. It is usually invoked like this: make DESTDIR=/home/john install which will install the concerned software using the installation -prefix, e.g. "/usr/local" prepended with the DESTDIR value which -finally gives "/home/john/usr/local". +prefix, e.g. ``/usr/local`` prepended with the ``DESTDIR`` value which +finally gives ``/home/john/usr/local``. -WARNING: DESTDIR may not be used on Windows because installation -prefix usually contains a drive letter like in "C:/Program Files" +WARNING: ``DESTDIR`` may not be used on Windows because installation +prefix usually contains a drive letter like in ``C:/Program Files`` which cannot be prepended with some other prefix. -The installation prefix is also added to CMAKE_SYSTEM_PREFIX_PATH so -that find_package, find_program, find_library, find_path, and -find_file will search the prefix for other software. +The installation prefix is also added to :variable:`CMAKE_SYSTEM_PREFIX_PATH` +so that :command:`find_package`, :command:`find_program`, +:command:`find_library`, :command:`find_path`, and :command:`find_file` +will search the prefix for other software. .. note:: diff --git a/Help/variable/CMAKE_INSTALL_RPATH.rst b/Help/variable/CMAKE_INSTALL_RPATH.rst index 0992d57..813d1e0 100644 --- a/Help/variable/CMAKE_INSTALL_RPATH.rst +++ b/Help/variable/CMAKE_INSTALL_RPATH.rst @@ -5,4 +5,4 @@ The rpath to use for installed targets. A semicolon-separated list specifying the rpath to use in installed targets (for platforms that support it). This is used to initialize -the target property INSTALL_RPATH for all targets. +the target property :prop_tgt:`INSTALL_RPATH` for all targets. diff --git a/Help/variable/CMAKE_INSTALL_RPATH_USE_LINK_PATH.rst b/Help/variable/CMAKE_INSTALL_RPATH_USE_LINK_PATH.rst index 9277a3b..78148d5 100644 --- a/Help/variable/CMAKE_INSTALL_RPATH_USE_LINK_PATH.rst +++ b/Help/variable/CMAKE_INSTALL_RPATH_USE_LINK_PATH.rst @@ -3,7 +3,7 @@ CMAKE_INSTALL_RPATH_USE_LINK_PATH Add paths to linker search and installed rpath. -CMAKE_INSTALL_RPATH_USE_LINK_PATH is a boolean that if set to true +``CMAKE_INSTALL_RPATH_USE_LINK_PATH`` is a boolean that if set to ``true`` will append directories in the linker search path and outside the -project to the INSTALL_RPATH. This is used to initialize the target -property INSTALL_RPATH_USE_LINK_PATH for all targets. +project to the :prop_tgt:`INSTALL_RPATH`. This is used to initialize the +target property :prop_tgt:`INSTALL_RPATH_USE_LINK_PATH` for all targets. diff --git a/Help/variable/CMAKE_LANG_ARCHIVE_APPEND.rst b/Help/variable/CMAKE_LANG_ARCHIVE_APPEND.rst index 2c3abae..ab4ad71 100644 --- a/Help/variable/CMAKE_LANG_ARCHIVE_APPEND.rst +++ b/Help/variable/CMAKE_LANG_ARCHIVE_APPEND.rst @@ -4,6 +4,7 @@ CMAKE__ARCHIVE_APPEND Rule variable to append to a static archive. This is a rule variable that tells CMake how to append to a static -archive. It is used in place of CMAKE__CREATE_STATIC_LIBRARY on -some platforms in order to support large object counts. See also -CMAKE__ARCHIVE_CREATE and CMAKE__ARCHIVE_FINISH. +archive. It is used in place of :variable:`CMAKE__CREATE_STATIC_LIBRARY` +on some platforms in order to support large object counts. See also +:variable:`CMAKE__ARCHIVE_CREATE` and +:variable:`CMAKE__ARCHIVE_FINISH`. diff --git a/Help/variable/CMAKE_LANG_ARCHIVE_CREATE.rst b/Help/variable/CMAKE_LANG_ARCHIVE_CREATE.rst index f93dd11..fc295af 100644 --- a/Help/variable/CMAKE_LANG_ARCHIVE_CREATE.rst +++ b/Help/variable/CMAKE_LANG_ARCHIVE_CREATE.rst @@ -4,6 +4,7 @@ CMAKE__ARCHIVE_CREATE Rule variable to create a new static archive. This is a rule variable that tells CMake how to create a static -archive. It is used in place of CMAKE__CREATE_STATIC_LIBRARY on -some platforms in order to support large object counts. See also -CMAKE__ARCHIVE_APPEND and CMAKE__ARCHIVE_FINISH. +archive. It is used in place of :variable:`CMAKE__CREATE_STATIC_LIBRARY` +on some platforms in order to support large object counts. See also +:variable:`CMAKE__ARCHIVE_APPEND` and +:variable:`CMAKE__ARCHIVE_FINISH`. diff --git a/Help/variable/CMAKE_LANG_ARCHIVE_FINISH.rst b/Help/variable/CMAKE_LANG_ARCHIVE_FINISH.rst index fff4128..1bb5d65 100644 --- a/Help/variable/CMAKE_LANG_ARCHIVE_FINISH.rst +++ b/Help/variable/CMAKE_LANG_ARCHIVE_FINISH.rst @@ -4,6 +4,7 @@ CMAKE__ARCHIVE_FINISH Rule variable to finish an existing static archive. This is a rule variable that tells CMake how to finish a static -archive. It is used in place of CMAKE__CREATE_STATIC_LIBRARY on -some platforms in order to support large object counts. See also -CMAKE__ARCHIVE_CREATE and CMAKE__ARCHIVE_APPEND. +archive. It is used in place of :variable:`CMAKE__CREATE_STATIC_LIBRARY` +on some platforms in order to support large object counts. See also +:variable:`CMAKE__ARCHIVE_CREATE` and +:variable:`CMAKE__ARCHIVE_APPEND`. diff --git a/Help/variable/CMAKE_LANG_COMPILER.rst b/Help/variable/CMAKE_LANG_COMPILER.rst index fffc347..89df495 100644 --- a/Help/variable/CMAKE_LANG_COMPILER.rst +++ b/Help/variable/CMAKE_LANG_COMPILER.rst @@ -1,7 +1,7 @@ CMAKE__COMPILER --------------------- -The full path to the compiler for LANG. +The full path to the compiler for ``LANG``. -This is the command that will be used as the compiler. Once +This is the command that will be used as the ```` compiler. Once set, you can not change this variable. diff --git a/Help/variable/CMAKE_LANG_COMPILER_EXTERNAL_TOOLCHAIN.rst b/Help/variable/CMAKE_LANG_COMPILER_EXTERNAL_TOOLCHAIN.rst index 033998d..8bb7cc0 100644 --- a/Help/variable/CMAKE_LANG_COMPILER_EXTERNAL_TOOLCHAIN.rst +++ b/Help/variable/CMAKE_LANG_COMPILER_EXTERNAL_TOOLCHAIN.rst @@ -5,9 +5,9 @@ The external toolchain for cross-compiling, if supported. Some compiler toolchains do not ship their own auxilliary utilities such as archivers and linkers. The compiler driver may support a command-line argument -to specify the location of such tools. CMAKE__COMPILER_EXTERNAL_TOOLCHAIN -may be set to a path to a path to the external toolchain and will be passed -to the compiler driver if supported. +to specify the location of such tools. +``CMAKE__COMPILER_EXTERNAL_TOOLCHAIN`` may be set to a path to a path to +the external toolchain and will be passed to the compiler driver if supported. This variable may only be set in a toolchain file specified by the :variable:`CMAKE_TOOLCHAIN_FILE` variable. diff --git a/Help/variable/CMAKE_LANG_COMPILER_LOADED.rst b/Help/variable/CMAKE_LANG_COMPILER_LOADED.rst index 3b8e9aa..9308878 100644 --- a/Help/variable/CMAKE_LANG_COMPILER_LOADED.rst +++ b/Help/variable/CMAKE_LANG_COMPILER_LOADED.rst @@ -3,5 +3,5 @@ CMAKE__COMPILER_LOADED Defined to true if the language is enabled. -When language is enabled by project() or enable_language() this -variable is defined to 1. +When language ```` is enabled by :command:`project` or +:command:`enable_language` this variable is defined to ``1``. diff --git a/Help/variable/CMAKE_LANG_COMPILE_OBJECT.rst b/Help/variable/CMAKE_LANG_COMPILE_OBJECT.rst index f43ed6d..ba59cad 100644 --- a/Help/variable/CMAKE_LANG_COMPILE_OBJECT.rst +++ b/Help/variable/CMAKE_LANG_COMPILE_OBJECT.rst @@ -4,4 +4,4 @@ CMAKE__COMPILE_OBJECT Rule variable to compile a single object file. This is a rule variable that tells CMake how to compile a single -object file for the language . +object file for the language ````. diff --git a/Help/variable/CMAKE_LANG_CREATE_SHARED_LIBRARY.rst b/Help/variable/CMAKE_LANG_CREATE_SHARED_LIBRARY.rst index adf1624..be89f85 100644 --- a/Help/variable/CMAKE_LANG_CREATE_SHARED_LIBRARY.rst +++ b/Help/variable/CMAKE_LANG_CREATE_SHARED_LIBRARY.rst @@ -4,4 +4,4 @@ CMAKE__CREATE_SHARED_LIBRARY Rule variable to create a shared library. This is a rule variable that tells CMake how to create a shared -library for the language . +library for the language ````. diff --git a/Help/variable/CMAKE_LANG_CREATE_SHARED_MODULE.rst b/Help/variable/CMAKE_LANG_CREATE_SHARED_MODULE.rst index 406b4da..ae5f69d 100644 --- a/Help/variable/CMAKE_LANG_CREATE_SHARED_MODULE.rst +++ b/Help/variable/CMAKE_LANG_CREATE_SHARED_MODULE.rst @@ -4,4 +4,4 @@ CMAKE__CREATE_SHARED_MODULE Rule variable to create a shared module. This is a rule variable that tells CMake how to create a shared -library for the language . +library for the language ````. diff --git a/Help/variable/CMAKE_LANG_CREATE_STATIC_LIBRARY.rst b/Help/variable/CMAKE_LANG_CREATE_STATIC_LIBRARY.rst index 8114432..0cff200 100644 --- a/Help/variable/CMAKE_LANG_CREATE_STATIC_LIBRARY.rst +++ b/Help/variable/CMAKE_LANG_CREATE_STATIC_LIBRARY.rst @@ -4,4 +4,4 @@ CMAKE__CREATE_STATIC_LIBRARY Rule variable to create a static library. This is a rule variable that tells CMake how to create a static -library for the language . +library for the language ````. diff --git a/Help/variable/CMAKE_LANG_FLAGS.rst b/Help/variable/CMAKE_LANG_FLAGS.rst index 6aa0a3e..c57d92c 100644 --- a/Help/variable/CMAKE_LANG_FLAGS.rst +++ b/Help/variable/CMAKE_LANG_FLAGS.rst @@ -3,4 +3,4 @@ CMAKE__FLAGS Flags for all build types. - flags used regardless of the value of CMAKE_BUILD_TYPE. +```` flags used regardless of the value of :variable:`CMAKE_BUILD_TYPE`. diff --git a/Help/variable/CMAKE_LANG_FLAGS_DEBUG.rst b/Help/variable/CMAKE_LANG_FLAGS_DEBUG.rst index a727641..a233d4a 100644 --- a/Help/variable/CMAKE_LANG_FLAGS_DEBUG.rst +++ b/Help/variable/CMAKE_LANG_FLAGS_DEBUG.rst @@ -1,6 +1,6 @@ CMAKE__FLAGS_DEBUG ------------------------ -Flags for Debug build type or configuration. +Flags for ``Debug`` build type or configuration. - flags used when CMAKE_BUILD_TYPE is Debug. +```` flags used when :variable:`CMAKE_BUILD_TYPE` is ``Debug``. diff --git a/Help/variable/CMAKE_LANG_FLAGS_MINSIZEREL.rst b/Help/variable/CMAKE_LANG_FLAGS_MINSIZEREL.rst index fbb8516..a9436c1 100644 --- a/Help/variable/CMAKE_LANG_FLAGS_MINSIZEREL.rst +++ b/Help/variable/CMAKE_LANG_FLAGS_MINSIZEREL.rst @@ -1,7 +1,7 @@ CMAKE__FLAGS_MINSIZEREL ----------------------------- -Flags for MinSizeRel build type or configuration. +Flags for ``MinSizeRel`` build type or configuration. - flags used when CMAKE_BUILD_TYPE is MinSizeRel.Short for -minimum size release. +```` flags used when :variable:`CMAKE_BUILD_TYPE` is ``MinSizeRel`` +(short for minimum size release). diff --git a/Help/variable/CMAKE_LANG_FLAGS_RELEASE.rst b/Help/variable/CMAKE_LANG_FLAGS_RELEASE.rst index 4b2c926..ffc5d79 100644 --- a/Help/variable/CMAKE_LANG_FLAGS_RELEASE.rst +++ b/Help/variable/CMAKE_LANG_FLAGS_RELEASE.rst @@ -1,6 +1,6 @@ CMAKE__FLAGS_RELEASE -------------------------- -Flags for Release build type or configuration. +Flags for ``Release`` build type or configuration. - flags used when CMAKE_BUILD_TYPE is Release +```` flags used when :variable:`CMAKE_BUILD_TYPE` is ``Release``. diff --git a/Help/variable/CMAKE_LANG_FLAGS_RELWITHDEBINFO.rst b/Help/variable/CMAKE_LANG_FLAGS_RELWITHDEBINFO.rst index 16bd4e9..962768e 100644 --- a/Help/variable/CMAKE_LANG_FLAGS_RELWITHDEBINFO.rst +++ b/Help/variable/CMAKE_LANG_FLAGS_RELWITHDEBINFO.rst @@ -1,7 +1,7 @@ CMAKE__FLAGS_RELWITHDEBINFO --------------------------------- -Flags for RelWithDebInfo type or configuration. +Flags for ``RelWithDebInfo`` type or configuration. - flags used when CMAKE_BUILD_TYPE is RelWithDebInfo. Short for -Release With Debug Information. +```` flags used when :variable:`CMAKE_BUILD_TYPE` is ``RelWithDebInfo`` +(short for Release With Debug Information). diff --git a/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_DEBUG.rst b/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_DEBUG.rst index c5915c3..1f639a3 100644 --- a/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_DEBUG.rst +++ b/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_DEBUG.rst @@ -1,6 +1,6 @@ CMAKE__GHS_KERNEL_FLAGS_DEBUG ----------------------------------- -GHS kernel flags for Debug build type or configuration. +GHS kernel flags for ``Debug`` build type or configuration. - flags used when CMAKE_BUILD_TYPE is Debug. +```` flags used when :variable:`CMAKE_BUILD_TYPE` is ``Debug``. diff --git a/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_MINSIZEREL.rst b/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_MINSIZEREL.rst index f80e785..94e2115 100644 --- a/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_MINSIZEREL.rst +++ b/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_MINSIZEREL.rst @@ -1,7 +1,7 @@ CMAKE__GHS_KERNEL_FLAGS_MINSIZEREL ---------------------------------------- -GHS kernel flags for MinSizeRel build type or configuration. +GHS kernel flags for ``MinSizeRel`` build type or configuration. - flags used when CMAKE_BUILD_TYPE is MinSizeRel.Short for -minimum size release. +```` flags used when :variable:`CMAKE_BUILD_TYPE` is ``MinSizeRel`` +(short for minimum size release). diff --git a/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_RELEASE.rst b/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_RELEASE.rst index fe02bc3..74566ef 100644 --- a/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_RELEASE.rst +++ b/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_RELEASE.rst @@ -1,6 +1,6 @@ CMAKE__GHS_KERNEL_FLAGS_RELEASE ------------------------------------- -GHS kernel flags for Release build type or configuration. +GHS kernel flags for ``Release`` build type or configuration. - flags used when CMAKE_BUILD_TYPE is Release +```` flags used when :variable:`CMAKE_BUILD_TYPE` is ``Release``. diff --git a/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_RELWITHDEBINFO.rst b/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_RELWITHDEBINFO.rst index 220f7f9..d148193 100644 --- a/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_RELWITHDEBINFO.rst +++ b/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_RELWITHDEBINFO.rst @@ -1,7 +1,7 @@ CMAKE__GHS_KERNEL_FLAGS_RELWITHDEBINFO -------------------------------------------- -GHS kernel flags for RelWithDebInfo type or configuration. +GHS kernel flags for ``RelWithDebInfo`` type or configuration. - flags used when CMAKE_BUILD_TYPE is RelWithDebInfo. Short for -Release With Debug Information. +```` flags used when :variable:`CMAKE_BUILD_TYPE` is ``RelWithDebInfo`` +(short for Release With Debug Information). diff --git a/Help/variable/CMAKE_LANG_IMPLICIT_INCLUDE_DIRECTORIES.rst b/Help/variable/CMAKE_LANG_IMPLICIT_INCLUDE_DIRECTORIES.rst index c60e18c..cc80851 100644 --- a/Help/variable/CMAKE_LANG_IMPLICIT_INCLUDE_DIRECTORIES.rst +++ b/Help/variable/CMAKE_LANG_IMPLICIT_INCLUDE_DIRECTORIES.rst @@ -4,6 +4,6 @@ CMAKE__IMPLICIT_INCLUDE_DIRECTORIES Directories implicitly searched by the compiler for header files. CMake does not explicitly specify these directories on compiler -command lines for language . This prevents system include +command lines for language ````. This prevents system include directories from being treated as user include directories on some compilers. diff --git a/Help/variable/CMAKE_LANG_IMPLICIT_LINK_DIRECTORIES.rst b/Help/variable/CMAKE_LANG_IMPLICIT_LINK_DIRECTORIES.rst index 568950c..a0bd830 100644 --- a/Help/variable/CMAKE_LANG_IMPLICIT_LINK_DIRECTORIES.rst +++ b/Help/variable/CMAKE_LANG_IMPLICIT_LINK_DIRECTORIES.rst @@ -1,7 +1,7 @@ CMAKE__IMPLICIT_LINK_DIRECTORIES -------------------------------------- -Implicit linker search path detected for language . +Implicit linker search path detected for language ````. Compilers typically pass directories containing language runtime libraries and default library search paths when they invoke a linker. @@ -10,8 +10,8 @@ language. CMake automatically detects these directories for each language and reports the results in this variable. When a library in one of these directories is given by full path to -target_link_libraries() CMake will generate the -l form on link -lines to ensure the linker searches its implicit directories for the +:command:`target_link_libraries` CMake will generate the ``-l`` form on +link lines to ensure the linker searches its implicit directories for the library. Note that some toolchains read implicit directories from an -environment variable such as LIBRARY_PATH so keep its value consistent +environment variable such as ``LIBRARY_PATH`` so keep its value consistent when operating in a given build tree. diff --git a/Help/variable/CMAKE_LANG_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES.rst b/Help/variable/CMAKE_LANG_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES.rst index 05e6ddb..61ccc5a 100644 --- a/Help/variable/CMAKE_LANG_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES.rst +++ b/Help/variable/CMAKE_LANG_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES.rst @@ -1,7 +1,7 @@ CMAKE__IMPLICIT_LINK_FRAMEWORK_DIRECTORIES ------------------------------------------------ -Implicit linker framework search path detected for language . +Implicit linker framework search path detected for language ````. These paths are implicit linker framework search directories for the compiler's language. CMake automatically detects these directories diff --git a/Help/variable/CMAKE_LANG_IMPLICIT_LINK_LIBRARIES.rst b/Help/variable/CMAKE_LANG_IMPLICIT_LINK_LIBRARIES.rst index fddfed8..ec16477 100644 --- a/Help/variable/CMAKE_LANG_IMPLICIT_LINK_LIBRARIES.rst +++ b/Help/variable/CMAKE_LANG_IMPLICIT_LINK_LIBRARIES.rst @@ -1,7 +1,7 @@ CMAKE__IMPLICIT_LINK_LIBRARIES ------------------------------------ -Implicit link libraries and flags detected for language . +Implicit link libraries and flags detected for language ````. Compilers typically pass language runtime library names and other flags when they invoke a linker. These flags are implicit link diff --git a/Help/variable/CMAKE_LANG_LIBRARY_ARCHITECTURE.rst b/Help/variable/CMAKE_LANG_LIBRARY_ARCHITECTURE.rst index 4f31494..7f888ee 100644 --- a/Help/variable/CMAKE_LANG_LIBRARY_ARCHITECTURE.rst +++ b/Help/variable/CMAKE_LANG_LIBRARY_ARCHITECTURE.rst @@ -1,8 +1,8 @@ CMAKE__LIBRARY_ARCHITECTURE --------------------------------- -Target architecture library directory name detected for . +Target architecture library directory name detected for ````. -If the compiler passes to the linker an architecture-specific -system library search directory such as /lib/ this -variable contains the name if/as detected by CMake. +If the ```` compiler passes to the linker an architecture-specific +system library search directory such as ``/lib/`` this +variable contains the ```` name if/as detected by CMake. diff --git a/Help/variable/CMAKE_LANG_LINKER_PREFERENCE.rst b/Help/variable/CMAKE_LANG_LINKER_PREFERENCE.rst index af7ee60..ff82f8b 100644 --- a/Help/variable/CMAKE_LANG_LINKER_PREFERENCE.rst +++ b/Help/variable/CMAKE_LANG_LINKER_PREFERENCE.rst @@ -5,7 +5,7 @@ Preference value for linker language selection. The "linker language" for executable, shared library, and module targets is the language whose compiler will invoke the linker. The -LINKER_LANGUAGE target property sets the language explicitly. +:prop_tgt:`LINKER_LANGUAGE` target property sets the language explicitly. Otherwise, the linker language is that whose linker preference value is highest among languages compiled and linked into the target. See -also the CMAKE__LINKER_PREFERENCE_PROPAGATES variable. +also the :variable:`CMAKE__LINKER_PREFERENCE_PROPAGATES` variable. diff --git a/Help/variable/CMAKE_LANG_LINKER_PREFERENCE_PROPAGATES.rst b/Help/variable/CMAKE_LANG_LINKER_PREFERENCE_PROPAGATES.rst index d513767..dbbeb0a 100644 --- a/Help/variable/CMAKE_LANG_LINKER_PREFERENCE_PROPAGATES.rst +++ b/Help/variable/CMAKE_LANG_LINKER_PREFERENCE_PROPAGATES.rst @@ -1,7 +1,7 @@ CMAKE__LINKER_PREFERENCE_PROPAGATES ----------------------------------------- -True if CMAKE__LINKER_PREFERENCE propagates across targets. +True if :variable:`CMAKE__LINKER_PREFERENCE` propagates across targets. This is used when CMake selects a linker language for a target. Languages compiled directly into the target are always considered. A diff --git a/Help/variable/CMAKE_LANG_OUTPUT_EXTENSION.rst b/Help/variable/CMAKE_LANG_OUTPUT_EXTENSION.rst index 22fac29..0fbc566 100644 --- a/Help/variable/CMAKE_LANG_OUTPUT_EXTENSION.rst +++ b/Help/variable/CMAKE_LANG_OUTPUT_EXTENSION.rst @@ -3,5 +3,5 @@ CMAKE__OUTPUT_EXTENSION Extension for the output of a compile for a single file. -This is the extension for an object file for the given . For -example .obj for C on Windows. +This is the extension for an object file for the given ````. For +example ``.obj`` for C on Windows. diff --git a/Help/variable/CMAKE_LANG_SIMULATE_ID.rst b/Help/variable/CMAKE_LANG_SIMULATE_ID.rst index 646c0db..15c87a1 100644 --- a/Help/variable/CMAKE_LANG_SIMULATE_ID.rst +++ b/Help/variable/CMAKE_LANG_SIMULATE_ID.rst @@ -5,5 +5,5 @@ Identification string of "simulated" compiler. Some compilers simulate other compilers to serve as drop-in replacements. When CMake detects such a compiler it sets this -variable to what would have been the CMAKE__COMPILER_ID for the -simulated compiler. +variable to what would have been the :variable:`CMAKE__COMPILER_ID` for +the simulated compiler. diff --git a/Help/variable/CMAKE_LANG_SIMULATE_VERSION.rst b/Help/variable/CMAKE_LANG_SIMULATE_VERSION.rst index 982053d..d6325e0 100644 --- a/Help/variable/CMAKE_LANG_SIMULATE_VERSION.rst +++ b/Help/variable/CMAKE_LANG_SIMULATE_VERSION.rst @@ -5,5 +5,5 @@ Version string of "simulated" compiler. Some compilers simulate other compilers to serve as drop-in replacements. When CMake detects such a compiler it sets this -variable to what would have been the CMAKE__COMPILER_VERSION for -the simulated compiler. +variable to what would have been the :variable:`CMAKE__COMPILER_VERSION` +for the simulated compiler. diff --git a/Help/variable/CMAKE_LANG_SIZEOF_DATA_PTR.rst b/Help/variable/CMAKE_LANG_SIZEOF_DATA_PTR.rst index c85b5e0..7465923 100644 --- a/Help/variable/CMAKE_LANG_SIZEOF_DATA_PTR.rst +++ b/Help/variable/CMAKE_LANG_SIZEOF_DATA_PTR.rst @@ -1,7 +1,7 @@ CMAKE__SIZEOF_DATA_PTR ---------------------------- -Size of pointer-to-data types for language . +Size of pointer-to-data types for language ````. This holds the size (in bytes) of pointer-to-data types in the target -platform ABI. It is defined for languages C and CXX (C++). +platform ABI. It is defined for languages ``C`` and ``CXX`` (C++). diff --git a/Help/variable/CMAKE_LIBRARY_ARCHITECTURE.rst b/Help/variable/CMAKE_LIBRARY_ARCHITECTURE.rst index c9a15f3..8a7dcbd 100644 --- a/Help/variable/CMAKE_LIBRARY_ARCHITECTURE.rst +++ b/Help/variable/CMAKE_LIBRARY_ARCHITECTURE.rst @@ -3,5 +3,5 @@ CMAKE_LIBRARY_ARCHITECTURE Target architecture library directory name, if detected. -This is the value of CMAKE__LIBRARY_ARCHITECTURE as detected for -one of the enabled languages. +This is the value of :variable:`CMAKE__LIBRARY_ARCHITECTURE` as detected +for one of the enabled languages. diff --git a/Help/variable/CMAKE_LIBRARY_ARCHITECTURE_REGEX.rst b/Help/variable/CMAKE_LIBRARY_ARCHITECTURE_REGEX.rst index 6c41269..1eb2ac2 100644 --- a/Help/variable/CMAKE_LIBRARY_ARCHITECTURE_REGEX.rst +++ b/Help/variable/CMAKE_LIBRARY_ARCHITECTURE_REGEX.rst @@ -3,5 +3,5 @@ CMAKE_LIBRARY_ARCHITECTURE_REGEX Regex matching possible target architecture library directory names. -This is used to detect CMAKE__LIBRARY_ARCHITECTURE from the -implicit linker search path by matching the name. +This is used to detect :variable:`CMAKE__LIBRARY_ARCHITECTURE` from the +implicit linker search path by matching the ```` name. diff --git a/Help/variable/CMAKE_LIBRARY_PATH_FLAG.rst b/Help/variable/CMAKE_LIBRARY_PATH_FLAG.rst index ede39e9..ebe5fda 100644 --- a/Help/variable/CMAKE_LIBRARY_PATH_FLAG.rst +++ b/Help/variable/CMAKE_LIBRARY_PATH_FLAG.rst @@ -4,4 +4,4 @@ CMAKE_LIBRARY_PATH_FLAG The flag to be used to add a library search path to a compiler. The flag will be used to specify a library directory to the compiler. -On most compilers this is "-L". +On most compilers this is ``-L``. diff --git a/Help/variable/CMAKE_LINK_DEF_FILE_FLAG.rst b/Help/variable/CMAKE_LINK_DEF_FILE_FLAG.rst index 382447c..fa09f9f 100644 --- a/Help/variable/CMAKE_LINK_DEF_FILE_FLAG.rst +++ b/Help/variable/CMAKE_LINK_DEF_FILE_FLAG.rst @@ -1,7 +1,7 @@ CMAKE_LINK_DEF_FILE_FLAG ------------------------ -Linker flag to be used to specify a .def file for dll creation. +Linker flag to be used to specify a ``.def`` file for dll creation. -The flag will be used to add a .def file when creating a dll on +The flag will be used to add a ``.def`` file when creating a dll on Windows; this is only defined on Windows. diff --git a/Help/variable/CMAKE_LINK_DEPENDS_NO_SHARED.rst b/Help/variable/CMAKE_LINK_DEPENDS_NO_SHARED.rst index 6ae7df6..cec7906 100644 --- a/Help/variable/CMAKE_LINK_DEPENDS_NO_SHARED.rst +++ b/Help/variable/CMAKE_LINK_DEPENDS_NO_SHARED.rst @@ -3,6 +3,6 @@ CMAKE_LINK_DEPENDS_NO_SHARED Whether to skip link dependencies on shared library files. -This variable initializes the LINK_DEPENDS_NO_SHARED property on +This variable initializes the :prop_tgt:`LINK_DEPENDS_NO_SHARED` property on targets when they are created. See that target property for additional information. diff --git a/Help/variable/CMAKE_LINK_INTERFACE_LIBRARIES.rst b/Help/variable/CMAKE_LINK_INTERFACE_LIBRARIES.rst index efe6fd7..33865da 100644 --- a/Help/variable/CMAKE_LINK_INTERFACE_LIBRARIES.rst +++ b/Help/variable/CMAKE_LINK_INTERFACE_LIBRARIES.rst @@ -1,8 +1,8 @@ CMAKE_LINK_INTERFACE_LIBRARIES ------------------------------ -Default value for LINK_INTERFACE_LIBRARIES of targets. +Default value for :prop_tgt:`LINK_INTERFACE_LIBRARIES` of targets. -This variable is used to initialize the LINK_INTERFACE_LIBRARIES +This variable is used to initialize the :prop_tgt:`LINK_INTERFACE_LIBRARIES` property on all the targets. See that target property for additional information. diff --git a/Help/variable/CMAKE_LINK_LIBRARY_FLAG.rst b/Help/variable/CMAKE_LINK_LIBRARY_FLAG.rst index c3e02d7..b5197e4 100644 --- a/Help/variable/CMAKE_LINK_LIBRARY_FLAG.rst +++ b/Help/variable/CMAKE_LINK_LIBRARY_FLAG.rst @@ -4,4 +4,4 @@ CMAKE_LINK_LIBRARY_FLAG Flag to be used to link a library into an executable. The flag will be used to specify a library to link to an executable. -On most compilers this is "-l". +On most compilers this is ``-l``. diff --git a/Help/variable/CMAKE_LINK_LIBRARY_SUFFIX.rst b/Help/variable/CMAKE_LINK_LIBRARY_SUFFIX.rst index 390298d..0ddafe8 100644 --- a/Help/variable/CMAKE_LINK_LIBRARY_SUFFIX.rst +++ b/Help/variable/CMAKE_LINK_LIBRARY_SUFFIX.rst @@ -3,4 +3,4 @@ CMAKE_LINK_LIBRARY_SUFFIX The suffix for libraries that you link to. -The suffix to use for the end of a library filename, .lib on Windows. +The suffix to use for the end of a library filename, ``.lib`` on Windows. diff --git a/Help/variable/CMAKE_LINK_SEARCH_END_STATIC.rst b/Help/variable/CMAKE_LINK_SEARCH_END_STATIC.rst index 673f5d8..54cdaaa 100644 --- a/Help/variable/CMAKE_LINK_SEARCH_END_STATIC.rst +++ b/Help/variable/CMAKE_LINK_SEARCH_END_STATIC.rst @@ -3,14 +3,14 @@ CMAKE_LINK_SEARCH_END_STATIC End a link line such that static system libraries are used. -Some linkers support switches such as -Bstatic and -Bdynamic to -determine whether to use static or shared libraries for -lXXX options. +Some linkers support switches such as ``-Bstatic`` and ``-Bdynamic`` to +determine whether to use static or shared libraries for ``-lXXX`` options. CMake uses these options to set the link type for libraries whose full paths are not known or (in some cases) are in implicit link directories for the platform. By default CMake adds an option at the end of the library list (if necessary) to set the linker search type back to its starting type. This property switches the final linker -search type to -Bstatic regardless of how it started. +search type to ``-Bstatic`` regardless of how it started. This variable is used to initialize the target property :prop_tgt:`LINK_SEARCH_END_STATIC` for all targets. If set, it's diff --git a/Help/variable/CMAKE_LINK_SEARCH_START_STATIC.rst b/Help/variable/CMAKE_LINK_SEARCH_START_STATIC.rst index 223702c..0d52a314 100644 --- a/Help/variable/CMAKE_LINK_SEARCH_START_STATIC.rst +++ b/Help/variable/CMAKE_LINK_SEARCH_START_STATIC.rst @@ -3,14 +3,14 @@ CMAKE_LINK_SEARCH_START_STATIC Assume the linker looks for static libraries by default. -Some linkers support switches such as -Bstatic and -Bdynamic to -determine whether to use static or shared libraries for -lXXX options. +Some linkers support switches such as ``-Bstatic`` and ``-Bdynamic`` to +determine whether to use static or shared libraries for ``-lXXX`` options. CMake uses these options to set the link type for libraries whose full paths are not known or (in some cases) are in implicit link directories for the platform. By default the linker search type is -assumed to be -Bdynamic at the beginning of the library list. This -property switches the assumption to -Bstatic. It is intended for use -when linking an executable statically (e.g. with the GNU -static +assumed to be ``-Bdynamic`` at the beginning of the library list. This +property switches the assumption to ``-Bstatic``. It is intended for use +when linking an executable statically (e.g. with the GNU ``-static`` option). This variable is used to initialize the target property diff --git a/Help/variable/CMAKE_MACOSX_BUNDLE.rst b/Help/variable/CMAKE_MACOSX_BUNDLE.rst index e4768f3..0badaf0 100644 --- a/Help/variable/CMAKE_MACOSX_BUNDLE.rst +++ b/Help/variable/CMAKE_MACOSX_BUNDLE.rst @@ -1,7 +1,7 @@ CMAKE_MACOSX_BUNDLE ------------------- -Default value for MACOSX_BUNDLE of targets. +Default value for :prop_tgt:`MACOSX_BUNDLE` of targets. -This variable is used to initialize the MACOSX_BUNDLE property on all -the targets. See that target property for additional information. +This variable is used to initialize the :prop_tgt:`MACOSX_BUNDLE` property on +all the targets. See that target property for additional information. diff --git a/Help/variable/CMAKE_MAKE_PROGRAM.rst b/Help/variable/CMAKE_MAKE_PROGRAM.rst index 85b098b..edf2732 100644 --- a/Help/variable/CMAKE_MAKE_PROGRAM.rst +++ b/Help/variable/CMAKE_MAKE_PROGRAM.rst @@ -8,18 +8,18 @@ name if it is expected to be in the ``PATH``. The tool selected depends on the :variable:`CMAKE_GENERATOR` used to configure the project: -* The Makefile generators set this to ``make``, ``gmake``, or - a generator-specific tool (e.g. ``nmake`` for "NMake Makefiles"). +* The :ref:`Makefile Generators` set this to ``make``, ``gmake``, or + a generator-specific tool (e.g. ``nmake`` for :generator:`NMake Makefiles`). These generators store ``CMAKE_MAKE_PROGRAM`` in the CMake cache so that it may be edited by the user. -* The Ninja generator sets this to ``ninja``. +* The :generator:`Ninja` generator sets this to ``ninja``. This generator stores ``CMAKE_MAKE_PROGRAM`` in the CMake cache so that it may be edited by the user. -* The Xcode generator sets this to ``xcodebuild`` (or possibly an +* The :generator:`Xcode` generator sets this to ``xcodebuild`` (or possibly an otherwise undocumented ``cmakexbuild`` wrapper implementing some workarounds). @@ -33,7 +33,7 @@ to configure the project: a user or project explicitly adds ``CMAKE_MAKE_PROGRAM`` to the CMake cache then CMake will use the specified value. -* The Visual Studio generators set this to the full path to +* The :ref:`Visual Studio Generators` set this to the full path to ``MSBuild.exe`` (VS >= 10), ``devenv.com`` (VS 7,8,9), ``VCExpress.exe`` (VS Express 8,9), or ``msdev.exe`` (VS 6). (See also variables diff --git a/Help/variable/CMAKE_MAP_IMPORTED_CONFIG_CONFIG.rst b/Help/variable/CMAKE_MAP_IMPORTED_CONFIG_CONFIG.rst index 41ccde1..ed29afe 100644 --- a/Help/variable/CMAKE_MAP_IMPORTED_CONFIG_CONFIG.rst +++ b/Help/variable/CMAKE_MAP_IMPORTED_CONFIG_CONFIG.rst @@ -1,8 +1,8 @@ CMAKE_MAP_IMPORTED_CONFIG_ ---------------------------------- -Default value for MAP_IMPORTED_CONFIG_ of targets. +Default value for :prop_tgt:`MAP_IMPORTED_CONFIG_` of targets. -This variable is used to initialize the MAP_IMPORTED_CONFIG_ -property on all the targets. See that target property for additional -information. +This variable is used to initialize the +:prop_tgt:`MAP_IMPORTED_CONFIG_` property on all the targets. See +that target property for additional information. diff --git a/Help/variable/CMAKE_MFC_FLAG.rst b/Help/variable/CMAKE_MFC_FLAG.rst index 221d26e..f60e7a5 100644 --- a/Help/variable/CMAKE_MFC_FLAG.rst +++ b/Help/variable/CMAKE_MFC_FLAG.rst @@ -3,10 +3,10 @@ CMAKE_MFC_FLAG Tell cmake to use MFC for an executable or dll. -This can be set in a CMakeLists.txt file and will enable MFC in the -application. It should be set to 1 for the static MFC library, and 2 +This can be set in a ``CMakeLists.txt`` file and will enable MFC in the +application. It should be set to ``1`` for the static MFC library, and ``2`` for the shared MFC library. This is used in Visual Studio 6 and 7 -project files. The CMakeSetup dialog used MFC and the CMakeLists.txt +project files. The CMakeSetup dialog used MFC and the ``CMakeLists.txt`` looks like this: :: diff --git a/Help/variable/CMAKE_MINIMUM_REQUIRED_VERSION.rst b/Help/variable/CMAKE_MINIMUM_REQUIRED_VERSION.rst index 351de44..5a51634 100644 --- a/Help/variable/CMAKE_MINIMUM_REQUIRED_VERSION.rst +++ b/Help/variable/CMAKE_MINIMUM_REQUIRED_VERSION.rst @@ -1,7 +1,7 @@ CMAKE_MINIMUM_REQUIRED_VERSION ------------------------------ -Version specified to cmake_minimum_required command +Version specified to :command:`cmake_minimum_required` command -Variable containing the VERSION component specified in the -cmake_minimum_required command. +Variable containing the ``VERSION`` component specified in the +:command:`cmake_minimum_required` command. diff --git a/Help/variable/CMAKE_MODULE_LINKER_FLAGS_CONFIG.rst b/Help/variable/CMAKE_MODULE_LINKER_FLAGS_CONFIG.rst index 87a1901..393263e 100644 --- a/Help/variable/CMAKE_MODULE_LINKER_FLAGS_CONFIG.rst +++ b/Help/variable/CMAKE_MODULE_LINKER_FLAGS_CONFIG.rst @@ -3,4 +3,4 @@ CMAKE_MODULE_LINKER_FLAGS_ Flags to be used when linking a module. -Same as CMAKE_C_FLAGS_* but used by the linker when creating modules. +Same as ``CMAKE_C_FLAGS_*`` but used by the linker when creating modules. diff --git a/Help/variable/CMAKE_NOT_USING_CONFIG_FLAGS.rst b/Help/variable/CMAKE_NOT_USING_CONFIG_FLAGS.rst index cbe0350..98960c5 100644 --- a/Help/variable/CMAKE_NOT_USING_CONFIG_FLAGS.rst +++ b/Help/variable/CMAKE_NOT_USING_CONFIG_FLAGS.rst @@ -1,7 +1,7 @@ CMAKE_NOT_USING_CONFIG_FLAGS ---------------------------- -Skip _BUILD_TYPE flags if true. +Skip ``_BUILD_TYPE`` flags if true. This is an internal flag used by the generators in CMake to tell CMake -to skip the _BUILD_TYPE flags. +to skip the ``_BUILD_TYPE`` flags. diff --git a/Help/variable/CMAKE_NO_SYSTEM_FROM_IMPORTED.rst b/Help/variable/CMAKE_NO_SYSTEM_FROM_IMPORTED.rst index c1919af..61e04b4 100644 --- a/Help/variable/CMAKE_NO_SYSTEM_FROM_IMPORTED.rst +++ b/Help/variable/CMAKE_NO_SYSTEM_FROM_IMPORTED.rst @@ -1,8 +1,8 @@ CMAKE_NO_SYSTEM_FROM_IMPORTED ----------------------------- -Default value for NO_SYSTEM_FROM_IMPORTED of targets. +Default value for :prop_tgt:`NO_SYSTEM_FROM_IMPORTED` of targets. -This variable is used to initialize the NO_SYSTEM_FROM_IMPORTED +This variable is used to initialize the :prop_tgt:`NO_SYSTEM_FROM_IMPORTED` property on all the targets. See that target property for additional information. diff --git a/Help/variable/CMAKE_PARENT_LIST_FILE.rst b/Help/variable/CMAKE_PARENT_LIST_FILE.rst index 5566a72..cfd8608 100644 --- a/Help/variable/CMAKE_PARENT_LIST_FILE.rst +++ b/Help/variable/CMAKE_PARENT_LIST_FILE.rst @@ -3,7 +3,7 @@ CMAKE_PARENT_LIST_FILE Full path to the CMake file that included the current one. -While processing a CMake file loaded by include() or find_package() -this variable contains the full path to the file including it. The -top of the include stack is always the CMakeLists.txt for the current -directory. See also CMAKE_CURRENT_LIST_FILE. +While processing a CMake file loaded by :command:`include` or +:command:`find_package` this variable contains the full path to the file +including it. The top of the include stack is always the ``CMakeLists.txt`` +for the current directory. See also :variable:`CMAKE_CURRENT_LIST_FILE`. diff --git a/Help/variable/CMAKE_POLICY_DEFAULT_CMPNNNN.rst b/Help/variable/CMAKE_POLICY_DEFAULT_CMPNNNN.rst index e401aa5..43582be 100644 --- a/Help/variable/CMAKE_POLICY_DEFAULT_CMPNNNN.rst +++ b/Help/variable/CMAKE_POLICY_DEFAULT_CMPNNNN.rst @@ -1,16 +1,17 @@ CMAKE_POLICY_DEFAULT_CMP ------------------------------ -Default for CMake Policy CMP when it is otherwise left unset. +Default for CMake Policy ``CMP`` when it is otherwise left unset. -Commands cmake_minimum_required(VERSION) and cmake_policy(VERSION) by -default leave policies introduced after the given version unset. Set -CMAKE_POLICY_DEFAULT_CMP to OLD or NEW to specify the default -for policy CMP, where is the policy number. +Commands :command:`cmake_minimum_required(VERSION)` and +:command:`cmake_policy(VERSION)` by default leave policies introduced after +the given version unset. Set ``CMAKE_POLICY_DEFAULT_CMP`` to ``OLD`` +or ``NEW`` to specify the default for policy ``CMP``, where ```` +is the policy number. This variable should not be set by a project in CMake code; use -cmake_policy(SET) instead. Users running CMake may set this variable -in the cache (e.g. -DCMAKE_POLICY_DEFAULT_CMP=) to set -a policy not otherwise set by the project. Set to OLD to quiet a -policy warning while using old behavior or to NEW to try building the +:command:`cmake_policy(SET)` instead. Users running CMake may set this +variable in the cache (e.g. ``-DCMAKE_POLICY_DEFAULT_CMP=``) +to set a policy not otherwise set by the project. Set to ``OLD`` to quiet a +policy warning while using old behavior or to ``NEW`` to try building the project with new behavior. diff --git a/Help/variable/CMAKE_PROJECT_NAME.rst b/Help/variable/CMAKE_PROJECT_NAME.rst index 4734705..431e9f3 100644 --- a/Help/variable/CMAKE_PROJECT_NAME.rst +++ b/Help/variable/CMAKE_PROJECT_NAME.rst @@ -4,4 +4,4 @@ CMAKE_PROJECT_NAME The name of the current project. This specifies name of the current project from the closest inherited -PROJECT command. +:command:`project` command. diff --git a/Help/variable/CMAKE_ROOT.rst b/Help/variable/CMAKE_ROOT.rst index f963a7f..1d0a8af 100644 --- a/Help/variable/CMAKE_ROOT.rst +++ b/Help/variable/CMAKE_ROOT.rst @@ -3,6 +3,6 @@ CMAKE_ROOT Install directory for running cmake. -This is the install root for the running CMake and the Modules +This is the install root for the running CMake and the ``Modules`` directory can be found here. This is commonly used in this format: -${CMAKE_ROOT}/Modules +``${CMAKE_ROOT}/Modules`` diff --git a/Help/variable/CMAKE_SCRIPT_MODE_FILE.rst b/Help/variable/CMAKE_SCRIPT_MODE_FILE.rst index ad73cc0..981af60 100644 --- a/Help/variable/CMAKE_SCRIPT_MODE_FILE.rst +++ b/Help/variable/CMAKE_SCRIPT_MODE_FILE.rst @@ -1,8 +1,9 @@ CMAKE_SCRIPT_MODE_FILE ---------------------- -Full path to the -P script file currently being processed. +Full path to the :manual:`cmake(1)` ``-P`` script file currently being +processed. -When run in -P script mode, CMake sets this variable to the full path -of the script file. When run to configure a CMakeLists.txt file, this -variable is not set. +When run in :manual:`cmake(1)` ``-P`` script mode, CMake sets this variable to +the full path of the script file. When run to configure a ``CMakeLists.txt`` +file, this variable is not set. diff --git a/Help/variable/CMAKE_SHARED_LIBRARY_PREFIX.rst b/Help/variable/CMAKE_SHARED_LIBRARY_PREFIX.rst index a863e2a..8afabaf 100644 --- a/Help/variable/CMAKE_SHARED_LIBRARY_PREFIX.rst +++ b/Help/variable/CMAKE_SHARED_LIBRARY_PREFIX.rst @@ -3,6 +3,6 @@ CMAKE_SHARED_LIBRARY_PREFIX The prefix for shared libraries that you link to. -The prefix to use for the name of a shared library, lib on UNIX. +The prefix to use for the name of a shared library, ``lib`` on UNIX. -CMAKE_SHARED_LIBRARY_PREFIX_ overrides this for language . +``CMAKE_SHARED_LIBRARY_PREFIX_`` overrides this for language ````. diff --git a/Help/variable/CMAKE_SHARED_LIBRARY_SUFFIX.rst b/Help/variable/CMAKE_SHARED_LIBRARY_SUFFIX.rst index c296ecd..1f96a32 100644 --- a/Help/variable/CMAKE_SHARED_LIBRARY_SUFFIX.rst +++ b/Help/variable/CMAKE_SHARED_LIBRARY_SUFFIX.rst @@ -3,7 +3,7 @@ CMAKE_SHARED_LIBRARY_SUFFIX The suffix for shared libraries that you link to. -The suffix to use for the end of a shared library filename, .dll on +The suffix to use for the end of a shared library filename, ``.dll`` on Windows. -CMAKE_SHARED_LIBRARY_SUFFIX_ overrides this for language . +``CMAKE_SHARED_LIBRARY_SUFFIX_`` overrides this for language ````. diff --git a/Help/variable/CMAKE_SHARED_LINKER_FLAGS_CONFIG.rst b/Help/variable/CMAKE_SHARED_LINKER_FLAGS_CONFIG.rst index fedc626..4bf87a0 100644 --- a/Help/variable/CMAKE_SHARED_LINKER_FLAGS_CONFIG.rst +++ b/Help/variable/CMAKE_SHARED_LINKER_FLAGS_CONFIG.rst @@ -3,5 +3,5 @@ CMAKE_SHARED_LINKER_FLAGS_ Flags to be used when linking a shared library. -Same as CMAKE_C_FLAGS_* but used by the linker when creating shared +Same as ``CMAKE_C_FLAGS_*`` but used by the linker when creating shared libraries. diff --git a/Help/variable/CMAKE_SHARED_MODULE_PREFIX.rst b/Help/variable/CMAKE_SHARED_MODULE_PREFIX.rst index a5a2428..d6eef98 100644 --- a/Help/variable/CMAKE_SHARED_MODULE_PREFIX.rst +++ b/Help/variable/CMAKE_SHARED_MODULE_PREFIX.rst @@ -5,4 +5,4 @@ The prefix for loadable modules that you link to. The prefix to use for the name of a loadable module on this platform. -CMAKE_SHARED_MODULE_PREFIX_ overrides this for language . +``CMAKE_SHARED_MODULE_PREFIX_`` overrides this for language ````. diff --git a/Help/variable/CMAKE_SHARED_MODULE_SUFFIX.rst b/Help/variable/CMAKE_SHARED_MODULE_SUFFIX.rst index 32a3c34..81515c3 100644 --- a/Help/variable/CMAKE_SHARED_MODULE_SUFFIX.rst +++ b/Help/variable/CMAKE_SHARED_MODULE_SUFFIX.rst @@ -6,4 +6,4 @@ The suffix for shared libraries that you link to. The suffix to use for the end of a loadable module filename on this platform -CMAKE_SHARED_MODULE_SUFFIX_ overrides this for language . +``CMAKE_SHARED_MODULE_SUFFIX_`` overrides this for language ````. diff --git a/Help/variable/CMAKE_SIZEOF_VOID_P.rst b/Help/variable/CMAKE_SIZEOF_VOID_P.rst index 98dbed6..f5464d1 100644 --- a/Help/variable/CMAKE_SIZEOF_VOID_P.rst +++ b/Help/variable/CMAKE_SIZEOF_VOID_P.rst @@ -1,8 +1,8 @@ CMAKE_SIZEOF_VOID_P ------------------- -Size of a void pointer. +Size of a ``void`` pointer. This is set to the size of a pointer on the target machine, and is determined -by a try compile. If a 64 bit size is found, then the library search -path is modified to look for 64 bit libraries first. +by a try compile. If a 64-bit size is found, then the library search +path is modified to look for 64-bit libraries first. diff --git a/Help/variable/CMAKE_SKIP_INSTALL_ALL_DEPENDENCY.rst b/Help/variable/CMAKE_SKIP_INSTALL_ALL_DEPENDENCY.rst index 33ee8a8..80a68c9 100644 --- a/Help/variable/CMAKE_SKIP_INSTALL_ALL_DEPENDENCY.rst +++ b/Help/variable/CMAKE_SKIP_INSTALL_ALL_DEPENDENCY.rst @@ -1,11 +1,11 @@ CMAKE_SKIP_INSTALL_ALL_DEPENDENCY --------------------------------- -Don't make the install target depend on the all target. +Don't make the ``install`` target depend on the ``all`` target. -By default, the "install" target depends on the "all" target. This -has the effect, that when "make install" is invoked or INSTALL is -built, first the "all" target is built, then the installation starts. -If CMAKE_SKIP_INSTALL_ALL_DEPENDENCY is set to TRUE, this dependency -is not created, so the installation process will start immediately, +By default, the ``install`` target depends on the ``all`` target. This +has the effect, that when ``make install`` is invoked or ``INSTALL`` is +built, first the ``all`` target is built, then the installation starts. +If :variable:`CMAKE_SKIP_INSTALL_ALL_DEPENDENCY` is set to ``TRUE``, this +dependency is not created, so the installation process will start immediately, independent from whether the project has been completely built or not. diff --git a/Help/variable/CMAKE_SKIP_INSTALL_RPATH.rst b/Help/variable/CMAKE_SKIP_INSTALL_RPATH.rst index f16b212..cc0ac21 100644 --- a/Help/variable/CMAKE_SKIP_INSTALL_RPATH.rst +++ b/Help/variable/CMAKE_SKIP_INSTALL_RPATH.rst @@ -11,4 +11,4 @@ always installed without RPATH, even if RPATH is enabled when building. This can be useful for example to allow running tests from the build directory with RPATH enabled before the installation step. To omit RPATH in both the build and install steps, use -CMAKE_SKIP_RPATH instead. +:variable:`CMAKE_SKIP_RPATH` instead. diff --git a/Help/variable/CMAKE_SKIP_INSTALL_RULES.rst b/Help/variable/CMAKE_SKIP_INSTALL_RULES.rst index 5eda254..44966f3 100644 --- a/Help/variable/CMAKE_SKIP_INSTALL_RULES.rst +++ b/Help/variable/CMAKE_SKIP_INSTALL_RULES.rst @@ -3,5 +3,6 @@ CMAKE_SKIP_INSTALL_RULES Whether to disable generation of installation rules. -If TRUE, cmake will neither generate installaton rules nor -will it generate cmake_install.cmake files. This variable is FALSE by default. +If ``TRUE``, cmake will neither generate installaton rules nor +will it generate ``cmake_install.cmake`` files. This variable is ``FALSE`` by +default. diff --git a/Help/variable/CMAKE_SKIP_RPATH.rst b/Help/variable/CMAKE_SKIP_RPATH.rst index c93f67f..d7ce8e4 100644 --- a/Help/variable/CMAKE_SKIP_RPATH.rst +++ b/Help/variable/CMAKE_SKIP_RPATH.rst @@ -3,8 +3,8 @@ CMAKE_SKIP_RPATH If true, do not add run time path information. -If this is set to TRUE, then the rpath information is not added to +If this is set to ``TRUE``, then the rpath information is not added to compiled executables. The default is to add rpath information if the platform supports it. This allows for easy running from the build tree. To omit RPATH in the install step, but not the build step, use -CMAKE_SKIP_INSTALL_RPATH instead. +:variable:`CMAKE_SKIP_INSTALL_RPATH` instead. diff --git a/Help/variable/CMAKE_SOURCE_DIR.rst b/Help/variable/CMAKE_SOURCE_DIR.rst index 088fa83..3df0226 100644 --- a/Help/variable/CMAKE_SOURCE_DIR.rst +++ b/Help/variable/CMAKE_SOURCE_DIR.rst @@ -5,4 +5,4 @@ The path to the top level of the source tree. This is the full path to the top level of the current CMake source tree. For an in-source build, this would be the same as -CMAKE_BINARY_DIR. +:variable:`CMAKE_BINARY_DIR`. diff --git a/Help/variable/CMAKE_STAGING_PREFIX.rst b/Help/variable/CMAKE_STAGING_PREFIX.rst index c4de7da..1310e94 100644 --- a/Help/variable/CMAKE_STAGING_PREFIX.rst +++ b/Help/variable/CMAKE_STAGING_PREFIX.rst @@ -5,9 +5,10 @@ This variable may be set to a path to install to when cross-compiling. This can be useful if the path in :variable:`CMAKE_SYSROOT` is read-only, or otherwise should remain pristine. -The CMAKE_STAGING_PREFIX location is also used as a search prefix by the ``find_*`` -commands. This can be controlled by setting the :variable:`CMAKE_FIND_NO_INSTALL_PREFIX` -variable. +The ``CMAKE_STAGING_PREFIX`` location is also used as a search prefix by the +``find_*`` commands. This can be controlled by setting the +:variable:`CMAKE_FIND_NO_INSTALL_PREFIX` variable. -If any RPATH/RUNPATH entries passed to the linker contain the CMAKE_STAGING_PREFIX, -the matching path fragments are replaced with the :variable:`CMAKE_INSTALL_PREFIX`. +If any RPATH/RUNPATH entries passed to the linker contain the +``CMAKE_STAGING_PREFIX``, the matching path fragments are replaced with the +:variable:`CMAKE_INSTALL_PREFIX`. diff --git a/Help/variable/CMAKE_STATIC_LIBRARY_PREFIX.rst b/Help/variable/CMAKE_STATIC_LIBRARY_PREFIX.rst index 0a3095d..714b5cc 100644 --- a/Help/variable/CMAKE_STATIC_LIBRARY_PREFIX.rst +++ b/Help/variable/CMAKE_STATIC_LIBRARY_PREFIX.rst @@ -3,6 +3,6 @@ CMAKE_STATIC_LIBRARY_PREFIX The prefix for static libraries that you link to. -The prefix to use for the name of a static library, lib on UNIX. +The prefix to use for the name of a static library, ``lib`` on UNIX. -CMAKE_STATIC_LIBRARY_PREFIX_ overrides this for language . +``CMAKE_STATIC_LIBRARY_PREFIX_`` overrides this for language ````. diff --git a/Help/variable/CMAKE_STATIC_LIBRARY_SUFFIX.rst b/Help/variable/CMAKE_STATIC_LIBRARY_SUFFIX.rst index 4d07671..28dc09d 100644 --- a/Help/variable/CMAKE_STATIC_LIBRARY_SUFFIX.rst +++ b/Help/variable/CMAKE_STATIC_LIBRARY_SUFFIX.rst @@ -3,7 +3,7 @@ CMAKE_STATIC_LIBRARY_SUFFIX The suffix for static libraries that you link to. -The suffix to use for the end of a static library filename, .lib on +The suffix to use for the end of a static library filename, ``.lib`` on Windows. -CMAKE_STATIC_LIBRARY_SUFFIX_ overrides this for language . +``CMAKE_STATIC_LIBRARY_SUFFIX_`` overrides this for language ````. diff --git a/Help/variable/CMAKE_STATIC_LINKER_FLAGS_CONFIG.rst b/Help/variable/CMAKE_STATIC_LINKER_FLAGS_CONFIG.rst index 6cde24d..b9f8003 100644 --- a/Help/variable/CMAKE_STATIC_LINKER_FLAGS_CONFIG.rst +++ b/Help/variable/CMAKE_STATIC_LINKER_FLAGS_CONFIG.rst @@ -3,5 +3,5 @@ CMAKE_STATIC_LINKER_FLAGS_ Flags to be used when linking a static library. -Same as CMAKE_C_FLAGS_* but used by the linker when creating static +Same as ``CMAKE_C_FLAGS_*`` but used by the linker when creating static libraries. diff --git a/Help/variable/CMAKE_SYSTEM.rst b/Help/variable/CMAKE_SYSTEM.rst index 23f5980..c7d0d8a 100644 --- a/Help/variable/CMAKE_SYSTEM.rst +++ b/Help/variable/CMAKE_SYSTEM.rst @@ -1,7 +1,7 @@ CMAKE_SYSTEM ------------ -Composit Name of OS CMake is compiling for. +Composite name of operating system CMake is compiling for. This variable is the composite of :variable:`CMAKE_SYSTEM_NAME` and :variable:`CMAKE_SYSTEM_VERSION`, e.g. diff --git a/Help/variable/CMAKE_SYSTEM_NAME.rst b/Help/variable/CMAKE_SYSTEM_NAME.rst index 189dc18..0466da4 100644 --- a/Help/variable/CMAKE_SYSTEM_NAME.rst +++ b/Help/variable/CMAKE_SYSTEM_NAME.rst @@ -1,8 +1,8 @@ CMAKE_SYSTEM_NAME ----------------- -Name of the OS CMake is building for. +Name of the operating system CMake is building for. -This is the name of the OS on which CMake is targeting. This variable -is the same as :variable:`CMAKE_HOST_SYSTEM_NAME` if you build for the +This is the name of the operating system on which CMake is targeting. This +variable is the same as :variable:`CMAKE_HOST_SYSTEM_NAME` if you build for the host system instead of the target system when cross compiling. diff --git a/Help/variable/CMAKE_SYSTEM_PROCESSOR.rst b/Help/variable/CMAKE_SYSTEM_PROCESSOR.rst index 2f5313b..09280de 100644 --- a/Help/variable/CMAKE_SYSTEM_PROCESSOR.rst +++ b/Help/variable/CMAKE_SYSTEM_PROCESSOR.rst @@ -7,4 +7,4 @@ This variable is the same as :variable:`CMAKE_HOST_SYSTEM_PROCESSOR` if you build for the host system instead of the target system when cross compiling. -* The Green Hills MULTI generator sets this to ``ARM`` by default +* The :generator:`Green Hills MULTI` generator sets this to ``ARM`` by default. diff --git a/Help/variable/CMAKE_SYSTEM_VERSION.rst b/Help/variable/CMAKE_SYSTEM_VERSION.rst index 33510bb..3b3cdc5 100644 --- a/Help/variable/CMAKE_SYSTEM_VERSION.rst +++ b/Help/variable/CMAKE_SYSTEM_VERSION.rst @@ -1,7 +1,7 @@ CMAKE_SYSTEM_VERSION -------------------- -The OS version CMake is building for. +The operating system version CMake is building for. This variable is the same as :variable:`CMAKE_HOST_SYSTEM_VERSION` if you build for the host system instead of the target system when diff --git a/Help/variable/CMAKE_TOOLCHAIN_FILE.rst b/Help/variable/CMAKE_TOOLCHAIN_FILE.rst index e1a65e1..168ee74 100644 --- a/Help/variable/CMAKE_TOOLCHAIN_FILE.rst +++ b/Help/variable/CMAKE_TOOLCHAIN_FILE.rst @@ -4,6 +4,6 @@ CMAKE_TOOLCHAIN_FILE Path to toolchain file supplied to :manual:`cmake(1)`. This variable is specified on the command line when cross-compiling with CMake. -It is the path to a file which is read early in the CMake run and which specifies -locations for compilers and toolchain utilities, and other target platform and -compiler related information. +It is the path to a file which is read early in the CMake run and which +specifies locations for compilers and toolchain utilities, and other target +platform and compiler related information. diff --git a/Help/variable/CMAKE_TRY_COMPILE_CONFIGURATION.rst b/Help/variable/CMAKE_TRY_COMPILE_CONFIGURATION.rst index a92feab..d731f02 100644 --- a/Help/variable/CMAKE_TRY_COMPILE_CONFIGURATION.rst +++ b/Help/variable/CMAKE_TRY_COMPILE_CONFIGURATION.rst @@ -1,9 +1,10 @@ CMAKE_TRY_COMPILE_CONFIGURATION ------------------------------- -Build configuration used for try_compile and try_run projects. +Build configuration used for :command:`try_compile` and :command:`try_run` +projects. -Projects built by try_compile and try_run are built synchronously -during the CMake configuration step. Therefore a specific build +Projects built by :command:`try_compile` and :command:`try_run` are built +synchronously during the CMake configuration step. Therefore a specific build configuration must be chosen even if the generated build system supports multiple configurations. diff --git a/Help/variable/CMAKE_USER_MAKE_RULES_OVERRIDE.rst b/Help/variable/CMAKE_USER_MAKE_RULES_OVERRIDE.rst index 5a4c86b..9af0d97 100644 --- a/Help/variable/CMAKE_USER_MAKE_RULES_OVERRIDE.rst +++ b/Help/variable/CMAKE_USER_MAKE_RULES_OVERRIDE.rst @@ -4,20 +4,20 @@ CMAKE_USER_MAKE_RULES_OVERRIDE Specify a CMake file that overrides platform information. CMake loads the specified file while enabling support for each -language from either the project() or enable_language() commands. It -is loaded after CMake's builtin compiler and platform information +language from either the :command:`project` or :command:`enable_language` +commands. It is loaded after CMake's builtin compiler and platform information modules have been loaded but before the information is used. The file may set platform information variables to override CMake's defaults. This feature is intended for use only in overriding information variables that must be set before CMake builds its first test project to check that the compiler for a language works. It should not be -used to load a file in cases that a normal include() will work. Use +used to load a file in cases that a normal :command:`include` will work. Use it only as a last resort for behavior that cannot be achieved any -other way. For example, one may set CMAKE_C_FLAGS_INIT to change the -default value used to initialize CMAKE_C_FLAGS before it is cached. -The override file should NOT be used to set anything that could be set -after languages are enabled, such as variables like -CMAKE_RUNTIME_OUTPUT_DIRECTORY that affect the placement of binaries. -Information set in the file will be used for try_compile and try_run -builds too. +other way. For example, one may set ``CMAKE_C_FLAGS_INIT`` to change the +default value used to initialize :variable:`CMAKE_C_FLAGS _FLAGS>` +before it is cached. The override file should NOT be used to set anything +that could be set after languages are enabled, such as variables like +:variable:`CMAKE_RUNTIME_OUTPUT_DIRECTORY` that affect the placement of +binaries. Information set in the file will be used for :command:`try_compile` +and :command:`try_run` builds too. diff --git a/Help/variable/CMAKE_USER_MAKE_RULES_OVERRIDE_LANG.rst b/Help/variable/CMAKE_USER_MAKE_RULES_OVERRIDE_LANG.rst index e6d2c68..e7139ac 100644 --- a/Help/variable/CMAKE_USER_MAKE_RULES_OVERRIDE_LANG.rst +++ b/Help/variable/CMAKE_USER_MAKE_RULES_OVERRIDE_LANG.rst @@ -1,7 +1,8 @@ CMAKE_USER_MAKE_RULES_OVERRIDE_ ------------------------------------- -Specify a CMake file that overrides platform information for . +Specify a CMake file that overrides platform information for ````. -This is a language-specific version of CMAKE_USER_MAKE_RULES_OVERRIDE -loaded only when enabling language . +This is a language-specific version of +:variable:`CMAKE_USER_MAKE_RULES_OVERRIDE` loaded only when enabling language +````. diff --git a/Help/variable/CMAKE_VERBOSE_MAKEFILE.rst b/Help/variable/CMAKE_VERBOSE_MAKEFILE.rst index 2420a25..232a2fd 100644 --- a/Help/variable/CMAKE_VERBOSE_MAKEFILE.rst +++ b/Help/variable/CMAKE_VERBOSE_MAKEFILE.rst @@ -3,7 +3,7 @@ CMAKE_VERBOSE_MAKEFILE Enable verbose output from Makefile builds. -This variable is a cache entry initialized (to FALSE) by +This variable is a cache entry initialized (to ``FALSE``) by the :command:`project` command. Users may enable the option in their local build tree to get more verbose output from Makefile builds and show each command line as it is launched. diff --git a/Help/variable/CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD.rst b/Help/variable/CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD.rst index 68f1ff6..f54472a 100644 --- a/Help/variable/CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD.rst +++ b/Help/variable/CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD.rst @@ -1,8 +1,8 @@ CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD ----------------------------------------- -Include INSTALL target to default build. +Include ``INSTALL`` target to default build. -In Visual Studio solution, by default the INSTALL target will not be part of -the default build. Setting this variable will enable the INSTALL target to be -part of the default build. +In Visual Studio solution, by default the ``INSTALL`` target will not be part +of the default build. Setting this variable will enable the ``INSTALL`` target +to be part of the default build. diff --git a/Help/variable/CMAKE_VS_INTEL_Fortran_PROJECT_VERSION.rst b/Help/variable/CMAKE_VS_INTEL_Fortran_PROJECT_VERSION.rst index 7e9d317..0be10e5 100644 --- a/Help/variable/CMAKE_VS_INTEL_Fortran_PROJECT_VERSION.rst +++ b/Help/variable/CMAKE_VS_INTEL_Fortran_PROJECT_VERSION.rst @@ -1,7 +1,7 @@ CMAKE_VS_INTEL_Fortran_PROJECT_VERSION -------------------------------------- -When generating for Visual Studio 7 or greater with the Intel Fortran -plugin installed, this specifies the .vfproj project file format +When generating for :generator:`Visual Studio 7` or greater with the Intel +Fortran plugin installed, this specifies the ``.vfproj`` project file format version. This is intended for internal use by CMake and should not be used by project code. diff --git a/Help/variable/CMAKE_VS_PLATFORM_TOOLSET.rst b/Help/variable/CMAKE_VS_PLATFORM_TOOLSET.rst index 08c6061..144a41d 100644 --- a/Help/variable/CMAKE_VS_PLATFORM_TOOLSET.rst +++ b/Help/variable/CMAKE_VS_PLATFORM_TOOLSET.rst @@ -5,6 +5,6 @@ Visual Studio Platform Toolset name. VS 10 and above use MSBuild under the hood and support multiple compiler toolchains. CMake may specify a toolset explicitly, such as -"v110" for VS 11 or "Windows7.1SDK" for 64-bit support in VS 10 +``v110`` for VS 11 or ``Windows7.1SDK`` for 64-bit support in VS 10 Express. CMake provides the name of the chosen toolset in this variable. diff --git a/Help/variable/CMAKE_WARN_DEPRECATED.rst b/Help/variable/CMAKE_WARN_DEPRECATED.rst index 2a13895..7b8533c 100644 --- a/Help/variable/CMAKE_WARN_DEPRECATED.rst +++ b/Help/variable/CMAKE_WARN_DEPRECATED.rst @@ -3,8 +3,8 @@ CMAKE_WARN_DEPRECATED Whether to issue deprecation warnings for macros and functions. -If TRUE, this can be used by macros and functions to issue deprecation -warnings. This variable is FALSE by default. +If ``TRUE``, this can be used by macros and functions to issue deprecation +warnings. This variable is ``FALSE`` by default. These warnings can be enabled with the ``-Wdeprecated`` option, or disabled with the ``-Wno-deprecated`` option, when running diff --git a/Help/variable/CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION.rst b/Help/variable/CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION.rst index f6a188d..81c1158 100644 --- a/Help/variable/CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION.rst +++ b/Help/variable/CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION.rst @@ -1,8 +1,9 @@ CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION ------------------------------------------ -Ask cmake_install.cmake script to warn each time a file with absolute INSTALL DESTINATION is encountered. +Ask ``cmake_install.cmake`` script to warn each time a file with absolute +``INSTALL DESTINATION`` is encountered. -This variable is used by CMake-generated cmake_install.cmake scripts. -If one sets this variable to ON while running the script, it may get +This variable is used by CMake-generated ``cmake_install.cmake`` scripts. +If one sets this variable to ``ON`` while running the script, it may get warning messages from the script. diff --git a/Help/variable/CMAKE_WIN32_EXECUTABLE.rst b/Help/variable/CMAKE_WIN32_EXECUTABLE.rst index 3e1e0dd..b96abba 100644 --- a/Help/variable/CMAKE_WIN32_EXECUTABLE.rst +++ b/Help/variable/CMAKE_WIN32_EXECUTABLE.rst @@ -1,7 +1,7 @@ CMAKE_WIN32_EXECUTABLE ---------------------- -Default value for WIN32_EXECUTABLE of targets. +Default value for :prop_tgt:`WIN32_EXECUTABLE` of targets. -This variable is used to initialize the WIN32_EXECUTABLE property on -all the targets. See that target property for additional information. +This variable is used to initialize the :prop_tgt:`WIN32_EXECUTABLE` property +on all the targets. See that target property for additional information. diff --git a/Help/variable/CMAKE_XCODE_ATTRIBUTE_an-attribute.rst b/Help/variable/CMAKE_XCODE_ATTRIBUTE_an-attribute.rst index 096f64e..122b9f6 100644 --- a/Help/variable/CMAKE_XCODE_ATTRIBUTE_an-attribute.rst +++ b/Help/variable/CMAKE_XCODE_ATTRIBUTE_an-attribute.rst @@ -3,8 +3,8 @@ CMAKE_XCODE_ATTRIBUTE_ Set Xcode target attributes directly. -Tell the Xcode generator to set '' to a given value in -the generated Xcode project. Ignored on other generators. +Tell the :generator:`Xcode` generator to set '' to a given value +in the generated Xcode project. Ignored on other generators. See the :prop_tgt:`XCODE_ATTRIBUTE_` target property to set attributes on a specific target. diff --git a/Help/variable/CMAKE_XCODE_PLATFORM_TOOLSET.rst b/Help/variable/CMAKE_XCODE_PLATFORM_TOOLSET.rst index f0a4841..210da52 100644 --- a/Help/variable/CMAKE_XCODE_PLATFORM_TOOLSET.rst +++ b/Help/variable/CMAKE_XCODE_PLATFORM_TOOLSET.rst @@ -3,7 +3,7 @@ CMAKE_XCODE_PLATFORM_TOOLSET Xcode compiler selection. -Xcode supports selection of a compiler from one of the installed +:generator:`Xcode` supports selection of a compiler from one of the installed toolsets. CMake provides the name of the chosen toolset in this -variable, if any is explicitly selected (e.g. via the cmake -T -option). +variable, if any is explicitly selected (e.g. via the :manual:`cmake(1)` +``-T`` option). diff --git a/Help/variable/CPACK_ABSOLUTE_DESTINATION_FILES.rst b/Help/variable/CPACK_ABSOLUTE_DESTINATION_FILES.rst index d836629..928fe45 100644 --- a/Help/variable/CPACK_ABSOLUTE_DESTINATION_FILES.rst +++ b/Help/variable/CPACK_ABSOLUTE_DESTINATION_FILES.rst @@ -1,10 +1,10 @@ CPACK_ABSOLUTE_DESTINATION_FILES -------------------------------- -List of files which have been installed using an ABSOLUTE DESTINATION path. +List of files which have been installed using an ``ABSOLUTE DESTINATION`` path. This variable is a Read-Only variable which is set internally by CPack during installation and before packaging using -CMAKE_ABSOLUTE_DESTINATION_FILES defined in cmake_install.cmake +:variable:`CMAKE_ABSOLUTE_DESTINATION_FILES` defined in ``cmake_install.cmake`` scripts. The value can be used within CPack project configuration -file and/or CPack.cmake file of generator. +file and/or ``CPack.cmake`` file of ```` generator. diff --git a/Help/variable/CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY.rst b/Help/variable/CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY.rst index e938978..6cf75e4 100644 --- a/Help/variable/CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY.rst +++ b/Help/variable/CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY.rst @@ -3,6 +3,6 @@ CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY Boolean toggle to include/exclude top level directory (component case). -Similar usage as CPACK_INCLUDE_TOPLEVEL_DIRECTORY but for the -component case. See CPACK_INCLUDE_TOPLEVEL_DIRECTORY documentation -for the detail. +Similar usage as :variable:`CPACK_INCLUDE_TOPLEVEL_DIRECTORY` but for the +component case. See :variable:`CPACK_INCLUDE_TOPLEVEL_DIRECTORY` +documentation for the detail. diff --git a/Help/variable/CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION.rst b/Help/variable/CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION.rst index 4d96385..5dad6bd 100644 --- a/Help/variable/CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION.rst +++ b/Help/variable/CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION.rst @@ -1,10 +1,11 @@ CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION ------------------------------------------- -Ask CPack to error out as soon as a file with absolute INSTALL DESTINATION is encountered. +Ask CPack to error out as soon as a file with absolute ``INSTALL DESTINATION`` +is encountered. The fatal error is emitted before the installation of the offending -file takes place. Some CPack generators, like NSIS,enforce this +file takes place. Some CPack generators, like NSIS, enforce this internally. This variable triggers the definition -ofCMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION when CPack runsVariables -common to all CPack generators +of :variable:`CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION` when CPack +runs. diff --git a/Help/variable/CPACK_INCLUDE_TOPLEVEL_DIRECTORY.rst b/Help/variable/CPACK_INCLUDE_TOPLEVEL_DIRECTORY.rst index 4f96bff..b8e9105 100644 --- a/Help/variable/CPACK_INCLUDE_TOPLEVEL_DIRECTORY.rst +++ b/Help/variable/CPACK_INCLUDE_TOPLEVEL_DIRECTORY.rst @@ -4,16 +4,17 @@ CPACK_INCLUDE_TOPLEVEL_DIRECTORY Boolean toggle to include/exclude top level directory. When preparing a package CPack installs the item under the so-called -top level directory. The purpose of is to include (set to 1 or ON or -TRUE) the top level directory in the package or not (set to 0 or OFF -or FALSE). +top level directory. The purpose of is to include (set to ``1`` or ``ON`` or +``TRUE``) the top level directory in the package or not (set to ``0`` or +``OFF`` or ``FALSE``). Each CPack generator has a built-in default value for this variable. E.g. Archive generators (ZIP, TGZ, ...) includes the top level whereas RPM or DEB don't. The user may override the default value by setting this variable. -There is a similar variable CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY -which may be used to override the behavior for the component packaging +There is a similar variable +:variable:`CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY` which may be used +to override the behavior for the component packaging case which may have different default value for historical (now backward compatibility) reason. diff --git a/Help/variable/CPACK_INSTALL_SCRIPT.rst b/Help/variable/CPACK_INSTALL_SCRIPT.rst index 59b8cd7..12a48a4 100644 --- a/Help/variable/CPACK_INSTALL_SCRIPT.rst +++ b/Help/variable/CPACK_INSTALL_SCRIPT.rst @@ -5,4 +5,4 @@ Extra CMake script provided by the user. If set this CMake script will be executed by CPack during its local [CPack-private] installation which is done right before packaging the -files. The script is not called by e.g.: make install. +files. The script is not called by e.g.: ``make install``. diff --git a/Help/variable/CPACK_PACKAGING_INSTALL_PREFIX.rst b/Help/variable/CPACK_PACKAGING_INSTALL_PREFIX.rst index f9cfa1b..f423e2e 100644 --- a/Help/variable/CPACK_PACKAGING_INSTALL_PREFIX.rst +++ b/Help/variable/CPACK_PACKAGING_INSTALL_PREFIX.rst @@ -3,11 +3,13 @@ CPACK_PACKAGING_INSTALL_PREFIX The prefix used in the built package. -Each CPack generator has a default value (like /usr). This default -value may be overwritten from the CMakeLists.txt or the cpack command -line by setting an alternative value. +Each CPack generator has a default value (like ``/usr``). This default +value may be overwritten from the ``CMakeLists.txt`` or the :manual:`cpack(1)` +command line by setting an alternative value. Example: -e.g. set(CPACK_PACKAGING_INSTALL_PREFIX "/opt") +:: -This is not the same purpose as CMAKE_INSTALL_PREFIX which is used + set(CPACK_PACKAGING_INSTALL_PREFIX "/opt") + +This is not the same purpose as :variable:`CMAKE_INSTALL_PREFIX` which is used when installing from the build tree without building a package. diff --git a/Help/variable/CPACK_SET_DESTDIR.rst b/Help/variable/CPACK_SET_DESTDIR.rst index 69d82e6..27fd355 100644 --- a/Help/variable/CPACK_SET_DESTDIR.rst +++ b/Help/variable/CPACK_SET_DESTDIR.rst @@ -1,30 +1,31 @@ CPACK_SET_DESTDIR ----------------- -Boolean toggle to make CPack use DESTDIR mechanism when packaging. +Boolean toggle to make CPack use ``DESTDIR`` mechanism when packaging. -DESTDIR means DESTination DIRectory. It is commonly used by makefile +``DESTDIR`` means DESTination DIRectory. It is commonly used by makefile users in order to install software at non-default location. It is a basic relocation mechanism that should not be used on Windows (see -CMAKE_INSTALL_PREFIX documentation). It is usually invoked like this: +:variable:`CMAKE_INSTALL_PREFIX` documentation). It is usually invoked like +this: :: make DESTDIR=/home/john install which will install the concerned software using the installation -prefix, e.g. "/usr/local" prepended with the DESTDIR value which -finally gives "/home/john/usr/local". When preparing a package, CPack +prefix, e.g. ``/usr/local`` prepended with the ``DESTDIR`` value which +finally gives ``/home/john/usr/local``. When preparing a package, CPack first installs the items to be packaged in a local (to the build tree) -directory by using the same DESTDIR mechanism. Nevertheless, if -CPACK_SET_DESTDIR is set then CPack will set DESTDIR before doing the +directory by using the same ``DESTDIR`` mechanism. Nevertheless, if +``CPACK_SET_DESTDIR`` is set then CPack will set ``DESTDIR`` before doing the local install. The most noticeable difference is that without -CPACK_SET_DESTDIR, CPack uses CPACK_PACKAGING_INSTALL_PREFIX as a -prefix whereas with CPACK_SET_DESTDIR set, CPack will use -CMAKE_INSTALL_PREFIX as a prefix. +``CPACK_SET_DESTDIR``, CPack uses :variable:`CPACK_PACKAGING_INSTALL_PREFIX` +as a prefix whereas with ``CPACK_SET_DESTDIR`` set, CPack will use +:variable:`CMAKE_INSTALL_PREFIX` as a prefix. -Manually setting CPACK_SET_DESTDIR may help (or simply be necessary) -if some install rules uses absolute DESTINATION (see CMake INSTALL -command). However, starting with CPack/CMake 2.8.3 RPM and DEB -installers tries to handle DESTDIR automatically so that it is seldom -necessary for the user to set it. +Manually setting ``CPACK_SET_DESTDIR`` may help (or simply be necessary) +if some install rules uses absolute ``DESTINATION`` (see CMake +:command:`install` command). However, starting with CPack/CMake 2.8.3 RPM +and DEB installers tries to handle ``DESTDIR`` automatically so that it is +seldom necessary for the user to set it. diff --git a/Help/variable/CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION.rst b/Help/variable/CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION.rst index 8d6f54f..3fc5cca 100644 --- a/Help/variable/CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION.rst +++ b/Help/variable/CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION.rst @@ -1,8 +1,9 @@ CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION ------------------------------------------ -Ask CPack to warn each time a file with absolute INSTALL DESTINATION is encountered. +Ask CPack to warn each time a file with absolute ``INSTALL DESTINATION`` is +encountered. This variable triggers the definition of -CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION when CPack runs -cmake_install.cmake scripts. +:variable:`CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION` when CPack runs +``cmake_install.cmake`` scripts. diff --git a/Help/variable/CTEST_COVERAGE_COMMAND.rst b/Help/variable/CTEST_COVERAGE_COMMAND.rst index a669dd7..0491d42 100644 --- a/Help/variable/CTEST_COVERAGE_COMMAND.rst +++ b/Help/variable/CTEST_COVERAGE_COMMAND.rst @@ -12,12 +12,12 @@ Java project can generate a series of XML files. The Cobertura Coverage parser expects to read the coverage data from a single XML file which contains the coverage data for all modules. -Cobertura has a program with the ability to merge given cobertura.ser files +Cobertura has a program with the ability to merge given ``cobertura.ser`` files and then another program to generate a combined XML file from the previous merged file. For command line testing, this can be done by hand prior to CTest looking for the coverage files. For script builds, set the ``CTEST_COVERAGE_COMMAND`` variable to point to a file which will -perform these same steps, such as a .sh or .bat file. +perform these same steps, such as a ``.sh`` or ``.bat`` file. .. code-block:: cmake @@ -35,17 +35,17 @@ the :command:`configure_file` command and might contain the following code: cobertura-report --datafile coberturamerge.ser --destination . \ --format xml $SourceDirs -The script uses ``find`` to capture the paths to all of the cobertura.ser files -found below the project's source directory. It keeps the list of files and -supplies it as an argument to the ``cobertura-merge`` program. The ``--datafile`` -argument signifies where the result of the merge will be kept. +The script uses ``find`` to capture the paths to all of the ``cobertura.ser`` +files found below the project's source directory. It keeps the list of files +and supplies it as an argument to the ``cobertura-merge`` program. The +``--datafile`` argument signifies where the result of the merge will be kept. The combined ``coberturamerge.ser`` file is then used to generate the XML report -using the ``cobertura-report`` program. The call to the cobertura-report program -requires some named arguments. +using the ``cobertura-report`` program. The call to the cobertura-report +program requires some named arguments. ``--datafila`` - path to the merged .ser file + path to the merged ``.ser`` file ``--destination`` path to put the output files(s) @@ -54,7 +54,7 @@ requires some named arguments. file format to write output in: xml or html The rest of the supplied arguments consist of the full paths to the -/src/main/java directories of each module within the souce tree. These +``/src/main/java`` directories of each module within the souce tree. These directories are needed and should not be forgotten. .. _`Cobertura`: http://cobertura.github.io/cobertura/ diff --git a/Help/variable/CTEST_MEMORYCHECK_TYPE.rst b/Help/variable/CTEST_MEMORYCHECK_TYPE.rst index f1087c0..b963293 100644 --- a/Help/variable/CTEST_MEMORYCHECK_TYPE.rst +++ b/Help/variable/CTEST_MEMORYCHECK_TYPE.rst @@ -3,5 +3,6 @@ CTEST_MEMORYCHECK_TYPE Specify the CTest ``MemoryCheckType`` setting in a :manual:`ctest(1)` dashboard client script. -Valid values are Valgrind, Purify, BoundsChecker, and ThreadSanitizer, -AddressSanitizer, MemorySanitizer, and UndefinedBehaviorSanitizer. +Valid values are ``Valgrind``, ``Purify``, ``BoundsChecker``, and +``ThreadSanitizer``, ``AddressSanitizer``, ``MemorySanitizer``, and +``UndefinedBehaviorSanitizer``. diff --git a/Help/variable/CYGWIN.rst b/Help/variable/CYGWIN.rst index c168878..0039e07 100644 --- a/Help/variable/CYGWIN.rst +++ b/Help/variable/CYGWIN.rst @@ -1,6 +1,6 @@ CYGWIN ------ -True for Cygwin. +``True`` for Cygwin. -Set to true when using Cygwin. +Set to ``true`` when using Cygwin. diff --git a/Help/variable/ENV.rst b/Help/variable/ENV.rst index 977afc3..368152a 100644 --- a/Help/variable/ENV.rst +++ b/Help/variable/ENV.rst @@ -3,5 +3,5 @@ ENV Access environment variables. -Use the syntax $ENV{VAR} to read environment variable VAR. See also -the set() command to set ENV{VAR}. +Use the syntax ``$ENV{VAR}`` to read environment variable ``VAR``. See also +the :command:`set` command to set ``ENV{VAR}``. diff --git a/Help/variable/EXECUTABLE_OUTPUT_PATH.rst b/Help/variable/EXECUTABLE_OUTPUT_PATH.rst index 7079230..26d3e92 100644 --- a/Help/variable/EXECUTABLE_OUTPUT_PATH.rst +++ b/Help/variable/EXECUTABLE_OUTPUT_PATH.rst @@ -3,6 +3,6 @@ EXECUTABLE_OUTPUT_PATH Old executable location variable. -The target property RUNTIME_OUTPUT_DIRECTORY supercedes this variable -for a target if it is set. Executable targets are otherwise placed in +The target property :prop_tgt:`RUNTIME_OUTPUT_DIRECTORY` supercedes this +variable for a target if it is set. Executable targets are otherwise placed in this directory. diff --git a/Help/variable/LIBRARY_OUTPUT_PATH.rst b/Help/variable/LIBRARY_OUTPUT_PATH.rst index 1c1f8ae..ba02911 100644 --- a/Help/variable/LIBRARY_OUTPUT_PATH.rst +++ b/Help/variable/LIBRARY_OUTPUT_PATH.rst @@ -3,7 +3,7 @@ LIBRARY_OUTPUT_PATH Old library location variable. -The target properties ARCHIVE_OUTPUT_DIRECTORY, -LIBRARY_OUTPUT_DIRECTORY, and RUNTIME_OUTPUT_DIRECTORY supercede this -variable for a target if they are set. Library targets are otherwise -placed in this directory. +The target properties :prop_tgt:`ARCHIVE_OUTPUT_DIRECTORY`, +:prop_tgt:`LIBRARY_OUTPUT_DIRECTORY`, and :prop_tgt:`RUNTIME_OUTPUT_DIRECTORY` +supercede this variable for a target if they are set. Library targets are +otherwise placed in this directory. diff --git a/Help/variable/MINGW.rst b/Help/variable/MINGW.rst index 521d417..6d29be4 100644 --- a/Help/variable/MINGW.rst +++ b/Help/variable/MINGW.rst @@ -1,6 +1,6 @@ MINGW ----- -True when using MinGW +``True`` when using MinGW -Set to true when the compiler is some version of MinGW. +Set to ``true`` when the compiler is some version of MinGW. diff --git a/Help/variable/MSVC.rst b/Help/variable/MSVC.rst index e9f931b..913ed08 100644 --- a/Help/variable/MSVC.rst +++ b/Help/variable/MSVC.rst @@ -1,6 +1,6 @@ MSVC ---- -True when using Microsoft Visual C +``True`` when using Microsoft Visual C++. -Set to true when the compiler is some version of Microsoft Visual C. +Set to ``true`` when the compiler is some version of Microsoft Visual C++. diff --git a/Help/variable/MSVC10.rst b/Help/variable/MSVC10.rst index 894c5aa..33692ad 100644 --- a/Help/variable/MSVC10.rst +++ b/Help/variable/MSVC10.rst @@ -1,6 +1,6 @@ MSVC10 ------ -True when using Microsoft Visual C 10.0 +``True`` when using Microsoft Visual C++ 10.0 -Set to true when the compiler is version 10.0 of Microsoft Visual C. +Set to ``true`` when the compiler is version 10.0 of Microsoft Visual C++. diff --git a/Help/variable/MSVC11.rst b/Help/variable/MSVC11.rst index fe25297..3ab606d 100644 --- a/Help/variable/MSVC11.rst +++ b/Help/variable/MSVC11.rst @@ -1,6 +1,6 @@ MSVC11 ------ -True when using Microsoft Visual C 11.0 +``True`` when using Microsoft Visual C++ 11.0 -Set to true when the compiler is version 11.0 of Microsoft Visual C. +Set to ``true`` when the compiler is version 11.0 of Microsoft Visual C++. diff --git a/Help/variable/MSVC12.rst b/Help/variable/MSVC12.rst index 216d3d3..15fa64b 100644 --- a/Help/variable/MSVC12.rst +++ b/Help/variable/MSVC12.rst @@ -1,6 +1,6 @@ MSVC12 ------ -True when using Microsoft Visual C 12.0 +``True`` when using Microsoft Visual C++ 12.0. -Set to true when the compiler is version 12.0 of Microsoft Visual C. +Set to ``true`` when the compiler is version 12.0 of Microsoft Visual C++. diff --git a/Help/variable/MSVC14.rst b/Help/variable/MSVC14.rst index 33c782b..0b9125d 100644 --- a/Help/variable/MSVC14.rst +++ b/Help/variable/MSVC14.rst @@ -1,6 +1,6 @@ MSVC14 ------ -True when using Microsoft Visual C 14.0 +``True`` when using Microsoft Visual C++ 14.0. -Set to true when the compiler is version 14.0 of Microsoft Visual C. +Set to ``true`` when the compiler is version 14.0 of Microsoft Visual C++. diff --git a/Help/variable/MSVC60.rst b/Help/variable/MSVC60.rst index 572e9f4..14f09cf 100644 --- a/Help/variable/MSVC60.rst +++ b/Help/variable/MSVC60.rst @@ -1,6 +1,6 @@ MSVC60 ------ -True when using Microsoft Visual C 6.0 +``True`` when using Microsoft Visual C++ 6.0. -Set to true when the compiler is version 6.0 of Microsoft Visual C. +Set to ``true`` when the compiler is version 6.0 of Microsoft Visual C++. diff --git a/Help/variable/MSVC70.rst b/Help/variable/MSVC70.rst index b1b7a88..76fa96f 100644 --- a/Help/variable/MSVC70.rst +++ b/Help/variable/MSVC70.rst @@ -1,6 +1,6 @@ MSVC70 ------ -True when using Microsoft Visual C 7.0 +``True`` when using Microsoft Visual C++ 7.0. -Set to true when the compiler is version 7.0 of Microsoft Visual C. +Set to ``true`` when the compiler is version 7.0 of Microsoft Visual C++. diff --git a/Help/variable/MSVC71.rst b/Help/variable/MSVC71.rst index af309a6..d69d4fc 100644 --- a/Help/variable/MSVC71.rst +++ b/Help/variable/MSVC71.rst @@ -1,6 +1,6 @@ MSVC71 ------ -True when using Microsoft Visual C 7.1 +``True`` when using Microsoft Visual C++ 7.1. -Set to true when the compiler is version 7.1 of Microsoft Visual C. +Set to ``true`` when the compiler is version 7.1 of Microsoft Visual C++. diff --git a/Help/variable/MSVC80.rst b/Help/variable/MSVC80.rst index 306c67f..b17777c 100644 --- a/Help/variable/MSVC80.rst +++ b/Help/variable/MSVC80.rst @@ -1,6 +1,6 @@ MSVC80 ------ -True when using Microsoft Visual C 8.0 +``True`` when using Microsoft Visual C++ 8.0. -Set to true when the compiler is version 8.0 of Microsoft Visual C. +Set to ``true`` when the compiler is version 8.0 of Microsoft Visual C++. diff --git a/Help/variable/MSVC90.rst b/Help/variable/MSVC90.rst index 3cfcc67..7162d6c 100644 --- a/Help/variable/MSVC90.rst +++ b/Help/variable/MSVC90.rst @@ -1,6 +1,6 @@ MSVC90 ------ -True when using Microsoft Visual C 9.0 +``True`` when using Microsoft Visual C++ 9.0. -Set to true when the compiler is version 9.0 of Microsoft Visual C. +Set to ``true`` when the compiler is version 9.0 of Microsoft Visual C++. diff --git a/Help/variable/MSVC_IDE.rst b/Help/variable/MSVC_IDE.rst index 055f876..027d1bc 100644 --- a/Help/variable/MSVC_IDE.rst +++ b/Help/variable/MSVC_IDE.rst @@ -1,7 +1,7 @@ MSVC_IDE -------- -True when using the Microsoft Visual C IDE +``True`` when using the Microsoft Visual C++ IDE. -Set to true when the target platform is the Microsoft Visual C IDE, as +Set to ``true`` when the target platform is the Microsoft Visual C++ IDE, as opposed to the command line compiler. diff --git a/Help/variable/UNIX.rst b/Help/variable/UNIX.rst index 82e3454..0877b7c 100644 --- a/Help/variable/UNIX.rst +++ b/Help/variable/UNIX.rst @@ -1,7 +1,7 @@ UNIX ---- -True for UNIX and UNIX like operating systems. +``True`` for UNIX and UNIX like operating systems. -Set to true when the target system is UNIX or UNIX like (i.e. APPLE -and CYGWIN). +Set to ``true`` when the target system is UNIX or UNIX like (i.e. +:variable:`APPLE` and :variable:`CYGWIN`). diff --git a/Help/variable/WIN32.rst b/Help/variable/WIN32.rst index 8cf7bf3..2189069 100644 --- a/Help/variable/WIN32.rst +++ b/Help/variable/WIN32.rst @@ -1,6 +1,6 @@ WIN32 ----- -True on windows systems, including win64. +``True`` on Windows systems, including Win64. -Set to true when the target system is Windows. +Set to ``true`` when the target system is Windows. diff --git a/Help/variable/XCODE_VERSION.rst b/Help/variable/XCODE_VERSION.rst index b6f0403..b85d41e 100644 --- a/Help/variable/XCODE_VERSION.rst +++ b/Help/variable/XCODE_VERSION.rst @@ -1,7 +1,7 @@ XCODE_VERSION ------------- -Version of Xcode (Xcode generator only). +Version of Xcode (:generator:`Xcode` generator only). Under the Xcode generator, this is the version of Xcode as specified -in "Xcode.app/Contents/version.plist" (such as "3.1.2"). +in ``Xcode.app/Contents/version.plist`` (such as ``3.1.2``). ----------------------------------------------------------------------- Summary of changes: Help/manual/cmake.1.rst | 2 ++ Help/variable/APPLE.rst | 4 +-- Help/variable/BORLAND.rst | 4 +-- Help/variable/BUILD_SHARED_LIBS.rst | 6 ++-- Help/variable/CMAKE_ABSOLUTE_DESTINATION_FILES.rst | 4 +-- .../CMAKE_ANDROID_NATIVE_LIB_DEPENDENCIES.rst | 4 +-- .../CMAKE_ANDROID_NATIVE_LIB_DIRECTORIES.rst | 4 +-- Help/variable/CMAKE_ARGC.rst | 5 ++-- Help/variable/CMAKE_ARGV0.rst | 8 ++--- Help/variable/CMAKE_AUTOMOC_RELAXED_MODE.rst | 12 ++++---- Help/variable/CMAKE_AUTORCC.rst | 4 +-- Help/variable/CMAKE_AUTOUIC.rst | 4 +-- Help/variable/CMAKE_BINARY_DIR.rst | 2 +- Help/variable/CMAKE_BUILD_TYPE.rst | 25 ++++++++-------- Help/variable/CMAKE_BUILD_WITH_INSTALL_RPATH.rst | 10 +++---- Help/variable/CMAKE_CACHEFILE_DIR.rst | 6 ++-- Help/variable/CMAKE_CACHE_MAJOR_VERSION.rst | 2 +- Help/variable/CMAKE_CACHE_MINOR_VERSION.rst | 2 +- Help/variable/CMAKE_CACHE_PATCH_VERSION.rst | 2 +- Help/variable/CMAKE_CFG_INTDIR.rst | 21 ++++++------- Help/variable/CMAKE_CL_64.rst | 4 +-- Help/variable/CMAKE_COLOR_MAKEFILE.rst | 4 +-- Help/variable/CMAKE_COMMAND.rst | 8 ++--- Help/variable/CMAKE_COMPILER_IS_GNULANG.rst | 6 ++-- Help/variable/CMAKE_CONFIGURATION_TYPES.rst | 6 ++-- Help/variable/CMAKE_CONFIG_POSTFIX.rst | 6 ++-- Help/variable/CMAKE_CTEST_COMMAND.rst | 8 ++--- Help/variable/CMAKE_CURRENT_BINARY_DIR.rst | 2 +- Help/variable/CMAKE_CURRENT_LIST_DIR.rst | 6 ++-- Help/variable/CMAKE_CURRENT_LIST_FILE.rst | 2 +- Help/variable/CMAKE_CXX_COMPILE_FEATURES.rst | 4 +-- Help/variable/CMAKE_CXX_EXTENSIONS.rst | 2 +- Help/variable/CMAKE_CXX_STANDARD.rst | 2 +- Help/variable/CMAKE_CXX_STANDARD_REQUIRED.rst | 2 +- Help/variable/CMAKE_C_COMPILE_FEATURES.rst | 4 +-- Help/variable/CMAKE_C_EXTENSIONS.rst | 2 +- Help/variable/CMAKE_C_STANDARD.rst | 2 +- Help/variable/CMAKE_C_STANDARD_REQUIRED.rst | 2 +- Help/variable/CMAKE_DEBUG_POSTFIX.rst | 4 +-- Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst | 6 ++-- .../CMAKE_DISABLE_FIND_PACKAGE_PackageName.rst | 9 +++--- Help/variable/CMAKE_DL_LIBS.rst | 6 ++-- Help/variable/CMAKE_EDIT_COMMAND.rst | 6 ++-- Help/variable/CMAKE_ERROR_DEPRECATED.rst | 4 +-- ...CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION.rst | 5 ++-- Help/variable/CMAKE_EXECUTABLE_SUFFIX.rst | 4 +-- Help/variable/CMAKE_EXE_LINKER_FLAGS_CONFIG.rst | 2 +- Help/variable/CMAKE_EXTRA_GENERATOR.rst | 9 +++--- .../CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES.rst | 2 +- Help/variable/CMAKE_FIND_LIBRARY_PREFIXES.rst | 6 ++-- Help/variable/CMAKE_FIND_LIBRARY_SUFFIXES.rst | 6 ++-- Help/variable/CMAKE_FIND_NO_INSTALL_PREFIX.rst | 6 ++-- .../variable/CMAKE_FIND_PACKAGE_WARN_NO_MODULE.rst | 18 ++++++------ Help/variable/CMAKE_FIND_ROOT_PATH.rst | 4 +-- Help/variable/CMAKE_Fortran_FORMAT.rst | 6 ++-- Help/variable/CMAKE_Fortran_MODDIR_DEFAULT.rst | 6 ++-- Help/variable/CMAKE_Fortran_MODDIR_FLAG.rst | 2 +- Help/variable/CMAKE_Fortran_MODOUT_FLAG.rst | 2 +- Help/variable/CMAKE_Fortran_MODULE_DIRECTORY.rst | 2 +- Help/variable/CMAKE_GENERATOR.rst | 4 +-- Help/variable/CMAKE_GENERATOR_PLATFORM.rst | 4 +-- Help/variable/CMAKE_GENERATOR_TOOLSET.rst | 4 +-- Help/variable/CMAKE_GNUtoMS.rst | 6 ++-- Help/variable/CMAKE_HOST_APPLE.rst | 4 +-- Help/variable/CMAKE_HOST_SYSTEM_NAME.rst | 2 +- Help/variable/CMAKE_HOST_SYSTEM_PROCESSOR.rst | 4 +-- Help/variable/CMAKE_HOST_SYSTEM_VERSION.rst | 2 +- Help/variable/CMAKE_HOST_UNIX.rst | 4 +-- Help/variable/CMAKE_HOST_WIN32.rst | 4 +-- Help/variable/CMAKE_IMPORT_LIBRARY_PREFIX.rst | 2 +- Help/variable/CMAKE_IMPORT_LIBRARY_SUFFIX.rst | 2 +- Help/variable/CMAKE_INCLUDE_CURRENT_DIR.rst | 8 ++--- .../CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE.rst | 10 ++++--- Help/variable/CMAKE_INCLUDE_DIRECTORIES_BEFORE.rst | 7 +++-- .../CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE.rst | 4 +-- .../CMAKE_INSTALL_DEFAULT_COMPONENT_NAME.rst | 8 ++--- Help/variable/CMAKE_INSTALL_NAME_DIR.rst | 6 ++-- Help/variable/CMAKE_INSTALL_PREFIX.rst | 25 ++++++++-------- Help/variable/CMAKE_INSTALL_RPATH.rst | 2 +- .../variable/CMAKE_INSTALL_RPATH_USE_LINK_PATH.rst | 6 ++-- Help/variable/CMAKE_LANG_ARCHIVE_APPEND.rst | 7 +++-- Help/variable/CMAKE_LANG_ARCHIVE_CREATE.rst | 7 +++-- Help/variable/CMAKE_LANG_ARCHIVE_FINISH.rst | 7 +++-- Help/variable/CMAKE_LANG_COMPILER.rst | 4 +-- .../CMAKE_LANG_COMPILER_EXTERNAL_TOOLCHAIN.rst | 6 ++-- Help/variable/CMAKE_LANG_COMPILER_LOADED.rst | 4 +-- Help/variable/CMAKE_LANG_COMPILE_OBJECT.rst | 2 +- Help/variable/CMAKE_LANG_CREATE_SHARED_LIBRARY.rst | 2 +- Help/variable/CMAKE_LANG_CREATE_SHARED_MODULE.rst | 2 +- Help/variable/CMAKE_LANG_CREATE_STATIC_LIBRARY.rst | 2 +- Help/variable/CMAKE_LANG_FLAGS.rst | 2 +- Help/variable/CMAKE_LANG_FLAGS_DEBUG.rst | 4 +-- Help/variable/CMAKE_LANG_FLAGS_MINSIZEREL.rst | 6 ++-- Help/variable/CMAKE_LANG_FLAGS_RELEASE.rst | 4 +-- Help/variable/CMAKE_LANG_FLAGS_RELWITHDEBINFO.rst | 6 ++-- .../variable/CMAKE_LANG_GHS_KERNEL_FLAGS_DEBUG.rst | 4 +-- .../CMAKE_LANG_GHS_KERNEL_FLAGS_MINSIZEREL.rst | 6 ++-- .../CMAKE_LANG_GHS_KERNEL_FLAGS_RELEASE.rst | 4 +-- .../CMAKE_LANG_GHS_KERNEL_FLAGS_RELWITHDEBINFO.rst | 6 ++-- .../CMAKE_LANG_IMPLICIT_INCLUDE_DIRECTORIES.rst | 2 +- .../CMAKE_LANG_IMPLICIT_LINK_DIRECTORIES.rst | 8 ++--- ...KE_LANG_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES.rst | 2 +- .../CMAKE_LANG_IMPLICIT_LINK_LIBRARIES.rst | 2 +- Help/variable/CMAKE_LANG_LIBRARY_ARCHITECTURE.rst | 8 ++--- Help/variable/CMAKE_LANG_LINKER_PREFERENCE.rst | 4 +-- .../CMAKE_LANG_LINKER_PREFERENCE_PROPAGATES.rst | 2 +- Help/variable/CMAKE_LANG_OUTPUT_EXTENSION.rst | 4 +-- Help/variable/CMAKE_LANG_SIMULATE_ID.rst | 4 +-- Help/variable/CMAKE_LANG_SIMULATE_VERSION.rst | 4 +-- Help/variable/CMAKE_LANG_SIZEOF_DATA_PTR.rst | 4 +-- Help/variable/CMAKE_LIBRARY_ARCHITECTURE.rst | 4 +-- Help/variable/CMAKE_LIBRARY_ARCHITECTURE_REGEX.rst | 4 +-- Help/variable/CMAKE_LIBRARY_PATH_FLAG.rst | 2 +- Help/variable/CMAKE_LINK_DEF_FILE_FLAG.rst | 4 +-- Help/variable/CMAKE_LINK_DEPENDS_NO_SHARED.rst | 2 +- Help/variable/CMAKE_LINK_INTERFACE_LIBRARIES.rst | 4 +-- Help/variable/CMAKE_LINK_LIBRARY_FLAG.rst | 2 +- Help/variable/CMAKE_LINK_LIBRARY_SUFFIX.rst | 2 +- Help/variable/CMAKE_LINK_SEARCH_END_STATIC.rst | 6 ++-- Help/variable/CMAKE_LINK_SEARCH_START_STATIC.rst | 10 +++---- Help/variable/CMAKE_MACOSX_BUNDLE.rst | 6 ++-- Help/variable/CMAKE_MAKE_PROGRAM.rst | 10 +++---- Help/variable/CMAKE_MAP_IMPORTED_CONFIG_CONFIG.rst | 8 ++--- Help/variable/CMAKE_MFC_FLAG.rst | 6 ++-- Help/variable/CMAKE_MINIMUM_REQUIRED_VERSION.rst | 6 ++-- Help/variable/CMAKE_MODULE_LINKER_FLAGS_CONFIG.rst | 2 +- Help/variable/CMAKE_NOT_USING_CONFIG_FLAGS.rst | 4 +-- Help/variable/CMAKE_NO_SYSTEM_FROM_IMPORTED.rst | 4 +-- Help/variable/CMAKE_PARENT_LIST_FILE.rst | 8 ++--- Help/variable/CMAKE_POLICY_DEFAULT_CMPNNNN.rst | 19 ++++++------ Help/variable/CMAKE_PROJECT_NAME.rst | 2 +- Help/variable/CMAKE_ROOT.rst | 4 +-- Help/variable/CMAKE_SCRIPT_MODE_FILE.rst | 9 +++--- Help/variable/CMAKE_SHARED_LIBRARY_PREFIX.rst | 4 +-- Help/variable/CMAKE_SHARED_LIBRARY_SUFFIX.rst | 4 +-- Help/variable/CMAKE_SHARED_LINKER_FLAGS_CONFIG.rst | 2 +- Help/variable/CMAKE_SHARED_MODULE_PREFIX.rst | 2 +- Help/variable/CMAKE_SHARED_MODULE_SUFFIX.rst | 2 +- Help/variable/CMAKE_SIZEOF_VOID_P.rst | 6 ++-- .../variable/CMAKE_SKIP_INSTALL_ALL_DEPENDENCY.rst | 12 ++++---- Help/variable/CMAKE_SKIP_INSTALL_RPATH.rst | 2 +- Help/variable/CMAKE_SKIP_INSTALL_RULES.rst | 5 ++-- Help/variable/CMAKE_SKIP_RPATH.rst | 4 +-- Help/variable/CMAKE_SOURCE_DIR.rst | 2 +- Help/variable/CMAKE_STAGING_PREFIX.rst | 11 +++---- Help/variable/CMAKE_STATIC_LIBRARY_PREFIX.rst | 4 +-- Help/variable/CMAKE_STATIC_LIBRARY_SUFFIX.rst | 4 +-- Help/variable/CMAKE_STATIC_LINKER_FLAGS_CONFIG.rst | 2 +- Help/variable/CMAKE_SYSTEM.rst | 2 +- Help/variable/CMAKE_SYSTEM_NAME.rst | 6 ++-- Help/variable/CMAKE_SYSTEM_PROCESSOR.rst | 2 +- Help/variable/CMAKE_SYSTEM_VERSION.rst | 2 +- Help/variable/CMAKE_TOOLCHAIN_FILE.rst | 6 ++-- Help/variable/CMAKE_TRY_COMPILE_CONFIGURATION.rst | 7 +++-- Help/variable/CMAKE_USER_MAKE_RULES_OVERRIDE.rst | 20 ++++++------- .../CMAKE_USER_MAKE_RULES_OVERRIDE_LANG.rst | 7 +++-- Help/variable/CMAKE_VERBOSE_MAKEFILE.rst | 2 +- .../CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD.rst | 8 ++--- .../CMAKE_VS_INTEL_Fortran_PROJECT_VERSION.rst | 4 +-- Help/variable/CMAKE_VS_PLATFORM_TOOLSET.rst | 2 +- Help/variable/CMAKE_WARN_DEPRECATED.rst | 4 +-- .../CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION.rst | 7 +++-- Help/variable/CMAKE_WIN32_EXECUTABLE.rst | 6 ++-- .../CMAKE_XCODE_ATTRIBUTE_an-attribute.rst | 4 +-- Help/variable/CMAKE_XCODE_PLATFORM_TOOLSET.rst | 6 ++-- Help/variable/CPACK_ABSOLUTE_DESTINATION_FILES.rst | 6 ++-- .../CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY.rst | 6 ++-- ...CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION.rst | 9 +++--- Help/variable/CPACK_INCLUDE_TOPLEVEL_DIRECTORY.rst | 11 +++---- Help/variable/CPACK_INSTALL_SCRIPT.rst | 2 +- Help/variable/CPACK_PACKAGING_INSTALL_PREFIX.rst | 12 ++++---- Help/variable/CPACK_SET_DESTDIR.rst | 31 ++++++++++---------- .../CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION.rst | 7 +++-- Help/variable/CTEST_COVERAGE_COMMAND.rst | 20 ++++++------- Help/variable/CTEST_MEMORYCHECK_TYPE.rst | 5 ++-- Help/variable/CYGWIN.rst | 4 +-- Help/variable/ENV.rst | 4 +-- Help/variable/EXECUTABLE_OUTPUT_PATH.rst | 4 +-- Help/variable/LIBRARY_OUTPUT_PATH.rst | 8 ++--- Help/variable/MINGW.rst | 4 +-- Help/variable/MSVC.rst | 4 +-- Help/variable/MSVC10.rst | 4 +-- Help/variable/MSVC11.rst | 4 +-- Help/variable/MSVC12.rst | 4 +-- Help/variable/MSVC14.rst | 4 +-- Help/variable/MSVC60.rst | 4 +-- Help/variable/MSVC70.rst | 4 +-- Help/variable/MSVC71.rst | 4 +-- Help/variable/MSVC80.rst | 4 +-- Help/variable/MSVC90.rst | 4 +-- Help/variable/MSVC_IDE.rst | 4 +-- Help/variable/UNIX.rst | 6 ++-- Help/variable/WIN32.rst | 4 +-- Help/variable/XCODE_VERSION.rst | 4 +-- Source/CMakeVersion.cmake | 2 +- 195 files changed, 538 insertions(+), 509 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Thu Aug 20 00:01:09 2015 From: kwrobot at kitware.com (Kitware Robot) Date: Thu, 20 Aug 2015 00:01:09 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-875-ge72a5b2 Message-ID: <20150820040109.2BA9EB1857@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via e72a5b2c0b51f90970fc4ef27969cee9990be862 (commit) from 404d16e7bc1b18027f719cd8642d0a90c679c396 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e72a5b2c0b51f90970fc4ef27969cee9990be862 commit e72a5b2c0b51f90970fc4ef27969cee9990be862 Author: Kitware Robot AuthorDate: Thu Aug 20 00:01:07 2015 -0400 Commit: Kitware Robot CommitDate: Thu Aug 20 00:01:07 2015 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index f0a7cbd..54bbbbb 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150819) +set(CMake_VERSION_PATCH 20150820) #set(CMake_VERSION_RC 1) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 20 09:25:13 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 20 Aug 2015 09:25:13 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2274-g6a9aa5b Message-ID: <20150820132513.AA827B18CC@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 6a9aa5b378422f8d0d89b53e181c4bec2104f082 (commit) via 625225bbe6a84350759d7116a6cd5ad2f850e635 (commit) from 4527e186cb891f4dfe7c025066566a4f7d1a4346 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6a9aa5b378422f8d0d89b53e181c4bec2104f082 commit 6a9aa5b378422f8d0d89b53e181c4bec2104f082 Merge: 4527e18 625225b Author: Brad King AuthorDate: Thu Aug 20 09:25:12 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 20 09:25:12 2015 -0400 Merge topic 'hp-ux-itanium-shared-libs' into next 625225bb HP-UX: Do not use ".sl" extension for shared libs on Itanium http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=625225bbe6a84350759d7116a6cd5ad2f850e635 commit 625225bbe6a84350759d7116a6cd5ad2f850e635 Author: Brad King AuthorDate: Tue Aug 18 10:55:16 2015 -0400 Commit: Brad King CommitDate: Tue Aug 18 10:55:16 2015 -0400 HP-UX: Do not use ".sl" extension for shared libs on Itanium Instead use the standard ".so" extension. Suggested-by: Gerhard Grimm diff --git a/Modules/Platform/HP-UX.cmake b/Modules/Platform/HP-UX.cmake index 65cc731..df042cd 100644 --- a/Modules/Platform/HP-UX.cmake +++ b/Modules/Platform/HP-UX.cmake @@ -1,9 +1,11 @@ set(CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH /usr/lib) -set(CMAKE_SHARED_LIBRARY_SUFFIX ".sl") # .so +if(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL "ia64") + set(CMAKE_SHARED_LIBRARY_SUFFIX ".sl") # .so + set(CMAKE_FIND_LIBRARY_SUFFIXES ".sl" ".so" ".a") + set(CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES ".so") +endif() set(CMAKE_DL_LIBS "dld") -set(CMAKE_FIND_LIBRARY_SUFFIXES ".sl" ".so" ".a") -set(CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES ".so") # The HP linker needs to find transitive shared library dependencies # in the -L path. Therefore the runtime path must be added to the ----------------------------------------------------------------------- Summary of changes: Modules/Platform/HP-UX.cmake | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 20 09:29:45 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 20 Aug 2015 09:29:45 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2276-g24c0631 Message-ID: <20150820132945.4CD23B1931@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 24c06319347e706c83422af382a72a9f82b47eff (commit) via 5abe76d8bfafd0935d897c5f22e1485eef0c6904 (commit) from 6a9aa5b378422f8d0d89b53e181c4bec2104f082 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=24c06319347e706c83422af382a72a9f82b47eff commit 24c06319347e706c83422af382a72a9f82b47eff Merge: 6a9aa5b 5abe76d Author: Brad King AuthorDate: Thu Aug 20 09:29:44 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 20 09:29:44 2015 -0400 Merge topic 'MSVC-quote-for-release' into next 5abe76d8 Revert "CMake: Silence CMP0054 warning with separate project, enable_language calls." http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5abe76d8bfafd0935d897c5f22e1485eef0c6904 commit 5abe76d8bfafd0935d897c5f22e1485eef0c6904 Author: Matt McCormick AuthorDate: Wed Aug 19 22:40:14 2015 -0400 Commit: Matt McCormick CommitDate: Wed Aug 19 22:40:14 2015 -0400 Revert "CMake: Silence CMP0054 warning with separate project, enable_language calls." This reverts commit 306c9361ce1fffc85b2ffe88132885cf5955f1ba. diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index 7e6d8dc..893c454 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -103,17 +103,14 @@ if(NOT CMAKE_CXX_COMPILER_ID_RUN) CMAKE_DETERMINE_COMPILER_ID(CXX CXXFLAGS CMakeCXXCompilerId.cpp) # Set old compiler and platform id variables. - cmake_policy(PUSH) - cmake_policy(SET CMP0054 NEW) - if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") - set(CMAKE_COMPILER_IS_GNUCXX 1) - endif() - if("${CMAKE_CXX_PLATFORM_ID}" MATCHES "MinGW") - set(CMAKE_COMPILER_IS_MINGW 1) - elseif("${CMAKE_CXX_PLATFORM_ID}" MATCHES "Cygwin") - set(CMAKE_COMPILER_IS_CYGWIN 1) - endif() - cmake_policy(POP) + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") + set(CMAKE_COMPILER_IS_GNUCXX 1) + endif() + if("${CMAKE_CXX_PLATFORM_ID}" MATCHES "MinGW") + set(CMAKE_COMPILER_IS_MINGW 1) + elseif("${CMAKE_CXX_PLATFORM_ID}" MATCHES "Cygwin") + set(CMAKE_COMPILER_IS_CYGWIN 1) + endif() endif() if (NOT _CMAKE_TOOLCHAIN_LOCATION) ----------------------------------------------------------------------- Summary of changes: Modules/CMakeDetermineCXXCompiler.cmake | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 20 09:37:15 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 20 Aug 2015 09:37:15 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2278-g907ea3b Message-ID: <20150820133715.B242FB19D0@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 907ea3b6ed95b9ae3648868b77d744e82330fd9a (commit) via dc8822f0a7b4152c5cb880e6a7fccada767e2fb1 (commit) from 24c06319347e706c83422af382a72a9f82b47eff (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=907ea3b6ed95b9ae3648868b77d744e82330fd9a commit 907ea3b6ed95b9ae3648868b77d744e82330fd9a Merge: 24c0631 dc8822f Author: Brad King AuthorDate: Thu Aug 20 09:37:14 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 20 09:37:14 2015 -0400 Merge topic 'determine-compiler-CMP0054' into next dc8822f0 CMakeDetermine{C,CXX}Compiler: Avoid if() auto-dereferene in quoted arguments http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=dc8822f0a7b4152c5cb880e6a7fccada767e2fb1 commit dc8822f0a7b4152c5cb880e6a7fccada767e2fb1 Author: Matt McCormick AuthorDate: Wed Aug 19 22:40:38 2015 -0400 Commit: Brad King CommitDate: Thu Aug 20 09:35:16 2015 -0400 CMakeDetermine{C,CXX}Compiler: Avoid if() auto-dereferene in quoted arguments Exposed by a CMP0054 warning with code like: cmake_minimum_required(VERSION 2.8.9 FATAL_ERROR) project(MyProj NONE) enable_language(C) enable_language(CXX) While at it, use STREQUAL for testing the compiler id against "GNU". Suggested-by: Rolf Eike Beer diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index 937aa8c..db477cb 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -95,6 +95,7 @@ if(NOT CMAKE_C_COMPILER_ID_RUN) # Try to identify the compiler. set(CMAKE_C_COMPILER_ID) + set(CMAKE_C_PLATFORM_ID) file(READ ${CMAKE_ROOT}/Modules/CMakePlatformId.h.in CMAKE_C_COMPILER_ID_PLATFORM_CONTENT) @@ -108,12 +109,12 @@ if(NOT CMAKE_C_COMPILER_ID_RUN) CMAKE_DETERMINE_COMPILER_ID(C CFLAGS CMakeCCompilerId.c) # Set old compiler and platform id variables. - if(CMAKE_C_COMPILER_ID MATCHES "GNU") + if(CMAKE_C_COMPILER_ID STREQUAL "GNU") set(CMAKE_COMPILER_IS_GNUCC 1) endif() - if("${CMAKE_C_PLATFORM_ID}" MATCHES "MinGW") + if(CMAKE_C_PLATFORM_ID MATCHES "MinGW") set(CMAKE_COMPILER_IS_MINGW 1) - elseif("${CMAKE_C_PLATFORM_ID}" MATCHES "Cygwin") + elseif(CMAKE_C_PLATFORM_ID MATCHES "Cygwin") set(CMAKE_COMPILER_IS_CYGWIN 1) endif() endif() diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index 893c454..18e735b 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -90,6 +90,7 @@ if(NOT CMAKE_CXX_COMPILER_ID_RUN) # Try to identify the compiler. set(CMAKE_CXX_COMPILER_ID) + set(CMAKE_CXX_PLATFORM_ID) file(READ ${CMAKE_ROOT}/Modules/CMakePlatformId.h.in CMAKE_CXX_COMPILER_ID_PLATFORM_CONTENT) @@ -103,12 +104,12 @@ if(NOT CMAKE_CXX_COMPILER_ID_RUN) CMAKE_DETERMINE_COMPILER_ID(CXX CXXFLAGS CMakeCXXCompilerId.cpp) # Set old compiler and platform id variables. - if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") set(CMAKE_COMPILER_IS_GNUCXX 1) endif() - if("${CMAKE_CXX_PLATFORM_ID}" MATCHES "MinGW") + if(CMAKE_CXX_PLATFORM_ID MATCHES "MinGW") set(CMAKE_COMPILER_IS_MINGW 1) - elseif("${CMAKE_CXX_PLATFORM_ID}" MATCHES "Cygwin") + elseif(CMAKE_CXX_PLATFORM_ID MATCHES "Cygwin") set(CMAKE_COMPILER_IS_CYGWIN 1) endif() endif() ----------------------------------------------------------------------- Summary of changes: Modules/CMakeDetermineCCompiler.cmake | 7 ++++--- Modules/CMakeDetermineCXXCompiler.cmake | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 20 09:40:43 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 20 Aug 2015 09:40:43 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2280-gc4643d5 Message-ID: <20150820134043.6B041AF526@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via c4643d56966b19299bf05170a9a9241312ef390f (commit) via 3e94f94b898aa183badd2ac8be52d20b007d5b26 (commit) from 907ea3b6ed95b9ae3648868b77d744e82330fd9a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c4643d56966b19299bf05170a9a9241312ef390f commit c4643d56966b19299bf05170a9a9241312ef390f Merge: 907ea3b 3e94f94 Author: Brad King AuthorDate: Thu Aug 20 09:40:42 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 20 09:40:42 2015 -0400 Merge topic 'vs-fix-obj-extension' into next 3e94f94b cmLocalVisualStudioGenerator: Use computed .obj extension (#13685) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3e94f94b898aa183badd2ac8be52d20b007d5b26 commit 3e94f94b898aa183badd2ac8be52d20b007d5b26 Author: Bastien Schatt AuthorDate: Tue Aug 18 17:17:52 2015 +0200 Commit: Brad King CommitDate: Tue Aug 18 11:39:52 2015 -0400 cmLocalVisualStudioGenerator: Use computed .obj extension (#13685) CMAKE__OUTPUT_EXTENSION tells us the proper extension for the current toolchain. Teach the ComputeObjectFilenames method to use GetLanguageOutputExtension to look up the extension instead of hard-coding ".obj". This is already done in the code path for explicit file names inside our call to GetObjectFileNameWithoutTarget. diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index ca72939..3588853 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/Source/cmLocalVisualStudioGenerator.cxx @@ -57,7 +57,7 @@ void cmLocalVisualStudioGenerator::ComputeObjectFilenames( cmSourceFile const* sf = si->first; std::string objectNameLower = cmSystemTools::LowerCase( cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath())); - objectNameLower += ".obj"; + objectNameLower += this->GlobalGenerator->GetLanguageOutputExtension(*sf); counts[objectNameLower] += 1; } @@ -70,7 +70,7 @@ void cmLocalVisualStudioGenerator::ComputeObjectFilenames( cmSourceFile const* sf = si->first; std::string objectName = cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()); - objectName += ".obj"; + objectName += this->GlobalGenerator->GetLanguageOutputExtension(*sf); if(counts[cmSystemTools::LowerCase(objectName)] > 1) { const_cast(gt)->AddExplicitObjectName(sf); ----------------------------------------------------------------------- Summary of changes: Source/cmLocalVisualStudioGenerator.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 20 10:00:08 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 20 Aug 2015 10:00:08 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2282-ge559aba Message-ID: <20150820140008.EAEE3B1619@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via e559aba7ae577ed629aea40a5059d9d43d28fb0c (commit) via 3c37d2642d9000a2d01bc46ad0ea74a741bdb658 (commit) from c4643d56966b19299bf05170a9a9241312ef390f (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e559aba7ae577ed629aea40a5059d9d43d28fb0c commit e559aba7ae577ed629aea40a5059d9d43d28fb0c Merge: c4643d5 3c37d26 Author: Brad King AuthorDate: Thu Aug 20 10:00:07 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 20 10:00:07 2015 -0400 Merge topic 'OUTPUT_NAME-genex-no-recursion' into next 3c37d264 cmGeneratorTarget: Avoid recursion in GetOutputName method http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3c37d2642d9000a2d01bc46ad0ea74a741bdb658 commit 3c37d2642d9000a2d01bc46ad0ea74a741bdb658 Author: Robert Goulet AuthorDate: Fri Aug 14 20:35:58 2015 +0000 Commit: Brad King CommitDate: Thu Aug 20 09:56:45 2015 -0400 cmGeneratorTarget: Avoid recursion in GetOutputName method Since support for generator expressions was added to OUTPUT_NAME it is possible for project code to cause recursion in this method by using a $ genex. Detect and reject such cases. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 299c112..530acfe 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -270,48 +270,71 @@ const char *cmGeneratorTarget::GetProperty(const std::string& prop) const std::string cmGeneratorTarget::GetOutputName(const std::string& config, bool implib) const { - std::vector props; - std::string type = this->Target->GetOutputTargetType(implib); - std::string configUpper = cmSystemTools::UpperCase(config); - if(!type.empty() && !configUpper.empty()) - { - // _OUTPUT_NAME_ - props.push_back(type + "_OUTPUT_NAME_" + configUpper); - } - if(!type.empty()) + // Lookup/compute/cache the output name for this configuration. + OutputNameKey key(config, implib); + cmGeneratorTarget::OutputNameMapType::iterator i = + this->OutputNameMap.find(key); + if(i == this->OutputNameMap.end()) { - // _OUTPUT_NAME - props.push_back(type + "_OUTPUT_NAME"); - } - if(!configUpper.empty()) - { - // OUTPUT_NAME_ - props.push_back("OUTPUT_NAME_" + configUpper); - // _OUTPUT_NAME - props.push_back(configUpper + "_OUTPUT_NAME"); - } - // OUTPUT_NAME - props.push_back("OUTPUT_NAME"); + // Add empty name in map to detect potential recursion. + OutputNameMapType::value_type entry(key, ""); + i = this->OutputNameMap.insert(entry).first; - std::string outName; - for(std::vector::const_iterator i = props.begin(); - i != props.end(); ++i) - { - if (const char* outNameProp = this->Target->GetProperty(*i)) + // Compute output name. + std::vector props; + std::string type = this->Target->GetOutputTargetType(implib); + std::string configUpper = cmSystemTools::UpperCase(config); + if(!type.empty() && !configUpper.empty()) { - outName = outNameProp; - break; + // _OUTPUT_NAME_ + props.push_back(type + "_OUTPUT_NAME_" + configUpper); + } + if(!type.empty()) + { + // _OUTPUT_NAME + props.push_back(type + "_OUTPUT_NAME"); + } + if(!configUpper.empty()) + { + // OUTPUT_NAME_ + props.push_back("OUTPUT_NAME_" + configUpper); + // _OUTPUT_NAME + props.push_back(configUpper + "_OUTPUT_NAME"); + } + // OUTPUT_NAME + props.push_back("OUTPUT_NAME"); + + std::string outName; + for(std::vector::const_iterator it = props.begin(); + it != props.end(); ++it) + { + if (const char* outNameProp = this->Target->GetProperty(*it)) + { + outName = outNameProp; + break; + } } - } - if (outName.empty()) + if(outName.empty()) + { + outName = this->GetName(); + } + + // Now evaluate genex and update the previously-prepared map entry. + cmGeneratorExpression ge; + cmsys::auto_ptr cge = ge.Parse(outName); + i->second = cge->Evaluate(this->Makefile, config); + } + else if(i->second.empty()) { - outName = this->GetName(); + // An empty map entry indicates we have been called recursively + // from the above block. + this->Makefile->GetCMakeInstance()->IssueMessage( + cmake::FATAL_ERROR, + "Target '" + this->GetName() + "' OUTPUT_NAME depends on itself.", + this->Target->GetBacktrace()); } - - cmGeneratorExpression ge; - cmsys::auto_ptr cge = ge.Parse(outName); - return cge->Evaluate(this->Makefile, config); + return i->second; } //---------------------------------------------------------------------------- diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 68e7a8a..15b3335 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -375,6 +375,10 @@ private: }; mutable std::map LinkImplClosureMap; + typedef std::pair OutputNameKey; + typedef std::map OutputNameMapType; + mutable OutputNameMapType OutputNameMap; + public: std::vector const& GetLinkImplementationClosure(const std::string& config) const; diff --git a/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion-result.txt b/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion-stderr.txt b/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion-stderr.txt new file mode 100644 index 0000000..bf592e7 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at OUTPUT_NAME-recursion.cmake:[0-9]+ \(add_executable\): + Target 'empty1' OUTPUT_NAME depends on itself. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion.cmake b/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion.cmake new file mode 100644 index 0000000..5cb8050 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion.cmake @@ -0,0 +1,3 @@ +enable_language(C) +add_executable(empty1 empty.c) +set_property(TARGET empty1 PROPERTY OUTPUT_NAME $) diff --git a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake index 21fc851..0679024 100644 --- a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake @@ -26,6 +26,7 @@ run_cmake(COMPILE_LANGUAGE-add_library) run_cmake(COMPILE_LANGUAGE-add_test) run_cmake(COMPILE_LANGUAGE-unknown-lang) run_cmake(TARGET_FILE-recursion) +run_cmake(OUTPUT_NAME-recursion) run_cmake(ImportedTarget-TARGET_PDB_FILE) if(LINKER_SUPPORTS_PDB) diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion.cmake index 7633be1..e780103 100644 --- a/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion.cmake +++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion.cmake @@ -1,3 +1,4 @@ enable_language(C) add_executable(empty1 empty.c) +set_property(TARGET empty1 PROPERTY OUTPUT_NAME $) set_property(TARGET empty1 PROPERTY RUNTIME_OUTPUT_DIRECTORY $) ----------------------------------------------------------------------- Summary of changes: Source/cmGeneratorTarget.cxx | 93 ++++++++++++-------- Source/cmGeneratorTarget.h | 4 + .../OUTPUT_NAME-recursion-result.txt} | 0 .../OUTPUT_NAME-recursion-stderr.txt | 4 + .../OUTPUT_NAME-recursion.cmake | 3 + .../GeneratorExpression/RunCMakeTest.cmake | 1 + .../TARGET_FILE-recursion.cmake | 1 + 7 files changed, 71 insertions(+), 35 deletions(-) copy Tests/RunCMake/{CMP0004/CMP0004-NEW-result.txt => GeneratorExpression/OUTPUT_NAME-recursion-result.txt} (100%) create mode 100644 Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion-stderr.txt create mode 100644 Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion.cmake hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 20 10:47:15 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 20 Aug 2015 10:47:15 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2286-g3b595b4 Message-ID: <20150820144715.21F57B0E9B@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 3b595b4d66009263f1d6bb675f285f4b24508b2e (commit) via f799ffb5cb895855ac2aba54765622b81db5be38 (commit) via 899458ab20876aeea915a59e9bfb459d92d264de (commit) via e72a5b2c0b51f90970fc4ef27969cee9990be862 (commit) from e559aba7ae577ed629aea40a5059d9d43d28fb0c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3b595b4d66009263f1d6bb675f285f4b24508b2e commit 3b595b4d66009263f1d6bb675f285f4b24508b2e Merge: e559aba f799ffb Author: Brad King AuthorDate: Thu Aug 20 10:47:13 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 20 10:47:13 2015 -0400 Merge topic 'modules-no-soname' into next f799ffb5 Do not set SONAME for MODULE library targets (#15705) 899458ab Tests: Cover NO_SONAME property for SHARED libraries e72a5b2c CMake Nightly Date Stamp http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f799ffb5cb895855ac2aba54765622b81db5be38 commit f799ffb5cb895855ac2aba54765622b81db5be38 Author: Felix Geyer AuthorDate: Thu Aug 20 14:13:28 2015 +0200 Commit: Brad King CommitDate: Thu Aug 20 10:45:09 2015 -0400 Do not set SONAME for MODULE library targets (#15705) The SONAME field is only useful for shared libraries that application link against. diff --git a/Help/prop_tgt/NO_SONAME.rst b/Help/prop_tgt/NO_SONAME.rst index fc668b5..ee45ed8 100644 --- a/Help/prop_tgt/NO_SONAME.rst +++ b/Help/prop_tgt/NO_SONAME.rst @@ -1,11 +1,11 @@ NO_SONAME --------- -Whether to set "soname" when linking a shared library or module. +Whether to set "soname" when linking a shared library. -Enable this boolean property if a generated shared library or module +Enable this boolean property if a generated shared library should not have "soname" set. Default is to set "soname" on all -shared libraries and modules as long as the platform supports it. +shared libraries as long as the platform supports it. Generally, use this property only for leaf private libraries or plugins. If you use it on normal shared libraries which other targets link against, on some platforms a linker will insert a full path to diff --git a/Help/release/dev/modules-no-soname.rst b/Help/release/dev/modules-no-soname.rst new file mode 100644 index 0000000..8fe74f8 --- /dev/null +++ b/Help/release/dev/modules-no-soname.rst @@ -0,0 +1,7 @@ +modules-no-soname +----------------- + +* The ``SONAME`` field is no longer set for ``MODULE`` libraries + created with the :command:`add_library` command. ``MODULE`` + libraries are meant for explicit dynamic loading at runtime. + They cannot be linked so ``SONAME`` is not useful. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 299c112..89c1922 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -761,8 +761,7 @@ bool cmGeneratorTarget::HasSOName(const std::string& config) const { // soname is supported only for shared libraries and modules, // and then only when the platform supports an soname flag. - return ((this->GetType() == cmTarget::SHARED_LIBRARY || - this->GetType() == cmTarget::MODULE_LIBRARY) && + return ((this->GetType() == cmTarget::SHARED_LIBRARY) && !this->GetPropertyAsBool("NO_SONAME") && this->Makefile->GetSONameFlag(this->GetLinkerLanguage(config))); } diff --git a/Tests/Plugin/CMakeLists.txt b/Tests/Plugin/CMakeLists.txt index ecdece8..2b7bac1 100644 --- a/Tests/Plugin/CMakeLists.txt +++ b/Tests/Plugin/CMakeLists.txt @@ -52,13 +52,8 @@ target_link_libraries(example_mod_1 example_exe) if(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG AND "${CMAKE_C_CREATE_SHARED_MODULE}" MATCHES "SONAME_FLAG") - # Add a second plugin that should not have any soname. - add_library(example_mod_2 MODULE src/example_mod_1.c) - target_link_libraries(example_mod_2 example_exe) - set_property(TARGET example_mod_2 PROPERTY NO_SONAME 1) - # Verify that targets export with proper IMPORTED SONAME properties. - export(TARGETS example_mod_1 example_mod_2 NAMESPACE exp_ + export(TARGETS example_mod_1 NAMESPACE exp_ FILE ${CMAKE_CURRENT_BINARY_DIR}/mods.cmake) include(ExternalProject) @@ -68,7 +63,7 @@ if(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG AND DOWNLOAD_COMMAND "" INSTALL_COMMAND "" ) - add_dependencies(PluginTest example_mod_1 example_mod_2) + add_dependencies(PluginTest example_mod_1) endif() # TODO: diff --git a/Tests/Plugin/PluginTest/CMakeLists.txt b/Tests/Plugin/PluginTest/CMakeLists.txt index 79ef8a9..5626dbc 100644 --- a/Tests/Plugin/PluginTest/CMakeLists.txt +++ b/Tests/Plugin/PluginTest/CMakeLists.txt @@ -6,17 +6,11 @@ include(${CMAKE_CURRENT_BINARY_DIR}/../mods.cmake) get_property(configs TARGET exp_example_mod_1 PROPERTY IMPORTED_CONFIGURATIONS) foreach(c ${configs}) string(TOUPPER "${c}" CONFIG) - get_property(soname1 TARGET exp_example_mod_1 PROPERTY IMPORTED_SONAME_${CONFIG}) - get_property(soname2 TARGET exp_example_mod_2 PROPERTY IMPORTED_NO_SONAME_${CONFIG}) - if(soname1) - message(STATUS "exp_example_mod_1 has IMPORTED_SONAME_${CONFIG} as expected: ${soname1}") + get_property(soname TARGET exp_example_mod_1 PROPERTY IMPORTED_NO_SONAME_${CONFIG}) + if(soname) + message(STATUS "exp_example_mod_1 has IMPORTED_NO_SONAME_${CONFIG} as expected: ${soname}") else() - message(SEND_ERROR "exp_example_mod_1 does not have IMPORTED_SONAME_${CONFIG} but should") - endif() - if(soname2) - message(STATUS "exp_example_mod_2 has IMPORTED_NO_SONAME_${CONFIG} as expected: ${soname2}") - else() - message(SEND_ERROR "exp_example_mod_2 does not have IMPORTED_NO_SONAME_${CONFIG} but should") + message(SEND_ERROR "exp_example_mod_1 does not have IMPORTED_NO_SONAME_${CONFIG} but should") endif() endforeach() @@ -26,8 +20,7 @@ if("${CMAKE_EXECUTABLE_FORMAT}" MATCHES "ELF") if(READELF_EXE) add_custom_target(check_mod_soname ALL COMMAND ${CMAKE_COMMAND} -Dreadelf=${READELF_EXE} - -Dmod1=$ - -Dmod2=$ + -Dmod=$ -P ${CMAKE_CURRENT_SOURCE_DIR}/../check_mod_soname.cmake ) endif() diff --git a/Tests/Plugin/check_mod_soname.cmake b/Tests/Plugin/check_mod_soname.cmake index 3737b45..21a33b1 100644 --- a/Tests/Plugin/check_mod_soname.cmake +++ b/Tests/Plugin/check_mod_soname.cmake @@ -1,14 +1,7 @@ -execute_process(COMMAND ${readelf} -d ${mod1} OUTPUT_FILE ${mod1}.readelf.txt) -execute_process(COMMAND ${readelf} -d ${mod2} OUTPUT_FILE ${mod2}.readelf.txt) -file(STRINGS ${mod1}.readelf.txt soname1 REGEX "\\(SONAME\\)") -file(STRINGS ${mod2}.readelf.txt soname2 REGEX "\\(SONAME\\)") -if(soname1) - message(STATUS "${mod1} has soname as expected: ${soname1}") +execute_process(COMMAND ${readelf} -d ${mod} OUTPUT_FILE ${mod}.readelf.txt) +file(STRINGS ${mod}.readelf.txt soname REGEX "\\(SONAME\\)") +if(soname) + message(FATAL_ERROR "${mod} has soname but should not:\n ${soname}") else() - message(FATAL_ERROR "${mod1} has no soname but should:\n ${soname1}") -endif() -if(soname2) - message(FATAL_ERROR "${mod2} has soname but should not:\n ${soname2}") -else() - message(STATUS "${mod2} has no soname as expected") + message(STATUS "${mod} has no soname as expected") endif() http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=899458ab20876aeea915a59e9bfb459d92d264de commit 899458ab20876aeea915a59e9bfb459d92d264de Author: Brad King AuthorDate: Thu Aug 20 10:37:18 2015 -0400 Commit: Brad King CommitDate: Thu Aug 20 10:38:34 2015 -0400 Tests: Cover NO_SONAME property for SHARED libraries This property was added by commit v2.8.9~204^2~2 (Support building shared libraries or modules without soname, 2012-04-22). A test for using the property on MODULE libraries was added by commit v2.8.9~204^2~1 (Test NO_SONAME property, 2012-04-23). Add such a test for SHARED libraries too. diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt index 7fdfaa8..2b9e844 100644 --- a/Tests/ExportImport/Export/CMakeLists.txt +++ b/Tests/ExportImport/Export/CMakeLists.txt @@ -127,6 +127,9 @@ target_link_libraries(testLibCycleA testLibCycleB) target_link_libraries(testLibCycleB testLibCycleA) set_property(TARGET testLibCycleA PROPERTY LINK_INTERFACE_MULTIPLICITY 3) +add_library(testLibNoSONAME SHARED testLibNoSONAME.c) +set_property(TARGET testLibNoSONAME PROPERTY NO_SONAME 1) + # Test exporting dependent libraries into different exports add_library(testLibRequired testLibRequired.c) add_library(testLibDepends testLibDepends.c) @@ -467,6 +470,7 @@ install( testExe2lib testLib4lib testLib4libdbg testLib4libopt testLib6 testLib7 testLibCycleA testLibCycleB + testLibNoSONAME cmp0022NEW cmp0022OLD systemlib EXPORT exp @@ -527,6 +531,7 @@ export(TARGETS testExe1 testLib1 testLib2 testLib3 export(TARGETS testExe2 testLib4 testLib5 testLib6 testLib7 testExe3 testExe4 testExe2lib testLib4lib testLib4libdbg testLib4libopt testLibCycleA testLibCycleB + testLibNoSONAME testLibPerConfigDest NAMESPACE bld_ APPEND FILE ExportBuildTree.cmake diff --git a/Tests/ExportImport/Export/testLibNoSONAME.c b/Tests/ExportImport/Export/testLibNoSONAME.c new file mode 100644 index 0000000..2193e1f --- /dev/null +++ b/Tests/ExportImport/Export/testLibNoSONAME.c @@ -0,0 +1,7 @@ +#if defined(_WIN32) || defined(__CYGWIN__) +# define testLibNoSONAME_EXPORT __declspec(dllexport) +#else +# define testLibNoSONAME_EXPORT +#endif + +testLibNoSONAME_EXPORT int testLibNoSONAME(void) { return 0; } diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt index 0f56495..5ce9628 100644 --- a/Tests/ExportImport/Import/A/CMakeLists.txt +++ b/Tests/ExportImport/Import/A/CMakeLists.txt @@ -90,6 +90,50 @@ add_custom_target(check_testLib1_genex ALL -P ${CMAKE_CURRENT_SOURCE_DIR}/check_testLib1_genex.cmake ) +if(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG AND + "${CMAKE_C_CREATE_SHARED_MODULE}" MATCHES "SONAME_FLAG") + foreach(ns exp bld) + get_property(configs TARGET ${ns}_testLib5 PROPERTY IMPORTED_CONFIGURATIONS) + foreach(c ${configs}) + string(TOUPPER "${c}" CONFIG) + get_property(soname TARGET ${ns}_testLib5 PROPERTY IMPORTED_NO_SONAME_${CONFIG}) + if(soname) + message(SEND_ERROR "${ns}_testLib5 has IMPORTED_NO_SONAME_${CONFIG} but should:\n ${soname}") + else() + message(STATUS "${ns}_testLib5 does not have IMPORTED_NO_SONAME_${CONFIG} as expected") + endif() + endforeach() + + get_property(configs TARGET ${ns}_testLibNoSONAME PROPERTY IMPORTED_CONFIGURATIONS) + foreach(c ${configs}) + string(TOUPPER "${c}" CONFIG) + get_property(soname TARGET ${ns}_testLibNoSONAME PROPERTY IMPORTED_NO_SONAME_${CONFIG}) + if(soname) + message(STATUS "${ns}_testLibNoSONAME has IMPORTED_NO_SONAME_${CONFIG} as expected") + else() + message(SEND_ERROR "${ns}_testLibNoSONAME does not have IMPORTED_NO_SONAME_${CONFIG} but should") + endif() + endforeach() + + # Parse the binary to check for SONAME if possible. + if("${CMAKE_EXECUTABLE_FORMAT}" MATCHES "ELF") + find_program(READELF_EXE readelf) + if(READELF_EXE) + add_custom_target(check_${ns}_testLib5_soname ALL COMMAND + ${CMAKE_COMMAND} -Dreadelf=${READELF_EXE} + -Dlib=$ + -P ${CMAKE_CURRENT_SOURCE_DIR}/check_lib_soname.cmake + ) + add_custom_target(check_${ns}_testLibNoSONAME_soname ALL COMMAND + ${CMAKE_COMMAND} -Dreadelf=${READELF_EXE} + -Dlib=$ + -P ${CMAKE_CURRENT_SOURCE_DIR}/check_lib_nosoname.cmake + ) + endif() + endif() + endforeach() +endif() + add_executable(cmp0022OLD_test cmp0022OLD_test_vs6_1.cpp) target_link_libraries(cmp0022OLD_test bld_cmp0022OLD) add_executable(cmp0022NEW_test cmp0022NEW_test_vs6_1.cpp) diff --git a/Tests/ExportImport/Import/A/check_lib_nosoname.cmake b/Tests/ExportImport/Import/A/check_lib_nosoname.cmake new file mode 100644 index 0000000..6261ff4 --- /dev/null +++ b/Tests/ExportImport/Import/A/check_lib_nosoname.cmake @@ -0,0 +1,7 @@ +execute_process(COMMAND ${readelf} -d ${lib} OUTPUT_FILE ${lib}.readelf.txt) +file(STRINGS ${lib}.readelf.txt soname REGEX "\\(SONAME\\)") +if(soname) + message(FATAL_ERROR "${lib} has soname but should not:\n ${soname}") +else() + message(STATUS "${lib} has no soname as expected:\n ${soname}") +endif() diff --git a/Tests/ExportImport/Import/A/check_lib_soname.cmake b/Tests/ExportImport/Import/A/check_lib_soname.cmake new file mode 100644 index 0000000..7794e80 --- /dev/null +++ b/Tests/ExportImport/Import/A/check_lib_soname.cmake @@ -0,0 +1,7 @@ +execute_process(COMMAND ${readelf} -d ${lib} OUTPUT_FILE ${lib}.readelf.txt) +file(STRINGS ${lib}.readelf.txt soname REGEX "\\(SONAME\\)") +if(soname) + message(STATUS "${lib} has soname as expected:\n ${soname}") +else() + message(FATAL_ERROR "${lib} has no soname but should:\n ${soname}") +endif() ----------------------------------------------------------------------- Summary of changes: Help/prop_tgt/NO_SONAME.rst | 6 +-- Help/release/dev/modules-no-soname.rst | 7 ++++ Source/CMakeVersion.cmake | 2 +- Source/cmGeneratorTarget.cxx | 3 +- Tests/ExportImport/Export/CMakeLists.txt | 5 +++ Tests/ExportImport/Export/testLibNoSONAME.c | 7 ++++ Tests/ExportImport/Import/A/CMakeLists.txt | 44 ++++++++++++++++++++ .../ExportImport/Import/A/check_lib_nosoname.cmake | 7 ++++ Tests/ExportImport/Import/A/check_lib_soname.cmake | 7 ++++ Tests/Plugin/CMakeLists.txt | 9 +--- Tests/Plugin/PluginTest/CMakeLists.txt | 17 +++----- Tests/Plugin/check_mod_soname.cmake | 17 +++----- 12 files changed, 94 insertions(+), 37 deletions(-) create mode 100644 Help/release/dev/modules-no-soname.rst create mode 100644 Tests/ExportImport/Export/testLibNoSONAME.c create mode 100644 Tests/ExportImport/Import/A/check_lib_nosoname.cmake create mode 100644 Tests/ExportImport/Import/A/check_lib_soname.cmake hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 20 10:48:47 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 20 Aug 2015 10:48:47 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2288-g81e1e20 Message-ID: <20150820144847.C3F98B0FBC@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 81e1e20c6f12c50c99f0353b50160ec7fe19f261 (commit) via c66835fc37fa3dec32a437010648fee0b210a1a5 (commit) from 3b595b4d66009263f1d6bb675f285f4b24508b2e (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=81e1e20c6f12c50c99f0353b50160ec7fe19f261 commit 81e1e20c6f12c50c99f0353b50160ec7fe19f261 Merge: 3b595b4 c66835f Author: Brad King AuthorDate: Thu Aug 20 10:48:47 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 20 10:48:47 2015 -0400 Merge topic 'sublime-msvc-includes' into next c66835fc Extra Generator: Populate MSVC system include paths from environment (#15597) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c66835fc37fa3dec32a437010648fee0b210a1a5 commit c66835fc37fa3dec32a437010648fee0b210a1a5 Author: Gregor Jasny AuthorDate: Fri Aug 14 11:38:23 2015 +0200 Commit: Gregor Jasny CommitDate: Tue Aug 18 22:30:55 2015 +0200 Extra Generator: Populate MSVC system include paths from environment (#15597) diff --git a/Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake b/Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake index 064e650..3bfb876 100644 --- a/Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake +++ b/Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake @@ -101,6 +101,8 @@ if (NOT CMAKE_EXTRA_GENERATOR_C_SYSTEM_INCLUDE_DIRS) _DETERMINE_GCC_SYSTEM_INCLUDE_DIRS(c _dirs _defines) set(CMAKE_EXTRA_GENERATOR_C_SYSTEM_INCLUDE_DIRS "${_dirs}" CACHE INTERNAL "C compiler system include directories") set(CMAKE_EXTRA_GENERATOR_C_SYSTEM_DEFINED_MACROS "${_defines}" CACHE INTERNAL "C compiler system defined macros") + elseif ("${CMAKE_C_COMPILER_ID}" MATCHES MSVC) + set(CMAKE_EXTRA_GENERATOR_C_SYSTEM_INCLUDE_DIRS "$ENV{INCLUDE}" CACHE INTERNAL "C compiler system include directories") endif () endif () @@ -110,6 +112,8 @@ if (NOT CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_INCLUDE_DIRS) _DETERMINE_GCC_SYSTEM_INCLUDE_DIRS(c++ _dirs _defines) set(CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_INCLUDE_DIRS "${_dirs}" CACHE INTERNAL "CXX compiler system include directories") set(CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS "${_defines}" CACHE INTERNAL "CXX compiler system defined macros") + elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES MSVC) + set(CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_INCLUDE_DIRS "$ENV{INCLUDE}" CACHE INTERNAL "CXX compiler system include directories") endif () endif () ----------------------------------------------------------------------- Summary of changes: .../CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake | 4 ++++ 1 file changed, 4 insertions(+) hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 20 11:11:37 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 20 Aug 2015 11:11:37 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2290-g0c0852b Message-ID: <20150820151137.D2B5DB04BB@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 0c0852b1b0fe29ad445f4f0842343c39cf8e7c13 (commit) via c9ea75ec01b55b1793ea626964cbefcf4811ee2e (commit) from 81e1e20c6f12c50c99f0353b50160ec7fe19f261 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0c0852b1b0fe29ad445f4f0842343c39cf8e7c13 commit 0c0852b1b0fe29ad445f4f0842343c39cf8e7c13 Merge: 81e1e20 c9ea75e Author: Brad King AuthorDate: Thu Aug 20 11:11:36 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 20 11:11:36 2015 -0400 Merge topic 'ios-app-bundle-layout' into next c9ea75ec Fix iOS Bundle layouts (#15669) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c9ea75ec01b55b1793ea626964cbefcf4811ee2e commit c9ea75ec01b55b1793ea626964cbefcf4811ee2e Author: Gregor Jasny AuthorDate: Tue Aug 18 21:30:54 2015 +0200 Commit: Brad King CommitDate: Thu Aug 20 10:58:47 2015 -0400 Fix iOS Bundle layouts (#15669) In contrast to Mac OS X App bundle layout the iOS one lacks the Contents/MacOSX structure. See also the Bundle Structures documentation in Mac Developer Library: https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/BundleTypes/BundleTypes.html For now detect iOS targets by checking the SDK name/path. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 299c112..b9f78c6 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -951,9 +951,13 @@ cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, bool contentOnly) const { std::string fpath = this->GetFullName(config, false); - fpath += ".app/Contents"; - if(!contentOnly) - fpath += "/MacOS"; + fpath += ".app"; + if(!this->Makefile->PlatformIsAppleIos()) + { + fpath += "/Contents"; + if(!contentOnly) + fpath += "/MacOS"; + } return fpath; } @@ -985,9 +989,12 @@ std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config, } } fpath += ext; - fpath += "/Contents"; - if(!contentOnly) - fpath += "/MacOS"; + if(!this->Makefile->PlatformIsAppleIos()) + { + fpath += "/Contents"; + if(!contentOnly) + fpath += "/MacOS"; + } return fpath; } @@ -999,7 +1006,7 @@ cmGeneratorTarget::GetFrameworkDirectory(const std::string& config, std::string fpath; fpath += this->GetOutputName(config, false); fpath += ".framework"; - if(!rootDir) + if(!rootDir && !this->Makefile->PlatformIsAppleIos()) { fpath += "/Versions/"; fpath += this->Target->GetFrameworkVersion(); @@ -2146,9 +2153,12 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, if(this->Target->IsFrameworkOnApple()) { realName = prefix; - realName += "Versions/"; - realName += this->Target->GetFrameworkVersion(); - realName += "/"; + if(!this->Makefile->PlatformIsAppleIos()) + { + realName += "Versions/"; + realName += this->Target->GetFrameworkVersion(); + realName += "/"; + } realName += base; soName = realName; } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 85bc493..6e43b52 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2529,6 +2529,18 @@ bool cmMakefile::PlatformIs64Bit() const return false; } +bool cmMakefile::PlatformIsAppleIos() const +{ + std::string sdkRoot; + sdkRoot = this->GetSafeDefinition("CMAKE_OSX_SYSROOT"); + sdkRoot = cmSystemTools::LowerCase(sdkRoot); + + return sdkRoot.find("iphoneos") == 0 || + sdkRoot.find("/iphoneos") != std::string::npos || + sdkRoot.find("iphonesimulator") == 0 || + sdkRoot.find("/iphonesimulator") != std::string::npos; +} + const char* cmMakefile::GetSONameFlag(const std::string& language) const { std::string name = "CMAKE_SHARED_LIBRARY_SONAME"; diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 1c4da00..9f455cc 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -490,6 +490,9 @@ public: /** Return whether the target platform is 64-bit. */ bool PlatformIs64Bit() const; + /** Return whether the target platform is Apple iOS. */ + bool PlatformIsAppleIos() const; + /** Retrieve soname flag for the specified language if supported */ const char* GetSONameFlag(const std::string& language) const; diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake index b7de614..ef81739 100644 --- a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake @@ -7,3 +7,35 @@ run_cmake(XcodeObjectNeedsQuote) if (NOT XCODE_VERSION VERSION_LESS 6) run_cmake(XcodePlatformFrameworks) endif() + +# Use a single build tree for a few tests without cleaning. + +if(NOT XCODE_VERSION VERSION_LESS 5) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeBundlesOSX-build) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_OPTIONS "-DTEST_IOS=OFF") + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake(XcodeBundles) + run_cmake_command(XcodeBundles-build ${CMAKE_COMMAND} --build .) + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) + unset(RunCMake_TEST_OPTIONS) + + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeBundlesIOS-build) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_OPTIONS "-DTEST_IOS=ON") + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake(XcodeBundles) + run_cmake_command(XcodeBundles-build ${CMAKE_COMMAND} --build .) + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) + unset(RunCMake_TEST_OPTIONS) +endif() diff --git a/Tests/RunCMake/XcodeProject/XcodeBundles.cmake b/Tests/RunCMake/XcodeProject/XcodeBundles.cmake new file mode 100644 index 0000000..fdb5f11 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/XcodeBundles.cmake @@ -0,0 +1,43 @@ +# check if Xcode and CMake have the same understanding of Bundle layout + +cmake_minimum_required(VERSION 3.3) +enable_language(C) + +if(TEST_IOS) + set(CMAKE_OSX_SYSROOT iphoneos) + #set(CMAKE_OSX_ARCHITECTURES "i386") + set(CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos;-iphonesimulator") + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") +endif(TEST_IOS) + +# App Bundle + +add_executable(AppBundle MACOSX_BUNDLE main.m) + +add_custom_target(AppBundleTest ALL + COMMAND ${CMAKE_COMMAND} -E copy + "$" "$.old") + +add_dependencies(AppBundleTest AppBundle) + +# Framework + +add_library(Framework SHARED main.c) +set_target_properties(Framework PROPERTIES FRAMEWORK TRUE) + +add_custom_target(FrameworkTest ALL + COMMAND ${CMAKE_COMMAND} -E copy + "$" "$.old") + +add_dependencies(FrameworkTest Framework) + +# Bundle + +add_library(Bundle MODULE main.c) +set_target_properties(Bundle PROPERTIES BUNDLE TRUE) + +add_custom_target(BundleTest ALL + COMMAND ${CMAKE_COMMAND} -E copy + "$" "$.old") + +add_dependencies(BundleTest Bundle) diff --git a/Tests/RunCMake/XcodeProject/main.m b/Tests/RunCMake/XcodeProject/main.m new file mode 100644 index 0000000..6dc190a --- /dev/null +++ b/Tests/RunCMake/XcodeProject/main.m @@ -0,0 +1,3 @@ +int main(int argc, const char * argv[]) { + return 1; +} ----------------------------------------------------------------------- Summary of changes: Source/cmGeneratorTarget.cxx | 30 +++++++++++------ Source/cmMakefile.cxx | 12 +++++++ Source/cmMakefile.h | 3 ++ Tests/RunCMake/XcodeProject/RunCMakeTest.cmake | 32 ++++++++++++++++++ Tests/RunCMake/XcodeProject/XcodeBundles.cmake | 43 ++++++++++++++++++++++++ Tests/RunCMake/XcodeProject/main.m | 3 ++ 6 files changed, 113 insertions(+), 10 deletions(-) create mode 100644 Tests/RunCMake/XcodeProject/XcodeBundles.cmake create mode 100644 Tests/RunCMake/XcodeProject/main.m hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 20 11:51:48 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 20 Aug 2015 11:51:48 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2292-g42f1d11 Message-ID: <20150820155148.EEC83B134A@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 42f1d1166fff8f78ca9e5e5465bbae4047a7a94f (commit) via 3ab78a691cb97354401bbbfc4b1658844f3896f3 (commit) from 0c0852b1b0fe29ad445f4f0842343c39cf8e7c13 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=42f1d1166fff8f78ca9e5e5465bbae4047a7a94f commit 42f1d1166fff8f78ca9e5e5465bbae4047a7a94f Merge: 0c0852b 3ab78a6 Author: Brad King AuthorDate: Thu Aug 20 11:51:48 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 20 11:51:48 2015 -0400 Merge topic 'FindCUDA-vs2013-separate-compilation' into next 3ab78a69 FindCUDA: Fix object build rule for separate compilation on VS 2013+ http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3ab78a691cb97354401bbbfc4b1658844f3896f3 commit 3ab78a691cb97354401bbbfc4b1658844f3896f3 Author: Dominic Meiser AuthorDate: Thu Aug 20 08:28:07 2015 -0600 Commit: Brad King CommitDate: Thu Aug 20 11:50:52 2015 -0400 FindCUDA: Fix object build rule for separate compilation on VS 2013+ The handling of multilevel dependencies has been fixed in Visual Studio 2013. The work around used for VS 2010 and VS 2012 does not work for VS 2013 any more. Switch to normal object build rules for VS 2013 and newer. diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index f4b0783..1fc582f 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -1584,9 +1584,8 @@ function(CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS output_file cuda_target options # we work around that issue by compiling the intermediate link object as a # pre-link custom command in that situation. set(do_obj_build_rule TRUE) - if (MSVC_VERSION GREATER 1599) - # VS 2010 and 2012 have this problem. If future versions fix this issue, - # it should still work, it just won't be as nice as the other method. + if (MSVC_VERSION GREATER 1599 AND MSVC_VERSION LESS 1800) + # VS 2010 and 2012 have this problem. set(do_obj_build_rule FALSE) endif() ----------------------------------------------------------------------- Summary of changes: Modules/FindCUDA.cmake | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 20 11:52:29 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 20 Aug 2015 11:52:29 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2294-gbf6eff2 Message-ID: <20150820155229.A1CE1B13C1@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via bf6eff2ec7712a601736160c192eaa3b3fe4ae0a (commit) via 9b2f69925a59ac5bafdfafb650a2f2f785348085 (commit) from 42f1d1166fff8f78ca9e5e5465bbae4047a7a94f (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bf6eff2ec7712a601736160c192eaa3b3fe4ae0a commit bf6eff2ec7712a601736160c192eaa3b3fe4ae0a Merge: 42f1d11 9b2f699 Author: Brad King AuthorDate: Thu Aug 20 11:52:29 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 20 11:52:29 2015 -0400 Merge topic 'FindCUDA-vs2013-separate-compilation' into next 9b2f6992 FindCUDA: Fix object build rule for separate compilation on VS 2013+ (#15697) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9b2f69925a59ac5bafdfafb650a2f2f785348085 commit 9b2f69925a59ac5bafdfafb650a2f2f785348085 Author: Dominic Meiser AuthorDate: Thu Aug 20 08:28:07 2015 -0600 Commit: Brad King CommitDate: Thu Aug 20 11:52:11 2015 -0400 FindCUDA: Fix object build rule for separate compilation on VS 2013+ (#15697) The handling of multilevel dependencies has been fixed in Visual Studio 2013. The work around used for VS 2010 and VS 2012 does not work for VS 2013 any more. Switch to normal object build rules for VS 2013 and newer. diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index f4b0783..1fc582f 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -1584,9 +1584,8 @@ function(CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS output_file cuda_target options # we work around that issue by compiling the intermediate link object as a # pre-link custom command in that situation. set(do_obj_build_rule TRUE) - if (MSVC_VERSION GREATER 1599) - # VS 2010 and 2012 have this problem. If future versions fix this issue, - # it should still work, it just won't be as nice as the other method. + if (MSVC_VERSION GREATER 1599 AND MSVC_VERSION LESS 1800) + # VS 2010 and 2012 have this problem. set(do_obj_build_rule FALSE) endif() ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From kwrobot at kitware.com Fri Aug 21 00:01:11 2015 From: kwrobot at kitware.com (Kitware Robot) Date: Fri, 21 Aug 2015 00:01:11 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-876-g3755250 Message-ID: <20150821040112.2A1E5B19C0@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 3755250f8e52f809368d9b340da006272cd91a2c (commit) from e72a5b2c0b51f90970fc4ef27969cee9990be862 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3755250f8e52f809368d9b340da006272cd91a2c commit 3755250f8e52f809368d9b340da006272cd91a2c Author: Kitware Robot AuthorDate: Fri Aug 21 00:01:09 2015 -0400 Commit: Kitware Robot CommitDate: Fri Aug 21 00:01:09 2015 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 54bbbbb..e2de794 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150820) +set(CMake_VERSION_PATCH 20150821) #set(CMake_VERSION_RC 1) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Fri Aug 21 08:45:46 2015 From: brad.king at kitware.com (Brad King) Date: Fri, 21 Aug 2015 08:45:46 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2297-gd6ef5f4 Message-ID: <20150821124546.EB34DB0971@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via d6ef5f480846881bd110fd82ddd2e954be99b95e (commit) via e8585f45f57e23bc9eca068d8bee02888066d722 (commit) via 6db713c07f2f1b14f695e123008522daf3d26527 (commit) from bf6eff2ec7712a601736160c192eaa3b3fe4ae0a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d6ef5f480846881bd110fd82ddd2e954be99b95e commit d6ef5f480846881bd110fd82ddd2e954be99b95e Merge: bf6eff2 e8585f4 Author: Brad King AuthorDate: Fri Aug 21 08:45:45 2015 -0400 Commit: CMake Topic Stage CommitDate: Fri Aug 21 08:45:45 2015 -0400 Merge topic 'drop-cmsys-std-layer' into next e8585f45 Remove use of include and cmsys_stl::* 6db713c0 Remove use of include and cmsys_ios::* http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e8585f45f57e23bc9eca068d8bee02888066d722 commit e8585f45f57e23bc9eca068d8bee02888066d722 Author: Brad King AuthorDate: Thu Aug 20 16:06:40 2015 -0400 Commit: Brad King CommitDate: Thu Aug 20 16:19:08 2015 -0400 Remove use of include and cmsys_stl::* We no longer need this compatibility layer for the compilers we support. diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 65599e0..20807c8 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -27,8 +27,6 @@ #include #include #include -#include -#include #include #include diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 8ba8847..59590fd 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -18,8 +18,6 @@ #include "cmake.h" #include "cmAlgorithms.h" -#include - #include /* diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx index 0a66732..e8d158e 100644 --- a/Source/cmFindLibraryCommand.cxx +++ b/Source/cmFindLibraryCommand.cxx @@ -11,7 +11,6 @@ ============================================================================*/ #include "cmFindLibraryCommand.h" #include -#include cmFindLibraryCommand::cmFindLibraryCommand() { diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index ab3c1ee..c6c9f53 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -30,7 +30,6 @@ # include "cmLocale.h" # include #endif -#include #include #include diff --git a/Source/cmXMLSafe.h b/Source/cmXMLSafe.h index 42333fa..ead2e01 100644 --- a/Source/cmXMLSafe.h +++ b/Source/cmXMLSafe.h @@ -12,7 +12,8 @@ #ifndef cmXMLSafe_h #define cmXMLSafe_h -#include +#include +#include #include /** \class cmXMLSafe http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6db713c07f2f1b14f695e123008522daf3d26527 commit 6db713c07f2f1b14f695e123008522daf3d26527 Author: Brad King AuthorDate: Thu Aug 20 16:02:20 2015 -0400 Commit: Brad King CommitDate: Thu Aug 20 16:19:08 2015 -0400 Remove use of include and cmsys_ios::* We no longer need this compatibility layer for the compilers we support. diff --git a/Source/CPack/OSXScriptLauncher.cxx b/Source/CPack/OSXScriptLauncher.cxx index 1d7afbd..c271517 100644 --- a/Source/CPack/OSXScriptLauncher.cxx +++ b/Source/CPack/OSXScriptLauncher.cxx @@ -11,17 +11,18 @@ ============================================================================*/ #include #include -#include #include +#include + #include // For the PATH_MAX constant #include #define DebugError(x) \ - ofs << x << cmsys_ios::endl; \ - cmsys_ios::cout << x << cmsys_ios::endl + ofs << x << std::endl; \ + std::cout << x << std::endl int main(int argc, char* argv[]) { @@ -77,7 +78,7 @@ int main(int argc, char* argv[]) std::string scriptDirectory = cmsys::SystemTools::GetFilenamePath( fullScriptPath); - ofs << fullScriptPath.c_str() << cmsys_ios::endl; + ofs << fullScriptPath.c_str() << std::endl; std::vector args; args.push_back(fullScriptPath.c_str()); int cc; @@ -109,7 +110,7 @@ int main(int argc, char* argv[]) data[i] = ' '; } } - cmsys_ios::cout.write(data, length); + std::cout.write(data, length); } cmsysProcess_WaitForExit(cp, 0); diff --git a/Source/CPack/cmCPackSTGZGenerator.cxx b/Source/CPack/cmCPackSTGZGenerator.cxx index e5da5cf..109dcb7 100644 --- a/Source/CPack/cmCPackSTGZGenerator.cxx +++ b/Source/CPack/cmCPackSTGZGenerator.cxx @@ -19,7 +19,6 @@ #include "cmMakefile.h" #include "cmCPackLog.h" -#include #include #include #include @@ -85,7 +84,7 @@ int cmCPackSTGZGenerator::PackageFiles() int cmCPackSTGZGenerator::GenerateHeader(std::ostream* os) { cmCPackLogger(cmCPackLog::LOG_DEBUG, "Writing header" << std::endl); - cmsys_ios::ostringstream str; + std::ostringstream str; int counter = 0; std::string inLicFile = this->GetOption("CPACK_RESOURCE_FILE_LICENSE"); diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx index 6b84bab..5b9208a 100644 --- a/Source/CTest/cmCTestGIT.cxx +++ b/Source/CTest/cmCTestGIT.cxx @@ -17,7 +17,6 @@ #include "cmXMLSafe.h" #include -#include #include #include diff --git a/Source/CTest/cmCTestP4.cxx b/Source/CTest/cmCTestP4.cxx index 31002a6..5ce431a 100644 --- a/Source/CTest/cmCTestP4.cxx +++ b/Source/CTest/cmCTestP4.cxx @@ -16,7 +16,6 @@ #include "cmXMLSafe.h" #include -#include #include #include diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx index 44d0d4e..234af79 100644 --- a/Source/cmArchiveWrite.cxx +++ b/Source/cmArchiveWrite.cxx @@ -13,7 +13,6 @@ #include "cmSystemTools.h" #include "cmLocale.h" -#include #include #include #include @@ -67,7 +66,7 @@ struct cmArchiveWrite::Callback { cmArchiveWrite* self = static_cast(cd); if(self->Stream.write(static_cast(b), - static_cast(n))) + static_cast(n))) { return static_cast<__LA_SSIZE_T>(n); } @@ -313,7 +312,7 @@ bool cmArchiveWrite::AddFile(const char* file, //---------------------------------------------------------------------------- bool cmArchiveWrite::AddData(const char* file, size_t size) { - cmsys::ifstream fin(file, std::ios::in | cmsys_ios_binary); + cmsys::ifstream fin(file, std::ios::in | std::ios::binary); if(!fin) { this->Error = "Error opening \""; @@ -327,7 +326,7 @@ bool cmArchiveWrite::AddData(const char* file, size_t size) size_t nleft = size; while(nleft > 0) { - typedef cmsys_ios::streamsize ssize_type; + typedef std::streamsize ssize_type; size_t const nnext = nleft > sizeof(buffer)? sizeof(buffer) : nleft; ssize_type const nnext_s = static_cast(nnext); fin.read(buffer, nnext_s); diff --git a/Source/cmCMakeHostSystemInformationCommand.cxx b/Source/cmCMakeHostSystemInformationCommand.cxx index 5234538..6ff7c0d 100644 --- a/Source/cmCMakeHostSystemInformationCommand.cxx +++ b/Source/cmCMakeHostSystemInformationCommand.cxx @@ -11,8 +11,6 @@ ============================================================================*/ #include "cmCMakeHostSystemInformationCommand.h" -#include - // cmCMakeHostSystemInformation bool cmCMakeHostSystemInformationCommand ::InitialPass(std::vector const &args, cmExecutionStatus &) @@ -107,7 +105,7 @@ bool cmCMakeHostSystemInformationCommand std::string cmCMakeHostSystemInformationCommand ::ValueToString(size_t value) const { - cmsys_ios::stringstream tmp; + std::stringstream tmp; tmp << value; return tmp.str(); } diff --git a/Source/cmCryptoHash.cxx b/Source/cmCryptoHash.cxx index 74e17b6..6616218 100644 --- a/Source/cmCryptoHash.cxx +++ b/Source/cmCryptoHash.cxx @@ -46,7 +46,7 @@ std::string cmCryptoHash::HashString(const std::string& input) //---------------------------------------------------------------------------- std::string cmCryptoHash::HashFile(const std::string& file) { - cmsys::ifstream fin(file.c_str(), std::ios::in | cmsys_ios_binary); + cmsys::ifstream fin(file.c_str(), std::ios::in | std::ios::binary); if(!fin) { return ""; diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 68a6558..9b9071d 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -1378,7 +1378,7 @@ void cmFindPackageCommand::LoadPackageRegistryDir(std::string const& dir, cmFindPackageCommandHoldFile holdFile(fname.c_str()); // Load the file. - cmsys::ifstream fin(fname.c_str(), std::ios::in | cmsys_ios_binary); + cmsys::ifstream fin(fname.c_str(), std::ios::in | std::ios::binary); std::string fentry; if(fin && cmSystemTools::GetLineFromStream(fin, fentry) && this->CheckPackageRegistryEntry(fentry, outPaths)) diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 4eb9b13..f85e70e 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -26,7 +26,6 @@ #include #include -#include #include #include @@ -122,7 +121,7 @@ static void copyTargetProperty(cmTarget* destinationTarget, static std::string ReadAll(const std::string& filename) { cmsys::ifstream file(filename.c_str()); - cmsys_ios::stringstream stream; + std::stringstream stream; stream << file.rdbuf(); file.close(); return stream.str(); @@ -1640,7 +1639,7 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile) this->GenerateQrc(); } - cmsys_ios::stringstream outStream; + std::stringstream outStream; outStream << "/* This file is autogenerated, do not edit*/\n"; bool automocCppChanged = false; diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index a117238..ab3c1ee 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1482,7 +1482,7 @@ bool cmSystemTools::CreateTar(const char* outFileName, { #if defined(CMAKE_BUILD_WITH_CMAKE) std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); - cmsys::ofstream fout(outFileName, std::ios::out | cmsys_ios_binary); + cmsys::ofstream fout(outFileName, std::ios::out | std::ios::binary); if(!fout) { std::string e = "Cannot open output file \""; diff --git a/Source/cmXMLSafe.cxx b/Source/cmXMLSafe.cxx index 99f5625..4ad05ca 100644 --- a/Source/cmXMLSafe.cxx +++ b/Source/cmXMLSafe.cxx @@ -13,8 +13,8 @@ #include "cm_utf8.h" -#include -#include +#include +#include #include #include @@ -45,13 +45,13 @@ cmXMLSafe& cmXMLSafe::Quotes(bool b) //---------------------------------------------------------------------------- std::string cmXMLSafe::str() { - cmsys_ios::ostringstream ss; + std::ostringstream ss; ss << *this; return ss.str(); } //---------------------------------------------------------------------------- -cmsys_ios::ostream& operator<<(cmsys_ios::ostream& os, cmXMLSafe const& self) +std::ostream& operator<<(std::ostream& os, cmXMLSafe const& self) { char const* first = self.Data; char const* last = self.Data + self.Size; diff --git a/Source/cmXMLSafe.h b/Source/cmXMLSafe.h index c23a90c..42333fa 100644 --- a/Source/cmXMLSafe.h +++ b/Source/cmXMLSafe.h @@ -13,7 +13,7 @@ #define cmXMLSafe_h #include -#include +#include /** \class cmXMLSafe * \brief Write strings to XML with proper escapes @@ -37,8 +37,7 @@ private: char const* Data; unsigned long Size; bool DoQuotes; - friend cmsys_ios::ostream& operator<<(cmsys_ios::ostream&, - cmXMLSafe const&); + friend std::ostream& operator<<(std::ostream&, cmXMLSafe const&); }; #endif diff --git a/Tests/CMakeLib/testVisualStudioSlnParser.cxx b/Tests/CMakeLib/testVisualStudioSlnParser.cxx index 5b62f23..5007ab8 100644 --- a/Tests/CMakeLib/testVisualStudioSlnParser.cxx +++ b/Tests/CMakeLib/testVisualStudioSlnParser.cxx @@ -3,7 +3,7 @@ #include "cmVisualStudioSlnData.h" #include "cmVisualStudioSlnParser.h" -#include +#include //---------------------------------------------------------------------------- static bool parsedRight(cmVisualStudioSlnParser& parser, @@ -27,10 +27,10 @@ static bool parsedRight(cmVisualStudioSlnParser& parser, return true; } } - cmsys_ios::cerr << "cmVisualStudioSlnParser mis-parsed " << file - << "." SLN_EXTENSION << "; expected result " << expected - << ", got " << parser.GetParseResult() - << cmsys_ios::endl; + std::cerr << "cmVisualStudioSlnParser mis-parsed " << file + << "." SLN_EXTENSION << "; expected result " << expected + << ", got " << parser.GetParseResult() + << std::endl; return false; } @@ -42,8 +42,8 @@ int testVisualStudioSlnParser(int, char*[]) // Test clean parser if (parser.GetParseResult() != cmVisualStudioSlnParser::ResultOK) { - cmsys_ios::cerr << "cmVisualStudioSlnParser initialisation failed" - << cmsys_ios::endl; + std::cerr << "cmVisualStudioSlnParser initialisation failed" + << std::endl; return 1; } @@ -73,38 +73,38 @@ int testVisualStudioSlnParser(int, char*[]) const size_t expectedProjectCount = sizeof(names) / sizeof(*names); if (projects.size() != expectedProjectCount) { - cmsys_ios::cerr << "cmVisualStudioSlnParser returned bad number of " - << "projects (" << projects.size() << " instead of " - << expectedProjectCount << ')' - << cmsys_ios::endl; + std::cerr << "cmVisualStudioSlnParser returned bad number of " + << "projects (" << projects.size() << " instead of " + << expectedProjectCount << ')' + << std::endl; return 1; } for (size_t idx = 0; idx < expectedProjectCount; ++idx) { if (projects[idx].GetName() != names[idx]) { - cmsys_ios::cerr << "cmVisualStudioSlnParser returned bad project #" - << idx << "; expected \"" << names[idx] << "\", got \"" - << projects[idx].GetName() << '"' - << cmsys_ios::endl; + std::cerr << "cmVisualStudioSlnParser returned bad project #" + << idx << "; expected \"" << names[idx] << "\", got \"" + << projects[idx].GetName() << '"' + << std::endl; return 1; } } if (projects[0].GetRelativePath() != "Utilities\\3rdParty") { - cmsys_ios::cerr << "cmVisualStudioSlnParser returned bad relative path of " - << "project 3rdParty; expected \"Utilities\\3rdParty\", " - << "got \"" << projects[0].GetRelativePath() << '"' - << cmsys_ios::endl; + std::cerr << "cmVisualStudioSlnParser returned bad relative path of " + << "project 3rdParty; expected \"Utilities\\3rdParty\", " + << "got \"" << projects[0].GetRelativePath() << '"' + << std::endl; return 1; } if (projects[2].GetGUID() != "{59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}") { - cmsys_ios::cerr << "cmVisualStudioSlnParser returned bad relative path of " - << "project CMakeLib; expected " - << "\"{59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}\", " - << "got \"" << projects[2].GetGUID() << '"' - << cmsys_ios::endl; + std::cerr << "cmVisualStudioSlnParser returned bad relative path of " + << "project CMakeLib; expected " + << "\"{59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}\", " + << "got \"" << projects[2].GetGUID() << '"' + << std::endl; return 1; } } @@ -119,9 +119,9 @@ int testVisualStudioSlnParser(int, char*[]) } if (!parser.GetParseHadBOM()) { - cmsys_ios::cerr << "cmVisualStudioSlnParser didn't find BOM in bom." - << SLN_EXTENSION - << cmsys_ios::endl; + std::cerr << "cmVisualStudioSlnParser didn't find BOM in bom." + << SLN_EXTENSION + << std::endl; return 1; } @@ -131,9 +131,9 @@ int testVisualStudioSlnParser(int, char*[]) } if (parser.GetParseHadBOM()) { - cmsys_ios::cerr << "cmVisualStudioSlnParser found BOM in nobom." - << SLN_EXTENSION - << cmsys_ios::endl; + std::cerr << "cmVisualStudioSlnParser found BOM in nobom." + << SLN_EXTENSION + << std::endl; return 1; } } diff --git a/Tests/CMakeLib/testXMLParser.cxx b/Tests/CMakeLib/testXMLParser.cxx index 54ed5dc..b5219e2 100644 --- a/Tests/CMakeLib/testXMLParser.cxx +++ b/Tests/CMakeLib/testXMLParser.cxx @@ -2,7 +2,7 @@ #include "cmXMLParser.h" -#include +#include int testXMLParser(int, char*[]) { @@ -10,7 +10,7 @@ int testXMLParser(int, char*[]) cmXMLParser parser; if(!parser.ParseFile(SOURCE_DIR "/testXMLParser.xml")) { - cmsys_ios::cerr << "cmXMLParser failed!" << cmsys_ios::endl; + std::cerr << "cmXMLParser failed!" << std::endl; return 1; } return 0; ----------------------------------------------------------------------- Summary of changes: Source/CPack/OSXScriptLauncher.cxx | 11 +++-- Source/CPack/cmCPackSTGZGenerator.cxx | 3 +- Source/CTest/cmCTestCoverageHandler.cxx | 2 - Source/CTest/cmCTestGIT.cxx | 1 - Source/CTest/cmCTestP4.cxx | 1 - Source/cmArchiveWrite.cxx | 7 ++- Source/cmCMakeHostSystemInformationCommand.cxx | 4 +- Source/cmComputeLinkDepends.cxx | 2 - Source/cmCryptoHash.cxx | 2 +- Source/cmFindLibraryCommand.cxx | 1 - Source/cmFindPackageCommand.cxx | 2 +- Source/cmQtAutoGenerators.cxx | 5 +- Source/cmSystemTools.cxx | 3 +- Source/cmXMLSafe.cxx | 8 ++-- Source/cmXMLSafe.h | 8 ++-- Tests/CMakeLib/testVisualStudioSlnParser.cxx | 60 ++++++++++++------------ Tests/CMakeLib/testXMLParser.cxx | 4 +- 17 files changed, 56 insertions(+), 68 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Fri Aug 21 09:28:51 2015 From: brad.king at kitware.com (Brad King) Date: Fri, 21 Aug 2015 09:28:51 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-878-g162e7b5 Message-ID: <20150821132851.D286DB1855@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 162e7b5675673cb5521a2b1e98c0dc66d3bad4fd (commit) via dc8822f0a7b4152c5cb880e6a7fccada767e2fb1 (commit) from 3755250f8e52f809368d9b340da006272cd91a2c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=162e7b5675673cb5521a2b1e98c0dc66d3bad4fd commit 162e7b5675673cb5521a2b1e98c0dc66d3bad4fd Merge: 3755250 dc8822f Author: Brad King AuthorDate: Fri Aug 21 09:28:50 2015 -0400 Commit: CMake Topic Stage CommitDate: Fri Aug 21 09:28:50 2015 -0400 Merge topic 'determine-compiler-CMP0054' dc8822f0 CMakeDetermine{C,CXX}Compiler: Avoid if() auto-dereferene in quoted arguments ----------------------------------------------------------------------- Summary of changes: Modules/CMakeDetermineCCompiler.cmake | 7 ++++--- Modules/CMakeDetermineCXXCompiler.cmake | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Fri Aug 21 09:28:54 2015 From: brad.king at kitware.com (Brad King) Date: Fri, 21 Aug 2015 09:28:54 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-880-g4ae9362 Message-ID: <20150821132854.9378AB185D@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 4ae9362b5be154781543b9255e06366a528db359 (commit) via e89ea3d190492e41b37425ff021311c2b471f1b9 (commit) from 162e7b5675673cb5521a2b1e98c0dc66d3bad4fd (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4ae9362b5be154781543b9255e06366a528db359 commit 4ae9362b5be154781543b9255e06366a528db359 Merge: 162e7b5 e89ea3d Author: Brad King AuthorDate: Fri Aug 21 09:28:53 2015 -0400 Commit: CMake Topic Stage CommitDate: Fri Aug 21 09:28:53 2015 -0400 Merge topic 'get-filename-component-base-dir' e89ea3d1 get_filename_component: Teach new BASE_DIR parameter. ----------------------------------------------------------------------- Summary of changes: Help/command/get_filename_component.rst | 37 +++++++++++++++++--- .../dev/get-filename-component-base-dir.rst | 6 ++++ Source/cmGetFilenameComponentCommand.cxx | 20 ++++++++--- .../get_filename_component/KnownComponents.cmake | 33 +++++++++++++++++ 4 files changed, 87 insertions(+), 9 deletions(-) create mode 100644 Help/release/dev/get-filename-component-base-dir.rst hooks/post-receive -- CMake From brad.king at kitware.com Fri Aug 21 09:28:56 2015 From: brad.king at kitware.com (Brad King) Date: Fri, 21 Aug 2015 09:28:56 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-882-gf986574 Message-ID: <20150821132856.E83C1B186B@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via f9865743ed942b1932d664d136a4ad505b724bf6 (commit) via 625225bbe6a84350759d7116a6cd5ad2f850e635 (commit) from 4ae9362b5be154781543b9255e06366a528db359 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f9865743ed942b1932d664d136a4ad505b724bf6 commit f9865743ed942b1932d664d136a4ad505b724bf6 Merge: 4ae9362 625225b Author: Brad King AuthorDate: Fri Aug 21 09:28:55 2015 -0400 Commit: CMake Topic Stage CommitDate: Fri Aug 21 09:28:55 2015 -0400 Merge topic 'hp-ux-itanium-shared-libs' 625225bb HP-UX: Do not use ".sl" extension for shared libs on Itanium ----------------------------------------------------------------------- Summary of changes: Modules/Platform/HP-UX.cmake | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Fri Aug 21 09:28:59 2015 From: brad.king at kitware.com (Brad King) Date: Fri, 21 Aug 2015 09:28:59 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-884-gcecd0d1 Message-ID: <20150821132859.5B89EB186C@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via cecd0d186db5a415ef9fe261310cba020eb040a2 (commit) via 3e94f94b898aa183badd2ac8be52d20b007d5b26 (commit) from f9865743ed942b1932d664d136a4ad505b724bf6 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cecd0d186db5a415ef9fe261310cba020eb040a2 commit cecd0d186db5a415ef9fe261310cba020eb040a2 Merge: f986574 3e94f94 Author: Brad King AuthorDate: Fri Aug 21 09:28:58 2015 -0400 Commit: CMake Topic Stage CommitDate: Fri Aug 21 09:28:58 2015 -0400 Merge topic 'vs-fix-obj-extension' 3e94f94b cmLocalVisualStudioGenerator: Use computed .obj extension (#13685) ----------------------------------------------------------------------- Summary of changes: Source/cmLocalVisualStudioGenerator.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Fri Aug 21 09:29:01 2015 From: brad.king at kitware.com (Brad King) Date: Fri, 21 Aug 2015 09:29:01 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-886-g870d839 Message-ID: <20150821132901.666CAB185E@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 870d839f0d050e1db117c945d478938db657072e (commit) via c66835fc37fa3dec32a437010648fee0b210a1a5 (commit) from cecd0d186db5a415ef9fe261310cba020eb040a2 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=870d839f0d050e1db117c945d478938db657072e commit 870d839f0d050e1db117c945d478938db657072e Merge: cecd0d1 c66835f Author: Brad King AuthorDate: Fri Aug 21 09:29:00 2015 -0400 Commit: CMake Topic Stage CommitDate: Fri Aug 21 09:29:00 2015 -0400 Merge topic 'sublime-msvc-includes' c66835fc Extra Generator: Populate MSVC system include paths from environment (#15597) ----------------------------------------------------------------------- Summary of changes: .../CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake | 4 ++++ 1 file changed, 4 insertions(+) hooks/post-receive -- CMake From brad.king at kitware.com Fri Aug 21 09:29:03 2015 From: brad.king at kitware.com (Brad King) Date: Fri, 21 Aug 2015 09:29:03 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-888-gc450686 Message-ID: <20150821132903.AA981B185E@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via c450686ef20597d43d4f019b315275cc8a6ba4a2 (commit) via 3c37d2642d9000a2d01bc46ad0ea74a741bdb658 (commit) from 870d839f0d050e1db117c945d478938db657072e (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c450686ef20597d43d4f019b315275cc8a6ba4a2 commit c450686ef20597d43d4f019b315275cc8a6ba4a2 Merge: 870d839 3c37d26 Author: Brad King AuthorDate: Fri Aug 21 09:29:02 2015 -0400 Commit: CMake Topic Stage CommitDate: Fri Aug 21 09:29:02 2015 -0400 Merge topic 'OUTPUT_NAME-genex-no-recursion' 3c37d264 cmGeneratorTarget: Avoid recursion in GetOutputName method ----------------------------------------------------------------------- Summary of changes: Source/cmGeneratorTarget.cxx | 93 ++++++++++++-------- Source/cmGeneratorTarget.h | 4 + .../OUTPUT_NAME-recursion-result.txt} | 0 .../OUTPUT_NAME-recursion-stderr.txt | 4 + .../OUTPUT_NAME-recursion.cmake | 3 + .../GeneratorExpression/RunCMakeTest.cmake | 1 + .../TARGET_FILE-recursion.cmake | 1 + 7 files changed, 71 insertions(+), 35 deletions(-) copy Tests/RunCMake/{CMP0004/CMP0004-NEW-result.txt => GeneratorExpression/OUTPUT_NAME-recursion-result.txt} (100%) create mode 100644 Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion-stderr.txt create mode 100644 Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion.cmake hooks/post-receive -- CMake From brad.king at kitware.com Fri Aug 21 09:29:05 2015 From: brad.king at kitware.com (Brad King) Date: Fri, 21 Aug 2015 09:29:05 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-890-gdef5795 Message-ID: <20150821132905.BE5E3B188F@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via def5795bac507ca15f40f46ba3024e81fdcc150b (commit) via 9b2f69925a59ac5bafdfafb650a2f2f785348085 (commit) from c450686ef20597d43d4f019b315275cc8a6ba4a2 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=def5795bac507ca15f40f46ba3024e81fdcc150b commit def5795bac507ca15f40f46ba3024e81fdcc150b Merge: c450686 9b2f699 Author: Brad King AuthorDate: Fri Aug 21 09:29:04 2015 -0400 Commit: CMake Topic Stage CommitDate: Fri Aug 21 09:29:04 2015 -0400 Merge topic 'FindCUDA-vs2013-separate-compilation' 9b2f6992 FindCUDA: Fix object build rule for separate compilation on VS 2013+ (#15697) ----------------------------------------------------------------------- Summary of changes: Modules/FindCUDA.cmake | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Fri Aug 21 09:29:08 2015 From: brad.king at kitware.com (Brad King) Date: Fri, 21 Aug 2015 09:29:08 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-893-gbadde9c Message-ID: <20150821132908.1E53BB185D@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via badde9c2a11afd8f9127f757e964d0d94c777aad (commit) via f799ffb5cb895855ac2aba54765622b81db5be38 (commit) via 899458ab20876aeea915a59e9bfb459d92d264de (commit) from def5795bac507ca15f40f46ba3024e81fdcc150b (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=badde9c2a11afd8f9127f757e964d0d94c777aad commit badde9c2a11afd8f9127f757e964d0d94c777aad Merge: def5795 f799ffb Author: Brad King AuthorDate: Fri Aug 21 09:29:06 2015 -0400 Commit: CMake Topic Stage CommitDate: Fri Aug 21 09:29:06 2015 -0400 Merge topic 'modules-no-soname' f799ffb5 Do not set SONAME for MODULE library targets (#15705) 899458ab Tests: Cover NO_SONAME property for SHARED libraries ----------------------------------------------------------------------- Summary of changes: Help/prop_tgt/NO_SONAME.rst | 6 +-- Help/release/dev/modules-no-soname.rst | 7 ++++ Source/cmGeneratorTarget.cxx | 3 +- Tests/ExportImport/Export/CMakeLists.txt | 5 +++ Tests/ExportImport/Export/testLibNoSONAME.c | 7 ++++ Tests/ExportImport/Import/A/CMakeLists.txt | 44 ++++++++++++++++++++ .../ExportImport/Import/A/check_lib_nosoname.cmake | 7 ++++ Tests/ExportImport/Import/A/check_lib_soname.cmake | 7 ++++ Tests/Plugin/CMakeLists.txt | 9 +--- Tests/Plugin/PluginTest/CMakeLists.txt | 17 +++----- Tests/Plugin/check_mod_soname.cmake | 17 +++----- 11 files changed, 93 insertions(+), 36 deletions(-) create mode 100644 Help/release/dev/modules-no-soname.rst create mode 100644 Tests/ExportImport/Export/testLibNoSONAME.c create mode 100644 Tests/ExportImport/Import/A/check_lib_nosoname.cmake create mode 100644 Tests/ExportImport/Import/A/check_lib_soname.cmake hooks/post-receive -- CMake From brad.king at kitware.com Fri Aug 21 09:29:25 2015 From: brad.king at kitware.com (Brad King) Date: Fri, 21 Aug 2015 09:29:25 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2307-g5e1d630 Message-ID: <20150821132925.BA31AB1894@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 5e1d63010b81e6dd61e681f86d37d8cb69b604f8 (commit) via badde9c2a11afd8f9127f757e964d0d94c777aad (commit) via def5795bac507ca15f40f46ba3024e81fdcc150b (commit) via c450686ef20597d43d4f019b315275cc8a6ba4a2 (commit) via 870d839f0d050e1db117c945d478938db657072e (commit) via cecd0d186db5a415ef9fe261310cba020eb040a2 (commit) via f9865743ed942b1932d664d136a4ad505b724bf6 (commit) via 4ae9362b5be154781543b9255e06366a528db359 (commit) via 162e7b5675673cb5521a2b1e98c0dc66d3bad4fd (commit) via 3755250f8e52f809368d9b340da006272cd91a2c (commit) from d6ef5f480846881bd110fd82ddd2e954be99b95e (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5e1d63010b81e6dd61e681f86d37d8cb69b604f8 commit 5e1d63010b81e6dd61e681f86d37d8cb69b604f8 Merge: d6ef5f4 badde9c Author: Brad King AuthorDate: Fri Aug 21 09:29:16 2015 -0400 Commit: Brad King CommitDate: Fri Aug 21 09:29:16 2015 -0400 Merge branch 'master' into next ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Fri Aug 21 09:30:21 2015 From: brad.king at kitware.com (Brad King) Date: Fri, 21 Aug 2015 09:30:21 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2309-g824a398 Message-ID: <20150821133021.92F6CB18F0@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 824a39818d33bc5b25af7757f8deadc04d28db70 (commit) via 4476feac33a88942ebbe2d988c7db4a575de716f (commit) from 5e1d63010b81e6dd61e681f86d37d8cb69b604f8 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=824a39818d33bc5b25af7757f8deadc04d28db70 commit 824a39818d33bc5b25af7757f8deadc04d28db70 Merge: 5e1d630 4476fea Author: Brad King AuthorDate: Fri Aug 21 09:30:20 2015 -0400 Commit: CMake Topic Stage CommitDate: Fri Aug 21 09:30:20 2015 -0400 Merge topic 'java-updates' into next 4476feac UseJava: Add support for javah tool http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4476feac33a88942ebbe2d988c7db4a575de716f commit 4476feac33a88942ebbe2d988c7db4a575de716f Author: Marc Chevrier AuthorDate: Wed Aug 5 07:46:02 2015 +0000 Commit: Brad King CommitDate: Fri Aug 21 09:30:08 2015 -0400 UseJava: Add support for javah tool Add a `create_javah` API. diff --git a/Help/release/dev/java-updates.rst b/Help/release/dev/java-updates.rst index b777807..8fd4ed6 100644 --- a/Help/release/dev/java-updates.rst +++ b/Help/release/dev/java-updates.rst @@ -11,3 +11,6 @@ java-updates * The :module:`UseJava` module ``install_jar`` function learned new ``DESTINATION`` and ``COMPONENT`` options to specify the corresponding :command:`install` command options. + +* The :module:`UseJava` module gained a new ``create_javah`` + function to create C headers from Java classes. diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake index c61591d..dced6ec 100644 --- a/Modules/UseJava.cmake +++ b/Modules/UseJava.cmake @@ -309,6 +309,65 @@ # # # if you don't set the INSTALLPATH. +# +# :: +# +# create_javah(TARGET +# GENERATED_FILES +# CLASSES ... +# [CLASSPATH ...] +# [DEPENDS ...] +# [OUTPUT_NAME |OUTPUT_DIR ] +# ) +# +# Create C header files from java classes. These files provide the connective glue +# that allow your Java and C code to interact. +# +# There are two main signatures for create_javah. The first signature +# returns generated files throught variable specified by GENERATED_FILES option: +# +# :: +# +# Example: +# Create_javah(GENERATED_FILES files_headers +# CLASSES org.cmake.HelloWorld +# CLASSPATH hello.jar +# ) +# +# +# +# The second signature for create_javah creates a target which encapsulates +# header files generation. +# +# :: +# +# Example: +# Create_javah(TARGET target_headers +# CLASSES org.cmake.HelloWorld +# CLASSPATH hello.jar +# ) +# +# +# +# Both signatures share same options. +# +# ``CLASSES ...`` +# Specifies Java classes used to generate headers. +# +# ``CLASSPATH ...`` +# Specifies various paths to look up classes. Here .class files, jar files or targets +# created by command add_jar can be used. +# +# ``DEPENDS ...`` +# Targets on which the javah target depends +# +# ``OUTPUT_NAME `` +# Concatenates the resulting header files for all the classes listed by option CLASSES +# into . Same behavior as option '-o' of javah tool. +# +# ``OUTPUT_DIR `` +# Sets the directory where the header files will be generated. Same behavior as option +# '-d' of javah tool. If not specified, ${CMAKE_CURRENT_BINARY_DIR} is used as output directory. #============================================================================= # Copyright 2013 OpenGamma Ltd. @@ -1131,3 +1190,101 @@ function(create_javadoc _target) DESTINATION ${_javadoc_installpath} ) endfunction() + +function (create_javah) + cmake_parse_arguments(_create_javah + "" + "TARGET;GENERATED_FILES;OUTPUT_NAME;OUTPUT_DIR" + "CLASSES;CLASSPATH;DEPENDS" + ${ARGN}) + + # ckeck parameters + if (NOT _create_javah_TARGET AND NOT _create_javah_GENERATED_FILES) + message (FATAL_ERROR "create_javah: TARGET or GENERATED_FILES must be specified.") + endif() + if (_create_javah_OUTPUT_NAME AND _create_javah_OUTPUT_DIR) + message (FATAL_ERROR "create_javah: OUTPUT_NAME and OUTPUT_DIR are mutually exclusive.") + endif() + + if (NOT _create_javah_CLASSES) + message (FATAL_ERROR "create_javah: CLASSES is a required parameter.") + endif() + + set (_output_files) + if (WIN32 AND NOT CYGWIN AND CMAKE_HOST_SYSTEM_NAME MATCHES "Windows") + set(_classpath_sep ";") + else () + set(_classpath_sep ":") + endif() + + # handle javah options + set (_javah_options) + + if (_create_javah_CLASSPATH) + # CLASSPATH can specify directories, jar files or targets created with add_jar command + set (_classpath) + foreach (_path IN LISTS _create_javah_CLASSPATH) + if (TARGET ${_path}) + get_target_property (_jar_path ${_path} JAR_FILE) + if (_jar_path) + list (APPEND _classpath "${_jar_path}") + list (APPEND _create_javah_DEPENDS "${_path}") + else() + message(SEND_ERROR "create_javah: CLASSPATH target ${_path} is not a jar.") + endif() + elseif (EXISTS "${_path}") + list (APPEND _classpath "${_path}") + if (NOT IS_DIRECTORY "${_path}") + list (APPEND _create_javah_DEPENDS "${_path}") + endif() + else() + message(SEND_ERROR "create_javah: CLASSPATH entry ${_path} does not exist.") + endif() + endforeach() + string (REPLACE ";" "${_classpath_sep}" _classpath "${_classpath}") + list (APPEND _javah_options -classpath ${_classpath}) + endif() + + if (_create_javah_OUTPUT_DIR) + list (APPEND _javah_options -d "${_create_javah_OUTPUT_DIR}") + endif() + + if (_create_javah_OUTPUT_NAME) + list (APPEND _javah_options -o "${_create_javah_OUTPUT_NAME}") + set (_output_files "${_create_javah_OUTPUT_NAME}") + + get_filename_component (_create_javah_OUTPUT_DIR "${_create_javah_OUTPUT_NAME}" DIRECTORY) + get_filename_component (_create_javah_OUTPUT_DIR "${_create_javah_OUTPUT_DIR}" ABSOLUTE) + endif() + + if (NOT _create_javah_OUTPUT_DIR) + set (_create_javah_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}") + endif() + + if (NOT _create_javah_OUTPUT_NAME) + # compute output names + foreach (_class IN LISTS _create_javah_CLASSES) + string (REPLACE "." "_" _c_header "${_class}") + set (_c_header "${_create_javah_OUTPUT_DIR}/${_c_header}.h") + list (APPEND _output_files "${_c_header}") + endforeach() + endif() + + # finalize custom command arguments + if (_create_javah_DEPENDS) + list (INSERT _create_javah_DEPENDS 0 DEPENDS) + endif() + + add_custom_command (OUTPUT ${_output_files} + COMMAND "${Java_JAVAH_EXECUTABLE}" ${_javah_options} -jni ${_create_javah_CLASSES} + ${_create_javah_DEPENDS} + WORKING_DIRECTORY ${_create_javah_OUTPUT_DIR} + COMMENT "Building C header files from classes...") + + if (_create_javah_TARGET) + add_custom_target (${_create_javah_TARGET} ALL DEPENDS ${_output_files}) + endif() + if (_create_javah_GENERATED_FILES) + set (${_create_javah_GENERATED_FILES} ${_output_files} PARENT_SCOPE) + endif() +endfunction() diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 35b29bf..801d7e8 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -3036,6 +3036,31 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release --build-options ${build_options} --test-command ${JAVA_RUNTIME} -classpath hello2.jar HelloWorld) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJarSourceList") + + # For next test, java tool must have same architecture as toolchain + math(EXPR _object_mode "${CMAKE_SIZEOF_VOID_P} * 8") + execute_process( + COMMAND "${Java_JAVA_EXECUTABLE}" -d${_object_mode} -version + OUTPUT_QUIET ERROR_QUIET RESULT_VARIABLE _result + ) + if(_result EQUAL 0) + if(CMAKE_CONFIGURATION_TYPES) + set (JAVAH_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaJavah/$) + else() + set (JAVAH_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaJavah) + endif() + add_test(NAME Java.Javah COMMAND ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/JavaJavah" + "${CMake_BINARY_DIR}/Tests/JavaJavah" + ${build_generator_args} + --build-project helloJavah + --build-two-config + --build-run-dir "${CMake_BINARY_DIR}/Tests/JavaJavah/" + --build-options ${build_options} + --test-command ${JAVA_RUNTIME} -Djava.library.path=${JAVAH_LIBRARY_PATH} -classpath hello3.jar HelloWorld2) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJavah") + endif() endif() endif() endif() diff --git a/Tests/JavaJavah/B.cpp b/Tests/JavaJavah/B.cpp new file mode 100644 index 0000000..2666757 --- /dev/null +++ b/Tests/JavaJavah/B.cpp @@ -0,0 +1,10 @@ + +#include +#include + +#include "B.h" + +JNIEXPORT void JNICALL Java_B_printName(JNIEnv *, jobject) +{ + printf("B\n"); +} diff --git a/Tests/JavaJavah/B.java b/Tests/JavaJavah/B.java new file mode 100644 index 0000000..d731f39 --- /dev/null +++ b/Tests/JavaJavah/B.java @@ -0,0 +1,19 @@ +class B +{ + public B() + { + } + + public native void printName(); + + static { + try { + + System.loadLibrary("B"); + + } catch (UnsatisfiedLinkError e) { + System.err.println("Native code library failed to load.\n" + e); + System.exit(1); + } + } +} diff --git a/Tests/JavaJavah/CMakeLists.txt b/Tests/JavaJavah/CMakeLists.txt new file mode 100644 index 0000000..83b0ad0 --- /dev/null +++ b/Tests/JavaJavah/CMakeLists.txt @@ -0,0 +1,20 @@ +project(helloJavah Java CXX) + +cmake_minimum_required (VERSION 2.6) +set(CMAKE_VERBOSE_MAKEFILE 1) + +find_package(Java COMPONENTS Development) +include (UseJava) + +# JNI support +find_package(JNI) + +add_jar(hello3 B.java HelloWorld2.java) +create_javah(TARGET B_javah CLASSES B CLASSPATH hello3) + +add_library(B SHARED B.cpp) +add_dependencies(B B_javah) + +target_include_directories(B PRIVATE ${CMAKE_CURRENT_BINARY_DIR} + ${JAVA_INCLUDE_PATH} + ${JAVA_INCLUDE_PATH2}) diff --git a/Tests/JavaJavah/HelloWorld2.java b/Tests/JavaJavah/HelloWorld2.java new file mode 100644 index 0000000..faf7277 --- /dev/null +++ b/Tests/JavaJavah/HelloWorld2.java @@ -0,0 +1,10 @@ +class HelloWorld2 +{ + public static void main(String args[]) + { + B b; + b = new B(); + b.printName(); + System.out.println("Hello World!"); + } +} ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From brad.king at kitware.com Fri Aug 21 09:37:14 2015 From: brad.king at kitware.com (Brad King) Date: Fri, 21 Aug 2015 09:37:14 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2311-gdb93f63 Message-ID: <20150821133714.1C035B1A8F@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via db93f638b03edb5c72e62ec3155768d278840eca (commit) via 3bb707f0a1408dc0381ecbf4ec934e9f14d8927c (commit) from 824a39818d33bc5b25af7757f8deadc04d28db70 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=db93f638b03edb5c72e62ec3155768d278840eca commit db93f638b03edb5c72e62ec3155768d278840eca Merge: 824a398 3bb707f Author: Brad King AuthorDate: Fri Aug 21 09:37:11 2015 -0400 Commit: CMake Topic Stage CommitDate: Fri Aug 21 09:37:11 2015 -0400 Merge topic 'improve-variable-help-formatting' into next 3bb707f0 Help: Improve formatting of variable documentation http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3bb707f0a1408dc0381ecbf4ec934e9f14d8927c commit 3bb707f0a1408dc0381ecbf4ec934e9f14d8927c Author: James Johnston AuthorDate: Tue Aug 18 01:34:01 2015 -0400 Commit: Brad King CommitDate: Fri Aug 21 09:32:08 2015 -0400 Help: Improve formatting of variable documentation Improve formatting, primarily by: * Adding links to relevant commands, properties, generators, and so on. * Converting code, symbols, paths, and so on to fixed-width fonts. * Hard wrapping lines to 80 characters or less. diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst index 9ce4971..dac16bf 100644 --- a/Help/manual/cmake.1.rst +++ b/Help/manual/cmake.1.rst @@ -27,6 +27,8 @@ in each directory of a source tree with the name CMakeLists.txt. Users build a project by using CMake to generate a build system for a native tool on their platform. +.. _`CMake Options`: + Options ======= diff --git a/Help/variable/APPLE.rst b/Help/variable/APPLE.rst index 3afdee8..a8d2429 100644 --- a/Help/variable/APPLE.rst +++ b/Help/variable/APPLE.rst @@ -1,6 +1,6 @@ APPLE ----- -True if running on Mac OS X. +``True`` if running on Mac OS X. -Set to true on Mac OS X. +Set to ``true`` on Mac OS X. diff --git a/Help/variable/BORLAND.rst b/Help/variable/BORLAND.rst index 4af6085..badb733 100644 --- a/Help/variable/BORLAND.rst +++ b/Help/variable/BORLAND.rst @@ -1,6 +1,6 @@ BORLAND ------- -True if the Borland compiler is being used. +``True`` if the Borland compiler is being used. -This is set to true if the Borland compiler is being used. +This is set to ``true`` if the Borland compiler is being used. diff --git a/Help/variable/BUILD_SHARED_LIBS.rst b/Help/variable/BUILD_SHARED_LIBS.rst index 6f30efb..53087b2 100644 --- a/Help/variable/BUILD_SHARED_LIBS.rst +++ b/Help/variable/BUILD_SHARED_LIBS.rst @@ -1,10 +1,10 @@ BUILD_SHARED_LIBS ----------------- -Global flag to cause add_library to create shared libraries if on. +Global flag to cause :command:`add_library` to create shared libraries if on. If present and true, this will cause all libraries to be built shared unless the library was explicitly added as a static library. This -variable is often added to projects as an OPTION so that each user of -a project can decide if they want to build the project using shared or +variable is often added to projects as an :command:`option` so that each user +of a project can decide if they want to build the project using shared or static libraries. diff --git a/Help/variable/CMAKE_ABSOLUTE_DESTINATION_FILES.rst b/Help/variable/CMAKE_ABSOLUTE_DESTINATION_FILES.rst index 3691453..b6d0054 100644 --- a/Help/variable/CMAKE_ABSOLUTE_DESTINATION_FILES.rst +++ b/Help/variable/CMAKE_ABSOLUTE_DESTINATION_FILES.rst @@ -1,9 +1,9 @@ CMAKE_ABSOLUTE_DESTINATION_FILES -------------------------------- -List of files which have been installed using an ABSOLUTE DESTINATION path. +List of files which have been installed using an ``ABSOLUTE DESTINATION`` path. -This variable is defined by CMake-generated cmake_install.cmake +This variable is defined by CMake-generated ``cmake_install.cmake`` scripts. It can be used (read-only) by programs or scripts that source those install scripts. This is used by some CPack generators (e.g. RPM). diff --git a/Help/variable/CMAKE_ANDROID_NATIVE_LIB_DEPENDENCIES.rst b/Help/variable/CMAKE_ANDROID_NATIVE_LIB_DEPENDENCIES.rst index 52e60b1..4191907 100644 --- a/Help/variable/CMAKE_ANDROID_NATIVE_LIB_DEPENDENCIES.rst +++ b/Help/variable/CMAKE_ANDROID_NATIVE_LIB_DEPENDENCIES.rst @@ -1,5 +1,5 @@ CMAKE_ANDROID_NATIVE_LIB_DEPENDENCIES ------------------------------------- -Default value for the :prop_tgt:`ANDROID_NATIVE_LIB_DEPENDENCIES` target property. -See that target property for additional information. +Default value for the :prop_tgt:`ANDROID_NATIVE_LIB_DEPENDENCIES` target +property. See that target property for additional information. diff --git a/Help/variable/CMAKE_ANDROID_NATIVE_LIB_DIRECTORIES.rst b/Help/variable/CMAKE_ANDROID_NATIVE_LIB_DIRECTORIES.rst index 8480575..7cb9527 100644 --- a/Help/variable/CMAKE_ANDROID_NATIVE_LIB_DIRECTORIES.rst +++ b/Help/variable/CMAKE_ANDROID_NATIVE_LIB_DIRECTORIES.rst @@ -1,5 +1,5 @@ CMAKE_ANDROID_NATIVE_LIB_DIRECTORIES ------------------------------------ -Default value for the :prop_tgt:`ANDROID_NATIVE_LIB_DIRECTORIES` target property. -See that target property for additional information. +Default value for the :prop_tgt:`ANDROID_NATIVE_LIB_DIRECTORIES` target +property. See that target property for additional information. diff --git a/Help/variable/CMAKE_ARGC.rst b/Help/variable/CMAKE_ARGC.rst index be120b8..aec9711 100644 --- a/Help/variable/CMAKE_ARGC.rst +++ b/Help/variable/CMAKE_ARGC.rst @@ -3,5 +3,6 @@ CMAKE_ARGC Number of command line arguments passed to CMake in script mode. -When run in -P script mode, CMake sets this variable to the number of -command line arguments. See also CMAKE_ARGV0, 1, 2 ... +When run in :ref:`-P ` script mode, CMake sets this variable to +the number of command line arguments. See also :variable:`CMAKE_ARGV0`, +``1``, ``2`` ... diff --git a/Help/variable/CMAKE_ARGV0.rst b/Help/variable/CMAKE_ARGV0.rst index e5ed419..8b1ecb7 100644 --- a/Help/variable/CMAKE_ARGV0.rst +++ b/Help/variable/CMAKE_ARGV0.rst @@ -3,7 +3,7 @@ CMAKE_ARGV0 Command line argument passed to CMake in script mode. -When run in -P script mode, CMake sets this variable to the first -command line argument. It then also sets CMAKE_ARGV1, CMAKE_ARGV2, -... and so on, up to the number of command line arguments given. See -also CMAKE_ARGC. +When run in :ref:`-P ` script mode, CMake sets this variable to +the first command line argument. It then also sets ``CMAKE_ARGV1``, +``CMAKE_ARGV2``, ... and so on, up to the number of command line arguments +given. See also :variable:`CMAKE_ARGC`. diff --git a/Help/variable/CMAKE_AUTOMOC_RELAXED_MODE.rst b/Help/variable/CMAKE_AUTOMOC_RELAXED_MODE.rst index a814d40..addc62d 100644 --- a/Help/variable/CMAKE_AUTOMOC_RELAXED_MODE.rst +++ b/Help/variable/CMAKE_AUTOMOC_RELAXED_MODE.rst @@ -3,11 +3,11 @@ CMAKE_AUTOMOC_RELAXED_MODE Switch between strict and relaxed automoc mode. -By default, :prop_tgt:`AUTOMOC` behaves exactly as described in the documentation -of the :prop_tgt:`AUTOMOC` target property. When set to ``TRUE``, it accepts more -input and tries to find the correct input file for ``moc`` even if it -differs from the documented behaviour. In this mode it e.g. also -checks whether a header file is intended to be processed by moc when a -``"foo.moc"`` file has been included. +By default, :prop_tgt:`AUTOMOC` behaves exactly as described in the +documentation of the :prop_tgt:`AUTOMOC` target property. When set to +``TRUE``, it accepts more input and tries to find the correct input file for +``moc`` even if it differs from the documented behaviour. In this mode it +e.g. also checks whether a header file is intended to be processed by moc +when a ``"foo.moc"`` file has been included. Relaxed mode has to be enabled for KDE4 compatibility. diff --git a/Help/variable/CMAKE_AUTORCC.rst b/Help/variable/CMAKE_AUTORCC.rst index 067f766..7426105 100644 --- a/Help/variable/CMAKE_AUTORCC.rst +++ b/Help/variable/CMAKE_AUTORCC.rst @@ -3,5 +3,5 @@ CMAKE_AUTORCC Whether to handle ``rcc`` automatically for Qt targets. -This variable is used to initialize the :prop_tgt:`AUTORCC` property on all the targets. -See that target property for additional information. +This variable is used to initialize the :prop_tgt:`AUTORCC` property on all +the targets. See that target property for additional information. diff --git a/Help/variable/CMAKE_AUTOUIC.rst b/Help/variable/CMAKE_AUTOUIC.rst index 0beb555..5abefaa 100644 --- a/Help/variable/CMAKE_AUTOUIC.rst +++ b/Help/variable/CMAKE_AUTOUIC.rst @@ -3,5 +3,5 @@ CMAKE_AUTOUIC Whether to handle ``uic`` automatically for Qt targets. -This variable is used to initialize the :prop_tgt:`AUTOUIC` property on all the targets. -See that target property for additional information. +This variable is used to initialize the :prop_tgt:`AUTOUIC` property on all +the targets. See that target property for additional information. diff --git a/Help/variable/CMAKE_BINARY_DIR.rst b/Help/variable/CMAKE_BINARY_DIR.rst index 703bb58..f8dd8ab 100644 --- a/Help/variable/CMAKE_BINARY_DIR.rst +++ b/Help/variable/CMAKE_BINARY_DIR.rst @@ -5,4 +5,4 @@ The path to the top level of the build tree. This is the full path to the top level of the current CMake build tree. For an in-source build, this would be the same as -CMAKE_SOURCE_DIR. +:variable:`CMAKE_SOURCE_DIR`. diff --git a/Help/variable/CMAKE_BUILD_TYPE.rst b/Help/variable/CMAKE_BUILD_TYPE.rst index 68f08ba..2d54d60 100644 --- a/Help/variable/CMAKE_BUILD_TYPE.rst +++ b/Help/variable/CMAKE_BUILD_TYPE.rst @@ -4,16 +4,17 @@ CMAKE_BUILD_TYPE Specifies the build type on single-configuration generators. This statically specifies what build type (configuration) will be -built in this build tree. Possible values are empty, Debug, Release, -RelWithDebInfo and MinSizeRel. This variable is only meaningful to -single-configuration generators (such as make and Ninja) i.e. those -which choose a single configuration when CMake runs to generate a -build tree as opposed to multi-configuration generators which offer -selection of the build configuration within the generated build +built in this build tree. Possible values are empty, ``Debug``, ``Release``, +``RelWithDebInfo`` and ``MinSizeRel``. This variable is only meaningful to +single-configuration generators (such as :ref:`Makefile Generators` and +:generator:`Ninja`) i.e. those which choose a single configuration when CMake +runs to generate a build tree as opposed to multi-configuration generators +which offer selection of the build configuration within the generated build environment. There are many per-config properties and variables -(usually following clean SOME_VAR_ order conventions), such as -CMAKE_C_FLAGS_, specified as uppercase: -CMAKE_C_FLAGS_[DEBUG|RELEASE|RELWITHDEBINFO|MINSIZEREL]. For example, -in a build tree configured to build type Debug, CMake will see to -having CMAKE_C_FLAGS_DEBUG settings get added to the CMAKE_C_FLAGS -settings. See also CMAKE_CONFIGURATION_TYPES. +(usually following clean ``SOME_VAR_`` order conventions), such as +``CMAKE_C_FLAGS_``, specified as uppercase: +``CMAKE_C_FLAGS_[DEBUG|RELEASE|RELWITHDEBINFO|MINSIZEREL]``. For example, +in a build tree configured to build type ``Debug``, CMake will see to +having :variable:`CMAKE_C_FLAGS_DEBUG _FLAGS_DEBUG>` settings get +added to the :variable:`CMAKE_C_FLAGS _FLAGS>` settings. See +also :variable:`CMAKE_CONFIGURATION_TYPES`. diff --git a/Help/variable/CMAKE_BUILD_WITH_INSTALL_RPATH.rst b/Help/variable/CMAKE_BUILD_WITH_INSTALL_RPATH.rst index 6875da6..5b59a6e 100644 --- a/Help/variable/CMAKE_BUILD_WITH_INSTALL_RPATH.rst +++ b/Help/variable/CMAKE_BUILD_WITH_INSTALL_RPATH.rst @@ -1,11 +1,11 @@ CMAKE_BUILD_WITH_INSTALL_RPATH ------------------------------ -Use the install path for the RPATH +Use the install path for the ``RPATH``. -Normally CMake uses the build tree for the RPATH when building -executables etc on systems that use RPATH. When the software is +Normally CMake uses the build tree for the ``RPATH`` when building +executables etc on systems that use ``RPATH``. When the software is installed the executables etc are relinked by CMake to have the -install RPATH. If this variable is set to true then the software is -always built with the install path for the RPATH and does not need to +install ``RPATH``. If this variable is set to true then the software is +always built with the install path for the ``RPATH`` and does not need to be relinked when installed. diff --git a/Help/variable/CMAKE_CACHEFILE_DIR.rst b/Help/variable/CMAKE_CACHEFILE_DIR.rst index 78c7d93..8604d0e 100644 --- a/Help/variable/CMAKE_CACHEFILE_DIR.rst +++ b/Help/variable/CMAKE_CACHEFILE_DIR.rst @@ -1,7 +1,7 @@ CMAKE_CACHEFILE_DIR ------------------- -The directory with the CMakeCache.txt file. +The directory with the ``CMakeCache.txt`` file. -This is the full path to the directory that has the CMakeCache.txt -file in it. This is the same as CMAKE_BINARY_DIR. +This is the full path to the directory that has the ``CMakeCache.txt`` +file in it. This is the same as :variable:`CMAKE_BINARY_DIR`. diff --git a/Help/variable/CMAKE_CACHE_MAJOR_VERSION.rst b/Help/variable/CMAKE_CACHE_MAJOR_VERSION.rst index e6887d9..1e53ed6 100644 --- a/Help/variable/CMAKE_CACHE_MAJOR_VERSION.rst +++ b/Help/variable/CMAKE_CACHE_MAJOR_VERSION.rst @@ -1,7 +1,7 @@ CMAKE_CACHE_MAJOR_VERSION ------------------------- -Major version of CMake used to create the CMakeCache.txt file +Major version of CMake used to create the ``CMakeCache.txt`` file This stores the major version of CMake used to write a CMake cache file. It is only different when a different version of CMake is run diff --git a/Help/variable/CMAKE_CACHE_MINOR_VERSION.rst b/Help/variable/CMAKE_CACHE_MINOR_VERSION.rst index 799f0a9..5d174a3 100644 --- a/Help/variable/CMAKE_CACHE_MINOR_VERSION.rst +++ b/Help/variable/CMAKE_CACHE_MINOR_VERSION.rst @@ -1,7 +1,7 @@ CMAKE_CACHE_MINOR_VERSION ------------------------- -Minor version of CMake used to create the CMakeCache.txt file +Minor version of CMake used to create the ``CMakeCache.txt`` file This stores the minor version of CMake used to write a CMake cache file. It is only different when a different version of CMake is run diff --git a/Help/variable/CMAKE_CACHE_PATCH_VERSION.rst b/Help/variable/CMAKE_CACHE_PATCH_VERSION.rst index e67d544..22d267c 100644 --- a/Help/variable/CMAKE_CACHE_PATCH_VERSION.rst +++ b/Help/variable/CMAKE_CACHE_PATCH_VERSION.rst @@ -1,7 +1,7 @@ CMAKE_CACHE_PATCH_VERSION ------------------------- -Patch version of CMake used to create the CMakeCache.txt file +Patch version of CMake used to create the ``CMakeCache.txt`` file This stores the patch version of CMake used to write a CMake cache file. It is only different when a different version of CMake is run diff --git a/Help/variable/CMAKE_CFG_INTDIR.rst b/Help/variable/CMAKE_CFG_INTDIR.rst index 55f7b01..dcc1aed 100644 --- a/Help/variable/CMAKE_CFG_INTDIR.rst +++ b/Help/variable/CMAKE_CFG_INTDIR.rst @@ -4,11 +4,11 @@ CMAKE_CFG_INTDIR Build-time reference to per-configuration output subdirectory. For native build systems supporting multiple configurations in the -build tree (such as Visual Studio and Xcode), the value is a reference -to a build-time variable specifying the name of the per-configuration -output subdirectory. On Makefile generators this evaluates to "." -because there is only one configuration in a build tree. Example -values: +build tree (such as :ref:`Visual Studio Generators` and :generator:`Xcode`), +the value is a reference to a build-time variable specifying the name +of the per-configuration output subdirectory. On :ref:`Makefile Generators` +this evaluates to `.` because there is only one configuration in a build tree. +Example values: :: @@ -33,13 +33,14 @@ evaluated at build time. Example of intended usage: ) add_custom_target(drive ALL DEPENDS out.txt) -Note that CMAKE_CFG_INTDIR is no longer necessary for this purpose but +Note that ``CMAKE_CFG_INTDIR`` is no longer necessary for this purpose but has been left for compatibility with existing projects. Instead -add_custom_command() recognizes executable target names in its COMMAND -option, so "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/mytool" -can be replaced by just "mytool". +:command:`add_custom_command` recognizes executable target names in its +``COMMAND`` option, so +``${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/mytool`` can be replaced +by just ``mytool``. This variable is read-only. Setting it is undefined behavior. In multi-configuration build systems the value of this variable is passed -as the value of preprocessor symbol "CMAKE_INTDIR" to the compilation +as the value of preprocessor symbol ``CMAKE_INTDIR`` to the compilation of all source files. diff --git a/Help/variable/CMAKE_CL_64.rst b/Help/variable/CMAKE_CL_64.rst index 5096829..a1e86a5 100644 --- a/Help/variable/CMAKE_CL_64.rst +++ b/Help/variable/CMAKE_CL_64.rst @@ -1,6 +1,6 @@ CMAKE_CL_64 ----------- -Using the 64 bit compiler from Microsoft +Using the 64-bit compiler from Microsoft -Set to true when using the 64 bit cl compiler from Microsoft. +Set to ``true`` when using the 64-bit ``cl`` compiler from Microsoft. diff --git a/Help/variable/CMAKE_COLOR_MAKEFILE.rst b/Help/variable/CMAKE_COLOR_MAKEFILE.rst index 170baf3..bb86ecc 100644 --- a/Help/variable/CMAKE_COLOR_MAKEFILE.rst +++ b/Help/variable/CMAKE_COLOR_MAKEFILE.rst @@ -1,7 +1,7 @@ CMAKE_COLOR_MAKEFILE -------------------- -Enables color output when using the Makefile generator. +Enables color output when using the :ref:`Makefile Generators`. When enabled, the generated Makefiles will produce colored output. -Default is ON. +Default is ``ON``. diff --git a/Help/variable/CMAKE_COMMAND.rst b/Help/variable/CMAKE_COMMAND.rst index f4e5f1e..f80b46c 100644 --- a/Help/variable/CMAKE_COMMAND.rst +++ b/Help/variable/CMAKE_COMMAND.rst @@ -1,8 +1,8 @@ CMAKE_COMMAND ------------- -The full path to the cmake executable. +The full path to the :manual:`cmake(1)` executable. -This is the full path to the CMake executable cmake which is useful -from custom commands that want to use the cmake -E option for portable -system commands. (e.g. /usr/local/bin/cmake +This is the full path to the CMake executable :manual:`cmake(1)` which is +useful from custom commands that want to use the ``cmake -E`` option for +portable system commands. (e.g. ``/usr/local/bin/cmake``) diff --git a/Help/variable/CMAKE_COMPILER_IS_GNULANG.rst b/Help/variable/CMAKE_COMPILER_IS_GNULANG.rst index bc5652f..4b652c0 100644 --- a/Help/variable/CMAKE_COMPILER_IS_GNULANG.rst +++ b/Help/variable/CMAKE_COMPILER_IS_GNULANG.rst @@ -3,10 +3,10 @@ CMAKE_COMPILER_IS_GNU True if the compiler is GNU. -If the selected compiler is the GNU compiler then this is TRUE, -if not it is FALSE. Unlike the other per-language variables, this +If the selected ```` compiler is the GNU compiler then this is ``TRUE``, +if not it is ``FALSE``. Unlike the other per-language variables, this uses the GNU syntax for identifying languages instead of the CMake -syntax. Recognized values of the suffix are: +syntax. Recognized values of the ```` suffix are: :: diff --git a/Help/variable/CMAKE_CONFIGURATION_TYPES.rst b/Help/variable/CMAKE_CONFIGURATION_TYPES.rst index 986b969..34e99eb 100644 --- a/Help/variable/CMAKE_CONFIGURATION_TYPES.rst +++ b/Help/variable/CMAKE_CONFIGURATION_TYPES.rst @@ -4,7 +4,7 @@ CMAKE_CONFIGURATION_TYPES Specifies the available build types on multi-config generators. This specifies what build types (configurations) will be available -such as Debug, Release, RelWithDebInfo etc. This has reasonable +such as ``Debug``, ``Release``, ``RelWithDebInfo`` etc. This has reasonable defaults on most platforms, but can be extended to provide other build -types. See also CMAKE_BUILD_TYPE for details of managing -configuration data, and CMAKE_CFG_INTDIR. +types. See also :variable:`CMAKE_BUILD_TYPE` for details of managing +configuration data, and :variable:`CMAKE_CFG_INTDIR`. diff --git a/Help/variable/CMAKE_CONFIG_POSTFIX.rst b/Help/variable/CMAKE_CONFIG_POSTFIX.rst index af38bed..e686a43 100644 --- a/Help/variable/CMAKE_CONFIG_POSTFIX.rst +++ b/Help/variable/CMAKE_CONFIG_POSTFIX.rst @@ -1,7 +1,7 @@ CMAKE__POSTFIX ---------------------- -Default filename postfix for libraries under configuration . +Default filename postfix for libraries under configuration ````. -When a non-executable target is created its _POSTFIX target -property is initialized with the value of this variable if it is set. +When a non-executable target is created its :prop_tgt:`_POSTFIX` +target property is initialized with the value of this variable if it is set. diff --git a/Help/variable/CMAKE_CTEST_COMMAND.rst b/Help/variable/CMAKE_CTEST_COMMAND.rst index d5dd2c3..b2942e2 100644 --- a/Help/variable/CMAKE_CTEST_COMMAND.rst +++ b/Help/variable/CMAKE_CTEST_COMMAND.rst @@ -1,8 +1,8 @@ CMAKE_CTEST_COMMAND ------------------- -Full path to ctest command installed with cmake. +Full path to :manual:`ctest(1)` command installed with CMake. -This is the full path to the CTest executable ctest which is useful -from custom commands that want to use the cmake -E option for portable -system commands. +This is the full path to the CTest executable :manual:`ctest(1)` which is +useful from custom commands that want to use the :manual:`cmake(1)` ``-E`` +option for portable system commands. diff --git a/Help/variable/CMAKE_CURRENT_BINARY_DIR.rst b/Help/variable/CMAKE_CURRENT_BINARY_DIR.rst index fb55a11..cc3b639 100644 --- a/Help/variable/CMAKE_CURRENT_BINARY_DIR.rst +++ b/Help/variable/CMAKE_CURRENT_BINARY_DIR.rst @@ -4,7 +4,7 @@ CMAKE_CURRENT_BINARY_DIR The path to the binary directory currently being processed. This the full path to the build directory that is currently being -processed by cmake. Each directory added by add_subdirectory will +processed by cmake. Each directory added by :command:`add_subdirectory` will create a binary directory in the build tree, and as it is being processed this variable will be set. For in-source builds this is the current source directory being processed. diff --git a/Help/variable/CMAKE_CURRENT_LIST_DIR.rst b/Help/variable/CMAKE_CURRENT_LIST_DIR.rst index b816821..ebc3ab9 100644 --- a/Help/variable/CMAKE_CURRENT_LIST_DIR.rst +++ b/Help/variable/CMAKE_CURRENT_LIST_DIR.rst @@ -5,8 +5,8 @@ Full directory of the listfile currently being processed. As CMake processes the listfiles in your project this variable will always be set to the directory where the listfile which is currently -being processed (CMAKE_CURRENT_LIST_FILE) is located. The value has -dynamic scope. When CMake starts processing commands in a source file +being processed (:variable:`CMAKE_CURRENT_LIST_FILE`) is located. The value +has dynamic scope. When CMake starts processing commands in a source file it sets this variable to the directory where this file is located. When CMake finishes processing commands from the file it restores the previous value. Therefore the value of the variable inside a macro or @@ -14,4 +14,4 @@ function is the directory of the file invoking the bottom-most entry on the call stack, not the directory of the file containing the macro or function definition. -See also CMAKE_CURRENT_LIST_FILE. +See also :variable:`CMAKE_CURRENT_LIST_FILE`. diff --git a/Help/variable/CMAKE_CURRENT_LIST_FILE.rst b/Help/variable/CMAKE_CURRENT_LIST_FILE.rst index 910d7b4..84b0eee 100644 --- a/Help/variable/CMAKE_CURRENT_LIST_FILE.rst +++ b/Help/variable/CMAKE_CURRENT_LIST_FILE.rst @@ -12,4 +12,4 @@ value. Therefore the value of the variable inside a macro or function is the file invoking the bottom-most entry on the call stack, not the file containing the macro or function definition. -See also CMAKE_PARENT_LIST_FILE. +See also :variable:`CMAKE_PARENT_LIST_FILE`. diff --git a/Help/variable/CMAKE_CXX_COMPILE_FEATURES.rst b/Help/variable/CMAKE_CXX_COMPILE_FEATURES.rst index f003227..5c59f95 100644 --- a/Help/variable/CMAKE_CXX_COMPILE_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_COMPILE_FEATURES.rst @@ -4,8 +4,8 @@ CMAKE_CXX_COMPILE_FEATURES List of features known to the C++ compiler These features are known to be available for use with the C++ compiler. This -list is a subset of the features listed in the :prop_gbl:`CMAKE_CXX_KNOWN_FEATURES` -global property. +list is a subset of the features listed in the +:prop_gbl:`CMAKE_CXX_KNOWN_FEATURES` global property. See the :manual:`cmake-compile-features(7)` manual for information on compile features and a list of supported compilers. diff --git a/Help/variable/CMAKE_CXX_EXTENSIONS.rst b/Help/variable/CMAKE_CXX_EXTENSIONS.rst index b14d753..4a92425 100644 --- a/Help/variable/CMAKE_CXX_EXTENSIONS.rst +++ b/Help/variable/CMAKE_CXX_EXTENSIONS.rst @@ -1,7 +1,7 @@ CMAKE_CXX_EXTENSIONS -------------------- -Default value for ``CXX_EXTENSIONS`` property of targets. +Default value for :prop_tgt:`CXX_EXTENSIONS` property of targets. This variable is used to initialize the :prop_tgt:`CXX_EXTENSIONS` property on all targets. See that target property for additional diff --git a/Help/variable/CMAKE_CXX_STANDARD.rst b/Help/variable/CMAKE_CXX_STANDARD.rst index 2bc4525..8a8bdff 100644 --- a/Help/variable/CMAKE_CXX_STANDARD.rst +++ b/Help/variable/CMAKE_CXX_STANDARD.rst @@ -1,7 +1,7 @@ CMAKE_CXX_STANDARD ------------------ -Default value for ``CXX_STANDARD`` property of targets. +Default value for :prop_tgt:`CXX_STANDARD` property of targets. This variable is used to initialize the :prop_tgt:`CXX_STANDARD` property on all targets. See that target property for additional diff --git a/Help/variable/CMAKE_CXX_STANDARD_REQUIRED.rst b/Help/variable/CMAKE_CXX_STANDARD_REQUIRED.rst index 14ffcd1..4c71058 100644 --- a/Help/variable/CMAKE_CXX_STANDARD_REQUIRED.rst +++ b/Help/variable/CMAKE_CXX_STANDARD_REQUIRED.rst @@ -1,7 +1,7 @@ CMAKE_CXX_STANDARD_REQUIRED --------------------------- -Default value for ``CXX_STANDARD_REQUIRED`` property of targets. +Default value for :prop_tgt:`CXX_STANDARD_REQUIRED` property of targets. This variable is used to initialize the :prop_tgt:`CXX_STANDARD_REQUIRED` property on all targets. See that target property for additional diff --git a/Help/variable/CMAKE_C_COMPILE_FEATURES.rst b/Help/variable/CMAKE_C_COMPILE_FEATURES.rst index df66eae..8d1eca0 100644 --- a/Help/variable/CMAKE_C_COMPILE_FEATURES.rst +++ b/Help/variable/CMAKE_C_COMPILE_FEATURES.rst @@ -4,8 +4,8 @@ CMAKE_C_COMPILE_FEATURES List of features known to the C compiler These features are known to be available for use with the C compiler. This -list is a subset of the features listed in the :prop_gbl:`CMAKE_C_KNOWN_FEATURES` -global property. +list is a subset of the features listed in the +:prop_gbl:`CMAKE_C_KNOWN_FEATURES` global property. See the :manual:`cmake-compile-features(7)` manual for information on compile features and a list of supported compilers. diff --git a/Help/variable/CMAKE_C_EXTENSIONS.rst b/Help/variable/CMAKE_C_EXTENSIONS.rst index 25bec12..fa510d4 100644 --- a/Help/variable/CMAKE_C_EXTENSIONS.rst +++ b/Help/variable/CMAKE_C_EXTENSIONS.rst @@ -1,7 +1,7 @@ CMAKE_C_EXTENSIONS ------------------ -Default value for ``C_EXTENSIONS`` property of targets. +Default value for :prop_tgt:`C_EXTENSIONS` property of targets. This variable is used to initialize the :prop_tgt:`C_EXTENSIONS` property on all targets. See that target property for additional diff --git a/Help/variable/CMAKE_C_STANDARD.rst b/Help/variable/CMAKE_C_STANDARD.rst index 2eb4e43..b55e00c 100644 --- a/Help/variable/CMAKE_C_STANDARD.rst +++ b/Help/variable/CMAKE_C_STANDARD.rst @@ -1,7 +1,7 @@ CMAKE_C_STANDARD ---------------- -Default value for ``C_STANDARD`` property of targets. +Default value for :prop_tgt:`C_STANDARD` property of targets. This variable is used to initialize the :prop_tgt:`C_STANDARD` property on all targets. See that target property for additional diff --git a/Help/variable/CMAKE_C_STANDARD_REQUIRED.rst b/Help/variable/CMAKE_C_STANDARD_REQUIRED.rst index 5e415da..7f70f6e 100644 --- a/Help/variable/CMAKE_C_STANDARD_REQUIRED.rst +++ b/Help/variable/CMAKE_C_STANDARD_REQUIRED.rst @@ -1,7 +1,7 @@ CMAKE_C_STANDARD_REQUIRED ------------------------- -Default value for ``C_STANDARD_REQUIRED`` property of targets. +Default value for :prop_tgt:`C_STANDARD_REQUIRED` property of targets. This variable is used to initialize the :prop_tgt:`C_STANDARD_REQUIRED` property on all targets. See that target property for additional diff --git a/Help/variable/CMAKE_DEBUG_POSTFIX.rst b/Help/variable/CMAKE_DEBUG_POSTFIX.rst index fde24b2..08577a5 100644 --- a/Help/variable/CMAKE_DEBUG_POSTFIX.rst +++ b/Help/variable/CMAKE_DEBUG_POSTFIX.rst @@ -1,7 +1,7 @@ CMAKE_DEBUG_POSTFIX ------------------- -See variable CMAKE__POSTFIX. +See variable :variable:`CMAKE__POSTFIX`. This variable is a special case of the more-general -CMAKE__POSTFIX variable for the DEBUG configuration. +:variable:`CMAKE__POSTFIX` variable for the `DEBUG` configuration. diff --git a/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst b/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst index e200b86..513276e 100644 --- a/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst +++ b/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst @@ -9,6 +9,6 @@ only be used when evaluating the :prop_tgt:`INCLUDE_DIRECTORIES`, :prop_tgt:`COMPILE_DEFINITIONS`, :prop_tgt:`COMPILE_OPTIONS`, :prop_tgt:`AUTOUIC_OPTIONS`, :prop_tgt:`SOURCES`, :prop_tgt:`COMPILE_FEATURES`, :prop_tgt:`POSITION_INDEPENDENT_CODE` target properties and any other property -listed in :prop_tgt:`COMPATIBLE_INTERFACE_STRING` and other ``COMPATIBLE_INTERFACE_`` -properties. It outputs an origin for each entry in the target property. -Default is unset. +listed in :prop_tgt:`COMPATIBLE_INTERFACE_STRING` and other +``COMPATIBLE_INTERFACE_`` properties. It outputs an origin for each entry in +the target property. Default is unset. diff --git a/Help/variable/CMAKE_DISABLE_FIND_PACKAGE_PackageName.rst b/Help/variable/CMAKE_DISABLE_FIND_PACKAGE_PackageName.rst index bcb277c..ed60020 100644 --- a/Help/variable/CMAKE_DISABLE_FIND_PACKAGE_PackageName.rst +++ b/Help/variable/CMAKE_DISABLE_FIND_PACKAGE_PackageName.rst @@ -1,10 +1,11 @@ CMAKE_DISABLE_FIND_PACKAGE_ ---------------------------------------- -Variable for disabling find_package() calls. +Variable for disabling :command:`find_package` calls. -Every non-REQUIRED find_package() call in a project can be disabled by -setting the variable CMAKE_DISABLE_FIND_PACKAGE_ to TRUE. +Every non-``REQUIRED`` :command:`find_package` call in a project can be +disabled by setting the variable +``CMAKE_DISABLE_FIND_PACKAGE_`` to ``TRUE``. This can be used to build a project without an optional package, although that package is installed. @@ -12,4 +13,4 @@ This switch should be used during the initial CMake run. Otherwise if the package has already been found in a previous CMake run, the variables which have been stored in the cache will still be there. In that case it is recommended to remove the cache variables for this -package from the cache using the cache editor or cmake -U +package from the cache using the cache editor or :manual:`cmake(1)` ``-U`` diff --git a/Help/variable/CMAKE_DL_LIBS.rst b/Help/variable/CMAKE_DL_LIBS.rst index cae4565..1fe7641 100644 --- a/Help/variable/CMAKE_DL_LIBS.rst +++ b/Help/variable/CMAKE_DL_LIBS.rst @@ -1,7 +1,7 @@ CMAKE_DL_LIBS ------------- -Name of library containing dlopen and dlcose. +Name of library containing ``dlopen`` and ``dlcose``. -The name of the library that has dlopen and dlclose in it, usually --ldl on most UNIX machines. +The name of the library that has ``dlopen`` and ``dlclose`` in it, usually +``-ldl`` on most UNIX machines. diff --git a/Help/variable/CMAKE_EDIT_COMMAND.rst b/Help/variable/CMAKE_EDIT_COMMAND.rst index 562aa0b..2f4ab1f 100644 --- a/Help/variable/CMAKE_EDIT_COMMAND.rst +++ b/Help/variable/CMAKE_EDIT_COMMAND.rst @@ -1,8 +1,8 @@ CMAKE_EDIT_COMMAND ------------------ -Full path to cmake-gui or ccmake. Defined only for Makefile generators -when not using an "extra" generator for an IDE. +Full path to :manual:`cmake-gui(1)` or :manual:`ccmake(1)`. Defined only for +:ref:`Makefile Generators` when not using an "extra" generator for an IDE. This is the full path to the CMake executable that can graphically -edit the cache. For example, cmake-gui or ccmake. +edit the cache. For example, :manual:`cmake-gui(1)` or :manual:`ccmake(1)`. diff --git a/Help/variable/CMAKE_ERROR_DEPRECATED.rst b/Help/variable/CMAKE_ERROR_DEPRECATED.rst index 68befc2..39dc4a8 100644 --- a/Help/variable/CMAKE_ERROR_DEPRECATED.rst +++ b/Help/variable/CMAKE_ERROR_DEPRECATED.rst @@ -3,9 +3,9 @@ CMAKE_ERROR_DEPRECATED Whether to issue deprecation errors for macros and functions. -If TRUE, this can be used by macros and functions to issue fatal +If ``TRUE``, this can be used by macros and functions to issue fatal errors when deprecated macros or functions are used. This variable is -FALSE by default. +``FALSE`` by default. These errors can be enabled with the ``-Werror=deprecated`` option, or disabled with the ``-Wno-error=deprecated`` option, when running diff --git a/Help/variable/CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION.rst b/Help/variable/CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION.rst index 651d68d..38e9b7b 100644 --- a/Help/variable/CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION.rst +++ b/Help/variable/CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION.rst @@ -1,9 +1,10 @@ CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION ------------------------------------------- -Ask cmake_install.cmake script to error out as soon as a file with absolute INSTALL DESTINATION is encountered. +Ask ``cmake_install.cmake`` script to error out as soon as a file with +absolute ``INSTALL DESTINATION`` is encountered. The fatal error is emitted before the installation of the offending file takes place. This variable is used by CMake-generated -cmake_install.cmake scripts. If one sets this variable to ON while +``cmake_install.cmake`` scripts. If one sets this variable to ``ON`` while running the script, it may get fatal error messages from the script. diff --git a/Help/variable/CMAKE_EXECUTABLE_SUFFIX.rst b/Help/variable/CMAKE_EXECUTABLE_SUFFIX.rst index 45c313c..356590f 100644 --- a/Help/variable/CMAKE_EXECUTABLE_SUFFIX.rst +++ b/Help/variable/CMAKE_EXECUTABLE_SUFFIX.rst @@ -3,7 +3,7 @@ CMAKE_EXECUTABLE_SUFFIX The suffix for executables on this platform. -The suffix to use for the end of an executable filename if any, .exe +The suffix to use for the end of an executable filename if any, ``.exe`` on Windows. -CMAKE_EXECUTABLE_SUFFIX_ overrides this for language . +``CMAKE_EXECUTABLE_SUFFIX_`` overrides this for language ````. diff --git a/Help/variable/CMAKE_EXE_LINKER_FLAGS_CONFIG.rst b/Help/variable/CMAKE_EXE_LINKER_FLAGS_CONFIG.rst index dcaf300..0cd8113 100644 --- a/Help/variable/CMAKE_EXE_LINKER_FLAGS_CONFIG.rst +++ b/Help/variable/CMAKE_EXE_LINKER_FLAGS_CONFIG.rst @@ -3,5 +3,5 @@ CMAKE_EXE_LINKER_FLAGS_ Flags to be used when linking an executable. -Same as CMAKE_C_FLAGS_* but used by the linker when creating +Same as ``CMAKE_C_FLAGS_*`` but used by the linker when creating executables. diff --git a/Help/variable/CMAKE_EXTRA_GENERATOR.rst b/Help/variable/CMAKE_EXTRA_GENERATOR.rst index 71aec92..4d513e4 100644 --- a/Help/variable/CMAKE_EXTRA_GENERATOR.rst +++ b/Help/variable/CMAKE_EXTRA_GENERATOR.rst @@ -1,9 +1,10 @@ CMAKE_EXTRA_GENERATOR --------------------- -The extra generator used to build the project. +The extra generator used to build the project. See +:manual:`cmake-generators(7)`. When using the Eclipse, CodeBlocks or KDevelop generators, CMake -generates Makefiles (CMAKE_GENERATOR) and additionally project files -for the respective IDE. This IDE project file generator is stored in -CMAKE_EXTRA_GENERATOR (e.g. "Eclipse CDT4"). +generates Makefiles (:variable:`CMAKE_GENERATOR`) and additionally project +files for the respective IDE. This IDE project file generator is stored in +``CMAKE_EXTRA_GENERATOR`` (e.g. ``Eclipse CDT4``). diff --git a/Help/variable/CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES.rst b/Help/variable/CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES.rst index 6187a7a..a130adb 100644 --- a/Help/variable/CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES.rst +++ b/Help/variable/CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES.rst @@ -4,6 +4,6 @@ CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES Additional suffixes for shared libraries. Extensions for shared libraries other than that specified by -CMAKE_SHARED_LIBRARY_SUFFIX, if any. CMake uses this to recognize +:variable:`CMAKE_SHARED_LIBRARY_SUFFIX`, if any. CMake uses this to recognize external shared library files during analysis of libraries linked by a target. diff --git a/Help/variable/CMAKE_FIND_LIBRARY_PREFIXES.rst b/Help/variable/CMAKE_FIND_LIBRARY_PREFIXES.rst index 1a9e7ce..58354b2 100644 --- a/Help/variable/CMAKE_FIND_LIBRARY_PREFIXES.rst +++ b/Help/variable/CMAKE_FIND_LIBRARY_PREFIXES.rst @@ -4,6 +4,6 @@ CMAKE_FIND_LIBRARY_PREFIXES Prefixes to prepend when looking for libraries. This specifies what prefixes to add to library names when the -find_library command looks for libraries. On UNIX systems this is -typically lib, meaning that when trying to find the foo library it -will look for libfoo. +:command:`find_library` command looks for libraries. On UNIX systems this is +typically ``lib``, meaning that when trying to find the ``foo`` library it +will look for ``libfoo``. diff --git a/Help/variable/CMAKE_FIND_LIBRARY_SUFFIXES.rst b/Help/variable/CMAKE_FIND_LIBRARY_SUFFIXES.rst index c533909..4a64e33 100644 --- a/Help/variable/CMAKE_FIND_LIBRARY_SUFFIXES.rst +++ b/Help/variable/CMAKE_FIND_LIBRARY_SUFFIXES.rst @@ -4,6 +4,6 @@ CMAKE_FIND_LIBRARY_SUFFIXES Suffixes to append when looking for libraries. This specifies what suffixes to add to library names when the -find_library command looks for libraries. On Windows systems this is -typically .lib and .dll, meaning that when trying to find the foo -library it will look for foo.dll etc. +:command:`find_library` command looks for libraries. On Windows systems this +is typically ``.lib`` and ``.dll``, meaning that when trying to find the +``foo`` library it will look for ``foo.dll`` etc. diff --git a/Help/variable/CMAKE_FIND_NO_INSTALL_PREFIX.rst b/Help/variable/CMAKE_FIND_NO_INSTALL_PREFIX.rst index 70d920b..c49d264 100644 --- a/Help/variable/CMAKE_FIND_NO_INSTALL_PREFIX.rst +++ b/Help/variable/CMAKE_FIND_NO_INSTALL_PREFIX.rst @@ -8,8 +8,8 @@ CMake adds the :variable:`CMAKE_INSTALL_PREFIX` and the :variable:`CMAKE_SYSTEM_PREFIX_PATH` by default. This variable may be set on the command line to control that behavior. -Set :variable:`CMAKE_FIND_NO_INSTALL_PREFIX` to TRUE to tell find_package not -to search in the :variable:`CMAKE_INSTALL_PREFIX` or -:variable:`CMAKE_STAGING_PREFIX` by default. Note that the +Set ``CMAKE_FIND_NO_INSTALL_PREFIX`` to ``TRUE`` to tell +:command:`find_package` not to search in the :variable:`CMAKE_INSTALL_PREFIX` +or :variable:`CMAKE_STAGING_PREFIX` by default. Note that the prefix may still be searched for other reasons, such as being the same prefix as the CMake installation, or for being a built-in system prefix. diff --git a/Help/variable/CMAKE_FIND_PACKAGE_WARN_NO_MODULE.rst b/Help/variable/CMAKE_FIND_PACKAGE_WARN_NO_MODULE.rst index 5d7599c..f1116bb 100644 --- a/Help/variable/CMAKE_FIND_PACKAGE_WARN_NO_MODULE.rst +++ b/Help/variable/CMAKE_FIND_PACKAGE_WARN_NO_MODULE.rst @@ -1,19 +1,19 @@ CMAKE_FIND_PACKAGE_WARN_NO_MODULE --------------------------------- -Tell find_package to warn if called without an explicit mode. +Tell :command:`find_package` to warn if called without an explicit mode. -If find_package is called without an explicit mode option (MODULE, -CONFIG or NO_MODULE) and no Find.cmake module is in -CMAKE_MODULE_PATH then CMake implicitly assumes that the caller -intends to search for a package configuration file. If no package +If :command:`find_package` is called without an explicit mode option +(``MODULE``, ``CONFIG``, or ``NO_MODULE``) and no ``Find.cmake`` module +is in :variable:`CMAKE_MODULE_PATH` then CMake implicitly assumes that the +caller intends to search for a package configuration file. If no package configuration file is found then the wording of the failure message must account for both the case that the package is really missing and the case that the project has a bug and failed to provide the intended Find module. If instead the caller specifies an explicit mode option then the failure message can be more specific. -Set CMAKE_FIND_PACKAGE_WARN_NO_MODULE to TRUE to tell find_package to -warn when it implicitly assumes Config mode. This helps developers -enforce use of an explicit mode in all calls to find_package within a -project. +Set ``CMAKE_FIND_PACKAGE_WARN_NO_MODULE`` to ``TRUE`` to tell +:command:`find_package` to warn when it implicitly assumes Config mode. This +helps developers enforce use of an explicit mode in all calls to +:command:`find_package` within a project. diff --git a/Help/variable/CMAKE_FIND_ROOT_PATH.rst b/Help/variable/CMAKE_FIND_ROOT_PATH.rst index ccf5234..ba2cf31 100644 --- a/Help/variable/CMAKE_FIND_ROOT_PATH.rst +++ b/Help/variable/CMAKE_FIND_ROOT_PATH.rst @@ -4,5 +4,5 @@ CMAKE_FIND_ROOT_PATH :ref:`;-list ` of root paths to search on the filesystem. This variable is most useful when cross-compiling. CMake uses the paths in -this list as alternative roots to find filesystem items with :command:`find_package`, -:command:`find_library` etc. +this list as alternative roots to find filesystem items with +:command:`find_package`, :command:`find_library` etc. diff --git a/Help/variable/CMAKE_Fortran_FORMAT.rst b/Help/variable/CMAKE_Fortran_FORMAT.rst index c0e971c..1406e59 100644 --- a/Help/variable/CMAKE_Fortran_FORMAT.rst +++ b/Help/variable/CMAKE_Fortran_FORMAT.rst @@ -1,7 +1,7 @@ CMAKE_Fortran_FORMAT -------------------- -Set to FIXED or FREE to indicate the Fortran source layout. +Set to ``FIXED`` or ``FREE`` to indicate the Fortran source layout. -This variable is used to initialize the Fortran_FORMAT property on all -the targets. See that target property for additional information. +This variable is used to initialize the :prop_tgt:`Fortran_FORMAT` property on +all the targets. See that target property for additional information. diff --git a/Help/variable/CMAKE_Fortran_MODDIR_DEFAULT.rst b/Help/variable/CMAKE_Fortran_MODDIR_DEFAULT.rst index a8dfcdf..5aeab07 100644 --- a/Help/variable/CMAKE_Fortran_MODDIR_DEFAULT.rst +++ b/Help/variable/CMAKE_Fortran_MODDIR_DEFAULT.rst @@ -3,6 +3,6 @@ CMAKE_Fortran_MODDIR_DEFAULT Fortran default module output directory. -Most Fortran compilers write .mod files to the current working -directory. For those that do not, this is set to "." and used when -the Fortran_MODULE_DIRECTORY target property is not set. +Most Fortran compilers write ``.mod`` files to the current working +directory. For those that do not, this is set to ``.`` and used when +the :prop_tgt:`Fortran_MODULE_DIRECTORY` target property is not set. diff --git a/Help/variable/CMAKE_Fortran_MODDIR_FLAG.rst b/Help/variable/CMAKE_Fortran_MODDIR_FLAG.rst index 4b32df3..1da55ca 100644 --- a/Help/variable/CMAKE_Fortran_MODDIR_FLAG.rst +++ b/Help/variable/CMAKE_Fortran_MODDIR_FLAG.rst @@ -4,4 +4,4 @@ CMAKE_Fortran_MODDIR_FLAG Fortran flag for module output directory. This stores the flag needed to pass the value of the -Fortran_MODULE_DIRECTORY target property to the compiler. +:prop_tgt:`Fortran_MODULE_DIRECTORY` target property to the compiler. diff --git a/Help/variable/CMAKE_Fortran_MODOUT_FLAG.rst b/Help/variable/CMAKE_Fortran_MODOUT_FLAG.rst index a232213..2f83880 100644 --- a/Help/variable/CMAKE_Fortran_MODOUT_FLAG.rst +++ b/Help/variable/CMAKE_Fortran_MODOUT_FLAG.rst @@ -3,5 +3,5 @@ CMAKE_Fortran_MODOUT_FLAG Fortran flag to enable module output. -Most Fortran compilers write .mod files out by default. For others, +Most Fortran compilers write ``.mod`` files out by default. For others, this stores the flag needed to enable module output. diff --git a/Help/variable/CMAKE_Fortran_MODULE_DIRECTORY.rst b/Help/variable/CMAKE_Fortran_MODULE_DIRECTORY.rst index b1d49d8..3c7edc1 100644 --- a/Help/variable/CMAKE_Fortran_MODULE_DIRECTORY.rst +++ b/Help/variable/CMAKE_Fortran_MODULE_DIRECTORY.rst @@ -3,6 +3,6 @@ CMAKE_Fortran_MODULE_DIRECTORY Fortran module output directory. -This variable is used to initialize the Fortran_MODULE_DIRECTORY +This variable is used to initialize the :prop_tgt:`Fortran_MODULE_DIRECTORY` property on all the targets. See that target property for additional information. diff --git a/Help/variable/CMAKE_GENERATOR.rst b/Help/variable/CMAKE_GENERATOR.rst index a4e70a5..3f6ebc1 100644 --- a/Help/variable/CMAKE_GENERATOR.rst +++ b/Help/variable/CMAKE_GENERATOR.rst @@ -1,7 +1,7 @@ CMAKE_GENERATOR --------------- -The generator used to build the project. +The generator used to build the project. See :manual:`cmake-generators(7)`. The name of the generator that is being used to generate the build -files. (e.g. "Unix Makefiles", "Visual Studio 6", etc.) +files. (e.g. ``Unix Makefiles``, ``Visual Studio 6``, etc.) diff --git a/Help/variable/CMAKE_GENERATOR_PLATFORM.rst b/Help/variable/CMAKE_GENERATOR_PLATFORM.rst index 5559eb7..a5c284a 100644 --- a/Help/variable/CMAKE_GENERATOR_PLATFORM.rst +++ b/Help/variable/CMAKE_GENERATOR_PLATFORM.rst @@ -5,8 +5,8 @@ Generator-specific target platform name specified by user. Some CMake generators support a target platform name to be given to the native build system to choose a compiler toolchain. -If the user specifies a platform name (e.g. via the cmake -A option) -the value will be available in this variable. +If the user specifies a platform name (e.g. via the :manual:`cmake(1)` ``-A`` +option) the value will be available in this variable. The value of this variable should never be modified by project code. A toolchain file specified by the :variable:`CMAKE_TOOLCHAIN_FILE` diff --git a/Help/variable/CMAKE_GENERATOR_TOOLSET.rst b/Help/variable/CMAKE_GENERATOR_TOOLSET.rst index 9ccc8b3..89abe54 100644 --- a/Help/variable/CMAKE_GENERATOR_TOOLSET.rst +++ b/Help/variable/CMAKE_GENERATOR_TOOLSET.rst @@ -5,8 +5,8 @@ Native build system toolset name specified by user. Some CMake generators support a toolset name to be given to the native build system to choose a compiler. If the user specifies a toolset -name (e.g. via the cmake -T option) the value will be available in -this variable. +name (e.g. via the :manual:`cmake(1)` ``-T`` option) the value will be +available in this variable. The value of this variable should never be modified by project code. A toolchain file specified by the :variable:`CMAKE_TOOLCHAIN_FILE` diff --git a/Help/variable/CMAKE_GNUtoMS.rst b/Help/variable/CMAKE_GNUtoMS.rst index e253f59..9c0f59e 100644 --- a/Help/variable/CMAKE_GNUtoMS.rst +++ b/Help/variable/CMAKE_GNUtoMS.rst @@ -1,8 +1,8 @@ CMAKE_GNUtoMS ------------- -Convert GNU import libraries (.dll.a) to MS format (.lib). +Convert GNU import libraries (``.dll.a``) to MS format (``.lib``). -This variable is used to initialize the GNUtoMS property on targets -when they are created. See that target property for additional +This variable is used to initialize the :prop_tgt:`GNUtoMS` property on +targets when they are created. See that target property for additional information. diff --git a/Help/variable/CMAKE_HOST_APPLE.rst b/Help/variable/CMAKE_HOST_APPLE.rst index d4b8483..ac7b030 100644 --- a/Help/variable/CMAKE_HOST_APPLE.rst +++ b/Help/variable/CMAKE_HOST_APPLE.rst @@ -1,6 +1,6 @@ CMAKE_HOST_APPLE ---------------- -True for Apple OS X operating systems. +``True`` for Apple OS X operating systems. -Set to true when the host system is Apple OS X. +Set to ``true`` when the host system is Apple OS X. diff --git a/Help/variable/CMAKE_HOST_SYSTEM_NAME.rst b/Help/variable/CMAKE_HOST_SYSTEM_NAME.rst index a221de9..e5e6f67 100644 --- a/Help/variable/CMAKE_HOST_SYSTEM_NAME.rst +++ b/Help/variable/CMAKE_HOST_SYSTEM_NAME.rst @@ -4,5 +4,5 @@ CMAKE_HOST_SYSTEM_NAME Name of the OS CMake is running on. On systems that have the uname command, this variable is set to the -output of uname -s. ``Linux``, ``Windows``, and ``Darwin`` for Mac OS X +output of ``uname -s``. ``Linux``, ``Windows``, and ``Darwin`` for Mac OS X are the values found on the big three operating systems. diff --git a/Help/variable/CMAKE_HOST_SYSTEM_PROCESSOR.rst b/Help/variable/CMAKE_HOST_SYSTEM_PROCESSOR.rst index 790565a..ba8a850 100644 --- a/Help/variable/CMAKE_HOST_SYSTEM_PROCESSOR.rst +++ b/Help/variable/CMAKE_HOST_SYSTEM_PROCESSOR.rst @@ -3,6 +3,6 @@ CMAKE_HOST_SYSTEM_PROCESSOR The name of the CPU CMake is running on. -On systems that support uname, this variable is set to the output of -uname -p, on windows it is set to the value of the environment variable +On systems that support ``uname``, this variable is set to the output of +``uname -p``. On Windows it is set to the value of the environment variable ``PROCESSOR_ARCHITECTURE``. diff --git a/Help/variable/CMAKE_HOST_SYSTEM_VERSION.rst b/Help/variable/CMAKE_HOST_SYSTEM_VERSION.rst index e7e0052..ed23070 100644 --- a/Help/variable/CMAKE_HOST_SYSTEM_VERSION.rst +++ b/Help/variable/CMAKE_HOST_SYSTEM_VERSION.rst @@ -4,5 +4,5 @@ CMAKE_HOST_SYSTEM_VERSION The OS version CMake is running on. A numeric version string for the system. On systems that support -uname, this variable is set to the output of uname -r. On other +``uname``, this variable is set to the output of ``uname -r``. On other systems this is set to major-minor version numbers. diff --git a/Help/variable/CMAKE_HOST_UNIX.rst b/Help/variable/CMAKE_HOST_UNIX.rst index bbefba7..817a957 100644 --- a/Help/variable/CMAKE_HOST_UNIX.rst +++ b/Help/variable/CMAKE_HOST_UNIX.rst @@ -1,7 +1,7 @@ CMAKE_HOST_UNIX --------------- -True for UNIX and UNIX like operating systems. +``True`` for UNIX and UNIX like operating systems. -Set to true when the host system is UNIX or UNIX like (i.e. APPLE and +Set to ``true`` when the host system is UNIX or UNIX like (i.e. APPLE and CYGWIN). diff --git a/Help/variable/CMAKE_HOST_WIN32.rst b/Help/variable/CMAKE_HOST_WIN32.rst index 92ee456..0e4c891 100644 --- a/Help/variable/CMAKE_HOST_WIN32.rst +++ b/Help/variable/CMAKE_HOST_WIN32.rst @@ -1,6 +1,6 @@ CMAKE_HOST_WIN32 ---------------- -True on windows systems, including win64. +``True`` on Windows systems, including Win64. -Set to true when the host system is Windows and on Cygwin. +Set to ``true`` when the host system is Windows and on Cygwin. diff --git a/Help/variable/CMAKE_IMPORT_LIBRARY_PREFIX.rst b/Help/variable/CMAKE_IMPORT_LIBRARY_PREFIX.rst index 1d16a37..1561a1d 100644 --- a/Help/variable/CMAKE_IMPORT_LIBRARY_PREFIX.rst +++ b/Help/variable/CMAKE_IMPORT_LIBRARY_PREFIX.rst @@ -6,4 +6,4 @@ The prefix for import libraries that you link to. The prefix to use for the name of an import library if used on this platform. -CMAKE_IMPORT_LIBRARY_PREFIX_ overrides this for language . +``CMAKE_IMPORT_LIBRARY_PREFIX_`` overrides this for language ````. diff --git a/Help/variable/CMAKE_IMPORT_LIBRARY_SUFFIX.rst b/Help/variable/CMAKE_IMPORT_LIBRARY_SUFFIX.rst index c16825e..11aeab7 100644 --- a/Help/variable/CMAKE_IMPORT_LIBRARY_SUFFIX.rst +++ b/Help/variable/CMAKE_IMPORT_LIBRARY_SUFFIX.rst @@ -6,4 +6,4 @@ The suffix for import libraries that you link to. The suffix to use for the end of an import library filename if used on this platform. -CMAKE_IMPORT_LIBRARY_SUFFIX_ overrides this for language . +``CMAKE_IMPORT_LIBRARY_SUFFIX_`` overrides this for language ````. diff --git a/Help/variable/CMAKE_INCLUDE_CURRENT_DIR.rst b/Help/variable/CMAKE_INCLUDE_CURRENT_DIR.rst index 79f3952..6eea322 100644 --- a/Help/variable/CMAKE_INCLUDE_CURRENT_DIR.rst +++ b/Help/variable/CMAKE_INCLUDE_CURRENT_DIR.rst @@ -3,11 +3,11 @@ CMAKE_INCLUDE_CURRENT_DIR Automatically add the current source- and build directories to the include path. -If this variable is enabled, CMake automatically adds in each -directory ${CMAKE_CURRENT_SOURCE_DIR} and ${CMAKE_CURRENT_BINARY_DIR} -to the include path for this directory. These additional include +If this variable is enabled, CMake automatically adds +:variable:`CMAKE_CURRENT_SOURCE_DIR` and :variable:`CMAKE_CURRENT_BINARY_DIR` +to the include path for each directory. These additional include directories do not propagate down to subdirectories. This is useful mainly for out-of-source builds, where files generated into the build tree are included by files located in the source tree. -By default CMAKE_INCLUDE_CURRENT_DIR is OFF. +By default ``CMAKE_INCLUDE_CURRENT_DIR`` is ``OFF``. diff --git a/Help/variable/CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE.rst b/Help/variable/CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE.rst index 948db50..5fc95f0 100644 --- a/Help/variable/CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE.rst +++ b/Help/variable/CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE.rst @@ -1,10 +1,12 @@ CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE -------------------------------------- -Automatically add the current source- and build directories to the INTERFACE_INCLUDE_DIRECTORIES. +Automatically add the current source- and build directories to the +:prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` target property. If this variable is enabled, CMake automatically adds for each shared library target, static library target, module target and executable -target, ${CMAKE_CURRENT_SOURCE_DIR} and ${CMAKE_CURRENT_BINARY_DIR} to -the INTERFACE_INCLUDE_DIRECTORIES.By default -CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE is OFF. +target, :variable:`CMAKE_CURRENT_SOURCE_DIR` and +:variable:`CMAKE_CURRENT_BINARY_DIR` to +the :prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` target property. By default +``CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE`` is ``OFF``. diff --git a/Help/variable/CMAKE_INCLUDE_DIRECTORIES_BEFORE.rst b/Help/variable/CMAKE_INCLUDE_DIRECTORIES_BEFORE.rst index 3c1fbcf..e0f2a2e 100644 --- a/Help/variable/CMAKE_INCLUDE_DIRECTORIES_BEFORE.rst +++ b/Help/variable/CMAKE_INCLUDE_DIRECTORIES_BEFORE.rst @@ -1,8 +1,9 @@ CMAKE_INCLUDE_DIRECTORIES_BEFORE -------------------------------- -Whether to append or prepend directories by default in :command:`include_directories`. +Whether to append or prepend directories by default in +:command:`include_directories`. This variable affects the default behavior of the :command:`include_directories` -command. Setting this variable to 'ON' is equivalent to using the BEFORE option -in all uses of that command. +command. Setting this variable to ``ON`` is equivalent to using the ``BEFORE`` +option in all uses of that command. diff --git a/Help/variable/CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE.rst b/Help/variable/CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE.rst index cbd04d7..37d0a3d 100644 --- a/Help/variable/CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE.rst +++ b/Help/variable/CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE.rst @@ -4,5 +4,5 @@ CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE Whether to force prepending of project include directories. This variable affects the order of include directories generated in compiler -command lines. If set to 'ON', it causes the :variable:`CMAKE_SOURCE_DIR` and -the :variable:`CMAKE_BINARY_DIR` to appear first. +command lines. If set to ``ON``, it causes the :variable:`CMAKE_SOURCE_DIR` +and the :variable:`CMAKE_BINARY_DIR` to appear first. diff --git a/Help/variable/CMAKE_INSTALL_DEFAULT_COMPONENT_NAME.rst b/Help/variable/CMAKE_INSTALL_DEFAULT_COMPONENT_NAME.rst index 2ad0689..57160f1 100644 --- a/Help/variable/CMAKE_INSTALL_DEFAULT_COMPONENT_NAME.rst +++ b/Help/variable/CMAKE_INSTALL_DEFAULT_COMPONENT_NAME.rst @@ -1,9 +1,9 @@ CMAKE_INSTALL_DEFAULT_COMPONENT_NAME ------------------------------------ -Default component used in install() commands. +Default component used in :command:`install` commands. -If an install() command is used without the COMPONENT argument, these -files will be grouped into a default component. The name of this +If an :command:`install` command is used without the ``COMPONENT`` argument, +these files will be grouped into a default component. The name of this default install component will be taken from this variable. It -defaults to "Unspecified". +defaults to ``Unspecified``. diff --git a/Help/variable/CMAKE_INSTALL_NAME_DIR.rst b/Help/variable/CMAKE_INSTALL_NAME_DIR.rst index 540df6b..961d712 100644 --- a/Help/variable/CMAKE_INSTALL_NAME_DIR.rst +++ b/Help/variable/CMAKE_INSTALL_NAME_DIR.rst @@ -3,6 +3,6 @@ CMAKE_INSTALL_NAME_DIR Mac OS X directory name for installed targets. -CMAKE_INSTALL_NAME_DIR is used to initialize the INSTALL_NAME_DIR -property on all targets. See that target property for more -information. +``CMAKE_INSTALL_NAME_DIR`` is used to initialize the +:prop_tgt:`INSTALL_NAME_DIR` property on all targets. See that target +property for more information. diff --git a/Help/variable/CMAKE_INSTALL_PREFIX.rst b/Help/variable/CMAKE_INSTALL_PREFIX.rst index ee9b615..3f3347f 100644 --- a/Help/variable/CMAKE_INSTALL_PREFIX.rst +++ b/Help/variable/CMAKE_INSTALL_PREFIX.rst @@ -1,14 +1,14 @@ CMAKE_INSTALL_PREFIX -------------------- -Install directory used by install. +Install directory used by :command:`install`. -If "make install" is invoked or INSTALL is built, this directory is +If ``make install`` is invoked or ``INSTALL`` is built, this directory is prepended onto all install directories. This variable defaults to -/usr/local on UNIX and c:/Program Files on Windows. +``/usr/local`` on UNIX and ``c:/Program Files`` on Windows. -On UNIX one can use the DESTDIR mechanism in order to relocate the -whole installation. DESTDIR means DESTination DIRectory. It is +On UNIX one can use the ``DESTDIR`` mechanism in order to relocate the +whole installation. ``DESTDIR`` means DESTination DIRectory. It is commonly used by makefile users in order to install software at non-default location. It is usually invoked like this: @@ -17,16 +17,17 @@ non-default location. It is usually invoked like this: make DESTDIR=/home/john install which will install the concerned software using the installation -prefix, e.g. "/usr/local" prepended with the DESTDIR value which -finally gives "/home/john/usr/local". +prefix, e.g. ``/usr/local`` prepended with the ``DESTDIR`` value which +finally gives ``/home/john/usr/local``. -WARNING: DESTDIR may not be used on Windows because installation -prefix usually contains a drive letter like in "C:/Program Files" +WARNING: ``DESTDIR`` may not be used on Windows because installation +prefix usually contains a drive letter like in ``C:/Program Files`` which cannot be prepended with some other prefix. -The installation prefix is also added to CMAKE_SYSTEM_PREFIX_PATH so -that find_package, find_program, find_library, find_path, and -find_file will search the prefix for other software. +The installation prefix is also added to :variable:`CMAKE_SYSTEM_PREFIX_PATH` +so that :command:`find_package`, :command:`find_program`, +:command:`find_library`, :command:`find_path`, and :command:`find_file` +will search the prefix for other software. .. note:: diff --git a/Help/variable/CMAKE_INSTALL_RPATH.rst b/Help/variable/CMAKE_INSTALL_RPATH.rst index 0992d57..813d1e0 100644 --- a/Help/variable/CMAKE_INSTALL_RPATH.rst +++ b/Help/variable/CMAKE_INSTALL_RPATH.rst @@ -5,4 +5,4 @@ The rpath to use for installed targets. A semicolon-separated list specifying the rpath to use in installed targets (for platforms that support it). This is used to initialize -the target property INSTALL_RPATH for all targets. +the target property :prop_tgt:`INSTALL_RPATH` for all targets. diff --git a/Help/variable/CMAKE_INSTALL_RPATH_USE_LINK_PATH.rst b/Help/variable/CMAKE_INSTALL_RPATH_USE_LINK_PATH.rst index 9277a3b..78148d5 100644 --- a/Help/variable/CMAKE_INSTALL_RPATH_USE_LINK_PATH.rst +++ b/Help/variable/CMAKE_INSTALL_RPATH_USE_LINK_PATH.rst @@ -3,7 +3,7 @@ CMAKE_INSTALL_RPATH_USE_LINK_PATH Add paths to linker search and installed rpath. -CMAKE_INSTALL_RPATH_USE_LINK_PATH is a boolean that if set to true +``CMAKE_INSTALL_RPATH_USE_LINK_PATH`` is a boolean that if set to ``true`` will append directories in the linker search path and outside the -project to the INSTALL_RPATH. This is used to initialize the target -property INSTALL_RPATH_USE_LINK_PATH for all targets. +project to the :prop_tgt:`INSTALL_RPATH`. This is used to initialize the +target property :prop_tgt:`INSTALL_RPATH_USE_LINK_PATH` for all targets. diff --git a/Help/variable/CMAKE_LANG_ARCHIVE_APPEND.rst b/Help/variable/CMAKE_LANG_ARCHIVE_APPEND.rst index 2c3abae..ab4ad71 100644 --- a/Help/variable/CMAKE_LANG_ARCHIVE_APPEND.rst +++ b/Help/variable/CMAKE_LANG_ARCHIVE_APPEND.rst @@ -4,6 +4,7 @@ CMAKE__ARCHIVE_APPEND Rule variable to append to a static archive. This is a rule variable that tells CMake how to append to a static -archive. It is used in place of CMAKE__CREATE_STATIC_LIBRARY on -some platforms in order to support large object counts. See also -CMAKE__ARCHIVE_CREATE and CMAKE__ARCHIVE_FINISH. +archive. It is used in place of :variable:`CMAKE__CREATE_STATIC_LIBRARY` +on some platforms in order to support large object counts. See also +:variable:`CMAKE__ARCHIVE_CREATE` and +:variable:`CMAKE__ARCHIVE_FINISH`. diff --git a/Help/variable/CMAKE_LANG_ARCHIVE_CREATE.rst b/Help/variable/CMAKE_LANG_ARCHIVE_CREATE.rst index f93dd11..fc295af 100644 --- a/Help/variable/CMAKE_LANG_ARCHIVE_CREATE.rst +++ b/Help/variable/CMAKE_LANG_ARCHIVE_CREATE.rst @@ -4,6 +4,7 @@ CMAKE__ARCHIVE_CREATE Rule variable to create a new static archive. This is a rule variable that tells CMake how to create a static -archive. It is used in place of CMAKE__CREATE_STATIC_LIBRARY on -some platforms in order to support large object counts. See also -CMAKE__ARCHIVE_APPEND and CMAKE__ARCHIVE_FINISH. +archive. It is used in place of :variable:`CMAKE__CREATE_STATIC_LIBRARY` +on some platforms in order to support large object counts. See also +:variable:`CMAKE__ARCHIVE_APPEND` and +:variable:`CMAKE__ARCHIVE_FINISH`. diff --git a/Help/variable/CMAKE_LANG_ARCHIVE_FINISH.rst b/Help/variable/CMAKE_LANG_ARCHIVE_FINISH.rst index fff4128..1bb5d65 100644 --- a/Help/variable/CMAKE_LANG_ARCHIVE_FINISH.rst +++ b/Help/variable/CMAKE_LANG_ARCHIVE_FINISH.rst @@ -4,6 +4,7 @@ CMAKE__ARCHIVE_FINISH Rule variable to finish an existing static archive. This is a rule variable that tells CMake how to finish a static -archive. It is used in place of CMAKE__CREATE_STATIC_LIBRARY on -some platforms in order to support large object counts. See also -CMAKE__ARCHIVE_CREATE and CMAKE__ARCHIVE_APPEND. +archive. It is used in place of :variable:`CMAKE__CREATE_STATIC_LIBRARY` +on some platforms in order to support large object counts. See also +:variable:`CMAKE__ARCHIVE_CREATE` and +:variable:`CMAKE__ARCHIVE_APPEND`. diff --git a/Help/variable/CMAKE_LANG_COMPILER.rst b/Help/variable/CMAKE_LANG_COMPILER.rst index fffc347..89df495 100644 --- a/Help/variable/CMAKE_LANG_COMPILER.rst +++ b/Help/variable/CMAKE_LANG_COMPILER.rst @@ -1,7 +1,7 @@ CMAKE__COMPILER --------------------- -The full path to the compiler for LANG. +The full path to the compiler for ``LANG``. -This is the command that will be used as the compiler. Once +This is the command that will be used as the ```` compiler. Once set, you can not change this variable. diff --git a/Help/variable/CMAKE_LANG_COMPILER_EXTERNAL_TOOLCHAIN.rst b/Help/variable/CMAKE_LANG_COMPILER_EXTERNAL_TOOLCHAIN.rst index 033998d..8bb7cc0 100644 --- a/Help/variable/CMAKE_LANG_COMPILER_EXTERNAL_TOOLCHAIN.rst +++ b/Help/variable/CMAKE_LANG_COMPILER_EXTERNAL_TOOLCHAIN.rst @@ -5,9 +5,9 @@ The external toolchain for cross-compiling, if supported. Some compiler toolchains do not ship their own auxilliary utilities such as archivers and linkers. The compiler driver may support a command-line argument -to specify the location of such tools. CMAKE__COMPILER_EXTERNAL_TOOLCHAIN -may be set to a path to a path to the external toolchain and will be passed -to the compiler driver if supported. +to specify the location of such tools. +``CMAKE__COMPILER_EXTERNAL_TOOLCHAIN`` may be set to a path to a path to +the external toolchain and will be passed to the compiler driver if supported. This variable may only be set in a toolchain file specified by the :variable:`CMAKE_TOOLCHAIN_FILE` variable. diff --git a/Help/variable/CMAKE_LANG_COMPILER_LOADED.rst b/Help/variable/CMAKE_LANG_COMPILER_LOADED.rst index 3b8e9aa..9308878 100644 --- a/Help/variable/CMAKE_LANG_COMPILER_LOADED.rst +++ b/Help/variable/CMAKE_LANG_COMPILER_LOADED.rst @@ -3,5 +3,5 @@ CMAKE__COMPILER_LOADED Defined to true if the language is enabled. -When language is enabled by project() or enable_language() this -variable is defined to 1. +When language ```` is enabled by :command:`project` or +:command:`enable_language` this variable is defined to ``1``. diff --git a/Help/variable/CMAKE_LANG_COMPILE_OBJECT.rst b/Help/variable/CMAKE_LANG_COMPILE_OBJECT.rst index f43ed6d..ba59cad 100644 --- a/Help/variable/CMAKE_LANG_COMPILE_OBJECT.rst +++ b/Help/variable/CMAKE_LANG_COMPILE_OBJECT.rst @@ -4,4 +4,4 @@ CMAKE__COMPILE_OBJECT Rule variable to compile a single object file. This is a rule variable that tells CMake how to compile a single -object file for the language . +object file for the language ````. diff --git a/Help/variable/CMAKE_LANG_CREATE_SHARED_LIBRARY.rst b/Help/variable/CMAKE_LANG_CREATE_SHARED_LIBRARY.rst index adf1624..be89f85 100644 --- a/Help/variable/CMAKE_LANG_CREATE_SHARED_LIBRARY.rst +++ b/Help/variable/CMAKE_LANG_CREATE_SHARED_LIBRARY.rst @@ -4,4 +4,4 @@ CMAKE__CREATE_SHARED_LIBRARY Rule variable to create a shared library. This is a rule variable that tells CMake how to create a shared -library for the language . +library for the language ````. diff --git a/Help/variable/CMAKE_LANG_CREATE_SHARED_MODULE.rst b/Help/variable/CMAKE_LANG_CREATE_SHARED_MODULE.rst index 406b4da..ae5f69d 100644 --- a/Help/variable/CMAKE_LANG_CREATE_SHARED_MODULE.rst +++ b/Help/variable/CMAKE_LANG_CREATE_SHARED_MODULE.rst @@ -4,4 +4,4 @@ CMAKE__CREATE_SHARED_MODULE Rule variable to create a shared module. This is a rule variable that tells CMake how to create a shared -library for the language . +library for the language ````. diff --git a/Help/variable/CMAKE_LANG_CREATE_STATIC_LIBRARY.rst b/Help/variable/CMAKE_LANG_CREATE_STATIC_LIBRARY.rst index 8114432..0cff200 100644 --- a/Help/variable/CMAKE_LANG_CREATE_STATIC_LIBRARY.rst +++ b/Help/variable/CMAKE_LANG_CREATE_STATIC_LIBRARY.rst @@ -4,4 +4,4 @@ CMAKE__CREATE_STATIC_LIBRARY Rule variable to create a static library. This is a rule variable that tells CMake how to create a static -library for the language . +library for the language ````. diff --git a/Help/variable/CMAKE_LANG_FLAGS.rst b/Help/variable/CMAKE_LANG_FLAGS.rst index 6aa0a3e..c57d92c 100644 --- a/Help/variable/CMAKE_LANG_FLAGS.rst +++ b/Help/variable/CMAKE_LANG_FLAGS.rst @@ -3,4 +3,4 @@ CMAKE__FLAGS Flags for all build types. - flags used regardless of the value of CMAKE_BUILD_TYPE. +```` flags used regardless of the value of :variable:`CMAKE_BUILD_TYPE`. diff --git a/Help/variable/CMAKE_LANG_FLAGS_DEBUG.rst b/Help/variable/CMAKE_LANG_FLAGS_DEBUG.rst index a727641..a233d4a 100644 --- a/Help/variable/CMAKE_LANG_FLAGS_DEBUG.rst +++ b/Help/variable/CMAKE_LANG_FLAGS_DEBUG.rst @@ -1,6 +1,6 @@ CMAKE__FLAGS_DEBUG ------------------------ -Flags for Debug build type or configuration. +Flags for ``Debug`` build type or configuration. - flags used when CMAKE_BUILD_TYPE is Debug. +```` flags used when :variable:`CMAKE_BUILD_TYPE` is ``Debug``. diff --git a/Help/variable/CMAKE_LANG_FLAGS_MINSIZEREL.rst b/Help/variable/CMAKE_LANG_FLAGS_MINSIZEREL.rst index fbb8516..a9436c1 100644 --- a/Help/variable/CMAKE_LANG_FLAGS_MINSIZEREL.rst +++ b/Help/variable/CMAKE_LANG_FLAGS_MINSIZEREL.rst @@ -1,7 +1,7 @@ CMAKE__FLAGS_MINSIZEREL ----------------------------- -Flags for MinSizeRel build type or configuration. +Flags for ``MinSizeRel`` build type or configuration. - flags used when CMAKE_BUILD_TYPE is MinSizeRel.Short for -minimum size release. +```` flags used when :variable:`CMAKE_BUILD_TYPE` is ``MinSizeRel`` +(short for minimum size release). diff --git a/Help/variable/CMAKE_LANG_FLAGS_RELEASE.rst b/Help/variable/CMAKE_LANG_FLAGS_RELEASE.rst index 4b2c926..ffc5d79 100644 --- a/Help/variable/CMAKE_LANG_FLAGS_RELEASE.rst +++ b/Help/variable/CMAKE_LANG_FLAGS_RELEASE.rst @@ -1,6 +1,6 @@ CMAKE__FLAGS_RELEASE -------------------------- -Flags for Release build type or configuration. +Flags for ``Release`` build type or configuration. - flags used when CMAKE_BUILD_TYPE is Release +```` flags used when :variable:`CMAKE_BUILD_TYPE` is ``Release``. diff --git a/Help/variable/CMAKE_LANG_FLAGS_RELWITHDEBINFO.rst b/Help/variable/CMAKE_LANG_FLAGS_RELWITHDEBINFO.rst index 16bd4e9..962768e 100644 --- a/Help/variable/CMAKE_LANG_FLAGS_RELWITHDEBINFO.rst +++ b/Help/variable/CMAKE_LANG_FLAGS_RELWITHDEBINFO.rst @@ -1,7 +1,7 @@ CMAKE__FLAGS_RELWITHDEBINFO --------------------------------- -Flags for RelWithDebInfo type or configuration. +Flags for ``RelWithDebInfo`` type or configuration. - flags used when CMAKE_BUILD_TYPE is RelWithDebInfo. Short for -Release With Debug Information. +```` flags used when :variable:`CMAKE_BUILD_TYPE` is ``RelWithDebInfo`` +(short for Release With Debug Information). diff --git a/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_DEBUG.rst b/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_DEBUG.rst index c5915c3..1f639a3 100644 --- a/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_DEBUG.rst +++ b/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_DEBUG.rst @@ -1,6 +1,6 @@ CMAKE__GHS_KERNEL_FLAGS_DEBUG ----------------------------------- -GHS kernel flags for Debug build type or configuration. +GHS kernel flags for ``Debug`` build type or configuration. - flags used when CMAKE_BUILD_TYPE is Debug. +```` flags used when :variable:`CMAKE_BUILD_TYPE` is ``Debug``. diff --git a/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_MINSIZEREL.rst b/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_MINSIZEREL.rst index f80e785..94e2115 100644 --- a/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_MINSIZEREL.rst +++ b/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_MINSIZEREL.rst @@ -1,7 +1,7 @@ CMAKE__GHS_KERNEL_FLAGS_MINSIZEREL ---------------------------------------- -GHS kernel flags for MinSizeRel build type or configuration. +GHS kernel flags for ``MinSizeRel`` build type or configuration. - flags used when CMAKE_BUILD_TYPE is MinSizeRel.Short for -minimum size release. +```` flags used when :variable:`CMAKE_BUILD_TYPE` is ``MinSizeRel`` +(short for minimum size release). diff --git a/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_RELEASE.rst b/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_RELEASE.rst index fe02bc3..74566ef 100644 --- a/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_RELEASE.rst +++ b/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_RELEASE.rst @@ -1,6 +1,6 @@ CMAKE__GHS_KERNEL_FLAGS_RELEASE ------------------------------------- -GHS kernel flags for Release build type or configuration. +GHS kernel flags for ``Release`` build type or configuration. - flags used when CMAKE_BUILD_TYPE is Release +```` flags used when :variable:`CMAKE_BUILD_TYPE` is ``Release``. diff --git a/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_RELWITHDEBINFO.rst b/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_RELWITHDEBINFO.rst index 220f7f9..d148193 100644 --- a/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_RELWITHDEBINFO.rst +++ b/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_RELWITHDEBINFO.rst @@ -1,7 +1,7 @@ CMAKE__GHS_KERNEL_FLAGS_RELWITHDEBINFO -------------------------------------------- -GHS kernel flags for RelWithDebInfo type or configuration. +GHS kernel flags for ``RelWithDebInfo`` type or configuration. - flags used when CMAKE_BUILD_TYPE is RelWithDebInfo. Short for -Release With Debug Information. +```` flags used when :variable:`CMAKE_BUILD_TYPE` is ``RelWithDebInfo`` +(short for Release With Debug Information). diff --git a/Help/variable/CMAKE_LANG_IMPLICIT_INCLUDE_DIRECTORIES.rst b/Help/variable/CMAKE_LANG_IMPLICIT_INCLUDE_DIRECTORIES.rst index c60e18c..cc80851 100644 --- a/Help/variable/CMAKE_LANG_IMPLICIT_INCLUDE_DIRECTORIES.rst +++ b/Help/variable/CMAKE_LANG_IMPLICIT_INCLUDE_DIRECTORIES.rst @@ -4,6 +4,6 @@ CMAKE__IMPLICIT_INCLUDE_DIRECTORIES Directories implicitly searched by the compiler for header files. CMake does not explicitly specify these directories on compiler -command lines for language . This prevents system include +command lines for language ````. This prevents system include directories from being treated as user include directories on some compilers. diff --git a/Help/variable/CMAKE_LANG_IMPLICIT_LINK_DIRECTORIES.rst b/Help/variable/CMAKE_LANG_IMPLICIT_LINK_DIRECTORIES.rst index 568950c..a0bd830 100644 --- a/Help/variable/CMAKE_LANG_IMPLICIT_LINK_DIRECTORIES.rst +++ b/Help/variable/CMAKE_LANG_IMPLICIT_LINK_DIRECTORIES.rst @@ -1,7 +1,7 @@ CMAKE__IMPLICIT_LINK_DIRECTORIES -------------------------------------- -Implicit linker search path detected for language . +Implicit linker search path detected for language ````. Compilers typically pass directories containing language runtime libraries and default library search paths when they invoke a linker. @@ -10,8 +10,8 @@ language. CMake automatically detects these directories for each language and reports the results in this variable. When a library in one of these directories is given by full path to -target_link_libraries() CMake will generate the -l form on link -lines to ensure the linker searches its implicit directories for the +:command:`target_link_libraries` CMake will generate the ``-l`` form on +link lines to ensure the linker searches its implicit directories for the library. Note that some toolchains read implicit directories from an -environment variable such as LIBRARY_PATH so keep its value consistent +environment variable such as ``LIBRARY_PATH`` so keep its value consistent when operating in a given build tree. diff --git a/Help/variable/CMAKE_LANG_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES.rst b/Help/variable/CMAKE_LANG_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES.rst index 05e6ddb..61ccc5a 100644 --- a/Help/variable/CMAKE_LANG_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES.rst +++ b/Help/variable/CMAKE_LANG_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES.rst @@ -1,7 +1,7 @@ CMAKE__IMPLICIT_LINK_FRAMEWORK_DIRECTORIES ------------------------------------------------ -Implicit linker framework search path detected for language . +Implicit linker framework search path detected for language ````. These paths are implicit linker framework search directories for the compiler's language. CMake automatically detects these directories diff --git a/Help/variable/CMAKE_LANG_IMPLICIT_LINK_LIBRARIES.rst b/Help/variable/CMAKE_LANG_IMPLICIT_LINK_LIBRARIES.rst index fddfed8..ec16477 100644 --- a/Help/variable/CMAKE_LANG_IMPLICIT_LINK_LIBRARIES.rst +++ b/Help/variable/CMAKE_LANG_IMPLICIT_LINK_LIBRARIES.rst @@ -1,7 +1,7 @@ CMAKE__IMPLICIT_LINK_LIBRARIES ------------------------------------ -Implicit link libraries and flags detected for language . +Implicit link libraries and flags detected for language ````. Compilers typically pass language runtime library names and other flags when they invoke a linker. These flags are implicit link diff --git a/Help/variable/CMAKE_LANG_LIBRARY_ARCHITECTURE.rst b/Help/variable/CMAKE_LANG_LIBRARY_ARCHITECTURE.rst index 4f31494..7f888ee 100644 --- a/Help/variable/CMAKE_LANG_LIBRARY_ARCHITECTURE.rst +++ b/Help/variable/CMAKE_LANG_LIBRARY_ARCHITECTURE.rst @@ -1,8 +1,8 @@ CMAKE__LIBRARY_ARCHITECTURE --------------------------------- -Target architecture library directory name detected for . +Target architecture library directory name detected for ````. -If the compiler passes to the linker an architecture-specific -system library search directory such as /lib/ this -variable contains the name if/as detected by CMake. +If the ```` compiler passes to the linker an architecture-specific +system library search directory such as ``/lib/`` this +variable contains the ```` name if/as detected by CMake. diff --git a/Help/variable/CMAKE_LANG_LINKER_PREFERENCE.rst b/Help/variable/CMAKE_LANG_LINKER_PREFERENCE.rst index af7ee60..ff82f8b 100644 --- a/Help/variable/CMAKE_LANG_LINKER_PREFERENCE.rst +++ b/Help/variable/CMAKE_LANG_LINKER_PREFERENCE.rst @@ -5,7 +5,7 @@ Preference value for linker language selection. The "linker language" for executable, shared library, and module targets is the language whose compiler will invoke the linker. The -LINKER_LANGUAGE target property sets the language explicitly. +:prop_tgt:`LINKER_LANGUAGE` target property sets the language explicitly. Otherwise, the linker language is that whose linker preference value is highest among languages compiled and linked into the target. See -also the CMAKE__LINKER_PREFERENCE_PROPAGATES variable. +also the :variable:`CMAKE__LINKER_PREFERENCE_PROPAGATES` variable. diff --git a/Help/variable/CMAKE_LANG_LINKER_PREFERENCE_PROPAGATES.rst b/Help/variable/CMAKE_LANG_LINKER_PREFERENCE_PROPAGATES.rst index d513767..dbbeb0a 100644 --- a/Help/variable/CMAKE_LANG_LINKER_PREFERENCE_PROPAGATES.rst +++ b/Help/variable/CMAKE_LANG_LINKER_PREFERENCE_PROPAGATES.rst @@ -1,7 +1,7 @@ CMAKE__LINKER_PREFERENCE_PROPAGATES ----------------------------------------- -True if CMAKE__LINKER_PREFERENCE propagates across targets. +True if :variable:`CMAKE__LINKER_PREFERENCE` propagates across targets. This is used when CMake selects a linker language for a target. Languages compiled directly into the target are always considered. A diff --git a/Help/variable/CMAKE_LANG_OUTPUT_EXTENSION.rst b/Help/variable/CMAKE_LANG_OUTPUT_EXTENSION.rst index 22fac29..0fbc566 100644 --- a/Help/variable/CMAKE_LANG_OUTPUT_EXTENSION.rst +++ b/Help/variable/CMAKE_LANG_OUTPUT_EXTENSION.rst @@ -3,5 +3,5 @@ CMAKE__OUTPUT_EXTENSION Extension for the output of a compile for a single file. -This is the extension for an object file for the given . For -example .obj for C on Windows. +This is the extension for an object file for the given ````. For +example ``.obj`` for C on Windows. diff --git a/Help/variable/CMAKE_LANG_SIMULATE_ID.rst b/Help/variable/CMAKE_LANG_SIMULATE_ID.rst index 646c0db..15c87a1 100644 --- a/Help/variable/CMAKE_LANG_SIMULATE_ID.rst +++ b/Help/variable/CMAKE_LANG_SIMULATE_ID.rst @@ -5,5 +5,5 @@ Identification string of "simulated" compiler. Some compilers simulate other compilers to serve as drop-in replacements. When CMake detects such a compiler it sets this -variable to what would have been the CMAKE__COMPILER_ID for the -simulated compiler. +variable to what would have been the :variable:`CMAKE__COMPILER_ID` for +the simulated compiler. diff --git a/Help/variable/CMAKE_LANG_SIMULATE_VERSION.rst b/Help/variable/CMAKE_LANG_SIMULATE_VERSION.rst index 982053d..d6325e0 100644 --- a/Help/variable/CMAKE_LANG_SIMULATE_VERSION.rst +++ b/Help/variable/CMAKE_LANG_SIMULATE_VERSION.rst @@ -5,5 +5,5 @@ Version string of "simulated" compiler. Some compilers simulate other compilers to serve as drop-in replacements. When CMake detects such a compiler it sets this -variable to what would have been the CMAKE__COMPILER_VERSION for -the simulated compiler. +variable to what would have been the :variable:`CMAKE__COMPILER_VERSION` +for the simulated compiler. diff --git a/Help/variable/CMAKE_LANG_SIZEOF_DATA_PTR.rst b/Help/variable/CMAKE_LANG_SIZEOF_DATA_PTR.rst index c85b5e0..7465923 100644 --- a/Help/variable/CMAKE_LANG_SIZEOF_DATA_PTR.rst +++ b/Help/variable/CMAKE_LANG_SIZEOF_DATA_PTR.rst @@ -1,7 +1,7 @@ CMAKE__SIZEOF_DATA_PTR ---------------------------- -Size of pointer-to-data types for language . +Size of pointer-to-data types for language ````. This holds the size (in bytes) of pointer-to-data types in the target -platform ABI. It is defined for languages C and CXX (C++). +platform ABI. It is defined for languages ``C`` and ``CXX`` (C++). diff --git a/Help/variable/CMAKE_LIBRARY_ARCHITECTURE.rst b/Help/variable/CMAKE_LIBRARY_ARCHITECTURE.rst index c9a15f3..8a7dcbd 100644 --- a/Help/variable/CMAKE_LIBRARY_ARCHITECTURE.rst +++ b/Help/variable/CMAKE_LIBRARY_ARCHITECTURE.rst @@ -3,5 +3,5 @@ CMAKE_LIBRARY_ARCHITECTURE Target architecture library directory name, if detected. -This is the value of CMAKE__LIBRARY_ARCHITECTURE as detected for -one of the enabled languages. +This is the value of :variable:`CMAKE__LIBRARY_ARCHITECTURE` as detected +for one of the enabled languages. diff --git a/Help/variable/CMAKE_LIBRARY_ARCHITECTURE_REGEX.rst b/Help/variable/CMAKE_LIBRARY_ARCHITECTURE_REGEX.rst index 6c41269..1eb2ac2 100644 --- a/Help/variable/CMAKE_LIBRARY_ARCHITECTURE_REGEX.rst +++ b/Help/variable/CMAKE_LIBRARY_ARCHITECTURE_REGEX.rst @@ -3,5 +3,5 @@ CMAKE_LIBRARY_ARCHITECTURE_REGEX Regex matching possible target architecture library directory names. -This is used to detect CMAKE__LIBRARY_ARCHITECTURE from the -implicit linker search path by matching the name. +This is used to detect :variable:`CMAKE__LIBRARY_ARCHITECTURE` from the +implicit linker search path by matching the ```` name. diff --git a/Help/variable/CMAKE_LIBRARY_PATH_FLAG.rst b/Help/variable/CMAKE_LIBRARY_PATH_FLAG.rst index ede39e9..ebe5fda 100644 --- a/Help/variable/CMAKE_LIBRARY_PATH_FLAG.rst +++ b/Help/variable/CMAKE_LIBRARY_PATH_FLAG.rst @@ -4,4 +4,4 @@ CMAKE_LIBRARY_PATH_FLAG The flag to be used to add a library search path to a compiler. The flag will be used to specify a library directory to the compiler. -On most compilers this is "-L". +On most compilers this is ``-L``. diff --git a/Help/variable/CMAKE_LINK_DEF_FILE_FLAG.rst b/Help/variable/CMAKE_LINK_DEF_FILE_FLAG.rst index 382447c..fa09f9f 100644 --- a/Help/variable/CMAKE_LINK_DEF_FILE_FLAG.rst +++ b/Help/variable/CMAKE_LINK_DEF_FILE_FLAG.rst @@ -1,7 +1,7 @@ CMAKE_LINK_DEF_FILE_FLAG ------------------------ -Linker flag to be used to specify a .def file for dll creation. +Linker flag to be used to specify a ``.def`` file for dll creation. -The flag will be used to add a .def file when creating a dll on +The flag will be used to add a ``.def`` file when creating a dll on Windows; this is only defined on Windows. diff --git a/Help/variable/CMAKE_LINK_DEPENDS_NO_SHARED.rst b/Help/variable/CMAKE_LINK_DEPENDS_NO_SHARED.rst index 6ae7df6..cec7906 100644 --- a/Help/variable/CMAKE_LINK_DEPENDS_NO_SHARED.rst +++ b/Help/variable/CMAKE_LINK_DEPENDS_NO_SHARED.rst @@ -3,6 +3,6 @@ CMAKE_LINK_DEPENDS_NO_SHARED Whether to skip link dependencies on shared library files. -This variable initializes the LINK_DEPENDS_NO_SHARED property on +This variable initializes the :prop_tgt:`LINK_DEPENDS_NO_SHARED` property on targets when they are created. See that target property for additional information. diff --git a/Help/variable/CMAKE_LINK_INTERFACE_LIBRARIES.rst b/Help/variable/CMAKE_LINK_INTERFACE_LIBRARIES.rst index efe6fd7..33865da 100644 --- a/Help/variable/CMAKE_LINK_INTERFACE_LIBRARIES.rst +++ b/Help/variable/CMAKE_LINK_INTERFACE_LIBRARIES.rst @@ -1,8 +1,8 @@ CMAKE_LINK_INTERFACE_LIBRARIES ------------------------------ -Default value for LINK_INTERFACE_LIBRARIES of targets. +Default value for :prop_tgt:`LINK_INTERFACE_LIBRARIES` of targets. -This variable is used to initialize the LINK_INTERFACE_LIBRARIES +This variable is used to initialize the :prop_tgt:`LINK_INTERFACE_LIBRARIES` property on all the targets. See that target property for additional information. diff --git a/Help/variable/CMAKE_LINK_LIBRARY_FLAG.rst b/Help/variable/CMAKE_LINK_LIBRARY_FLAG.rst index c3e02d7..b5197e4 100644 --- a/Help/variable/CMAKE_LINK_LIBRARY_FLAG.rst +++ b/Help/variable/CMAKE_LINK_LIBRARY_FLAG.rst @@ -4,4 +4,4 @@ CMAKE_LINK_LIBRARY_FLAG Flag to be used to link a library into an executable. The flag will be used to specify a library to link to an executable. -On most compilers this is "-l". +On most compilers this is ``-l``. diff --git a/Help/variable/CMAKE_LINK_LIBRARY_SUFFIX.rst b/Help/variable/CMAKE_LINK_LIBRARY_SUFFIX.rst index 390298d..0ddafe8 100644 --- a/Help/variable/CMAKE_LINK_LIBRARY_SUFFIX.rst +++ b/Help/variable/CMAKE_LINK_LIBRARY_SUFFIX.rst @@ -3,4 +3,4 @@ CMAKE_LINK_LIBRARY_SUFFIX The suffix for libraries that you link to. -The suffix to use for the end of a library filename, .lib on Windows. +The suffix to use for the end of a library filename, ``.lib`` on Windows. diff --git a/Help/variable/CMAKE_LINK_SEARCH_END_STATIC.rst b/Help/variable/CMAKE_LINK_SEARCH_END_STATIC.rst index 673f5d8..54cdaaa 100644 --- a/Help/variable/CMAKE_LINK_SEARCH_END_STATIC.rst +++ b/Help/variable/CMAKE_LINK_SEARCH_END_STATIC.rst @@ -3,14 +3,14 @@ CMAKE_LINK_SEARCH_END_STATIC End a link line such that static system libraries are used. -Some linkers support switches such as -Bstatic and -Bdynamic to -determine whether to use static or shared libraries for -lXXX options. +Some linkers support switches such as ``-Bstatic`` and ``-Bdynamic`` to +determine whether to use static or shared libraries for ``-lXXX`` options. CMake uses these options to set the link type for libraries whose full paths are not known or (in some cases) are in implicit link directories for the platform. By default CMake adds an option at the end of the library list (if necessary) to set the linker search type back to its starting type. This property switches the final linker -search type to -Bstatic regardless of how it started. +search type to ``-Bstatic`` regardless of how it started. This variable is used to initialize the target property :prop_tgt:`LINK_SEARCH_END_STATIC` for all targets. If set, it's diff --git a/Help/variable/CMAKE_LINK_SEARCH_START_STATIC.rst b/Help/variable/CMAKE_LINK_SEARCH_START_STATIC.rst index 223702c..0d52a314 100644 --- a/Help/variable/CMAKE_LINK_SEARCH_START_STATIC.rst +++ b/Help/variable/CMAKE_LINK_SEARCH_START_STATIC.rst @@ -3,14 +3,14 @@ CMAKE_LINK_SEARCH_START_STATIC Assume the linker looks for static libraries by default. -Some linkers support switches such as -Bstatic and -Bdynamic to -determine whether to use static or shared libraries for -lXXX options. +Some linkers support switches such as ``-Bstatic`` and ``-Bdynamic`` to +determine whether to use static or shared libraries for ``-lXXX`` options. CMake uses these options to set the link type for libraries whose full paths are not known or (in some cases) are in implicit link directories for the platform. By default the linker search type is -assumed to be -Bdynamic at the beginning of the library list. This -property switches the assumption to -Bstatic. It is intended for use -when linking an executable statically (e.g. with the GNU -static +assumed to be ``-Bdynamic`` at the beginning of the library list. This +property switches the assumption to ``-Bstatic``. It is intended for use +when linking an executable statically (e.g. with the GNU ``-static`` option). This variable is used to initialize the target property diff --git a/Help/variable/CMAKE_MACOSX_BUNDLE.rst b/Help/variable/CMAKE_MACOSX_BUNDLE.rst index e4768f3..0badaf0 100644 --- a/Help/variable/CMAKE_MACOSX_BUNDLE.rst +++ b/Help/variable/CMAKE_MACOSX_BUNDLE.rst @@ -1,7 +1,7 @@ CMAKE_MACOSX_BUNDLE ------------------- -Default value for MACOSX_BUNDLE of targets. +Default value for :prop_tgt:`MACOSX_BUNDLE` of targets. -This variable is used to initialize the MACOSX_BUNDLE property on all -the targets. See that target property for additional information. +This variable is used to initialize the :prop_tgt:`MACOSX_BUNDLE` property on +all the targets. See that target property for additional information. diff --git a/Help/variable/CMAKE_MAKE_PROGRAM.rst b/Help/variable/CMAKE_MAKE_PROGRAM.rst index 85b098b..edf2732 100644 --- a/Help/variable/CMAKE_MAKE_PROGRAM.rst +++ b/Help/variable/CMAKE_MAKE_PROGRAM.rst @@ -8,18 +8,18 @@ name if it is expected to be in the ``PATH``. The tool selected depends on the :variable:`CMAKE_GENERATOR` used to configure the project: -* The Makefile generators set this to ``make``, ``gmake``, or - a generator-specific tool (e.g. ``nmake`` for "NMake Makefiles"). +* The :ref:`Makefile Generators` set this to ``make``, ``gmake``, or + a generator-specific tool (e.g. ``nmake`` for :generator:`NMake Makefiles`). These generators store ``CMAKE_MAKE_PROGRAM`` in the CMake cache so that it may be edited by the user. -* The Ninja generator sets this to ``ninja``. +* The :generator:`Ninja` generator sets this to ``ninja``. This generator stores ``CMAKE_MAKE_PROGRAM`` in the CMake cache so that it may be edited by the user. -* The Xcode generator sets this to ``xcodebuild`` (or possibly an +* The :generator:`Xcode` generator sets this to ``xcodebuild`` (or possibly an otherwise undocumented ``cmakexbuild`` wrapper implementing some workarounds). @@ -33,7 +33,7 @@ to configure the project: a user or project explicitly adds ``CMAKE_MAKE_PROGRAM`` to the CMake cache then CMake will use the specified value. -* The Visual Studio generators set this to the full path to +* The :ref:`Visual Studio Generators` set this to the full path to ``MSBuild.exe`` (VS >= 10), ``devenv.com`` (VS 7,8,9), ``VCExpress.exe`` (VS Express 8,9), or ``msdev.exe`` (VS 6). (See also variables diff --git a/Help/variable/CMAKE_MAP_IMPORTED_CONFIG_CONFIG.rst b/Help/variable/CMAKE_MAP_IMPORTED_CONFIG_CONFIG.rst index 41ccde1..ed29afe 100644 --- a/Help/variable/CMAKE_MAP_IMPORTED_CONFIG_CONFIG.rst +++ b/Help/variable/CMAKE_MAP_IMPORTED_CONFIG_CONFIG.rst @@ -1,8 +1,8 @@ CMAKE_MAP_IMPORTED_CONFIG_ ---------------------------------- -Default value for MAP_IMPORTED_CONFIG_ of targets. +Default value for :prop_tgt:`MAP_IMPORTED_CONFIG_` of targets. -This variable is used to initialize the MAP_IMPORTED_CONFIG_ -property on all the targets. See that target property for additional -information. +This variable is used to initialize the +:prop_tgt:`MAP_IMPORTED_CONFIG_` property on all the targets. See +that target property for additional information. diff --git a/Help/variable/CMAKE_MFC_FLAG.rst b/Help/variable/CMAKE_MFC_FLAG.rst index 221d26e..f60e7a5 100644 --- a/Help/variable/CMAKE_MFC_FLAG.rst +++ b/Help/variable/CMAKE_MFC_FLAG.rst @@ -3,10 +3,10 @@ CMAKE_MFC_FLAG Tell cmake to use MFC for an executable or dll. -This can be set in a CMakeLists.txt file and will enable MFC in the -application. It should be set to 1 for the static MFC library, and 2 +This can be set in a ``CMakeLists.txt`` file and will enable MFC in the +application. It should be set to ``1`` for the static MFC library, and ``2`` for the shared MFC library. This is used in Visual Studio 6 and 7 -project files. The CMakeSetup dialog used MFC and the CMakeLists.txt +project files. The CMakeSetup dialog used MFC and the ``CMakeLists.txt`` looks like this: :: diff --git a/Help/variable/CMAKE_MINIMUM_REQUIRED_VERSION.rst b/Help/variable/CMAKE_MINIMUM_REQUIRED_VERSION.rst index 351de44..5a51634 100644 --- a/Help/variable/CMAKE_MINIMUM_REQUIRED_VERSION.rst +++ b/Help/variable/CMAKE_MINIMUM_REQUIRED_VERSION.rst @@ -1,7 +1,7 @@ CMAKE_MINIMUM_REQUIRED_VERSION ------------------------------ -Version specified to cmake_minimum_required command +Version specified to :command:`cmake_minimum_required` command -Variable containing the VERSION component specified in the -cmake_minimum_required command. +Variable containing the ``VERSION`` component specified in the +:command:`cmake_minimum_required` command. diff --git a/Help/variable/CMAKE_MODULE_LINKER_FLAGS_CONFIG.rst b/Help/variable/CMAKE_MODULE_LINKER_FLAGS_CONFIG.rst index 87a1901..393263e 100644 --- a/Help/variable/CMAKE_MODULE_LINKER_FLAGS_CONFIG.rst +++ b/Help/variable/CMAKE_MODULE_LINKER_FLAGS_CONFIG.rst @@ -3,4 +3,4 @@ CMAKE_MODULE_LINKER_FLAGS_ Flags to be used when linking a module. -Same as CMAKE_C_FLAGS_* but used by the linker when creating modules. +Same as ``CMAKE_C_FLAGS_*`` but used by the linker when creating modules. diff --git a/Help/variable/CMAKE_NOT_USING_CONFIG_FLAGS.rst b/Help/variable/CMAKE_NOT_USING_CONFIG_FLAGS.rst index cbe0350..98960c5 100644 --- a/Help/variable/CMAKE_NOT_USING_CONFIG_FLAGS.rst +++ b/Help/variable/CMAKE_NOT_USING_CONFIG_FLAGS.rst @@ -1,7 +1,7 @@ CMAKE_NOT_USING_CONFIG_FLAGS ---------------------------- -Skip _BUILD_TYPE flags if true. +Skip ``_BUILD_TYPE`` flags if true. This is an internal flag used by the generators in CMake to tell CMake -to skip the _BUILD_TYPE flags. +to skip the ``_BUILD_TYPE`` flags. diff --git a/Help/variable/CMAKE_NO_SYSTEM_FROM_IMPORTED.rst b/Help/variable/CMAKE_NO_SYSTEM_FROM_IMPORTED.rst index c1919af..61e04b4 100644 --- a/Help/variable/CMAKE_NO_SYSTEM_FROM_IMPORTED.rst +++ b/Help/variable/CMAKE_NO_SYSTEM_FROM_IMPORTED.rst @@ -1,8 +1,8 @@ CMAKE_NO_SYSTEM_FROM_IMPORTED ----------------------------- -Default value for NO_SYSTEM_FROM_IMPORTED of targets. +Default value for :prop_tgt:`NO_SYSTEM_FROM_IMPORTED` of targets. -This variable is used to initialize the NO_SYSTEM_FROM_IMPORTED +This variable is used to initialize the :prop_tgt:`NO_SYSTEM_FROM_IMPORTED` property on all the targets. See that target property for additional information. diff --git a/Help/variable/CMAKE_PARENT_LIST_FILE.rst b/Help/variable/CMAKE_PARENT_LIST_FILE.rst index 5566a72..cfd8608 100644 --- a/Help/variable/CMAKE_PARENT_LIST_FILE.rst +++ b/Help/variable/CMAKE_PARENT_LIST_FILE.rst @@ -3,7 +3,7 @@ CMAKE_PARENT_LIST_FILE Full path to the CMake file that included the current one. -While processing a CMake file loaded by include() or find_package() -this variable contains the full path to the file including it. The -top of the include stack is always the CMakeLists.txt for the current -directory. See also CMAKE_CURRENT_LIST_FILE. +While processing a CMake file loaded by :command:`include` or +:command:`find_package` this variable contains the full path to the file +including it. The top of the include stack is always the ``CMakeLists.txt`` +for the current directory. See also :variable:`CMAKE_CURRENT_LIST_FILE`. diff --git a/Help/variable/CMAKE_POLICY_DEFAULT_CMPNNNN.rst b/Help/variable/CMAKE_POLICY_DEFAULT_CMPNNNN.rst index e401aa5..43582be 100644 --- a/Help/variable/CMAKE_POLICY_DEFAULT_CMPNNNN.rst +++ b/Help/variable/CMAKE_POLICY_DEFAULT_CMPNNNN.rst @@ -1,16 +1,17 @@ CMAKE_POLICY_DEFAULT_CMP ------------------------------ -Default for CMake Policy CMP when it is otherwise left unset. +Default for CMake Policy ``CMP`` when it is otherwise left unset. -Commands cmake_minimum_required(VERSION) and cmake_policy(VERSION) by -default leave policies introduced after the given version unset. Set -CMAKE_POLICY_DEFAULT_CMP to OLD or NEW to specify the default -for policy CMP, where is the policy number. +Commands :command:`cmake_minimum_required(VERSION)` and +:command:`cmake_policy(VERSION)` by default leave policies introduced after +the given version unset. Set ``CMAKE_POLICY_DEFAULT_CMP`` to ``OLD`` +or ``NEW`` to specify the default for policy ``CMP``, where ```` +is the policy number. This variable should not be set by a project in CMake code; use -cmake_policy(SET) instead. Users running CMake may set this variable -in the cache (e.g. -DCMAKE_POLICY_DEFAULT_CMP=) to set -a policy not otherwise set by the project. Set to OLD to quiet a -policy warning while using old behavior or to NEW to try building the +:command:`cmake_policy(SET)` instead. Users running CMake may set this +variable in the cache (e.g. ``-DCMAKE_POLICY_DEFAULT_CMP=``) +to set a policy not otherwise set by the project. Set to ``OLD`` to quiet a +policy warning while using old behavior or to ``NEW`` to try building the project with new behavior. diff --git a/Help/variable/CMAKE_PROJECT_NAME.rst b/Help/variable/CMAKE_PROJECT_NAME.rst index 4734705..431e9f3 100644 --- a/Help/variable/CMAKE_PROJECT_NAME.rst +++ b/Help/variable/CMAKE_PROJECT_NAME.rst @@ -4,4 +4,4 @@ CMAKE_PROJECT_NAME The name of the current project. This specifies name of the current project from the closest inherited -PROJECT command. +:command:`project` command. diff --git a/Help/variable/CMAKE_ROOT.rst b/Help/variable/CMAKE_ROOT.rst index f963a7f..1d0a8af 100644 --- a/Help/variable/CMAKE_ROOT.rst +++ b/Help/variable/CMAKE_ROOT.rst @@ -3,6 +3,6 @@ CMAKE_ROOT Install directory for running cmake. -This is the install root for the running CMake and the Modules +This is the install root for the running CMake and the ``Modules`` directory can be found here. This is commonly used in this format: -${CMAKE_ROOT}/Modules +``${CMAKE_ROOT}/Modules`` diff --git a/Help/variable/CMAKE_SCRIPT_MODE_FILE.rst b/Help/variable/CMAKE_SCRIPT_MODE_FILE.rst index ad73cc0..981af60 100644 --- a/Help/variable/CMAKE_SCRIPT_MODE_FILE.rst +++ b/Help/variable/CMAKE_SCRIPT_MODE_FILE.rst @@ -1,8 +1,9 @@ CMAKE_SCRIPT_MODE_FILE ---------------------- -Full path to the -P script file currently being processed. +Full path to the :manual:`cmake(1)` ``-P`` script file currently being +processed. -When run in -P script mode, CMake sets this variable to the full path -of the script file. When run to configure a CMakeLists.txt file, this -variable is not set. +When run in :manual:`cmake(1)` ``-P`` script mode, CMake sets this variable to +the full path of the script file. When run to configure a ``CMakeLists.txt`` +file, this variable is not set. diff --git a/Help/variable/CMAKE_SHARED_LIBRARY_PREFIX.rst b/Help/variable/CMAKE_SHARED_LIBRARY_PREFIX.rst index a863e2a..8afabaf 100644 --- a/Help/variable/CMAKE_SHARED_LIBRARY_PREFIX.rst +++ b/Help/variable/CMAKE_SHARED_LIBRARY_PREFIX.rst @@ -3,6 +3,6 @@ CMAKE_SHARED_LIBRARY_PREFIX The prefix for shared libraries that you link to. -The prefix to use for the name of a shared library, lib on UNIX. +The prefix to use for the name of a shared library, ``lib`` on UNIX. -CMAKE_SHARED_LIBRARY_PREFIX_ overrides this for language . +``CMAKE_SHARED_LIBRARY_PREFIX_`` overrides this for language ````. diff --git a/Help/variable/CMAKE_SHARED_LIBRARY_SUFFIX.rst b/Help/variable/CMAKE_SHARED_LIBRARY_SUFFIX.rst index c296ecd..1f96a32 100644 --- a/Help/variable/CMAKE_SHARED_LIBRARY_SUFFIX.rst +++ b/Help/variable/CMAKE_SHARED_LIBRARY_SUFFIX.rst @@ -3,7 +3,7 @@ CMAKE_SHARED_LIBRARY_SUFFIX The suffix for shared libraries that you link to. -The suffix to use for the end of a shared library filename, .dll on +The suffix to use for the end of a shared library filename, ``.dll`` on Windows. -CMAKE_SHARED_LIBRARY_SUFFIX_ overrides this for language . +``CMAKE_SHARED_LIBRARY_SUFFIX_`` overrides this for language ````. diff --git a/Help/variable/CMAKE_SHARED_LINKER_FLAGS_CONFIG.rst b/Help/variable/CMAKE_SHARED_LINKER_FLAGS_CONFIG.rst index fedc626..4bf87a0 100644 --- a/Help/variable/CMAKE_SHARED_LINKER_FLAGS_CONFIG.rst +++ b/Help/variable/CMAKE_SHARED_LINKER_FLAGS_CONFIG.rst @@ -3,5 +3,5 @@ CMAKE_SHARED_LINKER_FLAGS_ Flags to be used when linking a shared library. -Same as CMAKE_C_FLAGS_* but used by the linker when creating shared +Same as ``CMAKE_C_FLAGS_*`` but used by the linker when creating shared libraries. diff --git a/Help/variable/CMAKE_SHARED_MODULE_PREFIX.rst b/Help/variable/CMAKE_SHARED_MODULE_PREFIX.rst index a5a2428..d6eef98 100644 --- a/Help/variable/CMAKE_SHARED_MODULE_PREFIX.rst +++ b/Help/variable/CMAKE_SHARED_MODULE_PREFIX.rst @@ -5,4 +5,4 @@ The prefix for loadable modules that you link to. The prefix to use for the name of a loadable module on this platform. -CMAKE_SHARED_MODULE_PREFIX_ overrides this for language . +``CMAKE_SHARED_MODULE_PREFIX_`` overrides this for language ````. diff --git a/Help/variable/CMAKE_SHARED_MODULE_SUFFIX.rst b/Help/variable/CMAKE_SHARED_MODULE_SUFFIX.rst index 32a3c34..81515c3 100644 --- a/Help/variable/CMAKE_SHARED_MODULE_SUFFIX.rst +++ b/Help/variable/CMAKE_SHARED_MODULE_SUFFIX.rst @@ -6,4 +6,4 @@ The suffix for shared libraries that you link to. The suffix to use for the end of a loadable module filename on this platform -CMAKE_SHARED_MODULE_SUFFIX_ overrides this for language . +``CMAKE_SHARED_MODULE_SUFFIX_`` overrides this for language ````. diff --git a/Help/variable/CMAKE_SIZEOF_VOID_P.rst b/Help/variable/CMAKE_SIZEOF_VOID_P.rst index 98dbed6..f5464d1 100644 --- a/Help/variable/CMAKE_SIZEOF_VOID_P.rst +++ b/Help/variable/CMAKE_SIZEOF_VOID_P.rst @@ -1,8 +1,8 @@ CMAKE_SIZEOF_VOID_P ------------------- -Size of a void pointer. +Size of a ``void`` pointer. This is set to the size of a pointer on the target machine, and is determined -by a try compile. If a 64 bit size is found, then the library search -path is modified to look for 64 bit libraries first. +by a try compile. If a 64-bit size is found, then the library search +path is modified to look for 64-bit libraries first. diff --git a/Help/variable/CMAKE_SKIP_INSTALL_ALL_DEPENDENCY.rst b/Help/variable/CMAKE_SKIP_INSTALL_ALL_DEPENDENCY.rst index 33ee8a8..80a68c9 100644 --- a/Help/variable/CMAKE_SKIP_INSTALL_ALL_DEPENDENCY.rst +++ b/Help/variable/CMAKE_SKIP_INSTALL_ALL_DEPENDENCY.rst @@ -1,11 +1,11 @@ CMAKE_SKIP_INSTALL_ALL_DEPENDENCY --------------------------------- -Don't make the install target depend on the all target. +Don't make the ``install`` target depend on the ``all`` target. -By default, the "install" target depends on the "all" target. This -has the effect, that when "make install" is invoked or INSTALL is -built, first the "all" target is built, then the installation starts. -If CMAKE_SKIP_INSTALL_ALL_DEPENDENCY is set to TRUE, this dependency -is not created, so the installation process will start immediately, +By default, the ``install`` target depends on the ``all`` target. This +has the effect, that when ``make install`` is invoked or ``INSTALL`` is +built, first the ``all`` target is built, then the installation starts. +If :variable:`CMAKE_SKIP_INSTALL_ALL_DEPENDENCY` is set to ``TRUE``, this +dependency is not created, so the installation process will start immediately, independent from whether the project has been completely built or not. diff --git a/Help/variable/CMAKE_SKIP_INSTALL_RPATH.rst b/Help/variable/CMAKE_SKIP_INSTALL_RPATH.rst index f16b212..cc0ac21 100644 --- a/Help/variable/CMAKE_SKIP_INSTALL_RPATH.rst +++ b/Help/variable/CMAKE_SKIP_INSTALL_RPATH.rst @@ -11,4 +11,4 @@ always installed without RPATH, even if RPATH is enabled when building. This can be useful for example to allow running tests from the build directory with RPATH enabled before the installation step. To omit RPATH in both the build and install steps, use -CMAKE_SKIP_RPATH instead. +:variable:`CMAKE_SKIP_RPATH` instead. diff --git a/Help/variable/CMAKE_SKIP_INSTALL_RULES.rst b/Help/variable/CMAKE_SKIP_INSTALL_RULES.rst index 5eda254..44966f3 100644 --- a/Help/variable/CMAKE_SKIP_INSTALL_RULES.rst +++ b/Help/variable/CMAKE_SKIP_INSTALL_RULES.rst @@ -3,5 +3,6 @@ CMAKE_SKIP_INSTALL_RULES Whether to disable generation of installation rules. -If TRUE, cmake will neither generate installaton rules nor -will it generate cmake_install.cmake files. This variable is FALSE by default. +If ``TRUE``, cmake will neither generate installaton rules nor +will it generate ``cmake_install.cmake`` files. This variable is ``FALSE`` by +default. diff --git a/Help/variable/CMAKE_SKIP_RPATH.rst b/Help/variable/CMAKE_SKIP_RPATH.rst index c93f67f..d7ce8e4 100644 --- a/Help/variable/CMAKE_SKIP_RPATH.rst +++ b/Help/variable/CMAKE_SKIP_RPATH.rst @@ -3,8 +3,8 @@ CMAKE_SKIP_RPATH If true, do not add run time path information. -If this is set to TRUE, then the rpath information is not added to +If this is set to ``TRUE``, then the rpath information is not added to compiled executables. The default is to add rpath information if the platform supports it. This allows for easy running from the build tree. To omit RPATH in the install step, but not the build step, use -CMAKE_SKIP_INSTALL_RPATH instead. +:variable:`CMAKE_SKIP_INSTALL_RPATH` instead. diff --git a/Help/variable/CMAKE_SOURCE_DIR.rst b/Help/variable/CMAKE_SOURCE_DIR.rst index 088fa83..3df0226 100644 --- a/Help/variable/CMAKE_SOURCE_DIR.rst +++ b/Help/variable/CMAKE_SOURCE_DIR.rst @@ -5,4 +5,4 @@ The path to the top level of the source tree. This is the full path to the top level of the current CMake source tree. For an in-source build, this would be the same as -CMAKE_BINARY_DIR. +:variable:`CMAKE_BINARY_DIR`. diff --git a/Help/variable/CMAKE_STAGING_PREFIX.rst b/Help/variable/CMAKE_STAGING_PREFIX.rst index c4de7da..1310e94 100644 --- a/Help/variable/CMAKE_STAGING_PREFIX.rst +++ b/Help/variable/CMAKE_STAGING_PREFIX.rst @@ -5,9 +5,10 @@ This variable may be set to a path to install to when cross-compiling. This can be useful if the path in :variable:`CMAKE_SYSROOT` is read-only, or otherwise should remain pristine. -The CMAKE_STAGING_PREFIX location is also used as a search prefix by the ``find_*`` -commands. This can be controlled by setting the :variable:`CMAKE_FIND_NO_INSTALL_PREFIX` -variable. +The ``CMAKE_STAGING_PREFIX`` location is also used as a search prefix by the +``find_*`` commands. This can be controlled by setting the +:variable:`CMAKE_FIND_NO_INSTALL_PREFIX` variable. -If any RPATH/RUNPATH entries passed to the linker contain the CMAKE_STAGING_PREFIX, -the matching path fragments are replaced with the :variable:`CMAKE_INSTALL_PREFIX`. +If any RPATH/RUNPATH entries passed to the linker contain the +``CMAKE_STAGING_PREFIX``, the matching path fragments are replaced with the +:variable:`CMAKE_INSTALL_PREFIX`. diff --git a/Help/variable/CMAKE_STATIC_LIBRARY_PREFIX.rst b/Help/variable/CMAKE_STATIC_LIBRARY_PREFIX.rst index 0a3095d..714b5cc 100644 --- a/Help/variable/CMAKE_STATIC_LIBRARY_PREFIX.rst +++ b/Help/variable/CMAKE_STATIC_LIBRARY_PREFIX.rst @@ -3,6 +3,6 @@ CMAKE_STATIC_LIBRARY_PREFIX The prefix for static libraries that you link to. -The prefix to use for the name of a static library, lib on UNIX. +The prefix to use for the name of a static library, ``lib`` on UNIX. -CMAKE_STATIC_LIBRARY_PREFIX_ overrides this for language . +``CMAKE_STATIC_LIBRARY_PREFIX_`` overrides this for language ````. diff --git a/Help/variable/CMAKE_STATIC_LIBRARY_SUFFIX.rst b/Help/variable/CMAKE_STATIC_LIBRARY_SUFFIX.rst index 4d07671..28dc09d 100644 --- a/Help/variable/CMAKE_STATIC_LIBRARY_SUFFIX.rst +++ b/Help/variable/CMAKE_STATIC_LIBRARY_SUFFIX.rst @@ -3,7 +3,7 @@ CMAKE_STATIC_LIBRARY_SUFFIX The suffix for static libraries that you link to. -The suffix to use for the end of a static library filename, .lib on +The suffix to use for the end of a static library filename, ``.lib`` on Windows. -CMAKE_STATIC_LIBRARY_SUFFIX_ overrides this for language . +``CMAKE_STATIC_LIBRARY_SUFFIX_`` overrides this for language ````. diff --git a/Help/variable/CMAKE_STATIC_LINKER_FLAGS_CONFIG.rst b/Help/variable/CMAKE_STATIC_LINKER_FLAGS_CONFIG.rst index 6cde24d..b9f8003 100644 --- a/Help/variable/CMAKE_STATIC_LINKER_FLAGS_CONFIG.rst +++ b/Help/variable/CMAKE_STATIC_LINKER_FLAGS_CONFIG.rst @@ -3,5 +3,5 @@ CMAKE_STATIC_LINKER_FLAGS_ Flags to be used when linking a static library. -Same as CMAKE_C_FLAGS_* but used by the linker when creating static +Same as ``CMAKE_C_FLAGS_*`` but used by the linker when creating static libraries. diff --git a/Help/variable/CMAKE_SYSTEM.rst b/Help/variable/CMAKE_SYSTEM.rst index 23f5980..c7d0d8a 100644 --- a/Help/variable/CMAKE_SYSTEM.rst +++ b/Help/variable/CMAKE_SYSTEM.rst @@ -1,7 +1,7 @@ CMAKE_SYSTEM ------------ -Composit Name of OS CMake is compiling for. +Composite name of operating system CMake is compiling for. This variable is the composite of :variable:`CMAKE_SYSTEM_NAME` and :variable:`CMAKE_SYSTEM_VERSION`, e.g. diff --git a/Help/variable/CMAKE_SYSTEM_NAME.rst b/Help/variable/CMAKE_SYSTEM_NAME.rst index 189dc18..0466da4 100644 --- a/Help/variable/CMAKE_SYSTEM_NAME.rst +++ b/Help/variable/CMAKE_SYSTEM_NAME.rst @@ -1,8 +1,8 @@ CMAKE_SYSTEM_NAME ----------------- -Name of the OS CMake is building for. +Name of the operating system CMake is building for. -This is the name of the OS on which CMake is targeting. This variable -is the same as :variable:`CMAKE_HOST_SYSTEM_NAME` if you build for the +This is the name of the operating system on which CMake is targeting. This +variable is the same as :variable:`CMAKE_HOST_SYSTEM_NAME` if you build for the host system instead of the target system when cross compiling. diff --git a/Help/variable/CMAKE_SYSTEM_PROCESSOR.rst b/Help/variable/CMAKE_SYSTEM_PROCESSOR.rst index 2f5313b..09280de 100644 --- a/Help/variable/CMAKE_SYSTEM_PROCESSOR.rst +++ b/Help/variable/CMAKE_SYSTEM_PROCESSOR.rst @@ -7,4 +7,4 @@ This variable is the same as :variable:`CMAKE_HOST_SYSTEM_PROCESSOR` if you build for the host system instead of the target system when cross compiling. -* The Green Hills MULTI generator sets this to ``ARM`` by default +* The :generator:`Green Hills MULTI` generator sets this to ``ARM`` by default. diff --git a/Help/variable/CMAKE_SYSTEM_VERSION.rst b/Help/variable/CMAKE_SYSTEM_VERSION.rst index 33510bb..3b3cdc5 100644 --- a/Help/variable/CMAKE_SYSTEM_VERSION.rst +++ b/Help/variable/CMAKE_SYSTEM_VERSION.rst @@ -1,7 +1,7 @@ CMAKE_SYSTEM_VERSION -------------------- -The OS version CMake is building for. +The operating system version CMake is building for. This variable is the same as :variable:`CMAKE_HOST_SYSTEM_VERSION` if you build for the host system instead of the target system when diff --git a/Help/variable/CMAKE_TOOLCHAIN_FILE.rst b/Help/variable/CMAKE_TOOLCHAIN_FILE.rst index e1a65e1..168ee74 100644 --- a/Help/variable/CMAKE_TOOLCHAIN_FILE.rst +++ b/Help/variable/CMAKE_TOOLCHAIN_FILE.rst @@ -4,6 +4,6 @@ CMAKE_TOOLCHAIN_FILE Path to toolchain file supplied to :manual:`cmake(1)`. This variable is specified on the command line when cross-compiling with CMake. -It is the path to a file which is read early in the CMake run and which specifies -locations for compilers and toolchain utilities, and other target platform and -compiler related information. +It is the path to a file which is read early in the CMake run and which +specifies locations for compilers and toolchain utilities, and other target +platform and compiler related information. diff --git a/Help/variable/CMAKE_TRY_COMPILE_CONFIGURATION.rst b/Help/variable/CMAKE_TRY_COMPILE_CONFIGURATION.rst index a92feab..d731f02 100644 --- a/Help/variable/CMAKE_TRY_COMPILE_CONFIGURATION.rst +++ b/Help/variable/CMAKE_TRY_COMPILE_CONFIGURATION.rst @@ -1,9 +1,10 @@ CMAKE_TRY_COMPILE_CONFIGURATION ------------------------------- -Build configuration used for try_compile and try_run projects. +Build configuration used for :command:`try_compile` and :command:`try_run` +projects. -Projects built by try_compile and try_run are built synchronously -during the CMake configuration step. Therefore a specific build +Projects built by :command:`try_compile` and :command:`try_run` are built +synchronously during the CMake configuration step. Therefore a specific build configuration must be chosen even if the generated build system supports multiple configurations. diff --git a/Help/variable/CMAKE_USER_MAKE_RULES_OVERRIDE.rst b/Help/variable/CMAKE_USER_MAKE_RULES_OVERRIDE.rst index 5a4c86b..9af0d97 100644 --- a/Help/variable/CMAKE_USER_MAKE_RULES_OVERRIDE.rst +++ b/Help/variable/CMAKE_USER_MAKE_RULES_OVERRIDE.rst @@ -4,20 +4,20 @@ CMAKE_USER_MAKE_RULES_OVERRIDE Specify a CMake file that overrides platform information. CMake loads the specified file while enabling support for each -language from either the project() or enable_language() commands. It -is loaded after CMake's builtin compiler and platform information +language from either the :command:`project` or :command:`enable_language` +commands. It is loaded after CMake's builtin compiler and platform information modules have been loaded but before the information is used. The file may set platform information variables to override CMake's defaults. This feature is intended for use only in overriding information variables that must be set before CMake builds its first test project to check that the compiler for a language works. It should not be -used to load a file in cases that a normal include() will work. Use +used to load a file in cases that a normal :command:`include` will work. Use it only as a last resort for behavior that cannot be achieved any -other way. For example, one may set CMAKE_C_FLAGS_INIT to change the -default value used to initialize CMAKE_C_FLAGS before it is cached. -The override file should NOT be used to set anything that could be set -after languages are enabled, such as variables like -CMAKE_RUNTIME_OUTPUT_DIRECTORY that affect the placement of binaries. -Information set in the file will be used for try_compile and try_run -builds too. +other way. For example, one may set ``CMAKE_C_FLAGS_INIT`` to change the +default value used to initialize :variable:`CMAKE_C_FLAGS _FLAGS>` +before it is cached. The override file should NOT be used to set anything +that could be set after languages are enabled, such as variables like +:variable:`CMAKE_RUNTIME_OUTPUT_DIRECTORY` that affect the placement of +binaries. Information set in the file will be used for :command:`try_compile` +and :command:`try_run` builds too. diff --git a/Help/variable/CMAKE_USER_MAKE_RULES_OVERRIDE_LANG.rst b/Help/variable/CMAKE_USER_MAKE_RULES_OVERRIDE_LANG.rst index e6d2c68..e7139ac 100644 --- a/Help/variable/CMAKE_USER_MAKE_RULES_OVERRIDE_LANG.rst +++ b/Help/variable/CMAKE_USER_MAKE_RULES_OVERRIDE_LANG.rst @@ -1,7 +1,8 @@ CMAKE_USER_MAKE_RULES_OVERRIDE_ ------------------------------------- -Specify a CMake file that overrides platform information for . +Specify a CMake file that overrides platform information for ````. -This is a language-specific version of CMAKE_USER_MAKE_RULES_OVERRIDE -loaded only when enabling language . +This is a language-specific version of +:variable:`CMAKE_USER_MAKE_RULES_OVERRIDE` loaded only when enabling language +````. diff --git a/Help/variable/CMAKE_VERBOSE_MAKEFILE.rst b/Help/variable/CMAKE_VERBOSE_MAKEFILE.rst index 2420a25..232a2fd 100644 --- a/Help/variable/CMAKE_VERBOSE_MAKEFILE.rst +++ b/Help/variable/CMAKE_VERBOSE_MAKEFILE.rst @@ -3,7 +3,7 @@ CMAKE_VERBOSE_MAKEFILE Enable verbose output from Makefile builds. -This variable is a cache entry initialized (to FALSE) by +This variable is a cache entry initialized (to ``FALSE``) by the :command:`project` command. Users may enable the option in their local build tree to get more verbose output from Makefile builds and show each command line as it is launched. diff --git a/Help/variable/CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD.rst b/Help/variable/CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD.rst index 68f1ff6..f54472a 100644 --- a/Help/variable/CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD.rst +++ b/Help/variable/CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD.rst @@ -1,8 +1,8 @@ CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD ----------------------------------------- -Include INSTALL target to default build. +Include ``INSTALL`` target to default build. -In Visual Studio solution, by default the INSTALL target will not be part of -the default build. Setting this variable will enable the INSTALL target to be -part of the default build. +In Visual Studio solution, by default the ``INSTALL`` target will not be part +of the default build. Setting this variable will enable the ``INSTALL`` target +to be part of the default build. diff --git a/Help/variable/CMAKE_VS_INTEL_Fortran_PROJECT_VERSION.rst b/Help/variable/CMAKE_VS_INTEL_Fortran_PROJECT_VERSION.rst index 7e9d317..0be10e5 100644 --- a/Help/variable/CMAKE_VS_INTEL_Fortran_PROJECT_VERSION.rst +++ b/Help/variable/CMAKE_VS_INTEL_Fortran_PROJECT_VERSION.rst @@ -1,7 +1,7 @@ CMAKE_VS_INTEL_Fortran_PROJECT_VERSION -------------------------------------- -When generating for Visual Studio 7 or greater with the Intel Fortran -plugin installed, this specifies the .vfproj project file format +When generating for :generator:`Visual Studio 7` or greater with the Intel +Fortran plugin installed, this specifies the ``.vfproj`` project file format version. This is intended for internal use by CMake and should not be used by project code. diff --git a/Help/variable/CMAKE_VS_PLATFORM_TOOLSET.rst b/Help/variable/CMAKE_VS_PLATFORM_TOOLSET.rst index 08c6061..144a41d 100644 --- a/Help/variable/CMAKE_VS_PLATFORM_TOOLSET.rst +++ b/Help/variable/CMAKE_VS_PLATFORM_TOOLSET.rst @@ -5,6 +5,6 @@ Visual Studio Platform Toolset name. VS 10 and above use MSBuild under the hood and support multiple compiler toolchains. CMake may specify a toolset explicitly, such as -"v110" for VS 11 or "Windows7.1SDK" for 64-bit support in VS 10 +``v110`` for VS 11 or ``Windows7.1SDK`` for 64-bit support in VS 10 Express. CMake provides the name of the chosen toolset in this variable. diff --git a/Help/variable/CMAKE_WARN_DEPRECATED.rst b/Help/variable/CMAKE_WARN_DEPRECATED.rst index 2a13895..7b8533c 100644 --- a/Help/variable/CMAKE_WARN_DEPRECATED.rst +++ b/Help/variable/CMAKE_WARN_DEPRECATED.rst @@ -3,8 +3,8 @@ CMAKE_WARN_DEPRECATED Whether to issue deprecation warnings for macros and functions. -If TRUE, this can be used by macros and functions to issue deprecation -warnings. This variable is FALSE by default. +If ``TRUE``, this can be used by macros and functions to issue deprecation +warnings. This variable is ``FALSE`` by default. These warnings can be enabled with the ``-Wdeprecated`` option, or disabled with the ``-Wno-deprecated`` option, when running diff --git a/Help/variable/CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION.rst b/Help/variable/CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION.rst index f6a188d..81c1158 100644 --- a/Help/variable/CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION.rst +++ b/Help/variable/CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION.rst @@ -1,8 +1,9 @@ CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION ------------------------------------------ -Ask cmake_install.cmake script to warn each time a file with absolute INSTALL DESTINATION is encountered. +Ask ``cmake_install.cmake`` script to warn each time a file with absolute +``INSTALL DESTINATION`` is encountered. -This variable is used by CMake-generated cmake_install.cmake scripts. -If one sets this variable to ON while running the script, it may get +This variable is used by CMake-generated ``cmake_install.cmake`` scripts. +If one sets this variable to ``ON`` while running the script, it may get warning messages from the script. diff --git a/Help/variable/CMAKE_WIN32_EXECUTABLE.rst b/Help/variable/CMAKE_WIN32_EXECUTABLE.rst index 3e1e0dd..b96abba 100644 --- a/Help/variable/CMAKE_WIN32_EXECUTABLE.rst +++ b/Help/variable/CMAKE_WIN32_EXECUTABLE.rst @@ -1,7 +1,7 @@ CMAKE_WIN32_EXECUTABLE ---------------------- -Default value for WIN32_EXECUTABLE of targets. +Default value for :prop_tgt:`WIN32_EXECUTABLE` of targets. -This variable is used to initialize the WIN32_EXECUTABLE property on -all the targets. See that target property for additional information. +This variable is used to initialize the :prop_tgt:`WIN32_EXECUTABLE` property +on all the targets. See that target property for additional information. diff --git a/Help/variable/CMAKE_XCODE_ATTRIBUTE_an-attribute.rst b/Help/variable/CMAKE_XCODE_ATTRIBUTE_an-attribute.rst index 096f64e..122b9f6 100644 --- a/Help/variable/CMAKE_XCODE_ATTRIBUTE_an-attribute.rst +++ b/Help/variable/CMAKE_XCODE_ATTRIBUTE_an-attribute.rst @@ -3,8 +3,8 @@ CMAKE_XCODE_ATTRIBUTE_ Set Xcode target attributes directly. -Tell the Xcode generator to set '' to a given value in -the generated Xcode project. Ignored on other generators. +Tell the :generator:`Xcode` generator to set '' to a given value +in the generated Xcode project. Ignored on other generators. See the :prop_tgt:`XCODE_ATTRIBUTE_` target property to set attributes on a specific target. diff --git a/Help/variable/CMAKE_XCODE_PLATFORM_TOOLSET.rst b/Help/variable/CMAKE_XCODE_PLATFORM_TOOLSET.rst index f0a4841..210da52 100644 --- a/Help/variable/CMAKE_XCODE_PLATFORM_TOOLSET.rst +++ b/Help/variable/CMAKE_XCODE_PLATFORM_TOOLSET.rst @@ -3,7 +3,7 @@ CMAKE_XCODE_PLATFORM_TOOLSET Xcode compiler selection. -Xcode supports selection of a compiler from one of the installed +:generator:`Xcode` supports selection of a compiler from one of the installed toolsets. CMake provides the name of the chosen toolset in this -variable, if any is explicitly selected (e.g. via the cmake -T -option). +variable, if any is explicitly selected (e.g. via the :manual:`cmake(1)` +``-T`` option). diff --git a/Help/variable/CPACK_ABSOLUTE_DESTINATION_FILES.rst b/Help/variable/CPACK_ABSOLUTE_DESTINATION_FILES.rst index d836629..928fe45 100644 --- a/Help/variable/CPACK_ABSOLUTE_DESTINATION_FILES.rst +++ b/Help/variable/CPACK_ABSOLUTE_DESTINATION_FILES.rst @@ -1,10 +1,10 @@ CPACK_ABSOLUTE_DESTINATION_FILES -------------------------------- -List of files which have been installed using an ABSOLUTE DESTINATION path. +List of files which have been installed using an ``ABSOLUTE DESTINATION`` path. This variable is a Read-Only variable which is set internally by CPack during installation and before packaging using -CMAKE_ABSOLUTE_DESTINATION_FILES defined in cmake_install.cmake +:variable:`CMAKE_ABSOLUTE_DESTINATION_FILES` defined in ``cmake_install.cmake`` scripts. The value can be used within CPack project configuration -file and/or CPack.cmake file of generator. +file and/or ``CPack.cmake`` file of ```` generator. diff --git a/Help/variable/CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY.rst b/Help/variable/CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY.rst index e938978..6cf75e4 100644 --- a/Help/variable/CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY.rst +++ b/Help/variable/CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY.rst @@ -3,6 +3,6 @@ CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY Boolean toggle to include/exclude top level directory (component case). -Similar usage as CPACK_INCLUDE_TOPLEVEL_DIRECTORY but for the -component case. See CPACK_INCLUDE_TOPLEVEL_DIRECTORY documentation -for the detail. +Similar usage as :variable:`CPACK_INCLUDE_TOPLEVEL_DIRECTORY` but for the +component case. See :variable:`CPACK_INCLUDE_TOPLEVEL_DIRECTORY` +documentation for the detail. diff --git a/Help/variable/CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION.rst b/Help/variable/CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION.rst index 4d96385..5dad6bd 100644 --- a/Help/variable/CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION.rst +++ b/Help/variable/CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION.rst @@ -1,10 +1,11 @@ CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION ------------------------------------------- -Ask CPack to error out as soon as a file with absolute INSTALL DESTINATION is encountered. +Ask CPack to error out as soon as a file with absolute ``INSTALL DESTINATION`` +is encountered. The fatal error is emitted before the installation of the offending -file takes place. Some CPack generators, like NSIS,enforce this +file takes place. Some CPack generators, like NSIS, enforce this internally. This variable triggers the definition -ofCMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION when CPack runsVariables -common to all CPack generators +of :variable:`CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION` when CPack +runs. diff --git a/Help/variable/CPACK_INCLUDE_TOPLEVEL_DIRECTORY.rst b/Help/variable/CPACK_INCLUDE_TOPLEVEL_DIRECTORY.rst index 4f96bff..b8e9105 100644 --- a/Help/variable/CPACK_INCLUDE_TOPLEVEL_DIRECTORY.rst +++ b/Help/variable/CPACK_INCLUDE_TOPLEVEL_DIRECTORY.rst @@ -4,16 +4,17 @@ CPACK_INCLUDE_TOPLEVEL_DIRECTORY Boolean toggle to include/exclude top level directory. When preparing a package CPack installs the item under the so-called -top level directory. The purpose of is to include (set to 1 or ON or -TRUE) the top level directory in the package or not (set to 0 or OFF -or FALSE). +top level directory. The purpose of is to include (set to ``1`` or ``ON`` or +``TRUE``) the top level directory in the package or not (set to ``0`` or +``OFF`` or ``FALSE``). Each CPack generator has a built-in default value for this variable. E.g. Archive generators (ZIP, TGZ, ...) includes the top level whereas RPM or DEB don't. The user may override the default value by setting this variable. -There is a similar variable CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY -which may be used to override the behavior for the component packaging +There is a similar variable +:variable:`CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY` which may be used +to override the behavior for the component packaging case which may have different default value for historical (now backward compatibility) reason. diff --git a/Help/variable/CPACK_INSTALL_SCRIPT.rst b/Help/variable/CPACK_INSTALL_SCRIPT.rst index 59b8cd7..12a48a4 100644 --- a/Help/variable/CPACK_INSTALL_SCRIPT.rst +++ b/Help/variable/CPACK_INSTALL_SCRIPT.rst @@ -5,4 +5,4 @@ Extra CMake script provided by the user. If set this CMake script will be executed by CPack during its local [CPack-private] installation which is done right before packaging the -files. The script is not called by e.g.: make install. +files. The script is not called by e.g.: ``make install``. diff --git a/Help/variable/CPACK_PACKAGING_INSTALL_PREFIX.rst b/Help/variable/CPACK_PACKAGING_INSTALL_PREFIX.rst index f9cfa1b..f423e2e 100644 --- a/Help/variable/CPACK_PACKAGING_INSTALL_PREFIX.rst +++ b/Help/variable/CPACK_PACKAGING_INSTALL_PREFIX.rst @@ -3,11 +3,13 @@ CPACK_PACKAGING_INSTALL_PREFIX The prefix used in the built package. -Each CPack generator has a default value (like /usr). This default -value may be overwritten from the CMakeLists.txt or the cpack command -line by setting an alternative value. +Each CPack generator has a default value (like ``/usr``). This default +value may be overwritten from the ``CMakeLists.txt`` or the :manual:`cpack(1)` +command line by setting an alternative value. Example: -e.g. set(CPACK_PACKAGING_INSTALL_PREFIX "/opt") +:: -This is not the same purpose as CMAKE_INSTALL_PREFIX which is used + set(CPACK_PACKAGING_INSTALL_PREFIX "/opt") + +This is not the same purpose as :variable:`CMAKE_INSTALL_PREFIX` which is used when installing from the build tree without building a package. diff --git a/Help/variable/CPACK_SET_DESTDIR.rst b/Help/variable/CPACK_SET_DESTDIR.rst index 69d82e6..27fd355 100644 --- a/Help/variable/CPACK_SET_DESTDIR.rst +++ b/Help/variable/CPACK_SET_DESTDIR.rst @@ -1,30 +1,31 @@ CPACK_SET_DESTDIR ----------------- -Boolean toggle to make CPack use DESTDIR mechanism when packaging. +Boolean toggle to make CPack use ``DESTDIR`` mechanism when packaging. -DESTDIR means DESTination DIRectory. It is commonly used by makefile +``DESTDIR`` means DESTination DIRectory. It is commonly used by makefile users in order to install software at non-default location. It is a basic relocation mechanism that should not be used on Windows (see -CMAKE_INSTALL_PREFIX documentation). It is usually invoked like this: +:variable:`CMAKE_INSTALL_PREFIX` documentation). It is usually invoked like +this: :: make DESTDIR=/home/john install which will install the concerned software using the installation -prefix, e.g. "/usr/local" prepended with the DESTDIR value which -finally gives "/home/john/usr/local". When preparing a package, CPack +prefix, e.g. ``/usr/local`` prepended with the ``DESTDIR`` value which +finally gives ``/home/john/usr/local``. When preparing a package, CPack first installs the items to be packaged in a local (to the build tree) -directory by using the same DESTDIR mechanism. Nevertheless, if -CPACK_SET_DESTDIR is set then CPack will set DESTDIR before doing the +directory by using the same ``DESTDIR`` mechanism. Nevertheless, if +``CPACK_SET_DESTDIR`` is set then CPack will set ``DESTDIR`` before doing the local install. The most noticeable difference is that without -CPACK_SET_DESTDIR, CPack uses CPACK_PACKAGING_INSTALL_PREFIX as a -prefix whereas with CPACK_SET_DESTDIR set, CPack will use -CMAKE_INSTALL_PREFIX as a prefix. +``CPACK_SET_DESTDIR``, CPack uses :variable:`CPACK_PACKAGING_INSTALL_PREFIX` +as a prefix whereas with ``CPACK_SET_DESTDIR`` set, CPack will use +:variable:`CMAKE_INSTALL_PREFIX` as a prefix. -Manually setting CPACK_SET_DESTDIR may help (or simply be necessary) -if some install rules uses absolute DESTINATION (see CMake INSTALL -command). However, starting with CPack/CMake 2.8.3 RPM and DEB -installers tries to handle DESTDIR automatically so that it is seldom -necessary for the user to set it. +Manually setting ``CPACK_SET_DESTDIR`` may help (or simply be necessary) +if some install rules uses absolute ``DESTINATION`` (see CMake +:command:`install` command). However, starting with CPack/CMake 2.8.3 RPM +and DEB installers tries to handle ``DESTDIR`` automatically so that it is +seldom necessary for the user to set it. diff --git a/Help/variable/CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION.rst b/Help/variable/CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION.rst index 8d6f54f..3fc5cca 100644 --- a/Help/variable/CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION.rst +++ b/Help/variable/CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION.rst @@ -1,8 +1,9 @@ CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION ------------------------------------------ -Ask CPack to warn each time a file with absolute INSTALL DESTINATION is encountered. +Ask CPack to warn each time a file with absolute ``INSTALL DESTINATION`` is +encountered. This variable triggers the definition of -CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION when CPack runs -cmake_install.cmake scripts. +:variable:`CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION` when CPack runs +``cmake_install.cmake`` scripts. diff --git a/Help/variable/CTEST_COVERAGE_COMMAND.rst b/Help/variable/CTEST_COVERAGE_COMMAND.rst index a669dd7..0491d42 100644 --- a/Help/variable/CTEST_COVERAGE_COMMAND.rst +++ b/Help/variable/CTEST_COVERAGE_COMMAND.rst @@ -12,12 +12,12 @@ Java project can generate a series of XML files. The Cobertura Coverage parser expects to read the coverage data from a single XML file which contains the coverage data for all modules. -Cobertura has a program with the ability to merge given cobertura.ser files +Cobertura has a program with the ability to merge given ``cobertura.ser`` files and then another program to generate a combined XML file from the previous merged file. For command line testing, this can be done by hand prior to CTest looking for the coverage files. For script builds, set the ``CTEST_COVERAGE_COMMAND`` variable to point to a file which will -perform these same steps, such as a .sh or .bat file. +perform these same steps, such as a ``.sh`` or ``.bat`` file. .. code-block:: cmake @@ -35,17 +35,17 @@ the :command:`configure_file` command and might contain the following code: cobertura-report --datafile coberturamerge.ser --destination . \ --format xml $SourceDirs -The script uses ``find`` to capture the paths to all of the cobertura.ser files -found below the project's source directory. It keeps the list of files and -supplies it as an argument to the ``cobertura-merge`` program. The ``--datafile`` -argument signifies where the result of the merge will be kept. +The script uses ``find`` to capture the paths to all of the ``cobertura.ser`` +files found below the project's source directory. It keeps the list of files +and supplies it as an argument to the ``cobertura-merge`` program. The +``--datafile`` argument signifies where the result of the merge will be kept. The combined ``coberturamerge.ser`` file is then used to generate the XML report -using the ``cobertura-report`` program. The call to the cobertura-report program -requires some named arguments. +using the ``cobertura-report`` program. The call to the cobertura-report +program requires some named arguments. ``--datafila`` - path to the merged .ser file + path to the merged ``.ser`` file ``--destination`` path to put the output files(s) @@ -54,7 +54,7 @@ requires some named arguments. file format to write output in: xml or html The rest of the supplied arguments consist of the full paths to the -/src/main/java directories of each module within the souce tree. These +``/src/main/java`` directories of each module within the souce tree. These directories are needed and should not be forgotten. .. _`Cobertura`: http://cobertura.github.io/cobertura/ diff --git a/Help/variable/CTEST_MEMORYCHECK_TYPE.rst b/Help/variable/CTEST_MEMORYCHECK_TYPE.rst index f1087c0..b963293 100644 --- a/Help/variable/CTEST_MEMORYCHECK_TYPE.rst +++ b/Help/variable/CTEST_MEMORYCHECK_TYPE.rst @@ -3,5 +3,6 @@ CTEST_MEMORYCHECK_TYPE Specify the CTest ``MemoryCheckType`` setting in a :manual:`ctest(1)` dashboard client script. -Valid values are Valgrind, Purify, BoundsChecker, and ThreadSanitizer, -AddressSanitizer, MemorySanitizer, and UndefinedBehaviorSanitizer. +Valid values are ``Valgrind``, ``Purify``, ``BoundsChecker``, and +``ThreadSanitizer``, ``AddressSanitizer``, ``MemorySanitizer``, and +``UndefinedBehaviorSanitizer``. diff --git a/Help/variable/CYGWIN.rst b/Help/variable/CYGWIN.rst index c168878..0039e07 100644 --- a/Help/variable/CYGWIN.rst +++ b/Help/variable/CYGWIN.rst @@ -1,6 +1,6 @@ CYGWIN ------ -True for Cygwin. +``True`` for Cygwin. -Set to true when using Cygwin. +Set to ``true`` when using Cygwin. diff --git a/Help/variable/ENV.rst b/Help/variable/ENV.rst index 977afc3..368152a 100644 --- a/Help/variable/ENV.rst +++ b/Help/variable/ENV.rst @@ -3,5 +3,5 @@ ENV Access environment variables. -Use the syntax $ENV{VAR} to read environment variable VAR. See also -the set() command to set ENV{VAR}. +Use the syntax ``$ENV{VAR}`` to read environment variable ``VAR``. See also +the :command:`set` command to set ``ENV{VAR}``. diff --git a/Help/variable/EXECUTABLE_OUTPUT_PATH.rst b/Help/variable/EXECUTABLE_OUTPUT_PATH.rst index 7079230..26d3e92 100644 --- a/Help/variable/EXECUTABLE_OUTPUT_PATH.rst +++ b/Help/variable/EXECUTABLE_OUTPUT_PATH.rst @@ -3,6 +3,6 @@ EXECUTABLE_OUTPUT_PATH Old executable location variable. -The target property RUNTIME_OUTPUT_DIRECTORY supercedes this variable -for a target if it is set. Executable targets are otherwise placed in +The target property :prop_tgt:`RUNTIME_OUTPUT_DIRECTORY` supercedes this +variable for a target if it is set. Executable targets are otherwise placed in this directory. diff --git a/Help/variable/LIBRARY_OUTPUT_PATH.rst b/Help/variable/LIBRARY_OUTPUT_PATH.rst index 1c1f8ae..ba02911 100644 --- a/Help/variable/LIBRARY_OUTPUT_PATH.rst +++ b/Help/variable/LIBRARY_OUTPUT_PATH.rst @@ -3,7 +3,7 @@ LIBRARY_OUTPUT_PATH Old library location variable. -The target properties ARCHIVE_OUTPUT_DIRECTORY, -LIBRARY_OUTPUT_DIRECTORY, and RUNTIME_OUTPUT_DIRECTORY supercede this -variable for a target if they are set. Library targets are otherwise -placed in this directory. +The target properties :prop_tgt:`ARCHIVE_OUTPUT_DIRECTORY`, +:prop_tgt:`LIBRARY_OUTPUT_DIRECTORY`, and :prop_tgt:`RUNTIME_OUTPUT_DIRECTORY` +supercede this variable for a target if they are set. Library targets are +otherwise placed in this directory. diff --git a/Help/variable/MINGW.rst b/Help/variable/MINGW.rst index 521d417..6d29be4 100644 --- a/Help/variable/MINGW.rst +++ b/Help/variable/MINGW.rst @@ -1,6 +1,6 @@ MINGW ----- -True when using MinGW +``True`` when using MinGW -Set to true when the compiler is some version of MinGW. +Set to ``true`` when the compiler is some version of MinGW. diff --git a/Help/variable/MSVC.rst b/Help/variable/MSVC.rst index e9f931b..913ed08 100644 --- a/Help/variable/MSVC.rst +++ b/Help/variable/MSVC.rst @@ -1,6 +1,6 @@ MSVC ---- -True when using Microsoft Visual C +``True`` when using Microsoft Visual C++. -Set to true when the compiler is some version of Microsoft Visual C. +Set to ``true`` when the compiler is some version of Microsoft Visual C++. diff --git a/Help/variable/MSVC10.rst b/Help/variable/MSVC10.rst index 894c5aa..33692ad 100644 --- a/Help/variable/MSVC10.rst +++ b/Help/variable/MSVC10.rst @@ -1,6 +1,6 @@ MSVC10 ------ -True when using Microsoft Visual C 10.0 +``True`` when using Microsoft Visual C++ 10.0 -Set to true when the compiler is version 10.0 of Microsoft Visual C. +Set to ``true`` when the compiler is version 10.0 of Microsoft Visual C++. diff --git a/Help/variable/MSVC11.rst b/Help/variable/MSVC11.rst index fe25297..3ab606d 100644 --- a/Help/variable/MSVC11.rst +++ b/Help/variable/MSVC11.rst @@ -1,6 +1,6 @@ MSVC11 ------ -True when using Microsoft Visual C 11.0 +``True`` when using Microsoft Visual C++ 11.0 -Set to true when the compiler is version 11.0 of Microsoft Visual C. +Set to ``true`` when the compiler is version 11.0 of Microsoft Visual C++. diff --git a/Help/variable/MSVC12.rst b/Help/variable/MSVC12.rst index 216d3d3..15fa64b 100644 --- a/Help/variable/MSVC12.rst +++ b/Help/variable/MSVC12.rst @@ -1,6 +1,6 @@ MSVC12 ------ -True when using Microsoft Visual C 12.0 +``True`` when using Microsoft Visual C++ 12.0. -Set to true when the compiler is version 12.0 of Microsoft Visual C. +Set to ``true`` when the compiler is version 12.0 of Microsoft Visual C++. diff --git a/Help/variable/MSVC14.rst b/Help/variable/MSVC14.rst index 33c782b..0b9125d 100644 --- a/Help/variable/MSVC14.rst +++ b/Help/variable/MSVC14.rst @@ -1,6 +1,6 @@ MSVC14 ------ -True when using Microsoft Visual C 14.0 +``True`` when using Microsoft Visual C++ 14.0. -Set to true when the compiler is version 14.0 of Microsoft Visual C. +Set to ``true`` when the compiler is version 14.0 of Microsoft Visual C++. diff --git a/Help/variable/MSVC60.rst b/Help/variable/MSVC60.rst index 572e9f4..14f09cf 100644 --- a/Help/variable/MSVC60.rst +++ b/Help/variable/MSVC60.rst @@ -1,6 +1,6 @@ MSVC60 ------ -True when using Microsoft Visual C 6.0 +``True`` when using Microsoft Visual C++ 6.0. -Set to true when the compiler is version 6.0 of Microsoft Visual C. +Set to ``true`` when the compiler is version 6.0 of Microsoft Visual C++. diff --git a/Help/variable/MSVC70.rst b/Help/variable/MSVC70.rst index b1b7a88..76fa96f 100644 --- a/Help/variable/MSVC70.rst +++ b/Help/variable/MSVC70.rst @@ -1,6 +1,6 @@ MSVC70 ------ -True when using Microsoft Visual C 7.0 +``True`` when using Microsoft Visual C++ 7.0. -Set to true when the compiler is version 7.0 of Microsoft Visual C. +Set to ``true`` when the compiler is version 7.0 of Microsoft Visual C++. diff --git a/Help/variable/MSVC71.rst b/Help/variable/MSVC71.rst index af309a6..d69d4fc 100644 --- a/Help/variable/MSVC71.rst +++ b/Help/variable/MSVC71.rst @@ -1,6 +1,6 @@ MSVC71 ------ -True when using Microsoft Visual C 7.1 +``True`` when using Microsoft Visual C++ 7.1. -Set to true when the compiler is version 7.1 of Microsoft Visual C. +Set to ``true`` when the compiler is version 7.1 of Microsoft Visual C++. diff --git a/Help/variable/MSVC80.rst b/Help/variable/MSVC80.rst index 306c67f..b17777c 100644 --- a/Help/variable/MSVC80.rst +++ b/Help/variable/MSVC80.rst @@ -1,6 +1,6 @@ MSVC80 ------ -True when using Microsoft Visual C 8.0 +``True`` when using Microsoft Visual C++ 8.0. -Set to true when the compiler is version 8.0 of Microsoft Visual C. +Set to ``true`` when the compiler is version 8.0 of Microsoft Visual C++. diff --git a/Help/variable/MSVC90.rst b/Help/variable/MSVC90.rst index 3cfcc67..7162d6c 100644 --- a/Help/variable/MSVC90.rst +++ b/Help/variable/MSVC90.rst @@ -1,6 +1,6 @@ MSVC90 ------ -True when using Microsoft Visual C 9.0 +``True`` when using Microsoft Visual C++ 9.0. -Set to true when the compiler is version 9.0 of Microsoft Visual C. +Set to ``true`` when the compiler is version 9.0 of Microsoft Visual C++. diff --git a/Help/variable/MSVC_IDE.rst b/Help/variable/MSVC_IDE.rst index 055f876..027d1bc 100644 --- a/Help/variable/MSVC_IDE.rst +++ b/Help/variable/MSVC_IDE.rst @@ -1,7 +1,7 @@ MSVC_IDE -------- -True when using the Microsoft Visual C IDE +``True`` when using the Microsoft Visual C++ IDE. -Set to true when the target platform is the Microsoft Visual C IDE, as +Set to ``true`` when the target platform is the Microsoft Visual C++ IDE, as opposed to the command line compiler. diff --git a/Help/variable/UNIX.rst b/Help/variable/UNIX.rst index 82e3454..0877b7c 100644 --- a/Help/variable/UNIX.rst +++ b/Help/variable/UNIX.rst @@ -1,7 +1,7 @@ UNIX ---- -True for UNIX and UNIX like operating systems. +``True`` for UNIX and UNIX like operating systems. -Set to true when the target system is UNIX or UNIX like (i.e. APPLE -and CYGWIN). +Set to ``true`` when the target system is UNIX or UNIX like (i.e. +:variable:`APPLE` and :variable:`CYGWIN`). diff --git a/Help/variable/WIN32.rst b/Help/variable/WIN32.rst index 8cf7bf3..2189069 100644 --- a/Help/variable/WIN32.rst +++ b/Help/variable/WIN32.rst @@ -1,6 +1,6 @@ WIN32 ----- -True on windows systems, including win64. +``True`` on Windows systems, including Win64. -Set to true when the target system is Windows. +Set to ``true`` when the target system is Windows. diff --git a/Help/variable/XCODE_VERSION.rst b/Help/variable/XCODE_VERSION.rst index b6f0403..b85d41e 100644 --- a/Help/variable/XCODE_VERSION.rst +++ b/Help/variable/XCODE_VERSION.rst @@ -1,7 +1,7 @@ XCODE_VERSION ------------- -Version of Xcode (Xcode generator only). +Version of Xcode (:generator:`Xcode` generator only). Under the Xcode generator, this is the version of Xcode as specified -in "Xcode.app/Contents/version.plist" (such as "3.1.2"). +in ``Xcode.app/Contents/version.plist`` (such as ``3.1.2``). ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From brad.king at kitware.com Fri Aug 21 09:37:17 2015 From: brad.king at kitware.com (Brad King) Date: Fri, 21 Aug 2015 09:37:17 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-895-g86bb2ce Message-ID: <20150821133717.DCBBFB1A96@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 86bb2ce75793ff12905596edc83ecabf2bce22df (commit) via 3bb707f0a1408dc0381ecbf4ec934e9f14d8927c (commit) from badde9c2a11afd8f9127f757e964d0d94c777aad (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=86bb2ce75793ff12905596edc83ecabf2bce22df commit 86bb2ce75793ff12905596edc83ecabf2bce22df Merge: badde9c 3bb707f Author: Brad King AuthorDate: Fri Aug 21 09:37:16 2015 -0400 Commit: CMake Topic Stage CommitDate: Fri Aug 21 09:37:16 2015 -0400 Merge topic 'improve-variable-help-formatting' 3bb707f0 Help: Improve formatting of variable documentation ----------------------------------------------------------------------- Summary of changes: Help/manual/cmake.1.rst | 2 ++ Help/variable/APPLE.rst | 4 +-- Help/variable/BORLAND.rst | 4 +-- Help/variable/BUILD_SHARED_LIBS.rst | 6 ++-- Help/variable/CMAKE_ABSOLUTE_DESTINATION_FILES.rst | 4 +-- .../CMAKE_ANDROID_NATIVE_LIB_DEPENDENCIES.rst | 4 +-- .../CMAKE_ANDROID_NATIVE_LIB_DIRECTORIES.rst | 4 +-- Help/variable/CMAKE_ARGC.rst | 5 ++-- Help/variable/CMAKE_ARGV0.rst | 8 ++--- Help/variable/CMAKE_AUTOMOC_RELAXED_MODE.rst | 12 ++++---- Help/variable/CMAKE_AUTORCC.rst | 4 +-- Help/variable/CMAKE_AUTOUIC.rst | 4 +-- Help/variable/CMAKE_BINARY_DIR.rst | 2 +- Help/variable/CMAKE_BUILD_TYPE.rst | 25 ++++++++-------- Help/variable/CMAKE_BUILD_WITH_INSTALL_RPATH.rst | 10 +++---- Help/variable/CMAKE_CACHEFILE_DIR.rst | 6 ++-- Help/variable/CMAKE_CACHE_MAJOR_VERSION.rst | 2 +- Help/variable/CMAKE_CACHE_MINOR_VERSION.rst | 2 +- Help/variable/CMAKE_CACHE_PATCH_VERSION.rst | 2 +- Help/variable/CMAKE_CFG_INTDIR.rst | 21 ++++++------- Help/variable/CMAKE_CL_64.rst | 4 +-- Help/variable/CMAKE_COLOR_MAKEFILE.rst | 4 +-- Help/variable/CMAKE_COMMAND.rst | 8 ++--- Help/variable/CMAKE_COMPILER_IS_GNULANG.rst | 6 ++-- Help/variable/CMAKE_CONFIGURATION_TYPES.rst | 6 ++-- Help/variable/CMAKE_CONFIG_POSTFIX.rst | 6 ++-- Help/variable/CMAKE_CTEST_COMMAND.rst | 8 ++--- Help/variable/CMAKE_CURRENT_BINARY_DIR.rst | 2 +- Help/variable/CMAKE_CURRENT_LIST_DIR.rst | 6 ++-- Help/variable/CMAKE_CURRENT_LIST_FILE.rst | 2 +- Help/variable/CMAKE_CXX_COMPILE_FEATURES.rst | 4 +-- Help/variable/CMAKE_CXX_EXTENSIONS.rst | 2 +- Help/variable/CMAKE_CXX_STANDARD.rst | 2 +- Help/variable/CMAKE_CXX_STANDARD_REQUIRED.rst | 2 +- Help/variable/CMAKE_C_COMPILE_FEATURES.rst | 4 +-- Help/variable/CMAKE_C_EXTENSIONS.rst | 2 +- Help/variable/CMAKE_C_STANDARD.rst | 2 +- Help/variable/CMAKE_C_STANDARD_REQUIRED.rst | 2 +- Help/variable/CMAKE_DEBUG_POSTFIX.rst | 4 +-- Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst | 6 ++-- .../CMAKE_DISABLE_FIND_PACKAGE_PackageName.rst | 9 +++--- Help/variable/CMAKE_DL_LIBS.rst | 6 ++-- Help/variable/CMAKE_EDIT_COMMAND.rst | 6 ++-- Help/variable/CMAKE_ERROR_DEPRECATED.rst | 4 +-- ...CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION.rst | 5 ++-- Help/variable/CMAKE_EXECUTABLE_SUFFIX.rst | 4 +-- Help/variable/CMAKE_EXE_LINKER_FLAGS_CONFIG.rst | 2 +- Help/variable/CMAKE_EXTRA_GENERATOR.rst | 9 +++--- .../CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES.rst | 2 +- Help/variable/CMAKE_FIND_LIBRARY_PREFIXES.rst | 6 ++-- Help/variable/CMAKE_FIND_LIBRARY_SUFFIXES.rst | 6 ++-- Help/variable/CMAKE_FIND_NO_INSTALL_PREFIX.rst | 6 ++-- .../variable/CMAKE_FIND_PACKAGE_WARN_NO_MODULE.rst | 18 ++++++------ Help/variable/CMAKE_FIND_ROOT_PATH.rst | 4 +-- Help/variable/CMAKE_Fortran_FORMAT.rst | 6 ++-- Help/variable/CMAKE_Fortran_MODDIR_DEFAULT.rst | 6 ++-- Help/variable/CMAKE_Fortran_MODDIR_FLAG.rst | 2 +- Help/variable/CMAKE_Fortran_MODOUT_FLAG.rst | 2 +- Help/variable/CMAKE_Fortran_MODULE_DIRECTORY.rst | 2 +- Help/variable/CMAKE_GENERATOR.rst | 4 +-- Help/variable/CMAKE_GENERATOR_PLATFORM.rst | 4 +-- Help/variable/CMAKE_GENERATOR_TOOLSET.rst | 4 +-- Help/variable/CMAKE_GNUtoMS.rst | 6 ++-- Help/variable/CMAKE_HOST_APPLE.rst | 4 +-- Help/variable/CMAKE_HOST_SYSTEM_NAME.rst | 2 +- Help/variable/CMAKE_HOST_SYSTEM_PROCESSOR.rst | 4 +-- Help/variable/CMAKE_HOST_SYSTEM_VERSION.rst | 2 +- Help/variable/CMAKE_HOST_UNIX.rst | 4 +-- Help/variable/CMAKE_HOST_WIN32.rst | 4 +-- Help/variable/CMAKE_IMPORT_LIBRARY_PREFIX.rst | 2 +- Help/variable/CMAKE_IMPORT_LIBRARY_SUFFIX.rst | 2 +- Help/variable/CMAKE_INCLUDE_CURRENT_DIR.rst | 8 ++--- .../CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE.rst | 10 ++++--- Help/variable/CMAKE_INCLUDE_DIRECTORIES_BEFORE.rst | 7 +++-- .../CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE.rst | 4 +-- .../CMAKE_INSTALL_DEFAULT_COMPONENT_NAME.rst | 8 ++--- Help/variable/CMAKE_INSTALL_NAME_DIR.rst | 6 ++-- Help/variable/CMAKE_INSTALL_PREFIX.rst | 25 ++++++++-------- Help/variable/CMAKE_INSTALL_RPATH.rst | 2 +- .../variable/CMAKE_INSTALL_RPATH_USE_LINK_PATH.rst | 6 ++-- Help/variable/CMAKE_LANG_ARCHIVE_APPEND.rst | 7 +++-- Help/variable/CMAKE_LANG_ARCHIVE_CREATE.rst | 7 +++-- Help/variable/CMAKE_LANG_ARCHIVE_FINISH.rst | 7 +++-- Help/variable/CMAKE_LANG_COMPILER.rst | 4 +-- .../CMAKE_LANG_COMPILER_EXTERNAL_TOOLCHAIN.rst | 6 ++-- Help/variable/CMAKE_LANG_COMPILER_LOADED.rst | 4 +-- Help/variable/CMAKE_LANG_COMPILE_OBJECT.rst | 2 +- Help/variable/CMAKE_LANG_CREATE_SHARED_LIBRARY.rst | 2 +- Help/variable/CMAKE_LANG_CREATE_SHARED_MODULE.rst | 2 +- Help/variable/CMAKE_LANG_CREATE_STATIC_LIBRARY.rst | 2 +- Help/variable/CMAKE_LANG_FLAGS.rst | 2 +- Help/variable/CMAKE_LANG_FLAGS_DEBUG.rst | 4 +-- Help/variable/CMAKE_LANG_FLAGS_MINSIZEREL.rst | 6 ++-- Help/variable/CMAKE_LANG_FLAGS_RELEASE.rst | 4 +-- Help/variable/CMAKE_LANG_FLAGS_RELWITHDEBINFO.rst | 6 ++-- .../variable/CMAKE_LANG_GHS_KERNEL_FLAGS_DEBUG.rst | 4 +-- .../CMAKE_LANG_GHS_KERNEL_FLAGS_MINSIZEREL.rst | 6 ++-- .../CMAKE_LANG_GHS_KERNEL_FLAGS_RELEASE.rst | 4 +-- .../CMAKE_LANG_GHS_KERNEL_FLAGS_RELWITHDEBINFO.rst | 6 ++-- .../CMAKE_LANG_IMPLICIT_INCLUDE_DIRECTORIES.rst | 2 +- .../CMAKE_LANG_IMPLICIT_LINK_DIRECTORIES.rst | 8 ++--- ...KE_LANG_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES.rst | 2 +- .../CMAKE_LANG_IMPLICIT_LINK_LIBRARIES.rst | 2 +- Help/variable/CMAKE_LANG_LIBRARY_ARCHITECTURE.rst | 8 ++--- Help/variable/CMAKE_LANG_LINKER_PREFERENCE.rst | 4 +-- .../CMAKE_LANG_LINKER_PREFERENCE_PROPAGATES.rst | 2 +- Help/variable/CMAKE_LANG_OUTPUT_EXTENSION.rst | 4 +-- Help/variable/CMAKE_LANG_SIMULATE_ID.rst | 4 +-- Help/variable/CMAKE_LANG_SIMULATE_VERSION.rst | 4 +-- Help/variable/CMAKE_LANG_SIZEOF_DATA_PTR.rst | 4 +-- Help/variable/CMAKE_LIBRARY_ARCHITECTURE.rst | 4 +-- Help/variable/CMAKE_LIBRARY_ARCHITECTURE_REGEX.rst | 4 +-- Help/variable/CMAKE_LIBRARY_PATH_FLAG.rst | 2 +- Help/variable/CMAKE_LINK_DEF_FILE_FLAG.rst | 4 +-- Help/variable/CMAKE_LINK_DEPENDS_NO_SHARED.rst | 2 +- Help/variable/CMAKE_LINK_INTERFACE_LIBRARIES.rst | 4 +-- Help/variable/CMAKE_LINK_LIBRARY_FLAG.rst | 2 +- Help/variable/CMAKE_LINK_LIBRARY_SUFFIX.rst | 2 +- Help/variable/CMAKE_LINK_SEARCH_END_STATIC.rst | 6 ++-- Help/variable/CMAKE_LINK_SEARCH_START_STATIC.rst | 10 +++---- Help/variable/CMAKE_MACOSX_BUNDLE.rst | 6 ++-- Help/variable/CMAKE_MAKE_PROGRAM.rst | 10 +++---- Help/variable/CMAKE_MAP_IMPORTED_CONFIG_CONFIG.rst | 8 ++--- Help/variable/CMAKE_MFC_FLAG.rst | 6 ++-- Help/variable/CMAKE_MINIMUM_REQUIRED_VERSION.rst | 6 ++-- Help/variable/CMAKE_MODULE_LINKER_FLAGS_CONFIG.rst | 2 +- Help/variable/CMAKE_NOT_USING_CONFIG_FLAGS.rst | 4 +-- Help/variable/CMAKE_NO_SYSTEM_FROM_IMPORTED.rst | 4 +-- Help/variable/CMAKE_PARENT_LIST_FILE.rst | 8 ++--- Help/variable/CMAKE_POLICY_DEFAULT_CMPNNNN.rst | 19 ++++++------ Help/variable/CMAKE_PROJECT_NAME.rst | 2 +- Help/variable/CMAKE_ROOT.rst | 4 +-- Help/variable/CMAKE_SCRIPT_MODE_FILE.rst | 9 +++--- Help/variable/CMAKE_SHARED_LIBRARY_PREFIX.rst | 4 +-- Help/variable/CMAKE_SHARED_LIBRARY_SUFFIX.rst | 4 +-- Help/variable/CMAKE_SHARED_LINKER_FLAGS_CONFIG.rst | 2 +- Help/variable/CMAKE_SHARED_MODULE_PREFIX.rst | 2 +- Help/variable/CMAKE_SHARED_MODULE_SUFFIX.rst | 2 +- Help/variable/CMAKE_SIZEOF_VOID_P.rst | 6 ++-- .../variable/CMAKE_SKIP_INSTALL_ALL_DEPENDENCY.rst | 12 ++++---- Help/variable/CMAKE_SKIP_INSTALL_RPATH.rst | 2 +- Help/variable/CMAKE_SKIP_INSTALL_RULES.rst | 5 ++-- Help/variable/CMAKE_SKIP_RPATH.rst | 4 +-- Help/variable/CMAKE_SOURCE_DIR.rst | 2 +- Help/variable/CMAKE_STAGING_PREFIX.rst | 11 +++---- Help/variable/CMAKE_STATIC_LIBRARY_PREFIX.rst | 4 +-- Help/variable/CMAKE_STATIC_LIBRARY_SUFFIX.rst | 4 +-- Help/variable/CMAKE_STATIC_LINKER_FLAGS_CONFIG.rst | 2 +- Help/variable/CMAKE_SYSTEM.rst | 2 +- Help/variable/CMAKE_SYSTEM_NAME.rst | 6 ++-- Help/variable/CMAKE_SYSTEM_PROCESSOR.rst | 2 +- Help/variable/CMAKE_SYSTEM_VERSION.rst | 2 +- Help/variable/CMAKE_TOOLCHAIN_FILE.rst | 6 ++-- Help/variable/CMAKE_TRY_COMPILE_CONFIGURATION.rst | 7 +++-- Help/variable/CMAKE_USER_MAKE_RULES_OVERRIDE.rst | 20 ++++++------- .../CMAKE_USER_MAKE_RULES_OVERRIDE_LANG.rst | 7 +++-- Help/variable/CMAKE_VERBOSE_MAKEFILE.rst | 2 +- .../CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD.rst | 8 ++--- .../CMAKE_VS_INTEL_Fortran_PROJECT_VERSION.rst | 4 +-- Help/variable/CMAKE_VS_PLATFORM_TOOLSET.rst | 2 +- Help/variable/CMAKE_WARN_DEPRECATED.rst | 4 +-- .../CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION.rst | 7 +++-- Help/variable/CMAKE_WIN32_EXECUTABLE.rst | 6 ++-- .../CMAKE_XCODE_ATTRIBUTE_an-attribute.rst | 4 +-- Help/variable/CMAKE_XCODE_PLATFORM_TOOLSET.rst | 6 ++-- Help/variable/CPACK_ABSOLUTE_DESTINATION_FILES.rst | 6 ++-- .../CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY.rst | 6 ++-- ...CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION.rst | 9 +++--- Help/variable/CPACK_INCLUDE_TOPLEVEL_DIRECTORY.rst | 11 +++---- Help/variable/CPACK_INSTALL_SCRIPT.rst | 2 +- Help/variable/CPACK_PACKAGING_INSTALL_PREFIX.rst | 12 ++++---- Help/variable/CPACK_SET_DESTDIR.rst | 31 ++++++++++---------- .../CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION.rst | 7 +++-- Help/variable/CTEST_COVERAGE_COMMAND.rst | 20 ++++++------- Help/variable/CTEST_MEMORYCHECK_TYPE.rst | 5 ++-- Help/variable/CYGWIN.rst | 4 +-- Help/variable/ENV.rst | 4 +-- Help/variable/EXECUTABLE_OUTPUT_PATH.rst | 4 +-- Help/variable/LIBRARY_OUTPUT_PATH.rst | 8 ++--- Help/variable/MINGW.rst | 4 +-- Help/variable/MSVC.rst | 4 +-- Help/variable/MSVC10.rst | 4 +-- Help/variable/MSVC11.rst | 4 +-- Help/variable/MSVC12.rst | 4 +-- Help/variable/MSVC14.rst | 4 +-- Help/variable/MSVC60.rst | 4 +-- Help/variable/MSVC70.rst | 4 +-- Help/variable/MSVC71.rst | 4 +-- Help/variable/MSVC80.rst | 4 +-- Help/variable/MSVC90.rst | 4 +-- Help/variable/MSVC_IDE.rst | 4 +-- Help/variable/UNIX.rst | 6 ++-- Help/variable/WIN32.rst | 4 +-- Help/variable/XCODE_VERSION.rst | 4 +-- 194 files changed, 537 insertions(+), 508 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Fri Aug 21 09:37:33 2015 From: brad.king at kitware.com (Brad King) Date: Fri, 21 Aug 2015 09:37:33 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2313-g393825a Message-ID: <20150821133733.08C14B1A92@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 393825a583930bd45ccdc021c918500b0ead55c5 (commit) via 86bb2ce75793ff12905596edc83ecabf2bce22df (commit) from db93f638b03edb5c72e62ec3155768d278840eca (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=393825a583930bd45ccdc021c918500b0ead55c5 commit 393825a583930bd45ccdc021c918500b0ead55c5 Merge: db93f63 86bb2ce Author: Brad King AuthorDate: Fri Aug 21 09:37:26 2015 -0400 Commit: Brad King CommitDate: Fri Aug 21 09:37:26 2015 -0400 Merge branch 'master' into next ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From brad.king at kitware.com Fri Aug 21 10:56:41 2015 From: brad.king at kitware.com (Brad King) Date: Fri, 21 Aug 2015 10:56:41 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2315-g3296f9c Message-ID: <20150821145641.6922EB18C6@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 3296f9c8f9aa1f418fd9c8b195588df7e1ddee14 (commit) via 04e708d8df71234750b3ea00e2d9ada0dd7def82 (commit) from 393825a583930bd45ccdc021c918500b0ead55c5 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3296f9c8f9aa1f418fd9c8b195588df7e1ddee14 commit 3296f9c8f9aa1f418fd9c8b195588df7e1ddee14 Merge: 393825a 04e708d Author: Brad King AuthorDate: Fri Aug 21 10:56:40 2015 -0400 Commit: CMake Topic Stage CommitDate: Fri Aug 21 10:56:40 2015 -0400 Merge topic 'drop-cmsys-std-layer' into next 04e708d8 Remove use of include from KWSys http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=04e708d8df71234750b3ea00e2d9ada0dd7def82 commit 04e708d8df71234750b3ea00e2d9ada0dd7def82 Author: Brad King AuthorDate: Fri Aug 21 10:54:57 2015 -0400 Commit: Brad King CommitDate: Fri Aug 21 10:54:57 2015 -0400 Remove use of include from KWSys We no longer need this compatibility layer for the compilers we support. diff --git a/Source/cmStandardIncludes.h b/Source/cmStandardIncludes.h index a9796b9..468a589 100644 --- a/Source/cmStandardIncludes.h +++ b/Source/cmStandardIncludes.h @@ -33,14 +33,6 @@ // Provide fixed-size integer types. #include -// Include stream compatibility layer from KWSys. -// This is needed to work with large file support -// on some platforms whose stream operators do not -// support the large integer types. -#if defined(CMAKE_BUILD_WITH_CMAKE) -# include -#endif - #include #include #include ----------------------------------------------------------------------- Summary of changes: Source/cmStandardIncludes.h | 8 -------- 1 file changed, 8 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Fri Aug 21 13:48:06 2015 From: brad.king at kitware.com (Brad King) Date: Fri, 21 Aug 2015 13:48:06 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2317-g73b5206 Message-ID: <20150821174806.71BA2B0F24@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 73b5206f39e5e85314184ddc7c1f84a9b3dd7999 (commit) via 2c52ad3b97745c24abaff1fbe1005cefed58b7b3 (commit) from 3296f9c8f9aa1f418fd9c8b195588df7e1ddee14 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=73b5206f39e5e85314184ddc7c1f84a9b3dd7999 commit 73b5206f39e5e85314184ddc7c1f84a9b3dd7999 Merge: 3296f9c 2c52ad3 Author: Brad King AuthorDate: Fri Aug 21 13:48:05 2015 -0400 Commit: CMake Topic Stage CommitDate: Fri Aug 21 13:48:05 2015 -0400 Merge topic 'fix-include_directories-BEFORE' into next 2c52ad3b include_directories: Fix regression in BEFORE option (#15693) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2c52ad3b97745c24abaff1fbe1005cefed58b7b3 commit 2c52ad3b97745c24abaff1fbe1005cefed58b7b3 Author: Brad King AuthorDate: Fri Aug 21 13:42:04 2015 -0400 Commit: Brad King CommitDate: Fri Aug 21 13:47:53 2015 -0400 include_directories: Fix regression in BEFORE option (#15693) Refactoring in commit 6ed9c7e0 (cmState: Host buildsystem properties for directories, 2015-07-18) broke include_directories(BEFORE). Fix it and add a test case. diff --git a/Source/cmState.cxx b/Source/cmState.cxx index f425861..81c7275 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -1311,7 +1311,7 @@ void cmState::Directory::PrependIncludeDirectoriesEntry( this->DirectoryState->IncludeDirectoryBacktraces.begin() + std::distance(entryBegin, entryIt); - this->DirectoryState->IncludeDirectories.insert(rbegin.base(), vec); + this->DirectoryState->IncludeDirectories.insert(entryIt, vec); this->DirectoryState->IncludeDirectoryBacktraces.insert(btIt, lfbt); this->Snapshot_.Position->IncludeDirectoryPosition = diff --git a/Tests/RunCMake/include_directories/DirectoryBefore-stdout.txt b/Tests/RunCMake/include_directories/DirectoryBefore-stdout.txt new file mode 100644 index 0000000..e986082 --- /dev/null +++ b/Tests/RunCMake/include_directories/DirectoryBefore-stdout.txt @@ -0,0 +1 @@ +-- INCLUDE_DIRECTORIES: '[^;]*/Tests/RunCMake/include_directories/BeforeDir;[^;]*/Tests/RunCMake/include_directories/AfterDir' diff --git a/Tests/RunCMake/include_directories/DirectoryBefore.cmake b/Tests/RunCMake/include_directories/DirectoryBefore.cmake new file mode 100644 index 0000000..be3f663 --- /dev/null +++ b/Tests/RunCMake/include_directories/DirectoryBefore.cmake @@ -0,0 +1,4 @@ +include_directories(AfterDir) +include_directories(BEFORE BeforeDir) +get_property(dirs DIRECTORY PROPERTY INCLUDE_DIRECTORIES) +message(STATUS "INCLUDE_DIRECTORIES: '${dirs}'") diff --git a/Tests/RunCMake/include_directories/RunCMakeTest.cmake b/Tests/RunCMake/include_directories/RunCMakeTest.cmake index 54d5e97..57e8274 100644 --- a/Tests/RunCMake/include_directories/RunCMakeTest.cmake +++ b/Tests/RunCMake/include_directories/RunCMakeTest.cmake @@ -5,6 +5,7 @@ set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/NotDefa run_cmake(NotFoundContent) run_cmake(DebugIncludes) +run_cmake(DirectoryBefore) run_cmake(TID-bad-target) run_cmake(ImportedTarget) run_cmake(CMP0021) ----------------------------------------------------------------------- Summary of changes: Source/cmState.cxx | 2 +- Tests/RunCMake/include_directories/DirectoryBefore-stdout.txt | 1 + Tests/RunCMake/include_directories/DirectoryBefore.cmake | 4 ++++ Tests/RunCMake/include_directories/RunCMakeTest.cmake | 1 + 4 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 Tests/RunCMake/include_directories/DirectoryBefore-stdout.txt create mode 100644 Tests/RunCMake/include_directories/DirectoryBefore.cmake hooks/post-receive -- CMake From gjasny at googlemail.com Fri Aug 21 14:00:27 2015 From: gjasny at googlemail.com (Gregor Jasny) Date: Fri, 21 Aug 2015 14:00:27 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2319-g524481c Message-ID: <20150821180030.14313B183A@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 524481c809df3cb7b962af97ba1c9078dc5884c3 (commit) via 6819c083c3617d2a255c728fc0564306bdd15631 (commit) from 73b5206f39e5e85314184ddc7c1f84a9b3dd7999 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=524481c809df3cb7b962af97ba1c9078dc5884c3 commit 524481c809df3cb7b962af97ba1c9078dc5884c3 Merge: 73b5206 6819c08 Author: Gregor Jasny AuthorDate: Fri Aug 21 14:00:26 2015 -0400 Commit: CMake Topic Stage CommitDate: Fri Aug 21 14:00:26 2015 -0400 Merge topic 'ios-app-bundle-layout' into next 6819c083 fixup! Fix iOS Bundle layouts (#15669) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6819c083c3617d2a255c728fc0564306bdd15631 commit 6819c083c3617d2a255c728fc0564306bdd15631 Author: Gregor Jasny AuthorDate: Fri Aug 21 19:59:08 2015 +0200 Commit: Gregor Jasny CommitDate: Fri Aug 21 19:59:08 2015 +0200 fixup! Fix iOS Bundle layouts (#15669) diff --git a/Tests/RunCMake/XcodeProject/XcodeBundles.cmake b/Tests/RunCMake/XcodeProject/XcodeBundles.cmake index fdb5f11..daf230a 100644 --- a/Tests/RunCMake/XcodeProject/XcodeBundles.cmake +++ b/Tests/RunCMake/XcodeProject/XcodeBundles.cmake @@ -5,7 +5,7 @@ enable_language(C) if(TEST_IOS) set(CMAKE_OSX_SYSROOT iphoneos) - #set(CMAKE_OSX_ARCHITECTURES "i386") + set(CMAKE_OSX_ARCHITECTURES "armv7") set(CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos;-iphonesimulator") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") endif(TEST_IOS) ----------------------------------------------------------------------- Summary of changes: Tests/RunCMake/XcodeProject/XcodeBundles.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Fri Aug 21 15:11:00 2015 From: brad.king at kitware.com (Brad King) Date: Fri, 21 Aug 2015 15:11:00 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2321-g415769c Message-ID: <20150821191100.7EC88AFBCE@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 415769c967b1b583fe350dd077b1142935b04361 (commit) via 1637bd5ec532d0226b9e9c335eba853f27cd5fa2 (commit) from 524481c809df3cb7b962af97ba1c9078dc5884c3 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=415769c967b1b583fe350dd077b1142935b04361 commit 415769c967b1b583fe350dd077b1142935b04361 Merge: 524481c 1637bd5 Author: Brad King AuthorDate: Fri Aug 21 15:10:59 2015 -0400 Commit: CMake Topic Stage CommitDate: Fri Aug 21 15:10:59 2015 -0400 Merge topic 'fix-include_directories-BEFORE' into next 1637bd5e fixup! include_directories: Fix regression in BEFORE option (#15693) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1637bd5ec532d0226b9e9c335eba853f27cd5fa2 commit 1637bd5ec532d0226b9e9c335eba853f27cd5fa2 Author: Brad King AuthorDate: Fri Aug 21 15:09:21 2015 -0400 Commit: Brad King CommitDate: Fri Aug 21 15:09:21 2015 -0400 fixup! include_directories: Fix regression in BEFORE option (#15693) diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 81c7275..4ad6d3b 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -1296,15 +1296,14 @@ void cmState::Directory::PrependIncludeDirectoriesEntry( this->DirectoryState->IncludeDirectories.begin() + this->Snapshot_.Position->IncludeDirectoryPosition; - std::vector::const_reverse_iterator rend = + std::vector::reverse_iterator rend = this->DirectoryState->IncludeDirectories.rend(); std::vector::reverse_iterator rbegin = cmMakeReverseIterator(entryEnd); - std::vector::const_reverse_iterator crbegin = rbegin; - crbegin = std::find(crbegin, rend, cmPropertySentinal); + rbegin = std::find(rbegin, rend, cmPropertySentinal); - std::vector::const_iterator entryIt = crbegin.base(); - std::vector::const_iterator entryBegin = + std::vector::iterator entryIt = rbegin.base(); + std::vector::iterator entryBegin = this->DirectoryState->IncludeDirectories.begin(); std::vector::iterator btIt = ----------------------------------------------------------------------- Summary of changes: Source/cmState.cxx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Fri Aug 21 15:21:46 2015 From: brad.king at kitware.com (Brad King) Date: Fri, 21 Aug 2015 15:21:46 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2323-gc660fc3 Message-ID: <20150821192146.32C26B17D1@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via c660fc32242906a361ca99c513465278bcc0fe97 (commit) via a4bd30104fe6df3e4a6a37d0abb640a28126009d (commit) from 415769c967b1b583fe350dd077b1142935b04361 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c660fc32242906a361ca99c513465278bcc0fe97 commit c660fc32242906a361ca99c513465278bcc0fe97 Merge: 415769c a4bd301 Author: Brad King AuthorDate: Fri Aug 21 15:21:45 2015 -0400 Commit: CMake Topic Stage CommitDate: Fri Aug 21 15:21:45 2015 -0400 Merge topic 'fix-include_directories-BEFORE' into next a4bd3010 include_directories: Fix regression in BEFORE option (#15693) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a4bd30104fe6df3e4a6a37d0abb640a28126009d commit a4bd30104fe6df3e4a6a37d0abb640a28126009d Author: Brad King AuthorDate: Fri Aug 21 13:42:04 2015 -0400 Commit: Brad King CommitDate: Fri Aug 21 15:21:37 2015 -0400 include_directories: Fix regression in BEFORE option (#15693) Refactoring in commit 6ed9c7e0 (cmState: Host buildsystem properties for directories, 2015-07-18) broke include_directories(BEFORE). Fix it and add a test case. diff --git a/Source/cmState.cxx b/Source/cmState.cxx index f425861..4ad6d3b 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -1296,22 +1296,21 @@ void cmState::Directory::PrependIncludeDirectoriesEntry( this->DirectoryState->IncludeDirectories.begin() + this->Snapshot_.Position->IncludeDirectoryPosition; - std::vector::const_reverse_iterator rend = + std::vector::reverse_iterator rend = this->DirectoryState->IncludeDirectories.rend(); std::vector::reverse_iterator rbegin = cmMakeReverseIterator(entryEnd); - std::vector::const_reverse_iterator crbegin = rbegin; - crbegin = std::find(crbegin, rend, cmPropertySentinal); + rbegin = std::find(rbegin, rend, cmPropertySentinal); - std::vector::const_iterator entryIt = crbegin.base(); - std::vector::const_iterator entryBegin = + std::vector::iterator entryIt = rbegin.base(); + std::vector::iterator entryBegin = this->DirectoryState->IncludeDirectories.begin(); std::vector::iterator btIt = this->DirectoryState->IncludeDirectoryBacktraces.begin() + std::distance(entryBegin, entryIt); - this->DirectoryState->IncludeDirectories.insert(rbegin.base(), vec); + this->DirectoryState->IncludeDirectories.insert(entryIt, vec); this->DirectoryState->IncludeDirectoryBacktraces.insert(btIt, lfbt); this->Snapshot_.Position->IncludeDirectoryPosition = diff --git a/Tests/RunCMake/include_directories/DirectoryBefore-stdout.txt b/Tests/RunCMake/include_directories/DirectoryBefore-stdout.txt new file mode 100644 index 0000000..e986082 --- /dev/null +++ b/Tests/RunCMake/include_directories/DirectoryBefore-stdout.txt @@ -0,0 +1 @@ +-- INCLUDE_DIRECTORIES: '[^;]*/Tests/RunCMake/include_directories/BeforeDir;[^;]*/Tests/RunCMake/include_directories/AfterDir' diff --git a/Tests/RunCMake/include_directories/DirectoryBefore.cmake b/Tests/RunCMake/include_directories/DirectoryBefore.cmake new file mode 100644 index 0000000..be3f663 --- /dev/null +++ b/Tests/RunCMake/include_directories/DirectoryBefore.cmake @@ -0,0 +1,4 @@ +include_directories(AfterDir) +include_directories(BEFORE BeforeDir) +get_property(dirs DIRECTORY PROPERTY INCLUDE_DIRECTORIES) +message(STATUS "INCLUDE_DIRECTORIES: '${dirs}'") diff --git a/Tests/RunCMake/include_directories/RunCMakeTest.cmake b/Tests/RunCMake/include_directories/RunCMakeTest.cmake index 54d5e97..57e8274 100644 --- a/Tests/RunCMake/include_directories/RunCMakeTest.cmake +++ b/Tests/RunCMake/include_directories/RunCMakeTest.cmake @@ -5,6 +5,7 @@ set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/NotDefa run_cmake(NotFoundContent) run_cmake(DebugIncludes) +run_cmake(DirectoryBefore) run_cmake(TID-bad-target) run_cmake(ImportedTarget) run_cmake(CMP0021) ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From kwrobot at kitware.com Sat Aug 22 00:01:09 2015 From: kwrobot at kitware.com (Kitware Robot) Date: Sat, 22 Aug 2015 00:01:09 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-896-g29c1385 Message-ID: <20150822040109.AE426B158A@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 29c1385675df37146465e820d303de3cdd703e8c (commit) from 86bb2ce75793ff12905596edc83ecabf2bce22df (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=29c1385675df37146465e820d303de3cdd703e8c commit 29c1385675df37146465e820d303de3cdd703e8c Author: Kitware Robot AuthorDate: Sat Aug 22 00:01:07 2015 -0400 Commit: Kitware Robot CommitDate: Sat Aug 22 00:01:07 2015 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index e2de794..34f4282 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150821) +set(CMake_VERSION_PATCH 20150822) #set(CMake_VERSION_RC 1) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From gjasny at googlemail.com Sat Aug 22 04:31:19 2015 From: gjasny at googlemail.com (Gregor Jasny) Date: Sat, 22 Aug 2015 04:31:19 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2325-gc12be0d Message-ID: <20150822083119.D18CEB15DC@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via c12be0dce8d045b3759296f5ce0607e80820f27d (commit) via d4ab0ebf35edd9fa74ce915f6f0b23e006217fe3 (commit) from c660fc32242906a361ca99c513465278bcc0fe97 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c12be0dce8d045b3759296f5ce0607e80820f27d commit c12be0dce8d045b3759296f5ce0607e80820f27d Merge: c660fc3 d4ab0eb Author: Gregor Jasny AuthorDate: Sat Aug 22 04:31:18 2015 -0400 Commit: CMake Topic Stage CommitDate: Sat Aug 22 04:31:18 2015 -0400 Merge topic 'ios-app-bundle-layout' into next d4ab0ebf fixup! fixup! Fix iOS Bundle layouts (#15669) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d4ab0ebf35edd9fa74ce915f6f0b23e006217fe3 commit d4ab0ebf35edd9fa74ce915f6f0b23e006217fe3 Author: Gregor Jasny AuthorDate: Sat Aug 22 10:30:39 2015 +0200 Commit: Gregor Jasny CommitDate: Sat Aug 22 10:30:39 2015 +0200 fixup! fixup! Fix iOS Bundle layouts (#15669) diff --git a/Tests/RunCMake/XcodeProject/XcodeBundles.cmake b/Tests/RunCMake/XcodeProject/XcodeBundles.cmake index daf230a..d5cb51f 100644 --- a/Tests/RunCMake/XcodeProject/XcodeBundles.cmake +++ b/Tests/RunCMake/XcodeProject/XcodeBundles.cmake @@ -8,6 +8,7 @@ if(TEST_IOS) set(CMAKE_OSX_ARCHITECTURES "armv7") set(CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos;-iphonesimulator") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") + set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO") endif(TEST_IOS) # App Bundle @@ -20,16 +21,18 @@ add_custom_target(AppBundleTest ALL add_dependencies(AppBundleTest AppBundle) -# Framework +# Framework (not supported for iOS on Xcode < 6) -add_library(Framework SHARED main.c) -set_target_properties(Framework PROPERTIES FRAMEWORK TRUE) +if(NOT TEST_IOS OR NOT XCODE_VERSION VERSION_LESS 6) + add_library(Framework SHARED main.c) + set_target_properties(Framework PROPERTIES FRAMEWORK TRUE) -add_custom_target(FrameworkTest ALL - COMMAND ${CMAKE_COMMAND} -E copy - "$" "$.old") + add_custom_target(FrameworkTest ALL + COMMAND ${CMAKE_COMMAND} -E copy + "$" "$.old") -add_dependencies(FrameworkTest Framework) + add_dependencies(FrameworkTest Framework) +endif() # Bundle ----------------------------------------------------------------------- Summary of changes: Tests/RunCMake/XcodeProject/XcodeBundles.cmake | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Sun Aug 23 00:01:08 2015 From: kwrobot at kitware.com (Kitware Robot) Date: Sun, 23 Aug 2015 00:01:08 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-897-gb5f17d1 Message-ID: <20150823040108.BDFECB1685@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via b5f17d1b8038f2ed64faf4e56d3e407e7a848d52 (commit) from 29c1385675df37146465e820d303de3cdd703e8c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b5f17d1b8038f2ed64faf4e56d3e407e7a848d52 commit b5f17d1b8038f2ed64faf4e56d3e407e7a848d52 Author: Kitware Robot AuthorDate: Sun Aug 23 00:01:06 2015 -0400 Commit: Kitware Robot CommitDate: Sun Aug 23 00:01:06 2015 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 34f4282..736bc49 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150822) +set(CMake_VERSION_PATCH 20150823) #set(CMake_VERSION_RC 1) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From steveire at gmail.com Sun Aug 23 11:09:22 2015 From: steveire at gmail.com (Stephen Kelly) Date: Sun, 23 Aug 2015 11:09:22 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2335-g27ebbf3 Message-ID: <20150823150922.738452AA4@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 27ebbf3f4ed8b79fbe7c2c01c5faf43a242a52a1 (commit) via 505e1bd266469a4ed2452a333f1e40b9a4ab69d1 (commit) via 3dd1d3512061c46b8b5a5a66353bc0e8782cc5fb (commit) via 31dcb50a5166c60c65fad2bfc8a757d5c2a4aac9 (commit) via 6954c8936f52dcf7710e4b72b2e090b79bf38d1c (commit) via 1fc645bd9cffb3170743de5c983f2407eeaaa086 (commit) via 0f070dd3e12408e0e33945c3c8f585268c4b0db9 (commit) via 25e04ddffeba6d4b1c9deab1ea42038c322cec83 (commit) via 4bbe261cd34818379d06b68d2e153a98cfccfcf5 (commit) via 29c1385675df37146465e820d303de3cdd703e8c (commit) from c12be0dce8d045b3759296f5ce0607e80820f27d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=27ebbf3f4ed8b79fbe7c2c01c5faf43a242a52a1 commit 27ebbf3f4ed8b79fbe7c2c01c5faf43a242a52a1 Merge: c12be0d 505e1bd Author: Stephen Kelly AuthorDate: Sun Aug 23 11:09:20 2015 -0400 Commit: CMake Topic Stage CommitDate: Sun Aug 23 11:09:20 2015 -0400 Merge topic 'cmState-definitions' into next 505e1bd2 cmState: Reserve the number of cmLinkedTree nodes if known. 3dd1d351 cmLinkedTree: Add API for size query and reserve. 31dcb50a cmState: Host variable definitions. 6954c893 cmState: Add a VariableScope snapshot type. 1fc645bd cmState: Add a Base snapshot type. 0f070dd3 cmMakefile: Decouple the container of cmDefinitions from scoping logic. 25e04ddf cmDefinitions: Implement in terms of cmLinkedTree. 4bbe261c cmMakefile: Extract InitializeVarScope method. 29c13856 CMake Nightly Date Stamp http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=505e1bd266469a4ed2452a333f1e40b9a4ab69d1 commit 505e1bd266469a4ed2452a333f1e40b9a4ab69d1 Author: Stephen Kelly AuthorDate: Sun Jun 21 13:05:15 2015 +0200 Commit: Stephen Kelly CommitDate: Sun Aug 23 17:08:54 2015 +0200 cmState: Reserve the number of cmLinkedTree nodes if known. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index cda26cd..a19a074 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1141,6 +1141,42 @@ void cmGlobalGenerator::Configure() this->BinaryDirectories.insert( this->CMakeInstance->GetHomeOutputDirectory()); + if (const char *numStr = + this->GetCMakeInstance()->GetState() + ->GetInitializedCacheValue("CMAKE_NUMBER_OF_DEFINITION_STATES")) + { + int num = atoi(numStr); + this->GetCMakeInstance()->GetState()->ReserveDefinitions(num); + } + if (const char *numStr = + this->GetCMakeInstance()->GetState() + ->GetInitializedCacheValue("CMAKE_NUMBER_OF_SNAPSHOT_STATES")) + { + int num = atoi(numStr); + this->GetCMakeInstance()->GetState()->ReserveSnapshots(num); + } + if (const char *numStr = + this->GetCMakeInstance()->GetState() + ->GetInitializedCacheValue("CMAKE_NUMBER_OF_LISTFILE_STATES")) + { + int num = atoi(numStr); + this->GetCMakeInstance()->GetState()->ReserveListFiles(num); + } + if (const char *numStr = + this->GetCMakeInstance()->GetState() + ->GetInitializedCacheValue("CMAKE_NUMBER_OF_LOCAL_GENERATORS")) + { + int num = atoi(numStr); + this->GetCMakeInstance()->GetState()->ReserveDirectories(num); + } + if (const char *numStr = + this->GetCMakeInstance()->GetState() + ->GetInitializedCacheValue("CMAKE_NUMBER_OF_POLICY_STATES")) + { + int num = atoi(numStr); + this->GetCMakeInstance()->GetState()->ReservePolicies(num); + } + // now do it lg->GetMakefile()->Configure(); lg->GetMakefile()->EnforceDirectoryLevelRules(); @@ -1153,6 +1189,35 @@ void cmGlobalGenerator::Configure() ("CMAKE_NUMBER_OF_MAKEFILES", num, "number of local generators", cmState::INTERNAL); + { + std::ostringstream str; + str << this->GetCMakeInstance()->GetState()->DefinitionsSize(); + this->GetCMakeInstance()->AddCacheEntry + ("CMAKE_NUMBER_OF_DEFINITION_STATES", str.str().c_str(), + "number of definition states", cmState::INTERNAL); + } + { + std::ostringstream str; + str << this->GetCMakeInstance()->GetState()->SnapshotsSize(); + this->GetCMakeInstance()->AddCacheEntry + ("CMAKE_NUMBER_OF_SNAPSHOT_STATES", str.str().c_str(), + "number of snapshot states", cmState::INTERNAL); + } + { + std::ostringstream str; + str << this->GetCMakeInstance()->GetState()->ListFilesSize(); + this->GetCMakeInstance()->AddCacheEntry + ("CMAKE_NUMBER_OF_LISTFILE_STATES", str.str().c_str(), + "number of listfile states", cmState::INTERNAL); + } + { + std::ostringstream str; + str << this->GetCMakeInstance()->GetState()->PoliciesSize(); + this->GetCMakeInstance()->AddCacheEntry + ("CMAKE_NUMBER_OF_POLICY_STATES", str.str().c_str(), + "number of policy states", cmState::INTERNAL); + } + // check for link libraries and include directories containing "NOTFOUND" // and for infinite loops this->CheckLocalGenerators(); diff --git a/Source/cmState.cxx b/Source/cmState.cxx index ab309ad..99a7537 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -651,6 +651,56 @@ bool cmState::UseMSYSShell() const return this->MSYSShell; } +size_t cmState::DefinitionsSize() const +{ + return this->VarTree.Size(); +} + +void cmState::ReserveDefinitions(size_t amount) +{ + this->VarTree.Reserve(amount); +} + +size_t cmState::SnapshotsSize() const +{ + return this->SnapshotData.Size(); +} + +void cmState::ReserveSnapshots(size_t amount) +{ + this->SnapshotData.Reserve(amount); +} + +size_t cmState::ListFilesSize() const +{ + return this->ExecutionListFiles.Size(); +} + +void cmState::ReserveListFiles(size_t amount) +{ + this->ExecutionListFiles.Reserve(amount); +} + +size_t cmState::DirectoriesSize() const +{ + return this->BuildsystemDirectory.Size(); +} + +void cmState::ReserveDirectories(size_t amount) +{ + this->BuildsystemDirectory.Reserve(amount); +} + +size_t cmState::PoliciesSize() const +{ + return this->PolicyStack.Size(); +} + +void cmState::ReservePolicies(size_t amount) +{ + this->PolicyStack.Reserve(amount); +} + const char* cmState::GetBinaryDirectory() const { return this->BinaryDirectory.c_str(); diff --git a/Source/cmState.h b/Source/cmState.h index 5499665..8380587 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -270,6 +270,21 @@ public: void SetMSYSShell(bool mSYSShell); bool UseMSYSShell() const; + size_t DefinitionsSize() const; + void ReserveDefinitions(size_t amount); + + size_t SnapshotsSize() const; + void ReserveSnapshots(size_t amount); + + size_t ListFilesSize() const; + void ReserveListFiles(size_t amount); + + size_t DirectoriesSize() const; + void ReserveDirectories(size_t amount); + + size_t PoliciesSize() const; + void ReservePolicies(size_t amount); + private: std::map PropertyDefinitions; std::vector EnabledLanguages; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3dd1d3512061c46b8b5a5a66353bc0e8782cc5fb commit 3dd1d3512061c46b8b5a5a66353bc0e8782cc5fb Author: Stephen Kelly AuthorDate: Sun Jun 21 13:04:43 2015 +0200 Commit: Stephen Kelly CommitDate: Sun Aug 23 17:08:54 2015 +0200 cmLinkedTree: Add API for size query and reserve. diff --git a/Source/cmLinkedTree.h b/Source/cmLinkedTree.h index 3bcb940..385dff2 100644 --- a/Source/cmLinkedTree.h +++ b/Source/cmLinkedTree.h @@ -161,6 +161,17 @@ public: this->Data.clear(); } + size_t Size() const + { + return this->UpPositions.size(); + } + + void Reserve(size_t amount) + { + this->UpPositions.reserve(amount); + this->Data.reserve(amount); + } + private: T& GetReference(PositionType pos) { http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=31dcb50a5166c60c65fad2bfc8a757d5c2a4aac9 commit 31dcb50a5166c60c65fad2bfc8a757d5c2a4aac9 Author: Stephen Kelly AuthorDate: Sun Jun 21 21:26:43 2015 +0200 Commit: Stephen Kelly CommitDate: Sun Aug 23 17:08:54 2015 +0200 cmState: Host variable definitions. Version them through the snapshot system. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 1d02cfa..513a643 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -31,7 +31,6 @@ #endif #include "cmInstallGenerator.h" #include "cmTestGenerator.h" -#include "cmDefinitions.h" #include "cmAlgorithms.h" #include "cmake.h" #include // required for atoi @@ -47,132 +46,7 @@ class cmMakefile::Internals { public: - - enum ScopeType - { - BaseScope, - MacroScope, - FunctionScope, - VariableScope - }; - - struct VarScope - { - ScopeType Type; - cmLinkedTree::iterator Vars; - cmLinkedTree::iterator ParentScope; - }; - - cmLinkedTree VarTree; - cmLinkedTree VarScopes; - cmLinkedTree::iterator VarScopeIter; bool IsSourceFileTryCompile; - - void PushDefinitions(ScopeType scope) - { - assert(this->VarScopeIter.IsValid()); - assert(this->VarScopeIter->Vars.IsValid()); - cmLinkedTree::iterator origin = - this->VarScopeIter->Vars; - cmLinkedTree::iterator parentScope = -// this->VarTree.Extend(origin); - origin; - this->VarScopeIter->Vars = parentScope; - this->VarScopeIter = this->VarScopes.Extend(this->VarScopeIter); - this->VarScopeIter->ParentScope = parentScope; - this->VarScopeIter->Vars = this->VarTree.Extend(origin); - this->VarScopeIter->Type = scope; - } - - void InitializeVarScope() - { - assert(!this->VarScopeIter.IsValid()); - this->VarScopeIter = this->VarScopes.Extend(this->VarScopes.Root()); - this->VarScopeIter->Vars = this->VarTree.Extend(this->VarTree.Root()); - this->VarScopeIter->ParentScope = this->VarTree.Root(); - this->VarScopeIter->Type = BaseScope; - } - - void InitializeDefinitions(cmMakefile* parent) - { - assert(this->VarScopeIter.IsValid()); - assert(this->VarScopeIter->Vars.IsValid()); - *this->VarScopeIter->Vars = - cmDefinitions::MakeClosure(parent->Internal->VarScopeIter->Vars, - parent->Internal->VarTree.Root()); - } - - const char* GetDefinition(std::string const& name) - { - assert(this->VarScopeIter.IsValid()); - assert(this->VarScopeIter->Vars.IsValid()); - return cmDefinitions::Get(name, - this->VarScopeIter->Vars, this->VarTree.Root()); - } - - bool IsInitialized(std::string const& name) - { - return cmDefinitions::HasKey(name, - this->VarScopeIter->Vars, this->VarTree.Root()); - } - - void SetDefinition(std::string const& name, std::string const& value) - { - this->VarScopeIter->Vars->Set(name, value.c_str()); - } - - void RemoveDefinition(std::string const& name) - { - this->VarScopeIter->Vars->Set(name, 0); - } - - std::vector UnusedKeys() const - { - return this->VarScopeIter->Vars->UnusedKeys(); - } - - std::vector ClosureKeys() const - { - return cmDefinitions::ClosureKeys(this->VarScopeIter->Vars, - this->VarTree.Root()); - } - - void PopDefinitions() - { - ++this->VarScopeIter; - } - - bool RaiseScope(std::string const& var, const char* varDef, cmMakefile* mf) - { - assert(this->VarScopeIter->Vars != this->VarTree.Root()); - if(this->VarScopeIter->ParentScope == this->VarTree.Root()) - { - cmLocalGenerator* plg = mf->LocalGenerator->GetParent(); - if(!plg) - { - return false; - } - // Update the definition in the parent directory top scope. This - // directory's scope was initialized by the closure of the parent - // scope, so we do not need to localize the definition first. - cmMakefile* parent = plg->GetMakefile(); - if (varDef) - { - parent->AddDefinition(var, varDef); - } - else - { - parent->RemoveDefinition(var); - } - return true; - } - // First localize the definition in the current scope. - cmDefinitions::Raise(var, this->VarScopeIter->Vars, this->VarTree.Root()); - - // Now update the definition in the parent scope. - this->VarScopeIter->ParentScope->Set(var, varDef); - return true; - } }; // default is not to be building executables @@ -181,7 +55,6 @@ cmMakefile::cmMakefile(cmLocalGenerator* localGenerator) LocalGenerator(localGenerator), StateSnapshot(localGenerator->GetStateSnapshot()) { - this->Internal->InitializeVarScope(); this->Internal->IsSourceFileTryCompile = false; // Initialize these first since AddDefaultDefinitions calls AddDefinition @@ -1607,9 +1480,6 @@ void cmMakefile::AddLinkLibrary(const std::string& lib) void cmMakefile::InitializeFromParent(cmMakefile* parent) { - // Initialize definitions with the closure of the parent scope. - this->Internal->InitializeDefinitions(parent); - this->StateSnapshot.InitializeFromParent(); this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR", @@ -1674,8 +1544,6 @@ void cmMakefile::PushFunctionScope(std::string const& fileName, fileName); assert(this->StateSnapshot.IsValid()); - this->Internal->PushDefinitions(Internals::FunctionScope); - this->PushLoopBlockBarrier(); #if defined(CMAKE_BUILD_WITH_CMAKE) @@ -1702,8 +1570,6 @@ void cmMakefile::PopFunctionScope(bool reportError) this->PopLoopBlockBarrier(); this->CheckForUnusedVariables(); - - this->Internal->PopDefinitions(); } void cmMakefile::PushMacroScope(std::string const& fileName, @@ -2007,7 +1873,7 @@ void cmMakefile::AddDefinition(const std::string& name, const char* value) { this->LogUnused("changing definition", name); } - this->Internal->SetDefinition(name, value); + this->StateSnapshot.SetDefinition(name, value); #ifdef CMAKE_BUILD_WITH_CMAKE cmVariableWatch* vv = this->GetVariableWatch(); @@ -2070,7 +1936,7 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value, this->GetState()->AddCacheEntry(name, haveVal ? val.c_str() : 0, doc, type); // if there was a definition then remove it - this->Internal->RemoveDefinition(name); + this->StateSnapshot.RemoveDefinition(name); } @@ -2080,7 +1946,9 @@ void cmMakefile::AddDefinition(const std::string& name, bool value) { this->LogUnused("changing definition", name); } - this->Internal->SetDefinition(name, value ? "ON" : "OFF"); + + this->StateSnapshot.SetDefinition(name, value ? "ON" : "OFF"); + #ifdef CMAKE_BUILD_WITH_CMAKE cmVariableWatch* vv = this->GetVariableWatch(); if ( vv ) @@ -2097,7 +1965,7 @@ void cmMakefile::CheckForUnusedVariables() const { return; } - const std::vector& unused = this->Internal->UnusedKeys(); + const std::vector& unused = this->StateSnapshot.UnusedKeys(); std::vector::const_iterator it = unused.begin(); for (; it != unused.end(); ++it) { @@ -2107,12 +1975,12 @@ void cmMakefile::CheckForUnusedVariables() const void cmMakefile::MarkVariableAsUsed(const std::string& var) { - this->Internal->GetDefinition(var); + this->StateSnapshot.GetDefinition(var); } bool cmMakefile::VariableInitialized(const std::string& var) const { - return this->Internal->IsInitialized(var); + return this->StateSnapshot.IsInitialized(var); } void cmMakefile::LogUnused(const char* reason, @@ -2160,7 +2028,7 @@ void cmMakefile::RemoveDefinition(const std::string& name) { this->LogUnused("unsetting", name); } - this->Internal->RemoveDefinition(name); + this->StateSnapshot.RemoveDefinition(name); #ifdef CMAKE_BUILD_WITH_CMAKE cmVariableWatch* vv = this->GetVariableWatch(); if ( vv ) @@ -2626,7 +2494,7 @@ const char* cmMakefile::GetRequiredDefinition(const std::string& name) const bool cmMakefile::IsDefinitionSet(const std::string& name) const { - const char* def = this->Internal->GetDefinition(name); + const char* def = this->StateSnapshot.GetDefinition(name); if(!def) { def = this->GetState()->GetInitializedCacheValue(name); @@ -2647,7 +2515,7 @@ bool cmMakefile::IsDefinitionSet(const std::string& name) const const char* cmMakefile::GetDefinition(const std::string& name) const { - const char* def = this->Internal->GetDefinition(name); + const char* def = this->StateSnapshot.GetDefinition(name); if(!def) { def = this->GetState()->GetInitializedCacheValue(name); @@ -2683,7 +2551,7 @@ const char* cmMakefile::GetSafeDefinition(const std::string& def) const std::vector cmMakefile::GetDefinitions() const { - std::vector res = this->Internal->ClosureKeys(); + std::vector res = this->StateSnapshot.ClosureKeys(); std::vector cacheKeys = this->GetState()->GetCacheEntryKeys(); res.insert(res.end(), cacheKeys.begin(), cacheKeys.end()); std::sort(res.begin(), res.end()); @@ -4462,8 +4330,6 @@ std::string cmMakefile::FormatListFileStack() const void cmMakefile::PushScope() { - this->Internal->PushDefinitions(Internals::VariableScope); - std::string commandName; long line = 0; if (!this->ContextStack.empty()) @@ -4492,7 +4358,6 @@ void cmMakefile::PopScope() this->CheckForUnusedVariables(); - this->Internal->PopDefinitions(); this->StateSnapshot = this->GetState()->Pop(this->StateSnapshot); assert(this->StateSnapshot.IsValid()); @@ -4505,7 +4370,7 @@ void cmMakefile::RaiseScope(const std::string& var, const char *varDef) return; } - if (!this->Internal->RaiseScope(var, varDef, this)) + if (!this->StateSnapshot.RaiseScope(var, varDef)) { std::ostringstream m; m << "Cannot set \"" << var << "\": current scope has no parent."; diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 9e09353..ab309ad 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -15,6 +15,7 @@ #include "cmCacheManager.h" #include "cmCommand.h" #include "cmAlgorithms.h" +#include "cmDefinitions.h" #include @@ -29,6 +30,9 @@ struct cmState::SnapshotDataType cmLinkedTree::iterator ExecutionListFile; cmLinkedTree::iterator BuildSystemDirectory; + cmLinkedTree::iterator Vars; + cmLinkedTree::iterator Root; + cmLinkedTree::iterator Parent; std::string EntryPointCommand; long EntryPointLine; std::vector::size_type IncludeDirectoryPosition; @@ -275,6 +279,10 @@ cmState::Snapshot cmState::Reset() pos->PolicyScope = this->PolicyStack.Root(); assert(pos->Policies.IsValid()); assert(pos->PolicyRoot.IsValid()); + this->VarTree.Clear(); + pos->Vars = this->VarTree.Extend(this->VarTree.Root()); + pos->Parent = this->VarTree.Root(); + pos->Root = this->VarTree.Root(); this->DefineProperty ("RULE_LAUNCH_COMPILE", cmProperty::DIRECTORY, @@ -752,6 +760,10 @@ cmState::Snapshot cmState::CreateBaseSnapshot() pos->PolicyScope = this->PolicyStack.Root(); assert(pos->Policies.IsValid()); assert(pos->PolicyRoot.IsValid()); + pos->Vars = this->VarTree.Extend(this->VarTree.Root()); + assert(pos->Vars.IsValid()); + pos->Parent = this->VarTree.Root(); + pos->Root = this->VarTree.Root(); return cmState::Snapshot(this, pos); } @@ -779,6 +791,12 @@ cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot, pos->PolicyScope = originSnapshot.Position->Policies; assert(pos->Policies.IsValid()); assert(pos->PolicyRoot.IsValid()); + + cmLinkedTree::iterator origin = + originSnapshot.Position->Vars; + pos->Parent = origin; + pos->Root = origin; + pos->Vars = this->VarTree.Extend(origin); return cmState::Snapshot(this, pos); } @@ -798,6 +816,11 @@ cmState::CreateFunctionCallSnapshot(cmState::Snapshot originSnapshot, originSnapshot.Position->ExecutionListFile, fileName); pos->BuildSystemDirectory->DirectoryEnd = pos; pos->PolicyScope = originSnapshot.Position->Policies; + assert(originSnapshot.Position->Vars.IsValid()); + cmLinkedTree::iterator origin = + originSnapshot.Position->Vars; + pos->Parent = origin; + pos->Vars = this->VarTree.Extend(origin); return cmState::Snapshot(this, pos); } @@ -815,6 +838,7 @@ cmState::CreateMacroCallSnapshot(cmState::Snapshot originSnapshot, pos->SnapshotType = MacroCallType; pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile, fileName); + assert(originSnapshot.Position->Vars.IsValid()); pos->BuildSystemDirectory->DirectoryEnd = pos; pos->PolicyScope = originSnapshot.Position->Policies; return cmState::Snapshot(this, pos); @@ -833,6 +857,7 @@ cmState::CreateCallStackSnapshot(cmState::Snapshot originSnapshot, pos->SnapshotType = CallStackType; pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile, fileName); + assert(originSnapshot.Position->Vars.IsValid()); pos->BuildSystemDirectory->DirectoryEnd = pos; pos->PolicyScope = originSnapshot.Position->Policies; return cmState::Snapshot(this, pos); @@ -849,7 +874,13 @@ cmState::CreateVariableScopeSnapshot(cmState::Snapshot originSnapshot, pos->EntryPointLine = entryPointLine; pos->EntryPointCommand = entryPointCommand; pos->SnapshotType = VariableScopeType; + assert(originSnapshot.Position->Vars.IsValid()); + cmLinkedTree::iterator origin = + originSnapshot.Position->Vars; + pos->Parent = origin; + pos->Vars = this->VarTree.Extend(origin); + assert(pos->Vars.IsValid()); return cmState::Snapshot(this, pos); } @@ -1141,6 +1172,72 @@ bool cmState::Snapshot::HasDefinedPolicyCMP0011() return !this->Position->Policies->IsEmpty(); } +const char* cmState::Snapshot::GetDefinition(std::string const& name) const +{ + assert(this->Position->Vars.IsValid()); + return cmDefinitions::Get(name, this->Position->Vars, + this->Position->Root); +} + +bool cmState::Snapshot::IsInitialized(std::string const& name) const +{ + return cmDefinitions::HasKey(name, this->Position->Vars, + this->Position->Root); +} + +void cmState::Snapshot::SetDefinition(std::string const& name, + std::string const& value) +{ + this->Position->Vars->Set(name, value.c_str()); +} + +void cmState::Snapshot::RemoveDefinition(std::string const& name) +{ + this->Position->Vars->Set(name, 0); +} + +std::vector cmState::Snapshot::UnusedKeys() const +{ + return this->Position->Vars->UnusedKeys(); +} + +std::vector cmState::Snapshot::ClosureKeys() const +{ + return cmDefinitions::ClosureKeys(this->Position->Vars, + this->Position->Root); +} + +bool cmState::Snapshot::RaiseScope(std::string const& var, const char* varDef) +{ + if(this->Position->ScopeParent == this->Position->DirectoryParent) + { + Snapshot parentDir = this->GetBuildsystemDirectoryParent(); + if(!parentDir.IsValid()) + { + return false; + } + // Update the definition in the parent directory top scope. This + // directory's scope was initialized by the closure of the parent + // scope, so we do not need to localize the definition first. + if (varDef) + { + parentDir.SetDefinition(var, varDef); + } + else + { + parentDir.RemoveDefinition(var); + } + return true; + } + // First localize the definition in the current scope. + cmDefinitions::Raise(var, this->Position->Vars, + this->Position->Root); + + // Now update the definition in the parent scope. + this->Position->Parent->Set(var, varDef); + return true; +} + static const std::string cmPropertySentinal = std::string(); template @@ -1177,6 +1274,11 @@ void InitializeContentFromParent(T& parentContent, void cmState::Snapshot::InitializeFromParent() { PositionType parent = this->Position->DirectoryParent; + assert(this->Position->Vars.IsValid()); + assert(parent->Vars.IsValid()); + + *this->Position->Vars = + cmDefinitions::MakeClosure(parent->Vars, parent->Root); InitializeContentFromParent(parent->BuildSystemDirectory->IncludeDirectories, this->Position->BuildSystemDirectory->IncludeDirectories, diff --git a/Source/cmState.h b/Source/cmState.h index 4d87653..5499665 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -21,6 +21,8 @@ class cmake; class cmCommand; +class cmDefinitions; +class cmListFileBacktrace; class cmState { @@ -52,6 +54,14 @@ public: Snapshot(cmState* state = 0); Snapshot(cmState* state, PositionType position); + const char* GetDefinition(std::string const& name) const; + bool IsInitialized(std::string const& name) const; + void SetDefinition(std::string const& name, std::string const& value); + void RemoveDefinition(std::string const& name); + std::vector UnusedKeys() const; + std::vector ClosureKeys() const; + bool RaiseScope(std::string const& var, const char* varDef); + void SetListFile(std::string const& listfile); std::string GetExecutionListFile() const; @@ -273,6 +283,7 @@ private: cmLinkedTree PolicyStack; cmLinkedTree SnapshotData; + cmLinkedTree VarTree; std::vector SourceDirectoryComponents; std::vector BinaryDirectoryComponents; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6954c8936f52dcf7710e4b72b2e090b79bf38d1c commit 6954c8936f52dcf7710e4b72b2e090b79bf38d1c Author: Stephen Kelly AuthorDate: Sat Aug 1 19:41:26 2015 +0200 Commit: Stephen Kelly CommitDate: Sun Aug 23 17:08:54 2015 +0200 cmState: Add a VariableScope snapshot type. Match the scopes currently used in cmMakefile for definitions. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index aef016e..1d02cfa 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4464,6 +4464,17 @@ void cmMakefile::PushScope() { this->Internal->PushDefinitions(Internals::VariableScope); + std::string commandName; + long line = 0; + if (!this->ContextStack.empty()) + { + commandName = this->ContextStack.back()->Name; + line = this->ContextStack.back()->Line; + } + this->StateSnapshot = this->GetState()->CreateVariableScopeSnapshot( + this->StateSnapshot, + commandName, + line); this->PushLoopBlockBarrier(); #if defined(CMAKE_BUILD_WITH_CMAKE) @@ -4482,6 +4493,9 @@ void cmMakefile::PopScope() this->CheckForUnusedVariables(); this->Internal->PopDefinitions(); + this->StateSnapshot = + this->GetState()->Pop(this->StateSnapshot); + assert(this->StateSnapshot.IsValid()); } void cmMakefile::RaiseScope(const std::string& var, const char *varDef) diff --git a/Source/cmState.cxx b/Source/cmState.cxx index c777514..9e09353 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -20,6 +20,7 @@ struct cmState::SnapshotDataType { + cmState::PositionType ScopeParent; cmState::PositionType DirectoryParent; cmLinkedTree::iterator Policies; cmLinkedTree::iterator PolicyRoot; @@ -736,6 +737,7 @@ cmState::Snapshot cmState::CreateBaseSnapshot() { PositionType pos = this->SnapshotData.Extend(this->SnapshotData.Root()); pos->DirectoryParent = this->SnapshotData.Root(); + pos->ScopeParent = this->SnapshotData.Root(); pos->SnapshotType = BaseType; pos->BuildSystemDirectory = this->BuildsystemDirectory.Extend(this->BuildsystemDirectory.Root()); @@ -763,6 +765,7 @@ cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot, pos->EntryPointLine = entryPointLine; pos->EntryPointCommand = entryPointCommand; pos->DirectoryParent = originSnapshot.Position; + pos->ScopeParent = originSnapshot.Position; pos->SnapshotType = BuildsystemDirectoryType; pos->BuildSystemDirectory = this->BuildsystemDirectory.Extend( @@ -787,6 +790,7 @@ cmState::CreateFunctionCallSnapshot(cmState::Snapshot originSnapshot, { PositionType pos = this->SnapshotData.Extend(originSnapshot.Position, *originSnapshot.Position); + pos->ScopeParent = originSnapshot.Position; pos->EntryPointLine = entryPointLine; pos->EntryPointCommand = entryPointCommand; pos->SnapshotType = FunctionCallType; @@ -835,6 +839,21 @@ cmState::CreateCallStackSnapshot(cmState::Snapshot originSnapshot, } cmState::Snapshot +cmState::CreateVariableScopeSnapshot(cmState::Snapshot originSnapshot, + std::string const& entryPointCommand, + long entryPointLine) +{ + PositionType pos = this->SnapshotData.Extend(originSnapshot.Position, + *originSnapshot.Position); + pos->ScopeParent = originSnapshot.Position; + pos->EntryPointLine = entryPointLine; + pos->EntryPointCommand = entryPointCommand; + pos->SnapshotType = VariableScopeType; + + return cmState::Snapshot(this, pos); +} + +cmState::Snapshot cmState::CreateInlineListFileSnapshot(cmState::Snapshot originSnapshot, const std::string& entryPointCommand, long entryPointLine, diff --git a/Source/cmState.h b/Source/cmState.h index bc89cc8..4d87653 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -41,7 +41,8 @@ public: MacroCallType, CallStackType, InlineListFileType, - PolicyScopeType + PolicyScopeType, + VariableScopeType }; class Directory; @@ -155,6 +156,9 @@ public: std::string const& entryPointCommand, long entryPointLine, std::string const& fileName); + Snapshot CreateVariableScopeSnapshot(Snapshot originSnapshot, + std::string const& entryPointCommand, + long entryPointLine); Snapshot CreateInlineListFileSnapshot(Snapshot originSnapshot, const std::string& entryPointCommand, long entryPointLine, http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1fc645bd9cffb3170743de5c983f2407eeaaa086 commit 1fc645bd9cffb3170743de5c983f2407eeaaa086 Author: Stephen Kelly AuthorDate: Sat Aug 1 19:44:47 2015 +0200 Commit: Stephen Kelly CommitDate: Sun Aug 23 17:08:54 2015 +0200 cmState: Add a Base snapshot type. For completeness mostly. diff --git a/Source/cmState.cxx b/Source/cmState.cxx index f425861..c777514 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -736,7 +736,7 @@ cmState::Snapshot cmState::CreateBaseSnapshot() { PositionType pos = this->SnapshotData.Extend(this->SnapshotData.Root()); pos->DirectoryParent = this->SnapshotData.Root(); - pos->SnapshotType = BuildsystemDirectoryType; + pos->SnapshotType = BaseType; pos->BuildSystemDirectory = this->BuildsystemDirectory.Extend(this->BuildsystemDirectory.Root()); pos->ExecutionListFile = @@ -1019,7 +1019,8 @@ cmState::Snapshot cmState::Snapshot::GetCallStackParent() const { ++parentPos; } - if (parentPos->SnapshotType == cmState::BuildsystemDirectoryType) + if (parentPos->SnapshotType == cmState::BuildsystemDirectoryType + || parentPos->SnapshotType == cmState::BaseType) { return snapshot; } diff --git a/Source/cmState.h b/Source/cmState.h index 07aa2a5..bc89cc8 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -35,6 +35,7 @@ public: enum SnapshotType { + BaseType, BuildsystemDirectoryType, FunctionCallType, MacroCallType, http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0f070dd3e12408e0e33945c3c8f585268c4b0db9 commit 0f070dd3e12408e0e33945c3c8f585268c4b0db9 Author: Stephen Kelly AuthorDate: Sun May 31 11:26:05 2015 +0200 Commit: Stephen Kelly CommitDate: Sun Aug 23 17:08:53 2015 +0200 cmMakefile: Decouple the container of cmDefinitions from scoping logic. Maintain a Parent tree node for writing to in RaiseScope. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index afb0166..aef016e 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -47,73 +47,105 @@ class cmMakefile::Internals { public: + + enum ScopeType + { + BaseScope, + MacroScope, + FunctionScope, + VariableScope + }; + + struct VarScope + { + ScopeType Type; + cmLinkedTree::iterator Vars; + cmLinkedTree::iterator ParentScope; + }; + cmLinkedTree VarTree; - cmLinkedTree::iterator VarTreeIter; + cmLinkedTree VarScopes; + cmLinkedTree::iterator VarScopeIter; bool IsSourceFileTryCompile; - void PushDefinitions() + void PushDefinitions(ScopeType scope) { - assert(this->VarTreeIter.IsValid()); - this->VarTreeIter = this->VarTree.Extend(this->VarTreeIter); + assert(this->VarScopeIter.IsValid()); + assert(this->VarScopeIter->Vars.IsValid()); + cmLinkedTree::iterator origin = + this->VarScopeIter->Vars; + cmLinkedTree::iterator parentScope = +// this->VarTree.Extend(origin); + origin; + this->VarScopeIter->Vars = parentScope; + this->VarScopeIter = this->VarScopes.Extend(this->VarScopeIter); + this->VarScopeIter->ParentScope = parentScope; + this->VarScopeIter->Vars = this->VarTree.Extend(origin); + this->VarScopeIter->Type = scope; } void InitializeVarScope() { - this->VarTreeIter = this->VarTree.Root(); - this->PushDefinitions(); + assert(!this->VarScopeIter.IsValid()); + this->VarScopeIter = this->VarScopes.Extend(this->VarScopes.Root()); + this->VarScopeIter->Vars = this->VarTree.Extend(this->VarTree.Root()); + this->VarScopeIter->ParentScope = this->VarTree.Root(); + this->VarScopeIter->Type = BaseScope; } void InitializeDefinitions(cmMakefile* parent) { - *this->VarTreeIter = - cmDefinitions::MakeClosure(parent->Internal->VarTreeIter, + assert(this->VarScopeIter.IsValid()); + assert(this->VarScopeIter->Vars.IsValid()); + *this->VarScopeIter->Vars = + cmDefinitions::MakeClosure(parent->Internal->VarScopeIter->Vars, parent->Internal->VarTree.Root()); } const char* GetDefinition(std::string const& name) { - assert(this->VarTreeIter != this->VarTree.Root()); + assert(this->VarScopeIter.IsValid()); + assert(this->VarScopeIter->Vars.IsValid()); return cmDefinitions::Get(name, - this->VarTreeIter, this->VarTree.Root()); + this->VarScopeIter->Vars, this->VarTree.Root()); } bool IsInitialized(std::string const& name) { return cmDefinitions::HasKey(name, - this->VarTreeIter, this->VarTree.Root()); + this->VarScopeIter->Vars, this->VarTree.Root()); } void SetDefinition(std::string const& name, std::string const& value) { - this->VarTreeIter->Set(name, value.c_str()); + this->VarScopeIter->Vars->Set(name, value.c_str()); } void RemoveDefinition(std::string const& name) { - this->VarTreeIter->Set(name, 0); + this->VarScopeIter->Vars->Set(name, 0); } std::vector UnusedKeys() const { - return this->VarTreeIter->UnusedKeys(); + return this->VarScopeIter->Vars->UnusedKeys(); } std::vector ClosureKeys() const { - return cmDefinitions::ClosureKeys(this->VarTreeIter, this->VarTree.Root()); + return cmDefinitions::ClosureKeys(this->VarScopeIter->Vars, + this->VarTree.Root()); } void PopDefinitions() { - ++this->VarTreeIter; + ++this->VarScopeIter; } bool RaiseScope(std::string const& var, const char* varDef, cmMakefile* mf) { - cmLinkedTree::iterator it = this->VarTreeIter; - assert(it != this->VarTree.Root()); - ++it; - if(it == this->VarTree.Root()) + assert(this->VarScopeIter->Vars != this->VarTree.Root()); + if(this->VarScopeIter->ParentScope == this->VarTree.Root()) { cmLocalGenerator* plg = mf->LocalGenerator->GetParent(); if(!plg) @@ -135,10 +167,10 @@ public: return true; } // First localize the definition in the current scope. - cmDefinitions::Raise(var, this->VarTreeIter, this->VarTree.Root()); + cmDefinitions::Raise(var, this->VarScopeIter->Vars, this->VarTree.Root()); // Now update the definition in the parent scope. - it->Set(var, varDef); + this->VarScopeIter->ParentScope->Set(var, varDef); return true; } }; @@ -1642,7 +1674,7 @@ void cmMakefile::PushFunctionScope(std::string const& fileName, fileName); assert(this->StateSnapshot.IsValid()); - this->Internal->PushDefinitions(); + this->Internal->PushDefinitions(Internals::FunctionScope); this->PushLoopBlockBarrier(); @@ -4430,7 +4462,7 @@ std::string cmMakefile::FormatListFileStack() const void cmMakefile::PushScope() { - this->Internal->PushDefinitions(); + this->Internal->PushDefinitions(Internals::VariableScope); this->PushLoopBlockBarrier(); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=25e04ddffeba6d4b1c9deab1ea42038c322cec83 commit 25e04ddffeba6d4b1c9deab1ea42038c322cec83 Author: Stephen Kelly AuthorDate: Sat May 30 17:08:34 2015 +0200 Commit: Stephen Kelly CommitDate: Sun Aug 23 17:08:53 2015 +0200 cmDefinitions: Implement in terms of cmLinkedTree. Store the definitions in a cmLinkedTree in the cmMakefile. This can be moved to cmState and then the tree will provide snapshotting possibilities. It will also make the Closure copy created at the start of each cmMakefile unnecesarry. diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx index 2dab169..b06fb5c 100644 --- a/Source/cmDefinitions.cxx +++ b/Source/cmDefinitions.cxx @@ -56,9 +56,9 @@ void cmDefinitions::Raise(const std::string& key, } bool cmDefinitions::HasKey(const std::string& key, - StackConstIter begin, StackConstIter end) + StackIter begin, StackIter end) { - for (StackConstIter it = begin; it != end; ++it) + for (StackIter it = begin; it != end; ++it) { MapType::const_iterator i = it->Map.find(key); if (i != it->Map.end()) @@ -94,12 +94,12 @@ std::vector cmDefinitions::UnusedKeys() const } //---------------------------------------------------------------------------- -cmDefinitions cmDefinitions::MakeClosure(StackConstIter begin, - StackConstIter end) +cmDefinitions cmDefinitions::MakeClosure(StackIter begin, + StackIter end) { cmDefinitions closure; std::set undefined; - for (StackConstIter it = begin; it != end; ++it) + for (StackIter it = begin; it != end; ++it) { // Consider local definitions. for(MapType::const_iterator mi = it->Map.begin(); @@ -125,12 +125,12 @@ cmDefinitions cmDefinitions::MakeClosure(StackConstIter begin, //---------------------------------------------------------------------------- std::vector -cmDefinitions::ClosureKeys(StackConstIter begin, StackConstIter end) +cmDefinitions::ClosureKeys(StackIter begin, StackIter end) { std::set bound; std::vector defined; - for (StackConstIter it = begin; it != end; ++it) + for (StackIter it = begin; it != end; ++it) { defined.reserve(defined.size() + it->Map.size()); for(MapType::const_iterator mi = it->Map.begin(); diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h index 5fdcaab..411867c 100644 --- a/Source/cmDefinitions.h +++ b/Source/cmDefinitions.h @@ -13,6 +13,9 @@ #define cmDefinitions_h #include "cmStandardIncludes.h" + +#include "cmLinkedTree.h" + #if defined(CMAKE_BUILD_WITH_CMAKE) #ifdef CMake_HAVE_CXX11_UNORDERED_MAP #include @@ -32,26 +35,26 @@ */ class cmDefinitions { - typedef std::list::reverse_iterator StackIter; - typedef std::list::const_reverse_iterator StackConstIter; + typedef cmLinkedTree::iterator StackIter; public: static const char* Get(const std::string& key, StackIter begin, StackIter end); - static void Raise(const std::string& key, StackIter begin, StackIter end); + static void Raise(const std::string& key, + StackIter begin, StackIter end); static bool HasKey(const std::string& key, - StackConstIter begin, StackConstIter end); + StackIter begin, StackIter end); /** Set (or unset if null) a value associated with a key. */ void Set(const std::string& key, const char* value); std::vector UnusedKeys() const; - static std::vector ClosureKeys(StackConstIter begin, - StackConstIter end); + static std::vector ClosureKeys(StackIter begin, + StackIter end); - static cmDefinitions MakeClosure(StackConstIter begin, StackConstIter end); + static cmDefinitions MakeClosure(StackIter begin, StackIter end); private: // String with existence boolean. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 5b2499b..afb0166 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -47,70 +47,73 @@ class cmMakefile::Internals { public: - std::list VarStack; + cmLinkedTree VarTree; + cmLinkedTree::iterator VarTreeIter; bool IsSourceFileTryCompile; void PushDefinitions() { - this->VarStack.push_back(cmDefinitions()); + assert(this->VarTreeIter.IsValid()); + this->VarTreeIter = this->VarTree.Extend(this->VarTreeIter); } void InitializeVarScope() { + this->VarTreeIter = this->VarTree.Root(); this->PushDefinitions(); } void InitializeDefinitions(cmMakefile* parent) { - this->VarStack.back() = - cmDefinitions::MakeClosure(parent->Internal->VarStack.rbegin(), - parent->Internal->VarStack.rend()); + *this->VarTreeIter = + cmDefinitions::MakeClosure(parent->Internal->VarTreeIter, + parent->Internal->VarTree.Root()); } const char* GetDefinition(std::string const& name) { - return cmDefinitions::Get(name, this->VarStack.rbegin(), - this->VarStack.rend()); + assert(this->VarTreeIter != this->VarTree.Root()); + return cmDefinitions::Get(name, + this->VarTreeIter, this->VarTree.Root()); } bool IsInitialized(std::string const& name) { - return cmDefinitions::HasKey(name, this->VarStack.rbegin(), - this->VarStack.rend()); + return cmDefinitions::HasKey(name, + this->VarTreeIter, this->VarTree.Root()); } void SetDefinition(std::string const& name, std::string const& value) { - this->VarStack.back().Set(name, value.c_str()); + this->VarTreeIter->Set(name, value.c_str()); } void RemoveDefinition(std::string const& name) { - this->VarStack.back().Set(name, 0); + this->VarTreeIter->Set(name, 0); } std::vector UnusedKeys() const { - return this->VarStack.back().UnusedKeys(); + return this->VarTreeIter->UnusedKeys(); } std::vector ClosureKeys() const { - return cmDefinitions::ClosureKeys(this->VarStack.rbegin(), - this->VarStack.rend()); + return cmDefinitions::ClosureKeys(this->VarTreeIter, this->VarTree.Root()); } void PopDefinitions() { - this->VarStack.pop_back(); + ++this->VarTreeIter; } bool RaiseScope(std::string const& var, const char* varDef, cmMakefile* mf) { - std::list::reverse_iterator it = this->VarStack.rbegin(); - assert(it != this->VarStack.rend()); + cmLinkedTree::iterator it = this->VarTreeIter; + assert(it != this->VarTree.Root()); ++it; - if(it == this->VarStack.rend()) + if(it == this->VarTree.Root()) { cmLocalGenerator* plg = mf->LocalGenerator->GetParent(); if(!plg) @@ -132,7 +135,7 @@ public: return true; } // First localize the definition in the current scope. - cmDefinitions::Raise(var, this->VarStack.rbegin(), this->VarStack.rend()); + cmDefinitions::Raise(var, this->VarTreeIter, this->VarTree.Root()); // Now update the definition in the parent scope. it->Set(var, varDef); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4bbe261cd34818379d06b68d2e153a98cfccfcf5 commit 4bbe261cd34818379d06b68d2e153a98cfccfcf5 Author: Stephen Kelly AuthorDate: Mon Jun 8 20:04:24 2015 +0200 Commit: Stephen Kelly CommitDate: Sun Aug 23 17:08:53 2015 +0200 cmMakefile: Extract InitializeVarScope method. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 85bc493..5b2499b 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -55,6 +55,11 @@ public: this->VarStack.push_back(cmDefinitions()); } + void InitializeVarScope() + { + this->PushDefinitions(); + } + void InitializeDefinitions(cmMakefile* parent) { this->VarStack.back() = @@ -141,7 +146,7 @@ cmMakefile::cmMakefile(cmLocalGenerator* localGenerator) LocalGenerator(localGenerator), StateSnapshot(localGenerator->GetStateSnapshot()) { - this->Internal->PushDefinitions(); + this->Internal->InitializeVarScope(); this->Internal->IsSourceFileTryCompile = false; // Initialize these first since AddDefaultDefinitions calls AddDefinition ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- Source/cmDefinitions.cxx | 14 ++-- Source/cmDefinitions.h | 17 ++-- Source/cmGlobalGenerator.cxx | 65 ++++++++++++++++ Source/cmLinkedTree.h | 11 +++ Source/cmMakefile.cxx | 135 +++++++------------------------- Source/cmState.cxx | 176 +++++++++++++++++++++++++++++++++++++++++- Source/cmState.h | 33 +++++++- 8 files changed, 327 insertions(+), 126 deletions(-) hooks/post-receive -- CMake From steveire at gmail.com Sun Aug 23 11:47:22 2015 From: steveire at gmail.com (Stephen Kelly) Date: Sun, 23 Aug 2015 11:47:22 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2339-g456ea8c Message-ID: <20150823154722.C6967B13D8@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 456ea8c2a62f646f3b0192273cb49d8462f8ce02 (commit) via 1f39ee5bebf66aac33e7e1fa1172c048c13dfd2d (commit) via c259b8302648de1387e21e9ea907cd1a2cb49933 (commit) via 75e511eeaf77848ffef00d570cb10243764f51d2 (commit) from 27ebbf3f4ed8b79fbe7c2c01c5faf43a242a52a1 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=456ea8c2a62f646f3b0192273cb49d8462f8ce02 commit 456ea8c2a62f646f3b0192273cb49d8462f8ce02 Merge: 27ebbf3 1f39ee5 Author: Stephen Kelly AuthorDate: Sun Aug 23 11:47:21 2015 -0400 Commit: CMake Topic Stage CommitDate: Sun Aug 23 11:47:21 2015 -0400 Merge topic 'generators-use-cmLocalGenerator' into next 1f39ee5b cmInstallExportGenerator: Require cmLocalGenerator, not cmMakefile. c259b830 cmTestGenerator: Require cmLocalGenerator, not cmMakefile. 75e511ee cmInstallFilesGenerator: Require cmLocalGenerator, not cmMakefile. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1f39ee5bebf66aac33e7e1fa1172c048c13dfd2d commit 1f39ee5bebf66aac33e7e1fa1172c048c13dfd2d Author: Stephen Kelly AuthorDate: Wed Aug 5 23:05:22 2015 +0200 Commit: Stephen Kelly CommitDate: Sun Aug 23 17:46:23 2015 +0200 cmInstallExportGenerator: Require cmLocalGenerator, not cmMakefile. diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index d55be11..7ffab0c 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -72,8 +72,8 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) // Set an _IMPORT_PREFIX variable for import location properties // to reference if they are relative to the install prefix. - std::string installPrefix = - this->IEGen->GetMakefile()->GetSafeDefinition("CMAKE_INSTALL_PREFIX"); + std::string installPrefix = this->IEGen->GetLocalGenerator() + ->GetMakefile()->GetSafeDefinition("CMAKE_INSTALL_PREFIX"); std::string const& expDest = this->IEGen->GetDestination(); if(cmSystemTools::FileIsFullPath(expDest)) { diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index e22dc42..333c2ff 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -1406,7 +1406,7 @@ bool cmInstallCommand::HandleExportMode(std::vector const& args) ica.GetDestination().c_str(), ica.GetPermissions().c_str(), ica.GetConfigurations(), ica.GetComponent().c_str(), message, fname.c_str(), - name_space.GetCString(), exportOld.IsEnabled(), this->Makefile); + name_space.GetCString(), exportOld.IsEnabled()); this->Makefile->AddInstallGenerator(exportGenerator); return true; diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx index 7f6aa4d..97b9405 100644 --- a/Source/cmInstallExportGenerator.cxx +++ b/Source/cmInstallExportGenerator.cxx @@ -34,15 +34,14 @@ cmInstallExportGenerator::cmInstallExportGenerator( const char* component, MessageLevel message, const char* filename, const char* name_space, - bool exportOld, - cmMakefile* mf) + bool exportOld) :cmInstallGenerator(destination, configurations, component, message) ,ExportSet(exportSet) ,FilePermissions(file_permissions) ,FileName(filename) ,Namespace(name_space) ,ExportOld(exportOld) - ,Makefile(mf) + ,LocalGenerator(0) { this->EFGen = new cmExportInstallFileGenerator(this); exportSet->AddInstallation(this); @@ -54,12 +53,18 @@ cmInstallExportGenerator::~cmInstallExportGenerator() delete this->EFGen; } +void cmInstallExportGenerator::Compute(cmLocalGenerator* lg) +{ + this->LocalGenerator = lg; +} + //---------------------------------------------------------------------------- void cmInstallExportGenerator::ComputeTempDir() { // Choose a temporary directory in which to generate the import // files to be installed. - this->TempDir = this->Makefile->GetCurrentBinaryDirectory(); + this->TempDir = + this->LocalGenerator->GetMakefile()->GetCurrentBinaryDirectory(); this->TempDir += cmake::GetCMakeFilesDirectory(); this->TempDir += "/Export"; if(this->Destination.empty()) diff --git a/Source/cmInstallExportGenerator.h b/Source/cmInstallExportGenerator.h index 3e078f2..885ed05 100644 --- a/Source/cmInstallExportGenerator.h +++ b/Source/cmInstallExportGenerator.h @@ -32,12 +32,14 @@ public: const char* component, MessageLevel message, const char* filename, const char* name_space, - bool exportOld, cmMakefile* mf); + bool exportOld); ~cmInstallExportGenerator(); cmExportSet* GetExportSet() {return this->ExportSet;} - cmMakefile* GetMakefile() const { return this->Makefile; } + void Compute(cmLocalGenerator* lg); + + cmLocalGenerator* GetLocalGenerator() const { return this->LocalGenerator; } const std::string& GetNamespace() const { return this->Namespace; } @@ -57,7 +59,7 @@ protected: std::string FileName; std::string Namespace; bool ExportOld; - cmMakefile* Makefile; + cmLocalGenerator* LocalGenerator; std::string TempDir; std::string MainImportFile; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c259b8302648de1387e21e9ea907cd1a2cb49933 commit c259b8302648de1387e21e9ea907cd1a2cb49933 Author: Stephen Kelly AuthorDate: Wed Aug 5 21:03:26 2015 +0200 Commit: Stephen Kelly CommitDate: Sun Aug 23 17:46:07 2015 +0200 cmTestGenerator: Require cmLocalGenerator, not cmMakefile. diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index a831d88..edb644d 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -196,6 +196,7 @@ void cmLocalGenerator::GenerateTestFiles() for(std::vector::const_iterator gi = testers.begin(); gi != testers.end(); ++gi) { + (*gi)->Compute(this); (*gi)->Generate(fout, config, configurationTypes); } if (!this->Children.empty()) diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx index 1815ade..9d85f5a 100644 --- a/Source/cmTestGenerator.cxx +++ b/Source/cmTestGenerator.cxx @@ -14,6 +14,7 @@ #include "cmGeneratorExpression.h" #include "cmOutputConverter.h" #include "cmMakefile.h" +#include "cmLocalGenerator.h" #include "cmSystemTools.h" #include "cmTarget.h" #include "cmTest.h" @@ -27,6 +28,7 @@ cmTestGenerator { this->ActionsPerConfig = !test->GetOldStyle(); this->TestGenerated = false; + this->LG = 0; } //---------------------------------------------------------------------------- @@ -35,6 +37,11 @@ cmTestGenerator { } +void cmTestGenerator::Compute(cmLocalGenerator* lg) +{ + this->LG = lg; +} + //---------------------------------------------------------------------------- void cmTestGenerator::GenerateScriptConfigs(std::ostream& os, Indent const& indent) @@ -81,8 +88,8 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, // Check whether the command executable is a target whose name is to // be translated. std::string exe = command[0]; - cmMakefile* mf = this->Test->GetMakefile(); - cmGeneratorTarget* target = mf->FindGeneratorTargetToUse(exe); + cmGeneratorTarget* target = + this->LG->GetMakefile()->FindGeneratorTargetToUse(exe); if(target && target->GetType() == cmTarget::EXECUTABLE) { // Use the target file on disk. @@ -110,7 +117,7 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, else { // Use the command name given. - exe = ge.Parse(exe.c_str())->Evaluate(mf, config); + exe = ge.Parse(exe.c_str())->Evaluate(this->LG->GetMakefile(), config); cmSystemTools::ConvertToUnixSlashes(exe); } @@ -120,7 +127,8 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, ci != command.end(); ++ci) { os << " " << cmOutputConverter::EscapeForCMake( - ge.Parse(*ci)->Evaluate(mf, config)); + ge.Parse(*ci)->Evaluate( + this->LG->GetMakefile(), config)); } // Finish the test command. @@ -137,7 +145,8 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, { os << " " << i->first << " " << cmOutputConverter::EscapeForCMake( - ge.Parse(i->second.GetValue())->Evaluate(mf, config)); + ge.Parse(i->second.GetValue())->Evaluate(this->LG->GetMakefile(), + config)); } os << ")" << std::endl; } diff --git a/Source/cmTestGenerator.h b/Source/cmTestGenerator.h index 5446553..de8ab78 100644 --- a/Source/cmTestGenerator.h +++ b/Source/cmTestGenerator.h @@ -15,6 +15,7 @@ #include "cmScriptGenerator.h" class cmTest; +class cmLocalGenerator; /** \class cmTestGenerator * \brief Support class for generating install scripts. @@ -28,6 +29,8 @@ public: configurations = std::vector()); virtual ~cmTestGenerator(); + void Compute(cmLocalGenerator* lg); + protected: virtual void GenerateScriptConfigs(std::ostream& os, Indent const& indent); virtual void GenerateScriptActions(std::ostream& os, Indent const& indent); @@ -38,6 +41,7 @@ protected: virtual bool NeedsScriptNoConfig() const; void GenerateOldStyle(std::ostream& os, Indent const& indent); + cmLocalGenerator* LG; cmTest* Test; bool TestGenerated; }; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=75e511eeaf77848ffef00d570cb10243764f51d2 commit 75e511eeaf77848ffef00d570cb10243764f51d2 Author: Stephen Kelly AuthorDate: Sat Aug 1 09:01:03 2015 +0200 Commit: Stephen Kelly CommitDate: Sun Aug 23 17:21:27 2015 +0200 cmInstallFilesGenerator: Require cmLocalGenerator, not cmMakefile. diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index f548f5d..e22dc42 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -42,7 +42,7 @@ static cmInstallFilesGenerator* CreateInstallFilesGenerator( { cmInstallGenerator::MessageLevel message = cmInstallGenerator::SelectMessageLevel(mf); - return new cmInstallFilesGenerator(mf, + return new cmInstallFilesGenerator( absFiles, args.GetDestination().c_str(), programs, args.GetPermissions().c_str(), args.GetConfigurations(), args.GetComponent().c_str(), diff --git a/Source/cmInstallFilesCommand.cxx b/Source/cmInstallFilesCommand.cxx index 508c373..68557bd 100644 --- a/Source/cmInstallFilesCommand.cxx +++ b/Source/cmInstallFilesCommand.cxx @@ -128,7 +128,7 @@ void cmInstallFilesCommand::CreateInstallGenerator() const cmInstallGenerator::MessageLevel message = cmInstallGenerator::SelectMessageLevel(this->Makefile); this->Makefile->AddInstallGenerator( - new cmInstallFilesGenerator(this->Makefile, this->Files, + new cmInstallFilesGenerator(this->Files, destination.c_str(), false, no_permissions, no_configurations, no_component.c_str(), message, no_rename)); diff --git a/Source/cmInstallFilesGenerator.cxx b/Source/cmInstallFilesGenerator.cxx index ff2c6e5..c18b174 100644 --- a/Source/cmInstallFilesGenerator.cxx +++ b/Source/cmInstallFilesGenerator.cxx @@ -14,11 +14,11 @@ #include "cmGeneratorExpression.h" #include "cmMakefile.h" #include "cmSystemTools.h" +#include "cmLocalGenerator.h" //---------------------------------------------------------------------------- cmInstallFilesGenerator -::cmInstallFilesGenerator(cmMakefile* mf, - std::vector const& files, +::cmInstallFilesGenerator(std::vector const& files, const char* dest, bool programs, const char* file_permissions, std::vector const& configurations, @@ -27,7 +27,7 @@ cmInstallFilesGenerator const char* rename, bool optional): cmInstallGenerator(dest, configurations, component, message), - Makefile(mf), + LocalGenerator(0), Files(files), FilePermissions(file_permissions), Rename(rename), @@ -51,6 +51,11 @@ cmInstallFilesGenerator { } +void cmInstallFilesGenerator::Compute(cmLocalGenerator* lg) +{ + this->LocalGenerator = lg; +} + //---------------------------------------------------------------------------- void cmInstallFilesGenerator::AddFilesInstallRule( std::ostream& os, Indent const& indent, @@ -94,8 +99,8 @@ void cmInstallFilesGenerator::GenerateScriptForConfig(std::ostream& os, i != this->Files.end(); ++i) { cmsys::auto_ptr cge = ge.Parse(*i); - cmSystemTools::ExpandListArgument(cge->Evaluate(this->Makefile, config), - files); + cmSystemTools::ExpandListArgument(cge->Evaluate( + this->LocalGenerator->GetMakefile(), config), files); } this->AddFilesInstallRule(os, indent, files); } diff --git a/Source/cmInstallFilesGenerator.h b/Source/cmInstallFilesGenerator.h index bf482d6..00b3a79 100644 --- a/Source/cmInstallFilesGenerator.h +++ b/Source/cmInstallFilesGenerator.h @@ -14,16 +14,13 @@ #include "cmInstallGenerator.h" -class cmMakefile; - /** \class cmInstallFilesGenerator * \brief Generate file installation rules. */ class cmInstallFilesGenerator: public cmInstallGenerator { public: - cmInstallFilesGenerator(cmMakefile* mf, - std::vector const& files, + cmInstallFilesGenerator(std::vector const& files, const char* dest, bool programs, const char* file_permissions, std::vector const& configurations, @@ -33,6 +30,8 @@ public: bool optional = false); virtual ~cmInstallFilesGenerator(); + void Compute(cmLocalGenerator* lg); + protected: virtual void GenerateScriptActions(std::ostream& os, Indent const& indent); virtual void GenerateScriptForConfig(std::ostream& os, @@ -41,7 +40,7 @@ protected: void AddFilesInstallRule(std::ostream& os, Indent const& indent, std::vector const& files); - cmMakefile* Makefile; + cmLocalGenerator* LocalGenerator; std::vector Files; std::string FilePermissions; std::string Rename; diff --git a/Source/cmInstallProgramsCommand.cxx b/Source/cmInstallProgramsCommand.cxx index be8096c..e6fbe88 100644 --- a/Source/cmInstallProgramsCommand.cxx +++ b/Source/cmInstallProgramsCommand.cxx @@ -91,7 +91,7 @@ void cmInstallProgramsCommand::FinalPass() cmInstallGenerator::MessageLevel message = cmInstallGenerator::SelectMessageLevel(this->Makefile); this->Makefile->AddInstallGenerator( - new cmInstallFilesGenerator(this->Makefile, this->Files, + new cmInstallFilesGenerator(this->Files, destination.c_str(), true, no_permissions, no_configurations, no_component.c_str(), message, no_rename)); ----------------------------------------------------------------------- Summary of changes: Source/cmExportInstallFileGenerator.cxx | 4 ++-- Source/cmInstallCommand.cxx | 4 ++-- Source/cmInstallExportGenerator.cxx | 13 +++++++++---- Source/cmInstallExportGenerator.h | 8 +++++--- Source/cmInstallFilesCommand.cxx | 2 +- Source/cmInstallFilesGenerator.cxx | 15 ++++++++++----- Source/cmInstallFilesGenerator.h | 9 ++++----- Source/cmInstallProgramsCommand.cxx | 2 +- Source/cmLocalGenerator.cxx | 1 + Source/cmTestGenerator.cxx | 19 ++++++++++++++----- Source/cmTestGenerator.h | 4 ++++ 11 files changed, 53 insertions(+), 28 deletions(-) hooks/post-receive -- CMake From steveire at gmail.com Sun Aug 23 12:08:35 2015 From: steveire at gmail.com (Stephen Kelly) Date: Sun, 23 Aug 2015 12:08:35 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2346-gc750157 Message-ID: <20150823160835.E6DFAB19DC@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via c7501577fbc81d257017a5edfe0520da67e226eb (commit) via 3fa1b9641dd16ad93c64737fd2eeb131cca70f76 (commit) via 55e3927634a4b071c1cf52cc2dc406b8973b82cc (commit) via 04168cbb593be0d58326b09346e90a6348a862ff (commit) via 2394584ce2fa4ff88bb8b196e5a75fc5f848ba4a (commit) via b9eb3cd1405d423bf0156fabc3340c396b1f308c (commit) via f5d2b7a6942ee291f8e0d4e8a7a7869037913de7 (commit) from 456ea8c2a62f646f3b0192273cb49d8462f8ce02 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c7501577fbc81d257017a5edfe0520da67e226eb commit c7501577fbc81d257017a5edfe0520da67e226eb Merge: 456ea8c 3fa1b96 Author: Stephen Kelly AuthorDate: Sun Aug 23 12:08:34 2015 -0400 Commit: CMake Topic Stage CommitDate: Sun Aug 23 12:08:34 2015 -0400 Merge topic 'refactor-progress' into next 3fa1b964 cmGlobalUnixMakefileGenerator3: Change the progress container key. 55e39276 cmState: Make it possible to order cmState::Snapshot. 04168cbb cmGlobalUnixMakefileGenerator3: Rename member. 2394584c cmGlobalGenerator: Rename progress initializer method. b9eb3cd1 cmGlobalGenerator: Move LG to target map to subclass. f5d2b7a6 cmGlobalGenerator: Remove clearance of map. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3fa1b9641dd16ad93c64737fd2eeb131cca70f76 commit 3fa1b9641dd16ad93c64737fd2eeb131cca70f76 Author: Stephen Kelly AuthorDate: Sun Aug 2 10:29:01 2015 +0200 Commit: Stephen Kelly CommitDate: Sun Aug 23 18:05:13 2015 +0200 cmGlobalUnixMakefileGenerator3: Change the progress container key. diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 75c2fb8..b240924 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -943,7 +943,7 @@ void cmGlobalUnixMakefileGenerator3::InitializeProgressMarks() { // This local generator includes the target. std::set& targetSet = - this->DirectoryTargetsMap[clg]; + this->DirectoryTargetsMap[clg->GetStateSnapshot()]; targetSet.insert(gt); // Add dependencies of the included target. An excluded @@ -992,7 +992,7 @@ cmGlobalUnixMakefileGenerator3 size_t count = 0; std::set emitted; std::set const& targets - = this->DirectoryTargetsMap[lg]; + = this->DirectoryTargetsMap[lg->GetStateSnapshot()]; for(std::set::const_iterator t = targets.begin(); t != targets.end(); ++t) { diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index 7601cc4..c738c16 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -207,8 +207,9 @@ private: virtual const char* GetBuildIgnoreErrorsFlag() const { return "-i"; } virtual std::string GetEditCacheCommand() const; - std::map > - DirectoryTargetsMap; + std::map, + cmState::Snapshot::StrictWeakOrder> DirectoryTargetsMap; virtual void InitializeProgressMarks(); }; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=55e3927634a4b071c1cf52cc2dc406b8973b82cc commit 55e3927634a4b071c1cf52cc2dc406b8973b82cc Author: Stephen Kelly AuthorDate: Sun Aug 2 10:07:30 2015 +0200 Commit: Stephen Kelly CommitDate: Sun Aug 23 18:05:13 2015 +0200 cmState: Make it possible to order cmState::Snapshot. diff --git a/Source/cmLinkedTree.h b/Source/cmLinkedTree.h index 3bcb940..721a246 100644 --- a/Source/cmLinkedTree.h +++ b/Source/cmLinkedTree.h @@ -128,6 +128,13 @@ public: } return this->Position <= this->Tree->Data.size(); } + + bool StrictWeakOrdered(iterator other) const + { + assert(this->Tree); + assert(this->Tree == other.Tree); + return this->Position < other.Position; + } }; iterator Root() const diff --git a/Source/cmState.cxx b/Source/cmState.cxx index f425861..66f19c3 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -1411,3 +1411,9 @@ void cmState::Directory::ClearCompileOptions() this->DirectoryState->CompileOptionsBacktraces, this->Snapshot_.Position->CompileOptionsPosition); } + +bool cmState::Snapshot::StrictWeakOrder::operator()( + const cmState::Snapshot& lhs, const cmState::Snapshot& rhs) const +{ + return lhs.Position.StrictWeakOrdered(rhs.Position); +} diff --git a/Source/cmState.h b/Source/cmState.h index 07aa2a5..3132d1b 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -74,9 +74,16 @@ public: Directory GetDirectory() const; + struct StrictWeakOrder + { + bool operator()(const cmState::Snapshot& lhs, + const cmState::Snapshot& rhs) const; + }; + private: friend class cmState; friend class Directory; + friend struct StrictWeakOrder; cmState* State; cmState::PositionType Position; }; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=04168cbb593be0d58326b09346e90a6348a862ff commit 04168cbb593be0d58326b09346e90a6348a862ff Author: Stephen Kelly AuthorDate: Sun Aug 23 17:52:30 2015 +0200 Commit: Stephen Kelly CommitDate: Sun Aug 23 18:05:13 2015 +0200 cmGlobalUnixMakefileGenerator3: Rename member. diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index f8dee62..75c2fb8 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -921,7 +921,7 @@ cmGlobalUnixMakefileGenerator3 // generator directory level. void cmGlobalUnixMakefileGenerator3::InitializeProgressMarks() { - this->LocalGeneratorToTargetMap.clear(); + this->DirectoryTargetsMap.clear(); // Loop over all targets in all local generators. for(std::vector::const_iterator lgi = this->LocalGenerators.begin(); @@ -943,7 +943,7 @@ void cmGlobalUnixMakefileGenerator3::InitializeProgressMarks() { // This local generator includes the target. std::set& targetSet = - this->LocalGeneratorToTargetMap[clg]; + this->DirectoryTargetsMap[clg]; targetSet.insert(gt); // Add dependencies of the included target. An excluded @@ -992,7 +992,7 @@ cmGlobalUnixMakefileGenerator3 size_t count = 0; std::set emitted; std::set const& targets - = this->LocalGeneratorToTargetMap[lg]; + = this->DirectoryTargetsMap[lg]; for(std::set::const_iterator t = targets.begin(); t != targets.end(); ++t) { diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index a8f99dd..7601cc4 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -208,7 +208,7 @@ private: virtual std::string GetEditCacheCommand() const; std::map > - LocalGeneratorToTargetMap; + DirectoryTargetsMap; virtual void InitializeProgressMarks(); }; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2394584ce2fa4ff88bb8b196e5a75fc5f848ba4a commit 2394584ce2fa4ff88bb8b196e5a75fc5f848ba4a Author: Stephen Kelly AuthorDate: Sun Aug 2 10:23:12 2015 +0200 Commit: Stephen Kelly CommitDate: Sun Aug 23 18:05:13 2015 +0200 cmGlobalGenerator: Rename progress initializer method. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 2dddc7d..503c455 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1340,7 +1340,7 @@ void cmGlobalGenerator::Generate() // Create a map from local generator to the complete set of targets // it builds by default. - this->FillLocalGeneratorToTargetMap(); + this->InitializeProgressMarks(); for (i = 0; i < this->LocalGenerators.size(); ++i) { diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 86f52af..fe710f1 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -398,7 +398,7 @@ protected: void CheckLocalGenerators(); bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen) const; bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) const; - virtual void FillLocalGeneratorToTargetMap() {} + virtual void InitializeProgressMarks() {} void CreateDefaultGlobalTargets(cmTargets* targets); cmTarget CreateGlobalTarget(const std::string& name, const char* message, const cmCustomCommandLines* commandLines, diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 255b59d..f8dee62 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -919,7 +919,7 @@ cmGlobalUnixMakefileGenerator3 // Build a map that contains a the set of targets used by each local // generator directory level. -void cmGlobalUnixMakefileGenerator3::FillLocalGeneratorToTargetMap() +void cmGlobalUnixMakefileGenerator3::InitializeProgressMarks() { this->LocalGeneratorToTargetMap.clear(); // Loop over all targets in all local generators. diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index de7d858..a8f99dd 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -209,7 +209,7 @@ private: std::map > LocalGeneratorToTargetMap; - virtual void FillLocalGeneratorToTargetMap(); + virtual void InitializeProgressMarks(); }; #endif http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b9eb3cd1405d423bf0156fabc3340c396b1f308c commit b9eb3cd1405d423bf0156fabc3340c396b1f308c Author: Stephen Kelly AuthorDate: Sun Aug 2 10:22:12 2015 +0200 Commit: Stephen Kelly CommitDate: Sun Aug 23 18:05:01 2015 +0200 cmGlobalGenerator: Move LG to target map to subclass. This is the only user. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 621f1d4..2dddc7d 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2117,50 +2117,6 @@ void cmGlobalGenerator::FillProjectMap() } } - -// Build a map that contains a the set of targets used by each local -// generator directory level. -void cmGlobalGenerator::FillLocalGeneratorToTargetMap() -{ - this->LocalGeneratorToTargetMap.clear(); - // Loop over all targets in all local generators. - for(std::vector::const_iterator - lgi = this->LocalGenerators.begin(); - lgi != this->LocalGenerators.end(); ++lgi) - { - cmLocalGenerator* lg = *lgi; - cmMakefile* mf = lg->GetMakefile(); - cmTargets const& targets = mf->GetTargets(); - for(cmTargets::const_iterator t = targets.begin(); t != targets.end(); ++t) - { - cmTarget const& target = t->second; - - cmGeneratorTarget* gt = this->GetGeneratorTarget(&target); - - // Consider the directory containing the target and all its - // parents until something excludes the target. - for(cmLocalGenerator* clg = lg; clg && !this->IsExcluded(clg, gt); - clg = clg->GetParent()) - { - // This local generator includes the target. - std::set& targetSet = - this->LocalGeneratorToTargetMap[clg]; - targetSet.insert(gt); - - // Add dependencies of the included target. An excluded - // target may still be included if it is a dependency of a - // non-excluded target. - TargetDependSet const& tgtdeps = this->GetTargetDirectDepends(gt); - for(TargetDependSet::const_iterator ti = tgtdeps.begin(); - ti != tgtdeps.end(); ++ti) - { - targetSet.insert(*ti); - } - } - } - } -} - cmMakefile* cmGlobalGenerator::FindMakefile(const std::string& start_dir) const { diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index a13bede..86f52af 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -398,7 +398,7 @@ protected: void CheckLocalGenerators(); bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen) const; bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) const; - void FillLocalGeneratorToTargetMap(); + virtual void FillLocalGeneratorToTargetMap() {} void CreateDefaultGlobalTargets(cmTargets* targets); cmTarget CreateGlobalTarget(const std::string& name, const char* message, const cmCustomCommandLines* commandLines, @@ -413,8 +413,6 @@ protected: cmMakefile* CurrentMakefile; // map from project name to vector of local generators in that project std::map > ProjectMap; - std::map > - LocalGeneratorToTargetMap; // Set of named installation components requested by the project. std::set InstallComponents; diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 76d059ee..255b59d 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -917,6 +917,49 @@ cmGlobalUnixMakefileGenerator3 } } +// Build a map that contains a the set of targets used by each local +// generator directory level. +void cmGlobalUnixMakefileGenerator3::FillLocalGeneratorToTargetMap() +{ + this->LocalGeneratorToTargetMap.clear(); + // Loop over all targets in all local generators. + for(std::vector::const_iterator + lgi = this->LocalGenerators.begin(); + lgi != this->LocalGenerators.end(); ++lgi) + { + cmLocalGenerator* lg = *lgi; + cmMakefile* mf = lg->GetMakefile(); + cmTargets const& targets = mf->GetTargets(); + for(cmTargets::const_iterator t = targets.begin(); t != targets.end(); ++t) + { + cmTarget const& target = t->second; + + cmGeneratorTarget* gt = this->GetGeneratorTarget(&target); + + // Consider the directory containing the target and all its + // parents until something excludes the target. + for(cmLocalGenerator* clg = lg; clg && !this->IsExcluded(clg, gt); + clg = clg->GetParent()) + { + // This local generator includes the target. + std::set& targetSet = + this->LocalGeneratorToTargetMap[clg]; + targetSet.insert(gt); + + // Add dependencies of the included target. An excluded + // target may still be included if it is a dependency of a + // non-excluded target. + TargetDependSet const& tgtdeps = this->GetTargetDirectDepends(gt); + for(TargetDependSet::const_iterator ti = tgtdeps.begin(); + ti != tgtdeps.end(); ++ti) + { + targetSet.insert(*ti); + } + } + } + } +} + //---------------------------------------------------------------------------- size_t cmGlobalUnixMakefileGenerator3 diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index fc53fa8..de7d858 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -206,6 +206,10 @@ protected: private: virtual const char* GetBuildIgnoreErrorsFlag() const { return "-i"; } virtual std::string GetEditCacheCommand() const; + + std::map > + LocalGeneratorToTargetMap; + virtual void FillLocalGeneratorToTargetMap(); }; #endif http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f5d2b7a6942ee291f8e0d4e8a7a7869037913de7 commit f5d2b7a6942ee291f8e0d4e8a7a7869037913de7 Author: Stephen Kelly AuthorDate: Sun Aug 2 10:20:11 2015 +0200 Commit: Stephen Kelly CommitDate: Sun Aug 23 17:49:11 2015 +0200 cmGlobalGenerator: Remove clearance of map. It is always cleared before being re-populated. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index cda26cd..621f1d4 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1610,7 +1610,6 @@ void cmGlobalGenerator::ClearGeneratorMembers() this->TargetDependencies.clear(); this->TotalTargets.clear(); this->ImportedTargets.clear(); - this->LocalGeneratorToTargetMap.clear(); this->ProjectMap.clear(); this->RuleHashes.clear(); this->DirectoryContentMap.clear(); ----------------------------------------------------------------------- Summary of changes: Source/cmGlobalGenerator.cxx | 47 +---------------------------- Source/cmGlobalGenerator.h | 4 +-- Source/cmGlobalUnixMakefileGenerator3.cxx | 45 ++++++++++++++++++++++++++- Source/cmGlobalUnixMakefileGenerator3.h | 5 +++ Source/cmLinkedTree.h | 7 +++++ Source/cmState.cxx | 6 ++++ Source/cmState.h | 7 +++++ 7 files changed, 71 insertions(+), 50 deletions(-) hooks/post-receive -- CMake From steveire at gmail.com Sun Aug 23 13:05:39 2015 From: steveire at gmail.com (Stephen Kelly) Date: Sun, 23 Aug 2015 13:05:39 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2350-g29dfc9f Message-ID: <20150823170539.1DDF1B1953@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 29dfc9fdd943f4f651ad6f293a30528209af847b (commit) via eb47176870eedef7af8b53d98887d4326cb509de (commit) via d7fc7c3a403170035359e8e3b173725a04b6c1ff (commit) via bff27391a91d1410ef33187c0c35acc0a709720d (commit) from c7501577fbc81d257017a5edfe0520da67e226eb (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=29dfc9fdd943f4f651ad6f293a30528209af847b commit 29dfc9fdd943f4f651ad6f293a30528209af847b Merge: c750157 eb47176 Author: Stephen Kelly AuthorDate: Sun Aug 23 13:05:38 2015 -0400 Commit: CMake Topic Stage CommitDate: Sun Aug 23 13:05:38 2015 -0400 Merge topic 'cmState-definitions' into next eb471768 cmState: Reserve the number of cmLinkedTree nodes if known. d7fc7c3a cmLinkedTree: Add API for size query and reserve. bff27391 cmState: Host variable definitions. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=eb47176870eedef7af8b53d98887d4326cb509de commit eb47176870eedef7af8b53d98887d4326cb509de Author: Stephen Kelly AuthorDate: Sun Jun 21 13:05:15 2015 +0200 Commit: Stephen Kelly CommitDate: Sun Aug 23 19:05:13 2015 +0200 cmState: Reserve the number of cmLinkedTree nodes if known. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index cda26cd..a19a074 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1141,6 +1141,42 @@ void cmGlobalGenerator::Configure() this->BinaryDirectories.insert( this->CMakeInstance->GetHomeOutputDirectory()); + if (const char *numStr = + this->GetCMakeInstance()->GetState() + ->GetInitializedCacheValue("CMAKE_NUMBER_OF_DEFINITION_STATES")) + { + int num = atoi(numStr); + this->GetCMakeInstance()->GetState()->ReserveDefinitions(num); + } + if (const char *numStr = + this->GetCMakeInstance()->GetState() + ->GetInitializedCacheValue("CMAKE_NUMBER_OF_SNAPSHOT_STATES")) + { + int num = atoi(numStr); + this->GetCMakeInstance()->GetState()->ReserveSnapshots(num); + } + if (const char *numStr = + this->GetCMakeInstance()->GetState() + ->GetInitializedCacheValue("CMAKE_NUMBER_OF_LISTFILE_STATES")) + { + int num = atoi(numStr); + this->GetCMakeInstance()->GetState()->ReserveListFiles(num); + } + if (const char *numStr = + this->GetCMakeInstance()->GetState() + ->GetInitializedCacheValue("CMAKE_NUMBER_OF_LOCAL_GENERATORS")) + { + int num = atoi(numStr); + this->GetCMakeInstance()->GetState()->ReserveDirectories(num); + } + if (const char *numStr = + this->GetCMakeInstance()->GetState() + ->GetInitializedCacheValue("CMAKE_NUMBER_OF_POLICY_STATES")) + { + int num = atoi(numStr); + this->GetCMakeInstance()->GetState()->ReservePolicies(num); + } + // now do it lg->GetMakefile()->Configure(); lg->GetMakefile()->EnforceDirectoryLevelRules(); @@ -1153,6 +1189,35 @@ void cmGlobalGenerator::Configure() ("CMAKE_NUMBER_OF_MAKEFILES", num, "number of local generators", cmState::INTERNAL); + { + std::ostringstream str; + str << this->GetCMakeInstance()->GetState()->DefinitionsSize(); + this->GetCMakeInstance()->AddCacheEntry + ("CMAKE_NUMBER_OF_DEFINITION_STATES", str.str().c_str(), + "number of definition states", cmState::INTERNAL); + } + { + std::ostringstream str; + str << this->GetCMakeInstance()->GetState()->SnapshotsSize(); + this->GetCMakeInstance()->AddCacheEntry + ("CMAKE_NUMBER_OF_SNAPSHOT_STATES", str.str().c_str(), + "number of snapshot states", cmState::INTERNAL); + } + { + std::ostringstream str; + str << this->GetCMakeInstance()->GetState()->ListFilesSize(); + this->GetCMakeInstance()->AddCacheEntry + ("CMAKE_NUMBER_OF_LISTFILE_STATES", str.str().c_str(), + "number of listfile states", cmState::INTERNAL); + } + { + std::ostringstream str; + str << this->GetCMakeInstance()->GetState()->PoliciesSize(); + this->GetCMakeInstance()->AddCacheEntry + ("CMAKE_NUMBER_OF_POLICY_STATES", str.str().c_str(), + "number of policy states", cmState::INTERNAL); + } + // check for link libraries and include directories containing "NOTFOUND" // and for infinite loops this->CheckLocalGenerators(); diff --git a/Source/cmState.cxx b/Source/cmState.cxx index ab309ad..99a7537 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -651,6 +651,56 @@ bool cmState::UseMSYSShell() const return this->MSYSShell; } +size_t cmState::DefinitionsSize() const +{ + return this->VarTree.Size(); +} + +void cmState::ReserveDefinitions(size_t amount) +{ + this->VarTree.Reserve(amount); +} + +size_t cmState::SnapshotsSize() const +{ + return this->SnapshotData.Size(); +} + +void cmState::ReserveSnapshots(size_t amount) +{ + this->SnapshotData.Reserve(amount); +} + +size_t cmState::ListFilesSize() const +{ + return this->ExecutionListFiles.Size(); +} + +void cmState::ReserveListFiles(size_t amount) +{ + this->ExecutionListFiles.Reserve(amount); +} + +size_t cmState::DirectoriesSize() const +{ + return this->BuildsystemDirectory.Size(); +} + +void cmState::ReserveDirectories(size_t amount) +{ + this->BuildsystemDirectory.Reserve(amount); +} + +size_t cmState::PoliciesSize() const +{ + return this->PolicyStack.Size(); +} + +void cmState::ReservePolicies(size_t amount) +{ + this->PolicyStack.Reserve(amount); +} + const char* cmState::GetBinaryDirectory() const { return this->BinaryDirectory.c_str(); diff --git a/Source/cmState.h b/Source/cmState.h index 5499665..8380587 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -270,6 +270,21 @@ public: void SetMSYSShell(bool mSYSShell); bool UseMSYSShell() const; + size_t DefinitionsSize() const; + void ReserveDefinitions(size_t amount); + + size_t SnapshotsSize() const; + void ReserveSnapshots(size_t amount); + + size_t ListFilesSize() const; + void ReserveListFiles(size_t amount); + + size_t DirectoriesSize() const; + void ReserveDirectories(size_t amount); + + size_t PoliciesSize() const; + void ReservePolicies(size_t amount); + private: std::map PropertyDefinitions; std::vector EnabledLanguages; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d7fc7c3a403170035359e8e3b173725a04b6c1ff commit d7fc7c3a403170035359e8e3b173725a04b6c1ff Author: Stephen Kelly AuthorDate: Sun Jun 21 13:04:43 2015 +0200 Commit: Stephen Kelly CommitDate: Sun Aug 23 19:05:13 2015 +0200 cmLinkedTree: Add API for size query and reserve. diff --git a/Source/cmLinkedTree.h b/Source/cmLinkedTree.h index 3bcb940..385dff2 100644 --- a/Source/cmLinkedTree.h +++ b/Source/cmLinkedTree.h @@ -161,6 +161,17 @@ public: this->Data.clear(); } + size_t Size() const + { + return this->UpPositions.size(); + } + + void Reserve(size_t amount) + { + this->UpPositions.reserve(amount); + this->Data.reserve(amount); + } + private: T& GetReference(PositionType pos) { http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bff27391a91d1410ef33187c0c35acc0a709720d commit bff27391a91d1410ef33187c0c35acc0a709720d Author: Stephen Kelly AuthorDate: Sun Jun 21 21:26:43 2015 +0200 Commit: Stephen Kelly CommitDate: Sun Aug 23 19:05:11 2015 +0200 cmState: Host variable definitions. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 1d02cfa..513a643 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -31,7 +31,6 @@ #endif #include "cmInstallGenerator.h" #include "cmTestGenerator.h" -#include "cmDefinitions.h" #include "cmAlgorithms.h" #include "cmake.h" #include // required for atoi @@ -47,132 +46,7 @@ class cmMakefile::Internals { public: - - enum ScopeType - { - BaseScope, - MacroScope, - FunctionScope, - VariableScope - }; - - struct VarScope - { - ScopeType Type; - cmLinkedTree::iterator Vars; - cmLinkedTree::iterator ParentScope; - }; - - cmLinkedTree VarTree; - cmLinkedTree VarScopes; - cmLinkedTree::iterator VarScopeIter; bool IsSourceFileTryCompile; - - void PushDefinitions(ScopeType scope) - { - assert(this->VarScopeIter.IsValid()); - assert(this->VarScopeIter->Vars.IsValid()); - cmLinkedTree::iterator origin = - this->VarScopeIter->Vars; - cmLinkedTree::iterator parentScope = -// this->VarTree.Extend(origin); - origin; - this->VarScopeIter->Vars = parentScope; - this->VarScopeIter = this->VarScopes.Extend(this->VarScopeIter); - this->VarScopeIter->ParentScope = parentScope; - this->VarScopeIter->Vars = this->VarTree.Extend(origin); - this->VarScopeIter->Type = scope; - } - - void InitializeVarScope() - { - assert(!this->VarScopeIter.IsValid()); - this->VarScopeIter = this->VarScopes.Extend(this->VarScopes.Root()); - this->VarScopeIter->Vars = this->VarTree.Extend(this->VarTree.Root()); - this->VarScopeIter->ParentScope = this->VarTree.Root(); - this->VarScopeIter->Type = BaseScope; - } - - void InitializeDefinitions(cmMakefile* parent) - { - assert(this->VarScopeIter.IsValid()); - assert(this->VarScopeIter->Vars.IsValid()); - *this->VarScopeIter->Vars = - cmDefinitions::MakeClosure(parent->Internal->VarScopeIter->Vars, - parent->Internal->VarTree.Root()); - } - - const char* GetDefinition(std::string const& name) - { - assert(this->VarScopeIter.IsValid()); - assert(this->VarScopeIter->Vars.IsValid()); - return cmDefinitions::Get(name, - this->VarScopeIter->Vars, this->VarTree.Root()); - } - - bool IsInitialized(std::string const& name) - { - return cmDefinitions::HasKey(name, - this->VarScopeIter->Vars, this->VarTree.Root()); - } - - void SetDefinition(std::string const& name, std::string const& value) - { - this->VarScopeIter->Vars->Set(name, value.c_str()); - } - - void RemoveDefinition(std::string const& name) - { - this->VarScopeIter->Vars->Set(name, 0); - } - - std::vector UnusedKeys() const - { - return this->VarScopeIter->Vars->UnusedKeys(); - } - - std::vector ClosureKeys() const - { - return cmDefinitions::ClosureKeys(this->VarScopeIter->Vars, - this->VarTree.Root()); - } - - void PopDefinitions() - { - ++this->VarScopeIter; - } - - bool RaiseScope(std::string const& var, const char* varDef, cmMakefile* mf) - { - assert(this->VarScopeIter->Vars != this->VarTree.Root()); - if(this->VarScopeIter->ParentScope == this->VarTree.Root()) - { - cmLocalGenerator* plg = mf->LocalGenerator->GetParent(); - if(!plg) - { - return false; - } - // Update the definition in the parent directory top scope. This - // directory's scope was initialized by the closure of the parent - // scope, so we do not need to localize the definition first. - cmMakefile* parent = plg->GetMakefile(); - if (varDef) - { - parent->AddDefinition(var, varDef); - } - else - { - parent->RemoveDefinition(var); - } - return true; - } - // First localize the definition in the current scope. - cmDefinitions::Raise(var, this->VarScopeIter->Vars, this->VarTree.Root()); - - // Now update the definition in the parent scope. - this->VarScopeIter->ParentScope->Set(var, varDef); - return true; - } }; // default is not to be building executables @@ -181,7 +55,6 @@ cmMakefile::cmMakefile(cmLocalGenerator* localGenerator) LocalGenerator(localGenerator), StateSnapshot(localGenerator->GetStateSnapshot()) { - this->Internal->InitializeVarScope(); this->Internal->IsSourceFileTryCompile = false; // Initialize these first since AddDefaultDefinitions calls AddDefinition @@ -1607,9 +1480,6 @@ void cmMakefile::AddLinkLibrary(const std::string& lib) void cmMakefile::InitializeFromParent(cmMakefile* parent) { - // Initialize definitions with the closure of the parent scope. - this->Internal->InitializeDefinitions(parent); - this->StateSnapshot.InitializeFromParent(); this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR", @@ -1674,8 +1544,6 @@ void cmMakefile::PushFunctionScope(std::string const& fileName, fileName); assert(this->StateSnapshot.IsValid()); - this->Internal->PushDefinitions(Internals::FunctionScope); - this->PushLoopBlockBarrier(); #if defined(CMAKE_BUILD_WITH_CMAKE) @@ -1702,8 +1570,6 @@ void cmMakefile::PopFunctionScope(bool reportError) this->PopLoopBlockBarrier(); this->CheckForUnusedVariables(); - - this->Internal->PopDefinitions(); } void cmMakefile::PushMacroScope(std::string const& fileName, @@ -2007,7 +1873,7 @@ void cmMakefile::AddDefinition(const std::string& name, const char* value) { this->LogUnused("changing definition", name); } - this->Internal->SetDefinition(name, value); + this->StateSnapshot.SetDefinition(name, value); #ifdef CMAKE_BUILD_WITH_CMAKE cmVariableWatch* vv = this->GetVariableWatch(); @@ -2070,7 +1936,7 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value, this->GetState()->AddCacheEntry(name, haveVal ? val.c_str() : 0, doc, type); // if there was a definition then remove it - this->Internal->RemoveDefinition(name); + this->StateSnapshot.RemoveDefinition(name); } @@ -2080,7 +1946,9 @@ void cmMakefile::AddDefinition(const std::string& name, bool value) { this->LogUnused("changing definition", name); } - this->Internal->SetDefinition(name, value ? "ON" : "OFF"); + + this->StateSnapshot.SetDefinition(name, value ? "ON" : "OFF"); + #ifdef CMAKE_BUILD_WITH_CMAKE cmVariableWatch* vv = this->GetVariableWatch(); if ( vv ) @@ -2097,7 +1965,7 @@ void cmMakefile::CheckForUnusedVariables() const { return; } - const std::vector& unused = this->Internal->UnusedKeys(); + const std::vector& unused = this->StateSnapshot.UnusedKeys(); std::vector::const_iterator it = unused.begin(); for (; it != unused.end(); ++it) { @@ -2107,12 +1975,12 @@ void cmMakefile::CheckForUnusedVariables() const void cmMakefile::MarkVariableAsUsed(const std::string& var) { - this->Internal->GetDefinition(var); + this->StateSnapshot.GetDefinition(var); } bool cmMakefile::VariableInitialized(const std::string& var) const { - return this->Internal->IsInitialized(var); + return this->StateSnapshot.IsInitialized(var); } void cmMakefile::LogUnused(const char* reason, @@ -2160,7 +2028,7 @@ void cmMakefile::RemoveDefinition(const std::string& name) { this->LogUnused("unsetting", name); } - this->Internal->RemoveDefinition(name); + this->StateSnapshot.RemoveDefinition(name); #ifdef CMAKE_BUILD_WITH_CMAKE cmVariableWatch* vv = this->GetVariableWatch(); if ( vv ) @@ -2626,7 +2494,7 @@ const char* cmMakefile::GetRequiredDefinition(const std::string& name) const bool cmMakefile::IsDefinitionSet(const std::string& name) const { - const char* def = this->Internal->GetDefinition(name); + const char* def = this->StateSnapshot.GetDefinition(name); if(!def) { def = this->GetState()->GetInitializedCacheValue(name); @@ -2647,7 +2515,7 @@ bool cmMakefile::IsDefinitionSet(const std::string& name) const const char* cmMakefile::GetDefinition(const std::string& name) const { - const char* def = this->Internal->GetDefinition(name); + const char* def = this->StateSnapshot.GetDefinition(name); if(!def) { def = this->GetState()->GetInitializedCacheValue(name); @@ -2683,7 +2551,7 @@ const char* cmMakefile::GetSafeDefinition(const std::string& def) const std::vector cmMakefile::GetDefinitions() const { - std::vector res = this->Internal->ClosureKeys(); + std::vector res = this->StateSnapshot.ClosureKeys(); std::vector cacheKeys = this->GetState()->GetCacheEntryKeys(); res.insert(res.end(), cacheKeys.begin(), cacheKeys.end()); std::sort(res.begin(), res.end()); @@ -4462,8 +4330,6 @@ std::string cmMakefile::FormatListFileStack() const void cmMakefile::PushScope() { - this->Internal->PushDefinitions(Internals::VariableScope); - std::string commandName; long line = 0; if (!this->ContextStack.empty()) @@ -4492,7 +4358,6 @@ void cmMakefile::PopScope() this->CheckForUnusedVariables(); - this->Internal->PopDefinitions(); this->StateSnapshot = this->GetState()->Pop(this->StateSnapshot); assert(this->StateSnapshot.IsValid()); @@ -4505,7 +4370,7 @@ void cmMakefile::RaiseScope(const std::string& var, const char *varDef) return; } - if (!this->Internal->RaiseScope(var, varDef, this)) + if (!this->StateSnapshot.RaiseScope(var, varDef)) { std::ostringstream m; m << "Cannot set \"" << var << "\": current scope has no parent."; diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 9e09353..ab309ad 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -15,6 +15,7 @@ #include "cmCacheManager.h" #include "cmCommand.h" #include "cmAlgorithms.h" +#include "cmDefinitions.h" #include @@ -29,6 +30,9 @@ struct cmState::SnapshotDataType cmLinkedTree::iterator ExecutionListFile; cmLinkedTree::iterator BuildSystemDirectory; + cmLinkedTree::iterator Vars; + cmLinkedTree::iterator Root; + cmLinkedTree::iterator Parent; std::string EntryPointCommand; long EntryPointLine; std::vector::size_type IncludeDirectoryPosition; @@ -275,6 +279,10 @@ cmState::Snapshot cmState::Reset() pos->PolicyScope = this->PolicyStack.Root(); assert(pos->Policies.IsValid()); assert(pos->PolicyRoot.IsValid()); + this->VarTree.Clear(); + pos->Vars = this->VarTree.Extend(this->VarTree.Root()); + pos->Parent = this->VarTree.Root(); + pos->Root = this->VarTree.Root(); this->DefineProperty ("RULE_LAUNCH_COMPILE", cmProperty::DIRECTORY, @@ -752,6 +760,10 @@ cmState::Snapshot cmState::CreateBaseSnapshot() pos->PolicyScope = this->PolicyStack.Root(); assert(pos->Policies.IsValid()); assert(pos->PolicyRoot.IsValid()); + pos->Vars = this->VarTree.Extend(this->VarTree.Root()); + assert(pos->Vars.IsValid()); + pos->Parent = this->VarTree.Root(); + pos->Root = this->VarTree.Root(); return cmState::Snapshot(this, pos); } @@ -779,6 +791,12 @@ cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot, pos->PolicyScope = originSnapshot.Position->Policies; assert(pos->Policies.IsValid()); assert(pos->PolicyRoot.IsValid()); + + cmLinkedTree::iterator origin = + originSnapshot.Position->Vars; + pos->Parent = origin; + pos->Root = origin; + pos->Vars = this->VarTree.Extend(origin); return cmState::Snapshot(this, pos); } @@ -798,6 +816,11 @@ cmState::CreateFunctionCallSnapshot(cmState::Snapshot originSnapshot, originSnapshot.Position->ExecutionListFile, fileName); pos->BuildSystemDirectory->DirectoryEnd = pos; pos->PolicyScope = originSnapshot.Position->Policies; + assert(originSnapshot.Position->Vars.IsValid()); + cmLinkedTree::iterator origin = + originSnapshot.Position->Vars; + pos->Parent = origin; + pos->Vars = this->VarTree.Extend(origin); return cmState::Snapshot(this, pos); } @@ -815,6 +838,7 @@ cmState::CreateMacroCallSnapshot(cmState::Snapshot originSnapshot, pos->SnapshotType = MacroCallType; pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile, fileName); + assert(originSnapshot.Position->Vars.IsValid()); pos->BuildSystemDirectory->DirectoryEnd = pos; pos->PolicyScope = originSnapshot.Position->Policies; return cmState::Snapshot(this, pos); @@ -833,6 +857,7 @@ cmState::CreateCallStackSnapshot(cmState::Snapshot originSnapshot, pos->SnapshotType = CallStackType; pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile, fileName); + assert(originSnapshot.Position->Vars.IsValid()); pos->BuildSystemDirectory->DirectoryEnd = pos; pos->PolicyScope = originSnapshot.Position->Policies; return cmState::Snapshot(this, pos); @@ -849,7 +874,13 @@ cmState::CreateVariableScopeSnapshot(cmState::Snapshot originSnapshot, pos->EntryPointLine = entryPointLine; pos->EntryPointCommand = entryPointCommand; pos->SnapshotType = VariableScopeType; + assert(originSnapshot.Position->Vars.IsValid()); + cmLinkedTree::iterator origin = + originSnapshot.Position->Vars; + pos->Parent = origin; + pos->Vars = this->VarTree.Extend(origin); + assert(pos->Vars.IsValid()); return cmState::Snapshot(this, pos); } @@ -1141,6 +1172,72 @@ bool cmState::Snapshot::HasDefinedPolicyCMP0011() return !this->Position->Policies->IsEmpty(); } +const char* cmState::Snapshot::GetDefinition(std::string const& name) const +{ + assert(this->Position->Vars.IsValid()); + return cmDefinitions::Get(name, this->Position->Vars, + this->Position->Root); +} + +bool cmState::Snapshot::IsInitialized(std::string const& name) const +{ + return cmDefinitions::HasKey(name, this->Position->Vars, + this->Position->Root); +} + +void cmState::Snapshot::SetDefinition(std::string const& name, + std::string const& value) +{ + this->Position->Vars->Set(name, value.c_str()); +} + +void cmState::Snapshot::RemoveDefinition(std::string const& name) +{ + this->Position->Vars->Set(name, 0); +} + +std::vector cmState::Snapshot::UnusedKeys() const +{ + return this->Position->Vars->UnusedKeys(); +} + +std::vector cmState::Snapshot::ClosureKeys() const +{ + return cmDefinitions::ClosureKeys(this->Position->Vars, + this->Position->Root); +} + +bool cmState::Snapshot::RaiseScope(std::string const& var, const char* varDef) +{ + if(this->Position->ScopeParent == this->Position->DirectoryParent) + { + Snapshot parentDir = this->GetBuildsystemDirectoryParent(); + if(!parentDir.IsValid()) + { + return false; + } + // Update the definition in the parent directory top scope. This + // directory's scope was initialized by the closure of the parent + // scope, so we do not need to localize the definition first. + if (varDef) + { + parentDir.SetDefinition(var, varDef); + } + else + { + parentDir.RemoveDefinition(var); + } + return true; + } + // First localize the definition in the current scope. + cmDefinitions::Raise(var, this->Position->Vars, + this->Position->Root); + + // Now update the definition in the parent scope. + this->Position->Parent->Set(var, varDef); + return true; +} + static const std::string cmPropertySentinal = std::string(); template @@ -1177,6 +1274,11 @@ void InitializeContentFromParent(T& parentContent, void cmState::Snapshot::InitializeFromParent() { PositionType parent = this->Position->DirectoryParent; + assert(this->Position->Vars.IsValid()); + assert(parent->Vars.IsValid()); + + *this->Position->Vars = + cmDefinitions::MakeClosure(parent->Vars, parent->Root); InitializeContentFromParent(parent->BuildSystemDirectory->IncludeDirectories, this->Position->BuildSystemDirectory->IncludeDirectories, diff --git a/Source/cmState.h b/Source/cmState.h index 4d87653..5499665 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -21,6 +21,8 @@ class cmake; class cmCommand; +class cmDefinitions; +class cmListFileBacktrace; class cmState { @@ -52,6 +54,14 @@ public: Snapshot(cmState* state = 0); Snapshot(cmState* state, PositionType position); + const char* GetDefinition(std::string const& name) const; + bool IsInitialized(std::string const& name) const; + void SetDefinition(std::string const& name, std::string const& value); + void RemoveDefinition(std::string const& name); + std::vector UnusedKeys() const; + std::vector ClosureKeys() const; + bool RaiseScope(std::string const& var, const char* varDef); + void SetListFile(std::string const& listfile); std::string GetExecutionListFile() const; @@ -273,6 +283,7 @@ private: cmLinkedTree PolicyStack; cmLinkedTree SnapshotData; + cmLinkedTree VarTree; std::vector SourceDirectoryComponents; std::vector BinaryDirectoryComponents; ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From steveire at gmail.com Sun Aug 23 15:20:42 2015 From: steveire at gmail.com (Stephen Kelly) Date: Sun, 23 Aug 2015 15:20:42 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2352-g4e4b0ee Message-ID: <20150823192042.865F0B15F9@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 4e4b0eedf8184e832991b63e8109b1b04c925da5 (commit) via d8a571483950527c7f44b813a3b73eb1dbbc5435 (commit) from 29dfc9fdd943f4f651ad6f293a30528209af847b (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4e4b0eedf8184e832991b63e8109b1b04c925da5 commit 4e4b0eedf8184e832991b63e8109b1b04c925da5 Merge: 29dfc9f d8a5714 Author: Stephen Kelly AuthorDate: Sun Aug 23 15:20:41 2015 -0400 Commit: CMake Topic Stage CommitDate: Sun Aug 23 15:20:41 2015 -0400 Merge topic 'remove-unused-cmPolicies' into next d8a57148 cmake: Remove unused cmPolicies member. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d8a571483950527c7f44b813a3b73eb1dbbc5435 commit d8a571483950527c7f44b813a3b73eb1dbbc5435 Author: Stephen Kelly AuthorDate: Sun Aug 23 18:21:21 2015 +0200 Commit: Stephen Kelly CommitDate: Sun Aug 23 18:28:01 2015 +0200 cmake: Remove unused cmPolicies member. heaptrack showed a 1 byte allocation with the backtrace pointing here, as is the case since commit v3.3.0-rc1~112^2~5 (cmPolicies: Remove unused cmPolicy class., 2015-05-03) diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 62b3f83..1f5c4d4 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -133,7 +133,6 @@ cmake::cmake() this->ClearBuildSystem = false; this->FileComparison = new cmFileTimeComparison; - this->Policies = new cmPolicies(); this->State = new cmState(this); this->CurrentSnapshot = this->State->CreateBaseSnapshot(); @@ -171,7 +170,6 @@ cmake::cmake() cmake::~cmake() { delete this->CacheManager; - delete this->Policies; delete this->State; if (this->GlobalGenerator) { diff --git a/Source/cmake.h b/Source/cmake.h index 31f55ac..8ac8897 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -27,7 +27,6 @@ class cmVariableWatch; class cmFileTimeComparison; class cmExternalMakefileProjectGenerator; class cmDocumentationSection; -class cmPolicies; class cmTarget; class cmGeneratedFileStream; @@ -340,7 +339,6 @@ protected: void AddExtraGenerator(const std::string& name, CreateExtraGeneratorFunctionType newFunction); - cmPolicies *Policies; cmGlobalGenerator *GlobalGenerator; cmCacheManager *CacheManager; std::map WarningLevels; ----------------------------------------------------------------------- Summary of changes: Source/cmake.cxx | 2 -- Source/cmake.h | 2 -- 2 files changed, 4 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Mon Aug 24 00:01:08 2015 From: kwrobot at kitware.com (Kitware Robot) Date: Mon, 24 Aug 2015 00:01:08 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-898-g884c631 Message-ID: <20150824040108.89814B183F@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 884c63176f79b03e1cb57a24ad70760be000214d (commit) from b5f17d1b8038f2ed64faf4e56d3e407e7a848d52 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=884c63176f79b03e1cb57a24ad70760be000214d commit 884c63176f79b03e1cb57a24ad70760be000214d Author: Kitware Robot AuthorDate: Mon Aug 24 00:01:06 2015 -0400 Commit: Kitware Robot CommitDate: Mon Aug 24 00:01:06 2015 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 736bc49..cfbeab3 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150823) +set(CMake_VERSION_PATCH 20150824) #set(CMake_VERSION_RC 1) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From chuck.atkins at kitware.com Mon Aug 24 09:14:03 2015 From: chuck.atkins at kitware.com (Chuck Atkins) Date: Mon, 24 Aug 2015 09:14:03 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2354-ga545cec Message-ID: <20150824131403.3593EB11F0@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via a545cecbf50d59685021f45c51b6f34052b55f82 (commit) via 8354d1e6ce354692d0b5a157531c1428530d2737 (commit) from 4e4b0eedf8184e832991b63e8109b1b04c925da5 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a545cecbf50d59685021f45c51b6f34052b55f82 commit a545cecbf50d59685021f45c51b6f34052b55f82 Merge: 4e4b0ee 8354d1e Author: Chuck Atkins AuthorDate: Mon Aug 24 09:14:01 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 24 09:14:01 2015 -0400 Merge topic 'add-shared-link-flags-to-try_compile' into next 8354d1e6 try_compile: Pass hared library link flags into test project http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8354d1e6ce354692d0b5a157531c1428530d2737 commit 8354d1e6ce354692d0b5a157531c1428530d2737 Author: Chuck Atkins AuthorDate: Fri Aug 21 14:34:51 2015 -0400 Commit: Chuck Atkins CommitDate: Fri Aug 21 14:55:55 2015 -0400 try_compile: Pass hared library link flags into test project Copy CMAKE_SHARED_LIBRARY_LINK__FLAGS into the test project generated by try_compile, just like we already copy CMAKE_EXE_LINK_FLAGS (see policy CMP0056). For various compatibility reasons, the CMAKE_SHARED_LIBRARY_LINK__FLAGS are always used on executables. While these flags are usually set by the appropriate Platform and / or Toolchain file, a project may wish to override them (e.g. remove -rdynamic when linking agains a static runtime). In such a case, the project defined flags were not getting used for try_compile operations. Now they are. Add CMake Policy CMP0065 to activate this behavior in the same way that CMP0056 passes the CMAKE_EXE_LINK_FLAGS. Extend the RunCMake.try_compile test with a case covering this behavior for each policy setting. diff --git a/Help/command/try_compile.rst b/Help/command/try_compile.rst index 1ed24df..3131bdc 100644 --- a/Help/command/try_compile.rst +++ b/Help/command/try_compile.rst @@ -105,7 +105,10 @@ default values: * :variable:`CMAKE_POSITION_INDEPENDENT_CODE` If :policy:`CMP0056` is set to ``NEW``, then -:variable:`CMAKE_EXE_LINKER_FLAGS` is passed in as well. +:variable:`CMAKE_EXE_LINKER_FLAGS` is passed in. + +If :policy:`CMP0065` is set to ``NEW``, then +:variable:`CMAKE_SHARED_LIBRARY_LINK__FLAGS` is also passed in. Set the :variable:`CMAKE_TRY_COMPILE_CONFIGURATION` variable to choose a build configuration. diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst index 590f10d..ae5354f 100644 --- a/Help/manual/cmake-policies.7.rst +++ b/Help/manual/cmake-policies.7.rst @@ -122,3 +122,4 @@ All Policies /policy/CMP0062 /policy/CMP0063 /policy/CMP0064 + /policy/CMP0065 diff --git a/Help/policy/CMP0065.rst b/Help/policy/CMP0065.rst new file mode 100644 index 0000000..cbabd69 --- /dev/null +++ b/Help/policy/CMP0065.rst @@ -0,0 +1,38 @@ +CMP0065 +------- + +Honor shared library link flags in :command:`try_compile` source-file +signature. + +The :command:`try_compile` command source-file signature generates a +``CMakeLists.txt`` file to build the source file into an executable. +In order to compile the source the same way as it might be compiled +by the calling project, the generated project sets the value of the +:variable:`CMAKE__FLAGS` variable to that in the calling project. +The value of the :variable:`CMAKE_SHARED_LIBRARY_LINK__FLAGS` +variable may be needed in some cases, when it's changed from the +default settings in the Platform or Toolchain file, but CMake 3.3.1 and +lower did not set it in the generated project. CMake 3.3.2 and above +prefer to set it so that the additional linker flags are honored as +well as compiler flags. This policy provides compatibility with the +pre-3.3.2 behavior. + +The OLD behavior for this policy is to not set the value of the +:variable:`CMAKE_SHARED_LIBRARY_LINK__FLAGS` variable in the +generated test project and just rely on the values loaded from the +Platform file. The NEW behavior for this policy is to set the value of +the :variable:`CMAKE_SHARED_LIBRARY_LINK__FLAGS` variable in the +test project to the same as it is in the calling project. + +If the project code does not set the policy explicitly, users may +set it on the command line by defining the +:variable:`CMAKE_POLICY_DEFAULT_CMP0065 >` +variable in the cache. + +This policy was introduced in CMake version 3.3.2. Unlike most policies, +CMake version |release| does *not* warn by default when this policy +is not set and simply uses OLD behavior. See documentation of the +:variable:`CMAKE_POLICY_WARNING_CMP0065 >` +variable to control the warning. + +.. include:: DEPRECATED.txt diff --git a/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst b/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst index 8de0d56..582f9e4 100644 --- a/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst +++ b/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst @@ -13,6 +13,8 @@ warn by default: policy :policy:`CMP0056`. * ``CMAKE_POLICY_WARNING_CMP0060`` controls the warning for policy :policy:`CMP0060`. +* ``CMAKE_POLICY_WARNING_CMP0065`` controls the warning for + policy :policy:`CMP0065`. This variable should not be set by a project in CMake code. Project developers running CMake may set this variable in their cache to diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 9411555..a2d12a7 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -326,6 +326,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) fprintf(fout, "set(CMAKE_%s_FLAGS \"${CMAKE_%s_FLAGS}" " ${COMPILE_DEFINITIONS}\")\n", li->c_str(), li->c_str()); } + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0056)) { case cmPolicies::WARN: @@ -361,6 +362,44 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) } fprintf(fout, "set(CMAKE_EXE_LINKER_FLAGS \"${CMAKE_EXE_LINKER_FLAGS}" " ${EXE_LINKER_FLAGS}\")\n"); + + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0065)) + { + case cmPolicies::WARN: + if(this->Makefile->PolicyOptionalWarningEnabled( + "CMAKE_POLICY_WARNING_CMP0065")) + { + std::ostringstream w; + w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0065) << "\n" + "For compatibility with older versions of CMake, try_compile " + "is not honoring caller link flags (e.g. " + "CMAKE_SHARED_LIBRARY_LINK__FLAGS) in the test project." + ; + this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + } + case cmPolicies::OLD: + // OLD behavior is to do nothing. + break; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + this->Makefile->IssueMessage( + cmake::FATAL_ERROR, + cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0065) + ); + case cmPolicies::NEW: + // NEW behavior is to pass linker flags. + { + for(std::set::iterator li = testLangs.begin(); + li != testLangs.end(); ++li) + { + std::string var = "CMAKE_SHARED_LIBRARY_LINK_" + *li + "_FLAGS"; + const char* val = this->Makefile->GetDefinition(var); + fprintf(fout, "set(%s %s)\n", var.c_str(), + cmOutputConverter::EscapeForCMake(val?val:"").c_str()); + } + } break; + } + fprintf(fout, "include_directories(${INCLUDE_DIRECTORIES})\n"); fprintf(fout, "set(CMAKE_SUPPRESS_REGENERATION 1)\n"); fprintf(fout, "link_directories(${LINK_DIRECTORIES})\n"); diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index a791b89..5063249 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -195,7 +195,7 @@ class cmPolicy; "Strict checking for break() command.", \ 3, 2, 0, cmPolicies::WARN) \ SELECT(POLICY, CMP0056, \ - "Honor link flags in try_compile() source-file signature.", \ + "Honor exe link flags in try_compile() source-file signature.", \ 3, 2, 0, cmPolicies::WARN) \ SELECT(POLICY, CMP0057, \ "Support new IN_LIST if() operator.", \ @@ -220,7 +220,10 @@ class cmPolicy; 3, 3, 0, cmPolicies::WARN) \ SELECT(POLICY, CMP0064, \ "Support new TEST if() operator.", \ - 3, 3, 0, cmPolicies::WARN) + 3, 3, 0, cmPolicies::WARN) \ + SELECT(POLICY, CMP0065, \ + "Honor shared lib link flags in try_compile() source-file signature.", \ + 3, 2, 0, cmPolicies::WARN) #define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1) #define CM_FOR_EACH_POLICY_ID(POLICY) \ diff --git a/Tests/RunCMake/try_compile/CMP0056-stderr.txt b/Tests/RunCMake/try_compile/CMP0056-stderr.txt index 5c1f0e4..2adc3e5 100644 --- a/Tests/RunCMake/try_compile/CMP0056-stderr.txt +++ b/Tests/RunCMake/try_compile/CMP0056-stderr.txt @@ -2,9 +2,10 @@ before try_compile with CMP0056 WARN-default after try_compile with CMP0056 WARN-default * CMake Warning \(dev\) at CMP0056.cmake:[0-9]+ \(try_compile\): - Policy CMP0056 is not set: Honor link flags in try_compile\(\) source-file - signature. Run "cmake --help-policy CMP0056" for policy details. Use the - cmake_policy command to set the policy and suppress this warning. + Policy CMP0056 is not set: Honor exe link flags in try_compile\(\) + source-file signature. Run "cmake --help-policy CMP0056" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. For compatibility with older versions of CMake, try_compile is not honoring caller link flags \(e.g. CMAKE_EXE_LINKER_FLAGS\) in the test project. diff --git a/Tests/RunCMake/try_compile/CMP0065-stderr.txt b/Tests/RunCMake/try_compile/CMP0065-stderr.txt new file mode 100644 index 0000000..5bf1fff --- /dev/null +++ b/Tests/RunCMake/try_compile/CMP0065-stderr.txt @@ -0,0 +1,15 @@ +before try_compile with CMP0065 WARN-default +after try_compile with CMP0065 WARN-default +* +CMake Warning \(dev\) at CMP0065.cmake:[0-9]+ \(try_compile\): + Policy CMP0065 is not set: Honor shared lib link flags in try_compile\(\) + source-file signature. Run "cmake --help-policy CMP0065" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + For compatibility with older versions of CMake, try_compile is not honoring + caller link flags \(e.g. CMAKE_SHARED_LIBRARY_LINK__FLAGS\) in the + test project. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it.$ diff --git a/Tests/RunCMake/try_compile/CMP0065-stdout.txt b/Tests/RunCMake/try_compile/CMP0065-stdout.txt new file mode 100644 index 0000000..ba03ea7 --- /dev/null +++ b/Tests/RunCMake/try_compile/CMP0065-stdout.txt @@ -0,0 +1,4 @@ +-- try_compile with CMP0065 WARN-default worked as expected +-- try_compile with CMP0065 WARN-enabled worked as expected +-- try_compile with CMP0065 OLD worked as expected +-- try_compile with CMP0065 NEW worked as expected diff --git a/Tests/RunCMake/try_compile/CMP0065.cmake b/Tests/RunCMake/try_compile/CMP0065.cmake new file mode 100644 index 0000000..942f872 --- /dev/null +++ b/Tests/RunCMake/try_compile/CMP0065.cmake @@ -0,0 +1,67 @@ +enable_language(C) +set(obj "${CMAKE_C_OUTPUT_EXTENSION}") +if(BORLAND) + set(pre -) +endif() +set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS ${pre}BADFLAG${obj}) + +#----------------------------------------------------------------------------- +message("before try_compile with CMP0065 WARN-default") +try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/src.c + OUTPUT_VARIABLE out + ) +string(REPLACE "\n" "\n " out " ${out}") +if(NOT RESULT) + message(FATAL_ERROR "try_compile failed but should have passed:\n${out}") +elseif("x${out}" MATCHES "BADFLAG") + message(FATAL_ERROR "try_compile output mentions BADFLAG:\n${out}") +else() + message(STATUS "try_compile with CMP0065 WARN-default worked as expected") +endif() +message("after try_compile with CMP0065 WARN-default") + +#----------------------------------------------------------------------------- +set(CMAKE_POLICY_WARNING_CMP0065 ON) +try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/src.c + OUTPUT_VARIABLE out + ) +string(REPLACE "\n" "\n " out " ${out}") +if(NOT RESULT) + message(FATAL_ERROR "try_compile failed but should have passed:\n${out}") +elseif("x${out}" MATCHES "BADFLAG") + message(FATAL_ERROR "try_compile output mentions BADFLAG:\n${out}") +else() + message(STATUS "try_compile with CMP0065 WARN-enabled worked as expected") +endif() + +#----------------------------------------------------------------------------- +cmake_policy(SET CMP0065 OLD) +try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/src.c + OUTPUT_VARIABLE out + ) +string(REPLACE "\n" "\n " out " ${out}") +if(NOT RESULT) + message(FATAL_ERROR "try_compile failed but should have passed:\n${out}") +elseif("x${out}" MATCHES "BADFLAG") + message(FATAL_ERROR "try_compile output mentions BADFLAG:\n${out}") +else() + message(STATUS "try_compile with CMP0065 OLD worked as expected") +endif() + +#----------------------------------------------------------------------------- +cmake_policy(SET CMP0065 NEW) +try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/src.c + OUTPUT_VARIABLE out + ) +string(REPLACE "\n" "\n " out " ${out}") +if(RESULT) + message(FATAL_ERROR "try_compile passed but should have failed:\n${out}") +elseif(NOT "x${out}" MATCHES "BADFLAG") + message(FATAL_ERROR "try_compile did not fail with BADFLAG:\n${out}") +else() + message(STATUS "try_compile with CMP0065 NEW worked as expected") +endif() diff --git a/Tests/RunCMake/try_compile/RunCMakeTest.cmake b/Tests/RunCMake/try_compile/RunCMakeTest.cmake index 6cdbafa..98282e4 100644 --- a/Tests/RunCMake/try_compile/RunCMakeTest.cmake +++ b/Tests/RunCMake/try_compile/RunCMakeTest.cmake @@ -17,6 +17,7 @@ run_cmake(NonSourceCopyFile) run_cmake(NonSourceCompileDefinitions) run_cmake(CMP0056) +run_cmake(CMP0065) if(RunCMake_GENERATOR MATCHES "Make|Ninja") # Use a single build tree for a few tests without cleaning. ----------------------------------------------------------------------- Summary of changes: Help/command/try_compile.rst | 5 ++- Help/manual/cmake-policies.7.rst | 1 + Help/policy/CMP0065.rst | 38 +++++++++++++++++++ Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst | 2 + Source/cmCoreTryCompile.cxx | 39 ++++++++++++++++++++ Source/cmPolicies.h | 7 +++- Tests/RunCMake/try_compile/CMP0056-stderr.txt | 7 ++-- Tests/RunCMake/try_compile/CMP0065-stderr.txt | 15 ++++++++ Tests/RunCMake/try_compile/CMP0065-stdout.txt | 4 ++ .../try_compile/{CMP0056.cmake => CMP0065.cmake} | 20 +++++----- Tests/RunCMake/try_compile/RunCMakeTest.cmake | 1 + 11 files changed, 123 insertions(+), 16 deletions(-) create mode 100644 Help/policy/CMP0065.rst create mode 100644 Tests/RunCMake/try_compile/CMP0065-stderr.txt create mode 100644 Tests/RunCMake/try_compile/CMP0065-stdout.txt copy Tests/RunCMake/try_compile/{CMP0056.cmake => CMP0065.cmake} (78%) hooks/post-receive -- CMake From chuck.atkins at kitware.com Mon Aug 24 09:32:18 2015 From: chuck.atkins at kitware.com (Chuck Atkins) Date: Mon, 24 Aug 2015 09:32:18 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2356-g30053d2 Message-ID: <20150824133218.C0725B1A6D@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 30053d2113a57e86404da58bfb0e4e3d44c46743 (commit) via 1297f3dfb106803a002d8f0505bb5d54983c62cf (commit) from a545cecbf50d59685021f45c51b6f34052b55f82 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=30053d2113a57e86404da58bfb0e4e3d44c46743 commit 30053d2113a57e86404da58bfb0e4e3d44c46743 Merge: a545cec 1297f3d Author: Chuck Atkins AuthorDate: Mon Aug 24 09:32:18 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 24 09:32:18 2015 -0400 Merge topic 'add-shared-link-flags-to-try_compile' into next 1297f3df help: Remove bad references to CMAKE_SHARED_LIBRARY_LINK__FLAGS http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1297f3dfb106803a002d8f0505bb5d54983c62cf commit 1297f3dfb106803a002d8f0505bb5d54983c62cf Author: Chuck Atkins AuthorDate: Mon Aug 24 09:31:27 2015 -0400 Commit: Chuck Atkins CommitDate: Mon Aug 24 09:31:27 2015 -0400 help: Remove bad references to CMAKE_SHARED_LIBRARY_LINK__FLAGS diff --git a/Help/command/try_compile.rst b/Help/command/try_compile.rst index 3131bdc..a014b98 100644 --- a/Help/command/try_compile.rst +++ b/Help/command/try_compile.rst @@ -108,7 +108,7 @@ If :policy:`CMP0056` is set to ``NEW``, then :variable:`CMAKE_EXE_LINKER_FLAGS` is passed in. If :policy:`CMP0065` is set to ``NEW``, then -:variable:`CMAKE_SHARED_LIBRARY_LINK__FLAGS` is also passed in. +CMAKE_SHARED_LIBRARY_LINK__FLAGS is also passed in. Set the :variable:`CMAKE_TRY_COMPILE_CONFIGURATION` variable to choose a build configuration. diff --git a/Help/policy/CMP0065.rst b/Help/policy/CMP0065.rst index cbabd69..168b338 100644 --- a/Help/policy/CMP0065.rst +++ b/Help/policy/CMP0065.rst @@ -9,20 +9,19 @@ The :command:`try_compile` command source-file signature generates a In order to compile the source the same way as it might be compiled by the calling project, the generated project sets the value of the :variable:`CMAKE__FLAGS` variable to that in the calling project. -The value of the :variable:`CMAKE_SHARED_LIBRARY_LINK__FLAGS` -variable may be needed in some cases, when it's changed from the -default settings in the Platform or Toolchain file, but CMake 3.3.1 and -lower did not set it in the generated project. CMake 3.3.2 and above -prefer to set it so that the additional linker flags are honored as -well as compiler flags. This policy provides compatibility with the -pre-3.3.2 behavior. +The value of the CMAKE_SHARED_LIBRARY_LINK__FLAGS variable may be +needed in some cases, when it's changed from the default settings in the +Platform or Toolchain file, but CMake 3.3.1 and lower did not set it in +the generated project. CMake 3.3.2 and above prefer to set it so that +the additional linker flags are honored as well as compiler flags. This +policy provides compatibility with the pre-3.3.2 behavior. The OLD behavior for this policy is to not set the value of the -:variable:`CMAKE_SHARED_LIBRARY_LINK__FLAGS` variable in the -generated test project and just rely on the values loaded from the -Platform file. The NEW behavior for this policy is to set the value of -the :variable:`CMAKE_SHARED_LIBRARY_LINK__FLAGS` variable in the -test project to the same as it is in the calling project. +CMAKE_SHARED_LIBRARY_LINK__FLAGS variable in the generated test +project and just rely on the values loaded from the Platform file. The +NEW behavior for this policy is to set the value of the +CMAKE_SHARED_LIBRARY_LINK__FLAGS variable in the test project to +the same as it is in the calling project. If the project code does not set the policy explicitly, users may set it on the command line by defining the ----------------------------------------------------------------------- Summary of changes: Help/command/try_compile.rst | 2 +- Help/policy/CMP0065.rst | 23 +++++++++++------------ 2 files changed, 12 insertions(+), 13 deletions(-) hooks/post-receive -- CMake From chuck.atkins at kitware.com Mon Aug 24 09:33:25 2015 From: chuck.atkins at kitware.com (Chuck Atkins) Date: Mon, 24 Aug 2015 09:33:25 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2358-gf144891 Message-ID: <20150824133325.0AAFDB1AA6@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via f14489162bdef3afcc7c6da88adaf1b7aac10a81 (commit) via 96e04e199be36cfdd3ebda4a8714cc498e661bea (commit) from 30053d2113a57e86404da58bfb0e4e3d44c46743 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f14489162bdef3afcc7c6da88adaf1b7aac10a81 commit f14489162bdef3afcc7c6da88adaf1b7aac10a81 Merge: 30053d2 96e04e1 Author: Chuck Atkins AuthorDate: Mon Aug 24 09:33:24 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 24 09:33:24 2015 -0400 Merge topic 'add-shared-link-flags-to-try_compile' into next 96e04e19 try_compile: Pass hared library link flags into test project http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=96e04e199be36cfdd3ebda4a8714cc498e661bea commit 96e04e199be36cfdd3ebda4a8714cc498e661bea Author: Chuck Atkins AuthorDate: Fri Aug 21 14:34:51 2015 -0400 Commit: Chuck Atkins CommitDate: Mon Aug 24 09:33:02 2015 -0400 try_compile: Pass hared library link flags into test project Copy CMAKE_SHARED_LIBRARY_LINK__FLAGS into the test project generated by try_compile, just like we already copy CMAKE_EXE_LINK_FLAGS (see policy CMP0056). For various compatibility reasons, the CMAKE_SHARED_LIBRARY_LINK__FLAGS are always used on executables. While these flags are usually set by the appropriate Platform and / or Toolchain file, a project may wish to override them (e.g. remove -rdynamic when linking agains a static runtime). In such a case, the project defined flags were not getting used for try_compile operations. Now they are. Add CMake Policy CMP0065 to activate this behavior in the same way that CMP0056 passes the CMAKE_EXE_LINK_FLAGS. Extend the RunCMake.try_compile test with a case covering this behavior for each policy setting. diff --git a/Help/command/try_compile.rst b/Help/command/try_compile.rst index 1ed24df..a014b98 100644 --- a/Help/command/try_compile.rst +++ b/Help/command/try_compile.rst @@ -105,7 +105,10 @@ default values: * :variable:`CMAKE_POSITION_INDEPENDENT_CODE` If :policy:`CMP0056` is set to ``NEW``, then -:variable:`CMAKE_EXE_LINKER_FLAGS` is passed in as well. +:variable:`CMAKE_EXE_LINKER_FLAGS` is passed in. + +If :policy:`CMP0065` is set to ``NEW``, then +CMAKE_SHARED_LIBRARY_LINK__FLAGS is also passed in. Set the :variable:`CMAKE_TRY_COMPILE_CONFIGURATION` variable to choose a build configuration. diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst index 590f10d..ae5354f 100644 --- a/Help/manual/cmake-policies.7.rst +++ b/Help/manual/cmake-policies.7.rst @@ -122,3 +122,4 @@ All Policies /policy/CMP0062 /policy/CMP0063 /policy/CMP0064 + /policy/CMP0065 diff --git a/Help/policy/CMP0065.rst b/Help/policy/CMP0065.rst new file mode 100644 index 0000000..168b338 --- /dev/null +++ b/Help/policy/CMP0065.rst @@ -0,0 +1,37 @@ +CMP0065 +------- + +Honor shared library link flags in :command:`try_compile` source-file +signature. + +The :command:`try_compile` command source-file signature generates a +``CMakeLists.txt`` file to build the source file into an executable. +In order to compile the source the same way as it might be compiled +by the calling project, the generated project sets the value of the +:variable:`CMAKE__FLAGS` variable to that in the calling project. +The value of the CMAKE_SHARED_LIBRARY_LINK__FLAGS variable may be +needed in some cases, when it's changed from the default settings in the +Platform or Toolchain file, but CMake 3.3.1 and lower did not set it in +the generated project. CMake 3.3.2 and above prefer to set it so that +the additional linker flags are honored as well as compiler flags. This +policy provides compatibility with the pre-3.3.2 behavior. + +The OLD behavior for this policy is to not set the value of the +CMAKE_SHARED_LIBRARY_LINK__FLAGS variable in the generated test +project and just rely on the values loaded from the Platform file. The +NEW behavior for this policy is to set the value of the +CMAKE_SHARED_LIBRARY_LINK__FLAGS variable in the test project to +the same as it is in the calling project. + +If the project code does not set the policy explicitly, users may +set it on the command line by defining the +:variable:`CMAKE_POLICY_DEFAULT_CMP0065 >` +variable in the cache. + +This policy was introduced in CMake version 3.3.2. Unlike most policies, +CMake version |release| does *not* warn by default when this policy +is not set and simply uses OLD behavior. See documentation of the +:variable:`CMAKE_POLICY_WARNING_CMP0065 >` +variable to control the warning. + +.. include:: DEPRECATED.txt diff --git a/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst b/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst index 8de0d56..582f9e4 100644 --- a/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst +++ b/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst @@ -13,6 +13,8 @@ warn by default: policy :policy:`CMP0056`. * ``CMAKE_POLICY_WARNING_CMP0060`` controls the warning for policy :policy:`CMP0060`. +* ``CMAKE_POLICY_WARNING_CMP0065`` controls the warning for + policy :policy:`CMP0065`. This variable should not be set by a project in CMake code. Project developers running CMake may set this variable in their cache to diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 9411555..a2d12a7 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -326,6 +326,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) fprintf(fout, "set(CMAKE_%s_FLAGS \"${CMAKE_%s_FLAGS}" " ${COMPILE_DEFINITIONS}\")\n", li->c_str(), li->c_str()); } + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0056)) { case cmPolicies::WARN: @@ -361,6 +362,44 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) } fprintf(fout, "set(CMAKE_EXE_LINKER_FLAGS \"${CMAKE_EXE_LINKER_FLAGS}" " ${EXE_LINKER_FLAGS}\")\n"); + + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0065)) + { + case cmPolicies::WARN: + if(this->Makefile->PolicyOptionalWarningEnabled( + "CMAKE_POLICY_WARNING_CMP0065")) + { + std::ostringstream w; + w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0065) << "\n" + "For compatibility with older versions of CMake, try_compile " + "is not honoring caller link flags (e.g. " + "CMAKE_SHARED_LIBRARY_LINK__FLAGS) in the test project." + ; + this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + } + case cmPolicies::OLD: + // OLD behavior is to do nothing. + break; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + this->Makefile->IssueMessage( + cmake::FATAL_ERROR, + cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0065) + ); + case cmPolicies::NEW: + // NEW behavior is to pass linker flags. + { + for(std::set::iterator li = testLangs.begin(); + li != testLangs.end(); ++li) + { + std::string var = "CMAKE_SHARED_LIBRARY_LINK_" + *li + "_FLAGS"; + const char* val = this->Makefile->GetDefinition(var); + fprintf(fout, "set(%s %s)\n", var.c_str(), + cmOutputConverter::EscapeForCMake(val?val:"").c_str()); + } + } break; + } + fprintf(fout, "include_directories(${INCLUDE_DIRECTORIES})\n"); fprintf(fout, "set(CMAKE_SUPPRESS_REGENERATION 1)\n"); fprintf(fout, "link_directories(${LINK_DIRECTORIES})\n"); diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index a791b89..5063249 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -195,7 +195,7 @@ class cmPolicy; "Strict checking for break() command.", \ 3, 2, 0, cmPolicies::WARN) \ SELECT(POLICY, CMP0056, \ - "Honor link flags in try_compile() source-file signature.", \ + "Honor exe link flags in try_compile() source-file signature.", \ 3, 2, 0, cmPolicies::WARN) \ SELECT(POLICY, CMP0057, \ "Support new IN_LIST if() operator.", \ @@ -220,7 +220,10 @@ class cmPolicy; 3, 3, 0, cmPolicies::WARN) \ SELECT(POLICY, CMP0064, \ "Support new TEST if() operator.", \ - 3, 3, 0, cmPolicies::WARN) + 3, 3, 0, cmPolicies::WARN) \ + SELECT(POLICY, CMP0065, \ + "Honor shared lib link flags in try_compile() source-file signature.", \ + 3, 2, 0, cmPolicies::WARN) #define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1) #define CM_FOR_EACH_POLICY_ID(POLICY) \ diff --git a/Tests/RunCMake/try_compile/CMP0056-stderr.txt b/Tests/RunCMake/try_compile/CMP0056-stderr.txt index 5c1f0e4..2adc3e5 100644 --- a/Tests/RunCMake/try_compile/CMP0056-stderr.txt +++ b/Tests/RunCMake/try_compile/CMP0056-stderr.txt @@ -2,9 +2,10 @@ before try_compile with CMP0056 WARN-default after try_compile with CMP0056 WARN-default * CMake Warning \(dev\) at CMP0056.cmake:[0-9]+ \(try_compile\): - Policy CMP0056 is not set: Honor link flags in try_compile\(\) source-file - signature. Run "cmake --help-policy CMP0056" for policy details. Use the - cmake_policy command to set the policy and suppress this warning. + Policy CMP0056 is not set: Honor exe link flags in try_compile\(\) + source-file signature. Run "cmake --help-policy CMP0056" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. For compatibility with older versions of CMake, try_compile is not honoring caller link flags \(e.g. CMAKE_EXE_LINKER_FLAGS\) in the test project. diff --git a/Tests/RunCMake/try_compile/CMP0065-stderr.txt b/Tests/RunCMake/try_compile/CMP0065-stderr.txt new file mode 100644 index 0000000..5bf1fff --- /dev/null +++ b/Tests/RunCMake/try_compile/CMP0065-stderr.txt @@ -0,0 +1,15 @@ +before try_compile with CMP0065 WARN-default +after try_compile with CMP0065 WARN-default +* +CMake Warning \(dev\) at CMP0065.cmake:[0-9]+ \(try_compile\): + Policy CMP0065 is not set: Honor shared lib link flags in try_compile\(\) + source-file signature. Run "cmake --help-policy CMP0065" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + For compatibility with older versions of CMake, try_compile is not honoring + caller link flags \(e.g. CMAKE_SHARED_LIBRARY_LINK__FLAGS\) in the + test project. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it.$ diff --git a/Tests/RunCMake/try_compile/CMP0065-stdout.txt b/Tests/RunCMake/try_compile/CMP0065-stdout.txt new file mode 100644 index 0000000..ba03ea7 --- /dev/null +++ b/Tests/RunCMake/try_compile/CMP0065-stdout.txt @@ -0,0 +1,4 @@ +-- try_compile with CMP0065 WARN-default worked as expected +-- try_compile with CMP0065 WARN-enabled worked as expected +-- try_compile with CMP0065 OLD worked as expected +-- try_compile with CMP0065 NEW worked as expected diff --git a/Tests/RunCMake/try_compile/CMP0065.cmake b/Tests/RunCMake/try_compile/CMP0065.cmake new file mode 100644 index 0000000..942f872 --- /dev/null +++ b/Tests/RunCMake/try_compile/CMP0065.cmake @@ -0,0 +1,67 @@ +enable_language(C) +set(obj "${CMAKE_C_OUTPUT_EXTENSION}") +if(BORLAND) + set(pre -) +endif() +set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS ${pre}BADFLAG${obj}) + +#----------------------------------------------------------------------------- +message("before try_compile with CMP0065 WARN-default") +try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/src.c + OUTPUT_VARIABLE out + ) +string(REPLACE "\n" "\n " out " ${out}") +if(NOT RESULT) + message(FATAL_ERROR "try_compile failed but should have passed:\n${out}") +elseif("x${out}" MATCHES "BADFLAG") + message(FATAL_ERROR "try_compile output mentions BADFLAG:\n${out}") +else() + message(STATUS "try_compile with CMP0065 WARN-default worked as expected") +endif() +message("after try_compile with CMP0065 WARN-default") + +#----------------------------------------------------------------------------- +set(CMAKE_POLICY_WARNING_CMP0065 ON) +try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/src.c + OUTPUT_VARIABLE out + ) +string(REPLACE "\n" "\n " out " ${out}") +if(NOT RESULT) + message(FATAL_ERROR "try_compile failed but should have passed:\n${out}") +elseif("x${out}" MATCHES "BADFLAG") + message(FATAL_ERROR "try_compile output mentions BADFLAG:\n${out}") +else() + message(STATUS "try_compile with CMP0065 WARN-enabled worked as expected") +endif() + +#----------------------------------------------------------------------------- +cmake_policy(SET CMP0065 OLD) +try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/src.c + OUTPUT_VARIABLE out + ) +string(REPLACE "\n" "\n " out " ${out}") +if(NOT RESULT) + message(FATAL_ERROR "try_compile failed but should have passed:\n${out}") +elseif("x${out}" MATCHES "BADFLAG") + message(FATAL_ERROR "try_compile output mentions BADFLAG:\n${out}") +else() + message(STATUS "try_compile with CMP0065 OLD worked as expected") +endif() + +#----------------------------------------------------------------------------- +cmake_policy(SET CMP0065 NEW) +try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/src.c + OUTPUT_VARIABLE out + ) +string(REPLACE "\n" "\n " out " ${out}") +if(RESULT) + message(FATAL_ERROR "try_compile passed but should have failed:\n${out}") +elseif(NOT "x${out}" MATCHES "BADFLAG") + message(FATAL_ERROR "try_compile did not fail with BADFLAG:\n${out}") +else() + message(STATUS "try_compile with CMP0065 NEW worked as expected") +endif() diff --git a/Tests/RunCMake/try_compile/RunCMakeTest.cmake b/Tests/RunCMake/try_compile/RunCMakeTest.cmake index 6cdbafa..98282e4 100644 --- a/Tests/RunCMake/try_compile/RunCMakeTest.cmake +++ b/Tests/RunCMake/try_compile/RunCMakeTest.cmake @@ -17,6 +17,7 @@ run_cmake(NonSourceCopyFile) run_cmake(NonSourceCompileDefinitions) run_cmake(CMP0056) +run_cmake(CMP0065) if(RunCMake_GENERATOR MATCHES "Make|Ninja") # Use a single build tree for a few tests without cleaning. ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 24 09:56:35 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 24 Aug 2015 09:56:35 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2360-g814b038 Message-ID: <20150824135635.3094DB18DE@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 814b038ad7c36209408efbf12183a54afde37a7c (commit) via 744e6c497c01cb3a3129ca66d1cabfa83e17dbd4 (commit) from f14489162bdef3afcc7c6da88adaf1b7aac10a81 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=814b038ad7c36209408efbf12183a54afde37a7c commit 814b038ad7c36209408efbf12183a54afde37a7c Merge: f144891 744e6c4 Author: Brad King AuthorDate: Mon Aug 24 09:56:34 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 24 09:56:34 2015 -0400 Merge topic 'ios-app-bundle-layout' into next 744e6c49 Fix iOS Bundle layouts (#15669) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=744e6c497c01cb3a3129ca66d1cabfa83e17dbd4 commit 744e6c497c01cb3a3129ca66d1cabfa83e17dbd4 Author: Gregor Jasny AuthorDate: Tue Aug 18 21:30:54 2015 +0200 Commit: Brad King CommitDate: Mon Aug 24 09:50:20 2015 -0400 Fix iOS Bundle layouts (#15669) In contrast to Mac OS X App bundle layout the iOS one lacks the Contents/MacOSX structure. See also the Bundle Structures documentation in Mac Developer Library: https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/BundleTypes/BundleTypes.html For now detect iOS targets by checking the SDK name/path. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 299c112..b9f78c6 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -951,9 +951,13 @@ cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, bool contentOnly) const { std::string fpath = this->GetFullName(config, false); - fpath += ".app/Contents"; - if(!contentOnly) - fpath += "/MacOS"; + fpath += ".app"; + if(!this->Makefile->PlatformIsAppleIos()) + { + fpath += "/Contents"; + if(!contentOnly) + fpath += "/MacOS"; + } return fpath; } @@ -985,9 +989,12 @@ std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config, } } fpath += ext; - fpath += "/Contents"; - if(!contentOnly) - fpath += "/MacOS"; + if(!this->Makefile->PlatformIsAppleIos()) + { + fpath += "/Contents"; + if(!contentOnly) + fpath += "/MacOS"; + } return fpath; } @@ -999,7 +1006,7 @@ cmGeneratorTarget::GetFrameworkDirectory(const std::string& config, std::string fpath; fpath += this->GetOutputName(config, false); fpath += ".framework"; - if(!rootDir) + if(!rootDir && !this->Makefile->PlatformIsAppleIos()) { fpath += "/Versions/"; fpath += this->Target->GetFrameworkVersion(); @@ -2146,9 +2153,12 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, if(this->Target->IsFrameworkOnApple()) { realName = prefix; - realName += "Versions/"; - realName += this->Target->GetFrameworkVersion(); - realName += "/"; + if(!this->Makefile->PlatformIsAppleIos()) + { + realName += "Versions/"; + realName += this->Target->GetFrameworkVersion(); + realName += "/"; + } realName += base; soName = realName; } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 85bc493..6e43b52 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2529,6 +2529,18 @@ bool cmMakefile::PlatformIs64Bit() const return false; } +bool cmMakefile::PlatformIsAppleIos() const +{ + std::string sdkRoot; + sdkRoot = this->GetSafeDefinition("CMAKE_OSX_SYSROOT"); + sdkRoot = cmSystemTools::LowerCase(sdkRoot); + + return sdkRoot.find("iphoneos") == 0 || + sdkRoot.find("/iphoneos") != std::string::npos || + sdkRoot.find("iphonesimulator") == 0 || + sdkRoot.find("/iphonesimulator") != std::string::npos; +} + const char* cmMakefile::GetSONameFlag(const std::string& language) const { std::string name = "CMAKE_SHARED_LIBRARY_SONAME"; diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 1c4da00..9f455cc 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -490,6 +490,9 @@ public: /** Return whether the target platform is 64-bit. */ bool PlatformIs64Bit() const; + /** Return whether the target platform is Apple iOS. */ + bool PlatformIsAppleIos() const; + /** Retrieve soname flag for the specified language if supported */ const char* GetSONameFlag(const std::string& language) const; diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake index b7de614..ef81739 100644 --- a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake @@ -7,3 +7,35 @@ run_cmake(XcodeObjectNeedsQuote) if (NOT XCODE_VERSION VERSION_LESS 6) run_cmake(XcodePlatformFrameworks) endif() + +# Use a single build tree for a few tests without cleaning. + +if(NOT XCODE_VERSION VERSION_LESS 5) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeBundlesOSX-build) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_OPTIONS "-DTEST_IOS=OFF") + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake(XcodeBundles) + run_cmake_command(XcodeBundles-build ${CMAKE_COMMAND} --build .) + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) + unset(RunCMake_TEST_OPTIONS) + + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeBundlesIOS-build) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_OPTIONS "-DTEST_IOS=ON") + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake(XcodeBundles) + run_cmake_command(XcodeBundles-build ${CMAKE_COMMAND} --build .) + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) + unset(RunCMake_TEST_OPTIONS) +endif() diff --git a/Tests/RunCMake/XcodeProject/XcodeBundles.cmake b/Tests/RunCMake/XcodeProject/XcodeBundles.cmake new file mode 100644 index 0000000..d5cb51f --- /dev/null +++ b/Tests/RunCMake/XcodeProject/XcodeBundles.cmake @@ -0,0 +1,46 @@ +# check if Xcode and CMake have the same understanding of Bundle layout + +cmake_minimum_required(VERSION 3.3) +enable_language(C) + +if(TEST_IOS) + set(CMAKE_OSX_SYSROOT iphoneos) + set(CMAKE_OSX_ARCHITECTURES "armv7") + set(CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos;-iphonesimulator") + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") + set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO") +endif(TEST_IOS) + +# App Bundle + +add_executable(AppBundle MACOSX_BUNDLE main.m) + +add_custom_target(AppBundleTest ALL + COMMAND ${CMAKE_COMMAND} -E copy + "$" "$.old") + +add_dependencies(AppBundleTest AppBundle) + +# Framework (not supported for iOS on Xcode < 6) + +if(NOT TEST_IOS OR NOT XCODE_VERSION VERSION_LESS 6) + add_library(Framework SHARED main.c) + set_target_properties(Framework PROPERTIES FRAMEWORK TRUE) + + add_custom_target(FrameworkTest ALL + COMMAND ${CMAKE_COMMAND} -E copy + "$" "$.old") + + add_dependencies(FrameworkTest Framework) +endif() + +# Bundle + +add_library(Bundle MODULE main.c) +set_target_properties(Bundle PROPERTIES BUNDLE TRUE) + +add_custom_target(BundleTest ALL + COMMAND ${CMAKE_COMMAND} -E copy + "$" "$.old") + +add_dependencies(BundleTest Bundle) diff --git a/Tests/RunCMake/XcodeProject/main.m b/Tests/RunCMake/XcodeProject/main.m new file mode 100644 index 0000000..6dc190a --- /dev/null +++ b/Tests/RunCMake/XcodeProject/main.m @@ -0,0 +1,3 @@ +int main(int argc, const char * argv[]) { + return 1; +} ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 24 10:06:55 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 24 Aug 2015 10:06:55 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-900-gaaf9532 Message-ID: <20150824140655.BB666B17D1@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via aaf9532bbc2b45288de3350fa9379c10315c98d4 (commit) via a4bd30104fe6df3e4a6a37d0abb640a28126009d (commit) from 884c63176f79b03e1cb57a24ad70760be000214d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=aaf9532bbc2b45288de3350fa9379c10315c98d4 commit aaf9532bbc2b45288de3350fa9379c10315c98d4 Merge: 884c631 a4bd301 Author: Brad King AuthorDate: Mon Aug 24 10:06:54 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 24 10:06:54 2015 -0400 Merge topic 'fix-include_directories-BEFORE' a4bd3010 include_directories: Fix regression in BEFORE option (#15693) ----------------------------------------------------------------------- Summary of changes: Source/cmState.cxx | 11 +++++------ .../RunCMake/include_directories/DirectoryBefore-stdout.txt | 1 + Tests/RunCMake/include_directories/DirectoryBefore.cmake | 4 ++++ Tests/RunCMake/include_directories/RunCMakeTest.cmake | 1 + 4 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 Tests/RunCMake/include_directories/DirectoryBefore-stdout.txt create mode 100644 Tests/RunCMake/include_directories/DirectoryBefore.cmake hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 24 10:06:57 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 24 Aug 2015 10:06:57 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-904-g9135e37 Message-ID: <20150824140657.BB4D0B195F@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 9135e3707d18b3fc37274acc3fca3b9352309a09 (commit) via 1f39ee5bebf66aac33e7e1fa1172c048c13dfd2d (commit) via c259b8302648de1387e21e9ea907cd1a2cb49933 (commit) via 75e511eeaf77848ffef00d570cb10243764f51d2 (commit) from aaf9532bbc2b45288de3350fa9379c10315c98d4 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9135e3707d18b3fc37274acc3fca3b9352309a09 commit 9135e3707d18b3fc37274acc3fca3b9352309a09 Merge: aaf9532 1f39ee5 Author: Brad King AuthorDate: Mon Aug 24 10:06:56 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 24 10:06:56 2015 -0400 Merge topic 'generators-use-cmLocalGenerator' 1f39ee5b cmInstallExportGenerator: Require cmLocalGenerator, not cmMakefile. c259b830 cmTestGenerator: Require cmLocalGenerator, not cmMakefile. 75e511ee cmInstallFilesGenerator: Require cmLocalGenerator, not cmMakefile. ----------------------------------------------------------------------- Summary of changes: Source/cmExportInstallFileGenerator.cxx | 4 ++-- Source/cmInstallCommand.cxx | 4 ++-- Source/cmInstallExportGenerator.cxx | 13 +++++++++---- Source/cmInstallExportGenerator.h | 8 +++++--- Source/cmInstallFilesCommand.cxx | 2 +- Source/cmInstallFilesGenerator.cxx | 15 ++++++++++----- Source/cmInstallFilesGenerator.h | 9 ++++----- Source/cmInstallProgramsCommand.cxx | 2 +- Source/cmLocalGenerator.cxx | 1 + Source/cmTestGenerator.cxx | 19 ++++++++++++++----- Source/cmTestGenerator.h | 4 ++++ 11 files changed, 53 insertions(+), 28 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 24 10:06:59 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 24 Aug 2015 10:06:59 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-911-gd5d86ec Message-ID: <20150824140659.C05B2B1960@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via d5d86ecf50ea5fee2ce85c5ebe0695e477024741 (commit) via 3fa1b9641dd16ad93c64737fd2eeb131cca70f76 (commit) via 55e3927634a4b071c1cf52cc2dc406b8973b82cc (commit) via 04168cbb593be0d58326b09346e90a6348a862ff (commit) via 2394584ce2fa4ff88bb8b196e5a75fc5f848ba4a (commit) via b9eb3cd1405d423bf0156fabc3340c396b1f308c (commit) via f5d2b7a6942ee291f8e0d4e8a7a7869037913de7 (commit) from 9135e3707d18b3fc37274acc3fca3b9352309a09 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d5d86ecf50ea5fee2ce85c5ebe0695e477024741 commit d5d86ecf50ea5fee2ce85c5ebe0695e477024741 Merge: 9135e37 3fa1b96 Author: Brad King AuthorDate: Mon Aug 24 10:06:58 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 24 10:06:58 2015 -0400 Merge topic 'refactor-progress' 3fa1b964 cmGlobalUnixMakefileGenerator3: Change the progress container key. 55e39276 cmState: Make it possible to order cmState::Snapshot. 04168cbb cmGlobalUnixMakefileGenerator3: Rename member. 2394584c cmGlobalGenerator: Rename progress initializer method. b9eb3cd1 cmGlobalGenerator: Move LG to target map to subclass. f5d2b7a6 cmGlobalGenerator: Remove clearance of map. ----------------------------------------------------------------------- Summary of changes: Source/cmGlobalGenerator.cxx | 47 +---------------------------- Source/cmGlobalGenerator.h | 4 +-- Source/cmGlobalUnixMakefileGenerator3.cxx | 45 ++++++++++++++++++++++++++- Source/cmGlobalUnixMakefileGenerator3.h | 5 +++ Source/cmLinkedTree.h | 7 +++++ Source/cmState.cxx | 6 ++++ Source/cmState.h | 7 +++++ 7 files changed, 71 insertions(+), 50 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 24 10:07:01 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 24 Aug 2015 10:07:01 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-913-geeeb0eb Message-ID: <20150824140701.A7042B1AEE@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via eeeb0eb751d98c73fefd42d50f9c92fb7af1e0e8 (commit) via d8a571483950527c7f44b813a3b73eb1dbbc5435 (commit) from d5d86ecf50ea5fee2ce85c5ebe0695e477024741 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=eeeb0eb751d98c73fefd42d50f9c92fb7af1e0e8 commit eeeb0eb751d98c73fefd42d50f9c92fb7af1e0e8 Merge: d5d86ec d8a5714 Author: Brad King AuthorDate: Mon Aug 24 10:07:00 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 24 10:07:00 2015 -0400 Merge topic 'remove-unused-cmPolicies' d8a57148 cmake: Remove unused cmPolicies member. ----------------------------------------------------------------------- Summary of changes: Source/cmake.cxx | 2 -- Source/cmake.h | 2 -- 2 files changed, 4 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 24 10:07:04 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 24 Aug 2015 10:07:04 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-915-g5804388 Message-ID: <20150824140704.19656B1B22@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 58043880b944b1fc09d55f44f4abb4a52adfd288 (commit) via 744e6c497c01cb3a3129ca66d1cabfa83e17dbd4 (commit) from eeeb0eb751d98c73fefd42d50f9c92fb7af1e0e8 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=58043880b944b1fc09d55f44f4abb4a52adfd288 commit 58043880b944b1fc09d55f44f4abb4a52adfd288 Merge: eeeb0eb 744e6c4 Author: Brad King AuthorDate: Mon Aug 24 10:07:02 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 24 10:07:02 2015 -0400 Merge topic 'ios-app-bundle-layout' 744e6c49 Fix iOS Bundle layouts (#15669) ----------------------------------------------------------------------- Summary of changes: Source/cmGeneratorTarget.cxx | 30 ++++++++++------ Source/cmMakefile.cxx | 12 +++++++ Source/cmMakefile.h | 3 ++ Tests/RunCMake/XcodeProject/RunCMakeTest.cmake | 32 +++++++++++++++++ Tests/RunCMake/XcodeProject/XcodeBundles.cmake | 46 ++++++++++++++++++++++++ Tests/RunCMake/XcodeProject/main.m | 3 ++ 6 files changed, 116 insertions(+), 10 deletions(-) create mode 100644 Tests/RunCMake/XcodeProject/XcodeBundles.cmake create mode 100644 Tests/RunCMake/XcodeProject/main.m hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 24 10:07:06 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 24 Aug 2015 10:07:06 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-922-g2370a99 Message-ID: <20150824140706.27D27B1B22@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 2370a99400c6450606e25562386cf40bc9c41f38 (commit) via bff27391a91d1410ef33187c0c35acc0a709720d (commit) via 6954c8936f52dcf7710e4b72b2e090b79bf38d1c (commit) via 1fc645bd9cffb3170743de5c983f2407eeaaa086 (commit) via 0f070dd3e12408e0e33945c3c8f585268c4b0db9 (commit) via 25e04ddffeba6d4b1c9deab1ea42038c322cec83 (commit) via 4bbe261cd34818379d06b68d2e153a98cfccfcf5 (commit) from 58043880b944b1fc09d55f44f4abb4a52adfd288 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2370a99400c6450606e25562386cf40bc9c41f38 commit 2370a99400c6450606e25562386cf40bc9c41f38 Merge: 5804388 bff2739 Author: Brad King AuthorDate: Mon Aug 24 10:07:04 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 24 10:07:04 2015 -0400 Merge topic 'cmState-definitions' bff27391 cmState: Host variable definitions. 6954c893 cmState: Add a VariableScope snapshot type. 1fc645bd cmState: Add a Base snapshot type. 0f070dd3 cmMakefile: Decouple the container of cmDefinitions from scoping logic. 25e04ddf cmDefinitions: Implement in terms of cmLinkedTree. 4bbe261c cmMakefile: Extract InitializeVarScope method. ----------------------------------------------------------------------- Summary of changes: Source/cmDefinitions.cxx | 14 ++--- Source/cmDefinitions.h | 17 +++--- Source/cmMakefile.cxx | 135 ++++++++++------------------------------------ Source/cmState.cxx | 126 ++++++++++++++++++++++++++++++++++++++++++- Source/cmState.h | 18 ++++++- 5 files changed, 185 insertions(+), 125 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 24 10:07:30 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 24 Aug 2015 10:07:30 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2369-gfe6dfb2 Message-ID: <20150824140730.E7540B09C7@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via fe6dfb29181101040f540ded717ebf19c1469cd9 (commit) via 2370a99400c6450606e25562386cf40bc9c41f38 (commit) via 58043880b944b1fc09d55f44f4abb4a52adfd288 (commit) via eeeb0eb751d98c73fefd42d50f9c92fb7af1e0e8 (commit) via d5d86ecf50ea5fee2ce85c5ebe0695e477024741 (commit) via 9135e3707d18b3fc37274acc3fca3b9352309a09 (commit) via aaf9532bbc2b45288de3350fa9379c10315c98d4 (commit) via 884c63176f79b03e1cb57a24ad70760be000214d (commit) via b5f17d1b8038f2ed64faf4e56d3e407e7a848d52 (commit) from 814b038ad7c36209408efbf12183a54afde37a7c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fe6dfb29181101040f540ded717ebf19c1469cd9 commit fe6dfb29181101040f540ded717ebf19c1469cd9 Merge: 814b038 2370a99 Author: Brad King AuthorDate: Mon Aug 24 10:07:23 2015 -0400 Commit: Brad King CommitDate: Mon Aug 24 10:07:23 2015 -0400 Merge branch 'master' into next ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 24 10:40:16 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 24 Aug 2015 10:40:16 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2371-gac00a76 Message-ID: <20150824144016.77E7EB03C5@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via ac00a76e6a3cb80f1b91d7fbf3ca466ef9484908 (commit) via e7f937155f6f8b117d6292b3ffe6cf63c8eda9c0 (commit) from fe6dfb29181101040f540ded717ebf19c1469cd9 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ac00a76e6a3cb80f1b91d7fbf3ca466ef9484908 commit ac00a76e6a3cb80f1b91d7fbf3ca466ef9484908 Merge: fe6dfb2 e7f9371 Author: Brad King AuthorDate: Mon Aug 24 10:40:15 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 24 10:40:15 2015 -0400 Merge topic 'libarchive-modern-apis' into next e7f93715 Use modern libarchive APIs http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e7f937155f6f8b117d6292b3ffe6cf63c8eda9c0 commit e7f937155f6f8b117d6292b3ffe6cf63c8eda9c0 Author: P?der Rezs? AuthorDate: Sat Aug 22 18:14:12 2015 +0200 Commit: Brad King CommitDate: Mon Aug 24 10:40:04 2015 -0400 Use modern libarchive APIs Replace use of deprecated libarchive3 functions with their modern equivalents. diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx index 44d0d4e..9335680 100644 --- a/Source/cmArchiveWrite.cxx +++ b/Source/cmArchiveWrite.cxx @@ -90,49 +90,49 @@ cmArchiveWrite::cmArchiveWrite( switch (c) { case CompressNone: - if(archive_write_set_compression_none(this->Archive) != ARCHIVE_OK) + if(archive_write_add_filter_none(this->Archive) != ARCHIVE_OK) { - this->Error = "archive_write_set_compression_none: "; + this->Error = "archive_write_add_filter_none: "; this->Error += cm_archive_error_string(this->Archive); return; } break; case CompressCompress: - if(archive_write_set_compression_compress(this->Archive) != ARCHIVE_OK) + if(archive_write_add_filter_compress(this->Archive) != ARCHIVE_OK) { - this->Error = "archive_write_set_compression_compress: "; + this->Error = "archive_write_add_filter_compress: "; this->Error += cm_archive_error_string(this->Archive); return; } break; case CompressGZip: - if(archive_write_set_compression_gzip(this->Archive) != ARCHIVE_OK) + if(archive_write_add_filter_gzip(this->Archive) != ARCHIVE_OK) { - this->Error = "archive_write_set_compression_gzip: "; + this->Error = "archive_write_add_filter_gzip: "; this->Error += cm_archive_error_string(this->Archive); return; } break; case CompressBZip2: - if(archive_write_set_compression_bzip2(this->Archive) != ARCHIVE_OK) + if(archive_write_add_filter_bzip2(this->Archive) != ARCHIVE_OK) { - this->Error = "archive_write_set_compression_bzip2: "; + this->Error = "archive_write_add_filter_bzip2: "; this->Error += cm_archive_error_string(this->Archive); return; } break; case CompressLZMA: - if(archive_write_set_compression_lzma(this->Archive) != ARCHIVE_OK) + if(archive_write_add_filter_lzma(this->Archive) != ARCHIVE_OK) { - this->Error = "archive_write_set_compression_lzma: "; + this->Error = "archive_write_add_filter_lzma: "; this->Error += cm_archive_error_string(this->Archive); return; } break; case CompressXZ: - if(archive_write_set_compression_xz(this->Archive) != ARCHIVE_OK) + if(archive_write_add_filter_xz(this->Archive) != ARCHIVE_OK) { - this->Error = "archive_write_set_compression_xz: "; + this->Error = "archive_write_add_filter_xz: "; this->Error += cm_archive_error_string(this->Archive); return; } @@ -177,8 +177,8 @@ cmArchiveWrite::cmArchiveWrite( //---------------------------------------------------------------------------- cmArchiveWrite::~cmArchiveWrite() { - archive_read_finish(this->Disk); - archive_write_finish(this->Archive); + archive_read_free(this->Disk); + archive_write_free(this->Archive); } //---------------------------------------------------------------------------- diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index a117238..eba8d07 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1705,7 +1705,7 @@ bool extract_tar(const char* outFileName, bool verbose, static_cast(localeRAII); struct archive* a = archive_read_new(); struct archive *ext = archive_write_disk_new(); - archive_read_support_compression_all(a); + archive_read_support_filter_all(a); archive_read_support_format_all(a); struct archive_entry *entry; int r = cm_archive_read_open_file(a, outFileName, 10240); @@ -1792,7 +1792,7 @@ bool extract_tar(const char* outFileName, bool verbose, } archive_write_free(ext); archive_read_close(a); - archive_read_finish(a); + archive_read_free(a); return r == ARCHIVE_EOF || r == ARCHIVE_OK; } } ----------------------------------------------------------------------- Summary of changes: Source/cmArchiveWrite.cxx | 28 ++++++++++++++-------------- Source/cmSystemTools.cxx | 4 ++-- 2 files changed, 16 insertions(+), 16 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 24 11:07:23 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 24 Aug 2015 11:07:23 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2373-gd394212 Message-ID: <20150824150725.22E3CB1C18@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via d394212a00197cb777c5cd5b2a887a4a909110eb (commit) via c4d78b8bc05d44b8a46b5d2db6b52b42a101ef2d (commit) from ac00a76e6a3cb80f1b91d7fbf3ca466ef9484908 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d394212a00197cb777c5cd5b2a887a4a909110eb commit d394212a00197cb777c5cd5b2a887a4a909110eb Merge: ac00a76 c4d78b8 Author: Brad King AuthorDate: Mon Aug 24 11:07:20 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 24 11:07:20 2015 -0400 Merge topic 'FindJNI-linux-x32' into next c4d78b8b FindJNI: Add support for x32 architecture on Linux (#15710) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c4d78b8bc05d44b8a46b5d2db6b52b42a101ef2d commit c4d78b8bc05d44b8a46b5d2db6b52b42a101ef2d Author: Thorsten Glaser AuthorDate: Mon Aug 24 10:53:00 2015 -0400 Commit: Brad King CommitDate: Mon Aug 24 10:54:13 2015 -0400 FindJNI: Add support for x32 architecture on Linux (#15710) This architecture uses an amd64 kernel but x32 userland. Use CMAKE_LIBRARY_ARCHITECTURE to distinguish it for now. diff --git a/Modules/FindJNI.cmake b/Modules/FindJNI.cmake index d248fe1..d31fea3 100644 --- a/Modules/FindJNI.cmake +++ b/Modules/FindJNI.cmake @@ -42,7 +42,11 @@ macro(java_append_library_directories _var) # 1.6.0_18 + icedtea patches. However, it would be much better to base the # guess on the first part of the GNU config.guess platform triplet. if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") + if(CMAKE_LIBRARY_ARCHITECTURE STREQUAL "x86_64-linux-gnux32") + set(_java_libarch "x32" "amd64" "i386") + else() set(_java_libarch "amd64" "i386") + endif() elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$") set(_java_libarch "i386") elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^alpha") ----------------------------------------------------------------------- Summary of changes: Modules/FindJNI.cmake | 4 ++++ 1 file changed, 4 insertions(+) hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 24 11:23:50 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 24 Aug 2015 11:23:50 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2376-gf131a52 Message-ID: <20150824152350.16570B19E1@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via f131a5287a3b8a9f37fe1edef6cc95efd9ef78ef (commit) via bdae9ffe9dcc02c110bc5344ea137a82b42c745c (commit) via 0221184fdd5441ea2456fe1ff0fbedbeb8c1a837 (commit) from d394212a00197cb777c5cd5b2a887a4a909110eb (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f131a5287a3b8a9f37fe1edef6cc95efd9ef78ef commit f131a5287a3b8a9f37fe1edef6cc95efd9ef78ef Merge: d394212 bdae9ff Author: Brad King AuthorDate: Mon Aug 24 11:23:49 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 24 11:23:49 2015 -0400 Merge topic 'vs-store-phone-cert-thumbs' into next bdae9ffe VS: Windows Store/Phone package cert thumbprint 0221184f Simplify condition for using rpcrt4 library on Windows http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bdae9ffe9dcc02c110bc5344ea137a82b42c745c commit bdae9ffe9dcc02c110bc5344ea137a82b42c745c Author: Gilles Khouzam AuthorDate: Fri Aug 21 14:15:38 2015 -0700 Commit: Brad King CommitDate: Mon Aug 24 11:05:33 2015 -0400 VS: Windows Store/Phone package cert thumbprint Add the PackageCertificateThumbprint property when there is a certificate on a WindowsStore or Phone app. diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 1886519..16b9ea1 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -558,7 +558,8 @@ endif() if(WIN32 AND NOT UNIX) # We need the rpcrt4 library on Windows. - target_link_libraries(CMakeLib rpcrt4) + # We need the crypt32 library on Windows for crypto/cert APIs. + target_link_libraries(CMakeLib rpcrt4 crypt32) endif() # diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index a117238..3780ec0 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1013,6 +1013,94 @@ std::string cmSystemTools::ComputeStringMD5(const std::string& input) #endif } +//---------------------------------------------------------------------------- +std::string cmSystemTools::ComputeCertificateThumbprint( + const std::string& source) +{ + std::string thumbprint; + +#ifdef _WIN32 + BYTE* certData = NULL; + CRYPT_INTEGER_BLOB cryptBlob; + HCERTSTORE certStore = NULL; + PCCERT_CONTEXT certContext = NULL; + + HANDLE certFile = CreateFile(cmsys::Encoding::ToWide(source.c_str()).c_str(), + GENERIC_READ, + FILE_SHARE_READ, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + + if (certFile != INVALID_HANDLE_VALUE && certFile != NULL) + { + DWORD fileSize = GetFileSize(certFile, NULL); + if (fileSize != INVALID_FILE_SIZE) + { + certData = new BYTE[fileSize]; + if (certData != NULL) + { + DWORD dwRead = NULL; + if (ReadFile(certFile, certData, fileSize, &dwRead, NULL)) + { + cryptBlob.cbData = fileSize; + cryptBlob.pbData = certData; + + // Verify that this is a valid cert + if (PFXIsPFXBlob(&cryptBlob)) + { + // Open the certificate as a store + certStore = PFXImportCertStore( + &cryptBlob, NULL, CRYPT_EXPORTABLE); + if (certStore != NULL) + { + // There should only be 1 cert. + certContext = CertEnumCertificatesInStore(certStore, + certContext); + if (certContext != NULL) + { + // The hash is 20 bytes + BYTE hashData[20]; + DWORD hashLength = 20; + + // Buffer to print the hash. Each byte takes 2 chars + + // terminating character + char hashPrint[41]; + char *pHashPrint = hashPrint; + // Get the hash property from the certificate + if (CertGetCertificateContextProperty(certContext, + CERT_HASH_PROP_ID, hashData, &hashLength)) + { + for (DWORD i = 0; i < hashLength; i++) + { + // Convert each byte to hexadecimal + sprintf(pHashPrint, "%02X", hashData[i]); + pHashPrint += 2; + } + *pHashPrint = '\0'; + thumbprint = hashPrint; + } + CertFreeCertificateContext(certContext); + } + CertCloseStore(certStore, 0); + } + } + } + delete[] certData; + } + } + CloseHandle(certFile); + } +#else + (void)source; + cmSystemTools::Message("ComputeCertificateThumbprint is not implemented", + "Error"); +#endif + + return thumbprint; +} + void cmSystemTools::Glob(const std::string& directory, const std::string& regexp, std::vector& files) diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index fb58307..c12a1db 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -194,6 +194,9 @@ public: /** Compute the md5sum of a string. */ static std::string ComputeStringMD5(const std::string& input); + ///! Get the SHA thumbprint for a certificate file + static std::string ComputeCertificateThumbprint(const std::string& source); + /** * Run a single executable command * diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 80b8591..28a0425 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2893,7 +2893,7 @@ void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile() (*this->BuildFileStream) << cmVS10EscapeXML(artifactDir) << "\\\n"; this->WriteString("" - "$(TargetDir)resources.pri", 2); + "$(TargetDir)resources.pri\n", 2); // If we are missing files and we don't have a certificate and // aren't targeting WP8.0, add a default certificate @@ -2911,6 +2911,13 @@ void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile() this->WriteString("<", 2); (*this->BuildFileStream) << "PackageCertificateKeyFile>" << pfxFile << "\n"; + std::string thumb = cmSystemTools::ComputeCertificateThumbprint(pfxFile); + if (!thumb.empty()) + { + this->WriteString("", 2); + (*this->BuildFileStream) << thumb + << "\n"; + } this->WriteString("\n", 1); } else if(!pfxFile.empty()) @@ -2919,6 +2926,13 @@ void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile() this->WriteString("<", 2); (*this->BuildFileStream) << "PackageCertificateKeyFile>" << pfxFile << "\n"; + std::string thumb = cmSystemTools::ComputeCertificateThumbprint(pfxFile); + if (!thumb.empty()) + { + this->WriteString("", 2); + (*this->BuildFileStream) << thumb + << "\n"; + } this->WriteString("\n", 1); } } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0221184fdd5441ea2456fe1ff0fbedbeb8c1a837 commit 0221184fdd5441ea2456fe1ff0fbedbeb8c1a837 Author: Brad King AuthorDate: Mon Aug 24 10:58:42 2015 -0400 Commit: Brad King CommitDate: Mon Aug 24 10:58:42 2015 -0400 Simplify condition for using rpcrt4 library on Windows Drop the CMAKE_BUILD_ON_VISUAL_STUDIO variable and hard-code the condition at its only use. diff --git a/CMakeLists.txt b/CMakeLists.txt index 36244dd..5e13a7e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -144,17 +144,6 @@ macro(CMAKE_HANDLE_SYSTEM_LIBRARIES) endmacro() - - - -if(NOT CMake_TEST_EXTERNAL_CMAKE) - set(CMAKE_BUILD_ON_VISUAL_STUDIO 0) - if(WIN32 AND NOT UNIX AND NOT MINGW) - set(CMAKE_BUILD_ON_VISUAL_STUDIO 1) - endif() -endif() - - #----------------------------------------------------------------------- # a macro to determine the generator and ctest executable to use # for testing. Simply to improve readability of the main script. diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 428b364..1886519 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -556,8 +556,8 @@ if(APPLE) target_link_libraries(CMakeLib "-framework CoreFoundation") endif() -if(CMAKE_BUILD_ON_VISUAL_STUDIO OR MINGW) - # We need the rpcrt4 library for at least the VS7-VC10 generators. +if(WIN32 AND NOT UNIX) + # We need the rpcrt4 library on Windows. target_link_libraries(CMakeLib rpcrt4) endif() ----------------------------------------------------------------------- Summary of changes: CMakeLists.txt | 11 ---- Source/CMakeLists.txt | 7 ++- Source/cmSystemTools.cxx | 88 ++++++++++++++++++++++++++++ Source/cmSystemTools.h | 3 + Source/cmVisualStudio10TargetGenerator.cxx | 16 ++++- 5 files changed, 110 insertions(+), 15 deletions(-) hooks/post-receive -- CMake From eike at sf-mail.de Mon Aug 24 12:22:42 2015 From: eike at sf-mail.de (Rolf Eike Beer) Date: Mon, 24 Aug 2015 12:22:42 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2378-g60c550f Message-ID: <20150824162242.0B719B1883@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 60c550f84bc4a5a479392e0fe7d0b2a52d50524e (commit) via 64e527dbe3c55a01320b97cff38626171f96f686 (commit) from f131a5287a3b8a9f37fe1edef6cc95efd9ef78ef (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=60c550f84bc4a5a479392e0fe7d0b2a52d50524e commit 60c550f84bc4a5a479392e0fe7d0b2a52d50524e Merge: f131a52 64e527d Author: Rolf Eike Beer AuthorDate: Mon Aug 24 12:22:41 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 24 12:22:41 2015 -0400 Merge topic 'fphsa-typo' into next 64e527db FPHSA: fix typo in documentation http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=64e527dbe3c55a01320b97cff38626171f96f686 commit 64e527dbe3c55a01320b97cff38626171f96f686 Author: Rolf Eike Beer AuthorDate: Mon Aug 24 18:22:13 2015 +0200 Commit: Rolf Eike Beer CommitDate: Mon Aug 24 18:22:13 2015 +0200 FPHSA: fix typo in documentation diff --git a/Modules/FindPackageHandleStandardArgs.cmake b/Modules/FindPackageHandleStandardArgs.cmake index 1be38af..fe2dbea 100644 --- a/Modules/FindPackageHandleStandardArgs.cmake +++ b/Modules/FindPackageHandleStandardArgs.cmake @@ -42,7 +42,7 @@ valid filepaths. (recommended). Not valid in the full signature. ``FOUND_VAR `` - Obselete. Specifies either ``_FOUND`` or + Obsolete. Specifies either ``_FOUND`` or ``_FOUND`` as the result variable. This exists only for compatibility with older versions of CMake and is now ignored. Result variables of both names are always set for compatibility. ----------------------------------------------------------------------- Summary of changes: Modules/FindPackageHandleStandardArgs.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From steveire at gmail.com Mon Aug 24 14:02:57 2015 From: steveire at gmail.com (Stephen Kelly) Date: Mon, 24 Aug 2015 14:02:57 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2381-g34aeda5 Message-ID: <20150824180258.01CD5B1A7E@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 34aeda59a141683d6b8ff5dbbce4a6a3f9ca724b (commit) via f4150bd88d80f4a236ea5b0d648d8cc3122092fc (commit) via 0178754725c61dc6778f8591db1433a6c07e9f6f (commit) from 60c550f84bc4a5a479392e0fe7d0b2a52d50524e (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=34aeda59a141683d6b8ff5dbbce4a6a3f9ca724b commit 34aeda59a141683d6b8ff5dbbce4a6a3f9ca724b Merge: 60c550f f4150bd Author: Stephen Kelly AuthorDate: Mon Aug 24 14:02:56 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 24 14:02:56 2015 -0400 Merge topic 'cmState-prop_dir' into next f4150bd8 cmState: Move directory Properties from cmMakefile. 01787547 cmMakefile: Inline GetDefinitions into GetProperty. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f4150bd88d80f4a236ea5b0d648d8cc3122092fc commit f4150bd88d80f4a236ea5b0d648d8cc3122092fc Author: Stephen Kelly AuthorDate: Sat Jul 18 15:18:59 2015 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 24 20:02:21 2015 +0200 cmState: Move directory Properties from cmMakefile. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 3069218..2296d5a 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4075,152 +4075,28 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile, void cmMakefile::SetProperty(const std::string& prop, const char* value) { - if (prop == "INCLUDE_DIRECTORIES") - { - if (!value) - { - this->StateSnapshot.GetDirectory().ClearIncludeDirectories(); - return; - } - cmListFileBacktrace lfbt = this->GetBacktrace(); - this->StateSnapshot.GetDirectory().SetIncludeDirectories(value, lfbt); - return; - } - if (prop == "COMPILE_OPTIONS") - { - if (!value) - { - this->StateSnapshot.GetDirectory().ClearCompileOptions(); - return; - } - cmListFileBacktrace lfbt = this->GetBacktrace(); - this->StateSnapshot.GetDirectory().SetCompileOptions(value, lfbt); - return; - } - if (prop == "COMPILE_DEFINITIONS") - { - if (!value) - { - this->StateSnapshot.GetDirectory().ClearCompileDefinitions(); - return; - } - cmListFileBacktrace lfbt = this->GetBacktrace(); - this->StateSnapshot.GetDirectory().SetCompileDefinitions(value, lfbt); - return; - } - - this->Properties.SetProperty(prop, value); + cmListFileBacktrace lfbt = this->GetBacktrace(); + this->StateSnapshot.GetDirectory().SetProperty(prop, value, lfbt); } void cmMakefile::AppendProperty(const std::string& prop, const char* value, bool asString) { - if (prop == "INCLUDE_DIRECTORIES") - { - cmListFileBacktrace lfbt = this->GetBacktrace(); - this->StateSnapshot.GetDirectory().AppendIncludeDirectoriesEntry(value, - lfbt); - return; - } - if (prop == "COMPILE_OPTIONS") - { - cmListFileBacktrace lfbt = this->GetBacktrace(); - this->StateSnapshot.GetDirectory().AppendCompileOptionsEntry(value, lfbt); - return; - } - if (prop == "COMPILE_DEFINITIONS") - { - cmListFileBacktrace lfbt = this->GetBacktrace(); - this->StateSnapshot.GetDirectory().AppendCompileDefinitionsEntry(value, - lfbt); - return; - } - - this->Properties.AppendProperty(prop, value, asString); + cmListFileBacktrace lfbt = this->GetBacktrace(); + this->StateSnapshot.GetDirectory().AppendProperty(prop, value, + asString, lfbt); } const char *cmMakefile::GetProperty(const std::string& prop) const { - const bool chain = this->GetState()-> - IsPropertyChained(prop, cmProperty::DIRECTORY); - return this->GetProperty(prop, chain); + return this->StateSnapshot.GetDirectory().GetProperty(prop); } const char *cmMakefile::GetProperty(const std::string& prop, bool chain) const { - // watch for specific properties - static std::string output; - output = ""; - if (prop == "PARENT_DIRECTORY") - { - cmState::Snapshot parent = - this->StateSnapshot.GetBuildsystemDirectoryParent(); - if(parent.IsValid()) - { - return parent.GetDirectory().GetCurrentSource(); - } - return ""; - } - else if (prop == "LISTFILE_STACK") - { - std::vector listFiles; - cmState::Snapshot snp = this->StateSnapshot; - while (snp.IsValid()) - { - listFiles.push_back(snp.GetExecutionListFile()); - snp = snp.GetCallStackParent(); - } - std::reverse(listFiles.begin(), listFiles.end()); - output = cmJoin(listFiles, ";"); - return output.c_str(); - } - else if ( prop == "CACHE_VARIABLES" ) - { - output = cmJoin(this->GetState()->GetCacheEntryKeys(), ";"); - return output.c_str(); - } - else if (prop == "VARIABLES") - { - std::vector res = this->StateSnapshot.ClosureKeys(); - std::vector cacheKeys = this->GetState()->GetCacheEntryKeys(); - res.insert(res.end(), cacheKeys.begin(), cacheKeys.end()); - std::sort(res.begin(), res.end()); - output = cmJoin(res, ";"); - return output.c_str(); - } - else if (prop == "INCLUDE_DIRECTORIES") - { - output = cmJoin(this->StateSnapshot.GetDirectory() - .GetIncludeDirectoriesEntries(), ";"); - return output.c_str(); - } - else if (prop == "COMPILE_OPTIONS") - { - output = cmJoin(this->StateSnapshot.GetDirectory() - .GetCompileOptionsEntries(), ";"); - return output.c_str(); - } - else if (prop == "COMPILE_DEFINITIONS") - { - output = cmJoin(this->StateSnapshot.GetDirectory() - .GetCompileDefinitionsEntries(), ";"); - return output.c_str(); - } - - const char *retVal = this->Properties.GetPropertyValue(prop); - if (!retVal && chain) - { - if(this->LocalGenerator->GetParent()) - { - return this->LocalGenerator->GetParent()->GetMakefile()-> - GetProperty(prop, chain); - } - return this->GetState()->GetGlobalProperty(prop); - } - - return retVal; + return this->StateSnapshot.GetDirectory().GetProperty(prop, chain); } bool cmMakefile::GetPropertyAsBool(const std::string& prop) const @@ -4230,14 +4106,7 @@ bool cmMakefile::GetPropertyAsBool(const std::string& prop) const std::vector cmMakefile::GetPropertyKeys() const { - std::vector keys; - keys.reserve(this->Properties.size()); - for(cmPropertyMap::const_iterator it = this->Properties.begin(); - it != this->Properties.end(); ++it) - { - keys.push_back(it->first); - } - return keys; + return this->StateSnapshot.GetDirectory().GetPropertyKeys(); } cmTarget* cmMakefile::FindTarget(const std::string& name, diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 9f455cc..055170a 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -14,7 +14,6 @@ #include "cmExecutionStatus.h" #include "cmListFileCache.h" -#include "cmPropertyMap.h" #include "cmSystemTools.h" #include "cmTarget.h" #include "cmNewLineStyle.h" @@ -903,8 +902,6 @@ private: std::vector EvaluationFiles; - cmPropertyMap Properties; - std::vector ContextStack; std::vector ExecutionStatusStack; friend class cmMakefileCall; diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 336ff78..53fdae0 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -74,6 +74,8 @@ struct cmState::BuildsystemDirectoryStateType std::vector CompileOptions; std::vector CompileOptionsBacktraces; + + cmPropertyMap Properties; }; cmState::cmState(cmake* cm) @@ -271,6 +273,7 @@ cmState::Snapshot cmState::Reset() it->CompileOptions.clear(); it->CompileOptionsBacktraces.clear(); it->DirectoryEnd = pos; + it->Properties.clear(); } this->PolicyStack.Clear(); @@ -1538,3 +1541,163 @@ bool cmState::Snapshot::StrictWeakOrder::operator()( { return lhs.Position.StrictWeakOrdered(rhs.Position); } + +void cmState::Directory::SetProperty(const std::string& prop, + const char* value, + cmListFileBacktrace lfbt) +{ + if (prop == "INCLUDE_DIRECTORIES") + { + if (!value) + { + this->ClearIncludeDirectories(); + return; + } + this->SetIncludeDirectories(value, lfbt); + return; + } + if (prop == "COMPILE_OPTIONS") + { + if (!value) + { + this->ClearCompileOptions(); + return; + } + this->SetCompileOptions(value, lfbt); + return; + } + if (prop == "COMPILE_DEFINITIONS") + { + if (!value) + { + this->ClearCompileDefinitions(); + return; + } + this->SetCompileDefinitions(value, lfbt); + return; + } + + this->DirectoryState->Properties.SetProperty(prop, value); +} + +void cmState::Directory::AppendProperty(const std::string& prop, + const char* value, + bool asString, + cmListFileBacktrace lfbt) +{ + if (prop == "INCLUDE_DIRECTORIES") + { + this->AppendIncludeDirectoriesEntry(value, lfbt); + return; + } + if (prop == "COMPILE_OPTIONS") + { + this->AppendCompileOptionsEntry(value, lfbt); + return; + } + if (prop == "COMPILE_DEFINITIONS") + { + this->AppendCompileDefinitionsEntry(value, lfbt); + return; + } + + this->DirectoryState->Properties.AppendProperty(prop, value, asString); +} + +const char*cmState::Directory::GetProperty(const std::string& prop) const +{ + const bool chain = this->Snapshot_.State-> + IsPropertyChained(prop, cmProperty::DIRECTORY); + return this->GetProperty(prop, chain); +} + +const char* +cmState::Directory::GetProperty(const std::string& prop, bool chain) const +{ + static std::string output; + output = ""; + if (prop == "PARENT_DIRECTORY") + { + cmState::Snapshot parent = + this->Snapshot_.GetBuildsystemDirectoryParent(); + if(parent.IsValid()) + { + return parent.GetDirectory().GetCurrentSource(); + } + return ""; + } + else if (prop == "LISTFILE_STACK") + { + std::vector listFiles; + cmState::Snapshot snp = this->Snapshot_; + while (snp.IsValid()) + { + listFiles.push_back(snp.GetExecutionListFile()); + snp = snp.GetCallStackParent(); + } + std::reverse(listFiles.begin(), listFiles.end()); + output = cmJoin(listFiles, ";"); + return output.c_str(); + } + else if ( prop == "CACHE_VARIABLES" ) + { + output = cmJoin(this->Snapshot_.State->GetCacheEntryKeys(), ";"); + return output.c_str(); + } + else if (prop == "VARIABLES") + { + std::vector res = this->Snapshot_.ClosureKeys(); + std::vector cacheKeys = + this->Snapshot_.State->GetCacheEntryKeys(); + res.insert(res.end(), cacheKeys.begin(), cacheKeys.end()); + std::sort(res.begin(), res.end()); + output = cmJoin(res, ";"); + return output.c_str(); + } + else if (prop == "INCLUDE_DIRECTORIES") + { + output = cmJoin(this->GetIncludeDirectoriesEntries(), ";"); + return output.c_str(); + } + else if (prop == "COMPILE_OPTIONS") + { + output = cmJoin(this->GetCompileOptionsEntries(), ";"); + return output.c_str(); + } + else if (prop == "COMPILE_DEFINITIONS") + { + output = cmJoin(this->GetCompileDefinitionsEntries(), ";"); + return output.c_str(); + } + + const char *retVal = this->DirectoryState->Properties.GetPropertyValue(prop); + if (!retVal && chain) + { + Snapshot parentSnapshot = this->Snapshot_.GetBuildsystemDirectoryParent(); + if (parentSnapshot.IsValid()) + { + return parentSnapshot.GetDirectory().GetProperty(prop, chain); + } + return this->Snapshot_.State->GetGlobalProperty(prop); + } + + return retVal; +} + +bool cmState::Directory::GetPropertyAsBool(const std::string& prop) const +{ + return cmSystemTools::IsOn(this->GetProperty(prop)); +} + +std::vector cmState::Directory::GetPropertyKeys() const +{ + std::vector keys; + keys.reserve(this->DirectoryState->Properties.size()); + for(cmPropertyMap::const_iterator it = + this->DirectoryState->Properties.begin(); + it != this->DirectoryState->Properties.end(); ++it) + { + keys.push_back(it->first); + } + return keys; +} diff --git a/Source/cmState.h b/Source/cmState.h index 86945f6..e503cd2 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -146,6 +146,15 @@ public: cmListFileBacktrace const& lfbt); void ClearCompileOptions(); + void SetProperty(const std::string& prop, const char *value, + cmListFileBacktrace lfbt); + void AppendProperty(const std::string& prop, const char *value, + bool asString, cmListFileBacktrace lfbt); + const char *GetProperty(const std::string& prop) const; + const char *GetProperty(const std::string& prop, bool chain) const; + bool GetPropertyAsBool(const std::string& prop) const; + std::vector GetPropertyKeys() const; + private: void ComputeRelativePathTopSource(); void ComputeRelativePathTopBinary(); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0178754725c61dc6778f8591db1433a6c07e9f6f commit 0178754725c61dc6778f8591db1433a6c07e9f6f Author: Stephen Kelly AuthorDate: Sat Jul 18 14:54:14 2015 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 24 19:48:45 2015 +0200 cmMakefile: Inline GetDefinitions into GetProperty. It will soon move to cmState. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 7ad37e6..3069218 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4183,7 +4183,11 @@ const char *cmMakefile::GetProperty(const std::string& prop, } else if (prop == "VARIABLES") { - output = cmJoin(this->GetDefinitions(), ";"); + std::vector res = this->StateSnapshot.ClosureKeys(); + std::vector cacheKeys = this->GetState()->GetCacheEntryKeys(); + res.insert(res.end(), cacheKeys.begin(), cacheKeys.end()); + std::sort(res.begin(), res.end()); + output = cmJoin(res, ";"); return output.c_str(); } else if (prop == "INCLUDE_DIRECTORIES") ----------------------------------------------------------------------- Summary of changes: Source/cmMakefile.cxx | 143 +++---------------------------------------- Source/cmMakefile.h | 3 - Source/cmState.cxx | 163 +++++++++++++++++++++++++++++++++++++++++++++++++ Source/cmState.h | 9 +++ 4 files changed, 180 insertions(+), 138 deletions(-) hooks/post-receive -- CMake From steveire at gmail.com Mon Aug 24 14:04:14 2015 From: steveire at gmail.com (Stephen Kelly) Date: Mon, 24 Aug 2015 14:04:14 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2390-g4c849ca Message-ID: <20150824180416.BA425B1AAE@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 4c849cab1b87c33f6ae57962dc2150a8c61b7d39 (commit) via 7fbc56ac400fe7aaafaa581bca2f2848287ce7fd (commit) via 65c434e1b0247a47df763a616d1c8fdb20daba5c (commit) via be56feb6184e80eab5ce93b5ab81308452a5559f (commit) via 45f52003962f2f5ae58be2dd779f441bb4ca01f7 (commit) via af9fc277536f37980ccdab699a934b3c42e9fba9 (commit) via 9b44018d520cfabc347d6d79cafdf0a37c62b4e0 (commit) via 5f05b56284f9a76aa90562186aebd383a3ca9349 (commit) via 95925a60fce8a7b60fbea9873d9bb9fadf47cd02 (commit) from 34aeda59a141683d6b8ff5dbbce4a6a3f9ca724b (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4c849cab1b87c33f6ae57962dc2150a8c61b7d39 commit 4c849cab1b87c33f6ae57962dc2150a8c61b7d39 Merge: 34aeda5 7fbc56a Author: Stephen Kelly AuthorDate: Mon Aug 24 14:04:13 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 24 14:04:13 2015 -0400 Merge topic 'refactor-progress' into next 7fbc56ac cmGlobalUnixMakefileGenerator3: Implement progress in terms of cmState. 65c434e1 cmGlobalUnixMakefileGenerator3: Inline an IsExcluded call. be56feb6 cmGlobalGenerator: Extract new IsExcluded overload. 45f52003 cmGlobalGenerator: Implement IsExcluded in terms of cmState::Snapshot. af9fc277 cmState: Make Snapshot EqualityComparable. 9b44018d cmGlobalGenerator: Convert IsExcluded to loop. 5f05b562 cmGlobalGenerator: Refactor IsExcluded. 95925a60 cmGlobalGenerator: Don't use else after return. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7fbc56ac400fe7aaafaa581bca2f2848287ce7fd commit 7fbc56ac400fe7aaafaa581bca2f2848287ce7fd Author: Stephen Kelly AuthorDate: Sun Aug 2 10:41:55 2015 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 24 20:03:30 2015 +0200 cmGlobalUnixMakefileGenerator3: Implement progress in terms of cmState. diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 6a13977..8c8c56e 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -944,14 +944,17 @@ void cmGlobalUnixMakefileGenerator3::InitializeProgressMarks() continue; } + cmState::Snapshot csnp = lg->GetStateSnapshot(); + cmState::Snapshot tsnp = tlg->GetStateSnapshot(); + // Consider the directory containing the target and all its // parents until something excludes the target. - for(cmLocalGenerator* clg = lg; clg && !this->IsExcluded(clg, tlg); - clg = clg->GetParent()) + for( ; csnp.IsValid() && !this->IsExcluded(csnp, tsnp); + csnp = csnp.GetBuildsystemDirectoryParent()) { // This local generator includes the target. std::set& targetSet = - this->DirectoryTargetsMap[clg->GetStateSnapshot()]; + this->DirectoryTargetsMap[csnp]; targetSet.insert(gt); // Add dependencies of the included target. An excluded http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=65c434e1b0247a47df763a616d1c8fdb20daba5c commit 65c434e1b0247a47df763a616d1c8fdb20daba5c Author: Stephen Kelly AuthorDate: Sun Aug 2 10:39:19 2015 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 24 20:03:29 2015 +0200 cmGlobalUnixMakefileGenerator3: Inline an IsExcluded call. diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index b240924..6a13977 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -936,9 +936,17 @@ void cmGlobalUnixMakefileGenerator3::InitializeProgressMarks() cmGeneratorTarget* gt = this->GetGeneratorTarget(&target); + cmLocalGenerator* tlg = gt->GetLocalGenerator(); + + if(gt->GetType() == cmTarget::INTERFACE_LIBRARY + || gt->Target->GetPropertyAsBool("EXCLUDE_FROM_ALL")) + { + continue; + } + // Consider the directory containing the target and all its // parents until something excludes the target. - for(cmLocalGenerator* clg = lg; clg && !this->IsExcluded(clg, gt); + for(cmLocalGenerator* clg = lg; clg && !this->IsExcluded(clg, tlg); clg = clg->GetParent()) { // This local generator includes the target. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=be56feb6184e80eab5ce93b5ab81308452a5559f commit be56feb6184e80eab5ce93b5ab81308452a5559f Author: Stephen Kelly AuthorDate: Sun Aug 2 09:58:57 2015 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 24 20:03:29 2015 +0200 cmGlobalGenerator: Extract new IsExcluded overload. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index d7aca47..be7896d 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2041,13 +2041,10 @@ void cmGlobalGenerator::SetConfiguredFilesPath(cmGlobalGenerator* gen) } } -bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, - cmLocalGenerator* gen) const +bool cmGlobalGenerator::IsExcluded(cmState::Snapshot const& rootSnp, + cmState::Snapshot const& snp_) const { - assert(gen); - - cmState::Snapshot rootSnp = root->GetStateSnapshot(); - cmState::Snapshot snp = gen->GetStateSnapshot(); + cmState::Snapshot snp = snp_; while (snp.IsValid()) { if(snp == rootSnp) @@ -2067,6 +2064,17 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, } bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, + cmLocalGenerator* gen) const +{ + assert(gen); + + cmState::Snapshot rootSnp = root->GetStateSnapshot(); + cmState::Snapshot snp = gen->GetStateSnapshot(); + + return this->IsExcluded(rootSnp, snp); +} + +bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) const { if(target->GetType() == cmTarget::INTERFACE_LIBRARY diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index fe710f1..23501bc 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -396,6 +396,8 @@ protected: // has been populated. void FillProjectMap(); void CheckLocalGenerators(); + bool IsExcluded(cmState::Snapshot const& root, + cmState::Snapshot const& snp) const; bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen) const; bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) const; virtual void InitializeProgressMarks() {} http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=45f52003962f2f5ae58be2dd779f441bb4ca01f7 commit 45f52003962f2f5ae58be2dd779f441bb4ca01f7 Author: Stephen Kelly AuthorDate: Sun Aug 2 09:57:25 2015 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 24 20:03:29 2015 +0200 cmGlobalGenerator: Implement IsExcluded in terms of cmState::Snapshot. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index b7b4fba..d7aca47 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2046,21 +2046,22 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, { assert(gen); - cmLocalGenerator* lg = gen; - while (lg) + cmState::Snapshot rootSnp = root->GetStateSnapshot(); + cmState::Snapshot snp = gen->GetStateSnapshot(); + while (snp.IsValid()) { - if(lg == root) + if(snp == rootSnp) { // No directory excludes itself. return false; } - if(lg->GetMakefile()->GetPropertyAsBool("EXCLUDE_FROM_ALL")) + if(snp.GetDirectory().GetPropertyAsBool("EXCLUDE_FROM_ALL")) { // This directory is excluded from its parent. return true; } - lg = lg->GetParent(); + snp = snp.GetBuildsystemDirectoryParent(); } return false; } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=af9fc277536f37980ccdab699a934b3c42e9fba9 commit af9fc277536f37980ccdab699a934b3c42e9fba9 Author: Stephen Kelly AuthorDate: Sun Aug 2 09:56:08 2015 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 24 20:03:29 2015 +0200 cmState: Make Snapshot EqualityComparable. diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 53fdae0..4e4c2c6 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -1701,3 +1701,13 @@ std::vector cmState::Directory::GetPropertyKeys() const } return keys; } + +bool operator==(const cmState::Snapshot& lhs, const cmState::Snapshot& rhs) +{ + return lhs.Position == rhs.Position; +} + +bool operator!=(const cmState::Snapshot& lhs, const cmState::Snapshot& rhs) +{ + return lhs.Position != rhs.Position; +} diff --git a/Source/cmState.h b/Source/cmState.h index e503cd2..d683068 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -93,6 +93,10 @@ public: }; private: + friend bool operator==(const cmState::Snapshot& lhs, + const cmState::Snapshot& rhs); + friend bool operator!=(const cmState::Snapshot& lhs, + const cmState::Snapshot& rhs); friend class cmState; friend class Directory; friend struct StrictWeakOrder; @@ -314,4 +318,7 @@ private: bool MSYSShell; }; +bool operator==(const cmState::Snapshot& lhs, const cmState::Snapshot& rhs); +bool operator!=(const cmState::Snapshot& lhs, const cmState::Snapshot& rhs); + #endif http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9b44018d520cfabc347d6d79cafdf0a37c62b4e0 commit 9b44018d520cfabc347d6d79cafdf0a37c62b4e0 Author: Stephen Kelly AuthorDate: Sun Aug 2 09:54:22 2015 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 24 20:03:29 2015 +0200 cmGlobalGenerator: Convert IsExcluded to loop. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index a610b3d..b7b4fba 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2046,27 +2046,23 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, { assert(gen); - if(gen == root) + cmLocalGenerator* lg = gen; + while (lg) { - // No directory excludes itself. - return false; - } - - if(gen->GetMakefile()->GetPropertyAsBool("EXCLUDE_FROM_ALL")) - { - // This directory is excluded from its parent. - return true; - } + if(lg == root) + { + // No directory excludes itself. + return false; + } - cmLocalGenerator* lg = gen->GetParent(); - if (!lg) - { - return false; + if(lg->GetMakefile()->GetPropertyAsBool("EXCLUDE_FROM_ALL")) + { + // This directory is excluded from its parent. + return true; + } + lg = lg->GetParent(); } - - // This directory is included in its parent. Check whether the - // parent is excluded. - return this->IsExcluded(root, lg); + return false; } bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5f05b56284f9a76aa90562186aebd383a3ca9349 commit 5f05b56284f9a76aa90562186aebd383a3ca9349 Author: Stephen Kelly AuthorDate: Sun Aug 2 09:51:56 2015 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 24 20:03:29 2015 +0200 cmGlobalGenerator: Refactor IsExcluded. Make it easier to convert it to a loop. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 71b00c4..a610b3d 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2044,7 +2044,9 @@ void cmGlobalGenerator::SetConfiguredFilesPath(cmGlobalGenerator* gen) bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen) const { - if(!gen || gen == root) + assert(gen); + + if(gen == root) { // No directory excludes itself. return false; @@ -2056,9 +2058,15 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, return true; } + cmLocalGenerator* lg = gen->GetParent(); + if (!lg) + { + return false; + } + // This directory is included in its parent. Check whether the // parent is excluded. - return this->IsExcluded(root, gen->GetParent()); + return this->IsExcluded(root, lg); } bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=95925a60fce8a7b60fbea9873d9bb9fadf47cd02 commit 95925a60fce8a7b60fbea9873d9bb9fadf47cd02 Author: Stephen Kelly AuthorDate: Sun Aug 2 09:34:29 2015 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 24 20:03:29 2015 +0200 cmGlobalGenerator: Don't use else after return. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 503c455..71b00c4 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2070,12 +2070,9 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, // This target is excluded from its directory. return true; } - else - { - // This target is included in its directory. Check whether the - // directory is excluded. - return this->IsExcluded(root, target->GetLocalGenerator()); - } + // This target is included in its directory. Check whether the + // directory is excluded. + return this->IsExcluded(root, target->GetLocalGenerator()); } void ----------------------------------------------------------------------- Summary of changes: Source/cmGlobalGenerator.cxx | 48 +++++++++++++++++------------ Source/cmGlobalGenerator.h | 2 ++ Source/cmGlobalUnixMakefileGenerator3.cxx | 17 ++++++++-- Source/cmState.cxx | 10 ++++++ Source/cmState.h | 7 +++++ 5 files changed, 62 insertions(+), 22 deletions(-) hooks/post-receive -- CMake From steveire at gmail.com Mon Aug 24 14:05:17 2015 From: steveire at gmail.com (Stephen Kelly) Date: Mon, 24 Aug 2015 14:05:17 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2395-g300f3e9 Message-ID: <20150824180517.B47C3B1A32@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 300f3e937c0739efaaac7a3a1ddd1931cf0e6841 (commit) via e3078aa15328439e239b2beb4085dc644ec465ec (commit) via 7441fde34abf5a3eab58917b8bf4acb89d72c00c (commit) via ad0b0089ab9f094192f6109067d79ef5e66c85b7 (commit) via 314c9ae33bfd304c9622b89ec62bca052f6e0d39 (commit) from 4c849cab1b87c33f6ae57962dc2150a8c61b7d39 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=300f3e937c0739efaaac7a3a1ddd1931cf0e6841 commit 300f3e937c0739efaaac7a3a1ddd1931cf0e6841 Merge: 4c849ca e3078aa Author: Stephen Kelly AuthorDate: Mon Aug 24 14:05:16 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 24 14:05:16 2015 -0400 Merge topic 'refactor-features' into next e3078aa1 cmLocalGenerator: Implement GetFeature in terms of cmState. 7441fde3 cmLocalGenerator: Convert GetFeature recursion to loop. ad0b0089 cmLocalGenerator: Simplify GetFeature implementation. 314c9ae3 cmLocalGenerator: Make GetFeature tail-recursive. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e3078aa15328439e239b2beb4085dc644ec465ec commit e3078aa15328439e239b2beb4085dc644ec465ec Author: Stephen Kelly AuthorDate: Sun Aug 2 09:18:37 2015 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 24 20:04:37 2015 +0200 cmLocalGenerator: Implement GetFeature in terms of cmState. diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 8e12eb6..c2d1a7d 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2376,14 +2376,14 @@ const char* cmLocalGenerator::GetFeature(const std::string& feature, featureName += "_"; featureName += cmSystemTools::UpperCase(config); } - cmLocalGenerator* lg = this; - while(lg) + cmState::Snapshot snp = this->StateSnapshot; + while(snp.IsValid()) { - if(const char* value = lg->GetMakefile()->GetProperty(featureName)) + if(const char* value = snp.GetDirectory().GetProperty(featureName)) { return value; } - lg = lg->GetParent(); + snp = snp.GetBuildsystemDirectoryParent(); } return 0; } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7441fde34abf5a3eab58917b8bf4acb89d72c00c commit 7441fde34abf5a3eab58917b8bf4acb89d72c00c Author: Stephen Kelly AuthorDate: Sun Aug 2 09:16:17 2015 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 24 20:04:37 2015 +0200 cmLocalGenerator: Convert GetFeature recursion to loop. diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 2a88e3c..8e12eb6 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2376,16 +2376,16 @@ const char* cmLocalGenerator::GetFeature(const std::string& feature, featureName += "_"; featureName += cmSystemTools::UpperCase(config); } - if(const char* value = this->Makefile->GetProperty(featureName)) + cmLocalGenerator* lg = this; + while(lg) { - return value; - } - cmLocalGenerator* parent = this->GetParent(); - if(!parent) - { - return 0; + if(const char* value = lg->GetMakefile()->GetProperty(featureName)) + { + return value; + } + lg = lg->GetParent(); } - return parent->GetFeature(feature, config); + return 0; } //---------------------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ad0b0089ab9f094192f6109067d79ef5e66c85b7 commit ad0b0089ab9f094192f6109067d79ef5e66c85b7 Author: Stephen Kelly AuthorDate: Sun Aug 2 09:14:28 2015 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 24 20:04:37 2015 +0200 cmLocalGenerator: Simplify GetFeature implementation. diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 169cdf4..2a88e3c 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2368,19 +2368,15 @@ void cmLocalGenerator::AppendFeatureOptions( const char* cmLocalGenerator::GetFeature(const std::string& feature, const std::string& config) { + std::string featureName = feature; // TODO: Define accumulation policy for features (prepend, append, replace). // Currently we always replace. if(!config.empty()) { - std::string featureConfig = feature; - featureConfig += "_"; - featureConfig += cmSystemTools::UpperCase(config); - if(const char* value = this->Makefile->GetProperty(featureConfig)) - { - return value; - } + featureName += "_"; + featureName += cmSystemTools::UpperCase(config); } - if(const char* value = this->Makefile->GetProperty(feature)) + if(const char* value = this->Makefile->GetProperty(featureName)) { return value; } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=314c9ae33bfd304c9622b89ec62bca052f6e0d39 commit 314c9ae33bfd304c9622b89ec62bca052f6e0d39 Author: Stephen Kelly AuthorDate: Sun Aug 2 09:11:55 2015 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 24 20:04:37 2015 +0200 cmLocalGenerator: Make GetFeature tail-recursive. diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index edb644d..169cdf4 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2384,11 +2384,12 @@ const char* cmLocalGenerator::GetFeature(const std::string& feature, { return value; } - if(cmLocalGenerator* parent = this->GetParent()) + cmLocalGenerator* parent = this->GetParent(); + if(!parent) { - return parent->GetFeature(feature, config); + return 0; } - return 0; + return parent->GetFeature(feature, config); } //---------------------------------------------------------------------------- ----------------------------------------------------------------------- Summary of changes: Source/cmLocalGenerator.cxx | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) hooks/post-receive -- CMake From steveire at gmail.com Mon Aug 24 14:11:34 2015 From: steveire at gmail.com (Stephen Kelly) Date: Mon, 24 Aug 2015 14:11:34 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2401-g284bfd6 Message-ID: <20150824181134.23CBCB0A69@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 284bfd60c02a99c4da5a5b51a8ae39f3ca926fdf (commit) via 867b5be8b89c9b4f18ea604e1c61a154d0335c4c (commit) via 6c832219eadb6062c5026817ed86b81e583c8e5d (commit) via 3fcf383763e80b90e30fa06b29e0751ca19ab983 (commit) via 223f4a662fbe2caff92186e0875737fe3727a4fd (commit) via ae026f5458c5c919031a41310321ae26cd56fae0 (commit) from 300f3e937c0739efaaac7a3a1ddd1931cf0e6841 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=284bfd60c02a99c4da5a5b51a8ae39f3ca926fdf commit 284bfd60c02a99c4da5a5b51a8ae39f3ca926fdf Merge: 300f3e9 867b5be Author: Stephen Kelly AuthorDate: Mon Aug 24 14:11:33 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 24 14:11:33 2015 -0400 Merge topic 'rm-cmLocalGenerator-Children' into next 867b5be8 cmLocalGenerator: Remove unused Children member. 6c832219 cmLocalGenerator: Implement child traversal in terms of cmState. 3fcf3837 Makefiles: Remove valueless cast. 223f4a66 cmLocalGenerator: Simplify condition. ae026f54 cmState: Store Children states in parent state. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=867b5be8b89c9b4f18ea604e1c61a154d0335c4c commit 867b5be8b89c9b4f18ea604e1c61a154d0335c4c Author: Stephen Kelly AuthorDate: Sun Jul 19 16:38:55 2015 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 24 20:05:38 2015 +0200 cmLocalGenerator: Remove unused Children member. diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 9344f1d..b3fe3b0 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -50,10 +50,6 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg, assert(snapshot.IsValid()); this->GlobalGenerator = gg; this->Parent = parent; - if (parent) - { - parent->AddChild(this); - } this->Makefile = new cmMakefile(this); diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 1c18788..915814b 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -89,11 +89,6 @@ public: ///! set/get the parent generator cmLocalGenerator* GetParent() const {return this->Parent;} - ///! set/get the children - void AddChild(cmLocalGenerator* g) { this->Children.push_back(g); } - std::vector& GetChildren() { return this->Children; } - - void AddArchitectureFlags(std::string& flags, cmGeneratorTarget const* target, const std::string&lang, const std::string& config); @@ -349,7 +344,6 @@ protected: cmState::Snapshot StateSnapshot; cmGlobalGenerator *GlobalGenerator; cmLocalGenerator* Parent; - std::vector Children; std::map UniqueObjectNamesMap; std::string::size_type ObjectPathMax; std::set ObjectMaxPathViolations; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6c832219eadb6062c5026817ed86b81e583c8e5d commit 6c832219eadb6062c5026817ed86b81e583c8e5d Author: Stephen Kelly AuthorDate: Sun Jul 19 16:33:54 2015 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 24 20:05:37 2015 +0200 cmLocalGenerator: Implement child traversal in terms of cmState. diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index d951c13..fd7c768 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -495,10 +495,12 @@ cmGlobalUnixMakefileGenerator3 // The directory-level rule should depend on the directory-level // rules of the subdirectories. - for(std::vector::iterator sdi = - lg->GetChildren().begin(); sdi != lg->GetChildren().end(); ++sdi) + std::vector children + = lg->GetMakefile()->GetStateSnapshot().GetChildren(); + for(std::vector::const_iterator + ci = children.begin(); ci != children.end(); ++ci) { - std::string subdir = (*sdi)->GetMakefile()->GetCurrentBinaryDirectory(); + std::string subdir = ci->GetDirectory().GetCurrentBinary(); subdir += "/"; subdir += pass; depends.push_back(subdir); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index db464d6..9344f1d 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -200,12 +200,13 @@ void cmLocalGenerator::GenerateTestFiles() (*gi)->Generate(fout, config, configurationTypes); } size_t i; - for(i = 0; i < this->Children.size(); ++i) + std::vector children + = this->Makefile->GetStateSnapshot().GetChildren(); + for(i = 0; i < children.size(); ++i) { // TODO: Use add_subdirectory instead? fout << "subdirs("; - std::string outP = - this->Children[i]->GetMakefile()->GetCurrentBinaryDirectory(); + std::string outP = children[i].GetDirectory().GetCurrentBinary(); fout << this->Convert(outP,START_OUTPUT); fout << ")" << std::endl; } @@ -413,16 +414,18 @@ void cmLocalGenerator::GenerateInstallRules() this->GenerateTargetInstallRules(fout, config, configurationTypes); // Include install scripts from subdirectories. - if(!this->Children.empty()) + std::vector children + = this->Makefile->GetStateSnapshot().GetChildren(); + if(!children.empty()) { fout << "if(NOT CMAKE_INSTALL_LOCAL_ONLY)\n"; fout << " # Include the install script for each subdirectory.\n"; - for(std::vector::const_iterator - ci = this->Children.begin(); ci != this->Children.end(); ++ci) + for(std::vector::const_iterator + ci = children.begin(); ci != children.end(); ++ci) { - if(!(*ci)->GetMakefile()->GetPropertyAsBool("EXCLUDE_FROM_ALL")) + if(!ci->GetDirectory().GetPropertyAsBool("EXCLUDE_FROM_ALL")) { - std::string odir = (*ci)->GetMakefile()->GetCurrentBinaryDirectory(); + std::string odir = ci->GetDirectory().GetCurrentBinary(); cmSystemTools::ConvertToUnixSlashes(odir); fout << " include(\"" << odir << "/cmake_install.cmake\")" << std::endl; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3fcf383763e80b90e30fa06b29e0751ca19ab983 commit 3fcf383763e80b90e30fa06b29e0751ca19ab983 Author: Stephen Kelly AuthorDate: Sun Jul 19 16:35:36 2015 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 24 20:05:37 2015 +0200 Makefiles: Remove valueless cast. diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index b240924..d951c13 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -498,9 +498,7 @@ cmGlobalUnixMakefileGenerator3 for(std::vector::iterator sdi = lg->GetChildren().begin(); sdi != lg->GetChildren().end(); ++sdi) { - cmLocalUnixMakefileGenerator3* slg = - static_cast(*sdi); - std::string subdir = slg->GetMakefile()->GetCurrentBinaryDirectory(); + std::string subdir = (*sdi)->GetMakefile()->GetCurrentBinaryDirectory(); subdir += "/"; subdir += pass; depends.push_back(subdir); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=223f4a662fbe2caff92186e0875737fe3727a4fd commit 223f4a662fbe2caff92186e0875737fe3727a4fd Author: Stephen Kelly AuthorDate: Sun Jul 19 16:31:10 2015 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 24 20:05:37 2015 +0200 cmLocalGenerator: Simplify condition. diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index edb644d..db464d6 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -199,18 +199,15 @@ void cmLocalGenerator::GenerateTestFiles() (*gi)->Compute(this); (*gi)->Generate(fout, config, configurationTypes); } - if (!this->Children.empty()) - { - size_t i; - for(i = 0; i < this->Children.size(); ++i) - { - // TODO: Use add_subdirectory instead? - fout << "subdirs("; - std::string outP = - this->Children[i]->GetMakefile()->GetCurrentBinaryDirectory(); - fout << this->Convert(outP,START_OUTPUT); - fout << ")" << std::endl; - } + size_t i; + for(i = 0; i < this->Children.size(); ++i) + { + // TODO: Use add_subdirectory instead? + fout << "subdirs("; + std::string outP = + this->Children[i]->GetMakefile()->GetCurrentBinaryDirectory(); + fout << this->Convert(outP,START_OUTPUT); + fout << ")" << std::endl; } } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ae026f5458c5c919031a41310321ae26cd56fae0 commit ae026f5458c5c919031a41310321ae26cd56fae0 Author: Stephen Kelly AuthorDate: Sun Jul 19 16:26:49 2015 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 24 20:05:37 2015 +0200 cmState: Store Children states in parent state. diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 53fdae0..3df855a 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -76,6 +76,8 @@ struct cmState::BuildsystemDirectoryStateType std::vector CompileOptionsBacktraces; cmPropertyMap Properties; + + std::vector Children; }; cmState::cmState(cmake* cm) @@ -274,6 +276,7 @@ cmState::Snapshot cmState::Reset() it->CompileOptionsBacktraces.clear(); it->DirectoryEnd = pos; it->Properties.clear(); + it->Children.clear(); } this->PolicyStack.Clear(); @@ -800,7 +803,9 @@ cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot, pos->Parent = origin; pos->Root = origin; pos->Vars = this->VarTree.Extend(origin); - return cmState::Snapshot(this, pos); + cmState::Snapshot snapshot = cmState::Snapshot(this, pos); + originSnapshot.Position->BuildSystemDirectory->Children.push_back(snapshot); + return snapshot; } cmState::Snapshot @@ -938,6 +943,11 @@ cmState::Snapshot::Snapshot(cmState* state) { } +std::vector cmState::Snapshot::GetChildren() +{ + return this->Position->BuildSystemDirectory->Children; +} + cmState::Snapshot::Snapshot(cmState* state, PositionType position) : State(state), Position(position) diff --git a/Source/cmState.h b/Source/cmState.h index e503cd2..a488c62 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -65,6 +65,8 @@ public: void SetListFile(std::string const& listfile); std::string GetExecutionListFile() const; + + std::vector GetChildren(); std::string GetEntryPointCommand() const; long GetEntryPointLine() const; ----------------------------------------------------------------------- Summary of changes: Source/cmGlobalUnixMakefileGenerator3.cxx | 10 ++++---- Source/cmLocalGenerator.cxx | 36 +++++++++++++---------------- Source/cmLocalGenerator.h | 6 ----- Source/cmState.cxx | 12 +++++++++- Source/cmState.h | 2 ++ 5 files changed, 34 insertions(+), 32 deletions(-) hooks/post-receive -- CMake From steveire at gmail.com Mon Aug 24 14:16:57 2015 From: steveire at gmail.com (Stephen Kelly) Date: Mon, 24 Aug 2015 14:16:57 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2406-g98ec73c Message-ID: <20150824181657.A57A3B13F2@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 98ec73c459d7daa6800811726799559f0d0a12e2 (commit) via 67d456147dbf34266b59d71284c41d72a9fa95e2 (commit) via b500f8f98f79db2889013912b6784ac0473e487e (commit) via 3ece2f822e82c3c3da587a8c99a901abd343d60c (commit) via cfbf9805546b650f448273e9cfc1f7bbdff86bcc (commit) from 284bfd60c02a99c4da5a5b51a8ae39f3ca926fdf (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=98ec73c459d7daa6800811726799559f0d0a12e2 commit 98ec73c459d7daa6800811726799559f0d0a12e2 Merge: 284bfd6 67d4561 Author: Stephen Kelly AuthorDate: Mon Aug 24 14:16:56 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 24 14:16:56 2015 -0400 Merge topic 'cmState-ProjectName' into next 67d45614 cmGlobalGenerator: Implement FillProjectMap in terms of cmState. b500f8f9 cmState: Move ProjectName from cmMakefile. 3ece2f82 cmMakefile: Use std::string in ProjectName API. cfbf9805 cmMakefile: Out-of-line GetProjectName. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=67d456147dbf34266b59d71284c41d72a9fa95e2 commit 67d456147dbf34266b59d71284c41d72a9fa95e2 Author: Stephen Kelly AuthorDate: Sun Aug 2 09:41:11 2015 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 24 20:15:02 2015 +0200 cmGlobalGenerator: Implement FillProjectMap in terms of cmState. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 503c455..17bafbe 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2102,18 +2102,19 @@ void cmGlobalGenerator::FillProjectMap() for(i = 0; i < this->LocalGenerators.size(); ++i) { // for each local generator add all projects - cmLocalGenerator *lg = this->LocalGenerators[i]; + cmState::Snapshot snp = this->LocalGenerators[i]->GetStateSnapshot(); std::string name; do { - if (name != lg->GetMakefile()->GetProjectName()) + std::string snpProjName = snp.GetProjectName(); + if (name != snpProjName) { - name = lg->GetMakefile()->GetProjectName(); + name = snpProjName; this->ProjectMap[name].push_back(this->LocalGenerators[i]); } - lg = lg->GetParent(); + snp = snp.GetBuildsystemDirectoryParent(); } - while (lg); + while (snp.IsValid()); } } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b500f8f98f79db2889013912b6784ac0473e487e commit b500f8f98f79db2889013912b6784ac0473e487e Author: Stephen Kelly AuthorDate: Sun Aug 2 09:41:06 2015 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 24 20:15:02 2015 +0200 cmState: Move ProjectName from cmMakefile. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index abdd767..dbf41cc 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1525,7 +1525,7 @@ void cmMakefile::InitializeFromParent(cmMakefile* parent) parent->GetProperty("LINK_DIRECTORIES")); // the initial project name - this->ProjectName = parent->ProjectName; + this->SetProjectName(parent->GetProjectName()); // Copy include regular expressions. this->ComplainFileRegularExpression = parent->ComplainFileRegularExpression; @@ -2046,12 +2046,12 @@ void cmMakefile::RemoveCacheDefinition(const std::string& name) void cmMakefile::SetProjectName(std::string const& p) { - this->ProjectName = p; + this->StateSnapshot.SetProjectName(p); } std::string cmMakefile::GetProjectName() const { - return this->ProjectName.c_str(); + return this->StateSnapshot.GetProjectName(); } void cmMakefile::AddGlobalLinkInformation(const std::string& name, diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index dfd3e19..81bb510 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -810,8 +810,6 @@ protected: mutable std::set CMP0054ReportedIds; - std::string ProjectName; // project name - // libraries, classes, and executables mutable cmTargets Targets; #if defined(CMAKE_BUILD_WITH_CMAKE) diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 53fdae0..ce12b97 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -38,6 +38,8 @@ struct cmState::SnapshotDataType std::vector::size_type IncludeDirectoryPosition; std::vector::size_type CompileDefinitionsPosition; std::vector::size_type CompileOptionsPosition; + + std::string ProjectName; }; struct cmState::PolicyStackEntry: public cmPolicies::PolicyMap @@ -1312,6 +1314,16 @@ cmState::Directory cmState::Snapshot::GetDirectory() const return Directory(this->Position->BuildSystemDirectory, *this); } +void cmState::Snapshot::SetProjectName(const std::string& name) +{ + this->Position->ProjectName = name; +} + +std::string cmState::Snapshot::GetProjectName() const +{ + return this->Position->ProjectName; +} + cmState::Directory::Directory( cmLinkedTree::iterator iter, const cmState::Snapshot& snapshot) diff --git a/Source/cmState.h b/Source/cmState.h index e503cd2..c3ff4e8 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -86,6 +86,9 @@ public: Directory GetDirectory() const; + void SetProjectName(std::string const& name); + std::string GetProjectName() const; + struct StrictWeakOrder { bool operator()(const cmState::Snapshot& lhs, http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3ece2f822e82c3c3da587a8c99a901abd343d60c commit 3ece2f822e82c3c3da587a8c99a901abd343d60c Author: Stephen Kelly AuthorDate: Sun Aug 2 10:57:31 2015 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 24 20:15:00 2015 +0200 cmMakefile: Use std::string in ProjectName API. diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx index 591a2cd..7da334e 100644 --- a/Source/cmCPluginAPI.cxx +++ b/Source/cmCPluginAPI.cxx @@ -115,7 +115,9 @@ void CCONV cmAddCacheDefinition(void *arg, const char* name, const char* CCONV cmGetProjectName(void *arg) { cmMakefile *mf = static_cast(arg); - return mf->GetProjectName(); + static std::string name; + name = mf->GetProjectName(); + return name.c_str(); } const char* CCONV cmGetHomeDirectory(void *arg) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 73911a5..abdd767 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2044,12 +2044,12 @@ void cmMakefile::RemoveCacheDefinition(const std::string& name) this->GetState()->RemoveCacheEntry(name); } -void cmMakefile::SetProjectName(const char* p) +void cmMakefile::SetProjectName(std::string const& p) { this->ProjectName = p; } -const char* cmMakefile::GetProjectName() const +std::string cmMakefile::GetProjectName() const { return this->ProjectName.c_str(); } diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 959f0e7..dfd3e19 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -274,12 +274,12 @@ public: /** * Specify the name of the project for this build. */ - void SetProjectName(const char*); + void SetProjectName(std::string const& name); /** * Get the name of the project for this build. */ - const char* GetProjectName() const; + std::string GetProjectName() const; /** Get the configurations to be generated. */ std::string GetConfigurations(std::vector& configs, diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx index 46d7e01..7123125 100644 --- a/Source/cmProjectCommand.cxx +++ b/Source/cmProjectCommand.cxx @@ -20,7 +20,7 @@ bool cmProjectCommand this->SetError("PROJECT called with incorrect number of arguments"); return false; } - this->Makefile->SetProjectName(args[0].c_str()); + this->Makefile->SetProjectName(args[0]); std::string bindir = args[0]; bindir += "_BINARY_DIR"; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cfbf9805546b650f448273e9cfc1f7bbdff86bcc commit cfbf9805546b650f448273e9cfc1f7bbdff86bcc Author: Stephen Kelly AuthorDate: Sun Aug 2 10:56:33 2015 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 24 20:14:33 2015 +0200 cmMakefile: Out-of-line GetProjectName. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 2296d5a..73911a5 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2049,6 +2049,10 @@ void cmMakefile::SetProjectName(const char* p) this->ProjectName = p; } +const char* cmMakefile::GetProjectName() const +{ + return this->ProjectName.c_str(); +} void cmMakefile::AddGlobalLinkInformation(const std::string& name, cmTarget& target) diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 055170a..959f0e7 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -279,10 +279,7 @@ public: /** * Get the name of the project for this build. */ - const char* GetProjectName() const - { - return this->ProjectName.c_str(); - } + const char* GetProjectName() const; /** Get the configurations to be generated. */ std::string GetConfigurations(std::vector& configs, ----------------------------------------------------------------------- Summary of changes: Source/cmCPluginAPI.cxx | 4 +++- Source/cmGlobalGenerator.cxx | 11 ++++++----- Source/cmMakefile.cxx | 10 +++++++--- Source/cmMakefile.h | 9 ++------- Source/cmProjectCommand.cxx | 2 +- Source/cmState.cxx | 12 ++++++++++++ Source/cmState.h | 3 +++ 7 files changed, 34 insertions(+), 17 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 24 14:28:44 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 24 Aug 2015 14:28:44 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-926-gddb7f28 Message-ID: <20150824182844.705CEB1985@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via ddb7f280ce4e7a76dc66c53e933df9e11ee35e20 (commit) via 04e708d8df71234750b3ea00e2d9ada0dd7def82 (commit) via e8585f45f57e23bc9eca068d8bee02888066d722 (commit) via 6db713c07f2f1b14f695e123008522daf3d26527 (commit) from 2370a99400c6450606e25562386cf40bc9c41f38 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ddb7f280ce4e7a76dc66c53e933df9e11ee35e20 commit ddb7f280ce4e7a76dc66c53e933df9e11ee35e20 Merge: 2370a99 04e708d Author: Brad King AuthorDate: Mon Aug 24 14:28:43 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 24 14:28:43 2015 -0400 Merge topic 'drop-cmsys-std-layer' 04e708d8 Remove use of include from KWSys e8585f45 Remove use of include and cmsys_stl::* 6db713c0 Remove use of include and cmsys_ios::* ----------------------------------------------------------------------- Summary of changes: Source/CPack/OSXScriptLauncher.cxx | 11 +++-- Source/CPack/cmCPackSTGZGenerator.cxx | 3 +- Source/CTest/cmCTestCoverageHandler.cxx | 2 - Source/CTest/cmCTestGIT.cxx | 1 - Source/CTest/cmCTestP4.cxx | 1 - Source/cmArchiveWrite.cxx | 7 ++- Source/cmCMakeHostSystemInformationCommand.cxx | 4 +- Source/cmComputeLinkDepends.cxx | 2 - Source/cmCryptoHash.cxx | 2 +- Source/cmFindLibraryCommand.cxx | 1 - Source/cmFindPackageCommand.cxx | 2 +- Source/cmQtAutoGenerators.cxx | 5 +- Source/cmStandardIncludes.h | 8 ---- Source/cmSystemTools.cxx | 3 +- Source/cmXMLSafe.cxx | 8 ++-- Source/cmXMLSafe.h | 8 ++-- Tests/CMakeLib/testVisualStudioSlnParser.cxx | 60 ++++++++++++------------ Tests/CMakeLib/testXMLParser.cxx | 4 +- 18 files changed, 56 insertions(+), 76 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 24 14:28:57 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 24 Aug 2015 14:28:57 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2408-gcfcd894 Message-ID: <20150824182857.E80ABB1985@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via cfcd894286a8e301ee4dbec4ad06cfd268e3e8df (commit) via ddb7f280ce4e7a76dc66c53e933df9e11ee35e20 (commit) from 98ec73c459d7daa6800811726799559f0d0a12e2 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cfcd894286a8e301ee4dbec4ad06cfd268e3e8df commit cfcd894286a8e301ee4dbec4ad06cfd268e3e8df Merge: 98ec73c ddb7f28 Author: Brad King AuthorDate: Mon Aug 24 14:28:51 2015 -0400 Commit: Brad King CommitDate: Mon Aug 24 14:28:51 2015 -0400 Merge branch 'master' into next ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 24 14:30:54 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 24 Aug 2015 14:30:54 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2410-g536fc37 Message-ID: <20150824183054.A0ED3B1971@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 536fc37c4505057b3ba2b0d79a28828c47b42a22 (commit) via 1768830551a16cb7ac420d575acb2e7e625eb879 (commit) from cfcd894286a8e301ee4dbec4ad06cfd268e3e8df (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=536fc37c4505057b3ba2b0d79a28828c47b42a22 commit 536fc37c4505057b3ba2b0d79a28828c47b42a22 Merge: cfcd894 1768830 Author: Brad King AuthorDate: Mon Aug 24 14:30:53 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 24 14:30:53 2015 -0400 Merge topic 'add-shared-link-flags-to-try_compile' into next 17688305 Revert "try_compile: Pass hared library link flags into test project" http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1768830551a16cb7ac420d575acb2e7e625eb879 commit 1768830551a16cb7ac420d575acb2e7e625eb879 Author: Brad King AuthorDate: Mon Aug 24 14:30:34 2015 -0400 Commit: Brad King CommitDate: Mon Aug 24 14:30:38 2015 -0400 Revert "try_compile: Pass hared library link flags into test project" This reverts commit 96e04e199be36cfdd3ebda4a8714cc498e661bea. We've chosen an alternative design. diff --git a/Help/command/try_compile.rst b/Help/command/try_compile.rst index a014b98..1ed24df 100644 --- a/Help/command/try_compile.rst +++ b/Help/command/try_compile.rst @@ -105,10 +105,7 @@ default values: * :variable:`CMAKE_POSITION_INDEPENDENT_CODE` If :policy:`CMP0056` is set to ``NEW``, then -:variable:`CMAKE_EXE_LINKER_FLAGS` is passed in. - -If :policy:`CMP0065` is set to ``NEW``, then -CMAKE_SHARED_LIBRARY_LINK__FLAGS is also passed in. +:variable:`CMAKE_EXE_LINKER_FLAGS` is passed in as well. Set the :variable:`CMAKE_TRY_COMPILE_CONFIGURATION` variable to choose a build configuration. diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst index ae5354f..590f10d 100644 --- a/Help/manual/cmake-policies.7.rst +++ b/Help/manual/cmake-policies.7.rst @@ -122,4 +122,3 @@ All Policies /policy/CMP0062 /policy/CMP0063 /policy/CMP0064 - /policy/CMP0065 diff --git a/Help/policy/CMP0065.rst b/Help/policy/CMP0065.rst deleted file mode 100644 index 168b338..0000000 --- a/Help/policy/CMP0065.rst +++ /dev/null @@ -1,37 +0,0 @@ -CMP0065 -------- - -Honor shared library link flags in :command:`try_compile` source-file -signature. - -The :command:`try_compile` command source-file signature generates a -``CMakeLists.txt`` file to build the source file into an executable. -In order to compile the source the same way as it might be compiled -by the calling project, the generated project sets the value of the -:variable:`CMAKE__FLAGS` variable to that in the calling project. -The value of the CMAKE_SHARED_LIBRARY_LINK__FLAGS variable may be -needed in some cases, when it's changed from the default settings in the -Platform or Toolchain file, but CMake 3.3.1 and lower did not set it in -the generated project. CMake 3.3.2 and above prefer to set it so that -the additional linker flags are honored as well as compiler flags. This -policy provides compatibility with the pre-3.3.2 behavior. - -The OLD behavior for this policy is to not set the value of the -CMAKE_SHARED_LIBRARY_LINK__FLAGS variable in the generated test -project and just rely on the values loaded from the Platform file. The -NEW behavior for this policy is to set the value of the -CMAKE_SHARED_LIBRARY_LINK__FLAGS variable in the test project to -the same as it is in the calling project. - -If the project code does not set the policy explicitly, users may -set it on the command line by defining the -:variable:`CMAKE_POLICY_DEFAULT_CMP0065 >` -variable in the cache. - -This policy was introduced in CMake version 3.3.2. Unlike most policies, -CMake version |release| does *not* warn by default when this policy -is not set and simply uses OLD behavior. See documentation of the -:variable:`CMAKE_POLICY_WARNING_CMP0065 >` -variable to control the warning. - -.. include:: DEPRECATED.txt diff --git a/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst b/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst index 582f9e4..8de0d56 100644 --- a/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst +++ b/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst @@ -13,8 +13,6 @@ warn by default: policy :policy:`CMP0056`. * ``CMAKE_POLICY_WARNING_CMP0060`` controls the warning for policy :policy:`CMP0060`. -* ``CMAKE_POLICY_WARNING_CMP0065`` controls the warning for - policy :policy:`CMP0065`. This variable should not be set by a project in CMake code. Project developers running CMake may set this variable in their cache to diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index a2d12a7..9411555 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -326,7 +326,6 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) fprintf(fout, "set(CMAKE_%s_FLAGS \"${CMAKE_%s_FLAGS}" " ${COMPILE_DEFINITIONS}\")\n", li->c_str(), li->c_str()); } - switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0056)) { case cmPolicies::WARN: @@ -362,44 +361,6 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) } fprintf(fout, "set(CMAKE_EXE_LINKER_FLAGS \"${CMAKE_EXE_LINKER_FLAGS}" " ${EXE_LINKER_FLAGS}\")\n"); - - switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0065)) - { - case cmPolicies::WARN: - if(this->Makefile->PolicyOptionalWarningEnabled( - "CMAKE_POLICY_WARNING_CMP0065")) - { - std::ostringstream w; - w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0065) << "\n" - "For compatibility with older versions of CMake, try_compile " - "is not honoring caller link flags (e.g. " - "CMAKE_SHARED_LIBRARY_LINK__FLAGS) in the test project." - ; - this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); - } - case cmPolicies::OLD: - // OLD behavior is to do nothing. - break; - case cmPolicies::REQUIRED_IF_USED: - case cmPolicies::REQUIRED_ALWAYS: - this->Makefile->IssueMessage( - cmake::FATAL_ERROR, - cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0065) - ); - case cmPolicies::NEW: - // NEW behavior is to pass linker flags. - { - for(std::set::iterator li = testLangs.begin(); - li != testLangs.end(); ++li) - { - std::string var = "CMAKE_SHARED_LIBRARY_LINK_" + *li + "_FLAGS"; - const char* val = this->Makefile->GetDefinition(var); - fprintf(fout, "set(%s %s)\n", var.c_str(), - cmOutputConverter::EscapeForCMake(val?val:"").c_str()); - } - } break; - } - fprintf(fout, "include_directories(${INCLUDE_DIRECTORIES})\n"); fprintf(fout, "set(CMAKE_SUPPRESS_REGENERATION 1)\n"); fprintf(fout, "link_directories(${LINK_DIRECTORIES})\n"); diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 5063249..a791b89 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -195,7 +195,7 @@ class cmPolicy; "Strict checking for break() command.", \ 3, 2, 0, cmPolicies::WARN) \ SELECT(POLICY, CMP0056, \ - "Honor exe link flags in try_compile() source-file signature.", \ + "Honor link flags in try_compile() source-file signature.", \ 3, 2, 0, cmPolicies::WARN) \ SELECT(POLICY, CMP0057, \ "Support new IN_LIST if() operator.", \ @@ -220,10 +220,7 @@ class cmPolicy; 3, 3, 0, cmPolicies::WARN) \ SELECT(POLICY, CMP0064, \ "Support new TEST if() operator.", \ - 3, 3, 0, cmPolicies::WARN) \ - SELECT(POLICY, CMP0065, \ - "Honor shared lib link flags in try_compile() source-file signature.", \ - 3, 2, 0, cmPolicies::WARN) + 3, 3, 0, cmPolicies::WARN) #define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1) #define CM_FOR_EACH_POLICY_ID(POLICY) \ diff --git a/Tests/RunCMake/try_compile/CMP0056-stderr.txt b/Tests/RunCMake/try_compile/CMP0056-stderr.txt index 2adc3e5..5c1f0e4 100644 --- a/Tests/RunCMake/try_compile/CMP0056-stderr.txt +++ b/Tests/RunCMake/try_compile/CMP0056-stderr.txt @@ -2,10 +2,9 @@ before try_compile with CMP0056 WARN-default after try_compile with CMP0056 WARN-default * CMake Warning \(dev\) at CMP0056.cmake:[0-9]+ \(try_compile\): - Policy CMP0056 is not set: Honor exe link flags in try_compile\(\) - source-file signature. Run "cmake --help-policy CMP0056" for policy - details. Use the cmake_policy command to set the policy and suppress this - warning. + Policy CMP0056 is not set: Honor link flags in try_compile\(\) source-file + signature. Run "cmake --help-policy CMP0056" for policy details. Use the + cmake_policy command to set the policy and suppress this warning. For compatibility with older versions of CMake, try_compile is not honoring caller link flags \(e.g. CMAKE_EXE_LINKER_FLAGS\) in the test project. diff --git a/Tests/RunCMake/try_compile/CMP0065-stderr.txt b/Tests/RunCMake/try_compile/CMP0065-stderr.txt deleted file mode 100644 index 5bf1fff..0000000 --- a/Tests/RunCMake/try_compile/CMP0065-stderr.txt +++ /dev/null @@ -1,15 +0,0 @@ -before try_compile with CMP0065 WARN-default -after try_compile with CMP0065 WARN-default -* -CMake Warning \(dev\) at CMP0065.cmake:[0-9]+ \(try_compile\): - Policy CMP0065 is not set: Honor shared lib link flags in try_compile\(\) - source-file signature. Run "cmake --help-policy CMP0065" for policy - details. Use the cmake_policy command to set the policy and suppress this - warning. - - For compatibility with older versions of CMake, try_compile is not honoring - caller link flags \(e.g. CMAKE_SHARED_LIBRARY_LINK__FLAGS\) in the - test project. -Call Stack \(most recent call first\): - CMakeLists.txt:[0-9]+ \(include\) -This warning is for project developers. Use -Wno-dev to suppress it.$ diff --git a/Tests/RunCMake/try_compile/CMP0065-stdout.txt b/Tests/RunCMake/try_compile/CMP0065-stdout.txt deleted file mode 100644 index ba03ea7..0000000 --- a/Tests/RunCMake/try_compile/CMP0065-stdout.txt +++ /dev/null @@ -1,4 +0,0 @@ --- try_compile with CMP0065 WARN-default worked as expected --- try_compile with CMP0065 WARN-enabled worked as expected --- try_compile with CMP0065 OLD worked as expected --- try_compile with CMP0065 NEW worked as expected diff --git a/Tests/RunCMake/try_compile/CMP0065.cmake b/Tests/RunCMake/try_compile/CMP0065.cmake deleted file mode 100644 index 942f872..0000000 --- a/Tests/RunCMake/try_compile/CMP0065.cmake +++ /dev/null @@ -1,67 +0,0 @@ -enable_language(C) -set(obj "${CMAKE_C_OUTPUT_EXTENSION}") -if(BORLAND) - set(pre -) -endif() -set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS ${pre}BADFLAG${obj}) - -#----------------------------------------------------------------------------- -message("before try_compile with CMP0065 WARN-default") -try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/src.c - OUTPUT_VARIABLE out - ) -string(REPLACE "\n" "\n " out " ${out}") -if(NOT RESULT) - message(FATAL_ERROR "try_compile failed but should have passed:\n${out}") -elseif("x${out}" MATCHES "BADFLAG") - message(FATAL_ERROR "try_compile output mentions BADFLAG:\n${out}") -else() - message(STATUS "try_compile with CMP0065 WARN-default worked as expected") -endif() -message("after try_compile with CMP0065 WARN-default") - -#----------------------------------------------------------------------------- -set(CMAKE_POLICY_WARNING_CMP0065 ON) -try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/src.c - OUTPUT_VARIABLE out - ) -string(REPLACE "\n" "\n " out " ${out}") -if(NOT RESULT) - message(FATAL_ERROR "try_compile failed but should have passed:\n${out}") -elseif("x${out}" MATCHES "BADFLAG") - message(FATAL_ERROR "try_compile output mentions BADFLAG:\n${out}") -else() - message(STATUS "try_compile with CMP0065 WARN-enabled worked as expected") -endif() - -#----------------------------------------------------------------------------- -cmake_policy(SET CMP0065 OLD) -try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/src.c - OUTPUT_VARIABLE out - ) -string(REPLACE "\n" "\n " out " ${out}") -if(NOT RESULT) - message(FATAL_ERROR "try_compile failed but should have passed:\n${out}") -elseif("x${out}" MATCHES "BADFLAG") - message(FATAL_ERROR "try_compile output mentions BADFLAG:\n${out}") -else() - message(STATUS "try_compile with CMP0065 OLD worked as expected") -endif() - -#----------------------------------------------------------------------------- -cmake_policy(SET CMP0065 NEW) -try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/src.c - OUTPUT_VARIABLE out - ) -string(REPLACE "\n" "\n " out " ${out}") -if(RESULT) - message(FATAL_ERROR "try_compile passed but should have failed:\n${out}") -elseif(NOT "x${out}" MATCHES "BADFLAG") - message(FATAL_ERROR "try_compile did not fail with BADFLAG:\n${out}") -else() - message(STATUS "try_compile with CMP0065 NEW worked as expected") -endif() diff --git a/Tests/RunCMake/try_compile/RunCMakeTest.cmake b/Tests/RunCMake/try_compile/RunCMakeTest.cmake index 98282e4..6cdbafa 100644 --- a/Tests/RunCMake/try_compile/RunCMakeTest.cmake +++ b/Tests/RunCMake/try_compile/RunCMakeTest.cmake @@ -17,7 +17,6 @@ run_cmake(NonSourceCopyFile) run_cmake(NonSourceCompileDefinitions) run_cmake(CMP0056) -run_cmake(CMP0065) if(RunCMake_GENERATOR MATCHES "Make|Ninja") # Use a single build tree for a few tests without cleaning. ----------------------------------------------------------------------- Summary of changes: Help/command/try_compile.rst | 5 +- Help/manual/cmake-policies.7.rst | 1 - Help/policy/CMP0065.rst | 37 ------------- Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst | 2 - Source/cmCoreTryCompile.cxx | 39 -------------- Source/cmPolicies.h | 7 +-- Tests/RunCMake/try_compile/CMP0056-stderr.txt | 7 ++- Tests/RunCMake/try_compile/CMP0065-stderr.txt | 15 ------ Tests/RunCMake/try_compile/CMP0065-stdout.txt | 4 -- Tests/RunCMake/try_compile/CMP0065.cmake | 67 ------------------------ Tests/RunCMake/try_compile/RunCMakeTest.cmake | 1 - 11 files changed, 6 insertions(+), 179 deletions(-) delete mode 100644 Help/policy/CMP0065.rst delete mode 100644 Tests/RunCMake/try_compile/CMP0065-stderr.txt delete mode 100644 Tests/RunCMake/try_compile/CMP0065-stdout.txt delete mode 100644 Tests/RunCMake/try_compile/CMP0065.cmake hooks/post-receive -- CMake From steveire at gmail.com Mon Aug 24 14:41:27 2015 From: steveire at gmail.com (Stephen Kelly) Date: Mon, 24 Aug 2015 14:41:27 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2413-g6c485ea Message-ID: <20150824184127.71990B09F9@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 6c485ea8009341d0c746ed3bac3c5d31e6bcea7f (commit) via 0138a0e9116567f5e9c45e36d657d01e3953e6fe (commit) via 9faef0000924a39cb82f54bb91a9ca734a4c8643 (commit) from 536fc37c4505057b3ba2b0d79a28828c47b42a22 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6c485ea8009341d0c746ed3bac3c5d31e6bcea7f commit 6c485ea8009341d0c746ed3bac3c5d31e6bcea7f Merge: 536fc37 0138a0e Author: Stephen Kelly AuthorDate: Mon Aug 24 14:41:26 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 24 14:41:26 2015 -0400 Merge topic 'cmState-definitions' into next 0138a0e9 Revert "cmLinkedTree: Add API for size query and reserve." 9faef000 Revert "cmState: Reserve the number of cmLinkedTree nodes if known." http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0138a0e9116567f5e9c45e36d657d01e3953e6fe commit 0138a0e9116567f5e9c45e36d657d01e3953e6fe Author: Stephen Kelly AuthorDate: Mon Aug 24 20:40:54 2015 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 24 20:40:54 2015 +0200 Revert "cmLinkedTree: Add API for size query and reserve." This reverts commit d7fc7c3a403170035359e8e3b173725a04b6c1ff. diff --git a/Source/cmLinkedTree.h b/Source/cmLinkedTree.h index 385dff2..3bcb940 100644 --- a/Source/cmLinkedTree.h +++ b/Source/cmLinkedTree.h @@ -161,17 +161,6 @@ public: this->Data.clear(); } - size_t Size() const - { - return this->UpPositions.size(); - } - - void Reserve(size_t amount) - { - this->UpPositions.reserve(amount); - this->Data.reserve(amount); - } - private: T& GetReference(PositionType pos) { http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9faef0000924a39cb82f54bb91a9ca734a4c8643 commit 9faef0000924a39cb82f54bb91a9ca734a4c8643 Author: Stephen Kelly AuthorDate: Mon Aug 24 20:40:50 2015 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 24 20:40:50 2015 +0200 Revert "cmState: Reserve the number of cmLinkedTree nodes if known." This reverts commit eb47176870eedef7af8b53d98887d4326cb509de. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index a19a074..cda26cd 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1141,42 +1141,6 @@ void cmGlobalGenerator::Configure() this->BinaryDirectories.insert( this->CMakeInstance->GetHomeOutputDirectory()); - if (const char *numStr = - this->GetCMakeInstance()->GetState() - ->GetInitializedCacheValue("CMAKE_NUMBER_OF_DEFINITION_STATES")) - { - int num = atoi(numStr); - this->GetCMakeInstance()->GetState()->ReserveDefinitions(num); - } - if (const char *numStr = - this->GetCMakeInstance()->GetState() - ->GetInitializedCacheValue("CMAKE_NUMBER_OF_SNAPSHOT_STATES")) - { - int num = atoi(numStr); - this->GetCMakeInstance()->GetState()->ReserveSnapshots(num); - } - if (const char *numStr = - this->GetCMakeInstance()->GetState() - ->GetInitializedCacheValue("CMAKE_NUMBER_OF_LISTFILE_STATES")) - { - int num = atoi(numStr); - this->GetCMakeInstance()->GetState()->ReserveListFiles(num); - } - if (const char *numStr = - this->GetCMakeInstance()->GetState() - ->GetInitializedCacheValue("CMAKE_NUMBER_OF_LOCAL_GENERATORS")) - { - int num = atoi(numStr); - this->GetCMakeInstance()->GetState()->ReserveDirectories(num); - } - if (const char *numStr = - this->GetCMakeInstance()->GetState() - ->GetInitializedCacheValue("CMAKE_NUMBER_OF_POLICY_STATES")) - { - int num = atoi(numStr); - this->GetCMakeInstance()->GetState()->ReservePolicies(num); - } - // now do it lg->GetMakefile()->Configure(); lg->GetMakefile()->EnforceDirectoryLevelRules(); @@ -1189,35 +1153,6 @@ void cmGlobalGenerator::Configure() ("CMAKE_NUMBER_OF_MAKEFILES", num, "number of local generators", cmState::INTERNAL); - { - std::ostringstream str; - str << this->GetCMakeInstance()->GetState()->DefinitionsSize(); - this->GetCMakeInstance()->AddCacheEntry - ("CMAKE_NUMBER_OF_DEFINITION_STATES", str.str().c_str(), - "number of definition states", cmState::INTERNAL); - } - { - std::ostringstream str; - str << this->GetCMakeInstance()->GetState()->SnapshotsSize(); - this->GetCMakeInstance()->AddCacheEntry - ("CMAKE_NUMBER_OF_SNAPSHOT_STATES", str.str().c_str(), - "number of snapshot states", cmState::INTERNAL); - } - { - std::ostringstream str; - str << this->GetCMakeInstance()->GetState()->ListFilesSize(); - this->GetCMakeInstance()->AddCacheEntry - ("CMAKE_NUMBER_OF_LISTFILE_STATES", str.str().c_str(), - "number of listfile states", cmState::INTERNAL); - } - { - std::ostringstream str; - str << this->GetCMakeInstance()->GetState()->PoliciesSize(); - this->GetCMakeInstance()->AddCacheEntry - ("CMAKE_NUMBER_OF_POLICY_STATES", str.str().c_str(), - "number of policy states", cmState::INTERNAL); - } - // check for link libraries and include directories containing "NOTFOUND" // and for infinite loops this->CheckLocalGenerators(); diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 99a7537..ab309ad 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -651,56 +651,6 @@ bool cmState::UseMSYSShell() const return this->MSYSShell; } -size_t cmState::DefinitionsSize() const -{ - return this->VarTree.Size(); -} - -void cmState::ReserveDefinitions(size_t amount) -{ - this->VarTree.Reserve(amount); -} - -size_t cmState::SnapshotsSize() const -{ - return this->SnapshotData.Size(); -} - -void cmState::ReserveSnapshots(size_t amount) -{ - this->SnapshotData.Reserve(amount); -} - -size_t cmState::ListFilesSize() const -{ - return this->ExecutionListFiles.Size(); -} - -void cmState::ReserveListFiles(size_t amount) -{ - this->ExecutionListFiles.Reserve(amount); -} - -size_t cmState::DirectoriesSize() const -{ - return this->BuildsystemDirectory.Size(); -} - -void cmState::ReserveDirectories(size_t amount) -{ - this->BuildsystemDirectory.Reserve(amount); -} - -size_t cmState::PoliciesSize() const -{ - return this->PolicyStack.Size(); -} - -void cmState::ReservePolicies(size_t amount) -{ - this->PolicyStack.Reserve(amount); -} - const char* cmState::GetBinaryDirectory() const { return this->BinaryDirectory.c_str(); diff --git a/Source/cmState.h b/Source/cmState.h index 8380587..5499665 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -270,21 +270,6 @@ public: void SetMSYSShell(bool mSYSShell); bool UseMSYSShell() const; - size_t DefinitionsSize() const; - void ReserveDefinitions(size_t amount); - - size_t SnapshotsSize() const; - void ReserveSnapshots(size_t amount); - - size_t ListFilesSize() const; - void ReserveListFiles(size_t amount); - - size_t DirectoriesSize() const; - void ReserveDirectories(size_t amount); - - size_t PoliciesSize() const; - void ReservePolicies(size_t amount); - private: std::map PropertyDefinitions; std::vector EnabledLanguages; ----------------------------------------------------------------------- Summary of changes: Source/cmGlobalGenerator.cxx | 65 ------------------------------------------ Source/cmLinkedTree.h | 11 ------- Source/cmState.cxx | 50 -------------------------------- Source/cmState.h | 15 ---------- 4 files changed, 141 deletions(-) hooks/post-receive -- CMake From steveire at gmail.com Mon Aug 24 14:48:49 2015 From: steveire at gmail.com (Stephen Kelly) Date: Mon, 24 Aug 2015 14:48:49 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2419-g9908727 Message-ID: <20150824184849.E13FDB17E2@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 9908727dfa4a0bfeb38aaf5e1111e5127361aee8 (commit) via e876963fc9e03018a189f4433050d459a475afbf (commit) via 44ffb9cdb4329c5ed9b724659f234d26da336b5a (commit) via 8f89f8b1e9693abbc50d917c04846000bf14e189 (commit) via 524610f967e5289810a0d67a2942493d8f61d1dd (commit) via 0e14c7ee6375fcaa975194557523f5a1a8686a8a (commit) from 6c485ea8009341d0c746ed3bac3c5d31e6bcea7f (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9908727dfa4a0bfeb38aaf5e1111e5127361aee8 commit 9908727dfa4a0bfeb38aaf5e1111e5127361aee8 Merge: 6c485ea e876963 Author: Stephen Kelly AuthorDate: Mon Aug 24 14:48:48 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 24 14:48:48 2015 -0400 Merge topic 'consistent-empty' into next e876963f Replace '0 == instances.size()' with instances.empty(). 44ffb9cd Replace foo.size() pattern with !foo.empty(). 8f89f8b1 Replace 'foo.size() != 0' pattern with !foo.empty(). 524610f9 Replace 'foo.size() == 0' pattern with foo.empty(). 0e14c7ee Replace 'foo.size() > 0' pattern with !foo.empty(). http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e876963fc9e03018a189f4433050d459a475afbf commit e876963fc9e03018a189f4433050d459a475afbf Author: Stephen Kelly AuthorDate: Thu Jan 15 23:45:51 2015 +0100 Commit: Stephen Kelly CommitDate: Mon Aug 24 20:47:18 2015 +0200 Replace '0 == instances.size()' with instances.empty(). This is not a pattern. diff --git a/Source/cmCallVisualStudioMacro.cxx b/Source/cmCallVisualStudioMacro.cxx index c211111..0e04838 100644 --- a/Source/cmCallVisualStudioMacro.cxx +++ b/Source/cmCallVisualStudioMacro.cxx @@ -498,7 +498,7 @@ int cmCallVisualStudioMacro::CallMacro( } } - if(0 == instances.size()) + if(instances.empty()) { // no instances to call http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=44ffb9cdb4329c5ed9b724659f234d26da336b5a commit 44ffb9cdb4329c5ed9b724659f234d26da336b5a Author: Stephen Kelly AuthorDate: Fri Jan 16 01:17:32 2015 +0100 Commit: Stephen Kelly CommitDate: Mon Aug 24 20:47:18 2015 +0200 Replace foo.size() pattern with !foo.empty(). diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index b3eb7b2..6f25e50 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -217,7 +217,7 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration() { std::string defaultRef = "WixUI_InstallDir"; - if(this->Components.size()) + if(!this->Components.empty()) { defaultRef = "WixUI_FeatureTree"; } @@ -1005,7 +1005,7 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons( shortcut.workingDirectoryId = directoryId; shortcuts.insert(cmWIXShortcuts::START_MENU, id, shortcut); - if(desktopExecutables.size() && + if(!desktopExecutables.empty() && std::find(desktopExecutables.begin(), desktopExecutables.end(), executableName) diff --git a/Source/CPack/WiX/cmWIXAccessControlList.cxx b/Source/CPack/WiX/cmWIXAccessControlList.cxx index aeec968..fc0d3d3 100644 --- a/Source/CPack/WiX/cmWIXAccessControlList.cxx +++ b/Source/CPack/WiX/cmWIXAccessControlList.cxx @@ -71,7 +71,7 @@ void cmWIXAccessControlList::CreatePermissionElement( this->SourceWriter.BeginElement("Permission"); this->SourceWriter.AddAttribute("User", user); - if(domain.size()) + if(!domain.empty()) { this->SourceWriter.AddAttribute("Domain", domain); } diff --git a/Source/CPack/WiX/cmWIXPatch.cxx b/Source/CPack/WiX/cmWIXPatch.cxx index b5202e0..5a8dc63 100644 --- a/Source/CPack/WiX/cmWIXPatch.cxx +++ b/Source/CPack/WiX/cmWIXPatch.cxx @@ -79,7 +79,7 @@ bool cmWIXPatch::CheckForUnappliedFragments() fragmentList += "'"; } - if(fragmentList.size()) + if(!fragmentList.empty()) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Some XML patch fragments did not have matching IDs: " << diff --git a/Source/CPack/WiX/cmWIXSourceWriter.cxx b/Source/CPack/WiX/cmWIXSourceWriter.cxx index 219fca8..8d38e9b 100644 --- a/Source/CPack/WiX/cmWIXSourceWriter.cxx +++ b/Source/CPack/WiX/cmWIXSourceWriter.cxx @@ -128,7 +128,7 @@ void cmWIXSourceWriter::AddAttribute( void cmWIXSourceWriter::AddAttributeUnlessEmpty( std::string const& key, std::string const& value) { - if(value.size()) + if(!value.empty()) { AddAttribute(key, value); } diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index 49aad97..6cdda28 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -536,7 +536,7 @@ int cmCPackNSISGenerator::InitializeInternal() << ".lnk\"" << std::endl; // see if CPACK_CREATE_DESKTOP_LINK_ExeName is on // if so add a desktop link - if(cpackPackageDesktopLinksVector.size() && + if(!cpackPackageDesktopLinksVector.empty() && std::find(cpackPackageDesktopLinksVector.begin(), cpackPackageDesktopLinksVector.end(), execName) diff --git a/Source/cmGlobalMSYSMakefileGenerator.cxx b/Source/cmGlobalMSYSMakefileGenerator.cxx index a84923b..9a6f3ba 100644 --- a/Source/cmGlobalMSYSMakefileGenerator.cxx +++ b/Source/cmGlobalMSYSMakefileGenerator.cxx @@ -62,19 +62,19 @@ void cmGlobalMSYSMakefileGenerator locations.push_back("c:/mingw/bin"); std::string tgcc = cmSystemTools::FindProgram("gcc", locations); std::string gcc = "gcc.exe"; - if(tgcc.size()) + if(!tgcc.empty()) { gcc = tgcc; } std::string tgxx = cmSystemTools::FindProgram("g++", locations); std::string gxx = "g++.exe"; - if(tgxx.size()) + if(!tgxx.empty()) { gxx = tgxx; } std::string trc = cmSystemTools::FindProgram("windres", locations); std::string rc = "windres.exe"; - if(trc.size()) + if(!trc.empty()) { rc = trc; } diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 553d568..b0aa243 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -81,7 +81,7 @@ bool cmGlobalVisualStudioGenerator::Compute() { std::vector& gen = it->second; // add the ALL_BUILD to the first local generator of each project - if(gen.size()) + if(!gen.empty()) { // Use no actual command lines so that the target itself is not // considered always out of date. diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 39933cb..4ba29f5 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -772,7 +772,7 @@ cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg, sf->GetProperty("COMPILE_DEFINITIONS"), true); if (!flagsBuild.IsEmpty()) { - if (flags.size()) + if (!flags.empty()) { flags += ' '; } @@ -1874,7 +1874,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, { extraLinkOptionsVar = "CMAKE_MODULE_LINKER_FLAGS"; } - if(extraLinkOptionsVar.size()) + if(!extraLinkOptionsVar.empty()) { this->CurrentLocalGenerator ->AddConfigVariableFlags(extraLinkOptions, @@ -2614,7 +2614,7 @@ std::string cmGlobalXCodeGenerator::AddConfigurations(cmXCodeObject* target, config->SetComment(configVector[i].c_str()); config->AddAttribute("buildSettings", buildSettings); } - if(configVector.size()) + if(!configVector.empty()) { configlist->AddAttribute("defaultConfigurationName", this->CreateString(configVector[0].c_str())); diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx index 9ded83a..9e3185c 100644 --- a/Source/cmLocalVisualStudio10Generator.cxx +++ b/Source/cmLocalVisualStudio10Generator.cxx @@ -33,7 +33,7 @@ class cmVS10XMLParser : public cmXMLParser virtual void StartElement(const std::string& name, const char**) { // once the GUID is found do nothing - if(this->GUID.size()) + if(!this->GUID.empty()) { return; } diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 5b78f0d..0d07536 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -984,7 +984,7 @@ void cmLocalVisualStudio6Generator std::string libMultiLineDebugOptions; std::string libMultiLineOptimizedOptions; - if(libPath.size()) + if(!libPath.empty()) { std::string lpath = this->ConvertToOutputFormat(libPath.c_str(), SHELL); @@ -1017,7 +1017,7 @@ void cmLocalVisualStudio6Generator libMultiLineOptionsForDebug += " \n"; } } - if(exePath.size()) + if(!exePath.empty()) { std::string lpath = this->ConvertToOutputFormat(exePath.c_str(), SHELL); @@ -1452,7 +1452,7 @@ void cmLocalVisualStudio6Generator #ifdef CM_USE_OLD_VS6 // Compute link information for the target. - if(extraLinkOptions.size()) + if(!extraLinkOptions.empty()) { libOptions += " "; libOptions += extraLinkOptions; @@ -1543,7 +1543,7 @@ void cmLocalVisualStudio6Generator std::string line; std::string libnameExports; - if(exportSymbol.size()) + if(!exportSymbol.empty()) { libnameExports = "/D \""; libnameExports += exportSymbol; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 2445995..5de6d37 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -2283,7 +2283,7 @@ public: virtual void StartElement(const std::string& name, const char** atts) { // once the GUID is found do nothing - if(this->GUID.size()) + if(!this->GUID.empty()) { return; } diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 6344979..823b550 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1656,7 +1656,7 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( // for the first time we need a new line if there is something // produced here. const char* firstString = ">\n"; - if(objectName.size()) + if(!objectName.empty()) { (*this->BuildFileStream ) << firstString; firstString = ""; @@ -1675,7 +1675,7 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( defPropName += configUpper; if(const char* ccdefs = sf.GetProperty(defPropName.c_str())) { - if(configDefines.size()) + if(!configDefines.empty()) { configDefines += ";"; } diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx index abd350e..bd4eb69 100644 --- a/Source/cmVisualStudioGeneratorOptions.cxx +++ b/Source/cmVisualStudioGeneratorOptions.cxx @@ -274,7 +274,7 @@ cmVisualStudioGeneratorOptions { // if there are configuration specific flags, then // use the configuration specific tag for PreprocessorDefinitions - if(this->Configuration.size()) + if(!this->Configuration.empty()) { fout << prefix; this->TargetGenerator->WritePlatformConfigTag( @@ -346,7 +346,7 @@ cmVisualStudioGeneratorOptions m != this->FlagMap.end(); ++m) { fout << indent; - if(this->Configuration.size()) + if(!this->Configuration.empty()) { this->TargetGenerator->WritePlatformConfigTag( m->first.c_str(), @@ -398,7 +398,7 @@ cmVisualStudioGeneratorOptions if(this->Version >= cmGlobalVisualStudioGenerator::VS10) { fout << prefix; - if(this->Configuration.size()) + if(!this->Configuration.empty()) { this->TargetGenerator->WritePlatformConfigTag( "AdditionalOptions", http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8f89f8b1e9693abbc50d917c04846000bf14e189 commit 8f89f8b1e9693abbc50d917c04846000bf14e189 Author: Stephen Kelly AuthorDate: Fri Jan 16 01:13:57 2015 +0100 Commit: Stephen Kelly CommitDate: Mon Aug 24 20:47:17 2015 +0200 Replace 'foo.size() != 0' pattern with !foo.empty(). diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index a6568f1..6344979 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2422,7 +2422,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) libs = this->Makefile->GetSafeDefinition(standardLibsVar.c_str()); // Remove trailing spaces from libs std::string::size_type pos = libs.size()-1; - if(libs.size() != 0) + if(!libs.empty()) { while(libs[pos] == ' ') { http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=524610f967e5289810a0d67a2942493d8f61d1dd commit 524610f967e5289810a0d67a2942493d8f61d1dd Author: Stephen Kelly AuthorDate: Fri Jan 16 01:12:53 2015 +0100 Commit: Stephen Kelly CommitDate: Mon Aug 24 20:47:17 2015 +0200 Replace 'foo.size() == 0' pattern with foo.empty(). diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index 2de2bc4..49aad97 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -49,7 +49,7 @@ int cmCPackNSISGenerator::PackageFiles() // TODO: Fix nsis to force out file name std::string nsisInFileName = this->FindTemplate("NSIS.template.in"); - if ( nsisInFileName.size() == 0 ) + if (nsisInFileName.empty()) { cmCPackLogger(cmCPackLog::LOG_ERROR, "CPack error: Could not find NSIS installer template file." @@ -58,7 +58,7 @@ int cmCPackNSISGenerator::PackageFiles() } std::string nsisInInstallOptions = this->FindTemplate("NSIS.InstallOptions.ini.in"); - if ( nsisInInstallOptions.size() == 0 ) + if (nsisInInstallOptions.empty()) { cmCPackLogger(cmCPackLog::LOG_ERROR, "CPack error: Could not find NSIS installer options file." diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx index 65a15ee..b7c897c 100644 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ b/Source/cmGlobalVisualStudio6Generator.cxx @@ -255,7 +255,7 @@ void cmGlobalVisualStudio6Generator ::OutputDSWFile(cmLocalGenerator* root, std::vector& generators) { - if(generators.size() == 0) + if(generators.empty()) { return; } diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index f7b6470..607642c 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -212,7 +212,7 @@ cmGlobalVisualStudio71Generator { const char* name = di->c_str(); std::string guid = this->GetGUID(name); - if(guid.size() == 0) + if(guid.empty()) { std::string m = "Target: "; m += target.GetName(); diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index f8d882c..2660d23 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -359,7 +359,7 @@ void cmGlobalVisualStudio7Generator ::OutputSLNFile(cmLocalGenerator* root, std::vector& generators) { - if(generators.size() == 0) + if(generators.empty()) { return; } @@ -736,7 +736,7 @@ cmGlobalVisualStudio7Generator { const char* name = di->c_str(); std::string guid = this->GetGUID(name); - if(guid.size() == 0) + if(guid.empty()) { std::string m = "Target: "; m += target.GetName(); diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 29e1034..5b78f0d 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -988,7 +988,7 @@ void cmLocalVisualStudio6Generator { std::string lpath = this->ConvertToOutputFormat(libPath.c_str(), SHELL); - if(lpath.size() == 0) + if(lpath.empty()) { lpath = "."; } @@ -1021,7 +1021,7 @@ void cmLocalVisualStudio6Generator { std::string lpath = this->ConvertToOutputFormat(exePath.c_str(), SHELL); - if(lpath.size() == 0) + if(lpath.empty()) { lpath = "."; } @@ -1062,7 +1062,7 @@ void cmLocalVisualStudio6Generator } std::string lpath = this->ConvertToOutputFormat(path.c_str(), SHELL); - if(lpath.size() == 0) + if(lpath.empty()) { lpath = "."; } diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index a38a061..2445995 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -2331,7 +2331,7 @@ void cmLocalVisualStudio7Generator::ReadAndStoreExternalGUID( cmVS7XMLParser parser; parser.ParseFile(path); // if we can not find a GUID then we will generate one later - if(parser.GUID.size() == 0) + if(parser.GUID.empty()) { return; } diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 80b8591..a6568f1 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2783,7 +2783,7 @@ void cmVisualStudio10TargetGenerator::WriteEvent( std::vector const& commands, std::string const& configName) { - if(commands.size() == 0) + if(commands.empty()) { return; } diff --git a/Source/cmXCode21Object.cxx b/Source/cmXCode21Object.cxx index f30f700..3973540 100644 --- a/Source/cmXCode21Object.cxx +++ b/Source/cmXCode21Object.cxx @@ -22,7 +22,7 @@ cmXCode21Object::cmXCode21Object(PBXType ptype, Type type) //---------------------------------------------------------------------------- void cmXCode21Object::PrintComment(std::ostream& out) { - if(this->Comment.size() == 0) + if(this->Comment.empty()) { cmXCodeObject* n = this->GetObject("name"); if(n) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0e14c7ee6375fcaa975194557523f5a1a8686a8a commit 0e14c7ee6375fcaa975194557523f5a1a8686a8a Author: Stephen Kelly AuthorDate: Fri Jan 16 01:10:07 2015 +0100 Commit: Stephen Kelly CommitDate: Mon Aug 24 20:47:17 2015 +0200 Replace 'foo.size() > 0' pattern with !foo.empty(). diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.cxx b/Source/CPack/IFW/cmCPackIFWGenerator.cxx index 09e123c..43d34ee 100644 --- a/Source/CPack/IFW/cmCPackIFWGenerator.cxx +++ b/Source/CPack/IFW/cmCPackIFWGenerator.cxx @@ -191,7 +191,7 @@ int cmCPackIFWGenerator::PackageFiles() } } // TODO: set correct name for multipackages - if (this->packageFileNames.size() > 0) + if (!this->packageFileNames.empty()) { ifwCmd += " " + packageFileNames[0]; } diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index 1ab4c9c..f7b6470 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -250,7 +250,7 @@ void cmGlobalVisualStudio71Generator std::set::const_iterator it; for(it = depends.begin(); it != depends.end(); ++it) { - if(it->size() > 0) + if(!it->empty()) { fout << "\t\t{" << this->GetGUID(it->c_str()) diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index c38a35a..553d568 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -265,7 +265,7 @@ cmGlobalVisualStudioGenerator { std::vector filenames; this->GetFilesReplacedDuringGenerate(filenames); - if (filenames.size() > 0) + if (!filenames.empty()) { // Convert vector to semi-colon delimited string of filenames: std::string projects; ----------------------------------------------------------------------- Summary of changes: Source/CPack/IFW/cmCPackIFWGenerator.cxx | 2 +- Source/CPack/WiX/cmCPackWIXGenerator.cxx | 4 ++-- Source/CPack/WiX/cmWIXAccessControlList.cxx | 2 +- Source/CPack/WiX/cmWIXPatch.cxx | 2 +- Source/CPack/WiX/cmWIXSourceWriter.cxx | 2 +- Source/CPack/cmCPackNSISGenerator.cxx | 6 +++--- Source/cmCallVisualStudioMacro.cxx | 2 +- Source/cmGlobalMSYSMakefileGenerator.cxx | 6 +++--- Source/cmGlobalVisualStudio6Generator.cxx | 2 +- Source/cmGlobalVisualStudio71Generator.cxx | 4 ++-- Source/cmGlobalVisualStudio7Generator.cxx | 4 ++-- Source/cmGlobalVisualStudioGenerator.cxx | 4 ++-- Source/cmGlobalXCodeGenerator.cxx | 6 +++--- Source/cmLocalVisualStudio10Generator.cxx | 2 +- Source/cmLocalVisualStudio6Generator.cxx | 14 +++++++------- Source/cmLocalVisualStudio7Generator.cxx | 4 ++-- Source/cmVisualStudio10TargetGenerator.cxx | 8 ++++---- Source/cmVisualStudioGeneratorOptions.cxx | 6 +++--- Source/cmXCode21Object.cxx | 2 +- 19 files changed, 41 insertions(+), 41 deletions(-) hooks/post-receive -- CMake From steveire at gmail.com Mon Aug 24 15:52:43 2015 From: steveire at gmail.com (Stephen Kelly) Date: Mon, 24 Aug 2015 15:52:43 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2421-g638e36e Message-ID: <20150824195243.3B8B2B18BD@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 638e36e30d9430d2fe134d1a4c3903e37b589ff4 (commit) via 19e9b6d4a22c2b4e6d3f66a701fe3283b555d186 (commit) from 9908727dfa4a0bfeb38aaf5e1111e5127361aee8 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=638e36e30d9430d2fe134d1a4c3903e37b589ff4 commit 638e36e30d9430d2fe134d1a4c3903e37b589ff4 Merge: 9908727 19e9b6d Author: Stephen Kelly AuthorDate: Mon Aug 24 15:52:42 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 24 15:52:42 2015 -0400 Merge topic 'cmState-ProjectName' into next 19e9b6d4 Revert topic. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=19e9b6d4a22c2b4e6d3f66a701fe3283b555d186 commit 19e9b6d4a22c2b4e6d3f66a701fe3283b555d186 Author: Stephen Kelly AuthorDate: Mon Aug 24 21:51:44 2015 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 24 21:51:56 2015 +0200 Revert topic. diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx index 7da334e..591a2cd 100644 --- a/Source/cmCPluginAPI.cxx +++ b/Source/cmCPluginAPI.cxx @@ -115,9 +115,7 @@ void CCONV cmAddCacheDefinition(void *arg, const char* name, const char* CCONV cmGetProjectName(void *arg) { cmMakefile *mf = static_cast(arg); - static std::string name; - name = mf->GetProjectName(); - return name.c_str(); + return mf->GetProjectName(); } const char* CCONV cmGetHomeDirectory(void *arg) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 17bafbe..503c455 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2102,19 +2102,18 @@ void cmGlobalGenerator::FillProjectMap() for(i = 0; i < this->LocalGenerators.size(); ++i) { // for each local generator add all projects - cmState::Snapshot snp = this->LocalGenerators[i]->GetStateSnapshot(); + cmLocalGenerator *lg = this->LocalGenerators[i]; std::string name; do { - std::string snpProjName = snp.GetProjectName(); - if (name != snpProjName) + if (name != lg->GetMakefile()->GetProjectName()) { - name = snpProjName; + name = lg->GetMakefile()->GetProjectName(); this->ProjectMap[name].push_back(this->LocalGenerators[i]); } - snp = snp.GetBuildsystemDirectoryParent(); + lg = lg->GetParent(); } - while (snp.IsValid()); + while (lg); } } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index dbf41cc..2296d5a 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1525,7 +1525,7 @@ void cmMakefile::InitializeFromParent(cmMakefile* parent) parent->GetProperty("LINK_DIRECTORIES")); // the initial project name - this->SetProjectName(parent->GetProjectName()); + this->ProjectName = parent->ProjectName; // Copy include regular expressions. this->ComplainFileRegularExpression = parent->ComplainFileRegularExpression; @@ -2044,15 +2044,11 @@ void cmMakefile::RemoveCacheDefinition(const std::string& name) this->GetState()->RemoveCacheEntry(name); } -void cmMakefile::SetProjectName(std::string const& p) +void cmMakefile::SetProjectName(const char* p) { - this->StateSnapshot.SetProjectName(p); + this->ProjectName = p; } -std::string cmMakefile::GetProjectName() const -{ - return this->StateSnapshot.GetProjectName(); -} void cmMakefile::AddGlobalLinkInformation(const std::string& name, cmTarget& target) diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 81bb510..055170a 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -274,12 +274,15 @@ public: /** * Specify the name of the project for this build. */ - void SetProjectName(std::string const& name); + void SetProjectName(const char*); /** * Get the name of the project for this build. */ - std::string GetProjectName() const; + const char* GetProjectName() const + { + return this->ProjectName.c_str(); + } /** Get the configurations to be generated. */ std::string GetConfigurations(std::vector& configs, @@ -810,6 +813,8 @@ protected: mutable std::set CMP0054ReportedIds; + std::string ProjectName; // project name + // libraries, classes, and executables mutable cmTargets Targets; #if defined(CMAKE_BUILD_WITH_CMAKE) diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx index 7123125..46d7e01 100644 --- a/Source/cmProjectCommand.cxx +++ b/Source/cmProjectCommand.cxx @@ -20,7 +20,7 @@ bool cmProjectCommand this->SetError("PROJECT called with incorrect number of arguments"); return false; } - this->Makefile->SetProjectName(args[0]); + this->Makefile->SetProjectName(args[0].c_str()); std::string bindir = args[0]; bindir += "_BINARY_DIR"; diff --git a/Source/cmState.cxx b/Source/cmState.cxx index ce12b97..53fdae0 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -38,8 +38,6 @@ struct cmState::SnapshotDataType std::vector::size_type IncludeDirectoryPosition; std::vector::size_type CompileDefinitionsPosition; std::vector::size_type CompileOptionsPosition; - - std::string ProjectName; }; struct cmState::PolicyStackEntry: public cmPolicies::PolicyMap @@ -1314,16 +1312,6 @@ cmState::Directory cmState::Snapshot::GetDirectory() const return Directory(this->Position->BuildSystemDirectory, *this); } -void cmState::Snapshot::SetProjectName(const std::string& name) -{ - this->Position->ProjectName = name; -} - -std::string cmState::Snapshot::GetProjectName() const -{ - return this->Position->ProjectName; -} - cmState::Directory::Directory( cmLinkedTree::iterator iter, const cmState::Snapshot& snapshot) diff --git a/Source/cmState.h b/Source/cmState.h index c3ff4e8..e503cd2 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -86,9 +86,6 @@ public: Directory GetDirectory() const; - void SetProjectName(std::string const& name); - std::string GetProjectName() const; - struct StrictWeakOrder { bool operator()(const cmState::Snapshot& lhs, ----------------------------------------------------------------------- Summary of changes: Source/cmCPluginAPI.cxx | 4 +--- Source/cmGlobalGenerator.cxx | 11 +++++------ Source/cmMakefile.cxx | 10 +++------- Source/cmMakefile.h | 9 +++++++-- Source/cmProjectCommand.cxx | 2 +- Source/cmState.cxx | 12 ------------ Source/cmState.h | 3 --- 7 files changed, 17 insertions(+), 34 deletions(-) hooks/post-receive -- CMake From steveire at gmail.com Mon Aug 24 16:43:47 2015 From: steveire at gmail.com (Stephen Kelly) Date: Mon, 24 Aug 2015 16:43:47 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2426-gbbc1c49 Message-ID: <20150824204347.422D0B13DB@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via bbc1c4930d4220341cb40b885a8385b553a76962 (commit) via b9a41481f81d86c22ad88379d72dd2eea62e96c2 (commit) via 59a0a2d11440695747a570f960f42c84f1933b46 (commit) via 660c297e03628a15c10fe9d3b325dabbdd6f3201 (commit) via 5cb05849d91a178621011729d6c409f91cb011c6 (commit) from 638e36e30d9430d2fe134d1a4c3903e37b589ff4 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bbc1c4930d4220341cb40b885a8385b553a76962 commit bbc1c4930d4220341cb40b885a8385b553a76962 Merge: 638e36e b9a4148 Author: Stephen Kelly AuthorDate: Mon Aug 24 16:43:46 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 24 16:43:46 2015 -0400 Merge topic 'cmState-ProjectName' into next b9a41481 cmGlobalGenerator: Implement FillProjectMap in terms of cmState. 59a0a2d1 cmState: Move ProjectName from cmMakefile. 660c297e cmMakefile: Use std::string in ProjectName API. 5cb05849 cmMakefile: Out-of-line GetProjectName. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b9a41481f81d86c22ad88379d72dd2eea62e96c2 commit b9a41481f81d86c22ad88379d72dd2eea62e96c2 Author: Stephen Kelly AuthorDate: Sun Aug 2 09:41:11 2015 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 24 22:41:44 2015 +0200 cmGlobalGenerator: Implement FillProjectMap in terms of cmState. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 503c455..17bafbe 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2102,18 +2102,19 @@ void cmGlobalGenerator::FillProjectMap() for(i = 0; i < this->LocalGenerators.size(); ++i) { // for each local generator add all projects - cmLocalGenerator *lg = this->LocalGenerators[i]; + cmState::Snapshot snp = this->LocalGenerators[i]->GetStateSnapshot(); std::string name; do { - if (name != lg->GetMakefile()->GetProjectName()) + std::string snpProjName = snp.GetProjectName(); + if (name != snpProjName) { - name = lg->GetMakefile()->GetProjectName(); + name = snpProjName; this->ProjectMap[name].push_back(this->LocalGenerators[i]); } - lg = lg->GetParent(); + snp = snp.GetBuildsystemDirectoryParent(); } - while (lg); + while (snp.IsValid()); } } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=59a0a2d11440695747a570f960f42c84f1933b46 commit 59a0a2d11440695747a570f960f42c84f1933b46 Author: Stephen Kelly AuthorDate: Sun Aug 2 09:41:06 2015 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 24 22:40:47 2015 +0200 cmState: Move ProjectName from cmMakefile. It is necessary for now to always return the last set project name for the directory, but that can be replaced with a snapshotted version in the future. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index abdd767..dbf41cc 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1525,7 +1525,7 @@ void cmMakefile::InitializeFromParent(cmMakefile* parent) parent->GetProperty("LINK_DIRECTORIES")); // the initial project name - this->ProjectName = parent->ProjectName; + this->SetProjectName(parent->GetProjectName()); // Copy include regular expressions. this->ComplainFileRegularExpression = parent->ComplainFileRegularExpression; @@ -2046,12 +2046,12 @@ void cmMakefile::RemoveCacheDefinition(const std::string& name) void cmMakefile::SetProjectName(std::string const& p) { - this->ProjectName = p; + this->StateSnapshot.SetProjectName(p); } std::string cmMakefile::GetProjectName() const { - return this->ProjectName.c_str(); + return this->StateSnapshot.GetProjectName(); } void cmMakefile::AddGlobalLinkInformation(const std::string& name, diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index dfd3e19..81bb510 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -810,8 +810,6 @@ protected: mutable std::set CMP0054ReportedIds; - std::string ProjectName; // project name - // libraries, classes, and executables mutable cmTargets Targets; #if defined(CMAKE_BUILD_WITH_CMAKE) diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 53fdae0..6c5370e 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -38,6 +38,8 @@ struct cmState::SnapshotDataType std::vector::size_type IncludeDirectoryPosition; std::vector::size_type CompileDefinitionsPosition; std::vector::size_type CompileOptionsPosition; + + std::string ProjectName; }; struct cmState::PolicyStackEntry: public cmPolicies::PolicyMap @@ -1312,6 +1314,16 @@ cmState::Directory cmState::Snapshot::GetDirectory() const return Directory(this->Position->BuildSystemDirectory, *this); } +void cmState::Snapshot::SetProjectName(const std::string& name) +{ + this->Position->ProjectName = name; +} + +std::string cmState::Snapshot::GetProjectName() const +{ + return this->Position->BuildSystemDirectory->DirectoryEnd->ProjectName; +} + cmState::Directory::Directory( cmLinkedTree::iterator iter, const cmState::Snapshot& snapshot) diff --git a/Source/cmState.h b/Source/cmState.h index e503cd2..c3ff4e8 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -86,6 +86,9 @@ public: Directory GetDirectory() const; + void SetProjectName(std::string const& name); + std::string GetProjectName() const; + struct StrictWeakOrder { bool operator()(const cmState::Snapshot& lhs, http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=660c297e03628a15c10fe9d3b325dabbdd6f3201 commit 660c297e03628a15c10fe9d3b325dabbdd6f3201 Author: Stephen Kelly AuthorDate: Sun Aug 2 10:57:31 2015 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 24 22:39:56 2015 +0200 cmMakefile: Use std::string in ProjectName API. diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx index 591a2cd..7da334e 100644 --- a/Source/cmCPluginAPI.cxx +++ b/Source/cmCPluginAPI.cxx @@ -115,7 +115,9 @@ void CCONV cmAddCacheDefinition(void *arg, const char* name, const char* CCONV cmGetProjectName(void *arg) { cmMakefile *mf = static_cast(arg); - return mf->GetProjectName(); + static std::string name; + name = mf->GetProjectName(); + return name.c_str(); } const char* CCONV cmGetHomeDirectory(void *arg) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 73911a5..abdd767 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2044,12 +2044,12 @@ void cmMakefile::RemoveCacheDefinition(const std::string& name) this->GetState()->RemoveCacheEntry(name); } -void cmMakefile::SetProjectName(const char* p) +void cmMakefile::SetProjectName(std::string const& p) { this->ProjectName = p; } -const char* cmMakefile::GetProjectName() const +std::string cmMakefile::GetProjectName() const { return this->ProjectName.c_str(); } diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 959f0e7..dfd3e19 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -274,12 +274,12 @@ public: /** * Specify the name of the project for this build. */ - void SetProjectName(const char*); + void SetProjectName(std::string const& name); /** * Get the name of the project for this build. */ - const char* GetProjectName() const; + std::string GetProjectName() const; /** Get the configurations to be generated. */ std::string GetConfigurations(std::vector& configs, diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx index 46d7e01..7123125 100644 --- a/Source/cmProjectCommand.cxx +++ b/Source/cmProjectCommand.cxx @@ -20,7 +20,7 @@ bool cmProjectCommand this->SetError("PROJECT called with incorrect number of arguments"); return false; } - this->Makefile->SetProjectName(args[0].c_str()); + this->Makefile->SetProjectName(args[0]); std::string bindir = args[0]; bindir += "_BINARY_DIR"; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5cb05849d91a178621011729d6c409f91cb011c6 commit 5cb05849d91a178621011729d6c409f91cb011c6 Author: Stephen Kelly AuthorDate: Sun Aug 2 10:56:33 2015 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 24 22:39:54 2015 +0200 cmMakefile: Out-of-line GetProjectName. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 2296d5a..73911a5 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2049,6 +2049,10 @@ void cmMakefile::SetProjectName(const char* p) this->ProjectName = p; } +const char* cmMakefile::GetProjectName() const +{ + return this->ProjectName.c_str(); +} void cmMakefile::AddGlobalLinkInformation(const std::string& name, cmTarget& target) diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 055170a..959f0e7 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -279,10 +279,7 @@ public: /** * Get the name of the project for this build. */ - const char* GetProjectName() const - { - return this->ProjectName.c_str(); - } + const char* GetProjectName() const; /** Get the configurations to be generated. */ std::string GetConfigurations(std::vector& configs, ----------------------------------------------------------------------- Summary of changes: Source/cmCPluginAPI.cxx | 4 +++- Source/cmGlobalGenerator.cxx | 11 ++++++----- Source/cmMakefile.cxx | 10 +++++++--- Source/cmMakefile.h | 9 ++------- Source/cmProjectCommand.cxx | 2 +- Source/cmState.cxx | 12 ++++++++++++ Source/cmState.h | 3 +++ 7 files changed, 34 insertions(+), 17 deletions(-) hooks/post-receive -- CMake From steveire at gmail.com Mon Aug 24 17:36:50 2015 From: steveire at gmail.com (Stephen Kelly) Date: Mon, 24 Aug 2015 17:36:50 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2428-ga3d0518 Message-ID: <20150824213654.0BFD7B1622@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via a3d0518c64d2a3848487ac0d2fc93af622bacc61 (commit) via dc02e143313548eaced4e4c6c0635f69e518aaca (commit) from bbc1c4930d4220341cb40b885a8385b553a76962 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a3d0518c64d2a3848487ac0d2fc93af622bacc61 commit a3d0518c64d2a3848487ac0d2fc93af622bacc61 Merge: bbc1c49 dc02e14 Author: Stephen Kelly AuthorDate: Mon Aug 24 17:36:49 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 24 17:36:49 2015 -0400 Merge topic 'cmState-ProjectName' into next dc02e143 Revert topic. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=dc02e143313548eaced4e4c6c0635f69e518aaca commit dc02e143313548eaced4e4c6c0635f69e518aaca Author: Stephen Kelly AuthorDate: Mon Aug 24 23:36:13 2015 +0200 Commit: Stephen Kelly CommitDate: Mon Aug 24 23:36:27 2015 +0200 Revert topic. diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx index 7da334e..591a2cd 100644 --- a/Source/cmCPluginAPI.cxx +++ b/Source/cmCPluginAPI.cxx @@ -115,9 +115,7 @@ void CCONV cmAddCacheDefinition(void *arg, const char* name, const char* CCONV cmGetProjectName(void *arg) { cmMakefile *mf = static_cast(arg); - static std::string name; - name = mf->GetProjectName(); - return name.c_str(); + return mf->GetProjectName(); } const char* CCONV cmGetHomeDirectory(void *arg) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 17bafbe..503c455 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2102,19 +2102,18 @@ void cmGlobalGenerator::FillProjectMap() for(i = 0; i < this->LocalGenerators.size(); ++i) { // for each local generator add all projects - cmState::Snapshot snp = this->LocalGenerators[i]->GetStateSnapshot(); + cmLocalGenerator *lg = this->LocalGenerators[i]; std::string name; do { - std::string snpProjName = snp.GetProjectName(); - if (name != snpProjName) + if (name != lg->GetMakefile()->GetProjectName()) { - name = snpProjName; + name = lg->GetMakefile()->GetProjectName(); this->ProjectMap[name].push_back(this->LocalGenerators[i]); } - snp = snp.GetBuildsystemDirectoryParent(); + lg = lg->GetParent(); } - while (snp.IsValid()); + while (lg); } } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index dbf41cc..2296d5a 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1525,7 +1525,7 @@ void cmMakefile::InitializeFromParent(cmMakefile* parent) parent->GetProperty("LINK_DIRECTORIES")); // the initial project name - this->SetProjectName(parent->GetProjectName()); + this->ProjectName = parent->ProjectName; // Copy include regular expressions. this->ComplainFileRegularExpression = parent->ComplainFileRegularExpression; @@ -2044,15 +2044,11 @@ void cmMakefile::RemoveCacheDefinition(const std::string& name) this->GetState()->RemoveCacheEntry(name); } -void cmMakefile::SetProjectName(std::string const& p) +void cmMakefile::SetProjectName(const char* p) { - this->StateSnapshot.SetProjectName(p); + this->ProjectName = p; } -std::string cmMakefile::GetProjectName() const -{ - return this->StateSnapshot.GetProjectName(); -} void cmMakefile::AddGlobalLinkInformation(const std::string& name, cmTarget& target) diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 81bb510..055170a 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -274,12 +274,15 @@ public: /** * Specify the name of the project for this build. */ - void SetProjectName(std::string const& name); + void SetProjectName(const char*); /** * Get the name of the project for this build. */ - std::string GetProjectName() const; + const char* GetProjectName() const + { + return this->ProjectName.c_str(); + } /** Get the configurations to be generated. */ std::string GetConfigurations(std::vector& configs, @@ -810,6 +813,8 @@ protected: mutable std::set CMP0054ReportedIds; + std::string ProjectName; // project name + // libraries, classes, and executables mutable cmTargets Targets; #if defined(CMAKE_BUILD_WITH_CMAKE) diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx index 7123125..46d7e01 100644 --- a/Source/cmProjectCommand.cxx +++ b/Source/cmProjectCommand.cxx @@ -20,7 +20,7 @@ bool cmProjectCommand this->SetError("PROJECT called with incorrect number of arguments"); return false; } - this->Makefile->SetProjectName(args[0]); + this->Makefile->SetProjectName(args[0].c_str()); std::string bindir = args[0]; bindir += "_BINARY_DIR"; diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 6c5370e..53fdae0 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -38,8 +38,6 @@ struct cmState::SnapshotDataType std::vector::size_type IncludeDirectoryPosition; std::vector::size_type CompileDefinitionsPosition; std::vector::size_type CompileOptionsPosition; - - std::string ProjectName; }; struct cmState::PolicyStackEntry: public cmPolicies::PolicyMap @@ -1314,16 +1312,6 @@ cmState::Directory cmState::Snapshot::GetDirectory() const return Directory(this->Position->BuildSystemDirectory, *this); } -void cmState::Snapshot::SetProjectName(const std::string& name) -{ - this->Position->ProjectName = name; -} - -std::string cmState::Snapshot::GetProjectName() const -{ - return this->Position->BuildSystemDirectory->DirectoryEnd->ProjectName; -} - cmState::Directory::Directory( cmLinkedTree::iterator iter, const cmState::Snapshot& snapshot) diff --git a/Source/cmState.h b/Source/cmState.h index c3ff4e8..e503cd2 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -86,9 +86,6 @@ public: Directory GetDirectory() const; - void SetProjectName(std::string const& name); - std::string GetProjectName() const; - struct StrictWeakOrder { bool operator()(const cmState::Snapshot& lhs, ----------------------------------------------------------------------- Summary of changes: Source/cmCPluginAPI.cxx | 4 +--- Source/cmGlobalGenerator.cxx | 11 +++++------ Source/cmMakefile.cxx | 10 +++------- Source/cmMakefile.h | 9 +++++++-- Source/cmProjectCommand.cxx | 2 +- Source/cmState.cxx | 12 ------------ Source/cmState.h | 3 --- 7 files changed, 17 insertions(+), 34 deletions(-) hooks/post-receive -- CMake From johnstonj.public at codenest.com Mon Aug 24 23:10:58 2015 From: johnstonj.public at codenest.com (James Johnston) Date: Mon, 24 Aug 2015 23:10:58 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2430-g50e7fa6 Message-ID: <20150825031059.52E0EB11CB@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 50e7fa615cfcb63b337640d353fc153a74ac1fde (commit) via 1869eacb3d2e897695007f210da219a0ee73cba8 (commit) from a3d0518c64d2a3848487ac0d2fc93af622bacc61 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=50e7fa615cfcb63b337640d353fc153a74ac1fde commit 50e7fa615cfcb63b337640d353fc153a74ac1fde Merge: a3d0518 1869eac Author: James Johnston AuthorDate: Mon Aug 24 23:10:56 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 24 23:10:56 2015 -0400 Merge topic 'fix-load-command-doc-classification' into next 1869eacb Help: Fix classification of load_command in command TOC. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1869eacb3d2e897695007f210da219a0ee73cba8 commit 1869eacb3d2e897695007f210da219a0ee73cba8 Author: James Johnston AuthorDate: Mon Aug 24 23:09:31 2015 -0400 Commit: James Johnston CommitDate: Mon Aug 24 23:09:31 2015 -0400 Help: Fix classification of load_command in command TOC. In CMake 3.0, the load_command command was deprecated. However, the position of load_command in the help TOC was not fixed at that time: it was still listed as a "Normal Command". diff --git a/Help/manual/cmake-commands.7.rst b/Help/manual/cmake-commands.7.rst index c916f77..5b92b51 100644 --- a/Help/manual/cmake-commands.7.rst +++ b/Help/manual/cmake-commands.7.rst @@ -71,7 +71,6 @@ These commands may be used freely in CMake projects. /command/link_libraries /command/list /command/load_cache - /command/load_command /command/macro /command/mark_as_advanced /command/math @@ -119,6 +118,7 @@ versions of CMake. Do not use them in new code. /command/install_files /command/install_programs /command/install_targets + /command/load_command /command/make_directory /command/output_required_files /command/remove ----------------------------------------------------------------------- Summary of changes: Help/manual/cmake-commands.7.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Tue Aug 25 00:01:09 2015 From: kwrobot at kitware.com (Kitware Robot) Date: Tue, 25 Aug 2015 00:01:09 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-927-ga8f8848 Message-ID: <20150825040109.4EDEFB16F3@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via a8f884824167c09b5f988b6add0a0b3370b6be8a (commit) from ddb7f280ce4e7a76dc66c53e933df9e11ee35e20 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a8f884824167c09b5f988b6add0a0b3370b6be8a commit a8f884824167c09b5f988b6add0a0b3370b6be8a Author: Kitware Robot AuthorDate: Tue Aug 25 00:01:07 2015 -0400 Commit: Kitware Robot CommitDate: Tue Aug 25 00:01:07 2015 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index cfbeab3..4e0b28c 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150824) +set(CMake_VERSION_PATCH 20150825) #set(CMake_VERSION_RC 1) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Tue Aug 25 09:46:31 2015 From: brad.king at kitware.com (Brad King) Date: Tue, 25 Aug 2015 09:46:31 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2433-g7b03a6b Message-ID: <20150825134632.011C0B04BB@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 7b03a6bd559fdfabf7bab274cb3f99f9bc212edc (commit) via 7a64f35d714da66a43a22e8501a2cec383e04025 (commit) via 1c9e979cb8839e59d5e33bb9dd0d3316ac7403ca (commit) from 50e7fa615cfcb63b337640d353fc153a74ac1fde (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7b03a6bd559fdfabf7bab274cb3f99f9bc212edc commit 7b03a6bd559fdfabf7bab274cb3f99f9bc212edc Merge: 50e7fa6 7a64f35 Author: Brad King AuthorDate: Tue Aug 25 09:46:31 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 25 09:46:31 2015 -0400 Merge topic 'vs-store-phone-cert-thumbs' into next 7a64f35d fixup! VS: Windows Store/Phone package cert thumbprint 1c9e979c fixup! VS: Windows Store/Phone package cert thumbprint http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7a64f35d714da66a43a22e8501a2cec383e04025 commit 7a64f35d714da66a43a22e8501a2cec383e04025 Author: Brad King AuthorDate: Tue Aug 25 09:46:19 2015 -0400 Commit: Brad King CommitDate: Tue Aug 25 09:46:19 2015 -0400 fixup! VS: Windows Store/Phone package cert thumbprint diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 3780ec0..583e1d0 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1041,7 +1041,7 @@ std::string cmSystemTools::ComputeCertificateThumbprint( certData = new BYTE[fileSize]; if (certData != NULL) { - DWORD dwRead = NULL; + DWORD dwRead = 0; if (ReadFile(certFile, certData, fileSize, &dwRead, NULL)) { cryptBlob.cbData = fileSize; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1c9e979cb8839e59d5e33bb9dd0d3316ac7403ca commit 1c9e979cb8839e59d5e33bb9dd0d3316ac7403ca Author: Brad King AuthorDate: Tue Aug 25 09:21:04 2015 -0400 Commit: Brad King CommitDate: Tue Aug 25 09:21:04 2015 -0400 fixup! VS: Windows Store/Phone package cert thumbprint diff --git a/CTestCustom.cmake.in b/CTestCustom.cmake.in index f29ac70..d3cff51 100644 --- a/CTestCustom.cmake.in +++ b/CTestCustom.cmake.in @@ -32,6 +32,7 @@ set(CTEST_CUSTOM_WARNING_EXCEPTION "remark: .*LOOP WAS VECTORIZED" "warning .980: wrong number of actual arguments to intrinsic function .std::basic_" "LINK : warning LNK4089: all references to.*ADVAPI32.dll.*discarded by /OPT:REF" + "LINK : warning LNK4089: all references to.*CRYPT32.dll.*discarded by /OPT:REF" "LINK : warning LNK4089: all references to.*PSAPI.DLL.*discarded by /OPT:REF" "LINK : warning LNK4089: all references to.*RPCRT4.dll.*discarded by /OPT:REF" "LINK : warning LNK4089: all references to.*SHELL32.dll.*discarded by /OPT:REF" ----------------------------------------------------------------------- Summary of changes: CTestCustom.cmake.in | 1 + Source/cmSystemTools.cxx | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Tue Aug 25 09:47:27 2015 From: brad.king at kitware.com (Brad King) Date: Tue, 25 Aug 2015 09:47:27 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2435-gf23c21d Message-ID: <20150825134727.D7E9EB14FD@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via f23c21d028ecebc11ac724ea663d783eb477f4f8 (commit) via 290b0f94b597f5a833f59cc8f70f1627bf8d1aa9 (commit) from 7b03a6bd559fdfabf7bab274cb3f99f9bc212edc (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f23c21d028ecebc11ac724ea663d783eb477f4f8 commit f23c21d028ecebc11ac724ea663d783eb477f4f8 Merge: 7b03a6b 290b0f9 Author: Brad King AuthorDate: Tue Aug 25 09:47:27 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 25 09:47:27 2015 -0400 Merge topic 'FindJNI-suse-and-ibm' into next 290b0f94 FindJNI: Add support for SuSE platform and IBM Java SDK http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=290b0f94b597f5a833f59cc8f70f1627bf8d1aa9 commit 290b0f94b597f5a833f59cc8f70f1627bf8d1aa9 Author: Marc Chevrier AuthorDate: Tue Aug 25 09:31:30 2015 +0200 Commit: Brad King CommitDate: Tue Aug 25 09:47:05 2015 -0400 FindJNI: Add support for SuSE platform and IBM Java SDK diff --git a/Modules/FindJNI.cmake b/Modules/FindJNI.cmake index d31fea3..6958a2a 100644 --- a/Modules/FindJNI.cmake +++ b/Modules/FindJNI.cmake @@ -156,6 +156,9 @@ JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_LIBRARY_DIRECTORIES /usr/local/jre-1.7.0/lib/{libarch} /usr/local/jdk-1.6.0/jre/lib/{libarch} /usr/local/jre-1.6.0/lib/{libarch} + # SuSE specific paths for default JVM + /usr/lib64/jvm/java/jre/lib/{libarch} + /usr/lib64/jvm/jre/lib/{libarch} ) set(JAVA_JVM_LIBRARY_DIRECTORIES) @@ -164,6 +167,9 @@ foreach(dir ${JAVA_AWT_LIBRARY_DIRECTORIES}) "${dir}" "${dir}/client" "${dir}/server" + # IBM SDK, Java Technology Edition, specific paths + "${dir}/j9vm" + "${dir}/default" ) endforeach() @@ -193,6 +199,8 @@ list(APPEND JAVA_AWT_INCLUDE_DIRECTORIES # OpenBSD specific path for default JVM /usr/local/jdk-1.7.0/include /usr/local/jdk-1.6.0/include + # SuSE specific paths for default JVM + /usr/lib64/jvm/java/include ) foreach(JAVA_PROG "${JAVA_RUNTIME}" "${JAVA_COMPILE}" "${JAVA_ARCHIVE}") ----------------------------------------------------------------------- Summary of changes: Modules/FindJNI.cmake | 8 ++++++++ 1 file changed, 8 insertions(+) hooks/post-receive -- CMake From steveire at gmail.com Tue Aug 25 13:58:03 2015 From: steveire at gmail.com (Stephen Kelly) Date: Tue, 25 Aug 2015 13:58:03 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2440-g7a826b2 Message-ID: <20150825175803.34666B1A5D@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 7a826b20db6797d1d49ca9851ee744c94dd9374e (commit) via 637c56b4e0ce0205f3f28a670881aad07320ff17 (commit) via b3f2299e0600f3488aaeb78ebf66d1108201ea17 (commit) via 6ce940ac9701c93be01ed169c6bd23b22e04782f (commit) via e8c0341d86e3f2b9658dfc594641f9ba1b29165b (commit) from f23c21d028ecebc11ac724ea663d783eb477f4f8 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7a826b20db6797d1d49ca9851ee744c94dd9374e commit 7a826b20db6797d1d49ca9851ee744c94dd9374e Merge: f23c21d 637c56b Author: Stephen Kelly AuthorDate: Tue Aug 25 13:58:02 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 25 13:58:02 2015 -0400 Merge topic 'cmState-ProjectName' into next 637c56b4 cmGlobalGenerator: Implement FillProjectMap in terms of cmState. b3f2299e cmState: Move ProjectName from cmMakefile. 6ce940ac cmMakefile: Use std::string in ProjectName API. e8c0341d cmMakefile: Out-of-line GetProjectName. diff --cc Source/cmState.cxx index a401265,6cd58b6..b30c10b --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@@ -75,9 -75,9 +75,11 @@@ struct cmState::BuildsystemDirectorySta std::vector CompileOptions; std::vector CompileOptionsBacktraces; + std::string ProjectName; + cmPropertyMap Properties; + + std::vector Children; }; cmState::cmState(cmake* cm) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=637c56b4e0ce0205f3f28a670881aad07320ff17 commit 637c56b4e0ce0205f3f28a670881aad07320ff17 Author: Stephen Kelly AuthorDate: Sun Aug 2 09:41:11 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 19:57:44 2015 +0200 cmGlobalGenerator: Implement FillProjectMap in terms of cmState. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 503c455..17bafbe 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2102,18 +2102,19 @@ void cmGlobalGenerator::FillProjectMap() for(i = 0; i < this->LocalGenerators.size(); ++i) { // for each local generator add all projects - cmLocalGenerator *lg = this->LocalGenerators[i]; + cmState::Snapshot snp = this->LocalGenerators[i]->GetStateSnapshot(); std::string name; do { - if (name != lg->GetMakefile()->GetProjectName()) + std::string snpProjName = snp.GetProjectName(); + if (name != snpProjName) { - name = lg->GetMakefile()->GetProjectName(); + name = snpProjName; this->ProjectMap[name].push_back(this->LocalGenerators[i]); } - lg = lg->GetParent(); + snp = snp.GetBuildsystemDirectoryParent(); } - while (lg); + while (snp.IsValid()); } } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b3f2299e0600f3488aaeb78ebf66d1108201ea17 commit b3f2299e0600f3488aaeb78ebf66d1108201ea17 Author: Stephen Kelly AuthorDate: Sun Aug 2 09:41:06 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 19:57:42 2015 +0200 cmState: Move ProjectName from cmMakefile. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index abdd767..dbf41cc 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1525,7 +1525,7 @@ void cmMakefile::InitializeFromParent(cmMakefile* parent) parent->GetProperty("LINK_DIRECTORIES")); // the initial project name - this->ProjectName = parent->ProjectName; + this->SetProjectName(parent->GetProjectName()); // Copy include regular expressions. this->ComplainFileRegularExpression = parent->ComplainFileRegularExpression; @@ -2046,12 +2046,12 @@ void cmMakefile::RemoveCacheDefinition(const std::string& name) void cmMakefile::SetProjectName(std::string const& p) { - this->ProjectName = p; + this->StateSnapshot.SetProjectName(p); } std::string cmMakefile::GetProjectName() const { - return this->ProjectName.c_str(); + return this->StateSnapshot.GetProjectName(); } void cmMakefile::AddGlobalLinkInformation(const std::string& name, diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index dfd3e19..81bb510 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -810,8 +810,6 @@ protected: mutable std::set CMP0054ReportedIds; - std::string ProjectName; // project name - // libraries, classes, and executables mutable cmTargets Targets; #if defined(CMAKE_BUILD_WITH_CMAKE) diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 53fdae0..6cd58b6 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -75,6 +75,8 @@ struct cmState::BuildsystemDirectoryStateType std::vector CompileOptions; std::vector CompileOptionsBacktraces; + std::string ProjectName; + cmPropertyMap Properties; }; @@ -1312,6 +1314,16 @@ cmState::Directory cmState::Snapshot::GetDirectory() const return Directory(this->Position->BuildSystemDirectory, *this); } +void cmState::Snapshot::SetProjectName(const std::string& name) +{ + this->Position->BuildSystemDirectory->ProjectName = name; +} + +std::string cmState::Snapshot::GetProjectName() const +{ + return this->Position->BuildSystemDirectory->ProjectName; +} + cmState::Directory::Directory( cmLinkedTree::iterator iter, const cmState::Snapshot& snapshot) diff --git a/Source/cmState.h b/Source/cmState.h index e503cd2..c3ff4e8 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -86,6 +86,9 @@ public: Directory GetDirectory() const; + void SetProjectName(std::string const& name); + std::string GetProjectName() const; + struct StrictWeakOrder { bool operator()(const cmState::Snapshot& lhs, http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6ce940ac9701c93be01ed169c6bd23b22e04782f commit 6ce940ac9701c93be01ed169c6bd23b22e04782f Author: Stephen Kelly AuthorDate: Sun Aug 2 10:57:31 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 19:55:34 2015 +0200 cmMakefile: Use std::string in ProjectName API. diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx index 591a2cd..7da334e 100644 --- a/Source/cmCPluginAPI.cxx +++ b/Source/cmCPluginAPI.cxx @@ -115,7 +115,9 @@ void CCONV cmAddCacheDefinition(void *arg, const char* name, const char* CCONV cmGetProjectName(void *arg) { cmMakefile *mf = static_cast(arg); - return mf->GetProjectName(); + static std::string name; + name = mf->GetProjectName(); + return name.c_str(); } const char* CCONV cmGetHomeDirectory(void *arg) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 73911a5..abdd767 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2044,12 +2044,12 @@ void cmMakefile::RemoveCacheDefinition(const std::string& name) this->GetState()->RemoveCacheEntry(name); } -void cmMakefile::SetProjectName(const char* p) +void cmMakefile::SetProjectName(std::string const& p) { this->ProjectName = p; } -const char* cmMakefile::GetProjectName() const +std::string cmMakefile::GetProjectName() const { return this->ProjectName.c_str(); } diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 959f0e7..dfd3e19 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -274,12 +274,12 @@ public: /** * Specify the name of the project for this build. */ - void SetProjectName(const char*); + void SetProjectName(std::string const& name); /** * Get the name of the project for this build. */ - const char* GetProjectName() const; + std::string GetProjectName() const; /** Get the configurations to be generated. */ std::string GetConfigurations(std::vector& configs, diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx index 46d7e01..7123125 100644 --- a/Source/cmProjectCommand.cxx +++ b/Source/cmProjectCommand.cxx @@ -20,7 +20,7 @@ bool cmProjectCommand this->SetError("PROJECT called with incorrect number of arguments"); return false; } - this->Makefile->SetProjectName(args[0].c_str()); + this->Makefile->SetProjectName(args[0]); std::string bindir = args[0]; bindir += "_BINARY_DIR"; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e8c0341d86e3f2b9658dfc594641f9ba1b29165b commit e8c0341d86e3f2b9658dfc594641f9ba1b29165b Author: Stephen Kelly AuthorDate: Sun Aug 2 10:56:33 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 19:55:32 2015 +0200 cmMakefile: Out-of-line GetProjectName. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 2296d5a..73911a5 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2049,6 +2049,10 @@ void cmMakefile::SetProjectName(const char* p) this->ProjectName = p; } +const char* cmMakefile::GetProjectName() const +{ + return this->ProjectName.c_str(); +} void cmMakefile::AddGlobalLinkInformation(const std::string& name, cmTarget& target) diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 055170a..959f0e7 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -279,10 +279,7 @@ public: /** * Get the name of the project for this build. */ - const char* GetProjectName() const - { - return this->ProjectName.c_str(); - } + const char* GetProjectName() const; /** Get the configurations to be generated. */ std::string GetConfigurations(std::vector& configs, ----------------------------------------------------------------------- Summary of changes: Source/cmCPluginAPI.cxx | 4 +++- Source/cmGlobalGenerator.cxx | 11 ++++++----- Source/cmMakefile.cxx | 10 +++++++--- Source/cmMakefile.h | 9 ++------- Source/cmProjectCommand.cxx | 2 +- Source/cmState.cxx | 12 ++++++++++++ Source/cmState.h | 3 +++ 7 files changed, 34 insertions(+), 17 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Tue Aug 25 15:13:24 2015 From: brad.king at kitware.com (Brad King) Date: Tue, 25 Aug 2015 15:13:24 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-930-g9aeee9c Message-ID: <20150825191324.81890B1325@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 9aeee9c60887cf2a5528116c5e1d215f35b2f09f (commit) via f4150bd88d80f4a236ea5b0d648d8cc3122092fc (commit) via 0178754725c61dc6778f8591db1433a6c07e9f6f (commit) from a8f884824167c09b5f988b6add0a0b3370b6be8a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9aeee9c60887cf2a5528116c5e1d215f35b2f09f commit 9aeee9c60887cf2a5528116c5e1d215f35b2f09f Merge: a8f8848 f4150bd Author: Brad King AuthorDate: Tue Aug 25 15:13:23 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 25 15:13:23 2015 -0400 Merge topic 'cmState-prop_dir' f4150bd8 cmState: Move directory Properties from cmMakefile. 01787547 cmMakefile: Inline GetDefinitions into GetProperty. ----------------------------------------------------------------------- Summary of changes: Source/cmMakefile.cxx | 143 +++---------------------------------------- Source/cmMakefile.h | 3 - Source/cmState.cxx | 163 +++++++++++++++++++++++++++++++++++++++++++++++++ Source/cmState.h | 9 +++ 4 files changed, 180 insertions(+), 138 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Tue Aug 25 15:13:26 2015 From: brad.king at kitware.com (Brad King) Date: Tue, 25 Aug 2015 15:13:26 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-932-gd030a46 Message-ID: <20150825191326.7B04DB132D@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via d030a46913479442ca12c6d193be546b9f471ca0 (commit) via c4d78b8bc05d44b8a46b5d2db6b52b42a101ef2d (commit) from 9aeee9c60887cf2a5528116c5e1d215f35b2f09f (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d030a46913479442ca12c6d193be546b9f471ca0 commit d030a46913479442ca12c6d193be546b9f471ca0 Merge: 9aeee9c c4d78b8 Author: Brad King AuthorDate: Tue Aug 25 15:13:25 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 25 15:13:25 2015 -0400 Merge topic 'FindJNI-linux-x32' c4d78b8b FindJNI: Add support for x32 architecture on Linux (#15710) ----------------------------------------------------------------------- Summary of changes: Modules/FindJNI.cmake | 4 ++++ 1 file changed, 4 insertions(+) hooks/post-receive -- CMake From brad.king at kitware.com Tue Aug 25 15:13:28 2015 From: brad.king at kitware.com (Brad King) Date: Tue, 25 Aug 2015 15:13:28 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-934-g84aa251 Message-ID: <20150825191328.82D9CB133D@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 84aa2519b00177450b97d328065332ea192f76b8 (commit) via 1869eacb3d2e897695007f210da219a0ee73cba8 (commit) from d030a46913479442ca12c6d193be546b9f471ca0 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=84aa2519b00177450b97d328065332ea192f76b8 commit 84aa2519b00177450b97d328065332ea192f76b8 Merge: d030a46 1869eac Author: Brad King AuthorDate: Tue Aug 25 15:13:27 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 25 15:13:27 2015 -0400 Merge topic 'fix-load-command-doc-classification' 1869eacb Help: Fix classification of load_command in command TOC. ----------------------------------------------------------------------- Summary of changes: Help/manual/cmake-commands.7.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Tue Aug 25 15:13:30 2015 From: brad.king at kitware.com (Brad King) Date: Tue, 25 Aug 2015 15:13:30 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-936-g90eb6de Message-ID: <20150825191330.6D46DB134A@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 90eb6de68ff809b39515a1ac2cff823e86c205e2 (commit) via 64e527dbe3c55a01320b97cff38626171f96f686 (commit) from 84aa2519b00177450b97d328065332ea192f76b8 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=90eb6de68ff809b39515a1ac2cff823e86c205e2 commit 90eb6de68ff809b39515a1ac2cff823e86c205e2 Merge: 84aa251 64e527d Author: Brad King AuthorDate: Tue Aug 25 15:13:29 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 25 15:13:29 2015 -0400 Merge topic 'fphsa-typo' 64e527db FPHSA: fix typo in documentation ----------------------------------------------------------------------- Summary of changes: Modules/FindPackageHandleStandardArgs.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Tue Aug 25 15:13:32 2015 From: brad.king at kitware.com (Brad King) Date: Tue, 25 Aug 2015 15:13:32 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-938-g96dafff Message-ID: <20150825191332.8E7F4B13BF@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 96dafff97fb4674db3c47b89902722edef45fc65 (commit) via e7f937155f6f8b117d6292b3ffe6cf63c8eda9c0 (commit) from 90eb6de68ff809b39515a1ac2cff823e86c205e2 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=96dafff97fb4674db3c47b89902722edef45fc65 commit 96dafff97fb4674db3c47b89902722edef45fc65 Merge: 90eb6de e7f9371 Author: Brad King AuthorDate: Tue Aug 25 15:13:31 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 25 15:13:31 2015 -0400 Merge topic 'libarchive-modern-apis' e7f93715 Use modern libarchive APIs ----------------------------------------------------------------------- Summary of changes: Source/cmArchiveWrite.cxx | 28 ++++++++++++++-------------- Source/cmSystemTools.cxx | 4 ++-- 2 files changed, 16 insertions(+), 16 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Tue Aug 25 15:13:34 2015 From: brad.king at kitware.com (Brad King) Date: Tue, 25 Aug 2015 15:13:34 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-944-gcdb9984 Message-ID: <20150825191334.B7972B132E@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via cdb9984bff78b8f76c3b8c3f622928e4f29920a1 (commit) via e876963fc9e03018a189f4433050d459a475afbf (commit) via 44ffb9cdb4329c5ed9b724659f234d26da336b5a (commit) via 8f89f8b1e9693abbc50d917c04846000bf14e189 (commit) via 524610f967e5289810a0d67a2942493d8f61d1dd (commit) via 0e14c7ee6375fcaa975194557523f5a1a8686a8a (commit) from 96dafff97fb4674db3c47b89902722edef45fc65 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cdb9984bff78b8f76c3b8c3f622928e4f29920a1 commit cdb9984bff78b8f76c3b8c3f622928e4f29920a1 Merge: 96dafff e876963 Author: Brad King AuthorDate: Tue Aug 25 15:13:33 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 25 15:13:33 2015 -0400 Merge topic 'consistent-empty' e876963f Replace '0 == instances.size()' with instances.empty(). 44ffb9cd Replace foo.size() pattern with !foo.empty(). 8f89f8b1 Replace 'foo.size() != 0' pattern with !foo.empty(). 524610f9 Replace 'foo.size() == 0' pattern with foo.empty(). 0e14c7ee Replace 'foo.size() > 0' pattern with !foo.empty(). ----------------------------------------------------------------------- Summary of changes: Source/CPack/IFW/cmCPackIFWGenerator.cxx | 2 +- Source/CPack/WiX/cmCPackWIXGenerator.cxx | 4 ++-- Source/CPack/WiX/cmWIXAccessControlList.cxx | 2 +- Source/CPack/WiX/cmWIXPatch.cxx | 2 +- Source/CPack/WiX/cmWIXSourceWriter.cxx | 2 +- Source/CPack/cmCPackNSISGenerator.cxx | 6 +++--- Source/cmCallVisualStudioMacro.cxx | 2 +- Source/cmGlobalMSYSMakefileGenerator.cxx | 6 +++--- Source/cmGlobalVisualStudio6Generator.cxx | 2 +- Source/cmGlobalVisualStudio71Generator.cxx | 4 ++-- Source/cmGlobalVisualStudio7Generator.cxx | 4 ++-- Source/cmGlobalVisualStudioGenerator.cxx | 4 ++-- Source/cmGlobalXCodeGenerator.cxx | 6 +++--- Source/cmLocalVisualStudio10Generator.cxx | 2 +- Source/cmLocalVisualStudio6Generator.cxx | 14 +++++++------- Source/cmLocalVisualStudio7Generator.cxx | 4 ++-- Source/cmVisualStudio10TargetGenerator.cxx | 8 ++++---- Source/cmVisualStudioGeneratorOptions.cxx | 6 +++--- Source/cmXCode21Object.cxx | 2 +- 19 files changed, 41 insertions(+), 41 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Tue Aug 25 15:13:51 2015 From: brad.king at kitware.com (Brad King) Date: Tue, 25 Aug 2015 15:13:51 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2448-gd70e7e1 Message-ID: <20150825191351.81890B132E@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via d70e7e1491ec53571d1948c89cf658393ebee406 (commit) via cdb9984bff78b8f76c3b8c3f622928e4f29920a1 (commit) via 96dafff97fb4674db3c47b89902722edef45fc65 (commit) via 90eb6de68ff809b39515a1ac2cff823e86c205e2 (commit) via 84aa2519b00177450b97d328065332ea192f76b8 (commit) via d030a46913479442ca12c6d193be546b9f471ca0 (commit) via 9aeee9c60887cf2a5528116c5e1d215f35b2f09f (commit) via a8f884824167c09b5f988b6add0a0b3370b6be8a (commit) from 7a826b20db6797d1d49ca9851ee744c94dd9374e (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d70e7e1491ec53571d1948c89cf658393ebee406 commit d70e7e1491ec53571d1948c89cf658393ebee406 Merge: 7a826b2 cdb9984 Author: Brad King AuthorDate: Tue Aug 25 15:13:42 2015 -0400 Commit: Brad King CommitDate: Tue Aug 25 15:13:42 2015 -0400 Merge branch 'master' into next ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From gjasny at googlemail.com Tue Aug 25 15:48:43 2015 From: gjasny at googlemail.com (Gregor Jasny) Date: Tue, 25 Aug 2015 15:48:43 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2450-g849ccc5 Message-ID: <20150825194843.720ADB18D7@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 849ccc59e315e64b2c2c98d79ba2108810c461ca (commit) via 67f60958b61941264b0e2a63ad527dd346a6b1e3 (commit) from d70e7e1491ec53571d1948c89cf658393ebee406 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=849ccc59e315e64b2c2c98d79ba2108810c461ca commit 849ccc59e315e64b2c2c98d79ba2108810c461ca Merge: d70e7e1 67f6095 Author: Gregor Jasny AuthorDate: Tue Aug 25 15:48:42 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 25 15:48:42 2015 -0400 Merge topic 'apple-tbd-stubs' into next 67f60958 Darwin: Add support for tbd library stub files http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=67f60958b61941264b0e2a63ad527dd346a6b1e3 commit 67f60958b61941264b0e2a63ad527dd346a6b1e3 Author: Gregor Jasny AuthorDate: Sat Aug 15 21:01:31 2015 +0200 Commit: Gregor Jasny CommitDate: Mon Aug 24 22:29:33 2015 +0200 Darwin: Add support for tbd library stub files Starting with Xcode 7 the OSX and iOS SDKs contain only stub files for dynamic system libraries. These stub files contain some meta data and a list of exported sysbols in plain text. They are handled by the toolchain like regular dylibs. diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake index 4e4810a..bb085ac 100644 --- a/Modules/Platform/Darwin.cmake +++ b/Modules/Platform/Darwin.cmake @@ -53,7 +53,7 @@ set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-dynamiclib -Wl,-headerpad_max_install_ set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle -Wl,-headerpad_max_install_names") set(CMAKE_SHARED_MODULE_LOADER_C_FLAG "-Wl,-bundle_loader,") set(CMAKE_SHARED_MODULE_LOADER_CXX_FLAG "-Wl,-bundle_loader,") -set(CMAKE_FIND_LIBRARY_SUFFIXES ".dylib" ".so" ".a") +set(CMAKE_FIND_LIBRARY_SUFFIXES ".tbd" ".dylib" ".so" ".a") # hack: if a new cmake (which uses CMAKE_INSTALL_NAME_TOOL) runs on an old build tree # (where install_name_tool was hardcoded) and where CMAKE_INSTALL_NAME_TOOL isn't in the cache diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake index ef81739..1151abf 100644 --- a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake @@ -39,3 +39,9 @@ if(NOT XCODE_VERSION VERSION_LESS 5) unset(RunCMake_TEST_NO_CLEAN) unset(RunCMake_TEST_OPTIONS) endif() + +if(NOT XCODE_VERSION VERSION_LESS 7) + set(RunCMake_TEST_OPTIONS "-DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/osx.cmake") + run_cmake(XcodeTbdStub) + unset(RunCMake_TEST_OPTIONS) +endif() diff --git a/Tests/RunCMake/XcodeProject/XcodeTbdStub-stdout.txt b/Tests/RunCMake/XcodeProject/XcodeTbdStub-stdout.txt new file mode 100644 index 0000000..9d9e143 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/XcodeTbdStub-stdout.txt @@ -0,0 +1 @@ +.*/libz\.tbd.* diff --git a/Tests/RunCMake/XcodeProject/XcodeTbdStub.cmake b/Tests/RunCMake/XcodeProject/XcodeTbdStub.cmake new file mode 100644 index 0000000..e83d7f3 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/XcodeTbdStub.cmake @@ -0,0 +1,2 @@ +cmake_minimum_required(VERSION 3.3) +find_package(ZLIB REQUIRED) diff --git a/Tests/RunCMake/XcodeProject/osx.cmake b/Tests/RunCMake/XcodeProject/osx.cmake new file mode 100644 index 0000000..e021fcd --- /dev/null +++ b/Tests/RunCMake/XcodeProject/osx.cmake @@ -0,0 +1,18 @@ +set(CMAKE_SYSTEM_NAME Darwin) +set(CMAKE_SYSTEM_VERSION 1) +set(UNIX True) +set(APPLE True) + +find_program(XCRUN_EXECUTABLE xcrun) +if(NOT XCRUN_EXECUTABLE) + message(FATAL_ERROR "xcrun not found") +endif() + +execute_process( + COMMAND ${XCRUN_EXECUTABLE} --sdk macosx --show-sdk-path + OUTPUT_VARIABLE OSX_SDK_PATH + OUTPUT_STRIP_TRAILING_WHITESPACE) + +set(CMAKE_OSX_SYSROOT ${OSX_SDK_PATH} CACHE PATH "Sysroot used for OSX support") + +set(CMAKE_FIND_ROOT_PATH ${OSX_SDK_PATH} CACHE PATH "Find search path root") ----------------------------------------------------------------------- Summary of changes: Modules/Platform/Darwin.cmake | 2 +- Tests/RunCMake/XcodeProject/RunCMakeTest.cmake | 6 ++++++ Tests/RunCMake/XcodeProject/XcodeTbdStub-stdout.txt | 1 + Tests/RunCMake/XcodeProject/XcodeTbdStub.cmake | 2 ++ Tests/RunCMake/XcodeProject/osx.cmake | 18 ++++++++++++++++++ 5 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 Tests/RunCMake/XcodeProject/XcodeTbdStub-stdout.txt create mode 100644 Tests/RunCMake/XcodeProject/XcodeTbdStub.cmake create mode 100644 Tests/RunCMake/XcodeProject/osx.cmake hooks/post-receive -- CMake From steveire at gmail.com Tue Aug 25 16:10:46 2015 From: steveire at gmail.com (Stephen Kelly) Date: Tue, 25 Aug 2015 16:10:46 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2465-g8f95633 Message-ID: <20150825201046.86080B0819@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 8f95633f6049542a3b59872dd9ef03690131427f (commit) via 7996f986c4c5099ed537e49cf3ae85d6fb3366a5 (commit) via 033677678a2d019a319dfa275f109ad1fac5e644 (commit) via 9f3742039a438838739486a150a47699ca336013 (commit) via f81ff045d42b85312e87431ca8ba79a04c548b65 (commit) via 21373d85a2f6ddf4bd8f2ccaae0cd916fe2b10d8 (commit) via 19f3c0e1acb7a22a504e4451de252f97ae5c880d (commit) via 0ee67ade934579d161fa7e2bb350b7dc3c0dd038 (commit) via a41b5ad17f6436b956c46d2844a309ea7231c08e (commit) via 772fa0b5189745928a6bc9320e605121eaccdf1b (commit) via 0c3cfc2ee4b82d3d6790cbc217978b1460b2b034 (commit) via ad1abb4b319f2f901d072338abce670276af415d (commit) via 00a065a117555251d94957fb0e02e0524e17166a (commit) via b4c1aeaf9ed65c8956aefd8ced6171bca05ba9fa (commit) via ef4a3106b217aad59dd969349d835617d926ae47 (commit) from 849ccc59e315e64b2c2c98d79ba2108810c461ca (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8f95633f6049542a3b59872dd9ef03690131427f commit 8f95633f6049542a3b59872dd9ef03690131427f Merge: 849ccc5 7996f98 Author: Stephen Kelly AuthorDate: Tue Aug 25 16:10:44 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 25 16:10:44 2015 -0400 Merge topic 'use-generator-target' into next 7996f986 cmGeneratorTarget: Move GetConfigCommonSourceFiles from cmTarget. 03367767 cmGeneratorTarget: Move GetLanguages from cmTarget. 9f374203 cmGeneratorTarget: Move ComputeLinkImplementationLanguages from cmTarget. f81ff045 cmGeneratorTarget: Move HaveBuildTreeRPath from cmTarget. 21373d85 cmGeneratorTarget: Move GetLinkImplementation from cmTarget. 19f3c0e1 cmTarget: Add GetLinkImplMap method. 0ee67ade cmLinkItem: Add cmOptionalLinkImplementation type. a41b5ad1 cmLinkItem: Add cmLinkImplementation type. 772fa0b5 cmGeneratorTarget: Move compile defintions processing from cmTarget. 0c3cfc2e cmGeneratorTarget: Move compile features processing from cmTarget. ad1abb4b cmGeneratorTarget: Move compile options processing from cmTarget. 00a065a1 cmGeneratorTarget: Move include directory processing from cmTarget. b4c1aeaf cmGeneratorTarget: Move link iface helpers from cmTarget. ef4a3106 cmGeneratorTarget: Move GetLinkInterface from cmTarget. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7996f986c4c5099ed537e49cf3ae85d6fb3366a5 commit 7996f986c4c5099ed537e49cf3ae85d6fb3366a5 Author: Stephen Kelly AuthorDate: Wed Aug 5 17:37:50 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 22:05:29 2015 +0200 cmGeneratorTarget: Move GetConfigCommonSourceFiles from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 40ede70..db7ecb6 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -4396,11 +4396,67 @@ cmGeneratorTarget::GetLinkImplementation(const std::string& config) const } //---------------------------------------------------------------------------- +bool cmGeneratorTarget::GetConfigCommonSourceFiles( + std::vector& files) const +{ + std::vector configs; + this->Makefile->GetConfigurations(configs); + if (configs.empty()) + { + configs.push_back(""); + } + + std::vector::const_iterator it = configs.begin(); + const std::string& firstConfig = *it; + this->Target->GetSourceFiles(files, firstConfig); + + for ( ; it != configs.end(); ++it) + { + std::vector configFiles; + this->Target->GetSourceFiles(configFiles, *it); + if (configFiles != files) + { + std::string firstConfigFiles; + const char* sep = ""; + for (std::vector::const_iterator fi = files.begin(); + fi != files.end(); ++fi) + { + firstConfigFiles += sep; + firstConfigFiles += (*fi)->GetFullPath(); + sep = "\n "; + } + + std::string thisConfigFiles; + sep = ""; + for (std::vector::const_iterator fi = configFiles.begin(); + fi != configFiles.end(); ++fi) + { + thisConfigFiles += sep; + thisConfigFiles += (*fi)->GetFullPath(); + sep = "\n "; + } + std::ostringstream e; + e << "Target \"" << this->GetName() << "\" has source files which vary by " + "configuration. This is not supported by the \"" + << this->LocalGenerator->GetGlobalGenerator()->GetName() + << "\" generator.\n" + "Config \"" << firstConfig << "\":\n" + " " << firstConfigFiles << "\n" + "Config \"" << *it << "\":\n" + " " << thisConfigFiles << "\n"; + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); + return false; + } + } + return true; +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetLanguages(std::set& languages, const std::string& config) const { std::vector sourceFiles; - this->Target->GetSourceFiles(sourceFiles, config); + this->GetSourceFiles(sourceFiles, config); for(std::vector::const_iterator i = sourceFiles.begin(); i != sourceFiles.end(); ++i) { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index e7ec23a..6d66bfe 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -241,6 +241,8 @@ public: void GetLanguages(std::set& languages, std::string const& config) const; + bool GetConfigCommonSourceFiles(std::vector& files) const; + bool HaveBuildTreeRPATH(const std::string& config) const; /** Full path with trailing slash to the top-level directory diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index b70f3c9..756daa0 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1124,7 +1124,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, // organize the sources std::vector classes; - if (!cmtarget.GetConfigCommonSourceFiles(classes)) + if (!gtgt->GetConfigCommonSourceFiles(classes)) { return false; } @@ -1505,7 +1505,8 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases, } std::vector classes; - if (!cmtarget.GetConfigCommonSourceFiles(classes)) + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); + if (!gtgt->GetConfigCommonSourceFiles(classes)) { return; } @@ -2557,7 +2558,8 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget) if(cmtarget.GetType() == cmTarget::UTILITY) { std::vector sources; - if (!cmtarget.GetConfigCommonSourceFiles(sources)) + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); + if (!gtgt->GetConfigCommonSourceFiles(sources)) { return 0; } @@ -3085,7 +3087,8 @@ bool cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root, } std::vector classes; - if (!cmtarget.GetConfigCommonSourceFiles(classes)) + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); + if (!gtgt->GetConfigCommonSourceFiles(classes)) { return false; } diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index c58e7e4..94e517b 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -403,7 +403,8 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg, ) { std::vector srcFiles; - target->GetConfigCommonSourceFiles(srcFiles); + cmGeneratorTarget* gtgt = lg->GetGlobalGenerator()->GetGeneratorTarget(target); + gtgt->GetConfigCommonSourceFiles(srcFiles); for(std::vector::const_iterator fileIt = srcFiles.begin(); fileIt != srcFiles.end(); ++fileIt) @@ -661,7 +662,10 @@ void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target) const char* sepHeaders = ""; std::vector srcFiles; - target->GetConfigCommonSourceFiles(srcFiles); + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); + gtgt->GetConfigCommonSourceFiles(srcFiles); const char *skipMocSep = ""; const char *skipUicSep = ""; @@ -1046,7 +1050,10 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) cmMakefile *makefile = target->GetMakefile(); std::vector srcFiles; - target->GetConfigCommonSourceFiles(srcFiles); + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); + gtgt->GetConfigCommonSourceFiles(srcFiles); std::string qrcInputs; const char* qrcInputsSep = ""; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1b31d58..f19a52c 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -726,62 +726,6 @@ void cmTarget::GetSourceFiles(std::vector &files, } //---------------------------------------------------------------------------- -bool -cmTarget::GetConfigCommonSourceFiles(std::vector& files) const -{ - std::vector configs; - this->Makefile->GetConfigurations(configs); - if (configs.empty()) - { - configs.push_back(""); - } - - std::vector::const_iterator it = configs.begin(); - const std::string& firstConfig = *it; - this->GetSourceFiles(files, firstConfig); - - for ( ; it != configs.end(); ++it) - { - std::vector configFiles; - this->GetSourceFiles(configFiles, *it); - if (configFiles != files) - { - std::string firstConfigFiles; - const char* sep = ""; - for (std::vector::const_iterator fi = files.begin(); - fi != files.end(); ++fi) - { - firstConfigFiles += sep; - firstConfigFiles += (*fi)->GetFullPath(); - sep = "\n "; - } - - std::string thisConfigFiles; - sep = ""; - for (std::vector::const_iterator fi = configFiles.begin(); - fi != configFiles.end(); ++fi) - { - thisConfigFiles += sep; - thisConfigFiles += (*fi)->GetFullPath(); - sep = "\n "; - } - std::ostringstream e; - e << "Target \"" << this->Name << "\" has source files which vary by " - "configuration. This is not supported by the \"" - << this->Makefile->GetGlobalGenerator()->GetName() - << "\" generator.\n" - "Config \"" << firstConfig << "\":\n" - " " << firstConfigFiles << "\n" - "Config \"" << *it << "\":\n" - " " << thisConfigFiles << "\n"; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); - return false; - } - } - return true; -} - -//---------------------------------------------------------------------------- void cmTarget::GetSourceFiles(std::vector &files, const std::string& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 504703d..7f026a2 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -137,8 +137,6 @@ public: */ void GetSourceFiles(std::vector &files, const std::string& config) const; - bool GetConfigCommonSourceFiles(std::vector& files) const; - /** * Add sources to the target. */ http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=033677678a2d019a319dfa275f109ad1fac5e644 commit 033677678a2d019a319dfa275f109ad1fac5e644 Author: Stephen Kelly AuthorDate: Wed Aug 5 17:37:50 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 22:04:25 2015 +0200 cmGeneratorTarget: Move GetLanguages from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 31c8677..40ede70 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -4396,6 +4396,57 @@ cmGeneratorTarget::GetLinkImplementation(const std::string& config) const } //---------------------------------------------------------------------------- +void cmGeneratorTarget::GetLanguages(std::set& languages, + const std::string& config) const +{ + std::vector sourceFiles; + this->Target->GetSourceFiles(sourceFiles, config); + for(std::vector::const_iterator + i = sourceFiles.begin(); i != sourceFiles.end(); ++i) + { + const std::string& lang = (*i)->GetLanguage(); + if(!lang.empty()) + { + languages.insert(lang); + } + } + + std::vector objectLibraries; + std::vector externalObjects; + if (!this->Makefile->IsConfigured()) + { + std::vector objectTargets; + this->Target->GetObjectLibrariesCMP0026(objectTargets); + objectLibraries.reserve(objectTargets.size()); + for (std::vector::const_iterator it = objectTargets.begin(); + it != objectTargets.end(); ++it) + { + objectLibraries.push_back( + this->LocalGenerator->GetGlobalGenerator()->GetGeneratorTarget(*it)); + } + } + else + { + this->GetExternalObjects(externalObjects, config); + for(std::vector::const_iterator + i = externalObjects.begin(); i != externalObjects.end(); ++i) + { + std::string objLib = (*i)->GetObjectLibrary(); + if (cmTarget* tgt = this->Makefile->FindTargetToUse(objLib)) + { + objectLibraries.push_back( + this->LocalGenerator->GetGlobalGenerator()->GetGeneratorTarget(tgt)); + } + } + } + for(std::vector::const_iterator + i = objectLibraries.begin(); i != objectLibraries.end(); ++i) + { + (*i)->GetLanguages(languages, config); + } +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::ComputeLinkImplementationLanguages( const std::string& config, cmOptionalLinkImplementation& impl) const @@ -4403,7 +4454,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLanguages( // This target needs runtime libraries for its source languages. std::set languages; // Get languages used in our source files. - this->Target->GetLanguages(languages, config); + this->GetLanguages(languages, config); // Copy the set of langauges to the link implementation. impl.Languages.insert(impl.Languages.begin(), languages.begin(), languages.end()); diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 7cb3acd..e7ec23a 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -233,6 +233,14 @@ public: cmOptionalLinkImplementation& impl ) const; + // Compute the set of languages compiled by the target. This is + // computed every time it is called because the languages can change + // when source file properties are changed and we do not have enough + // information to forward these property changes to the targets + // until we have per-target object file properties. + void GetLanguages(std::set& languages, + std::string const& config) const; + bool HaveBuildTreeRPATH(const std::string& config) const; /** Full path with trailing slash to the top-level directory diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index b240924..331caad 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -1134,7 +1134,8 @@ bool cmGlobalUnixMakefileGenerator3 ::NeedRequiresStep(cmTarget const& target) { std::set languages; - target.GetLanguages(languages, + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&target); + gtgt->GetLanguages(languages, target.GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE")); for(std::set::const_iterator l = languages.begin(); l != languages.end(); ++l) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index dda4829..b70f3c9 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1805,7 +1805,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, // Compute the compilation flags for each language. std::set languages; - target.GetLanguages(languages, configName); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); + gtgt->GetLanguages(languages, configName); std::map cflags; for (std::set::iterator li = languages.begin(); li != languages.end(); ++li) @@ -1827,7 +1828,6 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, AddCompileOptions(flags, &target, lang, configName); } - cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); std::string llang = gtgt->GetLinkerLanguage(configName); if(binary && llang.empty()) { diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index ce370bc..50fcf21 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1257,7 +1257,8 @@ cmLocalUnixMakefileGenerator3 { // Get the set of source languages in the target. std::set languages; - target.GetLanguages(languages, + cmGeneratorTarget *gtgt = this->GlobalGenerator->GetGeneratorTarget(&target); + gtgt->GetLanguages(languages, this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); fout << "\n" << "# Per-language clean rules from dependency scanning.\n" diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 0b3df90..cf88a74 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -276,7 +276,7 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags() { // write language flags for target std::set languages; - this->Target->GetLanguages(languages, + this->GeneratorTarget->GetLanguages(languages, this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); // put the compiler in the rules.make file so that if it changes // things rebuild diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 45892f2..1b31d58 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3132,50 +3132,6 @@ cmTarget::GetObjectLibrariesCMP0026(std::vector& objlibs) const } //---------------------------------------------------------------------------- -void cmTarget::GetLanguages(std::set& languages, - const std::string& config) const -{ - std::vector sourceFiles; - this->GetSourceFiles(sourceFiles, config); - for(std::vector::const_iterator - i = sourceFiles.begin(); i != sourceFiles.end(); ++i) - { - const std::string& lang = (*i)->GetLanguage(); - if(!lang.empty()) - { - languages.insert(lang); - } - } - - std::vector objectLibraries; - std::vector externalObjects; - if (!this->Makefile->IsConfigured()) - { - this->GetObjectLibrariesCMP0026(objectLibraries); - } - else - { - cmGeneratorTarget* gt = this->Makefile->GetGlobalGenerator() - ->GetGeneratorTarget(this); - gt->GetExternalObjects(externalObjects, config); - for(std::vector::const_iterator - i = externalObjects.begin(); i != externalObjects.end(); ++i) - { - std::string objLib = (*i)->GetObjectLibrary(); - if (cmTarget* tgt = this->Makefile->FindTargetToUse(objLib)) - { - objectLibraries.push_back(tgt); - } - } - } - for(std::vector::const_iterator - i = objectLibraries.begin(); i != objectLibraries.end(); ++i) - { - (*i)->GetLanguages(languages, config); - } -} - -//---------------------------------------------------------------------------- cmTarget::ImportInfo const* cmTarget::GetImportInfo(const std::string& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index d2e74c2..504703d 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -304,14 +304,6 @@ public: If no macro should be defined null is returned. */ const char* GetExportMacro() const; - // Compute the set of languages compiled by the target. This is - // computed every time it is called because the languages can change - // when source file properties are changed and we do not have enough - // information to forward these property changes to the targets - // until we have per-target object file properties. - void GetLanguages(std::set& languages, - std::string const& config) const; - /** Return whether this target is an executable with symbol exports enabled. */ bool IsExecutableWithExports() const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9f3742039a438838739486a150a47699ca336013 commit 9f3742039a438838739486a150a47699ca336013 Author: Stephen Kelly AuthorDate: Wed Aug 5 17:37:50 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 22:03:36 2015 +0200 cmGeneratorTarget: Move ComputeLinkImplementationLanguages from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 4530333..31c8677 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -4390,12 +4390,26 @@ cmGeneratorTarget::GetLinkImplementation(const std::string& config) const if(!impl.LanguagesDone) { impl.LanguagesDone = true; - this->Target->ComputeLinkImplementationLanguages(config, impl); + this->ComputeLinkImplementationLanguages(config, impl); } return &impl; } //---------------------------------------------------------------------------- +void cmGeneratorTarget::ComputeLinkImplementationLanguages( + const std::string& config, + cmOptionalLinkImplementation& impl) const +{ + // This target needs runtime libraries for its source languages. + std::set languages; + // Get languages used in our source files. + this->Target->GetLanguages(languages, config); + // Copy the set of langauges to the link implementation. + impl.Languages.insert(impl.Languages.begin(), + languages.begin(), languages.end()); +} + +//---------------------------------------------------------------------------- bool cmGeneratorTarget::HaveBuildTreeRPATH(const std::string& config) const { if (this->Target->GetPropertyAsBool("SKIP_BUILD_RPATH")) diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index e5dbc69..7cb3acd 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -229,6 +229,10 @@ public: cmLinkImplementation const* GetLinkImplementation(const std::string& config) const; + void ComputeLinkImplementationLanguages(const std::string& config, + cmOptionalLinkImplementation& impl + ) const; + bool HaveBuildTreeRPATH(const std::string& config) const; /** Full path with trailing slash to the top-level directory diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 7b32ce8..45892f2 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3705,20 +3705,6 @@ void cmTarget::ComputeLinkImplementationLibraries( } //---------------------------------------------------------------------------- -void cmTarget::ComputeLinkImplementationLanguages( - const std::string& config, - cmOptionalLinkImplementation& impl) const -{ - // This target needs runtime libraries for its source languages. - std::set languages; - // Get languages used in our source files. - this->GetLanguages(languages, config); - // Copy the set of langauges to the link implementation. - impl.Languages.insert(impl.Languages.begin(), - languages.begin(), languages.end()); -} - -//---------------------------------------------------------------------------- cmTarget const* cmTarget::FindTargetToLink(std::string const& name) const { cmTarget const* tgt = this->Makefile->FindTargetToUse(name); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index ea5f7ae..d2e74c2 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -237,9 +237,6 @@ public: void ComputeLinkImplementationLibraries(const std::string& config, cmOptionalLinkImplementation& impl, cmTarget const* head) const; - void ComputeLinkImplementationLanguages(const std::string& config, - cmOptionalLinkImplementation& impl - ) const; cmOptionalLinkImplementation& GetLinkImplMap(std::string const& config) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f81ff045d42b85312e87431ca8ba79a04c548b65 commit f81ff045d42b85312e87431ca8ba79a04c548b65 Author: Stephen Kelly AuthorDate: Wed Aug 5 17:37:49 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 22:03:02 2015 +0200 cmGeneratorTarget: Move HaveBuildTreeRPath from cmTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 6ba0eed..192ad5f 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -1925,7 +1925,7 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, (outputRuntime && this->Target->Target->HaveInstallTreeRPATH() && linking_for_install); bool use_build_rpath = - (outputRuntime && this->Target->Target->HaveBuildTreeRPATH(this->Config) && + (outputRuntime && this->Target->HaveBuildTreeRPATH(this->Config) && !linking_for_install); bool use_link_rpath = outputRuntime && linking_for_install && diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 25fb627..4530333 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -908,7 +908,7 @@ cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const // If either a build or install tree rpath is set then the rpath // will likely change between the build tree and install tree and // this target must be relinked. - return this->Target->HaveBuildTreeRPATH(config) + return this->HaveBuildTreeRPATH(config) || this->Target->HaveInstallTreeRPATH(); } @@ -4394,3 +4394,18 @@ cmGeneratorTarget::GetLinkImplementation(const std::string& config) const } return &impl; } + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::HaveBuildTreeRPATH(const std::string& config) const +{ + if (this->Target->GetPropertyAsBool("SKIP_BUILD_RPATH")) + { + return false; + } + if(cmLinkImplementationLibraries const* impl = + this->Target->GetLinkImplementationLibraries(config)) + { + return !impl->Libraries.empty(); + } + return false; +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 91837db..e5dbc69 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -229,6 +229,8 @@ public: cmLinkImplementation const* GetLinkImplementation(const std::string& config) const; + bool HaveBuildTreeRPATH(const std::string& config) const; + /** Full path with trailing slash to the top-level directory holding object files for this target. Includes the build time config name placeholder if needed for the generator. */ diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 4984d95..7b32ce8 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2811,21 +2811,6 @@ void cmTarget::SetPropertyDefault(const std::string& property, } //---------------------------------------------------------------------------- -bool cmTarget::HaveBuildTreeRPATH(const std::string& config) const -{ - if (this->GetPropertyAsBool("SKIP_BUILD_RPATH")) - { - return false; - } - if(cmLinkImplementationLibraries const* impl = - this->GetLinkImplementationLibraries(config)) - { - return !impl->Libraries.empty(); - } - return false; -} - -//---------------------------------------------------------------------------- bool cmTarget::HaveInstallTreeRPATH() const { const char* install_rpath = this->GetProperty("INSTALL_RPATH"); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 0e68562..ea5f7ae 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -293,7 +293,6 @@ public: bool GetImplibGNUtoMS(std::string const& gnuName, std::string& out, const char* newExt = 0) const; - bool HaveBuildTreeRPATH(const std::string& config) const; bool HaveInstallTreeRPATH() const; // Get the properties http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=21373d85a2f6ddf4bd8f2ccaae0cd916fe2b10d8 commit 21373d85a2f6ddf4bd8f2ccaae0cd916fe2b10d8 Author: Stephen Kelly AuthorDate: Wed Aug 5 17:37:49 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 22:02:31 2015 +0200 cmGeneratorTarget: Move GetLinkImplementation from cmTarget. diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 38d1b68..20fa169 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -555,7 +555,7 @@ void cmComputeLinkDepends::AddDirectLinkEntries() { // Add direct link dependencies in this configuration. cmLinkImplementation const* impl = - this->Target->Target->GetLinkImplementation(this->Config); + this->Target->GetLinkImplementation(this->Config); this->AddLinkEntries(-1, impl->Libraries); for(std::vector::const_iterator wi = impl->WrongConfigLibraries.begin(); diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index ec9c61b..7488e09 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -252,8 +252,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) } } - cmLinkImplementation const* impl = - depender->Target->GetLinkImplementation(*it); + cmLinkImplementation const* impl = depender->GetLinkImplementation(*it); // A target should not depend on itself. emitted.insert(depender->GetName()); diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 29caa71..25fb627 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1336,7 +1336,7 @@ void cmGeneratorTarget::ComputeLinkClosure(const std::string& config, // Get languages built in this target. UNORDERED_SET languages; cmLinkImplementation const* impl = - this->Target->GetLinkImplementation(config); + this->GetLinkImplementation(config); assert(impl); for(std::vector::const_iterator li = impl->Languages.begin(); li != impl->Languages.end(); ++li) @@ -4295,7 +4295,7 @@ void cmGeneratorTarget::ComputeLinkInterface(const std::string& config, if (this->GetType() != cmTarget::INTERFACE_LIBRARY) { cmLinkImplementation const* impl = - this->Target->GetLinkImplementation(config); + this->GetLinkImplementation(config); for(std::vector::const_iterator li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li) { @@ -4336,7 +4336,7 @@ void cmGeneratorTarget::ComputeLinkInterface(const std::string& config, { // Targets using this archive need its language runtime libraries. if(cmLinkImplementation const* impl = - this->Target->GetLinkImplementation(config)) + this->GetLinkImplementation(config)) { iface.Languages = impl->Languages; } @@ -4370,3 +4370,27 @@ void cmGeneratorTarget::ComputeLinkInterface(const std::string& config, } } } + +//---------------------------------------------------------------------------- +const cmLinkImplementation * +cmGeneratorTarget::GetLinkImplementation(const std::string& config) const +{ + // There is no link implementation for imported targets. + if(this->Target->IsImported()) + { + return 0; + } + + cmOptionalLinkImplementation& impl = this->Target->GetLinkImplMap(config); + if(!impl.LibrariesDone) + { + impl.LibrariesDone = true; + this->Target->ComputeLinkImplementationLibraries(config, impl, this->Target); + } + if(!impl.LanguagesDone) + { + impl.LanguagesDone = true; + this->Target->ComputeLinkImplementationLanguages(config, impl); + } + return &impl; +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 9456bb1..91837db 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -226,6 +226,9 @@ public: LinkClosure const* GetLinkClosure(const std::string& config) const; void ComputeLinkClosure(const std::string& config, LinkClosure& lc) const; + cmLinkImplementation const* + GetLinkImplementation(const std::string& config) const; + /** Full path with trailing slash to the top-level directory holding object files for this target. Includes the build time config name placeholder if needed for the generator. */ diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 75604a2..dda4829 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1384,7 +1384,7 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmTarget& cmtarget) // If the language is compiled as a source trust Xcode to link with it. cmLinkImplementation const* impl = - cmtarget.GetLinkImplementation("NOCONFIG"); + gtgt->GetLinkImplementation("NOCONFIG"); for(std::vector::const_iterator li = impl->Languages.begin(); li != impl->Languages.end(); ++li) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 4c2c6b1..4984d95 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3565,30 +3565,6 @@ void cmTargetInternals::AddInterfaceEntries( } } -//---------------------------------------------------------------------------- -const cmLinkImplementation * -cmTarget::GetLinkImplementation(const std::string& config) const -{ - // There is no link implementation for imported targets. - if(this->IsImported()) - { - return 0; - } - - cmOptionalLinkImplementation& impl = this->GetLinkImplMap(config); - if(!impl.LibrariesDone) - { - impl.LibrariesDone = true; - this->ComputeLinkImplementationLibraries(config, impl, this); - } - if(!impl.LanguagesDone) - { - impl.LanguagesDone = true; - this->ComputeLinkImplementationLanguages(config, impl); - } - return &impl; -} - cmOptionalLinkImplementation& cmTarget::GetLinkImplMap(std::string const& config) const { // Populate the link implementation for this configuration. diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 6f3772b..0e68562 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -231,9 +231,6 @@ public: void GetObjectLibrariesCMP0026(std::vector& objlibs) const; - cmLinkImplementation const* - GetLinkImplementation(const std::string& config) const; - cmLinkImplementationLibraries const* GetLinkImplementationLibraries(const std::string& config) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=19f3c0e1acb7a22a504e4451de252f97ae5c880d commit 19f3c0e1acb7a22a504e4451de252f97ae5c880d Author: Stephen Kelly AuthorDate: Wed Aug 5 17:37:49 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 22:02:31 2015 +0200 cmTarget: Add GetLinkImplMap method. This is a temporary refactoring artifact. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 18d1220..4c2c6b1 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3575,10 +3575,7 @@ cmTarget::GetLinkImplementation(const std::string& config) const return 0; } - // Populate the link implementation for this configuration. - std::string CONFIG = cmSystemTools::UpperCase(config); - cmOptionalLinkImplementation& - impl = this->Internal->LinkImplMap[CONFIG][this]; + cmOptionalLinkImplementation& impl = this->GetLinkImplMap(config); if(!impl.LibrariesDone) { impl.LibrariesDone = true; @@ -3592,6 +3589,13 @@ cmTarget::GetLinkImplementation(const std::string& config) const return &impl; } +cmOptionalLinkImplementation& cmTarget::GetLinkImplMap(std::string const& config) const +{ + // Populate the link implementation for this configuration. + std::string CONFIG = cmSystemTools::UpperCase(config); + return Internal->LinkImplMap[CONFIG][this]; +} + //---------------------------------------------------------------------------- cmLinkImplementationLibraries const* cmTarget::GetLinkImplementationLibraries(const std::string& config) const diff --git a/Source/cmTarget.h b/Source/cmTarget.h index d49b23e..6f3772b 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -244,6 +244,8 @@ public: cmOptionalLinkImplementation& impl ) const; + cmOptionalLinkImplementation& GetLinkImplMap(std::string const& config) const; + cmTarget const* FindTargetToLink(std::string const& name) const; /** Strip off leading and trailing whitespace from an item named in http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0ee67ade934579d161fa7e2bb350b7dc3c0dd038 commit 0ee67ade934579d161fa7e2bb350b7dc3c0dd038 Author: Stephen Kelly AuthorDate: Wed Aug 5 17:37:48 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 22:01:56 2015 +0200 cmLinkItem: Add cmOptionalLinkImplementation type. Move the associated Compute* methods to the cmTarget class. diff --git a/Source/cmLinkItem.h b/Source/cmLinkItem.h index accc83c..f1d914f 100644 --- a/Source/cmLinkItem.h +++ b/Source/cmLinkItem.h @@ -62,4 +62,15 @@ struct cmLinkImplementation: public cmLinkImplementationLibraries std::vector Languages; }; +// Cache link implementation computation from each configuration. +struct cmOptionalLinkImplementation: public cmLinkImplementation +{ + cmOptionalLinkImplementation(): + LibrariesDone(false), LanguagesDone(false), + HadHeadSensitiveCondition(false) {} + bool LibrariesDone; + bool LanguagesDone; + bool HadHeadSensitiveCondition; +}; + #endif diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e6408c4..18d1220 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -96,27 +96,8 @@ public: typedef std::map ImportInfoMapType; ImportInfoMapType ImportInfoMap; - // Cache link implementation computation from each configuration. - struct OptionalLinkImplementation: public cmLinkImplementation - { - OptionalLinkImplementation(): - LibrariesDone(false), LanguagesDone(false), - HadHeadSensitiveCondition(false) {} - bool LibrariesDone; - bool LanguagesDone; - bool HadHeadSensitiveCondition; - }; - void ComputeLinkImplementationLibraries(cmTarget const* thisTarget, - const std::string& config, - OptionalLinkImplementation& impl, - cmTarget const* head) const; - void ComputeLinkImplementationLanguages(cmTarget const* thisTarget, - const std::string& config, - OptionalLinkImplementation& impl - ) const; - struct HeadToLinkImplementationMap: - public std::map {}; + public std::map {}; typedef std::map LinkImplMapType; LinkImplMapType LinkImplMap; @@ -3596,18 +3577,17 @@ cmTarget::GetLinkImplementation(const std::string& config) const // Populate the link implementation for this configuration. std::string CONFIG = cmSystemTools::UpperCase(config); - cmTargetInternals::OptionalLinkImplementation& + cmOptionalLinkImplementation& impl = this->Internal->LinkImplMap[CONFIG][this]; if(!impl.LibrariesDone) { impl.LibrariesDone = true; - this->Internal - ->ComputeLinkImplementationLibraries(this, config, impl, this); + this->ComputeLinkImplementationLibraries(config, impl, this); } if(!impl.LanguagesDone) { impl.LanguagesDone = true; - this->Internal->ComputeLinkImplementationLanguages(this, config, impl); + this->ComputeLinkImplementationLanguages(config, impl); } return &impl; } @@ -3642,39 +3622,36 @@ cmTarget::GetLinkImplementationLibrariesInternal(const std::string& config, return &hm.begin()->second; } - cmTargetInternals::OptionalLinkImplementation& impl = hm[head]; + cmOptionalLinkImplementation& impl = hm[head]; if(!impl.LibrariesDone) { impl.LibrariesDone = true; - this->Internal - ->ComputeLinkImplementationLibraries(this, config, impl, head); + this->ComputeLinkImplementationLibraries(config, impl, head); } return &impl; } //---------------------------------------------------------------------------- -void -cmTargetInternals::ComputeLinkImplementationLibraries( - cmTarget const* thisTarget, +void cmTarget::ComputeLinkImplementationLibraries( const std::string& config, - OptionalLinkImplementation& impl, + cmOptionalLinkImplementation& impl, cmTarget const* head) const { // Collect libraries directly linked in this configuration. for (std::vector::const_iterator - le = this->LinkImplementationPropertyEntries.begin(), - end = this->LinkImplementationPropertyEntries.end(); + le = this->Internal->LinkImplementationPropertyEntries.begin(), + end = this->Internal->LinkImplementationPropertyEntries.end(); le != end; ++le) { std::vector llibs; cmGeneratorExpressionDAGChecker dagChecker( - thisTarget->GetName(), + this->GetName(), "LINK_LIBRARIES", 0, 0); cmGeneratorExpression ge(le->Backtrace); cmsys::auto_ptr const cge = ge.Parse(le->Value); std::string const evaluated = - cge->Evaluate(thisTarget->Makefile, config, false, head, &dagChecker); + cge->Evaluate(this->Makefile, config, false, head, &dagChecker); cmSystemTools::ExpandListArgument(evaluated, llibs); if(cge->GetHadHeadSensitiveCondition()) { @@ -3685,15 +3662,15 @@ cmTargetInternals::ComputeLinkImplementationLibraries( li != llibs.end(); ++li) { // Skip entries that resolve to the target itself or are empty. - std::string name = thisTarget->CheckCMP0004(*li); - if(name == thisTarget->GetName() || name.empty()) + std::string name = this->CheckCMP0004(*li); + if(name == this->GetName() || name.empty()) { - if(name == thisTarget->GetName()) + if(name == this->GetName()) { bool noMessage = false; cmake::MessageType messageType = cmake::FATAL_ERROR; std::ostringstream e; - switch(thisTarget->GetPolicyStatusCMP0038()) + switch(this->GetPolicyStatusCMP0038()) { case cmPolicies::WARN: { @@ -3712,9 +3689,9 @@ cmTargetInternals::ComputeLinkImplementationLibraries( if(!noMessage) { - e << "Target \"" << thisTarget->GetName() << "\" links to itself."; - thisTarget->Makefile->GetCMakeInstance()->IssueMessage( - messageType, e.str(), thisTarget->GetBacktrace()); + e << "Target \"" << this->GetName() << "\" links to itself."; + this->Makefile->GetCMakeInstance()->IssueMessage( + messageType, e.str(), this->GetBacktrace()); if (messageType == cmake::FATAL_ERROR) { return; @@ -3726,7 +3703,7 @@ cmTargetInternals::ComputeLinkImplementationLibraries( // The entry is meant for this configuration. impl.Libraries.push_back( - cmLinkImplItem(name, thisTarget->FindTargetToLink(name), + cmLinkImplItem(name, this->FindTargetToLink(name), le->Backtrace, evaluated != le->Value)); } @@ -3734,45 +3711,43 @@ cmTargetInternals::ComputeLinkImplementationLibraries( for (std::set::const_iterator it = seenProps.begin(); it != seenProps.end(); ++it) { - if (!thisTarget->GetProperty(*it)) + if (!this->GetProperty(*it)) { - thisTarget->LinkImplicitNullProperties.insert(*it); + this->LinkImplicitNullProperties.insert(*it); } } - cge->GetMaxLanguageStandard(thisTarget, thisTarget->MaxLanguageStandards); + cge->GetMaxLanguageStandard(this, this->MaxLanguageStandards); } - cmTarget::LinkLibraryType linkType = thisTarget->ComputeLinkType(config); + cmTarget::LinkLibraryType linkType = this->ComputeLinkType(config); cmTarget::LinkLibraryVectorType const& oldllibs = - thisTarget->GetOriginalLinkLibraries(); + this->GetOriginalLinkLibraries(); for(cmTarget::LinkLibraryVectorType::const_iterator li = oldllibs.begin(); li != oldllibs.end(); ++li) { if(li->second != cmTarget::GENERAL && li->second != linkType) { - std::string name = thisTarget->CheckCMP0004(li->first); - if(name == thisTarget->GetName() || name.empty()) + std::string name = this->CheckCMP0004(li->first); + if(name == this->GetName() || name.empty()) { continue; } // Support OLD behavior for CMP0003. impl.WrongConfigLibraries.push_back( - cmLinkItem(name, thisTarget->FindTargetToLink(name))); + cmLinkItem(name, this->FindTargetToLink(name))); } } } //---------------------------------------------------------------------------- -void -cmTargetInternals::ComputeLinkImplementationLanguages( - cmTarget const* thisTarget, +void cmTarget::ComputeLinkImplementationLanguages( const std::string& config, - OptionalLinkImplementation& impl) const + cmOptionalLinkImplementation& impl) const { // This target needs runtime libraries for its source languages. std::set languages; // Get languages used in our source files. - thisTarget->GetLanguages(languages, config); + this->GetLanguages(languages, config); // Copy the set of langauges to the link implementation. impl.Languages.insert(impl.Languages.begin(), languages.begin(), languages.end()); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 19cc220..d49b23e 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -237,6 +237,13 @@ public: cmLinkImplementationLibraries const* GetLinkImplementationLibraries(const std::string& config) const; + void ComputeLinkImplementationLibraries(const std::string& config, + cmOptionalLinkImplementation& impl, + cmTarget const* head) const; + void ComputeLinkImplementationLanguages(const std::string& config, + cmOptionalLinkImplementation& impl + ) const; + cmTarget const* FindTargetToLink(std::string const& name) const; /** Strip off leading and trailing whitespace from an item named in http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a41b5ad17f6436b956c46d2844a309ea7231c08e commit a41b5ad17f6436b956c46d2844a309ea7231c08e Author: Stephen Kelly AuthorDate: Wed Aug 5 17:37:48 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 21:58:18 2015 +0200 cmLinkItem: Add cmLinkImplementation type. diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 87d96e3..38d1b68 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -554,7 +554,7 @@ void cmComputeLinkDepends::AddVarLinkEntries(int depender_index, void cmComputeLinkDepends::AddDirectLinkEntries() { // Add direct link dependencies in this configuration. - cmTarget::LinkImplementation const* impl = + cmLinkImplementation const* impl = this->Target->Target->GetLinkImplementation(this->Config); this->AddLinkEntries(-1, impl->Libraries); for(std::vector::const_iterator diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index fd4b567..ec9c61b 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -252,7 +252,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) } } - cmTarget::LinkImplementation const* impl = + cmLinkImplementation const* impl = depender->Target->GetLinkImplementation(*it); // A target should not depend on itself. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 88086e2..29caa71 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1335,7 +1335,7 @@ void cmGeneratorTarget::ComputeLinkClosure(const std::string& config, { // Get languages built in this target. UNORDERED_SET languages; - cmTarget::LinkImplementation const* impl = + cmLinkImplementation const* impl = this->Target->GetLinkImplementation(config); assert(impl); for(std::vector::const_iterator li = impl->Languages.begin(); @@ -4294,7 +4294,7 @@ void cmGeneratorTarget::ComputeLinkInterface(const std::string& config, } if (this->GetType() != cmTarget::INTERFACE_LIBRARY) { - cmTarget::LinkImplementation const* impl = + cmLinkImplementation const* impl = this->Target->GetLinkImplementation(config); for(std::vector::const_iterator li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li) @@ -4335,7 +4335,7 @@ void cmGeneratorTarget::ComputeLinkInterface(const std::string& config, if(this->Target->LinkLanguagePropagatesToDependents()) { // Targets using this archive need its language runtime libraries. - if(cmTarget::LinkImplementation const* impl = + if(cmLinkImplementation const* impl = this->Target->GetLinkImplementation(config)) { iface.Languages = impl->Languages; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 33fd637..75604a2 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1383,7 +1383,7 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmTarget& cmtarget) if(llang.empty()) { return; } // If the language is compiled as a source trust Xcode to link with it. - cmTarget::LinkImplementation const* impl = + cmLinkImplementation const* impl = cmtarget.GetLinkImplementation("NOCONFIG"); for(std::vector::const_iterator li = impl->Languages.begin(); li != impl->Languages.end(); ++li) diff --git a/Source/cmLinkItem.h b/Source/cmLinkItem.h index a5427de..accc83c 100644 --- a/Source/cmLinkItem.h +++ b/Source/cmLinkItem.h @@ -56,4 +56,10 @@ struct cmLinkImplementationLibraries std::vector WrongConfigLibraries; }; +struct cmLinkImplementation: public cmLinkImplementationLibraries +{ + // Languages whose runtime libraries must be linked. + std::vector Languages; +}; + #endif diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index d1b7755..e6408c4 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -97,7 +97,7 @@ public: ImportInfoMapType ImportInfoMap; // Cache link implementation computation from each configuration. - struct OptionalLinkImplementation: public cmTarget::LinkImplementation + struct OptionalLinkImplementation: public cmLinkImplementation { OptionalLinkImplementation(): LibrariesDone(false), LanguagesDone(false), @@ -3585,7 +3585,7 @@ void cmTargetInternals::AddInterfaceEntries( } //---------------------------------------------------------------------------- -cmTarget::LinkImplementation const* +const cmLinkImplementation * cmTarget::GetLinkImplementation(const std::string& config) const { // There is no link implementation for imported targets. diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 34a75ea..19cc220 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -231,12 +231,7 @@ public: void GetObjectLibrariesCMP0026(std::vector& objlibs) const; - struct LinkImplementation: public cmLinkImplementationLibraries - { - // Languages whose runtime libraries must be linked. - std::vector Languages; - }; - LinkImplementation const* + cmLinkImplementation const* GetLinkImplementation(const std::string& config) const; cmLinkImplementationLibraries const* http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=772fa0b5189745928a6bc9320e605121eaccdf1b commit 772fa0b5189745928a6bc9320e605121eaccdf1b Author: Stephen Kelly AuthorDate: Wed Aug 5 00:00:53 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 21:57:13 2015 +0200 cmGeneratorTarget: Move compile defintions processing from cmTarget. diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 933a256..dfd51c7 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -609,7 +609,7 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, // the compilerdefines for this target std::vector cdefs; - target->GetCompileDefinitions(cdefs, buildType, "C"); + gtgt->GetCompileDefinitions(cdefs, buildType, "C"); // Expand the list. for(std::vector::const_iterator di = cdefs.begin(); diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index bed1bd4..88086e2 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -262,7 +262,8 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) SourceFileFlagsConstructed(false), DebugIncludesDone(false), DebugCompileOptionsDone(false), - DebugCompileFeaturesDone(false) + DebugCompileFeaturesDone(false), + DebugCompileDefinitionsDone(false) { this->Makefile = this->Target->GetMakefile(); this->LocalGenerator = lg; @@ -282,6 +283,11 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) t->GetCompileFeaturesEntries(), t->GetCompileFeaturesBacktraces(), this->CompileFeaturesEntries); + + CreatePropertyGeneratorExpressions( + t->GetCompileDefinitionsEntries(), + t->GetCompileDefinitionsBacktraces(), + this->CompileDefinitionsEntries); } cmGeneratorTarget::~cmGeneratorTarget() @@ -289,6 +295,7 @@ cmGeneratorTarget::~cmGeneratorTarget() cmDeleteAll(this->IncludeDirectoriesEntries); cmDeleteAll(this->CompileOptionsEntries); cmDeleteAll(this->CompileFeaturesEntries); + cmDeleteAll(this->CompileDefinitionsEntries); cmDeleteAll(this->LinkInformation); this->LinkInformation.clear(); } @@ -2445,6 +2452,108 @@ void cmGeneratorTarget::GetCompileFeatures(std::vector &result, } //---------------------------------------------------------------------------- +static void processCompileDefinitions(cmGeneratorTarget const* tgt, + const std::vector &entries, + std::vector &options, + UNORDERED_SET &uniqueOptions, + cmGeneratorExpressionDAGChecker *dagChecker, + const std::string& config, bool debugOptions, + std::string const& language) +{ + processCompileOptionsInternal(tgt, entries, options, uniqueOptions, + dagChecker, config, debugOptions, + "definitions", language); +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GetCompileDefinitions(std::vector &list, + const std::string& config, + const std::string& language) const +{ + UNORDERED_SET uniqueOptions; + + cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), + "COMPILE_DEFINITIONS", 0, 0); + + std::vector debugProperties; + const char *debugProp = + this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); + if (debugProp) + { + cmSystemTools::ExpandListArgument(debugProp, debugProperties); + } + + bool debugDefines = !this->DebugCompileDefinitionsDone + && std::find(debugProperties.begin(), + debugProperties.end(), + "COMPILE_DEFINITIONS") + != debugProperties.end(); + + if (this->Makefile->IsConfigured()) + { + this->DebugCompileDefinitionsDone = true; + } + + processCompileDefinitions(this, + this->CompileDefinitionsEntries, + list, + uniqueOptions, + &dagChecker, + config, + debugDefines, + language); + + std::vector + linkInterfaceCompileDefinitionsEntries; + AddInterfaceEntries( + this, config, "INTERFACE_COMPILE_DEFINITIONS", + linkInterfaceCompileDefinitionsEntries); + if (!config.empty()) + { + std::string configPropName = "COMPILE_DEFINITIONS_" + + cmSystemTools::UpperCase(config); + const char *configProp = this->Target->GetProperty(configPropName); + if (configProp) + { + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0043)) + { + case cmPolicies::WARN: + { + std::ostringstream e; + e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0043); + this->LocalGenerator->IssueMessage(cmake::AUTHOR_WARNING, + e.str()); + } + case cmPolicies::OLD: + { + cmGeneratorExpression ge; + cmsys::auto_ptr cge = + ge.Parse(configProp); + linkInterfaceCompileDefinitionsEntries + .push_back(new cmGeneratorTarget::TargetPropertyEntry(cge)); + } + break; + case cmPolicies::NEW: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::REQUIRED_IF_USED: + break; + } + } + } + + processCompileDefinitions(this, + linkInterfaceCompileDefinitionsEntries, + list, + uniqueOptions, + &dagChecker, + config, + debugDefines, + language); + + cmDeleteAll(linkInterfaceCompileDefinitionsEntries); +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GenerateTargetManifest( const std::string& config) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index e57485f..9456bb1 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -252,6 +252,10 @@ public: void GetCompileFeatures(std::vector &features, const std::string& config) const; + void GetCompileDefinitions(std::vector &result, + const std::string& config, + const std::string& language) const; + bool IsSystemIncludeDirectory(const std::string& dir, const std::string& config) const; @@ -459,10 +463,12 @@ private: mutable bool DebugIncludesDone; mutable bool DebugCompileOptionsDone; mutable bool DebugCompileFeaturesDone; + mutable bool DebugCompileDefinitionsDone; std::vector IncludeDirectoriesEntries; std::vector CompileOptionsEntries; std::vector CompileFeaturesEntries; + std::vector CompileDefinitionsEntries; void ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, cmTarget const* headTarget, diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 503c455..c0f1817 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1550,7 +1550,6 @@ void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes, ti != targets.end(); ++ti) { cmTarget* t = &ti->second; - t->Compute(); cmGeneratorTarget* gt = new cmGeneratorTarget(t, lg); this->GeneratorTargets[t] = gt; generatorTargets[t] = gt; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 4ba29f5..33fd637 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1855,7 +1855,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, this->AppendDefines(ppDefs, exportMacro); } std::vector targetDefines; - target.GetCompileDefinitions(targetDefines, configName, "C"); + gtgt->GetCompileDefinitions(targetDefines, configName, "C"); this->AppendDefines(ppDefs, targetDefines); buildSettings->AddAttribute ("GCC_PREPROCESSOR_DEFINITIONS", ppDefs.CreateList()); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index a7e4191..c1cc241 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1083,7 +1083,8 @@ void cmLocalGenerator::AddCompileDefinitions(std::set& defines, const std::string& lang) { std::vector targetDefines; - target->GetCompileDefinitions(targetDefines, config, lang); + cmGeneratorTarget* gtgt = this->GlobalGenerator->GetGeneratorTarget(target); + gtgt->GetCompileDefinitions(targetDefines, config, lang); this->AppendDefines(defines, targetDefines); } diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index f85e70e..c58e7e4 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -474,8 +474,6 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg, /*byproducts=*/rcc_output, depends, commandLines, false, autogenComment.c_str()); - autogenTarget->Compute(); - cmGeneratorTarget* gt = new cmGeneratorTarget(autogenTarget, lg); makefile->AddGeneratorTarget(autogenTarget, gt); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 7a23e9d..d1b7755 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -146,7 +146,6 @@ public: std::vector CompileFeaturesBacktraces; std::vector CompileDefinitionsEntries; std::vector CompileDefinitionsBacktraces; - std::vector CompileDefinitionsItems; std::vector SourceEntries; std::vector LinkImplementationPropertyEntries; @@ -175,7 +174,6 @@ cmTarget::cmTarget() this->IsApple = false; this->IsImportedTarget = false; this->BuildInterfaceIncludesAppended = false; - this->DebugCompileDefinitionsDone = false; this->DebugSourcesDone = false; this->LinkImplementationLanguageIsContextDependent = true; } @@ -418,14 +416,6 @@ void CreatePropertyGeneratorExpressions( } } -void cmTarget::Compute() -{ - CreatePropertyGeneratorExpressions( - this->Internal->CompileDefinitionsEntries, - this->Internal->CompileDefinitionsBacktraces, - this->Internal->CompileDefinitionsItems); -} - //---------------------------------------------------------------------------- void cmTarget::AddUtility(const std::string& u, cmMakefile *makefile) { @@ -1329,6 +1319,16 @@ cmBacktraceRange cmTarget::GetCompileFeaturesBacktraces() const return cmMakeRange(this->Internal->CompileFeaturesBacktraces); } +cmStringRange cmTarget::GetCompileDefinitionsEntries() const +{ + return cmMakeRange(this->Internal->CompileDefinitionsEntries); +} + +cmBacktraceRange cmTarget::GetCompileDefinitionsBacktraces() const +{ + return cmMakeRange(this->Internal->CompileDefinitionsBacktraces); +} + #if defined(_WIN32) && !defined(__CYGWIN__) //---------------------------------------------------------------------------- void @@ -1926,156 +1926,6 @@ void cmTarget::InsertCompileDefinition(std::string const& entry, } //---------------------------------------------------------------------------- -static void processCompileOptionsInternal(cmTarget const* tgt, - const std::vector &entries, - std::vector &options, - UNORDERED_SET &uniqueOptions, - cmGeneratorExpressionDAGChecker *dagChecker, - const std::string& config, bool debugOptions, const char *logName, - std::string const& language) -{ - cmMakefile *mf = tgt->GetMakefile(); - - for (std::vector::const_iterator - it = entries.begin(), end = entries.end(); it != end; ++it) - { - std::vector entryOptions; - cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf, - config, - false, - tgt, - dagChecker, - language), - entryOptions); - std::string usedOptions; - for(std::vector::iterator - li = entryOptions.begin(); li != entryOptions.end(); ++li) - { - std::string const& opt = *li; - - if(uniqueOptions.insert(opt).second) - { - options.push_back(opt); - if (debugOptions) - { - usedOptions += " * " + opt + "\n"; - } - } - } - if (!usedOptions.empty()) - { - mf->GetCMakeInstance()->IssueMessage(cmake::LOG, - std::string("Used compile ") + logName - + std::string(" for target ") - + tgt->GetName() + ":\n" - + usedOptions, (*it)->ge->GetBacktrace()); - } - } -} - -//---------------------------------------------------------------------------- -static void processCompileDefinitions(cmTarget const* tgt, - const std::vector &entries, - std::vector &options, - UNORDERED_SET &uniqueOptions, - cmGeneratorExpressionDAGChecker *dagChecker, - const std::string& config, bool debugOptions, - std::string const& language) -{ - processCompileOptionsInternal(tgt, entries, options, uniqueOptions, - dagChecker, config, debugOptions, - "definitions", language); -} - -//---------------------------------------------------------------------------- -void cmTarget::GetCompileDefinitions(std::vector &list, - const std::string& config, - const std::string& language) const -{ - UNORDERED_SET uniqueOptions; - - cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), - "COMPILE_DEFINITIONS", 0, 0); - - std::vector debugProperties; - const char *debugProp = - this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); - if (debugProp) - { - cmSystemTools::ExpandListArgument(debugProp, debugProperties); - } - - bool debugDefines = !this->DebugCompileDefinitionsDone - && std::find(debugProperties.begin(), - debugProperties.end(), - "COMPILE_DEFINITIONS") - != debugProperties.end(); - - if (this->Makefile->IsConfigured()) - { - this->DebugCompileDefinitionsDone = true; - } - - processCompileDefinitions(this, - this->Internal->CompileDefinitionsItems, - list, - uniqueOptions, - &dagChecker, - config, - debugDefines, - language); - - std::vector - linkInterfaceCompileDefinitionsEntries; - this->Internal->AddInterfaceEntries( - this, config, "INTERFACE_COMPILE_DEFINITIONS", - linkInterfaceCompileDefinitionsEntries); - if (!config.empty()) - { - std::string configPropName = "COMPILE_DEFINITIONS_" - + cmSystemTools::UpperCase(config); - const char *configProp = this->GetProperty(configPropName); - if (configProp) - { - switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0043)) - { - case cmPolicies::WARN: - { - std::ostringstream e; - e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0043); - this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, - e.str()); - } - case cmPolicies::OLD: - { - cmGeneratorExpression ge; - cmsys::auto_ptr cge = - ge.Parse(configProp); - linkInterfaceCompileDefinitionsEntries - .push_back(new cmTargetInternals::TargetPropertyEntry(cge)); - } - break; - case cmPolicies::NEW: - case cmPolicies::REQUIRED_ALWAYS: - case cmPolicies::REQUIRED_IF_USED: - break; - } - } - } - - processCompileDefinitions(this, - linkInterfaceCompileDefinitionsEntries, - list, - uniqueOptions, - &dagChecker, - config, - debugDefines, - language); - - cmDeleteAll(linkInterfaceCompileDefinitionsEntries); -} - -//---------------------------------------------------------------------------- void cmTarget::MaybeInvalidatePropertyCache(const std::string& prop) { // Wipe out maps caching information affected by this property. @@ -4035,7 +3885,6 @@ cmTargetInternalPointer //---------------------------------------------------------------------------- cmTargetInternalPointer::~cmTargetInternalPointer() { - cmDeleteAll(this->Pointer->CompileDefinitionsItems); cmDeleteAll(this->Pointer->SourceEntries); delete this->Pointer; } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index aae558e..34a75ea 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -132,8 +132,6 @@ public: void AddPostBuildCommand(cmCustomCommand const &cmd) {this->PostBuildCommands.push_back(cmd);} - void Compute(); - /** * Get the list of the source files used by this target */ @@ -309,10 +307,6 @@ public: If no macro should be defined null is returned. */ const char* GetExportMacro() const; - void GetCompileDefinitions(std::vector &result, - const std::string& config, - const std::string& language) const; - // Compute the set of languages compiled by the target. This is // computed every time it is called because the languages can change // when source file properties are changed and we do not have enough @@ -402,6 +396,9 @@ public: cmStringRange GetCompileFeaturesEntries() const; cmBacktraceRange GetCompileFeaturesBacktraces() const; + cmStringRange GetCompileDefinitionsEntries() const; + cmBacktraceRange GetCompileDefinitionsBacktraces() const; + #if defined(_WIN32) && !defined(__CYGWIN__) const LinkLibraryVectorType &GetLinkLibrariesForVS6() const { return this->LinkLibrariesForVS6;} @@ -516,7 +513,6 @@ private: bool IsApple; bool IsImportedTarget; bool BuildInterfaceIncludesAppended; - mutable bool DebugCompileDefinitionsDone; mutable bool DebugSourcesDone; mutable bool LinkImplementationLanguageIsContextDependent; #if defined(_WIN32) && !defined(__CYGWIN__) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0c3cfc2ee4b82d3d6790cbc217978b1460b2b034 commit 0c3cfc2ee4b82d3d6790cbc217978b1460b2b034 Author: Stephen Kelly AuthorDate: Tue Aug 4 23:48:58 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 21:56:43 2015 +0200 cmGeneratorTarget: Move compile features processing from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 594eb59..bed1bd4 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -261,7 +261,8 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) : Target(t), SourceFileFlagsConstructed(false), DebugIncludesDone(false), - DebugCompileOptionsDone(false) + DebugCompileOptionsDone(false), + DebugCompileFeaturesDone(false) { this->Makefile = this->Target->GetMakefile(); this->LocalGenerator = lg; @@ -276,12 +277,18 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) t->GetCompileOptionsEntries(), t->GetCompileOptionsBacktraces(), this->CompileOptionsEntries); + + CreatePropertyGeneratorExpressions( + t->GetCompileFeaturesEntries(), + t->GetCompileFeaturesBacktraces(), + this->CompileFeaturesEntries); } cmGeneratorTarget::~cmGeneratorTarget() { cmDeleteAll(this->IncludeDirectoriesEntries); cmDeleteAll(this->CompileOptionsEntries); + cmDeleteAll(this->CompileFeaturesEntries); cmDeleteAll(this->LinkInformation); this->LinkInformation.clear(); } @@ -2371,6 +2378,73 @@ void cmGeneratorTarget::GetCompileOptions(std::vector &result, } //---------------------------------------------------------------------------- +static void processCompileFeatures(cmGeneratorTarget const* tgt, + const std::vector &entries, + std::vector &options, + UNORDERED_SET &uniqueOptions, + cmGeneratorExpressionDAGChecker *dagChecker, + const std::string& config, bool debugOptions) +{ + processCompileOptionsInternal(tgt, entries, options, uniqueOptions, + dagChecker, config, debugOptions, "features", + std::string()); +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GetCompileFeatures(std::vector &result, + const std::string& config) const +{ + UNORDERED_SET uniqueFeatures; + + cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), + "COMPILE_FEATURES", + 0, 0); + + std::vector debugProperties; + const char *debugProp = + this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); + if (debugProp) + { + cmSystemTools::ExpandListArgument(debugProp, debugProperties); + } + + bool debugFeatures = !this->DebugCompileFeaturesDone + && std::find(debugProperties.begin(), + debugProperties.end(), + "COMPILE_FEATURES") + != debugProperties.end(); + + if (this->Makefile->IsConfigured()) + { + this->DebugCompileFeaturesDone = true; + } + + processCompileFeatures(this, + this->CompileFeaturesEntries, + result, + uniqueFeatures, + &dagChecker, + config, + debugFeatures); + + std::vector + linkInterfaceCompileFeaturesEntries; + AddInterfaceEntries( + this, config, "INTERFACE_COMPILE_FEATURES", + linkInterfaceCompileFeaturesEntries); + + processCompileFeatures(this, + linkInterfaceCompileFeaturesEntries, + result, + uniqueFeatures, + &dagChecker, + config, + debugFeatures); + + cmDeleteAll(linkInterfaceCompileFeaturesEntries); +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GenerateTargetManifest( const std::string& config) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 99dc746..e57485f 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -249,6 +249,9 @@ public: const std::string& config, const std::string& language) const; + void GetCompileFeatures(std::vector &features, + const std::string& config) const; + bool IsSystemIncludeDirectory(const std::string& dir, const std::string& config) const; @@ -455,9 +458,11 @@ private: mutable bool PolicyWarnedCMP0022; mutable bool DebugIncludesDone; mutable bool DebugCompileOptionsDone; + mutable bool DebugCompileFeaturesDone; std::vector IncludeDirectoriesEntries; std::vector CompileOptionsEntries; + std::vector CompileFeaturesEntries; void ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, cmTarget const* headTarget, diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 89515ff..a7e4191 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1138,7 +1138,7 @@ void cmLocalGenerator::AddCompileOptions( } } std::vector features; - target->GetCompileFeatures(features, config); + gtgt->GetCompileFeatures(features, config); for(std::vector::const_iterator it = features.begin(); it != features.end(); ++it) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 466f98a..7a23e9d 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -144,7 +144,6 @@ public: std::vector CompileOptionsBacktraces; std::vector CompileFeaturesEntries; std::vector CompileFeaturesBacktraces; - std::vector CompileFeaturesItems; std::vector CompileDefinitionsEntries; std::vector CompileDefinitionsBacktraces; std::vector CompileDefinitionsItems; @@ -176,7 +175,6 @@ cmTarget::cmTarget() this->IsApple = false; this->IsImportedTarget = false; this->BuildInterfaceIncludesAppended = false; - this->DebugCompileFeaturesDone = false; this->DebugCompileDefinitionsDone = false; this->DebugSourcesDone = false; this->LinkImplementationLanguageIsContextDependent = true; @@ -423,11 +421,6 @@ void CreatePropertyGeneratorExpressions( void cmTarget::Compute() { CreatePropertyGeneratorExpressions( - this->Internal->CompileFeaturesEntries, - this->Internal->CompileFeaturesBacktraces, - this->Internal->CompileFeaturesItems); - - CreatePropertyGeneratorExpressions( this->Internal->CompileDefinitionsEntries, this->Internal->CompileDefinitionsBacktraces, this->Internal->CompileDefinitionsItems); @@ -1326,6 +1319,16 @@ cmBacktraceRange cmTarget::GetCompileOptionsBacktraces() const return cmMakeRange(this->Internal->CompileOptionsBacktraces); } +cmStringRange cmTarget::GetCompileFeaturesEntries() const +{ + return cmMakeRange(this->Internal->CompileFeaturesEntries); +} + +cmBacktraceRange cmTarget::GetCompileFeaturesBacktraces() const +{ + return cmMakeRange(this->Internal->CompileFeaturesBacktraces); +} + #if defined(_WIN32) && !defined(__CYGWIN__) //---------------------------------------------------------------------------- void @@ -2073,73 +2076,6 @@ void cmTarget::GetCompileDefinitions(std::vector &list, } //---------------------------------------------------------------------------- -static void processCompileFeatures(cmTarget const* tgt, - const std::vector &entries, - std::vector &options, - UNORDERED_SET &uniqueOptions, - cmGeneratorExpressionDAGChecker *dagChecker, - const std::string& config, bool debugOptions) -{ - processCompileOptionsInternal(tgt, entries, options, uniqueOptions, - dagChecker, config, debugOptions, "features", - std::string()); -} - -//---------------------------------------------------------------------------- -void cmTarget::GetCompileFeatures(std::vector &result, - const std::string& config) const -{ - UNORDERED_SET uniqueFeatures; - - cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), - "COMPILE_FEATURES", - 0, 0); - - std::vector debugProperties; - const char *debugProp = - this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); - if (debugProp) - { - cmSystemTools::ExpandListArgument(debugProp, debugProperties); - } - - bool debugFeatures = !this->DebugCompileFeaturesDone - && std::find(debugProperties.begin(), - debugProperties.end(), - "COMPILE_FEATURES") - != debugProperties.end(); - - if (this->Makefile->IsConfigured()) - { - this->DebugCompileFeaturesDone = true; - } - - processCompileFeatures(this, - this->Internal->CompileFeaturesItems, - result, - uniqueFeatures, - &dagChecker, - config, - debugFeatures); - - std::vector - linkInterfaceCompileFeaturesEntries; - this->Internal->AddInterfaceEntries( - this, config, "INTERFACE_COMPILE_FEATURES", - linkInterfaceCompileFeaturesEntries); - - processCompileFeatures(this, - linkInterfaceCompileFeaturesEntries, - result, - uniqueFeatures, - &dagChecker, - config, - debugFeatures); - - cmDeleteAll(linkInterfaceCompileFeaturesEntries); -} - -//---------------------------------------------------------------------------- void cmTarget::MaybeInvalidatePropertyCache(const std::string& prop) { // Wipe out maps caching information affected by this property. @@ -4099,7 +4035,6 @@ cmTargetInternalPointer //---------------------------------------------------------------------------- cmTargetInternalPointer::~cmTargetInternalPointer() { - cmDeleteAll(this->Pointer->CompileFeaturesItems); cmDeleteAll(this->Pointer->CompileDefinitionsItems); cmDeleteAll(this->Pointer->SourceEntries); delete this->Pointer; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 05b6aec..aae558e 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -375,9 +375,6 @@ public: void AppendBuildInterfaceIncludes(); - void GetCompileFeatures(std::vector &features, - const std::string& config) const; - bool IsNullImpliedByLinkLibraries(const std::string &p) const; std::string GetDebugGeneratorExpressions(const std::string &value, @@ -402,6 +399,9 @@ public: cmStringRange GetCompileOptionsEntries() const; cmBacktraceRange GetCompileOptionsBacktraces() const; + cmStringRange GetCompileFeaturesEntries() const; + cmBacktraceRange GetCompileFeaturesBacktraces() const; + #if defined(_WIN32) && !defined(__CYGWIN__) const LinkLibraryVectorType &GetLinkLibrariesForVS6() const { return this->LinkLibrariesForVS6;} @@ -518,7 +518,6 @@ private: bool BuildInterfaceIncludesAppended; mutable bool DebugCompileDefinitionsDone; mutable bool DebugSourcesDone; - mutable bool DebugCompileFeaturesDone; mutable bool LinkImplementationLanguageIsContextDependent; #if defined(_WIN32) && !defined(__CYGWIN__) bool LinkLibrariesForVS6Analyzed; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ad1abb4b319f2f901d072338abce670276af415d commit ad1abb4b319f2f901d072338abce670276af415d Author: Stephen Kelly AuthorDate: Tue Aug 4 23:43:56 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 21:54:53 2015 +0200 cmGeneratorTarget: Move compile options processing from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c3a832d..594eb59 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -260,7 +260,8 @@ void CreatePropertyGeneratorExpressions( cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) : Target(t), SourceFileFlagsConstructed(false), - DebugIncludesDone(false) + DebugIncludesDone(false), + DebugCompileOptionsDone(false) { this->Makefile = this->Target->GetMakefile(); this->LocalGenerator = lg; @@ -270,11 +271,17 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) t->GetIncludeDirectoriesEntries(), t->GetIncludeDirectoriesBacktraces(), this->IncludeDirectoriesEntries); + + CreatePropertyGeneratorExpressions( + t->GetCompileOptionsEntries(), + t->GetCompileOptionsBacktraces(), + this->CompileOptionsEntries); } cmGeneratorTarget::~cmGeneratorTarget() { cmDeleteAll(this->IncludeDirectoriesEntries); + cmDeleteAll(this->CompileOptionsEntries); cmDeleteAll(this->LinkInformation); this->LinkInformation.clear(); } @@ -2245,6 +2252,125 @@ cmGeneratorTarget::GetIncludeDirectories(const std::string& config, } //---------------------------------------------------------------------------- +static void processCompileOptionsInternal(cmGeneratorTarget const* tgt, + const std::vector &entries, + std::vector &options, + UNORDERED_SET &uniqueOptions, + cmGeneratorExpressionDAGChecker *dagChecker, + const std::string& config, bool debugOptions, const char *logName, + std::string const& language) +{ + cmMakefile *mf = tgt->Target->GetMakefile(); + + for (std::vector::const_iterator + it = entries.begin(), end = entries.end(); it != end; ++it) + { + std::vector entryOptions; + cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf, + config, + false, + tgt->Target, + dagChecker, + language), + entryOptions); + std::string usedOptions; + for(std::vector::iterator + li = entryOptions.begin(); li != entryOptions.end(); ++li) + { + std::string const& opt = *li; + + if(uniqueOptions.insert(opt).second) + { + options.push_back(opt); + if (debugOptions) + { + usedOptions += " * " + opt + "\n"; + } + } + } + if (!usedOptions.empty()) + { + mf->GetCMakeInstance()->IssueMessage(cmake::LOG, + std::string("Used compile ") + logName + + std::string(" for target ") + + tgt->GetName() + ":\n" + + usedOptions, (*it)->ge->GetBacktrace()); + } + } +} + +//---------------------------------------------------------------------------- +static void processCompileOptions(cmGeneratorTarget const* tgt, + const std::vector &entries, + std::vector &options, + UNORDERED_SET &uniqueOptions, + cmGeneratorExpressionDAGChecker *dagChecker, + const std::string& config, bool debugOptions, + std::string const& language) +{ + processCompileOptionsInternal(tgt, entries, options, uniqueOptions, + dagChecker, config, debugOptions, "options", + language); +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GetCompileOptions(std::vector &result, + const std::string& config, + const std::string& language) const +{ + UNORDERED_SET uniqueOptions; + + cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), + "COMPILE_OPTIONS", 0, 0); + + std::vector debugProperties; + const char *debugProp = + this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); + if (debugProp) + { + cmSystemTools::ExpandListArgument(debugProp, debugProperties); + } + + bool debugOptions = !this->DebugCompileOptionsDone + && std::find(debugProperties.begin(), + debugProperties.end(), + "COMPILE_OPTIONS") + != debugProperties.end(); + + if (this->Makefile->IsConfigured()) + { + this->DebugCompileOptionsDone = true; + } + + processCompileOptions(this, + this->CompileOptionsEntries, + result, + uniqueOptions, + &dagChecker, + config, + debugOptions, + language); + + std::vector + linkInterfaceCompileOptionsEntries; + + AddInterfaceEntries( + this, config, "INTERFACE_COMPILE_OPTIONS", + linkInterfaceCompileOptionsEntries); + + processCompileOptions(this, + linkInterfaceCompileOptionsEntries, + result, + uniqueOptions, + &dagChecker, + config, + debugOptions, + language); + + cmDeleteAll(linkInterfaceCompileOptionsEntries); +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GenerateTargetManifest( const std::string& config) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 9407d1f..99dc746 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -245,6 +245,10 @@ public: std::vector GetIncludeDirectories( const std::string& config, const std::string& lang) const; + void GetCompileOptions(std::vector &result, + const std::string& config, + const std::string& language) const; + bool IsSystemIncludeDirectory(const std::string& dir, const std::string& config) const; @@ -450,8 +454,10 @@ private: mutable bool PolicyWarnedCMP0022; mutable bool DebugIncludesDone; + mutable bool DebugCompileOptionsDone; std::vector IncludeDirectoriesEntries; + std::vector CompileOptionsEntries; void ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, cmTarget const* headTarget, diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index edb644d..89515ff 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1094,6 +1094,10 @@ void cmLocalGenerator::AddCompileOptions( ) { std::string langFlagRegexVar = std::string("CMAKE_")+lang+"_FLAG_REGEX"; + + cmGeneratorTarget* gtgt = + this->GlobalGenerator->GetGeneratorTarget(target); + if(const char* langFlagRegexStr = this->Makefile->GetDefinition(langFlagRegexVar)) { @@ -1104,7 +1108,7 @@ void cmLocalGenerator::AddCompileOptions( { cmSystemTools::ParseWindowsCommandLine(targetFlags, opts); } - target->GetCompileOptions(opts, config, lang); + gtgt->GetCompileOptions(opts, config, lang); for(std::vector::const_iterator i = opts.begin(); i != opts.end(); ++i) { @@ -1125,7 +1129,7 @@ void cmLocalGenerator::AddCompileOptions( this->AppendFlags(flags, targetFlags); } std::vector opts; - target->GetCompileOptions(opts, config, lang); + gtgt->GetCompileOptions(opts, config, lang); for(std::vector::const_iterator i = opts.begin(); i != opts.end(); ++i) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index fb4241b..466f98a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -142,7 +142,6 @@ public: std::vector IncludeDirectoriesBacktraces; std::vector CompileOptionsEntries; std::vector CompileOptionsBacktraces; - std::vector CompileOptionsItems; std::vector CompileFeaturesEntries; std::vector CompileFeaturesBacktraces; std::vector CompileFeaturesItems; @@ -177,7 +176,6 @@ cmTarget::cmTarget() this->IsApple = false; this->IsImportedTarget = false; this->BuildInterfaceIncludesAppended = false; - this->DebugCompileOptionsDone = false; this->DebugCompileFeaturesDone = false; this->DebugCompileDefinitionsDone = false; this->DebugSourcesDone = false; @@ -425,11 +423,6 @@ void CreatePropertyGeneratorExpressions( void cmTarget::Compute() { CreatePropertyGeneratorExpressions( - this->Internal->CompileOptionsEntries, - this->Internal->CompileOptionsBacktraces, - this->Internal->CompileOptionsItems); - - CreatePropertyGeneratorExpressions( this->Internal->CompileFeaturesEntries, this->Internal->CompileFeaturesBacktraces, this->Internal->CompileFeaturesItems); @@ -1323,6 +1316,16 @@ cmBacktraceRange cmTarget::GetIncludeDirectoriesBacktraces() const return cmMakeRange(this->Internal->IncludeDirectoriesBacktraces); } +cmStringRange cmTarget::GetCompileOptionsEntries() const +{ + return cmMakeRange(this->Internal->CompileOptionsEntries); +} + +cmBacktraceRange cmTarget::GetCompileOptionsBacktraces() const +{ + return cmMakeRange(this->Internal->CompileOptionsBacktraces); +} + #if defined(_WIN32) && !defined(__CYGWIN__) //---------------------------------------------------------------------------- void @@ -1968,77 +1971,6 @@ static void processCompileOptionsInternal(cmTarget const* tgt, } //---------------------------------------------------------------------------- -static void processCompileOptions(cmTarget const* tgt, - const std::vector &entries, - std::vector &options, - UNORDERED_SET &uniqueOptions, - cmGeneratorExpressionDAGChecker *dagChecker, - const std::string& config, bool debugOptions, - std::string const& language) -{ - processCompileOptionsInternal(tgt, entries, options, uniqueOptions, - dagChecker, config, debugOptions, "options", - language); -} - -//---------------------------------------------------------------------------- -void cmTarget::GetCompileOptions(std::vector &result, - const std::string& config, - const std::string& language) const -{ - UNORDERED_SET uniqueOptions; - - cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), - "COMPILE_OPTIONS", 0, 0); - - std::vector debugProperties; - const char *debugProp = - this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); - if (debugProp) - { - cmSystemTools::ExpandListArgument(debugProp, debugProperties); - } - - bool debugOptions = !this->DebugCompileOptionsDone - && std::find(debugProperties.begin(), - debugProperties.end(), - "COMPILE_OPTIONS") - != debugProperties.end(); - - if (this->Makefile->IsConfigured()) - { - this->DebugCompileOptionsDone = true; - } - - processCompileOptions(this, - this->Internal->CompileOptionsItems, - result, - uniqueOptions, - &dagChecker, - config, - debugOptions, - language); - - std::vector - linkInterfaceCompileOptionsEntries; - - this->Internal->AddInterfaceEntries( - this, config, "INTERFACE_COMPILE_OPTIONS", - linkInterfaceCompileOptionsEntries); - - processCompileOptions(this, - linkInterfaceCompileOptionsEntries, - result, - uniqueOptions, - &dagChecker, - config, - debugOptions, - language); - - cmDeleteAll(linkInterfaceCompileOptionsEntries); -} - -//---------------------------------------------------------------------------- static void processCompileDefinitions(cmTarget const* tgt, const std::vector &entries, std::vector &options, @@ -4167,7 +4099,6 @@ cmTargetInternalPointer //---------------------------------------------------------------------------- cmTargetInternalPointer::~cmTargetInternalPointer() { - cmDeleteAll(this->Pointer->CompileOptionsItems); cmDeleteAll(this->Pointer->CompileFeaturesItems); cmDeleteAll(this->Pointer->CompileDefinitionsItems); cmDeleteAll(this->Pointer->SourceEntries); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 13e4f2d..05b6aec 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -375,9 +375,6 @@ public: void AppendBuildInterfaceIncludes(); - void GetCompileOptions(std::vector &result, - const std::string& config, - const std::string& language) const; void GetCompileFeatures(std::vector &features, const std::string& config) const; @@ -402,6 +399,9 @@ public: cmStringRange GetIncludeDirectoriesEntries() const; cmBacktraceRange GetIncludeDirectoriesBacktraces() const; + cmStringRange GetCompileOptionsEntries() const; + cmBacktraceRange GetCompileOptionsBacktraces() const; + #if defined(_WIN32) && !defined(__CYGWIN__) const LinkLibraryVectorType &GetLinkLibrariesForVS6() const { return this->LinkLibrariesForVS6;} @@ -516,7 +516,6 @@ private: bool IsApple; bool IsImportedTarget; bool BuildInterfaceIncludesAppended; - mutable bool DebugCompileOptionsDone; mutable bool DebugCompileDefinitionsDone; mutable bool DebugSourcesDone; mutable bool DebugCompileFeaturesDone; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=00a065a117555251d94957fb0e02e0524e17166a commit 00a065a117555251d94957fb0e02e0524e17166a Author: Stephen Kelly AuthorDate: Tue Aug 4 23:14:53 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 21:52:44 2015 +0200 cmGeneratorTarget: Move include directory processing from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 4e87a7c..c3a832d 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -34,6 +34,18 @@ #define UNORDERED_SET std::set #endif +class cmGeneratorTarget::TargetPropertyEntry { + static cmLinkImplItem NoLinkImplItem; +public: + TargetPropertyEntry(cmsys::auto_ptr cge, + cmLinkImplItem const& item = NoLinkImplItem) + : ge(cge), LinkImplItem(item) + {} + const cmsys::auto_ptr ge; + cmLinkImplItem const& LinkImplItem; +}; +cmLinkImplItem cmGeneratorTarget::TargetPropertyEntry::NoLinkImplItem; + //---------------------------------------------------------------------------- void reportBadObjLib(std::vector const& badObjLib, cmGeneratorTarget const* target, cmake *cm) @@ -227,18 +239,42 @@ struct TagVisitor } }; +void CreatePropertyGeneratorExpressions( + cmStringRange const& entries, + cmBacktraceRange const& backtraces, + std::vector& items, + bool evaluateForBuildsystem = false) +{ + std::vector::const_iterator btIt = backtraces.begin(); + for (std::vector::const_iterator it = entries.begin(); + it != entries.end(); ++it, ++btIt) + { + cmGeneratorExpression ge(*btIt); + cmsys::auto_ptr cge = ge.Parse(*it); + cge->SetEvaluateForBuildsystem(evaluateForBuildsystem); + items.push_back(new cmGeneratorTarget::TargetPropertyEntry(cge)); + } +} + //---------------------------------------------------------------------------- cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) : Target(t), - SourceFileFlagsConstructed(false) + SourceFileFlagsConstructed(false), + DebugIncludesDone(false) { this->Makefile = this->Target->GetMakefile(); this->LocalGenerator = lg; this->GlobalGenerator = this->LocalGenerator->GetGlobalGenerator(); + + CreatePropertyGeneratorExpressions( + t->GetIncludeDirectoriesEntries(), + t->GetIncludeDirectoriesBacktraces(), + this->IncludeDirectoriesEntries); } cmGeneratorTarget::~cmGeneratorTarget() { + cmDeleteAll(this->IncludeDirectoriesEntries); cmDeleteAll(this->LinkInformation); this->LinkInformation.clear(); } @@ -1964,13 +2000,248 @@ cmGeneratorTarget::GetCreateRuleVariable(std::string const& lang, } return ""; } +//---------------------------------------------------------------------------- +static void processIncludeDirectories(cmGeneratorTarget const* tgt, + const std::vector &entries, + std::vector &includes, + UNORDERED_SET &uniqueIncludes, + cmGeneratorExpressionDAGChecker *dagChecker, + const std::string& config, bool debugIncludes, + const std::string& language) +{ + cmMakefile *mf = tgt->Target->GetMakefile(); + + for (std::vector::const_iterator + it = entries.begin(), end = entries.end(); it != end; ++it) + { + cmLinkImplItem const& item = (*it)->LinkImplItem; + std::string const& targetName = item; + bool const fromImported = item.Target && item.Target->IsImported(); + bool const checkCMP0027 = item.FromGenex; + std::vector entryIncludes; + cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf, + config, + false, + tgt->Target, + dagChecker, language), + entryIncludes); + + std::string usedIncludes; + for(std::vector::iterator + li = entryIncludes.begin(); li != entryIncludes.end(); ++li) + { + if (fromImported + && !cmSystemTools::FileExists(li->c_str())) + { + std::ostringstream e; + cmake::MessageType messageType = cmake::FATAL_ERROR; + if (checkCMP0027) + { + switch(tgt->Target->GetPolicyStatusCMP0027()) + { + case cmPolicies::WARN: + e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0027) << "\n"; + case cmPolicies::OLD: + messageType = cmake::AUTHOR_WARNING; + break; + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::NEW: + break; + } + } + e << "Imported target \"" << targetName << "\" includes " + "non-existent path\n \"" << *li << "\"\nin its " + "INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:\n" + "* The path was deleted, renamed, or moved to another " + "location.\n" + "* An install or uninstall procedure did not complete " + "successfully.\n" + "* The installation package was faulty and references files it " + "does not provide.\n"; + tgt->GetLocalGenerator()->IssueMessage(messageType, e.str()); + return; + } + + if (!cmSystemTools::FileIsFullPath(li->c_str())) + { + std::ostringstream e; + bool noMessage = false; + cmake::MessageType messageType = cmake::FATAL_ERROR; + if (!targetName.empty()) + { + e << "Target \"" << targetName << "\" contains relative " + "path in its INTERFACE_INCLUDE_DIRECTORIES:\n" + " \"" << *li << "\""; + } + else + { + switch(tgt->Target->GetPolicyStatusCMP0021()) + { + case cmPolicies::WARN: + { + e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0021) << "\n"; + messageType = cmake::AUTHOR_WARNING; + } + break; + case cmPolicies::OLD: + noMessage = true; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::NEW: + // Issue the fatal message. + break; + } + e << "Found relative path while evaluating include directories of " + "\"" << tgt->GetName() << "\":\n \"" << *li << "\"\n"; + } + if (!noMessage) + { + tgt->GetLocalGenerator()->IssueMessage(messageType, e.str()); + if (messageType == cmake::FATAL_ERROR) + { + return; + } + } + } + + if (!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 (!usedIncludes.empty()) + { + mf->GetCMakeInstance()->IssueMessage(cmake::LOG, + std::string("Used includes for target ") + + tgt->GetName() + ":\n" + + usedIncludes, (*it)->ge->GetBacktrace()); + } + } +} + + +//---------------------------------------------------------------------------- +static void AddInterfaceEntries( + cmGeneratorTarget const* thisTarget, std::string const& config, + std::string const& prop, + std::vector& entries) +{ + if(cmLinkImplementationLibraries const* impl = + thisTarget->Target->GetLinkImplementationLibraries(config)) + { + for (std::vector::const_iterator + it = impl->Libraries.begin(), end = impl->Libraries.end(); + it != end; ++it) + { + if(it->Target) + { + std::string genex = + "$"; + cmGeneratorExpression ge(it->Backtrace); + cmsys::auto_ptr cge = ge.Parse(genex); + cge->SetEvaluateForBuildsystem(true); + entries.push_back( + new cmGeneratorTarget::TargetPropertyEntry(cge, *it)); + } + } + } +} //---------------------------------------------------------------------------- std::vector cmGeneratorTarget::GetIncludeDirectories(const std::string& config, const std::string& lang) const { - return this->Target->GetIncludeDirectories(config, lang); + std::vector includes; + UNORDERED_SET uniqueIncludes; + + cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), + "INCLUDE_DIRECTORIES", 0, 0); + + std::vector debugProperties; + const char *debugProp = + this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); + if (debugProp) + { + cmSystemTools::ExpandListArgument(debugProp, debugProperties); + } + + bool debugIncludes = !this->DebugIncludesDone + && std::find(debugProperties.begin(), + debugProperties.end(), + "INCLUDE_DIRECTORIES") + != debugProperties.end(); + + if (this->Makefile->IsConfigured()) + { + this->DebugIncludesDone = true; + } + + processIncludeDirectories(this, + this->IncludeDirectoriesEntries, + includes, + uniqueIncludes, + &dagChecker, + config, + debugIncludes, + lang); + + std::vector + linkInterfaceIncludeDirectoriesEntries; + AddInterfaceEntries( + this, config, "INTERFACE_INCLUDE_DIRECTORIES", + linkInterfaceIncludeDirectoriesEntries); + + if(this->Makefile->IsOn("APPLE")) + { + cmLinkImplementationLibraries const* impl = + this->Target->GetLinkImplementationLibraries(config); + for(std::vector::const_iterator + it = impl->Libraries.begin(); + it != impl->Libraries.end(); ++it) + { + std::string libDir = cmSystemTools::CollapseFullPath(*it); + + static cmsys::RegularExpression + frameworkCheck("(.*\\.framework)(/Versions/[^/]+)?/[^/]+$"); + if(!frameworkCheck.find(libDir)) + { + continue; + } + + libDir = frameworkCheck.match(1); + + cmGeneratorExpression ge; + cmsys::auto_ptr cge = + ge.Parse(libDir.c_str()); + linkInterfaceIncludeDirectoriesEntries + .push_back(new cmGeneratorTarget::TargetPropertyEntry(cge)); + } + } + + processIncludeDirectories(this, + linkInterfaceIncludeDirectoriesEntries, + includes, + uniqueIncludes, + &dagChecker, + config, + debugIncludes, + lang); + + cmDeleteAll(linkInterfaceIncludeDirectoriesEntries); + + return includes; } //---------------------------------------------------------------------------- diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 46341d3..9407d1f 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -360,6 +360,8 @@ public: const std::string &report, const std::string &compatibilityType) const; + class TargetPropertyEntry; + private: friend class cmTargetTraceDependencies; struct SourceEntry { std::vector Depends; }; @@ -447,6 +449,9 @@ private: mutable LinkInterfaceMapType LinkInterfaceUsageRequirementsOnlyMap; mutable bool PolicyWarnedCMP0022; + mutable bool DebugIncludesDone; + + std::vector IncludeDirectoriesEntries; void ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, cmTarget const* headTarget, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e941fb6..fb4241b 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -140,7 +140,6 @@ public: }; std::vector IncludeDirectoriesEntries; std::vector IncludeDirectoriesBacktraces; - std::vector IncludeDirectoriesItems; std::vector CompileOptionsEntries; std::vector CompileOptionsBacktraces; std::vector CompileOptionsItems; @@ -178,7 +177,6 @@ cmTarget::cmTarget() this->IsApple = false; this->IsImportedTarget = false; this->BuildInterfaceIncludesAppended = false; - this->DebugIncludesDone = false; this->DebugCompileOptionsDone = false; this->DebugCompileFeaturesDone = false; this->DebugCompileDefinitionsDone = false; @@ -427,11 +425,6 @@ void CreatePropertyGeneratorExpressions( void cmTarget::Compute() { CreatePropertyGeneratorExpressions( - this->Internal->IncludeDirectoriesEntries, - this->Internal->IncludeDirectoriesBacktraces, - this->Internal->IncludeDirectoriesItems); - - CreatePropertyGeneratorExpressions( this->Internal->CompileOptionsEntries, this->Internal->CompileOptionsBacktraces, this->Internal->CompileOptionsItems); @@ -1320,6 +1313,16 @@ cmTarget::AddSystemIncludeDirectories(const std::set &incs) this->SystemIncludeDirectories.insert(incs.begin(), incs.end()); } +cmStringRange cmTarget::GetIncludeDirectoriesEntries() const +{ + return cmMakeRange(this->Internal->IncludeDirectoriesEntries); +} + +cmBacktraceRange cmTarget::GetIncludeDirectoriesBacktraces() const +{ + return cmMakeRange(this->Internal->IncludeDirectoriesBacktraces); +} + #if defined(_WIN32) && !defined(__CYGWIN__) //---------------------------------------------------------------------------- void @@ -1917,222 +1920,6 @@ void cmTarget::InsertCompileDefinition(std::string const& entry, } //---------------------------------------------------------------------------- -static void processIncludeDirectories(cmTarget const* tgt, - const std::vector &entries, - std::vector &includes, - UNORDERED_SET &uniqueIncludes, - cmGeneratorExpressionDAGChecker *dagChecker, - const std::string& config, bool debugIncludes, - const std::string& language) -{ - cmMakefile *mf = tgt->GetMakefile(); - - for (std::vector::const_iterator - it = entries.begin(), end = entries.end(); it != end; ++it) - { - cmLinkImplItem const& item = (*it)->LinkImplItem; - std::string const& targetName = item; - bool const fromImported = item.Target && item.Target->IsImported(); - bool const checkCMP0027 = item.FromGenex; - std::vector entryIncludes; - cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf, - config, - false, - tgt, - dagChecker, language), - entryIncludes); - - std::string usedIncludes; - for(std::vector::iterator - li = entryIncludes.begin(); li != entryIncludes.end(); ++li) - { - if (fromImported - && !cmSystemTools::FileExists(li->c_str())) - { - std::ostringstream e; - cmake::MessageType messageType = cmake::FATAL_ERROR; - if (checkCMP0027) - { - switch(tgt->GetPolicyStatusCMP0027()) - { - case cmPolicies::WARN: - e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0027) << "\n"; - case cmPolicies::OLD: - messageType = cmake::AUTHOR_WARNING; - break; - case cmPolicies::REQUIRED_ALWAYS: - case cmPolicies::REQUIRED_IF_USED: - case cmPolicies::NEW: - break; - } - } - e << "Imported target \"" << targetName << "\" includes " - "non-existent path\n \"" << *li << "\"\nin its " - "INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:\n" - "* The path was deleted, renamed, or moved to another " - "location.\n" - "* An install or uninstall procedure did not complete " - "successfully.\n" - "* The installation package was faulty and references files it " - "does not provide.\n"; - tgt->GetMakefile()->IssueMessage(messageType, e.str()); - return; - } - - if (!cmSystemTools::FileIsFullPath(li->c_str())) - { - std::ostringstream e; - bool noMessage = false; - cmake::MessageType messageType = cmake::FATAL_ERROR; - if (!targetName.empty()) - { - e << "Target \"" << targetName << "\" contains relative " - "path in its INTERFACE_INCLUDE_DIRECTORIES:\n" - " \"" << *li << "\""; - } - else - { - switch(tgt->GetPolicyStatusCMP0021()) - { - case cmPolicies::WARN: - { - e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0021) << "\n"; - messageType = cmake::AUTHOR_WARNING; - } - break; - case cmPolicies::OLD: - noMessage = true; - case cmPolicies::REQUIRED_IF_USED: - case cmPolicies::REQUIRED_ALWAYS: - case cmPolicies::NEW: - // Issue the fatal message. - break; - } - e << "Found relative path while evaluating include directories of " - "\"" << tgt->GetName() << "\":\n \"" << *li << "\"\n"; - } - if (!noMessage) - { - tgt->GetMakefile()->IssueMessage(messageType, e.str()); - if (messageType == cmake::FATAL_ERROR) - { - return; - } - } - } - - if (!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 (!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 std::string& config, - const std::string& language) const -{ - std::vector includes; - UNORDERED_SET uniqueIncludes; - - cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), - "INCLUDE_DIRECTORIES", 0, 0); - - std::vector debugProperties; - const char *debugProp = - this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); - if (debugProp) - { - cmSystemTools::ExpandListArgument(debugProp, debugProperties); - } - - bool debugIncludes = !this->DebugIncludesDone - && std::find(debugProperties.begin(), - debugProperties.end(), - "INCLUDE_DIRECTORIES") - != debugProperties.end(); - - if (this->Makefile->IsConfigured()) - { - this->DebugIncludesDone = true; - } - - processIncludeDirectories(this, - this->Internal->IncludeDirectoriesItems, - includes, - uniqueIncludes, - &dagChecker, - config, - debugIncludes, - language); - - std::vector - linkInterfaceIncludeDirectoriesEntries; - this->Internal->AddInterfaceEntries( - this, config, "INTERFACE_INCLUDE_DIRECTORIES", - linkInterfaceIncludeDirectoriesEntries); - - if(this->Makefile->IsOn("APPLE")) - { - cmLinkImplementationLibraries const* impl = - this->GetLinkImplementationLibraries(config); - for(std::vector::const_iterator - it = impl->Libraries.begin(); - it != impl->Libraries.end(); ++it) - { - std::string libDir = cmSystemTools::CollapseFullPath(*it); - - static cmsys::RegularExpression - frameworkCheck("(.*\\.framework)(/Versions/[^/]+)?/[^/]+$"); - if(!frameworkCheck.find(libDir)) - { - continue; - } - - libDir = frameworkCheck.match(1); - - cmGeneratorExpression ge; - cmsys::auto_ptr cge = - ge.Parse(libDir.c_str()); - linkInterfaceIncludeDirectoriesEntries - .push_back(new cmTargetInternals::TargetPropertyEntry(cge)); - } - } - - processIncludeDirectories(this, - linkInterfaceIncludeDirectoriesEntries, - includes, - uniqueIncludes, - &dagChecker, - config, - debugIncludes, - language); - - cmDeleteAll(linkInterfaceIncludeDirectoriesEntries); - - return includes; -} - -//---------------------------------------------------------------------------- static void processCompileOptionsInternal(cmTarget const* tgt, const std::vector &entries, std::vector &options, @@ -4380,7 +4167,6 @@ cmTargetInternalPointer //---------------------------------------------------------------------------- cmTargetInternalPointer::~cmTargetInternalPointer() { - cmDeleteAll(this->Pointer->IncludeDirectoriesItems); cmDeleteAll(this->Pointer->CompileOptionsItems); cmDeleteAll(this->Pointer->CompileFeaturesItems); cmDeleteAll(this->Pointer->CompileDefinitionsItems); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 103a7e8..13e4f2d 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -364,9 +364,6 @@ public: /** @return whether this target have a well defined output file name. */ bool HaveWellDefinedOutputFiles() const; - std::vector GetIncludeDirectories( - const std::string& config, - const std::string& language) const; void InsertInclude(std::string const& entry, cmListFileBacktrace const& bt, bool before = false); @@ -402,6 +399,9 @@ public: return this->MaxLanguageStandards; } + cmStringRange GetIncludeDirectoriesEntries() const; + cmBacktraceRange GetIncludeDirectoriesBacktraces() const; + #if defined(_WIN32) && !defined(__CYGWIN__) const LinkLibraryVectorType &GetLinkLibrariesForVS6() const { return this->LinkLibrariesForVS6;} @@ -516,7 +516,6 @@ private: bool IsApple; bool IsImportedTarget; bool BuildInterfaceIncludesAppended; - mutable bool DebugIncludesDone; mutable bool DebugCompileOptionsDone; mutable bool DebugCompileDefinitionsDone; mutable bool DebugSourcesDone; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b4c1aeaf9ed65c8956aefd8ced6171bca05ba9fa commit b4c1aeaf9ed65c8956aefd8ced6171bca05ba9fa Author: Stephen Kelly AuthorDate: Tue Aug 4 19:22:30 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 21:51:16 2015 +0200 cmGeneratorTarget: Move link iface helpers from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index cf4019c..4e87a7c 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3363,6 +3363,51 @@ cmGeneratorTarget::ReportPropertyOrigin(const std::string &p, } //---------------------------------------------------------------------------- +void cmGeneratorTarget::LookupLinkItems(std::vector const& names, + std::vector& items) const +{ + for(std::vector::const_iterator i = names.begin(); + i != names.end(); ++i) + { + std::string name = this->Target->CheckCMP0004(*i); + if(name == this->GetName() || name.empty()) + { + continue; + } + items.push_back(cmLinkItem(name, this->Target->FindTargetToLink(name))); + } +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::ExpandLinkItems(std::string const& prop, + std::string const& value, + std::string const& config, + cmTarget const* headTarget, + bool usage_requirements_only, + std::vector& items, + bool& hadHeadSensitiveCondition) const +{ + cmGeneratorExpression ge; + cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), prop, 0, 0); + // The $ expression may be in a link interface to specify private + // link dependencies that are otherwise excluded from usage requirements. + if(usage_requirements_only) + { + dagChecker.SetTransitivePropertiesOnly(); + } + std::vector libs; + cmsys::auto_ptr cge = ge.Parse(value); + cmSystemTools::ExpandListArgument(cge->Evaluate( + this->Makefile, + config, + false, + headTarget, + this->Target, &dagChecker), libs); + this->LookupLinkItems(libs, items); + hadHeadSensitiveCondition = cge->GetHadHeadSensitiveCondition(); +} + +//---------------------------------------------------------------------------- cmGeneratorTarget::LinkInterface const* cmGeneratorTarget::GetLinkInterface( const std::string& config, cmTarget const* head) const @@ -3397,14 +3442,14 @@ cmGeneratorTarget::LinkInterface const* cmGeneratorTarget::GetLinkInterface( { iface.LibrariesDone = true; this->ComputeLinkInterfaceLibraries( - this->Target, config, iface, head, false); + config, iface, head, false); } if(!iface.AllDone) { iface.AllDone = true; if(iface.Exists) { - this->ComputeLinkInterface(this->Target, config, iface, head); + this->ComputeLinkInterface(config, iface, head); } } @@ -3450,7 +3495,7 @@ cmGeneratorTarget::GetLinkInterfaceLibraries(const std::string& config, { iface.LibrariesDone = true; this->ComputeLinkInterfaceLibraries( - this->Target, config, iface, head, usage_requirements_only); + config, iface, head, usage_requirements_only); } return iface.Exists? &iface : 0; @@ -3487,13 +3532,13 @@ cmGeneratorTarget::GetImportLinkInterface(const std::string& config, iface.AllDone = true; iface.Multiplicity = info->Multiplicity; cmSystemTools::ExpandListArgument(info->Languages, iface.Languages); - this->Target->ExpandLinkItems(info->LibrariesProp, info->Libraries, config, + this->ExpandLinkItems(info->LibrariesProp, info->Libraries, config, headTarget, usage_requirements_only, iface.Libraries, iface.HadHeadSensitiveCondition); std::vector deps; cmSystemTools::ExpandListArgument(info->SharedDeps, deps); - this->Target->LookupLinkItems(deps, iface.SharedDeps); + this->LookupLinkItems(deps, iface.SharedDeps); } return &iface; @@ -3502,7 +3547,6 @@ cmGeneratorTarget::GetImportLinkInterface(const std::string& config, //---------------------------------------------------------------------------- void cmGeneratorTarget::ComputeLinkInterfaceLibraries( - cmTarget const* thisTarget, const std::string& config, OptionalLinkInterface& iface, cmTarget const* headTarget, @@ -3523,15 +3567,15 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( // libraries and executables that export symbols. const char* explicitLibraries = 0; std::string linkIfaceProp; - if(thisTarget->GetPolicyStatusCMP0022() != cmPolicies::OLD && - thisTarget->GetPolicyStatusCMP0022() != cmPolicies::WARN) + if(this->Target->GetPolicyStatusCMP0022() != cmPolicies::OLD && + this->Target->GetPolicyStatusCMP0022() != cmPolicies::WARN) { // CMP0022 NEW behavior is to use INTERFACE_LINK_LIBRARIES. linkIfaceProp = "INTERFACE_LINK_LIBRARIES"; - explicitLibraries = thisTarget->GetProperty(linkIfaceProp); + explicitLibraries = this->Target->GetProperty(linkIfaceProp); } - else if(thisTarget->GetType() == cmTarget::SHARED_LIBRARY || - thisTarget->IsExecutableWithExports()) + else if(this->Target->GetType() == cmTarget::SHARED_LIBRARY || + this->Target->IsExecutableWithExports()) { // CMP0022 OLD behavior is to use LINK_INTERFACE_LIBRARIES if set on a // shared lib or executable. @@ -3539,30 +3583,30 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( // Lookup the per-configuration property. linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; linkIfaceProp += suffix; - explicitLibraries = thisTarget->GetProperty(linkIfaceProp); + explicitLibraries = this->Target->GetProperty(linkIfaceProp); // If not set, try the generic property. if(!explicitLibraries) { linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; - explicitLibraries = thisTarget->GetProperty(linkIfaceProp); + explicitLibraries = this->Target->GetProperty(linkIfaceProp); } } if(explicitLibraries && - thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN && + this->Target->GetPolicyStatusCMP0022() == cmPolicies::WARN && !this->PolicyWarnedCMP0022) { // Compare the explicitly set old link interface properties to the // preferred new link interface property one and warn if different. const char* newExplicitLibraries = - thisTarget->GetProperty("INTERFACE_LINK_LIBRARIES"); + this->Target->GetProperty("INTERFACE_LINK_LIBRARIES"); if (newExplicitLibraries && strcmp(newExplicitLibraries, explicitLibraries) != 0) { std::ostringstream w; w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n" - "Target \"" << thisTarget->GetName() << "\" has an " + "Target \"" << this->Target->GetName() << "\" has an " "INTERFACE_LINK_LIBRARIES property which differs from its " << linkIfaceProp << " properties." "\n" @@ -3570,7 +3614,7 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( " " << newExplicitLibraries << "\n" << linkIfaceProp << ":\n" " " << (explicitLibraries ? explicitLibraries : "(empty)") << "\n"; - thisTarget->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + this->Target->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); this->PolicyWarnedCMP0022 = true; } } @@ -3578,8 +3622,8 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( // There is no implicit link interface for executables or modules // so if none was explicitly set then there is no link interface. if(!explicitLibraries && - (thisTarget->GetType() == cmTarget::EXECUTABLE || - (thisTarget->GetType() == cmTarget::MODULE_LIBRARY))) + (this->Target->GetType() == cmTarget::EXECUTABLE || + (this->Target->GetType() == cmTarget::MODULE_LIBRARY))) { return; } @@ -3589,13 +3633,13 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( if(explicitLibraries) { // The interface libraries have been explicitly set. - thisTarget->ExpandLinkItems(linkIfaceProp, explicitLibraries, config, + this->ExpandLinkItems(linkIfaceProp, explicitLibraries, config, headTarget, usage_requirements_only, iface.Libraries, iface.HadHeadSensitiveCondition); } - else if (thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN - || thisTarget->GetPolicyStatusCMP0022() == cmPolicies::OLD) + else if (this->Target->GetPolicyStatusCMP0022() == cmPolicies::WARN + || this->Target->GetPolicyStatusCMP0022() == cmPolicies::OLD) // If CMP0022 is NEW then the plain tll signature sets the // INTERFACE_LINK_LIBRARIES, so if we get here then the project // cleared the property explicitly and we should not fall back @@ -3603,20 +3647,20 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( { // The link implementation is the default link interface. cmLinkImplementationLibraries const* impl = - thisTarget->GetLinkImplementationLibrariesInternal(config, headTarget); + this->Target->GetLinkImplementationLibrariesInternal(config, headTarget); iface.Libraries.insert(iface.Libraries.end(), impl->Libraries.begin(), impl->Libraries.end()); - if(thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN && + if(this->Target->GetPolicyStatusCMP0022() == cmPolicies::WARN && !this->PolicyWarnedCMP0022 && !usage_requirements_only) { // Compare the link implementation fallback link interface to the // preferred new link interface property and warn if different. std::vector ifaceLibs; static const std::string newProp = "INTERFACE_LINK_LIBRARIES"; - if(const char* newExplicitLibraries = thisTarget->GetProperty(newProp)) + if(const char* newExplicitLibraries = this->Target->GetProperty(newProp)) { bool hadHeadSensitiveConditionDummy = false; - thisTarget->ExpandLinkItems(newProp, newExplicitLibraries, config, + this->ExpandLinkItems(newProp, newExplicitLibraries, config, headTarget, usage_requirements_only, ifaceLibs, hadHeadSensitiveConditionDummy); } @@ -3631,7 +3675,7 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( std::ostringstream w; w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n" - "Target \"" << thisTarget->GetName() << "\" has an " + "Target \"" << this->Target->GetName() << "\" has an " "INTERFACE_LINK_LIBRARIES property. " "This should be preferred as the source of the link interface " "for this library but because CMP0022 is not set CMake is " @@ -3642,7 +3686,7 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( " " << newLibraries << "\n" "Link implementation:\n" " " << oldLibraries << "\n"; - thisTarget->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + this->Target->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); this->PolicyWarnedCMP0022 = true; } } @@ -3650,16 +3694,15 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( } //---------------------------------------------------------------------------- -void cmGeneratorTarget::ComputeLinkInterface(cmTarget const* thisTarget, - const std::string& config, +void cmGeneratorTarget::ComputeLinkInterface(const std::string& config, OptionalLinkInterface& iface, cmTarget const* headTarget) const { if(iface.ExplicitLibraries) { - if(thisTarget->GetType() == cmTarget::SHARED_LIBRARY - || thisTarget->GetType() == cmTarget::STATIC_LIBRARY - || thisTarget->GetType() == cmTarget::INTERFACE_LIBRARY) + if(this->GetType() == cmTarget::SHARED_LIBRARY + || this->GetType() == cmTarget::STATIC_LIBRARY + || this->GetType() == cmTarget::INTERFACE_LIBRARY) { // Shared libraries may have runtime implementation dependencies // on other shared libraries that are not in the interface. @@ -3669,10 +3712,10 @@ void cmGeneratorTarget::ComputeLinkInterface(cmTarget const* thisTarget, { emitted.insert(*li); } - if (thisTarget->GetType() != cmTarget::INTERFACE_LIBRARY) + if (this->GetType() != cmTarget::INTERFACE_LIBRARY) { cmTarget::LinkImplementation const* impl = - thisTarget->GetLinkImplementation(config); + this->Target->GetLinkImplementation(config); for(std::vector::const_iterator li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li) { @@ -3698,28 +3741,28 @@ void cmGeneratorTarget::ComputeLinkInterface(cmTarget const* thisTarget, } } } - else if (thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN - || thisTarget->GetPolicyStatusCMP0022() == cmPolicies::OLD) + else if (this->Target->GetPolicyStatusCMP0022() == cmPolicies::WARN + || this->Target->GetPolicyStatusCMP0022() == cmPolicies::OLD) { // The link implementation is the default link interface. cmLinkImplementationLibraries const* - impl = thisTarget->GetLinkImplementationLibrariesInternal(config, + impl = this->Target->GetLinkImplementationLibrariesInternal(config, headTarget); iface.ImplementationIsInterface = true; iface.WrongConfigLibraries = impl->WrongConfigLibraries; } - if(thisTarget->LinkLanguagePropagatesToDependents()) + if(this->Target->LinkLanguagePropagatesToDependents()) { // Targets using this archive need its language runtime libraries. if(cmTarget::LinkImplementation const* impl = - thisTarget->GetLinkImplementation(config)) + this->Target->GetLinkImplementation(config)) { iface.Languages = impl->Languages; } } - if(thisTarget->GetType() == cmTarget::STATIC_LIBRARY) + if(this->GetType() == cmTarget::STATIC_LIBRARY) { // Construct the property name suffix for this configuration. std::string suffix = "_"; @@ -3736,12 +3779,12 @@ void cmGeneratorTarget::ComputeLinkInterface(cmTarget const* thisTarget, // dependencies? std::string propName = "LINK_INTERFACE_MULTIPLICITY"; propName += suffix; - if(const char* config_reps = thisTarget->GetProperty(propName)) + if(const char* config_reps = this->Target->GetProperty(propName)) { sscanf(config_reps, "%u", &iface.Multiplicity); } else if(const char* reps = - thisTarget->GetProperty("LINK_INTERFACE_MULTIPLICITY")) + this->Target->GetProperty("LINK_INTERFACE_MULTIPLICITY")) { sscanf(reps, "%u", &iface.Multiplicity); } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index e0d3425..46341d3 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -431,12 +431,10 @@ private: bool HadHeadSensitiveCondition; const char* ExplicitLibraries; }; - void ComputeLinkInterface(cmTarget const* thisTarget, - const std::string& config, + void ComputeLinkInterface(const std::string& config, OptionalLinkInterface& iface, cmTarget const* head) const; - void ComputeLinkInterfaceLibraries(cmTarget const* thisTarget, - const std::string& config, + void ComputeLinkInterfaceLibraries(const std::string& config, OptionalLinkInterface& iface, cmTarget const* head, bool usage_requirements_only) const; @@ -450,6 +448,14 @@ private: mutable bool PolicyWarnedCMP0022; + void ExpandLinkItems(std::string const& prop, std::string const& value, + std::string const& config, cmTarget const* headTarget, + bool usage_requirements_only, + std::vector& items, + bool& hadHeadSensitiveCondition) const; + void LookupLinkItems(std::vector const& names, + std::vector& items) const; + typedef std::pair OutputNameKey; typedef std::map OutputNameMapType; mutable OutputNameMapType OutputNameMap; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index aa60311..e941fb6 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3062,51 +3062,6 @@ bool cmTarget::GetPropertyAsBool(const std::string& prop) const } //---------------------------------------------------------------------------- -void cmTarget::ExpandLinkItems(std::string const& prop, - std::string const& value, - std::string const& config, - cmTarget const* headTarget, - bool usage_requirements_only, - std::vector& items, - bool& hadHeadSensitiveCondition) const -{ - cmGeneratorExpression ge; - cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), prop, 0, 0); - // The $ expression may be in a link interface to specify private - // link dependencies that are otherwise excluded from usage requirements. - if(usage_requirements_only) - { - dagChecker.SetTransitivePropertiesOnly(); - } - std::vector libs; - cmsys::auto_ptr cge = ge.Parse(value); - cmSystemTools::ExpandListArgument(cge->Evaluate( - this->Makefile, - config, - false, - headTarget, - this, &dagChecker), libs); - this->LookupLinkItems(libs, items); - hadHeadSensitiveCondition = cge->GetHadHeadSensitiveCondition(); -} - -//---------------------------------------------------------------------------- -void cmTarget::LookupLinkItems(std::vector const& names, - std::vector& items) const -{ - for(std::vector::const_iterator i = names.begin(); - i != names.end(); ++i) - { - std::string name = this->CheckCMP0004(*i); - if(name == this->GetName() || name.empty()) - { - continue; - } - items.push_back(cmLinkItem(name, this->FindTargetToLink(name))); - } -} - -//---------------------------------------------------------------------------- const char* cmTarget::GetSuffixVariableInternal(bool implib) const { switch(this->GetType()) diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 25de6a6..103a7e8 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -558,14 +558,6 @@ private: GetLinkImplementationLibrariesInternal(const std::string& config, cmTarget const* head) const; - void ExpandLinkItems(std::string const& prop, std::string const& value, - std::string const& config, cmTarget const* headTarget, - bool usage_requirements_only, - std::vector& items, - bool& hadHeadSensitiveCondition) const; - void LookupLinkItems(std::vector const& names, - std::vector& items) const; - std::string ProcessSourceItemCMP0049(const std::string& s); void ClearLinkMaps(); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ef4a3106b217aad59dd969349d835617d926ae47 commit ef4a3106b217aad59dd969349d835617d926ae47 Author: Stephen Kelly AuthorDate: Tue Aug 4 19:22:30 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 21:51:16 2015 +0200 cmGeneratorTarget: Move GetLinkInterface from cmTarget. diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 59590fd..87d96e3 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -361,8 +361,9 @@ void cmComputeLinkDepends::FollowLinkEntry(BFSEntry const& qe) if(entry.Target) { // Follow the target dependencies. - if(cmTarget::LinkInterface const* iface = - entry.Target->GetLinkInterface(this->Config, this->Target->Target)) + cmGeneratorTarget* gtgt = this->GlobalGenerator->GetGeneratorTarget(entry.Target); + if(cmGeneratorTarget::LinkInterface const* iface = + gtgt->GetLinkInterface(this->Config, this->Target->Target)) { const bool isIface = entry.Target->GetType() == cmTarget::INTERFACE_LIBRARY; @@ -396,7 +397,8 @@ void cmComputeLinkDepends::FollowLinkEntry(BFSEntry const& qe) //---------------------------------------------------------------------------- void cmComputeLinkDepends -::FollowSharedDeps(int depender_index, cmTarget::LinkInterface const* iface, +::FollowSharedDeps(int depender_index, + cmGeneratorTarget::LinkInterface const* iface, bool follow_interface) { // Follow dependencies if we have not followed them already. @@ -459,8 +461,10 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep) // Target items may have their own dependencies. if(entry.Target) { - if(cmTarget::LinkInterface const* iface = - entry.Target->GetLinkInterface(this->Config, this->Target->Target)) + cmGeneratorTarget* gtgt = + this->GlobalGenerator->GetGeneratorTarget(entry.Target); + if(cmGeneratorTarget::LinkInterface const* iface = + gtgt->GetLinkInterface(this->Config, this->Target->Target)) { // Follow public and private dependencies transitively. this->FollowSharedDeps(index, iface, true); @@ -930,8 +934,10 @@ int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl) { if(cmTarget const* target = this->EntryList[*ni].Target) { - if(cmTarget::LinkInterface const* iface = - target->GetLinkInterface(this->Config, this->Target->Target)) + cmGeneratorTarget* gtgt = + this->GlobalGenerator->GetGeneratorTarget(target); + if(cmGeneratorTarget::LinkInterface const* iface = + gtgt->GetLinkInterface(this->Config, this->Target->Target)) { if(iface->Multiplicity > count) { diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index b925a4f..e61175a 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -13,6 +13,7 @@ #define cmComputeLinkDepends_h #include "cmStandardIncludes.h" +#include "cmGeneratorTarget.h" #include "cmTarget.h" #include "cmGraphAdjacencyList.h" @@ -22,8 +23,6 @@ class cmComputeComponentGraph; class cmGlobalGenerator; class cmMakefile; -class cmGeneratorTarget; -class cmTarget; class cmake; /** \class cmComputeLinkDepends @@ -102,7 +101,7 @@ private: std::queue SharedDepQueue; std::set SharedDepFollowed; void FollowSharedDeps(int depender_index, - cmTarget::LinkInterface const* iface, + cmGeneratorTarget::LinkInterface const* iface, bool follow_interface = false); void QueueSharedDependencies(int depender_index, std::vector const& deps); diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index c4a03a0..fd4b567 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -296,8 +296,8 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, std::set &emitted) { cmGeneratorTarget const* depender = this->Targets[depender_index]; - if(cmTarget::LinkInterface const* iface = - dependee->Target->GetLinkInterface(config, + if(cmGeneratorTarget::LinkInterface const* iface = + dependee->GetLinkInterface(config, depender->Target)) { for(std::vector::const_iterator diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index cae60b7..97eb6b9 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -796,7 +796,7 @@ cmExportFileGenerator std::vector& missingTargets) { // Add the transitive link dependencies for this configuration. - cmTarget::LinkInterface const* iface = target->Target->GetLinkInterface( + cmGeneratorTarget::LinkInterface const* iface = target->GetLinkInterface( config, target->Target); if (!iface) @@ -909,9 +909,8 @@ cmExportFileGenerator } // Add the transitive link dependencies for this configuration. - if(cmTarget::LinkInterface const* iface = - target->Target - ->GetLinkInterface(config, target->Target)) + if(cmGeneratorTarget::LinkInterface const* iface = + target->GetLinkInterface(config, target->Target)) { this->SetImportLinkProperty(suffix, target, "IMPORTED_LINK_INTERFACE_LANGUAGES", diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 03bc83a..b957379 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1108,8 +1108,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode if(isInterfaceProperty) { - if(cmTarget::LinkInterfaceLibraries const* iface = - target->GetLinkInterfaceLibraries(context->Config, headTarget, true)) + if(cmGeneratorTarget::LinkInterfaceLibraries const* iface = + gtgt->GetLinkInterfaceLibraries(context->Config, headTarget, true)) { linkedTargetsContent = getLinkedTargetsContent(iface->Libraries, target, diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index dd58e7b..cf4019c 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1173,8 +1173,11 @@ public: return; } - cmTarget::LinkInterface const* iface = - item.Target->GetLinkInterface(this->Config, this->HeadTarget); + cmGeneratorTarget* gtgt = + this->Target->GetLocalGenerator()->GetGlobalGenerator() + ->GetGeneratorTarget(item.Target); + cmGeneratorTarget::LinkInterface const* iface = + gtgt->GetLinkInterface(this->Config, this->HeadTarget); if(!iface) { return; } for(std::vector::const_iterator @@ -1505,20 +1508,22 @@ void cmGeneratorTarget::GetAutoUicOptions(std::vector &result, void processILibs(const std::string& config, cmTarget const* headTarget, cmLinkItem const& item, + cmGlobalGenerator* gg, std::vector& tgts, std::set& emitted) { if (item.Target && emitted.insert(item.Target).second) { tgts.push_back(item.Target); - if(cmTarget::LinkInterfaceLibraries const* iface = - item.Target->GetLinkInterfaceLibraries(config, headTarget, true)) + cmGeneratorTarget* gt = gg->GetGeneratorTarget(item.Target); + if(cmGeneratorTarget::LinkInterfaceLibraries const* iface = + gt->GetLinkInterfaceLibraries(config, headTarget, true)) { for(std::vector::const_iterator it = iface->Libraries.begin(); it != iface->Libraries.end(); ++it) { - processILibs(config, headTarget, *it, tgts, emitted); + processILibs(config, headTarget, *it, gg, tgts, emitted); } } } @@ -1543,7 +1548,9 @@ cmGeneratorTarget::GetLinkImplementationClosure( it = impl->Libraries.begin(); it != impl->Libraries.end(); ++it) { - processILibs(config, this->Target, *it, tgts , emitted); + processILibs(config, this->Target, *it, + this->LocalGenerator->GetGlobalGenerator(), + tgts, emitted); } } return tgts; @@ -3354,3 +3361,389 @@ cmGeneratorTarget::ReportPropertyOrigin(const std::string &p, this->Makefile->GetCMakeInstance()->IssueMessage(cmake::LOG, areport); } + +//---------------------------------------------------------------------------- +cmGeneratorTarget::LinkInterface const* cmGeneratorTarget::GetLinkInterface( + const std::string& config, + cmTarget const* head) const +{ + // Imported targets have their own link interface. + if(this->Target->IsImported()) + { + return this->GetImportLinkInterface(config, head, false); + } + + // Link interfaces are not supported for executables that do not + // export symbols. + if(this->GetType() == cmTarget::EXECUTABLE && + !this->Target->IsExecutableWithExports()) + { + return 0; + } + + // Lookup any existing link interface for this configuration. + std::string CONFIG = cmSystemTools::UpperCase(config); + HeadToLinkInterfaceMap& hm = this->LinkInterfaceMap[CONFIG]; + + // If the link interface does not depend on the head target + // then return the one we computed first. + if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) + { + return &hm.begin()->second; + } + + OptionalLinkInterface& iface = hm[head]; + if(!iface.LibrariesDone) + { + iface.LibrariesDone = true; + this->ComputeLinkInterfaceLibraries( + this->Target, config, iface, head, false); + } + if(!iface.AllDone) + { + iface.AllDone = true; + if(iface.Exists) + { + this->ComputeLinkInterface(this->Target, config, iface, head); + } + } + + return iface.Exists? &iface : 0; +} + +//---------------------------------------------------------------------------- +cmGeneratorTarget::LinkInterfaceLibraries const* +cmGeneratorTarget::GetLinkInterfaceLibraries(const std::string& config, + cmTarget const* head, + bool usage_requirements_only) const +{ + // Imported targets have their own link interface. + if(this->Target->IsImported()) + { + return this->GetImportLinkInterface(config, head, usage_requirements_only); + } + + // Link interfaces are not supported for executables that do not + // export symbols. + if(this->GetType() == cmTarget::EXECUTABLE && + !this->Target->IsExecutableWithExports()) + { + return 0; + } + + // Lookup any existing link interface for this configuration. + std::string CONFIG = cmSystemTools::UpperCase(config); + HeadToLinkInterfaceMap& hm = + (usage_requirements_only ? + this->LinkInterfaceUsageRequirementsOnlyMap[CONFIG] : + this->LinkInterfaceMap[CONFIG]); + + // If the link interface does not depend on the head target + // then return the one we computed first. + if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) + { + return &hm.begin()->second; + } + + OptionalLinkInterface& iface = hm[head]; + if(!iface.LibrariesDone) + { + iface.LibrariesDone = true; + this->ComputeLinkInterfaceLibraries( + this->Target, config, iface, head, usage_requirements_only); + } + + return iface.Exists? &iface : 0; +} + +//---------------------------------------------------------------------------- +cmGeneratorTarget::LinkInterface const* +cmGeneratorTarget::GetImportLinkInterface(const std::string& config, + cmTarget const* headTarget, + bool usage_requirements_only) const +{ + cmTarget::ImportInfo const* info = this->Target->GetImportInfo(config); + if(!info) + { + return 0; + } + + std::string CONFIG = cmSystemTools::UpperCase(config); + HeadToLinkInterfaceMap& hm = + (usage_requirements_only ? + this->LinkInterfaceUsageRequirementsOnlyMap[CONFIG] : + this->LinkInterfaceMap[CONFIG]); + + // If the link interface does not depend on the head target + // then return the one we computed first. + if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) + { + return &hm.begin()->second; + } + + OptionalLinkInterface& iface = hm[headTarget]; + if(!iface.AllDone) + { + iface.AllDone = true; + iface.Multiplicity = info->Multiplicity; + cmSystemTools::ExpandListArgument(info->Languages, iface.Languages); + this->Target->ExpandLinkItems(info->LibrariesProp, info->Libraries, config, + headTarget, usage_requirements_only, + iface.Libraries, + iface.HadHeadSensitiveCondition); + std::vector deps; + cmSystemTools::ExpandListArgument(info->SharedDeps, deps); + this->Target->LookupLinkItems(deps, iface.SharedDeps); + } + + return &iface; +} + +//---------------------------------------------------------------------------- +void +cmGeneratorTarget::ComputeLinkInterfaceLibraries( + cmTarget const* thisTarget, + const std::string& config, + OptionalLinkInterface& iface, + cmTarget const* headTarget, + bool usage_requirements_only) const +{ + // Construct the property name suffix for this configuration. + std::string suffix = "_"; + if(!config.empty()) + { + suffix += cmSystemTools::UpperCase(config); + } + else + { + suffix += "NOCONFIG"; + } + + // An explicit list of interface libraries may be set for shared + // libraries and executables that export symbols. + const char* explicitLibraries = 0; + std::string linkIfaceProp; + if(thisTarget->GetPolicyStatusCMP0022() != cmPolicies::OLD && + thisTarget->GetPolicyStatusCMP0022() != cmPolicies::WARN) + { + // CMP0022 NEW behavior is to use INTERFACE_LINK_LIBRARIES. + linkIfaceProp = "INTERFACE_LINK_LIBRARIES"; + explicitLibraries = thisTarget->GetProperty(linkIfaceProp); + } + else if(thisTarget->GetType() == cmTarget::SHARED_LIBRARY || + thisTarget->IsExecutableWithExports()) + { + // CMP0022 OLD behavior is to use LINK_INTERFACE_LIBRARIES if set on a + // shared lib or executable. + + // Lookup the per-configuration property. + linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; + linkIfaceProp += suffix; + explicitLibraries = thisTarget->GetProperty(linkIfaceProp); + + // If not set, try the generic property. + if(!explicitLibraries) + { + linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; + explicitLibraries = thisTarget->GetProperty(linkIfaceProp); + } + } + + if(explicitLibraries && + thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN && + !this->PolicyWarnedCMP0022) + { + // Compare the explicitly set old link interface properties to the + // preferred new link interface property one and warn if different. + const char* newExplicitLibraries = + thisTarget->GetProperty("INTERFACE_LINK_LIBRARIES"); + if (newExplicitLibraries + && strcmp(newExplicitLibraries, explicitLibraries) != 0) + { + std::ostringstream w; + w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n" + "Target \"" << thisTarget->GetName() << "\" has an " + "INTERFACE_LINK_LIBRARIES property which differs from its " << + linkIfaceProp << " properties." + "\n" + "INTERFACE_LINK_LIBRARIES:\n" + " " << newExplicitLibraries << "\n" << + linkIfaceProp << ":\n" + " " << (explicitLibraries ? explicitLibraries : "(empty)") << "\n"; + thisTarget->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + this->PolicyWarnedCMP0022 = true; + } + } + + // There is no implicit link interface for executables or modules + // so if none was explicitly set then there is no link interface. + if(!explicitLibraries && + (thisTarget->GetType() == cmTarget::EXECUTABLE || + (thisTarget->GetType() == cmTarget::MODULE_LIBRARY))) + { + return; + } + iface.Exists = true; + iface.ExplicitLibraries = explicitLibraries; + + if(explicitLibraries) + { + // The interface libraries have been explicitly set. + thisTarget->ExpandLinkItems(linkIfaceProp, explicitLibraries, config, + headTarget, usage_requirements_only, + iface.Libraries, + iface.HadHeadSensitiveCondition); + } + else if (thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN + || thisTarget->GetPolicyStatusCMP0022() == cmPolicies::OLD) + // If CMP0022 is NEW then the plain tll signature sets the + // INTERFACE_LINK_LIBRARIES, so if we get here then the project + // cleared the property explicitly and we should not fall back + // to the link implementation. + { + // The link implementation is the default link interface. + cmLinkImplementationLibraries const* impl = + thisTarget->GetLinkImplementationLibrariesInternal(config, headTarget); + iface.Libraries.insert(iface.Libraries.end(), + impl->Libraries.begin(), impl->Libraries.end()); + if(thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN && + !this->PolicyWarnedCMP0022 && !usage_requirements_only) + { + // Compare the link implementation fallback link interface to the + // preferred new link interface property and warn if different. + std::vector ifaceLibs; + static const std::string newProp = "INTERFACE_LINK_LIBRARIES"; + if(const char* newExplicitLibraries = thisTarget->GetProperty(newProp)) + { + bool hadHeadSensitiveConditionDummy = false; + thisTarget->ExpandLinkItems(newProp, newExplicitLibraries, config, + headTarget, usage_requirements_only, + ifaceLibs, hadHeadSensitiveConditionDummy); + } + if (ifaceLibs != iface.Libraries) + { + std::string oldLibraries = cmJoin(impl->Libraries, ";"); + std::string newLibraries = cmJoin(ifaceLibs, ";"); + if(oldLibraries.empty()) + { oldLibraries = "(empty)"; } + if(newLibraries.empty()) + { newLibraries = "(empty)"; } + + std::ostringstream w; + w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n" + "Target \"" << thisTarget->GetName() << "\" has an " + "INTERFACE_LINK_LIBRARIES property. " + "This should be preferred as the source of the link interface " + "for this library but because CMP0022 is not set CMake is " + "ignoring the property and using the link implementation " + "as the link interface instead." + "\n" + "INTERFACE_LINK_LIBRARIES:\n" + " " << newLibraries << "\n" + "Link implementation:\n" + " " << oldLibraries << "\n"; + thisTarget->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + this->PolicyWarnedCMP0022 = true; + } + } + } +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::ComputeLinkInterface(cmTarget const* thisTarget, + const std::string& config, + OptionalLinkInterface& iface, + cmTarget const* headTarget) const +{ + if(iface.ExplicitLibraries) + { + if(thisTarget->GetType() == cmTarget::SHARED_LIBRARY + || thisTarget->GetType() == cmTarget::STATIC_LIBRARY + || thisTarget->GetType() == cmTarget::INTERFACE_LIBRARY) + { + // Shared libraries may have runtime implementation dependencies + // on other shared libraries that are not in the interface. + UNORDERED_SET emitted; + for(std::vector::const_iterator + li = iface.Libraries.begin(); li != iface.Libraries.end(); ++li) + { + emitted.insert(*li); + } + if (thisTarget->GetType() != cmTarget::INTERFACE_LIBRARY) + { + cmTarget::LinkImplementation const* impl = + thisTarget->GetLinkImplementation(config); + for(std::vector::const_iterator + li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li) + { + if(emitted.insert(*li).second) + { + if(li->Target) + { + // This is a runtime dependency on another shared library. + if(li->Target->GetType() == cmTarget::SHARED_LIBRARY) + { + iface.SharedDeps.push_back(*li); + } + } + else + { + // TODO: Recognize shared library file names. Perhaps this + // should be moved to cmComputeLinkInformation, but that creates + // a chicken-and-egg problem since this list is needed for its + // construction. + } + } + } + } + } + } + else if (thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN + || thisTarget->GetPolicyStatusCMP0022() == cmPolicies::OLD) + { + // The link implementation is the default link interface. + cmLinkImplementationLibraries const* + impl = thisTarget->GetLinkImplementationLibrariesInternal(config, + headTarget); + iface.ImplementationIsInterface = true; + iface.WrongConfigLibraries = impl->WrongConfigLibraries; + } + + if(thisTarget->LinkLanguagePropagatesToDependents()) + { + // Targets using this archive need its language runtime libraries. + if(cmTarget::LinkImplementation const* impl = + thisTarget->GetLinkImplementation(config)) + { + iface.Languages = impl->Languages; + } + } + + if(thisTarget->GetType() == cmTarget::STATIC_LIBRARY) + { + // Construct the property name suffix for this configuration. + std::string suffix = "_"; + if(!config.empty()) + { + suffix += cmSystemTools::UpperCase(config); + } + else + { + suffix += "NOCONFIG"; + } + + // How many repetitions are needed if this library has cyclic + // dependencies? + std::string propName = "LINK_INTERFACE_MULTIPLICITY"; + propName += suffix; + if(const char* config_reps = thisTarget->GetProperty(propName)) + { + sscanf(config_reps, "%u", &iface.Multiplicity); + } + else if(const char* reps = + thisTarget->GetProperty("LINK_INTERFACE_MULTIPLICITY")) + { + sscanf(reps, "%u", &iface.Multiplicity); + } + } +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 15b3335..e0d3425 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -13,6 +13,7 @@ #define cmGeneratorTarget_h #include "cmStandardIncludes.h" +#include "cmLinkItem.h" class cmCustomCommand; class cmGlobalGenerator; @@ -106,6 +107,48 @@ public: const char *GetLinkInterfaceDependentNumberMaxProperty(const std::string &p, const std::string& config) const; + /** The link interface specifies transitive library dependencies and + other information needed by targets that link to this target. */ + struct LinkInterfaceLibraries + { + // Libraries listed in the interface. + std::vector Libraries; + }; + + struct LinkInterface: public LinkInterfaceLibraries + { + // Languages whose runtime libraries must be linked. + std::vector Languages; + + // Shared library dependencies needed for linking on some platforms. + std::vector SharedDeps; + + // Number of repetitions of a strongly connected component of two + // or more static libraries. + int Multiplicity; + + // Libraries listed for other configurations. + // Needed only for OLD behavior of CMP0003. + std::vector WrongConfigLibraries; + + bool ImplementationIsInterface; + + LinkInterface(): Multiplicity(0), ImplementationIsInterface(false) {} + }; + + /** Get the link interface for the given configuration. Returns 0 + if the target cannot be linked. */ + LinkInterface const* GetLinkInterface(const std::string& config, + cmTarget const* headTarget) const; + + LinkInterface const* + GetImportLinkInterface(const std::string& config, cmTarget const* head, + bool usage_requirements_only) const; + + LinkInterfaceLibraries const* + GetLinkInterfaceLibraries(const std::string& config, + cmTarget const* headTarget, + bool usage_requirements_only) const; /** Get the full path to the target according to the settings in its makefile and the configuration type. */ @@ -375,6 +418,38 @@ private: }; mutable std::map LinkImplClosureMap; + // Cache link interface computation from each configuration. + struct OptionalLinkInterface: public LinkInterface + { + OptionalLinkInterface(): + LibrariesDone(false), AllDone(false), + Exists(false), HadHeadSensitiveCondition(false), + ExplicitLibraries(0) {} + bool LibrariesDone; + bool AllDone; + bool Exists; + bool HadHeadSensitiveCondition; + const char* ExplicitLibraries; + }; + void ComputeLinkInterface(cmTarget const* thisTarget, + const std::string& config, + OptionalLinkInterface& iface, + cmTarget const* head) const; + void ComputeLinkInterfaceLibraries(cmTarget const* thisTarget, + const std::string& config, + OptionalLinkInterface& iface, + cmTarget const* head, + bool usage_requirements_only) const; + + struct HeadToLinkInterfaceMap: + public std::map {}; + typedef std::map + LinkInterfaceMapType; + mutable LinkInterfaceMapType LinkInterfaceMap; + mutable LinkInterfaceMapType LinkInterfaceUsageRequirementsOnlyMap; + + mutable bool PolicyWarnedCMP0022; + typedef std::pair OutputNameKey; typedef std::map OutputNameMapType; mutable OutputNameMapType OutputNameMap; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 49b3239..aa60311 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -77,13 +77,11 @@ public: cmTargetInternals() : Backtrace() { - this->PolicyWarnedCMP0022 = false; this->UtilityItemsDone = false; } cmTargetInternals(cmTargetInternals const&) : Backtrace() { - this->PolicyWarnedCMP0022 = false; this->UtilityItemsDone = false; } ~cmTargetInternals(); @@ -91,36 +89,6 @@ public: // The backtrace when the target was created. cmListFileBacktrace Backtrace; - // Cache link interface computation from each configuration. - struct OptionalLinkInterface: public cmTarget::LinkInterface - { - OptionalLinkInterface(): - LibrariesDone(false), AllDone(false), - Exists(false), HadHeadSensitiveCondition(false), - ExplicitLibraries(0) {} - bool LibrariesDone; - bool AllDone; - bool Exists; - bool HadHeadSensitiveCondition; - const char* ExplicitLibraries; - }; - void ComputeLinkInterface(cmTarget const* thisTarget, - const std::string& config, - OptionalLinkInterface& iface, - cmTarget const* head) const; - void ComputeLinkInterfaceLibraries(cmTarget const* thisTarget, - const std::string& config, - OptionalLinkInterface& iface, - cmTarget const* head, - bool usage_requirements_only); - - struct HeadToLinkInterfaceMap: - public std::map {}; - typedef std::map - LinkInterfaceMapType; - LinkInterfaceMapType LinkInterfaceMap; - LinkInterfaceMapType LinkInterfaceUsageRequirementsOnlyMap; - bool PolicyWarnedCMP0022; typedef std::map OutputInfoMapType; OutputInfoMapType OutputInfoMap; @@ -538,8 +506,6 @@ void cmTarget::ClearLinkMaps() { this->LinkImplementationLanguageIsContextDependent = true; this->Internal->LinkImplMap.clear(); - this->Internal->LinkInterfaceMap.clear(); - this->Internal->LinkInterfaceUsageRequirementsOnlyMap.clear(); this->Internal->SourceFilesMap.clear(); } @@ -4133,393 +4099,6 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, } //---------------------------------------------------------------------------- -cmTarget::LinkInterface const* cmTarget::GetLinkInterface( - const std::string& config, - cmTarget const* head) const -{ - // Imported targets have their own link interface. - if(this->IsImported()) - { - return this->GetImportLinkInterface(config, head, false); - } - - // Link interfaces are not supported for executables that do not - // export symbols. - if(this->GetType() == cmTarget::EXECUTABLE && - !this->IsExecutableWithExports()) - { - return 0; - } - - // Lookup any existing link interface for this configuration. - std::string CONFIG = cmSystemTools::UpperCase(config); - cmTargetInternals::HeadToLinkInterfaceMap& hm = - this->Internal->LinkInterfaceMap[CONFIG]; - - // If the link interface does not depend on the head target - // then return the one we computed first. - if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) - { - return &hm.begin()->second; - } - - cmTargetInternals::OptionalLinkInterface& iface = hm[head]; - if(!iface.LibrariesDone) - { - iface.LibrariesDone = true; - this->Internal->ComputeLinkInterfaceLibraries( - this, config, iface, head, false); - } - if(!iface.AllDone) - { - iface.AllDone = true; - if(iface.Exists) - { - this->Internal->ComputeLinkInterface(this, config, iface, head); - } - } - - return iface.Exists? &iface : 0; -} - -//---------------------------------------------------------------------------- -cmTarget::LinkInterfaceLibraries const* -cmTarget::GetLinkInterfaceLibraries(const std::string& config, - cmTarget const* head, - bool usage_requirements_only) const -{ - // Imported targets have their own link interface. - if(this->IsImported()) - { - return this->GetImportLinkInterface(config, head, usage_requirements_only); - } - - // Link interfaces are not supported for executables that do not - // export symbols. - if(this->GetType() == cmTarget::EXECUTABLE && - !this->IsExecutableWithExports()) - { - return 0; - } - - // Lookup any existing link interface for this configuration. - std::string CONFIG = cmSystemTools::UpperCase(config); - cmTargetInternals::HeadToLinkInterfaceMap& hm = - (usage_requirements_only ? - this->Internal->LinkInterfaceUsageRequirementsOnlyMap[CONFIG] : - this->Internal->LinkInterfaceMap[CONFIG]); - - // If the link interface does not depend on the head target - // then return the one we computed first. - if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) - { - return &hm.begin()->second; - } - - cmTargetInternals::OptionalLinkInterface& iface = hm[head]; - if(!iface.LibrariesDone) - { - iface.LibrariesDone = true; - this->Internal->ComputeLinkInterfaceLibraries( - this, config, iface, head, usage_requirements_only); - } - - return iface.Exists? &iface : 0; -} - -//---------------------------------------------------------------------------- -cmTarget::LinkInterface const* -cmTarget::GetImportLinkInterface(const std::string& config, - cmTarget const* headTarget, - bool usage_requirements_only) const -{ - cmTarget::ImportInfo const* info = this->GetImportInfo(config); - if(!info) - { - return 0; - } - - std::string CONFIG = cmSystemTools::UpperCase(config); - cmTargetInternals::HeadToLinkInterfaceMap& hm = - (usage_requirements_only ? - this->Internal->LinkInterfaceUsageRequirementsOnlyMap[CONFIG] : - this->Internal->LinkInterfaceMap[CONFIG]); - - // If the link interface does not depend on the head target - // then return the one we computed first. - if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) - { - return &hm.begin()->second; - } - - cmTargetInternals::OptionalLinkInterface& iface = hm[headTarget]; - if(!iface.AllDone) - { - iface.AllDone = true; - iface.Multiplicity = info->Multiplicity; - cmSystemTools::ExpandListArgument(info->Languages, iface.Languages); - this->ExpandLinkItems(info->LibrariesProp, info->Libraries, config, - headTarget, usage_requirements_only, - iface.Libraries, - iface.HadHeadSensitiveCondition); - std::vector deps; - cmSystemTools::ExpandListArgument(info->SharedDeps, deps); - this->LookupLinkItems(deps, iface.SharedDeps); - } - - return &iface; -} - -//---------------------------------------------------------------------------- -void -cmTargetInternals::ComputeLinkInterfaceLibraries( - cmTarget const* thisTarget, - const std::string& config, - OptionalLinkInterface& iface, - cmTarget const* headTarget, - bool usage_requirements_only) -{ - // Construct the property name suffix for this configuration. - std::string suffix = "_"; - if(!config.empty()) - { - suffix += cmSystemTools::UpperCase(config); - } - else - { - suffix += "NOCONFIG"; - } - - // An explicit list of interface libraries may be set for shared - // libraries and executables that export symbols. - const char* explicitLibraries = 0; - std::string linkIfaceProp; - if(thisTarget->GetPolicyStatusCMP0022() != cmPolicies::OLD && - thisTarget->GetPolicyStatusCMP0022() != cmPolicies::WARN) - { - // CMP0022 NEW behavior is to use INTERFACE_LINK_LIBRARIES. - linkIfaceProp = "INTERFACE_LINK_LIBRARIES"; - explicitLibraries = thisTarget->GetProperty(linkIfaceProp); - } - else if(thisTarget->GetType() == cmTarget::SHARED_LIBRARY || - thisTarget->IsExecutableWithExports()) - { - // CMP0022 OLD behavior is to use LINK_INTERFACE_LIBRARIES if set on a - // shared lib or executable. - - // Lookup the per-configuration property. - linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; - linkIfaceProp += suffix; - explicitLibraries = thisTarget->GetProperty(linkIfaceProp); - - // If not set, try the generic property. - if(!explicitLibraries) - { - linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; - explicitLibraries = thisTarget->GetProperty(linkIfaceProp); - } - } - - if(explicitLibraries && - thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN && - !this->PolicyWarnedCMP0022) - { - // Compare the explicitly set old link interface properties to the - // preferred new link interface property one and warn if different. - const char* newExplicitLibraries = - thisTarget->GetProperty("INTERFACE_LINK_LIBRARIES"); - if (newExplicitLibraries - && strcmp(newExplicitLibraries, explicitLibraries) != 0) - { - std::ostringstream w; - w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n" - "Target \"" << thisTarget->GetName() << "\" has an " - "INTERFACE_LINK_LIBRARIES property which differs from its " << - linkIfaceProp << " properties." - "\n" - "INTERFACE_LINK_LIBRARIES:\n" - " " << newExplicitLibraries << "\n" << - linkIfaceProp << ":\n" - " " << (explicitLibraries ? explicitLibraries : "(empty)") << "\n"; - thisTarget->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); - this->PolicyWarnedCMP0022 = true; - } - } - - // There is no implicit link interface for executables or modules - // so if none was explicitly set then there is no link interface. - if(!explicitLibraries && - (thisTarget->GetType() == cmTarget::EXECUTABLE || - (thisTarget->GetType() == cmTarget::MODULE_LIBRARY))) - { - return; - } - iface.Exists = true; - iface.ExplicitLibraries = explicitLibraries; - - if(explicitLibraries) - { - // The interface libraries have been explicitly set. - thisTarget->ExpandLinkItems(linkIfaceProp, explicitLibraries, config, - headTarget, usage_requirements_only, - iface.Libraries, - iface.HadHeadSensitiveCondition); - } - else if (thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN - || thisTarget->GetPolicyStatusCMP0022() == cmPolicies::OLD) - // If CMP0022 is NEW then the plain tll signature sets the - // INTERFACE_LINK_LIBRARIES, so if we get here then the project - // cleared the property explicitly and we should not fall back - // to the link implementation. - { - // The link implementation is the default link interface. - cmLinkImplementationLibraries const* impl = - thisTarget->GetLinkImplementationLibrariesInternal(config, headTarget); - iface.Libraries.insert(iface.Libraries.end(), - impl->Libraries.begin(), impl->Libraries.end()); - if(thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN && - !this->PolicyWarnedCMP0022 && !usage_requirements_only) - { - // Compare the link implementation fallback link interface to the - // preferred new link interface property and warn if different. - std::vector ifaceLibs; - static const std::string newProp = "INTERFACE_LINK_LIBRARIES"; - if(const char* newExplicitLibraries = thisTarget->GetProperty(newProp)) - { - bool hadHeadSensitiveConditionDummy = false; - thisTarget->ExpandLinkItems(newProp, newExplicitLibraries, config, - headTarget, usage_requirements_only, - ifaceLibs, hadHeadSensitiveConditionDummy); - } - if (ifaceLibs != iface.Libraries) - { - std::string oldLibraries = cmJoin(impl->Libraries, ";"); - std::string newLibraries = cmJoin(ifaceLibs, ";"); - if(oldLibraries.empty()) - { oldLibraries = "(empty)"; } - if(newLibraries.empty()) - { newLibraries = "(empty)"; } - - std::ostringstream w; - w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n" - "Target \"" << thisTarget->GetName() << "\" has an " - "INTERFACE_LINK_LIBRARIES property. " - "This should be preferred as the source of the link interface " - "for this library but because CMP0022 is not set CMake is " - "ignoring the property and using the link implementation " - "as the link interface instead." - "\n" - "INTERFACE_LINK_LIBRARIES:\n" - " " << newLibraries << "\n" - "Link implementation:\n" - " " << oldLibraries << "\n"; - thisTarget->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); - this->PolicyWarnedCMP0022 = true; - } - } - } -} - -//---------------------------------------------------------------------------- -void cmTargetInternals::ComputeLinkInterface(cmTarget const* thisTarget, - const std::string& config, - OptionalLinkInterface& iface, - cmTarget const* headTarget) const -{ - if(iface.ExplicitLibraries) - { - if(thisTarget->GetType() == cmTarget::SHARED_LIBRARY - || thisTarget->GetType() == cmTarget::STATIC_LIBRARY - || thisTarget->GetType() == cmTarget::INTERFACE_LIBRARY) - { - // Shared libraries may have runtime implementation dependencies - // on other shared libraries that are not in the interface. - UNORDERED_SET emitted; - for(std::vector::const_iterator - li = iface.Libraries.begin(); li != iface.Libraries.end(); ++li) - { - emitted.insert(*li); - } - if (thisTarget->GetType() != cmTarget::INTERFACE_LIBRARY) - { - cmTarget::LinkImplementation const* impl = - thisTarget->GetLinkImplementation(config); - for(std::vector::const_iterator - li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li) - { - if(emitted.insert(*li).second) - { - if(li->Target) - { - // This is a runtime dependency on another shared library. - if(li->Target->GetType() == cmTarget::SHARED_LIBRARY) - { - iface.SharedDeps.push_back(*li); - } - } - else - { - // TODO: Recognize shared library file names. Perhaps this - // should be moved to cmComputeLinkInformation, but that creates - // a chicken-and-egg problem since this list is needed for its - // construction. - } - } - } - } - } - } - else if (thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN - || thisTarget->GetPolicyStatusCMP0022() == cmPolicies::OLD) - { - // The link implementation is the default link interface. - cmLinkImplementationLibraries const* - impl = thisTarget->GetLinkImplementationLibrariesInternal(config, - headTarget); - iface.ImplementationIsInterface = true; - iface.WrongConfigLibraries = impl->WrongConfigLibraries; - } - - if(thisTarget->LinkLanguagePropagatesToDependents()) - { - // Targets using this archive need its language runtime libraries. - if(cmTarget::LinkImplementation const* impl = - thisTarget->GetLinkImplementation(config)) - { - iface.Languages = impl->Languages; - } - } - - if(thisTarget->GetType() == cmTarget::STATIC_LIBRARY) - { - // Construct the property name suffix for this configuration. - std::string suffix = "_"; - if(!config.empty()) - { - suffix += cmSystemTools::UpperCase(config); - } - else - { - suffix += "NOCONFIG"; - } - - // How many repetitions are needed if this library has cyclic - // dependencies? - std::string propName = "LINK_INTERFACE_MULTIPLICITY"; - propName += suffix; - if(const char* config_reps = thisTarget->GetProperty(propName)) - { - sscanf(config_reps, "%u", &iface.Multiplicity); - } - else if(const char* reps = - thisTarget->GetProperty("LINK_INTERFACE_MULTIPLICITY")) - { - sscanf(reps, "%u", &iface.Multiplicity); - } - } -} - -//---------------------------------------------------------------------------- void cmTargetInternals::AddInterfaceEntries( cmTarget const* thisTarget, std::string const& config, std::string const& prop, std::vector& entries) diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 2007b40..25de6a6 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -233,43 +233,6 @@ public: void GetObjectLibrariesCMP0026(std::vector& objlibs) const; - /** The link interface specifies transitive library dependencies and - other information needed by targets that link to this target. */ - struct LinkInterfaceLibraries - { - // Libraries listed in the interface. - std::vector Libraries; - }; - struct LinkInterface: public LinkInterfaceLibraries - { - // Languages whose runtime libraries must be linked. - std::vector Languages; - - // Shared library dependencies needed for linking on some platforms. - std::vector SharedDeps; - - // Number of repetitions of a strongly connected component of two - // or more static libraries. - int Multiplicity; - - // Libraries listed for other configurations. - // Needed only for OLD behavior of CMP0003. - std::vector WrongConfigLibraries; - - bool ImplementationIsInterface; - - LinkInterface(): Multiplicity(0), ImplementationIsInterface(false) {} - }; - - /** Get the link interface for the given configuration. Returns 0 - if the target cannot be linked. */ - LinkInterface const* GetLinkInterface(const std::string& config, - cmTarget const* headTarget) const; - LinkInterfaceLibraries const* - GetLinkInterfaceLibraries(const std::string& config, - cmTarget const* headTarget, - bool usage_requirements_only) const; - struct LinkImplementation: public cmLinkImplementationLibraries { // Languages whose runtime libraries must be linked. @@ -591,11 +554,6 @@ private: void ComputeImportInfo(std::string const& desired_config, ImportInfo& info) const; - - LinkInterface const* - GetImportLinkInterface(const std::string& config, cmTarget const* head, - bool usage_requirements_only) const; - cmLinkImplementationLibraries const* GetLinkImplementationLibrariesInternal(const std::string& config, cmTarget const* head) const; ----------------------------------------------------------------------- Summary of changes: Source/cmComputeLinkDepends.cxx | 24 +- Source/cmComputeLinkDepends.h | 5 +- Source/cmComputeLinkInformation.cxx | 2 +- Source/cmComputeTargetDepends.cxx | 7 +- Source/cmExportFileGenerator.cxx | 7 +- Source/cmExtraCodeBlocksGenerator.cxx | 2 +- Source/cmGeneratorExpressionNode.cxx | 4 +- Source/cmGeneratorTarget.cxx | 1198 +++++++++++++++++++++++- Source/cmGeneratorTarget.h | 122 +++ Source/cmGlobalGenerator.cxx | 1 - Source/cmGlobalUnixMakefileGenerator3.cxx | 3 +- Source/cmGlobalXCodeGenerator.cxx | 21 +- Source/cmLinkItem.h | 17 + Source/cmLocalGenerator.cxx | 13 +- Source/cmLocalUnixMakefileGenerator3.cxx | 3 +- Source/cmMakefileTargetGenerator.cxx | 2 +- Source/cmQtAutoGenerators.cxx | 15 +- Source/cmTarget.cxx | 1431 +++-------------------------- Source/cmTarget.h | 106 +-- 19 files changed, 1553 insertions(+), 1430 deletions(-) hooks/post-receive -- CMake From steveire at gmail.com Tue Aug 25 16:26:56 2015 From: steveire at gmail.com (Stephen Kelly) Date: Tue, 25 Aug 2015 16:26:56 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2467-gec0bc17 Message-ID: <20150825202656.B2871B1A7E@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via ec0bc1765d8bff3c13835eff266ecfee9ecf00aa (commit) via a523d3a3fbcb0fedf90a3bf88450ce56e9c46298 (commit) from 8f95633f6049542a3b59872dd9ef03690131427f (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ec0bc1765d8bff3c13835eff266ecfee9ecf00aa commit ec0bc1765d8bff3c13835eff266ecfee9ecf00aa Merge: 8f95633 a523d3a Author: Stephen Kelly AuthorDate: Tue Aug 25 16:26:55 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 25 16:26:55 2015 -0400 Merge topic 'use-generator-target' into next a523d3a3 Revert topic. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a523d3a3fbcb0fedf90a3bf88450ce56e9c46298 commit a523d3a3fbcb0fedf90a3bf88450ce56e9c46298 Author: Stephen Kelly AuthorDate: Tue Aug 25 22:26:22 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 22:26:32 2015 +0200 Revert topic. diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 20fa169..59590fd 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -361,9 +361,8 @@ void cmComputeLinkDepends::FollowLinkEntry(BFSEntry const& qe) if(entry.Target) { // Follow the target dependencies. - cmGeneratorTarget* gtgt = this->GlobalGenerator->GetGeneratorTarget(entry.Target); - if(cmGeneratorTarget::LinkInterface const* iface = - gtgt->GetLinkInterface(this->Config, this->Target->Target)) + if(cmTarget::LinkInterface const* iface = + entry.Target->GetLinkInterface(this->Config, this->Target->Target)) { const bool isIface = entry.Target->GetType() == cmTarget::INTERFACE_LIBRARY; @@ -397,8 +396,7 @@ void cmComputeLinkDepends::FollowLinkEntry(BFSEntry const& qe) //---------------------------------------------------------------------------- void cmComputeLinkDepends -::FollowSharedDeps(int depender_index, - cmGeneratorTarget::LinkInterface const* iface, +::FollowSharedDeps(int depender_index, cmTarget::LinkInterface const* iface, bool follow_interface) { // Follow dependencies if we have not followed them already. @@ -461,10 +459,8 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep) // Target items may have their own dependencies. if(entry.Target) { - cmGeneratorTarget* gtgt = - this->GlobalGenerator->GetGeneratorTarget(entry.Target); - if(cmGeneratorTarget::LinkInterface const* iface = - gtgt->GetLinkInterface(this->Config, this->Target->Target)) + if(cmTarget::LinkInterface const* iface = + entry.Target->GetLinkInterface(this->Config, this->Target->Target)) { // Follow public and private dependencies transitively. this->FollowSharedDeps(index, iface, true); @@ -554,8 +550,8 @@ void cmComputeLinkDepends::AddVarLinkEntries(int depender_index, void cmComputeLinkDepends::AddDirectLinkEntries() { // Add direct link dependencies in this configuration. - cmLinkImplementation const* impl = - this->Target->GetLinkImplementation(this->Config); + cmTarget::LinkImplementation const* impl = + this->Target->Target->GetLinkImplementation(this->Config); this->AddLinkEntries(-1, impl->Libraries); for(std::vector::const_iterator wi = impl->WrongConfigLibraries.begin(); @@ -934,10 +930,8 @@ int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl) { if(cmTarget const* target = this->EntryList[*ni].Target) { - cmGeneratorTarget* gtgt = - this->GlobalGenerator->GetGeneratorTarget(target); - if(cmGeneratorTarget::LinkInterface const* iface = - gtgt->GetLinkInterface(this->Config, this->Target->Target)) + if(cmTarget::LinkInterface const* iface = + target->GetLinkInterface(this->Config, this->Target->Target)) { if(iface->Multiplicity > count) { diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index e61175a..b925a4f 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -13,7 +13,6 @@ #define cmComputeLinkDepends_h #include "cmStandardIncludes.h" -#include "cmGeneratorTarget.h" #include "cmTarget.h" #include "cmGraphAdjacencyList.h" @@ -23,6 +22,8 @@ class cmComputeComponentGraph; class cmGlobalGenerator; class cmMakefile; +class cmGeneratorTarget; +class cmTarget; class cmake; /** \class cmComputeLinkDepends @@ -101,7 +102,7 @@ private: std::queue SharedDepQueue; std::set SharedDepFollowed; void FollowSharedDeps(int depender_index, - cmGeneratorTarget::LinkInterface const* iface, + cmTarget::LinkInterface const* iface, bool follow_interface = false); void QueueSharedDependencies(int depender_index, std::vector const& deps); diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 192ad5f..6ba0eed 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -1925,7 +1925,7 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, (outputRuntime && this->Target->Target->HaveInstallTreeRPATH() && linking_for_install); bool use_build_rpath = - (outputRuntime && this->Target->HaveBuildTreeRPATH(this->Config) && + (outputRuntime && this->Target->Target->HaveBuildTreeRPATH(this->Config) && !linking_for_install); bool use_link_rpath = outputRuntime && linking_for_install && diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index 7488e09..c4a03a0 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -252,7 +252,8 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) } } - cmLinkImplementation const* impl = depender->GetLinkImplementation(*it); + cmTarget::LinkImplementation const* impl = + depender->Target->GetLinkImplementation(*it); // A target should not depend on itself. emitted.insert(depender->GetName()); @@ -295,8 +296,8 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, std::set &emitted) { cmGeneratorTarget const* depender = this->Targets[depender_index]; - if(cmGeneratorTarget::LinkInterface const* iface = - dependee->GetLinkInterface(config, + if(cmTarget::LinkInterface const* iface = + dependee->Target->GetLinkInterface(config, depender->Target)) { for(std::vector::const_iterator diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 97eb6b9..cae60b7 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -796,7 +796,7 @@ cmExportFileGenerator std::vector& missingTargets) { // Add the transitive link dependencies for this configuration. - cmGeneratorTarget::LinkInterface const* iface = target->GetLinkInterface( + cmTarget::LinkInterface const* iface = target->Target->GetLinkInterface( config, target->Target); if (!iface) @@ -909,8 +909,9 @@ cmExportFileGenerator } // Add the transitive link dependencies for this configuration. - if(cmGeneratorTarget::LinkInterface const* iface = - target->GetLinkInterface(config, target->Target)) + if(cmTarget::LinkInterface const* iface = + target->Target + ->GetLinkInterface(config, target->Target)) { this->SetImportLinkProperty(suffix, target, "IMPORTED_LINK_INTERFACE_LANGUAGES", diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index dfd51c7..933a256 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -609,7 +609,7 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, // the compilerdefines for this target std::vector cdefs; - gtgt->GetCompileDefinitions(cdefs, buildType, "C"); + target->GetCompileDefinitions(cdefs, buildType, "C"); // Expand the list. for(std::vector::const_iterator di = cdefs.begin(); diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index b957379..03bc83a 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1108,8 +1108,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode if(isInterfaceProperty) { - if(cmGeneratorTarget::LinkInterfaceLibraries const* iface = - gtgt->GetLinkInterfaceLibraries(context->Config, headTarget, true)) + if(cmTarget::LinkInterfaceLibraries const* iface = + target->GetLinkInterfaceLibraries(context->Config, headTarget, true)) { linkedTargetsContent = getLinkedTargetsContent(iface->Libraries, target, diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index db7ecb6..dd58e7b 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -34,18 +34,6 @@ #define UNORDERED_SET std::set #endif -class cmGeneratorTarget::TargetPropertyEntry { - static cmLinkImplItem NoLinkImplItem; -public: - TargetPropertyEntry(cmsys::auto_ptr cge, - cmLinkImplItem const& item = NoLinkImplItem) - : ge(cge), LinkImplItem(item) - {} - const cmsys::auto_ptr ge; - cmLinkImplItem const& LinkImplItem; -}; -cmLinkImplItem cmGeneratorTarget::TargetPropertyEntry::NoLinkImplItem; - //---------------------------------------------------------------------------- void reportBadObjLib(std::vector const& badObjLib, cmGeneratorTarget const* target, cmake *cm) @@ -239,63 +227,18 @@ struct TagVisitor } }; -void CreatePropertyGeneratorExpressions( - cmStringRange const& entries, - cmBacktraceRange const& backtraces, - std::vector& items, - bool evaluateForBuildsystem = false) -{ - std::vector::const_iterator btIt = backtraces.begin(); - for (std::vector::const_iterator it = entries.begin(); - it != entries.end(); ++it, ++btIt) - { - cmGeneratorExpression ge(*btIt); - cmsys::auto_ptr cge = ge.Parse(*it); - cge->SetEvaluateForBuildsystem(evaluateForBuildsystem); - items.push_back(new cmGeneratorTarget::TargetPropertyEntry(cge)); - } -} - //---------------------------------------------------------------------------- cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) : Target(t), - SourceFileFlagsConstructed(false), - DebugIncludesDone(false), - DebugCompileOptionsDone(false), - DebugCompileFeaturesDone(false), - DebugCompileDefinitionsDone(false) + SourceFileFlagsConstructed(false) { this->Makefile = this->Target->GetMakefile(); this->LocalGenerator = lg; this->GlobalGenerator = this->LocalGenerator->GetGlobalGenerator(); - - CreatePropertyGeneratorExpressions( - t->GetIncludeDirectoriesEntries(), - t->GetIncludeDirectoriesBacktraces(), - this->IncludeDirectoriesEntries); - - CreatePropertyGeneratorExpressions( - t->GetCompileOptionsEntries(), - t->GetCompileOptionsBacktraces(), - this->CompileOptionsEntries); - - CreatePropertyGeneratorExpressions( - t->GetCompileFeaturesEntries(), - t->GetCompileFeaturesBacktraces(), - this->CompileFeaturesEntries); - - CreatePropertyGeneratorExpressions( - t->GetCompileDefinitionsEntries(), - t->GetCompileDefinitionsBacktraces(), - this->CompileDefinitionsEntries); } cmGeneratorTarget::~cmGeneratorTarget() { - cmDeleteAll(this->IncludeDirectoriesEntries); - cmDeleteAll(this->CompileOptionsEntries); - cmDeleteAll(this->CompileFeaturesEntries); - cmDeleteAll(this->CompileDefinitionsEntries); cmDeleteAll(this->LinkInformation); this->LinkInformation.clear(); } @@ -908,7 +851,7 @@ cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const // If either a build or install tree rpath is set then the rpath // will likely change between the build tree and install tree and // this target must be relinked. - return this->HaveBuildTreeRPATH(config) + return this->Target->HaveBuildTreeRPATH(config) || this->Target->HaveInstallTreeRPATH(); } @@ -1230,11 +1173,8 @@ public: return; } - cmGeneratorTarget* gtgt = - this->Target->GetLocalGenerator()->GetGlobalGenerator() - ->GetGeneratorTarget(item.Target); - cmGeneratorTarget::LinkInterface const* iface = - gtgt->GetLinkInterface(this->Config, this->HeadTarget); + cmTarget::LinkInterface const* iface = + item.Target->GetLinkInterface(this->Config, this->HeadTarget); if(!iface) { return; } for(std::vector::const_iterator @@ -1335,8 +1275,8 @@ void cmGeneratorTarget::ComputeLinkClosure(const std::string& config, { // Get languages built in this target. UNORDERED_SET languages; - cmLinkImplementation const* impl = - this->GetLinkImplementation(config); + cmTarget::LinkImplementation const* impl = + this->Target->GetLinkImplementation(config); assert(impl); for(std::vector::const_iterator li = impl->Languages.begin(); li != impl->Languages.end(); ++li) @@ -1565,22 +1505,20 @@ void cmGeneratorTarget::GetAutoUicOptions(std::vector &result, void processILibs(const std::string& config, cmTarget const* headTarget, cmLinkItem const& item, - cmGlobalGenerator* gg, std::vector& tgts, std::set& emitted) { if (item.Target && emitted.insert(item.Target).second) { tgts.push_back(item.Target); - cmGeneratorTarget* gt = gg->GetGeneratorTarget(item.Target); - if(cmGeneratorTarget::LinkInterfaceLibraries const* iface = - gt->GetLinkInterfaceLibraries(config, headTarget, true)) + if(cmTarget::LinkInterfaceLibraries const* iface = + item.Target->GetLinkInterfaceLibraries(config, headTarget, true)) { for(std::vector::const_iterator it = iface->Libraries.begin(); it != iface->Libraries.end(); ++it) { - processILibs(config, headTarget, *it, gg, tgts, emitted); + processILibs(config, headTarget, *it, tgts, emitted); } } } @@ -1605,9 +1543,7 @@ cmGeneratorTarget::GetLinkImplementationClosure( it = impl->Libraries.begin(); it != impl->Libraries.end(); ++it) { - processILibs(config, this->Target, *it, - this->LocalGenerator->GetGlobalGenerator(), - tgts, emitted); + processILibs(config, this->Target, *it, tgts , emitted); } } return tgts; @@ -2021,536 +1957,13 @@ cmGeneratorTarget::GetCreateRuleVariable(std::string const& lang, } return ""; } -//---------------------------------------------------------------------------- -static void processIncludeDirectories(cmGeneratorTarget const* tgt, - const std::vector &entries, - std::vector &includes, - UNORDERED_SET &uniqueIncludes, - cmGeneratorExpressionDAGChecker *dagChecker, - const std::string& config, bool debugIncludes, - const std::string& language) -{ - cmMakefile *mf = tgt->Target->GetMakefile(); - - for (std::vector::const_iterator - it = entries.begin(), end = entries.end(); it != end; ++it) - { - cmLinkImplItem const& item = (*it)->LinkImplItem; - std::string const& targetName = item; - bool const fromImported = item.Target && item.Target->IsImported(); - bool const checkCMP0027 = item.FromGenex; - std::vector entryIncludes; - cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf, - config, - false, - tgt->Target, - dagChecker, language), - entryIncludes); - - std::string usedIncludes; - for(std::vector::iterator - li = entryIncludes.begin(); li != entryIncludes.end(); ++li) - { - if (fromImported - && !cmSystemTools::FileExists(li->c_str())) - { - std::ostringstream e; - cmake::MessageType messageType = cmake::FATAL_ERROR; - if (checkCMP0027) - { - switch(tgt->Target->GetPolicyStatusCMP0027()) - { - case cmPolicies::WARN: - e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0027) << "\n"; - case cmPolicies::OLD: - messageType = cmake::AUTHOR_WARNING; - break; - case cmPolicies::REQUIRED_ALWAYS: - case cmPolicies::REQUIRED_IF_USED: - case cmPolicies::NEW: - break; - } - } - e << "Imported target \"" << targetName << "\" includes " - "non-existent path\n \"" << *li << "\"\nin its " - "INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:\n" - "* The path was deleted, renamed, or moved to another " - "location.\n" - "* An install or uninstall procedure did not complete " - "successfully.\n" - "* The installation package was faulty and references files it " - "does not provide.\n"; - tgt->GetLocalGenerator()->IssueMessage(messageType, e.str()); - return; - } - - if (!cmSystemTools::FileIsFullPath(li->c_str())) - { - std::ostringstream e; - bool noMessage = false; - cmake::MessageType messageType = cmake::FATAL_ERROR; - if (!targetName.empty()) - { - e << "Target \"" << targetName << "\" contains relative " - "path in its INTERFACE_INCLUDE_DIRECTORIES:\n" - " \"" << *li << "\""; - } - else - { - switch(tgt->Target->GetPolicyStatusCMP0021()) - { - case cmPolicies::WARN: - { - e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0021) << "\n"; - messageType = cmake::AUTHOR_WARNING; - } - break; - case cmPolicies::OLD: - noMessage = true; - case cmPolicies::REQUIRED_IF_USED: - case cmPolicies::REQUIRED_ALWAYS: - case cmPolicies::NEW: - // Issue the fatal message. - break; - } - e << "Found relative path while evaluating include directories of " - "\"" << tgt->GetName() << "\":\n \"" << *li << "\"\n"; - } - if (!noMessage) - { - tgt->GetLocalGenerator()->IssueMessage(messageType, e.str()); - if (messageType == cmake::FATAL_ERROR) - { - return; - } - } - } - - if (!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 (!usedIncludes.empty()) - { - mf->GetCMakeInstance()->IssueMessage(cmake::LOG, - std::string("Used includes for target ") - + tgt->GetName() + ":\n" - + usedIncludes, (*it)->ge->GetBacktrace()); - } - } -} - - -//---------------------------------------------------------------------------- -static void AddInterfaceEntries( - cmGeneratorTarget const* thisTarget, std::string const& config, - std::string const& prop, - std::vector& entries) -{ - if(cmLinkImplementationLibraries const* impl = - thisTarget->Target->GetLinkImplementationLibraries(config)) - { - for (std::vector::const_iterator - it = impl->Libraries.begin(), end = impl->Libraries.end(); - it != end; ++it) - { - if(it->Target) - { - std::string genex = - "$"; - cmGeneratorExpression ge(it->Backtrace); - cmsys::auto_ptr cge = ge.Parse(genex); - cge->SetEvaluateForBuildsystem(true); - entries.push_back( - new cmGeneratorTarget::TargetPropertyEntry(cge, *it)); - } - } - } -} //---------------------------------------------------------------------------- std::vector cmGeneratorTarget::GetIncludeDirectories(const std::string& config, const std::string& lang) const { - std::vector includes; - UNORDERED_SET uniqueIncludes; - - cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), - "INCLUDE_DIRECTORIES", 0, 0); - - std::vector debugProperties; - const char *debugProp = - this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); - if (debugProp) - { - cmSystemTools::ExpandListArgument(debugProp, debugProperties); - } - - bool debugIncludes = !this->DebugIncludesDone - && std::find(debugProperties.begin(), - debugProperties.end(), - "INCLUDE_DIRECTORIES") - != debugProperties.end(); - - if (this->Makefile->IsConfigured()) - { - this->DebugIncludesDone = true; - } - - processIncludeDirectories(this, - this->IncludeDirectoriesEntries, - includes, - uniqueIncludes, - &dagChecker, - config, - debugIncludes, - lang); - - std::vector - linkInterfaceIncludeDirectoriesEntries; - AddInterfaceEntries( - this, config, "INTERFACE_INCLUDE_DIRECTORIES", - linkInterfaceIncludeDirectoriesEntries); - - if(this->Makefile->IsOn("APPLE")) - { - cmLinkImplementationLibraries const* impl = - this->Target->GetLinkImplementationLibraries(config); - for(std::vector::const_iterator - it = impl->Libraries.begin(); - it != impl->Libraries.end(); ++it) - { - std::string libDir = cmSystemTools::CollapseFullPath(*it); - - static cmsys::RegularExpression - frameworkCheck("(.*\\.framework)(/Versions/[^/]+)?/[^/]+$"); - if(!frameworkCheck.find(libDir)) - { - continue; - } - - libDir = frameworkCheck.match(1); - - cmGeneratorExpression ge; - cmsys::auto_ptr cge = - ge.Parse(libDir.c_str()); - linkInterfaceIncludeDirectoriesEntries - .push_back(new cmGeneratorTarget::TargetPropertyEntry(cge)); - } - } - - processIncludeDirectories(this, - linkInterfaceIncludeDirectoriesEntries, - includes, - uniqueIncludes, - &dagChecker, - config, - debugIncludes, - lang); - - cmDeleteAll(linkInterfaceIncludeDirectoriesEntries); - - return includes; -} - -//---------------------------------------------------------------------------- -static void processCompileOptionsInternal(cmGeneratorTarget const* tgt, - const std::vector &entries, - std::vector &options, - UNORDERED_SET &uniqueOptions, - cmGeneratorExpressionDAGChecker *dagChecker, - const std::string& config, bool debugOptions, const char *logName, - std::string const& language) -{ - cmMakefile *mf = tgt->Target->GetMakefile(); - - for (std::vector::const_iterator - it = entries.begin(), end = entries.end(); it != end; ++it) - { - std::vector entryOptions; - cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf, - config, - false, - tgt->Target, - dagChecker, - language), - entryOptions); - std::string usedOptions; - for(std::vector::iterator - li = entryOptions.begin(); li != entryOptions.end(); ++li) - { - std::string const& opt = *li; - - if(uniqueOptions.insert(opt).second) - { - options.push_back(opt); - if (debugOptions) - { - usedOptions += " * " + opt + "\n"; - } - } - } - if (!usedOptions.empty()) - { - mf->GetCMakeInstance()->IssueMessage(cmake::LOG, - std::string("Used compile ") + logName - + std::string(" for target ") - + tgt->GetName() + ":\n" - + usedOptions, (*it)->ge->GetBacktrace()); - } - } -} - -//---------------------------------------------------------------------------- -static void processCompileOptions(cmGeneratorTarget const* tgt, - const std::vector &entries, - std::vector &options, - UNORDERED_SET &uniqueOptions, - cmGeneratorExpressionDAGChecker *dagChecker, - const std::string& config, bool debugOptions, - std::string const& language) -{ - processCompileOptionsInternal(tgt, entries, options, uniqueOptions, - dagChecker, config, debugOptions, "options", - language); -} - -//---------------------------------------------------------------------------- -void cmGeneratorTarget::GetCompileOptions(std::vector &result, - const std::string& config, - const std::string& language) const -{ - UNORDERED_SET uniqueOptions; - - cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), - "COMPILE_OPTIONS", 0, 0); - - std::vector debugProperties; - const char *debugProp = - this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); - if (debugProp) - { - cmSystemTools::ExpandListArgument(debugProp, debugProperties); - } - - bool debugOptions = !this->DebugCompileOptionsDone - && std::find(debugProperties.begin(), - debugProperties.end(), - "COMPILE_OPTIONS") - != debugProperties.end(); - - if (this->Makefile->IsConfigured()) - { - this->DebugCompileOptionsDone = true; - } - - processCompileOptions(this, - this->CompileOptionsEntries, - result, - uniqueOptions, - &dagChecker, - config, - debugOptions, - language); - - std::vector - linkInterfaceCompileOptionsEntries; - - AddInterfaceEntries( - this, config, "INTERFACE_COMPILE_OPTIONS", - linkInterfaceCompileOptionsEntries); - - processCompileOptions(this, - linkInterfaceCompileOptionsEntries, - result, - uniqueOptions, - &dagChecker, - config, - debugOptions, - language); - - cmDeleteAll(linkInterfaceCompileOptionsEntries); -} - -//---------------------------------------------------------------------------- -static void processCompileFeatures(cmGeneratorTarget const* tgt, - const std::vector &entries, - std::vector &options, - UNORDERED_SET &uniqueOptions, - cmGeneratorExpressionDAGChecker *dagChecker, - const std::string& config, bool debugOptions) -{ - processCompileOptionsInternal(tgt, entries, options, uniqueOptions, - dagChecker, config, debugOptions, "features", - std::string()); -} - -//---------------------------------------------------------------------------- -void cmGeneratorTarget::GetCompileFeatures(std::vector &result, - const std::string& config) const -{ - UNORDERED_SET uniqueFeatures; - - cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), - "COMPILE_FEATURES", - 0, 0); - - std::vector debugProperties; - const char *debugProp = - this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); - if (debugProp) - { - cmSystemTools::ExpandListArgument(debugProp, debugProperties); - } - - bool debugFeatures = !this->DebugCompileFeaturesDone - && std::find(debugProperties.begin(), - debugProperties.end(), - "COMPILE_FEATURES") - != debugProperties.end(); - - if (this->Makefile->IsConfigured()) - { - this->DebugCompileFeaturesDone = true; - } - - processCompileFeatures(this, - this->CompileFeaturesEntries, - result, - uniqueFeatures, - &dagChecker, - config, - debugFeatures); - - std::vector - linkInterfaceCompileFeaturesEntries; - AddInterfaceEntries( - this, config, "INTERFACE_COMPILE_FEATURES", - linkInterfaceCompileFeaturesEntries); - - processCompileFeatures(this, - linkInterfaceCompileFeaturesEntries, - result, - uniqueFeatures, - &dagChecker, - config, - debugFeatures); - - cmDeleteAll(linkInterfaceCompileFeaturesEntries); -} - -//---------------------------------------------------------------------------- -static void processCompileDefinitions(cmGeneratorTarget const* tgt, - const std::vector &entries, - std::vector &options, - UNORDERED_SET &uniqueOptions, - cmGeneratorExpressionDAGChecker *dagChecker, - const std::string& config, bool debugOptions, - std::string const& language) -{ - processCompileOptionsInternal(tgt, entries, options, uniqueOptions, - dagChecker, config, debugOptions, - "definitions", language); -} - -//---------------------------------------------------------------------------- -void cmGeneratorTarget::GetCompileDefinitions(std::vector &list, - const std::string& config, - const std::string& language) const -{ - UNORDERED_SET uniqueOptions; - - cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), - "COMPILE_DEFINITIONS", 0, 0); - - std::vector debugProperties; - const char *debugProp = - this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); - if (debugProp) - { - cmSystemTools::ExpandListArgument(debugProp, debugProperties); - } - - bool debugDefines = !this->DebugCompileDefinitionsDone - && std::find(debugProperties.begin(), - debugProperties.end(), - "COMPILE_DEFINITIONS") - != debugProperties.end(); - - if (this->Makefile->IsConfigured()) - { - this->DebugCompileDefinitionsDone = true; - } - - processCompileDefinitions(this, - this->CompileDefinitionsEntries, - list, - uniqueOptions, - &dagChecker, - config, - debugDefines, - language); - - std::vector - linkInterfaceCompileDefinitionsEntries; - AddInterfaceEntries( - this, config, "INTERFACE_COMPILE_DEFINITIONS", - linkInterfaceCompileDefinitionsEntries); - if (!config.empty()) - { - std::string configPropName = "COMPILE_DEFINITIONS_" - + cmSystemTools::UpperCase(config); - const char *configProp = this->Target->GetProperty(configPropName); - if (configProp) - { - switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0043)) - { - case cmPolicies::WARN: - { - std::ostringstream e; - e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0043); - this->LocalGenerator->IssueMessage(cmake::AUTHOR_WARNING, - e.str()); - } - case cmPolicies::OLD: - { - cmGeneratorExpression ge; - cmsys::auto_ptr cge = - ge.Parse(configProp); - linkInterfaceCompileDefinitionsEntries - .push_back(new cmGeneratorTarget::TargetPropertyEntry(cge)); - } - break; - case cmPolicies::NEW: - case cmPolicies::REQUIRED_ALWAYS: - case cmPolicies::REQUIRED_IF_USED: - break; - } - } - } - - processCompileDefinitions(this, - linkInterfaceCompileDefinitionsEntries, - list, - uniqueOptions, - &dagChecker, - config, - debugDefines, - language); - - cmDeleteAll(linkInterfaceCompileDefinitionsEntries); + return this->Target->GetIncludeDirectories(config, lang); } //---------------------------------------------------------------------------- @@ -3941,592 +3354,3 @@ cmGeneratorTarget::ReportPropertyOrigin(const std::string &p, this->Makefile->GetCMakeInstance()->IssueMessage(cmake::LOG, areport); } - -//---------------------------------------------------------------------------- -void cmGeneratorTarget::LookupLinkItems(std::vector const& names, - std::vector& items) const -{ - for(std::vector::const_iterator i = names.begin(); - i != names.end(); ++i) - { - std::string name = this->Target->CheckCMP0004(*i); - if(name == this->GetName() || name.empty()) - { - continue; - } - items.push_back(cmLinkItem(name, this->Target->FindTargetToLink(name))); - } -} - -//---------------------------------------------------------------------------- -void cmGeneratorTarget::ExpandLinkItems(std::string const& prop, - std::string const& value, - std::string const& config, - cmTarget const* headTarget, - bool usage_requirements_only, - std::vector& items, - bool& hadHeadSensitiveCondition) const -{ - cmGeneratorExpression ge; - cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), prop, 0, 0); - // The $ expression may be in a link interface to specify private - // link dependencies that are otherwise excluded from usage requirements. - if(usage_requirements_only) - { - dagChecker.SetTransitivePropertiesOnly(); - } - std::vector libs; - cmsys::auto_ptr cge = ge.Parse(value); - cmSystemTools::ExpandListArgument(cge->Evaluate( - this->Makefile, - config, - false, - headTarget, - this->Target, &dagChecker), libs); - this->LookupLinkItems(libs, items); - hadHeadSensitiveCondition = cge->GetHadHeadSensitiveCondition(); -} - -//---------------------------------------------------------------------------- -cmGeneratorTarget::LinkInterface const* cmGeneratorTarget::GetLinkInterface( - const std::string& config, - cmTarget const* head) const -{ - // Imported targets have their own link interface. - if(this->Target->IsImported()) - { - return this->GetImportLinkInterface(config, head, false); - } - - // Link interfaces are not supported for executables that do not - // export symbols. - if(this->GetType() == cmTarget::EXECUTABLE && - !this->Target->IsExecutableWithExports()) - { - return 0; - } - - // Lookup any existing link interface for this configuration. - std::string CONFIG = cmSystemTools::UpperCase(config); - HeadToLinkInterfaceMap& hm = this->LinkInterfaceMap[CONFIG]; - - // If the link interface does not depend on the head target - // then return the one we computed first. - if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) - { - return &hm.begin()->second; - } - - OptionalLinkInterface& iface = hm[head]; - if(!iface.LibrariesDone) - { - iface.LibrariesDone = true; - this->ComputeLinkInterfaceLibraries( - config, iface, head, false); - } - if(!iface.AllDone) - { - iface.AllDone = true; - if(iface.Exists) - { - this->ComputeLinkInterface(config, iface, head); - } - } - - return iface.Exists? &iface : 0; -} - -//---------------------------------------------------------------------------- -cmGeneratorTarget::LinkInterfaceLibraries const* -cmGeneratorTarget::GetLinkInterfaceLibraries(const std::string& config, - cmTarget const* head, - bool usage_requirements_only) const -{ - // Imported targets have their own link interface. - if(this->Target->IsImported()) - { - return this->GetImportLinkInterface(config, head, usage_requirements_only); - } - - // Link interfaces are not supported for executables that do not - // export symbols. - if(this->GetType() == cmTarget::EXECUTABLE && - !this->Target->IsExecutableWithExports()) - { - return 0; - } - - // Lookup any existing link interface for this configuration. - std::string CONFIG = cmSystemTools::UpperCase(config); - HeadToLinkInterfaceMap& hm = - (usage_requirements_only ? - this->LinkInterfaceUsageRequirementsOnlyMap[CONFIG] : - this->LinkInterfaceMap[CONFIG]); - - // If the link interface does not depend on the head target - // then return the one we computed first. - if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) - { - return &hm.begin()->second; - } - - OptionalLinkInterface& iface = hm[head]; - if(!iface.LibrariesDone) - { - iface.LibrariesDone = true; - this->ComputeLinkInterfaceLibraries( - config, iface, head, usage_requirements_only); - } - - return iface.Exists? &iface : 0; -} - -//---------------------------------------------------------------------------- -cmGeneratorTarget::LinkInterface const* -cmGeneratorTarget::GetImportLinkInterface(const std::string& config, - cmTarget const* headTarget, - bool usage_requirements_only) const -{ - cmTarget::ImportInfo const* info = this->Target->GetImportInfo(config); - if(!info) - { - return 0; - } - - std::string CONFIG = cmSystemTools::UpperCase(config); - HeadToLinkInterfaceMap& hm = - (usage_requirements_only ? - this->LinkInterfaceUsageRequirementsOnlyMap[CONFIG] : - this->LinkInterfaceMap[CONFIG]); - - // If the link interface does not depend on the head target - // then return the one we computed first. - if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) - { - return &hm.begin()->second; - } - - OptionalLinkInterface& iface = hm[headTarget]; - if(!iface.AllDone) - { - iface.AllDone = true; - iface.Multiplicity = info->Multiplicity; - cmSystemTools::ExpandListArgument(info->Languages, iface.Languages); - this->ExpandLinkItems(info->LibrariesProp, info->Libraries, config, - headTarget, usage_requirements_only, - iface.Libraries, - iface.HadHeadSensitiveCondition); - std::vector deps; - cmSystemTools::ExpandListArgument(info->SharedDeps, deps); - this->LookupLinkItems(deps, iface.SharedDeps); - } - - return &iface; -} - -//---------------------------------------------------------------------------- -void -cmGeneratorTarget::ComputeLinkInterfaceLibraries( - const std::string& config, - OptionalLinkInterface& iface, - cmTarget const* headTarget, - bool usage_requirements_only) const -{ - // Construct the property name suffix for this configuration. - std::string suffix = "_"; - if(!config.empty()) - { - suffix += cmSystemTools::UpperCase(config); - } - else - { - suffix += "NOCONFIG"; - } - - // An explicit list of interface libraries may be set for shared - // libraries and executables that export symbols. - const char* explicitLibraries = 0; - std::string linkIfaceProp; - if(this->Target->GetPolicyStatusCMP0022() != cmPolicies::OLD && - this->Target->GetPolicyStatusCMP0022() != cmPolicies::WARN) - { - // CMP0022 NEW behavior is to use INTERFACE_LINK_LIBRARIES. - linkIfaceProp = "INTERFACE_LINK_LIBRARIES"; - explicitLibraries = this->Target->GetProperty(linkIfaceProp); - } - else if(this->Target->GetType() == cmTarget::SHARED_LIBRARY || - this->Target->IsExecutableWithExports()) - { - // CMP0022 OLD behavior is to use LINK_INTERFACE_LIBRARIES if set on a - // shared lib or executable. - - // Lookup the per-configuration property. - linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; - linkIfaceProp += suffix; - explicitLibraries = this->Target->GetProperty(linkIfaceProp); - - // If not set, try the generic property. - if(!explicitLibraries) - { - linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; - explicitLibraries = this->Target->GetProperty(linkIfaceProp); - } - } - - if(explicitLibraries && - this->Target->GetPolicyStatusCMP0022() == cmPolicies::WARN && - !this->PolicyWarnedCMP0022) - { - // Compare the explicitly set old link interface properties to the - // preferred new link interface property one and warn if different. - const char* newExplicitLibraries = - this->Target->GetProperty("INTERFACE_LINK_LIBRARIES"); - if (newExplicitLibraries - && strcmp(newExplicitLibraries, explicitLibraries) != 0) - { - std::ostringstream w; - w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n" - "Target \"" << this->Target->GetName() << "\" has an " - "INTERFACE_LINK_LIBRARIES property which differs from its " << - linkIfaceProp << " properties." - "\n" - "INTERFACE_LINK_LIBRARIES:\n" - " " << newExplicitLibraries << "\n" << - linkIfaceProp << ":\n" - " " << (explicitLibraries ? explicitLibraries : "(empty)") << "\n"; - this->Target->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); - this->PolicyWarnedCMP0022 = true; - } - } - - // There is no implicit link interface for executables or modules - // so if none was explicitly set then there is no link interface. - if(!explicitLibraries && - (this->Target->GetType() == cmTarget::EXECUTABLE || - (this->Target->GetType() == cmTarget::MODULE_LIBRARY))) - { - return; - } - iface.Exists = true; - iface.ExplicitLibraries = explicitLibraries; - - if(explicitLibraries) - { - // The interface libraries have been explicitly set. - this->ExpandLinkItems(linkIfaceProp, explicitLibraries, config, - headTarget, usage_requirements_only, - iface.Libraries, - iface.HadHeadSensitiveCondition); - } - else if (this->Target->GetPolicyStatusCMP0022() == cmPolicies::WARN - || this->Target->GetPolicyStatusCMP0022() == cmPolicies::OLD) - // If CMP0022 is NEW then the plain tll signature sets the - // INTERFACE_LINK_LIBRARIES, so if we get here then the project - // cleared the property explicitly and we should not fall back - // to the link implementation. - { - // The link implementation is the default link interface. - cmLinkImplementationLibraries const* impl = - this->Target->GetLinkImplementationLibrariesInternal(config, headTarget); - iface.Libraries.insert(iface.Libraries.end(), - impl->Libraries.begin(), impl->Libraries.end()); - if(this->Target->GetPolicyStatusCMP0022() == cmPolicies::WARN && - !this->PolicyWarnedCMP0022 && !usage_requirements_only) - { - // Compare the link implementation fallback link interface to the - // preferred new link interface property and warn if different. - std::vector ifaceLibs; - static const std::string newProp = "INTERFACE_LINK_LIBRARIES"; - if(const char* newExplicitLibraries = this->Target->GetProperty(newProp)) - { - bool hadHeadSensitiveConditionDummy = false; - this->ExpandLinkItems(newProp, newExplicitLibraries, config, - headTarget, usage_requirements_only, - ifaceLibs, hadHeadSensitiveConditionDummy); - } - if (ifaceLibs != iface.Libraries) - { - std::string oldLibraries = cmJoin(impl->Libraries, ";"); - std::string newLibraries = cmJoin(ifaceLibs, ";"); - if(oldLibraries.empty()) - { oldLibraries = "(empty)"; } - if(newLibraries.empty()) - { newLibraries = "(empty)"; } - - std::ostringstream w; - w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n" - "Target \"" << this->Target->GetName() << "\" has an " - "INTERFACE_LINK_LIBRARIES property. " - "This should be preferred as the source of the link interface " - "for this library but because CMP0022 is not set CMake is " - "ignoring the property and using the link implementation " - "as the link interface instead." - "\n" - "INTERFACE_LINK_LIBRARIES:\n" - " " << newLibraries << "\n" - "Link implementation:\n" - " " << oldLibraries << "\n"; - this->Target->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); - this->PolicyWarnedCMP0022 = true; - } - } - } -} - -//---------------------------------------------------------------------------- -void cmGeneratorTarget::ComputeLinkInterface(const std::string& config, - OptionalLinkInterface& iface, - cmTarget const* headTarget) const -{ - if(iface.ExplicitLibraries) - { - if(this->GetType() == cmTarget::SHARED_LIBRARY - || this->GetType() == cmTarget::STATIC_LIBRARY - || this->GetType() == cmTarget::INTERFACE_LIBRARY) - { - // Shared libraries may have runtime implementation dependencies - // on other shared libraries that are not in the interface. - UNORDERED_SET emitted; - for(std::vector::const_iterator - li = iface.Libraries.begin(); li != iface.Libraries.end(); ++li) - { - emitted.insert(*li); - } - if (this->GetType() != cmTarget::INTERFACE_LIBRARY) - { - cmLinkImplementation const* impl = - this->GetLinkImplementation(config); - for(std::vector::const_iterator - li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li) - { - if(emitted.insert(*li).second) - { - if(li->Target) - { - // This is a runtime dependency on another shared library. - if(li->Target->GetType() == cmTarget::SHARED_LIBRARY) - { - iface.SharedDeps.push_back(*li); - } - } - else - { - // TODO: Recognize shared library file names. Perhaps this - // should be moved to cmComputeLinkInformation, but that creates - // a chicken-and-egg problem since this list is needed for its - // construction. - } - } - } - } - } - } - else if (this->Target->GetPolicyStatusCMP0022() == cmPolicies::WARN - || this->Target->GetPolicyStatusCMP0022() == cmPolicies::OLD) - { - // The link implementation is the default link interface. - cmLinkImplementationLibraries const* - impl = this->Target->GetLinkImplementationLibrariesInternal(config, - headTarget); - iface.ImplementationIsInterface = true; - iface.WrongConfigLibraries = impl->WrongConfigLibraries; - } - - if(this->Target->LinkLanguagePropagatesToDependents()) - { - // Targets using this archive need its language runtime libraries. - if(cmLinkImplementation const* impl = - this->GetLinkImplementation(config)) - { - iface.Languages = impl->Languages; - } - } - - if(this->GetType() == cmTarget::STATIC_LIBRARY) - { - // Construct the property name suffix for this configuration. - std::string suffix = "_"; - if(!config.empty()) - { - suffix += cmSystemTools::UpperCase(config); - } - else - { - suffix += "NOCONFIG"; - } - - // How many repetitions are needed if this library has cyclic - // dependencies? - std::string propName = "LINK_INTERFACE_MULTIPLICITY"; - propName += suffix; - if(const char* config_reps = this->Target->GetProperty(propName)) - { - sscanf(config_reps, "%u", &iface.Multiplicity); - } - else if(const char* reps = - this->Target->GetProperty("LINK_INTERFACE_MULTIPLICITY")) - { - sscanf(reps, "%u", &iface.Multiplicity); - } - } -} - -//---------------------------------------------------------------------------- -const cmLinkImplementation * -cmGeneratorTarget::GetLinkImplementation(const std::string& config) const -{ - // There is no link implementation for imported targets. - if(this->Target->IsImported()) - { - return 0; - } - - cmOptionalLinkImplementation& impl = this->Target->GetLinkImplMap(config); - if(!impl.LibrariesDone) - { - impl.LibrariesDone = true; - this->Target->ComputeLinkImplementationLibraries(config, impl, this->Target); - } - if(!impl.LanguagesDone) - { - impl.LanguagesDone = true; - this->ComputeLinkImplementationLanguages(config, impl); - } - return &impl; -} - -//---------------------------------------------------------------------------- -bool cmGeneratorTarget::GetConfigCommonSourceFiles( - std::vector& files) const -{ - std::vector configs; - this->Makefile->GetConfigurations(configs); - if (configs.empty()) - { - configs.push_back(""); - } - - std::vector::const_iterator it = configs.begin(); - const std::string& firstConfig = *it; - this->Target->GetSourceFiles(files, firstConfig); - - for ( ; it != configs.end(); ++it) - { - std::vector configFiles; - this->Target->GetSourceFiles(configFiles, *it); - if (configFiles != files) - { - std::string firstConfigFiles; - const char* sep = ""; - for (std::vector::const_iterator fi = files.begin(); - fi != files.end(); ++fi) - { - firstConfigFiles += sep; - firstConfigFiles += (*fi)->GetFullPath(); - sep = "\n "; - } - - std::string thisConfigFiles; - sep = ""; - for (std::vector::const_iterator fi = configFiles.begin(); - fi != configFiles.end(); ++fi) - { - thisConfigFiles += sep; - thisConfigFiles += (*fi)->GetFullPath(); - sep = "\n "; - } - std::ostringstream e; - e << "Target \"" << this->GetName() << "\" has source files which vary by " - "configuration. This is not supported by the \"" - << this->LocalGenerator->GetGlobalGenerator()->GetName() - << "\" generator.\n" - "Config \"" << firstConfig << "\":\n" - " " << firstConfigFiles << "\n" - "Config \"" << *it << "\":\n" - " " << thisConfigFiles << "\n"; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); - return false; - } - } - return true; -} - -//---------------------------------------------------------------------------- -void cmGeneratorTarget::GetLanguages(std::set& languages, - const std::string& config) const -{ - std::vector sourceFiles; - this->GetSourceFiles(sourceFiles, config); - for(std::vector::const_iterator - i = sourceFiles.begin(); i != sourceFiles.end(); ++i) - { - const std::string& lang = (*i)->GetLanguage(); - if(!lang.empty()) - { - languages.insert(lang); - } - } - - std::vector objectLibraries; - std::vector externalObjects; - if (!this->Makefile->IsConfigured()) - { - std::vector objectTargets; - this->Target->GetObjectLibrariesCMP0026(objectTargets); - objectLibraries.reserve(objectTargets.size()); - for (std::vector::const_iterator it = objectTargets.begin(); - it != objectTargets.end(); ++it) - { - objectLibraries.push_back( - this->LocalGenerator->GetGlobalGenerator()->GetGeneratorTarget(*it)); - } - } - else - { - this->GetExternalObjects(externalObjects, config); - for(std::vector::const_iterator - i = externalObjects.begin(); i != externalObjects.end(); ++i) - { - std::string objLib = (*i)->GetObjectLibrary(); - if (cmTarget* tgt = this->Makefile->FindTargetToUse(objLib)) - { - objectLibraries.push_back( - this->LocalGenerator->GetGlobalGenerator()->GetGeneratorTarget(tgt)); - } - } - } - for(std::vector::const_iterator - i = objectLibraries.begin(); i != objectLibraries.end(); ++i) - { - (*i)->GetLanguages(languages, config); - } -} - -//---------------------------------------------------------------------------- -void cmGeneratorTarget::ComputeLinkImplementationLanguages( - const std::string& config, - cmOptionalLinkImplementation& impl) const -{ - // This target needs runtime libraries for its source languages. - std::set languages; - // Get languages used in our source files. - this->GetLanguages(languages, config); - // Copy the set of langauges to the link implementation. - impl.Languages.insert(impl.Languages.begin(), - languages.begin(), languages.end()); -} - -//---------------------------------------------------------------------------- -bool cmGeneratorTarget::HaveBuildTreeRPATH(const std::string& config) const -{ - if (this->Target->GetPropertyAsBool("SKIP_BUILD_RPATH")) - { - return false; - } - if(cmLinkImplementationLibraries const* impl = - this->Target->GetLinkImplementationLibraries(config)) - { - return !impl->Libraries.empty(); - } - return false; -} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 6d66bfe..15b3335 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -13,7 +13,6 @@ #define cmGeneratorTarget_h #include "cmStandardIncludes.h" -#include "cmLinkItem.h" class cmCustomCommand; class cmGlobalGenerator; @@ -107,48 +106,6 @@ public: const char *GetLinkInterfaceDependentNumberMaxProperty(const std::string &p, const std::string& config) const; - /** The link interface specifies transitive library dependencies and - other information needed by targets that link to this target. */ - struct LinkInterfaceLibraries - { - // Libraries listed in the interface. - std::vector Libraries; - }; - - struct LinkInterface: public LinkInterfaceLibraries - { - // Languages whose runtime libraries must be linked. - std::vector Languages; - - // Shared library dependencies needed for linking on some platforms. - std::vector SharedDeps; - - // Number of repetitions of a strongly connected component of two - // or more static libraries. - int Multiplicity; - - // Libraries listed for other configurations. - // Needed only for OLD behavior of CMP0003. - std::vector WrongConfigLibraries; - - bool ImplementationIsInterface; - - LinkInterface(): Multiplicity(0), ImplementationIsInterface(false) {} - }; - - /** Get the link interface for the given configuration. Returns 0 - if the target cannot be linked. */ - LinkInterface const* GetLinkInterface(const std::string& config, - cmTarget const* headTarget) const; - - LinkInterface const* - GetImportLinkInterface(const std::string& config, cmTarget const* head, - bool usage_requirements_only) const; - - LinkInterfaceLibraries const* - GetLinkInterfaceLibraries(const std::string& config, - cmTarget const* headTarget, - bool usage_requirements_only) const; /** Get the full path to the target according to the settings in its makefile and the configuration type. */ @@ -226,25 +183,6 @@ public: LinkClosure const* GetLinkClosure(const std::string& config) const; void ComputeLinkClosure(const std::string& config, LinkClosure& lc) const; - cmLinkImplementation const* - GetLinkImplementation(const std::string& config) const; - - void ComputeLinkImplementationLanguages(const std::string& config, - cmOptionalLinkImplementation& impl - ) const; - - // Compute the set of languages compiled by the target. This is - // computed every time it is called because the languages can change - // when source file properties are changed and we do not have enough - // information to forward these property changes to the targets - // until we have per-target object file properties. - void GetLanguages(std::set& languages, - std::string const& config) const; - - bool GetConfigCommonSourceFiles(std::vector& files) const; - - bool HaveBuildTreeRPATH(const std::string& config) const; - /** Full path with trailing slash to the top-level directory holding object files for this target. Includes the build time config name placeholder if needed for the generator. */ @@ -264,17 +202,6 @@ public: std::vector GetIncludeDirectories( const std::string& config, const std::string& lang) const; - void GetCompileOptions(std::vector &result, - const std::string& config, - const std::string& language) const; - - void GetCompileFeatures(std::vector &features, - const std::string& config) const; - - void GetCompileDefinitions(std::vector &result, - const std::string& config, - const std::string& language) const; - bool IsSystemIncludeDirectory(const std::string& dir, const std::string& config) const; @@ -390,8 +317,6 @@ public: const std::string &report, const std::string &compatibilityType) const; - class TargetPropertyEntry; - private: friend class cmTargetTraceDependencies; struct SourceEntry { std::vector Depends; }; @@ -450,53 +375,6 @@ private: }; mutable std::map LinkImplClosureMap; - // Cache link interface computation from each configuration. - struct OptionalLinkInterface: public LinkInterface - { - OptionalLinkInterface(): - LibrariesDone(false), AllDone(false), - Exists(false), HadHeadSensitiveCondition(false), - ExplicitLibraries(0) {} - bool LibrariesDone; - bool AllDone; - bool Exists; - bool HadHeadSensitiveCondition; - const char* ExplicitLibraries; - }; - void ComputeLinkInterface(const std::string& config, - OptionalLinkInterface& iface, - cmTarget const* head) const; - void ComputeLinkInterfaceLibraries(const std::string& config, - OptionalLinkInterface& iface, - cmTarget const* head, - bool usage_requirements_only) const; - - struct HeadToLinkInterfaceMap: - public std::map {}; - typedef std::map - LinkInterfaceMapType; - mutable LinkInterfaceMapType LinkInterfaceMap; - mutable LinkInterfaceMapType LinkInterfaceUsageRequirementsOnlyMap; - - mutable bool PolicyWarnedCMP0022; - mutable bool DebugIncludesDone; - mutable bool DebugCompileOptionsDone; - mutable bool DebugCompileFeaturesDone; - mutable bool DebugCompileDefinitionsDone; - - std::vector IncludeDirectoriesEntries; - std::vector CompileOptionsEntries; - std::vector CompileFeaturesEntries; - std::vector CompileDefinitionsEntries; - - void ExpandLinkItems(std::string const& prop, std::string const& value, - std::string const& config, cmTarget const* headTarget, - bool usage_requirements_only, - std::vector& items, - bool& hadHeadSensitiveCondition) const; - void LookupLinkItems(std::vector const& names, - std::vector& items) const; - typedef std::pair OutputNameKey; typedef std::map OutputNameMapType; mutable OutputNameMapType OutputNameMap; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index c0f1817..503c455 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1550,6 +1550,7 @@ void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes, ti != targets.end(); ++ti) { cmTarget* t = &ti->second; + t->Compute(); cmGeneratorTarget* gt = new cmGeneratorTarget(t, lg); this->GeneratorTargets[t] = gt; generatorTargets[t] = gt; diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 331caad..b240924 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -1134,8 +1134,7 @@ bool cmGlobalUnixMakefileGenerator3 ::NeedRequiresStep(cmTarget const& target) { std::set languages; - cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&target); - gtgt->GetLanguages(languages, + target.GetLanguages(languages, target.GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE")); for(std::set::const_iterator l = languages.begin(); l != languages.end(); ++l) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 756daa0..4ba29f5 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1124,7 +1124,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, // organize the sources std::vector classes; - if (!gtgt->GetConfigCommonSourceFiles(classes)) + if (!cmtarget.GetConfigCommonSourceFiles(classes)) { return false; } @@ -1383,8 +1383,8 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmTarget& cmtarget) if(llang.empty()) { return; } // If the language is compiled as a source trust Xcode to link with it. - cmLinkImplementation const* impl = - gtgt->GetLinkImplementation("NOCONFIG"); + cmTarget::LinkImplementation const* impl = + cmtarget.GetLinkImplementation("NOCONFIG"); for(std::vector::const_iterator li = impl->Languages.begin(); li != impl->Languages.end(); ++li) { @@ -1505,8 +1505,7 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases, } std::vector classes; - cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); - if (!gtgt->GetConfigCommonSourceFiles(classes)) + if (!cmtarget.GetConfigCommonSourceFiles(classes)) { return; } @@ -1806,8 +1805,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, // Compute the compilation flags for each language. std::set languages; - cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); - gtgt->GetLanguages(languages, configName); + target.GetLanguages(languages, configName); std::map cflags; for (std::set::iterator li = languages.begin(); li != languages.end(); ++li) @@ -1829,6 +1827,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, AddCompileOptions(flags, &target, lang, configName); } + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); std::string llang = gtgt->GetLinkerLanguage(configName); if(binary && llang.empty()) { @@ -1856,7 +1855,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, this->AppendDefines(ppDefs, exportMacro); } std::vector targetDefines; - gtgt->GetCompileDefinitions(targetDefines, configName, "C"); + target.GetCompileDefinitions(targetDefines, configName, "C"); this->AppendDefines(ppDefs, targetDefines); buildSettings->AddAttribute ("GCC_PREPROCESSOR_DEFINITIONS", ppDefs.CreateList()); @@ -2558,8 +2557,7 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget) if(cmtarget.GetType() == cmTarget::UTILITY) { std::vector sources; - cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); - if (!gtgt->GetConfigCommonSourceFiles(sources)) + if (!cmtarget.GetConfigCommonSourceFiles(sources)) { return 0; } @@ -3087,8 +3085,7 @@ bool cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root, } std::vector classes; - cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); - if (!gtgt->GetConfigCommonSourceFiles(classes)) + if (!cmtarget.GetConfigCommonSourceFiles(classes)) { return false; } diff --git a/Source/cmLinkItem.h b/Source/cmLinkItem.h index f1d914f..a5427de 100644 --- a/Source/cmLinkItem.h +++ b/Source/cmLinkItem.h @@ -56,21 +56,4 @@ struct cmLinkImplementationLibraries std::vector WrongConfigLibraries; }; -struct cmLinkImplementation: public cmLinkImplementationLibraries -{ - // Languages whose runtime libraries must be linked. - std::vector Languages; -}; - -// Cache link implementation computation from each configuration. -struct cmOptionalLinkImplementation: public cmLinkImplementation -{ - cmOptionalLinkImplementation(): - LibrariesDone(false), LanguagesDone(false), - HadHeadSensitiveCondition(false) {} - bool LibrariesDone; - bool LanguagesDone; - bool HadHeadSensitiveCondition; -}; - #endif diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index c1cc241..edb644d 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1083,8 +1083,7 @@ void cmLocalGenerator::AddCompileDefinitions(std::set& defines, const std::string& lang) { std::vector targetDefines; - cmGeneratorTarget* gtgt = this->GlobalGenerator->GetGeneratorTarget(target); - gtgt->GetCompileDefinitions(targetDefines, config, lang); + target->GetCompileDefinitions(targetDefines, config, lang); this->AppendDefines(defines, targetDefines); } @@ -1095,10 +1094,6 @@ void cmLocalGenerator::AddCompileOptions( ) { std::string langFlagRegexVar = std::string("CMAKE_")+lang+"_FLAG_REGEX"; - - cmGeneratorTarget* gtgt = - this->GlobalGenerator->GetGeneratorTarget(target); - if(const char* langFlagRegexStr = this->Makefile->GetDefinition(langFlagRegexVar)) { @@ -1109,7 +1104,7 @@ void cmLocalGenerator::AddCompileOptions( { cmSystemTools::ParseWindowsCommandLine(targetFlags, opts); } - gtgt->GetCompileOptions(opts, config, lang); + target->GetCompileOptions(opts, config, lang); for(std::vector::const_iterator i = opts.begin(); i != opts.end(); ++i) { @@ -1130,7 +1125,7 @@ void cmLocalGenerator::AddCompileOptions( this->AppendFlags(flags, targetFlags); } std::vector opts; - gtgt->GetCompileOptions(opts, config, lang); + target->GetCompileOptions(opts, config, lang); for(std::vector::const_iterator i = opts.begin(); i != opts.end(); ++i) { @@ -1139,7 +1134,7 @@ void cmLocalGenerator::AddCompileOptions( } } std::vector features; - gtgt->GetCompileFeatures(features, config); + target->GetCompileFeatures(features, config); for(std::vector::const_iterator it = features.begin(); it != features.end(); ++it) { diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 50fcf21..ce370bc 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1257,8 +1257,7 @@ cmLocalUnixMakefileGenerator3 { // Get the set of source languages in the target. std::set languages; - cmGeneratorTarget *gtgt = this->GlobalGenerator->GetGeneratorTarget(&target); - gtgt->GetLanguages(languages, + target.GetLanguages(languages, this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); fout << "\n" << "# Per-language clean rules from dependency scanning.\n" diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index cf88a74..0b3df90 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -276,7 +276,7 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags() { // write language flags for target std::set languages; - this->GeneratorTarget->GetLanguages(languages, + this->Target->GetLanguages(languages, this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); // put the compiler in the rules.make file so that if it changes // things rebuild diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 94e517b..f85e70e 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -403,8 +403,7 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg, ) { std::vector srcFiles; - cmGeneratorTarget* gtgt = lg->GetGlobalGenerator()->GetGeneratorTarget(target); - gtgt->GetConfigCommonSourceFiles(srcFiles); + target->GetConfigCommonSourceFiles(srcFiles); for(std::vector::const_iterator fileIt = srcFiles.begin(); fileIt != srcFiles.end(); ++fileIt) @@ -475,6 +474,8 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg, /*byproducts=*/rcc_output, depends, commandLines, false, autogenComment.c_str()); + autogenTarget->Compute(); + cmGeneratorTarget* gt = new cmGeneratorTarget(autogenTarget, lg); makefile->AddGeneratorTarget(autogenTarget, gt); @@ -662,10 +663,7 @@ void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target) const char* sepHeaders = ""; std::vector srcFiles; - cmGeneratorTarget *gtgt = target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(target); - gtgt->GetConfigCommonSourceFiles(srcFiles); + target->GetConfigCommonSourceFiles(srcFiles); const char *skipMocSep = ""; const char *skipUicSep = ""; @@ -1050,10 +1048,7 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) cmMakefile *makefile = target->GetMakefile(); std::vector srcFiles; - cmGeneratorTarget *gtgt = target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(target); - gtgt->GetConfigCommonSourceFiles(srcFiles); + target->GetConfigCommonSourceFiles(srcFiles); std::string qrcInputs; const char* qrcInputsSep = ""; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index f19a52c..49b3239 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -77,11 +77,13 @@ public: cmTargetInternals() : Backtrace() { + this->PolicyWarnedCMP0022 = false; this->UtilityItemsDone = false; } cmTargetInternals(cmTargetInternals const&) : Backtrace() { + this->PolicyWarnedCMP0022 = false; this->UtilityItemsDone = false; } ~cmTargetInternals(); @@ -89,6 +91,36 @@ public: // The backtrace when the target was created. cmListFileBacktrace Backtrace; + // Cache link interface computation from each configuration. + struct OptionalLinkInterface: public cmTarget::LinkInterface + { + OptionalLinkInterface(): + LibrariesDone(false), AllDone(false), + Exists(false), HadHeadSensitiveCondition(false), + ExplicitLibraries(0) {} + bool LibrariesDone; + bool AllDone; + bool Exists; + bool HadHeadSensitiveCondition; + const char* ExplicitLibraries; + }; + void ComputeLinkInterface(cmTarget const* thisTarget, + const std::string& config, + OptionalLinkInterface& iface, + cmTarget const* head) const; + void ComputeLinkInterfaceLibraries(cmTarget const* thisTarget, + const std::string& config, + OptionalLinkInterface& iface, + cmTarget const* head, + bool usage_requirements_only); + + struct HeadToLinkInterfaceMap: + public std::map {}; + typedef std::map + LinkInterfaceMapType; + LinkInterfaceMapType LinkInterfaceMap; + LinkInterfaceMapType LinkInterfaceUsageRequirementsOnlyMap; + bool PolicyWarnedCMP0022; typedef std::map OutputInfoMapType; OutputInfoMapType OutputInfoMap; @@ -96,8 +128,27 @@ public: typedef std::map ImportInfoMapType; ImportInfoMapType ImportInfoMap; + // Cache link implementation computation from each configuration. + struct OptionalLinkImplementation: public cmTarget::LinkImplementation + { + OptionalLinkImplementation(): + LibrariesDone(false), LanguagesDone(false), + HadHeadSensitiveCondition(false) {} + bool LibrariesDone; + bool LanguagesDone; + bool HadHeadSensitiveCondition; + }; + void ComputeLinkImplementationLibraries(cmTarget const* thisTarget, + const std::string& config, + OptionalLinkImplementation& impl, + cmTarget const* head) const; + void ComputeLinkImplementationLanguages(cmTarget const* thisTarget, + const std::string& config, + OptionalLinkImplementation& impl + ) const; + struct HeadToLinkImplementationMap: - public std::map {}; + public std::map {}; typedef std::map LinkImplMapType; LinkImplMapType LinkImplMap; @@ -121,12 +172,16 @@ public: }; std::vector IncludeDirectoriesEntries; std::vector IncludeDirectoriesBacktraces; + std::vector IncludeDirectoriesItems; std::vector CompileOptionsEntries; std::vector CompileOptionsBacktraces; + std::vector CompileOptionsItems; std::vector CompileFeaturesEntries; std::vector CompileFeaturesBacktraces; + std::vector CompileFeaturesItems; std::vector CompileDefinitionsEntries; std::vector CompileDefinitionsBacktraces; + std::vector CompileDefinitionsItems; std::vector SourceEntries; std::vector LinkImplementationPropertyEntries; @@ -155,6 +210,10 @@ cmTarget::cmTarget() this->IsApple = false; this->IsImportedTarget = false; this->BuildInterfaceIncludesAppended = false; + this->DebugIncludesDone = false; + this->DebugCompileOptionsDone = false; + this->DebugCompileFeaturesDone = false; + this->DebugCompileDefinitionsDone = false; this->DebugSourcesDone = false; this->LinkImplementationLanguageIsContextDependent = true; } @@ -397,6 +456,29 @@ void CreatePropertyGeneratorExpressions( } } +void cmTarget::Compute() +{ + CreatePropertyGeneratorExpressions( + this->Internal->IncludeDirectoriesEntries, + this->Internal->IncludeDirectoriesBacktraces, + this->Internal->IncludeDirectoriesItems); + + CreatePropertyGeneratorExpressions( + this->Internal->CompileOptionsEntries, + this->Internal->CompileOptionsBacktraces, + this->Internal->CompileOptionsItems); + + CreatePropertyGeneratorExpressions( + this->Internal->CompileFeaturesEntries, + this->Internal->CompileFeaturesBacktraces, + this->Internal->CompileFeaturesItems); + + CreatePropertyGeneratorExpressions( + this->Internal->CompileDefinitionsEntries, + this->Internal->CompileDefinitionsBacktraces, + this->Internal->CompileDefinitionsItems); +} + //---------------------------------------------------------------------------- void cmTarget::AddUtility(const std::string& u, cmMakefile *makefile) { @@ -456,6 +538,8 @@ void cmTarget::ClearLinkMaps() { this->LinkImplementationLanguageIsContextDependent = true; this->Internal->LinkImplMap.clear(); + this->Internal->LinkInterfaceMap.clear(); + this->Internal->LinkInterfaceUsageRequirementsOnlyMap.clear(); this->Internal->SourceFilesMap.clear(); } @@ -726,6 +810,62 @@ void cmTarget::GetSourceFiles(std::vector &files, } //---------------------------------------------------------------------------- +bool +cmTarget::GetConfigCommonSourceFiles(std::vector& files) const +{ + std::vector configs; + this->Makefile->GetConfigurations(configs); + if (configs.empty()) + { + configs.push_back(""); + } + + std::vector::const_iterator it = configs.begin(); + const std::string& firstConfig = *it; + this->GetSourceFiles(files, firstConfig); + + for ( ; it != configs.end(); ++it) + { + std::vector configFiles; + this->GetSourceFiles(configFiles, *it); + if (configFiles != files) + { + std::string firstConfigFiles; + const char* sep = ""; + for (std::vector::const_iterator fi = files.begin(); + fi != files.end(); ++fi) + { + firstConfigFiles += sep; + firstConfigFiles += (*fi)->GetFullPath(); + sep = "\n "; + } + + std::string thisConfigFiles; + sep = ""; + for (std::vector::const_iterator fi = configFiles.begin(); + fi != configFiles.end(); ++fi) + { + thisConfigFiles += sep; + thisConfigFiles += (*fi)->GetFullPath(); + sep = "\n "; + } + std::ostringstream e; + e << "Target \"" << this->Name << "\" has source files which vary by " + "configuration. This is not supported by the \"" + << this->Makefile->GetGlobalGenerator()->GetName() + << "\" generator.\n" + "Config \"" << firstConfig << "\":\n" + " " << firstConfigFiles << "\n" + "Config \"" << *it << "\":\n" + " " << thisConfigFiles << "\n"; + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); + return false; + } + } + return true; +} + +//---------------------------------------------------------------------------- void cmTarget::GetSourceFiles(std::vector &files, const std::string& config) const { @@ -1214,46 +1354,6 @@ cmTarget::AddSystemIncludeDirectories(const std::set &incs) this->SystemIncludeDirectories.insert(incs.begin(), incs.end()); } -cmStringRange cmTarget::GetIncludeDirectoriesEntries() const -{ - return cmMakeRange(this->Internal->IncludeDirectoriesEntries); -} - -cmBacktraceRange cmTarget::GetIncludeDirectoriesBacktraces() const -{ - return cmMakeRange(this->Internal->IncludeDirectoriesBacktraces); -} - -cmStringRange cmTarget::GetCompileOptionsEntries() const -{ - return cmMakeRange(this->Internal->CompileOptionsEntries); -} - -cmBacktraceRange cmTarget::GetCompileOptionsBacktraces() const -{ - return cmMakeRange(this->Internal->CompileOptionsBacktraces); -} - -cmStringRange cmTarget::GetCompileFeaturesEntries() const -{ - return cmMakeRange(this->Internal->CompileFeaturesEntries); -} - -cmBacktraceRange cmTarget::GetCompileFeaturesBacktraces() const -{ - return cmMakeRange(this->Internal->CompileFeaturesBacktraces); -} - -cmStringRange cmTarget::GetCompileDefinitionsEntries() const -{ - return cmMakeRange(this->Internal->CompileDefinitionsEntries); -} - -cmBacktraceRange cmTarget::GetCompileDefinitionsBacktraces() const -{ - return cmMakeRange(this->Internal->CompileDefinitionsBacktraces); -} - #if defined(_WIN32) && !defined(__CYGWIN__) //---------------------------------------------------------------------------- void @@ -1851,126 +1951,630 @@ void cmTarget::InsertCompileDefinition(std::string const& entry, } //---------------------------------------------------------------------------- -void cmTarget::MaybeInvalidatePropertyCache(const std::string& prop) +static void processIncludeDirectories(cmTarget const* tgt, + const std::vector &entries, + std::vector &includes, + UNORDERED_SET &uniqueIncludes, + cmGeneratorExpressionDAGChecker *dagChecker, + const std::string& config, bool debugIncludes, + const std::string& language) { - // Wipe out maps caching information affected by this property. - if(this->IsImported() && cmHasLiteralPrefix(prop, "IMPORTED")) - { - this->Internal->ImportInfoMap.clear(); - } - if(!this->IsImported() && cmHasLiteralPrefix(prop, "LINK_INTERFACE_")) + cmMakefile *mf = tgt->GetMakefile(); + + for (std::vector::const_iterator + it = entries.begin(), end = entries.end(); it != end; ++it) { - this->ClearLinkMaps(); + cmLinkImplItem const& item = (*it)->LinkImplItem; + std::string const& targetName = item; + bool const fromImported = item.Target && item.Target->IsImported(); + bool const checkCMP0027 = item.FromGenex; + std::vector entryIncludes; + cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf, + config, + false, + tgt, + dagChecker, language), + entryIncludes); + + std::string usedIncludes; + for(std::vector::iterator + li = entryIncludes.begin(); li != entryIncludes.end(); ++li) + { + if (fromImported + && !cmSystemTools::FileExists(li->c_str())) + { + std::ostringstream e; + cmake::MessageType messageType = cmake::FATAL_ERROR; + if (checkCMP0027) + { + switch(tgt->GetPolicyStatusCMP0027()) + { + case cmPolicies::WARN: + e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0027) << "\n"; + case cmPolicies::OLD: + messageType = cmake::AUTHOR_WARNING; + break; + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::NEW: + break; + } + } + e << "Imported target \"" << targetName << "\" includes " + "non-existent path\n \"" << *li << "\"\nin its " + "INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:\n" + "* The path was deleted, renamed, or moved to another " + "location.\n" + "* An install or uninstall procedure did not complete " + "successfully.\n" + "* The installation package was faulty and references files it " + "does not provide.\n"; + tgt->GetMakefile()->IssueMessage(messageType, e.str()); + return; + } + + if (!cmSystemTools::FileIsFullPath(li->c_str())) + { + std::ostringstream e; + bool noMessage = false; + cmake::MessageType messageType = cmake::FATAL_ERROR; + if (!targetName.empty()) + { + e << "Target \"" << targetName << "\" contains relative " + "path in its INTERFACE_INCLUDE_DIRECTORIES:\n" + " \"" << *li << "\""; + } + else + { + switch(tgt->GetPolicyStatusCMP0021()) + { + case cmPolicies::WARN: + { + e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0021) << "\n"; + messageType = cmake::AUTHOR_WARNING; + } + break; + case cmPolicies::OLD: + noMessage = true; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::NEW: + // Issue the fatal message. + break; + } + e << "Found relative path while evaluating include directories of " + "\"" << tgt->GetName() << "\":\n \"" << *li << "\"\n"; + } + if (!noMessage) + { + tgt->GetMakefile()->IssueMessage(messageType, e.str()); + if (messageType == cmake::FATAL_ERROR) + { + return; + } + } + } + + if (!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 (!usedIncludes.empty()) + { + mf->GetCMakeInstance()->IssueMessage(cmake::LOG, + std::string("Used includes for target ") + + tgt->GetName() + ":\n" + + usedIncludes, (*it)->ge->GetBacktrace()); + } } } //---------------------------------------------------------------------------- -static void cmTargetCheckLINK_INTERFACE_LIBRARIES( - const std::string& prop, const char* value, cmMakefile* context, - bool imported) +std::vector +cmTarget::GetIncludeDirectories(const std::string& config, + const std::string& language) const { - // Look for link-type keywords in the value. - static cmsys::RegularExpression - keys("(^|;)(debug|optimized|general)(;|$)"); - if(!keys.find(value)) + std::vector includes; + UNORDERED_SET uniqueIncludes; + + cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), + "INCLUDE_DIRECTORIES", 0, 0); + + std::vector debugProperties; + const char *debugProp = + this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); + if (debugProp) { - return; + cmSystemTools::ExpandListArgument(debugProp, debugProperties); } - // Support imported and non-imported versions of the property. - const char* base = (imported? - "IMPORTED_LINK_INTERFACE_LIBRARIES" : - "LINK_INTERFACE_LIBRARIES"); + bool debugIncludes = !this->DebugIncludesDone + && std::find(debugProperties.begin(), + debugProperties.end(), + "INCLUDE_DIRECTORIES") + != debugProperties.end(); - // Report an error. - std::ostringstream e; - e << "Property " << prop << " may not contain link-type keyword \"" - << keys.match(2) << "\". " - << "The " << base << " property has a per-configuration " - << "version called " << base << "_ which may be " - << "used to specify per-configuration rules."; - if(!imported) + if (this->Makefile->IsConfigured()) { - e << " " - << "Alternatively, an IMPORTED library may be created, configured " - << "with a per-configuration location, and then named in the " - << "property value. " - << "See the add_library command's IMPORTED mode for details." - << "\n" - << "If you have a list of libraries that already contains the " - << "keyword, use the target_link_libraries command with its " - << "LINK_INTERFACE_LIBRARIES mode to set the property. " - << "The command automatically recognizes link-type keywords and sets " - << "the LINK_INTERFACE_LIBRARIES and LINK_INTERFACE_LIBRARIES_DEBUG " - << "properties accordingly."; + this->DebugIncludesDone = true; } - context->IssueMessage(cmake::FATAL_ERROR, e.str()); -} -//---------------------------------------------------------------------------- -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)) + processIncludeDirectories(this, + this->Internal->IncludeDirectoriesItems, + includes, + uniqueIncludes, + &dagChecker, + config, + debugIncludes, + language); + + std::vector + linkInterfaceIncludeDirectoriesEntries; + this->Internal->AddInterfaceEntries( + this, config, "INTERFACE_INCLUDE_DIRECTORIES", + linkInterfaceIncludeDirectoriesEntries); + + if(this->Makefile->IsOn("APPLE")) { - return; + cmLinkImplementationLibraries const* impl = + this->GetLinkImplementationLibraries(config); + for(std::vector::const_iterator + it = impl->Libraries.begin(); + it != impl->Libraries.end(); ++it) + { + std::string libDir = cmSystemTools::CollapseFullPath(*it); + + static cmsys::RegularExpression + frameworkCheck("(.*\\.framework)(/Versions/[^/]+)?/[^/]+$"); + if(!frameworkCheck.find(libDir)) + { + continue; + } + + libDir = frameworkCheck.match(1); + + cmGeneratorExpression ge; + cmsys::auto_ptr cge = + ge.Parse(libDir.c_str()); + linkInterfaceIncludeDirectoriesEntries + .push_back(new cmTargetInternals::TargetPropertyEntry(cge)); + } } - // Report an error. - std::ostringstream e; + processIncludeDirectories(this, + linkInterfaceIncludeDirectoriesEntries, + includes, + uniqueIncludes, + &dagChecker, + config, + debugIncludes, + language); - 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."; + cmDeleteAll(linkInterfaceIncludeDirectoriesEntries); - context->IssueMessage(cmake::FATAL_ERROR, e.str()); + return includes; } //---------------------------------------------------------------------------- -void cmTarget::CheckProperty(const std::string& prop, - cmMakefile* context) const +static void processCompileOptionsInternal(cmTarget const* tgt, + const std::vector &entries, + std::vector &options, + UNORDERED_SET &uniqueOptions, + cmGeneratorExpressionDAGChecker *dagChecker, + const std::string& config, bool debugOptions, const char *logName, + std::string const& language) { - // Certain properties need checking. - if(cmHasLiteralPrefix(prop, "LINK_INTERFACE_LIBRARIES")) - { - if(const char* value = this->GetProperty(prop)) - { - cmTargetCheckLINK_INTERFACE_LIBRARIES(prop, value, context, false); - } - } - if(cmHasLiteralPrefix(prop, "IMPORTED_LINK_INTERFACE_LIBRARIES")) + cmMakefile *mf = tgt->GetMakefile(); + + for (std::vector::const_iterator + it = entries.begin(), end = entries.end(); it != end; ++it) { - if(const char* value = this->GetProperty(prop)) + std::vector entryOptions; + cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf, + config, + false, + tgt, + dagChecker, + language), + entryOptions); + std::string usedOptions; + for(std::vector::iterator + li = entryOptions.begin(); li != entryOptions.end(); ++li) { - cmTargetCheckLINK_INTERFACE_LIBRARIES(prop, value, context, true); + std::string const& opt = *li; + + if(uniqueOptions.insert(opt).second) + { + options.push_back(opt); + if (debugOptions) + { + usedOptions += " * " + opt + "\n"; + } + } } - } - if(cmHasLiteralPrefix(prop, "INTERFACE_LINK_LIBRARIES")) - { - if(const char* value = this->GetProperty(prop)) + if (!usedOptions.empty()) { - cmTargetCheckINTERFACE_LINK_LIBRARIES(value, context); + mf->GetCMakeInstance()->IssueMessage(cmake::LOG, + std::string("Used compile ") + logName + + std::string(" for target ") + + tgt->GetName() + ":\n" + + usedOptions, (*it)->ge->GetBacktrace()); } } } //---------------------------------------------------------------------------- -void cmTarget::MarkAsImported() +static void processCompileOptions(cmTarget const* tgt, + const std::vector &entries, + std::vector &options, + UNORDERED_SET &uniqueOptions, + cmGeneratorExpressionDAGChecker *dagChecker, + const std::string& config, bool debugOptions, + std::string const& language) { - this->IsImportedTarget = true; + processCompileOptionsInternal(tgt, entries, options, uniqueOptions, + dagChecker, config, debugOptions, "options", + language); } //---------------------------------------------------------------------------- -bool cmTarget::HaveWellDefinedOutputFiles() const +void cmTarget::GetCompileOptions(std::vector &result, + const std::string& config, + const std::string& language) const { - return - this->GetType() == cmTarget::STATIC_LIBRARY || - this->GetType() == cmTarget::SHARED_LIBRARY || - this->GetType() == cmTarget::MODULE_LIBRARY || + UNORDERED_SET uniqueOptions; + + cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), + "COMPILE_OPTIONS", 0, 0); + + std::vector debugProperties; + const char *debugProp = + this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); + if (debugProp) + { + cmSystemTools::ExpandListArgument(debugProp, debugProperties); + } + + bool debugOptions = !this->DebugCompileOptionsDone + && std::find(debugProperties.begin(), + debugProperties.end(), + "COMPILE_OPTIONS") + != debugProperties.end(); + + if (this->Makefile->IsConfigured()) + { + this->DebugCompileOptionsDone = true; + } + + processCompileOptions(this, + this->Internal->CompileOptionsItems, + result, + uniqueOptions, + &dagChecker, + config, + debugOptions, + language); + + std::vector + linkInterfaceCompileOptionsEntries; + + this->Internal->AddInterfaceEntries( + this, config, "INTERFACE_COMPILE_OPTIONS", + linkInterfaceCompileOptionsEntries); + + processCompileOptions(this, + linkInterfaceCompileOptionsEntries, + result, + uniqueOptions, + &dagChecker, + config, + debugOptions, + language); + + cmDeleteAll(linkInterfaceCompileOptionsEntries); +} + +//---------------------------------------------------------------------------- +static void processCompileDefinitions(cmTarget const* tgt, + const std::vector &entries, + std::vector &options, + UNORDERED_SET &uniqueOptions, + cmGeneratorExpressionDAGChecker *dagChecker, + const std::string& config, bool debugOptions, + std::string const& language) +{ + processCompileOptionsInternal(tgt, entries, options, uniqueOptions, + dagChecker, config, debugOptions, + "definitions", language); +} + +//---------------------------------------------------------------------------- +void cmTarget::GetCompileDefinitions(std::vector &list, + const std::string& config, + const std::string& language) const +{ + UNORDERED_SET uniqueOptions; + + cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), + "COMPILE_DEFINITIONS", 0, 0); + + std::vector debugProperties; + const char *debugProp = + this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); + if (debugProp) + { + cmSystemTools::ExpandListArgument(debugProp, debugProperties); + } + + bool debugDefines = !this->DebugCompileDefinitionsDone + && std::find(debugProperties.begin(), + debugProperties.end(), + "COMPILE_DEFINITIONS") + != debugProperties.end(); + + if (this->Makefile->IsConfigured()) + { + this->DebugCompileDefinitionsDone = true; + } + + processCompileDefinitions(this, + this->Internal->CompileDefinitionsItems, + list, + uniqueOptions, + &dagChecker, + config, + debugDefines, + language); + + std::vector + linkInterfaceCompileDefinitionsEntries; + this->Internal->AddInterfaceEntries( + this, config, "INTERFACE_COMPILE_DEFINITIONS", + linkInterfaceCompileDefinitionsEntries); + if (!config.empty()) + { + std::string configPropName = "COMPILE_DEFINITIONS_" + + cmSystemTools::UpperCase(config); + const char *configProp = this->GetProperty(configPropName); + if (configProp) + { + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0043)) + { + case cmPolicies::WARN: + { + std::ostringstream e; + e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0043); + this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, + e.str()); + } + case cmPolicies::OLD: + { + cmGeneratorExpression ge; + cmsys::auto_ptr cge = + ge.Parse(configProp); + linkInterfaceCompileDefinitionsEntries + .push_back(new cmTargetInternals::TargetPropertyEntry(cge)); + } + break; + case cmPolicies::NEW: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::REQUIRED_IF_USED: + break; + } + } + } + + processCompileDefinitions(this, + linkInterfaceCompileDefinitionsEntries, + list, + uniqueOptions, + &dagChecker, + config, + debugDefines, + language); + + cmDeleteAll(linkInterfaceCompileDefinitionsEntries); +} + +//---------------------------------------------------------------------------- +static void processCompileFeatures(cmTarget const* tgt, + const std::vector &entries, + std::vector &options, + UNORDERED_SET &uniqueOptions, + cmGeneratorExpressionDAGChecker *dagChecker, + const std::string& config, bool debugOptions) +{ + processCompileOptionsInternal(tgt, entries, options, uniqueOptions, + dagChecker, config, debugOptions, "features", + std::string()); +} + +//---------------------------------------------------------------------------- +void cmTarget::GetCompileFeatures(std::vector &result, + const std::string& config) const +{ + UNORDERED_SET uniqueFeatures; + + cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), + "COMPILE_FEATURES", + 0, 0); + + std::vector debugProperties; + const char *debugProp = + this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); + if (debugProp) + { + cmSystemTools::ExpandListArgument(debugProp, debugProperties); + } + + bool debugFeatures = !this->DebugCompileFeaturesDone + && std::find(debugProperties.begin(), + debugProperties.end(), + "COMPILE_FEATURES") + != debugProperties.end(); + + if (this->Makefile->IsConfigured()) + { + this->DebugCompileFeaturesDone = true; + } + + processCompileFeatures(this, + this->Internal->CompileFeaturesItems, + result, + uniqueFeatures, + &dagChecker, + config, + debugFeatures); + + std::vector + linkInterfaceCompileFeaturesEntries; + this->Internal->AddInterfaceEntries( + this, config, "INTERFACE_COMPILE_FEATURES", + linkInterfaceCompileFeaturesEntries); + + processCompileFeatures(this, + linkInterfaceCompileFeaturesEntries, + result, + uniqueFeatures, + &dagChecker, + config, + debugFeatures); + + cmDeleteAll(linkInterfaceCompileFeaturesEntries); +} + +//---------------------------------------------------------------------------- +void cmTarget::MaybeInvalidatePropertyCache(const std::string& prop) +{ + // Wipe out maps caching information affected by this property. + if(this->IsImported() && cmHasLiteralPrefix(prop, "IMPORTED")) + { + this->Internal->ImportInfoMap.clear(); + } + if(!this->IsImported() && cmHasLiteralPrefix(prop, "LINK_INTERFACE_")) + { + this->ClearLinkMaps(); + } +} + +//---------------------------------------------------------------------------- +static void cmTargetCheckLINK_INTERFACE_LIBRARIES( + const std::string& prop, const char* value, cmMakefile* context, + bool imported) +{ + // Look for link-type keywords in the value. + static cmsys::RegularExpression + keys("(^|;)(debug|optimized|general)(;|$)"); + if(!keys.find(value)) + { + return; + } + + // Support imported and non-imported versions of the property. + const char* base = (imported? + "IMPORTED_LINK_INTERFACE_LIBRARIES" : + "LINK_INTERFACE_LIBRARIES"); + + // Report an error. + std::ostringstream e; + e << "Property " << prop << " may not contain link-type keyword \"" + << keys.match(2) << "\". " + << "The " << base << " property has a per-configuration " + << "version called " << base << "_ which may be " + << "used to specify per-configuration rules."; + if(!imported) + { + e << " " + << "Alternatively, an IMPORTED library may be created, configured " + << "with a per-configuration location, and then named in the " + << "property value. " + << "See the add_library command's IMPORTED mode for details." + << "\n" + << "If you have a list of libraries that already contains the " + << "keyword, use the target_link_libraries command with its " + << "LINK_INTERFACE_LIBRARIES mode to set the property. " + << "The command automatically recognizes link-type keywords and sets " + << "the LINK_INTERFACE_LIBRARIES and LINK_INTERFACE_LIBRARIES_DEBUG " + << "properties accordingly."; + } + context->IssueMessage(cmake::FATAL_ERROR, e.str()); +} + +//---------------------------------------------------------------------------- +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. + std::ostringstream 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 std::string& prop, + cmMakefile* context) const +{ + // Certain properties need checking. + if(cmHasLiteralPrefix(prop, "LINK_INTERFACE_LIBRARIES")) + { + if(const char* value = this->GetProperty(prop)) + { + cmTargetCheckLINK_INTERFACE_LIBRARIES(prop, value, context, false); + } + } + if(cmHasLiteralPrefix(prop, "IMPORTED_LINK_INTERFACE_LIBRARIES")) + { + if(const char* value = this->GetProperty(prop)) + { + cmTargetCheckLINK_INTERFACE_LIBRARIES(prop, value, context, true); + } + } + if(cmHasLiteralPrefix(prop, "INTERFACE_LINK_LIBRARIES")) + { + if(const char* value = this->GetProperty(prop)) + { + cmTargetCheckINTERFACE_LINK_LIBRARIES(value, context); + } + } +} + +//---------------------------------------------------------------------------- +void cmTarget::MarkAsImported() +{ + this->IsImportedTarget = true; +} + +//---------------------------------------------------------------------------- +bool cmTarget::HaveWellDefinedOutputFiles() const +{ + return + this->GetType() == cmTarget::STATIC_LIBRARY || + this->GetType() == cmTarget::SHARED_LIBRARY || + this->GetType() == cmTarget::MODULE_LIBRARY || this->GetType() == cmTarget::EXECUTABLE; } @@ -2492,6 +3096,51 @@ bool cmTarget::GetPropertyAsBool(const std::string& prop) const } //---------------------------------------------------------------------------- +void cmTarget::ExpandLinkItems(std::string const& prop, + std::string const& value, + std::string const& config, + cmTarget const* headTarget, + bool usage_requirements_only, + std::vector& items, + bool& hadHeadSensitiveCondition) const +{ + cmGeneratorExpression ge; + cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), prop, 0, 0); + // The $ expression may be in a link interface to specify private + // link dependencies that are otherwise excluded from usage requirements. + if(usage_requirements_only) + { + dagChecker.SetTransitivePropertiesOnly(); + } + std::vector libs; + cmsys::auto_ptr cge = ge.Parse(value); + cmSystemTools::ExpandListArgument(cge->Evaluate( + this->Makefile, + config, + false, + headTarget, + this, &dagChecker), libs); + this->LookupLinkItems(libs, items); + hadHeadSensitiveCondition = cge->GetHadHeadSensitiveCondition(); +} + +//---------------------------------------------------------------------------- +void cmTarget::LookupLinkItems(std::vector const& names, + std::vector& items) const +{ + for(std::vector::const_iterator i = names.begin(); + i != names.end(); ++i) + { + std::string name = this->CheckCMP0004(*i); + if(name == this->GetName() || name.empty()) + { + continue; + } + items.push_back(cmLinkItem(name, this->FindTargetToLink(name))); + } +} + +//---------------------------------------------------------------------------- const char* cmTarget::GetSuffixVariableInternal(bool implib) const { switch(this->GetType()) @@ -2755,6 +3404,21 @@ void cmTarget::SetPropertyDefault(const std::string& property, } //---------------------------------------------------------------------------- +bool cmTarget::HaveBuildTreeRPATH(const std::string& config) const +{ + if (this->GetPropertyAsBool("SKIP_BUILD_RPATH")) + { + return false; + } + if(cmLinkImplementationLibraries const* impl = + this->GetLinkImplementationLibraries(config)) + { + return !impl->Libraries.empty(); + } + return false; +} + +//---------------------------------------------------------------------------- bool cmTarget::HaveInstallTreeRPATH() const { const char* install_rpath = this->GetProperty("INSTALL_RPATH"); @@ -3076,6 +3740,50 @@ cmTarget::GetObjectLibrariesCMP0026(std::vector& objlibs) const } //---------------------------------------------------------------------------- +void cmTarget::GetLanguages(std::set& languages, + const std::string& config) const +{ + std::vector sourceFiles; + this->GetSourceFiles(sourceFiles, config); + for(std::vector::const_iterator + i = sourceFiles.begin(); i != sourceFiles.end(); ++i) + { + const std::string& lang = (*i)->GetLanguage(); + if(!lang.empty()) + { + languages.insert(lang); + } + } + + std::vector objectLibraries; + std::vector externalObjects; + if (!this->Makefile->IsConfigured()) + { + this->GetObjectLibrariesCMP0026(objectLibraries); + } + else + { + cmGeneratorTarget* gt = this->Makefile->GetGlobalGenerator() + ->GetGeneratorTarget(this); + gt->GetExternalObjects(externalObjects, config); + for(std::vector::const_iterator + i = externalObjects.begin(); i != externalObjects.end(); ++i) + { + std::string objLib = (*i)->GetObjectLibrary(); + if (cmTarget* tgt = this->Makefile->FindTargetToUse(objLib)) + { + objectLibraries.push_back(tgt); + } + } + } + for(std::vector::const_iterator + i = objectLibraries.begin(); i != objectLibraries.end(); ++i) + { + (*i)->GetLanguages(languages, config); + } +} + +//---------------------------------------------------------------------------- cmTarget::ImportInfo const* cmTarget::GetImportInfo(const std::string& config) const { @@ -3425,6 +4133,393 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, } //---------------------------------------------------------------------------- +cmTarget::LinkInterface const* cmTarget::GetLinkInterface( + const std::string& config, + cmTarget const* head) const +{ + // Imported targets have their own link interface. + if(this->IsImported()) + { + return this->GetImportLinkInterface(config, head, false); + } + + // Link interfaces are not supported for executables that do not + // export symbols. + if(this->GetType() == cmTarget::EXECUTABLE && + !this->IsExecutableWithExports()) + { + return 0; + } + + // Lookup any existing link interface for this configuration. + std::string CONFIG = cmSystemTools::UpperCase(config); + cmTargetInternals::HeadToLinkInterfaceMap& hm = + this->Internal->LinkInterfaceMap[CONFIG]; + + // If the link interface does not depend on the head target + // then return the one we computed first. + if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) + { + return &hm.begin()->second; + } + + cmTargetInternals::OptionalLinkInterface& iface = hm[head]; + if(!iface.LibrariesDone) + { + iface.LibrariesDone = true; + this->Internal->ComputeLinkInterfaceLibraries( + this, config, iface, head, false); + } + if(!iface.AllDone) + { + iface.AllDone = true; + if(iface.Exists) + { + this->Internal->ComputeLinkInterface(this, config, iface, head); + } + } + + return iface.Exists? &iface : 0; +} + +//---------------------------------------------------------------------------- +cmTarget::LinkInterfaceLibraries const* +cmTarget::GetLinkInterfaceLibraries(const std::string& config, + cmTarget const* head, + bool usage_requirements_only) const +{ + // Imported targets have their own link interface. + if(this->IsImported()) + { + return this->GetImportLinkInterface(config, head, usage_requirements_only); + } + + // Link interfaces are not supported for executables that do not + // export symbols. + if(this->GetType() == cmTarget::EXECUTABLE && + !this->IsExecutableWithExports()) + { + return 0; + } + + // Lookup any existing link interface for this configuration. + std::string CONFIG = cmSystemTools::UpperCase(config); + cmTargetInternals::HeadToLinkInterfaceMap& hm = + (usage_requirements_only ? + this->Internal->LinkInterfaceUsageRequirementsOnlyMap[CONFIG] : + this->Internal->LinkInterfaceMap[CONFIG]); + + // If the link interface does not depend on the head target + // then return the one we computed first. + if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) + { + return &hm.begin()->second; + } + + cmTargetInternals::OptionalLinkInterface& iface = hm[head]; + if(!iface.LibrariesDone) + { + iface.LibrariesDone = true; + this->Internal->ComputeLinkInterfaceLibraries( + this, config, iface, head, usage_requirements_only); + } + + return iface.Exists? &iface : 0; +} + +//---------------------------------------------------------------------------- +cmTarget::LinkInterface const* +cmTarget::GetImportLinkInterface(const std::string& config, + cmTarget const* headTarget, + bool usage_requirements_only) const +{ + cmTarget::ImportInfo const* info = this->GetImportInfo(config); + if(!info) + { + return 0; + } + + std::string CONFIG = cmSystemTools::UpperCase(config); + cmTargetInternals::HeadToLinkInterfaceMap& hm = + (usage_requirements_only ? + this->Internal->LinkInterfaceUsageRequirementsOnlyMap[CONFIG] : + this->Internal->LinkInterfaceMap[CONFIG]); + + // If the link interface does not depend on the head target + // then return the one we computed first. + if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) + { + return &hm.begin()->second; + } + + cmTargetInternals::OptionalLinkInterface& iface = hm[headTarget]; + if(!iface.AllDone) + { + iface.AllDone = true; + iface.Multiplicity = info->Multiplicity; + cmSystemTools::ExpandListArgument(info->Languages, iface.Languages); + this->ExpandLinkItems(info->LibrariesProp, info->Libraries, config, + headTarget, usage_requirements_only, + iface.Libraries, + iface.HadHeadSensitiveCondition); + std::vector deps; + cmSystemTools::ExpandListArgument(info->SharedDeps, deps); + this->LookupLinkItems(deps, iface.SharedDeps); + } + + return &iface; +} + +//---------------------------------------------------------------------------- +void +cmTargetInternals::ComputeLinkInterfaceLibraries( + cmTarget const* thisTarget, + const std::string& config, + OptionalLinkInterface& iface, + cmTarget const* headTarget, + bool usage_requirements_only) +{ + // Construct the property name suffix for this configuration. + std::string suffix = "_"; + if(!config.empty()) + { + suffix += cmSystemTools::UpperCase(config); + } + else + { + suffix += "NOCONFIG"; + } + + // An explicit list of interface libraries may be set for shared + // libraries and executables that export symbols. + const char* explicitLibraries = 0; + std::string linkIfaceProp; + if(thisTarget->GetPolicyStatusCMP0022() != cmPolicies::OLD && + thisTarget->GetPolicyStatusCMP0022() != cmPolicies::WARN) + { + // CMP0022 NEW behavior is to use INTERFACE_LINK_LIBRARIES. + linkIfaceProp = "INTERFACE_LINK_LIBRARIES"; + explicitLibraries = thisTarget->GetProperty(linkIfaceProp); + } + else if(thisTarget->GetType() == cmTarget::SHARED_LIBRARY || + thisTarget->IsExecutableWithExports()) + { + // CMP0022 OLD behavior is to use LINK_INTERFACE_LIBRARIES if set on a + // shared lib or executable. + + // Lookup the per-configuration property. + linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; + linkIfaceProp += suffix; + explicitLibraries = thisTarget->GetProperty(linkIfaceProp); + + // If not set, try the generic property. + if(!explicitLibraries) + { + linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; + explicitLibraries = thisTarget->GetProperty(linkIfaceProp); + } + } + + if(explicitLibraries && + thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN && + !this->PolicyWarnedCMP0022) + { + // Compare the explicitly set old link interface properties to the + // preferred new link interface property one and warn if different. + const char* newExplicitLibraries = + thisTarget->GetProperty("INTERFACE_LINK_LIBRARIES"); + if (newExplicitLibraries + && strcmp(newExplicitLibraries, explicitLibraries) != 0) + { + std::ostringstream w; + w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n" + "Target \"" << thisTarget->GetName() << "\" has an " + "INTERFACE_LINK_LIBRARIES property which differs from its " << + linkIfaceProp << " properties." + "\n" + "INTERFACE_LINK_LIBRARIES:\n" + " " << newExplicitLibraries << "\n" << + linkIfaceProp << ":\n" + " " << (explicitLibraries ? explicitLibraries : "(empty)") << "\n"; + thisTarget->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + this->PolicyWarnedCMP0022 = true; + } + } + + // There is no implicit link interface for executables or modules + // so if none was explicitly set then there is no link interface. + if(!explicitLibraries && + (thisTarget->GetType() == cmTarget::EXECUTABLE || + (thisTarget->GetType() == cmTarget::MODULE_LIBRARY))) + { + return; + } + iface.Exists = true; + iface.ExplicitLibraries = explicitLibraries; + + if(explicitLibraries) + { + // The interface libraries have been explicitly set. + thisTarget->ExpandLinkItems(linkIfaceProp, explicitLibraries, config, + headTarget, usage_requirements_only, + iface.Libraries, + iface.HadHeadSensitiveCondition); + } + else if (thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN + || thisTarget->GetPolicyStatusCMP0022() == cmPolicies::OLD) + // If CMP0022 is NEW then the plain tll signature sets the + // INTERFACE_LINK_LIBRARIES, so if we get here then the project + // cleared the property explicitly and we should not fall back + // to the link implementation. + { + // The link implementation is the default link interface. + cmLinkImplementationLibraries const* impl = + thisTarget->GetLinkImplementationLibrariesInternal(config, headTarget); + iface.Libraries.insert(iface.Libraries.end(), + impl->Libraries.begin(), impl->Libraries.end()); + if(thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN && + !this->PolicyWarnedCMP0022 && !usage_requirements_only) + { + // Compare the link implementation fallback link interface to the + // preferred new link interface property and warn if different. + std::vector ifaceLibs; + static const std::string newProp = "INTERFACE_LINK_LIBRARIES"; + if(const char* newExplicitLibraries = thisTarget->GetProperty(newProp)) + { + bool hadHeadSensitiveConditionDummy = false; + thisTarget->ExpandLinkItems(newProp, newExplicitLibraries, config, + headTarget, usage_requirements_only, + ifaceLibs, hadHeadSensitiveConditionDummy); + } + if (ifaceLibs != iface.Libraries) + { + std::string oldLibraries = cmJoin(impl->Libraries, ";"); + std::string newLibraries = cmJoin(ifaceLibs, ";"); + if(oldLibraries.empty()) + { oldLibraries = "(empty)"; } + if(newLibraries.empty()) + { newLibraries = "(empty)"; } + + std::ostringstream w; + w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n" + "Target \"" << thisTarget->GetName() << "\" has an " + "INTERFACE_LINK_LIBRARIES property. " + "This should be preferred as the source of the link interface " + "for this library but because CMP0022 is not set CMake is " + "ignoring the property and using the link implementation " + "as the link interface instead." + "\n" + "INTERFACE_LINK_LIBRARIES:\n" + " " << newLibraries << "\n" + "Link implementation:\n" + " " << oldLibraries << "\n"; + thisTarget->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + this->PolicyWarnedCMP0022 = true; + } + } + } +} + +//---------------------------------------------------------------------------- +void cmTargetInternals::ComputeLinkInterface(cmTarget const* thisTarget, + const std::string& config, + OptionalLinkInterface& iface, + cmTarget const* headTarget) const +{ + if(iface.ExplicitLibraries) + { + if(thisTarget->GetType() == cmTarget::SHARED_LIBRARY + || thisTarget->GetType() == cmTarget::STATIC_LIBRARY + || thisTarget->GetType() == cmTarget::INTERFACE_LIBRARY) + { + // Shared libraries may have runtime implementation dependencies + // on other shared libraries that are not in the interface. + UNORDERED_SET emitted; + for(std::vector::const_iterator + li = iface.Libraries.begin(); li != iface.Libraries.end(); ++li) + { + emitted.insert(*li); + } + if (thisTarget->GetType() != cmTarget::INTERFACE_LIBRARY) + { + cmTarget::LinkImplementation const* impl = + thisTarget->GetLinkImplementation(config); + for(std::vector::const_iterator + li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li) + { + if(emitted.insert(*li).second) + { + if(li->Target) + { + // This is a runtime dependency on another shared library. + if(li->Target->GetType() == cmTarget::SHARED_LIBRARY) + { + iface.SharedDeps.push_back(*li); + } + } + else + { + // TODO: Recognize shared library file names. Perhaps this + // should be moved to cmComputeLinkInformation, but that creates + // a chicken-and-egg problem since this list is needed for its + // construction. + } + } + } + } + } + } + else if (thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN + || thisTarget->GetPolicyStatusCMP0022() == cmPolicies::OLD) + { + // The link implementation is the default link interface. + cmLinkImplementationLibraries const* + impl = thisTarget->GetLinkImplementationLibrariesInternal(config, + headTarget); + iface.ImplementationIsInterface = true; + iface.WrongConfigLibraries = impl->WrongConfigLibraries; + } + + if(thisTarget->LinkLanguagePropagatesToDependents()) + { + // Targets using this archive need its language runtime libraries. + if(cmTarget::LinkImplementation const* impl = + thisTarget->GetLinkImplementation(config)) + { + iface.Languages = impl->Languages; + } + } + + if(thisTarget->GetType() == cmTarget::STATIC_LIBRARY) + { + // Construct the property name suffix for this configuration. + std::string suffix = "_"; + if(!config.empty()) + { + suffix += cmSystemTools::UpperCase(config); + } + else + { + suffix += "NOCONFIG"; + } + + // How many repetitions are needed if this library has cyclic + // dependencies? + std::string propName = "LINK_INTERFACE_MULTIPLICITY"; + propName += suffix; + if(const char* config_reps = thisTarget->GetProperty(propName)) + { + sscanf(config_reps, "%u", &iface.Multiplicity); + } + else if(const char* reps = + thisTarget->GetProperty("LINK_INTERFACE_MULTIPLICITY")) + { + sscanf(reps, "%u", &iface.Multiplicity); + } + } +} + +//---------------------------------------------------------------------------- void cmTargetInternals::AddInterfaceEntries( cmTarget const* thisTarget, std::string const& config, std::string const& prop, std::vector& entries) @@ -3450,11 +4545,32 @@ void cmTargetInternals::AddInterfaceEntries( } } -cmOptionalLinkImplementation& cmTarget::GetLinkImplMap(std::string const& config) const +//---------------------------------------------------------------------------- +cmTarget::LinkImplementation const* +cmTarget::GetLinkImplementation(const std::string& config) const { + // There is no link implementation for imported targets. + if(this->IsImported()) + { + return 0; + } + // Populate the link implementation for this configuration. std::string CONFIG = cmSystemTools::UpperCase(config); - return Internal->LinkImplMap[CONFIG][this]; + cmTargetInternals::OptionalLinkImplementation& + impl = this->Internal->LinkImplMap[CONFIG][this]; + if(!impl.LibrariesDone) + { + impl.LibrariesDone = true; + this->Internal + ->ComputeLinkImplementationLibraries(this, config, impl, this); + } + if(!impl.LanguagesDone) + { + impl.LanguagesDone = true; + this->Internal->ComputeLinkImplementationLanguages(this, config, impl); + } + return &impl; } //---------------------------------------------------------------------------- @@ -3487,36 +4603,39 @@ cmTarget::GetLinkImplementationLibrariesInternal(const std::string& config, return &hm.begin()->second; } - cmOptionalLinkImplementation& impl = hm[head]; + cmTargetInternals::OptionalLinkImplementation& impl = hm[head]; if(!impl.LibrariesDone) { impl.LibrariesDone = true; - this->ComputeLinkImplementationLibraries(config, impl, head); + this->Internal + ->ComputeLinkImplementationLibraries(this, config, impl, head); } return &impl; } //---------------------------------------------------------------------------- -void cmTarget::ComputeLinkImplementationLibraries( +void +cmTargetInternals::ComputeLinkImplementationLibraries( + cmTarget const* thisTarget, const std::string& config, - cmOptionalLinkImplementation& impl, + OptionalLinkImplementation& impl, cmTarget const* head) const { // Collect libraries directly linked in this configuration. for (std::vector::const_iterator - le = this->Internal->LinkImplementationPropertyEntries.begin(), - end = this->Internal->LinkImplementationPropertyEntries.end(); + le = this->LinkImplementationPropertyEntries.begin(), + end = this->LinkImplementationPropertyEntries.end(); le != end; ++le) { std::vector llibs; cmGeneratorExpressionDAGChecker dagChecker( - this->GetName(), + thisTarget->GetName(), "LINK_LIBRARIES", 0, 0); cmGeneratorExpression ge(le->Backtrace); cmsys::auto_ptr const cge = ge.Parse(le->Value); std::string const evaluated = - cge->Evaluate(this->Makefile, config, false, head, &dagChecker); + cge->Evaluate(thisTarget->Makefile, config, false, head, &dagChecker); cmSystemTools::ExpandListArgument(evaluated, llibs); if(cge->GetHadHeadSensitiveCondition()) { @@ -3527,15 +4646,15 @@ void cmTarget::ComputeLinkImplementationLibraries( li != llibs.end(); ++li) { // Skip entries that resolve to the target itself or are empty. - std::string name = this->CheckCMP0004(*li); - if(name == this->GetName() || name.empty()) + std::string name = thisTarget->CheckCMP0004(*li); + if(name == thisTarget->GetName() || name.empty()) { - if(name == this->GetName()) + if(name == thisTarget->GetName()) { bool noMessage = false; cmake::MessageType messageType = cmake::FATAL_ERROR; std::ostringstream e; - switch(this->GetPolicyStatusCMP0038()) + switch(thisTarget->GetPolicyStatusCMP0038()) { case cmPolicies::WARN: { @@ -3554,9 +4673,9 @@ void cmTarget::ComputeLinkImplementationLibraries( if(!noMessage) { - e << "Target \"" << this->GetName() << "\" links to itself."; - this->Makefile->GetCMakeInstance()->IssueMessage( - messageType, e.str(), this->GetBacktrace()); + e << "Target \"" << thisTarget->GetName() << "\" links to itself."; + thisTarget->Makefile->GetCMakeInstance()->IssueMessage( + messageType, e.str(), thisTarget->GetBacktrace()); if (messageType == cmake::FATAL_ERROR) { return; @@ -3568,7 +4687,7 @@ void cmTarget::ComputeLinkImplementationLibraries( // The entry is meant for this configuration. impl.Libraries.push_back( - cmLinkImplItem(name, this->FindTargetToLink(name), + cmLinkImplItem(name, thisTarget->FindTargetToLink(name), le->Backtrace, evaluated != le->Value)); } @@ -3576,35 +4695,51 @@ void cmTarget::ComputeLinkImplementationLibraries( for (std::set::const_iterator it = seenProps.begin(); it != seenProps.end(); ++it) { - if (!this->GetProperty(*it)) + if (!thisTarget->GetProperty(*it)) { - this->LinkImplicitNullProperties.insert(*it); + thisTarget->LinkImplicitNullProperties.insert(*it); } } - cge->GetMaxLanguageStandard(this, this->MaxLanguageStandards); + cge->GetMaxLanguageStandard(thisTarget, thisTarget->MaxLanguageStandards); } - cmTarget::LinkLibraryType linkType = this->ComputeLinkType(config); + cmTarget::LinkLibraryType linkType = thisTarget->ComputeLinkType(config); cmTarget::LinkLibraryVectorType const& oldllibs = - this->GetOriginalLinkLibraries(); + thisTarget->GetOriginalLinkLibraries(); for(cmTarget::LinkLibraryVectorType::const_iterator li = oldllibs.begin(); li != oldllibs.end(); ++li) { if(li->second != cmTarget::GENERAL && li->second != linkType) { - std::string name = this->CheckCMP0004(li->first); - if(name == this->GetName() || name.empty()) + std::string name = thisTarget->CheckCMP0004(li->first); + if(name == thisTarget->GetName() || name.empty()) { continue; } // Support OLD behavior for CMP0003. impl.WrongConfigLibraries.push_back( - cmLinkItem(name, this->FindTargetToLink(name))); + cmLinkItem(name, thisTarget->FindTargetToLink(name))); } } } //---------------------------------------------------------------------------- +void +cmTargetInternals::ComputeLinkImplementationLanguages( + cmTarget const* thisTarget, + const std::string& config, + OptionalLinkImplementation& impl) const +{ + // This target needs runtime libraries for its source languages. + std::set languages; + // Get languages used in our source files. + thisTarget->GetLanguages(languages, config); + // Copy the set of langauges to the link implementation. + impl.Languages.insert(impl.Languages.begin(), + languages.begin(), languages.end()); +} + +//---------------------------------------------------------------------------- cmTarget const* cmTarget::FindTargetToLink(std::string const& name) const { cmTarget const* tgt = this->Makefile->FindTargetToUse(name); @@ -3711,6 +4846,10 @@ cmTargetInternalPointer //---------------------------------------------------------------------------- cmTargetInternalPointer::~cmTargetInternalPointer() { + cmDeleteAll(this->Pointer->IncludeDirectoriesItems); + cmDeleteAll(this->Pointer->CompileOptionsItems); + cmDeleteAll(this->Pointer->CompileFeaturesItems); + cmDeleteAll(this->Pointer->CompileDefinitionsItems); cmDeleteAll(this->Pointer->SourceEntries); delete this->Pointer; } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 7f026a2..2007b40 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -132,11 +132,15 @@ public: void AddPostBuildCommand(cmCustomCommand const &cmd) {this->PostBuildCommands.push_back(cmd);} + void Compute(); + /** * Get the list of the source files used by this target */ void GetSourceFiles(std::vector &files, const std::string& config) const; + bool GetConfigCommonSourceFiles(std::vector& files) const; + /** * Add sources to the target. */ @@ -229,14 +233,53 @@ public: void GetObjectLibrariesCMP0026(std::vector& objlibs) const; - cmLinkImplementationLibraries const* - GetLinkImplementationLibraries(const std::string& config) const; + /** The link interface specifies transitive library dependencies and + other information needed by targets that link to this target. */ + struct LinkInterfaceLibraries + { + // Libraries listed in the interface. + std::vector Libraries; + }; + struct LinkInterface: public LinkInterfaceLibraries + { + // Languages whose runtime libraries must be linked. + std::vector Languages; - void ComputeLinkImplementationLibraries(const std::string& config, - cmOptionalLinkImplementation& impl, - cmTarget const* head) const; + // Shared library dependencies needed for linking on some platforms. + std::vector SharedDeps; - cmOptionalLinkImplementation& GetLinkImplMap(std::string const& config) const; + // Number of repetitions of a strongly connected component of two + // or more static libraries. + int Multiplicity; + + // Libraries listed for other configurations. + // Needed only for OLD behavior of CMP0003. + std::vector WrongConfigLibraries; + + bool ImplementationIsInterface; + + LinkInterface(): Multiplicity(0), ImplementationIsInterface(false) {} + }; + + /** Get the link interface for the given configuration. Returns 0 + if the target cannot be linked. */ + LinkInterface const* GetLinkInterface(const std::string& config, + cmTarget const* headTarget) const; + LinkInterfaceLibraries const* + GetLinkInterfaceLibraries(const std::string& config, + cmTarget const* headTarget, + bool usage_requirements_only) const; + + struct LinkImplementation: public cmLinkImplementationLibraries + { + // Languages whose runtime libraries must be linked. + std::vector Languages; + }; + LinkImplementation const* + GetLinkImplementation(const std::string& config) const; + + cmLinkImplementationLibraries const* + GetLinkImplementationLibraries(const std::string& config) const; cmTarget const* FindTargetToLink(std::string const& name) const; @@ -288,6 +331,7 @@ public: bool GetImplibGNUtoMS(std::string const& gnuName, std::string& out, const char* newExt = 0) const; + bool HaveBuildTreeRPATH(const std::string& config) const; bool HaveInstallTreeRPATH() const; // Get the properties @@ -302,6 +346,18 @@ public: If no macro should be defined null is returned. */ const char* GetExportMacro() const; + void GetCompileDefinitions(std::vector &result, + const std::string& config, + const std::string& language) const; + + // Compute the set of languages compiled by the target. This is + // computed every time it is called because the languages can change + // when source file properties are changed and we do not have enough + // information to forward these property changes to the targets + // until we have per-target object file properties. + void GetLanguages(std::set& languages, + std::string const& config) const; + /** Return whether this target is an executable with symbol exports enabled. */ bool IsExecutableWithExports() const; @@ -345,6 +401,9 @@ public: /** @return whether this target have a well defined output file name. */ bool HaveWellDefinedOutputFiles() const; + std::vector GetIncludeDirectories( + const std::string& config, + const std::string& language) const; void InsertInclude(std::string const& entry, cmListFileBacktrace const& bt, bool before = false); @@ -356,6 +415,12 @@ public: void AppendBuildInterfaceIncludes(); + void GetCompileOptions(std::vector &result, + const std::string& config, + const std::string& language) const; + void GetCompileFeatures(std::vector &features, + const std::string& config) const; + bool IsNullImpliedByLinkLibraries(const std::string &p) const; std::string GetDebugGeneratorExpressions(const std::string &value, @@ -374,18 +439,6 @@ public: return this->MaxLanguageStandards; } - cmStringRange GetIncludeDirectoriesEntries() const; - cmBacktraceRange GetIncludeDirectoriesBacktraces() const; - - cmStringRange GetCompileOptionsEntries() const; - cmBacktraceRange GetCompileOptionsBacktraces() const; - - cmStringRange GetCompileFeaturesEntries() const; - cmBacktraceRange GetCompileFeaturesBacktraces() const; - - cmStringRange GetCompileDefinitionsEntries() const; - cmBacktraceRange GetCompileDefinitionsBacktraces() const; - #if defined(_WIN32) && !defined(__CYGWIN__) const LinkLibraryVectorType &GetLinkLibrariesForVS6() const { return this->LinkLibrariesForVS6;} @@ -500,7 +553,11 @@ private: bool IsApple; bool IsImportedTarget; bool BuildInterfaceIncludesAppended; + mutable bool DebugIncludesDone; + mutable bool DebugCompileOptionsDone; + mutable bool DebugCompileDefinitionsDone; mutable bool DebugSourcesDone; + mutable bool DebugCompileFeaturesDone; mutable bool LinkImplementationLanguageIsContextDependent; #if defined(_WIN32) && !defined(__CYGWIN__) bool LinkLibrariesForVS6Analyzed; @@ -534,10 +591,23 @@ private: void ComputeImportInfo(std::string const& desired_config, ImportInfo& info) const; + + LinkInterface const* + GetImportLinkInterface(const std::string& config, cmTarget const* head, + bool usage_requirements_only) const; + cmLinkImplementationLibraries const* GetLinkImplementationLibrariesInternal(const std::string& config, cmTarget const* head) const; + void ExpandLinkItems(std::string const& prop, std::string const& value, + std::string const& config, cmTarget const* headTarget, + bool usage_requirements_only, + std::vector& items, + bool& hadHeadSensitiveCondition) const; + void LookupLinkItems(std::vector const& names, + std::vector& items) const; + std::string ProcessSourceItemCMP0049(const std::string& s); void ClearLinkMaps(); ----------------------------------------------------------------------- Summary of changes: Source/cmComputeLinkDepends.cxx | 24 +- Source/cmComputeLinkDepends.h | 5 +- Source/cmComputeLinkInformation.cxx | 2 +- Source/cmComputeTargetDepends.cxx | 7 +- Source/cmExportFileGenerator.cxx | 7 +- Source/cmExtraCodeBlocksGenerator.cxx | 2 +- Source/cmGeneratorExpressionNode.cxx | 4 +- Source/cmGeneratorTarget.cxx | 1198 +----------------------- Source/cmGeneratorTarget.h | 122 --- Source/cmGlobalGenerator.cxx | 1 + Source/cmGlobalUnixMakefileGenerator3.cxx | 3 +- Source/cmGlobalXCodeGenerator.cxx | 21 +- Source/cmLinkItem.h | 17 - Source/cmLocalGenerator.cxx | 13 +- Source/cmLocalUnixMakefileGenerator3.cxx | 3 +- Source/cmMakefileTargetGenerator.cxx | 2 +- Source/cmQtAutoGenerators.cxx | 15 +- Source/cmTarget.cxx | 1439 ++++++++++++++++++++++++++--- Source/cmTarget.h | 106 ++- 19 files changed, 1434 insertions(+), 1557 deletions(-) hooks/post-receive -- CMake From steveire at gmail.com Tue Aug 25 16:38:15 2015 From: steveire at gmail.com (Stephen Kelly) Date: Tue, 25 Aug 2015 16:38:15 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2482-gf91dd93 Message-ID: <20150825203815.96E23B1C3D@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via f91dd93d9afdb02268c285214abed9d8cc50f191 (commit) via 4898c4c0b79a0f39eb198d4b463688447b09d813 (commit) via 55933ca008a56fd038f80437ec815c3592dca676 (commit) via 0aa85bd05d6f1b19ee839a955b1ae7f45fd96761 (commit) via 622b158d186c4e38bed4097a7422d43c1e26bad1 (commit) via 61b3fdd7ce4424d6b986e5670c50c092483a7f3d (commit) via 4d8072b195d6547a92de835ef27ae205cc7c6609 (commit) via 2d347e68723dbd6e86877856ebff3bd13e5c4dab (commit) via 88f26ac1060a9062361f232c4ef4e5f78cd5c4f8 (commit) via 81fb482213b07ef4909de7d8246f120848b17437 (commit) via 09bd59c75114dd177c685a62a34a3010ff2250a0 (commit) via 8d45ba34d64cb5d7d71d8ade8b5f2226cd9e4734 (commit) via 6ee49bf15acc52ea8b0a32c3e64bfaf75be95846 (commit) via 2962880e25943d5c7670ca34986366c3f41fb67d (commit) via 7707a52f41947c1db1674563a6258f908c8efd6f (commit) from ec0bc1765d8bff3c13835eff266ecfee9ecf00aa (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f91dd93d9afdb02268c285214abed9d8cc50f191 commit f91dd93d9afdb02268c285214abed9d8cc50f191 Merge: ec0bc17 4898c4c Author: Stephen Kelly AuthorDate: Tue Aug 25 16:38:13 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 25 16:38:13 2015 -0400 Merge topic 'use-generator-target' into next 4898c4c0 cmGeneratorTarget: Move GetConfigCommonSourceFiles from cmTarget. 55933ca0 cmGeneratorTarget: Move GetLanguages from cmTarget. 0aa85bd0 cmGeneratorTarget: Move ComputeLinkImplementationLanguages from cmTarget. 622b158d cmGeneratorTarget: Move HaveBuildTreeRPath from cmTarget. 61b3fdd7 cmGeneratorTarget: Move GetLinkImplementation from cmTarget. 4d8072b1 cmTarget: Add GetLinkImplMap method. 2d347e68 cmLinkItem: Add cmOptionalLinkImplementation type. 88f26ac1 cmLinkItem: Add cmLinkImplementation type. 81fb4822 cmGeneratorTarget: Move compile defintions processing from cmTarget. 09bd59c7 cmGeneratorTarget: Move compile features processing from cmTarget. 8d45ba34 cmGeneratorTarget: Move compile options processing from cmTarget. 6ee49bf1 cmGeneratorTarget: Move include directory processing from cmTarget. 2962880e cmGeneratorTarget: Move link iface helpers from cmTarget. 7707a52f cmGeneratorTarget: Move GetLinkInterface from cmTarget. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4898c4c0b79a0f39eb198d4b463688447b09d813 commit 4898c4c0b79a0f39eb198d4b463688447b09d813 Author: Stephen Kelly AuthorDate: Wed Aug 5 17:37:50 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 22:37:11 2015 +0200 cmGeneratorTarget: Move GetConfigCommonSourceFiles from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 06c6137..9390b92 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -4397,11 +4397,68 @@ cmGeneratorTarget::GetLinkImplementation(const std::string& config) const } //---------------------------------------------------------------------------- +bool cmGeneratorTarget::GetConfigCommonSourceFiles( + std::vector& files) const +{ + std::vector configs; + this->Makefile->GetConfigurations(configs); + if (configs.empty()) + { + configs.push_back(""); + } + + std::vector::const_iterator it = configs.begin(); + const std::string& firstConfig = *it; + this->Target->GetSourceFiles(files, firstConfig); + + for ( ; it != configs.end(); ++it) + { + std::vector configFiles; + this->Target->GetSourceFiles(configFiles, *it); + if (configFiles != files) + { + std::string firstConfigFiles; + const char* sep = ""; + for (std::vector::const_iterator fi = files.begin(); + fi != files.end(); ++fi) + { + firstConfigFiles += sep; + firstConfigFiles += (*fi)->GetFullPath(); + sep = "\n "; + } + + std::string thisConfigFiles; + sep = ""; + for (std::vector::const_iterator fi = configFiles.begin(); + fi != configFiles.end(); ++fi) + { + thisConfigFiles += sep; + thisConfigFiles += (*fi)->GetFullPath(); + sep = "\n "; + } + std::ostringstream e; + e << "Target \"" << this->GetName() + << "\" has source files which vary by " + "configuration. This is not supported by the \"" + << this->LocalGenerator->GetGlobalGenerator()->GetName() + << "\" generator.\n" + "Config \"" << firstConfig << "\":\n" + " " << firstConfigFiles << "\n" + "Config \"" << *it << "\":\n" + " " << thisConfigFiles << "\n"; + this->LocalGenerator->IssueMessage(cmake::FATAL_ERROR, e.str()); + return false; + } + } + return true; +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetLanguages(std::set& languages, const std::string& config) const { std::vector sourceFiles; - this->Target->GetSourceFiles(sourceFiles, config); + this->GetSourceFiles(sourceFiles, config); for(std::vector::const_iterator i = sourceFiles.begin(); i != sourceFiles.end(); ++i) { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index e7ec23a..6d66bfe 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -241,6 +241,8 @@ public: void GetLanguages(std::set& languages, std::string const& config) const; + bool GetConfigCommonSourceFiles(std::vector& files) const; + bool HaveBuildTreeRPATH(const std::string& config) const; /** Full path with trailing slash to the top-level directory diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index b70f3c9..756daa0 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1124,7 +1124,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, // organize the sources std::vector classes; - if (!cmtarget.GetConfigCommonSourceFiles(classes)) + if (!gtgt->GetConfigCommonSourceFiles(classes)) { return false; } @@ -1505,7 +1505,8 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases, } std::vector classes; - if (!cmtarget.GetConfigCommonSourceFiles(classes)) + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); + if (!gtgt->GetConfigCommonSourceFiles(classes)) { return; } @@ -2557,7 +2558,8 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget) if(cmtarget.GetType() == cmTarget::UTILITY) { std::vector sources; - if (!cmtarget.GetConfigCommonSourceFiles(sources)) + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); + if (!gtgt->GetConfigCommonSourceFiles(sources)) { return 0; } @@ -3085,7 +3087,8 @@ bool cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root, } std::vector classes; - if (!cmtarget.GetConfigCommonSourceFiles(classes)) + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); + if (!gtgt->GetConfigCommonSourceFiles(classes)) { return false; } diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index c58e7e4..0a4b546 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -403,7 +403,9 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg, ) { std::vector srcFiles; - target->GetConfigCommonSourceFiles(srcFiles); + cmGeneratorTarget* gtgt = + lg->GetGlobalGenerator()->GetGeneratorTarget(target); + gtgt->GetConfigCommonSourceFiles(srcFiles); for(std::vector::const_iterator fileIt = srcFiles.begin(); fileIt != srcFiles.end(); ++fileIt) @@ -661,7 +663,10 @@ void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target) const char* sepHeaders = ""; std::vector srcFiles; - target->GetConfigCommonSourceFiles(srcFiles); + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); + gtgt->GetConfigCommonSourceFiles(srcFiles); const char *skipMocSep = ""; const char *skipUicSep = ""; @@ -1046,7 +1051,10 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) cmMakefile *makefile = target->GetMakefile(); std::vector srcFiles; - target->GetConfigCommonSourceFiles(srcFiles); + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); + gtgt->GetConfigCommonSourceFiles(srcFiles); std::string qrcInputs; const char* qrcInputsSep = ""; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 682e9b9..40d7ebf 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -726,62 +726,6 @@ void cmTarget::GetSourceFiles(std::vector &files, } //---------------------------------------------------------------------------- -bool -cmTarget::GetConfigCommonSourceFiles(std::vector& files) const -{ - std::vector configs; - this->Makefile->GetConfigurations(configs); - if (configs.empty()) - { - configs.push_back(""); - } - - std::vector::const_iterator it = configs.begin(); - const std::string& firstConfig = *it; - this->GetSourceFiles(files, firstConfig); - - for ( ; it != configs.end(); ++it) - { - std::vector configFiles; - this->GetSourceFiles(configFiles, *it); - if (configFiles != files) - { - std::string firstConfigFiles; - const char* sep = ""; - for (std::vector::const_iterator fi = files.begin(); - fi != files.end(); ++fi) - { - firstConfigFiles += sep; - firstConfigFiles += (*fi)->GetFullPath(); - sep = "\n "; - } - - std::string thisConfigFiles; - sep = ""; - for (std::vector::const_iterator fi = configFiles.begin(); - fi != configFiles.end(); ++fi) - { - thisConfigFiles += sep; - thisConfigFiles += (*fi)->GetFullPath(); - sep = "\n "; - } - std::ostringstream e; - e << "Target \"" << this->Name << "\" has source files which vary by " - "configuration. This is not supported by the \"" - << this->Makefile->GetGlobalGenerator()->GetName() - << "\" generator.\n" - "Config \"" << firstConfig << "\":\n" - " " << firstConfigFiles << "\n" - "Config \"" << *it << "\":\n" - " " << thisConfigFiles << "\n"; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); - return false; - } - } - return true; -} - -//---------------------------------------------------------------------------- void cmTarget::GetSourceFiles(std::vector &files, const std::string& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 8dee560..d032380 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -137,8 +137,6 @@ public: */ void GetSourceFiles(std::vector &files, const std::string& config) const; - bool GetConfigCommonSourceFiles(std::vector& files) const; - /** * Add sources to the target. */ http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=55933ca008a56fd038f80437ec815c3592dca676 commit 55933ca008a56fd038f80437ec815c3592dca676 Author: Stephen Kelly AuthorDate: Wed Aug 5 17:37:50 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 22:37:10 2015 +0200 cmGeneratorTarget: Move GetLanguages from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 8e126b9..06c6137 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -4397,6 +4397,57 @@ cmGeneratorTarget::GetLinkImplementation(const std::string& config) const } //---------------------------------------------------------------------------- +void cmGeneratorTarget::GetLanguages(std::set& languages, + const std::string& config) const +{ + std::vector sourceFiles; + this->Target->GetSourceFiles(sourceFiles, config); + for(std::vector::const_iterator + i = sourceFiles.begin(); i != sourceFiles.end(); ++i) + { + const std::string& lang = (*i)->GetLanguage(); + if(!lang.empty()) + { + languages.insert(lang); + } + } + + std::vector objectLibraries; + std::vector externalObjects; + if (!this->Makefile->IsConfigured()) + { + std::vector objectTargets; + this->Target->GetObjectLibrariesCMP0026(objectTargets); + objectLibraries.reserve(objectTargets.size()); + for (std::vector::const_iterator it = objectTargets.begin(); + it != objectTargets.end(); ++it) + { + objectLibraries.push_back(this->LocalGenerator->GetGlobalGenerator() + ->GetGeneratorTarget(*it)); + } + } + else + { + this->GetExternalObjects(externalObjects, config); + for(std::vector::const_iterator + i = externalObjects.begin(); i != externalObjects.end(); ++i) + { + std::string objLib = (*i)->GetObjectLibrary(); + if (cmTarget* tgt = this->Makefile->FindTargetToUse(objLib)) + { + objectLibraries.push_back(this->LocalGenerator->GetGlobalGenerator() + ->GetGeneratorTarget(tgt)); + } + } + } + for(std::vector::const_iterator + i = objectLibraries.begin(); i != objectLibraries.end(); ++i) + { + (*i)->GetLanguages(languages, config); + } +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::ComputeLinkImplementationLanguages( const std::string& config, cmOptionalLinkImplementation& impl) const @@ -4404,7 +4455,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLanguages( // This target needs runtime libraries for its source languages. std::set languages; // Get languages used in our source files. - this->Target->GetLanguages(languages, config); + this->GetLanguages(languages, config); // Copy the set of langauges to the link implementation. impl.Languages.insert(impl.Languages.begin(), languages.begin(), languages.end()); diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 7cb3acd..e7ec23a 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -233,6 +233,14 @@ public: cmOptionalLinkImplementation& impl ) const; + // Compute the set of languages compiled by the target. This is + // computed every time it is called because the languages can change + // when source file properties are changed and we do not have enough + // information to forward these property changes to the targets + // until we have per-target object file properties. + void GetLanguages(std::set& languages, + std::string const& config) const; + bool HaveBuildTreeRPATH(const std::string& config) const; /** Full path with trailing slash to the top-level directory diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index b240924..331caad 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -1134,7 +1134,8 @@ bool cmGlobalUnixMakefileGenerator3 ::NeedRequiresStep(cmTarget const& target) { std::set languages; - target.GetLanguages(languages, + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&target); + gtgt->GetLanguages(languages, target.GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE")); for(std::set::const_iterator l = languages.begin(); l != languages.end(); ++l) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index dda4829..b70f3c9 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1805,7 +1805,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, // Compute the compilation flags for each language. std::set languages; - target.GetLanguages(languages, configName); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); + gtgt->GetLanguages(languages, configName); std::map cflags; for (std::set::iterator li = languages.begin(); li != languages.end(); ++li) @@ -1827,7 +1828,6 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, AddCompileOptions(flags, &target, lang, configName); } - cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); std::string llang = gtgt->GetLinkerLanguage(configName); if(binary && llang.empty()) { diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index ce370bc..589105e 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1257,7 +1257,9 @@ cmLocalUnixMakefileGenerator3 { // Get the set of source languages in the target. std::set languages; - target.GetLanguages(languages, + cmGeneratorTarget *gtgt = + this->GlobalGenerator->GetGeneratorTarget(&target); + gtgt->GetLanguages(languages, this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); fout << "\n" << "# Per-language clean rules from dependency scanning.\n" diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 0b3df90..cf88a74 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -276,7 +276,7 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags() { // write language flags for target std::set languages; - this->Target->GetLanguages(languages, + this->GeneratorTarget->GetLanguages(languages, this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); // put the compiler in the rules.make file so that if it changes // things rebuild diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e8a315d..682e9b9 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3132,50 +3132,6 @@ cmTarget::GetObjectLibrariesCMP0026(std::vector& objlibs) const } //---------------------------------------------------------------------------- -void cmTarget::GetLanguages(std::set& languages, - const std::string& config) const -{ - std::vector sourceFiles; - this->GetSourceFiles(sourceFiles, config); - for(std::vector::const_iterator - i = sourceFiles.begin(); i != sourceFiles.end(); ++i) - { - const std::string& lang = (*i)->GetLanguage(); - if(!lang.empty()) - { - languages.insert(lang); - } - } - - std::vector objectLibraries; - std::vector externalObjects; - if (!this->Makefile->IsConfigured()) - { - this->GetObjectLibrariesCMP0026(objectLibraries); - } - else - { - cmGeneratorTarget* gt = this->Makefile->GetGlobalGenerator() - ->GetGeneratorTarget(this); - gt->GetExternalObjects(externalObjects, config); - for(std::vector::const_iterator - i = externalObjects.begin(); i != externalObjects.end(); ++i) - { - std::string objLib = (*i)->GetObjectLibrary(); - if (cmTarget* tgt = this->Makefile->FindTargetToUse(objLib)) - { - objectLibraries.push_back(tgt); - } - } - } - for(std::vector::const_iterator - i = objectLibraries.begin(); i != objectLibraries.end(); ++i) - { - (*i)->GetLanguages(languages, config); - } -} - -//---------------------------------------------------------------------------- cmTarget::ImportInfo const* cmTarget::GetImportInfo(const std::string& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 1db4ba1..8dee560 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -305,14 +305,6 @@ public: If no macro should be defined null is returned. */ const char* GetExportMacro() const; - // Compute the set of languages compiled by the target. This is - // computed every time it is called because the languages can change - // when source file properties are changed and we do not have enough - // information to forward these property changes to the targets - // until we have per-target object file properties. - void GetLanguages(std::set& languages, - std::string const& config) const; - /** Return whether this target is an executable with symbol exports enabled. */ bool IsExecutableWithExports() const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0aa85bd05d6f1b19ee839a955b1ae7f45fd96761 commit 0aa85bd05d6f1b19ee839a955b1ae7f45fd96761 Author: Stephen Kelly AuthorDate: Wed Aug 5 17:37:50 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 22:37:10 2015 +0200 cmGeneratorTarget: Move ComputeLinkImplementationLanguages from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index a4999ce..8e126b9 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -4391,12 +4391,26 @@ cmGeneratorTarget::GetLinkImplementation(const std::string& config) const if(!impl.LanguagesDone) { impl.LanguagesDone = true; - this->Target->ComputeLinkImplementationLanguages(config, impl); + this->ComputeLinkImplementationLanguages(config, impl); } return &impl; } //---------------------------------------------------------------------------- +void cmGeneratorTarget::ComputeLinkImplementationLanguages( + const std::string& config, + cmOptionalLinkImplementation& impl) const +{ + // This target needs runtime libraries for its source languages. + std::set languages; + // Get languages used in our source files. + this->Target->GetLanguages(languages, config); + // Copy the set of langauges to the link implementation. + impl.Languages.insert(impl.Languages.begin(), + languages.begin(), languages.end()); +} + +//---------------------------------------------------------------------------- bool cmGeneratorTarget::HaveBuildTreeRPATH(const std::string& config) const { if (this->Target->GetPropertyAsBool("SKIP_BUILD_RPATH")) diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index e5dbc69..7cb3acd 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -229,6 +229,10 @@ public: cmLinkImplementation const* GetLinkImplementation(const std::string& config) const; + void ComputeLinkImplementationLanguages(const std::string& config, + cmOptionalLinkImplementation& impl + ) const; + bool HaveBuildTreeRPATH(const std::string& config) const; /** Full path with trailing slash to the top-level directory diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 621d1b0..e8a315d 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3706,20 +3706,6 @@ void cmTarget::ComputeLinkImplementationLibraries( } //---------------------------------------------------------------------------- -void cmTarget::ComputeLinkImplementationLanguages( - const std::string& config, - cmOptionalLinkImplementation& impl) const -{ - // This target needs runtime libraries for its source languages. - std::set languages; - // Get languages used in our source files. - this->GetLanguages(languages, config); - // Copy the set of langauges to the link implementation. - impl.Languages.insert(impl.Languages.begin(), - languages.begin(), languages.end()); -} - -//---------------------------------------------------------------------------- cmTarget const* cmTarget::FindTargetToLink(std::string const& name) const { cmTarget const* tgt = this->Makefile->FindTargetToUse(name); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 8866e65..1db4ba1 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -237,9 +237,6 @@ public: void ComputeLinkImplementationLibraries(const std::string& config, cmOptionalLinkImplementation& impl, cmTarget const* head) const; - void ComputeLinkImplementationLanguages(const std::string& config, - cmOptionalLinkImplementation& impl - ) const; cmOptionalLinkImplementation& GetLinkImplMap(std::string const& config) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=622b158d186c4e38bed4097a7422d43c1e26bad1 commit 622b158d186c4e38bed4097a7422d43c1e26bad1 Author: Stephen Kelly AuthorDate: Wed Aug 5 17:37:49 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 22:37:10 2015 +0200 cmGeneratorTarget: Move HaveBuildTreeRPath from cmTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 6ba0eed..192ad5f 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -1925,7 +1925,7 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, (outputRuntime && this->Target->Target->HaveInstallTreeRPATH() && linking_for_install); bool use_build_rpath = - (outputRuntime && this->Target->Target->HaveBuildTreeRPATH(this->Config) && + (outputRuntime && this->Target->HaveBuildTreeRPATH(this->Config) && !linking_for_install); bool use_link_rpath = outputRuntime && linking_for_install && diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 5f73162..a4999ce 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -908,7 +908,7 @@ cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const // If either a build or install tree rpath is set then the rpath // will likely change between the build tree and install tree and // this target must be relinked. - return this->Target->HaveBuildTreeRPATH(config) + return this->HaveBuildTreeRPATH(config) || this->Target->HaveInstallTreeRPATH(); } @@ -4395,3 +4395,18 @@ cmGeneratorTarget::GetLinkImplementation(const std::string& config) const } return &impl; } + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::HaveBuildTreeRPATH(const std::string& config) const +{ + if (this->Target->GetPropertyAsBool("SKIP_BUILD_RPATH")) + { + return false; + } + if(cmLinkImplementationLibraries const* impl = + this->Target->GetLinkImplementationLibraries(config)) + { + return !impl->Libraries.empty(); + } + return false; +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 91837db..e5dbc69 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -229,6 +229,8 @@ public: cmLinkImplementation const* GetLinkImplementation(const std::string& config) const; + bool HaveBuildTreeRPATH(const std::string& config) const; + /** Full path with trailing slash to the top-level directory holding object files for this target. Includes the build time config name placeholder if needed for the generator. */ diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 6252ed5..621d1b0 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2811,21 +2811,6 @@ void cmTarget::SetPropertyDefault(const std::string& property, } //---------------------------------------------------------------------------- -bool cmTarget::HaveBuildTreeRPATH(const std::string& config) const -{ - if (this->GetPropertyAsBool("SKIP_BUILD_RPATH")) - { - return false; - } - if(cmLinkImplementationLibraries const* impl = - this->GetLinkImplementationLibraries(config)) - { - return !impl->Libraries.empty(); - } - return false; -} - -//---------------------------------------------------------------------------- bool cmTarget::HaveInstallTreeRPATH() const { const char* install_rpath = this->GetProperty("INSTALL_RPATH"); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 1d353ab..8866e65 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -294,7 +294,6 @@ public: bool GetImplibGNUtoMS(std::string const& gnuName, std::string& out, const char* newExt = 0) const; - bool HaveBuildTreeRPATH(const std::string& config) const; bool HaveInstallTreeRPATH() const; // Get the properties http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=61b3fdd7ce4424d6b986e5670c50c092483a7f3d commit 61b3fdd7ce4424d6b986e5670c50c092483a7f3d Author: Stephen Kelly AuthorDate: Wed Aug 5 17:37:49 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 22:37:10 2015 +0200 cmGeneratorTarget: Move GetLinkImplementation from cmTarget. diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 67790bc..5a5c1c1 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -556,7 +556,7 @@ void cmComputeLinkDepends::AddDirectLinkEntries() { // Add direct link dependencies in this configuration. cmLinkImplementation const* impl = - this->Target->Target->GetLinkImplementation(this->Config); + this->Target->GetLinkImplementation(this->Config); this->AddLinkEntries(-1, impl->Libraries); for(std::vector::const_iterator wi = impl->WrongConfigLibraries.begin(); diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index ec9c61b..7488e09 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -252,8 +252,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) } } - cmLinkImplementation const* impl = - depender->Target->GetLinkImplementation(*it); + cmLinkImplementation const* impl = depender->GetLinkImplementation(*it); // A target should not depend on itself. emitted.insert(depender->GetName()); diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 9449207..5f73162 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1336,7 +1336,7 @@ void cmGeneratorTarget::ComputeLinkClosure(const std::string& config, // Get languages built in this target. UNORDERED_SET languages; cmLinkImplementation const* impl = - this->Target->GetLinkImplementation(config); + this->GetLinkImplementation(config); assert(impl); for(std::vector::const_iterator li = impl->Languages.begin(); li != impl->Languages.end(); ++li) @@ -4295,7 +4295,7 @@ void cmGeneratorTarget::ComputeLinkInterface(const std::string& config, if (this->GetType() != cmTarget::INTERFACE_LIBRARY) { cmLinkImplementation const* impl = - this->Target->GetLinkImplementation(config); + this->GetLinkImplementation(config); for(std::vector::const_iterator li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li) { @@ -4336,7 +4336,7 @@ void cmGeneratorTarget::ComputeLinkInterface(const std::string& config, { // Targets using this archive need its language runtime libraries. if(cmLinkImplementation const* impl = - this->Target->GetLinkImplementation(config)) + this->GetLinkImplementation(config)) { iface.Languages = impl->Languages; } @@ -4370,3 +4370,28 @@ void cmGeneratorTarget::ComputeLinkInterface(const std::string& config, } } } + +//---------------------------------------------------------------------------- +const cmLinkImplementation * +cmGeneratorTarget::GetLinkImplementation(const std::string& config) const +{ + // There is no link implementation for imported targets. + if(this->Target->IsImported()) + { + return 0; + } + + cmOptionalLinkImplementation& impl = this->Target->GetLinkImplMap(config); + if(!impl.LibrariesDone) + { + impl.LibrariesDone = true; + this->Target->ComputeLinkImplementationLibraries(config, impl, + this->Target); + } + if(!impl.LanguagesDone) + { + impl.LanguagesDone = true; + this->Target->ComputeLinkImplementationLanguages(config, impl); + } + return &impl; +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 9456bb1..91837db 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -226,6 +226,9 @@ public: LinkClosure const* GetLinkClosure(const std::string& config) const; void ComputeLinkClosure(const std::string& config, LinkClosure& lc) const; + cmLinkImplementation const* + GetLinkImplementation(const std::string& config) const; + /** Full path with trailing slash to the top-level directory holding object files for this target. Includes the build time config name placeholder if needed for the generator. */ diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 75604a2..dda4829 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1384,7 +1384,7 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmTarget& cmtarget) // If the language is compiled as a source trust Xcode to link with it. cmLinkImplementation const* impl = - cmtarget.GetLinkImplementation("NOCONFIG"); + gtgt->GetLinkImplementation("NOCONFIG"); for(std::vector::const_iterator li = impl->Languages.begin(); li != impl->Languages.end(); ++li) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index a14e1c2..6252ed5 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3565,30 +3565,6 @@ void cmTargetInternals::AddInterfaceEntries( } } -//---------------------------------------------------------------------------- -const cmLinkImplementation * -cmTarget::GetLinkImplementation(const std::string& config) const -{ - // There is no link implementation for imported targets. - if(this->IsImported()) - { - return 0; - } - - cmOptionalLinkImplementation& impl = this->GetLinkImplMap(config); - if(!impl.LibrariesDone) - { - impl.LibrariesDone = true; - this->ComputeLinkImplementationLibraries(config, impl, this); - } - if(!impl.LanguagesDone) - { - impl.LanguagesDone = true; - this->ComputeLinkImplementationLanguages(config, impl); - } - return &impl; -} - cmOptionalLinkImplementation& cmTarget::GetLinkImplMap(std::string const& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 6411d12..1d353ab 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -231,9 +231,6 @@ public: void GetObjectLibrariesCMP0026(std::vector& objlibs) const; - cmLinkImplementation const* - GetLinkImplementation(const std::string& config) const; - cmLinkImplementationLibraries const* GetLinkImplementationLibraries(const std::string& config) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4d8072b195d6547a92de835ef27ae205cc7c6609 commit 4d8072b195d6547a92de835ef27ae205cc7c6609 Author: Stephen Kelly AuthorDate: Wed Aug 5 17:37:49 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 22:37:10 2015 +0200 cmTarget: Add GetLinkImplMap method. This is a temporary refactoring artifact. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 18d1220..a14e1c2 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3575,10 +3575,7 @@ cmTarget::GetLinkImplementation(const std::string& config) const return 0; } - // Populate the link implementation for this configuration. - std::string CONFIG = cmSystemTools::UpperCase(config); - cmOptionalLinkImplementation& - impl = this->Internal->LinkImplMap[CONFIG][this]; + cmOptionalLinkImplementation& impl = this->GetLinkImplMap(config); if(!impl.LibrariesDone) { impl.LibrariesDone = true; @@ -3592,6 +3589,14 @@ cmTarget::GetLinkImplementation(const std::string& config) const return &impl; } +cmOptionalLinkImplementation& +cmTarget::GetLinkImplMap(std::string const& config) const +{ + // Populate the link implementation for this configuration. + std::string CONFIG = cmSystemTools::UpperCase(config); + return Internal->LinkImplMap[CONFIG][this]; +} + //---------------------------------------------------------------------------- cmLinkImplementationLibraries const* cmTarget::GetLinkImplementationLibraries(const std::string& config) const diff --git a/Source/cmTarget.h b/Source/cmTarget.h index d49b23e..6411d12 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -244,6 +244,9 @@ public: cmOptionalLinkImplementation& impl ) const; + cmOptionalLinkImplementation& + GetLinkImplMap(std::string const& config) const; + cmTarget const* FindTargetToLink(std::string const& name) const; /** Strip off leading and trailing whitespace from an item named in http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2d347e68723dbd6e86877856ebff3bd13e5c4dab commit 2d347e68723dbd6e86877856ebff3bd13e5c4dab Author: Stephen Kelly AuthorDate: Wed Aug 5 17:37:48 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 22:37:09 2015 +0200 cmLinkItem: Add cmOptionalLinkImplementation type. Move the associated Compute* methods to the cmTarget class. diff --git a/Source/cmLinkItem.h b/Source/cmLinkItem.h index accc83c..f1d914f 100644 --- a/Source/cmLinkItem.h +++ b/Source/cmLinkItem.h @@ -62,4 +62,15 @@ struct cmLinkImplementation: public cmLinkImplementationLibraries std::vector Languages; }; +// Cache link implementation computation from each configuration. +struct cmOptionalLinkImplementation: public cmLinkImplementation +{ + cmOptionalLinkImplementation(): + LibrariesDone(false), LanguagesDone(false), + HadHeadSensitiveCondition(false) {} + bool LibrariesDone; + bool LanguagesDone; + bool HadHeadSensitiveCondition; +}; + #endif diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e6408c4..18d1220 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -96,27 +96,8 @@ public: typedef std::map ImportInfoMapType; ImportInfoMapType ImportInfoMap; - // Cache link implementation computation from each configuration. - struct OptionalLinkImplementation: public cmLinkImplementation - { - OptionalLinkImplementation(): - LibrariesDone(false), LanguagesDone(false), - HadHeadSensitiveCondition(false) {} - bool LibrariesDone; - bool LanguagesDone; - bool HadHeadSensitiveCondition; - }; - void ComputeLinkImplementationLibraries(cmTarget const* thisTarget, - const std::string& config, - OptionalLinkImplementation& impl, - cmTarget const* head) const; - void ComputeLinkImplementationLanguages(cmTarget const* thisTarget, - const std::string& config, - OptionalLinkImplementation& impl - ) const; - struct HeadToLinkImplementationMap: - public std::map {}; + public std::map {}; typedef std::map LinkImplMapType; LinkImplMapType LinkImplMap; @@ -3596,18 +3577,17 @@ cmTarget::GetLinkImplementation(const std::string& config) const // Populate the link implementation for this configuration. std::string CONFIG = cmSystemTools::UpperCase(config); - cmTargetInternals::OptionalLinkImplementation& + cmOptionalLinkImplementation& impl = this->Internal->LinkImplMap[CONFIG][this]; if(!impl.LibrariesDone) { impl.LibrariesDone = true; - this->Internal - ->ComputeLinkImplementationLibraries(this, config, impl, this); + this->ComputeLinkImplementationLibraries(config, impl, this); } if(!impl.LanguagesDone) { impl.LanguagesDone = true; - this->Internal->ComputeLinkImplementationLanguages(this, config, impl); + this->ComputeLinkImplementationLanguages(config, impl); } return &impl; } @@ -3642,39 +3622,36 @@ cmTarget::GetLinkImplementationLibrariesInternal(const std::string& config, return &hm.begin()->second; } - cmTargetInternals::OptionalLinkImplementation& impl = hm[head]; + cmOptionalLinkImplementation& impl = hm[head]; if(!impl.LibrariesDone) { impl.LibrariesDone = true; - this->Internal - ->ComputeLinkImplementationLibraries(this, config, impl, head); + this->ComputeLinkImplementationLibraries(config, impl, head); } return &impl; } //---------------------------------------------------------------------------- -void -cmTargetInternals::ComputeLinkImplementationLibraries( - cmTarget const* thisTarget, +void cmTarget::ComputeLinkImplementationLibraries( const std::string& config, - OptionalLinkImplementation& impl, + cmOptionalLinkImplementation& impl, cmTarget const* head) const { // Collect libraries directly linked in this configuration. for (std::vector::const_iterator - le = this->LinkImplementationPropertyEntries.begin(), - end = this->LinkImplementationPropertyEntries.end(); + le = this->Internal->LinkImplementationPropertyEntries.begin(), + end = this->Internal->LinkImplementationPropertyEntries.end(); le != end; ++le) { std::vector llibs; cmGeneratorExpressionDAGChecker dagChecker( - thisTarget->GetName(), + this->GetName(), "LINK_LIBRARIES", 0, 0); cmGeneratorExpression ge(le->Backtrace); cmsys::auto_ptr const cge = ge.Parse(le->Value); std::string const evaluated = - cge->Evaluate(thisTarget->Makefile, config, false, head, &dagChecker); + cge->Evaluate(this->Makefile, config, false, head, &dagChecker); cmSystemTools::ExpandListArgument(evaluated, llibs); if(cge->GetHadHeadSensitiveCondition()) { @@ -3685,15 +3662,15 @@ cmTargetInternals::ComputeLinkImplementationLibraries( li != llibs.end(); ++li) { // Skip entries that resolve to the target itself or are empty. - std::string name = thisTarget->CheckCMP0004(*li); - if(name == thisTarget->GetName() || name.empty()) + std::string name = this->CheckCMP0004(*li); + if(name == this->GetName() || name.empty()) { - if(name == thisTarget->GetName()) + if(name == this->GetName()) { bool noMessage = false; cmake::MessageType messageType = cmake::FATAL_ERROR; std::ostringstream e; - switch(thisTarget->GetPolicyStatusCMP0038()) + switch(this->GetPolicyStatusCMP0038()) { case cmPolicies::WARN: { @@ -3712,9 +3689,9 @@ cmTargetInternals::ComputeLinkImplementationLibraries( if(!noMessage) { - e << "Target \"" << thisTarget->GetName() << "\" links to itself."; - thisTarget->Makefile->GetCMakeInstance()->IssueMessage( - messageType, e.str(), thisTarget->GetBacktrace()); + e << "Target \"" << this->GetName() << "\" links to itself."; + this->Makefile->GetCMakeInstance()->IssueMessage( + messageType, e.str(), this->GetBacktrace()); if (messageType == cmake::FATAL_ERROR) { return; @@ -3726,7 +3703,7 @@ cmTargetInternals::ComputeLinkImplementationLibraries( // The entry is meant for this configuration. impl.Libraries.push_back( - cmLinkImplItem(name, thisTarget->FindTargetToLink(name), + cmLinkImplItem(name, this->FindTargetToLink(name), le->Backtrace, evaluated != le->Value)); } @@ -3734,45 +3711,43 @@ cmTargetInternals::ComputeLinkImplementationLibraries( for (std::set::const_iterator it = seenProps.begin(); it != seenProps.end(); ++it) { - if (!thisTarget->GetProperty(*it)) + if (!this->GetProperty(*it)) { - thisTarget->LinkImplicitNullProperties.insert(*it); + this->LinkImplicitNullProperties.insert(*it); } } - cge->GetMaxLanguageStandard(thisTarget, thisTarget->MaxLanguageStandards); + cge->GetMaxLanguageStandard(this, this->MaxLanguageStandards); } - cmTarget::LinkLibraryType linkType = thisTarget->ComputeLinkType(config); + cmTarget::LinkLibraryType linkType = this->ComputeLinkType(config); cmTarget::LinkLibraryVectorType const& oldllibs = - thisTarget->GetOriginalLinkLibraries(); + this->GetOriginalLinkLibraries(); for(cmTarget::LinkLibraryVectorType::const_iterator li = oldllibs.begin(); li != oldllibs.end(); ++li) { if(li->second != cmTarget::GENERAL && li->second != linkType) { - std::string name = thisTarget->CheckCMP0004(li->first); - if(name == thisTarget->GetName() || name.empty()) + std::string name = this->CheckCMP0004(li->first); + if(name == this->GetName() || name.empty()) { continue; } // Support OLD behavior for CMP0003. impl.WrongConfigLibraries.push_back( - cmLinkItem(name, thisTarget->FindTargetToLink(name))); + cmLinkItem(name, this->FindTargetToLink(name))); } } } //---------------------------------------------------------------------------- -void -cmTargetInternals::ComputeLinkImplementationLanguages( - cmTarget const* thisTarget, +void cmTarget::ComputeLinkImplementationLanguages( const std::string& config, - OptionalLinkImplementation& impl) const + cmOptionalLinkImplementation& impl) const { // This target needs runtime libraries for its source languages. std::set languages; // Get languages used in our source files. - thisTarget->GetLanguages(languages, config); + this->GetLanguages(languages, config); // Copy the set of langauges to the link implementation. impl.Languages.insert(impl.Languages.begin(), languages.begin(), languages.end()); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 19cc220..d49b23e 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -237,6 +237,13 @@ public: cmLinkImplementationLibraries const* GetLinkImplementationLibraries(const std::string& config) const; + void ComputeLinkImplementationLibraries(const std::string& config, + cmOptionalLinkImplementation& impl, + cmTarget const* head) const; + void ComputeLinkImplementationLanguages(const std::string& config, + cmOptionalLinkImplementation& impl + ) const; + cmTarget const* FindTargetToLink(std::string const& name) const; /** Strip off leading and trailing whitespace from an item named in http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=88f26ac1060a9062361f232c4ef4e5f78cd5c4f8 commit 88f26ac1060a9062361f232c4ef4e5f78cd5c4f8 Author: Stephen Kelly AuthorDate: Wed Aug 5 17:37:48 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 22:37:09 2015 +0200 cmLinkItem: Add cmLinkImplementation type. diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 2e5331d..67790bc 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -555,7 +555,7 @@ void cmComputeLinkDepends::AddVarLinkEntries(int depender_index, void cmComputeLinkDepends::AddDirectLinkEntries() { // Add direct link dependencies in this configuration. - cmTarget::LinkImplementation const* impl = + cmLinkImplementation const* impl = this->Target->Target->GetLinkImplementation(this->Config); this->AddLinkEntries(-1, impl->Libraries); for(std::vector::const_iterator diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index fd4b567..ec9c61b 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -252,7 +252,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) } } - cmTarget::LinkImplementation const* impl = + cmLinkImplementation const* impl = depender->Target->GetLinkImplementation(*it); // A target should not depend on itself. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 4f1a54b..9449207 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1335,7 +1335,7 @@ void cmGeneratorTarget::ComputeLinkClosure(const std::string& config, { // Get languages built in this target. UNORDERED_SET languages; - cmTarget::LinkImplementation const* impl = + cmLinkImplementation const* impl = this->Target->GetLinkImplementation(config); assert(impl); for(std::vector::const_iterator li = impl->Languages.begin(); @@ -4294,7 +4294,7 @@ void cmGeneratorTarget::ComputeLinkInterface(const std::string& config, } if (this->GetType() != cmTarget::INTERFACE_LIBRARY) { - cmTarget::LinkImplementation const* impl = + cmLinkImplementation const* impl = this->Target->GetLinkImplementation(config); for(std::vector::const_iterator li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li) @@ -4335,7 +4335,7 @@ void cmGeneratorTarget::ComputeLinkInterface(const std::string& config, if(this->Target->LinkLanguagePropagatesToDependents()) { // Targets using this archive need its language runtime libraries. - if(cmTarget::LinkImplementation const* impl = + if(cmLinkImplementation const* impl = this->Target->GetLinkImplementation(config)) { iface.Languages = impl->Languages; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 33fd637..75604a2 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1383,7 +1383,7 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmTarget& cmtarget) if(llang.empty()) { return; } // If the language is compiled as a source trust Xcode to link with it. - cmTarget::LinkImplementation const* impl = + cmLinkImplementation const* impl = cmtarget.GetLinkImplementation("NOCONFIG"); for(std::vector::const_iterator li = impl->Languages.begin(); li != impl->Languages.end(); ++li) diff --git a/Source/cmLinkItem.h b/Source/cmLinkItem.h index a5427de..accc83c 100644 --- a/Source/cmLinkItem.h +++ b/Source/cmLinkItem.h @@ -56,4 +56,10 @@ struct cmLinkImplementationLibraries std::vector WrongConfigLibraries; }; +struct cmLinkImplementation: public cmLinkImplementationLibraries +{ + // Languages whose runtime libraries must be linked. + std::vector Languages; +}; + #endif diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index d1b7755..e6408c4 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -97,7 +97,7 @@ public: ImportInfoMapType ImportInfoMap; // Cache link implementation computation from each configuration. - struct OptionalLinkImplementation: public cmTarget::LinkImplementation + struct OptionalLinkImplementation: public cmLinkImplementation { OptionalLinkImplementation(): LibrariesDone(false), LanguagesDone(false), @@ -3585,7 +3585,7 @@ void cmTargetInternals::AddInterfaceEntries( } //---------------------------------------------------------------------------- -cmTarget::LinkImplementation const* +const cmLinkImplementation * cmTarget::GetLinkImplementation(const std::string& config) const { // There is no link implementation for imported targets. diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 34a75ea..19cc220 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -231,12 +231,7 @@ public: void GetObjectLibrariesCMP0026(std::vector& objlibs) const; - struct LinkImplementation: public cmLinkImplementationLibraries - { - // Languages whose runtime libraries must be linked. - std::vector Languages; - }; - LinkImplementation const* + cmLinkImplementation const* GetLinkImplementation(const std::string& config) const; cmLinkImplementationLibraries const* http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=81fb482213b07ef4909de7d8246f120848b17437 commit 81fb482213b07ef4909de7d8246f120848b17437 Author: Stephen Kelly AuthorDate: Wed Aug 5 00:00:53 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 22:37:09 2015 +0200 cmGeneratorTarget: Move compile defintions processing from cmTarget. diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 933a256..dfd51c7 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -609,7 +609,7 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, // the compilerdefines for this target std::vector cdefs; - target->GetCompileDefinitions(cdefs, buildType, "C"); + gtgt->GetCompileDefinitions(cdefs, buildType, "C"); // Expand the list. for(std::vector::const_iterator di = cdefs.begin(); diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 393ade9..4f1a54b 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -262,7 +262,8 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) SourceFileFlagsConstructed(false), DebugIncludesDone(false), DebugCompileOptionsDone(false), - DebugCompileFeaturesDone(false) + DebugCompileFeaturesDone(false), + DebugCompileDefinitionsDone(false) { this->Makefile = this->Target->GetMakefile(); this->LocalGenerator = lg; @@ -282,6 +283,11 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) t->GetCompileFeaturesEntries(), t->GetCompileFeaturesBacktraces(), this->CompileFeaturesEntries); + + CreatePropertyGeneratorExpressions( + t->GetCompileDefinitionsEntries(), + t->GetCompileDefinitionsBacktraces(), + this->CompileDefinitionsEntries); } cmGeneratorTarget::~cmGeneratorTarget() @@ -289,6 +295,7 @@ cmGeneratorTarget::~cmGeneratorTarget() cmDeleteAll(this->IncludeDirectoriesEntries); cmDeleteAll(this->CompileOptionsEntries); cmDeleteAll(this->CompileFeaturesEntries); + cmDeleteAll(this->CompileDefinitionsEntries); cmDeleteAll(this->LinkInformation); this->LinkInformation.clear(); } @@ -2445,6 +2452,108 @@ void cmGeneratorTarget::GetCompileFeatures(std::vector &result, } //---------------------------------------------------------------------------- +static void processCompileDefinitions(cmGeneratorTarget const* tgt, + const std::vector &entries, + std::vector &options, + UNORDERED_SET &uniqueOptions, + cmGeneratorExpressionDAGChecker *dagChecker, + const std::string& config, bool debugOptions, + std::string const& language) +{ + processCompileOptionsInternal(tgt, entries, options, uniqueOptions, + dagChecker, config, debugOptions, + "definitions", language); +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GetCompileDefinitions(std::vector &list, + const std::string& config, + const std::string& language) const +{ + UNORDERED_SET uniqueOptions; + + cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), + "COMPILE_DEFINITIONS", 0, 0); + + std::vector debugProperties; + const char *debugProp = + this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); + if (debugProp) + { + cmSystemTools::ExpandListArgument(debugProp, debugProperties); + } + + bool debugDefines = !this->DebugCompileDefinitionsDone + && std::find(debugProperties.begin(), + debugProperties.end(), + "COMPILE_DEFINITIONS") + != debugProperties.end(); + + if (this->Makefile->IsConfigured()) + { + this->DebugCompileDefinitionsDone = true; + } + + processCompileDefinitions(this, + this->CompileDefinitionsEntries, + list, + uniqueOptions, + &dagChecker, + config, + debugDefines, + language); + + std::vector + linkInterfaceCompileDefinitionsEntries; + AddInterfaceEntries( + this, config, "INTERFACE_COMPILE_DEFINITIONS", + linkInterfaceCompileDefinitionsEntries); + if (!config.empty()) + { + std::string configPropName = "COMPILE_DEFINITIONS_" + + cmSystemTools::UpperCase(config); + const char *configProp = this->Target->GetProperty(configPropName); + if (configProp) + { + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0043)) + { + case cmPolicies::WARN: + { + std::ostringstream e; + e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0043); + this->LocalGenerator->IssueMessage(cmake::AUTHOR_WARNING, + e.str()); + } + case cmPolicies::OLD: + { + cmGeneratorExpression ge; + cmsys::auto_ptr cge = + ge.Parse(configProp); + linkInterfaceCompileDefinitionsEntries + .push_back(new cmGeneratorTarget::TargetPropertyEntry(cge)); + } + break; + case cmPolicies::NEW: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::REQUIRED_IF_USED: + break; + } + } + } + + processCompileDefinitions(this, + linkInterfaceCompileDefinitionsEntries, + list, + uniqueOptions, + &dagChecker, + config, + debugDefines, + language); + + cmDeleteAll(linkInterfaceCompileDefinitionsEntries); +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GenerateTargetManifest( const std::string& config) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index e57485f..9456bb1 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -252,6 +252,10 @@ public: void GetCompileFeatures(std::vector &features, const std::string& config) const; + void GetCompileDefinitions(std::vector &result, + const std::string& config, + const std::string& language) const; + bool IsSystemIncludeDirectory(const std::string& dir, const std::string& config) const; @@ -459,10 +463,12 @@ private: mutable bool DebugIncludesDone; mutable bool DebugCompileOptionsDone; mutable bool DebugCompileFeaturesDone; + mutable bool DebugCompileDefinitionsDone; std::vector IncludeDirectoriesEntries; std::vector CompileOptionsEntries; std::vector CompileFeaturesEntries; + std::vector CompileDefinitionsEntries; void ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, cmTarget const* headTarget, diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 503c455..c0f1817 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1550,7 +1550,6 @@ void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes, ti != targets.end(); ++ti) { cmTarget* t = &ti->second; - t->Compute(); cmGeneratorTarget* gt = new cmGeneratorTarget(t, lg); this->GeneratorTargets[t] = gt; generatorTargets[t] = gt; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 4ba29f5..33fd637 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1855,7 +1855,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, this->AppendDefines(ppDefs, exportMacro); } std::vector targetDefines; - target.GetCompileDefinitions(targetDefines, configName, "C"); + gtgt->GetCompileDefinitions(targetDefines, configName, "C"); this->AppendDefines(ppDefs, targetDefines); buildSettings->AddAttribute ("GCC_PREPROCESSOR_DEFINITIONS", ppDefs.CreateList()); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index a7e4191..c1cc241 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1083,7 +1083,8 @@ void cmLocalGenerator::AddCompileDefinitions(std::set& defines, const std::string& lang) { std::vector targetDefines; - target->GetCompileDefinitions(targetDefines, config, lang); + cmGeneratorTarget* gtgt = this->GlobalGenerator->GetGeneratorTarget(target); + gtgt->GetCompileDefinitions(targetDefines, config, lang); this->AppendDefines(defines, targetDefines); } diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index f85e70e..c58e7e4 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -474,8 +474,6 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg, /*byproducts=*/rcc_output, depends, commandLines, false, autogenComment.c_str()); - autogenTarget->Compute(); - cmGeneratorTarget* gt = new cmGeneratorTarget(autogenTarget, lg); makefile->AddGeneratorTarget(autogenTarget, gt); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 7a23e9d..d1b7755 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -146,7 +146,6 @@ public: std::vector CompileFeaturesBacktraces; std::vector CompileDefinitionsEntries; std::vector CompileDefinitionsBacktraces; - std::vector CompileDefinitionsItems; std::vector SourceEntries; std::vector LinkImplementationPropertyEntries; @@ -175,7 +174,6 @@ cmTarget::cmTarget() this->IsApple = false; this->IsImportedTarget = false; this->BuildInterfaceIncludesAppended = false; - this->DebugCompileDefinitionsDone = false; this->DebugSourcesDone = false; this->LinkImplementationLanguageIsContextDependent = true; } @@ -418,14 +416,6 @@ void CreatePropertyGeneratorExpressions( } } -void cmTarget::Compute() -{ - CreatePropertyGeneratorExpressions( - this->Internal->CompileDefinitionsEntries, - this->Internal->CompileDefinitionsBacktraces, - this->Internal->CompileDefinitionsItems); -} - //---------------------------------------------------------------------------- void cmTarget::AddUtility(const std::string& u, cmMakefile *makefile) { @@ -1329,6 +1319,16 @@ cmBacktraceRange cmTarget::GetCompileFeaturesBacktraces() const return cmMakeRange(this->Internal->CompileFeaturesBacktraces); } +cmStringRange cmTarget::GetCompileDefinitionsEntries() const +{ + return cmMakeRange(this->Internal->CompileDefinitionsEntries); +} + +cmBacktraceRange cmTarget::GetCompileDefinitionsBacktraces() const +{ + return cmMakeRange(this->Internal->CompileDefinitionsBacktraces); +} + #if defined(_WIN32) && !defined(__CYGWIN__) //---------------------------------------------------------------------------- void @@ -1926,156 +1926,6 @@ void cmTarget::InsertCompileDefinition(std::string const& entry, } //---------------------------------------------------------------------------- -static void processCompileOptionsInternal(cmTarget const* tgt, - const std::vector &entries, - std::vector &options, - UNORDERED_SET &uniqueOptions, - cmGeneratorExpressionDAGChecker *dagChecker, - const std::string& config, bool debugOptions, const char *logName, - std::string const& language) -{ - cmMakefile *mf = tgt->GetMakefile(); - - for (std::vector::const_iterator - it = entries.begin(), end = entries.end(); it != end; ++it) - { - std::vector entryOptions; - cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf, - config, - false, - tgt, - dagChecker, - language), - entryOptions); - std::string usedOptions; - for(std::vector::iterator - li = entryOptions.begin(); li != entryOptions.end(); ++li) - { - std::string const& opt = *li; - - if(uniqueOptions.insert(opt).second) - { - options.push_back(opt); - if (debugOptions) - { - usedOptions += " * " + opt + "\n"; - } - } - } - if (!usedOptions.empty()) - { - mf->GetCMakeInstance()->IssueMessage(cmake::LOG, - std::string("Used compile ") + logName - + std::string(" for target ") - + tgt->GetName() + ":\n" - + usedOptions, (*it)->ge->GetBacktrace()); - } - } -} - -//---------------------------------------------------------------------------- -static void processCompileDefinitions(cmTarget const* tgt, - const std::vector &entries, - std::vector &options, - UNORDERED_SET &uniqueOptions, - cmGeneratorExpressionDAGChecker *dagChecker, - const std::string& config, bool debugOptions, - std::string const& language) -{ - processCompileOptionsInternal(tgt, entries, options, uniqueOptions, - dagChecker, config, debugOptions, - "definitions", language); -} - -//---------------------------------------------------------------------------- -void cmTarget::GetCompileDefinitions(std::vector &list, - const std::string& config, - const std::string& language) const -{ - UNORDERED_SET uniqueOptions; - - cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), - "COMPILE_DEFINITIONS", 0, 0); - - std::vector debugProperties; - const char *debugProp = - this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); - if (debugProp) - { - cmSystemTools::ExpandListArgument(debugProp, debugProperties); - } - - bool debugDefines = !this->DebugCompileDefinitionsDone - && std::find(debugProperties.begin(), - debugProperties.end(), - "COMPILE_DEFINITIONS") - != debugProperties.end(); - - if (this->Makefile->IsConfigured()) - { - this->DebugCompileDefinitionsDone = true; - } - - processCompileDefinitions(this, - this->Internal->CompileDefinitionsItems, - list, - uniqueOptions, - &dagChecker, - config, - debugDefines, - language); - - std::vector - linkInterfaceCompileDefinitionsEntries; - this->Internal->AddInterfaceEntries( - this, config, "INTERFACE_COMPILE_DEFINITIONS", - linkInterfaceCompileDefinitionsEntries); - if (!config.empty()) - { - std::string configPropName = "COMPILE_DEFINITIONS_" - + cmSystemTools::UpperCase(config); - const char *configProp = this->GetProperty(configPropName); - if (configProp) - { - switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0043)) - { - case cmPolicies::WARN: - { - std::ostringstream e; - e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0043); - this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, - e.str()); - } - case cmPolicies::OLD: - { - cmGeneratorExpression ge; - cmsys::auto_ptr cge = - ge.Parse(configProp); - linkInterfaceCompileDefinitionsEntries - .push_back(new cmTargetInternals::TargetPropertyEntry(cge)); - } - break; - case cmPolicies::NEW: - case cmPolicies::REQUIRED_ALWAYS: - case cmPolicies::REQUIRED_IF_USED: - break; - } - } - } - - processCompileDefinitions(this, - linkInterfaceCompileDefinitionsEntries, - list, - uniqueOptions, - &dagChecker, - config, - debugDefines, - language); - - cmDeleteAll(linkInterfaceCompileDefinitionsEntries); -} - -//---------------------------------------------------------------------------- void cmTarget::MaybeInvalidatePropertyCache(const std::string& prop) { // Wipe out maps caching information affected by this property. @@ -4035,7 +3885,6 @@ cmTargetInternalPointer //---------------------------------------------------------------------------- cmTargetInternalPointer::~cmTargetInternalPointer() { - cmDeleteAll(this->Pointer->CompileDefinitionsItems); cmDeleteAll(this->Pointer->SourceEntries); delete this->Pointer; } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index aae558e..34a75ea 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -132,8 +132,6 @@ public: void AddPostBuildCommand(cmCustomCommand const &cmd) {this->PostBuildCommands.push_back(cmd);} - void Compute(); - /** * Get the list of the source files used by this target */ @@ -309,10 +307,6 @@ public: If no macro should be defined null is returned. */ const char* GetExportMacro() const; - void GetCompileDefinitions(std::vector &result, - const std::string& config, - const std::string& language) const; - // Compute the set of languages compiled by the target. This is // computed every time it is called because the languages can change // when source file properties are changed and we do not have enough @@ -402,6 +396,9 @@ public: cmStringRange GetCompileFeaturesEntries() const; cmBacktraceRange GetCompileFeaturesBacktraces() const; + cmStringRange GetCompileDefinitionsEntries() const; + cmBacktraceRange GetCompileDefinitionsBacktraces() const; + #if defined(_WIN32) && !defined(__CYGWIN__) const LinkLibraryVectorType &GetLinkLibrariesForVS6() const { return this->LinkLibrariesForVS6;} @@ -516,7 +513,6 @@ private: bool IsApple; bool IsImportedTarget; bool BuildInterfaceIncludesAppended; - mutable bool DebugCompileDefinitionsDone; mutable bool DebugSourcesDone; mutable bool LinkImplementationLanguageIsContextDependent; #if defined(_WIN32) && !defined(__CYGWIN__) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=09bd59c75114dd177c685a62a34a3010ff2250a0 commit 09bd59c75114dd177c685a62a34a3010ff2250a0 Author: Stephen Kelly AuthorDate: Tue Aug 4 23:48:58 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 22:37:09 2015 +0200 cmGeneratorTarget: Move compile features processing from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index a56d95d..393ade9 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -261,7 +261,8 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) : Target(t), SourceFileFlagsConstructed(false), DebugIncludesDone(false), - DebugCompileOptionsDone(false) + DebugCompileOptionsDone(false), + DebugCompileFeaturesDone(false) { this->Makefile = this->Target->GetMakefile(); this->LocalGenerator = lg; @@ -276,12 +277,18 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) t->GetCompileOptionsEntries(), t->GetCompileOptionsBacktraces(), this->CompileOptionsEntries); + + CreatePropertyGeneratorExpressions( + t->GetCompileFeaturesEntries(), + t->GetCompileFeaturesBacktraces(), + this->CompileFeaturesEntries); } cmGeneratorTarget::~cmGeneratorTarget() { cmDeleteAll(this->IncludeDirectoriesEntries); cmDeleteAll(this->CompileOptionsEntries); + cmDeleteAll(this->CompileFeaturesEntries); cmDeleteAll(this->LinkInformation); this->LinkInformation.clear(); } @@ -2371,6 +2378,73 @@ void cmGeneratorTarget::GetCompileOptions(std::vector &result, } //---------------------------------------------------------------------------- +static void processCompileFeatures(cmGeneratorTarget const* tgt, + const std::vector &entries, + std::vector &options, + UNORDERED_SET &uniqueOptions, + cmGeneratorExpressionDAGChecker *dagChecker, + const std::string& config, bool debugOptions) +{ + processCompileOptionsInternal(tgt, entries, options, uniqueOptions, + dagChecker, config, debugOptions, "features", + std::string()); +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GetCompileFeatures(std::vector &result, + const std::string& config) const +{ + UNORDERED_SET uniqueFeatures; + + cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), + "COMPILE_FEATURES", + 0, 0); + + std::vector debugProperties; + const char *debugProp = + this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); + if (debugProp) + { + cmSystemTools::ExpandListArgument(debugProp, debugProperties); + } + + bool debugFeatures = !this->DebugCompileFeaturesDone + && std::find(debugProperties.begin(), + debugProperties.end(), + "COMPILE_FEATURES") + != debugProperties.end(); + + if (this->Makefile->IsConfigured()) + { + this->DebugCompileFeaturesDone = true; + } + + processCompileFeatures(this, + this->CompileFeaturesEntries, + result, + uniqueFeatures, + &dagChecker, + config, + debugFeatures); + + std::vector + linkInterfaceCompileFeaturesEntries; + AddInterfaceEntries( + this, config, "INTERFACE_COMPILE_FEATURES", + linkInterfaceCompileFeaturesEntries); + + processCompileFeatures(this, + linkInterfaceCompileFeaturesEntries, + result, + uniqueFeatures, + &dagChecker, + config, + debugFeatures); + + cmDeleteAll(linkInterfaceCompileFeaturesEntries); +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GenerateTargetManifest( const std::string& config) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 99dc746..e57485f 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -249,6 +249,9 @@ public: const std::string& config, const std::string& language) const; + void GetCompileFeatures(std::vector &features, + const std::string& config) const; + bool IsSystemIncludeDirectory(const std::string& dir, const std::string& config) const; @@ -455,9 +458,11 @@ private: mutable bool PolicyWarnedCMP0022; mutable bool DebugIncludesDone; mutable bool DebugCompileOptionsDone; + mutable bool DebugCompileFeaturesDone; std::vector IncludeDirectoriesEntries; std::vector CompileOptionsEntries; + std::vector CompileFeaturesEntries; void ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, cmTarget const* headTarget, diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 89515ff..a7e4191 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1138,7 +1138,7 @@ void cmLocalGenerator::AddCompileOptions( } } std::vector features; - target->GetCompileFeatures(features, config); + gtgt->GetCompileFeatures(features, config); for(std::vector::const_iterator it = features.begin(); it != features.end(); ++it) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 466f98a..7a23e9d 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -144,7 +144,6 @@ public: std::vector CompileOptionsBacktraces; std::vector CompileFeaturesEntries; std::vector CompileFeaturesBacktraces; - std::vector CompileFeaturesItems; std::vector CompileDefinitionsEntries; std::vector CompileDefinitionsBacktraces; std::vector CompileDefinitionsItems; @@ -176,7 +175,6 @@ cmTarget::cmTarget() this->IsApple = false; this->IsImportedTarget = false; this->BuildInterfaceIncludesAppended = false; - this->DebugCompileFeaturesDone = false; this->DebugCompileDefinitionsDone = false; this->DebugSourcesDone = false; this->LinkImplementationLanguageIsContextDependent = true; @@ -423,11 +421,6 @@ void CreatePropertyGeneratorExpressions( void cmTarget::Compute() { CreatePropertyGeneratorExpressions( - this->Internal->CompileFeaturesEntries, - this->Internal->CompileFeaturesBacktraces, - this->Internal->CompileFeaturesItems); - - CreatePropertyGeneratorExpressions( this->Internal->CompileDefinitionsEntries, this->Internal->CompileDefinitionsBacktraces, this->Internal->CompileDefinitionsItems); @@ -1326,6 +1319,16 @@ cmBacktraceRange cmTarget::GetCompileOptionsBacktraces() const return cmMakeRange(this->Internal->CompileOptionsBacktraces); } +cmStringRange cmTarget::GetCompileFeaturesEntries() const +{ + return cmMakeRange(this->Internal->CompileFeaturesEntries); +} + +cmBacktraceRange cmTarget::GetCompileFeaturesBacktraces() const +{ + return cmMakeRange(this->Internal->CompileFeaturesBacktraces); +} + #if defined(_WIN32) && !defined(__CYGWIN__) //---------------------------------------------------------------------------- void @@ -2073,73 +2076,6 @@ void cmTarget::GetCompileDefinitions(std::vector &list, } //---------------------------------------------------------------------------- -static void processCompileFeatures(cmTarget const* tgt, - const std::vector &entries, - std::vector &options, - UNORDERED_SET &uniqueOptions, - cmGeneratorExpressionDAGChecker *dagChecker, - const std::string& config, bool debugOptions) -{ - processCompileOptionsInternal(tgt, entries, options, uniqueOptions, - dagChecker, config, debugOptions, "features", - std::string()); -} - -//---------------------------------------------------------------------------- -void cmTarget::GetCompileFeatures(std::vector &result, - const std::string& config) const -{ - UNORDERED_SET uniqueFeatures; - - cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), - "COMPILE_FEATURES", - 0, 0); - - std::vector debugProperties; - const char *debugProp = - this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); - if (debugProp) - { - cmSystemTools::ExpandListArgument(debugProp, debugProperties); - } - - bool debugFeatures = !this->DebugCompileFeaturesDone - && std::find(debugProperties.begin(), - debugProperties.end(), - "COMPILE_FEATURES") - != debugProperties.end(); - - if (this->Makefile->IsConfigured()) - { - this->DebugCompileFeaturesDone = true; - } - - processCompileFeatures(this, - this->Internal->CompileFeaturesItems, - result, - uniqueFeatures, - &dagChecker, - config, - debugFeatures); - - std::vector - linkInterfaceCompileFeaturesEntries; - this->Internal->AddInterfaceEntries( - this, config, "INTERFACE_COMPILE_FEATURES", - linkInterfaceCompileFeaturesEntries); - - processCompileFeatures(this, - linkInterfaceCompileFeaturesEntries, - result, - uniqueFeatures, - &dagChecker, - config, - debugFeatures); - - cmDeleteAll(linkInterfaceCompileFeaturesEntries); -} - -//---------------------------------------------------------------------------- void cmTarget::MaybeInvalidatePropertyCache(const std::string& prop) { // Wipe out maps caching information affected by this property. @@ -4099,7 +4035,6 @@ cmTargetInternalPointer //---------------------------------------------------------------------------- cmTargetInternalPointer::~cmTargetInternalPointer() { - cmDeleteAll(this->Pointer->CompileFeaturesItems); cmDeleteAll(this->Pointer->CompileDefinitionsItems); cmDeleteAll(this->Pointer->SourceEntries); delete this->Pointer; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 05b6aec..aae558e 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -375,9 +375,6 @@ public: void AppendBuildInterfaceIncludes(); - void GetCompileFeatures(std::vector &features, - const std::string& config) const; - bool IsNullImpliedByLinkLibraries(const std::string &p) const; std::string GetDebugGeneratorExpressions(const std::string &value, @@ -402,6 +399,9 @@ public: cmStringRange GetCompileOptionsEntries() const; cmBacktraceRange GetCompileOptionsBacktraces() const; + cmStringRange GetCompileFeaturesEntries() const; + cmBacktraceRange GetCompileFeaturesBacktraces() const; + #if defined(_WIN32) && !defined(__CYGWIN__) const LinkLibraryVectorType &GetLinkLibrariesForVS6() const { return this->LinkLibrariesForVS6;} @@ -518,7 +518,6 @@ private: bool BuildInterfaceIncludesAppended; mutable bool DebugCompileDefinitionsDone; mutable bool DebugSourcesDone; - mutable bool DebugCompileFeaturesDone; mutable bool LinkImplementationLanguageIsContextDependent; #if defined(_WIN32) && !defined(__CYGWIN__) bool LinkLibrariesForVS6Analyzed; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8d45ba34d64cb5d7d71d8ade8b5f2226cd9e4734 commit 8d45ba34d64cb5d7d71d8ade8b5f2226cd9e4734 Author: Stephen Kelly AuthorDate: Tue Aug 4 23:43:56 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 22:37:09 2015 +0200 cmGeneratorTarget: Move compile options processing from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 01967da..a56d95d 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -260,7 +260,8 @@ void CreatePropertyGeneratorExpressions( cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) : Target(t), SourceFileFlagsConstructed(false), - DebugIncludesDone(false) + DebugIncludesDone(false), + DebugCompileOptionsDone(false) { this->Makefile = this->Target->GetMakefile(); this->LocalGenerator = lg; @@ -270,11 +271,17 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) t->GetIncludeDirectoriesEntries(), t->GetIncludeDirectoriesBacktraces(), this->IncludeDirectoriesEntries); + + CreatePropertyGeneratorExpressions( + t->GetCompileOptionsEntries(), + t->GetCompileOptionsBacktraces(), + this->CompileOptionsEntries); } cmGeneratorTarget::~cmGeneratorTarget() { cmDeleteAll(this->IncludeDirectoriesEntries); + cmDeleteAll(this->CompileOptionsEntries); cmDeleteAll(this->LinkInformation); this->LinkInformation.clear(); } @@ -2245,6 +2252,125 @@ cmGeneratorTarget::GetIncludeDirectories(const std::string& config, } //---------------------------------------------------------------------------- +static void processCompileOptionsInternal(cmGeneratorTarget const* tgt, + const std::vector &entries, + std::vector &options, + UNORDERED_SET &uniqueOptions, + cmGeneratorExpressionDAGChecker *dagChecker, + const std::string& config, bool debugOptions, const char *logName, + std::string const& language) +{ + cmMakefile *mf = tgt->Target->GetMakefile(); + + for (std::vector::const_iterator + it = entries.begin(), end = entries.end(); it != end; ++it) + { + std::vector entryOptions; + cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf, + config, + false, + tgt->Target, + dagChecker, + language), + entryOptions); + std::string usedOptions; + for(std::vector::iterator + li = entryOptions.begin(); li != entryOptions.end(); ++li) + { + std::string const& opt = *li; + + if(uniqueOptions.insert(opt).second) + { + options.push_back(opt); + if (debugOptions) + { + usedOptions += " * " + opt + "\n"; + } + } + } + if (!usedOptions.empty()) + { + mf->GetCMakeInstance()->IssueMessage(cmake::LOG, + std::string("Used compile ") + logName + + std::string(" for target ") + + tgt->GetName() + ":\n" + + usedOptions, (*it)->ge->GetBacktrace()); + } + } +} + +//---------------------------------------------------------------------------- +static void processCompileOptions(cmGeneratorTarget const* tgt, + const std::vector &entries, + std::vector &options, + UNORDERED_SET &uniqueOptions, + cmGeneratorExpressionDAGChecker *dagChecker, + const std::string& config, bool debugOptions, + std::string const& language) +{ + processCompileOptionsInternal(tgt, entries, options, uniqueOptions, + dagChecker, config, debugOptions, "options", + language); +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GetCompileOptions(std::vector &result, + const std::string& config, + const std::string& language) const +{ + UNORDERED_SET uniqueOptions; + + cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), + "COMPILE_OPTIONS", 0, 0); + + std::vector debugProperties; + const char *debugProp = + this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); + if (debugProp) + { + cmSystemTools::ExpandListArgument(debugProp, debugProperties); + } + + bool debugOptions = !this->DebugCompileOptionsDone + && std::find(debugProperties.begin(), + debugProperties.end(), + "COMPILE_OPTIONS") + != debugProperties.end(); + + if (this->Makefile->IsConfigured()) + { + this->DebugCompileOptionsDone = true; + } + + processCompileOptions(this, + this->CompileOptionsEntries, + result, + uniqueOptions, + &dagChecker, + config, + debugOptions, + language); + + std::vector + linkInterfaceCompileOptionsEntries; + + AddInterfaceEntries( + this, config, "INTERFACE_COMPILE_OPTIONS", + linkInterfaceCompileOptionsEntries); + + processCompileOptions(this, + linkInterfaceCompileOptionsEntries, + result, + uniqueOptions, + &dagChecker, + config, + debugOptions, + language); + + cmDeleteAll(linkInterfaceCompileOptionsEntries); +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GenerateTargetManifest( const std::string& config) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 9407d1f..99dc746 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -245,6 +245,10 @@ public: std::vector GetIncludeDirectories( const std::string& config, const std::string& lang) const; + void GetCompileOptions(std::vector &result, + const std::string& config, + const std::string& language) const; + bool IsSystemIncludeDirectory(const std::string& dir, const std::string& config) const; @@ -450,8 +454,10 @@ private: mutable bool PolicyWarnedCMP0022; mutable bool DebugIncludesDone; + mutable bool DebugCompileOptionsDone; std::vector IncludeDirectoriesEntries; + std::vector CompileOptionsEntries; void ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, cmTarget const* headTarget, diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index edb644d..89515ff 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1094,6 +1094,10 @@ void cmLocalGenerator::AddCompileOptions( ) { std::string langFlagRegexVar = std::string("CMAKE_")+lang+"_FLAG_REGEX"; + + cmGeneratorTarget* gtgt = + this->GlobalGenerator->GetGeneratorTarget(target); + if(const char* langFlagRegexStr = this->Makefile->GetDefinition(langFlagRegexVar)) { @@ -1104,7 +1108,7 @@ void cmLocalGenerator::AddCompileOptions( { cmSystemTools::ParseWindowsCommandLine(targetFlags, opts); } - target->GetCompileOptions(opts, config, lang); + gtgt->GetCompileOptions(opts, config, lang); for(std::vector::const_iterator i = opts.begin(); i != opts.end(); ++i) { @@ -1125,7 +1129,7 @@ void cmLocalGenerator::AddCompileOptions( this->AppendFlags(flags, targetFlags); } std::vector opts; - target->GetCompileOptions(opts, config, lang); + gtgt->GetCompileOptions(opts, config, lang); for(std::vector::const_iterator i = opts.begin(); i != opts.end(); ++i) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index fb4241b..466f98a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -142,7 +142,6 @@ public: std::vector IncludeDirectoriesBacktraces; std::vector CompileOptionsEntries; std::vector CompileOptionsBacktraces; - std::vector CompileOptionsItems; std::vector CompileFeaturesEntries; std::vector CompileFeaturesBacktraces; std::vector CompileFeaturesItems; @@ -177,7 +176,6 @@ cmTarget::cmTarget() this->IsApple = false; this->IsImportedTarget = false; this->BuildInterfaceIncludesAppended = false; - this->DebugCompileOptionsDone = false; this->DebugCompileFeaturesDone = false; this->DebugCompileDefinitionsDone = false; this->DebugSourcesDone = false; @@ -425,11 +423,6 @@ void CreatePropertyGeneratorExpressions( void cmTarget::Compute() { CreatePropertyGeneratorExpressions( - this->Internal->CompileOptionsEntries, - this->Internal->CompileOptionsBacktraces, - this->Internal->CompileOptionsItems); - - CreatePropertyGeneratorExpressions( this->Internal->CompileFeaturesEntries, this->Internal->CompileFeaturesBacktraces, this->Internal->CompileFeaturesItems); @@ -1323,6 +1316,16 @@ cmBacktraceRange cmTarget::GetIncludeDirectoriesBacktraces() const return cmMakeRange(this->Internal->IncludeDirectoriesBacktraces); } +cmStringRange cmTarget::GetCompileOptionsEntries() const +{ + return cmMakeRange(this->Internal->CompileOptionsEntries); +} + +cmBacktraceRange cmTarget::GetCompileOptionsBacktraces() const +{ + return cmMakeRange(this->Internal->CompileOptionsBacktraces); +} + #if defined(_WIN32) && !defined(__CYGWIN__) //---------------------------------------------------------------------------- void @@ -1968,77 +1971,6 @@ static void processCompileOptionsInternal(cmTarget const* tgt, } //---------------------------------------------------------------------------- -static void processCompileOptions(cmTarget const* tgt, - const std::vector &entries, - std::vector &options, - UNORDERED_SET &uniqueOptions, - cmGeneratorExpressionDAGChecker *dagChecker, - const std::string& config, bool debugOptions, - std::string const& language) -{ - processCompileOptionsInternal(tgt, entries, options, uniqueOptions, - dagChecker, config, debugOptions, "options", - language); -} - -//---------------------------------------------------------------------------- -void cmTarget::GetCompileOptions(std::vector &result, - const std::string& config, - const std::string& language) const -{ - UNORDERED_SET uniqueOptions; - - cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), - "COMPILE_OPTIONS", 0, 0); - - std::vector debugProperties; - const char *debugProp = - this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); - if (debugProp) - { - cmSystemTools::ExpandListArgument(debugProp, debugProperties); - } - - bool debugOptions = !this->DebugCompileOptionsDone - && std::find(debugProperties.begin(), - debugProperties.end(), - "COMPILE_OPTIONS") - != debugProperties.end(); - - if (this->Makefile->IsConfigured()) - { - this->DebugCompileOptionsDone = true; - } - - processCompileOptions(this, - this->Internal->CompileOptionsItems, - result, - uniqueOptions, - &dagChecker, - config, - debugOptions, - language); - - std::vector - linkInterfaceCompileOptionsEntries; - - this->Internal->AddInterfaceEntries( - this, config, "INTERFACE_COMPILE_OPTIONS", - linkInterfaceCompileOptionsEntries); - - processCompileOptions(this, - linkInterfaceCompileOptionsEntries, - result, - uniqueOptions, - &dagChecker, - config, - debugOptions, - language); - - cmDeleteAll(linkInterfaceCompileOptionsEntries); -} - -//---------------------------------------------------------------------------- static void processCompileDefinitions(cmTarget const* tgt, const std::vector &entries, std::vector &options, @@ -4167,7 +4099,6 @@ cmTargetInternalPointer //---------------------------------------------------------------------------- cmTargetInternalPointer::~cmTargetInternalPointer() { - cmDeleteAll(this->Pointer->CompileOptionsItems); cmDeleteAll(this->Pointer->CompileFeaturesItems); cmDeleteAll(this->Pointer->CompileDefinitionsItems); cmDeleteAll(this->Pointer->SourceEntries); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 13e4f2d..05b6aec 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -375,9 +375,6 @@ public: void AppendBuildInterfaceIncludes(); - void GetCompileOptions(std::vector &result, - const std::string& config, - const std::string& language) const; void GetCompileFeatures(std::vector &features, const std::string& config) const; @@ -402,6 +399,9 @@ public: cmStringRange GetIncludeDirectoriesEntries() const; cmBacktraceRange GetIncludeDirectoriesBacktraces() const; + cmStringRange GetCompileOptionsEntries() const; + cmBacktraceRange GetCompileOptionsBacktraces() const; + #if defined(_WIN32) && !defined(__CYGWIN__) const LinkLibraryVectorType &GetLinkLibrariesForVS6() const { return this->LinkLibrariesForVS6;} @@ -516,7 +516,6 @@ private: bool IsApple; bool IsImportedTarget; bool BuildInterfaceIncludesAppended; - mutable bool DebugCompileOptionsDone; mutable bool DebugCompileDefinitionsDone; mutable bool DebugSourcesDone; mutable bool DebugCompileFeaturesDone; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6ee49bf15acc52ea8b0a32c3e64bfaf75be95846 commit 6ee49bf15acc52ea8b0a32c3e64bfaf75be95846 Author: Stephen Kelly AuthorDate: Tue Aug 4 23:14:53 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 22:37:08 2015 +0200 cmGeneratorTarget: Move include directory processing from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 1e8e83b..01967da 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -34,6 +34,18 @@ #define UNORDERED_SET std::set #endif +class cmGeneratorTarget::TargetPropertyEntry { + static cmLinkImplItem NoLinkImplItem; +public: + TargetPropertyEntry(cmsys::auto_ptr cge, + cmLinkImplItem const& item = NoLinkImplItem) + : ge(cge), LinkImplItem(item) + {} + const cmsys::auto_ptr ge; + cmLinkImplItem const& LinkImplItem; +}; +cmLinkImplItem cmGeneratorTarget::TargetPropertyEntry::NoLinkImplItem; + //---------------------------------------------------------------------------- void reportBadObjLib(std::vector const& badObjLib, cmGeneratorTarget const* target, cmake *cm) @@ -227,18 +239,42 @@ struct TagVisitor } }; +void CreatePropertyGeneratorExpressions( + cmStringRange const& entries, + cmBacktraceRange const& backtraces, + std::vector& items, + bool evaluateForBuildsystem = false) +{ + std::vector::const_iterator btIt = backtraces.begin(); + for (std::vector::const_iterator it = entries.begin(); + it != entries.end(); ++it, ++btIt) + { + cmGeneratorExpression ge(*btIt); + cmsys::auto_ptr cge = ge.Parse(*it); + cge->SetEvaluateForBuildsystem(evaluateForBuildsystem); + items.push_back(new cmGeneratorTarget::TargetPropertyEntry(cge)); + } +} + //---------------------------------------------------------------------------- cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) : Target(t), - SourceFileFlagsConstructed(false) + SourceFileFlagsConstructed(false), + DebugIncludesDone(false) { this->Makefile = this->Target->GetMakefile(); this->LocalGenerator = lg; this->GlobalGenerator = this->LocalGenerator->GetGlobalGenerator(); + + CreatePropertyGeneratorExpressions( + t->GetIncludeDirectoriesEntries(), + t->GetIncludeDirectoriesBacktraces(), + this->IncludeDirectoriesEntries); } cmGeneratorTarget::~cmGeneratorTarget() { + cmDeleteAll(this->IncludeDirectoriesEntries); cmDeleteAll(this->LinkInformation); this->LinkInformation.clear(); } @@ -1964,13 +2000,248 @@ cmGeneratorTarget::GetCreateRuleVariable(std::string const& lang, } return ""; } +//---------------------------------------------------------------------------- +static void processIncludeDirectories(cmGeneratorTarget const* tgt, + const std::vector &entries, + std::vector &includes, + UNORDERED_SET &uniqueIncludes, + cmGeneratorExpressionDAGChecker *dagChecker, + const std::string& config, bool debugIncludes, + const std::string& language) +{ + cmMakefile *mf = tgt->Target->GetMakefile(); + + for (std::vector::const_iterator + it = entries.begin(), end = entries.end(); it != end; ++it) + { + cmLinkImplItem const& item = (*it)->LinkImplItem; + std::string const& targetName = item; + bool const fromImported = item.Target && item.Target->IsImported(); + bool const checkCMP0027 = item.FromGenex; + std::vector entryIncludes; + cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf, + config, + false, + tgt->Target, + dagChecker, language), + entryIncludes); + + std::string usedIncludes; + for(std::vector::iterator + li = entryIncludes.begin(); li != entryIncludes.end(); ++li) + { + if (fromImported + && !cmSystemTools::FileExists(li->c_str())) + { + std::ostringstream e; + cmake::MessageType messageType = cmake::FATAL_ERROR; + if (checkCMP0027) + { + switch(tgt->Target->GetPolicyStatusCMP0027()) + { + case cmPolicies::WARN: + e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0027) << "\n"; + case cmPolicies::OLD: + messageType = cmake::AUTHOR_WARNING; + break; + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::NEW: + break; + } + } + e << "Imported target \"" << targetName << "\" includes " + "non-existent path\n \"" << *li << "\"\nin its " + "INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:\n" + "* The path was deleted, renamed, or moved to another " + "location.\n" + "* An install or uninstall procedure did not complete " + "successfully.\n" + "* The installation package was faulty and references files it " + "does not provide.\n"; + tgt->GetLocalGenerator()->IssueMessage(messageType, e.str()); + return; + } + + if (!cmSystemTools::FileIsFullPath(li->c_str())) + { + std::ostringstream e; + bool noMessage = false; + cmake::MessageType messageType = cmake::FATAL_ERROR; + if (!targetName.empty()) + { + e << "Target \"" << targetName << "\" contains relative " + "path in its INTERFACE_INCLUDE_DIRECTORIES:\n" + " \"" << *li << "\""; + } + else + { + switch(tgt->Target->GetPolicyStatusCMP0021()) + { + case cmPolicies::WARN: + { + e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0021) << "\n"; + messageType = cmake::AUTHOR_WARNING; + } + break; + case cmPolicies::OLD: + noMessage = true; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::NEW: + // Issue the fatal message. + break; + } + e << "Found relative path while evaluating include directories of " + "\"" << tgt->GetName() << "\":\n \"" << *li << "\"\n"; + } + if (!noMessage) + { + tgt->GetLocalGenerator()->IssueMessage(messageType, e.str()); + if (messageType == cmake::FATAL_ERROR) + { + return; + } + } + } + + if (!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 (!usedIncludes.empty()) + { + mf->GetCMakeInstance()->IssueMessage(cmake::LOG, + std::string("Used includes for target ") + + tgt->GetName() + ":\n" + + usedIncludes, (*it)->ge->GetBacktrace()); + } + } +} + + +//---------------------------------------------------------------------------- +static void AddInterfaceEntries( + cmGeneratorTarget const* thisTarget, std::string const& config, + std::string const& prop, + std::vector& entries) +{ + if(cmLinkImplementationLibraries const* impl = + thisTarget->Target->GetLinkImplementationLibraries(config)) + { + for (std::vector::const_iterator + it = impl->Libraries.begin(), end = impl->Libraries.end(); + it != end; ++it) + { + if(it->Target) + { + std::string genex = + "$"; + cmGeneratorExpression ge(it->Backtrace); + cmsys::auto_ptr cge = ge.Parse(genex); + cge->SetEvaluateForBuildsystem(true); + entries.push_back( + new cmGeneratorTarget::TargetPropertyEntry(cge, *it)); + } + } + } +} //---------------------------------------------------------------------------- std::vector cmGeneratorTarget::GetIncludeDirectories(const std::string& config, const std::string& lang) const { - return this->Target->GetIncludeDirectories(config, lang); + std::vector includes; + UNORDERED_SET uniqueIncludes; + + cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), + "INCLUDE_DIRECTORIES", 0, 0); + + std::vector debugProperties; + const char *debugProp = + this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); + if (debugProp) + { + cmSystemTools::ExpandListArgument(debugProp, debugProperties); + } + + bool debugIncludes = !this->DebugIncludesDone + && std::find(debugProperties.begin(), + debugProperties.end(), + "INCLUDE_DIRECTORIES") + != debugProperties.end(); + + if (this->Makefile->IsConfigured()) + { + this->DebugIncludesDone = true; + } + + processIncludeDirectories(this, + this->IncludeDirectoriesEntries, + includes, + uniqueIncludes, + &dagChecker, + config, + debugIncludes, + lang); + + std::vector + linkInterfaceIncludeDirectoriesEntries; + AddInterfaceEntries( + this, config, "INTERFACE_INCLUDE_DIRECTORIES", + linkInterfaceIncludeDirectoriesEntries); + + if(this->Makefile->IsOn("APPLE")) + { + cmLinkImplementationLibraries const* impl = + this->Target->GetLinkImplementationLibraries(config); + for(std::vector::const_iterator + it = impl->Libraries.begin(); + it != impl->Libraries.end(); ++it) + { + std::string libDir = cmSystemTools::CollapseFullPath(*it); + + static cmsys::RegularExpression + frameworkCheck("(.*\\.framework)(/Versions/[^/]+)?/[^/]+$"); + if(!frameworkCheck.find(libDir)) + { + continue; + } + + libDir = frameworkCheck.match(1); + + cmGeneratorExpression ge; + cmsys::auto_ptr cge = + ge.Parse(libDir.c_str()); + linkInterfaceIncludeDirectoriesEntries + .push_back(new cmGeneratorTarget::TargetPropertyEntry(cge)); + } + } + + processIncludeDirectories(this, + linkInterfaceIncludeDirectoriesEntries, + includes, + uniqueIncludes, + &dagChecker, + config, + debugIncludes, + lang); + + cmDeleteAll(linkInterfaceIncludeDirectoriesEntries); + + return includes; } //---------------------------------------------------------------------------- diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 46341d3..9407d1f 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -360,6 +360,8 @@ public: const std::string &report, const std::string &compatibilityType) const; + class TargetPropertyEntry; + private: friend class cmTargetTraceDependencies; struct SourceEntry { std::vector Depends; }; @@ -447,6 +449,9 @@ private: mutable LinkInterfaceMapType LinkInterfaceUsageRequirementsOnlyMap; mutable bool PolicyWarnedCMP0022; + mutable bool DebugIncludesDone; + + std::vector IncludeDirectoriesEntries; void ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, cmTarget const* headTarget, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e941fb6..fb4241b 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -140,7 +140,6 @@ public: }; std::vector IncludeDirectoriesEntries; std::vector IncludeDirectoriesBacktraces; - std::vector IncludeDirectoriesItems; std::vector CompileOptionsEntries; std::vector CompileOptionsBacktraces; std::vector CompileOptionsItems; @@ -178,7 +177,6 @@ cmTarget::cmTarget() this->IsApple = false; this->IsImportedTarget = false; this->BuildInterfaceIncludesAppended = false; - this->DebugIncludesDone = false; this->DebugCompileOptionsDone = false; this->DebugCompileFeaturesDone = false; this->DebugCompileDefinitionsDone = false; @@ -427,11 +425,6 @@ void CreatePropertyGeneratorExpressions( void cmTarget::Compute() { CreatePropertyGeneratorExpressions( - this->Internal->IncludeDirectoriesEntries, - this->Internal->IncludeDirectoriesBacktraces, - this->Internal->IncludeDirectoriesItems); - - CreatePropertyGeneratorExpressions( this->Internal->CompileOptionsEntries, this->Internal->CompileOptionsBacktraces, this->Internal->CompileOptionsItems); @@ -1320,6 +1313,16 @@ cmTarget::AddSystemIncludeDirectories(const std::set &incs) this->SystemIncludeDirectories.insert(incs.begin(), incs.end()); } +cmStringRange cmTarget::GetIncludeDirectoriesEntries() const +{ + return cmMakeRange(this->Internal->IncludeDirectoriesEntries); +} + +cmBacktraceRange cmTarget::GetIncludeDirectoriesBacktraces() const +{ + return cmMakeRange(this->Internal->IncludeDirectoriesBacktraces); +} + #if defined(_WIN32) && !defined(__CYGWIN__) //---------------------------------------------------------------------------- void @@ -1917,222 +1920,6 @@ void cmTarget::InsertCompileDefinition(std::string const& entry, } //---------------------------------------------------------------------------- -static void processIncludeDirectories(cmTarget const* tgt, - const std::vector &entries, - std::vector &includes, - UNORDERED_SET &uniqueIncludes, - cmGeneratorExpressionDAGChecker *dagChecker, - const std::string& config, bool debugIncludes, - const std::string& language) -{ - cmMakefile *mf = tgt->GetMakefile(); - - for (std::vector::const_iterator - it = entries.begin(), end = entries.end(); it != end; ++it) - { - cmLinkImplItem const& item = (*it)->LinkImplItem; - std::string const& targetName = item; - bool const fromImported = item.Target && item.Target->IsImported(); - bool const checkCMP0027 = item.FromGenex; - std::vector entryIncludes; - cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf, - config, - false, - tgt, - dagChecker, language), - entryIncludes); - - std::string usedIncludes; - for(std::vector::iterator - li = entryIncludes.begin(); li != entryIncludes.end(); ++li) - { - if (fromImported - && !cmSystemTools::FileExists(li->c_str())) - { - std::ostringstream e; - cmake::MessageType messageType = cmake::FATAL_ERROR; - if (checkCMP0027) - { - switch(tgt->GetPolicyStatusCMP0027()) - { - case cmPolicies::WARN: - e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0027) << "\n"; - case cmPolicies::OLD: - messageType = cmake::AUTHOR_WARNING; - break; - case cmPolicies::REQUIRED_ALWAYS: - case cmPolicies::REQUIRED_IF_USED: - case cmPolicies::NEW: - break; - } - } - e << "Imported target \"" << targetName << "\" includes " - "non-existent path\n \"" << *li << "\"\nin its " - "INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:\n" - "* The path was deleted, renamed, or moved to another " - "location.\n" - "* An install or uninstall procedure did not complete " - "successfully.\n" - "* The installation package was faulty and references files it " - "does not provide.\n"; - tgt->GetMakefile()->IssueMessage(messageType, e.str()); - return; - } - - if (!cmSystemTools::FileIsFullPath(li->c_str())) - { - std::ostringstream e; - bool noMessage = false; - cmake::MessageType messageType = cmake::FATAL_ERROR; - if (!targetName.empty()) - { - e << "Target \"" << targetName << "\" contains relative " - "path in its INTERFACE_INCLUDE_DIRECTORIES:\n" - " \"" << *li << "\""; - } - else - { - switch(tgt->GetPolicyStatusCMP0021()) - { - case cmPolicies::WARN: - { - e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0021) << "\n"; - messageType = cmake::AUTHOR_WARNING; - } - break; - case cmPolicies::OLD: - noMessage = true; - case cmPolicies::REQUIRED_IF_USED: - case cmPolicies::REQUIRED_ALWAYS: - case cmPolicies::NEW: - // Issue the fatal message. - break; - } - e << "Found relative path while evaluating include directories of " - "\"" << tgt->GetName() << "\":\n \"" << *li << "\"\n"; - } - if (!noMessage) - { - tgt->GetMakefile()->IssueMessage(messageType, e.str()); - if (messageType == cmake::FATAL_ERROR) - { - return; - } - } - } - - if (!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 (!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 std::string& config, - const std::string& language) const -{ - std::vector includes; - UNORDERED_SET uniqueIncludes; - - cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), - "INCLUDE_DIRECTORIES", 0, 0); - - std::vector debugProperties; - const char *debugProp = - this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); - if (debugProp) - { - cmSystemTools::ExpandListArgument(debugProp, debugProperties); - } - - bool debugIncludes = !this->DebugIncludesDone - && std::find(debugProperties.begin(), - debugProperties.end(), - "INCLUDE_DIRECTORIES") - != debugProperties.end(); - - if (this->Makefile->IsConfigured()) - { - this->DebugIncludesDone = true; - } - - processIncludeDirectories(this, - this->Internal->IncludeDirectoriesItems, - includes, - uniqueIncludes, - &dagChecker, - config, - debugIncludes, - language); - - std::vector - linkInterfaceIncludeDirectoriesEntries; - this->Internal->AddInterfaceEntries( - this, config, "INTERFACE_INCLUDE_DIRECTORIES", - linkInterfaceIncludeDirectoriesEntries); - - if(this->Makefile->IsOn("APPLE")) - { - cmLinkImplementationLibraries const* impl = - this->GetLinkImplementationLibraries(config); - for(std::vector::const_iterator - it = impl->Libraries.begin(); - it != impl->Libraries.end(); ++it) - { - std::string libDir = cmSystemTools::CollapseFullPath(*it); - - static cmsys::RegularExpression - frameworkCheck("(.*\\.framework)(/Versions/[^/]+)?/[^/]+$"); - if(!frameworkCheck.find(libDir)) - { - continue; - } - - libDir = frameworkCheck.match(1); - - cmGeneratorExpression ge; - cmsys::auto_ptr cge = - ge.Parse(libDir.c_str()); - linkInterfaceIncludeDirectoriesEntries - .push_back(new cmTargetInternals::TargetPropertyEntry(cge)); - } - } - - processIncludeDirectories(this, - linkInterfaceIncludeDirectoriesEntries, - includes, - uniqueIncludes, - &dagChecker, - config, - debugIncludes, - language); - - cmDeleteAll(linkInterfaceIncludeDirectoriesEntries); - - return includes; -} - -//---------------------------------------------------------------------------- static void processCompileOptionsInternal(cmTarget const* tgt, const std::vector &entries, std::vector &options, @@ -4380,7 +4167,6 @@ cmTargetInternalPointer //---------------------------------------------------------------------------- cmTargetInternalPointer::~cmTargetInternalPointer() { - cmDeleteAll(this->Pointer->IncludeDirectoriesItems); cmDeleteAll(this->Pointer->CompileOptionsItems); cmDeleteAll(this->Pointer->CompileFeaturesItems); cmDeleteAll(this->Pointer->CompileDefinitionsItems); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 103a7e8..13e4f2d 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -364,9 +364,6 @@ public: /** @return whether this target have a well defined output file name. */ bool HaveWellDefinedOutputFiles() const; - std::vector GetIncludeDirectories( - const std::string& config, - const std::string& language) const; void InsertInclude(std::string const& entry, cmListFileBacktrace const& bt, bool before = false); @@ -402,6 +399,9 @@ public: return this->MaxLanguageStandards; } + cmStringRange GetIncludeDirectoriesEntries() const; + cmBacktraceRange GetIncludeDirectoriesBacktraces() const; + #if defined(_WIN32) && !defined(__CYGWIN__) const LinkLibraryVectorType &GetLinkLibrariesForVS6() const { return this->LinkLibrariesForVS6;} @@ -516,7 +516,6 @@ private: bool IsApple; bool IsImportedTarget; bool BuildInterfaceIncludesAppended; - mutable bool DebugIncludesDone; mutable bool DebugCompileOptionsDone; mutable bool DebugCompileDefinitionsDone; mutable bool DebugSourcesDone; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2962880e25943d5c7670ca34986366c3f41fb67d commit 2962880e25943d5c7670ca34986366c3f41fb67d Author: Stephen Kelly AuthorDate: Tue Aug 4 19:22:30 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 22:37:08 2015 +0200 cmGeneratorTarget: Move link iface helpers from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index cf4019c..1e8e83b 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3363,6 +3363,51 @@ cmGeneratorTarget::ReportPropertyOrigin(const std::string &p, } //---------------------------------------------------------------------------- +void cmGeneratorTarget::LookupLinkItems(std::vector const& names, + std::vector& items) const +{ + for(std::vector::const_iterator i = names.begin(); + i != names.end(); ++i) + { + std::string name = this->Target->CheckCMP0004(*i); + if(name == this->GetName() || name.empty()) + { + continue; + } + items.push_back(cmLinkItem(name, this->Target->FindTargetToLink(name))); + } +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::ExpandLinkItems(std::string const& prop, + std::string const& value, + std::string const& config, + cmTarget const* headTarget, + bool usage_requirements_only, + std::vector& items, + bool& hadHeadSensitiveCondition) const +{ + cmGeneratorExpression ge; + cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), prop, 0, 0); + // The $ expression may be in a link interface to specify private + // link dependencies that are otherwise excluded from usage requirements. + if(usage_requirements_only) + { + dagChecker.SetTransitivePropertiesOnly(); + } + std::vector libs; + cmsys::auto_ptr cge = ge.Parse(value); + cmSystemTools::ExpandListArgument(cge->Evaluate( + this->Makefile, + config, + false, + headTarget, + this->Target, &dagChecker), libs); + this->LookupLinkItems(libs, items); + hadHeadSensitiveCondition = cge->GetHadHeadSensitiveCondition(); +} + +//---------------------------------------------------------------------------- cmGeneratorTarget::LinkInterface const* cmGeneratorTarget::GetLinkInterface( const std::string& config, cmTarget const* head) const @@ -3397,14 +3442,14 @@ cmGeneratorTarget::LinkInterface const* cmGeneratorTarget::GetLinkInterface( { iface.LibrariesDone = true; this->ComputeLinkInterfaceLibraries( - this->Target, config, iface, head, false); + config, iface, head, false); } if(!iface.AllDone) { iface.AllDone = true; if(iface.Exists) { - this->ComputeLinkInterface(this->Target, config, iface, head); + this->ComputeLinkInterface(config, iface, head); } } @@ -3450,7 +3495,7 @@ cmGeneratorTarget::GetLinkInterfaceLibraries(const std::string& config, { iface.LibrariesDone = true; this->ComputeLinkInterfaceLibraries( - this->Target, config, iface, head, usage_requirements_only); + config, iface, head, usage_requirements_only); } return iface.Exists? &iface : 0; @@ -3487,13 +3532,13 @@ cmGeneratorTarget::GetImportLinkInterface(const std::string& config, iface.AllDone = true; iface.Multiplicity = info->Multiplicity; cmSystemTools::ExpandListArgument(info->Languages, iface.Languages); - this->Target->ExpandLinkItems(info->LibrariesProp, info->Libraries, config, + this->ExpandLinkItems(info->LibrariesProp, info->Libraries, config, headTarget, usage_requirements_only, iface.Libraries, iface.HadHeadSensitiveCondition); std::vector deps; cmSystemTools::ExpandListArgument(info->SharedDeps, deps); - this->Target->LookupLinkItems(deps, iface.SharedDeps); + this->LookupLinkItems(deps, iface.SharedDeps); } return &iface; @@ -3502,7 +3547,6 @@ cmGeneratorTarget::GetImportLinkInterface(const std::string& config, //---------------------------------------------------------------------------- void cmGeneratorTarget::ComputeLinkInterfaceLibraries( - cmTarget const* thisTarget, const std::string& config, OptionalLinkInterface& iface, cmTarget const* headTarget, @@ -3523,15 +3567,15 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( // libraries and executables that export symbols. const char* explicitLibraries = 0; std::string linkIfaceProp; - if(thisTarget->GetPolicyStatusCMP0022() != cmPolicies::OLD && - thisTarget->GetPolicyStatusCMP0022() != cmPolicies::WARN) + if(this->Target->GetPolicyStatusCMP0022() != cmPolicies::OLD && + this->Target->GetPolicyStatusCMP0022() != cmPolicies::WARN) { // CMP0022 NEW behavior is to use INTERFACE_LINK_LIBRARIES. linkIfaceProp = "INTERFACE_LINK_LIBRARIES"; - explicitLibraries = thisTarget->GetProperty(linkIfaceProp); + explicitLibraries = this->Target->GetProperty(linkIfaceProp); } - else if(thisTarget->GetType() == cmTarget::SHARED_LIBRARY || - thisTarget->IsExecutableWithExports()) + else if(this->Target->GetType() == cmTarget::SHARED_LIBRARY || + this->Target->IsExecutableWithExports()) { // CMP0022 OLD behavior is to use LINK_INTERFACE_LIBRARIES if set on a // shared lib or executable. @@ -3539,30 +3583,30 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( // Lookup the per-configuration property. linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; linkIfaceProp += suffix; - explicitLibraries = thisTarget->GetProperty(linkIfaceProp); + explicitLibraries = this->Target->GetProperty(linkIfaceProp); // If not set, try the generic property. if(!explicitLibraries) { linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; - explicitLibraries = thisTarget->GetProperty(linkIfaceProp); + explicitLibraries = this->Target->GetProperty(linkIfaceProp); } } if(explicitLibraries && - thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN && + this->Target->GetPolicyStatusCMP0022() == cmPolicies::WARN && !this->PolicyWarnedCMP0022) { // Compare the explicitly set old link interface properties to the // preferred new link interface property one and warn if different. const char* newExplicitLibraries = - thisTarget->GetProperty("INTERFACE_LINK_LIBRARIES"); + this->Target->GetProperty("INTERFACE_LINK_LIBRARIES"); if (newExplicitLibraries && strcmp(newExplicitLibraries, explicitLibraries) != 0) { std::ostringstream w; w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n" - "Target \"" << thisTarget->GetName() << "\" has an " + "Target \"" << this->Target->GetName() << "\" has an " "INTERFACE_LINK_LIBRARIES property which differs from its " << linkIfaceProp << " properties." "\n" @@ -3570,7 +3614,7 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( " " << newExplicitLibraries << "\n" << linkIfaceProp << ":\n" " " << (explicitLibraries ? explicitLibraries : "(empty)") << "\n"; - thisTarget->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + this->LocalGenerator->IssueMessage(cmake::AUTHOR_WARNING, w.str()); this->PolicyWarnedCMP0022 = true; } } @@ -3578,8 +3622,8 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( // There is no implicit link interface for executables or modules // so if none was explicitly set then there is no link interface. if(!explicitLibraries && - (thisTarget->GetType() == cmTarget::EXECUTABLE || - (thisTarget->GetType() == cmTarget::MODULE_LIBRARY))) + (this->Target->GetType() == cmTarget::EXECUTABLE || + (this->Target->GetType() == cmTarget::MODULE_LIBRARY))) { return; } @@ -3589,13 +3633,13 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( if(explicitLibraries) { // The interface libraries have been explicitly set. - thisTarget->ExpandLinkItems(linkIfaceProp, explicitLibraries, config, + this->ExpandLinkItems(linkIfaceProp, explicitLibraries, config, headTarget, usage_requirements_only, iface.Libraries, iface.HadHeadSensitiveCondition); } - else if (thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN - || thisTarget->GetPolicyStatusCMP0022() == cmPolicies::OLD) + else if (this->Target->GetPolicyStatusCMP0022() == cmPolicies::WARN + || this->Target->GetPolicyStatusCMP0022() == cmPolicies::OLD) // If CMP0022 is NEW then the plain tll signature sets the // INTERFACE_LINK_LIBRARIES, so if we get here then the project // cleared the property explicitly and we should not fall back @@ -3603,20 +3647,20 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( { // The link implementation is the default link interface. cmLinkImplementationLibraries const* impl = - thisTarget->GetLinkImplementationLibrariesInternal(config, headTarget); + this->Target->GetLinkImplementationLibrariesInternal(config, headTarget); iface.Libraries.insert(iface.Libraries.end(), impl->Libraries.begin(), impl->Libraries.end()); - if(thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN && + if(this->Target->GetPolicyStatusCMP0022() == cmPolicies::WARN && !this->PolicyWarnedCMP0022 && !usage_requirements_only) { // Compare the link implementation fallback link interface to the // preferred new link interface property and warn if different. std::vector ifaceLibs; static const std::string newProp = "INTERFACE_LINK_LIBRARIES"; - if(const char* newExplicitLibraries = thisTarget->GetProperty(newProp)) + if(const char* newExplicitLibraries = this->Target->GetProperty(newProp)) { bool hadHeadSensitiveConditionDummy = false; - thisTarget->ExpandLinkItems(newProp, newExplicitLibraries, config, + this->ExpandLinkItems(newProp, newExplicitLibraries, config, headTarget, usage_requirements_only, ifaceLibs, hadHeadSensitiveConditionDummy); } @@ -3631,7 +3675,7 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( std::ostringstream w; w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n" - "Target \"" << thisTarget->GetName() << "\" has an " + "Target \"" << this->Target->GetName() << "\" has an " "INTERFACE_LINK_LIBRARIES property. " "This should be preferred as the source of the link interface " "for this library but because CMP0022 is not set CMake is " @@ -3642,7 +3686,7 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( " " << newLibraries << "\n" "Link implementation:\n" " " << oldLibraries << "\n"; - thisTarget->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + this->LocalGenerator->IssueMessage(cmake::AUTHOR_WARNING, w.str()); this->PolicyWarnedCMP0022 = true; } } @@ -3650,16 +3694,15 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( } //---------------------------------------------------------------------------- -void cmGeneratorTarget::ComputeLinkInterface(cmTarget const* thisTarget, - const std::string& config, +void cmGeneratorTarget::ComputeLinkInterface(const std::string& config, OptionalLinkInterface& iface, cmTarget const* headTarget) const { if(iface.ExplicitLibraries) { - if(thisTarget->GetType() == cmTarget::SHARED_LIBRARY - || thisTarget->GetType() == cmTarget::STATIC_LIBRARY - || thisTarget->GetType() == cmTarget::INTERFACE_LIBRARY) + if(this->GetType() == cmTarget::SHARED_LIBRARY + || this->GetType() == cmTarget::STATIC_LIBRARY + || this->GetType() == cmTarget::INTERFACE_LIBRARY) { // Shared libraries may have runtime implementation dependencies // on other shared libraries that are not in the interface. @@ -3669,10 +3712,10 @@ void cmGeneratorTarget::ComputeLinkInterface(cmTarget const* thisTarget, { emitted.insert(*li); } - if (thisTarget->GetType() != cmTarget::INTERFACE_LIBRARY) + if (this->GetType() != cmTarget::INTERFACE_LIBRARY) { cmTarget::LinkImplementation const* impl = - thisTarget->GetLinkImplementation(config); + this->Target->GetLinkImplementation(config); for(std::vector::const_iterator li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li) { @@ -3698,28 +3741,28 @@ void cmGeneratorTarget::ComputeLinkInterface(cmTarget const* thisTarget, } } } - else if (thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN - || thisTarget->GetPolicyStatusCMP0022() == cmPolicies::OLD) + else if (this->Target->GetPolicyStatusCMP0022() == cmPolicies::WARN + || this->Target->GetPolicyStatusCMP0022() == cmPolicies::OLD) { // The link implementation is the default link interface. cmLinkImplementationLibraries const* - impl = thisTarget->GetLinkImplementationLibrariesInternal(config, + impl = this->Target->GetLinkImplementationLibrariesInternal(config, headTarget); iface.ImplementationIsInterface = true; iface.WrongConfigLibraries = impl->WrongConfigLibraries; } - if(thisTarget->LinkLanguagePropagatesToDependents()) + if(this->Target->LinkLanguagePropagatesToDependents()) { // Targets using this archive need its language runtime libraries. if(cmTarget::LinkImplementation const* impl = - thisTarget->GetLinkImplementation(config)) + this->Target->GetLinkImplementation(config)) { iface.Languages = impl->Languages; } } - if(thisTarget->GetType() == cmTarget::STATIC_LIBRARY) + if(this->GetType() == cmTarget::STATIC_LIBRARY) { // Construct the property name suffix for this configuration. std::string suffix = "_"; @@ -3736,12 +3779,12 @@ void cmGeneratorTarget::ComputeLinkInterface(cmTarget const* thisTarget, // dependencies? std::string propName = "LINK_INTERFACE_MULTIPLICITY"; propName += suffix; - if(const char* config_reps = thisTarget->GetProperty(propName)) + if(const char* config_reps = this->Target->GetProperty(propName)) { sscanf(config_reps, "%u", &iface.Multiplicity); } else if(const char* reps = - thisTarget->GetProperty("LINK_INTERFACE_MULTIPLICITY")) + this->Target->GetProperty("LINK_INTERFACE_MULTIPLICITY")) { sscanf(reps, "%u", &iface.Multiplicity); } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index e0d3425..46341d3 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -431,12 +431,10 @@ private: bool HadHeadSensitiveCondition; const char* ExplicitLibraries; }; - void ComputeLinkInterface(cmTarget const* thisTarget, - const std::string& config, + void ComputeLinkInterface(const std::string& config, OptionalLinkInterface& iface, cmTarget const* head) const; - void ComputeLinkInterfaceLibraries(cmTarget const* thisTarget, - const std::string& config, + void ComputeLinkInterfaceLibraries(const std::string& config, OptionalLinkInterface& iface, cmTarget const* head, bool usage_requirements_only) const; @@ -450,6 +448,14 @@ private: mutable bool PolicyWarnedCMP0022; + void ExpandLinkItems(std::string const& prop, std::string const& value, + std::string const& config, cmTarget const* headTarget, + bool usage_requirements_only, + std::vector& items, + bool& hadHeadSensitiveCondition) const; + void LookupLinkItems(std::vector const& names, + std::vector& items) const; + typedef std::pair OutputNameKey; typedef std::map OutputNameMapType; mutable OutputNameMapType OutputNameMap; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index aa60311..e941fb6 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3062,51 +3062,6 @@ bool cmTarget::GetPropertyAsBool(const std::string& prop) const } //---------------------------------------------------------------------------- -void cmTarget::ExpandLinkItems(std::string const& prop, - std::string const& value, - std::string const& config, - cmTarget const* headTarget, - bool usage_requirements_only, - std::vector& items, - bool& hadHeadSensitiveCondition) const -{ - cmGeneratorExpression ge; - cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), prop, 0, 0); - // The $ expression may be in a link interface to specify private - // link dependencies that are otherwise excluded from usage requirements. - if(usage_requirements_only) - { - dagChecker.SetTransitivePropertiesOnly(); - } - std::vector libs; - cmsys::auto_ptr cge = ge.Parse(value); - cmSystemTools::ExpandListArgument(cge->Evaluate( - this->Makefile, - config, - false, - headTarget, - this, &dagChecker), libs); - this->LookupLinkItems(libs, items); - hadHeadSensitiveCondition = cge->GetHadHeadSensitiveCondition(); -} - -//---------------------------------------------------------------------------- -void cmTarget::LookupLinkItems(std::vector const& names, - std::vector& items) const -{ - for(std::vector::const_iterator i = names.begin(); - i != names.end(); ++i) - { - std::string name = this->CheckCMP0004(*i); - if(name == this->GetName() || name.empty()) - { - continue; - } - items.push_back(cmLinkItem(name, this->FindTargetToLink(name))); - } -} - -//---------------------------------------------------------------------------- const char* cmTarget::GetSuffixVariableInternal(bool implib) const { switch(this->GetType()) diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 25de6a6..103a7e8 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -558,14 +558,6 @@ private: GetLinkImplementationLibrariesInternal(const std::string& config, cmTarget const* head) const; - void ExpandLinkItems(std::string const& prop, std::string const& value, - std::string const& config, cmTarget const* headTarget, - bool usage_requirements_only, - std::vector& items, - bool& hadHeadSensitiveCondition) const; - void LookupLinkItems(std::vector const& names, - std::vector& items) const; - std::string ProcessSourceItemCMP0049(const std::string& s); void ClearLinkMaps(); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7707a52f41947c1db1674563a6258f908c8efd6f commit 7707a52f41947c1db1674563a6258f908c8efd6f Author: Stephen Kelly AuthorDate: Tue Aug 4 19:22:30 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 22:37:06 2015 +0200 cmGeneratorTarget: Move GetLinkInterface from cmTarget. diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 59590fd..2e5331d 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -361,8 +361,10 @@ void cmComputeLinkDepends::FollowLinkEntry(BFSEntry const& qe) if(entry.Target) { // Follow the target dependencies. - if(cmTarget::LinkInterface const* iface = - entry.Target->GetLinkInterface(this->Config, this->Target->Target)) + cmGeneratorTarget* gtgt = + this->GlobalGenerator->GetGeneratorTarget(entry.Target); + if(cmGeneratorTarget::LinkInterface const* iface = + gtgt->GetLinkInterface(this->Config, this->Target->Target)) { const bool isIface = entry.Target->GetType() == cmTarget::INTERFACE_LIBRARY; @@ -396,7 +398,8 @@ void cmComputeLinkDepends::FollowLinkEntry(BFSEntry const& qe) //---------------------------------------------------------------------------- void cmComputeLinkDepends -::FollowSharedDeps(int depender_index, cmTarget::LinkInterface const* iface, +::FollowSharedDeps(int depender_index, + cmGeneratorTarget::LinkInterface const* iface, bool follow_interface) { // Follow dependencies if we have not followed them already. @@ -459,8 +462,10 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep) // Target items may have their own dependencies. if(entry.Target) { - if(cmTarget::LinkInterface const* iface = - entry.Target->GetLinkInterface(this->Config, this->Target->Target)) + cmGeneratorTarget* gtgt = + this->GlobalGenerator->GetGeneratorTarget(entry.Target); + if(cmGeneratorTarget::LinkInterface const* iface = + gtgt->GetLinkInterface(this->Config, this->Target->Target)) { // Follow public and private dependencies transitively. this->FollowSharedDeps(index, iface, true); @@ -930,8 +935,10 @@ int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl) { if(cmTarget const* target = this->EntryList[*ni].Target) { - if(cmTarget::LinkInterface const* iface = - target->GetLinkInterface(this->Config, this->Target->Target)) + cmGeneratorTarget* gtgt = + this->GlobalGenerator->GetGeneratorTarget(target); + if(cmGeneratorTarget::LinkInterface const* iface = + gtgt->GetLinkInterface(this->Config, this->Target->Target)) { if(iface->Multiplicity > count) { diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index b925a4f..e61175a 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -13,6 +13,7 @@ #define cmComputeLinkDepends_h #include "cmStandardIncludes.h" +#include "cmGeneratorTarget.h" #include "cmTarget.h" #include "cmGraphAdjacencyList.h" @@ -22,8 +23,6 @@ class cmComputeComponentGraph; class cmGlobalGenerator; class cmMakefile; -class cmGeneratorTarget; -class cmTarget; class cmake; /** \class cmComputeLinkDepends @@ -102,7 +101,7 @@ private: std::queue SharedDepQueue; std::set SharedDepFollowed; void FollowSharedDeps(int depender_index, - cmTarget::LinkInterface const* iface, + cmGeneratorTarget::LinkInterface const* iface, bool follow_interface = false); void QueueSharedDependencies(int depender_index, std::vector const& deps); diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index c4a03a0..fd4b567 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -296,8 +296,8 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, std::set &emitted) { cmGeneratorTarget const* depender = this->Targets[depender_index]; - if(cmTarget::LinkInterface const* iface = - dependee->Target->GetLinkInterface(config, + if(cmGeneratorTarget::LinkInterface const* iface = + dependee->GetLinkInterface(config, depender->Target)) { for(std::vector::const_iterator diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index cae60b7..97eb6b9 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -796,7 +796,7 @@ cmExportFileGenerator std::vector& missingTargets) { // Add the transitive link dependencies for this configuration. - cmTarget::LinkInterface const* iface = target->Target->GetLinkInterface( + cmGeneratorTarget::LinkInterface const* iface = target->GetLinkInterface( config, target->Target); if (!iface) @@ -909,9 +909,8 @@ cmExportFileGenerator } // Add the transitive link dependencies for this configuration. - if(cmTarget::LinkInterface const* iface = - target->Target - ->GetLinkInterface(config, target->Target)) + if(cmGeneratorTarget::LinkInterface const* iface = + target->GetLinkInterface(config, target->Target)) { this->SetImportLinkProperty(suffix, target, "IMPORTED_LINK_INTERFACE_LANGUAGES", diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 03bc83a..b957379 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1108,8 +1108,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode if(isInterfaceProperty) { - if(cmTarget::LinkInterfaceLibraries const* iface = - target->GetLinkInterfaceLibraries(context->Config, headTarget, true)) + if(cmGeneratorTarget::LinkInterfaceLibraries const* iface = + gtgt->GetLinkInterfaceLibraries(context->Config, headTarget, true)) { linkedTargetsContent = getLinkedTargetsContent(iface->Libraries, target, diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index dd58e7b..cf4019c 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1173,8 +1173,11 @@ public: return; } - cmTarget::LinkInterface const* iface = - item.Target->GetLinkInterface(this->Config, this->HeadTarget); + cmGeneratorTarget* gtgt = + this->Target->GetLocalGenerator()->GetGlobalGenerator() + ->GetGeneratorTarget(item.Target); + cmGeneratorTarget::LinkInterface const* iface = + gtgt->GetLinkInterface(this->Config, this->HeadTarget); if(!iface) { return; } for(std::vector::const_iterator @@ -1505,20 +1508,22 @@ void cmGeneratorTarget::GetAutoUicOptions(std::vector &result, void processILibs(const std::string& config, cmTarget const* headTarget, cmLinkItem const& item, + cmGlobalGenerator* gg, std::vector& tgts, std::set& emitted) { if (item.Target && emitted.insert(item.Target).second) { tgts.push_back(item.Target); - if(cmTarget::LinkInterfaceLibraries const* iface = - item.Target->GetLinkInterfaceLibraries(config, headTarget, true)) + cmGeneratorTarget* gt = gg->GetGeneratorTarget(item.Target); + if(cmGeneratorTarget::LinkInterfaceLibraries const* iface = + gt->GetLinkInterfaceLibraries(config, headTarget, true)) { for(std::vector::const_iterator it = iface->Libraries.begin(); it != iface->Libraries.end(); ++it) { - processILibs(config, headTarget, *it, tgts, emitted); + processILibs(config, headTarget, *it, gg, tgts, emitted); } } } @@ -1543,7 +1548,9 @@ cmGeneratorTarget::GetLinkImplementationClosure( it = impl->Libraries.begin(); it != impl->Libraries.end(); ++it) { - processILibs(config, this->Target, *it, tgts , emitted); + processILibs(config, this->Target, *it, + this->LocalGenerator->GetGlobalGenerator(), + tgts, emitted); } } return tgts; @@ -3354,3 +3361,389 @@ cmGeneratorTarget::ReportPropertyOrigin(const std::string &p, this->Makefile->GetCMakeInstance()->IssueMessage(cmake::LOG, areport); } + +//---------------------------------------------------------------------------- +cmGeneratorTarget::LinkInterface const* cmGeneratorTarget::GetLinkInterface( + const std::string& config, + cmTarget const* head) const +{ + // Imported targets have their own link interface. + if(this->Target->IsImported()) + { + return this->GetImportLinkInterface(config, head, false); + } + + // Link interfaces are not supported for executables that do not + // export symbols. + if(this->GetType() == cmTarget::EXECUTABLE && + !this->Target->IsExecutableWithExports()) + { + return 0; + } + + // Lookup any existing link interface for this configuration. + std::string CONFIG = cmSystemTools::UpperCase(config); + HeadToLinkInterfaceMap& hm = this->LinkInterfaceMap[CONFIG]; + + // If the link interface does not depend on the head target + // then return the one we computed first. + if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) + { + return &hm.begin()->second; + } + + OptionalLinkInterface& iface = hm[head]; + if(!iface.LibrariesDone) + { + iface.LibrariesDone = true; + this->ComputeLinkInterfaceLibraries( + this->Target, config, iface, head, false); + } + if(!iface.AllDone) + { + iface.AllDone = true; + if(iface.Exists) + { + this->ComputeLinkInterface(this->Target, config, iface, head); + } + } + + return iface.Exists? &iface : 0; +} + +//---------------------------------------------------------------------------- +cmGeneratorTarget::LinkInterfaceLibraries const* +cmGeneratorTarget::GetLinkInterfaceLibraries(const std::string& config, + cmTarget const* head, + bool usage_requirements_only) const +{ + // Imported targets have their own link interface. + if(this->Target->IsImported()) + { + return this->GetImportLinkInterface(config, head, usage_requirements_only); + } + + // Link interfaces are not supported for executables that do not + // export symbols. + if(this->GetType() == cmTarget::EXECUTABLE && + !this->Target->IsExecutableWithExports()) + { + return 0; + } + + // Lookup any existing link interface for this configuration. + std::string CONFIG = cmSystemTools::UpperCase(config); + HeadToLinkInterfaceMap& hm = + (usage_requirements_only ? + this->LinkInterfaceUsageRequirementsOnlyMap[CONFIG] : + this->LinkInterfaceMap[CONFIG]); + + // If the link interface does not depend on the head target + // then return the one we computed first. + if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) + { + return &hm.begin()->second; + } + + OptionalLinkInterface& iface = hm[head]; + if(!iface.LibrariesDone) + { + iface.LibrariesDone = true; + this->ComputeLinkInterfaceLibraries( + this->Target, config, iface, head, usage_requirements_only); + } + + return iface.Exists? &iface : 0; +} + +//---------------------------------------------------------------------------- +cmGeneratorTarget::LinkInterface const* +cmGeneratorTarget::GetImportLinkInterface(const std::string& config, + cmTarget const* headTarget, + bool usage_requirements_only) const +{ + cmTarget::ImportInfo const* info = this->Target->GetImportInfo(config); + if(!info) + { + return 0; + } + + std::string CONFIG = cmSystemTools::UpperCase(config); + HeadToLinkInterfaceMap& hm = + (usage_requirements_only ? + this->LinkInterfaceUsageRequirementsOnlyMap[CONFIG] : + this->LinkInterfaceMap[CONFIG]); + + // If the link interface does not depend on the head target + // then return the one we computed first. + if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) + { + return &hm.begin()->second; + } + + OptionalLinkInterface& iface = hm[headTarget]; + if(!iface.AllDone) + { + iface.AllDone = true; + iface.Multiplicity = info->Multiplicity; + cmSystemTools::ExpandListArgument(info->Languages, iface.Languages); + this->Target->ExpandLinkItems(info->LibrariesProp, info->Libraries, config, + headTarget, usage_requirements_only, + iface.Libraries, + iface.HadHeadSensitiveCondition); + std::vector deps; + cmSystemTools::ExpandListArgument(info->SharedDeps, deps); + this->Target->LookupLinkItems(deps, iface.SharedDeps); + } + + return &iface; +} + +//---------------------------------------------------------------------------- +void +cmGeneratorTarget::ComputeLinkInterfaceLibraries( + cmTarget const* thisTarget, + const std::string& config, + OptionalLinkInterface& iface, + cmTarget const* headTarget, + bool usage_requirements_only) const +{ + // Construct the property name suffix for this configuration. + std::string suffix = "_"; + if(!config.empty()) + { + suffix += cmSystemTools::UpperCase(config); + } + else + { + suffix += "NOCONFIG"; + } + + // An explicit list of interface libraries may be set for shared + // libraries and executables that export symbols. + const char* explicitLibraries = 0; + std::string linkIfaceProp; + if(thisTarget->GetPolicyStatusCMP0022() != cmPolicies::OLD && + thisTarget->GetPolicyStatusCMP0022() != cmPolicies::WARN) + { + // CMP0022 NEW behavior is to use INTERFACE_LINK_LIBRARIES. + linkIfaceProp = "INTERFACE_LINK_LIBRARIES"; + explicitLibraries = thisTarget->GetProperty(linkIfaceProp); + } + else if(thisTarget->GetType() == cmTarget::SHARED_LIBRARY || + thisTarget->IsExecutableWithExports()) + { + // CMP0022 OLD behavior is to use LINK_INTERFACE_LIBRARIES if set on a + // shared lib or executable. + + // Lookup the per-configuration property. + linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; + linkIfaceProp += suffix; + explicitLibraries = thisTarget->GetProperty(linkIfaceProp); + + // If not set, try the generic property. + if(!explicitLibraries) + { + linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; + explicitLibraries = thisTarget->GetProperty(linkIfaceProp); + } + } + + if(explicitLibraries && + thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN && + !this->PolicyWarnedCMP0022) + { + // Compare the explicitly set old link interface properties to the + // preferred new link interface property one and warn if different. + const char* newExplicitLibraries = + thisTarget->GetProperty("INTERFACE_LINK_LIBRARIES"); + if (newExplicitLibraries + && strcmp(newExplicitLibraries, explicitLibraries) != 0) + { + std::ostringstream w; + w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n" + "Target \"" << thisTarget->GetName() << "\" has an " + "INTERFACE_LINK_LIBRARIES property which differs from its " << + linkIfaceProp << " properties." + "\n" + "INTERFACE_LINK_LIBRARIES:\n" + " " << newExplicitLibraries << "\n" << + linkIfaceProp << ":\n" + " " << (explicitLibraries ? explicitLibraries : "(empty)") << "\n"; + thisTarget->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + this->PolicyWarnedCMP0022 = true; + } + } + + // There is no implicit link interface for executables or modules + // so if none was explicitly set then there is no link interface. + if(!explicitLibraries && + (thisTarget->GetType() == cmTarget::EXECUTABLE || + (thisTarget->GetType() == cmTarget::MODULE_LIBRARY))) + { + return; + } + iface.Exists = true; + iface.ExplicitLibraries = explicitLibraries; + + if(explicitLibraries) + { + // The interface libraries have been explicitly set. + thisTarget->ExpandLinkItems(linkIfaceProp, explicitLibraries, config, + headTarget, usage_requirements_only, + iface.Libraries, + iface.HadHeadSensitiveCondition); + } + else if (thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN + || thisTarget->GetPolicyStatusCMP0022() == cmPolicies::OLD) + // If CMP0022 is NEW then the plain tll signature sets the + // INTERFACE_LINK_LIBRARIES, so if we get here then the project + // cleared the property explicitly and we should not fall back + // to the link implementation. + { + // The link implementation is the default link interface. + cmLinkImplementationLibraries const* impl = + thisTarget->GetLinkImplementationLibrariesInternal(config, headTarget); + iface.Libraries.insert(iface.Libraries.end(), + impl->Libraries.begin(), impl->Libraries.end()); + if(thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN && + !this->PolicyWarnedCMP0022 && !usage_requirements_only) + { + // Compare the link implementation fallback link interface to the + // preferred new link interface property and warn if different. + std::vector ifaceLibs; + static const std::string newProp = "INTERFACE_LINK_LIBRARIES"; + if(const char* newExplicitLibraries = thisTarget->GetProperty(newProp)) + { + bool hadHeadSensitiveConditionDummy = false; + thisTarget->ExpandLinkItems(newProp, newExplicitLibraries, config, + headTarget, usage_requirements_only, + ifaceLibs, hadHeadSensitiveConditionDummy); + } + if (ifaceLibs != iface.Libraries) + { + std::string oldLibraries = cmJoin(impl->Libraries, ";"); + std::string newLibraries = cmJoin(ifaceLibs, ";"); + if(oldLibraries.empty()) + { oldLibraries = "(empty)"; } + if(newLibraries.empty()) + { newLibraries = "(empty)"; } + + std::ostringstream w; + w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n" + "Target \"" << thisTarget->GetName() << "\" has an " + "INTERFACE_LINK_LIBRARIES property. " + "This should be preferred as the source of the link interface " + "for this library but because CMP0022 is not set CMake is " + "ignoring the property and using the link implementation " + "as the link interface instead." + "\n" + "INTERFACE_LINK_LIBRARIES:\n" + " " << newLibraries << "\n" + "Link implementation:\n" + " " << oldLibraries << "\n"; + thisTarget->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + this->PolicyWarnedCMP0022 = true; + } + } + } +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::ComputeLinkInterface(cmTarget const* thisTarget, + const std::string& config, + OptionalLinkInterface& iface, + cmTarget const* headTarget) const +{ + if(iface.ExplicitLibraries) + { + if(thisTarget->GetType() == cmTarget::SHARED_LIBRARY + || thisTarget->GetType() == cmTarget::STATIC_LIBRARY + || thisTarget->GetType() == cmTarget::INTERFACE_LIBRARY) + { + // Shared libraries may have runtime implementation dependencies + // on other shared libraries that are not in the interface. + UNORDERED_SET emitted; + for(std::vector::const_iterator + li = iface.Libraries.begin(); li != iface.Libraries.end(); ++li) + { + emitted.insert(*li); + } + if (thisTarget->GetType() != cmTarget::INTERFACE_LIBRARY) + { + cmTarget::LinkImplementation const* impl = + thisTarget->GetLinkImplementation(config); + for(std::vector::const_iterator + li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li) + { + if(emitted.insert(*li).second) + { + if(li->Target) + { + // This is a runtime dependency on another shared library. + if(li->Target->GetType() == cmTarget::SHARED_LIBRARY) + { + iface.SharedDeps.push_back(*li); + } + } + else + { + // TODO: Recognize shared library file names. Perhaps this + // should be moved to cmComputeLinkInformation, but that creates + // a chicken-and-egg problem since this list is needed for its + // construction. + } + } + } + } + } + } + else if (thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN + || thisTarget->GetPolicyStatusCMP0022() == cmPolicies::OLD) + { + // The link implementation is the default link interface. + cmLinkImplementationLibraries const* + impl = thisTarget->GetLinkImplementationLibrariesInternal(config, + headTarget); + iface.ImplementationIsInterface = true; + iface.WrongConfigLibraries = impl->WrongConfigLibraries; + } + + if(thisTarget->LinkLanguagePropagatesToDependents()) + { + // Targets using this archive need its language runtime libraries. + if(cmTarget::LinkImplementation const* impl = + thisTarget->GetLinkImplementation(config)) + { + iface.Languages = impl->Languages; + } + } + + if(thisTarget->GetType() == cmTarget::STATIC_LIBRARY) + { + // Construct the property name suffix for this configuration. + std::string suffix = "_"; + if(!config.empty()) + { + suffix += cmSystemTools::UpperCase(config); + } + else + { + suffix += "NOCONFIG"; + } + + // How many repetitions are needed if this library has cyclic + // dependencies? + std::string propName = "LINK_INTERFACE_MULTIPLICITY"; + propName += suffix; + if(const char* config_reps = thisTarget->GetProperty(propName)) + { + sscanf(config_reps, "%u", &iface.Multiplicity); + } + else if(const char* reps = + thisTarget->GetProperty("LINK_INTERFACE_MULTIPLICITY")) + { + sscanf(reps, "%u", &iface.Multiplicity); + } + } +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 15b3335..e0d3425 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -13,6 +13,7 @@ #define cmGeneratorTarget_h #include "cmStandardIncludes.h" +#include "cmLinkItem.h" class cmCustomCommand; class cmGlobalGenerator; @@ -106,6 +107,48 @@ public: const char *GetLinkInterfaceDependentNumberMaxProperty(const std::string &p, const std::string& config) const; + /** The link interface specifies transitive library dependencies and + other information needed by targets that link to this target. */ + struct LinkInterfaceLibraries + { + // Libraries listed in the interface. + std::vector Libraries; + }; + + struct LinkInterface: public LinkInterfaceLibraries + { + // Languages whose runtime libraries must be linked. + std::vector Languages; + + // Shared library dependencies needed for linking on some platforms. + std::vector SharedDeps; + + // Number of repetitions of a strongly connected component of two + // or more static libraries. + int Multiplicity; + + // Libraries listed for other configurations. + // Needed only for OLD behavior of CMP0003. + std::vector WrongConfigLibraries; + + bool ImplementationIsInterface; + + LinkInterface(): Multiplicity(0), ImplementationIsInterface(false) {} + }; + + /** Get the link interface for the given configuration. Returns 0 + if the target cannot be linked. */ + LinkInterface const* GetLinkInterface(const std::string& config, + cmTarget const* headTarget) const; + + LinkInterface const* + GetImportLinkInterface(const std::string& config, cmTarget const* head, + bool usage_requirements_only) const; + + LinkInterfaceLibraries const* + GetLinkInterfaceLibraries(const std::string& config, + cmTarget const* headTarget, + bool usage_requirements_only) const; /** Get the full path to the target according to the settings in its makefile and the configuration type. */ @@ -375,6 +418,38 @@ private: }; mutable std::map LinkImplClosureMap; + // Cache link interface computation from each configuration. + struct OptionalLinkInterface: public LinkInterface + { + OptionalLinkInterface(): + LibrariesDone(false), AllDone(false), + Exists(false), HadHeadSensitiveCondition(false), + ExplicitLibraries(0) {} + bool LibrariesDone; + bool AllDone; + bool Exists; + bool HadHeadSensitiveCondition; + const char* ExplicitLibraries; + }; + void ComputeLinkInterface(cmTarget const* thisTarget, + const std::string& config, + OptionalLinkInterface& iface, + cmTarget const* head) const; + void ComputeLinkInterfaceLibraries(cmTarget const* thisTarget, + const std::string& config, + OptionalLinkInterface& iface, + cmTarget const* head, + bool usage_requirements_only) const; + + struct HeadToLinkInterfaceMap: + public std::map {}; + typedef std::map + LinkInterfaceMapType; + mutable LinkInterfaceMapType LinkInterfaceMap; + mutable LinkInterfaceMapType LinkInterfaceUsageRequirementsOnlyMap; + + mutable bool PolicyWarnedCMP0022; + typedef std::pair OutputNameKey; typedef std::map OutputNameMapType; mutable OutputNameMapType OutputNameMap; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 49b3239..aa60311 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -77,13 +77,11 @@ public: cmTargetInternals() : Backtrace() { - this->PolicyWarnedCMP0022 = false; this->UtilityItemsDone = false; } cmTargetInternals(cmTargetInternals const&) : Backtrace() { - this->PolicyWarnedCMP0022 = false; this->UtilityItemsDone = false; } ~cmTargetInternals(); @@ -91,36 +89,6 @@ public: // The backtrace when the target was created. cmListFileBacktrace Backtrace; - // Cache link interface computation from each configuration. - struct OptionalLinkInterface: public cmTarget::LinkInterface - { - OptionalLinkInterface(): - LibrariesDone(false), AllDone(false), - Exists(false), HadHeadSensitiveCondition(false), - ExplicitLibraries(0) {} - bool LibrariesDone; - bool AllDone; - bool Exists; - bool HadHeadSensitiveCondition; - const char* ExplicitLibraries; - }; - void ComputeLinkInterface(cmTarget const* thisTarget, - const std::string& config, - OptionalLinkInterface& iface, - cmTarget const* head) const; - void ComputeLinkInterfaceLibraries(cmTarget const* thisTarget, - const std::string& config, - OptionalLinkInterface& iface, - cmTarget const* head, - bool usage_requirements_only); - - struct HeadToLinkInterfaceMap: - public std::map {}; - typedef std::map - LinkInterfaceMapType; - LinkInterfaceMapType LinkInterfaceMap; - LinkInterfaceMapType LinkInterfaceUsageRequirementsOnlyMap; - bool PolicyWarnedCMP0022; typedef std::map OutputInfoMapType; OutputInfoMapType OutputInfoMap; @@ -538,8 +506,6 @@ void cmTarget::ClearLinkMaps() { this->LinkImplementationLanguageIsContextDependent = true; this->Internal->LinkImplMap.clear(); - this->Internal->LinkInterfaceMap.clear(); - this->Internal->LinkInterfaceUsageRequirementsOnlyMap.clear(); this->Internal->SourceFilesMap.clear(); } @@ -4133,393 +4099,6 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, } //---------------------------------------------------------------------------- -cmTarget::LinkInterface const* cmTarget::GetLinkInterface( - const std::string& config, - cmTarget const* head) const -{ - // Imported targets have their own link interface. - if(this->IsImported()) - { - return this->GetImportLinkInterface(config, head, false); - } - - // Link interfaces are not supported for executables that do not - // export symbols. - if(this->GetType() == cmTarget::EXECUTABLE && - !this->IsExecutableWithExports()) - { - return 0; - } - - // Lookup any existing link interface for this configuration. - std::string CONFIG = cmSystemTools::UpperCase(config); - cmTargetInternals::HeadToLinkInterfaceMap& hm = - this->Internal->LinkInterfaceMap[CONFIG]; - - // If the link interface does not depend on the head target - // then return the one we computed first. - if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) - { - return &hm.begin()->second; - } - - cmTargetInternals::OptionalLinkInterface& iface = hm[head]; - if(!iface.LibrariesDone) - { - iface.LibrariesDone = true; - this->Internal->ComputeLinkInterfaceLibraries( - this, config, iface, head, false); - } - if(!iface.AllDone) - { - iface.AllDone = true; - if(iface.Exists) - { - this->Internal->ComputeLinkInterface(this, config, iface, head); - } - } - - return iface.Exists? &iface : 0; -} - -//---------------------------------------------------------------------------- -cmTarget::LinkInterfaceLibraries const* -cmTarget::GetLinkInterfaceLibraries(const std::string& config, - cmTarget const* head, - bool usage_requirements_only) const -{ - // Imported targets have their own link interface. - if(this->IsImported()) - { - return this->GetImportLinkInterface(config, head, usage_requirements_only); - } - - // Link interfaces are not supported for executables that do not - // export symbols. - if(this->GetType() == cmTarget::EXECUTABLE && - !this->IsExecutableWithExports()) - { - return 0; - } - - // Lookup any existing link interface for this configuration. - std::string CONFIG = cmSystemTools::UpperCase(config); - cmTargetInternals::HeadToLinkInterfaceMap& hm = - (usage_requirements_only ? - this->Internal->LinkInterfaceUsageRequirementsOnlyMap[CONFIG] : - this->Internal->LinkInterfaceMap[CONFIG]); - - // If the link interface does not depend on the head target - // then return the one we computed first. - if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) - { - return &hm.begin()->second; - } - - cmTargetInternals::OptionalLinkInterface& iface = hm[head]; - if(!iface.LibrariesDone) - { - iface.LibrariesDone = true; - this->Internal->ComputeLinkInterfaceLibraries( - this, config, iface, head, usage_requirements_only); - } - - return iface.Exists? &iface : 0; -} - -//---------------------------------------------------------------------------- -cmTarget::LinkInterface const* -cmTarget::GetImportLinkInterface(const std::string& config, - cmTarget const* headTarget, - bool usage_requirements_only) const -{ - cmTarget::ImportInfo const* info = this->GetImportInfo(config); - if(!info) - { - return 0; - } - - std::string CONFIG = cmSystemTools::UpperCase(config); - cmTargetInternals::HeadToLinkInterfaceMap& hm = - (usage_requirements_only ? - this->Internal->LinkInterfaceUsageRequirementsOnlyMap[CONFIG] : - this->Internal->LinkInterfaceMap[CONFIG]); - - // If the link interface does not depend on the head target - // then return the one we computed first. - if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) - { - return &hm.begin()->second; - } - - cmTargetInternals::OptionalLinkInterface& iface = hm[headTarget]; - if(!iface.AllDone) - { - iface.AllDone = true; - iface.Multiplicity = info->Multiplicity; - cmSystemTools::ExpandListArgument(info->Languages, iface.Languages); - this->ExpandLinkItems(info->LibrariesProp, info->Libraries, config, - headTarget, usage_requirements_only, - iface.Libraries, - iface.HadHeadSensitiveCondition); - std::vector deps; - cmSystemTools::ExpandListArgument(info->SharedDeps, deps); - this->LookupLinkItems(deps, iface.SharedDeps); - } - - return &iface; -} - -//---------------------------------------------------------------------------- -void -cmTargetInternals::ComputeLinkInterfaceLibraries( - cmTarget const* thisTarget, - const std::string& config, - OptionalLinkInterface& iface, - cmTarget const* headTarget, - bool usage_requirements_only) -{ - // Construct the property name suffix for this configuration. - std::string suffix = "_"; - if(!config.empty()) - { - suffix += cmSystemTools::UpperCase(config); - } - else - { - suffix += "NOCONFIG"; - } - - // An explicit list of interface libraries may be set for shared - // libraries and executables that export symbols. - const char* explicitLibraries = 0; - std::string linkIfaceProp; - if(thisTarget->GetPolicyStatusCMP0022() != cmPolicies::OLD && - thisTarget->GetPolicyStatusCMP0022() != cmPolicies::WARN) - { - // CMP0022 NEW behavior is to use INTERFACE_LINK_LIBRARIES. - linkIfaceProp = "INTERFACE_LINK_LIBRARIES"; - explicitLibraries = thisTarget->GetProperty(linkIfaceProp); - } - else if(thisTarget->GetType() == cmTarget::SHARED_LIBRARY || - thisTarget->IsExecutableWithExports()) - { - // CMP0022 OLD behavior is to use LINK_INTERFACE_LIBRARIES if set on a - // shared lib or executable. - - // Lookup the per-configuration property. - linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; - linkIfaceProp += suffix; - explicitLibraries = thisTarget->GetProperty(linkIfaceProp); - - // If not set, try the generic property. - if(!explicitLibraries) - { - linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; - explicitLibraries = thisTarget->GetProperty(linkIfaceProp); - } - } - - if(explicitLibraries && - thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN && - !this->PolicyWarnedCMP0022) - { - // Compare the explicitly set old link interface properties to the - // preferred new link interface property one and warn if different. - const char* newExplicitLibraries = - thisTarget->GetProperty("INTERFACE_LINK_LIBRARIES"); - if (newExplicitLibraries - && strcmp(newExplicitLibraries, explicitLibraries) != 0) - { - std::ostringstream w; - w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n" - "Target \"" << thisTarget->GetName() << "\" has an " - "INTERFACE_LINK_LIBRARIES property which differs from its " << - linkIfaceProp << " properties." - "\n" - "INTERFACE_LINK_LIBRARIES:\n" - " " << newExplicitLibraries << "\n" << - linkIfaceProp << ":\n" - " " << (explicitLibraries ? explicitLibraries : "(empty)") << "\n"; - thisTarget->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); - this->PolicyWarnedCMP0022 = true; - } - } - - // There is no implicit link interface for executables or modules - // so if none was explicitly set then there is no link interface. - if(!explicitLibraries && - (thisTarget->GetType() == cmTarget::EXECUTABLE || - (thisTarget->GetType() == cmTarget::MODULE_LIBRARY))) - { - return; - } - iface.Exists = true; - iface.ExplicitLibraries = explicitLibraries; - - if(explicitLibraries) - { - // The interface libraries have been explicitly set. - thisTarget->ExpandLinkItems(linkIfaceProp, explicitLibraries, config, - headTarget, usage_requirements_only, - iface.Libraries, - iface.HadHeadSensitiveCondition); - } - else if (thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN - || thisTarget->GetPolicyStatusCMP0022() == cmPolicies::OLD) - // If CMP0022 is NEW then the plain tll signature sets the - // INTERFACE_LINK_LIBRARIES, so if we get here then the project - // cleared the property explicitly and we should not fall back - // to the link implementation. - { - // The link implementation is the default link interface. - cmLinkImplementationLibraries const* impl = - thisTarget->GetLinkImplementationLibrariesInternal(config, headTarget); - iface.Libraries.insert(iface.Libraries.end(), - impl->Libraries.begin(), impl->Libraries.end()); - if(thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN && - !this->PolicyWarnedCMP0022 && !usage_requirements_only) - { - // Compare the link implementation fallback link interface to the - // preferred new link interface property and warn if different. - std::vector ifaceLibs; - static const std::string newProp = "INTERFACE_LINK_LIBRARIES"; - if(const char* newExplicitLibraries = thisTarget->GetProperty(newProp)) - { - bool hadHeadSensitiveConditionDummy = false; - thisTarget->ExpandLinkItems(newProp, newExplicitLibraries, config, - headTarget, usage_requirements_only, - ifaceLibs, hadHeadSensitiveConditionDummy); - } - if (ifaceLibs != iface.Libraries) - { - std::string oldLibraries = cmJoin(impl->Libraries, ";"); - std::string newLibraries = cmJoin(ifaceLibs, ";"); - if(oldLibraries.empty()) - { oldLibraries = "(empty)"; } - if(newLibraries.empty()) - { newLibraries = "(empty)"; } - - std::ostringstream w; - w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n" - "Target \"" << thisTarget->GetName() << "\" has an " - "INTERFACE_LINK_LIBRARIES property. " - "This should be preferred as the source of the link interface " - "for this library but because CMP0022 is not set CMake is " - "ignoring the property and using the link implementation " - "as the link interface instead." - "\n" - "INTERFACE_LINK_LIBRARIES:\n" - " " << newLibraries << "\n" - "Link implementation:\n" - " " << oldLibraries << "\n"; - thisTarget->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); - this->PolicyWarnedCMP0022 = true; - } - } - } -} - -//---------------------------------------------------------------------------- -void cmTargetInternals::ComputeLinkInterface(cmTarget const* thisTarget, - const std::string& config, - OptionalLinkInterface& iface, - cmTarget const* headTarget) const -{ - if(iface.ExplicitLibraries) - { - if(thisTarget->GetType() == cmTarget::SHARED_LIBRARY - || thisTarget->GetType() == cmTarget::STATIC_LIBRARY - || thisTarget->GetType() == cmTarget::INTERFACE_LIBRARY) - { - // Shared libraries may have runtime implementation dependencies - // on other shared libraries that are not in the interface. - UNORDERED_SET emitted; - for(std::vector::const_iterator - li = iface.Libraries.begin(); li != iface.Libraries.end(); ++li) - { - emitted.insert(*li); - } - if (thisTarget->GetType() != cmTarget::INTERFACE_LIBRARY) - { - cmTarget::LinkImplementation const* impl = - thisTarget->GetLinkImplementation(config); - for(std::vector::const_iterator - li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li) - { - if(emitted.insert(*li).second) - { - if(li->Target) - { - // This is a runtime dependency on another shared library. - if(li->Target->GetType() == cmTarget::SHARED_LIBRARY) - { - iface.SharedDeps.push_back(*li); - } - } - else - { - // TODO: Recognize shared library file names. Perhaps this - // should be moved to cmComputeLinkInformation, but that creates - // a chicken-and-egg problem since this list is needed for its - // construction. - } - } - } - } - } - } - else if (thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN - || thisTarget->GetPolicyStatusCMP0022() == cmPolicies::OLD) - { - // The link implementation is the default link interface. - cmLinkImplementationLibraries const* - impl = thisTarget->GetLinkImplementationLibrariesInternal(config, - headTarget); - iface.ImplementationIsInterface = true; - iface.WrongConfigLibraries = impl->WrongConfigLibraries; - } - - if(thisTarget->LinkLanguagePropagatesToDependents()) - { - // Targets using this archive need its language runtime libraries. - if(cmTarget::LinkImplementation const* impl = - thisTarget->GetLinkImplementation(config)) - { - iface.Languages = impl->Languages; - } - } - - if(thisTarget->GetType() == cmTarget::STATIC_LIBRARY) - { - // Construct the property name suffix for this configuration. - std::string suffix = "_"; - if(!config.empty()) - { - suffix += cmSystemTools::UpperCase(config); - } - else - { - suffix += "NOCONFIG"; - } - - // How many repetitions are needed if this library has cyclic - // dependencies? - std::string propName = "LINK_INTERFACE_MULTIPLICITY"; - propName += suffix; - if(const char* config_reps = thisTarget->GetProperty(propName)) - { - sscanf(config_reps, "%u", &iface.Multiplicity); - } - else if(const char* reps = - thisTarget->GetProperty("LINK_INTERFACE_MULTIPLICITY")) - { - sscanf(reps, "%u", &iface.Multiplicity); - } - } -} - -//---------------------------------------------------------------------------- void cmTargetInternals::AddInterfaceEntries( cmTarget const* thisTarget, std::string const& config, std::string const& prop, std::vector& entries) diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 2007b40..25de6a6 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -233,43 +233,6 @@ public: void GetObjectLibrariesCMP0026(std::vector& objlibs) const; - /** The link interface specifies transitive library dependencies and - other information needed by targets that link to this target. */ - struct LinkInterfaceLibraries - { - // Libraries listed in the interface. - std::vector Libraries; - }; - struct LinkInterface: public LinkInterfaceLibraries - { - // Languages whose runtime libraries must be linked. - std::vector Languages; - - // Shared library dependencies needed for linking on some platforms. - std::vector SharedDeps; - - // Number of repetitions of a strongly connected component of two - // or more static libraries. - int Multiplicity; - - // Libraries listed for other configurations. - // Needed only for OLD behavior of CMP0003. - std::vector WrongConfigLibraries; - - bool ImplementationIsInterface; - - LinkInterface(): Multiplicity(0), ImplementationIsInterface(false) {} - }; - - /** Get the link interface for the given configuration. Returns 0 - if the target cannot be linked. */ - LinkInterface const* GetLinkInterface(const std::string& config, - cmTarget const* headTarget) const; - LinkInterfaceLibraries const* - GetLinkInterfaceLibraries(const std::string& config, - cmTarget const* headTarget, - bool usage_requirements_only) const; - struct LinkImplementation: public cmLinkImplementationLibraries { // Languages whose runtime libraries must be linked. @@ -591,11 +554,6 @@ private: void ComputeImportInfo(std::string const& desired_config, ImportInfo& info) const; - - LinkInterface const* - GetImportLinkInterface(const std::string& config, cmTarget const* head, - bool usage_requirements_only) const; - cmLinkImplementationLibraries const* GetLinkImplementationLibrariesInternal(const std::string& config, cmTarget const* head) const; ----------------------------------------------------------------------- Summary of changes: Source/cmComputeLinkDepends.cxx | 25 +- Source/cmComputeLinkDepends.h | 5 +- Source/cmComputeLinkInformation.cxx | 2 +- Source/cmComputeTargetDepends.cxx | 7 +- Source/cmExportFileGenerator.cxx | 7 +- Source/cmExtraCodeBlocksGenerator.cxx | 2 +- Source/cmGeneratorExpressionNode.cxx | 4 +- Source/cmGeneratorTarget.cxx | 1200 +++++++++++++++++++++++- Source/cmGeneratorTarget.h | 122 +++ Source/cmGlobalGenerator.cxx | 1 - Source/cmGlobalUnixMakefileGenerator3.cxx | 3 +- Source/cmGlobalXCodeGenerator.cxx | 21 +- Source/cmLinkItem.h | 17 + Source/cmLocalGenerator.cxx | 13 +- Source/cmLocalUnixMakefileGenerator3.cxx | 4 +- Source/cmMakefileTargetGenerator.cxx | 2 +- Source/cmQtAutoGenerators.cxx | 16 +- Source/cmTarget.cxx | 1432 +++-------------------------- Source/cmTarget.h | 107 +-- 19 files changed, 1560 insertions(+), 1430 deletions(-) hooks/post-receive -- CMake From steveire at gmail.com Tue Aug 25 17:12:09 2015 From: steveire at gmail.com (Stephen Kelly) Date: Tue, 25 Aug 2015 17:12:09 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2490-g9bfcb9d Message-ID: <20150825211209.610B7B0BA7@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 9bfcb9d4edc48a47beff5bdeb0e476012ef3fce9 (commit) via 7f551b4f2635816553c2ff7dacef78254875116e (commit) via cd6293cdf8cf04fca70497a2474989b773fe922e (commit) via de6b2895824fdac9a25fa9cd2f0f7c38b29547dc (commit) via e35ee02d6e6aa5d1e9bc50d7c378dcbbabcf52bd (commit) via 00f2298f0788404cf170ed6ab50b73ef890b4302 (commit) via 6254ba95784ae29616b17ad8b42d4f31560c2c65 (commit) via cf0a78dc4ce7debb62ceb4d12235ea75e19bebe2 (commit) from f91dd93d9afdb02268c285214abed9d8cc50f191 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9bfcb9d4edc48a47beff5bdeb0e476012ef3fce9 commit 9bfcb9d4edc48a47beff5bdeb0e476012ef3fce9 Merge: f91dd93 7f551b4 Author: Stephen Kelly AuthorDate: Tue Aug 25 17:12:07 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 25 17:12:07 2015 -0400 Merge topic 'minor-cleanups' into next 7f551b4f cmGlobalGenerator: Implement VS6 check without virtual method. cd6293cd cmMakefile: Fix style. de6b2895 cmTarget: Remove vestigal method declaration. e35ee02d cmTarget: Fix indentation. 00f2298f Reduce uses of cmMakefile::GetGlobalGenerator. 6254ba95 cmMakefile: Remove Internal class. cf0a78dc cmGeneratorTarget: Issue messages through the local generator. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7f551b4f2635816553c2ff7dacef78254875116e commit 7f551b4f2635816553c2ff7dacef78254875116e Author: Stephen Kelly AuthorDate: Mon Aug 24 09:08:29 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 23:06:33 2015 +0200 cmGlobalGenerator: Implement VS6 check without virtual method. Don't require existence of a global generator for this check. diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index fe710f1..3403cf9 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -242,7 +242,7 @@ public: #if defined(_WIN32) && !defined(__CYGWIN__) /** Is this the Visual Studio 6 generator? */ - virtual bool IsForVS6() const { return false; } + bool IsForVS6() const { return this->GetName() == "Visual Studio 6"; } #endif ///! Find a target by name by searching the local generators. diff --git a/Source/cmGlobalVisualStudio6Generator.h b/Source/cmGlobalVisualStudio6Generator.h index 2460158..420cb0b 100644 --- a/Source/cmGlobalVisualStudio6Generator.h +++ b/Source/cmGlobalVisualStudio6Generator.h @@ -85,8 +85,6 @@ public: virtual void FindMakeProgram(cmMakefile*); - virtual bool IsForVS6() const { return true; } - protected: virtual void Generate(); virtual const char* GetIDEVersion() { return "6.0"; } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cd6293cdf8cf04fca70497a2474989b773fe922e commit cd6293cdf8cf04fca70497a2474989b773fe922e Author: Stephen Kelly AuthorDate: Mon Aug 24 07:45:26 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 23:06:33 2015 +0200 cmMakefile: Fix style. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 3289881..1550c7b 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2072,7 +2072,8 @@ void cmMakefile::AddGlobalLinkInformation(const std::string& name, if(std::find(this->LinkDirectories.begin(), this->LinkDirectories.end(), newdir) == this->LinkDirectories.end()) - {target.AddLinkDirectory(*j); + { + target.AddLinkDirectory(*j); } } } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=de6b2895824fdac9a25fa9cd2f0f7c38b29547dc commit de6b2895824fdac9a25fa9cd2f0f7c38b29547dc Author: Stephen Kelly AuthorDate: Tue Aug 25 07:24:45 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 23:06:33 2015 +0200 cmTarget: Remove vestigal method declaration. The definition was removed in commit v3.1.0-rc1~688^2~5 (cmTarget: Allow any generator expression in SOURCES property., 2014-03-18). diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 2007b40..dccf550 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -614,8 +614,6 @@ private: void MaybeInvalidatePropertyCache(const std::string& prop); - void ProcessSourceExpression(std::string const& expr); - // Internal representation details. friend class cmTargetInternals; friend class cmGeneratorTarget; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e35ee02d6e6aa5d1e9bc50d7c378dcbbabcf52bd commit e35ee02d6e6aa5d1e9bc50d7c378dcbbabcf52bd Author: Stephen Kelly AuthorDate: Tue Aug 25 08:07:04 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 23:06:33 2015 +0200 cmTarget: Fix indentation. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 49b3239..747f465 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -1842,12 +1842,12 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } - this->Internal->SourceFilesMap.clear(); - cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - cmsys::auto_ptr cge = ge.Parse(value); - this->Internal->SourceEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->SourceFilesMap.clear(); + cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + cmGeneratorExpression ge(lfbt); + cmsys::auto_ptr cge = ge.Parse(value); + this->Internal->SourceEntries.push_back( + new cmTargetInternals::TargetPropertyEntry(cge)); } else { http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=00f2298f0788404cf170ed6ab50b73ef890b4302 commit 00f2298f0788404cf170ed6ab50b73ef890b4302 Author: Stephen Kelly AuthorDate: Tue Aug 25 22:55:11 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 23:06:33 2015 +0200 Reduce uses of cmMakefile::GetGlobalGenerator. Don't assume the cmMakefile has a global generator. diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 59590fd..1e02ae4 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -12,6 +12,7 @@ #include "cmComputeLinkDepends.h" #include "cmComputeComponentGraph.h" +#include "cmLocalGenerator.h" #include "cmGlobalGenerator.h" #include "cmMakefile.h" #include "cmTarget.h" @@ -177,7 +178,8 @@ cmComputeLinkDepends // Store context information. this->Target = target; this->Makefile = this->Target->Target->GetMakefile(); - this->GlobalGenerator = this->Makefile->GetGlobalGenerator(); + this->GlobalGenerator = + this->Target->GetLocalGenerator()->GetGlobalGenerator(); this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance(); // The configuration being linked. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 6ba0eed..6c3822f 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -769,7 +769,7 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, std::string lib; if(tgt) { - gtgt = tgt->GetMakefile()->GetGlobalGenerator()->GetGeneratorTarget(tgt); + gtgt = this->GlobalGenerator->GetGeneratorTarget(tgt); lib = gtgt->GetFullPath(this->Config, this->UseImportLibrary); this->AddLibraryRuntimeInfo(lib, tgt); diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index ffdb54f..25fc8a7 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1228,7 +1228,7 @@ public: : Preference(0), Target(target) { this->Makefile = this->Target->Makefile; - this->GG = this->Makefile->GetGlobalGenerator(); + this->GG = this->Target->GetLocalGenerator()->GetGlobalGenerator(); } void Consider(const char* lang) { http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6254ba95784ae29616b17ad8b42d4f31560c2c65 commit 6254ba95784ae29616b17ad8b42d4f31560c2c65 Author: Stephen Kelly AuthorDate: Tue Aug 25 22:19:57 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 22:19:57 2015 +0200 cmMakefile: Remove Internal class. Move only remaining state to the direct class. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 2296d5a..3289881 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -43,19 +43,12 @@ #include // for isspace #include -class cmMakefile::Internals -{ -public: - bool IsSourceFileTryCompile; -}; - // default is not to be building executables cmMakefile::cmMakefile(cmLocalGenerator* localGenerator) - : Internal(new Internals), - LocalGenerator(localGenerator), + : LocalGenerator(localGenerator), StateSnapshot(localGenerator->GetStateSnapshot()) { - this->Internal->IsSourceFileTryCompile = false; + this->IsSourceFileTryCompile = false; // Initialize these first since AddDefaultDefinitions calls AddDefinition this->WarnUnused = this->GetCMakeInstance()->GetWarnUnused(); @@ -3616,7 +3609,7 @@ int cmMakefile::TryCompile(const std::string& srcdir, const std::vector *cmakeArgs, std::string& output) { - this->Internal->IsSourceFileTryCompile = fast; + this->IsSourceFileTryCompile = fast; // does the binary directory exist ? If not create it... if (!cmSystemTools::FileIsDirectory(bindir)) { @@ -3641,7 +3634,7 @@ int cmMakefile::TryCompile(const std::string& srcdir, "Internal CMake error, TryCompile bad GlobalGenerator"); // return to the original directory cmSystemTools::ChangeDirectory(cwd); - this->Internal->IsSourceFileTryCompile = false; + this->IsSourceFileTryCompile = false; return 1; } cm.SetGlobalGenerator(gg); @@ -3712,7 +3705,7 @@ int cmMakefile::TryCompile(const std::string& srcdir, "Internal CMake error, TryCompile configure of cmake failed"); // return to the original directory cmSystemTools::ChangeDirectory(cwd); - this->Internal->IsSourceFileTryCompile = false; + this->IsSourceFileTryCompile = false; return 1; } @@ -3722,7 +3715,7 @@ int cmMakefile::TryCompile(const std::string& srcdir, "Internal CMake error, TryCompile generation of cmake failed"); // return to the original directory cmSystemTools::ChangeDirectory(cwd); - this->Internal->IsSourceFileTryCompile = false; + this->IsSourceFileTryCompile = false; return 1; } @@ -3735,13 +3728,13 @@ int cmMakefile::TryCompile(const std::string& srcdir, this); cmSystemTools::ChangeDirectory(cwd); - this->Internal->IsSourceFileTryCompile = false; + this->IsSourceFileTryCompile = false; return ret; } bool cmMakefile::GetIsSourceFileTryCompile() const { - return this->Internal->IsSourceFileTryCompile; + return this->IsSourceFileTryCompile; } cmake *cmMakefile::GetCMakeInstance() const diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 055170a..1f8a054 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -62,8 +62,6 @@ class cmGeneratorExpressionEvaluationFile; */ class cmMakefile { - class Internals; - cmsys::auto_ptr Internal; public: /* Mark a variable as used */ void MarkVariableAsUsed(const std::string& var); @@ -996,6 +994,7 @@ private: bool CheckSystemVars; bool CheckCMP0000; bool Configured; + bool IsSourceFileTryCompile; mutable bool SuppressWatches; }; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cf0a78dc4ce7debb62ceb4d12235ea75e19bebe2 commit cf0a78dc4ce7debb62ceb4d12235ea75e19bebe2 Author: Stephen Kelly AuthorDate: Tue Aug 25 22:18:39 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 22:18:39 2015 +0200 cmGeneratorTarget: Issue messages through the local generator. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index dd58e7b..ffdb54f 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1403,7 +1403,7 @@ cmGeneratorTarget::CompileInfo const* cmGeneratorTarget::GetCompileInfo( msg += this->GetName(); msg += " which has type "; msg += cmTarget::GetTargetTypeName(this->Target->GetType()); - this->Makefile->IssueMessage(cmake::INTERNAL_ERROR, msg); + this->LocalGenerator->IssueMessage(cmake::INTERNAL_ERROR, msg); return 0; } @@ -2093,7 +2093,7 @@ cmGeneratorTarget::NormalGetRealName(const std::string& config) const { std::string msg = "NormalGetRealName called on imported target: "; msg += this->GetName(); - this->Makefile->IssueMessage(cmake::INTERNAL_ERROR, msg); + this->LocalGenerator->IssueMessage(cmake::INTERNAL_ERROR, msg); } if(this->GetType() == cmTarget::EXECUTABLE) ----------------------------------------------------------------------- Summary of changes: Source/cmComputeLinkDepends.cxx | 4 +++- Source/cmComputeLinkInformation.cxx | 2 +- Source/cmGeneratorTarget.cxx | 6 +++--- Source/cmGlobalGenerator.h | 2 +- Source/cmGlobalVisualStudio6Generator.h | 2 -- Source/cmMakefile.cxx | 26 ++++++++++---------------- Source/cmMakefile.h | 3 +-- Source/cmTarget.cxx | 12 ++++++------ Source/cmTarget.h | 2 -- 9 files changed, 25 insertions(+), 34 deletions(-) hooks/post-receive -- CMake From steveire at gmail.com Tue Aug 25 17:26:30 2015 From: steveire at gmail.com (Stephen Kelly) Date: Tue, 25 Aug 2015 17:26:30 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2493-g0c1b27f Message-ID: <20150825212630.5D6F7B1944@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 0c1b27f050d3890cef1fd621a36cc53bd9dda7b7 (commit) via 87892dcb3dbaf65489caacf2e5eb2a5a26b711a6 (commit) via 873c9f072c79bc6a80fe5acb8c0386665cf979ef (commit) from 9bfcb9d4edc48a47beff5bdeb0e476012ef3fce9 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0c1b27f050d3890cef1fd621a36cc53bd9dda7b7 commit 0c1b27f050d3890cef1fd621a36cc53bd9dda7b7 Merge: 9bfcb9d 87892dc Author: Stephen Kelly AuthorDate: Tue Aug 25 17:26:29 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 25 17:26:29 2015 -0400 Merge topic 'use-generator-target' into next 87892dcb simplify. 873c9f07 simplify http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=87892dcb3dbaf65489caacf2e5eb2a5a26b711a6 commit 87892dcb3dbaf65489caacf2e5eb2a5a26b711a6 Author: Stephen Kelly AuthorDate: Tue Aug 25 23:26:01 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 23:26:06 2015 +0200 simplify. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 9fb8375..5c83879 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -4440,7 +4440,7 @@ bool cmGeneratorTarget::GetConfigCommonSourceFiles( e << "Target \"" << this->GetName() << "\" has source files which vary by " "configuration. This is not supported by the \"" - << this->LocalGenerator->GetGlobalGenerator()->GetName() + << this->GlobalGenerator->GetName() << "\" generator.\n" "Config \"" << firstConfig << "\":\n" " " << firstConfigFiles << "\n" http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=873c9f072c79bc6a80fe5acb8c0386665cf979ef commit 873c9f072c79bc6a80fe5acb8c0386665cf979ef Author: Stephen Kelly AuthorDate: Tue Aug 25 23:25:18 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 23:25:56 2015 +0200 simplify diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 9390b92..9fb8375 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -4479,7 +4479,7 @@ void cmGeneratorTarget::GetLanguages(std::set& languages, for (std::vector::const_iterator it = objectTargets.begin(); it != objectTargets.end(); ++it) { - objectLibraries.push_back(this->LocalGenerator->GetGlobalGenerator() + objectLibraries.push_back(this->GlobalGenerator ->GetGeneratorTarget(*it)); } } @@ -4492,7 +4492,7 @@ void cmGeneratorTarget::GetLanguages(std::set& languages, std::string objLib = (*i)->GetObjectLibrary(); if (cmTarget* tgt = this->Makefile->FindTargetToUse(objLib)) { - objectLibraries.push_back(this->LocalGenerator->GetGlobalGenerator() + objectLibraries.push_back(this->GlobalGenerator ->GetGeneratorTarget(tgt)); } } ----------------------------------------------------------------------- Summary of changes: Source/cmGeneratorTarget.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) hooks/post-receive -- CMake From steveire at gmail.com Tue Aug 25 17:27:21 2015 From: steveire at gmail.com (Stephen Kelly) Date: Tue, 25 Aug 2015 17:27:21 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2496-gb3ee076 Message-ID: <20150825212721.3922AB19F8@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via b3ee076f10eeaa5fcfb01d7e90820bdccbd3d397 (commit) via 976bdbf6a94dedb41a7988bff83153173faf043b (commit) via 06c2a30f336d417964cabae520885eb4eee5d77e (commit) from 0c1b27f050d3890cef1fd621a36cc53bd9dda7b7 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b3ee076f10eeaa5fcfb01d7e90820bdccbd3d397 commit b3ee076f10eeaa5fcfb01d7e90820bdccbd3d397 Merge: 0c1b27f 976bdbf Author: Stephen Kelly AuthorDate: Tue Aug 25 17:27:20 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 25 17:27:20 2015 -0400 Merge topic 'use-generator-target' into next 976bdbf6 cmGeneratorTarget: Move GetConfigCommonSourceFiles from cmTarget. 06c2a30f cmGeneratorTarget: Move GetLanguages from cmTarget. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=976bdbf6a94dedb41a7988bff83153173faf043b commit 976bdbf6a94dedb41a7988bff83153173faf043b Author: Stephen Kelly AuthorDate: Wed Aug 5 17:37:50 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 23:26:45 2015 +0200 cmGeneratorTarget: Move GetConfigCommonSourceFiles from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index e6507e7..5c83879 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -4397,11 +4397,68 @@ cmGeneratorTarget::GetLinkImplementation(const std::string& config) const } //---------------------------------------------------------------------------- +bool cmGeneratorTarget::GetConfigCommonSourceFiles( + std::vector& files) const +{ + std::vector configs; + this->Makefile->GetConfigurations(configs); + if (configs.empty()) + { + configs.push_back(""); + } + + std::vector::const_iterator it = configs.begin(); + const std::string& firstConfig = *it; + this->Target->GetSourceFiles(files, firstConfig); + + for ( ; it != configs.end(); ++it) + { + std::vector configFiles; + this->Target->GetSourceFiles(configFiles, *it); + if (configFiles != files) + { + std::string firstConfigFiles; + const char* sep = ""; + for (std::vector::const_iterator fi = files.begin(); + fi != files.end(); ++fi) + { + firstConfigFiles += sep; + firstConfigFiles += (*fi)->GetFullPath(); + sep = "\n "; + } + + std::string thisConfigFiles; + sep = ""; + for (std::vector::const_iterator fi = configFiles.begin(); + fi != configFiles.end(); ++fi) + { + thisConfigFiles += sep; + thisConfigFiles += (*fi)->GetFullPath(); + sep = "\n "; + } + std::ostringstream e; + e << "Target \"" << this->GetName() + << "\" has source files which vary by " + "configuration. This is not supported by the \"" + << this->GlobalGenerator->GetName() + << "\" generator.\n" + "Config \"" << firstConfig << "\":\n" + " " << firstConfigFiles << "\n" + "Config \"" << *it << "\":\n" + " " << thisConfigFiles << "\n"; + this->LocalGenerator->IssueMessage(cmake::FATAL_ERROR, e.str()); + return false; + } + } + return true; +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetLanguages(std::set& languages, const std::string& config) const { std::vector sourceFiles; - this->Target->GetSourceFiles(sourceFiles, config); + this->GetSourceFiles(sourceFiles, config); for(std::vector::const_iterator i = sourceFiles.begin(); i != sourceFiles.end(); ++i) { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index e7ec23a..6d66bfe 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -241,6 +241,8 @@ public: void GetLanguages(std::set& languages, std::string const& config) const; + bool GetConfigCommonSourceFiles(std::vector& files) const; + bool HaveBuildTreeRPATH(const std::string& config) const; /** Full path with trailing slash to the top-level directory diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index b70f3c9..756daa0 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1124,7 +1124,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, // organize the sources std::vector classes; - if (!cmtarget.GetConfigCommonSourceFiles(classes)) + if (!gtgt->GetConfigCommonSourceFiles(classes)) { return false; } @@ -1505,7 +1505,8 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases, } std::vector classes; - if (!cmtarget.GetConfigCommonSourceFiles(classes)) + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); + if (!gtgt->GetConfigCommonSourceFiles(classes)) { return; } @@ -2557,7 +2558,8 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget) if(cmtarget.GetType() == cmTarget::UTILITY) { std::vector sources; - if (!cmtarget.GetConfigCommonSourceFiles(sources)) + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); + if (!gtgt->GetConfigCommonSourceFiles(sources)) { return 0; } @@ -3085,7 +3087,8 @@ bool cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root, } std::vector classes; - if (!cmtarget.GetConfigCommonSourceFiles(classes)) + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); + if (!gtgt->GetConfigCommonSourceFiles(classes)) { return false; } diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index c58e7e4..0a4b546 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -403,7 +403,9 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg, ) { std::vector srcFiles; - target->GetConfigCommonSourceFiles(srcFiles); + cmGeneratorTarget* gtgt = + lg->GetGlobalGenerator()->GetGeneratorTarget(target); + gtgt->GetConfigCommonSourceFiles(srcFiles); for(std::vector::const_iterator fileIt = srcFiles.begin(); fileIt != srcFiles.end(); ++fileIt) @@ -661,7 +663,10 @@ void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target) const char* sepHeaders = ""; std::vector srcFiles; - target->GetConfigCommonSourceFiles(srcFiles); + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); + gtgt->GetConfigCommonSourceFiles(srcFiles); const char *skipMocSep = ""; const char *skipUicSep = ""; @@ -1046,7 +1051,10 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) cmMakefile *makefile = target->GetMakefile(); std::vector srcFiles; - target->GetConfigCommonSourceFiles(srcFiles); + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); + gtgt->GetConfigCommonSourceFiles(srcFiles); std::string qrcInputs; const char* qrcInputsSep = ""; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 682e9b9..40d7ebf 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -726,62 +726,6 @@ void cmTarget::GetSourceFiles(std::vector &files, } //---------------------------------------------------------------------------- -bool -cmTarget::GetConfigCommonSourceFiles(std::vector& files) const -{ - std::vector configs; - this->Makefile->GetConfigurations(configs); - if (configs.empty()) - { - configs.push_back(""); - } - - std::vector::const_iterator it = configs.begin(); - const std::string& firstConfig = *it; - this->GetSourceFiles(files, firstConfig); - - for ( ; it != configs.end(); ++it) - { - std::vector configFiles; - this->GetSourceFiles(configFiles, *it); - if (configFiles != files) - { - std::string firstConfigFiles; - const char* sep = ""; - for (std::vector::const_iterator fi = files.begin(); - fi != files.end(); ++fi) - { - firstConfigFiles += sep; - firstConfigFiles += (*fi)->GetFullPath(); - sep = "\n "; - } - - std::string thisConfigFiles; - sep = ""; - for (std::vector::const_iterator fi = configFiles.begin(); - fi != configFiles.end(); ++fi) - { - thisConfigFiles += sep; - thisConfigFiles += (*fi)->GetFullPath(); - sep = "\n "; - } - std::ostringstream e; - e << "Target \"" << this->Name << "\" has source files which vary by " - "configuration. This is not supported by the \"" - << this->Makefile->GetGlobalGenerator()->GetName() - << "\" generator.\n" - "Config \"" << firstConfig << "\":\n" - " " << firstConfigFiles << "\n" - "Config \"" << *it << "\":\n" - " " << thisConfigFiles << "\n"; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); - return false; - } - } - return true; -} - -//---------------------------------------------------------------------------- void cmTarget::GetSourceFiles(std::vector &files, const std::string& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 8dee560..d032380 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -137,8 +137,6 @@ public: */ void GetSourceFiles(std::vector &files, const std::string& config) const; - bool GetConfigCommonSourceFiles(std::vector& files) const; - /** * Add sources to the target. */ http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=06c2a30f336d417964cabae520885eb4eee5d77e commit 06c2a30f336d417964cabae520885eb4eee5d77e Author: Stephen Kelly AuthorDate: Wed Aug 5 17:37:50 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 23:26:45 2015 +0200 cmGeneratorTarget: Move GetLanguages from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 8e126b9..e6507e7 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -4397,6 +4397,57 @@ cmGeneratorTarget::GetLinkImplementation(const std::string& config) const } //---------------------------------------------------------------------------- +void cmGeneratorTarget::GetLanguages(std::set& languages, + const std::string& config) const +{ + std::vector sourceFiles; + this->Target->GetSourceFiles(sourceFiles, config); + for(std::vector::const_iterator + i = sourceFiles.begin(); i != sourceFiles.end(); ++i) + { + const std::string& lang = (*i)->GetLanguage(); + if(!lang.empty()) + { + languages.insert(lang); + } + } + + std::vector objectLibraries; + std::vector externalObjects; + if (!this->Makefile->IsConfigured()) + { + std::vector objectTargets; + this->Target->GetObjectLibrariesCMP0026(objectTargets); + objectLibraries.reserve(objectTargets.size()); + for (std::vector::const_iterator it = objectTargets.begin(); + it != objectTargets.end(); ++it) + { + objectLibraries.push_back(this->GlobalGenerator + ->GetGeneratorTarget(*it)); + } + } + else + { + this->GetExternalObjects(externalObjects, config); + for(std::vector::const_iterator + i = externalObjects.begin(); i != externalObjects.end(); ++i) + { + std::string objLib = (*i)->GetObjectLibrary(); + if (cmTarget* tgt = this->Makefile->FindTargetToUse(objLib)) + { + objectLibraries.push_back(this->GlobalGenerator + ->GetGeneratorTarget(tgt)); + } + } + } + for(std::vector::const_iterator + i = objectLibraries.begin(); i != objectLibraries.end(); ++i) + { + (*i)->GetLanguages(languages, config); + } +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::ComputeLinkImplementationLanguages( const std::string& config, cmOptionalLinkImplementation& impl) const @@ -4404,7 +4455,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLanguages( // This target needs runtime libraries for its source languages. std::set languages; // Get languages used in our source files. - this->Target->GetLanguages(languages, config); + this->GetLanguages(languages, config); // Copy the set of langauges to the link implementation. impl.Languages.insert(impl.Languages.begin(), languages.begin(), languages.end()); diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 7cb3acd..e7ec23a 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -233,6 +233,14 @@ public: cmOptionalLinkImplementation& impl ) const; + // Compute the set of languages compiled by the target. This is + // computed every time it is called because the languages can change + // when source file properties are changed and we do not have enough + // information to forward these property changes to the targets + // until we have per-target object file properties. + void GetLanguages(std::set& languages, + std::string const& config) const; + bool HaveBuildTreeRPATH(const std::string& config) const; /** Full path with trailing slash to the top-level directory diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index b240924..331caad 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -1134,7 +1134,8 @@ bool cmGlobalUnixMakefileGenerator3 ::NeedRequiresStep(cmTarget const& target) { std::set languages; - target.GetLanguages(languages, + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&target); + gtgt->GetLanguages(languages, target.GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE")); for(std::set::const_iterator l = languages.begin(); l != languages.end(); ++l) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index dda4829..b70f3c9 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1805,7 +1805,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, // Compute the compilation flags for each language. std::set languages; - target.GetLanguages(languages, configName); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); + gtgt->GetLanguages(languages, configName); std::map cflags; for (std::set::iterator li = languages.begin(); li != languages.end(); ++li) @@ -1827,7 +1828,6 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, AddCompileOptions(flags, &target, lang, configName); } - cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); std::string llang = gtgt->GetLinkerLanguage(configName); if(binary && llang.empty()) { diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index ce370bc..589105e 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1257,7 +1257,9 @@ cmLocalUnixMakefileGenerator3 { // Get the set of source languages in the target. std::set languages; - target.GetLanguages(languages, + cmGeneratorTarget *gtgt = + this->GlobalGenerator->GetGeneratorTarget(&target); + gtgt->GetLanguages(languages, this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); fout << "\n" << "# Per-language clean rules from dependency scanning.\n" diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 0b3df90..cf88a74 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -276,7 +276,7 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags() { // write language flags for target std::set languages; - this->Target->GetLanguages(languages, + this->GeneratorTarget->GetLanguages(languages, this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); // put the compiler in the rules.make file so that if it changes // things rebuild diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e8a315d..682e9b9 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3132,50 +3132,6 @@ cmTarget::GetObjectLibrariesCMP0026(std::vector& objlibs) const } //---------------------------------------------------------------------------- -void cmTarget::GetLanguages(std::set& languages, - const std::string& config) const -{ - std::vector sourceFiles; - this->GetSourceFiles(sourceFiles, config); - for(std::vector::const_iterator - i = sourceFiles.begin(); i != sourceFiles.end(); ++i) - { - const std::string& lang = (*i)->GetLanguage(); - if(!lang.empty()) - { - languages.insert(lang); - } - } - - std::vector objectLibraries; - std::vector externalObjects; - if (!this->Makefile->IsConfigured()) - { - this->GetObjectLibrariesCMP0026(objectLibraries); - } - else - { - cmGeneratorTarget* gt = this->Makefile->GetGlobalGenerator() - ->GetGeneratorTarget(this); - gt->GetExternalObjects(externalObjects, config); - for(std::vector::const_iterator - i = externalObjects.begin(); i != externalObjects.end(); ++i) - { - std::string objLib = (*i)->GetObjectLibrary(); - if (cmTarget* tgt = this->Makefile->FindTargetToUse(objLib)) - { - objectLibraries.push_back(tgt); - } - } - } - for(std::vector::const_iterator - i = objectLibraries.begin(); i != objectLibraries.end(); ++i) - { - (*i)->GetLanguages(languages, config); - } -} - -//---------------------------------------------------------------------------- cmTarget::ImportInfo const* cmTarget::GetImportInfo(const std::string& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 1db4ba1..8dee560 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -305,14 +305,6 @@ public: If no macro should be defined null is returned. */ const char* GetExportMacro() const; - // Compute the set of languages compiled by the target. This is - // computed every time it is called because the languages can change - // when source file properties are changed and we do not have enough - // information to forward these property changes to the targets - // until we have per-target object file properties. - void GetLanguages(std::set& languages, - std::string const& config) const; - /** Return whether this target is an executable with symbol exports enabled. */ bool IsExecutableWithExports() const; ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From steveire at gmail.com Tue Aug 25 17:43:10 2015 From: steveire at gmail.com (Stephen Kelly) Date: Tue, 25 Aug 2015 17:43:10 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2503-gd680282 Message-ID: <20150825214310.8263AB13C9@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via d680282224da579f124c8b26efb71b70db87fd47 (commit) via aeeed727d50330deef90ef09c24639fa62f3010d (commit) via 4836df6df1c01a46d75c8c32cae1fc51bd0332cd (commit) via 2617827b99961436ef7fe7ea4cb50cfc4c5fc203 (commit) via f5e9a738f976e8793bbae348f9535e64b9022e47 (commit) via ece6945b9d40fb47c3ac1070db9e1b46739b6448 (commit) via e4e4417bec7b089637832a4026a5130aa99da587 (commit) from b3ee076f10eeaa5fcfb01d7e90820bdccbd3d397 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d680282224da579f124c8b26efb71b70db87fd47 commit d680282224da579f124c8b26efb71b70db87fd47 Merge: b3ee076 aeeed72 Author: Stephen Kelly AuthorDate: Tue Aug 25 17:43:09 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 25 17:43:09 2015 -0400 Merge topic 'use-generator-target' into next aeeed727 fix sources 4836df6d languages 2617827b fix compute f5e9a738 compile-options ece6945b include-directories e4e4417b compile-definitions http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=aeeed727d50330deef90ef09c24639fa62f3010d commit aeeed727d50330deef90ef09c24639fa62f3010d Author: Stephen Kelly AuthorDate: Tue Aug 25 23:41:24 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 23:42:54 2015 +0200 fix sources diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 84fdcad..b422fdc 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -843,7 +843,7 @@ cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget const& target) // Issue diagnostic if the source files depend on the config. std::vector sources; - if (!target.GetConfigCommonSourceFiles(sources)) + if (!gt->GetConfigCommonSourceFiles(sources)) { return false; } diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 0d07536..3a44367 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -305,9 +305,12 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout, // We may be modifying the source groups temporarily, so make a copy. std::vector sourceGroups = this->Makefile->GetSourceGroups(); + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); + // get the classes from the source lists then add them to the groups std::vector classes; - if (!target.GetConfigCommonSourceFiles(classes)) + if (!gt->GetConfigCommonSourceFiles(classes)) { return; } diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index f17c9a4..55ad852 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1469,10 +1469,13 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, // We may be modifying the source groups temporarily, so make a copy. std::vector sourceGroups = this->Makefile->GetSourceGroups(); + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); + // get the classes from the source lists then add them to the groups this->ModuleDefinitionFile = ""; std::vector classes; - if (!target.GetConfigCommonSourceFiles(classes)) + if (!gt->GetConfigCommonSourceFiles(classes)) { return; } @@ -1514,8 +1517,6 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, { // VS >= 8 support per-config source locations so we // list object library content as external objects. - cmGeneratorTarget* gt = - this->GlobalGenerator->GetGeneratorTarget(&target); std::vector objs; gt->UseObjectLibraries(objs, ""); if(!objs.empty()) diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 464a83a..e7716d8 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -965,7 +965,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups() std::vector sourceGroups = this->Makefile->GetSourceGroups(); std::vector classes; - if (!this->Target->GetConfigCommonSourceFiles(classes)) + if (!this->GeneratorTarget->GetConfigCommonSourceFiles(classes)) { return; } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4836df6df1c01a46d75c8c32cae1fc51bd0332cd commit 4836df6df1c01a46d75c8c32cae1fc51bd0332cd Author: Stephen Kelly AuthorDate: Tue Aug 25 23:40:08 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 23:42:54 2015 +0200 languages diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 634366e..84fdcad 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -839,6 +839,8 @@ cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget const& target) // check to see if this is a fortran build std::set languages; { + cmGeneratorTarget* gt = this->GetGeneratorTarget(&target); + // Issue diagnostic if the source files depend on the config. std::vector sources; if (!target.GetConfigCommonSourceFiles(sources)) @@ -846,7 +848,7 @@ cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget const& target) return false; } } - target.GetLanguages(languages, ""); + gt->GetLanguages(languages, ""); if(languages.size() == 1) { if(*languages.begin() == "Fortran") http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2617827b99961436ef7fe7ea4cb50cfc4c5fc203 commit 2617827b99961436ef7fe7ea4cb50cfc4c5fc203 Author: Stephen Kelly AuthorDate: Tue Aug 25 23:39:40 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 23:42:48 2015 +0200 fix compute diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 51dcab0..28f0425 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -254,7 +254,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() mf->AddUtilityCommand(CMAKE_CHECK_BUILD_SYSTEM_TARGET, false, no_working_directory, no_depends, noCommandLines); - tgt->Compute(); + cmGeneratorTarget* gt = new cmGeneratorTarget(tgt, lg); mf->AddGeneratorTarget(tgt, gt); diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index b0aa243..634366e 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -90,7 +90,7 @@ bool cmGlobalVisualStudioGenerator::Compute() AddUtilityCommand("ALL_BUILD", true, no_working_dir, no_depends, no_commands, false, "Build all projects"); - allBuild->Compute(); + cmGeneratorTarget* gt = new cmGeneratorTarget(allBuild, gen[0]); allBuild->GetMakefile()->AddGeneratorTarget(allBuild, gt); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 756daa0..eb547bd 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -463,7 +463,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, cmTarget* allbuild = mf->AddUtilityCommand("ALL_BUILD", true, no_depends, no_working_directory, "echo", "Build all projects"); - allbuild->Compute(); + cmGeneratorTarget* allBuildGt = new cmGeneratorTarget(allbuild, root); mf->AddGeneratorTarget(allbuild, allBuildGt); @@ -498,7 +498,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, true, no_depends, no_working_directory, "make", "-f", file.c_str()); - check->Compute(); + cmGeneratorTarget* checkGt = new cmGeneratorTarget(check, root); mf->AddGeneratorTarget(check, checkGt); } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f5e9a738f976e8793bbae348f9535e64b9022e47 commit f5e9a738f976e8793bbae348f9535e64b9022e47 Author: Stephen Kelly AuthorDate: Tue Aug 25 23:39:15 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 23:42:01 2015 +0200 compile-options diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index 75125bc..846b6e2 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -559,7 +559,7 @@ bool cmGhsMultiTargetGenerator::IsNotKernel(std::string const &config, { bool output; std::vector options; - this->Target->GetCompileOptions(options, config, language); + this->GeneratorTarget->GetCompileOptions(options, config, language); output = options.end() == std::find(options.begin(), options.end(), "-kernel"); return output; @@ -588,7 +588,7 @@ bool cmGhsMultiTargetGenerator::DetermineIfDynamicDownload( { std::vector options; bool output = false; - this->Target->GetCompileOptions(options, config, language); + this->GeneratorTarget->GetCompileOptions(options, config, language); for (std::vector::const_iterator options_i = options.begin(); options_i != options.end(); ++options_i) { http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ece6945b9d40fb47c3ac1070db9e1b46739b6448 commit ece6945b9d40fb47c3ac1070db9e1b46739b6448 Author: Stephen Kelly AuthorDate: Tue Aug 25 23:39:03 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 23:42:01 2015 +0200 include-directories diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index ff4216b..75125bc 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -344,7 +344,7 @@ void cmGhsMultiTargetGenerator::WriteIncludes(const std::string &config, const std::string &language) { std::vector includes = - this->Target->GetIncludeDirectories(config, language); + this->GeneratorTarget->GetIncludeDirectories(config, language); for (std::vector::const_iterator includes_i = includes.begin(); includes_i != includes.end(); ++includes_i) { http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e4e4417bec7b089637832a4026a5130aa99da587 commit e4e4417bec7b089637832a4026a5130aa99da587 Author: Stephen Kelly AuthorDate: Tue Aug 25 23:38:51 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 23:42:00 2015 +0200 compile-definitions diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index 1e57c33..ff4216b 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -330,7 +330,8 @@ void cmGhsMultiTargetGenerator::WriteCompilerDefinitions( const std::string &config, const std::string &language) { std::vector compileDefinitions; - this->Target->GetCompileDefinitions(compileDefinitions, config, language); + this->GeneratorTarget->GetCompileDefinitions(compileDefinitions, + config, language); for (std::vector::const_iterator cdI = compileDefinitions.begin(); cdI != compileDefinitions.end(); ++cdI) diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 5de6d37..f17c9a4 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -763,7 +763,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, targetOptions.Parse(defineFlags.c_str()); targetOptions.ParseFinish(); std::vector targetDefines; - target.GetCompileDefinitions(targetDefines, configName, "CXX"); + gt->GetCompileDefinitions(targetDefines, configName, "CXX"); targetOptions.AddDefines(targetDefines); targetOptions.SetVerboseMakefile( this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE")); diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 823b550..464a83a 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1934,7 +1934,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( clOptions.Parse(flags.c_str()); clOptions.Parse(defineFlags.c_str()); std::vector targetDefines; - this->Target->GetCompileDefinitions(targetDefines, + this->GeneratorTarget->GetCompileDefinitions(targetDefines, configName.c_str(), "CXX"); clOptions.AddDefines(targetDefines); if(this->MSTools) ----------------------------------------------------------------------- Summary of changes: Source/cmGhsMultiTargetGenerator.cxx | 9 +++++---- Source/cmGlobalVisualStudio8Generator.cxx | 2 +- Source/cmGlobalVisualStudioGenerator.cxx | 8 +++++--- Source/cmGlobalXCodeGenerator.cxx | 4 ++-- Source/cmLocalVisualStudio6Generator.cxx | 5 ++++- Source/cmLocalVisualStudio7Generator.cxx | 9 +++++---- Source/cmVisualStudio10TargetGenerator.cxx | 4 ++-- 7 files changed, 24 insertions(+), 17 deletions(-) hooks/post-receive -- CMake From steveire at gmail.com Tue Aug 25 17:57:47 2015 From: steveire at gmail.com (Stephen Kelly) Date: Tue, 25 Aug 2015 17:57:47 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2516-g12af124 Message-ID: <20150825215747.769A5B0F24@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 12af1245ee99372e77d8ae50feb3cc25c33c8362 (commit) via ccb4496f6451a4bcbf20f5cf67c7f2e7451e581b (commit) via 9e70086973b3cca74a9455535467dc9dd3b889bf (commit) via 94644f864db95d61c680f92d6cfd1a4928305331 (commit) via e585982cbb2910be05cd2a50aec455fc6f6528d2 (commit) via 76c351181ab69f57ab741ea869b20e5526dea4cb (commit) via ef4fdfd49a02952ca5b2e347f0c041fbf3ae48a1 (commit) via ef9431a968e2ef77159a1ac1c8fa931c8a179eb2 (commit) via d09514361491425ce25c27518167a2ce78c568c8 (commit) via 784e1d001a151d17884b124cc12e5a9ef9878477 (commit) via 0ff2e1ea2a7b70ee828f3738df884378917f261e (commit) via a9a750bb9372b9b4dbdb506510f99e50fcf1b21b (commit) via 09c5d93651499887187095c297561d490c51dafe (commit) from d680282224da579f124c8b26efb71b70db87fd47 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=12af1245ee99372e77d8ae50feb3cc25c33c8362 commit 12af1245ee99372e77d8ae50feb3cc25c33c8362 Merge: d680282 ccb4496 Author: Stephen Kelly AuthorDate: Tue Aug 25 17:57:45 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 25 17:57:45 2015 -0400 Merge topic 'use-generator-target' into next ccb4496f cmGeneratorTarget: Move GetConfigCommonSourceFiles from cmTarget. 9e700869 cmGeneratorTarget: Move GetLanguages from cmTarget. 94644f86 cmGeneratorTarget: Move ComputeLinkImplementationLanguages from cmTarget. e585982c cmGeneratorTarget: Move HaveBuildTreeRPath from cmTarget. 76c35118 cmGeneratorTarget: Move GetLinkImplementation from cmTarget. ef4fdfd4 cmTarget: Add GetLinkImplMap method. ef9431a9 cmLinkItem: Add cmOptionalLinkImplementation type. d0951436 cmLinkItem: Add cmLinkImplementation type. 784e1d00 cmGeneratorTarget: Move compile defintions processing from cmTarget. 0ff2e1ea cmGeneratorTarget: Move compile features processing from cmTarget. a9a750bb cmGeneratorTarget: Move compile options processing from cmTarget. 09c5d936 cmGeneratorTarget: Move include directory processing from cmTarget. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ccb4496f6451a4bcbf20f5cf67c7f2e7451e581b commit ccb4496f6451a4bcbf20f5cf67c7f2e7451e581b Author: Stephen Kelly AuthorDate: Wed Aug 5 17:37:50 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 23:44:15 2015 +0200 cmGeneratorTarget: Move GetConfigCommonSourceFiles from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index e6507e7..5c83879 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -4397,11 +4397,68 @@ cmGeneratorTarget::GetLinkImplementation(const std::string& config) const } //---------------------------------------------------------------------------- +bool cmGeneratorTarget::GetConfigCommonSourceFiles( + std::vector& files) const +{ + std::vector configs; + this->Makefile->GetConfigurations(configs); + if (configs.empty()) + { + configs.push_back(""); + } + + std::vector::const_iterator it = configs.begin(); + const std::string& firstConfig = *it; + this->Target->GetSourceFiles(files, firstConfig); + + for ( ; it != configs.end(); ++it) + { + std::vector configFiles; + this->Target->GetSourceFiles(configFiles, *it); + if (configFiles != files) + { + std::string firstConfigFiles; + const char* sep = ""; + for (std::vector::const_iterator fi = files.begin(); + fi != files.end(); ++fi) + { + firstConfigFiles += sep; + firstConfigFiles += (*fi)->GetFullPath(); + sep = "\n "; + } + + std::string thisConfigFiles; + sep = ""; + for (std::vector::const_iterator fi = configFiles.begin(); + fi != configFiles.end(); ++fi) + { + thisConfigFiles += sep; + thisConfigFiles += (*fi)->GetFullPath(); + sep = "\n "; + } + std::ostringstream e; + e << "Target \"" << this->GetName() + << "\" has source files which vary by " + "configuration. This is not supported by the \"" + << this->GlobalGenerator->GetName() + << "\" generator.\n" + "Config \"" << firstConfig << "\":\n" + " " << firstConfigFiles << "\n" + "Config \"" << *it << "\":\n" + " " << thisConfigFiles << "\n"; + this->LocalGenerator->IssueMessage(cmake::FATAL_ERROR, e.str()); + return false; + } + } + return true; +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetLanguages(std::set& languages, const std::string& config) const { std::vector sourceFiles; - this->Target->GetSourceFiles(sourceFiles, config); + this->GetSourceFiles(sourceFiles, config); for(std::vector::const_iterator i = sourceFiles.begin(); i != sourceFiles.end(); ++i) { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index e7ec23a..6d66bfe 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -241,6 +241,8 @@ public: void GetLanguages(std::set& languages, std::string const& config) const; + bool GetConfigCommonSourceFiles(std::vector& files) const; + bool HaveBuildTreeRPATH(const std::string& config) const; /** Full path with trailing slash to the top-level directory diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 84fdcad..b422fdc 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -843,7 +843,7 @@ cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget const& target) // Issue diagnostic if the source files depend on the config. std::vector sources; - if (!target.GetConfigCommonSourceFiles(sources)) + if (!gt->GetConfigCommonSourceFiles(sources)) { return false; } diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 4511de5..eb547bd 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1124,7 +1124,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, // organize the sources std::vector classes; - if (!cmtarget.GetConfigCommonSourceFiles(classes)) + if (!gtgt->GetConfigCommonSourceFiles(classes)) { return false; } @@ -1505,7 +1505,8 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases, } std::vector classes; - if (!cmtarget.GetConfigCommonSourceFiles(classes)) + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); + if (!gtgt->GetConfigCommonSourceFiles(classes)) { return; } @@ -2557,7 +2558,8 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget) if(cmtarget.GetType() == cmTarget::UTILITY) { std::vector sources; - if (!cmtarget.GetConfigCommonSourceFiles(sources)) + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); + if (!gtgt->GetConfigCommonSourceFiles(sources)) { return 0; } @@ -3085,7 +3087,8 @@ bool cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root, } std::vector classes; - if (!cmtarget.GetConfigCommonSourceFiles(classes)) + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); + if (!gtgt->GetConfigCommonSourceFiles(classes)) { return false; } diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 0d07536..3a44367 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -305,9 +305,12 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout, // We may be modifying the source groups temporarily, so make a copy. std::vector sourceGroups = this->Makefile->GetSourceGroups(); + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); + // get the classes from the source lists then add them to the groups std::vector classes; - if (!target.GetConfigCommonSourceFiles(classes)) + if (!gt->GetConfigCommonSourceFiles(classes)) { return; } diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index f17c9a4..55ad852 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1469,10 +1469,13 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, // We may be modifying the source groups temporarily, so make a copy. std::vector sourceGroups = this->Makefile->GetSourceGroups(); + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); + // get the classes from the source lists then add them to the groups this->ModuleDefinitionFile = ""; std::vector classes; - if (!target.GetConfigCommonSourceFiles(classes)) + if (!gt->GetConfigCommonSourceFiles(classes)) { return; } @@ -1514,8 +1517,6 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, { // VS >= 8 support per-config source locations so we // list object library content as external objects. - cmGeneratorTarget* gt = - this->GlobalGenerator->GetGeneratorTarget(&target); std::vector objs; gt->UseObjectLibraries(objs, ""); if(!objs.empty()) diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index c58e7e4..0a4b546 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -403,7 +403,9 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg, ) { std::vector srcFiles; - target->GetConfigCommonSourceFiles(srcFiles); + cmGeneratorTarget* gtgt = + lg->GetGlobalGenerator()->GetGeneratorTarget(target); + gtgt->GetConfigCommonSourceFiles(srcFiles); for(std::vector::const_iterator fileIt = srcFiles.begin(); fileIt != srcFiles.end(); ++fileIt) @@ -661,7 +663,10 @@ void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target) const char* sepHeaders = ""; std::vector srcFiles; - target->GetConfigCommonSourceFiles(srcFiles); + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); + gtgt->GetConfigCommonSourceFiles(srcFiles); const char *skipMocSep = ""; const char *skipUicSep = ""; @@ -1046,7 +1051,10 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) cmMakefile *makefile = target->GetMakefile(); std::vector srcFiles; - target->GetConfigCommonSourceFiles(srcFiles); + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); + gtgt->GetConfigCommonSourceFiles(srcFiles); std::string qrcInputs; const char* qrcInputsSep = ""; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 682e9b9..40d7ebf 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -726,62 +726,6 @@ void cmTarget::GetSourceFiles(std::vector &files, } //---------------------------------------------------------------------------- -bool -cmTarget::GetConfigCommonSourceFiles(std::vector& files) const -{ - std::vector configs; - this->Makefile->GetConfigurations(configs); - if (configs.empty()) - { - configs.push_back(""); - } - - std::vector::const_iterator it = configs.begin(); - const std::string& firstConfig = *it; - this->GetSourceFiles(files, firstConfig); - - for ( ; it != configs.end(); ++it) - { - std::vector configFiles; - this->GetSourceFiles(configFiles, *it); - if (configFiles != files) - { - std::string firstConfigFiles; - const char* sep = ""; - for (std::vector::const_iterator fi = files.begin(); - fi != files.end(); ++fi) - { - firstConfigFiles += sep; - firstConfigFiles += (*fi)->GetFullPath(); - sep = "\n "; - } - - std::string thisConfigFiles; - sep = ""; - for (std::vector::const_iterator fi = configFiles.begin(); - fi != configFiles.end(); ++fi) - { - thisConfigFiles += sep; - thisConfigFiles += (*fi)->GetFullPath(); - sep = "\n "; - } - std::ostringstream e; - e << "Target \"" << this->Name << "\" has source files which vary by " - "configuration. This is not supported by the \"" - << this->Makefile->GetGlobalGenerator()->GetName() - << "\" generator.\n" - "Config \"" << firstConfig << "\":\n" - " " << firstConfigFiles << "\n" - "Config \"" << *it << "\":\n" - " " << thisConfigFiles << "\n"; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); - return false; - } - } - return true; -} - -//---------------------------------------------------------------------------- void cmTarget::GetSourceFiles(std::vector &files, const std::string& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 8dee560..d032380 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -137,8 +137,6 @@ public: */ void GetSourceFiles(std::vector &files, const std::string& config) const; - bool GetConfigCommonSourceFiles(std::vector& files) const; - /** * Add sources to the target. */ diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 464a83a..e7716d8 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -965,7 +965,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups() std::vector sourceGroups = this->Makefile->GetSourceGroups(); std::vector classes; - if (!this->Target->GetConfigCommonSourceFiles(classes)) + if (!this->GeneratorTarget->GetConfigCommonSourceFiles(classes)) { return; } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9e70086973b3cca74a9455535467dc9dd3b889bf commit 9e70086973b3cca74a9455535467dc9dd3b889bf Author: Stephen Kelly AuthorDate: Wed Aug 5 17:37:50 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 23:44:15 2015 +0200 cmGeneratorTarget: Move GetLanguages from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 8e126b9..e6507e7 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -4397,6 +4397,57 @@ cmGeneratorTarget::GetLinkImplementation(const std::string& config) const } //---------------------------------------------------------------------------- +void cmGeneratorTarget::GetLanguages(std::set& languages, + const std::string& config) const +{ + std::vector sourceFiles; + this->Target->GetSourceFiles(sourceFiles, config); + for(std::vector::const_iterator + i = sourceFiles.begin(); i != sourceFiles.end(); ++i) + { + const std::string& lang = (*i)->GetLanguage(); + if(!lang.empty()) + { + languages.insert(lang); + } + } + + std::vector objectLibraries; + std::vector externalObjects; + if (!this->Makefile->IsConfigured()) + { + std::vector objectTargets; + this->Target->GetObjectLibrariesCMP0026(objectTargets); + objectLibraries.reserve(objectTargets.size()); + for (std::vector::const_iterator it = objectTargets.begin(); + it != objectTargets.end(); ++it) + { + objectLibraries.push_back(this->GlobalGenerator + ->GetGeneratorTarget(*it)); + } + } + else + { + this->GetExternalObjects(externalObjects, config); + for(std::vector::const_iterator + i = externalObjects.begin(); i != externalObjects.end(); ++i) + { + std::string objLib = (*i)->GetObjectLibrary(); + if (cmTarget* tgt = this->Makefile->FindTargetToUse(objLib)) + { + objectLibraries.push_back(this->GlobalGenerator + ->GetGeneratorTarget(tgt)); + } + } + } + for(std::vector::const_iterator + i = objectLibraries.begin(); i != objectLibraries.end(); ++i) + { + (*i)->GetLanguages(languages, config); + } +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::ComputeLinkImplementationLanguages( const std::string& config, cmOptionalLinkImplementation& impl) const @@ -4404,7 +4455,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLanguages( // This target needs runtime libraries for its source languages. std::set languages; // Get languages used in our source files. - this->Target->GetLanguages(languages, config); + this->GetLanguages(languages, config); // Copy the set of langauges to the link implementation. impl.Languages.insert(impl.Languages.begin(), languages.begin(), languages.end()); diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 7cb3acd..e7ec23a 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -233,6 +233,14 @@ public: cmOptionalLinkImplementation& impl ) const; + // Compute the set of languages compiled by the target. This is + // computed every time it is called because the languages can change + // when source file properties are changed and we do not have enough + // information to forward these property changes to the targets + // until we have per-target object file properties. + void GetLanguages(std::set& languages, + std::string const& config) const; + bool HaveBuildTreeRPATH(const std::string& config) const; /** Full path with trailing slash to the top-level directory diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index b240924..331caad 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -1134,7 +1134,8 @@ bool cmGlobalUnixMakefileGenerator3 ::NeedRequiresStep(cmTarget const& target) { std::set languages; - target.GetLanguages(languages, + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&target); + gtgt->GetLanguages(languages, target.GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE")); for(std::set::const_iterator l = languages.begin(); l != languages.end(); ++l) diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 634366e..84fdcad 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -839,6 +839,8 @@ cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget const& target) // check to see if this is a fortran build std::set languages; { + cmGeneratorTarget* gt = this->GetGeneratorTarget(&target); + // Issue diagnostic if the source files depend on the config. std::vector sources; if (!target.GetConfigCommonSourceFiles(sources)) @@ -846,7 +848,7 @@ cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget const& target) return false; } } - target.GetLanguages(languages, ""); + gt->GetLanguages(languages, ""); if(languages.size() == 1) { if(*languages.begin() == "Fortran") diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 68fd06b..4511de5 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1805,7 +1805,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, // Compute the compilation flags for each language. std::set languages; - target.GetLanguages(languages, configName); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); + gtgt->GetLanguages(languages, configName); std::map cflags; for (std::set::iterator li = languages.begin(); li != languages.end(); ++li) @@ -1827,7 +1828,6 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, AddCompileOptions(flags, &target, lang, configName); } - cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); std::string llang = gtgt->GetLinkerLanguage(configName); if(binary && llang.empty()) { diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index ce370bc..589105e 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1257,7 +1257,9 @@ cmLocalUnixMakefileGenerator3 { // Get the set of source languages in the target. std::set languages; - target.GetLanguages(languages, + cmGeneratorTarget *gtgt = + this->GlobalGenerator->GetGeneratorTarget(&target); + gtgt->GetLanguages(languages, this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); fout << "\n" << "# Per-language clean rules from dependency scanning.\n" diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 0b3df90..cf88a74 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -276,7 +276,7 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags() { // write language flags for target std::set languages; - this->Target->GetLanguages(languages, + this->GeneratorTarget->GetLanguages(languages, this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); // put the compiler in the rules.make file so that if it changes // things rebuild diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e8a315d..682e9b9 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3132,50 +3132,6 @@ cmTarget::GetObjectLibrariesCMP0026(std::vector& objlibs) const } //---------------------------------------------------------------------------- -void cmTarget::GetLanguages(std::set& languages, - const std::string& config) const -{ - std::vector sourceFiles; - this->GetSourceFiles(sourceFiles, config); - for(std::vector::const_iterator - i = sourceFiles.begin(); i != sourceFiles.end(); ++i) - { - const std::string& lang = (*i)->GetLanguage(); - if(!lang.empty()) - { - languages.insert(lang); - } - } - - std::vector objectLibraries; - std::vector externalObjects; - if (!this->Makefile->IsConfigured()) - { - this->GetObjectLibrariesCMP0026(objectLibraries); - } - else - { - cmGeneratorTarget* gt = this->Makefile->GetGlobalGenerator() - ->GetGeneratorTarget(this); - gt->GetExternalObjects(externalObjects, config); - for(std::vector::const_iterator - i = externalObjects.begin(); i != externalObjects.end(); ++i) - { - std::string objLib = (*i)->GetObjectLibrary(); - if (cmTarget* tgt = this->Makefile->FindTargetToUse(objLib)) - { - objectLibraries.push_back(tgt); - } - } - } - for(std::vector::const_iterator - i = objectLibraries.begin(); i != objectLibraries.end(); ++i) - { - (*i)->GetLanguages(languages, config); - } -} - -//---------------------------------------------------------------------------- cmTarget::ImportInfo const* cmTarget::GetImportInfo(const std::string& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 1db4ba1..8dee560 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -305,14 +305,6 @@ public: If no macro should be defined null is returned. */ const char* GetExportMacro() const; - // Compute the set of languages compiled by the target. This is - // computed every time it is called because the languages can change - // when source file properties are changed and we do not have enough - // information to forward these property changes to the targets - // until we have per-target object file properties. - void GetLanguages(std::set& languages, - std::string const& config) const; - /** Return whether this target is an executable with symbol exports enabled. */ bool IsExecutableWithExports() const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=94644f864db95d61c680f92d6cfd1a4928305331 commit 94644f864db95d61c680f92d6cfd1a4928305331 Author: Stephen Kelly AuthorDate: Wed Aug 5 17:37:50 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 23:44:15 2015 +0200 cmGeneratorTarget: Move ComputeLinkImplementationLanguages from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index a4999ce..8e126b9 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -4391,12 +4391,26 @@ cmGeneratorTarget::GetLinkImplementation(const std::string& config) const if(!impl.LanguagesDone) { impl.LanguagesDone = true; - this->Target->ComputeLinkImplementationLanguages(config, impl); + this->ComputeLinkImplementationLanguages(config, impl); } return &impl; } //---------------------------------------------------------------------------- +void cmGeneratorTarget::ComputeLinkImplementationLanguages( + const std::string& config, + cmOptionalLinkImplementation& impl) const +{ + // This target needs runtime libraries for its source languages. + std::set languages; + // Get languages used in our source files. + this->Target->GetLanguages(languages, config); + // Copy the set of langauges to the link implementation. + impl.Languages.insert(impl.Languages.begin(), + languages.begin(), languages.end()); +} + +//---------------------------------------------------------------------------- bool cmGeneratorTarget::HaveBuildTreeRPATH(const std::string& config) const { if (this->Target->GetPropertyAsBool("SKIP_BUILD_RPATH")) diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index e5dbc69..7cb3acd 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -229,6 +229,10 @@ public: cmLinkImplementation const* GetLinkImplementation(const std::string& config) const; + void ComputeLinkImplementationLanguages(const std::string& config, + cmOptionalLinkImplementation& impl + ) const; + bool HaveBuildTreeRPATH(const std::string& config) const; /** Full path with trailing slash to the top-level directory diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 621d1b0..e8a315d 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3706,20 +3706,6 @@ void cmTarget::ComputeLinkImplementationLibraries( } //---------------------------------------------------------------------------- -void cmTarget::ComputeLinkImplementationLanguages( - const std::string& config, - cmOptionalLinkImplementation& impl) const -{ - // This target needs runtime libraries for its source languages. - std::set languages; - // Get languages used in our source files. - this->GetLanguages(languages, config); - // Copy the set of langauges to the link implementation. - impl.Languages.insert(impl.Languages.begin(), - languages.begin(), languages.end()); -} - -//---------------------------------------------------------------------------- cmTarget const* cmTarget::FindTargetToLink(std::string const& name) const { cmTarget const* tgt = this->Makefile->FindTargetToUse(name); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 8866e65..1db4ba1 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -237,9 +237,6 @@ public: void ComputeLinkImplementationLibraries(const std::string& config, cmOptionalLinkImplementation& impl, cmTarget const* head) const; - void ComputeLinkImplementationLanguages(const std::string& config, - cmOptionalLinkImplementation& impl - ) const; cmOptionalLinkImplementation& GetLinkImplMap(std::string const& config) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e585982cbb2910be05cd2a50aec455fc6f6528d2 commit e585982cbb2910be05cd2a50aec455fc6f6528d2 Author: Stephen Kelly AuthorDate: Wed Aug 5 17:37:49 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 23:44:15 2015 +0200 cmGeneratorTarget: Move HaveBuildTreeRPath from cmTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 6ba0eed..192ad5f 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -1925,7 +1925,7 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, (outputRuntime && this->Target->Target->HaveInstallTreeRPATH() && linking_for_install); bool use_build_rpath = - (outputRuntime && this->Target->Target->HaveBuildTreeRPATH(this->Config) && + (outputRuntime && this->Target->HaveBuildTreeRPATH(this->Config) && !linking_for_install); bool use_link_rpath = outputRuntime && linking_for_install && diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 5f73162..a4999ce 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -908,7 +908,7 @@ cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const // If either a build or install tree rpath is set then the rpath // will likely change between the build tree and install tree and // this target must be relinked. - return this->Target->HaveBuildTreeRPATH(config) + return this->HaveBuildTreeRPATH(config) || this->Target->HaveInstallTreeRPATH(); } @@ -4395,3 +4395,18 @@ cmGeneratorTarget::GetLinkImplementation(const std::string& config) const } return &impl; } + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::HaveBuildTreeRPATH(const std::string& config) const +{ + if (this->Target->GetPropertyAsBool("SKIP_BUILD_RPATH")) + { + return false; + } + if(cmLinkImplementationLibraries const* impl = + this->Target->GetLinkImplementationLibraries(config)) + { + return !impl->Libraries.empty(); + } + return false; +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 91837db..e5dbc69 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -229,6 +229,8 @@ public: cmLinkImplementation const* GetLinkImplementation(const std::string& config) const; + bool HaveBuildTreeRPATH(const std::string& config) const; + /** Full path with trailing slash to the top-level directory holding object files for this target. Includes the build time config name placeholder if needed for the generator. */ diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 6252ed5..621d1b0 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2811,21 +2811,6 @@ void cmTarget::SetPropertyDefault(const std::string& property, } //---------------------------------------------------------------------------- -bool cmTarget::HaveBuildTreeRPATH(const std::string& config) const -{ - if (this->GetPropertyAsBool("SKIP_BUILD_RPATH")) - { - return false; - } - if(cmLinkImplementationLibraries const* impl = - this->GetLinkImplementationLibraries(config)) - { - return !impl->Libraries.empty(); - } - return false; -} - -//---------------------------------------------------------------------------- bool cmTarget::HaveInstallTreeRPATH() const { const char* install_rpath = this->GetProperty("INSTALL_RPATH"); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 1d353ab..8866e65 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -294,7 +294,6 @@ public: bool GetImplibGNUtoMS(std::string const& gnuName, std::string& out, const char* newExt = 0) const; - bool HaveBuildTreeRPATH(const std::string& config) const; bool HaveInstallTreeRPATH() const; // Get the properties http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=76c351181ab69f57ab741ea869b20e5526dea4cb commit 76c351181ab69f57ab741ea869b20e5526dea4cb Author: Stephen Kelly AuthorDate: Wed Aug 5 17:37:49 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 23:44:15 2015 +0200 cmGeneratorTarget: Move GetLinkImplementation from cmTarget. diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 67790bc..5a5c1c1 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -556,7 +556,7 @@ void cmComputeLinkDepends::AddDirectLinkEntries() { // Add direct link dependencies in this configuration. cmLinkImplementation const* impl = - this->Target->Target->GetLinkImplementation(this->Config); + this->Target->GetLinkImplementation(this->Config); this->AddLinkEntries(-1, impl->Libraries); for(std::vector::const_iterator wi = impl->WrongConfigLibraries.begin(); diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index ec9c61b..7488e09 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -252,8 +252,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) } } - cmLinkImplementation const* impl = - depender->Target->GetLinkImplementation(*it); + cmLinkImplementation const* impl = depender->GetLinkImplementation(*it); // A target should not depend on itself. emitted.insert(depender->GetName()); diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 9449207..5f73162 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1336,7 +1336,7 @@ void cmGeneratorTarget::ComputeLinkClosure(const std::string& config, // Get languages built in this target. UNORDERED_SET languages; cmLinkImplementation const* impl = - this->Target->GetLinkImplementation(config); + this->GetLinkImplementation(config); assert(impl); for(std::vector::const_iterator li = impl->Languages.begin(); li != impl->Languages.end(); ++li) @@ -4295,7 +4295,7 @@ void cmGeneratorTarget::ComputeLinkInterface(const std::string& config, if (this->GetType() != cmTarget::INTERFACE_LIBRARY) { cmLinkImplementation const* impl = - this->Target->GetLinkImplementation(config); + this->GetLinkImplementation(config); for(std::vector::const_iterator li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li) { @@ -4336,7 +4336,7 @@ void cmGeneratorTarget::ComputeLinkInterface(const std::string& config, { // Targets using this archive need its language runtime libraries. if(cmLinkImplementation const* impl = - this->Target->GetLinkImplementation(config)) + this->GetLinkImplementation(config)) { iface.Languages = impl->Languages; } @@ -4370,3 +4370,28 @@ void cmGeneratorTarget::ComputeLinkInterface(const std::string& config, } } } + +//---------------------------------------------------------------------------- +const cmLinkImplementation * +cmGeneratorTarget::GetLinkImplementation(const std::string& config) const +{ + // There is no link implementation for imported targets. + if(this->Target->IsImported()) + { + return 0; + } + + cmOptionalLinkImplementation& impl = this->Target->GetLinkImplMap(config); + if(!impl.LibrariesDone) + { + impl.LibrariesDone = true; + this->Target->ComputeLinkImplementationLibraries(config, impl, + this->Target); + } + if(!impl.LanguagesDone) + { + impl.LanguagesDone = true; + this->Target->ComputeLinkImplementationLanguages(config, impl); + } + return &impl; +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 9456bb1..91837db 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -226,6 +226,9 @@ public: LinkClosure const* GetLinkClosure(const std::string& config) const; void ComputeLinkClosure(const std::string& config, LinkClosure& lc) const; + cmLinkImplementation const* + GetLinkImplementation(const std::string& config) const; + /** Full path with trailing slash to the top-level directory holding object files for this target. Includes the build time config name placeholder if needed for the generator. */ diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index f78a8a1..68fd06b 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1384,7 +1384,7 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmTarget& cmtarget) // If the language is compiled as a source trust Xcode to link with it. cmLinkImplementation const* impl = - cmtarget.GetLinkImplementation("NOCONFIG"); + gtgt->GetLinkImplementation("NOCONFIG"); for(std::vector::const_iterator li = impl->Languages.begin(); li != impl->Languages.end(); ++li) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index a14e1c2..6252ed5 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3565,30 +3565,6 @@ void cmTargetInternals::AddInterfaceEntries( } } -//---------------------------------------------------------------------------- -const cmLinkImplementation * -cmTarget::GetLinkImplementation(const std::string& config) const -{ - // There is no link implementation for imported targets. - if(this->IsImported()) - { - return 0; - } - - cmOptionalLinkImplementation& impl = this->GetLinkImplMap(config); - if(!impl.LibrariesDone) - { - impl.LibrariesDone = true; - this->ComputeLinkImplementationLibraries(config, impl, this); - } - if(!impl.LanguagesDone) - { - impl.LanguagesDone = true; - this->ComputeLinkImplementationLanguages(config, impl); - } - return &impl; -} - cmOptionalLinkImplementation& cmTarget::GetLinkImplMap(std::string const& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 6411d12..1d353ab 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -231,9 +231,6 @@ public: void GetObjectLibrariesCMP0026(std::vector& objlibs) const; - cmLinkImplementation const* - GetLinkImplementation(const std::string& config) const; - cmLinkImplementationLibraries const* GetLinkImplementationLibraries(const std::string& config) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ef4fdfd49a02952ca5b2e347f0c041fbf3ae48a1 commit ef4fdfd49a02952ca5b2e347f0c041fbf3ae48a1 Author: Stephen Kelly AuthorDate: Wed Aug 5 17:37:49 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 23:44:14 2015 +0200 cmTarget: Add GetLinkImplMap method. This is a temporary refactoring artifact. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 18d1220..a14e1c2 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3575,10 +3575,7 @@ cmTarget::GetLinkImplementation(const std::string& config) const return 0; } - // Populate the link implementation for this configuration. - std::string CONFIG = cmSystemTools::UpperCase(config); - cmOptionalLinkImplementation& - impl = this->Internal->LinkImplMap[CONFIG][this]; + cmOptionalLinkImplementation& impl = this->GetLinkImplMap(config); if(!impl.LibrariesDone) { impl.LibrariesDone = true; @@ -3592,6 +3589,14 @@ cmTarget::GetLinkImplementation(const std::string& config) const return &impl; } +cmOptionalLinkImplementation& +cmTarget::GetLinkImplMap(std::string const& config) const +{ + // Populate the link implementation for this configuration. + std::string CONFIG = cmSystemTools::UpperCase(config); + return Internal->LinkImplMap[CONFIG][this]; +} + //---------------------------------------------------------------------------- cmLinkImplementationLibraries const* cmTarget::GetLinkImplementationLibraries(const std::string& config) const diff --git a/Source/cmTarget.h b/Source/cmTarget.h index d49b23e..6411d12 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -244,6 +244,9 @@ public: cmOptionalLinkImplementation& impl ) const; + cmOptionalLinkImplementation& + GetLinkImplMap(std::string const& config) const; + cmTarget const* FindTargetToLink(std::string const& name) const; /** Strip off leading and trailing whitespace from an item named in http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ef9431a968e2ef77159a1ac1c8fa931c8a179eb2 commit ef9431a968e2ef77159a1ac1c8fa931c8a179eb2 Author: Stephen Kelly AuthorDate: Wed Aug 5 17:37:48 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 23:44:14 2015 +0200 cmLinkItem: Add cmOptionalLinkImplementation type. Move the associated Compute* methods to the cmTarget class. diff --git a/Source/cmLinkItem.h b/Source/cmLinkItem.h index accc83c..f1d914f 100644 --- a/Source/cmLinkItem.h +++ b/Source/cmLinkItem.h @@ -62,4 +62,15 @@ struct cmLinkImplementation: public cmLinkImplementationLibraries std::vector Languages; }; +// Cache link implementation computation from each configuration. +struct cmOptionalLinkImplementation: public cmLinkImplementation +{ + cmOptionalLinkImplementation(): + LibrariesDone(false), LanguagesDone(false), + HadHeadSensitiveCondition(false) {} + bool LibrariesDone; + bool LanguagesDone; + bool HadHeadSensitiveCondition; +}; + #endif diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e6408c4..18d1220 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -96,27 +96,8 @@ public: typedef std::map ImportInfoMapType; ImportInfoMapType ImportInfoMap; - // Cache link implementation computation from each configuration. - struct OptionalLinkImplementation: public cmLinkImplementation - { - OptionalLinkImplementation(): - LibrariesDone(false), LanguagesDone(false), - HadHeadSensitiveCondition(false) {} - bool LibrariesDone; - bool LanguagesDone; - bool HadHeadSensitiveCondition; - }; - void ComputeLinkImplementationLibraries(cmTarget const* thisTarget, - const std::string& config, - OptionalLinkImplementation& impl, - cmTarget const* head) const; - void ComputeLinkImplementationLanguages(cmTarget const* thisTarget, - const std::string& config, - OptionalLinkImplementation& impl - ) const; - struct HeadToLinkImplementationMap: - public std::map {}; + public std::map {}; typedef std::map LinkImplMapType; LinkImplMapType LinkImplMap; @@ -3596,18 +3577,17 @@ cmTarget::GetLinkImplementation(const std::string& config) const // Populate the link implementation for this configuration. std::string CONFIG = cmSystemTools::UpperCase(config); - cmTargetInternals::OptionalLinkImplementation& + cmOptionalLinkImplementation& impl = this->Internal->LinkImplMap[CONFIG][this]; if(!impl.LibrariesDone) { impl.LibrariesDone = true; - this->Internal - ->ComputeLinkImplementationLibraries(this, config, impl, this); + this->ComputeLinkImplementationLibraries(config, impl, this); } if(!impl.LanguagesDone) { impl.LanguagesDone = true; - this->Internal->ComputeLinkImplementationLanguages(this, config, impl); + this->ComputeLinkImplementationLanguages(config, impl); } return &impl; } @@ -3642,39 +3622,36 @@ cmTarget::GetLinkImplementationLibrariesInternal(const std::string& config, return &hm.begin()->second; } - cmTargetInternals::OptionalLinkImplementation& impl = hm[head]; + cmOptionalLinkImplementation& impl = hm[head]; if(!impl.LibrariesDone) { impl.LibrariesDone = true; - this->Internal - ->ComputeLinkImplementationLibraries(this, config, impl, head); + this->ComputeLinkImplementationLibraries(config, impl, head); } return &impl; } //---------------------------------------------------------------------------- -void -cmTargetInternals::ComputeLinkImplementationLibraries( - cmTarget const* thisTarget, +void cmTarget::ComputeLinkImplementationLibraries( const std::string& config, - OptionalLinkImplementation& impl, + cmOptionalLinkImplementation& impl, cmTarget const* head) const { // Collect libraries directly linked in this configuration. for (std::vector::const_iterator - le = this->LinkImplementationPropertyEntries.begin(), - end = this->LinkImplementationPropertyEntries.end(); + le = this->Internal->LinkImplementationPropertyEntries.begin(), + end = this->Internal->LinkImplementationPropertyEntries.end(); le != end; ++le) { std::vector llibs; cmGeneratorExpressionDAGChecker dagChecker( - thisTarget->GetName(), + this->GetName(), "LINK_LIBRARIES", 0, 0); cmGeneratorExpression ge(le->Backtrace); cmsys::auto_ptr const cge = ge.Parse(le->Value); std::string const evaluated = - cge->Evaluate(thisTarget->Makefile, config, false, head, &dagChecker); + cge->Evaluate(this->Makefile, config, false, head, &dagChecker); cmSystemTools::ExpandListArgument(evaluated, llibs); if(cge->GetHadHeadSensitiveCondition()) { @@ -3685,15 +3662,15 @@ cmTargetInternals::ComputeLinkImplementationLibraries( li != llibs.end(); ++li) { // Skip entries that resolve to the target itself or are empty. - std::string name = thisTarget->CheckCMP0004(*li); - if(name == thisTarget->GetName() || name.empty()) + std::string name = this->CheckCMP0004(*li); + if(name == this->GetName() || name.empty()) { - if(name == thisTarget->GetName()) + if(name == this->GetName()) { bool noMessage = false; cmake::MessageType messageType = cmake::FATAL_ERROR; std::ostringstream e; - switch(thisTarget->GetPolicyStatusCMP0038()) + switch(this->GetPolicyStatusCMP0038()) { case cmPolicies::WARN: { @@ -3712,9 +3689,9 @@ cmTargetInternals::ComputeLinkImplementationLibraries( if(!noMessage) { - e << "Target \"" << thisTarget->GetName() << "\" links to itself."; - thisTarget->Makefile->GetCMakeInstance()->IssueMessage( - messageType, e.str(), thisTarget->GetBacktrace()); + e << "Target \"" << this->GetName() << "\" links to itself."; + this->Makefile->GetCMakeInstance()->IssueMessage( + messageType, e.str(), this->GetBacktrace()); if (messageType == cmake::FATAL_ERROR) { return; @@ -3726,7 +3703,7 @@ cmTargetInternals::ComputeLinkImplementationLibraries( // The entry is meant for this configuration. impl.Libraries.push_back( - cmLinkImplItem(name, thisTarget->FindTargetToLink(name), + cmLinkImplItem(name, this->FindTargetToLink(name), le->Backtrace, evaluated != le->Value)); } @@ -3734,45 +3711,43 @@ cmTargetInternals::ComputeLinkImplementationLibraries( for (std::set::const_iterator it = seenProps.begin(); it != seenProps.end(); ++it) { - if (!thisTarget->GetProperty(*it)) + if (!this->GetProperty(*it)) { - thisTarget->LinkImplicitNullProperties.insert(*it); + this->LinkImplicitNullProperties.insert(*it); } } - cge->GetMaxLanguageStandard(thisTarget, thisTarget->MaxLanguageStandards); + cge->GetMaxLanguageStandard(this, this->MaxLanguageStandards); } - cmTarget::LinkLibraryType linkType = thisTarget->ComputeLinkType(config); + cmTarget::LinkLibraryType linkType = this->ComputeLinkType(config); cmTarget::LinkLibraryVectorType const& oldllibs = - thisTarget->GetOriginalLinkLibraries(); + this->GetOriginalLinkLibraries(); for(cmTarget::LinkLibraryVectorType::const_iterator li = oldllibs.begin(); li != oldllibs.end(); ++li) { if(li->second != cmTarget::GENERAL && li->second != linkType) { - std::string name = thisTarget->CheckCMP0004(li->first); - if(name == thisTarget->GetName() || name.empty()) + std::string name = this->CheckCMP0004(li->first); + if(name == this->GetName() || name.empty()) { continue; } // Support OLD behavior for CMP0003. impl.WrongConfigLibraries.push_back( - cmLinkItem(name, thisTarget->FindTargetToLink(name))); + cmLinkItem(name, this->FindTargetToLink(name))); } } } //---------------------------------------------------------------------------- -void -cmTargetInternals::ComputeLinkImplementationLanguages( - cmTarget const* thisTarget, +void cmTarget::ComputeLinkImplementationLanguages( const std::string& config, - OptionalLinkImplementation& impl) const + cmOptionalLinkImplementation& impl) const { // This target needs runtime libraries for its source languages. std::set languages; // Get languages used in our source files. - thisTarget->GetLanguages(languages, config); + this->GetLanguages(languages, config); // Copy the set of langauges to the link implementation. impl.Languages.insert(impl.Languages.begin(), languages.begin(), languages.end()); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 19cc220..d49b23e 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -237,6 +237,13 @@ public: cmLinkImplementationLibraries const* GetLinkImplementationLibraries(const std::string& config) const; + void ComputeLinkImplementationLibraries(const std::string& config, + cmOptionalLinkImplementation& impl, + cmTarget const* head) const; + void ComputeLinkImplementationLanguages(const std::string& config, + cmOptionalLinkImplementation& impl + ) const; + cmTarget const* FindTargetToLink(std::string const& name) const; /** Strip off leading and trailing whitespace from an item named in http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d09514361491425ce25c27518167a2ce78c568c8 commit d09514361491425ce25c27518167a2ce78c568c8 Author: Stephen Kelly AuthorDate: Wed Aug 5 17:37:48 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 23:44:14 2015 +0200 cmLinkItem: Add cmLinkImplementation type. diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 2e5331d..67790bc 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -555,7 +555,7 @@ void cmComputeLinkDepends::AddVarLinkEntries(int depender_index, void cmComputeLinkDepends::AddDirectLinkEntries() { // Add direct link dependencies in this configuration. - cmTarget::LinkImplementation const* impl = + cmLinkImplementation const* impl = this->Target->Target->GetLinkImplementation(this->Config); this->AddLinkEntries(-1, impl->Libraries); for(std::vector::const_iterator diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index fd4b567..ec9c61b 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -252,7 +252,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) } } - cmTarget::LinkImplementation const* impl = + cmLinkImplementation const* impl = depender->Target->GetLinkImplementation(*it); // A target should not depend on itself. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 4f1a54b..9449207 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1335,7 +1335,7 @@ void cmGeneratorTarget::ComputeLinkClosure(const std::string& config, { // Get languages built in this target. UNORDERED_SET languages; - cmTarget::LinkImplementation const* impl = + cmLinkImplementation const* impl = this->Target->GetLinkImplementation(config); assert(impl); for(std::vector::const_iterator li = impl->Languages.begin(); @@ -4294,7 +4294,7 @@ void cmGeneratorTarget::ComputeLinkInterface(const std::string& config, } if (this->GetType() != cmTarget::INTERFACE_LIBRARY) { - cmTarget::LinkImplementation const* impl = + cmLinkImplementation const* impl = this->Target->GetLinkImplementation(config); for(std::vector::const_iterator li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li) @@ -4335,7 +4335,7 @@ void cmGeneratorTarget::ComputeLinkInterface(const std::string& config, if(this->Target->LinkLanguagePropagatesToDependents()) { // Targets using this archive need its language runtime libraries. - if(cmTarget::LinkImplementation const* impl = + if(cmLinkImplementation const* impl = this->Target->GetLinkImplementation(config)) { iface.Languages = impl->Languages; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 87c61dd..f78a8a1 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1383,7 +1383,7 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmTarget& cmtarget) if(llang.empty()) { return; } // If the language is compiled as a source trust Xcode to link with it. - cmTarget::LinkImplementation const* impl = + cmLinkImplementation const* impl = cmtarget.GetLinkImplementation("NOCONFIG"); for(std::vector::const_iterator li = impl->Languages.begin(); li != impl->Languages.end(); ++li) diff --git a/Source/cmLinkItem.h b/Source/cmLinkItem.h index a5427de..accc83c 100644 --- a/Source/cmLinkItem.h +++ b/Source/cmLinkItem.h @@ -56,4 +56,10 @@ struct cmLinkImplementationLibraries std::vector WrongConfigLibraries; }; +struct cmLinkImplementation: public cmLinkImplementationLibraries +{ + // Languages whose runtime libraries must be linked. + std::vector Languages; +}; + #endif diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index d1b7755..e6408c4 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -97,7 +97,7 @@ public: ImportInfoMapType ImportInfoMap; // Cache link implementation computation from each configuration. - struct OptionalLinkImplementation: public cmTarget::LinkImplementation + struct OptionalLinkImplementation: public cmLinkImplementation { OptionalLinkImplementation(): LibrariesDone(false), LanguagesDone(false), @@ -3585,7 +3585,7 @@ void cmTargetInternals::AddInterfaceEntries( } //---------------------------------------------------------------------------- -cmTarget::LinkImplementation const* +const cmLinkImplementation * cmTarget::GetLinkImplementation(const std::string& config) const { // There is no link implementation for imported targets. diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 34a75ea..19cc220 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -231,12 +231,7 @@ public: void GetObjectLibrariesCMP0026(std::vector& objlibs) const; - struct LinkImplementation: public cmLinkImplementationLibraries - { - // Languages whose runtime libraries must be linked. - std::vector Languages; - }; - LinkImplementation const* + cmLinkImplementation const* GetLinkImplementation(const std::string& config) const; cmLinkImplementationLibraries const* http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=784e1d001a151d17884b124cc12e5a9ef9878477 commit 784e1d001a151d17884b124cc12e5a9ef9878477 Author: Stephen Kelly AuthorDate: Wed Aug 5 00:00:53 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 23:44:14 2015 +0200 cmGeneratorTarget: Move compile defintions processing from cmTarget. diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 933a256..dfd51c7 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -609,7 +609,7 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, // the compilerdefines for this target std::vector cdefs; - target->GetCompileDefinitions(cdefs, buildType, "C"); + gtgt->GetCompileDefinitions(cdefs, buildType, "C"); // Expand the list. for(std::vector::const_iterator di = cdefs.begin(); diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 393ade9..4f1a54b 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -262,7 +262,8 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) SourceFileFlagsConstructed(false), DebugIncludesDone(false), DebugCompileOptionsDone(false), - DebugCompileFeaturesDone(false) + DebugCompileFeaturesDone(false), + DebugCompileDefinitionsDone(false) { this->Makefile = this->Target->GetMakefile(); this->LocalGenerator = lg; @@ -282,6 +283,11 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) t->GetCompileFeaturesEntries(), t->GetCompileFeaturesBacktraces(), this->CompileFeaturesEntries); + + CreatePropertyGeneratorExpressions( + t->GetCompileDefinitionsEntries(), + t->GetCompileDefinitionsBacktraces(), + this->CompileDefinitionsEntries); } cmGeneratorTarget::~cmGeneratorTarget() @@ -289,6 +295,7 @@ cmGeneratorTarget::~cmGeneratorTarget() cmDeleteAll(this->IncludeDirectoriesEntries); cmDeleteAll(this->CompileOptionsEntries); cmDeleteAll(this->CompileFeaturesEntries); + cmDeleteAll(this->CompileDefinitionsEntries); cmDeleteAll(this->LinkInformation); this->LinkInformation.clear(); } @@ -2445,6 +2452,108 @@ void cmGeneratorTarget::GetCompileFeatures(std::vector &result, } //---------------------------------------------------------------------------- +static void processCompileDefinitions(cmGeneratorTarget const* tgt, + const std::vector &entries, + std::vector &options, + UNORDERED_SET &uniqueOptions, + cmGeneratorExpressionDAGChecker *dagChecker, + const std::string& config, bool debugOptions, + std::string const& language) +{ + processCompileOptionsInternal(tgt, entries, options, uniqueOptions, + dagChecker, config, debugOptions, + "definitions", language); +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GetCompileDefinitions(std::vector &list, + const std::string& config, + const std::string& language) const +{ + UNORDERED_SET uniqueOptions; + + cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), + "COMPILE_DEFINITIONS", 0, 0); + + std::vector debugProperties; + const char *debugProp = + this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); + if (debugProp) + { + cmSystemTools::ExpandListArgument(debugProp, debugProperties); + } + + bool debugDefines = !this->DebugCompileDefinitionsDone + && std::find(debugProperties.begin(), + debugProperties.end(), + "COMPILE_DEFINITIONS") + != debugProperties.end(); + + if (this->Makefile->IsConfigured()) + { + this->DebugCompileDefinitionsDone = true; + } + + processCompileDefinitions(this, + this->CompileDefinitionsEntries, + list, + uniqueOptions, + &dagChecker, + config, + debugDefines, + language); + + std::vector + linkInterfaceCompileDefinitionsEntries; + AddInterfaceEntries( + this, config, "INTERFACE_COMPILE_DEFINITIONS", + linkInterfaceCompileDefinitionsEntries); + if (!config.empty()) + { + std::string configPropName = "COMPILE_DEFINITIONS_" + + cmSystemTools::UpperCase(config); + const char *configProp = this->Target->GetProperty(configPropName); + if (configProp) + { + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0043)) + { + case cmPolicies::WARN: + { + std::ostringstream e; + e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0043); + this->LocalGenerator->IssueMessage(cmake::AUTHOR_WARNING, + e.str()); + } + case cmPolicies::OLD: + { + cmGeneratorExpression ge; + cmsys::auto_ptr cge = + ge.Parse(configProp); + linkInterfaceCompileDefinitionsEntries + .push_back(new cmGeneratorTarget::TargetPropertyEntry(cge)); + } + break; + case cmPolicies::NEW: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::REQUIRED_IF_USED: + break; + } + } + } + + processCompileDefinitions(this, + linkInterfaceCompileDefinitionsEntries, + list, + uniqueOptions, + &dagChecker, + config, + debugDefines, + language); + + cmDeleteAll(linkInterfaceCompileDefinitionsEntries); +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GenerateTargetManifest( const std::string& config) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index e57485f..9456bb1 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -252,6 +252,10 @@ public: void GetCompileFeatures(std::vector &features, const std::string& config) const; + void GetCompileDefinitions(std::vector &result, + const std::string& config, + const std::string& language) const; + bool IsSystemIncludeDirectory(const std::string& dir, const std::string& config) const; @@ -459,10 +463,12 @@ private: mutable bool DebugIncludesDone; mutable bool DebugCompileOptionsDone; mutable bool DebugCompileFeaturesDone; + mutable bool DebugCompileDefinitionsDone; std::vector IncludeDirectoriesEntries; std::vector CompileOptionsEntries; std::vector CompileFeaturesEntries; + std::vector CompileDefinitionsEntries; void ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, cmTarget const* headTarget, diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index 790e68b..846b6e2 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -330,7 +330,8 @@ void cmGhsMultiTargetGenerator::WriteCompilerDefinitions( const std::string &config, const std::string &language) { std::vector compileDefinitions; - this->Target->GetCompileDefinitions(compileDefinitions, config, language); + this->GeneratorTarget->GetCompileDefinitions(compileDefinitions, + config, language); for (std::vector::const_iterator cdI = compileDefinitions.begin(); cdI != compileDefinitions.end(); ++cdI) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 503c455..c0f1817 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1550,7 +1550,6 @@ void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes, ti != targets.end(); ++ti) { cmTarget* t = &ti->second; - t->Compute(); cmGeneratorTarget* gt = new cmGeneratorTarget(t, lg); this->GeneratorTargets[t] = gt; generatorTargets[t] = gt; diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 51dcab0..28f0425 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -254,7 +254,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() mf->AddUtilityCommand(CMAKE_CHECK_BUILD_SYSTEM_TARGET, false, no_working_directory, no_depends, noCommandLines); - tgt->Compute(); + cmGeneratorTarget* gt = new cmGeneratorTarget(tgt, lg); mf->AddGeneratorTarget(tgt, gt); diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index b0aa243..634366e 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -90,7 +90,7 @@ bool cmGlobalVisualStudioGenerator::Compute() AddUtilityCommand("ALL_BUILD", true, no_working_dir, no_depends, no_commands, false, "Build all projects"); - allBuild->Compute(); + cmGeneratorTarget* gt = new cmGeneratorTarget(allBuild, gen[0]); allBuild->GetMakefile()->AddGeneratorTarget(allBuild, gt); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 4ba29f5..87c61dd 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -463,7 +463,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, cmTarget* allbuild = mf->AddUtilityCommand("ALL_BUILD", true, no_depends, no_working_directory, "echo", "Build all projects"); - allbuild->Compute(); + cmGeneratorTarget* allBuildGt = new cmGeneratorTarget(allbuild, root); mf->AddGeneratorTarget(allbuild, allBuildGt); @@ -498,7 +498,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, true, no_depends, no_working_directory, "make", "-f", file.c_str()); - check->Compute(); + cmGeneratorTarget* checkGt = new cmGeneratorTarget(check, root); mf->AddGeneratorTarget(check, checkGt); } @@ -1855,7 +1855,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, this->AppendDefines(ppDefs, exportMacro); } std::vector targetDefines; - target.GetCompileDefinitions(targetDefines, configName, "C"); + gtgt->GetCompileDefinitions(targetDefines, configName, "C"); this->AppendDefines(ppDefs, targetDefines); buildSettings->AddAttribute ("GCC_PREPROCESSOR_DEFINITIONS", ppDefs.CreateList()); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index a7e4191..c1cc241 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1083,7 +1083,8 @@ void cmLocalGenerator::AddCompileDefinitions(std::set& defines, const std::string& lang) { std::vector targetDefines; - target->GetCompileDefinitions(targetDefines, config, lang); + cmGeneratorTarget* gtgt = this->GlobalGenerator->GetGeneratorTarget(target); + gtgt->GetCompileDefinitions(targetDefines, config, lang); this->AppendDefines(defines, targetDefines); } diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 5de6d37..f17c9a4 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -763,7 +763,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, targetOptions.Parse(defineFlags.c_str()); targetOptions.ParseFinish(); std::vector targetDefines; - target.GetCompileDefinitions(targetDefines, configName, "CXX"); + gt->GetCompileDefinitions(targetDefines, configName, "CXX"); targetOptions.AddDefines(targetDefines); targetOptions.SetVerboseMakefile( this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE")); diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index f85e70e..c58e7e4 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -474,8 +474,6 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg, /*byproducts=*/rcc_output, depends, commandLines, false, autogenComment.c_str()); - autogenTarget->Compute(); - cmGeneratorTarget* gt = new cmGeneratorTarget(autogenTarget, lg); makefile->AddGeneratorTarget(autogenTarget, gt); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 7a23e9d..d1b7755 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -146,7 +146,6 @@ public: std::vector CompileFeaturesBacktraces; std::vector CompileDefinitionsEntries; std::vector CompileDefinitionsBacktraces; - std::vector CompileDefinitionsItems; std::vector SourceEntries; std::vector LinkImplementationPropertyEntries; @@ -175,7 +174,6 @@ cmTarget::cmTarget() this->IsApple = false; this->IsImportedTarget = false; this->BuildInterfaceIncludesAppended = false; - this->DebugCompileDefinitionsDone = false; this->DebugSourcesDone = false; this->LinkImplementationLanguageIsContextDependent = true; } @@ -418,14 +416,6 @@ void CreatePropertyGeneratorExpressions( } } -void cmTarget::Compute() -{ - CreatePropertyGeneratorExpressions( - this->Internal->CompileDefinitionsEntries, - this->Internal->CompileDefinitionsBacktraces, - this->Internal->CompileDefinitionsItems); -} - //---------------------------------------------------------------------------- void cmTarget::AddUtility(const std::string& u, cmMakefile *makefile) { @@ -1329,6 +1319,16 @@ cmBacktraceRange cmTarget::GetCompileFeaturesBacktraces() const return cmMakeRange(this->Internal->CompileFeaturesBacktraces); } +cmStringRange cmTarget::GetCompileDefinitionsEntries() const +{ + return cmMakeRange(this->Internal->CompileDefinitionsEntries); +} + +cmBacktraceRange cmTarget::GetCompileDefinitionsBacktraces() const +{ + return cmMakeRange(this->Internal->CompileDefinitionsBacktraces); +} + #if defined(_WIN32) && !defined(__CYGWIN__) //---------------------------------------------------------------------------- void @@ -1926,156 +1926,6 @@ void cmTarget::InsertCompileDefinition(std::string const& entry, } //---------------------------------------------------------------------------- -static void processCompileOptionsInternal(cmTarget const* tgt, - const std::vector &entries, - std::vector &options, - UNORDERED_SET &uniqueOptions, - cmGeneratorExpressionDAGChecker *dagChecker, - const std::string& config, bool debugOptions, const char *logName, - std::string const& language) -{ - cmMakefile *mf = tgt->GetMakefile(); - - for (std::vector::const_iterator - it = entries.begin(), end = entries.end(); it != end; ++it) - { - std::vector entryOptions; - cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf, - config, - false, - tgt, - dagChecker, - language), - entryOptions); - std::string usedOptions; - for(std::vector::iterator - li = entryOptions.begin(); li != entryOptions.end(); ++li) - { - std::string const& opt = *li; - - if(uniqueOptions.insert(opt).second) - { - options.push_back(opt); - if (debugOptions) - { - usedOptions += " * " + opt + "\n"; - } - } - } - if (!usedOptions.empty()) - { - mf->GetCMakeInstance()->IssueMessage(cmake::LOG, - std::string("Used compile ") + logName - + std::string(" for target ") - + tgt->GetName() + ":\n" - + usedOptions, (*it)->ge->GetBacktrace()); - } - } -} - -//---------------------------------------------------------------------------- -static void processCompileDefinitions(cmTarget const* tgt, - const std::vector &entries, - std::vector &options, - UNORDERED_SET &uniqueOptions, - cmGeneratorExpressionDAGChecker *dagChecker, - const std::string& config, bool debugOptions, - std::string const& language) -{ - processCompileOptionsInternal(tgt, entries, options, uniqueOptions, - dagChecker, config, debugOptions, - "definitions", language); -} - -//---------------------------------------------------------------------------- -void cmTarget::GetCompileDefinitions(std::vector &list, - const std::string& config, - const std::string& language) const -{ - UNORDERED_SET uniqueOptions; - - cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), - "COMPILE_DEFINITIONS", 0, 0); - - std::vector debugProperties; - const char *debugProp = - this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); - if (debugProp) - { - cmSystemTools::ExpandListArgument(debugProp, debugProperties); - } - - bool debugDefines = !this->DebugCompileDefinitionsDone - && std::find(debugProperties.begin(), - debugProperties.end(), - "COMPILE_DEFINITIONS") - != debugProperties.end(); - - if (this->Makefile->IsConfigured()) - { - this->DebugCompileDefinitionsDone = true; - } - - processCompileDefinitions(this, - this->Internal->CompileDefinitionsItems, - list, - uniqueOptions, - &dagChecker, - config, - debugDefines, - language); - - std::vector - linkInterfaceCompileDefinitionsEntries; - this->Internal->AddInterfaceEntries( - this, config, "INTERFACE_COMPILE_DEFINITIONS", - linkInterfaceCompileDefinitionsEntries); - if (!config.empty()) - { - std::string configPropName = "COMPILE_DEFINITIONS_" - + cmSystemTools::UpperCase(config); - const char *configProp = this->GetProperty(configPropName); - if (configProp) - { - switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0043)) - { - case cmPolicies::WARN: - { - std::ostringstream e; - e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0043); - this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, - e.str()); - } - case cmPolicies::OLD: - { - cmGeneratorExpression ge; - cmsys::auto_ptr cge = - ge.Parse(configProp); - linkInterfaceCompileDefinitionsEntries - .push_back(new cmTargetInternals::TargetPropertyEntry(cge)); - } - break; - case cmPolicies::NEW: - case cmPolicies::REQUIRED_ALWAYS: - case cmPolicies::REQUIRED_IF_USED: - break; - } - } - } - - processCompileDefinitions(this, - linkInterfaceCompileDefinitionsEntries, - list, - uniqueOptions, - &dagChecker, - config, - debugDefines, - language); - - cmDeleteAll(linkInterfaceCompileDefinitionsEntries); -} - -//---------------------------------------------------------------------------- void cmTarget::MaybeInvalidatePropertyCache(const std::string& prop) { // Wipe out maps caching information affected by this property. @@ -4035,7 +3885,6 @@ cmTargetInternalPointer //---------------------------------------------------------------------------- cmTargetInternalPointer::~cmTargetInternalPointer() { - cmDeleteAll(this->Pointer->CompileDefinitionsItems); cmDeleteAll(this->Pointer->SourceEntries); delete this->Pointer; } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index aae558e..34a75ea 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -132,8 +132,6 @@ public: void AddPostBuildCommand(cmCustomCommand const &cmd) {this->PostBuildCommands.push_back(cmd);} - void Compute(); - /** * Get the list of the source files used by this target */ @@ -309,10 +307,6 @@ public: If no macro should be defined null is returned. */ const char* GetExportMacro() const; - void GetCompileDefinitions(std::vector &result, - const std::string& config, - const std::string& language) const; - // Compute the set of languages compiled by the target. This is // computed every time it is called because the languages can change // when source file properties are changed and we do not have enough @@ -402,6 +396,9 @@ public: cmStringRange GetCompileFeaturesEntries() const; cmBacktraceRange GetCompileFeaturesBacktraces() const; + cmStringRange GetCompileDefinitionsEntries() const; + cmBacktraceRange GetCompileDefinitionsBacktraces() const; + #if defined(_WIN32) && !defined(__CYGWIN__) const LinkLibraryVectorType &GetLinkLibrariesForVS6() const { return this->LinkLibrariesForVS6;} @@ -516,7 +513,6 @@ private: bool IsApple; bool IsImportedTarget; bool BuildInterfaceIncludesAppended; - mutable bool DebugCompileDefinitionsDone; mutable bool DebugSourcesDone; mutable bool LinkImplementationLanguageIsContextDependent; #if defined(_WIN32) && !defined(__CYGWIN__) diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 823b550..464a83a 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1934,7 +1934,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( clOptions.Parse(flags.c_str()); clOptions.Parse(defineFlags.c_str()); std::vector targetDefines; - this->Target->GetCompileDefinitions(targetDefines, + this->GeneratorTarget->GetCompileDefinitions(targetDefines, configName.c_str(), "CXX"); clOptions.AddDefines(targetDefines); if(this->MSTools) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0ff2e1ea2a7b70ee828f3738df884378917f261e commit 0ff2e1ea2a7b70ee828f3738df884378917f261e Author: Stephen Kelly AuthorDate: Tue Aug 4 23:48:58 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 23:43:52 2015 +0200 cmGeneratorTarget: Move compile features processing from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index a56d95d..393ade9 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -261,7 +261,8 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) : Target(t), SourceFileFlagsConstructed(false), DebugIncludesDone(false), - DebugCompileOptionsDone(false) + DebugCompileOptionsDone(false), + DebugCompileFeaturesDone(false) { this->Makefile = this->Target->GetMakefile(); this->LocalGenerator = lg; @@ -276,12 +277,18 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) t->GetCompileOptionsEntries(), t->GetCompileOptionsBacktraces(), this->CompileOptionsEntries); + + CreatePropertyGeneratorExpressions( + t->GetCompileFeaturesEntries(), + t->GetCompileFeaturesBacktraces(), + this->CompileFeaturesEntries); } cmGeneratorTarget::~cmGeneratorTarget() { cmDeleteAll(this->IncludeDirectoriesEntries); cmDeleteAll(this->CompileOptionsEntries); + cmDeleteAll(this->CompileFeaturesEntries); cmDeleteAll(this->LinkInformation); this->LinkInformation.clear(); } @@ -2371,6 +2378,73 @@ void cmGeneratorTarget::GetCompileOptions(std::vector &result, } //---------------------------------------------------------------------------- +static void processCompileFeatures(cmGeneratorTarget const* tgt, + const std::vector &entries, + std::vector &options, + UNORDERED_SET &uniqueOptions, + cmGeneratorExpressionDAGChecker *dagChecker, + const std::string& config, bool debugOptions) +{ + processCompileOptionsInternal(tgt, entries, options, uniqueOptions, + dagChecker, config, debugOptions, "features", + std::string()); +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GetCompileFeatures(std::vector &result, + const std::string& config) const +{ + UNORDERED_SET uniqueFeatures; + + cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), + "COMPILE_FEATURES", + 0, 0); + + std::vector debugProperties; + const char *debugProp = + this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); + if (debugProp) + { + cmSystemTools::ExpandListArgument(debugProp, debugProperties); + } + + bool debugFeatures = !this->DebugCompileFeaturesDone + && std::find(debugProperties.begin(), + debugProperties.end(), + "COMPILE_FEATURES") + != debugProperties.end(); + + if (this->Makefile->IsConfigured()) + { + this->DebugCompileFeaturesDone = true; + } + + processCompileFeatures(this, + this->CompileFeaturesEntries, + result, + uniqueFeatures, + &dagChecker, + config, + debugFeatures); + + std::vector + linkInterfaceCompileFeaturesEntries; + AddInterfaceEntries( + this, config, "INTERFACE_COMPILE_FEATURES", + linkInterfaceCompileFeaturesEntries); + + processCompileFeatures(this, + linkInterfaceCompileFeaturesEntries, + result, + uniqueFeatures, + &dagChecker, + config, + debugFeatures); + + cmDeleteAll(linkInterfaceCompileFeaturesEntries); +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GenerateTargetManifest( const std::string& config) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 99dc746..e57485f 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -249,6 +249,9 @@ public: const std::string& config, const std::string& language) const; + void GetCompileFeatures(std::vector &features, + const std::string& config) const; + bool IsSystemIncludeDirectory(const std::string& dir, const std::string& config) const; @@ -455,9 +458,11 @@ private: mutable bool PolicyWarnedCMP0022; mutable bool DebugIncludesDone; mutable bool DebugCompileOptionsDone; + mutable bool DebugCompileFeaturesDone; std::vector IncludeDirectoriesEntries; std::vector CompileOptionsEntries; + std::vector CompileFeaturesEntries; void ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, cmTarget const* headTarget, diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 89515ff..a7e4191 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1138,7 +1138,7 @@ void cmLocalGenerator::AddCompileOptions( } } std::vector features; - target->GetCompileFeatures(features, config); + gtgt->GetCompileFeatures(features, config); for(std::vector::const_iterator it = features.begin(); it != features.end(); ++it) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 466f98a..7a23e9d 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -144,7 +144,6 @@ public: std::vector CompileOptionsBacktraces; std::vector CompileFeaturesEntries; std::vector CompileFeaturesBacktraces; - std::vector CompileFeaturesItems; std::vector CompileDefinitionsEntries; std::vector CompileDefinitionsBacktraces; std::vector CompileDefinitionsItems; @@ -176,7 +175,6 @@ cmTarget::cmTarget() this->IsApple = false; this->IsImportedTarget = false; this->BuildInterfaceIncludesAppended = false; - this->DebugCompileFeaturesDone = false; this->DebugCompileDefinitionsDone = false; this->DebugSourcesDone = false; this->LinkImplementationLanguageIsContextDependent = true; @@ -423,11 +421,6 @@ void CreatePropertyGeneratorExpressions( void cmTarget::Compute() { CreatePropertyGeneratorExpressions( - this->Internal->CompileFeaturesEntries, - this->Internal->CompileFeaturesBacktraces, - this->Internal->CompileFeaturesItems); - - CreatePropertyGeneratorExpressions( this->Internal->CompileDefinitionsEntries, this->Internal->CompileDefinitionsBacktraces, this->Internal->CompileDefinitionsItems); @@ -1326,6 +1319,16 @@ cmBacktraceRange cmTarget::GetCompileOptionsBacktraces() const return cmMakeRange(this->Internal->CompileOptionsBacktraces); } +cmStringRange cmTarget::GetCompileFeaturesEntries() const +{ + return cmMakeRange(this->Internal->CompileFeaturesEntries); +} + +cmBacktraceRange cmTarget::GetCompileFeaturesBacktraces() const +{ + return cmMakeRange(this->Internal->CompileFeaturesBacktraces); +} + #if defined(_WIN32) && !defined(__CYGWIN__) //---------------------------------------------------------------------------- void @@ -2073,73 +2076,6 @@ void cmTarget::GetCompileDefinitions(std::vector &list, } //---------------------------------------------------------------------------- -static void processCompileFeatures(cmTarget const* tgt, - const std::vector &entries, - std::vector &options, - UNORDERED_SET &uniqueOptions, - cmGeneratorExpressionDAGChecker *dagChecker, - const std::string& config, bool debugOptions) -{ - processCompileOptionsInternal(tgt, entries, options, uniqueOptions, - dagChecker, config, debugOptions, "features", - std::string()); -} - -//---------------------------------------------------------------------------- -void cmTarget::GetCompileFeatures(std::vector &result, - const std::string& config) const -{ - UNORDERED_SET uniqueFeatures; - - cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), - "COMPILE_FEATURES", - 0, 0); - - std::vector debugProperties; - const char *debugProp = - this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); - if (debugProp) - { - cmSystemTools::ExpandListArgument(debugProp, debugProperties); - } - - bool debugFeatures = !this->DebugCompileFeaturesDone - && std::find(debugProperties.begin(), - debugProperties.end(), - "COMPILE_FEATURES") - != debugProperties.end(); - - if (this->Makefile->IsConfigured()) - { - this->DebugCompileFeaturesDone = true; - } - - processCompileFeatures(this, - this->Internal->CompileFeaturesItems, - result, - uniqueFeatures, - &dagChecker, - config, - debugFeatures); - - std::vector - linkInterfaceCompileFeaturesEntries; - this->Internal->AddInterfaceEntries( - this, config, "INTERFACE_COMPILE_FEATURES", - linkInterfaceCompileFeaturesEntries); - - processCompileFeatures(this, - linkInterfaceCompileFeaturesEntries, - result, - uniqueFeatures, - &dagChecker, - config, - debugFeatures); - - cmDeleteAll(linkInterfaceCompileFeaturesEntries); -} - -//---------------------------------------------------------------------------- void cmTarget::MaybeInvalidatePropertyCache(const std::string& prop) { // Wipe out maps caching information affected by this property. @@ -4099,7 +4035,6 @@ cmTargetInternalPointer //---------------------------------------------------------------------------- cmTargetInternalPointer::~cmTargetInternalPointer() { - cmDeleteAll(this->Pointer->CompileFeaturesItems); cmDeleteAll(this->Pointer->CompileDefinitionsItems); cmDeleteAll(this->Pointer->SourceEntries); delete this->Pointer; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 05b6aec..aae558e 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -375,9 +375,6 @@ public: void AppendBuildInterfaceIncludes(); - void GetCompileFeatures(std::vector &features, - const std::string& config) const; - bool IsNullImpliedByLinkLibraries(const std::string &p) const; std::string GetDebugGeneratorExpressions(const std::string &value, @@ -402,6 +399,9 @@ public: cmStringRange GetCompileOptionsEntries() const; cmBacktraceRange GetCompileOptionsBacktraces() const; + cmStringRange GetCompileFeaturesEntries() const; + cmBacktraceRange GetCompileFeaturesBacktraces() const; + #if defined(_WIN32) && !defined(__CYGWIN__) const LinkLibraryVectorType &GetLinkLibrariesForVS6() const { return this->LinkLibrariesForVS6;} @@ -518,7 +518,6 @@ private: bool BuildInterfaceIncludesAppended; mutable bool DebugCompileDefinitionsDone; mutable bool DebugSourcesDone; - mutable bool DebugCompileFeaturesDone; mutable bool LinkImplementationLanguageIsContextDependent; #if defined(_WIN32) && !defined(__CYGWIN__) bool LinkLibrariesForVS6Analyzed; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a9a750bb9372b9b4dbdb506510f99e50fcf1b21b commit a9a750bb9372b9b4dbdb506510f99e50fcf1b21b Author: Stephen Kelly AuthorDate: Tue Aug 4 23:43:56 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 23:43:52 2015 +0200 cmGeneratorTarget: Move compile options processing from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 01967da..a56d95d 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -260,7 +260,8 @@ void CreatePropertyGeneratorExpressions( cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) : Target(t), SourceFileFlagsConstructed(false), - DebugIncludesDone(false) + DebugIncludesDone(false), + DebugCompileOptionsDone(false) { this->Makefile = this->Target->GetMakefile(); this->LocalGenerator = lg; @@ -270,11 +271,17 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) t->GetIncludeDirectoriesEntries(), t->GetIncludeDirectoriesBacktraces(), this->IncludeDirectoriesEntries); + + CreatePropertyGeneratorExpressions( + t->GetCompileOptionsEntries(), + t->GetCompileOptionsBacktraces(), + this->CompileOptionsEntries); } cmGeneratorTarget::~cmGeneratorTarget() { cmDeleteAll(this->IncludeDirectoriesEntries); + cmDeleteAll(this->CompileOptionsEntries); cmDeleteAll(this->LinkInformation); this->LinkInformation.clear(); } @@ -2245,6 +2252,125 @@ cmGeneratorTarget::GetIncludeDirectories(const std::string& config, } //---------------------------------------------------------------------------- +static void processCompileOptionsInternal(cmGeneratorTarget const* tgt, + const std::vector &entries, + std::vector &options, + UNORDERED_SET &uniqueOptions, + cmGeneratorExpressionDAGChecker *dagChecker, + const std::string& config, bool debugOptions, const char *logName, + std::string const& language) +{ + cmMakefile *mf = tgt->Target->GetMakefile(); + + for (std::vector::const_iterator + it = entries.begin(), end = entries.end(); it != end; ++it) + { + std::vector entryOptions; + cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf, + config, + false, + tgt->Target, + dagChecker, + language), + entryOptions); + std::string usedOptions; + for(std::vector::iterator + li = entryOptions.begin(); li != entryOptions.end(); ++li) + { + std::string const& opt = *li; + + if(uniqueOptions.insert(opt).second) + { + options.push_back(opt); + if (debugOptions) + { + usedOptions += " * " + opt + "\n"; + } + } + } + if (!usedOptions.empty()) + { + mf->GetCMakeInstance()->IssueMessage(cmake::LOG, + std::string("Used compile ") + logName + + std::string(" for target ") + + tgt->GetName() + ":\n" + + usedOptions, (*it)->ge->GetBacktrace()); + } + } +} + +//---------------------------------------------------------------------------- +static void processCompileOptions(cmGeneratorTarget const* tgt, + const std::vector &entries, + std::vector &options, + UNORDERED_SET &uniqueOptions, + cmGeneratorExpressionDAGChecker *dagChecker, + const std::string& config, bool debugOptions, + std::string const& language) +{ + processCompileOptionsInternal(tgt, entries, options, uniqueOptions, + dagChecker, config, debugOptions, "options", + language); +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GetCompileOptions(std::vector &result, + const std::string& config, + const std::string& language) const +{ + UNORDERED_SET uniqueOptions; + + cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), + "COMPILE_OPTIONS", 0, 0); + + std::vector debugProperties; + const char *debugProp = + this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); + if (debugProp) + { + cmSystemTools::ExpandListArgument(debugProp, debugProperties); + } + + bool debugOptions = !this->DebugCompileOptionsDone + && std::find(debugProperties.begin(), + debugProperties.end(), + "COMPILE_OPTIONS") + != debugProperties.end(); + + if (this->Makefile->IsConfigured()) + { + this->DebugCompileOptionsDone = true; + } + + processCompileOptions(this, + this->CompileOptionsEntries, + result, + uniqueOptions, + &dagChecker, + config, + debugOptions, + language); + + std::vector + linkInterfaceCompileOptionsEntries; + + AddInterfaceEntries( + this, config, "INTERFACE_COMPILE_OPTIONS", + linkInterfaceCompileOptionsEntries); + + processCompileOptions(this, + linkInterfaceCompileOptionsEntries, + result, + uniqueOptions, + &dagChecker, + config, + debugOptions, + language); + + cmDeleteAll(linkInterfaceCompileOptionsEntries); +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GenerateTargetManifest( const std::string& config) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 9407d1f..99dc746 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -245,6 +245,10 @@ public: std::vector GetIncludeDirectories( const std::string& config, const std::string& lang) const; + void GetCompileOptions(std::vector &result, + const std::string& config, + const std::string& language) const; + bool IsSystemIncludeDirectory(const std::string& dir, const std::string& config) const; @@ -450,8 +454,10 @@ private: mutable bool PolicyWarnedCMP0022; mutable bool DebugIncludesDone; + mutable bool DebugCompileOptionsDone; std::vector IncludeDirectoriesEntries; + std::vector CompileOptionsEntries; void ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, cmTarget const* headTarget, diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index 7af17cd..790e68b 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -558,7 +558,7 @@ bool cmGhsMultiTargetGenerator::IsNotKernel(std::string const &config, { bool output; std::vector options; - this->Target->GetCompileOptions(options, config, language); + this->GeneratorTarget->GetCompileOptions(options, config, language); output = options.end() == std::find(options.begin(), options.end(), "-kernel"); return output; @@ -587,7 +587,7 @@ bool cmGhsMultiTargetGenerator::DetermineIfDynamicDownload( { std::vector options; bool output = false; - this->Target->GetCompileOptions(options, config, language); + this->GeneratorTarget->GetCompileOptions(options, config, language); for (std::vector::const_iterator options_i = options.begin(); options_i != options.end(); ++options_i) { diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index edb644d..89515ff 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1094,6 +1094,10 @@ void cmLocalGenerator::AddCompileOptions( ) { std::string langFlagRegexVar = std::string("CMAKE_")+lang+"_FLAG_REGEX"; + + cmGeneratorTarget* gtgt = + this->GlobalGenerator->GetGeneratorTarget(target); + if(const char* langFlagRegexStr = this->Makefile->GetDefinition(langFlagRegexVar)) { @@ -1104,7 +1108,7 @@ void cmLocalGenerator::AddCompileOptions( { cmSystemTools::ParseWindowsCommandLine(targetFlags, opts); } - target->GetCompileOptions(opts, config, lang); + gtgt->GetCompileOptions(opts, config, lang); for(std::vector::const_iterator i = opts.begin(); i != opts.end(); ++i) { @@ -1125,7 +1129,7 @@ void cmLocalGenerator::AddCompileOptions( this->AppendFlags(flags, targetFlags); } std::vector opts; - target->GetCompileOptions(opts, config, lang); + gtgt->GetCompileOptions(opts, config, lang); for(std::vector::const_iterator i = opts.begin(); i != opts.end(); ++i) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index fb4241b..466f98a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -142,7 +142,6 @@ public: std::vector IncludeDirectoriesBacktraces; std::vector CompileOptionsEntries; std::vector CompileOptionsBacktraces; - std::vector CompileOptionsItems; std::vector CompileFeaturesEntries; std::vector CompileFeaturesBacktraces; std::vector CompileFeaturesItems; @@ -177,7 +176,6 @@ cmTarget::cmTarget() this->IsApple = false; this->IsImportedTarget = false; this->BuildInterfaceIncludesAppended = false; - this->DebugCompileOptionsDone = false; this->DebugCompileFeaturesDone = false; this->DebugCompileDefinitionsDone = false; this->DebugSourcesDone = false; @@ -425,11 +423,6 @@ void CreatePropertyGeneratorExpressions( void cmTarget::Compute() { CreatePropertyGeneratorExpressions( - this->Internal->CompileOptionsEntries, - this->Internal->CompileOptionsBacktraces, - this->Internal->CompileOptionsItems); - - CreatePropertyGeneratorExpressions( this->Internal->CompileFeaturesEntries, this->Internal->CompileFeaturesBacktraces, this->Internal->CompileFeaturesItems); @@ -1323,6 +1316,16 @@ cmBacktraceRange cmTarget::GetIncludeDirectoriesBacktraces() const return cmMakeRange(this->Internal->IncludeDirectoriesBacktraces); } +cmStringRange cmTarget::GetCompileOptionsEntries() const +{ + return cmMakeRange(this->Internal->CompileOptionsEntries); +} + +cmBacktraceRange cmTarget::GetCompileOptionsBacktraces() const +{ + return cmMakeRange(this->Internal->CompileOptionsBacktraces); +} + #if defined(_WIN32) && !defined(__CYGWIN__) //---------------------------------------------------------------------------- void @@ -1968,77 +1971,6 @@ static void processCompileOptionsInternal(cmTarget const* tgt, } //---------------------------------------------------------------------------- -static void processCompileOptions(cmTarget const* tgt, - const std::vector &entries, - std::vector &options, - UNORDERED_SET &uniqueOptions, - cmGeneratorExpressionDAGChecker *dagChecker, - const std::string& config, bool debugOptions, - std::string const& language) -{ - processCompileOptionsInternal(tgt, entries, options, uniqueOptions, - dagChecker, config, debugOptions, "options", - language); -} - -//---------------------------------------------------------------------------- -void cmTarget::GetCompileOptions(std::vector &result, - const std::string& config, - const std::string& language) const -{ - UNORDERED_SET uniqueOptions; - - cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), - "COMPILE_OPTIONS", 0, 0); - - std::vector debugProperties; - const char *debugProp = - this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); - if (debugProp) - { - cmSystemTools::ExpandListArgument(debugProp, debugProperties); - } - - bool debugOptions = !this->DebugCompileOptionsDone - && std::find(debugProperties.begin(), - debugProperties.end(), - "COMPILE_OPTIONS") - != debugProperties.end(); - - if (this->Makefile->IsConfigured()) - { - this->DebugCompileOptionsDone = true; - } - - processCompileOptions(this, - this->Internal->CompileOptionsItems, - result, - uniqueOptions, - &dagChecker, - config, - debugOptions, - language); - - std::vector - linkInterfaceCompileOptionsEntries; - - this->Internal->AddInterfaceEntries( - this, config, "INTERFACE_COMPILE_OPTIONS", - linkInterfaceCompileOptionsEntries); - - processCompileOptions(this, - linkInterfaceCompileOptionsEntries, - result, - uniqueOptions, - &dagChecker, - config, - debugOptions, - language); - - cmDeleteAll(linkInterfaceCompileOptionsEntries); -} - -//---------------------------------------------------------------------------- static void processCompileDefinitions(cmTarget const* tgt, const std::vector &entries, std::vector &options, @@ -4167,7 +4099,6 @@ cmTargetInternalPointer //---------------------------------------------------------------------------- cmTargetInternalPointer::~cmTargetInternalPointer() { - cmDeleteAll(this->Pointer->CompileOptionsItems); cmDeleteAll(this->Pointer->CompileFeaturesItems); cmDeleteAll(this->Pointer->CompileDefinitionsItems); cmDeleteAll(this->Pointer->SourceEntries); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 13e4f2d..05b6aec 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -375,9 +375,6 @@ public: void AppendBuildInterfaceIncludes(); - void GetCompileOptions(std::vector &result, - const std::string& config, - const std::string& language) const; void GetCompileFeatures(std::vector &features, const std::string& config) const; @@ -402,6 +399,9 @@ public: cmStringRange GetIncludeDirectoriesEntries() const; cmBacktraceRange GetIncludeDirectoriesBacktraces() const; + cmStringRange GetCompileOptionsEntries() const; + cmBacktraceRange GetCompileOptionsBacktraces() const; + #if defined(_WIN32) && !defined(__CYGWIN__) const LinkLibraryVectorType &GetLinkLibrariesForVS6() const { return this->LinkLibrariesForVS6;} @@ -516,7 +516,6 @@ private: bool IsApple; bool IsImportedTarget; bool BuildInterfaceIncludesAppended; - mutable bool DebugCompileOptionsDone; mutable bool DebugCompileDefinitionsDone; mutable bool DebugSourcesDone; mutable bool DebugCompileFeaturesDone; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=09c5d93651499887187095c297561d490c51dafe commit 09c5d93651499887187095c297561d490c51dafe Author: Stephen Kelly AuthorDate: Tue Aug 4 23:14:53 2015 +0200 Commit: Stephen Kelly CommitDate: Tue Aug 25 23:43:51 2015 +0200 cmGeneratorTarget: Move include directory processing from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 1e8e83b..01967da 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -34,6 +34,18 @@ #define UNORDERED_SET std::set #endif +class cmGeneratorTarget::TargetPropertyEntry { + static cmLinkImplItem NoLinkImplItem; +public: + TargetPropertyEntry(cmsys::auto_ptr cge, + cmLinkImplItem const& item = NoLinkImplItem) + : ge(cge), LinkImplItem(item) + {} + const cmsys::auto_ptr ge; + cmLinkImplItem const& LinkImplItem; +}; +cmLinkImplItem cmGeneratorTarget::TargetPropertyEntry::NoLinkImplItem; + //---------------------------------------------------------------------------- void reportBadObjLib(std::vector const& badObjLib, cmGeneratorTarget const* target, cmake *cm) @@ -227,18 +239,42 @@ struct TagVisitor } }; +void CreatePropertyGeneratorExpressions( + cmStringRange const& entries, + cmBacktraceRange const& backtraces, + std::vector& items, + bool evaluateForBuildsystem = false) +{ + std::vector::const_iterator btIt = backtraces.begin(); + for (std::vector::const_iterator it = entries.begin(); + it != entries.end(); ++it, ++btIt) + { + cmGeneratorExpression ge(*btIt); + cmsys::auto_ptr cge = ge.Parse(*it); + cge->SetEvaluateForBuildsystem(evaluateForBuildsystem); + items.push_back(new cmGeneratorTarget::TargetPropertyEntry(cge)); + } +} + //---------------------------------------------------------------------------- cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) : Target(t), - SourceFileFlagsConstructed(false) + SourceFileFlagsConstructed(false), + DebugIncludesDone(false) { this->Makefile = this->Target->GetMakefile(); this->LocalGenerator = lg; this->GlobalGenerator = this->LocalGenerator->GetGlobalGenerator(); + + CreatePropertyGeneratorExpressions( + t->GetIncludeDirectoriesEntries(), + t->GetIncludeDirectoriesBacktraces(), + this->IncludeDirectoriesEntries); } cmGeneratorTarget::~cmGeneratorTarget() { + cmDeleteAll(this->IncludeDirectoriesEntries); cmDeleteAll(this->LinkInformation); this->LinkInformation.clear(); } @@ -1964,13 +2000,248 @@ cmGeneratorTarget::GetCreateRuleVariable(std::string const& lang, } return ""; } +//---------------------------------------------------------------------------- +static void processIncludeDirectories(cmGeneratorTarget const* tgt, + const std::vector &entries, + std::vector &includes, + UNORDERED_SET &uniqueIncludes, + cmGeneratorExpressionDAGChecker *dagChecker, + const std::string& config, bool debugIncludes, + const std::string& language) +{ + cmMakefile *mf = tgt->Target->GetMakefile(); + + for (std::vector::const_iterator + it = entries.begin(), end = entries.end(); it != end; ++it) + { + cmLinkImplItem const& item = (*it)->LinkImplItem; + std::string const& targetName = item; + bool const fromImported = item.Target && item.Target->IsImported(); + bool const checkCMP0027 = item.FromGenex; + std::vector entryIncludes; + cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf, + config, + false, + tgt->Target, + dagChecker, language), + entryIncludes); + + std::string usedIncludes; + for(std::vector::iterator + li = entryIncludes.begin(); li != entryIncludes.end(); ++li) + { + if (fromImported + && !cmSystemTools::FileExists(li->c_str())) + { + std::ostringstream e; + cmake::MessageType messageType = cmake::FATAL_ERROR; + if (checkCMP0027) + { + switch(tgt->Target->GetPolicyStatusCMP0027()) + { + case cmPolicies::WARN: + e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0027) << "\n"; + case cmPolicies::OLD: + messageType = cmake::AUTHOR_WARNING; + break; + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::NEW: + break; + } + } + e << "Imported target \"" << targetName << "\" includes " + "non-existent path\n \"" << *li << "\"\nin its " + "INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:\n" + "* The path was deleted, renamed, or moved to another " + "location.\n" + "* An install or uninstall procedure did not complete " + "successfully.\n" + "* The installation package was faulty and references files it " + "does not provide.\n"; + tgt->GetLocalGenerator()->IssueMessage(messageType, e.str()); + return; + } + + if (!cmSystemTools::FileIsFullPath(li->c_str())) + { + std::ostringstream e; + bool noMessage = false; + cmake::MessageType messageType = cmake::FATAL_ERROR; + if (!targetName.empty()) + { + e << "Target \"" << targetName << "\" contains relative " + "path in its INTERFACE_INCLUDE_DIRECTORIES:\n" + " \"" << *li << "\""; + } + else + { + switch(tgt->Target->GetPolicyStatusCMP0021()) + { + case cmPolicies::WARN: + { + e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0021) << "\n"; + messageType = cmake::AUTHOR_WARNING; + } + break; + case cmPolicies::OLD: + noMessage = true; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::NEW: + // Issue the fatal message. + break; + } + e << "Found relative path while evaluating include directories of " + "\"" << tgt->GetName() << "\":\n \"" << *li << "\"\n"; + } + if (!noMessage) + { + tgt->GetLocalGenerator()->IssueMessage(messageType, e.str()); + if (messageType == cmake::FATAL_ERROR) + { + return; + } + } + } + + if (!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 (!usedIncludes.empty()) + { + mf->GetCMakeInstance()->IssueMessage(cmake::LOG, + std::string("Used includes for target ") + + tgt->GetName() + ":\n" + + usedIncludes, (*it)->ge->GetBacktrace()); + } + } +} + + +//---------------------------------------------------------------------------- +static void AddInterfaceEntries( + cmGeneratorTarget const* thisTarget, std::string const& config, + std::string const& prop, + std::vector& entries) +{ + if(cmLinkImplementationLibraries const* impl = + thisTarget->Target->GetLinkImplementationLibraries(config)) + { + for (std::vector::const_iterator + it = impl->Libraries.begin(), end = impl->Libraries.end(); + it != end; ++it) + { + if(it->Target) + { + std::string genex = + "$"; + cmGeneratorExpression ge(it->Backtrace); + cmsys::auto_ptr cge = ge.Parse(genex); + cge->SetEvaluateForBuildsystem(true); + entries.push_back( + new cmGeneratorTarget::TargetPropertyEntry(cge, *it)); + } + } + } +} //---------------------------------------------------------------------------- std::vector cmGeneratorTarget::GetIncludeDirectories(const std::string& config, const std::string& lang) const { - return this->Target->GetIncludeDirectories(config, lang); + std::vector includes; + UNORDERED_SET uniqueIncludes; + + cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), + "INCLUDE_DIRECTORIES", 0, 0); + + std::vector debugProperties; + const char *debugProp = + this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); + if (debugProp) + { + cmSystemTools::ExpandListArgument(debugProp, debugProperties); + } + + bool debugIncludes = !this->DebugIncludesDone + && std::find(debugProperties.begin(), + debugProperties.end(), + "INCLUDE_DIRECTORIES") + != debugProperties.end(); + + if (this->Makefile->IsConfigured()) + { + this->DebugIncludesDone = true; + } + + processIncludeDirectories(this, + this->IncludeDirectoriesEntries, + includes, + uniqueIncludes, + &dagChecker, + config, + debugIncludes, + lang); + + std::vector + linkInterfaceIncludeDirectoriesEntries; + AddInterfaceEntries( + this, config, "INTERFACE_INCLUDE_DIRECTORIES", + linkInterfaceIncludeDirectoriesEntries); + + if(this->Makefile->IsOn("APPLE")) + { + cmLinkImplementationLibraries const* impl = + this->Target->GetLinkImplementationLibraries(config); + for(std::vector::const_iterator + it = impl->Libraries.begin(); + it != impl->Libraries.end(); ++it) + { + std::string libDir = cmSystemTools::CollapseFullPath(*it); + + static cmsys::RegularExpression + frameworkCheck("(.*\\.framework)(/Versions/[^/]+)?/[^/]+$"); + if(!frameworkCheck.find(libDir)) + { + continue; + } + + libDir = frameworkCheck.match(1); + + cmGeneratorExpression ge; + cmsys::auto_ptr cge = + ge.Parse(libDir.c_str()); + linkInterfaceIncludeDirectoriesEntries + .push_back(new cmGeneratorTarget::TargetPropertyEntry(cge)); + } + } + + processIncludeDirectories(this, + linkInterfaceIncludeDirectoriesEntries, + includes, + uniqueIncludes, + &dagChecker, + config, + debugIncludes, + lang); + + cmDeleteAll(linkInterfaceIncludeDirectoriesEntries); + + return includes; } //---------------------------------------------------------------------------- diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 46341d3..9407d1f 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -360,6 +360,8 @@ public: const std::string &report, const std::string &compatibilityType) const; + class TargetPropertyEntry; + private: friend class cmTargetTraceDependencies; struct SourceEntry { std::vector Depends; }; @@ -447,6 +449,9 @@ private: mutable LinkInterfaceMapType LinkInterfaceUsageRequirementsOnlyMap; mutable bool PolicyWarnedCMP0022; + mutable bool DebugIncludesDone; + + std::vector IncludeDirectoriesEntries; void ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, cmTarget const* headTarget, diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index 1e57c33..7af17cd 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -343,7 +343,7 @@ void cmGhsMultiTargetGenerator::WriteIncludes(const std::string &config, const std::string &language) { std::vector includes = - this->Target->GetIncludeDirectories(config, language); + this->GeneratorTarget->GetIncludeDirectories(config, language); for (std::vector::const_iterator includes_i = includes.begin(); includes_i != includes.end(); ++includes_i) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e941fb6..fb4241b 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -140,7 +140,6 @@ public: }; std::vector IncludeDirectoriesEntries; std::vector IncludeDirectoriesBacktraces; - std::vector IncludeDirectoriesItems; std::vector CompileOptionsEntries; std::vector CompileOptionsBacktraces; std::vector CompileOptionsItems; @@ -178,7 +177,6 @@ cmTarget::cmTarget() this->IsApple = false; this->IsImportedTarget = false; this->BuildInterfaceIncludesAppended = false; - this->DebugIncludesDone = false; this->DebugCompileOptionsDone = false; this->DebugCompileFeaturesDone = false; this->DebugCompileDefinitionsDone = false; @@ -427,11 +425,6 @@ void CreatePropertyGeneratorExpressions( void cmTarget::Compute() { CreatePropertyGeneratorExpressions( - this->Internal->IncludeDirectoriesEntries, - this->Internal->IncludeDirectoriesBacktraces, - this->Internal->IncludeDirectoriesItems); - - CreatePropertyGeneratorExpressions( this->Internal->CompileOptionsEntries, this->Internal->CompileOptionsBacktraces, this->Internal->CompileOptionsItems); @@ -1320,6 +1313,16 @@ cmTarget::AddSystemIncludeDirectories(const std::set &incs) this->SystemIncludeDirectories.insert(incs.begin(), incs.end()); } +cmStringRange cmTarget::GetIncludeDirectoriesEntries() const +{ + return cmMakeRange(this->Internal->IncludeDirectoriesEntries); +} + +cmBacktraceRange cmTarget::GetIncludeDirectoriesBacktraces() const +{ + return cmMakeRange(this->Internal->IncludeDirectoriesBacktraces); +} + #if defined(_WIN32) && !defined(__CYGWIN__) //---------------------------------------------------------------------------- void @@ -1917,222 +1920,6 @@ void cmTarget::InsertCompileDefinition(std::string const& entry, } //---------------------------------------------------------------------------- -static void processIncludeDirectories(cmTarget const* tgt, - const std::vector &entries, - std::vector &includes, - UNORDERED_SET &uniqueIncludes, - cmGeneratorExpressionDAGChecker *dagChecker, - const std::string& config, bool debugIncludes, - const std::string& language) -{ - cmMakefile *mf = tgt->GetMakefile(); - - for (std::vector::const_iterator - it = entries.begin(), end = entries.end(); it != end; ++it) - { - cmLinkImplItem const& item = (*it)->LinkImplItem; - std::string const& targetName = item; - bool const fromImported = item.Target && item.Target->IsImported(); - bool const checkCMP0027 = item.FromGenex; - std::vector entryIncludes; - cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf, - config, - false, - tgt, - dagChecker, language), - entryIncludes); - - std::string usedIncludes; - for(std::vector::iterator - li = entryIncludes.begin(); li != entryIncludes.end(); ++li) - { - if (fromImported - && !cmSystemTools::FileExists(li->c_str())) - { - std::ostringstream e; - cmake::MessageType messageType = cmake::FATAL_ERROR; - if (checkCMP0027) - { - switch(tgt->GetPolicyStatusCMP0027()) - { - case cmPolicies::WARN: - e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0027) << "\n"; - case cmPolicies::OLD: - messageType = cmake::AUTHOR_WARNING; - break; - case cmPolicies::REQUIRED_ALWAYS: - case cmPolicies::REQUIRED_IF_USED: - case cmPolicies::NEW: - break; - } - } - e << "Imported target \"" << targetName << "\" includes " - "non-existent path\n \"" << *li << "\"\nin its " - "INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:\n" - "* The path was deleted, renamed, or moved to another " - "location.\n" - "* An install or uninstall procedure did not complete " - "successfully.\n" - "* The installation package was faulty and references files it " - "does not provide.\n"; - tgt->GetMakefile()->IssueMessage(messageType, e.str()); - return; - } - - if (!cmSystemTools::FileIsFullPath(li->c_str())) - { - std::ostringstream e; - bool noMessage = false; - cmake::MessageType messageType = cmake::FATAL_ERROR; - if (!targetName.empty()) - { - e << "Target \"" << targetName << "\" contains relative " - "path in its INTERFACE_INCLUDE_DIRECTORIES:\n" - " \"" << *li << "\""; - } - else - { - switch(tgt->GetPolicyStatusCMP0021()) - { - case cmPolicies::WARN: - { - e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0021) << "\n"; - messageType = cmake::AUTHOR_WARNING; - } - break; - case cmPolicies::OLD: - noMessage = true; - case cmPolicies::REQUIRED_IF_USED: - case cmPolicies::REQUIRED_ALWAYS: - case cmPolicies::NEW: - // Issue the fatal message. - break; - } - e << "Found relative path while evaluating include directories of " - "\"" << tgt->GetName() << "\":\n \"" << *li << "\"\n"; - } - if (!noMessage) - { - tgt->GetMakefile()->IssueMessage(messageType, e.str()); - if (messageType == cmake::FATAL_ERROR) - { - return; - } - } - } - - if (!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 (!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 std::string& config, - const std::string& language) const -{ - std::vector includes; - UNORDERED_SET uniqueIncludes; - - cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), - "INCLUDE_DIRECTORIES", 0, 0); - - std::vector debugProperties; - const char *debugProp = - this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); - if (debugProp) - { - cmSystemTools::ExpandListArgument(debugProp, debugProperties); - } - - bool debugIncludes = !this->DebugIncludesDone - && std::find(debugProperties.begin(), - debugProperties.end(), - "INCLUDE_DIRECTORIES") - != debugProperties.end(); - - if (this->Makefile->IsConfigured()) - { - this->DebugIncludesDone = true; - } - - processIncludeDirectories(this, - this->Internal->IncludeDirectoriesItems, - includes, - uniqueIncludes, - &dagChecker, - config, - debugIncludes, - language); - - std::vector - linkInterfaceIncludeDirectoriesEntries; - this->Internal->AddInterfaceEntries( - this, config, "INTERFACE_INCLUDE_DIRECTORIES", - linkInterfaceIncludeDirectoriesEntries); - - if(this->Makefile->IsOn("APPLE")) - { - cmLinkImplementationLibraries const* impl = - this->GetLinkImplementationLibraries(config); - for(std::vector::const_iterator - it = impl->Libraries.begin(); - it != impl->Libraries.end(); ++it) - { - std::string libDir = cmSystemTools::CollapseFullPath(*it); - - static cmsys::RegularExpression - frameworkCheck("(.*\\.framework)(/Versions/[^/]+)?/[^/]+$"); - if(!frameworkCheck.find(libDir)) - { - continue; - } - - libDir = frameworkCheck.match(1); - - cmGeneratorExpression ge; - cmsys::auto_ptr cge = - ge.Parse(libDir.c_str()); - linkInterfaceIncludeDirectoriesEntries - .push_back(new cmTargetInternals::TargetPropertyEntry(cge)); - } - } - - processIncludeDirectories(this, - linkInterfaceIncludeDirectoriesEntries, - includes, - uniqueIncludes, - &dagChecker, - config, - debugIncludes, - language); - - cmDeleteAll(linkInterfaceIncludeDirectoriesEntries); - - return includes; -} - -//---------------------------------------------------------------------------- static void processCompileOptionsInternal(cmTarget const* tgt, const std::vector &entries, std::vector &options, @@ -4380,7 +4167,6 @@ cmTargetInternalPointer //---------------------------------------------------------------------------- cmTargetInternalPointer::~cmTargetInternalPointer() { - cmDeleteAll(this->Pointer->IncludeDirectoriesItems); cmDeleteAll(this->Pointer->CompileOptionsItems); cmDeleteAll(this->Pointer->CompileFeaturesItems); cmDeleteAll(this->Pointer->CompileDefinitionsItems); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 103a7e8..13e4f2d 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -364,9 +364,6 @@ public: /** @return whether this target have a well defined output file name. */ bool HaveWellDefinedOutputFiles() const; - std::vector GetIncludeDirectories( - const std::string& config, - const std::string& language) const; void InsertInclude(std::string const& entry, cmListFileBacktrace const& bt, bool before = false); @@ -402,6 +399,9 @@ public: return this->MaxLanguageStandards; } + cmStringRange GetIncludeDirectoriesEntries() const; + cmBacktraceRange GetIncludeDirectoriesBacktraces() const; + #if defined(_WIN32) && !defined(__CYGWIN__) const LinkLibraryVectorType &GetLinkLibrariesForVS6() const { return this->LinkLibrariesForVS6;} @@ -516,7 +516,6 @@ private: bool IsApple; bool IsImportedTarget; bool BuildInterfaceIncludesAppended; - mutable bool DebugIncludesDone; mutable bool DebugCompileOptionsDone; mutable bool DebugCompileDefinitionsDone; mutable bool DebugSourcesDone; ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From steveire at gmail.com Tue Aug 25 18:06:26 2015 From: steveire at gmail.com (Stephen Kelly) Date: Tue, 25 Aug 2015 18:06:26 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2518-g6792bac Message-ID: <20150825220626.9EED8B0569@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 6792bac389454c54660335f98f3a07163da17467 (commit) via 59ebf292bbe8a039dd0530cd84e7b58448b3770c (commit) from 12af1245ee99372e77d8ae50feb3cc25c33c8362 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6792bac389454c54660335f98f3a07163da17467 commit 6792bac389454c54660335f98f3a07163da17467 Merge: 12af124 59ebf29 Author: Stephen Kelly AuthorDate: Tue Aug 25 18:06:25 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 25 18:06:25 2015 -0400 Merge topic 'use-generator-target' into next 59ebf292 fixup! cmGeneratorTarget: Move GetLanguages from cmTarget. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=59ebf292bbe8a039dd0530cd84e7b58448b3770c commit 59ebf292bbe8a039dd0530cd84e7b58448b3770c Author: Stephen Kelly AuthorDate: Wed Aug 26 00:06:08 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 26 00:06:08 2015 +0200 fixup! cmGeneratorTarget: Move GetLanguages from cmTarget. diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index b422fdc..771d72d 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -836,10 +836,11 @@ void RegisterVisualStudioMacros(const std::string& macrosFile, bool cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget const& target) { + cmGeneratorTarget* gt = this->GetGeneratorTarget(&target); + // check to see if this is a fortran build std::set languages; { - cmGeneratorTarget* gt = this->GetGeneratorTarget(&target); // Issue diagnostic if the source files depend on the config. std::vector sources; ----------------------------------------------------------------------- Summary of changes: Source/cmGlobalVisualStudioGenerator.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) hooks/post-receive -- CMake From steveire at gmail.com Tue Aug 25 18:06:56 2015 From: steveire at gmail.com (Stephen Kelly) Date: Tue, 25 Aug 2015 18:06:56 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2521-gc2182a3 Message-ID: <20150825220656.574B1B1B9A@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via c2182a307118524bf6bbe567dfff849e396ee796 (commit) via 96b63ec87594298906b28adeac7d02da4859b097 (commit) via 28edac28a33131410ecdb414fd00372925f9836d (commit) from 6792bac389454c54660335f98f3a07163da17467 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c2182a307118524bf6bbe567dfff849e396ee796 commit c2182a307118524bf6bbe567dfff849e396ee796 Merge: 6792bac 96b63ec Author: Stephen Kelly AuthorDate: Tue Aug 25 18:06:55 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 25 18:06:55 2015 -0400 Merge topic 'use-generator-target' into next 96b63ec8 cmGeneratorTarget: Move GetConfigCommonSourceFiles from cmTarget. 28edac28 cmGeneratorTarget: Move GetLanguages from cmTarget. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=96b63ec87594298906b28adeac7d02da4859b097 commit 96b63ec87594298906b28adeac7d02da4859b097 Author: Stephen Kelly AuthorDate: Wed Aug 5 17:37:50 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 26 00:06:33 2015 +0200 cmGeneratorTarget: Move GetConfigCommonSourceFiles from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index e6507e7..5c83879 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -4397,11 +4397,68 @@ cmGeneratorTarget::GetLinkImplementation(const std::string& config) const } //---------------------------------------------------------------------------- +bool cmGeneratorTarget::GetConfigCommonSourceFiles( + std::vector& files) const +{ + std::vector configs; + this->Makefile->GetConfigurations(configs); + if (configs.empty()) + { + configs.push_back(""); + } + + std::vector::const_iterator it = configs.begin(); + const std::string& firstConfig = *it; + this->Target->GetSourceFiles(files, firstConfig); + + for ( ; it != configs.end(); ++it) + { + std::vector configFiles; + this->Target->GetSourceFiles(configFiles, *it); + if (configFiles != files) + { + std::string firstConfigFiles; + const char* sep = ""; + for (std::vector::const_iterator fi = files.begin(); + fi != files.end(); ++fi) + { + firstConfigFiles += sep; + firstConfigFiles += (*fi)->GetFullPath(); + sep = "\n "; + } + + std::string thisConfigFiles; + sep = ""; + for (std::vector::const_iterator fi = configFiles.begin(); + fi != configFiles.end(); ++fi) + { + thisConfigFiles += sep; + thisConfigFiles += (*fi)->GetFullPath(); + sep = "\n "; + } + std::ostringstream e; + e << "Target \"" << this->GetName() + << "\" has source files which vary by " + "configuration. This is not supported by the \"" + << this->GlobalGenerator->GetName() + << "\" generator.\n" + "Config \"" << firstConfig << "\":\n" + " " << firstConfigFiles << "\n" + "Config \"" << *it << "\":\n" + " " << thisConfigFiles << "\n"; + this->LocalGenerator->IssueMessage(cmake::FATAL_ERROR, e.str()); + return false; + } + } + return true; +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetLanguages(std::set& languages, const std::string& config) const { std::vector sourceFiles; - this->Target->GetSourceFiles(sourceFiles, config); + this->GetSourceFiles(sourceFiles, config); for(std::vector::const_iterator i = sourceFiles.begin(); i != sourceFiles.end(); ++i) { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index e7ec23a..6d66bfe 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -241,6 +241,8 @@ public: void GetLanguages(std::set& languages, std::string const& config) const; + bool GetConfigCommonSourceFiles(std::vector& files) const; + bool HaveBuildTreeRPATH(const std::string& config) const; /** Full path with trailing slash to the top-level directory diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 6857cd2..771d72d 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -844,7 +844,7 @@ cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget const& target) // Issue diagnostic if the source files depend on the config. std::vector sources; - if (!target.GetConfigCommonSourceFiles(sources)) + if (!gt->GetConfigCommonSourceFiles(sources)) { return false; } diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 4511de5..eb547bd 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1124,7 +1124,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, // organize the sources std::vector classes; - if (!cmtarget.GetConfigCommonSourceFiles(classes)) + if (!gtgt->GetConfigCommonSourceFiles(classes)) { return false; } @@ -1505,7 +1505,8 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases, } std::vector classes; - if (!cmtarget.GetConfigCommonSourceFiles(classes)) + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); + if (!gtgt->GetConfigCommonSourceFiles(classes)) { return; } @@ -2557,7 +2558,8 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget) if(cmtarget.GetType() == cmTarget::UTILITY) { std::vector sources; - if (!cmtarget.GetConfigCommonSourceFiles(sources)) + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); + if (!gtgt->GetConfigCommonSourceFiles(sources)) { return 0; } @@ -3085,7 +3087,8 @@ bool cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root, } std::vector classes; - if (!cmtarget.GetConfigCommonSourceFiles(classes)) + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); + if (!gtgt->GetConfigCommonSourceFiles(classes)) { return false; } diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 0d07536..3a44367 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -305,9 +305,12 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout, // We may be modifying the source groups temporarily, so make a copy. std::vector sourceGroups = this->Makefile->GetSourceGroups(); + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); + // get the classes from the source lists then add them to the groups std::vector classes; - if (!target.GetConfigCommonSourceFiles(classes)) + if (!gt->GetConfigCommonSourceFiles(classes)) { return; } diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index f17c9a4..55ad852 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1469,10 +1469,13 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, // We may be modifying the source groups temporarily, so make a copy. std::vector sourceGroups = this->Makefile->GetSourceGroups(); + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); + // get the classes from the source lists then add them to the groups this->ModuleDefinitionFile = ""; std::vector classes; - if (!target.GetConfigCommonSourceFiles(classes)) + if (!gt->GetConfigCommonSourceFiles(classes)) { return; } @@ -1514,8 +1517,6 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, { // VS >= 8 support per-config source locations so we // list object library content as external objects. - cmGeneratorTarget* gt = - this->GlobalGenerator->GetGeneratorTarget(&target); std::vector objs; gt->UseObjectLibraries(objs, ""); if(!objs.empty()) diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index c58e7e4..0a4b546 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -403,7 +403,9 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg, ) { std::vector srcFiles; - target->GetConfigCommonSourceFiles(srcFiles); + cmGeneratorTarget* gtgt = + lg->GetGlobalGenerator()->GetGeneratorTarget(target); + gtgt->GetConfigCommonSourceFiles(srcFiles); for(std::vector::const_iterator fileIt = srcFiles.begin(); fileIt != srcFiles.end(); ++fileIt) @@ -661,7 +663,10 @@ void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target) const char* sepHeaders = ""; std::vector srcFiles; - target->GetConfigCommonSourceFiles(srcFiles); + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); + gtgt->GetConfigCommonSourceFiles(srcFiles); const char *skipMocSep = ""; const char *skipUicSep = ""; @@ -1046,7 +1051,10 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) cmMakefile *makefile = target->GetMakefile(); std::vector srcFiles; - target->GetConfigCommonSourceFiles(srcFiles); + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); + gtgt->GetConfigCommonSourceFiles(srcFiles); std::string qrcInputs; const char* qrcInputsSep = ""; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 682e9b9..40d7ebf 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -726,62 +726,6 @@ void cmTarget::GetSourceFiles(std::vector &files, } //---------------------------------------------------------------------------- -bool -cmTarget::GetConfigCommonSourceFiles(std::vector& files) const -{ - std::vector configs; - this->Makefile->GetConfigurations(configs); - if (configs.empty()) - { - configs.push_back(""); - } - - std::vector::const_iterator it = configs.begin(); - const std::string& firstConfig = *it; - this->GetSourceFiles(files, firstConfig); - - for ( ; it != configs.end(); ++it) - { - std::vector configFiles; - this->GetSourceFiles(configFiles, *it); - if (configFiles != files) - { - std::string firstConfigFiles; - const char* sep = ""; - for (std::vector::const_iterator fi = files.begin(); - fi != files.end(); ++fi) - { - firstConfigFiles += sep; - firstConfigFiles += (*fi)->GetFullPath(); - sep = "\n "; - } - - std::string thisConfigFiles; - sep = ""; - for (std::vector::const_iterator fi = configFiles.begin(); - fi != configFiles.end(); ++fi) - { - thisConfigFiles += sep; - thisConfigFiles += (*fi)->GetFullPath(); - sep = "\n "; - } - std::ostringstream e; - e << "Target \"" << this->Name << "\" has source files which vary by " - "configuration. This is not supported by the \"" - << this->Makefile->GetGlobalGenerator()->GetName() - << "\" generator.\n" - "Config \"" << firstConfig << "\":\n" - " " << firstConfigFiles << "\n" - "Config \"" << *it << "\":\n" - " " << thisConfigFiles << "\n"; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); - return false; - } - } - return true; -} - -//---------------------------------------------------------------------------- void cmTarget::GetSourceFiles(std::vector &files, const std::string& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 8dee560..d032380 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -137,8 +137,6 @@ public: */ void GetSourceFiles(std::vector &files, const std::string& config) const; - bool GetConfigCommonSourceFiles(std::vector& files) const; - /** * Add sources to the target. */ diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 464a83a..e7716d8 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -965,7 +965,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups() std::vector sourceGroups = this->Makefile->GetSourceGroups(); std::vector classes; - if (!this->Target->GetConfigCommonSourceFiles(classes)) + if (!this->GeneratorTarget->GetConfigCommonSourceFiles(classes)) { return; } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=28edac28a33131410ecdb414fd00372925f9836d commit 28edac28a33131410ecdb414fd00372925f9836d Author: Stephen Kelly AuthorDate: Wed Aug 5 17:37:50 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 26 00:06:33 2015 +0200 cmGeneratorTarget: Move GetLanguages from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 8e126b9..e6507e7 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -4397,6 +4397,57 @@ cmGeneratorTarget::GetLinkImplementation(const std::string& config) const } //---------------------------------------------------------------------------- +void cmGeneratorTarget::GetLanguages(std::set& languages, + const std::string& config) const +{ + std::vector sourceFiles; + this->Target->GetSourceFiles(sourceFiles, config); + for(std::vector::const_iterator + i = sourceFiles.begin(); i != sourceFiles.end(); ++i) + { + const std::string& lang = (*i)->GetLanguage(); + if(!lang.empty()) + { + languages.insert(lang); + } + } + + std::vector objectLibraries; + std::vector externalObjects; + if (!this->Makefile->IsConfigured()) + { + std::vector objectTargets; + this->Target->GetObjectLibrariesCMP0026(objectTargets); + objectLibraries.reserve(objectTargets.size()); + for (std::vector::const_iterator it = objectTargets.begin(); + it != objectTargets.end(); ++it) + { + objectLibraries.push_back(this->GlobalGenerator + ->GetGeneratorTarget(*it)); + } + } + else + { + this->GetExternalObjects(externalObjects, config); + for(std::vector::const_iterator + i = externalObjects.begin(); i != externalObjects.end(); ++i) + { + std::string objLib = (*i)->GetObjectLibrary(); + if (cmTarget* tgt = this->Makefile->FindTargetToUse(objLib)) + { + objectLibraries.push_back(this->GlobalGenerator + ->GetGeneratorTarget(tgt)); + } + } + } + for(std::vector::const_iterator + i = objectLibraries.begin(); i != objectLibraries.end(); ++i) + { + (*i)->GetLanguages(languages, config); + } +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::ComputeLinkImplementationLanguages( const std::string& config, cmOptionalLinkImplementation& impl) const @@ -4404,7 +4455,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLanguages( // This target needs runtime libraries for its source languages. std::set languages; // Get languages used in our source files. - this->Target->GetLanguages(languages, config); + this->GetLanguages(languages, config); // Copy the set of langauges to the link implementation. impl.Languages.insert(impl.Languages.begin(), languages.begin(), languages.end()); diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 7cb3acd..e7ec23a 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -233,6 +233,14 @@ public: cmOptionalLinkImplementation& impl ) const; + // Compute the set of languages compiled by the target. This is + // computed every time it is called because the languages can change + // when source file properties are changed and we do not have enough + // information to forward these property changes to the targets + // until we have per-target object file properties. + void GetLanguages(std::set& languages, + std::string const& config) const; + bool HaveBuildTreeRPATH(const std::string& config) const; /** Full path with trailing slash to the top-level directory diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index b240924..331caad 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -1134,7 +1134,8 @@ bool cmGlobalUnixMakefileGenerator3 ::NeedRequiresStep(cmTarget const& target) { std::set languages; - target.GetLanguages(languages, + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&target); + gtgt->GetLanguages(languages, target.GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE")); for(std::set::const_iterator l = languages.begin(); l != languages.end(); ++l) diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 634366e..6857cd2 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -836,9 +836,12 @@ void RegisterVisualStudioMacros(const std::string& macrosFile, bool cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget const& target) { + cmGeneratorTarget* gt = this->GetGeneratorTarget(&target); + // check to see if this is a fortran build std::set languages; { + // Issue diagnostic if the source files depend on the config. std::vector sources; if (!target.GetConfigCommonSourceFiles(sources)) @@ -846,7 +849,7 @@ cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget const& target) return false; } } - target.GetLanguages(languages, ""); + gt->GetLanguages(languages, ""); if(languages.size() == 1) { if(*languages.begin() == "Fortran") diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 68fd06b..4511de5 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1805,7 +1805,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, // Compute the compilation flags for each language. std::set languages; - target.GetLanguages(languages, configName); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); + gtgt->GetLanguages(languages, configName); std::map cflags; for (std::set::iterator li = languages.begin(); li != languages.end(); ++li) @@ -1827,7 +1828,6 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, AddCompileOptions(flags, &target, lang, configName); } - cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); std::string llang = gtgt->GetLinkerLanguage(configName); if(binary && llang.empty()) { diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index ce370bc..589105e 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1257,7 +1257,9 @@ cmLocalUnixMakefileGenerator3 { // Get the set of source languages in the target. std::set languages; - target.GetLanguages(languages, + cmGeneratorTarget *gtgt = + this->GlobalGenerator->GetGeneratorTarget(&target); + gtgt->GetLanguages(languages, this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); fout << "\n" << "# Per-language clean rules from dependency scanning.\n" diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 0b3df90..cf88a74 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -276,7 +276,7 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags() { // write language flags for target std::set languages; - this->Target->GetLanguages(languages, + this->GeneratorTarget->GetLanguages(languages, this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); // put the compiler in the rules.make file so that if it changes // things rebuild diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e8a315d..682e9b9 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3132,50 +3132,6 @@ cmTarget::GetObjectLibrariesCMP0026(std::vector& objlibs) const } //---------------------------------------------------------------------------- -void cmTarget::GetLanguages(std::set& languages, - const std::string& config) const -{ - std::vector sourceFiles; - this->GetSourceFiles(sourceFiles, config); - for(std::vector::const_iterator - i = sourceFiles.begin(); i != sourceFiles.end(); ++i) - { - const std::string& lang = (*i)->GetLanguage(); - if(!lang.empty()) - { - languages.insert(lang); - } - } - - std::vector objectLibraries; - std::vector externalObjects; - if (!this->Makefile->IsConfigured()) - { - this->GetObjectLibrariesCMP0026(objectLibraries); - } - else - { - cmGeneratorTarget* gt = this->Makefile->GetGlobalGenerator() - ->GetGeneratorTarget(this); - gt->GetExternalObjects(externalObjects, config); - for(std::vector::const_iterator - i = externalObjects.begin(); i != externalObjects.end(); ++i) - { - std::string objLib = (*i)->GetObjectLibrary(); - if (cmTarget* tgt = this->Makefile->FindTargetToUse(objLib)) - { - objectLibraries.push_back(tgt); - } - } - } - for(std::vector::const_iterator - i = objectLibraries.begin(); i != objectLibraries.end(); ++i) - { - (*i)->GetLanguages(languages, config); - } -} - -//---------------------------------------------------------------------------- cmTarget::ImportInfo const* cmTarget::GetImportInfo(const std::string& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 1db4ba1..8dee560 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -305,14 +305,6 @@ public: If no macro should be defined null is returned. */ const char* GetExportMacro() const; - // Compute the set of languages compiled by the target. This is - // computed every time it is called because the languages can change - // when source file properties are changed and we do not have enough - // information to forward these property changes to the targets - // until we have per-target object file properties. - void GetLanguages(std::set& languages, - std::string const& config) const; - /** Return whether this target is an executable with symbol exports enabled. */ bool IsExecutableWithExports() const; ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From steveire at gmail.com Tue Aug 25 18:08:02 2015 From: steveire at gmail.com (Stephen Kelly) Date: Tue, 25 Aug 2015 18:08:02 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2523-g1e744a0 Message-ID: <20150825220802.237A2B1B0E@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 1e744a06addbbf60545c6bc29441810af552e9d6 (commit) via 4ffc76e24f669f0b6c0119fa2a64088983f4691b (commit) from c2182a307118524bf6bbe567dfff849e396ee796 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1e744a06addbbf60545c6bc29441810af552e9d6 commit 1e744a06addbbf60545c6bc29441810af552e9d6 Merge: c2182a3 4ffc76e Author: Stephen Kelly AuthorDate: Tue Aug 25 18:08:01 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 25 18:08:01 2015 -0400 Merge topic 'use-generator-target' into next 4ffc76e2 fixup! cmGeneratorTarget: Move GetLanguages from cmTarget. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4ffc76e24f669f0b6c0119fa2a64088983f4691b commit 4ffc76e24f669f0b6c0119fa2a64088983f4691b Author: Stephen Kelly AuthorDate: Wed Aug 26 00:07:34 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 26 00:07:34 2015 +0200 fixup! cmGeneratorTarget: Move GetLanguages from cmTarget. diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 771d72d..2bf04b4 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -841,7 +841,6 @@ cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget const& target) // check to see if this is a fortran build std::set languages; { - // Issue diagnostic if the source files depend on the config. std::vector sources; if (!gt->GetConfigCommonSourceFiles(sources)) ----------------------------------------------------------------------- Summary of changes: Source/cmGlobalVisualStudioGenerator.cxx | 1 - 1 file changed, 1 deletion(-) hooks/post-receive -- CMake From steveire at gmail.com Tue Aug 25 18:09:00 2015 From: steveire at gmail.com (Stephen Kelly) Date: Tue, 25 Aug 2015 18:09:00 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2526-gb847cf9 Message-ID: <20150825220900.6B628B1BF4@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via b847cf94af02e660f611e333e384d35c6c38f5c1 (commit) via 5c88e5ff5584216463fdc9ec87a10829ca537f5b (commit) via 927ceca89e5da76b142bd598fb460bd796caf889 (commit) from 1e744a06addbbf60545c6bc29441810af552e9d6 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b847cf94af02e660f611e333e384d35c6c38f5c1 commit b847cf94af02e660f611e333e384d35c6c38f5c1 Merge: 1e744a0 5c88e5f Author: Stephen Kelly AuthorDate: Tue Aug 25 18:08:59 2015 -0400 Commit: CMake Topic Stage CommitDate: Tue Aug 25 18:08:59 2015 -0400 Merge topic 'use-generator-target' into next 5c88e5ff cmGeneratorTarget: Move GetConfigCommonSourceFiles from cmTarget. 927ceca8 cmGeneratorTarget: Move GetLanguages from cmTarget. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5c88e5ff5584216463fdc9ec87a10829ca537f5b commit 5c88e5ff5584216463fdc9ec87a10829ca537f5b Author: Stephen Kelly AuthorDate: Wed Aug 5 17:37:50 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 26 00:08:23 2015 +0200 cmGeneratorTarget: Move GetConfigCommonSourceFiles from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index e6507e7..5c83879 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -4397,11 +4397,68 @@ cmGeneratorTarget::GetLinkImplementation(const std::string& config) const } //---------------------------------------------------------------------------- +bool cmGeneratorTarget::GetConfigCommonSourceFiles( + std::vector& files) const +{ + std::vector configs; + this->Makefile->GetConfigurations(configs); + if (configs.empty()) + { + configs.push_back(""); + } + + std::vector::const_iterator it = configs.begin(); + const std::string& firstConfig = *it; + this->Target->GetSourceFiles(files, firstConfig); + + for ( ; it != configs.end(); ++it) + { + std::vector configFiles; + this->Target->GetSourceFiles(configFiles, *it); + if (configFiles != files) + { + std::string firstConfigFiles; + const char* sep = ""; + for (std::vector::const_iterator fi = files.begin(); + fi != files.end(); ++fi) + { + firstConfigFiles += sep; + firstConfigFiles += (*fi)->GetFullPath(); + sep = "\n "; + } + + std::string thisConfigFiles; + sep = ""; + for (std::vector::const_iterator fi = configFiles.begin(); + fi != configFiles.end(); ++fi) + { + thisConfigFiles += sep; + thisConfigFiles += (*fi)->GetFullPath(); + sep = "\n "; + } + std::ostringstream e; + e << "Target \"" << this->GetName() + << "\" has source files which vary by " + "configuration. This is not supported by the \"" + << this->GlobalGenerator->GetName() + << "\" generator.\n" + "Config \"" << firstConfig << "\":\n" + " " << firstConfigFiles << "\n" + "Config \"" << *it << "\":\n" + " " << thisConfigFiles << "\n"; + this->LocalGenerator->IssueMessage(cmake::FATAL_ERROR, e.str()); + return false; + } + } + return true; +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetLanguages(std::set& languages, const std::string& config) const { std::vector sourceFiles; - this->Target->GetSourceFiles(sourceFiles, config); + this->GetSourceFiles(sourceFiles, config); for(std::vector::const_iterator i = sourceFiles.begin(); i != sourceFiles.end(); ++i) { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index e7ec23a..6d66bfe 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -241,6 +241,8 @@ public: void GetLanguages(std::set& languages, std::string const& config) const; + bool GetConfigCommonSourceFiles(std::vector& files) const; + bool HaveBuildTreeRPATH(const std::string& config) const; /** Full path with trailing slash to the top-level directory diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 9b1f4c2..2bf04b4 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -843,7 +843,7 @@ cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget const& target) { // Issue diagnostic if the source files depend on the config. std::vector sources; - if (!target.GetConfigCommonSourceFiles(sources)) + if (!gt->GetConfigCommonSourceFiles(sources)) { return false; } diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 4511de5..eb547bd 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1124,7 +1124,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, // organize the sources std::vector classes; - if (!cmtarget.GetConfigCommonSourceFiles(classes)) + if (!gtgt->GetConfigCommonSourceFiles(classes)) { return false; } @@ -1505,7 +1505,8 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases, } std::vector classes; - if (!cmtarget.GetConfigCommonSourceFiles(classes)) + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); + if (!gtgt->GetConfigCommonSourceFiles(classes)) { return; } @@ -2557,7 +2558,8 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget) if(cmtarget.GetType() == cmTarget::UTILITY) { std::vector sources; - if (!cmtarget.GetConfigCommonSourceFiles(sources)) + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); + if (!gtgt->GetConfigCommonSourceFiles(sources)) { return 0; } @@ -3085,7 +3087,8 @@ bool cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root, } std::vector classes; - if (!cmtarget.GetConfigCommonSourceFiles(classes)) + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); + if (!gtgt->GetConfigCommonSourceFiles(classes)) { return false; } diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 0d07536..3a44367 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -305,9 +305,12 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout, // We may be modifying the source groups temporarily, so make a copy. std::vector sourceGroups = this->Makefile->GetSourceGroups(); + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); + // get the classes from the source lists then add them to the groups std::vector classes; - if (!target.GetConfigCommonSourceFiles(classes)) + if (!gt->GetConfigCommonSourceFiles(classes)) { return; } diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index f17c9a4..55ad852 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1469,10 +1469,13 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, // We may be modifying the source groups temporarily, so make a copy. std::vector sourceGroups = this->Makefile->GetSourceGroups(); + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); + // get the classes from the source lists then add them to the groups this->ModuleDefinitionFile = ""; std::vector classes; - if (!target.GetConfigCommonSourceFiles(classes)) + if (!gt->GetConfigCommonSourceFiles(classes)) { return; } @@ -1514,8 +1517,6 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, { // VS >= 8 support per-config source locations so we // list object library content as external objects. - cmGeneratorTarget* gt = - this->GlobalGenerator->GetGeneratorTarget(&target); std::vector objs; gt->UseObjectLibraries(objs, ""); if(!objs.empty()) diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index c58e7e4..0a4b546 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -403,7 +403,9 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg, ) { std::vector srcFiles; - target->GetConfigCommonSourceFiles(srcFiles); + cmGeneratorTarget* gtgt = + lg->GetGlobalGenerator()->GetGeneratorTarget(target); + gtgt->GetConfigCommonSourceFiles(srcFiles); for(std::vector::const_iterator fileIt = srcFiles.begin(); fileIt != srcFiles.end(); ++fileIt) @@ -661,7 +663,10 @@ void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target) const char* sepHeaders = ""; std::vector srcFiles; - target->GetConfigCommonSourceFiles(srcFiles); + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); + gtgt->GetConfigCommonSourceFiles(srcFiles); const char *skipMocSep = ""; const char *skipUicSep = ""; @@ -1046,7 +1051,10 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) cmMakefile *makefile = target->GetMakefile(); std::vector srcFiles; - target->GetConfigCommonSourceFiles(srcFiles); + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); + gtgt->GetConfigCommonSourceFiles(srcFiles); std::string qrcInputs; const char* qrcInputsSep = ""; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 682e9b9..40d7ebf 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -726,62 +726,6 @@ void cmTarget::GetSourceFiles(std::vector &files, } //---------------------------------------------------------------------------- -bool -cmTarget::GetConfigCommonSourceFiles(std::vector& files) const -{ - std::vector configs; - this->Makefile->GetConfigurations(configs); - if (configs.empty()) - { - configs.push_back(""); - } - - std::vector::const_iterator it = configs.begin(); - const std::string& firstConfig = *it; - this->GetSourceFiles(files, firstConfig); - - for ( ; it != configs.end(); ++it) - { - std::vector configFiles; - this->GetSourceFiles(configFiles, *it); - if (configFiles != files) - { - std::string firstConfigFiles; - const char* sep = ""; - for (std::vector::const_iterator fi = files.begin(); - fi != files.end(); ++fi) - { - firstConfigFiles += sep; - firstConfigFiles += (*fi)->GetFullPath(); - sep = "\n "; - } - - std::string thisConfigFiles; - sep = ""; - for (std::vector::const_iterator fi = configFiles.begin(); - fi != configFiles.end(); ++fi) - { - thisConfigFiles += sep; - thisConfigFiles += (*fi)->GetFullPath(); - sep = "\n "; - } - std::ostringstream e; - e << "Target \"" << this->Name << "\" has source files which vary by " - "configuration. This is not supported by the \"" - << this->Makefile->GetGlobalGenerator()->GetName() - << "\" generator.\n" - "Config \"" << firstConfig << "\":\n" - " " << firstConfigFiles << "\n" - "Config \"" << *it << "\":\n" - " " << thisConfigFiles << "\n"; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); - return false; - } - } - return true; -} - -//---------------------------------------------------------------------------- void cmTarget::GetSourceFiles(std::vector &files, const std::string& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 8dee560..d032380 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -137,8 +137,6 @@ public: */ void GetSourceFiles(std::vector &files, const std::string& config) const; - bool GetConfigCommonSourceFiles(std::vector& files) const; - /** * Add sources to the target. */ diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 464a83a..e7716d8 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -965,7 +965,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups() std::vector sourceGroups = this->Makefile->GetSourceGroups(); std::vector classes; - if (!this->Target->GetConfigCommonSourceFiles(classes)) + if (!this->GeneratorTarget->GetConfigCommonSourceFiles(classes)) { return; } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=927ceca89e5da76b142bd598fb460bd796caf889 commit 927ceca89e5da76b142bd598fb460bd796caf889 Author: Stephen Kelly AuthorDate: Wed Aug 5 17:37:50 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 26 00:08:23 2015 +0200 cmGeneratorTarget: Move GetLanguages from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 8e126b9..e6507e7 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -4397,6 +4397,57 @@ cmGeneratorTarget::GetLinkImplementation(const std::string& config) const } //---------------------------------------------------------------------------- +void cmGeneratorTarget::GetLanguages(std::set& languages, + const std::string& config) const +{ + std::vector sourceFiles; + this->Target->GetSourceFiles(sourceFiles, config); + for(std::vector::const_iterator + i = sourceFiles.begin(); i != sourceFiles.end(); ++i) + { + const std::string& lang = (*i)->GetLanguage(); + if(!lang.empty()) + { + languages.insert(lang); + } + } + + std::vector objectLibraries; + std::vector externalObjects; + if (!this->Makefile->IsConfigured()) + { + std::vector objectTargets; + this->Target->GetObjectLibrariesCMP0026(objectTargets); + objectLibraries.reserve(objectTargets.size()); + for (std::vector::const_iterator it = objectTargets.begin(); + it != objectTargets.end(); ++it) + { + objectLibraries.push_back(this->GlobalGenerator + ->GetGeneratorTarget(*it)); + } + } + else + { + this->GetExternalObjects(externalObjects, config); + for(std::vector::const_iterator + i = externalObjects.begin(); i != externalObjects.end(); ++i) + { + std::string objLib = (*i)->GetObjectLibrary(); + if (cmTarget* tgt = this->Makefile->FindTargetToUse(objLib)) + { + objectLibraries.push_back(this->GlobalGenerator + ->GetGeneratorTarget(tgt)); + } + } + } + for(std::vector::const_iterator + i = objectLibraries.begin(); i != objectLibraries.end(); ++i) + { + (*i)->GetLanguages(languages, config); + } +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::ComputeLinkImplementationLanguages( const std::string& config, cmOptionalLinkImplementation& impl) const @@ -4404,7 +4455,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLanguages( // This target needs runtime libraries for its source languages. std::set languages; // Get languages used in our source files. - this->Target->GetLanguages(languages, config); + this->GetLanguages(languages, config); // Copy the set of langauges to the link implementation. impl.Languages.insert(impl.Languages.begin(), languages.begin(), languages.end()); diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 7cb3acd..e7ec23a 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -233,6 +233,14 @@ public: cmOptionalLinkImplementation& impl ) const; + // Compute the set of languages compiled by the target. This is + // computed every time it is called because the languages can change + // when source file properties are changed and we do not have enough + // information to forward these property changes to the targets + // until we have per-target object file properties. + void GetLanguages(std::set& languages, + std::string const& config) const; + bool HaveBuildTreeRPATH(const std::string& config) const; /** Full path with trailing slash to the top-level directory diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index b240924..331caad 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -1134,7 +1134,8 @@ bool cmGlobalUnixMakefileGenerator3 ::NeedRequiresStep(cmTarget const& target) { std::set languages; - target.GetLanguages(languages, + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&target); + gtgt->GetLanguages(languages, target.GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE")); for(std::set::const_iterator l = languages.begin(); l != languages.end(); ++l) diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 634366e..9b1f4c2 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -836,6 +836,8 @@ void RegisterVisualStudioMacros(const std::string& macrosFile, bool cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget const& target) { + cmGeneratorTarget* gt = this->GetGeneratorTarget(&target); + // check to see if this is a fortran build std::set languages; { @@ -846,7 +848,7 @@ cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget const& target) return false; } } - target.GetLanguages(languages, ""); + gt->GetLanguages(languages, ""); if(languages.size() == 1) { if(*languages.begin() == "Fortran") diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 68fd06b..4511de5 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1805,7 +1805,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, // Compute the compilation flags for each language. std::set languages; - target.GetLanguages(languages, configName); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); + gtgt->GetLanguages(languages, configName); std::map cflags; for (std::set::iterator li = languages.begin(); li != languages.end(); ++li) @@ -1827,7 +1828,6 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, AddCompileOptions(flags, &target, lang, configName); } - cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); std::string llang = gtgt->GetLinkerLanguage(configName); if(binary && llang.empty()) { diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index ce370bc..589105e 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1257,7 +1257,9 @@ cmLocalUnixMakefileGenerator3 { // Get the set of source languages in the target. std::set languages; - target.GetLanguages(languages, + cmGeneratorTarget *gtgt = + this->GlobalGenerator->GetGeneratorTarget(&target); + gtgt->GetLanguages(languages, this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); fout << "\n" << "# Per-language clean rules from dependency scanning.\n" diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 0b3df90..cf88a74 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -276,7 +276,7 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags() { // write language flags for target std::set languages; - this->Target->GetLanguages(languages, + this->GeneratorTarget->GetLanguages(languages, this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); // put the compiler in the rules.make file so that if it changes // things rebuild diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e8a315d..682e9b9 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3132,50 +3132,6 @@ cmTarget::GetObjectLibrariesCMP0026(std::vector& objlibs) const } //---------------------------------------------------------------------------- -void cmTarget::GetLanguages(std::set& languages, - const std::string& config) const -{ - std::vector sourceFiles; - this->GetSourceFiles(sourceFiles, config); - for(std::vector::const_iterator - i = sourceFiles.begin(); i != sourceFiles.end(); ++i) - { - const std::string& lang = (*i)->GetLanguage(); - if(!lang.empty()) - { - languages.insert(lang); - } - } - - std::vector objectLibraries; - std::vector externalObjects; - if (!this->Makefile->IsConfigured()) - { - this->GetObjectLibrariesCMP0026(objectLibraries); - } - else - { - cmGeneratorTarget* gt = this->Makefile->GetGlobalGenerator() - ->GetGeneratorTarget(this); - gt->GetExternalObjects(externalObjects, config); - for(std::vector::const_iterator - i = externalObjects.begin(); i != externalObjects.end(); ++i) - { - std::string objLib = (*i)->GetObjectLibrary(); - if (cmTarget* tgt = this->Makefile->FindTargetToUse(objLib)) - { - objectLibraries.push_back(tgt); - } - } - } - for(std::vector::const_iterator - i = objectLibraries.begin(); i != objectLibraries.end(); ++i) - { - (*i)->GetLanguages(languages, config); - } -} - -//---------------------------------------------------------------------------- cmTarget::ImportInfo const* cmTarget::GetImportInfo(const std::string& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 1db4ba1..8dee560 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -305,14 +305,6 @@ public: If no macro should be defined null is returned. */ const char* GetExportMacro() const; - // Compute the set of languages compiled by the target. This is - // computed every time it is called because the languages can change - // when source file properties are changed and we do not have enough - // information to forward these property changes to the targets - // until we have per-target object file properties. - void GetLanguages(std::set& languages, - std::string const& config) const; - /** Return whether this target is an executable with symbol exports enabled. */ bool IsExecutableWithExports() const; ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From kwrobot at kitware.com Wed Aug 26 00:01:10 2015 From: kwrobot at kitware.com (Kitware Robot) Date: Wed, 26 Aug 2015 00:01:10 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-945-g33df7f3 Message-ID: <20150826040110.4317BB1A26@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 33df7f36d0b99a87880ee76d39b5814c98e78bd1 (commit) from cdb9984bff78b8f76c3b8c3f622928e4f29920a1 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=33df7f36d0b99a87880ee76d39b5814c98e78bd1 commit 33df7f36d0b99a87880ee76d39b5814c98e78bd1 Author: Kitware Robot AuthorDate: Wed Aug 26 00:01:07 2015 -0400 Commit: Kitware Robot CommitDate: Wed Aug 26 00:01:07 2015 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 4e0b28c..aa25287 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150825) +set(CMake_VERSION_PATCH 20150826) #set(CMake_VERSION_RC 1) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From steveire at gmail.com Wed Aug 26 02:06:34 2015 From: steveire at gmail.com (Stephen Kelly) Date: Wed, 26 Aug 2015 02:06:34 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2528-g6fbcda2 Message-ID: <20150826060637.05566B0AC3@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 6fbcda20e178eaa6fb5c4fd0a78f3623f190ae60 (commit) via b95c988484b1a65d6c94fbba53c756316449ef14 (commit) from b847cf94af02e660f611e333e384d35c6c38f5c1 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6fbcda20e178eaa6fb5c4fd0a78f3623f190ae60 commit 6fbcda20e178eaa6fb5c4fd0a78f3623f190ae60 Merge: b847cf9 b95c988 Author: Stephen Kelly AuthorDate: Wed Aug 26 02:06:31 2015 -0400 Commit: CMake Topic Stage CommitDate: Wed Aug 26 02:06:31 2015 -0400 Merge topic 'use-generator-target' into next b95c9884 Revert topic. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b95c988484b1a65d6c94fbba53c756316449ef14 commit b95c988484b1a65d6c94fbba53c756316449ef14 Author: Stephen Kelly AuthorDate: Wed Aug 26 08:05:55 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 26 08:06:05 2015 +0200 Revert topic. diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 5a5c1c1..59590fd 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -361,10 +361,8 @@ void cmComputeLinkDepends::FollowLinkEntry(BFSEntry const& qe) if(entry.Target) { // Follow the target dependencies. - cmGeneratorTarget* gtgt = - this->GlobalGenerator->GetGeneratorTarget(entry.Target); - if(cmGeneratorTarget::LinkInterface const* iface = - gtgt->GetLinkInterface(this->Config, this->Target->Target)) + if(cmTarget::LinkInterface const* iface = + entry.Target->GetLinkInterface(this->Config, this->Target->Target)) { const bool isIface = entry.Target->GetType() == cmTarget::INTERFACE_LIBRARY; @@ -398,8 +396,7 @@ void cmComputeLinkDepends::FollowLinkEntry(BFSEntry const& qe) //---------------------------------------------------------------------------- void cmComputeLinkDepends -::FollowSharedDeps(int depender_index, - cmGeneratorTarget::LinkInterface const* iface, +::FollowSharedDeps(int depender_index, cmTarget::LinkInterface const* iface, bool follow_interface) { // Follow dependencies if we have not followed them already. @@ -462,10 +459,8 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep) // Target items may have their own dependencies. if(entry.Target) { - cmGeneratorTarget* gtgt = - this->GlobalGenerator->GetGeneratorTarget(entry.Target); - if(cmGeneratorTarget::LinkInterface const* iface = - gtgt->GetLinkInterface(this->Config, this->Target->Target)) + if(cmTarget::LinkInterface const* iface = + entry.Target->GetLinkInterface(this->Config, this->Target->Target)) { // Follow public and private dependencies transitively. this->FollowSharedDeps(index, iface, true); @@ -555,8 +550,8 @@ void cmComputeLinkDepends::AddVarLinkEntries(int depender_index, void cmComputeLinkDepends::AddDirectLinkEntries() { // Add direct link dependencies in this configuration. - cmLinkImplementation const* impl = - this->Target->GetLinkImplementation(this->Config); + cmTarget::LinkImplementation const* impl = + this->Target->Target->GetLinkImplementation(this->Config); this->AddLinkEntries(-1, impl->Libraries); for(std::vector::const_iterator wi = impl->WrongConfigLibraries.begin(); @@ -935,10 +930,8 @@ int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl) { if(cmTarget const* target = this->EntryList[*ni].Target) { - cmGeneratorTarget* gtgt = - this->GlobalGenerator->GetGeneratorTarget(target); - if(cmGeneratorTarget::LinkInterface const* iface = - gtgt->GetLinkInterface(this->Config, this->Target->Target)) + if(cmTarget::LinkInterface const* iface = + target->GetLinkInterface(this->Config, this->Target->Target)) { if(iface->Multiplicity > count) { diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index e61175a..b925a4f 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -13,7 +13,6 @@ #define cmComputeLinkDepends_h #include "cmStandardIncludes.h" -#include "cmGeneratorTarget.h" #include "cmTarget.h" #include "cmGraphAdjacencyList.h" @@ -23,6 +22,8 @@ class cmComputeComponentGraph; class cmGlobalGenerator; class cmMakefile; +class cmGeneratorTarget; +class cmTarget; class cmake; /** \class cmComputeLinkDepends @@ -101,7 +102,7 @@ private: std::queue SharedDepQueue; std::set SharedDepFollowed; void FollowSharedDeps(int depender_index, - cmGeneratorTarget::LinkInterface const* iface, + cmTarget::LinkInterface const* iface, bool follow_interface = false); void QueueSharedDependencies(int depender_index, std::vector const& deps); diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 192ad5f..6ba0eed 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -1925,7 +1925,7 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, (outputRuntime && this->Target->Target->HaveInstallTreeRPATH() && linking_for_install); bool use_build_rpath = - (outputRuntime && this->Target->HaveBuildTreeRPATH(this->Config) && + (outputRuntime && this->Target->Target->HaveBuildTreeRPATH(this->Config) && !linking_for_install); bool use_link_rpath = outputRuntime && linking_for_install && diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index 7488e09..c4a03a0 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -252,7 +252,8 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) } } - cmLinkImplementation const* impl = depender->GetLinkImplementation(*it); + cmTarget::LinkImplementation const* impl = + depender->Target->GetLinkImplementation(*it); // A target should not depend on itself. emitted.insert(depender->GetName()); @@ -295,8 +296,8 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, std::set &emitted) { cmGeneratorTarget const* depender = this->Targets[depender_index]; - if(cmGeneratorTarget::LinkInterface const* iface = - dependee->GetLinkInterface(config, + if(cmTarget::LinkInterface const* iface = + dependee->Target->GetLinkInterface(config, depender->Target)) { for(std::vector::const_iterator diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 97eb6b9..cae60b7 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -796,7 +796,7 @@ cmExportFileGenerator std::vector& missingTargets) { // Add the transitive link dependencies for this configuration. - cmGeneratorTarget::LinkInterface const* iface = target->GetLinkInterface( + cmTarget::LinkInterface const* iface = target->Target->GetLinkInterface( config, target->Target); if (!iface) @@ -909,8 +909,9 @@ cmExportFileGenerator } // Add the transitive link dependencies for this configuration. - if(cmGeneratorTarget::LinkInterface const* iface = - target->GetLinkInterface(config, target->Target)) + if(cmTarget::LinkInterface const* iface = + target->Target + ->GetLinkInterface(config, target->Target)) { this->SetImportLinkProperty(suffix, target, "IMPORTED_LINK_INTERFACE_LANGUAGES", diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index dfd51c7..933a256 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -609,7 +609,7 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, // the compilerdefines for this target std::vector cdefs; - gtgt->GetCompileDefinitions(cdefs, buildType, "C"); + target->GetCompileDefinitions(cdefs, buildType, "C"); // Expand the list. for(std::vector::const_iterator di = cdefs.begin(); diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index b957379..03bc83a 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1108,8 +1108,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode if(isInterfaceProperty) { - if(cmGeneratorTarget::LinkInterfaceLibraries const* iface = - gtgt->GetLinkInterfaceLibraries(context->Config, headTarget, true)) + if(cmTarget::LinkInterfaceLibraries const* iface = + target->GetLinkInterfaceLibraries(context->Config, headTarget, true)) { linkedTargetsContent = getLinkedTargetsContent(iface->Libraries, target, diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 5c83879..dd58e7b 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -34,18 +34,6 @@ #define UNORDERED_SET std::set #endif -class cmGeneratorTarget::TargetPropertyEntry { - static cmLinkImplItem NoLinkImplItem; -public: - TargetPropertyEntry(cmsys::auto_ptr cge, - cmLinkImplItem const& item = NoLinkImplItem) - : ge(cge), LinkImplItem(item) - {} - const cmsys::auto_ptr ge; - cmLinkImplItem const& LinkImplItem; -}; -cmLinkImplItem cmGeneratorTarget::TargetPropertyEntry::NoLinkImplItem; - //---------------------------------------------------------------------------- void reportBadObjLib(std::vector const& badObjLib, cmGeneratorTarget const* target, cmake *cm) @@ -239,63 +227,18 @@ struct TagVisitor } }; -void CreatePropertyGeneratorExpressions( - cmStringRange const& entries, - cmBacktraceRange const& backtraces, - std::vector& items, - bool evaluateForBuildsystem = false) -{ - std::vector::const_iterator btIt = backtraces.begin(); - for (std::vector::const_iterator it = entries.begin(); - it != entries.end(); ++it, ++btIt) - { - cmGeneratorExpression ge(*btIt); - cmsys::auto_ptr cge = ge.Parse(*it); - cge->SetEvaluateForBuildsystem(evaluateForBuildsystem); - items.push_back(new cmGeneratorTarget::TargetPropertyEntry(cge)); - } -} - //---------------------------------------------------------------------------- cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) : Target(t), - SourceFileFlagsConstructed(false), - DebugIncludesDone(false), - DebugCompileOptionsDone(false), - DebugCompileFeaturesDone(false), - DebugCompileDefinitionsDone(false) + SourceFileFlagsConstructed(false) { this->Makefile = this->Target->GetMakefile(); this->LocalGenerator = lg; this->GlobalGenerator = this->LocalGenerator->GetGlobalGenerator(); - - CreatePropertyGeneratorExpressions( - t->GetIncludeDirectoriesEntries(), - t->GetIncludeDirectoriesBacktraces(), - this->IncludeDirectoriesEntries); - - CreatePropertyGeneratorExpressions( - t->GetCompileOptionsEntries(), - t->GetCompileOptionsBacktraces(), - this->CompileOptionsEntries); - - CreatePropertyGeneratorExpressions( - t->GetCompileFeaturesEntries(), - t->GetCompileFeaturesBacktraces(), - this->CompileFeaturesEntries); - - CreatePropertyGeneratorExpressions( - t->GetCompileDefinitionsEntries(), - t->GetCompileDefinitionsBacktraces(), - this->CompileDefinitionsEntries); } cmGeneratorTarget::~cmGeneratorTarget() { - cmDeleteAll(this->IncludeDirectoriesEntries); - cmDeleteAll(this->CompileOptionsEntries); - cmDeleteAll(this->CompileFeaturesEntries); - cmDeleteAll(this->CompileDefinitionsEntries); cmDeleteAll(this->LinkInformation); this->LinkInformation.clear(); } @@ -908,7 +851,7 @@ cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const // If either a build or install tree rpath is set then the rpath // will likely change between the build tree and install tree and // this target must be relinked. - return this->HaveBuildTreeRPATH(config) + return this->Target->HaveBuildTreeRPATH(config) || this->Target->HaveInstallTreeRPATH(); } @@ -1230,11 +1173,8 @@ public: return; } - cmGeneratorTarget* gtgt = - this->Target->GetLocalGenerator()->GetGlobalGenerator() - ->GetGeneratorTarget(item.Target); - cmGeneratorTarget::LinkInterface const* iface = - gtgt->GetLinkInterface(this->Config, this->HeadTarget); + cmTarget::LinkInterface const* iface = + item.Target->GetLinkInterface(this->Config, this->HeadTarget); if(!iface) { return; } for(std::vector::const_iterator @@ -1335,8 +1275,8 @@ void cmGeneratorTarget::ComputeLinkClosure(const std::string& config, { // Get languages built in this target. UNORDERED_SET languages; - cmLinkImplementation const* impl = - this->GetLinkImplementation(config); + cmTarget::LinkImplementation const* impl = + this->Target->GetLinkImplementation(config); assert(impl); for(std::vector::const_iterator li = impl->Languages.begin(); li != impl->Languages.end(); ++li) @@ -1565,22 +1505,20 @@ void cmGeneratorTarget::GetAutoUicOptions(std::vector &result, void processILibs(const std::string& config, cmTarget const* headTarget, cmLinkItem const& item, - cmGlobalGenerator* gg, std::vector& tgts, std::set& emitted) { if (item.Target && emitted.insert(item.Target).second) { tgts.push_back(item.Target); - cmGeneratorTarget* gt = gg->GetGeneratorTarget(item.Target); - if(cmGeneratorTarget::LinkInterfaceLibraries const* iface = - gt->GetLinkInterfaceLibraries(config, headTarget, true)) + if(cmTarget::LinkInterfaceLibraries const* iface = + item.Target->GetLinkInterfaceLibraries(config, headTarget, true)) { for(std::vector::const_iterator it = iface->Libraries.begin(); it != iface->Libraries.end(); ++it) { - processILibs(config, headTarget, *it, gg, tgts, emitted); + processILibs(config, headTarget, *it, tgts, emitted); } } } @@ -1605,9 +1543,7 @@ cmGeneratorTarget::GetLinkImplementationClosure( it = impl->Libraries.begin(); it != impl->Libraries.end(); ++it) { - processILibs(config, this->Target, *it, - this->LocalGenerator->GetGlobalGenerator(), - tgts, emitted); + processILibs(config, this->Target, *it, tgts , emitted); } } return tgts; @@ -2021,536 +1957,13 @@ cmGeneratorTarget::GetCreateRuleVariable(std::string const& lang, } return ""; } -//---------------------------------------------------------------------------- -static void processIncludeDirectories(cmGeneratorTarget const* tgt, - const std::vector &entries, - std::vector &includes, - UNORDERED_SET &uniqueIncludes, - cmGeneratorExpressionDAGChecker *dagChecker, - const std::string& config, bool debugIncludes, - const std::string& language) -{ - cmMakefile *mf = tgt->Target->GetMakefile(); - - for (std::vector::const_iterator - it = entries.begin(), end = entries.end(); it != end; ++it) - { - cmLinkImplItem const& item = (*it)->LinkImplItem; - std::string const& targetName = item; - bool const fromImported = item.Target && item.Target->IsImported(); - bool const checkCMP0027 = item.FromGenex; - std::vector entryIncludes; - cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf, - config, - false, - tgt->Target, - dagChecker, language), - entryIncludes); - - std::string usedIncludes; - for(std::vector::iterator - li = entryIncludes.begin(); li != entryIncludes.end(); ++li) - { - if (fromImported - && !cmSystemTools::FileExists(li->c_str())) - { - std::ostringstream e; - cmake::MessageType messageType = cmake::FATAL_ERROR; - if (checkCMP0027) - { - switch(tgt->Target->GetPolicyStatusCMP0027()) - { - case cmPolicies::WARN: - e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0027) << "\n"; - case cmPolicies::OLD: - messageType = cmake::AUTHOR_WARNING; - break; - case cmPolicies::REQUIRED_ALWAYS: - case cmPolicies::REQUIRED_IF_USED: - case cmPolicies::NEW: - break; - } - } - e << "Imported target \"" << targetName << "\" includes " - "non-existent path\n \"" << *li << "\"\nin its " - "INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:\n" - "* The path was deleted, renamed, or moved to another " - "location.\n" - "* An install or uninstall procedure did not complete " - "successfully.\n" - "* The installation package was faulty and references files it " - "does not provide.\n"; - tgt->GetLocalGenerator()->IssueMessage(messageType, e.str()); - return; - } - - if (!cmSystemTools::FileIsFullPath(li->c_str())) - { - std::ostringstream e; - bool noMessage = false; - cmake::MessageType messageType = cmake::FATAL_ERROR; - if (!targetName.empty()) - { - e << "Target \"" << targetName << "\" contains relative " - "path in its INTERFACE_INCLUDE_DIRECTORIES:\n" - " \"" << *li << "\""; - } - else - { - switch(tgt->Target->GetPolicyStatusCMP0021()) - { - case cmPolicies::WARN: - { - e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0021) << "\n"; - messageType = cmake::AUTHOR_WARNING; - } - break; - case cmPolicies::OLD: - noMessage = true; - case cmPolicies::REQUIRED_IF_USED: - case cmPolicies::REQUIRED_ALWAYS: - case cmPolicies::NEW: - // Issue the fatal message. - break; - } - e << "Found relative path while evaluating include directories of " - "\"" << tgt->GetName() << "\":\n \"" << *li << "\"\n"; - } - if (!noMessage) - { - tgt->GetLocalGenerator()->IssueMessage(messageType, e.str()); - if (messageType == cmake::FATAL_ERROR) - { - return; - } - } - } - - if (!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 (!usedIncludes.empty()) - { - mf->GetCMakeInstance()->IssueMessage(cmake::LOG, - std::string("Used includes for target ") - + tgt->GetName() + ":\n" - + usedIncludes, (*it)->ge->GetBacktrace()); - } - } -} - - -//---------------------------------------------------------------------------- -static void AddInterfaceEntries( - cmGeneratorTarget const* thisTarget, std::string const& config, - std::string const& prop, - std::vector& entries) -{ - if(cmLinkImplementationLibraries const* impl = - thisTarget->Target->GetLinkImplementationLibraries(config)) - { - for (std::vector::const_iterator - it = impl->Libraries.begin(), end = impl->Libraries.end(); - it != end; ++it) - { - if(it->Target) - { - std::string genex = - "$"; - cmGeneratorExpression ge(it->Backtrace); - cmsys::auto_ptr cge = ge.Parse(genex); - cge->SetEvaluateForBuildsystem(true); - entries.push_back( - new cmGeneratorTarget::TargetPropertyEntry(cge, *it)); - } - } - } -} //---------------------------------------------------------------------------- std::vector cmGeneratorTarget::GetIncludeDirectories(const std::string& config, const std::string& lang) const { - std::vector includes; - UNORDERED_SET uniqueIncludes; - - cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), - "INCLUDE_DIRECTORIES", 0, 0); - - std::vector debugProperties; - const char *debugProp = - this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); - if (debugProp) - { - cmSystemTools::ExpandListArgument(debugProp, debugProperties); - } - - bool debugIncludes = !this->DebugIncludesDone - && std::find(debugProperties.begin(), - debugProperties.end(), - "INCLUDE_DIRECTORIES") - != debugProperties.end(); - - if (this->Makefile->IsConfigured()) - { - this->DebugIncludesDone = true; - } - - processIncludeDirectories(this, - this->IncludeDirectoriesEntries, - includes, - uniqueIncludes, - &dagChecker, - config, - debugIncludes, - lang); - - std::vector - linkInterfaceIncludeDirectoriesEntries; - AddInterfaceEntries( - this, config, "INTERFACE_INCLUDE_DIRECTORIES", - linkInterfaceIncludeDirectoriesEntries); - - if(this->Makefile->IsOn("APPLE")) - { - cmLinkImplementationLibraries const* impl = - this->Target->GetLinkImplementationLibraries(config); - for(std::vector::const_iterator - it = impl->Libraries.begin(); - it != impl->Libraries.end(); ++it) - { - std::string libDir = cmSystemTools::CollapseFullPath(*it); - - static cmsys::RegularExpression - frameworkCheck("(.*\\.framework)(/Versions/[^/]+)?/[^/]+$"); - if(!frameworkCheck.find(libDir)) - { - continue; - } - - libDir = frameworkCheck.match(1); - - cmGeneratorExpression ge; - cmsys::auto_ptr cge = - ge.Parse(libDir.c_str()); - linkInterfaceIncludeDirectoriesEntries - .push_back(new cmGeneratorTarget::TargetPropertyEntry(cge)); - } - } - - processIncludeDirectories(this, - linkInterfaceIncludeDirectoriesEntries, - includes, - uniqueIncludes, - &dagChecker, - config, - debugIncludes, - lang); - - cmDeleteAll(linkInterfaceIncludeDirectoriesEntries); - - return includes; -} - -//---------------------------------------------------------------------------- -static void processCompileOptionsInternal(cmGeneratorTarget const* tgt, - const std::vector &entries, - std::vector &options, - UNORDERED_SET &uniqueOptions, - cmGeneratorExpressionDAGChecker *dagChecker, - const std::string& config, bool debugOptions, const char *logName, - std::string const& language) -{ - cmMakefile *mf = tgt->Target->GetMakefile(); - - for (std::vector::const_iterator - it = entries.begin(), end = entries.end(); it != end; ++it) - { - std::vector entryOptions; - cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf, - config, - false, - tgt->Target, - dagChecker, - language), - entryOptions); - std::string usedOptions; - for(std::vector::iterator - li = entryOptions.begin(); li != entryOptions.end(); ++li) - { - std::string const& opt = *li; - - if(uniqueOptions.insert(opt).second) - { - options.push_back(opt); - if (debugOptions) - { - usedOptions += " * " + opt + "\n"; - } - } - } - if (!usedOptions.empty()) - { - mf->GetCMakeInstance()->IssueMessage(cmake::LOG, - std::string("Used compile ") + logName - + std::string(" for target ") - + tgt->GetName() + ":\n" - + usedOptions, (*it)->ge->GetBacktrace()); - } - } -} - -//---------------------------------------------------------------------------- -static void processCompileOptions(cmGeneratorTarget const* tgt, - const std::vector &entries, - std::vector &options, - UNORDERED_SET &uniqueOptions, - cmGeneratorExpressionDAGChecker *dagChecker, - const std::string& config, bool debugOptions, - std::string const& language) -{ - processCompileOptionsInternal(tgt, entries, options, uniqueOptions, - dagChecker, config, debugOptions, "options", - language); -} - -//---------------------------------------------------------------------------- -void cmGeneratorTarget::GetCompileOptions(std::vector &result, - const std::string& config, - const std::string& language) const -{ - UNORDERED_SET uniqueOptions; - - cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), - "COMPILE_OPTIONS", 0, 0); - - std::vector debugProperties; - const char *debugProp = - this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); - if (debugProp) - { - cmSystemTools::ExpandListArgument(debugProp, debugProperties); - } - - bool debugOptions = !this->DebugCompileOptionsDone - && std::find(debugProperties.begin(), - debugProperties.end(), - "COMPILE_OPTIONS") - != debugProperties.end(); - - if (this->Makefile->IsConfigured()) - { - this->DebugCompileOptionsDone = true; - } - - processCompileOptions(this, - this->CompileOptionsEntries, - result, - uniqueOptions, - &dagChecker, - config, - debugOptions, - language); - - std::vector - linkInterfaceCompileOptionsEntries; - - AddInterfaceEntries( - this, config, "INTERFACE_COMPILE_OPTIONS", - linkInterfaceCompileOptionsEntries); - - processCompileOptions(this, - linkInterfaceCompileOptionsEntries, - result, - uniqueOptions, - &dagChecker, - config, - debugOptions, - language); - - cmDeleteAll(linkInterfaceCompileOptionsEntries); -} - -//---------------------------------------------------------------------------- -static void processCompileFeatures(cmGeneratorTarget const* tgt, - const std::vector &entries, - std::vector &options, - UNORDERED_SET &uniqueOptions, - cmGeneratorExpressionDAGChecker *dagChecker, - const std::string& config, bool debugOptions) -{ - processCompileOptionsInternal(tgt, entries, options, uniqueOptions, - dagChecker, config, debugOptions, "features", - std::string()); -} - -//---------------------------------------------------------------------------- -void cmGeneratorTarget::GetCompileFeatures(std::vector &result, - const std::string& config) const -{ - UNORDERED_SET uniqueFeatures; - - cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), - "COMPILE_FEATURES", - 0, 0); - - std::vector debugProperties; - const char *debugProp = - this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); - if (debugProp) - { - cmSystemTools::ExpandListArgument(debugProp, debugProperties); - } - - bool debugFeatures = !this->DebugCompileFeaturesDone - && std::find(debugProperties.begin(), - debugProperties.end(), - "COMPILE_FEATURES") - != debugProperties.end(); - - if (this->Makefile->IsConfigured()) - { - this->DebugCompileFeaturesDone = true; - } - - processCompileFeatures(this, - this->CompileFeaturesEntries, - result, - uniqueFeatures, - &dagChecker, - config, - debugFeatures); - - std::vector - linkInterfaceCompileFeaturesEntries; - AddInterfaceEntries( - this, config, "INTERFACE_COMPILE_FEATURES", - linkInterfaceCompileFeaturesEntries); - - processCompileFeatures(this, - linkInterfaceCompileFeaturesEntries, - result, - uniqueFeatures, - &dagChecker, - config, - debugFeatures); - - cmDeleteAll(linkInterfaceCompileFeaturesEntries); -} - -//---------------------------------------------------------------------------- -static void processCompileDefinitions(cmGeneratorTarget const* tgt, - const std::vector &entries, - std::vector &options, - UNORDERED_SET &uniqueOptions, - cmGeneratorExpressionDAGChecker *dagChecker, - const std::string& config, bool debugOptions, - std::string const& language) -{ - processCompileOptionsInternal(tgt, entries, options, uniqueOptions, - dagChecker, config, debugOptions, - "definitions", language); -} - -//---------------------------------------------------------------------------- -void cmGeneratorTarget::GetCompileDefinitions(std::vector &list, - const std::string& config, - const std::string& language) const -{ - UNORDERED_SET uniqueOptions; - - cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), - "COMPILE_DEFINITIONS", 0, 0); - - std::vector debugProperties; - const char *debugProp = - this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); - if (debugProp) - { - cmSystemTools::ExpandListArgument(debugProp, debugProperties); - } - - bool debugDefines = !this->DebugCompileDefinitionsDone - && std::find(debugProperties.begin(), - debugProperties.end(), - "COMPILE_DEFINITIONS") - != debugProperties.end(); - - if (this->Makefile->IsConfigured()) - { - this->DebugCompileDefinitionsDone = true; - } - - processCompileDefinitions(this, - this->CompileDefinitionsEntries, - list, - uniqueOptions, - &dagChecker, - config, - debugDefines, - language); - - std::vector - linkInterfaceCompileDefinitionsEntries; - AddInterfaceEntries( - this, config, "INTERFACE_COMPILE_DEFINITIONS", - linkInterfaceCompileDefinitionsEntries); - if (!config.empty()) - { - std::string configPropName = "COMPILE_DEFINITIONS_" - + cmSystemTools::UpperCase(config); - const char *configProp = this->Target->GetProperty(configPropName); - if (configProp) - { - switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0043)) - { - case cmPolicies::WARN: - { - std::ostringstream e; - e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0043); - this->LocalGenerator->IssueMessage(cmake::AUTHOR_WARNING, - e.str()); - } - case cmPolicies::OLD: - { - cmGeneratorExpression ge; - cmsys::auto_ptr cge = - ge.Parse(configProp); - linkInterfaceCompileDefinitionsEntries - .push_back(new cmGeneratorTarget::TargetPropertyEntry(cge)); - } - break; - case cmPolicies::NEW: - case cmPolicies::REQUIRED_ALWAYS: - case cmPolicies::REQUIRED_IF_USED: - break; - } - } - } - - processCompileDefinitions(this, - linkInterfaceCompileDefinitionsEntries, - list, - uniqueOptions, - &dagChecker, - config, - debugDefines, - language); - - cmDeleteAll(linkInterfaceCompileDefinitionsEntries); + return this->Target->GetIncludeDirectories(config, lang); } //---------------------------------------------------------------------------- @@ -3941,594 +3354,3 @@ cmGeneratorTarget::ReportPropertyOrigin(const std::string &p, this->Makefile->GetCMakeInstance()->IssueMessage(cmake::LOG, areport); } - -//---------------------------------------------------------------------------- -void cmGeneratorTarget::LookupLinkItems(std::vector const& names, - std::vector& items) const -{ - for(std::vector::const_iterator i = names.begin(); - i != names.end(); ++i) - { - std::string name = this->Target->CheckCMP0004(*i); - if(name == this->GetName() || name.empty()) - { - continue; - } - items.push_back(cmLinkItem(name, this->Target->FindTargetToLink(name))); - } -} - -//---------------------------------------------------------------------------- -void cmGeneratorTarget::ExpandLinkItems(std::string const& prop, - std::string const& value, - std::string const& config, - cmTarget const* headTarget, - bool usage_requirements_only, - std::vector& items, - bool& hadHeadSensitiveCondition) const -{ - cmGeneratorExpression ge; - cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), prop, 0, 0); - // The $ expression may be in a link interface to specify private - // link dependencies that are otherwise excluded from usage requirements. - if(usage_requirements_only) - { - dagChecker.SetTransitivePropertiesOnly(); - } - std::vector libs; - cmsys::auto_ptr cge = ge.Parse(value); - cmSystemTools::ExpandListArgument(cge->Evaluate( - this->Makefile, - config, - false, - headTarget, - this->Target, &dagChecker), libs); - this->LookupLinkItems(libs, items); - hadHeadSensitiveCondition = cge->GetHadHeadSensitiveCondition(); -} - -//---------------------------------------------------------------------------- -cmGeneratorTarget::LinkInterface const* cmGeneratorTarget::GetLinkInterface( - const std::string& config, - cmTarget const* head) const -{ - // Imported targets have their own link interface. - if(this->Target->IsImported()) - { - return this->GetImportLinkInterface(config, head, false); - } - - // Link interfaces are not supported for executables that do not - // export symbols. - if(this->GetType() == cmTarget::EXECUTABLE && - !this->Target->IsExecutableWithExports()) - { - return 0; - } - - // Lookup any existing link interface for this configuration. - std::string CONFIG = cmSystemTools::UpperCase(config); - HeadToLinkInterfaceMap& hm = this->LinkInterfaceMap[CONFIG]; - - // If the link interface does not depend on the head target - // then return the one we computed first. - if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) - { - return &hm.begin()->second; - } - - OptionalLinkInterface& iface = hm[head]; - if(!iface.LibrariesDone) - { - iface.LibrariesDone = true; - this->ComputeLinkInterfaceLibraries( - config, iface, head, false); - } - if(!iface.AllDone) - { - iface.AllDone = true; - if(iface.Exists) - { - this->ComputeLinkInterface(config, iface, head); - } - } - - return iface.Exists? &iface : 0; -} - -//---------------------------------------------------------------------------- -cmGeneratorTarget::LinkInterfaceLibraries const* -cmGeneratorTarget::GetLinkInterfaceLibraries(const std::string& config, - cmTarget const* head, - bool usage_requirements_only) const -{ - // Imported targets have their own link interface. - if(this->Target->IsImported()) - { - return this->GetImportLinkInterface(config, head, usage_requirements_only); - } - - // Link interfaces are not supported for executables that do not - // export symbols. - if(this->GetType() == cmTarget::EXECUTABLE && - !this->Target->IsExecutableWithExports()) - { - return 0; - } - - // Lookup any existing link interface for this configuration. - std::string CONFIG = cmSystemTools::UpperCase(config); - HeadToLinkInterfaceMap& hm = - (usage_requirements_only ? - this->LinkInterfaceUsageRequirementsOnlyMap[CONFIG] : - this->LinkInterfaceMap[CONFIG]); - - // If the link interface does not depend on the head target - // then return the one we computed first. - if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) - { - return &hm.begin()->second; - } - - OptionalLinkInterface& iface = hm[head]; - if(!iface.LibrariesDone) - { - iface.LibrariesDone = true; - this->ComputeLinkInterfaceLibraries( - config, iface, head, usage_requirements_only); - } - - return iface.Exists? &iface : 0; -} - -//---------------------------------------------------------------------------- -cmGeneratorTarget::LinkInterface const* -cmGeneratorTarget::GetImportLinkInterface(const std::string& config, - cmTarget const* headTarget, - bool usage_requirements_only) const -{ - cmTarget::ImportInfo const* info = this->Target->GetImportInfo(config); - if(!info) - { - return 0; - } - - std::string CONFIG = cmSystemTools::UpperCase(config); - HeadToLinkInterfaceMap& hm = - (usage_requirements_only ? - this->LinkInterfaceUsageRequirementsOnlyMap[CONFIG] : - this->LinkInterfaceMap[CONFIG]); - - // If the link interface does not depend on the head target - // then return the one we computed first. - if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) - { - return &hm.begin()->second; - } - - OptionalLinkInterface& iface = hm[headTarget]; - if(!iface.AllDone) - { - iface.AllDone = true; - iface.Multiplicity = info->Multiplicity; - cmSystemTools::ExpandListArgument(info->Languages, iface.Languages); - this->ExpandLinkItems(info->LibrariesProp, info->Libraries, config, - headTarget, usage_requirements_only, - iface.Libraries, - iface.HadHeadSensitiveCondition); - std::vector deps; - cmSystemTools::ExpandListArgument(info->SharedDeps, deps); - this->LookupLinkItems(deps, iface.SharedDeps); - } - - return &iface; -} - -//---------------------------------------------------------------------------- -void -cmGeneratorTarget::ComputeLinkInterfaceLibraries( - const std::string& config, - OptionalLinkInterface& iface, - cmTarget const* headTarget, - bool usage_requirements_only) const -{ - // Construct the property name suffix for this configuration. - std::string suffix = "_"; - if(!config.empty()) - { - suffix += cmSystemTools::UpperCase(config); - } - else - { - suffix += "NOCONFIG"; - } - - // An explicit list of interface libraries may be set for shared - // libraries and executables that export symbols. - const char* explicitLibraries = 0; - std::string linkIfaceProp; - if(this->Target->GetPolicyStatusCMP0022() != cmPolicies::OLD && - this->Target->GetPolicyStatusCMP0022() != cmPolicies::WARN) - { - // CMP0022 NEW behavior is to use INTERFACE_LINK_LIBRARIES. - linkIfaceProp = "INTERFACE_LINK_LIBRARIES"; - explicitLibraries = this->Target->GetProperty(linkIfaceProp); - } - else if(this->Target->GetType() == cmTarget::SHARED_LIBRARY || - this->Target->IsExecutableWithExports()) - { - // CMP0022 OLD behavior is to use LINK_INTERFACE_LIBRARIES if set on a - // shared lib or executable. - - // Lookup the per-configuration property. - linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; - linkIfaceProp += suffix; - explicitLibraries = this->Target->GetProperty(linkIfaceProp); - - // If not set, try the generic property. - if(!explicitLibraries) - { - linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; - explicitLibraries = this->Target->GetProperty(linkIfaceProp); - } - } - - if(explicitLibraries && - this->Target->GetPolicyStatusCMP0022() == cmPolicies::WARN && - !this->PolicyWarnedCMP0022) - { - // Compare the explicitly set old link interface properties to the - // preferred new link interface property one and warn if different. - const char* newExplicitLibraries = - this->Target->GetProperty("INTERFACE_LINK_LIBRARIES"); - if (newExplicitLibraries - && strcmp(newExplicitLibraries, explicitLibraries) != 0) - { - std::ostringstream w; - w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n" - "Target \"" << this->Target->GetName() << "\" has an " - "INTERFACE_LINK_LIBRARIES property which differs from its " << - linkIfaceProp << " properties." - "\n" - "INTERFACE_LINK_LIBRARIES:\n" - " " << newExplicitLibraries << "\n" << - linkIfaceProp << ":\n" - " " << (explicitLibraries ? explicitLibraries : "(empty)") << "\n"; - this->LocalGenerator->IssueMessage(cmake::AUTHOR_WARNING, w.str()); - this->PolicyWarnedCMP0022 = true; - } - } - - // There is no implicit link interface for executables or modules - // so if none was explicitly set then there is no link interface. - if(!explicitLibraries && - (this->Target->GetType() == cmTarget::EXECUTABLE || - (this->Target->GetType() == cmTarget::MODULE_LIBRARY))) - { - return; - } - iface.Exists = true; - iface.ExplicitLibraries = explicitLibraries; - - if(explicitLibraries) - { - // The interface libraries have been explicitly set. - this->ExpandLinkItems(linkIfaceProp, explicitLibraries, config, - headTarget, usage_requirements_only, - iface.Libraries, - iface.HadHeadSensitiveCondition); - } - else if (this->Target->GetPolicyStatusCMP0022() == cmPolicies::WARN - || this->Target->GetPolicyStatusCMP0022() == cmPolicies::OLD) - // If CMP0022 is NEW then the plain tll signature sets the - // INTERFACE_LINK_LIBRARIES, so if we get here then the project - // cleared the property explicitly and we should not fall back - // to the link implementation. - { - // The link implementation is the default link interface. - cmLinkImplementationLibraries const* impl = - this->Target->GetLinkImplementationLibrariesInternal(config, headTarget); - iface.Libraries.insert(iface.Libraries.end(), - impl->Libraries.begin(), impl->Libraries.end()); - if(this->Target->GetPolicyStatusCMP0022() == cmPolicies::WARN && - !this->PolicyWarnedCMP0022 && !usage_requirements_only) - { - // Compare the link implementation fallback link interface to the - // preferred new link interface property and warn if different. - std::vector ifaceLibs; - static const std::string newProp = "INTERFACE_LINK_LIBRARIES"; - if(const char* newExplicitLibraries = this->Target->GetProperty(newProp)) - { - bool hadHeadSensitiveConditionDummy = false; - this->ExpandLinkItems(newProp, newExplicitLibraries, config, - headTarget, usage_requirements_only, - ifaceLibs, hadHeadSensitiveConditionDummy); - } - if (ifaceLibs != iface.Libraries) - { - std::string oldLibraries = cmJoin(impl->Libraries, ";"); - std::string newLibraries = cmJoin(ifaceLibs, ";"); - if(oldLibraries.empty()) - { oldLibraries = "(empty)"; } - if(newLibraries.empty()) - { newLibraries = "(empty)"; } - - std::ostringstream w; - w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n" - "Target \"" << this->Target->GetName() << "\" has an " - "INTERFACE_LINK_LIBRARIES property. " - "This should be preferred as the source of the link interface " - "for this library but because CMP0022 is not set CMake is " - "ignoring the property and using the link implementation " - "as the link interface instead." - "\n" - "INTERFACE_LINK_LIBRARIES:\n" - " " << newLibraries << "\n" - "Link implementation:\n" - " " << oldLibraries << "\n"; - this->LocalGenerator->IssueMessage(cmake::AUTHOR_WARNING, w.str()); - this->PolicyWarnedCMP0022 = true; - } - } - } -} - -//---------------------------------------------------------------------------- -void cmGeneratorTarget::ComputeLinkInterface(const std::string& config, - OptionalLinkInterface& iface, - cmTarget const* headTarget) const -{ - if(iface.ExplicitLibraries) - { - if(this->GetType() == cmTarget::SHARED_LIBRARY - || this->GetType() == cmTarget::STATIC_LIBRARY - || this->GetType() == cmTarget::INTERFACE_LIBRARY) - { - // Shared libraries may have runtime implementation dependencies - // on other shared libraries that are not in the interface. - UNORDERED_SET emitted; - for(std::vector::const_iterator - li = iface.Libraries.begin(); li != iface.Libraries.end(); ++li) - { - emitted.insert(*li); - } - if (this->GetType() != cmTarget::INTERFACE_LIBRARY) - { - cmLinkImplementation const* impl = - this->GetLinkImplementation(config); - for(std::vector::const_iterator - li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li) - { - if(emitted.insert(*li).second) - { - if(li->Target) - { - // This is a runtime dependency on another shared library. - if(li->Target->GetType() == cmTarget::SHARED_LIBRARY) - { - iface.SharedDeps.push_back(*li); - } - } - else - { - // TODO: Recognize shared library file names. Perhaps this - // should be moved to cmComputeLinkInformation, but that creates - // a chicken-and-egg problem since this list is needed for its - // construction. - } - } - } - } - } - } - else if (this->Target->GetPolicyStatusCMP0022() == cmPolicies::WARN - || this->Target->GetPolicyStatusCMP0022() == cmPolicies::OLD) - { - // The link implementation is the default link interface. - cmLinkImplementationLibraries const* - impl = this->Target->GetLinkImplementationLibrariesInternal(config, - headTarget); - iface.ImplementationIsInterface = true; - iface.WrongConfigLibraries = impl->WrongConfigLibraries; - } - - if(this->Target->LinkLanguagePropagatesToDependents()) - { - // Targets using this archive need its language runtime libraries. - if(cmLinkImplementation const* impl = - this->GetLinkImplementation(config)) - { - iface.Languages = impl->Languages; - } - } - - if(this->GetType() == cmTarget::STATIC_LIBRARY) - { - // Construct the property name suffix for this configuration. - std::string suffix = "_"; - if(!config.empty()) - { - suffix += cmSystemTools::UpperCase(config); - } - else - { - suffix += "NOCONFIG"; - } - - // How many repetitions are needed if this library has cyclic - // dependencies? - std::string propName = "LINK_INTERFACE_MULTIPLICITY"; - propName += suffix; - if(const char* config_reps = this->Target->GetProperty(propName)) - { - sscanf(config_reps, "%u", &iface.Multiplicity); - } - else if(const char* reps = - this->Target->GetProperty("LINK_INTERFACE_MULTIPLICITY")) - { - sscanf(reps, "%u", &iface.Multiplicity); - } - } -} - -//---------------------------------------------------------------------------- -const cmLinkImplementation * -cmGeneratorTarget::GetLinkImplementation(const std::string& config) const -{ - // There is no link implementation for imported targets. - if(this->Target->IsImported()) - { - return 0; - } - - cmOptionalLinkImplementation& impl = this->Target->GetLinkImplMap(config); - if(!impl.LibrariesDone) - { - impl.LibrariesDone = true; - this->Target->ComputeLinkImplementationLibraries(config, impl, - this->Target); - } - if(!impl.LanguagesDone) - { - impl.LanguagesDone = true; - this->ComputeLinkImplementationLanguages(config, impl); - } - return &impl; -} - -//---------------------------------------------------------------------------- -bool cmGeneratorTarget::GetConfigCommonSourceFiles( - std::vector& files) const -{ - std::vector configs; - this->Makefile->GetConfigurations(configs); - if (configs.empty()) - { - configs.push_back(""); - } - - std::vector::const_iterator it = configs.begin(); - const std::string& firstConfig = *it; - this->Target->GetSourceFiles(files, firstConfig); - - for ( ; it != configs.end(); ++it) - { - std::vector configFiles; - this->Target->GetSourceFiles(configFiles, *it); - if (configFiles != files) - { - std::string firstConfigFiles; - const char* sep = ""; - for (std::vector::const_iterator fi = files.begin(); - fi != files.end(); ++fi) - { - firstConfigFiles += sep; - firstConfigFiles += (*fi)->GetFullPath(); - sep = "\n "; - } - - std::string thisConfigFiles; - sep = ""; - for (std::vector::const_iterator fi = configFiles.begin(); - fi != configFiles.end(); ++fi) - { - thisConfigFiles += sep; - thisConfigFiles += (*fi)->GetFullPath(); - sep = "\n "; - } - std::ostringstream e; - e << "Target \"" << this->GetName() - << "\" has source files which vary by " - "configuration. This is not supported by the \"" - << this->GlobalGenerator->GetName() - << "\" generator.\n" - "Config \"" << firstConfig << "\":\n" - " " << firstConfigFiles << "\n" - "Config \"" << *it << "\":\n" - " " << thisConfigFiles << "\n"; - this->LocalGenerator->IssueMessage(cmake::FATAL_ERROR, e.str()); - return false; - } - } - return true; -} - -//---------------------------------------------------------------------------- -void cmGeneratorTarget::GetLanguages(std::set& languages, - const std::string& config) const -{ - std::vector sourceFiles; - this->GetSourceFiles(sourceFiles, config); - for(std::vector::const_iterator - i = sourceFiles.begin(); i != sourceFiles.end(); ++i) - { - const std::string& lang = (*i)->GetLanguage(); - if(!lang.empty()) - { - languages.insert(lang); - } - } - - std::vector objectLibraries; - std::vector externalObjects; - if (!this->Makefile->IsConfigured()) - { - std::vector objectTargets; - this->Target->GetObjectLibrariesCMP0026(objectTargets); - objectLibraries.reserve(objectTargets.size()); - for (std::vector::const_iterator it = objectTargets.begin(); - it != objectTargets.end(); ++it) - { - objectLibraries.push_back(this->GlobalGenerator - ->GetGeneratorTarget(*it)); - } - } - else - { - this->GetExternalObjects(externalObjects, config); - for(std::vector::const_iterator - i = externalObjects.begin(); i != externalObjects.end(); ++i) - { - std::string objLib = (*i)->GetObjectLibrary(); - if (cmTarget* tgt = this->Makefile->FindTargetToUse(objLib)) - { - objectLibraries.push_back(this->GlobalGenerator - ->GetGeneratorTarget(tgt)); - } - } - } - for(std::vector::const_iterator - i = objectLibraries.begin(); i != objectLibraries.end(); ++i) - { - (*i)->GetLanguages(languages, config); - } -} - -//---------------------------------------------------------------------------- -void cmGeneratorTarget::ComputeLinkImplementationLanguages( - const std::string& config, - cmOptionalLinkImplementation& impl) const -{ - // This target needs runtime libraries for its source languages. - std::set languages; - // Get languages used in our source files. - this->GetLanguages(languages, config); - // Copy the set of langauges to the link implementation. - impl.Languages.insert(impl.Languages.begin(), - languages.begin(), languages.end()); -} - -//---------------------------------------------------------------------------- -bool cmGeneratorTarget::HaveBuildTreeRPATH(const std::string& config) const -{ - if (this->Target->GetPropertyAsBool("SKIP_BUILD_RPATH")) - { - return false; - } - if(cmLinkImplementationLibraries const* impl = - this->Target->GetLinkImplementationLibraries(config)) - { - return !impl->Libraries.empty(); - } - return false; -} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 6d66bfe..15b3335 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -13,7 +13,6 @@ #define cmGeneratorTarget_h #include "cmStandardIncludes.h" -#include "cmLinkItem.h" class cmCustomCommand; class cmGlobalGenerator; @@ -107,48 +106,6 @@ public: const char *GetLinkInterfaceDependentNumberMaxProperty(const std::string &p, const std::string& config) const; - /** The link interface specifies transitive library dependencies and - other information needed by targets that link to this target. */ - struct LinkInterfaceLibraries - { - // Libraries listed in the interface. - std::vector Libraries; - }; - - struct LinkInterface: public LinkInterfaceLibraries - { - // Languages whose runtime libraries must be linked. - std::vector Languages; - - // Shared library dependencies needed for linking on some platforms. - std::vector SharedDeps; - - // Number of repetitions of a strongly connected component of two - // or more static libraries. - int Multiplicity; - - // Libraries listed for other configurations. - // Needed only for OLD behavior of CMP0003. - std::vector WrongConfigLibraries; - - bool ImplementationIsInterface; - - LinkInterface(): Multiplicity(0), ImplementationIsInterface(false) {} - }; - - /** Get the link interface for the given configuration. Returns 0 - if the target cannot be linked. */ - LinkInterface const* GetLinkInterface(const std::string& config, - cmTarget const* headTarget) const; - - LinkInterface const* - GetImportLinkInterface(const std::string& config, cmTarget const* head, - bool usage_requirements_only) const; - - LinkInterfaceLibraries const* - GetLinkInterfaceLibraries(const std::string& config, - cmTarget const* headTarget, - bool usage_requirements_only) const; /** Get the full path to the target according to the settings in its makefile and the configuration type. */ @@ -226,25 +183,6 @@ public: LinkClosure const* GetLinkClosure(const std::string& config) const; void ComputeLinkClosure(const std::string& config, LinkClosure& lc) const; - cmLinkImplementation const* - GetLinkImplementation(const std::string& config) const; - - void ComputeLinkImplementationLanguages(const std::string& config, - cmOptionalLinkImplementation& impl - ) const; - - // Compute the set of languages compiled by the target. This is - // computed every time it is called because the languages can change - // when source file properties are changed and we do not have enough - // information to forward these property changes to the targets - // until we have per-target object file properties. - void GetLanguages(std::set& languages, - std::string const& config) const; - - bool GetConfigCommonSourceFiles(std::vector& files) const; - - bool HaveBuildTreeRPATH(const std::string& config) const; - /** Full path with trailing slash to the top-level directory holding object files for this target. Includes the build time config name placeholder if needed for the generator. */ @@ -264,17 +202,6 @@ public: std::vector GetIncludeDirectories( const std::string& config, const std::string& lang) const; - void GetCompileOptions(std::vector &result, - const std::string& config, - const std::string& language) const; - - void GetCompileFeatures(std::vector &features, - const std::string& config) const; - - void GetCompileDefinitions(std::vector &result, - const std::string& config, - const std::string& language) const; - bool IsSystemIncludeDirectory(const std::string& dir, const std::string& config) const; @@ -390,8 +317,6 @@ public: const std::string &report, const std::string &compatibilityType) const; - class TargetPropertyEntry; - private: friend class cmTargetTraceDependencies; struct SourceEntry { std::vector Depends; }; @@ -450,53 +375,6 @@ private: }; mutable std::map LinkImplClosureMap; - // Cache link interface computation from each configuration. - struct OptionalLinkInterface: public LinkInterface - { - OptionalLinkInterface(): - LibrariesDone(false), AllDone(false), - Exists(false), HadHeadSensitiveCondition(false), - ExplicitLibraries(0) {} - bool LibrariesDone; - bool AllDone; - bool Exists; - bool HadHeadSensitiveCondition; - const char* ExplicitLibraries; - }; - void ComputeLinkInterface(const std::string& config, - OptionalLinkInterface& iface, - cmTarget const* head) const; - void ComputeLinkInterfaceLibraries(const std::string& config, - OptionalLinkInterface& iface, - cmTarget const* head, - bool usage_requirements_only) const; - - struct HeadToLinkInterfaceMap: - public std::map {}; - typedef std::map - LinkInterfaceMapType; - mutable LinkInterfaceMapType LinkInterfaceMap; - mutable LinkInterfaceMapType LinkInterfaceUsageRequirementsOnlyMap; - - mutable bool PolicyWarnedCMP0022; - mutable bool DebugIncludesDone; - mutable bool DebugCompileOptionsDone; - mutable bool DebugCompileFeaturesDone; - mutable bool DebugCompileDefinitionsDone; - - std::vector IncludeDirectoriesEntries; - std::vector CompileOptionsEntries; - std::vector CompileFeaturesEntries; - std::vector CompileDefinitionsEntries; - - void ExpandLinkItems(std::string const& prop, std::string const& value, - std::string const& config, cmTarget const* headTarget, - bool usage_requirements_only, - std::vector& items, - bool& hadHeadSensitiveCondition) const; - void LookupLinkItems(std::vector const& names, - std::vector& items) const; - typedef std::pair OutputNameKey; typedef std::map OutputNameMapType; mutable OutputNameMapType OutputNameMap; diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index 846b6e2..1e57c33 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -330,8 +330,7 @@ void cmGhsMultiTargetGenerator::WriteCompilerDefinitions( const std::string &config, const std::string &language) { std::vector compileDefinitions; - this->GeneratorTarget->GetCompileDefinitions(compileDefinitions, - config, language); + this->Target->GetCompileDefinitions(compileDefinitions, config, language); for (std::vector::const_iterator cdI = compileDefinitions.begin(); cdI != compileDefinitions.end(); ++cdI) @@ -344,7 +343,7 @@ void cmGhsMultiTargetGenerator::WriteIncludes(const std::string &config, const std::string &language) { std::vector includes = - this->GeneratorTarget->GetIncludeDirectories(config, language); + this->Target->GetIncludeDirectories(config, language); for (std::vector::const_iterator includes_i = includes.begin(); includes_i != includes.end(); ++includes_i) { @@ -559,7 +558,7 @@ bool cmGhsMultiTargetGenerator::IsNotKernel(std::string const &config, { bool output; std::vector options; - this->GeneratorTarget->GetCompileOptions(options, config, language); + this->Target->GetCompileOptions(options, config, language); output = options.end() == std::find(options.begin(), options.end(), "-kernel"); return output; @@ -588,7 +587,7 @@ bool cmGhsMultiTargetGenerator::DetermineIfDynamicDownload( { std::vector options; bool output = false; - this->GeneratorTarget->GetCompileOptions(options, config, language); + this->Target->GetCompileOptions(options, config, language); for (std::vector::const_iterator options_i = options.begin(); options_i != options.end(); ++options_i) { diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index c0f1817..503c455 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1550,6 +1550,7 @@ void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes, ti != targets.end(); ++ti) { cmTarget* t = &ti->second; + t->Compute(); cmGeneratorTarget* gt = new cmGeneratorTarget(t, lg); this->GeneratorTargets[t] = gt; generatorTargets[t] = gt; diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 331caad..b240924 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -1134,8 +1134,7 @@ bool cmGlobalUnixMakefileGenerator3 ::NeedRequiresStep(cmTarget const& target) { std::set languages; - cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&target); - gtgt->GetLanguages(languages, + target.GetLanguages(languages, target.GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE")); for(std::set::const_iterator l = languages.begin(); l != languages.end(); ++l) diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 28f0425..51dcab0 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -254,7 +254,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() mf->AddUtilityCommand(CMAKE_CHECK_BUILD_SYSTEM_TARGET, false, no_working_directory, no_depends, noCommandLines); - + tgt->Compute(); cmGeneratorTarget* gt = new cmGeneratorTarget(tgt, lg); mf->AddGeneratorTarget(tgt, gt); diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 2bf04b4..b0aa243 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -90,7 +90,7 @@ bool cmGlobalVisualStudioGenerator::Compute() AddUtilityCommand("ALL_BUILD", true, no_working_dir, no_depends, no_commands, false, "Build all projects"); - + allBuild->Compute(); cmGeneratorTarget* gt = new cmGeneratorTarget(allBuild, gen[0]); allBuild->GetMakefile()->AddGeneratorTarget(allBuild, gt); @@ -836,19 +836,17 @@ void RegisterVisualStudioMacros(const std::string& macrosFile, bool cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget const& target) { - cmGeneratorTarget* gt = this->GetGeneratorTarget(&target); - // check to see if this is a fortran build std::set languages; { // Issue diagnostic if the source files depend on the config. std::vector sources; - if (!gt->GetConfigCommonSourceFiles(sources)) + if (!target.GetConfigCommonSourceFiles(sources)) { return false; } } - gt->GetLanguages(languages, ""); + target.GetLanguages(languages, ""); if(languages.size() == 1) { if(*languages.begin() == "Fortran") diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index eb547bd..4ba29f5 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -463,7 +463,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, cmTarget* allbuild = mf->AddUtilityCommand("ALL_BUILD", true, no_depends, no_working_directory, "echo", "Build all projects"); - + allbuild->Compute(); cmGeneratorTarget* allBuildGt = new cmGeneratorTarget(allbuild, root); mf->AddGeneratorTarget(allbuild, allBuildGt); @@ -498,7 +498,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, true, no_depends, no_working_directory, "make", "-f", file.c_str()); - + check->Compute(); cmGeneratorTarget* checkGt = new cmGeneratorTarget(check, root); mf->AddGeneratorTarget(check, checkGt); } @@ -1124,7 +1124,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, // organize the sources std::vector classes; - if (!gtgt->GetConfigCommonSourceFiles(classes)) + if (!cmtarget.GetConfigCommonSourceFiles(classes)) { return false; } @@ -1383,8 +1383,8 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmTarget& cmtarget) if(llang.empty()) { return; } // If the language is compiled as a source trust Xcode to link with it. - cmLinkImplementation const* impl = - gtgt->GetLinkImplementation("NOCONFIG"); + cmTarget::LinkImplementation const* impl = + cmtarget.GetLinkImplementation("NOCONFIG"); for(std::vector::const_iterator li = impl->Languages.begin(); li != impl->Languages.end(); ++li) { @@ -1505,8 +1505,7 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases, } std::vector classes; - cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); - if (!gtgt->GetConfigCommonSourceFiles(classes)) + if (!cmtarget.GetConfigCommonSourceFiles(classes)) { return; } @@ -1806,8 +1805,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, // Compute the compilation flags for each language. std::set languages; - cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); - gtgt->GetLanguages(languages, configName); + target.GetLanguages(languages, configName); std::map cflags; for (std::set::iterator li = languages.begin(); li != languages.end(); ++li) @@ -1829,6 +1827,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, AddCompileOptions(flags, &target, lang, configName); } + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); std::string llang = gtgt->GetLinkerLanguage(configName); if(binary && llang.empty()) { @@ -1856,7 +1855,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, this->AppendDefines(ppDefs, exportMacro); } std::vector targetDefines; - gtgt->GetCompileDefinitions(targetDefines, configName, "C"); + target.GetCompileDefinitions(targetDefines, configName, "C"); this->AppendDefines(ppDefs, targetDefines); buildSettings->AddAttribute ("GCC_PREPROCESSOR_DEFINITIONS", ppDefs.CreateList()); @@ -2558,8 +2557,7 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget) if(cmtarget.GetType() == cmTarget::UTILITY) { std::vector sources; - cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); - if (!gtgt->GetConfigCommonSourceFiles(sources)) + if (!cmtarget.GetConfigCommonSourceFiles(sources)) { return 0; } @@ -3087,8 +3085,7 @@ bool cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root, } std::vector classes; - cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); - if (!gtgt->GetConfigCommonSourceFiles(classes)) + if (!cmtarget.GetConfigCommonSourceFiles(classes)) { return false; } diff --git a/Source/cmLinkItem.h b/Source/cmLinkItem.h index f1d914f..a5427de 100644 --- a/Source/cmLinkItem.h +++ b/Source/cmLinkItem.h @@ -56,21 +56,4 @@ struct cmLinkImplementationLibraries std::vector WrongConfigLibraries; }; -struct cmLinkImplementation: public cmLinkImplementationLibraries -{ - // Languages whose runtime libraries must be linked. - std::vector Languages; -}; - -// Cache link implementation computation from each configuration. -struct cmOptionalLinkImplementation: public cmLinkImplementation -{ - cmOptionalLinkImplementation(): - LibrariesDone(false), LanguagesDone(false), - HadHeadSensitiveCondition(false) {} - bool LibrariesDone; - bool LanguagesDone; - bool HadHeadSensitiveCondition; -}; - #endif diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index c1cc241..edb644d 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1083,8 +1083,7 @@ void cmLocalGenerator::AddCompileDefinitions(std::set& defines, const std::string& lang) { std::vector targetDefines; - cmGeneratorTarget* gtgt = this->GlobalGenerator->GetGeneratorTarget(target); - gtgt->GetCompileDefinitions(targetDefines, config, lang); + target->GetCompileDefinitions(targetDefines, config, lang); this->AppendDefines(defines, targetDefines); } @@ -1095,10 +1094,6 @@ void cmLocalGenerator::AddCompileOptions( ) { std::string langFlagRegexVar = std::string("CMAKE_")+lang+"_FLAG_REGEX"; - - cmGeneratorTarget* gtgt = - this->GlobalGenerator->GetGeneratorTarget(target); - if(const char* langFlagRegexStr = this->Makefile->GetDefinition(langFlagRegexVar)) { @@ -1109,7 +1104,7 @@ void cmLocalGenerator::AddCompileOptions( { cmSystemTools::ParseWindowsCommandLine(targetFlags, opts); } - gtgt->GetCompileOptions(opts, config, lang); + target->GetCompileOptions(opts, config, lang); for(std::vector::const_iterator i = opts.begin(); i != opts.end(); ++i) { @@ -1130,7 +1125,7 @@ void cmLocalGenerator::AddCompileOptions( this->AppendFlags(flags, targetFlags); } std::vector opts; - gtgt->GetCompileOptions(opts, config, lang); + target->GetCompileOptions(opts, config, lang); for(std::vector::const_iterator i = opts.begin(); i != opts.end(); ++i) { @@ -1139,7 +1134,7 @@ void cmLocalGenerator::AddCompileOptions( } } std::vector features; - gtgt->GetCompileFeatures(features, config); + target->GetCompileFeatures(features, config); for(std::vector::const_iterator it = features.begin(); it != features.end(); ++it) { diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 589105e..ce370bc 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1257,9 +1257,7 @@ cmLocalUnixMakefileGenerator3 { // Get the set of source languages in the target. std::set languages; - cmGeneratorTarget *gtgt = - this->GlobalGenerator->GetGeneratorTarget(&target); - gtgt->GetLanguages(languages, + target.GetLanguages(languages, this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); fout << "\n" << "# Per-language clean rules from dependency scanning.\n" diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 3a44367..0d07536 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -305,12 +305,9 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout, // We may be modifying the source groups temporarily, so make a copy. std::vector sourceGroups = this->Makefile->GetSourceGroups(); - cmGeneratorTarget* gt = - this->GlobalGenerator->GetGeneratorTarget(&target); - // get the classes from the source lists then add them to the groups std::vector classes; - if (!gt->GetConfigCommonSourceFiles(classes)) + if (!target.GetConfigCommonSourceFiles(classes)) { return; } diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 55ad852..5de6d37 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -763,7 +763,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, targetOptions.Parse(defineFlags.c_str()); targetOptions.ParseFinish(); std::vector targetDefines; - gt->GetCompileDefinitions(targetDefines, configName, "CXX"); + target.GetCompileDefinitions(targetDefines, configName, "CXX"); targetOptions.AddDefines(targetDefines); targetOptions.SetVerboseMakefile( this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE")); @@ -1469,13 +1469,10 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, // We may be modifying the source groups temporarily, so make a copy. std::vector sourceGroups = this->Makefile->GetSourceGroups(); - cmGeneratorTarget* gt = - this->GlobalGenerator->GetGeneratorTarget(&target); - // get the classes from the source lists then add them to the groups this->ModuleDefinitionFile = ""; std::vector classes; - if (!gt->GetConfigCommonSourceFiles(classes)) + if (!target.GetConfigCommonSourceFiles(classes)) { return; } @@ -1517,6 +1514,8 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, { // VS >= 8 support per-config source locations so we // list object library content as external objects. + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); std::vector objs; gt->UseObjectLibraries(objs, ""); if(!objs.empty()) diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index cf88a74..0b3df90 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -276,7 +276,7 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags() { // write language flags for target std::set languages; - this->GeneratorTarget->GetLanguages(languages, + this->Target->GetLanguages(languages, this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); // put the compiler in the rules.make file so that if it changes // things rebuild diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 0a4b546..f85e70e 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -403,9 +403,7 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg, ) { std::vector srcFiles; - cmGeneratorTarget* gtgt = - lg->GetGlobalGenerator()->GetGeneratorTarget(target); - gtgt->GetConfigCommonSourceFiles(srcFiles); + target->GetConfigCommonSourceFiles(srcFiles); for(std::vector::const_iterator fileIt = srcFiles.begin(); fileIt != srcFiles.end(); ++fileIt) @@ -476,6 +474,8 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg, /*byproducts=*/rcc_output, depends, commandLines, false, autogenComment.c_str()); + autogenTarget->Compute(); + cmGeneratorTarget* gt = new cmGeneratorTarget(autogenTarget, lg); makefile->AddGeneratorTarget(autogenTarget, gt); @@ -663,10 +663,7 @@ void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target) const char* sepHeaders = ""; std::vector srcFiles; - cmGeneratorTarget *gtgt = target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(target); - gtgt->GetConfigCommonSourceFiles(srcFiles); + target->GetConfigCommonSourceFiles(srcFiles); const char *skipMocSep = ""; const char *skipUicSep = ""; @@ -1051,10 +1048,7 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) cmMakefile *makefile = target->GetMakefile(); std::vector srcFiles; - cmGeneratorTarget *gtgt = target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(target); - gtgt->GetConfigCommonSourceFiles(srcFiles); + target->GetConfigCommonSourceFiles(srcFiles); std::string qrcInputs; const char* qrcInputsSep = ""; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 40d7ebf..49b3239 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -77,11 +77,13 @@ public: cmTargetInternals() : Backtrace() { + this->PolicyWarnedCMP0022 = false; this->UtilityItemsDone = false; } cmTargetInternals(cmTargetInternals const&) : Backtrace() { + this->PolicyWarnedCMP0022 = false; this->UtilityItemsDone = false; } ~cmTargetInternals(); @@ -89,6 +91,36 @@ public: // The backtrace when the target was created. cmListFileBacktrace Backtrace; + // Cache link interface computation from each configuration. + struct OptionalLinkInterface: public cmTarget::LinkInterface + { + OptionalLinkInterface(): + LibrariesDone(false), AllDone(false), + Exists(false), HadHeadSensitiveCondition(false), + ExplicitLibraries(0) {} + bool LibrariesDone; + bool AllDone; + bool Exists; + bool HadHeadSensitiveCondition; + const char* ExplicitLibraries; + }; + void ComputeLinkInterface(cmTarget const* thisTarget, + const std::string& config, + OptionalLinkInterface& iface, + cmTarget const* head) const; + void ComputeLinkInterfaceLibraries(cmTarget const* thisTarget, + const std::string& config, + OptionalLinkInterface& iface, + cmTarget const* head, + bool usage_requirements_only); + + struct HeadToLinkInterfaceMap: + public std::map {}; + typedef std::map + LinkInterfaceMapType; + LinkInterfaceMapType LinkInterfaceMap; + LinkInterfaceMapType LinkInterfaceUsageRequirementsOnlyMap; + bool PolicyWarnedCMP0022; typedef std::map OutputInfoMapType; OutputInfoMapType OutputInfoMap; @@ -96,8 +128,27 @@ public: typedef std::map ImportInfoMapType; ImportInfoMapType ImportInfoMap; + // Cache link implementation computation from each configuration. + struct OptionalLinkImplementation: public cmTarget::LinkImplementation + { + OptionalLinkImplementation(): + LibrariesDone(false), LanguagesDone(false), + HadHeadSensitiveCondition(false) {} + bool LibrariesDone; + bool LanguagesDone; + bool HadHeadSensitiveCondition; + }; + void ComputeLinkImplementationLibraries(cmTarget const* thisTarget, + const std::string& config, + OptionalLinkImplementation& impl, + cmTarget const* head) const; + void ComputeLinkImplementationLanguages(cmTarget const* thisTarget, + const std::string& config, + OptionalLinkImplementation& impl + ) const; + struct HeadToLinkImplementationMap: - public std::map {}; + public std::map {}; typedef std::map LinkImplMapType; LinkImplMapType LinkImplMap; @@ -121,12 +172,16 @@ public: }; std::vector IncludeDirectoriesEntries; std::vector IncludeDirectoriesBacktraces; + std::vector IncludeDirectoriesItems; std::vector CompileOptionsEntries; std::vector CompileOptionsBacktraces; + std::vector CompileOptionsItems; std::vector CompileFeaturesEntries; std::vector CompileFeaturesBacktraces; + std::vector CompileFeaturesItems; std::vector CompileDefinitionsEntries; std::vector CompileDefinitionsBacktraces; + std::vector CompileDefinitionsItems; std::vector SourceEntries; std::vector LinkImplementationPropertyEntries; @@ -155,6 +210,10 @@ cmTarget::cmTarget() this->IsApple = false; this->IsImportedTarget = false; this->BuildInterfaceIncludesAppended = false; + this->DebugIncludesDone = false; + this->DebugCompileOptionsDone = false; + this->DebugCompileFeaturesDone = false; + this->DebugCompileDefinitionsDone = false; this->DebugSourcesDone = false; this->LinkImplementationLanguageIsContextDependent = true; } @@ -397,6 +456,29 @@ void CreatePropertyGeneratorExpressions( } } +void cmTarget::Compute() +{ + CreatePropertyGeneratorExpressions( + this->Internal->IncludeDirectoriesEntries, + this->Internal->IncludeDirectoriesBacktraces, + this->Internal->IncludeDirectoriesItems); + + CreatePropertyGeneratorExpressions( + this->Internal->CompileOptionsEntries, + this->Internal->CompileOptionsBacktraces, + this->Internal->CompileOptionsItems); + + CreatePropertyGeneratorExpressions( + this->Internal->CompileFeaturesEntries, + this->Internal->CompileFeaturesBacktraces, + this->Internal->CompileFeaturesItems); + + CreatePropertyGeneratorExpressions( + this->Internal->CompileDefinitionsEntries, + this->Internal->CompileDefinitionsBacktraces, + this->Internal->CompileDefinitionsItems); +} + //---------------------------------------------------------------------------- void cmTarget::AddUtility(const std::string& u, cmMakefile *makefile) { @@ -456,6 +538,8 @@ void cmTarget::ClearLinkMaps() { this->LinkImplementationLanguageIsContextDependent = true; this->Internal->LinkImplMap.clear(); + this->Internal->LinkInterfaceMap.clear(); + this->Internal->LinkInterfaceUsageRequirementsOnlyMap.clear(); this->Internal->SourceFilesMap.clear(); } @@ -726,6 +810,62 @@ void cmTarget::GetSourceFiles(std::vector &files, } //---------------------------------------------------------------------------- +bool +cmTarget::GetConfigCommonSourceFiles(std::vector& files) const +{ + std::vector configs; + this->Makefile->GetConfigurations(configs); + if (configs.empty()) + { + configs.push_back(""); + } + + std::vector::const_iterator it = configs.begin(); + const std::string& firstConfig = *it; + this->GetSourceFiles(files, firstConfig); + + for ( ; it != configs.end(); ++it) + { + std::vector configFiles; + this->GetSourceFiles(configFiles, *it); + if (configFiles != files) + { + std::string firstConfigFiles; + const char* sep = ""; + for (std::vector::const_iterator fi = files.begin(); + fi != files.end(); ++fi) + { + firstConfigFiles += sep; + firstConfigFiles += (*fi)->GetFullPath(); + sep = "\n "; + } + + std::string thisConfigFiles; + sep = ""; + for (std::vector::const_iterator fi = configFiles.begin(); + fi != configFiles.end(); ++fi) + { + thisConfigFiles += sep; + thisConfigFiles += (*fi)->GetFullPath(); + sep = "\n "; + } + std::ostringstream e; + e << "Target \"" << this->Name << "\" has source files which vary by " + "configuration. This is not supported by the \"" + << this->Makefile->GetGlobalGenerator()->GetName() + << "\" generator.\n" + "Config \"" << firstConfig << "\":\n" + " " << firstConfigFiles << "\n" + "Config \"" << *it << "\":\n" + " " << thisConfigFiles << "\n"; + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); + return false; + } + } + return true; +} + +//---------------------------------------------------------------------------- void cmTarget::GetSourceFiles(std::vector &files, const std::string& config) const { @@ -1214,46 +1354,6 @@ cmTarget::AddSystemIncludeDirectories(const std::set &incs) this->SystemIncludeDirectories.insert(incs.begin(), incs.end()); } -cmStringRange cmTarget::GetIncludeDirectoriesEntries() const -{ - return cmMakeRange(this->Internal->IncludeDirectoriesEntries); -} - -cmBacktraceRange cmTarget::GetIncludeDirectoriesBacktraces() const -{ - return cmMakeRange(this->Internal->IncludeDirectoriesBacktraces); -} - -cmStringRange cmTarget::GetCompileOptionsEntries() const -{ - return cmMakeRange(this->Internal->CompileOptionsEntries); -} - -cmBacktraceRange cmTarget::GetCompileOptionsBacktraces() const -{ - return cmMakeRange(this->Internal->CompileOptionsBacktraces); -} - -cmStringRange cmTarget::GetCompileFeaturesEntries() const -{ - return cmMakeRange(this->Internal->CompileFeaturesEntries); -} - -cmBacktraceRange cmTarget::GetCompileFeaturesBacktraces() const -{ - return cmMakeRange(this->Internal->CompileFeaturesBacktraces); -} - -cmStringRange cmTarget::GetCompileDefinitionsEntries() const -{ - return cmMakeRange(this->Internal->CompileDefinitionsEntries); -} - -cmBacktraceRange cmTarget::GetCompileDefinitionsBacktraces() const -{ - return cmMakeRange(this->Internal->CompileDefinitionsBacktraces); -} - #if defined(_WIN32) && !defined(__CYGWIN__) //---------------------------------------------------------------------------- void @@ -1851,126 +1951,630 @@ void cmTarget::InsertCompileDefinition(std::string const& entry, } //---------------------------------------------------------------------------- -void cmTarget::MaybeInvalidatePropertyCache(const std::string& prop) +static void processIncludeDirectories(cmTarget const* tgt, + const std::vector &entries, + std::vector &includes, + UNORDERED_SET &uniqueIncludes, + cmGeneratorExpressionDAGChecker *dagChecker, + const std::string& config, bool debugIncludes, + const std::string& language) { - // Wipe out maps caching information affected by this property. - if(this->IsImported() && cmHasLiteralPrefix(prop, "IMPORTED")) - { - this->Internal->ImportInfoMap.clear(); - } - if(!this->IsImported() && cmHasLiteralPrefix(prop, "LINK_INTERFACE_")) + cmMakefile *mf = tgt->GetMakefile(); + + for (std::vector::const_iterator + it = entries.begin(), end = entries.end(); it != end; ++it) { - this->ClearLinkMaps(); + cmLinkImplItem const& item = (*it)->LinkImplItem; + std::string const& targetName = item; + bool const fromImported = item.Target && item.Target->IsImported(); + bool const checkCMP0027 = item.FromGenex; + std::vector entryIncludes; + cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf, + config, + false, + tgt, + dagChecker, language), + entryIncludes); + + std::string usedIncludes; + for(std::vector::iterator + li = entryIncludes.begin(); li != entryIncludes.end(); ++li) + { + if (fromImported + && !cmSystemTools::FileExists(li->c_str())) + { + std::ostringstream e; + cmake::MessageType messageType = cmake::FATAL_ERROR; + if (checkCMP0027) + { + switch(tgt->GetPolicyStatusCMP0027()) + { + case cmPolicies::WARN: + e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0027) << "\n"; + case cmPolicies::OLD: + messageType = cmake::AUTHOR_WARNING; + break; + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::NEW: + break; + } + } + e << "Imported target \"" << targetName << "\" includes " + "non-existent path\n \"" << *li << "\"\nin its " + "INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:\n" + "* The path was deleted, renamed, or moved to another " + "location.\n" + "* An install or uninstall procedure did not complete " + "successfully.\n" + "* The installation package was faulty and references files it " + "does not provide.\n"; + tgt->GetMakefile()->IssueMessage(messageType, e.str()); + return; + } + + if (!cmSystemTools::FileIsFullPath(li->c_str())) + { + std::ostringstream e; + bool noMessage = false; + cmake::MessageType messageType = cmake::FATAL_ERROR; + if (!targetName.empty()) + { + e << "Target \"" << targetName << "\" contains relative " + "path in its INTERFACE_INCLUDE_DIRECTORIES:\n" + " \"" << *li << "\""; + } + else + { + switch(tgt->GetPolicyStatusCMP0021()) + { + case cmPolicies::WARN: + { + e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0021) << "\n"; + messageType = cmake::AUTHOR_WARNING; + } + break; + case cmPolicies::OLD: + noMessage = true; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::NEW: + // Issue the fatal message. + break; + } + e << "Found relative path while evaluating include directories of " + "\"" << tgt->GetName() << "\":\n \"" << *li << "\"\n"; + } + if (!noMessage) + { + tgt->GetMakefile()->IssueMessage(messageType, e.str()); + if (messageType == cmake::FATAL_ERROR) + { + return; + } + } + } + + if (!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 (!usedIncludes.empty()) + { + mf->GetCMakeInstance()->IssueMessage(cmake::LOG, + std::string("Used includes for target ") + + tgt->GetName() + ":\n" + + usedIncludes, (*it)->ge->GetBacktrace()); + } } } //---------------------------------------------------------------------------- -static void cmTargetCheckLINK_INTERFACE_LIBRARIES( - const std::string& prop, const char* value, cmMakefile* context, - bool imported) +std::vector +cmTarget::GetIncludeDirectories(const std::string& config, + const std::string& language) const { - // Look for link-type keywords in the value. - static cmsys::RegularExpression - keys("(^|;)(debug|optimized|general)(;|$)"); - if(!keys.find(value)) + std::vector includes; + UNORDERED_SET uniqueIncludes; + + cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), + "INCLUDE_DIRECTORIES", 0, 0); + + std::vector debugProperties; + const char *debugProp = + this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); + if (debugProp) { - return; + cmSystemTools::ExpandListArgument(debugProp, debugProperties); } - // Support imported and non-imported versions of the property. - const char* base = (imported? - "IMPORTED_LINK_INTERFACE_LIBRARIES" : - "LINK_INTERFACE_LIBRARIES"); + bool debugIncludes = !this->DebugIncludesDone + && std::find(debugProperties.begin(), + debugProperties.end(), + "INCLUDE_DIRECTORIES") + != debugProperties.end(); - // Report an error. - std::ostringstream e; - e << "Property " << prop << " may not contain link-type keyword \"" - << keys.match(2) << "\". " - << "The " << base << " property has a per-configuration " - << "version called " << base << "_ which may be " - << "used to specify per-configuration rules."; - if(!imported) + if (this->Makefile->IsConfigured()) { - e << " " - << "Alternatively, an IMPORTED library may be created, configured " - << "with a per-configuration location, and then named in the " - << "property value. " - << "See the add_library command's IMPORTED mode for details." - << "\n" - << "If you have a list of libraries that already contains the " - << "keyword, use the target_link_libraries command with its " - << "LINK_INTERFACE_LIBRARIES mode to set the property. " - << "The command automatically recognizes link-type keywords and sets " - << "the LINK_INTERFACE_LIBRARIES and LINK_INTERFACE_LIBRARIES_DEBUG " - << "properties accordingly."; + this->DebugIncludesDone = true; } - context->IssueMessage(cmake::FATAL_ERROR, e.str()); -} -//---------------------------------------------------------------------------- -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)) + processIncludeDirectories(this, + this->Internal->IncludeDirectoriesItems, + includes, + uniqueIncludes, + &dagChecker, + config, + debugIncludes, + language); + + std::vector + linkInterfaceIncludeDirectoriesEntries; + this->Internal->AddInterfaceEntries( + this, config, "INTERFACE_INCLUDE_DIRECTORIES", + linkInterfaceIncludeDirectoriesEntries); + + if(this->Makefile->IsOn("APPLE")) { - return; + cmLinkImplementationLibraries const* impl = + this->GetLinkImplementationLibraries(config); + for(std::vector::const_iterator + it = impl->Libraries.begin(); + it != impl->Libraries.end(); ++it) + { + std::string libDir = cmSystemTools::CollapseFullPath(*it); + + static cmsys::RegularExpression + frameworkCheck("(.*\\.framework)(/Versions/[^/]+)?/[^/]+$"); + if(!frameworkCheck.find(libDir)) + { + continue; + } + + libDir = frameworkCheck.match(1); + + cmGeneratorExpression ge; + cmsys::auto_ptr cge = + ge.Parse(libDir.c_str()); + linkInterfaceIncludeDirectoriesEntries + .push_back(new cmTargetInternals::TargetPropertyEntry(cge)); + } } - // Report an error. - std::ostringstream e; + processIncludeDirectories(this, + linkInterfaceIncludeDirectoriesEntries, + includes, + uniqueIncludes, + &dagChecker, + config, + debugIncludes, + language); - 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."; + cmDeleteAll(linkInterfaceIncludeDirectoriesEntries); - context->IssueMessage(cmake::FATAL_ERROR, e.str()); + return includes; } //---------------------------------------------------------------------------- -void cmTarget::CheckProperty(const std::string& prop, - cmMakefile* context) const +static void processCompileOptionsInternal(cmTarget const* tgt, + const std::vector &entries, + std::vector &options, + UNORDERED_SET &uniqueOptions, + cmGeneratorExpressionDAGChecker *dagChecker, + const std::string& config, bool debugOptions, const char *logName, + std::string const& language) { - // Certain properties need checking. - if(cmHasLiteralPrefix(prop, "LINK_INTERFACE_LIBRARIES")) - { - if(const char* value = this->GetProperty(prop)) - { - cmTargetCheckLINK_INTERFACE_LIBRARIES(prop, value, context, false); - } - } - if(cmHasLiteralPrefix(prop, "IMPORTED_LINK_INTERFACE_LIBRARIES")) + cmMakefile *mf = tgt->GetMakefile(); + + for (std::vector::const_iterator + it = entries.begin(), end = entries.end(); it != end; ++it) { - if(const char* value = this->GetProperty(prop)) + std::vector entryOptions; + cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf, + config, + false, + tgt, + dagChecker, + language), + entryOptions); + std::string usedOptions; + for(std::vector::iterator + li = entryOptions.begin(); li != entryOptions.end(); ++li) { - cmTargetCheckLINK_INTERFACE_LIBRARIES(prop, value, context, true); + std::string const& opt = *li; + + if(uniqueOptions.insert(opt).second) + { + options.push_back(opt); + if (debugOptions) + { + usedOptions += " * " + opt + "\n"; + } + } } - } - if(cmHasLiteralPrefix(prop, "INTERFACE_LINK_LIBRARIES")) - { - if(const char* value = this->GetProperty(prop)) + if (!usedOptions.empty()) { - cmTargetCheckINTERFACE_LINK_LIBRARIES(value, context); + mf->GetCMakeInstance()->IssueMessage(cmake::LOG, + std::string("Used compile ") + logName + + std::string(" for target ") + + tgt->GetName() + ":\n" + + usedOptions, (*it)->ge->GetBacktrace()); } } } //---------------------------------------------------------------------------- -void cmTarget::MarkAsImported() +static void processCompileOptions(cmTarget const* tgt, + const std::vector &entries, + std::vector &options, + UNORDERED_SET &uniqueOptions, + cmGeneratorExpressionDAGChecker *dagChecker, + const std::string& config, bool debugOptions, + std::string const& language) { - this->IsImportedTarget = true; + processCompileOptionsInternal(tgt, entries, options, uniqueOptions, + dagChecker, config, debugOptions, "options", + language); } //---------------------------------------------------------------------------- -bool cmTarget::HaveWellDefinedOutputFiles() const +void cmTarget::GetCompileOptions(std::vector &result, + const std::string& config, + const std::string& language) const { - return - this->GetType() == cmTarget::STATIC_LIBRARY || - this->GetType() == cmTarget::SHARED_LIBRARY || - this->GetType() == cmTarget::MODULE_LIBRARY || + UNORDERED_SET uniqueOptions; + + cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), + "COMPILE_OPTIONS", 0, 0); + + std::vector debugProperties; + const char *debugProp = + this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); + if (debugProp) + { + cmSystemTools::ExpandListArgument(debugProp, debugProperties); + } + + bool debugOptions = !this->DebugCompileOptionsDone + && std::find(debugProperties.begin(), + debugProperties.end(), + "COMPILE_OPTIONS") + != debugProperties.end(); + + if (this->Makefile->IsConfigured()) + { + this->DebugCompileOptionsDone = true; + } + + processCompileOptions(this, + this->Internal->CompileOptionsItems, + result, + uniqueOptions, + &dagChecker, + config, + debugOptions, + language); + + std::vector + linkInterfaceCompileOptionsEntries; + + this->Internal->AddInterfaceEntries( + this, config, "INTERFACE_COMPILE_OPTIONS", + linkInterfaceCompileOptionsEntries); + + processCompileOptions(this, + linkInterfaceCompileOptionsEntries, + result, + uniqueOptions, + &dagChecker, + config, + debugOptions, + language); + + cmDeleteAll(linkInterfaceCompileOptionsEntries); +} + +//---------------------------------------------------------------------------- +static void processCompileDefinitions(cmTarget const* tgt, + const std::vector &entries, + std::vector &options, + UNORDERED_SET &uniqueOptions, + cmGeneratorExpressionDAGChecker *dagChecker, + const std::string& config, bool debugOptions, + std::string const& language) +{ + processCompileOptionsInternal(tgt, entries, options, uniqueOptions, + dagChecker, config, debugOptions, + "definitions", language); +} + +//---------------------------------------------------------------------------- +void cmTarget::GetCompileDefinitions(std::vector &list, + const std::string& config, + const std::string& language) const +{ + UNORDERED_SET uniqueOptions; + + cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), + "COMPILE_DEFINITIONS", 0, 0); + + std::vector debugProperties; + const char *debugProp = + this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); + if (debugProp) + { + cmSystemTools::ExpandListArgument(debugProp, debugProperties); + } + + bool debugDefines = !this->DebugCompileDefinitionsDone + && std::find(debugProperties.begin(), + debugProperties.end(), + "COMPILE_DEFINITIONS") + != debugProperties.end(); + + if (this->Makefile->IsConfigured()) + { + this->DebugCompileDefinitionsDone = true; + } + + processCompileDefinitions(this, + this->Internal->CompileDefinitionsItems, + list, + uniqueOptions, + &dagChecker, + config, + debugDefines, + language); + + std::vector + linkInterfaceCompileDefinitionsEntries; + this->Internal->AddInterfaceEntries( + this, config, "INTERFACE_COMPILE_DEFINITIONS", + linkInterfaceCompileDefinitionsEntries); + if (!config.empty()) + { + std::string configPropName = "COMPILE_DEFINITIONS_" + + cmSystemTools::UpperCase(config); + const char *configProp = this->GetProperty(configPropName); + if (configProp) + { + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0043)) + { + case cmPolicies::WARN: + { + std::ostringstream e; + e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0043); + this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, + e.str()); + } + case cmPolicies::OLD: + { + cmGeneratorExpression ge; + cmsys::auto_ptr cge = + ge.Parse(configProp); + linkInterfaceCompileDefinitionsEntries + .push_back(new cmTargetInternals::TargetPropertyEntry(cge)); + } + break; + case cmPolicies::NEW: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::REQUIRED_IF_USED: + break; + } + } + } + + processCompileDefinitions(this, + linkInterfaceCompileDefinitionsEntries, + list, + uniqueOptions, + &dagChecker, + config, + debugDefines, + language); + + cmDeleteAll(linkInterfaceCompileDefinitionsEntries); +} + +//---------------------------------------------------------------------------- +static void processCompileFeatures(cmTarget const* tgt, + const std::vector &entries, + std::vector &options, + UNORDERED_SET &uniqueOptions, + cmGeneratorExpressionDAGChecker *dagChecker, + const std::string& config, bool debugOptions) +{ + processCompileOptionsInternal(tgt, entries, options, uniqueOptions, + dagChecker, config, debugOptions, "features", + std::string()); +} + +//---------------------------------------------------------------------------- +void cmTarget::GetCompileFeatures(std::vector &result, + const std::string& config) const +{ + UNORDERED_SET uniqueFeatures; + + cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), + "COMPILE_FEATURES", + 0, 0); + + std::vector debugProperties; + const char *debugProp = + this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); + if (debugProp) + { + cmSystemTools::ExpandListArgument(debugProp, debugProperties); + } + + bool debugFeatures = !this->DebugCompileFeaturesDone + && std::find(debugProperties.begin(), + debugProperties.end(), + "COMPILE_FEATURES") + != debugProperties.end(); + + if (this->Makefile->IsConfigured()) + { + this->DebugCompileFeaturesDone = true; + } + + processCompileFeatures(this, + this->Internal->CompileFeaturesItems, + result, + uniqueFeatures, + &dagChecker, + config, + debugFeatures); + + std::vector + linkInterfaceCompileFeaturesEntries; + this->Internal->AddInterfaceEntries( + this, config, "INTERFACE_COMPILE_FEATURES", + linkInterfaceCompileFeaturesEntries); + + processCompileFeatures(this, + linkInterfaceCompileFeaturesEntries, + result, + uniqueFeatures, + &dagChecker, + config, + debugFeatures); + + cmDeleteAll(linkInterfaceCompileFeaturesEntries); +} + +//---------------------------------------------------------------------------- +void cmTarget::MaybeInvalidatePropertyCache(const std::string& prop) +{ + // Wipe out maps caching information affected by this property. + if(this->IsImported() && cmHasLiteralPrefix(prop, "IMPORTED")) + { + this->Internal->ImportInfoMap.clear(); + } + if(!this->IsImported() && cmHasLiteralPrefix(prop, "LINK_INTERFACE_")) + { + this->ClearLinkMaps(); + } +} + +//---------------------------------------------------------------------------- +static void cmTargetCheckLINK_INTERFACE_LIBRARIES( + const std::string& prop, const char* value, cmMakefile* context, + bool imported) +{ + // Look for link-type keywords in the value. + static cmsys::RegularExpression + keys("(^|;)(debug|optimized|general)(;|$)"); + if(!keys.find(value)) + { + return; + } + + // Support imported and non-imported versions of the property. + const char* base = (imported? + "IMPORTED_LINK_INTERFACE_LIBRARIES" : + "LINK_INTERFACE_LIBRARIES"); + + // Report an error. + std::ostringstream e; + e << "Property " << prop << " may not contain link-type keyword \"" + << keys.match(2) << "\". " + << "The " << base << " property has a per-configuration " + << "version called " << base << "_ which may be " + << "used to specify per-configuration rules."; + if(!imported) + { + e << " " + << "Alternatively, an IMPORTED library may be created, configured " + << "with a per-configuration location, and then named in the " + << "property value. " + << "See the add_library command's IMPORTED mode for details." + << "\n" + << "If you have a list of libraries that already contains the " + << "keyword, use the target_link_libraries command with its " + << "LINK_INTERFACE_LIBRARIES mode to set the property. " + << "The command automatically recognizes link-type keywords and sets " + << "the LINK_INTERFACE_LIBRARIES and LINK_INTERFACE_LIBRARIES_DEBUG " + << "properties accordingly."; + } + context->IssueMessage(cmake::FATAL_ERROR, e.str()); +} + +//---------------------------------------------------------------------------- +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. + std::ostringstream 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 std::string& prop, + cmMakefile* context) const +{ + // Certain properties need checking. + if(cmHasLiteralPrefix(prop, "LINK_INTERFACE_LIBRARIES")) + { + if(const char* value = this->GetProperty(prop)) + { + cmTargetCheckLINK_INTERFACE_LIBRARIES(prop, value, context, false); + } + } + if(cmHasLiteralPrefix(prop, "IMPORTED_LINK_INTERFACE_LIBRARIES")) + { + if(const char* value = this->GetProperty(prop)) + { + cmTargetCheckLINK_INTERFACE_LIBRARIES(prop, value, context, true); + } + } + if(cmHasLiteralPrefix(prop, "INTERFACE_LINK_LIBRARIES")) + { + if(const char* value = this->GetProperty(prop)) + { + cmTargetCheckINTERFACE_LINK_LIBRARIES(value, context); + } + } +} + +//---------------------------------------------------------------------------- +void cmTarget::MarkAsImported() +{ + this->IsImportedTarget = true; +} + +//---------------------------------------------------------------------------- +bool cmTarget::HaveWellDefinedOutputFiles() const +{ + return + this->GetType() == cmTarget::STATIC_LIBRARY || + this->GetType() == cmTarget::SHARED_LIBRARY || + this->GetType() == cmTarget::MODULE_LIBRARY || this->GetType() == cmTarget::EXECUTABLE; } @@ -2492,6 +3096,51 @@ bool cmTarget::GetPropertyAsBool(const std::string& prop) const } //---------------------------------------------------------------------------- +void cmTarget::ExpandLinkItems(std::string const& prop, + std::string const& value, + std::string const& config, + cmTarget const* headTarget, + bool usage_requirements_only, + std::vector& items, + bool& hadHeadSensitiveCondition) const +{ + cmGeneratorExpression ge; + cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), prop, 0, 0); + // The $ expression may be in a link interface to specify private + // link dependencies that are otherwise excluded from usage requirements. + if(usage_requirements_only) + { + dagChecker.SetTransitivePropertiesOnly(); + } + std::vector libs; + cmsys::auto_ptr cge = ge.Parse(value); + cmSystemTools::ExpandListArgument(cge->Evaluate( + this->Makefile, + config, + false, + headTarget, + this, &dagChecker), libs); + this->LookupLinkItems(libs, items); + hadHeadSensitiveCondition = cge->GetHadHeadSensitiveCondition(); +} + +//---------------------------------------------------------------------------- +void cmTarget::LookupLinkItems(std::vector const& names, + std::vector& items) const +{ + for(std::vector::const_iterator i = names.begin(); + i != names.end(); ++i) + { + std::string name = this->CheckCMP0004(*i); + if(name == this->GetName() || name.empty()) + { + continue; + } + items.push_back(cmLinkItem(name, this->FindTargetToLink(name))); + } +} + +//---------------------------------------------------------------------------- const char* cmTarget::GetSuffixVariableInternal(bool implib) const { switch(this->GetType()) @@ -2755,6 +3404,21 @@ void cmTarget::SetPropertyDefault(const std::string& property, } //---------------------------------------------------------------------------- +bool cmTarget::HaveBuildTreeRPATH(const std::string& config) const +{ + if (this->GetPropertyAsBool("SKIP_BUILD_RPATH")) + { + return false; + } + if(cmLinkImplementationLibraries const* impl = + this->GetLinkImplementationLibraries(config)) + { + return !impl->Libraries.empty(); + } + return false; +} + +//---------------------------------------------------------------------------- bool cmTarget::HaveInstallTreeRPATH() const { const char* install_rpath = this->GetProperty("INSTALL_RPATH"); @@ -3076,6 +3740,50 @@ cmTarget::GetObjectLibrariesCMP0026(std::vector& objlibs) const } //---------------------------------------------------------------------------- +void cmTarget::GetLanguages(std::set& languages, + const std::string& config) const +{ + std::vector sourceFiles; + this->GetSourceFiles(sourceFiles, config); + for(std::vector::const_iterator + i = sourceFiles.begin(); i != sourceFiles.end(); ++i) + { + const std::string& lang = (*i)->GetLanguage(); + if(!lang.empty()) + { + languages.insert(lang); + } + } + + std::vector objectLibraries; + std::vector externalObjects; + if (!this->Makefile->IsConfigured()) + { + this->GetObjectLibrariesCMP0026(objectLibraries); + } + else + { + cmGeneratorTarget* gt = this->Makefile->GetGlobalGenerator() + ->GetGeneratorTarget(this); + gt->GetExternalObjects(externalObjects, config); + for(std::vector::const_iterator + i = externalObjects.begin(); i != externalObjects.end(); ++i) + { + std::string objLib = (*i)->GetObjectLibrary(); + if (cmTarget* tgt = this->Makefile->FindTargetToUse(objLib)) + { + objectLibraries.push_back(tgt); + } + } + } + for(std::vector::const_iterator + i = objectLibraries.begin(); i != objectLibraries.end(); ++i) + { + (*i)->GetLanguages(languages, config); + } +} + +//---------------------------------------------------------------------------- cmTarget::ImportInfo const* cmTarget::GetImportInfo(const std::string& config) const { @@ -3425,6 +4133,393 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, } //---------------------------------------------------------------------------- +cmTarget::LinkInterface const* cmTarget::GetLinkInterface( + const std::string& config, + cmTarget const* head) const +{ + // Imported targets have their own link interface. + if(this->IsImported()) + { + return this->GetImportLinkInterface(config, head, false); + } + + // Link interfaces are not supported for executables that do not + // export symbols. + if(this->GetType() == cmTarget::EXECUTABLE && + !this->IsExecutableWithExports()) + { + return 0; + } + + // Lookup any existing link interface for this configuration. + std::string CONFIG = cmSystemTools::UpperCase(config); + cmTargetInternals::HeadToLinkInterfaceMap& hm = + this->Internal->LinkInterfaceMap[CONFIG]; + + // If the link interface does not depend on the head target + // then return the one we computed first. + if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) + { + return &hm.begin()->second; + } + + cmTargetInternals::OptionalLinkInterface& iface = hm[head]; + if(!iface.LibrariesDone) + { + iface.LibrariesDone = true; + this->Internal->ComputeLinkInterfaceLibraries( + this, config, iface, head, false); + } + if(!iface.AllDone) + { + iface.AllDone = true; + if(iface.Exists) + { + this->Internal->ComputeLinkInterface(this, config, iface, head); + } + } + + return iface.Exists? &iface : 0; +} + +//---------------------------------------------------------------------------- +cmTarget::LinkInterfaceLibraries const* +cmTarget::GetLinkInterfaceLibraries(const std::string& config, + cmTarget const* head, + bool usage_requirements_only) const +{ + // Imported targets have their own link interface. + if(this->IsImported()) + { + return this->GetImportLinkInterface(config, head, usage_requirements_only); + } + + // Link interfaces are not supported for executables that do not + // export symbols. + if(this->GetType() == cmTarget::EXECUTABLE && + !this->IsExecutableWithExports()) + { + return 0; + } + + // Lookup any existing link interface for this configuration. + std::string CONFIG = cmSystemTools::UpperCase(config); + cmTargetInternals::HeadToLinkInterfaceMap& hm = + (usage_requirements_only ? + this->Internal->LinkInterfaceUsageRequirementsOnlyMap[CONFIG] : + this->Internal->LinkInterfaceMap[CONFIG]); + + // If the link interface does not depend on the head target + // then return the one we computed first. + if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) + { + return &hm.begin()->second; + } + + cmTargetInternals::OptionalLinkInterface& iface = hm[head]; + if(!iface.LibrariesDone) + { + iface.LibrariesDone = true; + this->Internal->ComputeLinkInterfaceLibraries( + this, config, iface, head, usage_requirements_only); + } + + return iface.Exists? &iface : 0; +} + +//---------------------------------------------------------------------------- +cmTarget::LinkInterface const* +cmTarget::GetImportLinkInterface(const std::string& config, + cmTarget const* headTarget, + bool usage_requirements_only) const +{ + cmTarget::ImportInfo const* info = this->GetImportInfo(config); + if(!info) + { + return 0; + } + + std::string CONFIG = cmSystemTools::UpperCase(config); + cmTargetInternals::HeadToLinkInterfaceMap& hm = + (usage_requirements_only ? + this->Internal->LinkInterfaceUsageRequirementsOnlyMap[CONFIG] : + this->Internal->LinkInterfaceMap[CONFIG]); + + // If the link interface does not depend on the head target + // then return the one we computed first. + if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) + { + return &hm.begin()->second; + } + + cmTargetInternals::OptionalLinkInterface& iface = hm[headTarget]; + if(!iface.AllDone) + { + iface.AllDone = true; + iface.Multiplicity = info->Multiplicity; + cmSystemTools::ExpandListArgument(info->Languages, iface.Languages); + this->ExpandLinkItems(info->LibrariesProp, info->Libraries, config, + headTarget, usage_requirements_only, + iface.Libraries, + iface.HadHeadSensitiveCondition); + std::vector deps; + cmSystemTools::ExpandListArgument(info->SharedDeps, deps); + this->LookupLinkItems(deps, iface.SharedDeps); + } + + return &iface; +} + +//---------------------------------------------------------------------------- +void +cmTargetInternals::ComputeLinkInterfaceLibraries( + cmTarget const* thisTarget, + const std::string& config, + OptionalLinkInterface& iface, + cmTarget const* headTarget, + bool usage_requirements_only) +{ + // Construct the property name suffix for this configuration. + std::string suffix = "_"; + if(!config.empty()) + { + suffix += cmSystemTools::UpperCase(config); + } + else + { + suffix += "NOCONFIG"; + } + + // An explicit list of interface libraries may be set for shared + // libraries and executables that export symbols. + const char* explicitLibraries = 0; + std::string linkIfaceProp; + if(thisTarget->GetPolicyStatusCMP0022() != cmPolicies::OLD && + thisTarget->GetPolicyStatusCMP0022() != cmPolicies::WARN) + { + // CMP0022 NEW behavior is to use INTERFACE_LINK_LIBRARIES. + linkIfaceProp = "INTERFACE_LINK_LIBRARIES"; + explicitLibraries = thisTarget->GetProperty(linkIfaceProp); + } + else if(thisTarget->GetType() == cmTarget::SHARED_LIBRARY || + thisTarget->IsExecutableWithExports()) + { + // CMP0022 OLD behavior is to use LINK_INTERFACE_LIBRARIES if set on a + // shared lib or executable. + + // Lookup the per-configuration property. + linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; + linkIfaceProp += suffix; + explicitLibraries = thisTarget->GetProperty(linkIfaceProp); + + // If not set, try the generic property. + if(!explicitLibraries) + { + linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; + explicitLibraries = thisTarget->GetProperty(linkIfaceProp); + } + } + + if(explicitLibraries && + thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN && + !this->PolicyWarnedCMP0022) + { + // Compare the explicitly set old link interface properties to the + // preferred new link interface property one and warn if different. + const char* newExplicitLibraries = + thisTarget->GetProperty("INTERFACE_LINK_LIBRARIES"); + if (newExplicitLibraries + && strcmp(newExplicitLibraries, explicitLibraries) != 0) + { + std::ostringstream w; + w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n" + "Target \"" << thisTarget->GetName() << "\" has an " + "INTERFACE_LINK_LIBRARIES property which differs from its " << + linkIfaceProp << " properties." + "\n" + "INTERFACE_LINK_LIBRARIES:\n" + " " << newExplicitLibraries << "\n" << + linkIfaceProp << ":\n" + " " << (explicitLibraries ? explicitLibraries : "(empty)") << "\n"; + thisTarget->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + this->PolicyWarnedCMP0022 = true; + } + } + + // There is no implicit link interface for executables or modules + // so if none was explicitly set then there is no link interface. + if(!explicitLibraries && + (thisTarget->GetType() == cmTarget::EXECUTABLE || + (thisTarget->GetType() == cmTarget::MODULE_LIBRARY))) + { + return; + } + iface.Exists = true; + iface.ExplicitLibraries = explicitLibraries; + + if(explicitLibraries) + { + // The interface libraries have been explicitly set. + thisTarget->ExpandLinkItems(linkIfaceProp, explicitLibraries, config, + headTarget, usage_requirements_only, + iface.Libraries, + iface.HadHeadSensitiveCondition); + } + else if (thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN + || thisTarget->GetPolicyStatusCMP0022() == cmPolicies::OLD) + // If CMP0022 is NEW then the plain tll signature sets the + // INTERFACE_LINK_LIBRARIES, so if we get here then the project + // cleared the property explicitly and we should not fall back + // to the link implementation. + { + // The link implementation is the default link interface. + cmLinkImplementationLibraries const* impl = + thisTarget->GetLinkImplementationLibrariesInternal(config, headTarget); + iface.Libraries.insert(iface.Libraries.end(), + impl->Libraries.begin(), impl->Libraries.end()); + if(thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN && + !this->PolicyWarnedCMP0022 && !usage_requirements_only) + { + // Compare the link implementation fallback link interface to the + // preferred new link interface property and warn if different. + std::vector ifaceLibs; + static const std::string newProp = "INTERFACE_LINK_LIBRARIES"; + if(const char* newExplicitLibraries = thisTarget->GetProperty(newProp)) + { + bool hadHeadSensitiveConditionDummy = false; + thisTarget->ExpandLinkItems(newProp, newExplicitLibraries, config, + headTarget, usage_requirements_only, + ifaceLibs, hadHeadSensitiveConditionDummy); + } + if (ifaceLibs != iface.Libraries) + { + std::string oldLibraries = cmJoin(impl->Libraries, ";"); + std::string newLibraries = cmJoin(ifaceLibs, ";"); + if(oldLibraries.empty()) + { oldLibraries = "(empty)"; } + if(newLibraries.empty()) + { newLibraries = "(empty)"; } + + std::ostringstream w; + w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n" + "Target \"" << thisTarget->GetName() << "\" has an " + "INTERFACE_LINK_LIBRARIES property. " + "This should be preferred as the source of the link interface " + "for this library but because CMP0022 is not set CMake is " + "ignoring the property and using the link implementation " + "as the link interface instead." + "\n" + "INTERFACE_LINK_LIBRARIES:\n" + " " << newLibraries << "\n" + "Link implementation:\n" + " " << oldLibraries << "\n"; + thisTarget->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + this->PolicyWarnedCMP0022 = true; + } + } + } +} + +//---------------------------------------------------------------------------- +void cmTargetInternals::ComputeLinkInterface(cmTarget const* thisTarget, + const std::string& config, + OptionalLinkInterface& iface, + cmTarget const* headTarget) const +{ + if(iface.ExplicitLibraries) + { + if(thisTarget->GetType() == cmTarget::SHARED_LIBRARY + || thisTarget->GetType() == cmTarget::STATIC_LIBRARY + || thisTarget->GetType() == cmTarget::INTERFACE_LIBRARY) + { + // Shared libraries may have runtime implementation dependencies + // on other shared libraries that are not in the interface. + UNORDERED_SET emitted; + for(std::vector::const_iterator + li = iface.Libraries.begin(); li != iface.Libraries.end(); ++li) + { + emitted.insert(*li); + } + if (thisTarget->GetType() != cmTarget::INTERFACE_LIBRARY) + { + cmTarget::LinkImplementation const* impl = + thisTarget->GetLinkImplementation(config); + for(std::vector::const_iterator + li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li) + { + if(emitted.insert(*li).second) + { + if(li->Target) + { + // This is a runtime dependency on another shared library. + if(li->Target->GetType() == cmTarget::SHARED_LIBRARY) + { + iface.SharedDeps.push_back(*li); + } + } + else + { + // TODO: Recognize shared library file names. Perhaps this + // should be moved to cmComputeLinkInformation, but that creates + // a chicken-and-egg problem since this list is needed for its + // construction. + } + } + } + } + } + } + else if (thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN + || thisTarget->GetPolicyStatusCMP0022() == cmPolicies::OLD) + { + // The link implementation is the default link interface. + cmLinkImplementationLibraries const* + impl = thisTarget->GetLinkImplementationLibrariesInternal(config, + headTarget); + iface.ImplementationIsInterface = true; + iface.WrongConfigLibraries = impl->WrongConfigLibraries; + } + + if(thisTarget->LinkLanguagePropagatesToDependents()) + { + // Targets using this archive need its language runtime libraries. + if(cmTarget::LinkImplementation const* impl = + thisTarget->GetLinkImplementation(config)) + { + iface.Languages = impl->Languages; + } + } + + if(thisTarget->GetType() == cmTarget::STATIC_LIBRARY) + { + // Construct the property name suffix for this configuration. + std::string suffix = "_"; + if(!config.empty()) + { + suffix += cmSystemTools::UpperCase(config); + } + else + { + suffix += "NOCONFIG"; + } + + // How many repetitions are needed if this library has cyclic + // dependencies? + std::string propName = "LINK_INTERFACE_MULTIPLICITY"; + propName += suffix; + if(const char* config_reps = thisTarget->GetProperty(propName)) + { + sscanf(config_reps, "%u", &iface.Multiplicity); + } + else if(const char* reps = + thisTarget->GetProperty("LINK_INTERFACE_MULTIPLICITY")) + { + sscanf(reps, "%u", &iface.Multiplicity); + } + } +} + +//---------------------------------------------------------------------------- void cmTargetInternals::AddInterfaceEntries( cmTarget const* thisTarget, std::string const& config, std::string const& prop, std::vector& entries) @@ -3450,12 +4545,32 @@ void cmTargetInternals::AddInterfaceEntries( } } -cmOptionalLinkImplementation& -cmTarget::GetLinkImplMap(std::string const& config) const +//---------------------------------------------------------------------------- +cmTarget::LinkImplementation const* +cmTarget::GetLinkImplementation(const std::string& config) const { + // There is no link implementation for imported targets. + if(this->IsImported()) + { + return 0; + } + // Populate the link implementation for this configuration. std::string CONFIG = cmSystemTools::UpperCase(config); - return Internal->LinkImplMap[CONFIG][this]; + cmTargetInternals::OptionalLinkImplementation& + impl = this->Internal->LinkImplMap[CONFIG][this]; + if(!impl.LibrariesDone) + { + impl.LibrariesDone = true; + this->Internal + ->ComputeLinkImplementationLibraries(this, config, impl, this); + } + if(!impl.LanguagesDone) + { + impl.LanguagesDone = true; + this->Internal->ComputeLinkImplementationLanguages(this, config, impl); + } + return &impl; } //---------------------------------------------------------------------------- @@ -3488,36 +4603,39 @@ cmTarget::GetLinkImplementationLibrariesInternal(const std::string& config, return &hm.begin()->second; } - cmOptionalLinkImplementation& impl = hm[head]; + cmTargetInternals::OptionalLinkImplementation& impl = hm[head]; if(!impl.LibrariesDone) { impl.LibrariesDone = true; - this->ComputeLinkImplementationLibraries(config, impl, head); + this->Internal + ->ComputeLinkImplementationLibraries(this, config, impl, head); } return &impl; } //---------------------------------------------------------------------------- -void cmTarget::ComputeLinkImplementationLibraries( +void +cmTargetInternals::ComputeLinkImplementationLibraries( + cmTarget const* thisTarget, const std::string& config, - cmOptionalLinkImplementation& impl, + OptionalLinkImplementation& impl, cmTarget const* head) const { // Collect libraries directly linked in this configuration. for (std::vector::const_iterator - le = this->Internal->LinkImplementationPropertyEntries.begin(), - end = this->Internal->LinkImplementationPropertyEntries.end(); + le = this->LinkImplementationPropertyEntries.begin(), + end = this->LinkImplementationPropertyEntries.end(); le != end; ++le) { std::vector llibs; cmGeneratorExpressionDAGChecker dagChecker( - this->GetName(), + thisTarget->GetName(), "LINK_LIBRARIES", 0, 0); cmGeneratorExpression ge(le->Backtrace); cmsys::auto_ptr const cge = ge.Parse(le->Value); std::string const evaluated = - cge->Evaluate(this->Makefile, config, false, head, &dagChecker); + cge->Evaluate(thisTarget->Makefile, config, false, head, &dagChecker); cmSystemTools::ExpandListArgument(evaluated, llibs); if(cge->GetHadHeadSensitiveCondition()) { @@ -3528,15 +4646,15 @@ void cmTarget::ComputeLinkImplementationLibraries( li != llibs.end(); ++li) { // Skip entries that resolve to the target itself or are empty. - std::string name = this->CheckCMP0004(*li); - if(name == this->GetName() || name.empty()) + std::string name = thisTarget->CheckCMP0004(*li); + if(name == thisTarget->GetName() || name.empty()) { - if(name == this->GetName()) + if(name == thisTarget->GetName()) { bool noMessage = false; cmake::MessageType messageType = cmake::FATAL_ERROR; std::ostringstream e; - switch(this->GetPolicyStatusCMP0038()) + switch(thisTarget->GetPolicyStatusCMP0038()) { case cmPolicies::WARN: { @@ -3555,9 +4673,9 @@ void cmTarget::ComputeLinkImplementationLibraries( if(!noMessage) { - e << "Target \"" << this->GetName() << "\" links to itself."; - this->Makefile->GetCMakeInstance()->IssueMessage( - messageType, e.str(), this->GetBacktrace()); + e << "Target \"" << thisTarget->GetName() << "\" links to itself."; + thisTarget->Makefile->GetCMakeInstance()->IssueMessage( + messageType, e.str(), thisTarget->GetBacktrace()); if (messageType == cmake::FATAL_ERROR) { return; @@ -3569,7 +4687,7 @@ void cmTarget::ComputeLinkImplementationLibraries( // The entry is meant for this configuration. impl.Libraries.push_back( - cmLinkImplItem(name, this->FindTargetToLink(name), + cmLinkImplItem(name, thisTarget->FindTargetToLink(name), le->Backtrace, evaluated != le->Value)); } @@ -3577,35 +4695,51 @@ void cmTarget::ComputeLinkImplementationLibraries( for (std::set::const_iterator it = seenProps.begin(); it != seenProps.end(); ++it) { - if (!this->GetProperty(*it)) + if (!thisTarget->GetProperty(*it)) { - this->LinkImplicitNullProperties.insert(*it); + thisTarget->LinkImplicitNullProperties.insert(*it); } } - cge->GetMaxLanguageStandard(this, this->MaxLanguageStandards); + cge->GetMaxLanguageStandard(thisTarget, thisTarget->MaxLanguageStandards); } - cmTarget::LinkLibraryType linkType = this->ComputeLinkType(config); + cmTarget::LinkLibraryType linkType = thisTarget->ComputeLinkType(config); cmTarget::LinkLibraryVectorType const& oldllibs = - this->GetOriginalLinkLibraries(); + thisTarget->GetOriginalLinkLibraries(); for(cmTarget::LinkLibraryVectorType::const_iterator li = oldllibs.begin(); li != oldllibs.end(); ++li) { if(li->second != cmTarget::GENERAL && li->second != linkType) { - std::string name = this->CheckCMP0004(li->first); - if(name == this->GetName() || name.empty()) + std::string name = thisTarget->CheckCMP0004(li->first); + if(name == thisTarget->GetName() || name.empty()) { continue; } // Support OLD behavior for CMP0003. impl.WrongConfigLibraries.push_back( - cmLinkItem(name, this->FindTargetToLink(name))); + cmLinkItem(name, thisTarget->FindTargetToLink(name))); } } } //---------------------------------------------------------------------------- +void +cmTargetInternals::ComputeLinkImplementationLanguages( + cmTarget const* thisTarget, + const std::string& config, + OptionalLinkImplementation& impl) const +{ + // This target needs runtime libraries for its source languages. + std::set languages; + // Get languages used in our source files. + thisTarget->GetLanguages(languages, config); + // Copy the set of langauges to the link implementation. + impl.Languages.insert(impl.Languages.begin(), + languages.begin(), languages.end()); +} + +//---------------------------------------------------------------------------- cmTarget const* cmTarget::FindTargetToLink(std::string const& name) const { cmTarget const* tgt = this->Makefile->FindTargetToUse(name); @@ -3712,6 +4846,10 @@ cmTargetInternalPointer //---------------------------------------------------------------------------- cmTargetInternalPointer::~cmTargetInternalPointer() { + cmDeleteAll(this->Pointer->IncludeDirectoriesItems); + cmDeleteAll(this->Pointer->CompileOptionsItems); + cmDeleteAll(this->Pointer->CompileFeaturesItems); + cmDeleteAll(this->Pointer->CompileDefinitionsItems); cmDeleteAll(this->Pointer->SourceEntries); delete this->Pointer; } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index d032380..2007b40 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -132,11 +132,15 @@ public: void AddPostBuildCommand(cmCustomCommand const &cmd) {this->PostBuildCommands.push_back(cmd);} + void Compute(); + /** * Get the list of the source files used by this target */ void GetSourceFiles(std::vector &files, const std::string& config) const; + bool GetConfigCommonSourceFiles(std::vector& files) const; + /** * Add sources to the target. */ @@ -229,15 +233,53 @@ public: void GetObjectLibrariesCMP0026(std::vector& objlibs) const; - cmLinkImplementationLibraries const* - GetLinkImplementationLibraries(const std::string& config) const; + /** The link interface specifies transitive library dependencies and + other information needed by targets that link to this target. */ + struct LinkInterfaceLibraries + { + // Libraries listed in the interface. + std::vector Libraries; + }; + struct LinkInterface: public LinkInterfaceLibraries + { + // Languages whose runtime libraries must be linked. + std::vector Languages; - void ComputeLinkImplementationLibraries(const std::string& config, - cmOptionalLinkImplementation& impl, - cmTarget const* head) const; + // Shared library dependencies needed for linking on some platforms. + std::vector SharedDeps; - cmOptionalLinkImplementation& - GetLinkImplMap(std::string const& config) const; + // Number of repetitions of a strongly connected component of two + // or more static libraries. + int Multiplicity; + + // Libraries listed for other configurations. + // Needed only for OLD behavior of CMP0003. + std::vector WrongConfigLibraries; + + bool ImplementationIsInterface; + + LinkInterface(): Multiplicity(0), ImplementationIsInterface(false) {} + }; + + /** Get the link interface for the given configuration. Returns 0 + if the target cannot be linked. */ + LinkInterface const* GetLinkInterface(const std::string& config, + cmTarget const* headTarget) const; + LinkInterfaceLibraries const* + GetLinkInterfaceLibraries(const std::string& config, + cmTarget const* headTarget, + bool usage_requirements_only) const; + + struct LinkImplementation: public cmLinkImplementationLibraries + { + // Languages whose runtime libraries must be linked. + std::vector Languages; + }; + LinkImplementation const* + GetLinkImplementation(const std::string& config) const; + + cmLinkImplementationLibraries const* + GetLinkImplementationLibraries(const std::string& config) const; cmTarget const* FindTargetToLink(std::string const& name) const; @@ -289,6 +331,7 @@ public: bool GetImplibGNUtoMS(std::string const& gnuName, std::string& out, const char* newExt = 0) const; + bool HaveBuildTreeRPATH(const std::string& config) const; bool HaveInstallTreeRPATH() const; // Get the properties @@ -303,6 +346,18 @@ public: If no macro should be defined null is returned. */ const char* GetExportMacro() const; + void GetCompileDefinitions(std::vector &result, + const std::string& config, + const std::string& language) const; + + // Compute the set of languages compiled by the target. This is + // computed every time it is called because the languages can change + // when source file properties are changed and we do not have enough + // information to forward these property changes to the targets + // until we have per-target object file properties. + void GetLanguages(std::set& languages, + std::string const& config) const; + /** Return whether this target is an executable with symbol exports enabled. */ bool IsExecutableWithExports() const; @@ -346,6 +401,9 @@ public: /** @return whether this target have a well defined output file name. */ bool HaveWellDefinedOutputFiles() const; + std::vector GetIncludeDirectories( + const std::string& config, + const std::string& language) const; void InsertInclude(std::string const& entry, cmListFileBacktrace const& bt, bool before = false); @@ -357,6 +415,12 @@ public: void AppendBuildInterfaceIncludes(); + void GetCompileOptions(std::vector &result, + const std::string& config, + const std::string& language) const; + void GetCompileFeatures(std::vector &features, + const std::string& config) const; + bool IsNullImpliedByLinkLibraries(const std::string &p) const; std::string GetDebugGeneratorExpressions(const std::string &value, @@ -375,18 +439,6 @@ public: return this->MaxLanguageStandards; } - cmStringRange GetIncludeDirectoriesEntries() const; - cmBacktraceRange GetIncludeDirectoriesBacktraces() const; - - cmStringRange GetCompileOptionsEntries() const; - cmBacktraceRange GetCompileOptionsBacktraces() const; - - cmStringRange GetCompileFeaturesEntries() const; - cmBacktraceRange GetCompileFeaturesBacktraces() const; - - cmStringRange GetCompileDefinitionsEntries() const; - cmBacktraceRange GetCompileDefinitionsBacktraces() const; - #if defined(_WIN32) && !defined(__CYGWIN__) const LinkLibraryVectorType &GetLinkLibrariesForVS6() const { return this->LinkLibrariesForVS6;} @@ -501,7 +553,11 @@ private: bool IsApple; bool IsImportedTarget; bool BuildInterfaceIncludesAppended; + mutable bool DebugIncludesDone; + mutable bool DebugCompileOptionsDone; + mutable bool DebugCompileDefinitionsDone; mutable bool DebugSourcesDone; + mutable bool DebugCompileFeaturesDone; mutable bool LinkImplementationLanguageIsContextDependent; #if defined(_WIN32) && !defined(__CYGWIN__) bool LinkLibrariesForVS6Analyzed; @@ -535,10 +591,23 @@ private: void ComputeImportInfo(std::string const& desired_config, ImportInfo& info) const; + + LinkInterface const* + GetImportLinkInterface(const std::string& config, cmTarget const* head, + bool usage_requirements_only) const; + cmLinkImplementationLibraries const* GetLinkImplementationLibrariesInternal(const std::string& config, cmTarget const* head) const; + void ExpandLinkItems(std::string const& prop, std::string const& value, + std::string const& config, cmTarget const* headTarget, + bool usage_requirements_only, + std::vector& items, + bool& hadHeadSensitiveCondition) const; + void LookupLinkItems(std::vector const& names, + std::vector& items) const; + std::string ProcessSourceItemCMP0049(const std::string& s); void ClearLinkMaps(); diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index e7716d8..823b550 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -965,7 +965,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups() std::vector sourceGroups = this->Makefile->GetSourceGroups(); std::vector classes; - if (!this->GeneratorTarget->GetConfigCommonSourceFiles(classes)) + if (!this->Target->GetConfigCommonSourceFiles(classes)) { return; } @@ -1934,7 +1934,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( clOptions.Parse(flags.c_str()); clOptions.Parse(defineFlags.c_str()); std::vector targetDefines; - this->GeneratorTarget->GetCompileDefinitions(targetDefines, + this->Target->GetCompileDefinitions(targetDefines, configName.c_str(), "CXX"); clOptions.AddDefines(targetDefines); if(this->MSTools) ----------------------------------------------------------------------- Summary of changes: Source/cmComputeLinkDepends.cxx | 25 +- Source/cmComputeLinkDepends.h | 5 +- Source/cmComputeLinkInformation.cxx | 2 +- Source/cmComputeTargetDepends.cxx | 7 +- Source/cmExportFileGenerator.cxx | 7 +- Source/cmExtraCodeBlocksGenerator.cxx | 2 +- Source/cmGeneratorExpressionNode.cxx | 4 +- Source/cmGeneratorTarget.cxx | 1200 +---------------------- Source/cmGeneratorTarget.h | 122 --- Source/cmGhsMultiTargetGenerator.cxx | 9 +- Source/cmGlobalGenerator.cxx | 1 + Source/cmGlobalUnixMakefileGenerator3.cxx | 3 +- Source/cmGlobalVisualStudio8Generator.cxx | 2 +- Source/cmGlobalVisualStudioGenerator.cxx | 8 +- Source/cmGlobalXCodeGenerator.cxx | 25 +- Source/cmLinkItem.h | 17 - Source/cmLocalGenerator.cxx | 13 +- Source/cmLocalUnixMakefileGenerator3.cxx | 4 +- Source/cmLocalVisualStudio6Generator.cxx | 5 +- Source/cmLocalVisualStudio7Generator.cxx | 9 +- Source/cmMakefileTargetGenerator.cxx | 2 +- Source/cmQtAutoGenerators.cxx | 16 +- Source/cmTarget.cxx | 1440 +++++++++++++++++++++++++--- Source/cmTarget.h | 107 ++- Source/cmVisualStudio10TargetGenerator.cxx | 4 +- 25 files changed, 1451 insertions(+), 1588 deletions(-) hooks/post-receive -- CMake From steveire at gmail.com Wed Aug 26 13:59:49 2015 From: steveire at gmail.com (Stephen Kelly) Date: Wed, 26 Aug 2015 13:59:49 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2552-g566f149 Message-ID: <20150826175949.90086B2058@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 566f149abf8bab6956f43010375cde30dd67125d (commit) via c2b7336ff3122c57a235aeaa1699ba5627ecf3ce (commit) via 69329fff70300debf10b62ac08a6bcee9ae7bc3c (commit) via 0431f2c4d7cbfcd873bc34caee9ed09253e8c8ad (commit) via abe9505df94e9a1511238c41f9d4459064148c94 (commit) via d4a24c0e953e0032a2e483917850b7f8f387bbb2 (commit) via 83981cf5931aaa2d9bbf4f99ea55c99736173fdf (commit) via 771e79a2bf97e2e5de40106396358adc773014f1 (commit) via 3846ebcf2b60b73e3eec848bd3dd41711eac5dc4 (commit) via a7f5d70dde50ac74726f3c23d276d2fdac70d659 (commit) via d051086ccec5cd4b381cf47afb0e7fe962ed4c0b (commit) via db4cb92bda8b43c3d66d27533622bb802e823589 (commit) via e6ccbf6f30fb7b893b00a7c26fa165065eed4323 (commit) via 8bfb0c53dae93d697ca5d92ff79068af351fe56b (commit) via 2cb3e5740269757f6f93d24a4d13570ee72de318 (commit) via 6d3d099b4a2d8b020fb1a9ebeb29b17b3fb6c9d6 (commit) via 0db9d9278760c90be1fbf5c4eeb93ef9c524041a (commit) via 84b847e42fde288bc102198aedeb68e19b41ef1e (commit) via 6220241fd0bb7902c932742a7aa3d6a96fd0e919 (commit) via 6353816786caccfef7acb3fd72aa28e0366da405 (commit) via 20993de46444e0f74700a641b54a8ca7e015bac4 (commit) via f8ca51a054732d5b0e2c6052ee102b748bd5848c (commit) via d67584ccc4262c103a180504cb294e3ad6b6910d (commit) via 33df7f36d0b99a87880ee76d39b5814c98e78bd1 (commit) from 6fbcda20e178eaa6fb5c4fd0a78f3623f190ae60 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=566f149abf8bab6956f43010375cde30dd67125d commit 566f149abf8bab6956f43010375cde30dd67125d Merge: 6fbcda2 c2b7336 Author: Stephen Kelly AuthorDate: Wed Aug 26 13:59:45 2015 -0400 Commit: CMake Topic Stage CommitDate: Wed Aug 26 13:59:45 2015 -0400 Merge topic 'use-generator-target' into next c2b7336f cmGeneratorTarget: Move GetConfigCommonSourceFiles from cmTarget. 69329fff cmGeneratorTarget: Move GetLanguages from cmTarget. 0431f2c4 cmGeneratorTarget: Move ComputeLinkImplementationLanguages from cmTarget. abe9505d cmGeneratorTarget: Move HaveBuildTreeRPath from cmTarget. d4a24c0e cmGeneratorTarget: Move GetLinkImplementation from cmTarget. 83981cf5 cmTarget: Add GetLinkImplMap method. 771e79a2 cmLinkItem: Add cmOptionalLinkImplementation type. 3846ebcf cmLinkItem: Add cmLinkImplementation type. a7f5d70d cmGeneratorTarget: Move compile defintions processing from cmTarget. d051086c cmGeneratorTarget: Move compile features processing from cmTarget. db4cb92b cmGeneratorTarget: Move compile options processing from cmTarget. e6ccbf6f cmGeneratorTarget: Move include directory processing from cmTarget. 8bfb0c53 cmGeneratorTarget: Move link iface helpers from cmTarget. 2cb3e574 cmGeneratorTarget: Move GetImportLinkInterface from cmTarget. 6d3d099b cmGeneratorTarget: Move ComputeLinkInterfaceLibraries from cmTarget. 0db9d927 cmGeneratorTarget: Move GetLinkInterfaceLibraries from cmTarget. ... http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c2b7336ff3122c57a235aeaa1699ba5627ecf3ce commit c2b7336ff3122c57a235aeaa1699ba5627ecf3ce Author: Stephen Kelly AuthorDate: Wed Aug 5 17:37:50 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 26 19:46:33 2015 +0200 cmGeneratorTarget: Move GetConfigCommonSourceFiles from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 4ada029..cd7671d 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -4416,11 +4416,68 @@ cmGeneratorTarget::GetLinkImplementation(const std::string& config) const } //---------------------------------------------------------------------------- +bool cmGeneratorTarget::GetConfigCommonSourceFiles( + std::vector& files) const +{ + std::vector configs; + this->Makefile->GetConfigurations(configs); + if (configs.empty()) + { + configs.push_back(""); + } + + std::vector::const_iterator it = configs.begin(); + const std::string& firstConfig = *it; + this->Target->GetSourceFiles(files, firstConfig); + + for ( ; it != configs.end(); ++it) + { + std::vector configFiles; + this->Target->GetSourceFiles(configFiles, *it); + if (configFiles != files) + { + std::string firstConfigFiles; + const char* sep = ""; + for (std::vector::const_iterator fi = files.begin(); + fi != files.end(); ++fi) + { + firstConfigFiles += sep; + firstConfigFiles += (*fi)->GetFullPath(); + sep = "\n "; + } + + std::string thisConfigFiles; + sep = ""; + for (std::vector::const_iterator fi = configFiles.begin(); + fi != configFiles.end(); ++fi) + { + thisConfigFiles += sep; + thisConfigFiles += (*fi)->GetFullPath(); + sep = "\n "; + } + std::ostringstream e; + e << "Target \"" << this->GetName() + << "\" has source files which vary by " + "configuration. This is not supported by the \"" + << this->GlobalGenerator->GetName() + << "\" generator.\n" + "Config \"" << firstConfig << "\":\n" + " " << firstConfigFiles << "\n" + "Config \"" << *it << "\":\n" + " " << thisConfigFiles << "\n"; + this->LocalGenerator->IssueMessage(cmake::FATAL_ERROR, e.str()); + return false; + } + } + return true; +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetLanguages(std::set& languages, const std::string& config) const { std::vector sourceFiles; - this->Target->GetSourceFiles(sourceFiles, config); + this->GetSourceFiles(sourceFiles, config); for(std::vector::const_iterator i = sourceFiles.begin(); i != sourceFiles.end(); ++i) { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 5f96f2a..2c8467f 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -213,6 +213,8 @@ public: void GetLanguages(std::set& languages, std::string const& config) const; + bool GetConfigCommonSourceFiles(std::vector& files) const; + bool HaveBuildTreeRPATH(const std::string& config) const; /** Full path with trailing slash to the top-level directory diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 9b1f4c2..2bf04b4 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -843,7 +843,7 @@ cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget const& target) { // Issue diagnostic if the source files depend on the config. std::vector sources; - if (!target.GetConfigCommonSourceFiles(sources)) + if (!gt->GetConfigCommonSourceFiles(sources)) { return false; } diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 4511de5..eb547bd 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1124,7 +1124,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, // organize the sources std::vector classes; - if (!cmtarget.GetConfigCommonSourceFiles(classes)) + if (!gtgt->GetConfigCommonSourceFiles(classes)) { return false; } @@ -1505,7 +1505,8 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases, } std::vector classes; - if (!cmtarget.GetConfigCommonSourceFiles(classes)) + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); + if (!gtgt->GetConfigCommonSourceFiles(classes)) { return; } @@ -2557,7 +2558,8 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget) if(cmtarget.GetType() == cmTarget::UTILITY) { std::vector sources; - if (!cmtarget.GetConfigCommonSourceFiles(sources)) + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); + if (!gtgt->GetConfigCommonSourceFiles(sources)) { return 0; } @@ -3085,7 +3087,8 @@ bool cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root, } std::vector classes; - if (!cmtarget.GetConfigCommonSourceFiles(classes)) + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); + if (!gtgt->GetConfigCommonSourceFiles(classes)) { return false; } diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 0d07536..3a44367 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -305,9 +305,12 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout, // We may be modifying the source groups temporarily, so make a copy. std::vector sourceGroups = this->Makefile->GetSourceGroups(); + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); + // get the classes from the source lists then add them to the groups std::vector classes; - if (!target.GetConfigCommonSourceFiles(classes)) + if (!gt->GetConfigCommonSourceFiles(classes)) { return; } diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index f17c9a4..55ad852 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1469,10 +1469,13 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, // We may be modifying the source groups temporarily, so make a copy. std::vector sourceGroups = this->Makefile->GetSourceGroups(); + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); + // get the classes from the source lists then add them to the groups this->ModuleDefinitionFile = ""; std::vector classes; - if (!target.GetConfigCommonSourceFiles(classes)) + if (!gt->GetConfigCommonSourceFiles(classes)) { return; } @@ -1514,8 +1517,6 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, { // VS >= 8 support per-config source locations so we // list object library content as external objects. - cmGeneratorTarget* gt = - this->GlobalGenerator->GetGeneratorTarget(&target); std::vector objs; gt->UseObjectLibraries(objs, ""); if(!objs.empty()) diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index c58e7e4..0a4b546 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -403,7 +403,9 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg, ) { std::vector srcFiles; - target->GetConfigCommonSourceFiles(srcFiles); + cmGeneratorTarget* gtgt = + lg->GetGlobalGenerator()->GetGeneratorTarget(target); + gtgt->GetConfigCommonSourceFiles(srcFiles); for(std::vector::const_iterator fileIt = srcFiles.begin(); fileIt != srcFiles.end(); ++fileIt) @@ -661,7 +663,10 @@ void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target) const char* sepHeaders = ""; std::vector srcFiles; - target->GetConfigCommonSourceFiles(srcFiles); + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); + gtgt->GetConfigCommonSourceFiles(srcFiles); const char *skipMocSep = ""; const char *skipUicSep = ""; @@ -1046,7 +1051,10 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) cmMakefile *makefile = target->GetMakefile(); std::vector srcFiles; - target->GetConfigCommonSourceFiles(srcFiles); + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); + gtgt->GetConfigCommonSourceFiles(srcFiles); std::string qrcInputs; const char* qrcInputsSep = ""; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 8a21269..b2c70f0 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -725,62 +725,6 @@ void cmTarget::GetSourceFiles(std::vector &files, } //---------------------------------------------------------------------------- -bool -cmTarget::GetConfigCommonSourceFiles(std::vector& files) const -{ - std::vector configs; - this->Makefile->GetConfigurations(configs); - if (configs.empty()) - { - configs.push_back(""); - } - - std::vector::const_iterator it = configs.begin(); - const std::string& firstConfig = *it; - this->GetSourceFiles(files, firstConfig); - - for ( ; it != configs.end(); ++it) - { - std::vector configFiles; - this->GetSourceFiles(configFiles, *it); - if (configFiles != files) - { - std::string firstConfigFiles; - const char* sep = ""; - for (std::vector::const_iterator fi = files.begin(); - fi != files.end(); ++fi) - { - firstConfigFiles += sep; - firstConfigFiles += (*fi)->GetFullPath(); - sep = "\n "; - } - - std::string thisConfigFiles; - sep = ""; - for (std::vector::const_iterator fi = configFiles.begin(); - fi != configFiles.end(); ++fi) - { - thisConfigFiles += sep; - thisConfigFiles += (*fi)->GetFullPath(); - sep = "\n "; - } - std::ostringstream e; - e << "Target \"" << this->Name << "\" has source files which vary by " - "configuration. This is not supported by the \"" - << this->Makefile->GetGlobalGenerator()->GetName() - << "\" generator.\n" - "Config \"" << firstConfig << "\":\n" - " " << firstConfigFiles << "\n" - "Config \"" << *it << "\":\n" - " " << thisConfigFiles << "\n"; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); - return false; - } - } - return true; -} - -//---------------------------------------------------------------------------- void cmTarget::GetSourceFiles(std::vector &files, const std::string& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 8dee560..d032380 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -137,8 +137,6 @@ public: */ void GetSourceFiles(std::vector &files, const std::string& config) const; - bool GetConfigCommonSourceFiles(std::vector& files) const; - /** * Add sources to the target. */ diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 464a83a..e7716d8 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -965,7 +965,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups() std::vector sourceGroups = this->Makefile->GetSourceGroups(); std::vector classes; - if (!this->Target->GetConfigCommonSourceFiles(classes)) + if (!this->GeneratorTarget->GetConfigCommonSourceFiles(classes)) { return; } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=69329fff70300debf10b62ac08a6bcee9ae7bc3c commit 69329fff70300debf10b62ac08a6bcee9ae7bc3c Author: Stephen Kelly AuthorDate: Wed Aug 5 17:37:50 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 26 19:46:32 2015 +0200 cmGeneratorTarget: Move GetLanguages from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 22b1baf..4ada029 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -4416,6 +4416,57 @@ cmGeneratorTarget::GetLinkImplementation(const std::string& config) const } //---------------------------------------------------------------------------- +void cmGeneratorTarget::GetLanguages(std::set& languages, + const std::string& config) const +{ + std::vector sourceFiles; + this->Target->GetSourceFiles(sourceFiles, config); + for(std::vector::const_iterator + i = sourceFiles.begin(); i != sourceFiles.end(); ++i) + { + const std::string& lang = (*i)->GetLanguage(); + if(!lang.empty()) + { + languages.insert(lang); + } + } + + std::vector objectLibraries; + std::vector externalObjects; + if (!this->Makefile->IsConfigured()) + { + std::vector objectTargets; + this->Target->GetObjectLibrariesCMP0026(objectTargets); + objectLibraries.reserve(objectTargets.size()); + for (std::vector::const_iterator it = objectTargets.begin(); + it != objectTargets.end(); ++it) + { + objectLibraries.push_back(this->GlobalGenerator + ->GetGeneratorTarget(*it)); + } + } + else + { + this->GetExternalObjects(externalObjects, config); + for(std::vector::const_iterator + i = externalObjects.begin(); i != externalObjects.end(); ++i) + { + std::string objLib = (*i)->GetObjectLibrary(); + if (cmTarget* tgt = this->Makefile->FindTargetToUse(objLib)) + { + objectLibraries.push_back(this->GlobalGenerator + ->GetGeneratorTarget(tgt)); + } + } + } + for(std::vector::const_iterator + i = objectLibraries.begin(); i != objectLibraries.end(); ++i) + { + (*i)->GetLanguages(languages, config); + } +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::ComputeLinkImplementationLanguages( const std::string& config, cmOptionalLinkImplementation& impl) const @@ -4423,7 +4474,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLanguages( // This target needs runtime libraries for its source languages. std::set languages; // Get languages used in our source files. - this->Target->GetLanguages(languages, config); + this->GetLanguages(languages, config); // Copy the set of langauges to the link implementation. impl.Languages.insert(impl.Languages.begin(), languages.begin(), languages.end()); diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index f5dc20d..5f96f2a 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -205,6 +205,14 @@ public: cmOptionalLinkImplementation& impl ) const; + // Compute the set of languages compiled by the target. This is + // computed every time it is called because the languages can change + // when source file properties are changed and we do not have enough + // information to forward these property changes to the targets + // until we have per-target object file properties. + void GetLanguages(std::set& languages, + std::string const& config) const; + bool HaveBuildTreeRPATH(const std::string& config) const; /** Full path with trailing slash to the top-level directory diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index b240924..331caad 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -1134,7 +1134,8 @@ bool cmGlobalUnixMakefileGenerator3 ::NeedRequiresStep(cmTarget const& target) { std::set languages; - target.GetLanguages(languages, + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&target); + gtgt->GetLanguages(languages, target.GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE")); for(std::set::const_iterator l = languages.begin(); l != languages.end(); ++l) diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 634366e..9b1f4c2 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -836,6 +836,8 @@ void RegisterVisualStudioMacros(const std::string& macrosFile, bool cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget const& target) { + cmGeneratorTarget* gt = this->GetGeneratorTarget(&target); + // check to see if this is a fortran build std::set languages; { @@ -846,7 +848,7 @@ cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget const& target) return false; } } - target.GetLanguages(languages, ""); + gt->GetLanguages(languages, ""); if(languages.size() == 1) { if(*languages.begin() == "Fortran") diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 68fd06b..4511de5 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1805,7 +1805,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, // Compute the compilation flags for each language. std::set languages; - target.GetLanguages(languages, configName); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); + gtgt->GetLanguages(languages, configName); std::map cflags; for (std::set::iterator li = languages.begin(); li != languages.end(); ++li) @@ -1827,7 +1828,6 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, AddCompileOptions(flags, &target, lang, configName); } - cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); std::string llang = gtgt->GetLinkerLanguage(configName); if(binary && llang.empty()) { diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index ce370bc..589105e 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1257,7 +1257,9 @@ cmLocalUnixMakefileGenerator3 { // Get the set of source languages in the target. std::set languages; - target.GetLanguages(languages, + cmGeneratorTarget *gtgt = + this->GlobalGenerator->GetGeneratorTarget(&target); + gtgt->GetLanguages(languages, this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); fout << "\n" << "# Per-language clean rules from dependency scanning.\n" diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 0b3df90..cf88a74 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -276,7 +276,7 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags() { // write language flags for target std::set languages; - this->Target->GetLanguages(languages, + this->GeneratorTarget->GetLanguages(languages, this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); // put the compiler in the rules.make file so that if it changes // things rebuild diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index f395c45..8a21269 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3131,50 +3131,6 @@ cmTarget::GetObjectLibrariesCMP0026(std::vector& objlibs) const } //---------------------------------------------------------------------------- -void cmTarget::GetLanguages(std::set& languages, - const std::string& config) const -{ - std::vector sourceFiles; - this->GetSourceFiles(sourceFiles, config); - for(std::vector::const_iterator - i = sourceFiles.begin(); i != sourceFiles.end(); ++i) - { - const std::string& lang = (*i)->GetLanguage(); - if(!lang.empty()) - { - languages.insert(lang); - } - } - - std::vector objectLibraries; - std::vector externalObjects; - if (!this->Makefile->IsConfigured()) - { - this->GetObjectLibrariesCMP0026(objectLibraries); - } - else - { - cmGeneratorTarget* gt = this->Makefile->GetGlobalGenerator() - ->GetGeneratorTarget(this); - gt->GetExternalObjects(externalObjects, config); - for(std::vector::const_iterator - i = externalObjects.begin(); i != externalObjects.end(); ++i) - { - std::string objLib = (*i)->GetObjectLibrary(); - if (cmTarget* tgt = this->Makefile->FindTargetToUse(objLib)) - { - objectLibraries.push_back(tgt); - } - } - } - for(std::vector::const_iterator - i = objectLibraries.begin(); i != objectLibraries.end(); ++i) - { - (*i)->GetLanguages(languages, config); - } -} - -//---------------------------------------------------------------------------- cmTarget::ImportInfo const* cmTarget::GetImportInfo(const std::string& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 1db4ba1..8dee560 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -305,14 +305,6 @@ public: If no macro should be defined null is returned. */ const char* GetExportMacro() const; - // Compute the set of languages compiled by the target. This is - // computed every time it is called because the languages can change - // when source file properties are changed and we do not have enough - // information to forward these property changes to the targets - // until we have per-target object file properties. - void GetLanguages(std::set& languages, - std::string const& config) const; - /** Return whether this target is an executable with symbol exports enabled. */ bool IsExecutableWithExports() const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0431f2c4d7cbfcd873bc34caee9ed09253e8c8ad commit 0431f2c4d7cbfcd873bc34caee9ed09253e8c8ad Author: Stephen Kelly AuthorDate: Wed Aug 5 17:37:50 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 26 19:46:32 2015 +0200 cmGeneratorTarget: Move ComputeLinkImplementationLanguages from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 9dc045c..22b1baf 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -4410,12 +4410,26 @@ cmGeneratorTarget::GetLinkImplementation(const std::string& config) const if(!impl.LanguagesDone) { impl.LanguagesDone = true; - this->Target->ComputeLinkImplementationLanguages(config, impl); + this->ComputeLinkImplementationLanguages(config, impl); } return &impl; } //---------------------------------------------------------------------------- +void cmGeneratorTarget::ComputeLinkImplementationLanguages( + const std::string& config, + cmOptionalLinkImplementation& impl) const +{ + // This target needs runtime libraries for its source languages. + std::set languages; + // Get languages used in our source files. + this->Target->GetLanguages(languages, config); + // Copy the set of langauges to the link implementation. + impl.Languages.insert(impl.Languages.begin(), + languages.begin(), languages.end()); +} + +//---------------------------------------------------------------------------- bool cmGeneratorTarget::HaveBuildTreeRPATH(const std::string& config) const { if (this->Target->GetPropertyAsBool("SKIP_BUILD_RPATH")) diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 99463c7..f5dc20d 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -201,6 +201,10 @@ public: cmLinkImplementation const* GetLinkImplementation(const std::string& config) const; + void ComputeLinkImplementationLanguages(const std::string& config, + cmOptionalLinkImplementation& impl + ) const; + bool HaveBuildTreeRPATH(const std::string& config) const; /** Full path with trailing slash to the top-level directory diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 9073f82..f395c45 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3705,20 +3705,6 @@ void cmTarget::ComputeLinkImplementationLibraries( } //---------------------------------------------------------------------------- -void cmTarget::ComputeLinkImplementationLanguages( - const std::string& config, - cmOptionalLinkImplementation& impl) const -{ - // This target needs runtime libraries for its source languages. - std::set languages; - // Get languages used in our source files. - this->GetLanguages(languages, config); - // Copy the set of langauges to the link implementation. - impl.Languages.insert(impl.Languages.begin(), - languages.begin(), languages.end()); -} - -//---------------------------------------------------------------------------- cmTarget const* cmTarget::FindTargetToLink(std::string const& name) const { cmTarget const* tgt = this->Makefile->FindTargetToUse(name); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 8866e65..1db4ba1 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -237,9 +237,6 @@ public: void ComputeLinkImplementationLibraries(const std::string& config, cmOptionalLinkImplementation& impl, cmTarget const* head) const; - void ComputeLinkImplementationLanguages(const std::string& config, - cmOptionalLinkImplementation& impl - ) const; cmOptionalLinkImplementation& GetLinkImplMap(std::string const& config) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=abe9505df94e9a1511238c41f9d4459064148c94 commit abe9505df94e9a1511238c41f9d4459064148c94 Author: Stephen Kelly AuthorDate: Wed Aug 5 17:37:49 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 26 19:46:32 2015 +0200 cmGeneratorTarget: Move HaveBuildTreeRPath from cmTarget. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 6ba0eed..192ad5f 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -1925,7 +1925,7 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, (outputRuntime && this->Target->Target->HaveInstallTreeRPATH() && linking_for_install); bool use_build_rpath = - (outputRuntime && this->Target->Target->HaveBuildTreeRPATH(this->Config) && + (outputRuntime && this->Target->HaveBuildTreeRPATH(this->Config) && !linking_for_install); bool use_link_rpath = outputRuntime && linking_for_install && diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 44fac1d..9dc045c 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -909,7 +909,7 @@ cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const // If either a build or install tree rpath is set then the rpath // will likely change between the build tree and install tree and // this target must be relinked. - return this->Target->HaveBuildTreeRPATH(config) + return this->HaveBuildTreeRPATH(config) || this->Target->HaveInstallTreeRPATH(); } @@ -4414,3 +4414,18 @@ cmGeneratorTarget::GetLinkImplementation(const std::string& config) const } return &impl; } + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::HaveBuildTreeRPATH(const std::string& config) const +{ + if (this->Target->GetPropertyAsBool("SKIP_BUILD_RPATH")) + { + return false; + } + if(cmLinkImplementationLibraries const* impl = + this->Target->GetLinkImplementationLibraries(config)) + { + return !impl->Libraries.empty(); + } + return false; +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 58f5f6b..99463c7 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -201,6 +201,8 @@ public: cmLinkImplementation const* GetLinkImplementation(const std::string& config) const; + bool HaveBuildTreeRPATH(const std::string& config) const; + /** Full path with trailing slash to the top-level directory holding object files for this target. Includes the build time config name placeholder if needed for the generator. */ diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index a8ea0b8..9073f82 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2810,21 +2810,6 @@ void cmTarget::SetPropertyDefault(const std::string& property, } //---------------------------------------------------------------------------- -bool cmTarget::HaveBuildTreeRPATH(const std::string& config) const -{ - if (this->GetPropertyAsBool("SKIP_BUILD_RPATH")) - { - return false; - } - if(cmLinkImplementationLibraries const* impl = - this->GetLinkImplementationLibraries(config)) - { - return !impl->Libraries.empty(); - } - return false; -} - -//---------------------------------------------------------------------------- bool cmTarget::HaveInstallTreeRPATH() const { const char* install_rpath = this->GetProperty("INSTALL_RPATH"); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 1d353ab..8866e65 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -294,7 +294,6 @@ public: bool GetImplibGNUtoMS(std::string const& gnuName, std::string& out, const char* newExt = 0) const; - bool HaveBuildTreeRPATH(const std::string& config) const; bool HaveInstallTreeRPATH() const; // Get the properties http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d4a24c0e953e0032a2e483917850b7f8f387bbb2 commit d4a24c0e953e0032a2e483917850b7f8f387bbb2 Author: Stephen Kelly AuthorDate: Wed Aug 5 17:37:49 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 26 19:46:32 2015 +0200 cmGeneratorTarget: Move GetLinkImplementation from cmTarget. diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 4b7faa7..e774e16 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -555,7 +555,7 @@ void cmComputeLinkDepends::AddDirectLinkEntries() { // Add direct link dependencies in this configuration. cmLinkImplementation const* impl = - this->Target->Target->GetLinkImplementation(this->Config); + this->Target->GetLinkImplementation(this->Config); this->AddLinkEntries(-1, impl->Libraries); for(std::vector::const_iterator wi = impl->WrongConfigLibraries.begin(); diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index 8ed4ddb..9e37c35 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -252,8 +252,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) } } - cmLinkImplementation const* impl = - depender->Target->GetLinkImplementation(*it); + cmLinkImplementation const* impl = depender->GetLinkImplementation(*it); // A target should not depend on itself. emitted.insert(depender->GetName()); diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 057aa07..44fac1d 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1336,7 +1336,7 @@ void cmGeneratorTarget::ComputeLinkClosure(const std::string& config, // Get languages built in this target. UNORDERED_SET languages; cmLinkImplementation const* impl = - this->Target->GetLinkImplementation(config); + this->GetLinkImplementation(config); assert(impl); for(std::vector::const_iterator li = impl->Languages.begin(); li != impl->Languages.end(); ++li) @@ -4058,7 +4058,7 @@ void cmGeneratorTarget::ComputeLinkInterface(const std::string& config, if (this->GetType() != cmTarget::INTERFACE_LIBRARY) { cmLinkImplementation const* impl = - this->Target->GetLinkImplementation(config); + this->GetLinkImplementation(config); for(std::vector::const_iterator li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li) { @@ -4099,7 +4099,7 @@ void cmGeneratorTarget::ComputeLinkInterface(const std::string& config, { // Targets using this archive need its language runtime libraries. if(cmLinkImplementation const* impl = - this->Target->GetLinkImplementation(config)) + this->GetLinkImplementation(config)) { iface.Languages = impl->Languages; } @@ -4389,3 +4389,28 @@ cmGeneratorTarget::GetHeadToLinkInterfaceUsageRequirementsMap( std::string CONFIG = cmSystemTools::UpperCase(config); return this->LinkInterfaceUsageRequirementsOnlyMap[CONFIG]; } + +//---------------------------------------------------------------------------- +const cmLinkImplementation * +cmGeneratorTarget::GetLinkImplementation(const std::string& config) const +{ + // There is no link implementation for imported targets. + if(this->Target->IsImported()) + { + return 0; + } + + cmOptionalLinkImplementation& impl = this->Target->GetLinkImplMap(config); + if(!impl.LibrariesDone) + { + impl.LibrariesDone = true; + this->Target->ComputeLinkImplementationLibraries(config, impl, + this->Target); + } + if(!impl.LanguagesDone) + { + impl.LanguagesDone = true; + this->Target->ComputeLinkImplementationLanguages(config, impl); + } + return &impl; +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 557eb17..58f5f6b 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -198,6 +198,9 @@ public: LinkClosure const* GetLinkClosure(const std::string& config) const; void ComputeLinkClosure(const std::string& config, LinkClosure& lc) const; + cmLinkImplementation const* + GetLinkImplementation(const std::string& config) const; + /** Full path with trailing slash to the top-level directory holding object files for this target. Includes the build time config name placeholder if needed for the generator. */ diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index f78a8a1..68fd06b 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1384,7 +1384,7 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmTarget& cmtarget) // If the language is compiled as a source trust Xcode to link with it. cmLinkImplementation const* impl = - cmtarget.GetLinkImplementation("NOCONFIG"); + gtgt->GetLinkImplementation("NOCONFIG"); for(std::vector::const_iterator li = impl->Languages.begin(); li != impl->Languages.end(); ++li) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 2e37c08..a8ea0b8 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3564,30 +3564,6 @@ void cmTargetInternals::AddInterfaceEntries( } } -//---------------------------------------------------------------------------- -const cmLinkImplementation * -cmTarget::GetLinkImplementation(const std::string& config) const -{ - // There is no link implementation for imported targets. - if(this->IsImported()) - { - return 0; - } - - cmOptionalLinkImplementation& impl = this->GetLinkImplMap(config); - if(!impl.LibrariesDone) - { - impl.LibrariesDone = true; - this->ComputeLinkImplementationLibraries(config, impl, this); - } - if(!impl.LanguagesDone) - { - impl.LanguagesDone = true; - this->ComputeLinkImplementationLanguages(config, impl); - } - return &impl; -} - cmOptionalLinkImplementation& cmTarget::GetLinkImplMap(std::string const& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 6411d12..1d353ab 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -231,9 +231,6 @@ public: void GetObjectLibrariesCMP0026(std::vector& objlibs) const; - cmLinkImplementation const* - GetLinkImplementation(const std::string& config) const; - cmLinkImplementationLibraries const* GetLinkImplementationLibraries(const std::string& config) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=83981cf5931aaa2d9bbf4f99ea55c99736173fdf commit 83981cf5931aaa2d9bbf4f99ea55c99736173fdf Author: Stephen Kelly AuthorDate: Wed Aug 5 17:37:49 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 26 19:46:31 2015 +0200 cmTarget: Add GetLinkImplMap method. This is a temporary refactoring artifact. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 0be3eb1..2e37c08 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3574,10 +3574,7 @@ cmTarget::GetLinkImplementation(const std::string& config) const return 0; } - // Populate the link implementation for this configuration. - std::string CONFIG = cmSystemTools::UpperCase(config); - cmOptionalLinkImplementation& - impl = this->Internal->LinkImplMap[CONFIG][this]; + cmOptionalLinkImplementation& impl = this->GetLinkImplMap(config); if(!impl.LibrariesDone) { impl.LibrariesDone = true; @@ -3591,6 +3588,14 @@ cmTarget::GetLinkImplementation(const std::string& config) const return &impl; } +cmOptionalLinkImplementation& +cmTarget::GetLinkImplMap(std::string const& config) const +{ + // Populate the link implementation for this configuration. + std::string CONFIG = cmSystemTools::UpperCase(config); + return Internal->LinkImplMap[CONFIG][this]; +} + //---------------------------------------------------------------------------- cmLinkImplementationLibraries const* cmTarget::GetLinkImplementationLibraries(const std::string& config) const diff --git a/Source/cmTarget.h b/Source/cmTarget.h index d49b23e..6411d12 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -244,6 +244,9 @@ public: cmOptionalLinkImplementation& impl ) const; + cmOptionalLinkImplementation& + GetLinkImplMap(std::string const& config) const; + cmTarget const* FindTargetToLink(std::string const& name) const; /** Strip off leading and trailing whitespace from an item named in http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=771e79a2bf97e2e5de40106396358adc773014f1 commit 771e79a2bf97e2e5de40106396358adc773014f1 Author: Stephen Kelly AuthorDate: Wed Aug 5 17:37:48 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 26 19:46:31 2015 +0200 cmLinkItem: Add cmOptionalLinkImplementation type. Move the associated Compute* methods to the cmTarget class. diff --git a/Source/cmLinkItem.h b/Source/cmLinkItem.h index b2336f0..10dd465 100644 --- a/Source/cmLinkItem.h +++ b/Source/cmLinkItem.h @@ -107,4 +107,15 @@ struct cmLinkImplementation: public cmLinkImplementationLibraries std::vector Languages; }; +// Cache link implementation computation from each configuration. +struct cmOptionalLinkImplementation: public cmLinkImplementation +{ + cmOptionalLinkImplementation(): + LibrariesDone(false), LanguagesDone(false), + HadHeadSensitiveCondition(false) {} + bool LibrariesDone; + bool LanguagesDone; + bool HadHeadSensitiveCondition; +}; + #endif diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index c007994..0be3eb1 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -95,27 +95,8 @@ public: typedef std::map ImportInfoMapType; ImportInfoMapType ImportInfoMap; - // Cache link implementation computation from each configuration. - struct OptionalLinkImplementation: public cmLinkImplementation - { - OptionalLinkImplementation(): - LibrariesDone(false), LanguagesDone(false), - HadHeadSensitiveCondition(false) {} - bool LibrariesDone; - bool LanguagesDone; - bool HadHeadSensitiveCondition; - }; - void ComputeLinkImplementationLibraries(cmTarget const* thisTarget, - const std::string& config, - OptionalLinkImplementation& impl, - cmTarget const* head) const; - void ComputeLinkImplementationLanguages(cmTarget const* thisTarget, - const std::string& config, - OptionalLinkImplementation& impl - ) const; - struct HeadToLinkImplementationMap: - public std::map {}; + public std::map {}; typedef std::map LinkImplMapType; LinkImplMapType LinkImplMap; @@ -3595,18 +3576,17 @@ cmTarget::GetLinkImplementation(const std::string& config) const // Populate the link implementation for this configuration. std::string CONFIG = cmSystemTools::UpperCase(config); - cmTargetInternals::OptionalLinkImplementation& + cmOptionalLinkImplementation& impl = this->Internal->LinkImplMap[CONFIG][this]; if(!impl.LibrariesDone) { impl.LibrariesDone = true; - this->Internal - ->ComputeLinkImplementationLibraries(this, config, impl, this); + this->ComputeLinkImplementationLibraries(config, impl, this); } if(!impl.LanguagesDone) { impl.LanguagesDone = true; - this->Internal->ComputeLinkImplementationLanguages(this, config, impl); + this->ComputeLinkImplementationLanguages(config, impl); } return &impl; } @@ -3641,39 +3621,36 @@ cmTarget::GetLinkImplementationLibrariesInternal(const std::string& config, return &hm.begin()->second; } - cmTargetInternals::OptionalLinkImplementation& impl = hm[head]; + cmOptionalLinkImplementation& impl = hm[head]; if(!impl.LibrariesDone) { impl.LibrariesDone = true; - this->Internal - ->ComputeLinkImplementationLibraries(this, config, impl, head); + this->ComputeLinkImplementationLibraries(config, impl, head); } return &impl; } //---------------------------------------------------------------------------- -void -cmTargetInternals::ComputeLinkImplementationLibraries( - cmTarget const* thisTarget, +void cmTarget::ComputeLinkImplementationLibraries( const std::string& config, - OptionalLinkImplementation& impl, + cmOptionalLinkImplementation& impl, cmTarget const* head) const { // Collect libraries directly linked in this configuration. for (std::vector::const_iterator - le = this->LinkImplementationPropertyEntries.begin(), - end = this->LinkImplementationPropertyEntries.end(); + le = this->Internal->LinkImplementationPropertyEntries.begin(), + end = this->Internal->LinkImplementationPropertyEntries.end(); le != end; ++le) { std::vector llibs; cmGeneratorExpressionDAGChecker dagChecker( - thisTarget->GetName(), + this->GetName(), "LINK_LIBRARIES", 0, 0); cmGeneratorExpression ge(le->Backtrace); cmsys::auto_ptr const cge = ge.Parse(le->Value); std::string const evaluated = - cge->Evaluate(thisTarget->Makefile, config, false, head, &dagChecker); + cge->Evaluate(this->Makefile, config, false, head, &dagChecker); cmSystemTools::ExpandListArgument(evaluated, llibs); if(cge->GetHadHeadSensitiveCondition()) { @@ -3684,15 +3661,15 @@ cmTargetInternals::ComputeLinkImplementationLibraries( li != llibs.end(); ++li) { // Skip entries that resolve to the target itself or are empty. - std::string name = thisTarget->CheckCMP0004(*li); - if(name == thisTarget->GetName() || name.empty()) + std::string name = this->CheckCMP0004(*li); + if(name == this->GetName() || name.empty()) { - if(name == thisTarget->GetName()) + if(name == this->GetName()) { bool noMessage = false; cmake::MessageType messageType = cmake::FATAL_ERROR; std::ostringstream e; - switch(thisTarget->GetPolicyStatusCMP0038()) + switch(this->GetPolicyStatusCMP0038()) { case cmPolicies::WARN: { @@ -3711,9 +3688,9 @@ cmTargetInternals::ComputeLinkImplementationLibraries( if(!noMessage) { - e << "Target \"" << thisTarget->GetName() << "\" links to itself."; - thisTarget->Makefile->GetCMakeInstance()->IssueMessage( - messageType, e.str(), thisTarget->GetBacktrace()); + e << "Target \"" << this->GetName() << "\" links to itself."; + this->Makefile->GetCMakeInstance()->IssueMessage( + messageType, e.str(), this->GetBacktrace()); if (messageType == cmake::FATAL_ERROR) { return; @@ -3725,7 +3702,7 @@ cmTargetInternals::ComputeLinkImplementationLibraries( // The entry is meant for this configuration. impl.Libraries.push_back( - cmLinkImplItem(name, thisTarget->FindTargetToLink(name), + cmLinkImplItem(name, this->FindTargetToLink(name), le->Backtrace, evaluated != le->Value)); } @@ -3733,45 +3710,43 @@ cmTargetInternals::ComputeLinkImplementationLibraries( for (std::set::const_iterator it = seenProps.begin(); it != seenProps.end(); ++it) { - if (!thisTarget->GetProperty(*it)) + if (!this->GetProperty(*it)) { - thisTarget->LinkImplicitNullProperties.insert(*it); + this->LinkImplicitNullProperties.insert(*it); } } - cge->GetMaxLanguageStandard(thisTarget, thisTarget->MaxLanguageStandards); + cge->GetMaxLanguageStandard(this, this->MaxLanguageStandards); } - cmTarget::LinkLibraryType linkType = thisTarget->ComputeLinkType(config); + cmTarget::LinkLibraryType linkType = this->ComputeLinkType(config); cmTarget::LinkLibraryVectorType const& oldllibs = - thisTarget->GetOriginalLinkLibraries(); + this->GetOriginalLinkLibraries(); for(cmTarget::LinkLibraryVectorType::const_iterator li = oldllibs.begin(); li != oldllibs.end(); ++li) { if(li->second != cmTarget::GENERAL && li->second != linkType) { - std::string name = thisTarget->CheckCMP0004(li->first); - if(name == thisTarget->GetName() || name.empty()) + std::string name = this->CheckCMP0004(li->first); + if(name == this->GetName() || name.empty()) { continue; } // Support OLD behavior for CMP0003. impl.WrongConfigLibraries.push_back( - cmLinkItem(name, thisTarget->FindTargetToLink(name))); + cmLinkItem(name, this->FindTargetToLink(name))); } } } //---------------------------------------------------------------------------- -void -cmTargetInternals::ComputeLinkImplementationLanguages( - cmTarget const* thisTarget, +void cmTarget::ComputeLinkImplementationLanguages( const std::string& config, - OptionalLinkImplementation& impl) const + cmOptionalLinkImplementation& impl) const { // This target needs runtime libraries for its source languages. std::set languages; // Get languages used in our source files. - thisTarget->GetLanguages(languages, config); + this->GetLanguages(languages, config); // Copy the set of langauges to the link implementation. impl.Languages.insert(impl.Languages.begin(), languages.begin(), languages.end()); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 19cc220..d49b23e 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -237,6 +237,13 @@ public: cmLinkImplementationLibraries const* GetLinkImplementationLibraries(const std::string& config) const; + void ComputeLinkImplementationLibraries(const std::string& config, + cmOptionalLinkImplementation& impl, + cmTarget const* head) const; + void ComputeLinkImplementationLanguages(const std::string& config, + cmOptionalLinkImplementation& impl + ) const; + cmTarget const* FindTargetToLink(std::string const& name) const; /** Strip off leading and trailing whitespace from an item named in http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3846ebcf2b60b73e3eec848bd3dd41711eac5dc4 commit 3846ebcf2b60b73e3eec848bd3dd41711eac5dc4 Author: Stephen Kelly AuthorDate: Wed Aug 5 17:37:48 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 26 19:46:31 2015 +0200 cmLinkItem: Add cmLinkImplementation type. diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 5e9627b..4b7faa7 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -554,7 +554,7 @@ void cmComputeLinkDepends::AddVarLinkEntries(int depender_index, void cmComputeLinkDepends::AddDirectLinkEntries() { // Add direct link dependencies in this configuration. - cmTarget::LinkImplementation const* impl = + cmLinkImplementation const* impl = this->Target->Target->GetLinkImplementation(this->Config); this->AddLinkEntries(-1, impl->Libraries); for(std::vector::const_iterator diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index 83b2a0e..8ed4ddb 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -252,7 +252,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) } } - cmTarget::LinkImplementation const* impl = + cmLinkImplementation const* impl = depender->Target->GetLinkImplementation(*it); // A target should not depend on itself. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c499cd9..057aa07 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1335,7 +1335,7 @@ void cmGeneratorTarget::ComputeLinkClosure(const std::string& config, { // Get languages built in this target. UNORDERED_SET languages; - cmTarget::LinkImplementation const* impl = + cmLinkImplementation const* impl = this->Target->GetLinkImplementation(config); assert(impl); for(std::vector::const_iterator li = impl->Languages.begin(); @@ -4057,7 +4057,7 @@ void cmGeneratorTarget::ComputeLinkInterface(const std::string& config, } if (this->GetType() != cmTarget::INTERFACE_LIBRARY) { - cmTarget::LinkImplementation const* impl = + cmLinkImplementation const* impl = this->Target->GetLinkImplementation(config); for(std::vector::const_iterator li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li) @@ -4098,7 +4098,7 @@ void cmGeneratorTarget::ComputeLinkInterface(const std::string& config, if(this->Target->LinkLanguagePropagatesToDependents()) { // Targets using this archive need its language runtime libraries. - if(cmTarget::LinkImplementation const* impl = + if(cmLinkImplementation const* impl = this->Target->GetLinkImplementation(config)) { iface.Languages = impl->Languages; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 87c61dd..f78a8a1 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1383,7 +1383,7 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmTarget& cmtarget) if(llang.empty()) { return; } // If the language is compiled as a source trust Xcode to link with it. - cmTarget::LinkImplementation const* impl = + cmLinkImplementation const* impl = cmtarget.GetLinkImplementation("NOCONFIG"); for(std::vector::const_iterator li = impl->Languages.begin(); li != impl->Languages.end(); ++li) diff --git a/Source/cmLinkItem.h b/Source/cmLinkItem.h index 91220b8..b2336f0 100644 --- a/Source/cmLinkItem.h +++ b/Source/cmLinkItem.h @@ -101,4 +101,10 @@ struct cmHeadToLinkInterfaceMap: { }; +struct cmLinkImplementation: public cmLinkImplementationLibraries +{ + // Languages whose runtime libraries must be linked. + std::vector Languages; +}; + #endif diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index ea03ffe..c007994 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -96,7 +96,7 @@ public: ImportInfoMapType ImportInfoMap; // Cache link implementation computation from each configuration. - struct OptionalLinkImplementation: public cmTarget::LinkImplementation + struct OptionalLinkImplementation: public cmLinkImplementation { OptionalLinkImplementation(): LibrariesDone(false), LanguagesDone(false), @@ -3584,7 +3584,7 @@ void cmTargetInternals::AddInterfaceEntries( } //---------------------------------------------------------------------------- -cmTarget::LinkImplementation const* +const cmLinkImplementation * cmTarget::GetLinkImplementation(const std::string& config) const { // There is no link implementation for imported targets. diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 34a75ea..19cc220 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -231,12 +231,7 @@ public: void GetObjectLibrariesCMP0026(std::vector& objlibs) const; - struct LinkImplementation: public cmLinkImplementationLibraries - { - // Languages whose runtime libraries must be linked. - std::vector Languages; - }; - LinkImplementation const* + cmLinkImplementation const* GetLinkImplementation(const std::string& config) const; cmLinkImplementationLibraries const* http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a7f5d70dde50ac74726f3c23d276d2fdac70d659 commit a7f5d70dde50ac74726f3c23d276d2fdac70d659 Author: Stephen Kelly AuthorDate: Wed Aug 5 00:00:53 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 26 19:46:30 2015 +0200 cmGeneratorTarget: Move compile defintions processing from cmTarget. diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 933a256..dfd51c7 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -609,7 +609,7 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, // the compilerdefines for this target std::vector cdefs; - target->GetCompileDefinitions(cdefs, buildType, "C"); + gtgt->GetCompileDefinitions(cdefs, buildType, "C"); // Expand the list. for(std::vector::const_iterator di = cdefs.begin(); diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 5a67c15..c499cd9 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -263,7 +263,8 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) PolicyWarnedCMP0022(false), DebugIncludesDone(false), DebugCompileOptionsDone(false), - DebugCompileFeaturesDone(false) + DebugCompileFeaturesDone(false), + DebugCompileDefinitionsDone(false) { this->Makefile = this->Target->GetMakefile(); this->LocalGenerator = lg; @@ -283,6 +284,11 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) t->GetCompileFeaturesEntries(), t->GetCompileFeaturesBacktraces(), this->CompileFeaturesEntries); + + CreatePropertyGeneratorExpressions( + t->GetCompileDefinitionsEntries(), + t->GetCompileDefinitionsBacktraces(), + this->CompileDefinitionsEntries); } cmGeneratorTarget::~cmGeneratorTarget() @@ -290,6 +296,7 @@ cmGeneratorTarget::~cmGeneratorTarget() cmDeleteAll(this->IncludeDirectoriesEntries); cmDeleteAll(this->CompileOptionsEntries); cmDeleteAll(this->CompileFeaturesEntries); + cmDeleteAll(this->CompileDefinitionsEntries); cmDeleteAll(this->LinkInformation); this->LinkInformation.clear(); } @@ -2445,6 +2452,108 @@ void cmGeneratorTarget::GetCompileFeatures(std::vector &result, } //---------------------------------------------------------------------------- +static void processCompileDefinitions(cmGeneratorTarget const* tgt, + const std::vector &entries, + std::vector &options, + UNORDERED_SET &uniqueOptions, + cmGeneratorExpressionDAGChecker *dagChecker, + const std::string& config, bool debugOptions, + std::string const& language) +{ + processCompileOptionsInternal(tgt, entries, options, uniqueOptions, + dagChecker, config, debugOptions, + "definitions", language); +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GetCompileDefinitions(std::vector &list, + const std::string& config, + const std::string& language) const +{ + UNORDERED_SET uniqueOptions; + + cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), + "COMPILE_DEFINITIONS", 0, 0); + + std::vector debugProperties; + const char *debugProp = + this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); + if (debugProp) + { + cmSystemTools::ExpandListArgument(debugProp, debugProperties); + } + + bool debugDefines = !this->DebugCompileDefinitionsDone + && std::find(debugProperties.begin(), + debugProperties.end(), + "COMPILE_DEFINITIONS") + != debugProperties.end(); + + if (this->Makefile->IsConfigured()) + { + this->DebugCompileDefinitionsDone = true; + } + + processCompileDefinitions(this, + this->CompileDefinitionsEntries, + list, + uniqueOptions, + &dagChecker, + config, + debugDefines, + language); + + std::vector + linkInterfaceCompileDefinitionsEntries; + AddInterfaceEntries( + this, config, "INTERFACE_COMPILE_DEFINITIONS", + linkInterfaceCompileDefinitionsEntries); + if (!config.empty()) + { + std::string configPropName = "COMPILE_DEFINITIONS_" + + cmSystemTools::UpperCase(config); + const char *configProp = this->Target->GetProperty(configPropName); + if (configProp) + { + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0043)) + { + case cmPolicies::WARN: + { + std::ostringstream e; + e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0043); + this->LocalGenerator->IssueMessage(cmake::AUTHOR_WARNING, + e.str()); + } + case cmPolicies::OLD: + { + cmGeneratorExpression ge; + cmsys::auto_ptr cge = + ge.Parse(configProp); + linkInterfaceCompileDefinitionsEntries + .push_back(new cmGeneratorTarget::TargetPropertyEntry(cge)); + } + break; + case cmPolicies::NEW: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::REQUIRED_IF_USED: + break; + } + } + } + + processCompileDefinitions(this, + linkInterfaceCompileDefinitionsEntries, + list, + uniqueOptions, + &dagChecker, + config, + debugDefines, + language); + + cmDeleteAll(linkInterfaceCompileDefinitionsEntries); +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GenerateTargetManifest( const std::string& config) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 7e718af..557eb17 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -224,6 +224,10 @@ public: void GetCompileFeatures(std::vector &features, const std::string& config) const; + void GetCompileDefinitions(std::vector &result, + const std::string& config, + const std::string& language) const; + bool IsSystemIncludeDirectory(const std::string& dir, const std::string& config) const; @@ -416,6 +420,7 @@ private: std::vector IncludeDirectoriesEntries; std::vector CompileOptionsEntries; std::vector CompileFeaturesEntries; + std::vector CompileDefinitionsEntries; void ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, cmTarget const* headTarget, @@ -432,6 +437,7 @@ private: mutable bool DebugIncludesDone; mutable bool DebugCompileOptionsDone; mutable bool DebugCompileFeaturesDone; + mutable bool DebugCompileDefinitionsDone; public: std::vector const& diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index 790e68b..846b6e2 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -330,7 +330,8 @@ void cmGhsMultiTargetGenerator::WriteCompilerDefinitions( const std::string &config, const std::string &language) { std::vector compileDefinitions; - this->Target->GetCompileDefinitions(compileDefinitions, config, language); + this->GeneratorTarget->GetCompileDefinitions(compileDefinitions, + config, language); for (std::vector::const_iterator cdI = compileDefinitions.begin(); cdI != compileDefinitions.end(); ++cdI) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 503c455..c0f1817 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1550,7 +1550,6 @@ void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes, ti != targets.end(); ++ti) { cmTarget* t = &ti->second; - t->Compute(); cmGeneratorTarget* gt = new cmGeneratorTarget(t, lg); this->GeneratorTargets[t] = gt; generatorTargets[t] = gt; diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 51dcab0..28f0425 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -254,7 +254,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() mf->AddUtilityCommand(CMAKE_CHECK_BUILD_SYSTEM_TARGET, false, no_working_directory, no_depends, noCommandLines); - tgt->Compute(); + cmGeneratorTarget* gt = new cmGeneratorTarget(tgt, lg); mf->AddGeneratorTarget(tgt, gt); diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index b0aa243..634366e 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -90,7 +90,7 @@ bool cmGlobalVisualStudioGenerator::Compute() AddUtilityCommand("ALL_BUILD", true, no_working_dir, no_depends, no_commands, false, "Build all projects"); - allBuild->Compute(); + cmGeneratorTarget* gt = new cmGeneratorTarget(allBuild, gen[0]); allBuild->GetMakefile()->AddGeneratorTarget(allBuild, gt); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 4ba29f5..87c61dd 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -463,7 +463,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, cmTarget* allbuild = mf->AddUtilityCommand("ALL_BUILD", true, no_depends, no_working_directory, "echo", "Build all projects"); - allbuild->Compute(); + cmGeneratorTarget* allBuildGt = new cmGeneratorTarget(allbuild, root); mf->AddGeneratorTarget(allbuild, allBuildGt); @@ -498,7 +498,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, true, no_depends, no_working_directory, "make", "-f", file.c_str()); - check->Compute(); + cmGeneratorTarget* checkGt = new cmGeneratorTarget(check, root); mf->AddGeneratorTarget(check, checkGt); } @@ -1855,7 +1855,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, this->AppendDefines(ppDefs, exportMacro); } std::vector targetDefines; - target.GetCompileDefinitions(targetDefines, configName, "C"); + gtgt->GetCompileDefinitions(targetDefines, configName, "C"); this->AppendDefines(ppDefs, targetDefines); buildSettings->AddAttribute ("GCC_PREPROCESSOR_DEFINITIONS", ppDefs.CreateList()); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index a7e4191..c1cc241 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1083,7 +1083,8 @@ void cmLocalGenerator::AddCompileDefinitions(std::set& defines, const std::string& lang) { std::vector targetDefines; - target->GetCompileDefinitions(targetDefines, config, lang); + cmGeneratorTarget* gtgt = this->GlobalGenerator->GetGeneratorTarget(target); + gtgt->GetCompileDefinitions(targetDefines, config, lang); this->AppendDefines(defines, targetDefines); } diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 5de6d37..f17c9a4 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -763,7 +763,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, targetOptions.Parse(defineFlags.c_str()); targetOptions.ParseFinish(); std::vector targetDefines; - target.GetCompileDefinitions(targetDefines, configName, "CXX"); + gt->GetCompileDefinitions(targetDefines, configName, "CXX"); targetOptions.AddDefines(targetDefines); targetOptions.SetVerboseMakefile( this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE")); diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index f85e70e..c58e7e4 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -474,8 +474,6 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg, /*byproducts=*/rcc_output, depends, commandLines, false, autogenComment.c_str()); - autogenTarget->Compute(); - cmGeneratorTarget* gt = new cmGeneratorTarget(autogenTarget, lg); makefile->AddGeneratorTarget(autogenTarget, gt); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 4ddbcb3..ea03ffe 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -145,7 +145,6 @@ public: std::vector CompileFeaturesBacktraces; std::vector CompileDefinitionsEntries; std::vector CompileDefinitionsBacktraces; - std::vector CompileDefinitionsItems; std::vector SourceEntries; std::vector LinkImplementationPropertyEntries; @@ -174,7 +173,6 @@ cmTarget::cmTarget() this->IsApple = false; this->IsImportedTarget = false; this->BuildInterfaceIncludesAppended = false; - this->DebugCompileDefinitionsDone = false; this->DebugSourcesDone = false; this->LinkImplementationLanguageIsContextDependent = true; } @@ -417,14 +415,6 @@ void CreatePropertyGeneratorExpressions( } } -void cmTarget::Compute() -{ - CreatePropertyGeneratorExpressions( - this->Internal->CompileDefinitionsEntries, - this->Internal->CompileDefinitionsBacktraces, - this->Internal->CompileDefinitionsItems); -} - //---------------------------------------------------------------------------- void cmTarget::AddUtility(const std::string& u, cmMakefile *makefile) { @@ -1328,6 +1318,16 @@ cmBacktraceRange cmTarget::GetCompileFeaturesBacktraces() const return cmMakeRange(this->Internal->CompileFeaturesBacktraces); } +cmStringRange cmTarget::GetCompileDefinitionsEntries() const +{ + return cmMakeRange(this->Internal->CompileDefinitionsEntries); +} + +cmBacktraceRange cmTarget::GetCompileDefinitionsBacktraces() const +{ + return cmMakeRange(this->Internal->CompileDefinitionsBacktraces); +} + #if defined(_WIN32) && !defined(__CYGWIN__) //---------------------------------------------------------------------------- void @@ -1925,156 +1925,6 @@ void cmTarget::InsertCompileDefinition(std::string const& entry, } //---------------------------------------------------------------------------- -static void processCompileOptionsInternal(cmTarget const* tgt, - const std::vector &entries, - std::vector &options, - UNORDERED_SET &uniqueOptions, - cmGeneratorExpressionDAGChecker *dagChecker, - const std::string& config, bool debugOptions, const char *logName, - std::string const& language) -{ - cmMakefile *mf = tgt->GetMakefile(); - - for (std::vector::const_iterator - it = entries.begin(), end = entries.end(); it != end; ++it) - { - std::vector entryOptions; - cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf, - config, - false, - tgt, - dagChecker, - language), - entryOptions); - std::string usedOptions; - for(std::vector::iterator - li = entryOptions.begin(); li != entryOptions.end(); ++li) - { - std::string const& opt = *li; - - if(uniqueOptions.insert(opt).second) - { - options.push_back(opt); - if (debugOptions) - { - usedOptions += " * " + opt + "\n"; - } - } - } - if (!usedOptions.empty()) - { - mf->GetCMakeInstance()->IssueMessage(cmake::LOG, - std::string("Used compile ") + logName - + std::string(" for target ") - + tgt->GetName() + ":\n" - + usedOptions, (*it)->ge->GetBacktrace()); - } - } -} - -//---------------------------------------------------------------------------- -static void processCompileDefinitions(cmTarget const* tgt, - const std::vector &entries, - std::vector &options, - UNORDERED_SET &uniqueOptions, - cmGeneratorExpressionDAGChecker *dagChecker, - const std::string& config, bool debugOptions, - std::string const& language) -{ - processCompileOptionsInternal(tgt, entries, options, uniqueOptions, - dagChecker, config, debugOptions, - "definitions", language); -} - -//---------------------------------------------------------------------------- -void cmTarget::GetCompileDefinitions(std::vector &list, - const std::string& config, - const std::string& language) const -{ - UNORDERED_SET uniqueOptions; - - cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), - "COMPILE_DEFINITIONS", 0, 0); - - std::vector debugProperties; - const char *debugProp = - this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); - if (debugProp) - { - cmSystemTools::ExpandListArgument(debugProp, debugProperties); - } - - bool debugDefines = !this->DebugCompileDefinitionsDone - && std::find(debugProperties.begin(), - debugProperties.end(), - "COMPILE_DEFINITIONS") - != debugProperties.end(); - - if (this->Makefile->IsConfigured()) - { - this->DebugCompileDefinitionsDone = true; - } - - processCompileDefinitions(this, - this->Internal->CompileDefinitionsItems, - list, - uniqueOptions, - &dagChecker, - config, - debugDefines, - language); - - std::vector - linkInterfaceCompileDefinitionsEntries; - this->Internal->AddInterfaceEntries( - this, config, "INTERFACE_COMPILE_DEFINITIONS", - linkInterfaceCompileDefinitionsEntries); - if (!config.empty()) - { - std::string configPropName = "COMPILE_DEFINITIONS_" - + cmSystemTools::UpperCase(config); - const char *configProp = this->GetProperty(configPropName); - if (configProp) - { - switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0043)) - { - case cmPolicies::WARN: - { - std::ostringstream e; - e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0043); - this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, - e.str()); - } - case cmPolicies::OLD: - { - cmGeneratorExpression ge; - cmsys::auto_ptr cge = - ge.Parse(configProp); - linkInterfaceCompileDefinitionsEntries - .push_back(new cmTargetInternals::TargetPropertyEntry(cge)); - } - break; - case cmPolicies::NEW: - case cmPolicies::REQUIRED_ALWAYS: - case cmPolicies::REQUIRED_IF_USED: - break; - } - } - } - - processCompileDefinitions(this, - linkInterfaceCompileDefinitionsEntries, - list, - uniqueOptions, - &dagChecker, - config, - debugDefines, - language); - - cmDeleteAll(linkInterfaceCompileDefinitionsEntries); -} - -//---------------------------------------------------------------------------- void cmTarget::MaybeInvalidatePropertyCache(const std::string& prop) { // Wipe out maps caching information affected by this property. @@ -4034,7 +3884,6 @@ cmTargetInternalPointer //---------------------------------------------------------------------------- cmTargetInternalPointer::~cmTargetInternalPointer() { - cmDeleteAll(this->Pointer->CompileDefinitionsItems); cmDeleteAll(this->Pointer->SourceEntries); delete this->Pointer; } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index aae558e..34a75ea 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -132,8 +132,6 @@ public: void AddPostBuildCommand(cmCustomCommand const &cmd) {this->PostBuildCommands.push_back(cmd);} - void Compute(); - /** * Get the list of the source files used by this target */ @@ -309,10 +307,6 @@ public: If no macro should be defined null is returned. */ const char* GetExportMacro() const; - void GetCompileDefinitions(std::vector &result, - const std::string& config, - const std::string& language) const; - // Compute the set of languages compiled by the target. This is // computed every time it is called because the languages can change // when source file properties are changed and we do not have enough @@ -402,6 +396,9 @@ public: cmStringRange GetCompileFeaturesEntries() const; cmBacktraceRange GetCompileFeaturesBacktraces() const; + cmStringRange GetCompileDefinitionsEntries() const; + cmBacktraceRange GetCompileDefinitionsBacktraces() const; + #if defined(_WIN32) && !defined(__CYGWIN__) const LinkLibraryVectorType &GetLinkLibrariesForVS6() const { return this->LinkLibrariesForVS6;} @@ -516,7 +513,6 @@ private: bool IsApple; bool IsImportedTarget; bool BuildInterfaceIncludesAppended; - mutable bool DebugCompileDefinitionsDone; mutable bool DebugSourcesDone; mutable bool LinkImplementationLanguageIsContextDependent; #if defined(_WIN32) && !defined(__CYGWIN__) diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 823b550..464a83a 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1934,7 +1934,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( clOptions.Parse(flags.c_str()); clOptions.Parse(defineFlags.c_str()); std::vector targetDefines; - this->Target->GetCompileDefinitions(targetDefines, + this->GeneratorTarget->GetCompileDefinitions(targetDefines, configName.c_str(), "CXX"); clOptions.AddDefines(targetDefines); if(this->MSTools) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d051086ccec5cd4b381cf47afb0e7fe962ed4c0b commit d051086ccec5cd4b381cf47afb0e7fe962ed4c0b Author: Stephen Kelly AuthorDate: Tue Aug 4 23:48:58 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 26 19:46:10 2015 +0200 cmGeneratorTarget: Move compile features processing from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 77e352f..5a67c15 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -262,7 +262,8 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) SourceFileFlagsConstructed(false), PolicyWarnedCMP0022(false), DebugIncludesDone(false), - DebugCompileOptionsDone(false) + DebugCompileOptionsDone(false), + DebugCompileFeaturesDone(false) { this->Makefile = this->Target->GetMakefile(); this->LocalGenerator = lg; @@ -277,12 +278,18 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) t->GetCompileOptionsEntries(), t->GetCompileOptionsBacktraces(), this->CompileOptionsEntries); + + CreatePropertyGeneratorExpressions( + t->GetCompileFeaturesEntries(), + t->GetCompileFeaturesBacktraces(), + this->CompileFeaturesEntries); } cmGeneratorTarget::~cmGeneratorTarget() { cmDeleteAll(this->IncludeDirectoriesEntries); cmDeleteAll(this->CompileOptionsEntries); + cmDeleteAll(this->CompileFeaturesEntries); cmDeleteAll(this->LinkInformation); this->LinkInformation.clear(); } @@ -2371,6 +2378,73 @@ void cmGeneratorTarget::GetCompileOptions(std::vector &result, } //---------------------------------------------------------------------------- +static void processCompileFeatures(cmGeneratorTarget const* tgt, + const std::vector &entries, + std::vector &options, + UNORDERED_SET &uniqueOptions, + cmGeneratorExpressionDAGChecker *dagChecker, + const std::string& config, bool debugOptions) +{ + processCompileOptionsInternal(tgt, entries, options, uniqueOptions, + dagChecker, config, debugOptions, "features", + std::string()); +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GetCompileFeatures(std::vector &result, + const std::string& config) const +{ + UNORDERED_SET uniqueFeatures; + + cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), + "COMPILE_FEATURES", + 0, 0); + + std::vector debugProperties; + const char *debugProp = + this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); + if (debugProp) + { + cmSystemTools::ExpandListArgument(debugProp, debugProperties); + } + + bool debugFeatures = !this->DebugCompileFeaturesDone + && std::find(debugProperties.begin(), + debugProperties.end(), + "COMPILE_FEATURES") + != debugProperties.end(); + + if (this->Makefile->IsConfigured()) + { + this->DebugCompileFeaturesDone = true; + } + + processCompileFeatures(this, + this->CompileFeaturesEntries, + result, + uniqueFeatures, + &dagChecker, + config, + debugFeatures); + + std::vector + linkInterfaceCompileFeaturesEntries; + AddInterfaceEntries( + this, config, "INTERFACE_COMPILE_FEATURES", + linkInterfaceCompileFeaturesEntries); + + processCompileFeatures(this, + linkInterfaceCompileFeaturesEntries, + result, + uniqueFeatures, + &dagChecker, + config, + debugFeatures); + + cmDeleteAll(linkInterfaceCompileFeaturesEntries); +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GenerateTargetManifest( const std::string& config) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 1fb8cfe..7e718af 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -221,6 +221,9 @@ public: const std::string& config, const std::string& language) const; + void GetCompileFeatures(std::vector &features, + const std::string& config) const; + bool IsSystemIncludeDirectory(const std::string& dir, const std::string& config) const; @@ -412,6 +415,7 @@ private: std::vector IncludeDirectoriesEntries; std::vector CompileOptionsEntries; + std::vector CompileFeaturesEntries; void ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, cmTarget const* headTarget, @@ -427,6 +431,7 @@ private: mutable bool PolicyWarnedCMP0022; mutable bool DebugIncludesDone; mutable bool DebugCompileOptionsDone; + mutable bool DebugCompileFeaturesDone; public: std::vector const& diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 89515ff..a7e4191 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1138,7 +1138,7 @@ void cmLocalGenerator::AddCompileOptions( } } std::vector features; - target->GetCompileFeatures(features, config); + gtgt->GetCompileFeatures(features, config); for(std::vector::const_iterator it = features.begin(); it != features.end(); ++it) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 9e13ea0..4ddbcb3 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -143,7 +143,6 @@ public: std::vector CompileOptionsBacktraces; std::vector CompileFeaturesEntries; std::vector CompileFeaturesBacktraces; - std::vector CompileFeaturesItems; std::vector CompileDefinitionsEntries; std::vector CompileDefinitionsBacktraces; std::vector CompileDefinitionsItems; @@ -175,7 +174,6 @@ cmTarget::cmTarget() this->IsApple = false; this->IsImportedTarget = false; this->BuildInterfaceIncludesAppended = false; - this->DebugCompileFeaturesDone = false; this->DebugCompileDefinitionsDone = false; this->DebugSourcesDone = false; this->LinkImplementationLanguageIsContextDependent = true; @@ -422,11 +420,6 @@ void CreatePropertyGeneratorExpressions( void cmTarget::Compute() { CreatePropertyGeneratorExpressions( - this->Internal->CompileFeaturesEntries, - this->Internal->CompileFeaturesBacktraces, - this->Internal->CompileFeaturesItems); - - CreatePropertyGeneratorExpressions( this->Internal->CompileDefinitionsEntries, this->Internal->CompileDefinitionsBacktraces, this->Internal->CompileDefinitionsItems); @@ -1325,6 +1318,16 @@ cmBacktraceRange cmTarget::GetCompileOptionsBacktraces() const return cmMakeRange(this->Internal->CompileOptionsBacktraces); } +cmStringRange cmTarget::GetCompileFeaturesEntries() const +{ + return cmMakeRange(this->Internal->CompileFeaturesEntries); +} + +cmBacktraceRange cmTarget::GetCompileFeaturesBacktraces() const +{ + return cmMakeRange(this->Internal->CompileFeaturesBacktraces); +} + #if defined(_WIN32) && !defined(__CYGWIN__) //---------------------------------------------------------------------------- void @@ -2072,73 +2075,6 @@ void cmTarget::GetCompileDefinitions(std::vector &list, } //---------------------------------------------------------------------------- -static void processCompileFeatures(cmTarget const* tgt, - const std::vector &entries, - std::vector &options, - UNORDERED_SET &uniqueOptions, - cmGeneratorExpressionDAGChecker *dagChecker, - const std::string& config, bool debugOptions) -{ - processCompileOptionsInternal(tgt, entries, options, uniqueOptions, - dagChecker, config, debugOptions, "features", - std::string()); -} - -//---------------------------------------------------------------------------- -void cmTarget::GetCompileFeatures(std::vector &result, - const std::string& config) const -{ - UNORDERED_SET uniqueFeatures; - - cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), - "COMPILE_FEATURES", - 0, 0); - - std::vector debugProperties; - const char *debugProp = - this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); - if (debugProp) - { - cmSystemTools::ExpandListArgument(debugProp, debugProperties); - } - - bool debugFeatures = !this->DebugCompileFeaturesDone - && std::find(debugProperties.begin(), - debugProperties.end(), - "COMPILE_FEATURES") - != debugProperties.end(); - - if (this->Makefile->IsConfigured()) - { - this->DebugCompileFeaturesDone = true; - } - - processCompileFeatures(this, - this->Internal->CompileFeaturesItems, - result, - uniqueFeatures, - &dagChecker, - config, - debugFeatures); - - std::vector - linkInterfaceCompileFeaturesEntries; - this->Internal->AddInterfaceEntries( - this, config, "INTERFACE_COMPILE_FEATURES", - linkInterfaceCompileFeaturesEntries); - - processCompileFeatures(this, - linkInterfaceCompileFeaturesEntries, - result, - uniqueFeatures, - &dagChecker, - config, - debugFeatures); - - cmDeleteAll(linkInterfaceCompileFeaturesEntries); -} - -//---------------------------------------------------------------------------- void cmTarget::MaybeInvalidatePropertyCache(const std::string& prop) { // Wipe out maps caching information affected by this property. @@ -4098,7 +4034,6 @@ cmTargetInternalPointer //---------------------------------------------------------------------------- cmTargetInternalPointer::~cmTargetInternalPointer() { - cmDeleteAll(this->Pointer->CompileFeaturesItems); cmDeleteAll(this->Pointer->CompileDefinitionsItems); cmDeleteAll(this->Pointer->SourceEntries); delete this->Pointer; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 05b6aec..aae558e 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -375,9 +375,6 @@ public: void AppendBuildInterfaceIncludes(); - void GetCompileFeatures(std::vector &features, - const std::string& config) const; - bool IsNullImpliedByLinkLibraries(const std::string &p) const; std::string GetDebugGeneratorExpressions(const std::string &value, @@ -402,6 +399,9 @@ public: cmStringRange GetCompileOptionsEntries() const; cmBacktraceRange GetCompileOptionsBacktraces() const; + cmStringRange GetCompileFeaturesEntries() const; + cmBacktraceRange GetCompileFeaturesBacktraces() const; + #if defined(_WIN32) && !defined(__CYGWIN__) const LinkLibraryVectorType &GetLinkLibrariesForVS6() const { return this->LinkLibrariesForVS6;} @@ -518,7 +518,6 @@ private: bool BuildInterfaceIncludesAppended; mutable bool DebugCompileDefinitionsDone; mutable bool DebugSourcesDone; - mutable bool DebugCompileFeaturesDone; mutable bool LinkImplementationLanguageIsContextDependent; #if defined(_WIN32) && !defined(__CYGWIN__) bool LinkLibrariesForVS6Analyzed; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=db4cb92bda8b43c3d66d27533622bb802e823589 commit db4cb92bda8b43c3d66d27533622bb802e823589 Author: Stephen Kelly AuthorDate: Tue Aug 4 23:43:56 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 26 19:45:51 2015 +0200 cmGeneratorTarget: Move compile options processing from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 7ba2863..77e352f 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -261,7 +261,8 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) : Target(t), SourceFileFlagsConstructed(false), PolicyWarnedCMP0022(false), - DebugIncludesDone(false) + DebugIncludesDone(false), + DebugCompileOptionsDone(false) { this->Makefile = this->Target->GetMakefile(); this->LocalGenerator = lg; @@ -271,11 +272,17 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) t->GetIncludeDirectoriesEntries(), t->GetIncludeDirectoriesBacktraces(), this->IncludeDirectoriesEntries); + + CreatePropertyGeneratorExpressions( + t->GetCompileOptionsEntries(), + t->GetCompileOptionsBacktraces(), + this->CompileOptionsEntries); } cmGeneratorTarget::~cmGeneratorTarget() { cmDeleteAll(this->IncludeDirectoriesEntries); + cmDeleteAll(this->CompileOptionsEntries); cmDeleteAll(this->LinkInformation); this->LinkInformation.clear(); } @@ -2245,6 +2252,125 @@ cmGeneratorTarget::GetIncludeDirectories(const std::string& config, } //---------------------------------------------------------------------------- +static void processCompileOptionsInternal(cmGeneratorTarget const* tgt, + const std::vector &entries, + std::vector &options, + UNORDERED_SET &uniqueOptions, + cmGeneratorExpressionDAGChecker *dagChecker, + const std::string& config, bool debugOptions, const char *logName, + std::string const& language) +{ + cmMakefile *mf = tgt->Target->GetMakefile(); + + for (std::vector::const_iterator + it = entries.begin(), end = entries.end(); it != end; ++it) + { + std::vector entryOptions; + cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf, + config, + false, + tgt->Target, + dagChecker, + language), + entryOptions); + std::string usedOptions; + for(std::vector::iterator + li = entryOptions.begin(); li != entryOptions.end(); ++li) + { + std::string const& opt = *li; + + if(uniqueOptions.insert(opt).second) + { + options.push_back(opt); + if (debugOptions) + { + usedOptions += " * " + opt + "\n"; + } + } + } + if (!usedOptions.empty()) + { + mf->GetCMakeInstance()->IssueMessage(cmake::LOG, + std::string("Used compile ") + logName + + std::string(" for target ") + + tgt->GetName() + ":\n" + + usedOptions, (*it)->ge->GetBacktrace()); + } + } +} + +//---------------------------------------------------------------------------- +static void processCompileOptions(cmGeneratorTarget const* tgt, + const std::vector &entries, + std::vector &options, + UNORDERED_SET &uniqueOptions, + cmGeneratorExpressionDAGChecker *dagChecker, + const std::string& config, bool debugOptions, + std::string const& language) +{ + processCompileOptionsInternal(tgt, entries, options, uniqueOptions, + dagChecker, config, debugOptions, "options", + language); +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GetCompileOptions(std::vector &result, + const std::string& config, + const std::string& language) const +{ + UNORDERED_SET uniqueOptions; + + cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), + "COMPILE_OPTIONS", 0, 0); + + std::vector debugProperties; + const char *debugProp = + this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); + if (debugProp) + { + cmSystemTools::ExpandListArgument(debugProp, debugProperties); + } + + bool debugOptions = !this->DebugCompileOptionsDone + && std::find(debugProperties.begin(), + debugProperties.end(), + "COMPILE_OPTIONS") + != debugProperties.end(); + + if (this->Makefile->IsConfigured()) + { + this->DebugCompileOptionsDone = true; + } + + processCompileOptions(this, + this->CompileOptionsEntries, + result, + uniqueOptions, + &dagChecker, + config, + debugOptions, + language); + + std::vector + linkInterfaceCompileOptionsEntries; + + AddInterfaceEntries( + this, config, "INTERFACE_COMPILE_OPTIONS", + linkInterfaceCompileOptionsEntries); + + processCompileOptions(this, + linkInterfaceCompileOptionsEntries, + result, + uniqueOptions, + &dagChecker, + config, + debugOptions, + language); + + cmDeleteAll(linkInterfaceCompileOptionsEntries); +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GenerateTargetManifest( const std::string& config) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 513884f..1fb8cfe 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -217,6 +217,10 @@ public: std::vector GetIncludeDirectories( const std::string& config, const std::string& lang) const; + void GetCompileOptions(std::vector &result, + const std::string& config, + const std::string& language) const; + bool IsSystemIncludeDirectory(const std::string& dir, const std::string& config) const; @@ -407,6 +411,7 @@ private: bool usage_requirements_only) const; std::vector IncludeDirectoriesEntries; + std::vector CompileOptionsEntries; void ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, cmTarget const* headTarget, @@ -421,6 +426,7 @@ private: mutable OutputNameMapType OutputNameMap; mutable bool PolicyWarnedCMP0022; mutable bool DebugIncludesDone; + mutable bool DebugCompileOptionsDone; public: std::vector const& diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index 7af17cd..790e68b 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -558,7 +558,7 @@ bool cmGhsMultiTargetGenerator::IsNotKernel(std::string const &config, { bool output; std::vector options; - this->Target->GetCompileOptions(options, config, language); + this->GeneratorTarget->GetCompileOptions(options, config, language); output = options.end() == std::find(options.begin(), options.end(), "-kernel"); return output; @@ -587,7 +587,7 @@ bool cmGhsMultiTargetGenerator::DetermineIfDynamicDownload( { std::vector options; bool output = false; - this->Target->GetCompileOptions(options, config, language); + this->GeneratorTarget->GetCompileOptions(options, config, language); for (std::vector::const_iterator options_i = options.begin(); options_i != options.end(); ++options_i) { diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index edb644d..89515ff 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1094,6 +1094,10 @@ void cmLocalGenerator::AddCompileOptions( ) { std::string langFlagRegexVar = std::string("CMAKE_")+lang+"_FLAG_REGEX"; + + cmGeneratorTarget* gtgt = + this->GlobalGenerator->GetGeneratorTarget(target); + if(const char* langFlagRegexStr = this->Makefile->GetDefinition(langFlagRegexVar)) { @@ -1104,7 +1108,7 @@ void cmLocalGenerator::AddCompileOptions( { cmSystemTools::ParseWindowsCommandLine(targetFlags, opts); } - target->GetCompileOptions(opts, config, lang); + gtgt->GetCompileOptions(opts, config, lang); for(std::vector::const_iterator i = opts.begin(); i != opts.end(); ++i) { @@ -1125,7 +1129,7 @@ void cmLocalGenerator::AddCompileOptions( this->AppendFlags(flags, targetFlags); } std::vector opts; - target->GetCompileOptions(opts, config, lang); + gtgt->GetCompileOptions(opts, config, lang); for(std::vector::const_iterator i = opts.begin(); i != opts.end(); ++i) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 06d21cc..9e13ea0 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -141,7 +141,6 @@ public: std::vector IncludeDirectoriesBacktraces; std::vector CompileOptionsEntries; std::vector CompileOptionsBacktraces; - std::vector CompileOptionsItems; std::vector CompileFeaturesEntries; std::vector CompileFeaturesBacktraces; std::vector CompileFeaturesItems; @@ -176,7 +175,6 @@ cmTarget::cmTarget() this->IsApple = false; this->IsImportedTarget = false; this->BuildInterfaceIncludesAppended = false; - this->DebugCompileOptionsDone = false; this->DebugCompileFeaturesDone = false; this->DebugCompileDefinitionsDone = false; this->DebugSourcesDone = false; @@ -424,11 +422,6 @@ void CreatePropertyGeneratorExpressions( void cmTarget::Compute() { CreatePropertyGeneratorExpressions( - this->Internal->CompileOptionsEntries, - this->Internal->CompileOptionsBacktraces, - this->Internal->CompileOptionsItems); - - CreatePropertyGeneratorExpressions( this->Internal->CompileFeaturesEntries, this->Internal->CompileFeaturesBacktraces, this->Internal->CompileFeaturesItems); @@ -1322,6 +1315,16 @@ cmBacktraceRange cmTarget::GetIncludeDirectoriesBacktraces() const return cmMakeRange(this->Internal->IncludeDirectoriesBacktraces); } +cmStringRange cmTarget::GetCompileOptionsEntries() const +{ + return cmMakeRange(this->Internal->CompileOptionsEntries); +} + +cmBacktraceRange cmTarget::GetCompileOptionsBacktraces() const +{ + return cmMakeRange(this->Internal->CompileOptionsBacktraces); +} + #if defined(_WIN32) && !defined(__CYGWIN__) //---------------------------------------------------------------------------- void @@ -1967,77 +1970,6 @@ static void processCompileOptionsInternal(cmTarget const* tgt, } //---------------------------------------------------------------------------- -static void processCompileOptions(cmTarget const* tgt, - const std::vector &entries, - std::vector &options, - UNORDERED_SET &uniqueOptions, - cmGeneratorExpressionDAGChecker *dagChecker, - const std::string& config, bool debugOptions, - std::string const& language) -{ - processCompileOptionsInternal(tgt, entries, options, uniqueOptions, - dagChecker, config, debugOptions, "options", - language); -} - -//---------------------------------------------------------------------------- -void cmTarget::GetCompileOptions(std::vector &result, - const std::string& config, - const std::string& language) const -{ - UNORDERED_SET uniqueOptions; - - cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), - "COMPILE_OPTIONS", 0, 0); - - std::vector debugProperties; - const char *debugProp = - this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); - if (debugProp) - { - cmSystemTools::ExpandListArgument(debugProp, debugProperties); - } - - bool debugOptions = !this->DebugCompileOptionsDone - && std::find(debugProperties.begin(), - debugProperties.end(), - "COMPILE_OPTIONS") - != debugProperties.end(); - - if (this->Makefile->IsConfigured()) - { - this->DebugCompileOptionsDone = true; - } - - processCompileOptions(this, - this->Internal->CompileOptionsItems, - result, - uniqueOptions, - &dagChecker, - config, - debugOptions, - language); - - std::vector - linkInterfaceCompileOptionsEntries; - - this->Internal->AddInterfaceEntries( - this, config, "INTERFACE_COMPILE_OPTIONS", - linkInterfaceCompileOptionsEntries); - - processCompileOptions(this, - linkInterfaceCompileOptionsEntries, - result, - uniqueOptions, - &dagChecker, - config, - debugOptions, - language); - - cmDeleteAll(linkInterfaceCompileOptionsEntries); -} - -//---------------------------------------------------------------------------- static void processCompileDefinitions(cmTarget const* tgt, const std::vector &entries, std::vector &options, @@ -4166,7 +4098,6 @@ cmTargetInternalPointer //---------------------------------------------------------------------------- cmTargetInternalPointer::~cmTargetInternalPointer() { - cmDeleteAll(this->Pointer->CompileOptionsItems); cmDeleteAll(this->Pointer->CompileFeaturesItems); cmDeleteAll(this->Pointer->CompileDefinitionsItems); cmDeleteAll(this->Pointer->SourceEntries); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 13e4f2d..05b6aec 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -375,9 +375,6 @@ public: void AppendBuildInterfaceIncludes(); - void GetCompileOptions(std::vector &result, - const std::string& config, - const std::string& language) const; void GetCompileFeatures(std::vector &features, const std::string& config) const; @@ -402,6 +399,9 @@ public: cmStringRange GetIncludeDirectoriesEntries() const; cmBacktraceRange GetIncludeDirectoriesBacktraces() const; + cmStringRange GetCompileOptionsEntries() const; + cmBacktraceRange GetCompileOptionsBacktraces() const; + #if defined(_WIN32) && !defined(__CYGWIN__) const LinkLibraryVectorType &GetLinkLibrariesForVS6() const { return this->LinkLibrariesForVS6;} @@ -516,7 +516,6 @@ private: bool IsApple; bool IsImportedTarget; bool BuildInterfaceIncludesAppended; - mutable bool DebugCompileOptionsDone; mutable bool DebugCompileDefinitionsDone; mutable bool DebugSourcesDone; mutable bool DebugCompileFeaturesDone; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e6ccbf6f30fb7b893b00a7c26fa165065eed4323 commit e6ccbf6f30fb7b893b00a7c26fa165065eed4323 Author: Stephen Kelly AuthorDate: Tue Aug 4 23:14:53 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 26 19:45:21 2015 +0200 cmGeneratorTarget: Move include directory processing from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 4250806..7ba2863 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -34,6 +34,18 @@ #define UNORDERED_SET std::set #endif +class cmGeneratorTarget::TargetPropertyEntry { + static cmLinkImplItem NoLinkImplItem; +public: + TargetPropertyEntry(cmsys::auto_ptr cge, + cmLinkImplItem const& item = NoLinkImplItem) + : ge(cge), LinkImplItem(item) + {} + const cmsys::auto_ptr ge; + cmLinkImplItem const& LinkImplItem; +}; +cmLinkImplItem cmGeneratorTarget::TargetPropertyEntry::NoLinkImplItem; + //---------------------------------------------------------------------------- void reportBadObjLib(std::vector const& badObjLib, cmGeneratorTarget const* target, cmake *cm) @@ -227,19 +239,43 @@ struct TagVisitor } }; +void CreatePropertyGeneratorExpressions( + cmStringRange const& entries, + cmBacktraceRange const& backtraces, + std::vector& items, + bool evaluateForBuildsystem = false) +{ + std::vector::const_iterator btIt = backtraces.begin(); + for (std::vector::const_iterator it = entries.begin(); + it != entries.end(); ++it, ++btIt) + { + cmGeneratorExpression ge(*btIt); + cmsys::auto_ptr cge = ge.Parse(*it); + cge->SetEvaluateForBuildsystem(evaluateForBuildsystem); + items.push_back(new cmGeneratorTarget::TargetPropertyEntry(cge)); + } +} + //---------------------------------------------------------------------------- cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) : Target(t), SourceFileFlagsConstructed(false), - PolicyWarnedCMP0022(false) + PolicyWarnedCMP0022(false), + DebugIncludesDone(false) { this->Makefile = this->Target->GetMakefile(); this->LocalGenerator = lg; this->GlobalGenerator = this->LocalGenerator->GetGlobalGenerator(); + + CreatePropertyGeneratorExpressions( + t->GetIncludeDirectoriesEntries(), + t->GetIncludeDirectoriesBacktraces(), + this->IncludeDirectoriesEntries); } cmGeneratorTarget::~cmGeneratorTarget() { + cmDeleteAll(this->IncludeDirectoriesEntries); cmDeleteAll(this->LinkInformation); this->LinkInformation.clear(); } @@ -1964,13 +2000,248 @@ cmGeneratorTarget::GetCreateRuleVariable(std::string const& lang, } return ""; } +//---------------------------------------------------------------------------- +static void processIncludeDirectories(cmGeneratorTarget const* tgt, + const std::vector &entries, + std::vector &includes, + UNORDERED_SET &uniqueIncludes, + cmGeneratorExpressionDAGChecker *dagChecker, + const std::string& config, bool debugIncludes, + const std::string& language) +{ + cmMakefile *mf = tgt->Target->GetMakefile(); + + for (std::vector::const_iterator + it = entries.begin(), end = entries.end(); it != end; ++it) + { + cmLinkImplItem const& item = (*it)->LinkImplItem; + std::string const& targetName = item; + bool const fromImported = item.Target && item.Target->IsImported(); + bool const checkCMP0027 = item.FromGenex; + std::vector entryIncludes; + cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf, + config, + false, + tgt->Target, + dagChecker, language), + entryIncludes); + + std::string usedIncludes; + for(std::vector::iterator + li = entryIncludes.begin(); li != entryIncludes.end(); ++li) + { + if (fromImported + && !cmSystemTools::FileExists(li->c_str())) + { + std::ostringstream e; + cmake::MessageType messageType = cmake::FATAL_ERROR; + if (checkCMP0027) + { + switch(tgt->Target->GetPolicyStatusCMP0027()) + { + case cmPolicies::WARN: + e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0027) << "\n"; + case cmPolicies::OLD: + messageType = cmake::AUTHOR_WARNING; + break; + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::NEW: + break; + } + } + e << "Imported target \"" << targetName << "\" includes " + "non-existent path\n \"" << *li << "\"\nin its " + "INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:\n" + "* The path was deleted, renamed, or moved to another " + "location.\n" + "* An install or uninstall procedure did not complete " + "successfully.\n" + "* The installation package was faulty and references files it " + "does not provide.\n"; + tgt->GetLocalGenerator()->IssueMessage(messageType, e.str()); + return; + } + + if (!cmSystemTools::FileIsFullPath(li->c_str())) + { + std::ostringstream e; + bool noMessage = false; + cmake::MessageType messageType = cmake::FATAL_ERROR; + if (!targetName.empty()) + { + e << "Target \"" << targetName << "\" contains relative " + "path in its INTERFACE_INCLUDE_DIRECTORIES:\n" + " \"" << *li << "\""; + } + else + { + switch(tgt->Target->GetPolicyStatusCMP0021()) + { + case cmPolicies::WARN: + { + e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0021) << "\n"; + messageType = cmake::AUTHOR_WARNING; + } + break; + case cmPolicies::OLD: + noMessage = true; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::NEW: + // Issue the fatal message. + break; + } + e << "Found relative path while evaluating include directories of " + "\"" << tgt->GetName() << "\":\n \"" << *li << "\"\n"; + } + if (!noMessage) + { + tgt->GetLocalGenerator()->IssueMessage(messageType, e.str()); + if (messageType == cmake::FATAL_ERROR) + { + return; + } + } + } + + if (!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 (!usedIncludes.empty()) + { + mf->GetCMakeInstance()->IssueMessage(cmake::LOG, + std::string("Used includes for target ") + + tgt->GetName() + ":\n" + + usedIncludes, (*it)->ge->GetBacktrace()); + } + } +} + + +//---------------------------------------------------------------------------- +static void AddInterfaceEntries( + cmGeneratorTarget const* thisTarget, std::string const& config, + std::string const& prop, + std::vector& entries) +{ + if(cmLinkImplementationLibraries const* impl = + thisTarget->Target->GetLinkImplementationLibraries(config)) + { + for (std::vector::const_iterator + it = impl->Libraries.begin(), end = impl->Libraries.end(); + it != end; ++it) + { + if(it->Target) + { + std::string genex = + "$"; + cmGeneratorExpression ge(it->Backtrace); + cmsys::auto_ptr cge = ge.Parse(genex); + cge->SetEvaluateForBuildsystem(true); + entries.push_back( + new cmGeneratorTarget::TargetPropertyEntry(cge, *it)); + } + } + } +} //---------------------------------------------------------------------------- std::vector cmGeneratorTarget::GetIncludeDirectories(const std::string& config, const std::string& lang) const { - return this->Target->GetIncludeDirectories(config, lang); + std::vector includes; + UNORDERED_SET uniqueIncludes; + + cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), + "INCLUDE_DIRECTORIES", 0, 0); + + std::vector debugProperties; + const char *debugProp = + this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); + if (debugProp) + { + cmSystemTools::ExpandListArgument(debugProp, debugProperties); + } + + bool debugIncludes = !this->DebugIncludesDone + && std::find(debugProperties.begin(), + debugProperties.end(), + "INCLUDE_DIRECTORIES") + != debugProperties.end(); + + if (this->Makefile->IsConfigured()) + { + this->DebugIncludesDone = true; + } + + processIncludeDirectories(this, + this->IncludeDirectoriesEntries, + includes, + uniqueIncludes, + &dagChecker, + config, + debugIncludes, + lang); + + std::vector + linkInterfaceIncludeDirectoriesEntries; + AddInterfaceEntries( + this, config, "INTERFACE_INCLUDE_DIRECTORIES", + linkInterfaceIncludeDirectoriesEntries); + + if(this->Makefile->IsOn("APPLE")) + { + cmLinkImplementationLibraries const* impl = + this->Target->GetLinkImplementationLibraries(config); + for(std::vector::const_iterator + it = impl->Libraries.begin(); + it != impl->Libraries.end(); ++it) + { + std::string libDir = cmSystemTools::CollapseFullPath(*it); + + static cmsys::RegularExpression + frameworkCheck("(.*\\.framework)(/Versions/[^/]+)?/[^/]+$"); + if(!frameworkCheck.find(libDir)) + { + continue; + } + + libDir = frameworkCheck.match(1); + + cmGeneratorExpression ge; + cmsys::auto_ptr cge = + ge.Parse(libDir.c_str()); + linkInterfaceIncludeDirectoriesEntries + .push_back(new cmGeneratorTarget::TargetPropertyEntry(cge)); + } + } + + processIncludeDirectories(this, + linkInterfaceIncludeDirectoriesEntries, + includes, + uniqueIncludes, + &dagChecker, + config, + debugIncludes, + lang); + + cmDeleteAll(linkInterfaceIncludeDirectoriesEntries); + + return includes; } //---------------------------------------------------------------------------- diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 2e0d5fe..513884f 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -332,6 +332,8 @@ public: const std::string &report, const std::string &compatibilityType) const; + class TargetPropertyEntry; + private: friend class cmTargetTraceDependencies; struct SourceEntry { std::vector Depends; }; @@ -404,6 +406,8 @@ private: GetImportLinkInterface(const std::string& config, cmTarget const* head, bool usage_requirements_only) const; + std::vector IncludeDirectoriesEntries; + void ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, cmTarget const* headTarget, bool usage_requirements_only, @@ -416,6 +420,7 @@ private: typedef std::map OutputNameMapType; mutable OutputNameMapType OutputNameMap; mutable bool PolicyWarnedCMP0022; + mutable bool DebugIncludesDone; public: std::vector const& diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index 1e57c33..7af17cd 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -343,7 +343,7 @@ void cmGhsMultiTargetGenerator::WriteIncludes(const std::string &config, const std::string &language) { std::vector includes = - this->Target->GetIncludeDirectories(config, language); + this->GeneratorTarget->GetIncludeDirectories(config, language); for (std::vector::const_iterator includes_i = includes.begin(); includes_i != includes.end(); ++includes_i) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index be8d58e..06d21cc 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -139,7 +139,6 @@ public: }; std::vector IncludeDirectoriesEntries; std::vector IncludeDirectoriesBacktraces; - std::vector IncludeDirectoriesItems; std::vector CompileOptionsEntries; std::vector CompileOptionsBacktraces; std::vector CompileOptionsItems; @@ -177,7 +176,6 @@ cmTarget::cmTarget() this->IsApple = false; this->IsImportedTarget = false; this->BuildInterfaceIncludesAppended = false; - this->DebugIncludesDone = false; this->DebugCompileOptionsDone = false; this->DebugCompileFeaturesDone = false; this->DebugCompileDefinitionsDone = false; @@ -426,11 +424,6 @@ void CreatePropertyGeneratorExpressions( void cmTarget::Compute() { CreatePropertyGeneratorExpressions( - this->Internal->IncludeDirectoriesEntries, - this->Internal->IncludeDirectoriesBacktraces, - this->Internal->IncludeDirectoriesItems); - - CreatePropertyGeneratorExpressions( this->Internal->CompileOptionsEntries, this->Internal->CompileOptionsBacktraces, this->Internal->CompileOptionsItems); @@ -1319,6 +1312,16 @@ cmTarget::AddSystemIncludeDirectories(const std::set &incs) this->SystemIncludeDirectories.insert(incs.begin(), incs.end()); } +cmStringRange cmTarget::GetIncludeDirectoriesEntries() const +{ + return cmMakeRange(this->Internal->IncludeDirectoriesEntries); +} + +cmBacktraceRange cmTarget::GetIncludeDirectoriesBacktraces() const +{ + return cmMakeRange(this->Internal->IncludeDirectoriesBacktraces); +} + #if defined(_WIN32) && !defined(__CYGWIN__) //---------------------------------------------------------------------------- void @@ -1916,222 +1919,6 @@ void cmTarget::InsertCompileDefinition(std::string const& entry, } //---------------------------------------------------------------------------- -static void processIncludeDirectories(cmTarget const* tgt, - const std::vector &entries, - std::vector &includes, - UNORDERED_SET &uniqueIncludes, - cmGeneratorExpressionDAGChecker *dagChecker, - const std::string& config, bool debugIncludes, - const std::string& language) -{ - cmMakefile *mf = tgt->GetMakefile(); - - for (std::vector::const_iterator - it = entries.begin(), end = entries.end(); it != end; ++it) - { - cmLinkImplItem const& item = (*it)->LinkImplItem; - std::string const& targetName = item; - bool const fromImported = item.Target && item.Target->IsImported(); - bool const checkCMP0027 = item.FromGenex; - std::vector entryIncludes; - cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf, - config, - false, - tgt, - dagChecker, language), - entryIncludes); - - std::string usedIncludes; - for(std::vector::iterator - li = entryIncludes.begin(); li != entryIncludes.end(); ++li) - { - if (fromImported - && !cmSystemTools::FileExists(li->c_str())) - { - std::ostringstream e; - cmake::MessageType messageType = cmake::FATAL_ERROR; - if (checkCMP0027) - { - switch(tgt->GetPolicyStatusCMP0027()) - { - case cmPolicies::WARN: - e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0027) << "\n"; - case cmPolicies::OLD: - messageType = cmake::AUTHOR_WARNING; - break; - case cmPolicies::REQUIRED_ALWAYS: - case cmPolicies::REQUIRED_IF_USED: - case cmPolicies::NEW: - break; - } - } - e << "Imported target \"" << targetName << "\" includes " - "non-existent path\n \"" << *li << "\"\nin its " - "INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:\n" - "* The path was deleted, renamed, or moved to another " - "location.\n" - "* An install or uninstall procedure did not complete " - "successfully.\n" - "* The installation package was faulty and references files it " - "does not provide.\n"; - tgt->GetMakefile()->IssueMessage(messageType, e.str()); - return; - } - - if (!cmSystemTools::FileIsFullPath(li->c_str())) - { - std::ostringstream e; - bool noMessage = false; - cmake::MessageType messageType = cmake::FATAL_ERROR; - if (!targetName.empty()) - { - e << "Target \"" << targetName << "\" contains relative " - "path in its INTERFACE_INCLUDE_DIRECTORIES:\n" - " \"" << *li << "\""; - } - else - { - switch(tgt->GetPolicyStatusCMP0021()) - { - case cmPolicies::WARN: - { - e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0021) << "\n"; - messageType = cmake::AUTHOR_WARNING; - } - break; - case cmPolicies::OLD: - noMessage = true; - case cmPolicies::REQUIRED_IF_USED: - case cmPolicies::REQUIRED_ALWAYS: - case cmPolicies::NEW: - // Issue the fatal message. - break; - } - e << "Found relative path while evaluating include directories of " - "\"" << tgt->GetName() << "\":\n \"" << *li << "\"\n"; - } - if (!noMessage) - { - tgt->GetMakefile()->IssueMessage(messageType, e.str()); - if (messageType == cmake::FATAL_ERROR) - { - return; - } - } - } - - if (!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 (!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 std::string& config, - const std::string& language) const -{ - std::vector includes; - UNORDERED_SET uniqueIncludes; - - cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), - "INCLUDE_DIRECTORIES", 0, 0); - - std::vector debugProperties; - const char *debugProp = - this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); - if (debugProp) - { - cmSystemTools::ExpandListArgument(debugProp, debugProperties); - } - - bool debugIncludes = !this->DebugIncludesDone - && std::find(debugProperties.begin(), - debugProperties.end(), - "INCLUDE_DIRECTORIES") - != debugProperties.end(); - - if (this->Makefile->IsConfigured()) - { - this->DebugIncludesDone = true; - } - - processIncludeDirectories(this, - this->Internal->IncludeDirectoriesItems, - includes, - uniqueIncludes, - &dagChecker, - config, - debugIncludes, - language); - - std::vector - linkInterfaceIncludeDirectoriesEntries; - this->Internal->AddInterfaceEntries( - this, config, "INTERFACE_INCLUDE_DIRECTORIES", - linkInterfaceIncludeDirectoriesEntries); - - if(this->Makefile->IsOn("APPLE")) - { - cmLinkImplementationLibraries const* impl = - this->GetLinkImplementationLibraries(config); - for(std::vector::const_iterator - it = impl->Libraries.begin(); - it != impl->Libraries.end(); ++it) - { - std::string libDir = cmSystemTools::CollapseFullPath(*it); - - static cmsys::RegularExpression - frameworkCheck("(.*\\.framework)(/Versions/[^/]+)?/[^/]+$"); - if(!frameworkCheck.find(libDir)) - { - continue; - } - - libDir = frameworkCheck.match(1); - - cmGeneratorExpression ge; - cmsys::auto_ptr cge = - ge.Parse(libDir.c_str()); - linkInterfaceIncludeDirectoriesEntries - .push_back(new cmTargetInternals::TargetPropertyEntry(cge)); - } - } - - processIncludeDirectories(this, - linkInterfaceIncludeDirectoriesEntries, - includes, - uniqueIncludes, - &dagChecker, - config, - debugIncludes, - language); - - cmDeleteAll(linkInterfaceIncludeDirectoriesEntries); - - return includes; -} - -//---------------------------------------------------------------------------- static void processCompileOptionsInternal(cmTarget const* tgt, const std::vector &entries, std::vector &options, @@ -4379,7 +4166,6 @@ cmTargetInternalPointer //---------------------------------------------------------------------------- cmTargetInternalPointer::~cmTargetInternalPointer() { - cmDeleteAll(this->Pointer->IncludeDirectoriesItems); cmDeleteAll(this->Pointer->CompileOptionsItems); cmDeleteAll(this->Pointer->CompileFeaturesItems); cmDeleteAll(this->Pointer->CompileDefinitionsItems); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 103a7e8..13e4f2d 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -364,9 +364,6 @@ public: /** @return whether this target have a well defined output file name. */ bool HaveWellDefinedOutputFiles() const; - std::vector GetIncludeDirectories( - const std::string& config, - const std::string& language) const; void InsertInclude(std::string const& entry, cmListFileBacktrace const& bt, bool before = false); @@ -402,6 +399,9 @@ public: return this->MaxLanguageStandards; } + cmStringRange GetIncludeDirectoriesEntries() const; + cmBacktraceRange GetIncludeDirectoriesBacktraces() const; + #if defined(_WIN32) && !defined(__CYGWIN__) const LinkLibraryVectorType &GetLinkLibrariesForVS6() const { return this->LinkLibrariesForVS6;} @@ -516,7 +516,6 @@ private: bool IsApple; bool IsImportedTarget; bool BuildInterfaceIncludesAppended; - mutable bool DebugIncludesDone; mutable bool DebugCompileOptionsDone; mutable bool DebugCompileDefinitionsDone; mutable bool DebugSourcesDone; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8bfb0c53dae93d697ca5d92ff79068af351fe56b commit 8bfb0c53dae93d697ca5d92ff79068af351fe56b Author: Stephen Kelly AuthorDate: Tue Aug 4 19:22:30 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 26 19:39:29 2015 +0200 cmGeneratorTarget: Move link iface helpers from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c966e24..4250806 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3363,6 +3363,51 @@ cmGeneratorTarget::ReportPropertyOrigin(const std::string &p, } //---------------------------------------------------------------------------- +void cmGeneratorTarget::LookupLinkItems(std::vector const& names, + std::vector& items) const +{ + for(std::vector::const_iterator i = names.begin(); + i != names.end(); ++i) + { + std::string name = this->Target->CheckCMP0004(*i); + if(name == this->GetName() || name.empty()) + { + continue; + } + items.push_back(cmLinkItem(name, this->Target->FindTargetToLink(name))); + } +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::ExpandLinkItems(std::string const& prop, + std::string const& value, + std::string const& config, + cmTarget const* headTarget, + bool usage_requirements_only, + std::vector& items, + bool& hadHeadSensitiveCondition) const +{ + cmGeneratorExpression ge; + cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), prop, 0, 0); + // The $ expression may be in a link interface to specify private + // link dependencies that are otherwise excluded from usage requirements. + if(usage_requirements_only) + { + dagChecker.SetTransitivePropertiesOnly(); + } + std::vector libs; + cmsys::auto_ptr cge = ge.Parse(value); + cmSystemTools::ExpandListArgument(cge->Evaluate( + this->Makefile, + config, + false, + headTarget, + this->Target, &dagChecker), libs); + this->LookupLinkItems(libs, items); + hadHeadSensitiveCondition = cge->GetHadHeadSensitiveCondition(); +} + +//---------------------------------------------------------------------------- cmLinkInterface const* cmGeneratorTarget::GetLinkInterface(const std::string& config, cmTarget const* head) const @@ -3644,7 +3689,7 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( if(explicitLibraries) { // The interface libraries have been explicitly set. - this->Target->ExpandLinkItems(linkIfaceProp, explicitLibraries, + this->ExpandLinkItems(linkIfaceProp, explicitLibraries, config, headTarget, usage_requirements_only, iface.Libraries, @@ -3673,7 +3718,7 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( if(const char* newExplicitLibraries = this->GetProperty(newProp)) { bool hadHeadSensitiveConditionDummy = false; - this->Target->ExpandLinkItems(newProp, newExplicitLibraries, config, + this->ExpandLinkItems(newProp, newExplicitLibraries, config, headTarget, usage_requirements_only, ifaceLibs, hadHeadSensitiveConditionDummy); } @@ -3737,14 +3782,14 @@ cmGeneratorTarget::GetImportLinkInterface(const std::string& config, iface.AllDone = true; iface.Multiplicity = info->Multiplicity; cmSystemTools::ExpandListArgument(info->Languages, iface.Languages); - this->Target->ExpandLinkItems(info->LibrariesProp, info->Libraries, + this->ExpandLinkItems(info->LibrariesProp, info->Libraries, config, headTarget, usage_requirements_only, iface.Libraries, iface.HadHeadSensitiveCondition); std::vector deps; cmSystemTools::ExpandListArgument(info->SharedDeps, deps); - this->Target->LookupLinkItems(deps, iface.SharedDeps); + this->LookupLinkItems(deps, iface.SharedDeps); } return &iface; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 9c5adf6..2e0d5fe 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -404,6 +404,14 @@ private: GetImportLinkInterface(const std::string& config, cmTarget const* head, bool usage_requirements_only) const; + void ExpandLinkItems(std::string const& prop, std::string const& value, + std::string const& config, cmTarget const* headTarget, + bool usage_requirements_only, + std::vector& items, + bool& hadHeadSensitiveCondition) const; + void LookupLinkItems(std::vector const& names, + std::vector& items) const; + typedef std::pair OutputNameKey; typedef std::map OutputNameMapType; mutable OutputNameMapType OutputNameMap; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 8628583..be8d58e 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3061,51 +3061,6 @@ bool cmTarget::GetPropertyAsBool(const std::string& prop) const } //---------------------------------------------------------------------------- -void cmTarget::ExpandLinkItems(std::string const& prop, - std::string const& value, - std::string const& config, - cmTarget const* headTarget, - bool usage_requirements_only, - std::vector& items, - bool& hadHeadSensitiveCondition) const -{ - cmGeneratorExpression ge; - cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), prop, 0, 0); - // The $ expression may be in a link interface to specify private - // link dependencies that are otherwise excluded from usage requirements. - if(usage_requirements_only) - { - dagChecker.SetTransitivePropertiesOnly(); - } - std::vector libs; - cmsys::auto_ptr cge = ge.Parse(value); - cmSystemTools::ExpandListArgument(cge->Evaluate( - this->Makefile, - config, - false, - headTarget, - this, &dagChecker), libs); - this->LookupLinkItems(libs, items); - hadHeadSensitiveCondition = cge->GetHadHeadSensitiveCondition(); -} - -//---------------------------------------------------------------------------- -void cmTarget::LookupLinkItems(std::vector const& names, - std::vector& items) const -{ - for(std::vector::const_iterator i = names.begin(); - i != names.end(); ++i) - { - std::string name = this->CheckCMP0004(*i); - if(name == this->GetName() || name.empty()) - { - continue; - } - items.push_back(cmLinkItem(name, this->FindTargetToLink(name))); - } -} - -//---------------------------------------------------------------------------- const char* cmTarget::GetSuffixVariableInternal(bool implib) const { switch(this->GetType()) diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 25de6a6..103a7e8 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -558,14 +558,6 @@ private: GetLinkImplementationLibrariesInternal(const std::string& config, cmTarget const* head) const; - void ExpandLinkItems(std::string const& prop, std::string const& value, - std::string const& config, cmTarget const* headTarget, - bool usage_requirements_only, - std::vector& items, - bool& hadHeadSensitiveCondition) const; - void LookupLinkItems(std::vector const& names, - std::vector& items) const; - std::string ProcessSourceItemCMP0049(const std::string& s); void ClearLinkMaps(); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2cb3e5740269757f6f93d24a4d13570ee72de318 commit 2cb3e5740269757f6f93d24a4d13570ee72de318 Author: Stephen Kelly AuthorDate: Wed Aug 26 19:39:17 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 26 19:39:17 2015 +0200 cmGeneratorTarget: Move GetImportLinkInterface from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 40a3637..c966e24 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3370,7 +3370,7 @@ cmGeneratorTarget::GetLinkInterface(const std::string& config, // Imported targets have their own link interface. if(this->IsImported()) { - return this->Target->GetImportLinkInterface(config, head, false); + return this->GetImportLinkInterface(config, head, false); } // Link interfaces are not supported for executables that do not @@ -3383,7 +3383,7 @@ cmGeneratorTarget::GetLinkInterface(const std::string& config, // Lookup any existing link interface for this configuration. cmHeadToLinkInterfaceMap& hm = - this->Target->GetHeadToLinkInterfaceMap(config); + this->GetHeadToLinkInterfaceMap(config); // If the link interface does not depend on the head target // then return the one we computed first. @@ -3518,7 +3518,7 @@ cmGeneratorTarget::GetLinkInterfaceLibraries(const std::string& config, // Imported targets have their own link interface. if(this->IsImported()) { - return this->Target->GetImportLinkInterface(config, head, + return this->GetImportLinkInterface(config, head, usage_requirements_only); } @@ -3534,8 +3534,8 @@ cmGeneratorTarget::GetLinkInterfaceLibraries(const std::string& config, std::string CONFIG = cmSystemTools::UpperCase(config); cmHeadToLinkInterfaceMap& hm = (usage_requirements_only ? - this->Target->GetHeadToLinkInterfaceUsageRequirementsMap(config) : - this->Target->GetHeadToLinkInterfaceMap(config)); + this->GetHeadToLinkInterfaceUsageRequirementsMap(config) : + this->GetHeadToLinkInterfaceMap(config)); // If the link interface does not depend on the head target // then return the one we computed first. @@ -3705,3 +3705,62 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( } } } + +//---------------------------------------------------------------------------- +const cmLinkInterface * +cmGeneratorTarget::GetImportLinkInterface(const std::string& config, + cmTarget const* headTarget, + bool usage_requirements_only) const +{ + cmTarget::ImportInfo const* info = this->Target->GetImportInfo(config); + if(!info) + { + return 0; + } + + std::string CONFIG = cmSystemTools::UpperCase(config); + cmHeadToLinkInterfaceMap& hm = + (usage_requirements_only ? + this->GetHeadToLinkInterfaceUsageRequirementsMap(config) : + this->GetHeadToLinkInterfaceMap(config)); + + // If the link interface does not depend on the head target + // then return the one we computed first. + if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) + { + return &hm.begin()->second; + } + + cmOptionalLinkInterface& iface = hm[headTarget]; + if(!iface.AllDone) + { + iface.AllDone = true; + iface.Multiplicity = info->Multiplicity; + cmSystemTools::ExpandListArgument(info->Languages, iface.Languages); + this->Target->ExpandLinkItems(info->LibrariesProp, info->Libraries, + config, + headTarget, usage_requirements_only, + iface.Libraries, + iface.HadHeadSensitiveCondition); + std::vector deps; + cmSystemTools::ExpandListArgument(info->SharedDeps, deps); + this->Target->LookupLinkItems(deps, iface.SharedDeps); + } + + return &iface; +} + +cmHeadToLinkInterfaceMap& +cmGeneratorTarget::GetHeadToLinkInterfaceMap(const std::string &config) const +{ + std::string CONFIG = cmSystemTools::UpperCase(config); + return this->LinkInterfaceMap[CONFIG]; +} + +cmHeadToLinkInterfaceMap& +cmGeneratorTarget::GetHeadToLinkInterfaceUsageRequirementsMap( + const std::string &config) const +{ + std::string CONFIG = cmSystemTools::UpperCase(config); + return this->LinkInterfaceUsageRequirementsOnlyMap[CONFIG]; +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index ac2b96c..9c5adf6 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -390,6 +390,20 @@ private: }; mutable std::map LinkImplClosureMap; + typedef std::map + LinkInterfaceMapType; + mutable LinkInterfaceMapType LinkInterfaceMap; + mutable LinkInterfaceMapType LinkInterfaceUsageRequirementsOnlyMap; + + cmHeadToLinkInterfaceMap& + GetHeadToLinkInterfaceMap(std::string const& config) const; + cmHeadToLinkInterfaceMap& GetHeadToLinkInterfaceUsageRequirementsMap( + std::string const& config) const; + + cmLinkInterface const* + GetImportLinkInterface(const std::string& config, cmTarget const* head, + bool usage_requirements_only) const; + typedef std::pair OutputNameKey; typedef std::map OutputNameMapType; mutable OutputNameMapType OutputNameMap; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 9e9aed4..8628583 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -89,11 +89,6 @@ public: // The backtrace when the target was created. cmListFileBacktrace Backtrace; - typedef std::map - LinkInterfaceMapType; - LinkInterfaceMapType LinkInterfaceMap; - LinkInterfaceMapType LinkInterfaceUsageRequirementsOnlyMap; - typedef std::map OutputInfoMapType; OutputInfoMapType OutputInfoMap; @@ -510,8 +505,6 @@ void cmTarget::ClearLinkMaps() { this->LinkImplementationLanguageIsContextDependent = true; this->Internal->LinkImplMap.clear(); - this->Internal->LinkInterfaceMap.clear(); - this->Internal->LinkInterfaceUsageRequirementsOnlyMap.clear(); this->Internal->SourceFilesMap.clear(); } @@ -4104,64 +4097,6 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, } } -cmHeadToLinkInterfaceMap& -cmTarget::GetHeadToLinkInterfaceMap(const std::string &config) const -{ - std::string CONFIG = cmSystemTools::UpperCase(config); - return this->Internal->LinkInterfaceMap[CONFIG]; -} - -cmHeadToLinkInterfaceMap& -cmTarget::GetHeadToLinkInterfaceUsageRequirementsMap( - const std::string &config) const -{ - std::string CONFIG = cmSystemTools::UpperCase(config); - return this->Internal->LinkInterfaceUsageRequirementsOnlyMap[CONFIG]; -} - -//---------------------------------------------------------------------------- -const cmLinkInterface * -cmTarget::GetImportLinkInterface(const std::string& config, - cmTarget const* headTarget, - bool usage_requirements_only) const -{ - cmTarget::ImportInfo const* info = this->GetImportInfo(config); - if(!info) - { - return 0; - } - - std::string CONFIG = cmSystemTools::UpperCase(config); - cmHeadToLinkInterfaceMap& hm = - (usage_requirements_only ? - this->GetHeadToLinkInterfaceUsageRequirementsMap(config) : - this->GetHeadToLinkInterfaceMap(config)); - - // If the link interface does not depend on the head target - // then return the one we computed first. - if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) - { - return &hm.begin()->second; - } - - cmOptionalLinkInterface& iface = hm[headTarget]; - if(!iface.AllDone) - { - iface.AllDone = true; - iface.Multiplicity = info->Multiplicity; - cmSystemTools::ExpandListArgument(info->Languages, iface.Languages); - this->ExpandLinkItems(info->LibrariesProp, info->Libraries, config, - headTarget, usage_requirements_only, - iface.Libraries, - iface.HadHeadSensitiveCondition); - std::vector deps; - cmSystemTools::ExpandListArgument(info->SharedDeps, deps); - this->LookupLinkItems(deps, iface.SharedDeps); - } - - return &iface; -} - //---------------------------------------------------------------------------- void cmTargetInternals::AddInterfaceEntries( cmTarget const* thisTarget, std::string const& config, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 985e958..25de6a6 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -233,11 +233,6 @@ public: void GetObjectLibrariesCMP0026(std::vector& objlibs) const; - cmHeadToLinkInterfaceMap& - GetHeadToLinkInterfaceMap(std::string const& config) const; - cmHeadToLinkInterfaceMap& GetHeadToLinkInterfaceUsageRequirementsMap( - std::string const& config) const; - struct LinkImplementation: public cmLinkImplementationLibraries { // Languages whose runtime libraries must be linked. @@ -559,11 +554,6 @@ private: void ComputeImportInfo(std::string const& desired_config, ImportInfo& info) const; - - cmLinkInterface const* - GetImportLinkInterface(const std::string& config, cmTarget const* head, - bool usage_requirements_only) const; - cmLinkImplementationLibraries const* GetLinkImplementationLibrariesInternal(const std::string& config, cmTarget const* head) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6d3d099b4a2d8b020fb1a9ebeb29b17b3fb6c9d6 commit 6d3d099b4a2d8b020fb1a9ebeb29b17b3fb6c9d6 Author: Stephen Kelly AuthorDate: Wed Aug 26 19:38:57 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 26 19:38:57 2015 +0200 cmGeneratorTarget: Move ComputeLinkInterfaceLibraries from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 2489c99..40a3637 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -230,7 +230,8 @@ struct TagVisitor //---------------------------------------------------------------------------- cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) : Target(t), - SourceFileFlagsConstructed(false) + SourceFileFlagsConstructed(false), + PolicyWarnedCMP0022(false) { this->Makefile = this->Target->GetMakefile(); this->LocalGenerator = lg; @@ -3395,7 +3396,7 @@ cmGeneratorTarget::GetLinkInterface(const std::string& config, if(!iface.LibrariesDone) { iface.LibrariesDone = true; - this->Target->ComputeLinkInterfaceLibraries( + this->ComputeLinkInterfaceLibraries( config, iface, head, false); } if(!iface.AllDone) @@ -3547,9 +3548,160 @@ cmGeneratorTarget::GetLinkInterfaceLibraries(const std::string& config, if(!iface.LibrariesDone) { iface.LibrariesDone = true; - this->Target->ComputeLinkInterfaceLibraries( + this->ComputeLinkInterfaceLibraries( config, iface, head, usage_requirements_only); } return iface.Exists? &iface : 0; } + +//---------------------------------------------------------------------------- +void +cmGeneratorTarget::ComputeLinkInterfaceLibraries( + const std::string& config, + cmOptionalLinkInterface& iface, + cmTarget const* headTarget, + bool usage_requirements_only) const +{ + // Construct the property name suffix for this configuration. + std::string suffix = "_"; + if(!config.empty()) + { + suffix += cmSystemTools::UpperCase(config); + } + else + { + suffix += "NOCONFIG"; + } + + // An explicit list of interface libraries may be set for shared + // libraries and executables that export symbols. + const char* explicitLibraries = 0; + std::string linkIfaceProp; + if(this->Target->GetPolicyStatusCMP0022() != cmPolicies::OLD && + this->Target->GetPolicyStatusCMP0022() != cmPolicies::WARN) + { + // CMP0022 NEW behavior is to use INTERFACE_LINK_LIBRARIES. + linkIfaceProp = "INTERFACE_LINK_LIBRARIES"; + explicitLibraries = this->GetProperty(linkIfaceProp); + } + else if(this->GetType() == cmTarget::SHARED_LIBRARY || + this->Target->IsExecutableWithExports()) + { + // CMP0022 OLD behavior is to use LINK_INTERFACE_LIBRARIES if set on a + // shared lib or executable. + + // Lookup the per-configuration property. + linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; + linkIfaceProp += suffix; + explicitLibraries = this->GetProperty(linkIfaceProp); + + // If not set, try the generic property. + if(!explicitLibraries) + { + linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; + explicitLibraries = this->GetProperty(linkIfaceProp); + } + } + + if(explicitLibraries && + this->Target->GetPolicyStatusCMP0022() == cmPolicies::WARN && + !this->PolicyWarnedCMP0022) + { + // Compare the explicitly set old link interface properties to the + // preferred new link interface property one and warn if different. + const char* newExplicitLibraries = + this->GetProperty("INTERFACE_LINK_LIBRARIES"); + if (newExplicitLibraries + && strcmp(newExplicitLibraries, explicitLibraries) != 0) + { + std::ostringstream w; + w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n" + "Target \"" << this->GetName() << "\" has an " + "INTERFACE_LINK_LIBRARIES property which differs from its " << + linkIfaceProp << " properties." + "\n" + "INTERFACE_LINK_LIBRARIES:\n" + " " << newExplicitLibraries << "\n" << + linkIfaceProp << ":\n" + " " << (explicitLibraries ? explicitLibraries : "(empty)") << "\n"; + this->LocalGenerator->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + this->PolicyWarnedCMP0022 = true; + } + } + + // There is no implicit link interface for executables or modules + // so if none was explicitly set then there is no link interface. + if(!explicitLibraries && + (this->GetType() == cmTarget::EXECUTABLE || + (this->GetType() == cmTarget::MODULE_LIBRARY))) + { + return; + } + iface.Exists = true; + iface.ExplicitLibraries = explicitLibraries; + + if(explicitLibraries) + { + // The interface libraries have been explicitly set. + this->Target->ExpandLinkItems(linkIfaceProp, explicitLibraries, + config, + headTarget, usage_requirements_only, + iface.Libraries, + iface.HadHeadSensitiveCondition); + } + else if (this->Target->GetPolicyStatusCMP0022() == cmPolicies::WARN + || this->Target->GetPolicyStatusCMP0022() == cmPolicies::OLD) + // If CMP0022 is NEW then the plain tll signature sets the + // INTERFACE_LINK_LIBRARIES, so if we get here then the project + // cleared the property explicitly and we should not fall back + // to the link implementation. + { + // The link implementation is the default link interface. + cmLinkImplementationLibraries const* impl = + this->Target->GetLinkImplementationLibrariesInternal(config, + headTarget); + iface.Libraries.insert(iface.Libraries.end(), + impl->Libraries.begin(), impl->Libraries.end()); + if(this->Target->GetPolicyStatusCMP0022() == cmPolicies::WARN && + !this->PolicyWarnedCMP0022 && !usage_requirements_only) + { + // Compare the link implementation fallback link interface to the + // preferred new link interface property and warn if different. + std::vector ifaceLibs; + static const std::string newProp = "INTERFACE_LINK_LIBRARIES"; + if(const char* newExplicitLibraries = this->GetProperty(newProp)) + { + bool hadHeadSensitiveConditionDummy = false; + this->Target->ExpandLinkItems(newProp, newExplicitLibraries, config, + headTarget, usage_requirements_only, + ifaceLibs, hadHeadSensitiveConditionDummy); + } + if (ifaceLibs != iface.Libraries) + { + std::string oldLibraries = cmJoin(impl->Libraries, ";"); + std::string newLibraries = cmJoin(ifaceLibs, ";"); + if(oldLibraries.empty()) + { oldLibraries = "(empty)"; } + if(newLibraries.empty()) + { newLibraries = "(empty)"; } + + std::ostringstream w; + w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n" + "Target \"" << this->GetName() << "\" has an " + "INTERFACE_LINK_LIBRARIES property. " + "This should be preferred as the source of the link interface " + "for this library but because CMP0022 is not set CMake is " + "ignoring the property and using the link implementation " + "as the link interface instead." + "\n" + "INTERFACE_LINK_LIBRARIES:\n" + " " << newLibraries << "\n" + "Link implementation:\n" + " " << oldLibraries << "\n"; + this->LocalGenerator->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + this->PolicyWarnedCMP0022 = true; + } + } + } +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 43fcb4a..ac2b96c 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -117,6 +117,11 @@ public: cmTarget const* headTarget, bool usage_requirements_only) const; + void ComputeLinkInterfaceLibraries(const std::string& config, + cmOptionalLinkInterface &iface, + cmTarget const* head, + bool usage_requirements_only) const; + /** Get the full path to the target according to the settings in its makefile and the configuration type. */ std::string GetFullPath(const std::string& config="", bool implib = false, @@ -388,6 +393,7 @@ private: typedef std::pair OutputNameKey; typedef std::map OutputNameMapType; mutable OutputNameMapType OutputNameMap; + mutable bool PolicyWarnedCMP0022; public: std::vector const& diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 00dbc6a..9e9aed4 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -77,13 +77,11 @@ public: cmTargetInternals() : Backtrace() { - this->PolicyWarnedCMP0022 = false; this->UtilityItemsDone = false; } cmTargetInternals(cmTargetInternals const&) : Backtrace() { - this->PolicyWarnedCMP0022 = false; this->UtilityItemsDone = false; } ~cmTargetInternals(); @@ -95,7 +93,6 @@ public: LinkInterfaceMapType; LinkInterfaceMapType LinkInterfaceMap; LinkInterfaceMapType LinkInterfaceUsageRequirementsOnlyMap; - bool PolicyWarnedCMP0022; typedef std::map OutputInfoMapType; OutputInfoMapType OutputInfoMap; @@ -4166,156 +4163,6 @@ cmTarget::GetImportLinkInterface(const std::string& config, } //---------------------------------------------------------------------------- -void -cmTarget::ComputeLinkInterfaceLibraries( - const std::string& config, - cmOptionalLinkInterface& iface, - cmTarget const* headTarget, - bool usage_requirements_only) const -{ - // Construct the property name suffix for this configuration. - std::string suffix = "_"; - if(!config.empty()) - { - suffix += cmSystemTools::UpperCase(config); - } - else - { - suffix += "NOCONFIG"; - } - - // An explicit list of interface libraries may be set for shared - // libraries and executables that export symbols. - const char* explicitLibraries = 0; - std::string linkIfaceProp; - if(this->GetPolicyStatusCMP0022() != cmPolicies::OLD && - this->GetPolicyStatusCMP0022() != cmPolicies::WARN) - { - // CMP0022 NEW behavior is to use INTERFACE_LINK_LIBRARIES. - linkIfaceProp = "INTERFACE_LINK_LIBRARIES"; - explicitLibraries = this->GetProperty(linkIfaceProp); - } - else if(this->GetType() == cmTarget::SHARED_LIBRARY || - this->IsExecutableWithExports()) - { - // CMP0022 OLD behavior is to use LINK_INTERFACE_LIBRARIES if set on a - // shared lib or executable. - - // Lookup the per-configuration property. - linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; - linkIfaceProp += suffix; - explicitLibraries = this->GetProperty(linkIfaceProp); - - // If not set, try the generic property. - if(!explicitLibraries) - { - linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; - explicitLibraries = this->GetProperty(linkIfaceProp); - } - } - - if(explicitLibraries && - this->GetPolicyStatusCMP0022() == cmPolicies::WARN && - !this->Internal->PolicyWarnedCMP0022) - { - // Compare the explicitly set old link interface properties to the - // preferred new link interface property one and warn if different. - const char* newExplicitLibraries = - this->GetProperty("INTERFACE_LINK_LIBRARIES"); - if (newExplicitLibraries - && strcmp(newExplicitLibraries, explicitLibraries) != 0) - { - std::ostringstream w; - w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n" - "Target \"" << this->GetName() << "\" has an " - "INTERFACE_LINK_LIBRARIES property which differs from its " << - linkIfaceProp << " properties." - "\n" - "INTERFACE_LINK_LIBRARIES:\n" - " " << newExplicitLibraries << "\n" << - linkIfaceProp << ":\n" - " " << (explicitLibraries ? explicitLibraries : "(empty)") << "\n"; - this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); - this->Internal->PolicyWarnedCMP0022 = true; - } - } - - // There is no implicit link interface for executables or modules - // so if none was explicitly set then there is no link interface. - if(!explicitLibraries && - (this->GetType() == cmTarget::EXECUTABLE || - (this->GetType() == cmTarget::MODULE_LIBRARY))) - { - return; - } - iface.Exists = true; - iface.ExplicitLibraries = explicitLibraries; - - if(explicitLibraries) - { - // The interface libraries have been explicitly set. - this->ExpandLinkItems(linkIfaceProp, explicitLibraries, config, - headTarget, usage_requirements_only, - iface.Libraries, - iface.HadHeadSensitiveCondition); - } - else if (this->GetPolicyStatusCMP0022() == cmPolicies::WARN - || this->GetPolicyStatusCMP0022() == cmPolicies::OLD) - // If CMP0022 is NEW then the plain tll signature sets the - // INTERFACE_LINK_LIBRARIES, so if we get here then the project - // cleared the property explicitly and we should not fall back - // to the link implementation. - { - // The link implementation is the default link interface. - cmLinkImplementationLibraries const* impl = - this->GetLinkImplementationLibrariesInternal(config, headTarget); - iface.Libraries.insert(iface.Libraries.end(), - impl->Libraries.begin(), impl->Libraries.end()); - if(this->GetPolicyStatusCMP0022() == cmPolicies::WARN && - !this->Internal->PolicyWarnedCMP0022 && !usage_requirements_only) - { - // Compare the link implementation fallback link interface to the - // preferred new link interface property and warn if different. - std::vector ifaceLibs; - static const std::string newProp = "INTERFACE_LINK_LIBRARIES"; - if(const char* newExplicitLibraries = this->GetProperty(newProp)) - { - bool hadHeadSensitiveConditionDummy = false; - this->ExpandLinkItems(newProp, newExplicitLibraries, config, - headTarget, usage_requirements_only, - ifaceLibs, hadHeadSensitiveConditionDummy); - } - if (ifaceLibs != iface.Libraries) - { - std::string oldLibraries = cmJoin(impl->Libraries, ";"); - std::string newLibraries = cmJoin(ifaceLibs, ";"); - if(oldLibraries.empty()) - { oldLibraries = "(empty)"; } - if(newLibraries.empty()) - { newLibraries = "(empty)"; } - - std::ostringstream w; - w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n" - "Target \"" << this->GetName() << "\" has an " - "INTERFACE_LINK_LIBRARIES property. " - "This should be preferred as the source of the link interface " - "for this library but because CMP0022 is not set CMake is " - "ignoring the property and using the link implementation " - "as the link interface instead." - "\n" - "INTERFACE_LINK_LIBRARIES:\n" - " " << newLibraries << "\n" - "Link implementation:\n" - " " << oldLibraries << "\n"; - this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); - this->Internal->PolicyWarnedCMP0022 = true; - } - } - } -} - - -//---------------------------------------------------------------------------- void cmTargetInternals::AddInterfaceEntries( cmTarget const* thisTarget, std::string const& config, std::string const& prop, std::vector& entries) diff --git a/Source/cmTarget.h b/Source/cmTarget.h index f124084..985e958 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -233,11 +233,6 @@ public: void GetObjectLibrariesCMP0026(std::vector& objlibs) const; - void ComputeLinkInterfaceLibraries(const std::string& config, - cmOptionalLinkInterface &iface, - cmTarget const* head, - bool usage_requirements_only) const; - cmHeadToLinkInterfaceMap& GetHeadToLinkInterfaceMap(std::string const& config) const; cmHeadToLinkInterfaceMap& GetHeadToLinkInterfaceUsageRequirementsMap( http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0db9d9278760c90be1fbf5c4eeb93ef9c524041a commit 0db9d9278760c90be1fbf5c4eeb93ef9c524041a Author: Stephen Kelly AuthorDate: Wed Aug 26 19:38:37 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 26 19:38:37 2015 +0200 cmGeneratorTarget: Move GetLinkInterfaceLibraries from cmTarget. diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 9509c2b..31b6766 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1109,7 +1109,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode if(isInterfaceProperty) { if(cmLinkInterfaceLibraries const* iface = - target->GetLinkInterfaceLibraries(context->Config, headTarget, true)) + gtgt->GetLinkInterfaceLibraries(context->Config, headTarget, true)) { linkedTargetsContent = getLinkedTargetsContent(iface->Libraries, target, diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 058a120..2489c99 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1507,20 +1507,22 @@ void cmGeneratorTarget::GetAutoUicOptions(std::vector &result, void processILibs(const std::string& config, cmTarget const* headTarget, cmLinkItem const& item, + cmGlobalGenerator* gg, std::vector& tgts, std::set& emitted) { if (item.Target && emitted.insert(item.Target).second) { tgts.push_back(item.Target); + cmGeneratorTarget* gt = gg->GetGeneratorTarget(item.Target); if(cmLinkInterfaceLibraries const* iface = - item.Target->GetLinkInterfaceLibraries(config, headTarget, true)) + gt->GetLinkInterfaceLibraries(config, headTarget, true)) { for(std::vector::const_iterator it = iface->Libraries.begin(); it != iface->Libraries.end(); ++it) { - processILibs(config, headTarget, *it, tgts, emitted); + processILibs(config, headTarget, *it, gg, tgts, emitted); } } } @@ -1545,7 +1547,9 @@ cmGeneratorTarget::GetLinkImplementationClosure( it = impl->Libraries.begin(); it != impl->Libraries.end(); ++it) { - processILibs(config, this->Target, *it, tgts , emitted); + processILibs(config, this->Target, *it, + this->LocalGenerator->GetGlobalGenerator(), + tgts , emitted); } } return tgts; @@ -3503,3 +3507,49 @@ void cmGeneratorTarget::ComputeLinkInterface(const std::string& config, } } } + +//---------------------------------------------------------------------------- +const cmLinkInterfaceLibraries * +cmGeneratorTarget::GetLinkInterfaceLibraries(const std::string& config, + cmTarget const* head, + bool usage_requirements_only) const +{ + // Imported targets have their own link interface. + if(this->IsImported()) + { + return this->Target->GetImportLinkInterface(config, head, + usage_requirements_only); + } + + // Link interfaces are not supported for executables that do not + // export symbols. + if(this->GetType() == cmTarget::EXECUTABLE && + !this->Target->IsExecutableWithExports()) + { + return 0; + } + + // Lookup any existing link interface for this configuration. + std::string CONFIG = cmSystemTools::UpperCase(config); + cmHeadToLinkInterfaceMap& hm = + (usage_requirements_only ? + this->Target->GetHeadToLinkInterfaceUsageRequirementsMap(config) : + this->Target->GetHeadToLinkInterfaceMap(config)); + + // If the link interface does not depend on the head target + // then return the one we computed first. + if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) + { + return &hm.begin()->second; + } + + cmOptionalLinkInterface& iface = hm[head]; + if(!iface.LibrariesDone) + { + iface.LibrariesDone = true; + this->Target->ComputeLinkInterfaceLibraries( + config, iface, head, usage_requirements_only); + } + + return iface.Exists? &iface : 0; +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 282ab89..43fcb4a 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -112,6 +112,11 @@ public: cmOptionalLinkInterface& iface, cmTarget const* head) const; + cmLinkInterfaceLibraries const* + GetLinkInterfaceLibraries(const std::string& config, + cmTarget const* headTarget, + bool usage_requirements_only) const; + /** Get the full path to the target according to the settings in its makefile and the configuration type. */ std::string GetFullPath(const std::string& config="", bool implib = false, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index c8a9148..00dbc6a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4107,50 +4107,6 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, } } -//---------------------------------------------------------------------------- -const cmLinkInterfaceLibraries * -cmTarget::GetLinkInterfaceLibraries(const std::string& config, - cmTarget const* head, - bool usage_requirements_only) const -{ - // Imported targets have their own link interface. - if(this->IsImported()) - { - return this->GetImportLinkInterface(config, head, usage_requirements_only); - } - - // Link interfaces are not supported for executables that do not - // export symbols. - if(this->GetType() == cmTarget::EXECUTABLE && - !this->IsExecutableWithExports()) - { - return 0; - } - - // Lookup any existing link interface for this configuration. - cmHeadToLinkInterfaceMap& hm = - (usage_requirements_only ? - this->GetHeadToLinkInterfaceUsageRequirementsMap(config) : - this->GetHeadToLinkInterfaceMap(config)); - - // If the link interface does not depend on the head target - // then return the one we computed first. - if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) - { - return &hm.begin()->second; - } - - cmOptionalLinkInterface& iface = hm[head]; - if(!iface.LibrariesDone) - { - iface.LibrariesDone = true; - this->ComputeLinkInterfaceLibraries( - config, iface, head, usage_requirements_only); - } - - return iface.Exists? &iface : 0; -} - cmHeadToLinkInterfaceMap& cmTarget::GetHeadToLinkInterfaceMap(const std::string &config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e71820e..f124084 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -238,11 +238,6 @@ public: cmTarget const* head, bool usage_requirements_only) const; - cmLinkInterfaceLibraries const* - GetLinkInterfaceLibraries(const std::string& config, - cmTarget const* headTarget, - bool usage_requirements_only) const; - cmHeadToLinkInterfaceMap& GetHeadToLinkInterfaceMap(std::string const& config) const; cmHeadToLinkInterfaceMap& GetHeadToLinkInterfaceUsageRequirementsMap( http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=84b847e42fde288bc102198aedeb68e19b41ef1e commit 84b847e42fde288bc102198aedeb68e19b41ef1e Author: Stephen Kelly AuthorDate: Wed Aug 26 19:38:14 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 26 19:38:14 2015 +0200 cmGeneratorTarget: Move ComputeLinkInterface from cmTarget. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 5d84309..058a120 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3399,9 +3399,107 @@ cmGeneratorTarget::GetLinkInterface(const std::string& config, iface.AllDone = true; if(iface.Exists) { - this->Target->ComputeLinkInterface(config, iface, head); + this->ComputeLinkInterface(config, iface, head); } } return iface.Exists? &iface : 0; } + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::ComputeLinkInterface(const std::string& config, + cmOptionalLinkInterface &iface, + cmTarget const* headTarget) const +{ + if(iface.ExplicitLibraries) + { + if(this->GetType() == cmTarget::SHARED_LIBRARY + || this->GetType() == cmTarget::STATIC_LIBRARY + || this->GetType() == cmTarget::INTERFACE_LIBRARY) + { + // Shared libraries may have runtime implementation dependencies + // on other shared libraries that are not in the interface. + UNORDERED_SET emitted; + for(std::vector::const_iterator + li = iface.Libraries.begin(); li != iface.Libraries.end(); ++li) + { + emitted.insert(*li); + } + if (this->GetType() != cmTarget::INTERFACE_LIBRARY) + { + cmTarget::LinkImplementation const* impl = + this->Target->GetLinkImplementation(config); + for(std::vector::const_iterator + li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li) + { + if(emitted.insert(*li).second) + { + if(li->Target) + { + // This is a runtime dependency on another shared library. + if(li->Target->GetType() == cmTarget::SHARED_LIBRARY) + { + iface.SharedDeps.push_back(*li); + } + } + else + { + // TODO: Recognize shared library file names. Perhaps this + // should be moved to cmComputeLinkInformation, but that creates + // a chicken-and-egg problem since this list is needed for its + // construction. + } + } + } + } + } + } + else if (this->Target->GetPolicyStatusCMP0022() == cmPolicies::WARN + || this->Target->GetPolicyStatusCMP0022() == cmPolicies::OLD) + { + // The link implementation is the default link interface. + cmLinkImplementationLibraries const* + impl = this->Target->GetLinkImplementationLibrariesInternal(config, + headTarget); + iface.ImplementationIsInterface = true; + iface.WrongConfigLibraries = impl->WrongConfigLibraries; + } + + if(this->Target->LinkLanguagePropagatesToDependents()) + { + // Targets using this archive need its language runtime libraries. + if(cmTarget::LinkImplementation const* impl = + this->Target->GetLinkImplementation(config)) + { + iface.Languages = impl->Languages; + } + } + + if(this->GetType() == cmTarget::STATIC_LIBRARY) + { + // Construct the property name suffix for this configuration. + std::string suffix = "_"; + if(!config.empty()) + { + suffix += cmSystemTools::UpperCase(config); + } + else + { + suffix += "NOCONFIG"; + } + + // How many repetitions are needed if this library has cyclic + // dependencies? + std::string propName = "LINK_INTERFACE_MULTIPLICITY"; + propName += suffix; + if(const char* config_reps = this->GetProperty(propName)) + { + sscanf(config_reps, "%u", &iface.Multiplicity); + } + else if(const char* reps = + this->GetProperty("LINK_INTERFACE_MULTIPLICITY")) + { + sscanf(reps, "%u", &iface.Multiplicity); + } + } +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 2dbb502..282ab89 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -108,6 +108,9 @@ public: cmLinkInterface const* GetLinkInterface(const std::string& config, cmTarget const* headTarget) const; + void ComputeLinkInterface(const std::string& config, + cmOptionalLinkInterface& iface, + cmTarget const* head) const; /** Get the full path to the target according to the settings in its makefile and the configuration type. */ diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index ee298ac..c8a9148 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4358,103 +4358,6 @@ cmTarget::ComputeLinkInterfaceLibraries( } } -//---------------------------------------------------------------------------- -void cmTarget::ComputeLinkInterface(const std::string& config, - cmOptionalLinkInterface &iface, - cmTarget const* headTarget) const -{ - if(iface.ExplicitLibraries) - { - if(this->GetType() == cmTarget::SHARED_LIBRARY - || this->GetType() == cmTarget::STATIC_LIBRARY - || this->GetType() == cmTarget::INTERFACE_LIBRARY) - { - // Shared libraries may have runtime implementation dependencies - // on other shared libraries that are not in the interface. - UNORDERED_SET emitted; - for(std::vector::const_iterator - li = iface.Libraries.begin(); li != iface.Libraries.end(); ++li) - { - emitted.insert(*li); - } - if (this->GetType() != cmTarget::INTERFACE_LIBRARY) - { - cmTarget::LinkImplementation const* impl = - this->GetLinkImplementation(config); - for(std::vector::const_iterator - li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li) - { - if(emitted.insert(*li).second) - { - if(li->Target) - { - // This is a runtime dependency on another shared library. - if(li->Target->GetType() == cmTarget::SHARED_LIBRARY) - { - iface.SharedDeps.push_back(*li); - } - } - else - { - // TODO: Recognize shared library file names. Perhaps this - // should be moved to cmComputeLinkInformation, but that creates - // a chicken-and-egg problem since this list is needed for its - // construction. - } - } - } - } - } - } - else if (this->GetPolicyStatusCMP0022() == cmPolicies::WARN - || this->GetPolicyStatusCMP0022() == cmPolicies::OLD) - { - // The link implementation is the default link interface. - cmLinkImplementationLibraries const* - impl = this->GetLinkImplementationLibrariesInternal(config, - headTarget); - iface.ImplementationIsInterface = true; - iface.WrongConfigLibraries = impl->WrongConfigLibraries; - } - - if(this->LinkLanguagePropagatesToDependents()) - { - // Targets using this archive need its language runtime libraries. - if(cmTarget::LinkImplementation const* impl = - this->GetLinkImplementation(config)) - { - iface.Languages = impl->Languages; - } - } - - if(this->GetType() == cmTarget::STATIC_LIBRARY) - { - // Construct the property name suffix for this configuration. - std::string suffix = "_"; - if(!config.empty()) - { - suffix += cmSystemTools::UpperCase(config); - } - else - { - suffix += "NOCONFIG"; - } - - // How many repetitions are needed if this library has cyclic - // dependencies? - std::string propName = "LINK_INTERFACE_MULTIPLICITY"; - propName += suffix; - if(const char* config_reps = this->GetProperty(propName)) - { - sscanf(config_reps, "%u", &iface.Multiplicity); - } - else if(const char* reps = - this->GetProperty("LINK_INTERFACE_MULTIPLICITY")) - { - sscanf(reps, "%u", &iface.Multiplicity); - } - } -} //---------------------------------------------------------------------------- void cmTargetInternals::AddInterfaceEntries( diff --git a/Source/cmTarget.h b/Source/cmTarget.h index a8c6e8f..e71820e 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -233,9 +233,6 @@ public: void GetObjectLibrariesCMP0026(std::vector& objlibs) const; - void ComputeLinkInterface(const std::string& config, - cmOptionalLinkInterface& iface, - cmTarget const* head) const; void ComputeLinkInterfaceLibraries(const std::string& config, cmOptionalLinkInterface &iface, cmTarget const* head, http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6220241fd0bb7902c932742a7aa3d6a96fd0e919 commit 6220241fd0bb7902c932742a7aa3d6a96fd0e919 Author: Stephen Kelly AuthorDate: Wed Aug 26 19:37:45 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 26 19:37:45 2015 +0200 cmGeneratorTarget: Move GetLinkInterface from cmTarget. diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 03ec820..5e9627b 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -360,9 +360,11 @@ void cmComputeLinkDepends::FollowLinkEntry(BFSEntry const& qe) // Follow the item's dependencies. if(entry.Target) { + cmGeneratorTarget* gtgt = + this->GlobalGenerator->GetGeneratorTarget(entry.Target); // Follow the target dependencies. if(cmLinkInterface const* iface = - entry.Target->GetLinkInterface(this->Config, this->Target->Target)) + gtgt->GetLinkInterface(this->Config, this->Target->Target)) { const bool isIface = entry.Target->GetType() == cmTarget::INTERFACE_LIBRARY; @@ -459,8 +461,10 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep) // Target items may have their own dependencies. if(entry.Target) { + cmGeneratorTarget* gtgt = + this->GlobalGenerator->GetGeneratorTarget(entry.Target); if(cmLinkInterface const* iface = - entry.Target->GetLinkInterface(this->Config, this->Target->Target)) + gtgt->GetLinkInterface(this->Config, this->Target->Target)) { // Follow public and private dependencies transitively. this->FollowSharedDeps(index, iface, true); @@ -930,8 +934,10 @@ int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl) { if(cmTarget const* target = this->EntryList[*ni].Target) { + cmGeneratorTarget* gtgt = + this->GlobalGenerator->GetGeneratorTarget(target); if(cmLinkInterface const* iface = - target->GetLinkInterface(this->Config, this->Target->Target)) + gtgt->GetLinkInterface(this->Config, this->Target->Target)) { if(iface->Multiplicity > count) { diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index aeb9184..83b2a0e 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -297,7 +297,7 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, { cmGeneratorTarget const* depender = this->Targets[depender_index]; if(cmLinkInterface const* iface = - dependee->Target->GetLinkInterface(config, + dependee->GetLinkInterface(config, depender->Target)) { for(std::vector::const_iterator diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index d559a07..9a7d73f 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -796,9 +796,8 @@ cmExportFileGenerator std::vector& missingTargets) { // Add the transitive link dependencies for this configuration. - cmLinkInterface const* iface = target->Target->GetLinkInterface( - config, - target->Target); + cmLinkInterface const* iface = target->GetLinkInterface(config, + target->Target); if (!iface) { return; @@ -910,8 +909,7 @@ cmExportFileGenerator // Add the transitive link dependencies for this configuration. if(cmLinkInterface const* iface = - target->Target - ->GetLinkInterface(config, target->Target)) + target->GetLinkInterface(config, target->Target)) { this->SetImportLinkProperty(suffix, target, "IMPORTED_LINK_INTERFACE_LANGUAGES", diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 06a4c6a..5d84309 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1172,9 +1172,11 @@ public: { return; } - + cmGeneratorTarget* gtgt = + this->Target->GetLocalGenerator()->GetGlobalGenerator() + ->GetGeneratorTarget(item.Target); cmLinkInterface const* iface = - item.Target->GetLinkInterface(this->Config, this->HeadTarget); + gtgt->GetLinkInterface(this->Config, this->HeadTarget); if(!iface) { return; } for(std::vector::const_iterator @@ -3354,3 +3356,52 @@ cmGeneratorTarget::ReportPropertyOrigin(const std::string &p, this->Makefile->GetCMakeInstance()->IssueMessage(cmake::LOG, areport); } + +//---------------------------------------------------------------------------- +cmLinkInterface const* +cmGeneratorTarget::GetLinkInterface(const std::string& config, + cmTarget const* head) const +{ + // Imported targets have their own link interface. + if(this->IsImported()) + { + return this->Target->GetImportLinkInterface(config, head, false); + } + + // Link interfaces are not supported for executables that do not + // export symbols. + if(this->GetType() == cmTarget::EXECUTABLE && + !this->Target->IsExecutableWithExports()) + { + return 0; + } + + // Lookup any existing link interface for this configuration. + cmHeadToLinkInterfaceMap& hm = + this->Target->GetHeadToLinkInterfaceMap(config); + + // If the link interface does not depend on the head target + // then return the one we computed first. + if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) + { + return &hm.begin()->second; + } + + cmOptionalLinkInterface& iface = hm[head]; + if(!iface.LibrariesDone) + { + iface.LibrariesDone = true; + this->Target->ComputeLinkInterfaceLibraries( + config, iface, head, false); + } + if(!iface.AllDone) + { + iface.AllDone = true; + if(iface.Exists) + { + this->Target->ComputeLinkInterface(config, iface, head); + } + } + + return iface.Exists? &iface : 0; +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 15b3335..2dbb502 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -12,7 +12,7 @@ #ifndef cmGeneratorTarget_h #define cmGeneratorTarget_h -#include "cmStandardIncludes.h" +#include "cmLinkItem.h" class cmCustomCommand; class cmGlobalGenerator; @@ -106,6 +106,8 @@ public: const char *GetLinkInterfaceDependentNumberMaxProperty(const std::string &p, const std::string& config) const; + cmLinkInterface const* GetLinkInterface(const std::string& config, + cmTarget const* headTarget) const; /** Get the full path to the target according to the settings in its makefile and the configuration type. */ diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index fb545b1..ee298ac 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4108,53 +4108,6 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, } //---------------------------------------------------------------------------- -cmLinkInterface const* cmTarget::GetLinkInterface(const std::string& config, - cmTarget const* head) const -{ - // Imported targets have their own link interface. - if(this->IsImported()) - { - return this->GetImportLinkInterface(config, head, false); - } - - // Link interfaces are not supported for executables that do not - // export symbols. - if(this->GetType() == cmTarget::EXECUTABLE && - !this->IsExecutableWithExports()) - { - return 0; - } - - // Lookup any existing link interface for this configuration. - cmHeadToLinkInterfaceMap& hm = this->GetHeadToLinkInterfaceMap(config); - - // If the link interface does not depend on the head target - // then return the one we computed first. - if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) - { - return &hm.begin()->second; - } - - cmOptionalLinkInterface& iface = hm[head]; - if(!iface.LibrariesDone) - { - iface.LibrariesDone = true; - this->ComputeLinkInterfaceLibraries( - config, iface, head, false); - } - if(!iface.AllDone) - { - iface.AllDone = true; - if(iface.Exists) - { - this->ComputeLinkInterface(config, iface, head); - } - } - - return iface.Exists? &iface : 0; -} - -//---------------------------------------------------------------------------- const cmLinkInterfaceLibraries * cmTarget::GetLinkInterfaceLibraries(const std::string& config, cmTarget const* head, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 53a8bd6..a8c6e8f 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -241,10 +241,6 @@ public: cmTarget const* head, bool usage_requirements_only) const; - /** Get the link interface for the given configuration. Returns 0 - if the target cannot be linked. */ - cmLinkInterface const* GetLinkInterface(const std::string& config, - cmTarget const* headTarget) const; cmLinkInterfaceLibraries const* GetLinkInterfaceLibraries(const std::string& config, cmTarget const* headTarget, http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6353816786caccfef7acb3fd72aa28e0366da405 commit 6353816786caccfef7acb3fd72aa28e0366da405 Author: Stephen Kelly AuthorDate: Wed Aug 26 19:37:32 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 26 19:37:32 2015 +0200 cmTarget: Add GetHeadToLinkInterfaceMap methods. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index a10cb86..fb545b1 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4126,9 +4126,7 @@ cmLinkInterface const* cmTarget::GetLinkInterface(const std::string& config, } // Lookup any existing link interface for this configuration. - std::string CONFIG = cmSystemTools::UpperCase(config); - cmHeadToLinkInterfaceMap& hm = - this->Internal->LinkInterfaceMap[CONFIG]; + cmHeadToLinkInterfaceMap& hm = this->GetHeadToLinkInterfaceMap(config); // If the link interface does not depend on the head target // then return the one we computed first. @@ -4177,11 +4175,10 @@ cmTarget::GetLinkInterfaceLibraries(const std::string& config, } // Lookup any existing link interface for this configuration. - std::string CONFIG = cmSystemTools::UpperCase(config); cmHeadToLinkInterfaceMap& hm = (usage_requirements_only ? - this->Internal->LinkInterfaceUsageRequirementsOnlyMap[CONFIG] : - this->Internal->LinkInterfaceMap[CONFIG]); + this->GetHeadToLinkInterfaceUsageRequirementsMap(config) : + this->GetHeadToLinkInterfaceMap(config)); // If the link interface does not depend on the head target // then return the one we computed first. @@ -4201,6 +4198,21 @@ cmTarget::GetLinkInterfaceLibraries(const std::string& config, return iface.Exists? &iface : 0; } +cmHeadToLinkInterfaceMap& +cmTarget::GetHeadToLinkInterfaceMap(const std::string &config) const +{ + std::string CONFIG = cmSystemTools::UpperCase(config); + return this->Internal->LinkInterfaceMap[CONFIG]; +} + +cmHeadToLinkInterfaceMap& +cmTarget::GetHeadToLinkInterfaceUsageRequirementsMap( + const std::string &config) const +{ + std::string CONFIG = cmSystemTools::UpperCase(config); + return this->Internal->LinkInterfaceUsageRequirementsOnlyMap[CONFIG]; +} + //---------------------------------------------------------------------------- const cmLinkInterface * cmTarget::GetImportLinkInterface(const std::string& config, @@ -4216,8 +4228,8 @@ cmTarget::GetImportLinkInterface(const std::string& config, std::string CONFIG = cmSystemTools::UpperCase(config); cmHeadToLinkInterfaceMap& hm = (usage_requirements_only ? - this->Internal->LinkInterfaceUsageRequirementsOnlyMap[CONFIG] : - this->Internal->LinkInterfaceMap[CONFIG]); + this->GetHeadToLinkInterfaceUsageRequirementsMap(config) : + this->GetHeadToLinkInterfaceMap(config)); // If the link interface does not depend on the head target // then return the one we computed first. diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 563caf8..53a8bd6 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -250,6 +250,11 @@ public: cmTarget const* headTarget, bool usage_requirements_only) const; + cmHeadToLinkInterfaceMap& + GetHeadToLinkInterfaceMap(std::string const& config) const; + cmHeadToLinkInterfaceMap& GetHeadToLinkInterfaceUsageRequirementsMap( + std::string const& config) const; + struct LinkImplementation: public cmLinkImplementationLibraries { // Languages whose runtime libraries must be linked. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=20993de46444e0f74700a641b54a8ca7e015bac4 commit 20993de46444e0f74700a641b54a8ca7e015bac4 Author: Stephen Kelly AuthorDate: Wed Aug 26 19:37:06 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 26 19:37:06 2015 +0200 cmTarget: Move cmHeadToLinkInterfaceMap out. diff --git a/Source/cmLinkItem.h b/Source/cmLinkItem.h index eb585ab..91220b8 100644 --- a/Source/cmLinkItem.h +++ b/Source/cmLinkItem.h @@ -96,4 +96,9 @@ struct cmOptionalLinkInterface: public cmLinkInterface const char* ExplicitLibraries; }; +struct cmHeadToLinkInterfaceMap: + public std::map +{ +}; + #endif diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 60453e1..a10cb86 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -91,9 +91,7 @@ public: // The backtrace when the target was created. cmListFileBacktrace Backtrace; - struct HeadToLinkInterfaceMap: - public std::map {}; - typedef std::map + typedef std::map LinkInterfaceMapType; LinkInterfaceMapType LinkInterfaceMap; LinkInterfaceMapType LinkInterfaceUsageRequirementsOnlyMap; @@ -4129,7 +4127,7 @@ cmLinkInterface const* cmTarget::GetLinkInterface(const std::string& config, // Lookup any existing link interface for this configuration. std::string CONFIG = cmSystemTools::UpperCase(config); - cmTargetInternals::HeadToLinkInterfaceMap& hm = + cmHeadToLinkInterfaceMap& hm = this->Internal->LinkInterfaceMap[CONFIG]; // If the link interface does not depend on the head target @@ -4180,7 +4178,7 @@ cmTarget::GetLinkInterfaceLibraries(const std::string& config, // Lookup any existing link interface for this configuration. std::string CONFIG = cmSystemTools::UpperCase(config); - cmTargetInternals::HeadToLinkInterfaceMap& hm = + cmHeadToLinkInterfaceMap& hm = (usage_requirements_only ? this->Internal->LinkInterfaceUsageRequirementsOnlyMap[CONFIG] : this->Internal->LinkInterfaceMap[CONFIG]); @@ -4216,7 +4214,7 @@ cmTarget::GetImportLinkInterface(const std::string& config, } std::string CONFIG = cmSystemTools::UpperCase(config); - cmTargetInternals::HeadToLinkInterfaceMap& hm = + cmHeadToLinkInterfaceMap& hm = (usage_requirements_only ? this->Internal->LinkInterfaceUsageRequirementsOnlyMap[CONFIG] : this->Internal->LinkInterfaceMap[CONFIG]); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f8ca51a054732d5b0e2c6052ee102b748bd5848c commit f8ca51a054732d5b0e2c6052ee102b748bd5848c Author: Stephen Kelly AuthorDate: Wed Aug 26 19:36:13 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 26 19:36:13 2015 +0200 cmGeneratorTarget: Move ComputeLinkInterface from cmTarget. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 974aff5..60453e1 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -91,16 +91,6 @@ public: // The backtrace when the target was created. cmListFileBacktrace Backtrace; - void ComputeLinkInterface(cmTarget const* thisTarget, - const std::string& config, - cmOptionalLinkInterface& iface, - cmTarget const* head) const; - void ComputeLinkInterfaceLibraries(cmTarget const* thisTarget, - const std::string& config, - cmOptionalLinkInterface &iface, - cmTarget const* head, - bool usage_requirements_only); - struct HeadToLinkInterfaceMap: public std::map {}; typedef std::map @@ -4153,15 +4143,15 @@ cmLinkInterface const* cmTarget::GetLinkInterface(const std::string& config, if(!iface.LibrariesDone) { iface.LibrariesDone = true; - this->Internal->ComputeLinkInterfaceLibraries( - this, config, iface, head, false); + this->ComputeLinkInterfaceLibraries( + config, iface, head, false); } if(!iface.AllDone) { iface.AllDone = true; if(iface.Exists) { - this->Internal->ComputeLinkInterface(this, config, iface, head); + this->ComputeLinkInterface(config, iface, head); } } @@ -4206,8 +4196,8 @@ cmTarget::GetLinkInterfaceLibraries(const std::string& config, if(!iface.LibrariesDone) { iface.LibrariesDone = true; - this->Internal->ComputeLinkInterfaceLibraries( - this, config, iface, head, usage_requirements_only); + this->ComputeLinkInterfaceLibraries( + config, iface, head, usage_requirements_only); } return iface.Exists? &iface : 0; @@ -4258,12 +4248,11 @@ cmTarget::GetImportLinkInterface(const std::string& config, //---------------------------------------------------------------------------- void -cmTargetInternals::ComputeLinkInterfaceLibraries( - cmTarget const* thisTarget, +cmTarget::ComputeLinkInterfaceLibraries( const std::string& config, cmOptionalLinkInterface& iface, cmTarget const* headTarget, - bool usage_requirements_only) + bool usage_requirements_only) const { // Construct the property name suffix for this configuration. std::string suffix = "_"; @@ -4280,15 +4269,15 @@ cmTargetInternals::ComputeLinkInterfaceLibraries( // libraries and executables that export symbols. const char* explicitLibraries = 0; std::string linkIfaceProp; - if(thisTarget->GetPolicyStatusCMP0022() != cmPolicies::OLD && - thisTarget->GetPolicyStatusCMP0022() != cmPolicies::WARN) + if(this->GetPolicyStatusCMP0022() != cmPolicies::OLD && + this->GetPolicyStatusCMP0022() != cmPolicies::WARN) { // CMP0022 NEW behavior is to use INTERFACE_LINK_LIBRARIES. linkIfaceProp = "INTERFACE_LINK_LIBRARIES"; - explicitLibraries = thisTarget->GetProperty(linkIfaceProp); + explicitLibraries = this->GetProperty(linkIfaceProp); } - else if(thisTarget->GetType() == cmTarget::SHARED_LIBRARY || - thisTarget->IsExecutableWithExports()) + else if(this->GetType() == cmTarget::SHARED_LIBRARY || + this->IsExecutableWithExports()) { // CMP0022 OLD behavior is to use LINK_INTERFACE_LIBRARIES if set on a // shared lib or executable. @@ -4296,30 +4285,30 @@ cmTargetInternals::ComputeLinkInterfaceLibraries( // Lookup the per-configuration property. linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; linkIfaceProp += suffix; - explicitLibraries = thisTarget->GetProperty(linkIfaceProp); + explicitLibraries = this->GetProperty(linkIfaceProp); // If not set, try the generic property. if(!explicitLibraries) { linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; - explicitLibraries = thisTarget->GetProperty(linkIfaceProp); + explicitLibraries = this->GetProperty(linkIfaceProp); } } if(explicitLibraries && - thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN && - !this->PolicyWarnedCMP0022) + this->GetPolicyStatusCMP0022() == cmPolicies::WARN && + !this->Internal->PolicyWarnedCMP0022) { // Compare the explicitly set old link interface properties to the // preferred new link interface property one and warn if different. const char* newExplicitLibraries = - thisTarget->GetProperty("INTERFACE_LINK_LIBRARIES"); + this->GetProperty("INTERFACE_LINK_LIBRARIES"); if (newExplicitLibraries && strcmp(newExplicitLibraries, explicitLibraries) != 0) { std::ostringstream w; w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n" - "Target \"" << thisTarget->GetName() << "\" has an " + "Target \"" << this->GetName() << "\" has an " "INTERFACE_LINK_LIBRARIES property which differs from its " << linkIfaceProp << " properties." "\n" @@ -4327,16 +4316,16 @@ cmTargetInternals::ComputeLinkInterfaceLibraries( " " << newExplicitLibraries << "\n" << linkIfaceProp << ":\n" " " << (explicitLibraries ? explicitLibraries : "(empty)") << "\n"; - thisTarget->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); - this->PolicyWarnedCMP0022 = true; + this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + this->Internal->PolicyWarnedCMP0022 = true; } } // There is no implicit link interface for executables or modules // so if none was explicitly set then there is no link interface. if(!explicitLibraries && - (thisTarget->GetType() == cmTarget::EXECUTABLE || - (thisTarget->GetType() == cmTarget::MODULE_LIBRARY))) + (this->GetType() == cmTarget::EXECUTABLE || + (this->GetType() == cmTarget::MODULE_LIBRARY))) { return; } @@ -4346,13 +4335,13 @@ cmTargetInternals::ComputeLinkInterfaceLibraries( if(explicitLibraries) { // The interface libraries have been explicitly set. - thisTarget->ExpandLinkItems(linkIfaceProp, explicitLibraries, config, + this->ExpandLinkItems(linkIfaceProp, explicitLibraries, config, headTarget, usage_requirements_only, iface.Libraries, iface.HadHeadSensitiveCondition); } - else if (thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN - || thisTarget->GetPolicyStatusCMP0022() == cmPolicies::OLD) + else if (this->GetPolicyStatusCMP0022() == cmPolicies::WARN + || this->GetPolicyStatusCMP0022() == cmPolicies::OLD) // If CMP0022 is NEW then the plain tll signature sets the // INTERFACE_LINK_LIBRARIES, so if we get here then the project // cleared the property explicitly and we should not fall back @@ -4360,20 +4349,20 @@ cmTargetInternals::ComputeLinkInterfaceLibraries( { // The link implementation is the default link interface. cmLinkImplementationLibraries const* impl = - thisTarget->GetLinkImplementationLibrariesInternal(config, headTarget); + this->GetLinkImplementationLibrariesInternal(config, headTarget); iface.Libraries.insert(iface.Libraries.end(), impl->Libraries.begin(), impl->Libraries.end()); - if(thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN && - !this->PolicyWarnedCMP0022 && !usage_requirements_only) + if(this->GetPolicyStatusCMP0022() == cmPolicies::WARN && + !this->Internal->PolicyWarnedCMP0022 && !usage_requirements_only) { // Compare the link implementation fallback link interface to the // preferred new link interface property and warn if different. std::vector ifaceLibs; static const std::string newProp = "INTERFACE_LINK_LIBRARIES"; - if(const char* newExplicitLibraries = thisTarget->GetProperty(newProp)) + if(const char* newExplicitLibraries = this->GetProperty(newProp)) { bool hadHeadSensitiveConditionDummy = false; - thisTarget->ExpandLinkItems(newProp, newExplicitLibraries, config, + this->ExpandLinkItems(newProp, newExplicitLibraries, config, headTarget, usage_requirements_only, ifaceLibs, hadHeadSensitiveConditionDummy); } @@ -4388,7 +4377,7 @@ cmTargetInternals::ComputeLinkInterfaceLibraries( std::ostringstream w; w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n" - "Target \"" << thisTarget->GetName() << "\" has an " + "Target \"" << this->GetName() << "\" has an " "INTERFACE_LINK_LIBRARIES property. " "This should be preferred as the source of the link interface " "for this library but because CMP0022 is not set CMake is " @@ -4399,24 +4388,23 @@ cmTargetInternals::ComputeLinkInterfaceLibraries( " " << newLibraries << "\n" "Link implementation:\n" " " << oldLibraries << "\n"; - thisTarget->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); - this->PolicyWarnedCMP0022 = true; + this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + this->Internal->PolicyWarnedCMP0022 = true; } } } } //---------------------------------------------------------------------------- -void cmTargetInternals::ComputeLinkInterface(cmTarget const* thisTarget, - const std::string& config, - cmOptionalLinkInterface &iface, - cmTarget const* headTarget) const +void cmTarget::ComputeLinkInterface(const std::string& config, + cmOptionalLinkInterface &iface, + cmTarget const* headTarget) const { if(iface.ExplicitLibraries) { - if(thisTarget->GetType() == cmTarget::SHARED_LIBRARY - || thisTarget->GetType() == cmTarget::STATIC_LIBRARY - || thisTarget->GetType() == cmTarget::INTERFACE_LIBRARY) + if(this->GetType() == cmTarget::SHARED_LIBRARY + || this->GetType() == cmTarget::STATIC_LIBRARY + || this->GetType() == cmTarget::INTERFACE_LIBRARY) { // Shared libraries may have runtime implementation dependencies // on other shared libraries that are not in the interface. @@ -4426,10 +4414,10 @@ void cmTargetInternals::ComputeLinkInterface(cmTarget const* thisTarget, { emitted.insert(*li); } - if (thisTarget->GetType() != cmTarget::INTERFACE_LIBRARY) + if (this->GetType() != cmTarget::INTERFACE_LIBRARY) { cmTarget::LinkImplementation const* impl = - thisTarget->GetLinkImplementation(config); + this->GetLinkImplementation(config); for(std::vector::const_iterator li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li) { @@ -4455,28 +4443,28 @@ void cmTargetInternals::ComputeLinkInterface(cmTarget const* thisTarget, } } } - else if (thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN - || thisTarget->GetPolicyStatusCMP0022() == cmPolicies::OLD) + else if (this->GetPolicyStatusCMP0022() == cmPolicies::WARN + || this->GetPolicyStatusCMP0022() == cmPolicies::OLD) { // The link implementation is the default link interface. cmLinkImplementationLibraries const* - impl = thisTarget->GetLinkImplementationLibrariesInternal(config, + impl = this->GetLinkImplementationLibrariesInternal(config, headTarget); iface.ImplementationIsInterface = true; iface.WrongConfigLibraries = impl->WrongConfigLibraries; } - if(thisTarget->LinkLanguagePropagatesToDependents()) + if(this->LinkLanguagePropagatesToDependents()) { // Targets using this archive need its language runtime libraries. if(cmTarget::LinkImplementation const* impl = - thisTarget->GetLinkImplementation(config)) + this->GetLinkImplementation(config)) { iface.Languages = impl->Languages; } } - if(thisTarget->GetType() == cmTarget::STATIC_LIBRARY) + if(this->GetType() == cmTarget::STATIC_LIBRARY) { // Construct the property name suffix for this configuration. std::string suffix = "_"; @@ -4493,12 +4481,12 @@ void cmTargetInternals::ComputeLinkInterface(cmTarget const* thisTarget, // dependencies? std::string propName = "LINK_INTERFACE_MULTIPLICITY"; propName += suffix; - if(const char* config_reps = thisTarget->GetProperty(propName)) + if(const char* config_reps = this->GetProperty(propName)) { sscanf(config_reps, "%u", &iface.Multiplicity); } else if(const char* reps = - thisTarget->GetProperty("LINK_INTERFACE_MULTIPLICITY")) + this->GetProperty("LINK_INTERFACE_MULTIPLICITY")) { sscanf(reps, "%u", &iface.Multiplicity); } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 8594e05..563caf8 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -233,6 +233,14 @@ public: void GetObjectLibrariesCMP0026(std::vector& objlibs) const; + void ComputeLinkInterface(const std::string& config, + cmOptionalLinkInterface& iface, + cmTarget const* head) const; + void ComputeLinkInterfaceLibraries(const std::string& config, + cmOptionalLinkInterface &iface, + cmTarget const* head, + bool usage_requirements_only) const; + /** Get the link interface for the given configuration. Returns 0 if the target cannot be linked. */ cmLinkInterface const* GetLinkInterface(const std::string& config, http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d67584ccc4262c103a180504cb294e3ad6b6910d commit d67584ccc4262c103a180504cb294e3ad6b6910d Author: Stephen Kelly AuthorDate: Wed Aug 26 19:35:45 2015 +0200 Commit: Stephen Kelly CommitDate: Wed Aug 26 19:35:45 2015 +0200 cmTarget: Move link interface libraries struct out. diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 59590fd..03ec820 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -361,7 +361,7 @@ void cmComputeLinkDepends::FollowLinkEntry(BFSEntry const& qe) if(entry.Target) { // Follow the target dependencies. - if(cmTarget::LinkInterface const* iface = + if(cmLinkInterface const* iface = entry.Target->GetLinkInterface(this->Config, this->Target->Target)) { const bool isIface = @@ -396,7 +396,7 @@ void cmComputeLinkDepends::FollowLinkEntry(BFSEntry const& qe) //---------------------------------------------------------------------------- void cmComputeLinkDepends -::FollowSharedDeps(int depender_index, cmTarget::LinkInterface const* iface, +::FollowSharedDeps(int depender_index, cmLinkInterface const* iface, bool follow_interface) { // Follow dependencies if we have not followed them already. @@ -459,7 +459,7 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep) // Target items may have their own dependencies. if(entry.Target) { - if(cmTarget::LinkInterface const* iface = + if(cmLinkInterface const* iface = entry.Target->GetLinkInterface(this->Config, this->Target->Target)) { // Follow public and private dependencies transitively. @@ -930,7 +930,7 @@ int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl) { if(cmTarget const* target = this->EntryList[*ni].Target) { - if(cmTarget::LinkInterface const* iface = + if(cmLinkInterface const* iface = target->GetLinkInterface(this->Config, this->Target->Target)) { if(iface->Multiplicity > count) diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index b925a4f..2cbb430 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -102,7 +102,7 @@ private: std::queue SharedDepQueue; std::set SharedDepFollowed; void FollowSharedDeps(int depender_index, - cmTarget::LinkInterface const* iface, + cmLinkInterface const* iface, bool follow_interface = false); void QueueSharedDependencies(int depender_index, std::vector const& deps); diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index c4a03a0..aeb9184 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -296,7 +296,7 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, std::set &emitted) { cmGeneratorTarget const* depender = this->Targets[depender_index]; - if(cmTarget::LinkInterface const* iface = + if(cmLinkInterface const* iface = dependee->Target->GetLinkInterface(config, depender->Target)) { diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index cae60b7..d559a07 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -796,7 +796,7 @@ cmExportFileGenerator std::vector& missingTargets) { // Add the transitive link dependencies for this configuration. - cmTarget::LinkInterface const* iface = target->Target->GetLinkInterface( + cmLinkInterface const* iface = target->Target->GetLinkInterface( config, target->Target); if (!iface) @@ -909,7 +909,7 @@ cmExportFileGenerator } // Add the transitive link dependencies for this configuration. - if(cmTarget::LinkInterface const* iface = + if(cmLinkInterface const* iface = target->Target ->GetLinkInterface(config, target->Target)) { diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 03bc83a..9509c2b 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1108,7 +1108,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode if(isInterfaceProperty) { - if(cmTarget::LinkInterfaceLibraries const* iface = + if(cmLinkInterfaceLibraries const* iface = target->GetLinkInterfaceLibraries(context->Config, headTarget, true)) { linkedTargetsContent = diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index dd58e7b..06a4c6a 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1173,7 +1173,7 @@ public: return; } - cmTarget::LinkInterface const* iface = + cmLinkInterface const* iface = item.Target->GetLinkInterface(this->Config, this->HeadTarget); if(!iface) { return; } @@ -1511,7 +1511,7 @@ void processILibs(const std::string& config, if (item.Target && emitted.insert(item.Target).second) { tgts.push_back(item.Target); - if(cmTarget::LinkInterfaceLibraries const* iface = + if(cmLinkInterfaceLibraries const* iface = item.Target->GetLinkInterfaceLibraries(config, headTarget, true)) { for(std::vector::const_iterator diff --git a/Source/cmLinkItem.h b/Source/cmLinkItem.h index a5427de..eb585ab 100644 --- a/Source/cmLinkItem.h +++ b/Source/cmLinkItem.h @@ -56,4 +56,44 @@ struct cmLinkImplementationLibraries std::vector WrongConfigLibraries; }; +struct cmLinkInterfaceLibraries +{ + // Libraries listed in the interface. + std::vector Libraries; +}; + +struct cmLinkInterface: public cmLinkInterfaceLibraries +{ + // Languages whose runtime libraries must be linked. + std::vector Languages; + + // Shared library dependencies needed for linking on some platforms. + std::vector SharedDeps; + + // Number of repetitions of a strongly connected component of two + // or more static libraries. + int Multiplicity; + + // Libraries listed for other configurations. + // Needed only for OLD behavior of CMP0003. + std::vector WrongConfigLibraries; + + bool ImplementationIsInterface; + + cmLinkInterface(): Multiplicity(0), ImplementationIsInterface(false) {} +}; + +struct cmOptionalLinkInterface: public cmLinkInterface +{ + cmOptionalLinkInterface(): + LibrariesDone(false), AllDone(false), + Exists(false), HadHeadSensitiveCondition(false), + ExplicitLibraries(0) {} + bool LibrariesDone; + bool AllDone; + bool Exists; + bool HadHeadSensitiveCondition; + const char* ExplicitLibraries; +}; + #endif diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 49b3239..974aff5 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -91,31 +91,18 @@ public: // The backtrace when the target was created. cmListFileBacktrace Backtrace; - // Cache link interface computation from each configuration. - struct OptionalLinkInterface: public cmTarget::LinkInterface - { - OptionalLinkInterface(): - LibrariesDone(false), AllDone(false), - Exists(false), HadHeadSensitiveCondition(false), - ExplicitLibraries(0) {} - bool LibrariesDone; - bool AllDone; - bool Exists; - bool HadHeadSensitiveCondition; - const char* ExplicitLibraries; - }; void ComputeLinkInterface(cmTarget const* thisTarget, const std::string& config, - OptionalLinkInterface& iface, + cmOptionalLinkInterface& iface, cmTarget const* head) const; void ComputeLinkInterfaceLibraries(cmTarget const* thisTarget, const std::string& config, - OptionalLinkInterface& iface, + cmOptionalLinkInterface &iface, cmTarget const* head, bool usage_requirements_only); struct HeadToLinkInterfaceMap: - public std::map {}; + public std::map {}; typedef std::map LinkInterfaceMapType; LinkInterfaceMapType LinkInterfaceMap; @@ -4133,8 +4120,7 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, } //---------------------------------------------------------------------------- -cmTarget::LinkInterface const* cmTarget::GetLinkInterface( - const std::string& config, +cmLinkInterface const* cmTarget::GetLinkInterface(const std::string& config, cmTarget const* head) const { // Imported targets have their own link interface. @@ -4163,7 +4149,7 @@ cmTarget::LinkInterface const* cmTarget::GetLinkInterface( return &hm.begin()->second; } - cmTargetInternals::OptionalLinkInterface& iface = hm[head]; + cmOptionalLinkInterface& iface = hm[head]; if(!iface.LibrariesDone) { iface.LibrariesDone = true; @@ -4183,7 +4169,7 @@ cmTarget::LinkInterface const* cmTarget::GetLinkInterface( } //---------------------------------------------------------------------------- -cmTarget::LinkInterfaceLibraries const* +const cmLinkInterfaceLibraries * cmTarget::GetLinkInterfaceLibraries(const std::string& config, cmTarget const* head, bool usage_requirements_only) const @@ -4216,7 +4202,7 @@ cmTarget::GetLinkInterfaceLibraries(const std::string& config, return &hm.begin()->second; } - cmTargetInternals::OptionalLinkInterface& iface = hm[head]; + cmOptionalLinkInterface& iface = hm[head]; if(!iface.LibrariesDone) { iface.LibrariesDone = true; @@ -4228,7 +4214,7 @@ cmTarget::GetLinkInterfaceLibraries(const std::string& config, } //---------------------------------------------------------------------------- -cmTarget::LinkInterface const* +const cmLinkInterface * cmTarget::GetImportLinkInterface(const std::string& config, cmTarget const* headTarget, bool usage_requirements_only) const @@ -4252,7 +4238,7 @@ cmTarget::GetImportLinkInterface(const std::string& config, return &hm.begin()->second; } - cmTargetInternals::OptionalLinkInterface& iface = hm[headTarget]; + cmOptionalLinkInterface& iface = hm[headTarget]; if(!iface.AllDone) { iface.AllDone = true; @@ -4275,7 +4261,7 @@ void cmTargetInternals::ComputeLinkInterfaceLibraries( cmTarget const* thisTarget, const std::string& config, - OptionalLinkInterface& iface, + cmOptionalLinkInterface& iface, cmTarget const* headTarget, bool usage_requirements_only) { @@ -4423,7 +4409,7 @@ cmTargetInternals::ComputeLinkInterfaceLibraries( //---------------------------------------------------------------------------- void cmTargetInternals::ComputeLinkInterface(cmTarget const* thisTarget, const std::string& config, - OptionalLinkInterface& iface, + cmOptionalLinkInterface &iface, cmTarget const* headTarget) const { if(iface.ExplicitLibraries) diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 2007b40..8594e05 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -233,39 +233,11 @@ public: void GetObjectLibrariesCMP0026(std::vector& objlibs) const; - /** The link interface specifies transitive library dependencies and - other information needed by targets that link to this target. */ - struct LinkInterfaceLibraries - { - // Libraries listed in the interface. - std::vector Libraries; - }; - struct LinkInterface: public LinkInterfaceLibraries - { - // Languages whose runtime libraries must be linked. - std::vector Languages; - - // Shared library dependencies needed for linking on some platforms. - std::vector SharedDeps; - - // Number of repetitions of a strongly connected component of two - // or more static libraries. - int Multiplicity; - - // Libraries listed for other configurations. - // Needed only for OLD behavior of CMP0003. - std::vector WrongConfigLibraries; - - bool ImplementationIsInterface; - - LinkInterface(): Multiplicity(0), ImplementationIsInterface(false) {} - }; - /** Get the link interface for the given configuration. Returns 0 if the target cannot be linked. */ - LinkInterface const* GetLinkInterface(const std::string& config, + cmLinkInterface const* GetLinkInterface(const std::string& config, cmTarget const* headTarget) const; - LinkInterfaceLibraries const* + cmLinkInterfaceLibraries const* GetLinkInterfaceLibraries(const std::string& config, cmTarget const* headTarget, bool usage_requirements_only) const; @@ -592,7 +564,7 @@ private: ImportInfo& info) const; - LinkInterface const* + cmLinkInterface const* GetImportLinkInterface(const std::string& config, cmTarget const* head, bool usage_requirements_only) const; ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- Source/cmComputeLinkDepends.cxx | 24 +- Source/cmComputeLinkDepends.h | 2 +- Source/cmComputeLinkInformation.cxx | 2 +- Source/cmComputeTargetDepends.cxx | 7 +- Source/cmExportFileGenerator.cxx | 10 +- Source/cmExtraCodeBlocksGenerator.cxx | 2 +- Source/cmGeneratorExpressionNode.cxx | 4 +- Source/cmGeneratorTarget.cxx | 1221 +++++++++++++++++++++++- Source/cmGeneratorTarget.h | 81 +- Source/cmGhsMultiTargetGenerator.cxx | 9 +- Source/cmGlobalGenerator.cxx | 1 - Source/cmGlobalUnixMakefileGenerator3.cxx | 3 +- Source/cmGlobalVisualStudio8Generator.cxx | 2 +- Source/cmGlobalVisualStudioGenerator.cxx | 8 +- Source/cmGlobalXCodeGenerator.cxx | 25 +- Source/cmLinkItem.h | 62 ++ Source/cmLocalGenerator.cxx | 13 +- Source/cmLocalUnixMakefileGenerator3.cxx | 4 +- Source/cmLocalVisualStudio6Generator.cxx | 5 +- Source/cmLocalVisualStudio7Generator.cxx | 9 +- Source/cmMakefileTargetGenerator.cxx | 2 +- Source/cmQtAutoGenerators.cxx | 16 +- Source/cmTarget.cxx | 1433 +++------------------------- Source/cmTarget.h | 107 +-- Source/cmVisualStudio10TargetGenerator.cxx | 4 +- 26 files changed, 1607 insertions(+), 1451 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Thu Aug 27 00:01:09 2015 From: kwrobot at kitware.com (Kitware Robot) Date: Thu, 27 Aug 2015 00:01:09 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-946-g81ad562 Message-ID: <20150827040109.1C243B22F6@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 81ad5622b486cd246d2407448461517b21787cf6 (commit) from 33df7f36d0b99a87880ee76d39b5814c98e78bd1 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=81ad5622b486cd246d2407448461517b21787cf6 commit 81ad5622b486cd246d2407448461517b21787cf6 Author: Kitware Robot AuthorDate: Thu Aug 27 00:01:06 2015 -0400 Commit: Kitware Robot CommitDate: Thu Aug 27 00:01:06 2015 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index aa25287..1894b69 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150826) +set(CMake_VERSION_PATCH 20150827) #set(CMake_VERSION_RC 1) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 27 10:03:58 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 27 Aug 2015 10:03:58 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-948-gef0bf87 Message-ID: <20150827140358.3E32FB2840@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via ef0bf87939d40c3a42129c82e3233fd9a27a5da8 (commit) via 4476feac33a88942ebbe2d988c7db4a575de716f (commit) from 81ad5622b486cd246d2407448461517b21787cf6 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ef0bf87939d40c3a42129c82e3233fd9a27a5da8 commit ef0bf87939d40c3a42129c82e3233fd9a27a5da8 Merge: 81ad562 4476fea Author: Brad King AuthorDate: Thu Aug 27 10:03:56 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 27 10:03:56 2015 -0400 Merge topic 'java-updates' 4476feac UseJava: Add support for javah tool ----------------------------------------------------------------------- Summary of changes: Help/release/dev/java-updates.rst | 3 + Modules/UseJava.cmake | 157 ++++++++++++++++++++ Tests/CMakeLists.txt | 25 ++++ Tests/JavaJavah/B.cpp | 10 ++ Tests/JavaJavah/B.java | 19 +++ Tests/JavaJavah/CMakeLists.txt | 20 +++ .../HelloWorld.java => JavaJavah/HelloWorld2.java} | 9 +- 7 files changed, 238 insertions(+), 5 deletions(-) create mode 100644 Tests/JavaJavah/B.cpp create mode 100644 Tests/JavaJavah/B.java create mode 100644 Tests/JavaJavah/CMakeLists.txt copy Tests/{Java/HelloWorld.java => JavaJavah/HelloWorld2.java} (57%) hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 27 10:04:00 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 27 Aug 2015 10:04:00 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-950-gba6533e Message-ID: <20150827140400.86AC6B2845@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via ba6533e658f63d9446993882788f03263d32fe1b (commit) via 67f60958b61941264b0e2a63ad527dd346a6b1e3 (commit) from ef0bf87939d40c3a42129c82e3233fd9a27a5da8 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ba6533e658f63d9446993882788f03263d32fe1b commit ba6533e658f63d9446993882788f03263d32fe1b Merge: ef0bf87 67f6095 Author: Brad King AuthorDate: Thu Aug 27 10:03:58 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 27 10:03:58 2015 -0400 Merge topic 'apple-tbd-stubs' 67f60958 Darwin: Add support for tbd library stub files ----------------------------------------------------------------------- Summary of changes: Modules/Platform/Darwin.cmake | 2 +- Tests/RunCMake/XcodeProject/RunCMakeTest.cmake | 6 ++++++ Tests/RunCMake/XcodeProject/XcodeTbdStub-stdout.txt | 1 + Tests/RunCMake/XcodeProject/XcodeTbdStub.cmake | 2 ++ Tests/RunCMake/XcodeProject/osx.cmake | 18 ++++++++++++++++++ 5 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 Tests/RunCMake/XcodeProject/XcodeTbdStub-stdout.txt create mode 100644 Tests/RunCMake/XcodeProject/XcodeTbdStub.cmake create mode 100644 Tests/RunCMake/XcodeProject/osx.cmake hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 27 10:04:02 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 27 Aug 2015 10:04:02 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-952-gf96b6af Message-ID: <20150827140402.81B67B2842@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via f96b6af18aebc5791047bc6d7b33375ac570c6e9 (commit) via 290b0f94b597f5a833f59cc8f70f1627bf8d1aa9 (commit) from ba6533e658f63d9446993882788f03263d32fe1b (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f96b6af18aebc5791047bc6d7b33375ac570c6e9 commit f96b6af18aebc5791047bc6d7b33375ac570c6e9 Merge: ba6533e 290b0f9 Author: Brad King AuthorDate: Thu Aug 27 10:04:01 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 27 10:04:01 2015 -0400 Merge topic 'FindJNI-suse-and-ibm' 290b0f94 FindJNI: Add support for SuSE platform and IBM Java SDK ----------------------------------------------------------------------- Summary of changes: Modules/FindJNI.cmake | 8 ++++++++ 1 file changed, 8 insertions(+) hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 27 10:04:04 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 27 Aug 2015 10:04:04 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-961-g2985b9c Message-ID: <20150827140404.9361BB284B@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 2985b9c00348c81d3cba9603e50a22da4e54cefa (commit) via 7fbc56ac400fe7aaafaa581bca2f2848287ce7fd (commit) via 65c434e1b0247a47df763a616d1c8fdb20daba5c (commit) via be56feb6184e80eab5ce93b5ab81308452a5559f (commit) via 45f52003962f2f5ae58be2dd779f441bb4ca01f7 (commit) via af9fc277536f37980ccdab699a934b3c42e9fba9 (commit) via 9b44018d520cfabc347d6d79cafdf0a37c62b4e0 (commit) via 5f05b56284f9a76aa90562186aebd383a3ca9349 (commit) via 95925a60fce8a7b60fbea9873d9bb9fadf47cd02 (commit) from f96b6af18aebc5791047bc6d7b33375ac570c6e9 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2985b9c00348c81d3cba9603e50a22da4e54cefa commit 2985b9c00348c81d3cba9603e50a22da4e54cefa Merge: f96b6af 7fbc56a Author: Brad King AuthorDate: Thu Aug 27 10:04:03 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 27 10:04:03 2015 -0400 Merge topic 'refactor-progress' 7fbc56ac cmGlobalUnixMakefileGenerator3: Implement progress in terms of cmState. 65c434e1 cmGlobalUnixMakefileGenerator3: Inline an IsExcluded call. be56feb6 cmGlobalGenerator: Extract new IsExcluded overload. 45f52003 cmGlobalGenerator: Implement IsExcluded in terms of cmState::Snapshot. af9fc277 cmState: Make Snapshot EqualityComparable. 9b44018d cmGlobalGenerator: Convert IsExcluded to loop. 5f05b562 cmGlobalGenerator: Refactor IsExcluded. 95925a60 cmGlobalGenerator: Don't use else after return. ----------------------------------------------------------------------- Summary of changes: Source/cmGlobalGenerator.cxx | 48 +++++++++++++++++------------ Source/cmGlobalGenerator.h | 2 ++ Source/cmGlobalUnixMakefileGenerator3.cxx | 17 ++++++++-- Source/cmState.cxx | 10 ++++++ Source/cmState.h | 7 +++++ 5 files changed, 62 insertions(+), 22 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 27 10:04:06 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 27 Aug 2015 10:04:06 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-966-ga97bb6a Message-ID: <20150827140406.B2A98B284B@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via a97bb6ae3f70febd207ef2373287237249f082e5 (commit) via e3078aa15328439e239b2beb4085dc644ec465ec (commit) via 7441fde34abf5a3eab58917b8bf4acb89d72c00c (commit) via ad0b0089ab9f094192f6109067d79ef5e66c85b7 (commit) via 314c9ae33bfd304c9622b89ec62bca052f6e0d39 (commit) from 2985b9c00348c81d3cba9603e50a22da4e54cefa (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a97bb6ae3f70febd207ef2373287237249f082e5 commit a97bb6ae3f70febd207ef2373287237249f082e5 Merge: 2985b9c e3078aa Author: Brad King AuthorDate: Thu Aug 27 10:04:05 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 27 10:04:05 2015 -0400 Merge topic 'refactor-features' e3078aa1 cmLocalGenerator: Implement GetFeature in terms of cmState. 7441fde3 cmLocalGenerator: Convert GetFeature recursion to loop. ad0b0089 cmLocalGenerator: Simplify GetFeature implementation. 314c9ae3 cmLocalGenerator: Make GetFeature tail-recursive. ----------------------------------------------------------------------- Summary of changes: Source/cmLocalGenerator.cxx | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 27 10:04:08 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 27 Aug 2015 10:04:08 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-972-g6904b6e Message-ID: <20150827140408.F0DDAB2864@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 6904b6efdc2ea35c3490ba33cb352b03ea3085f5 (commit) via 867b5be8b89c9b4f18ea604e1c61a154d0335c4c (commit) via 6c832219eadb6062c5026817ed86b81e583c8e5d (commit) via 3fcf383763e80b90e30fa06b29e0751ca19ab983 (commit) via 223f4a662fbe2caff92186e0875737fe3727a4fd (commit) via ae026f5458c5c919031a41310321ae26cd56fae0 (commit) from a97bb6ae3f70febd207ef2373287237249f082e5 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6904b6efdc2ea35c3490ba33cb352b03ea3085f5 commit 6904b6efdc2ea35c3490ba33cb352b03ea3085f5 Merge: a97bb6a 867b5be Author: Brad King AuthorDate: Thu Aug 27 10:04:07 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 27 10:04:07 2015 -0400 Merge topic 'rm-cmLocalGenerator-Children' 867b5be8 cmLocalGenerator: Remove unused Children member. 6c832219 cmLocalGenerator: Implement child traversal in terms of cmState. 3fcf3837 Makefiles: Remove valueless cast. 223f4a66 cmLocalGenerator: Simplify condition. ae026f54 cmState: Store Children states in parent state. ----------------------------------------------------------------------- Summary of changes: Source/cmGlobalUnixMakefileGenerator3.cxx | 10 ++++---- Source/cmLocalGenerator.cxx | 36 +++++++++++++---------------- Source/cmLocalGenerator.h | 6 ----- Source/cmState.cxx | 12 +++++++++- Source/cmState.h | 2 ++ 5 files changed, 34 insertions(+), 32 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 27 10:04:11 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 27 Aug 2015 10:04:11 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-977-g0d0b9b5 Message-ID: <20150827140411.4D679B285A@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 0d0b9b52f8a538a6327e2e9f848b943474afc682 (commit) via 637c56b4e0ce0205f3f28a670881aad07320ff17 (commit) via b3f2299e0600f3488aaeb78ebf66d1108201ea17 (commit) via 6ce940ac9701c93be01ed169c6bd23b22e04782f (commit) via e8c0341d86e3f2b9658dfc594641f9ba1b29165b (commit) from 6904b6efdc2ea35c3490ba33cb352b03ea3085f5 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0d0b9b52f8a538a6327e2e9f848b943474afc682 commit 0d0b9b52f8a538a6327e2e9f848b943474afc682 Merge: 6904b6e 637c56b Author: Brad King AuthorDate: Thu Aug 27 10:04:09 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 27 10:04:09 2015 -0400 Merge topic 'cmState-ProjectName' 637c56b4 cmGlobalGenerator: Implement FillProjectMap in terms of cmState. b3f2299e cmState: Move ProjectName from cmMakefile. 6ce940ac cmMakefile: Use std::string in ProjectName API. e8c0341d cmMakefile: Out-of-line GetProjectName. diff --cc Source/cmState.cxx index a401265,6cd58b6..b30c10b --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@@ -75,9 -75,9 +75,11 @@@ struct cmState::BuildsystemDirectorySta std::vector CompileOptions; std::vector CompileOptionsBacktraces; + std::string ProjectName; + cmPropertyMap Properties; + + std::vector Children; }; cmState::cmState(cmake* cm) ----------------------------------------------------------------------- Summary of changes: Source/cmCPluginAPI.cxx | 4 +++- Source/cmGlobalGenerator.cxx | 11 ++++++----- Source/cmMakefile.cxx | 10 +++++++--- Source/cmMakefile.h | 9 ++------- Source/cmProjectCommand.cxx | 2 +- Source/cmState.cxx | 12 ++++++++++++ Source/cmState.h | 3 +++ 7 files changed, 34 insertions(+), 17 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 27 10:04:13 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 27 Aug 2015 10:04:13 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-985-g445077c Message-ID: <20150827140413.78187B284E@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 445077cbd2343050250eb0d541633010db659312 (commit) via 7f551b4f2635816553c2ff7dacef78254875116e (commit) via cd6293cdf8cf04fca70497a2474989b773fe922e (commit) via de6b2895824fdac9a25fa9cd2f0f7c38b29547dc (commit) via e35ee02d6e6aa5d1e9bc50d7c378dcbbabcf52bd (commit) via 00f2298f0788404cf170ed6ab50b73ef890b4302 (commit) via 6254ba95784ae29616b17ad8b42d4f31560c2c65 (commit) via cf0a78dc4ce7debb62ceb4d12235ea75e19bebe2 (commit) from 0d0b9b52f8a538a6327e2e9f848b943474afc682 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=445077cbd2343050250eb0d541633010db659312 commit 445077cbd2343050250eb0d541633010db659312 Merge: 0d0b9b5 7f551b4 Author: Brad King AuthorDate: Thu Aug 27 10:04:12 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 27 10:04:12 2015 -0400 Merge topic 'minor-cleanups' 7f551b4f cmGlobalGenerator: Implement VS6 check without virtual method. cd6293cd cmMakefile: Fix style. de6b2895 cmTarget: Remove vestigal method declaration. e35ee02d cmTarget: Fix indentation. 00f2298f Reduce uses of cmMakefile::GetGlobalGenerator. 6254ba95 cmMakefile: Remove Internal class. cf0a78dc cmGeneratorTarget: Issue messages through the local generator. ----------------------------------------------------------------------- Summary of changes: Source/cmComputeLinkDepends.cxx | 4 +++- Source/cmComputeLinkInformation.cxx | 2 +- Source/cmGeneratorTarget.cxx | 6 +++--- Source/cmGlobalGenerator.h | 2 +- Source/cmGlobalVisualStudio6Generator.h | 2 -- Source/cmMakefile.cxx | 26 ++++++++++---------------- Source/cmMakefile.h | 3 +-- Source/cmTarget.cxx | 12 ++++++------ Source/cmTarget.h | 2 -- 9 files changed, 25 insertions(+), 34 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 27 10:04:32 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 27 Aug 2015 10:04:32 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2562-g5e9b2b6 Message-ID: <20150827140432.384D8B2870@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 5e9b2b657002a916fec48aad86653c59de343c07 (commit) via 445077cbd2343050250eb0d541633010db659312 (commit) via 0d0b9b52f8a538a6327e2e9f848b943474afc682 (commit) via 6904b6efdc2ea35c3490ba33cb352b03ea3085f5 (commit) via a97bb6ae3f70febd207ef2373287237249f082e5 (commit) via 2985b9c00348c81d3cba9603e50a22da4e54cefa (commit) via f96b6af18aebc5791047bc6d7b33375ac570c6e9 (commit) via ba6533e658f63d9446993882788f03263d32fe1b (commit) via ef0bf87939d40c3a42129c82e3233fd9a27a5da8 (commit) via 81ad5622b486cd246d2407448461517b21787cf6 (commit) from 566f149abf8bab6956f43010375cde30dd67125d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5e9b2b657002a916fec48aad86653c59de343c07 commit 5e9b2b657002a916fec48aad86653c59de343c07 Merge: 566f149 445077c Author: Brad King AuthorDate: Thu Aug 27 10:04:23 2015 -0400 Commit: Brad King CommitDate: Thu Aug 27 10:04:23 2015 -0400 Merge branch 'master' into next ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 27 10:07:34 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 27 Aug 2015 10:07:34 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-1008-g27e4b21 Message-ID: <20150827140735.351ABB2948@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 27e4b21dfa926a522bb32674b8836ebb79d51bc5 (commit) via c2b7336ff3122c57a235aeaa1699ba5627ecf3ce (commit) via 69329fff70300debf10b62ac08a6bcee9ae7bc3c (commit) via 0431f2c4d7cbfcd873bc34caee9ed09253e8c8ad (commit) via abe9505df94e9a1511238c41f9d4459064148c94 (commit) via d4a24c0e953e0032a2e483917850b7f8f387bbb2 (commit) via 83981cf5931aaa2d9bbf4f99ea55c99736173fdf (commit) via 771e79a2bf97e2e5de40106396358adc773014f1 (commit) via 3846ebcf2b60b73e3eec848bd3dd41711eac5dc4 (commit) via a7f5d70dde50ac74726f3c23d276d2fdac70d659 (commit) via d051086ccec5cd4b381cf47afb0e7fe962ed4c0b (commit) via db4cb92bda8b43c3d66d27533622bb802e823589 (commit) via e6ccbf6f30fb7b893b00a7c26fa165065eed4323 (commit) via 8bfb0c53dae93d697ca5d92ff79068af351fe56b (commit) via 2cb3e5740269757f6f93d24a4d13570ee72de318 (commit) via 6d3d099b4a2d8b020fb1a9ebeb29b17b3fb6c9d6 (commit) via 0db9d9278760c90be1fbf5c4eeb93ef9c524041a (commit) via 84b847e42fde288bc102198aedeb68e19b41ef1e (commit) via 6220241fd0bb7902c932742a7aa3d6a96fd0e919 (commit) via 6353816786caccfef7acb3fd72aa28e0366da405 (commit) via 20993de46444e0f74700a641b54a8ca7e015bac4 (commit) via f8ca51a054732d5b0e2c6052ee102b748bd5848c (commit) via d67584ccc4262c103a180504cb294e3ad6b6910d (commit) from 445077cbd2343050250eb0d541633010db659312 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=27e4b21dfa926a522bb32674b8836ebb79d51bc5 commit 27e4b21dfa926a522bb32674b8836ebb79d51bc5 Merge: 445077c c2b7336 Author: Brad King AuthorDate: Thu Aug 27 10:07:32 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 27 10:07:32 2015 -0400 Merge topic 'use-generator-target' c2b7336f cmGeneratorTarget: Move GetConfigCommonSourceFiles from cmTarget. 69329fff cmGeneratorTarget: Move GetLanguages from cmTarget. 0431f2c4 cmGeneratorTarget: Move ComputeLinkImplementationLanguages from cmTarget. abe9505d cmGeneratorTarget: Move HaveBuildTreeRPath from cmTarget. d4a24c0e cmGeneratorTarget: Move GetLinkImplementation from cmTarget. 83981cf5 cmTarget: Add GetLinkImplMap method. 771e79a2 cmLinkItem: Add cmOptionalLinkImplementation type. 3846ebcf cmLinkItem: Add cmLinkImplementation type. a7f5d70d cmGeneratorTarget: Move compile defintions processing from cmTarget. d051086c cmGeneratorTarget: Move compile features processing from cmTarget. db4cb92b cmGeneratorTarget: Move compile options processing from cmTarget. e6ccbf6f cmGeneratorTarget: Move include directory processing from cmTarget. 8bfb0c53 cmGeneratorTarget: Move link iface helpers from cmTarget. 2cb3e574 cmGeneratorTarget: Move GetImportLinkInterface from cmTarget. 6d3d099b cmGeneratorTarget: Move ComputeLinkInterfaceLibraries from cmTarget. 0db9d927 cmGeneratorTarget: Move GetLinkInterfaceLibraries from cmTarget. ... ----------------------------------------------------------------------- Summary of changes: Source/cmComputeLinkDepends.cxx | 24 +- Source/cmComputeLinkDepends.h | 2 +- Source/cmComputeLinkInformation.cxx | 2 +- Source/cmComputeTargetDepends.cxx | 7 +- Source/cmExportFileGenerator.cxx | 10 +- Source/cmExtraCodeBlocksGenerator.cxx | 2 +- Source/cmGeneratorExpressionNode.cxx | 4 +- Source/cmGeneratorTarget.cxx | 1221 +++++++++++++++++++++++- Source/cmGeneratorTarget.h | 81 +- Source/cmGhsMultiTargetGenerator.cxx | 9 +- Source/cmGlobalGenerator.cxx | 1 - Source/cmGlobalUnixMakefileGenerator3.cxx | 3 +- Source/cmGlobalVisualStudio8Generator.cxx | 2 +- Source/cmGlobalVisualStudioGenerator.cxx | 8 +- Source/cmGlobalXCodeGenerator.cxx | 25 +- Source/cmLinkItem.h | 62 ++ Source/cmLocalGenerator.cxx | 13 +- Source/cmLocalUnixMakefileGenerator3.cxx | 4 +- Source/cmLocalVisualStudio6Generator.cxx | 5 +- Source/cmLocalVisualStudio7Generator.cxx | 9 +- Source/cmMakefileTargetGenerator.cxx | 2 +- Source/cmQtAutoGenerators.cxx | 16 +- Source/cmTarget.cxx | 1433 +++------------------------- Source/cmTarget.h | 107 +-- Source/cmVisualStudio10TargetGenerator.cxx | 4 +- 25 files changed, 1606 insertions(+), 1450 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 27 10:07:54 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 27 Aug 2015 10:07:54 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2564-g101e2c1 Message-ID: <20150827140754.C31A7B2954@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 101e2c1853a6edfdf10fe7786e695defc613b3b5 (commit) via 27e4b21dfa926a522bb32674b8836ebb79d51bc5 (commit) from 5e9b2b657002a916fec48aad86653c59de343c07 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=101e2c1853a6edfdf10fe7786e695defc613b3b5 commit 101e2c1853a6edfdf10fe7786e695defc613b3b5 Merge: 5e9b2b6 27e4b21 Author: Brad King AuthorDate: Thu Aug 27 10:07:48 2015 -0400 Commit: Brad King CommitDate: Thu Aug 27 10:07:48 2015 -0400 Merge branch 'master' into next ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 27 11:14:53 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 27 Aug 2015 11:14:53 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2566-g5328d0b Message-ID: <20150827151453.B1418B2248@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 5328d0bd617c6cdcbed1413924cc434acb32dd0b (commit) via 3e2865b46744e543af3045331b31b94df2ebe1ad (commit) from 101e2c1853a6edfdf10fe7786e695defc613b3b5 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5328d0bd617c6cdcbed1413924cc434acb32dd0b commit 5328d0bd617c6cdcbed1413924cc434acb32dd0b Merge: 101e2c1 3e2865b Author: Brad King AuthorDate: Thu Aug 27 11:14:53 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 27 11:14:53 2015 -0400 Merge topic 'GenerateExportHeader-cygwin-dllexport' into next 3e2865b4 GenerateExportHeader: Use dllexport/dllimport on Cygwin http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3e2865b46744e543af3045331b31b94df2ebe1ad commit 3e2865b46744e543af3045331b31b94df2ebe1ad Author: Tony Kelman AuthorDate: Thu Aug 27 07:48:18 2015 +0000 Commit: Brad King CommitDate: Thu Aug 27 10:08:34 2015 -0400 GenerateExportHeader: Use dllexport/dllimport on Cygwin Cygwin sits on top of Windows and so can use explicit symbol export and import markup too. Co-Author: Yaakov Selkowitz diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index aab29ea..8205425 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -268,7 +268,7 @@ macro(_DO_SET_MACRO_VALUES TARGET_LIBRARY) get_property(type TARGET ${TARGET_LIBRARY} PROPERTY TYPE) if(NOT ${type} STREQUAL "STATIC_LIBRARY") - if(WIN32) + if(WIN32 OR CYGWIN) set(DEFINE_EXPORT "__declspec(dllexport)") set(DEFINE_IMPORT "__declspec(dllimport)") elseif(COMPILER_HAS_HIDDEN_VISIBILITY AND USE_COMPILER_HIDDEN_VISIBILITY) diff --git a/Tests/Module/GenerateExportHeader/CMakeLists.txt b/Tests/Module/GenerateExportHeader/CMakeLists.txt index b52c44d..8cd25a4 100644 --- a/Tests/Module/GenerateExportHeader/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/CMakeLists.txt @@ -106,10 +106,10 @@ endif() add_executable(GenerateExportHeader exportheader_test.cpp) target_link_libraries(GenerateExportHeader ${link_libraries}) -if (WIN32) +if (WIN32 OR CYGWIN) if(MSVC AND COMPILER_HAS_DEPRECATED) set(_platform Win32) - elseif(MINGW AND COMPILER_HAS_DEPRECATED) + elseif((MINGW OR CYGWIN) AND COMPILER_HAS_DEPRECATED) set(_platform MinGW) else() set(_platform WinEmpty) ----------------------------------------------------------------------- Summary of changes: Modules/GenerateExportHeader.cmake | 2 +- Tests/Module/GenerateExportHeader/CMakeLists.txt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Thu Aug 27 13:35:41 2015 From: brad.king at kitware.com (Brad King) Date: Thu, 27 Aug 2015 13:35:41 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2569-g05faeb9 Message-ID: <20150827173541.865D5B24EA@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 05faeb9ad6d27696a5ba92af27f3bbcc8f90c5a1 (commit) via ac0bb4333d13e633e26d107f288162d7d6a37b3a (commit) via 92b835ec9d17b190b13da93702f0eb416b665a48 (commit) from 5328d0bd617c6cdcbed1413924cc434acb32dd0b (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=05faeb9ad6d27696a5ba92af27f3bbcc8f90c5a1 commit 05faeb9ad6d27696a5ba92af27f3bbcc8f90c5a1 Merge: 5328d0b ac0bb43 Author: Brad King AuthorDate: Thu Aug 27 13:35:40 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 27 13:35:40 2015 -0400 Merge topic 'vs-store-phone-cert-thumbs' into next ac0bb433 VS: Windows Store/Phone package cert thumbprint 92b835ec Simplify condition for using rpcrt4 library on Windows http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ac0bb4333d13e633e26d107f288162d7d6a37b3a commit ac0bb4333d13e633e26d107f288162d7d6a37b3a Author: Gilles Khouzam AuthorDate: Fri Aug 21 14:15:38 2015 -0700 Commit: Brad King CommitDate: Thu Aug 27 13:35:18 2015 -0400 VS: Windows Store/Phone package cert thumbprint Add the PackageCertificateThumbprint property when there is a certificate on a WindowsStore or Phone app. diff --git a/CTestCustom.cmake.in b/CTestCustom.cmake.in index f29ac70..d3cff51 100644 --- a/CTestCustom.cmake.in +++ b/CTestCustom.cmake.in @@ -32,6 +32,7 @@ set(CTEST_CUSTOM_WARNING_EXCEPTION "remark: .*LOOP WAS VECTORIZED" "warning .980: wrong number of actual arguments to intrinsic function .std::basic_" "LINK : warning LNK4089: all references to.*ADVAPI32.dll.*discarded by /OPT:REF" + "LINK : warning LNK4089: all references to.*CRYPT32.dll.*discarded by /OPT:REF" "LINK : warning LNK4089: all references to.*PSAPI.DLL.*discarded by /OPT:REF" "LINK : warning LNK4089: all references to.*RPCRT4.dll.*discarded by /OPT:REF" "LINK : warning LNK4089: all references to.*SHELL32.dll.*discarded by /OPT:REF" diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 1886519..16b9ea1 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -558,7 +558,8 @@ endif() if(WIN32 AND NOT UNIX) # We need the rpcrt4 library on Windows. - target_link_libraries(CMakeLib rpcrt4) + # We need the crypt32 library on Windows for crypto/cert APIs. + target_link_libraries(CMakeLib rpcrt4 crypt32) endif() # diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index a117238..583e1d0 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1013,6 +1013,94 @@ std::string cmSystemTools::ComputeStringMD5(const std::string& input) #endif } +//---------------------------------------------------------------------------- +std::string cmSystemTools::ComputeCertificateThumbprint( + const std::string& source) +{ + std::string thumbprint; + +#ifdef _WIN32 + BYTE* certData = NULL; + CRYPT_INTEGER_BLOB cryptBlob; + HCERTSTORE certStore = NULL; + PCCERT_CONTEXT certContext = NULL; + + HANDLE certFile = CreateFile(cmsys::Encoding::ToWide(source.c_str()).c_str(), + GENERIC_READ, + FILE_SHARE_READ, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + + if (certFile != INVALID_HANDLE_VALUE && certFile != NULL) + { + DWORD fileSize = GetFileSize(certFile, NULL); + if (fileSize != INVALID_FILE_SIZE) + { + certData = new BYTE[fileSize]; + if (certData != NULL) + { + DWORD dwRead = 0; + if (ReadFile(certFile, certData, fileSize, &dwRead, NULL)) + { + cryptBlob.cbData = fileSize; + cryptBlob.pbData = certData; + + // Verify that this is a valid cert + if (PFXIsPFXBlob(&cryptBlob)) + { + // Open the certificate as a store + certStore = PFXImportCertStore( + &cryptBlob, NULL, CRYPT_EXPORTABLE); + if (certStore != NULL) + { + // There should only be 1 cert. + certContext = CertEnumCertificatesInStore(certStore, + certContext); + if (certContext != NULL) + { + // The hash is 20 bytes + BYTE hashData[20]; + DWORD hashLength = 20; + + // Buffer to print the hash. Each byte takes 2 chars + + // terminating character + char hashPrint[41]; + char *pHashPrint = hashPrint; + // Get the hash property from the certificate + if (CertGetCertificateContextProperty(certContext, + CERT_HASH_PROP_ID, hashData, &hashLength)) + { + for (DWORD i = 0; i < hashLength; i++) + { + // Convert each byte to hexadecimal + sprintf(pHashPrint, "%02X", hashData[i]); + pHashPrint += 2; + } + *pHashPrint = '\0'; + thumbprint = hashPrint; + } + CertFreeCertificateContext(certContext); + } + CertCloseStore(certStore, 0); + } + } + } + delete[] certData; + } + } + CloseHandle(certFile); + } +#else + (void)source; + cmSystemTools::Message("ComputeCertificateThumbprint is not implemented", + "Error"); +#endif + + return thumbprint; +} + void cmSystemTools::Glob(const std::string& directory, const std::string& regexp, std::vector& files) diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index fb58307..c12a1db 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -194,6 +194,9 @@ public: /** Compute the md5sum of a string. */ static std::string ComputeStringMD5(const std::string& input); + ///! Get the SHA thumbprint for a certificate file + static std::string ComputeCertificateThumbprint(const std::string& source); + /** * Run a single executable command * diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 80b8591..28a0425 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2893,7 +2893,7 @@ void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile() (*this->BuildFileStream) << cmVS10EscapeXML(artifactDir) << "\\\n"; this->WriteString("" - "$(TargetDir)resources.pri", 2); + "$(TargetDir)resources.pri\n", 2); // If we are missing files and we don't have a certificate and // aren't targeting WP8.0, add a default certificate @@ -2911,6 +2911,13 @@ void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile() this->WriteString("<", 2); (*this->BuildFileStream) << "PackageCertificateKeyFile>" << pfxFile << "\n"; + std::string thumb = cmSystemTools::ComputeCertificateThumbprint(pfxFile); + if (!thumb.empty()) + { + this->WriteString("", 2); + (*this->BuildFileStream) << thumb + << "\n"; + } this->WriteString("\n", 1); } else if(!pfxFile.empty()) @@ -2919,6 +2926,13 @@ void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile() this->WriteString("<", 2); (*this->BuildFileStream) << "PackageCertificateKeyFile>" << pfxFile << "\n"; + std::string thumb = cmSystemTools::ComputeCertificateThumbprint(pfxFile); + if (!thumb.empty()) + { + this->WriteString("", 2); + (*this->BuildFileStream) << thumb + << "\n"; + } this->WriteString("\n", 1); } } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=92b835ec9d17b190b13da93702f0eb416b665a48 commit 92b835ec9d17b190b13da93702f0eb416b665a48 Author: Brad King AuthorDate: Mon Aug 24 10:58:42 2015 -0400 Commit: Brad King CommitDate: Thu Aug 27 13:35:13 2015 -0400 Simplify condition for using rpcrt4 library on Windows Drop the CMAKE_BUILD_ON_VISUAL_STUDIO variable and hard-code the condition at its only use. diff --git a/CMakeLists.txt b/CMakeLists.txt index 36244dd..5e13a7e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -144,17 +144,6 @@ macro(CMAKE_HANDLE_SYSTEM_LIBRARIES) endmacro() - - - -if(NOT CMake_TEST_EXTERNAL_CMAKE) - set(CMAKE_BUILD_ON_VISUAL_STUDIO 0) - if(WIN32 AND NOT UNIX AND NOT MINGW) - set(CMAKE_BUILD_ON_VISUAL_STUDIO 1) - endif() -endif() - - #----------------------------------------------------------------------- # a macro to determine the generator and ctest executable to use # for testing. Simply to improve readability of the main script. diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 428b364..1886519 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -556,8 +556,8 @@ if(APPLE) target_link_libraries(CMakeLib "-framework CoreFoundation") endif() -if(CMAKE_BUILD_ON_VISUAL_STUDIO OR MINGW) - # We need the rpcrt4 library for at least the VS7-VC10 generators. +if(WIN32 AND NOT UNIX) + # We need the rpcrt4 library on Windows. target_link_libraries(CMakeLib rpcrt4) endif() ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From steveire at gmail.com Thu Aug 27 16:15:10 2015 From: steveire at gmail.com (Stephen Kelly) Date: Thu, 27 Aug 2015 16:15:10 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2584-g698baec Message-ID: <20150827201510.C9BFAB22A9@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 698baeca7519b75caa4958f187bc57e32da63aad (commit) via 7ccd4a7ceeeb5ec04c62cf5c2c6f7e31430bc254 (commit) via 66e7c747675286ca46ec0f0c84d0f64658ebea72 (commit) via 6a502f0a67f7fdd3fb0d830e020e5860fd2b956c (commit) via ea832ddfa542fb8ba40c322d25ca084ecfb1747b (commit) via 641e0de381f80f39de9651d4a9def7726f26fbe5 (commit) via f9f62d445a65a236b67ea05c3bde0e9e47966d81 (commit) via 15d1c4c8a99c226987884bc487fdd1c4608d6e85 (commit) via 53b616680069cde4f2c4d06cb31228a141bf92b8 (commit) via a72a99b0d2474f09620e1a52a46e3ba74b1d99fa (commit) via 3b788d5d723bbc6c4e5849943f421e4c6aa509df (commit) via 2cdac1ac2011281e5fbba7b1641a729597cc0ba8 (commit) via c2de8617cec667afe49da3f592964a25fe7b50e0 (commit) via fa22a66e8f60e2ee4c5308e3a239a977dd54c70e (commit) via 5176697fa5333dadef7e5627ba187f557d77a8c2 (commit) from 05faeb9ad6d27696a5ba92af27f3bbcc8f90c5a1 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=698baeca7519b75caa4958f187bc57e32da63aad commit 698baeca7519b75caa4958f187bc57e32da63aad Merge: 05faeb9 7ccd4a7 Author: Stephen Kelly AuthorDate: Thu Aug 27 16:15:07 2015 -0400 Commit: CMake Topic Stage CommitDate: Thu Aug 27 16:15:07 2015 -0400 Merge topic 'generate-time-generators' into next 7ccd4a7c cmGlobalGenerator: Create all local generators after Configure(). 66e7c747 cmGlobalGenerator: Create global targets directly after Configure. 6a502f0a cmMakefile: Skip Global targets for CMP0019 evaluation. ea832ddf cmGlobalGenerator: Fill the project map at compute time. 641e0de3 cmGlobalGenerator: Rename method. f9f62d44 cmGlobalGenerator: Avoid cmLocalGenerator until after Configure. 15d1c4c8 cmLocalGenerator: Create from already-constructed cmMakefile. 53b61668 Ninja: Remove some incorrect comments adding no value. a72a99b0 cmCTestScriptHandler: Simplify deletes. 3b788d5d QtAutogen: Use a smart pointer. 2cdac1ac cmGlobalGenerator: Remove MakeLocalGenerator method. c2de8617 cmGlobalGenerator: Require a snapshot to create a local generator. fa22a66e cmMakefile: Remove cmLocalGenerator member. 5176697f cmLocalGenerator: Remove Parent pointer. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7ccd4a7ceeeb5ec04c62cf5c2c6f7e31430bc254 commit 7ccd4a7ceeeb5ec04c62cf5c2c6f7e31430bc254 Author: Stephen Kelly AuthorDate: Sun Aug 2 12:12:18 2015 +0200 Commit: Stephen Kelly CommitDate: Thu Aug 27 22:14:06 2015 +0200 cmGlobalGenerator: Create all local generators after Configure(). diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index b869312..cb272f3 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1130,9 +1130,6 @@ void cmGlobalGenerator::Configure() cmMakefile* dirMf = new cmMakefile(this, this->GetCMakeInstance()->GetCurrentSnapshot()); this->AddMakefile(dirMf); - cmLocalGenerator *lg = this->CreateLocalGenerator(dirMf); - this->Makefiles.push_back(lg->GetMakefile()); - this->LocalGenerators.push_back(lg); // set the Start directories dirMf->SetCurrentSourceDirectory @@ -1202,8 +1199,21 @@ void cmGlobalGenerator::Configure() } } +void cmGlobalGenerator::CreateLocalGenerators() +{ + cmDeleteAll(this->LocalGenerators); + this->LocalGenerators.clear(); + this->LocalGenerators.reserve(this->Makefiles.size()); + for (std::vector::const_iterator it = this->Makefiles.begin(); + it != this->Makefiles.end(); ++it) + { + this->LocalGenerators.push_back(this->CreateLocalGenerator(*it)); + } +} + void cmGlobalGenerator::CreateGenerationObjects(TargetTypes targetTypes) { + this->CreateLocalGenerators(); cmDeleteAll(this->GeneratorTargets); this->GeneratorTargets.clear(); this->CreateGeneratorTargets(targetTypes); diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 9fc2d45..4461831 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -91,6 +91,7 @@ public: ImportedOnly }; + void CreateLocalGenerators(); void CreateGenerationObjects(TargetTypes targetTypes = AllTargets); /** diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 626d0bd..6480667 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1756,13 +1756,6 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath, cmMakefile* subMf = new cmMakefile(this->GlobalGenerator, newSnapshot); this->GetGlobalGenerator()->AddMakefile(subMf); - // create a new local generator and set its parent - cmLocalGenerator *lg2 = this->GetGlobalGenerator() - ->CreateLocalGenerator(subMf); - this->GetGlobalGenerator()->AddMakefile(lg2->GetMakefile()); - this->GetGlobalGenerator()->AddLocalGenerator(lg2); - - // set the subdirs start dirs subMf->SetCurrentSourceDirectory(srcPath); subMf->SetCurrentBinaryDirectory(binPath); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=66e7c747675286ca46ec0f0c84d0f64658ebea72 commit 66e7c747675286ca46ec0f0c84d0f64658ebea72 Author: Stephen Kelly AuthorDate: Sun Aug 2 12:59:06 2015 +0200 Commit: Stephen Kelly CommitDate: Thu Aug 27 22:14:06 2015 +0200 cmGlobalGenerator: Create global targets directly after Configure. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index e286a1f..b869312 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1147,6 +1147,22 @@ void cmGlobalGenerator::Configure() dirMf->Configure(); dirMf->EnforceDirectoryLevelRules(); + // Put a copy of each global target in every directory. + cmTargets globalTargets; + this->CreateDefaultGlobalTargets(&globalTargets); + + for (unsigned int i = 0; i < this->Makefiles.size(); ++i) + { + cmMakefile* mf = this->Makefiles[i]; + cmTargets* targets = &(mf->GetTargets()); + cmTargets::iterator tit; + for ( tit = globalTargets.begin(); tit != globalTargets.end(); ++ tit ) + { + (*targets)[tit->first] = tit->second; + (*targets)[tit->first].SetMakefile(mf); + } + } + // update the cache entry for the number of local generators, this is used // for progress char num[100]; @@ -1184,25 +1200,6 @@ void cmGlobalGenerator::Configure() } this->CMakeInstance->UpdateProgress(msg.str().c_str(), -1); } - - unsigned int i; - - // Put a copy of each global target in every directory. - cmTargets globalTargets; - this->CreateDefaultGlobalTargets(&globalTargets); - - for (i = 0; i < this->Makefiles.size(); ++i) - { - cmMakefile* mf = this->Makefiles[i]; - cmTargets* targets = &(mf->GetTargets()); - cmTargets::iterator tit; - for ( tit = globalTargets.begin(); tit != globalTargets.end(); ++ tit ) - { - (*targets)[tit->first] = tit->second; - (*targets)[tit->first].SetMakefile(mf); - } - } - } void cmGlobalGenerator::CreateGenerationObjects(TargetTypes targetTypes) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6a502f0a67f7fdd3fb0d830e020e5860fd2b956c commit 6a502f0a67f7fdd3fb0d830e020e5860fd2b956c Author: Stephen Kelly AuthorDate: Sun Aug 2 13:25:53 2015 +0200 Commit: Stephen Kelly CommitDate: Thu Aug 27 22:14:06 2015 +0200 cmMakefile: Skip Global targets for CMP0019 evaluation. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index e28efc1..626d0bd 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2336,7 +2336,8 @@ void cmMakefile::ExpandVariablesCMP0019() l != this->Targets.end(); ++l) { cmTarget &t = l->second; - if (t.GetType() == cmTarget::INTERFACE_LIBRARY) + if (t.GetType() == cmTarget::INTERFACE_LIBRARY + || t.GetType() == cmTarget::GLOBAL_TARGET) { continue; } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ea832ddfa542fb8ba40c322d25ca084ecfb1747b commit ea832ddfa542fb8ba40c322d25ca084ecfb1747b Author: Stephen Kelly AuthorDate: Sun Aug 2 12:55:05 2015 +0200 Commit: Stephen Kelly CommitDate: Thu Aug 27 22:14:06 2015 +0200 cmGlobalGenerator: Fill the project map at compute time. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index d1a945e..e286a1f 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1159,10 +1159,6 @@ void cmGlobalGenerator::Configure() // and for infinite loops this->CheckTargetProperties(); - // at this point this->LocalGenerators has been filled, - // so create the map from project name to vector of local generators - this->FillProjectMap(); - if ( this->CMakeInstance->GetWorkingMode() == cmake::NORMAL_MODE) { std::ostringstream msg; @@ -1269,6 +1265,10 @@ bool cmGlobalGenerator::Compute() this->CreateGenerationObjects(); + // at this point this->LocalGenerators has been filled, + // so create the map from project name to vector of local generators + this->FillProjectMap(); + #ifdef CMAKE_BUILD_WITH_CMAKE // Iterate through all targets and set up automoc for those which have // the AUTOMOC, AUTOUIC or AUTORCC property set http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=641e0de381f80f39de9651d4a9def7726f26fbe5 commit 641e0de381f80f39de9651d4a9def7726f26fbe5 Author: Stephen Kelly AuthorDate: Sun Aug 2 12:44:07 2015 +0200 Commit: Stephen Kelly CommitDate: Thu Aug 27 22:14:05 2015 +0200 cmGlobalGenerator: Rename method. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index aa3b9c3..d1a945e 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1157,7 +1157,7 @@ void cmGlobalGenerator::Configure() // check for link libraries and include directories containing "NOTFOUND" // and for infinite loops - this->CheckLocalGenerators(); + this->CheckTargetProperties(); // at this point this->LocalGenerators has been filled, // so create the map from project name to vector of local generators @@ -1637,7 +1637,7 @@ void cmGlobalGenerator::ComputeTargetObjectDirectory(cmGeneratorTarget*) const { } -void cmGlobalGenerator::CheckLocalGenerators() +void cmGlobalGenerator::CheckTargetProperties() { std::map notFoundMap; // std::set notFoundMap; diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index b113488..9fc2d45 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -394,7 +394,7 @@ protected: // Fill the ProjectMap, this must be called after LocalGenerators // has been populated. void FillProjectMap(); - void CheckLocalGenerators(); + void CheckTargetProperties(); bool IsExcluded(cmState::Snapshot const& root, cmState::Snapshot const& snp) const; bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f9f62d445a65a236b67ea05c3bde0e9e47966d81 commit f9f62d445a65a236b67ea05c3bde0e9e47966d81 Author: Stephen Kelly AuthorDate: Sun Aug 2 12:08:49 2015 +0200 Commit: Stephen Kelly CommitDate: Thu Aug 27 22:14:05 2015 +0200 cmGlobalGenerator: Avoid cmLocalGenerator until after Configure. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 3b91f62..aa3b9c3 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1135,17 +1135,17 @@ void cmGlobalGenerator::Configure() this->LocalGenerators.push_back(lg); // set the Start directories - lg->GetMakefile()->SetCurrentSourceDirectory + dirMf->SetCurrentSourceDirectory (this->CMakeInstance->GetHomeDirectory()); - lg->GetMakefile()->SetCurrentBinaryDirectory + dirMf->SetCurrentBinaryDirectory (this->CMakeInstance->GetHomeOutputDirectory()); this->BinaryDirectories.insert( this->CMakeInstance->GetHomeOutputDirectory()); // now do it - lg->GetMakefile()->Configure(); - lg->GetMakefile()->EnforceDirectoryLevelRules(); + dirMf->Configure(); + dirMf->EnforceDirectoryLevelRules(); // update the cache entry for the number of local generators, this is used // for progress http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=15d1c4c8a99c226987884bc487fdd1c4608d6e85 commit 15d1c4c8a99c226987884bc487fdd1c4608d6e85 Author: Stephen Kelly AuthorDate: Sun Aug 2 11:41:51 2015 +0200 Commit: Stephen Kelly CommitDate: Thu Aug 27 22:14:03 2015 +0200 cmLocalGenerator: Create from already-constructed cmMakefile. Don't manage the lifetime of the cmMakefile with cmLocalGenerator. diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 8cbcd4e..92a4b2b 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -716,9 +716,10 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( cm.AddCMakePaths(); cm.SetProgressCallback(cmCPackGeneratorProgress, this); cmGlobalGenerator gg(&cm); + cmsys::auto_ptr mf( + new cmMakefile(&gg, cm.GetCurrentSnapshot())); cmsys::auto_ptr lg( - gg.CreateLocalGenerator(cm.GetCurrentSnapshot())); - cmMakefile *mf = lg->GetMakefile(); + gg.CreateLocalGenerator(mf.get())); std::string realInstallDirectory = tempInstallDirectory; if ( !installSubDirectory.empty() && installSubDirectory != "/" ) { diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index 96351f7..cb9cbc4 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -202,9 +202,10 @@ int main (int argc, char const* const* argv) cminst.SetHomeOutputDirectory(""); cminst.GetState()->RemoveUnscriptableCommands(); cmGlobalGenerator cmgg(&cminst); + cmsys::auto_ptr globalMF( + new cmMakefile(&cmgg, cminst.GetCurrentSnapshot())); cmsys::auto_ptr cmlg( - cmgg.CreateLocalGenerator(cminst.GetCurrentSnapshot())); - cmMakefile* globalMF = cmlg->GetMakefile(); + cmgg.CreateLocalGenerator(globalMF.get())); #if defined(__CYGWIN__) globalMF->AddDefinition("CMAKE_LEGACY_CYGWIN_WIN32", "0"); #endif @@ -358,8 +359,8 @@ int main (int argc, char const* const* argv) ++it ) { const char* gen = it->c_str(); - cmMakefile::ScopePushPop raii(globalMF); - cmMakefile* mf = globalMF; + cmMakefile::ScopePushPop raii(globalMF.get()); + cmMakefile* mf = globalMF.get(); cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "Specified generator: " << gen << std::endl); if ( parsed && !mf->GetDefinition("CPACK_PACKAGE_NAME") ) diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx index 7340d5c..fb0cce6 100644 --- a/Source/CTest/cmCTestLaunch.cxx +++ b/Source/CTest/cmCTestLaunch.cxx @@ -738,9 +738,9 @@ void cmCTestLaunch::LoadConfig() cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); cmGlobalGenerator gg(&cm); + cmsys::auto_ptr mf(new cmMakefile(&gg, cm.GetCurrentSnapshot())); cmsys::auto_ptr lg( - gg.CreateLocalGenerator(cm.GetCurrentSnapshot())); - cmMakefile* mf = lg->GetMakefile(); + gg.CreateLocalGenerator(mf.get())); std::string fname = this->LogDir; fname += "CTestLaunchConfig.cmake"; if(cmSystemTools::FileExists(fname.c_str()) && diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 4be5eb6..9154716 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -125,6 +125,7 @@ void cmCTestScriptHandler::Initialize() // what time in seconds did this script start running this->ScriptStartTime = 0; + delete this->Makefile; this->Makefile = 0; delete this->LocalGenerator; @@ -139,8 +140,7 @@ void cmCTestScriptHandler::Initialize() //---------------------------------------------------------------------- cmCTestScriptHandler::~cmCTestScriptHandler() { - // local generator owns the makefile - this->Makefile = 0; + delete this->Makefile; delete this->LocalGenerator; delete this->GlobalGenerator; delete this->CMake; @@ -317,6 +317,7 @@ void cmCTestScriptHandler::CreateCMake() delete this->CMake; delete this->GlobalGenerator; delete this->LocalGenerator; + delete this->Makefile; } this->CMake = new cmake; this->CMake->SetHomeDirectory(""); @@ -325,7 +326,9 @@ void cmCTestScriptHandler::CreateCMake() this->GlobalGenerator = new cmGlobalGenerator(this->CMake); cmState::Snapshot snapshot = this->CMake->GetCurrentSnapshot(); - this->LocalGenerator = this->GlobalGenerator->CreateLocalGenerator(snapshot); + this->Makefile = new cmMakefile(this->GlobalGenerator, snapshot); + this->LocalGenerator = + this->GlobalGenerator->CreateLocalGenerator(this->Makefile); this->Makefile = this->LocalGenerator->GetMakefile(); this->CMake->SetProgressCallback(ctestScriptProgressCallback, this->CTest); diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 9e00193..a523f57 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -1592,9 +1592,9 @@ void cmCTestTestHandler::GetListOfTests() cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); cmGlobalGenerator gg(&cm); + cmsys::auto_ptr mf(new cmMakefile(&gg, cm.GetCurrentSnapshot())); cmsys::auto_ptr lg( - gg.CreateLocalGenerator(cm.GetCurrentSnapshot())); - cmMakefile *mf = lg->GetMakefile(); + gg.CreateLocalGenerator(mf.get())); mf->AddDefinition("CTEST_CONFIGURATION_TYPE", this->CTest->GetConfigType().c_str()); diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 1786c2c..adefd1c 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -520,10 +520,10 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command) cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); cmGlobalGenerator gg(&cm); - cmsys::auto_ptr lg( - gg.CreateLocalGenerator(cm.GetCurrentSnapshot())); - cmMakefile *mf = lg->GetMakefile(); - if ( !this->ReadCustomConfigurationFileTree(this->BinaryDir.c_str(), mf) ) + cmsys::auto_ptr mf(new cmMakefile(&gg, cm.GetCurrentSnapshot())); + cmsys::auto_ptr lg(gg.CreateLocalGenerator(mf.get())); + if ( !this->ReadCustomConfigurationFileTree(this->BinaryDir.c_str(), + mf.get()) ) { cmCTestOptionalLog(this, DEBUG, "Cannot find custom configuration file tree" << std::endl, quiet); diff --git a/Source/cmGlobalBorlandMakefileGenerator.cxx b/Source/cmGlobalBorlandMakefileGenerator.cxx index c31f952..40e8d29 100644 --- a/Source/cmGlobalBorlandMakefileGenerator.cxx +++ b/Source/cmGlobalBorlandMakefileGenerator.cxx @@ -44,10 +44,10 @@ void cmGlobalBorlandMakefileGenerator ///! Create a local generator appropriate to this Global Generator cmLocalGenerator *cmGlobalBorlandMakefileGenerator::CreateLocalGenerator( - cmState::Snapshot snapshot) + cmMakefile *mf) { cmLocalUnixMakefileGenerator3* lg = - new cmLocalUnixMakefileGenerator3(this, snapshot); + new cmLocalUnixMakefileGenerator3(this, mf); lg->SetMakefileVariableSize(32); lg->SetMakeCommandEscapeTargetTwice(true); lg->SetBorlandMakeCurlyHack(true); diff --git a/Source/cmGlobalBorlandMakefileGenerator.h b/Source/cmGlobalBorlandMakefileGenerator.h index 62e458f..b59c86d 100644 --- a/Source/cmGlobalBorlandMakefileGenerator.h +++ b/Source/cmGlobalBorlandMakefileGenerator.h @@ -36,7 +36,7 @@ public: static void GetDocumentation(cmDocumentationEntry& entry); ///! Create a local generator appropriate to this Global Generator - virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); + virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf); /** * Try to determine system information such as shared library diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 7de807b..3b91f62 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1127,8 +1127,10 @@ void cmGlobalGenerator::Configure() this->FirstTimeProgress = 0.0f; this->ClearGeneratorMembers(); - // start with this directory - cmLocalGenerator *lg = this->CreateLocalGenerator(); + cmMakefile* dirMf = + new cmMakefile(this, this->GetCMakeInstance()->GetCurrentSnapshot()); + this->AddMakefile(dirMf); + cmLocalGenerator *lg = this->CreateLocalGenerator(dirMf); this->Makefiles.push_back(lg->GetMakefile()); this->LocalGenerators.push_back(lg); @@ -1600,6 +1602,7 @@ void cmGlobalGenerator::ClearGeneratorMembers() cmDeleteAll(this->BuildExportSets); this->BuildExportSets.clear(); + cmDeleteAll(this->Makefiles); this->Makefiles.clear(); cmDeleteAll(this->LocalGenerators); @@ -1986,9 +1989,9 @@ void cmGlobalGenerator::EnableInstallTarget() } cmLocalGenerator* -cmGlobalGenerator::CreateLocalGenerator(cmState::Snapshot snapshot) +cmGlobalGenerator::CreateLocalGenerator(cmMakefile* mf) { - return new cmLocalGenerator(this, snapshot); + return new cmLocalGenerator(this, mf); } void cmGlobalGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator *gen, diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 91c1aac..b113488 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -57,7 +57,7 @@ public: virtual ~cmGlobalGenerator(); virtual cmLocalGenerator* - CreateLocalGenerator(cmState::Snapshot snapshot = cmState::Snapshot()); + CreateLocalGenerator(cmMakefile* mf); ///! Get the name for this generator virtual std::string GetName() const { return "Generic"; } diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx index 29abb37..6dde1e3 100644 --- a/Source/cmGlobalGhsMultiGenerator.cxx +++ b/Source/cmGlobalGhsMultiGenerator.cxx @@ -33,9 +33,9 @@ cmGlobalGhsMultiGenerator::~cmGlobalGhsMultiGenerator() } cmLocalGenerator * -cmGlobalGhsMultiGenerator::CreateLocalGenerator(cmState::Snapshot snapshot) +cmGlobalGhsMultiGenerator::CreateLocalGenerator(cmMakefile* mf) { - return new cmLocalGhsMultiGenerator(this, snapshot); + return new cmLocalGhsMultiGenerator(this, mf); } void cmGlobalGhsMultiGenerator::GetDocumentation(cmDocumentationEntry &entry) diff --git a/Source/cmGlobalGhsMultiGenerator.h b/Source/cmGlobalGhsMultiGenerator.h index 873c20f..8f88d4f 100644 --- a/Source/cmGlobalGhsMultiGenerator.h +++ b/Source/cmGlobalGhsMultiGenerator.h @@ -31,7 +31,7 @@ public: { return new cmGlobalGeneratorSimpleFactory(); } ///! create the correct local generator - virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); + virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf); /// @return the name of this generator. static std::string GetActualName() { return "Green Hills MULTI"; } diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 72ef4d6..120bb03 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -528,9 +528,9 @@ cmGlobalNinjaGenerator::cmGlobalNinjaGenerator(cmake* cm) // Virtual public methods. cmLocalGenerator* -cmGlobalNinjaGenerator::CreateLocalGenerator(cmState::Snapshot snapshot) +cmGlobalNinjaGenerator::CreateLocalGenerator(cmMakefile* mf) { - return new cmLocalNinjaGenerator(this, snapshot); + return new cmLocalNinjaGenerator(this, mf); } void cmGlobalNinjaGenerator diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index ecc8928..d204a50 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -167,7 +167,7 @@ public: virtual ~cmGlobalNinjaGenerator() { } - virtual cmLocalGenerator* CreateLocalGenerator(cmState::Snapshot snapshot); + virtual cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf); virtual std::string GetName() const { return cmGlobalNinjaGenerator::GetActualName(); } diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 0d4ee15..cf4fd69 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -60,9 +60,9 @@ void cmGlobalUnixMakefileGenerator3 ///! Create a local generator appropriate to this Global Generator cmLocalGenerator* cmGlobalUnixMakefileGenerator3::CreateLocalGenerator( - cmState::Snapshot snapshot) + cmMakefile* mf) { - return new cmLocalUnixMakefileGenerator3(this, snapshot); + return new cmLocalUnixMakefileGenerator3(this, mf); } //---------------------------------------------------------------------------- @@ -577,17 +577,20 @@ void cmGlobalUnixMakefileGenerator3 makeOptions.begin(), makeOptions.end()); if (!targetName.empty()) { + cmMakefile* mf; cmLocalUnixMakefileGenerator3 *lg; if (!this->LocalGenerators.empty()) { lg = static_cast (this->LocalGenerators[0]); + mf = lg->GetMakefile(); } else { cmState::Snapshot snapshot = this->CMakeInstance->GetCurrentSnapshot(); + mf = new cmMakefile(this, snapshot); lg = static_cast - (this->CreateLocalGenerator(snapshot)); + (this->CreateLocalGenerator(mf)); // set the Start directories lg->GetMakefile()->SetCurrentSourceDirectory (this->CMakeInstance->GetHomeDirectory()); @@ -606,6 +609,7 @@ void cmGlobalUnixMakefileGenerator3 if (this->LocalGenerators.empty()) { delete lg; + delete mf; } } } diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index 3ea6bb2..5f39c79 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -67,8 +67,7 @@ public: /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); - ///! Create a local generator appropriate to this Global Generator3 - virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); + virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf); /** * Try to determine system information such as shared library diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index a36fed1..44d632d 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -307,9 +307,9 @@ void cmGlobalVisualStudio10Generator::WriteSLNHeader(std::ostream& fout) ///! Create a local generator appropriate to this Global Generator cmLocalGenerator* cmGlobalVisualStudio10Generator::CreateLocalGenerator( - cmState::Snapshot snapshot) + cmMakefile* mf) { - return new cmLocalVisualStudio10Generator(this, snapshot); + return new cmLocalVisualStudio10Generator(this, mf); } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index bbc22b9..8de7b09 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -48,7 +48,7 @@ public: virtual bool Compute(); ///! create the correct local generator - virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); + virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf); /** * Try to determine system information such as shared library diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx index 48c3d32..df49948 100644 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ b/Source/cmGlobalVisualStudio6Generator.cxx @@ -173,10 +173,9 @@ cmGlobalVisualStudio6Generator::GenerateBuildCommand( ///! Create a local generator appropriate to this Global Generator cmLocalGenerator * -cmGlobalVisualStudio6Generator::CreateLocalGenerator( - cmState::Snapshot snapshot) +cmGlobalVisualStudio6Generator::CreateLocalGenerator(cmMakefile* mf) { - return new cmLocalVisualStudio6Generator(this, snapshot); + return new cmLocalVisualStudio6Generator(this, mf); } diff --git a/Source/cmGlobalVisualStudio6Generator.h b/Source/cmGlobalVisualStudio6Generator.h index 0169be0..e9b24ea 100644 --- a/Source/cmGlobalVisualStudio6Generator.h +++ b/Source/cmGlobalVisualStudio6Generator.h @@ -39,7 +39,7 @@ public: static void GetDocumentation(cmDocumentationEntry& entry); ///! Create a local generator appropriate to this Global Generator - virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); + virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf); /** * Try to determine system information such as shared library diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index b8f6357..0175062 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -280,10 +280,10 @@ void cmGlobalVisualStudio7Generator::GenerateBuildCommand( ///! Create a local generator appropriate to this Global Generator cmLocalGenerator *cmGlobalVisualStudio7Generator::CreateLocalGenerator( - cmState::Snapshot snapshot) + cmMakefile* mf) { cmLocalVisualStudio7Generator *lg = - new cmLocalVisualStudio7Generator(this, snapshot); + new cmLocalVisualStudio7Generator(this, mf); return lg; } diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 5ada2c5..35575d1 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -43,7 +43,7 @@ public: std::string const& GetPlatformName() const; ///! Create a local generator appropriate to this Global Generator - virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); + virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf); virtual bool SetSystemName(std::string const& s, cmMakefile* mf); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index af3629d..33babec 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -371,9 +371,9 @@ cmGlobalXCodeGenerator::GenerateBuildCommand( //---------------------------------------------------------------------------- ///! Create a local generator appropriate to this Global Generator cmLocalGenerator * -cmGlobalXCodeGenerator::CreateLocalGenerator(cmState::Snapshot snapshot) +cmGlobalXCodeGenerator::CreateLocalGenerator(cmMakefile* mf) { - return new cmLocalXCodeGenerator(this, snapshot); + return new cmLocalXCodeGenerator(this, mf); } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index f93f62f..102c036 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -41,7 +41,7 @@ public: static void GetDocumentation(cmDocumentationEntry& entry); ///! Create a local generator appropriate to this Global Generator - virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); + virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile *mf); /** * Try to determine system information such as shared library diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx index 7da3085..2023697 100644 --- a/Source/cmGraphVizWriter.cxx +++ b/Source/cmGraphVizWriter.cxx @@ -68,9 +68,9 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName, cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); cmGlobalGenerator ggi(&cm); - cmsys::auto_ptr lg( - ggi.CreateLocalGenerator(cm.GetCurrentSnapshot())); - cmMakefile *mf = lg->GetMakefile(); + cmsys::auto_ptr mf( + new cmMakefile(&ggi, cm.GetCurrentSnapshot())); + cmsys::auto_ptr lg(ggi.CreateLocalGenerator(mf.get())); const char* inFileName = settingsFileName; diff --git a/Source/cmLocalCommonGenerator.cxx b/Source/cmLocalCommonGenerator.cxx index 58c707c..5a18e2f 100644 --- a/Source/cmLocalCommonGenerator.cxx +++ b/Source/cmLocalCommonGenerator.cxx @@ -14,8 +14,8 @@ #include "cmMakefile.h" cmLocalCommonGenerator::cmLocalCommonGenerator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot): - cmLocalGenerator(gg, snapshot) + cmMakefile* mf): + cmLocalGenerator(gg, mf) { } diff --git a/Source/cmLocalCommonGenerator.h b/Source/cmLocalCommonGenerator.h index b7caf0b..6b4b1cd 100644 --- a/Source/cmLocalCommonGenerator.h +++ b/Source/cmLocalCommonGenerator.h @@ -22,8 +22,7 @@ class cmCommonTargetGenerator; class cmLocalCommonGenerator: public cmLocalGenerator { public: - cmLocalCommonGenerator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot); + cmLocalCommonGenerator(cmGlobalGenerator* gg, cmMakefile* mf); ~cmLocalCommonGenerator(); std::string const& GetConfigName() { return this->ConfigName; } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 357a508..455b698 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -43,13 +43,13 @@ #endif cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot) - : cmOutputConverter(snapshot), StateSnapshot(snapshot) + cmMakefile* makefile) + : cmOutputConverter(makefile->GetStateSnapshot()), + StateSnapshot(makefile->GetStateSnapshot()) { - assert(snapshot.IsValid()); this->GlobalGenerator = gg; - this->Makefile = new cmMakefile(gg, snapshot); + this->Makefile = makefile; this->EmitUniversalBinaryFlags = true; this->BackwardsCompatibility = 0; @@ -58,7 +58,6 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg, cmLocalGenerator::~cmLocalGenerator() { - delete this->Makefile; } void cmLocalGenerator::IssueMessage(cmake::MessageType t, diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 4c0b1fe..28b5ed1 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -36,7 +36,7 @@ class cmCustomCommandGenerator; class cmLocalGenerator : public cmOutputConverter { public: - cmLocalGenerator(cmGlobalGenerator* gg, cmState::Snapshot snapshot); + cmLocalGenerator(cmGlobalGenerator* gg, cmMakefile* makefile); virtual ~cmLocalGenerator(); /** diff --git a/Source/cmLocalGhsMultiGenerator.cxx b/Source/cmLocalGhsMultiGenerator.cxx index 91dfeb4..bac989f 100644 --- a/Source/cmLocalGhsMultiGenerator.cxx +++ b/Source/cmLocalGhsMultiGenerator.cxx @@ -17,8 +17,8 @@ #include "cmGeneratedFileStream.h" cmLocalGhsMultiGenerator::cmLocalGhsMultiGenerator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot) - : cmLocalGenerator(gg, snapshot) + cmMakefile* mf) + : cmLocalGenerator(gg, mf) { } diff --git a/Source/cmLocalGhsMultiGenerator.h b/Source/cmLocalGhsMultiGenerator.h index 3309bfd..b6a9a33 100644 --- a/Source/cmLocalGhsMultiGenerator.h +++ b/Source/cmLocalGhsMultiGenerator.h @@ -25,8 +25,7 @@ class cmGeneratedFileStream; class cmLocalGhsMultiGenerator : public cmLocalGenerator { public: - cmLocalGhsMultiGenerator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot); + cmLocalGhsMultiGenerator(cmGlobalGenerator* gg, cmMakefile* mf); virtual ~cmLocalGhsMultiGenerator(); diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 62bf8b2..7525bf2 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -23,8 +23,8 @@ #include cmLocalNinjaGenerator::cmLocalNinjaGenerator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot) - : cmLocalCommonGenerator(gg, snapshot) + cmMakefile* mf) + : cmLocalCommonGenerator(gg, mf) , HomeRelativeOutputPath("") { this->TargetImplib = "$TARGET_IMPLIB"; diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index 4c158bc..8d3d49c 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -31,8 +31,7 @@ class cmake; class cmLocalNinjaGenerator : public cmLocalCommonGenerator { public: - cmLocalNinjaGenerator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot); + cmLocalNinjaGenerator(cmGlobalGenerator* gg, cmMakefile* mf); virtual ~cmLocalNinjaGenerator(); diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index d2b60d3..b131a63 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -80,9 +80,8 @@ static std::string cmSplitExtension(std::string const& in, std::string& base) //---------------------------------------------------------------------------- cmLocalUnixMakefileGenerator3:: -cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg, - cmState::Snapshot snapshot) - : cmLocalCommonGenerator(gg, snapshot) +cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg, cmMakefile* mf) + : cmLocalCommonGenerator(gg, mf) { this->MakefileVariableSize = 0; this->ColorMakefile = false; diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index 2b9af38..98f15e6 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -34,8 +34,7 @@ class cmSourceFile; class cmLocalUnixMakefileGenerator3 : public cmLocalCommonGenerator { public: - cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg, - cmState::Snapshot snapshot); + cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg, cmMakefile* mf); virtual ~cmLocalUnixMakefileGenerator3(); virtual void ComputeHomeRelativeOutputPath(); diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx index 25b3f19..b043b00 100644 --- a/Source/cmLocalVisualStudio10Generator.cxx +++ b/Source/cmLocalVisualStudio10Generator.cxx @@ -62,9 +62,8 @@ class cmVS10XMLParser : public cmXMLParser //---------------------------------------------------------------------------- cmLocalVisualStudio10Generator -::cmLocalVisualStudio10Generator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot): - cmLocalVisualStudio7Generator(gg, snapshot) +::cmLocalVisualStudio10Generator(cmGlobalGenerator* gg, cmMakefile* mf): + cmLocalVisualStudio7Generator(gg, mf) { } diff --git a/Source/cmLocalVisualStudio10Generator.h b/Source/cmLocalVisualStudio10Generator.h index 0f179fd..e187590 100644 --- a/Source/cmLocalVisualStudio10Generator.h +++ b/Source/cmLocalVisualStudio10Generator.h @@ -25,8 +25,7 @@ class cmLocalVisualStudio10Generator : public cmLocalVisualStudio7Generator { public: ///! Set cache only and recurse to false by default. - cmLocalVisualStudio10Generator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot); + cmLocalVisualStudio10Generator(cmGlobalGenerator* gg, cmMakefile* mf); virtual ~cmLocalVisualStudio10Generator(); diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 46e1987..cc94cd4 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -24,9 +24,8 @@ #include cmLocalVisualStudio6Generator -::cmLocalVisualStudio6Generator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot): - cmLocalVisualStudioGenerator(gg, snapshot) +::cmLocalVisualStudio6Generator(cmGlobalGenerator* gg, cmMakefile* mf): + cmLocalVisualStudioGenerator(gg, mf) { } diff --git a/Source/cmLocalVisualStudio6Generator.h b/Source/cmLocalVisualStudio6Generator.h index 86b4906..828d252 100644 --- a/Source/cmLocalVisualStudio6Generator.h +++ b/Source/cmLocalVisualStudio6Generator.h @@ -29,8 +29,7 @@ class cmLocalVisualStudio6Generator : public cmLocalVisualStudioGenerator { public: ///! Set cache only and recurse to false by default. - cmLocalVisualStudio6Generator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot); + cmLocalVisualStudio6Generator(cmGlobalGenerator* gg, cmMakefile* mf); virtual ~cmLocalVisualStudio6Generator(); diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index eebed7e..cf67251 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -53,9 +53,8 @@ static void cmConvertToWindowsSlash(std::string& s) //---------------------------------------------------------------------------- cmLocalVisualStudio7Generator -::cmLocalVisualStudio7Generator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot): - cmLocalVisualStudioGenerator(gg, snapshot) +::cmLocalVisualStudio7Generator(cmGlobalGenerator* gg, cmMakefile* mf): + cmLocalVisualStudioGenerator(gg, mf) { this->Internal = new cmLocalVisualStudio7GeneratorInternals(this); } diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h index 42ae097..bc05a06 100644 --- a/Source/cmLocalVisualStudio7Generator.h +++ b/Source/cmLocalVisualStudio7Generator.h @@ -35,8 +35,7 @@ class cmLocalVisualStudio7Generator : public cmLocalVisualStudioGenerator { public: ///! Set cache only and recurse to false by default. - cmLocalVisualStudio7Generator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot); + cmLocalVisualStudio7Generator(cmGlobalGenerator* gg, cmMakefile* mf); virtual ~cmLocalVisualStudio7Generator(); diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index 70f729f..c0072de 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/Source/cmLocalVisualStudioGenerator.cxx @@ -19,9 +19,8 @@ //---------------------------------------------------------------------------- cmLocalVisualStudioGenerator -::cmLocalVisualStudioGenerator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot) - : cmLocalGenerator(gg, snapshot) +::cmLocalVisualStudioGenerator(cmGlobalGenerator* gg, cmMakefile* mf) + : cmLocalGenerator(gg, mf) { } diff --git a/Source/cmLocalVisualStudioGenerator.h b/Source/cmLocalVisualStudioGenerator.h index 32244c7..071bfb3 100644 --- a/Source/cmLocalVisualStudioGenerator.h +++ b/Source/cmLocalVisualStudioGenerator.h @@ -31,8 +31,7 @@ class cmCustomCommandGenerator; class cmLocalVisualStudioGenerator : public cmLocalGenerator { public: - cmLocalVisualStudioGenerator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot); + cmLocalVisualStudioGenerator(cmGlobalGenerator* gg, cmMakefile* mf); virtual ~cmLocalVisualStudioGenerator(); /** Construct a script from the given list of command lines. */ diff --git a/Source/cmLocalXCodeGenerator.cxx b/Source/cmLocalXCodeGenerator.cxx index d6576f6..b19112d 100644 --- a/Source/cmLocalXCodeGenerator.cxx +++ b/Source/cmLocalXCodeGenerator.cxx @@ -16,8 +16,8 @@ //---------------------------------------------------------------------------- cmLocalXCodeGenerator::cmLocalXCodeGenerator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot) - : cmLocalGenerator(gg, snapshot) + cmMakefile* mf) + : cmLocalGenerator(gg, mf) { // the global generator does this, so do not // put these flags into the language flags diff --git a/Source/cmLocalXCodeGenerator.h b/Source/cmLocalXCodeGenerator.h index d96e78c..6d0926f 100644 --- a/Source/cmLocalXCodeGenerator.h +++ b/Source/cmLocalXCodeGenerator.h @@ -25,7 +25,7 @@ class cmLocalXCodeGenerator : public cmLocalGenerator public: ///! Set cache only and recurse to false by default. cmLocalXCodeGenerator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot); + cmMakefile* mf); virtual ~cmLocalXCodeGenerator(); virtual std::string GetTargetDirectory(cmTarget const& target) const; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 1df6213..e28efc1 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -16,7 +16,6 @@ #include "cmSourceFileLocation.h" #include "cmSystemTools.h" #include "cmGlobalGenerator.h" -#include "cmLocalGenerator.h" #include "cmCommands.h" #include "cmState.h" #include "cmOutputConverter.h" @@ -1754,13 +1753,15 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath, this->ContextStack.back()->Name, this->ContextStack.back()->Line); + cmMakefile* subMf = new cmMakefile(this->GlobalGenerator, newSnapshot); + this->GetGlobalGenerator()->AddMakefile(subMf); + // create a new local generator and set its parent cmLocalGenerator *lg2 = this->GetGlobalGenerator() - ->CreateLocalGenerator(newSnapshot); + ->CreateLocalGenerator(subMf); this->GetGlobalGenerator()->AddMakefile(lg2->GetMakefile()); this->GetGlobalGenerator()->AddLocalGenerator(lg2); - cmMakefile* subMf = lg2->GetMakefile(); // set the subdirs start dirs subMf->SetCurrentSourceDirectory(srcPath); diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 278f220..becfeba 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -1218,7 +1218,8 @@ bool cmQtAutoGenerators::Run(const std::string& targetDirectory, cmGlobalGenerator gg(&cm); cmState::Snapshot snapshot = cm.GetCurrentSnapshot(); - cmsys::auto_ptr lg = gg.CreateLocalGenerator(snapshot); + cmsys::auto_ptr mf(new cmMakefile(&gg, snapshot)); + cmsys::auto_ptr lg(gg.CreateLocalGenerator(mf.get())); lg->GetMakefile()->SetCurrentBinaryDirectory(targetDirectory); lg->GetMakefile()->SetCurrentSourceDirectory(targetDirectory); gg.SetCurrentMakefile(lg->GetMakefile()); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index ebc38d8..f069481 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -430,7 +430,8 @@ void cmake::ReadListFile(const std::vector& args, this->SetHomeDirectory(cmSystemTools::GetCurrentWorkingDirectory()); this->SetHomeOutputDirectory(cmSystemTools::GetCurrentWorkingDirectory()); cmState::Snapshot snapshot = this->GetCurrentSnapshot(); - cmsys::auto_ptr lg(gg->CreateLocalGenerator(snapshot)); + cmsys::auto_ptr mf(new cmMakefile(gg, snapshot)); + cmsys::auto_ptr lg(gg->CreateLocalGenerator(mf.get())); lg->GetMakefile()->SetCurrentBinaryDirectory (cmSystemTools::GetCurrentWorkingDirectory()); lg->GetMakefile()->SetCurrentSourceDirectory @@ -472,8 +473,8 @@ bool cmake::FindPackage(const std::vector& args) cmState::Snapshot snapshot = this->GetCurrentSnapshot(); // read in the list file to fill the cache - cmsys::auto_ptr lg(gg->CreateLocalGenerator(snapshot)); - cmMakefile* mf = lg->GetMakefile(); + cmsys::auto_ptr mf(new cmMakefile(gg, snapshot)); + cmsys::auto_ptr lg(gg->CreateLocalGenerator(mf.get())); mf->SetCurrentBinaryDirectory (cmSystemTools::GetCurrentWorkingDirectory()); mf->SetCurrentSourceDirectory @@ -2061,9 +2062,8 @@ int cmake::CheckBuildSystem() cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); cmGlobalGenerator gg(&cm); - cmsys::auto_ptr lg( - gg.CreateLocalGenerator(cm.GetCurrentSnapshot())); - cmMakefile* mf = lg->GetMakefile(); + cmsys::auto_ptr mf(new cmMakefile(&gg, cm.GetCurrentSnapshot())); + cmsys::auto_ptr lg(gg.CreateLocalGenerator(mf.get())); if(!mf->ReadListFile(this->CheckBuildSystemArgument.c_str()) || cmSystemTools::GetErrorOccuredFlag()) { @@ -2092,9 +2092,11 @@ int cmake::CheckBuildSystem() ggd(this->CreateGlobalGenerator(genName)); if(ggd.get()) { + cmsys::auto_ptr mfd(new cmMakefile(ggd.get(), + cm.GetCurrentSnapshot())); cmsys::auto_ptr lgd( - ggd->CreateLocalGenerator(cm.GetCurrentSnapshot())); - lgd->ClearDependencies(mf, verbose); + ggd->CreateLocalGenerator(mfd.get())); + lgd->ClearDependencies(mfd.get(), verbose); } } diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index c788474..aa70aa0 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -769,8 +769,9 @@ int cmcmd::ExecuteCMakeCommand(std::vector& args) { cm.SetGlobalGenerator(ggd); cmState::Snapshot snapshot = cm.GetCurrentSnapshot(); + cmsys::auto_ptr mf(new cmMakefile(ggd, snapshot)); cmsys::auto_ptr lgd( - ggd->CreateLocalGenerator(snapshot)); + ggd->CreateLocalGenerator(mf.get())); lgd->GetMakefile()->SetCurrentSourceDirectory(startDir); lgd->GetMakefile()->SetCurrentBinaryDirectory(startOutDir); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=53b616680069cde4f2c4d06cb31228a141bf92b8 commit 53b616680069cde4f2c4d06cb31228a141bf92b8 Author: Stephen Kelly AuthorDate: Thu Aug 27 22:13:34 2015 +0200 Commit: Stephen Kelly CommitDate: Thu Aug 27 22:13:34 2015 +0200 Ninja: Remove some incorrect comments adding no value. diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 418d6f7..ecc8928 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -162,32 +162,24 @@ public: public: cmGlobalNinjaGenerator(cmake* cm); - /// Convenience method for creating an instance of this class. static cmGlobalGeneratorFactory* NewFactory() { return new cmGlobalGeneratorSimpleFactory(); } - /// Destructor. virtual ~cmGlobalNinjaGenerator() { } - /// Overloaded methods. @see cmGlobalGenerator::CreateLocalGenerator() virtual cmLocalGenerator* CreateLocalGenerator(cmState::Snapshot snapshot); - /// Overloaded methods. @see cmGlobalGenerator::GetName(). virtual std::string GetName() const { return cmGlobalNinjaGenerator::GetActualName(); } - /// @return the name of this generator. static std::string GetActualName() { return "Ninja"; } - /// Overloaded methods. @see cmGlobalGenerator::GetDocumentation() static void GetDocumentation(cmDocumentationEntry& entry); - /// Overloaded methods. @see cmGlobalGenerator::EnableLanguage() virtual void EnableLanguage(std::vectorconst& languages, cmMakefile* mf, bool optional); - /// Overloaded methods. @see cmGlobalGenerator::GenerateBuildCommand() virtual void GenerateBuildCommand( std::vector& makeCommand, const std::string& makeProgram, @@ -306,11 +298,8 @@ public: protected: - /// Overloaded methods. @see cmGlobalGenerator::Generate() virtual void Generate(); - /// Overloaded methods. - /// @see cmGlobalGenerator::CheckALLOW_DUPLICATE_CUSTOM_TARGETS() virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const { return true; } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a72a99b0d2474f09620e1a52a46e3ba74b1d99fa commit a72a99b0d2474f09620e1a52a46e3ba74b1d99fa Author: Stephen Kelly AuthorDate: Mon Aug 24 23:00:21 2015 +0200 Commit: Stephen Kelly CommitDate: Thu Aug 27 21:39:18 2015 +0200 cmCTestScriptHandler: Simplify deletes. Deleting a nullptr is fine. diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 8327f29..4be5eb6 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -126,20 +126,14 @@ void cmCTestScriptHandler::Initialize() this->ScriptStartTime = 0; this->Makefile = 0; - if (this->LocalGenerator) - { - delete this->LocalGenerator; - } + + delete this->LocalGenerator; this->LocalGenerator = 0; - if (this->GlobalGenerator) - { - delete this->GlobalGenerator; - } + + delete this->GlobalGenerator; this->GlobalGenerator = 0; - if (this->CMake) - { - delete this->CMake; - } + + delete this->CMake; } //---------------------------------------------------------------------- @@ -147,20 +141,9 @@ cmCTestScriptHandler::~cmCTestScriptHandler() { // local generator owns the makefile this->Makefile = 0; - if (this->LocalGenerator) - { - delete this->LocalGenerator; - } - this->LocalGenerator = 0; - if (this->GlobalGenerator) - { - delete this->GlobalGenerator; - } - this->GlobalGenerator = 0; - if (this->CMake) - { - delete this->CMake; - } + delete this->LocalGenerator; + delete this->GlobalGenerator; + delete this->CMake; } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3b788d5d723bbc6c4e5849943f421e4c6aa509df commit 3b788d5d723bbc6c4e5849943f421e4c6aa509df Author: Stephen Kelly AuthorDate: Sun Aug 2 11:41:48 2015 +0200 Commit: Stephen Kelly CommitDate: Thu Aug 27 21:39:18 2015 +0200 QtAutogen: Use a smart pointer. diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 9cb005c..278f220 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -1218,7 +1218,7 @@ bool cmQtAutoGenerators::Run(const std::string& targetDirectory, cmGlobalGenerator gg(&cm); cmState::Snapshot snapshot = cm.GetCurrentSnapshot(); - cmLocalGenerator* lg = gg.CreateLocalGenerator(snapshot); + cmsys::auto_ptr lg = gg.CreateLocalGenerator(snapshot); lg->GetMakefile()->SetCurrentBinaryDirectory(targetDirectory); lg->GetMakefile()->SetCurrentSourceDirectory(targetDirectory); gg.SetCurrentMakefile(lg->GetMakefile()); @@ -1235,7 +1235,6 @@ bool cmQtAutoGenerators::Run(const std::string& targetDirectory, this->WriteOldMocDefinitionsFile(targetDirectory); - delete lg; return success; } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2cdac1ac2011281e5fbba7b1641a729597cc0ba8 commit 2cdac1ac2011281e5fbba7b1641a729597cc0ba8 Author: Stephen Kelly AuthorDate: Sun Aug 2 11:30:12 2015 +0200 Commit: Stephen Kelly CommitDate: Thu Aug 27 21:39:18 2015 +0200 cmGlobalGenerator: Remove MakeLocalGenerator method. Inline implementation to callers. diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 68509a5..8cbcd4e 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -717,7 +717,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( cm.SetProgressCallback(cmCPackGeneratorProgress, this); cmGlobalGenerator gg(&cm); cmsys::auto_ptr lg( - gg.MakeLocalGenerator(cm.GetCurrentSnapshot())); + gg.CreateLocalGenerator(cm.GetCurrentSnapshot())); cmMakefile *mf = lg->GetMakefile(); std::string realInstallDirectory = tempInstallDirectory; if ( !installSubDirectory.empty() && installSubDirectory != "/" ) diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index 0c53d1b..96351f7 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -203,7 +203,7 @@ int main (int argc, char const* const* argv) cminst.GetState()->RemoveUnscriptableCommands(); cmGlobalGenerator cmgg(&cminst); cmsys::auto_ptr cmlg( - cmgg.MakeLocalGenerator(cminst.GetCurrentSnapshot())); + cmgg.CreateLocalGenerator(cminst.GetCurrentSnapshot())); cmMakefile* globalMF = cmlg->GetMakefile(); #if defined(__CYGWIN__) globalMF->AddDefinition("CMAKE_LEGACY_CYGWIN_WIN32", "0"); diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx index d978568..7340d5c 100644 --- a/Source/CTest/cmCTestLaunch.cxx +++ b/Source/CTest/cmCTestLaunch.cxx @@ -739,7 +739,7 @@ void cmCTestLaunch::LoadConfig() cm.SetHomeOutputDirectory(""); cmGlobalGenerator gg(&cm); cmsys::auto_ptr lg( - gg.MakeLocalGenerator(cm.GetCurrentSnapshot())); + gg.CreateLocalGenerator(cm.GetCurrentSnapshot())); cmMakefile* mf = lg->GetMakefile(); std::string fname = this->LogDir; fname += "CTestLaunchConfig.cmake"; diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index c791302..8327f29 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -342,7 +342,7 @@ void cmCTestScriptHandler::CreateCMake() this->GlobalGenerator = new cmGlobalGenerator(this->CMake); cmState::Snapshot snapshot = this->CMake->GetCurrentSnapshot(); - this->LocalGenerator = this->GlobalGenerator->MakeLocalGenerator(snapshot); + this->LocalGenerator = this->GlobalGenerator->CreateLocalGenerator(snapshot); this->Makefile = this->LocalGenerator->GetMakefile(); this->CMake->SetProgressCallback(ctestScriptProgressCallback, this->CTest); diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 3262efd..9e00193 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -1593,7 +1593,7 @@ void cmCTestTestHandler::GetListOfTests() cm.SetHomeOutputDirectory(""); cmGlobalGenerator gg(&cm); cmsys::auto_ptr lg( - gg.MakeLocalGenerator(cm.GetCurrentSnapshot())); + gg.CreateLocalGenerator(cm.GetCurrentSnapshot())); cmMakefile *mf = lg->GetMakefile(); mf->AddDefinition("CTEST_CONFIGURATION_TYPE", this->CTest->GetConfigType().c_str()); diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index f020f9e..1786c2c 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -521,7 +521,7 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command) cm.SetHomeOutputDirectory(""); cmGlobalGenerator gg(&cm); cmsys::auto_ptr lg( - gg.MakeLocalGenerator(cm.GetCurrentSnapshot())); + gg.CreateLocalGenerator(cm.GetCurrentSnapshot())); cmMakefile *mf = lg->GetMakefile(); if ( !this->ReadCustomConfigurationFileTree(this->BinaryDir.c_str(), mf) ) { diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index efb119a..7de807b 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1128,7 +1128,7 @@ void cmGlobalGenerator::Configure() this->ClearGeneratorMembers(); // start with this directory - cmLocalGenerator *lg = this->MakeLocalGenerator(); + cmLocalGenerator *lg = this->CreateLocalGenerator(); this->Makefiles.push_back(lg->GetMakefile()); this->LocalGenerators.push_back(lg); @@ -1985,12 +1985,6 @@ void cmGlobalGenerator::EnableInstallTarget() this->InstallTargetEnabled = true; } -cmLocalGenerator * -cmGlobalGenerator::MakeLocalGenerator(cmState::Snapshot snapshot) -{ - return this->CreateLocalGenerator(snapshot); -} - cmLocalGenerator* cmGlobalGenerator::CreateLocalGenerator(cmState::Snapshot snapshot) { diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 2e0f7b5..91c1aac 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -56,8 +56,8 @@ public: cmGlobalGenerator(cmake* cm); virtual ~cmGlobalGenerator(); - cmLocalGenerator* - MakeLocalGenerator(cmState::Snapshot snapshot = cmState::Snapshot()); + virtual cmLocalGenerator* + CreateLocalGenerator(cmState::Snapshot snapshot = cmState::Snapshot()); ///! Get the name for this generator virtual std::string GetName() const { return "Generic"; } @@ -440,9 +440,6 @@ protected: virtual bool UseFolderProperty(); private: - ///! Create a local generator appropriate to this Global Generator - virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); - cmMakefile* TryCompileOuterMakefile; // If you add a new map here, make sure it is copied // in EnableLanguagesFromGenerator diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index c396af4..0d4ee15 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -587,7 +587,7 @@ void cmGlobalUnixMakefileGenerator3 { cmState::Snapshot snapshot = this->CMakeInstance->GetCurrentSnapshot(); lg = static_cast - (this->MakeLocalGenerator(snapshot)); + (this->CreateLocalGenerator(snapshot)); // set the Start directories lg->GetMakefile()->SetCurrentSourceDirectory (this->CMakeInstance->GetHomeDirectory()); diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx index 797b198..7da3085 100644 --- a/Source/cmGraphVizWriter.cxx +++ b/Source/cmGraphVizWriter.cxx @@ -69,7 +69,7 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName, cm.SetHomeOutputDirectory(""); cmGlobalGenerator ggi(&cm); cmsys::auto_ptr lg( - ggi.MakeLocalGenerator(cm.GetCurrentSnapshot())); + ggi.CreateLocalGenerator(cm.GetCurrentSnapshot())); cmMakefile *mf = lg->GetMakefile(); const char* inFileName = settingsFileName; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 10ce0b3..1df6213 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1756,7 +1756,7 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath, // create a new local generator and set its parent cmLocalGenerator *lg2 = this->GetGlobalGenerator() - ->MakeLocalGenerator(newSnapshot); + ->CreateLocalGenerator(newSnapshot); this->GetGlobalGenerator()->AddMakefile(lg2->GetMakefile()); this->GetGlobalGenerator()->AddLocalGenerator(lg2); diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index c6c045a..9cb005c 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -1218,7 +1218,7 @@ bool cmQtAutoGenerators::Run(const std::string& targetDirectory, cmGlobalGenerator gg(&cm); cmState::Snapshot snapshot = cm.GetCurrentSnapshot(); - cmLocalGenerator* lg = gg.MakeLocalGenerator(snapshot); + cmLocalGenerator* lg = gg.CreateLocalGenerator(snapshot); lg->GetMakefile()->SetCurrentBinaryDirectory(targetDirectory); lg->GetMakefile()->SetCurrentSourceDirectory(targetDirectory); gg.SetCurrentMakefile(lg->GetMakefile()); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 29271b8..ebc38d8 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -430,7 +430,7 @@ void cmake::ReadListFile(const std::vector& args, this->SetHomeDirectory(cmSystemTools::GetCurrentWorkingDirectory()); this->SetHomeOutputDirectory(cmSystemTools::GetCurrentWorkingDirectory()); cmState::Snapshot snapshot = this->GetCurrentSnapshot(); - cmsys::auto_ptr lg(gg->MakeLocalGenerator(snapshot)); + cmsys::auto_ptr lg(gg->CreateLocalGenerator(snapshot)); lg->GetMakefile()->SetCurrentBinaryDirectory (cmSystemTools::GetCurrentWorkingDirectory()); lg->GetMakefile()->SetCurrentSourceDirectory @@ -472,7 +472,7 @@ bool cmake::FindPackage(const std::vector& args) cmState::Snapshot snapshot = this->GetCurrentSnapshot(); // read in the list file to fill the cache - cmsys::auto_ptr lg(gg->MakeLocalGenerator(snapshot)); + cmsys::auto_ptr lg(gg->CreateLocalGenerator(snapshot)); cmMakefile* mf = lg->GetMakefile(); mf->SetCurrentBinaryDirectory (cmSystemTools::GetCurrentWorkingDirectory()); @@ -2062,7 +2062,7 @@ int cmake::CheckBuildSystem() cm.SetHomeOutputDirectory(""); cmGlobalGenerator gg(&cm); cmsys::auto_ptr lg( - gg.MakeLocalGenerator(cm.GetCurrentSnapshot())); + gg.CreateLocalGenerator(cm.GetCurrentSnapshot())); cmMakefile* mf = lg->GetMakefile(); if(!mf->ReadListFile(this->CheckBuildSystemArgument.c_str()) || cmSystemTools::GetErrorOccuredFlag()) @@ -2093,7 +2093,7 @@ int cmake::CheckBuildSystem() if(ggd.get()) { cmsys::auto_ptr lgd( - ggd->MakeLocalGenerator(cm.GetCurrentSnapshot())); + ggd->CreateLocalGenerator(cm.GetCurrentSnapshot())); lgd->ClearDependencies(mf, verbose); } } diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 868dbe3..c788474 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -770,7 +770,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector& args) cm.SetGlobalGenerator(ggd); cmState::Snapshot snapshot = cm.GetCurrentSnapshot(); cmsys::auto_ptr lgd( - ggd->MakeLocalGenerator(snapshot)); + ggd->CreateLocalGenerator(snapshot)); lgd->GetMakefile()->SetCurrentSourceDirectory(startDir); lgd->GetMakefile()->SetCurrentBinaryDirectory(startOutDir); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c2de8617cec667afe49da3f592964a25fe7b50e0 commit c2de8617cec667afe49da3f592964a25fe7b50e0 Author: Stephen Kelly AuthorDate: Sun May 31 01:43:31 2015 +0200 Commit: Stephen Kelly CommitDate: Thu Aug 27 21:39:18 2015 +0200 cmGlobalGenerator: Require a snapshot to create a local generator. diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index bf4df60..68509a5 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -716,7 +716,8 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( cm.AddCMakePaths(); cm.SetProgressCallback(cmCPackGeneratorProgress, this); cmGlobalGenerator gg(&cm); - cmsys::auto_ptr lg(gg.MakeLocalGenerator()); + cmsys::auto_ptr lg( + gg.MakeLocalGenerator(cm.GetCurrentSnapshot())); cmMakefile *mf = lg->GetMakefile(); std::string realInstallDirectory = tempInstallDirectory; if ( !installSubDirectory.empty() && installSubDirectory != "/" ) diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index c2fe763..0c53d1b 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -202,7 +202,8 @@ int main (int argc, char const* const* argv) cminst.SetHomeOutputDirectory(""); cminst.GetState()->RemoveUnscriptableCommands(); cmGlobalGenerator cmgg(&cminst); - cmsys::auto_ptr cmlg(cmgg.MakeLocalGenerator()); + cmsys::auto_ptr cmlg( + cmgg.MakeLocalGenerator(cminst.GetCurrentSnapshot())); cmMakefile* globalMF = cmlg->GetMakefile(); #if defined(__CYGWIN__) globalMF->AddDefinition("CMAKE_LEGACY_CYGWIN_WIN32", "0"); diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx index 0f588c5..d978568 100644 --- a/Source/CTest/cmCTestLaunch.cxx +++ b/Source/CTest/cmCTestLaunch.cxx @@ -738,7 +738,8 @@ void cmCTestLaunch::LoadConfig() cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); cmGlobalGenerator gg(&cm); - cmsys::auto_ptr lg(gg.MakeLocalGenerator()); + cmsys::auto_ptr lg( + gg.MakeLocalGenerator(cm.GetCurrentSnapshot())); cmMakefile* mf = lg->GetMakefile(); std::string fname = this->LogDir; fname += "CTestLaunchConfig.cmake"; diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 047bd98..c791302 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -341,7 +341,8 @@ void cmCTestScriptHandler::CreateCMake() this->CMake->AddCMakePaths(); this->GlobalGenerator = new cmGlobalGenerator(this->CMake); - this->LocalGenerator = this->GlobalGenerator->MakeLocalGenerator(); + cmState::Snapshot snapshot = this->CMake->GetCurrentSnapshot(); + this->LocalGenerator = this->GlobalGenerator->MakeLocalGenerator(snapshot); this->Makefile = this->LocalGenerator->GetMakefile(); this->CMake->SetProgressCallback(ctestScriptProgressCallback, this->CTest); diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index c8a0d27..3262efd 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -1592,7 +1592,8 @@ void cmCTestTestHandler::GetListOfTests() cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); cmGlobalGenerator gg(&cm); - cmsys::auto_ptr lg(gg.MakeLocalGenerator()); + cmsys::auto_ptr lg( + gg.MakeLocalGenerator(cm.GetCurrentSnapshot())); cmMakefile *mf = lg->GetMakefile(); mf->AddDefinition("CTEST_CONFIGURATION_TYPE", this->CTest->GetConfigType().c_str()); diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index b976469..f020f9e 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -520,7 +520,8 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command) cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); cmGlobalGenerator gg(&cm); - cmsys::auto_ptr lg(gg.MakeLocalGenerator()); + cmsys::auto_ptr lg( + gg.MakeLocalGenerator(cm.GetCurrentSnapshot())); cmMakefile *mf = lg->GetMakefile(); if ( !this->ReadCustomConfigurationFileTree(this->BinaryDir.c_str(), mf) ) { diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 01f50ed..efb119a 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1988,11 +1988,6 @@ void cmGlobalGenerator::EnableInstallTarget() cmLocalGenerator * cmGlobalGenerator::MakeLocalGenerator(cmState::Snapshot snapshot) { - if (!snapshot.IsValid()) - { - snapshot = this->CMakeInstance->GetCurrentSnapshot(); - } - return this->CreateLocalGenerator(snapshot); } diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 0f491aa..c396af4 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -585,8 +585,9 @@ void cmGlobalUnixMakefileGenerator3 } else { + cmState::Snapshot snapshot = this->CMakeInstance->GetCurrentSnapshot(); lg = static_cast - (this->MakeLocalGenerator()); + (this->MakeLocalGenerator(snapshot)); // set the Start directories lg->GetMakefile()->SetCurrentSourceDirectory (this->CMakeInstance->GetHomeDirectory()); diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx index fa29b4f..797b198 100644 --- a/Source/cmGraphVizWriter.cxx +++ b/Source/cmGraphVizWriter.cxx @@ -68,7 +68,8 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName, cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); cmGlobalGenerator ggi(&cm); - cmsys::auto_ptr lg(ggi.MakeLocalGenerator()); + cmsys::auto_ptr lg( + ggi.MakeLocalGenerator(cm.GetCurrentSnapshot())); cmMakefile *mf = lg->GetMakefile(); const char* inFileName = settingsFileName; diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 0a4b546..c6c045a 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -1217,7 +1217,8 @@ bool cmQtAutoGenerators::Run(const std::string& targetDirectory, cm.SetHomeDirectory(targetDirectory); cmGlobalGenerator gg(&cm); - cmLocalGenerator* lg = gg.MakeLocalGenerator(); + cmState::Snapshot snapshot = cm.GetCurrentSnapshot(); + cmLocalGenerator* lg = gg.MakeLocalGenerator(snapshot); lg->GetMakefile()->SetCurrentBinaryDirectory(targetDirectory); lg->GetMakefile()->SetCurrentSourceDirectory(targetDirectory); gg.SetCurrentMakefile(lg->GetMakefile()); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 1f5c4d4..29271b8 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -429,7 +429,8 @@ void cmake::ReadListFile(const std::vector& args, std::string homeOutputDir = this->GetHomeOutputDirectory(); this->SetHomeDirectory(cmSystemTools::GetCurrentWorkingDirectory()); this->SetHomeOutputDirectory(cmSystemTools::GetCurrentWorkingDirectory()); - cmsys::auto_ptr lg(gg->MakeLocalGenerator()); + cmState::Snapshot snapshot = this->GetCurrentSnapshot(); + cmsys::auto_ptr lg(gg->MakeLocalGenerator(snapshot)); lg->GetMakefile()->SetCurrentBinaryDirectory (cmSystemTools::GetCurrentWorkingDirectory()); lg->GetMakefile()->SetCurrentSourceDirectory @@ -469,8 +470,9 @@ bool cmake::FindPackage(const std::vector& args) cmGlobalGenerator *gg = new cmGlobalGenerator(this); this->SetGlobalGenerator(gg); + cmState::Snapshot snapshot = this->GetCurrentSnapshot(); // read in the list file to fill the cache - cmsys::auto_ptr lg(gg->MakeLocalGenerator()); + cmsys::auto_ptr lg(gg->MakeLocalGenerator(snapshot)); cmMakefile* mf = lg->GetMakefile(); mf->SetCurrentBinaryDirectory (cmSystemTools::GetCurrentWorkingDirectory()); @@ -2059,7 +2061,8 @@ int cmake::CheckBuildSystem() cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); cmGlobalGenerator gg(&cm); - cmsys::auto_ptr lg(gg.MakeLocalGenerator()); + cmsys::auto_ptr lg( + gg.MakeLocalGenerator(cm.GetCurrentSnapshot())); cmMakefile* mf = lg->GetMakefile(); if(!mf->ReadListFile(this->CheckBuildSystemArgument.c_str()) || cmSystemTools::GetErrorOccuredFlag()) @@ -2089,7 +2092,8 @@ int cmake::CheckBuildSystem() ggd(this->CreateGlobalGenerator(genName)); if(ggd.get()) { - cmsys::auto_ptr lgd(ggd->MakeLocalGenerator()); + cmsys::auto_ptr lgd( + ggd->MakeLocalGenerator(cm.GetCurrentSnapshot())); lgd->ClearDependencies(mf, verbose); } } diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 7bee0ea..868dbe3 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -768,7 +768,9 @@ int cmcmd::ExecuteCMakeCommand(std::vector& args) if(cmGlobalGenerator* ggd = cm.CreateGlobalGenerator(gen)) { cm.SetGlobalGenerator(ggd); - cmsys::auto_ptr lgd(ggd->MakeLocalGenerator()); + cmState::Snapshot snapshot = cm.GetCurrentSnapshot(); + cmsys::auto_ptr lgd( + ggd->MakeLocalGenerator(snapshot)); lgd->GetMakefile()->SetCurrentSourceDirectory(startDir); lgd->GetMakefile()->SetCurrentBinaryDirectory(startOutDir); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fa22a66e8f60e2ee4c5308e3a239a977dd54c70e commit fa22a66e8f60e2ee4c5308e3a239a977dd54c70e Author: Stephen Kelly AuthorDate: Sun Aug 2 11:20:28 2015 +0200 Commit: Stephen Kelly CommitDate: Thu Aug 27 21:39:18 2015 +0200 cmMakefile: Remove cmLocalGenerator member. diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index aea14d5..357a508 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -49,7 +49,7 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg, assert(snapshot.IsValid()); this->GlobalGenerator = gg; - this->Makefile = new cmMakefile(this); + this->Makefile = new cmMakefile(gg, snapshot); this->EmitUniversalBinaryFlags = true; this->BackwardsCompatibility = 0; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 2ba12a4..10ce0b3 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -44,9 +44,10 @@ #include // default is not to be building executables -cmMakefile::cmMakefile(cmLocalGenerator* localGenerator) - : LocalGenerator(localGenerator), - StateSnapshot(localGenerator->GetStateSnapshot()) +cmMakefile::cmMakefile(cmGlobalGenerator* globalGenerator, + cmState::Snapshot const& snapshot) + : GlobalGenerator(globalGenerator), + StateSnapshot(snapshot) { this->IsSourceFileTryCompile = false; @@ -3744,12 +3745,12 @@ bool cmMakefile::GetIsSourceFileTryCompile() const cmake *cmMakefile::GetCMakeInstance() const { - return this->GetGlobalGenerator()->GetCMakeInstance(); + return this->GlobalGenerator->GetCMakeInstance(); } cmGlobalGenerator* cmMakefile::GetGlobalGenerator() const { - return this->LocalGenerator->GetGlobalGenerator(); + return this->GlobalGenerator; } #ifdef CMAKE_BUILD_WITH_CMAKE diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index f3839aa..3cf20a6 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -42,7 +42,6 @@ class cmFunctionBlocker; class cmCommand; class cmInstallGenerator; -class cmLocalGenerator; class cmMakeDepend; class cmSourceFile; class cmTest; @@ -71,7 +70,8 @@ public: /** * Construct an empty makefile. */ - cmMakefile(cmLocalGenerator* localGenerator); + cmMakefile(cmGlobalGenerator* globalGenerator, + const cmState::Snapshot& snapshot); /** * Destructor. @@ -856,7 +856,7 @@ protected: #endif std::vector FinalPassCommands; - cmLocalGenerator* LocalGenerator; + cmGlobalGenerator* GlobalGenerator; bool IsFunctionBlocked(const cmListFileFunction& lff, cmExecutionStatus &status); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5176697fa5333dadef7e5627ba187f557d77a8c2 commit 5176697fa5333dadef7e5627ba187f557d77a8c2 Author: Stephen Kelly AuthorDate: Sun Aug 2 11:08:49 2015 +0200 Commit: Stephen Kelly CommitDate: Thu Aug 27 21:39:18 2015 +0200 cmLocalGenerator: Remove Parent pointer. diff --git a/Source/cmGlobalBorlandMakefileGenerator.cxx b/Source/cmGlobalBorlandMakefileGenerator.cxx index 87665a0..c31f952 100644 --- a/Source/cmGlobalBorlandMakefileGenerator.cxx +++ b/Source/cmGlobalBorlandMakefileGenerator.cxx @@ -44,10 +44,10 @@ void cmGlobalBorlandMakefileGenerator ///! Create a local generator appropriate to this Global Generator cmLocalGenerator *cmGlobalBorlandMakefileGenerator::CreateLocalGenerator( - cmLocalGenerator* parent, cmState::Snapshot snapshot) + cmState::Snapshot snapshot) { cmLocalUnixMakefileGenerator3* lg = - new cmLocalUnixMakefileGenerator3(this, parent, snapshot); + new cmLocalUnixMakefileGenerator3(this, snapshot); lg->SetMakefileVariableSize(32); lg->SetMakeCommandEscapeTargetTwice(true); lg->SetBorlandMakeCurlyHack(true); diff --git a/Source/cmGlobalBorlandMakefileGenerator.h b/Source/cmGlobalBorlandMakefileGenerator.h index 2ec510d..62e458f 100644 --- a/Source/cmGlobalBorlandMakefileGenerator.h +++ b/Source/cmGlobalBorlandMakefileGenerator.h @@ -36,8 +36,7 @@ public: static void GetDocumentation(cmDocumentationEntry& entry); ///! Create a local generator appropriate to this Global Generator - virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent, - cmState::Snapshot snapshot); + virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); /** * Try to determine system information such as shared library diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 46c1ccc..01f50ed 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1986,22 +1986,20 @@ void cmGlobalGenerator::EnableInstallTarget() } cmLocalGenerator * -cmGlobalGenerator::MakeLocalGenerator(cmState::Snapshot snapshot, - cmLocalGenerator *parent) +cmGlobalGenerator::MakeLocalGenerator(cmState::Snapshot snapshot) { if (!snapshot.IsValid()) { snapshot = this->CMakeInstance->GetCurrentSnapshot(); } - return this->CreateLocalGenerator(parent, snapshot); + return this->CreateLocalGenerator(snapshot); } cmLocalGenerator* -cmGlobalGenerator::CreateLocalGenerator(cmLocalGenerator* parent, - cmState::Snapshot snapshot) +cmGlobalGenerator::CreateLocalGenerator(cmState::Snapshot snapshot) { - return new cmLocalGenerator(this, parent, snapshot); + return new cmLocalGenerator(this, snapshot); } void cmGlobalGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator *gen, diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 21cbd44..2e0f7b5 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -56,9 +56,8 @@ public: cmGlobalGenerator(cmake* cm); virtual ~cmGlobalGenerator(); - cmLocalGenerator* MakeLocalGenerator( - cmState::Snapshot snapshot = cmState::Snapshot(), - cmLocalGenerator* parent = 0); + cmLocalGenerator* + MakeLocalGenerator(cmState::Snapshot snapshot = cmState::Snapshot()); ///! Get the name for this generator virtual std::string GetName() const { return "Generic"; } @@ -442,8 +441,7 @@ protected: private: ///! Create a local generator appropriate to this Global Generator - virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent, - cmState::Snapshot snapshot); + virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); cmMakefile* TryCompileOuterMakefile; // If you add a new map here, make sure it is copied diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx index f764418..29abb37 100644 --- a/Source/cmGlobalGhsMultiGenerator.cxx +++ b/Source/cmGlobalGhsMultiGenerator.cxx @@ -33,10 +33,9 @@ cmGlobalGhsMultiGenerator::~cmGlobalGhsMultiGenerator() } cmLocalGenerator * -cmGlobalGhsMultiGenerator::CreateLocalGenerator(cmLocalGenerator* parent, - cmState::Snapshot snapshot) +cmGlobalGhsMultiGenerator::CreateLocalGenerator(cmState::Snapshot snapshot) { - return new cmLocalGhsMultiGenerator(this, parent, snapshot); + return new cmLocalGhsMultiGenerator(this, snapshot); } void cmGlobalGhsMultiGenerator::GetDocumentation(cmDocumentationEntry &entry) diff --git a/Source/cmGlobalGhsMultiGenerator.h b/Source/cmGlobalGhsMultiGenerator.h index f1a3ed7..873c20f 100644 --- a/Source/cmGlobalGhsMultiGenerator.h +++ b/Source/cmGlobalGhsMultiGenerator.h @@ -31,8 +31,7 @@ public: { return new cmGlobalGeneratorSimpleFactory(); } ///! create the correct local generator - virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent, - cmState::Snapshot snapshot); + virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); /// @return the name of this generator. static std::string GetActualName() { return "Green Hills MULTI"; } diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index b92ad32..72ef4d6 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -528,10 +528,9 @@ cmGlobalNinjaGenerator::cmGlobalNinjaGenerator(cmake* cm) // Virtual public methods. cmLocalGenerator* -cmGlobalNinjaGenerator::CreateLocalGenerator(cmLocalGenerator* parent, - cmState::Snapshot snapshot) +cmGlobalNinjaGenerator::CreateLocalGenerator(cmState::Snapshot snapshot) { - return new cmLocalNinjaGenerator(this, parent, snapshot); + return new cmLocalNinjaGenerator(this, snapshot); } void cmGlobalNinjaGenerator diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index f103801..418d6f7 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -170,8 +170,7 @@ public: virtual ~cmGlobalNinjaGenerator() { } /// Overloaded methods. @see cmGlobalGenerator::CreateLocalGenerator() - virtual cmLocalGenerator* CreateLocalGenerator(cmLocalGenerator* parent, - cmState::Snapshot snapshot); + virtual cmLocalGenerator* CreateLocalGenerator(cmState::Snapshot snapshot); /// Overloaded methods. @see cmGlobalGenerator::GetName(). virtual std::string GetName() const { diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 605ece2..0f491aa 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -59,11 +59,10 @@ void cmGlobalUnixMakefileGenerator3 } ///! Create a local generator appropriate to this Global Generator -cmLocalGenerator * -cmGlobalUnixMakefileGenerator3::CreateLocalGenerator(cmLocalGenerator* parent, - cmState::Snapshot snapshot) +cmLocalGenerator* cmGlobalUnixMakefileGenerator3::CreateLocalGenerator( + cmState::Snapshot snapshot) { - return new cmLocalUnixMakefileGenerator3(this, parent, snapshot); + return new cmLocalUnixMakefileGenerator3(this, snapshot); } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index c738c16..3ea6bb2 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -68,8 +68,7 @@ public: static void GetDocumentation(cmDocumentationEntry& entry); ///! Create a local generator appropriate to this Global Generator3 - virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent, - cmState::Snapshot snapshot); + virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); /** * Try to determine system information such as shared library diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 8ec4fd9..a36fed1 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -306,11 +306,10 @@ void cmGlobalVisualStudio10Generator::WriteSLNHeader(std::ostream& fout) } ///! Create a local generator appropriate to this Global Generator -cmLocalGenerator * -cmGlobalVisualStudio10Generator::CreateLocalGenerator(cmLocalGenerator* parent, - cmState::Snapshot snapshot) +cmLocalGenerator* cmGlobalVisualStudio10Generator::CreateLocalGenerator( + cmState::Snapshot snapshot) { - return new cmLocalVisualStudio10Generator(this, parent, snapshot); + return new cmLocalVisualStudio10Generator(this, snapshot); } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 3d34a3f..bbc22b9 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -48,8 +48,7 @@ public: virtual bool Compute(); ///! create the correct local generator - virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent, - cmState::Snapshot snapshot); + virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); /** * Try to determine system information such as shared library diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx index b7c897c..48c3d32 100644 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ b/Source/cmGlobalVisualStudio6Generator.cxx @@ -173,10 +173,10 @@ cmGlobalVisualStudio6Generator::GenerateBuildCommand( ///! Create a local generator appropriate to this Global Generator cmLocalGenerator * -cmGlobalVisualStudio6Generator::CreateLocalGenerator(cmLocalGenerator* parent, +cmGlobalVisualStudio6Generator::CreateLocalGenerator( cmState::Snapshot snapshot) { - return new cmLocalVisualStudio6Generator(this, parent, snapshot); + return new cmLocalVisualStudio6Generator(this, snapshot); } diff --git a/Source/cmGlobalVisualStudio6Generator.h b/Source/cmGlobalVisualStudio6Generator.h index 420cb0b..0169be0 100644 --- a/Source/cmGlobalVisualStudio6Generator.h +++ b/Source/cmGlobalVisualStudio6Generator.h @@ -39,8 +39,7 @@ public: static void GetDocumentation(cmDocumentationEntry& entry); ///! Create a local generator appropriate to this Global Generator - virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent, - cmState::Snapshot snapshot); + virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); /** * Try to determine system information such as shared library diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 2660d23..b8f6357 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -279,12 +279,11 @@ void cmGlobalVisualStudio7Generator::GenerateBuildCommand( } ///! Create a local generator appropriate to this Global Generator -cmLocalGenerator * -cmGlobalVisualStudio7Generator::CreateLocalGenerator(cmLocalGenerator* parent, - cmState::Snapshot snapshot) +cmLocalGenerator *cmGlobalVisualStudio7Generator::CreateLocalGenerator( + cmState::Snapshot snapshot) { cmLocalVisualStudio7Generator *lg = - new cmLocalVisualStudio7Generator(this, parent, snapshot); + new cmLocalVisualStudio7Generator(this, snapshot); return lg; } diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 931ac9c..5ada2c5 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -43,8 +43,7 @@ public: std::string const& GetPlatformName() const; ///! Create a local generator appropriate to this Global Generator - virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent, - cmState::Snapshot snapshot); + virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); virtual bool SetSystemName(std::string const& s, cmMakefile* mf); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index eb547bd..af3629d 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -371,10 +371,9 @@ cmGlobalXCodeGenerator::GenerateBuildCommand( //---------------------------------------------------------------------------- ///! Create a local generator appropriate to this Global Generator cmLocalGenerator * -cmGlobalXCodeGenerator::CreateLocalGenerator(cmLocalGenerator* parent, - cmState::Snapshot snapshot) +cmGlobalXCodeGenerator::CreateLocalGenerator(cmState::Snapshot snapshot) { - return new cmLocalXCodeGenerator(this, parent, snapshot); + return new cmLocalXCodeGenerator(this, snapshot); } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index ee8bf2c..f93f62f 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -41,8 +41,7 @@ public: static void GetDocumentation(cmDocumentationEntry& entry); ///! Create a local generator appropriate to this Global Generator - virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent, - cmState::Snapshot snapshot); + virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); /** * Try to determine system information such as shared library diff --git a/Source/cmLocalCommonGenerator.cxx b/Source/cmLocalCommonGenerator.cxx index 4583446..58c707c 100644 --- a/Source/cmLocalCommonGenerator.cxx +++ b/Source/cmLocalCommonGenerator.cxx @@ -14,9 +14,8 @@ #include "cmMakefile.h" cmLocalCommonGenerator::cmLocalCommonGenerator(cmGlobalGenerator* gg, - cmLocalGenerator* parent, cmState::Snapshot snapshot): - cmLocalGenerator(gg, parent, snapshot) + cmLocalGenerator(gg, snapshot) { } diff --git a/Source/cmLocalCommonGenerator.h b/Source/cmLocalCommonGenerator.h index af94cda..b7caf0b 100644 --- a/Source/cmLocalCommonGenerator.h +++ b/Source/cmLocalCommonGenerator.h @@ -23,7 +23,6 @@ class cmLocalCommonGenerator: public cmLocalGenerator { public: cmLocalCommonGenerator(cmGlobalGenerator* gg, - cmLocalGenerator* parent, cmState::Snapshot snapshot); ~cmLocalCommonGenerator(); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 7ce4819..aea14d5 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -43,13 +43,11 @@ #endif cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg, - cmLocalGenerator* parent, cmState::Snapshot snapshot) : cmOutputConverter(snapshot), StateSnapshot(snapshot) { assert(snapshot.IsValid()); this->GlobalGenerator = gg; - this->Parent = parent; this->Makefile = new cmMakefile(this); diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 915814b..4c0b1fe 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -36,8 +36,7 @@ class cmCustomCommandGenerator; class cmLocalGenerator : public cmOutputConverter { public: - cmLocalGenerator(cmGlobalGenerator* gg, cmLocalGenerator* parent, - cmState::Snapshot snapshot); + cmLocalGenerator(cmGlobalGenerator* gg, cmState::Snapshot snapshot); virtual ~cmLocalGenerator(); /** @@ -86,9 +85,6 @@ public: cmState* GetState() const; cmState::Snapshot GetStateSnapshot() const; - ///! set/get the parent generator - cmLocalGenerator* GetParent() const {return this->Parent;} - void AddArchitectureFlags(std::string& flags, cmGeneratorTarget const* target, const std::string&lang, const std::string& config); @@ -343,7 +339,6 @@ protected: cmMakefile *Makefile; cmState::Snapshot StateSnapshot; cmGlobalGenerator *GlobalGenerator; - cmLocalGenerator* Parent; std::map UniqueObjectNamesMap; std::string::size_type ObjectPathMax; std::set ObjectMaxPathViolations; diff --git a/Source/cmLocalGhsMultiGenerator.cxx b/Source/cmLocalGhsMultiGenerator.cxx index 8e498dd..91dfeb4 100644 --- a/Source/cmLocalGhsMultiGenerator.cxx +++ b/Source/cmLocalGhsMultiGenerator.cxx @@ -17,9 +17,8 @@ #include "cmGeneratedFileStream.h" cmLocalGhsMultiGenerator::cmLocalGhsMultiGenerator(cmGlobalGenerator* gg, - cmLocalGenerator* parent, cmState::Snapshot snapshot) - : cmLocalGenerator(gg, parent, snapshot) + : cmLocalGenerator(gg, snapshot) { } diff --git a/Source/cmLocalGhsMultiGenerator.h b/Source/cmLocalGhsMultiGenerator.h index f52ef39..3309bfd 100644 --- a/Source/cmLocalGhsMultiGenerator.h +++ b/Source/cmLocalGhsMultiGenerator.h @@ -25,7 +25,7 @@ class cmGeneratedFileStream; class cmLocalGhsMultiGenerator : public cmLocalGenerator { public: - cmLocalGhsMultiGenerator(cmGlobalGenerator* gg, cmLocalGenerator* parent, + cmLocalGhsMultiGenerator(cmGlobalGenerator* gg, cmState::Snapshot snapshot); virtual ~cmLocalGhsMultiGenerator(); diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index cfca418..62bf8b2 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -23,9 +23,8 @@ #include cmLocalNinjaGenerator::cmLocalNinjaGenerator(cmGlobalGenerator* gg, - cmLocalGenerator* parent, cmState::Snapshot snapshot) - : cmLocalCommonGenerator(gg, parent, snapshot) + : cmLocalCommonGenerator(gg, snapshot) , HomeRelativeOutputPath("") { this->TargetImplib = "$TARGET_IMPLIB"; diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index d10be0c..4c158bc 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -31,7 +31,7 @@ class cmake; class cmLocalNinjaGenerator : public cmLocalCommonGenerator { public: - cmLocalNinjaGenerator(cmGlobalGenerator* gg, cmLocalGenerator* parent, + cmLocalNinjaGenerator(cmGlobalGenerator* gg, cmState::Snapshot snapshot); virtual ~cmLocalNinjaGenerator(); diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 589105e..d2b60d3 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -80,9 +80,9 @@ static std::string cmSplitExtension(std::string const& in, std::string& base) //---------------------------------------------------------------------------- cmLocalUnixMakefileGenerator3:: -cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg, cmLocalGenerator* parent, +cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg, cmState::Snapshot snapshot) - : cmLocalCommonGenerator(gg, parent, snapshot) + : cmLocalCommonGenerator(gg, snapshot) { this->MakefileVariableSize = 0; this->ColorMakefile = false; diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index 01ac01b..2b9af38 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -35,7 +35,6 @@ class cmLocalUnixMakefileGenerator3 : public cmLocalCommonGenerator { public: cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg, - cmLocalGenerator* parent, cmState::Snapshot snapshot); virtual ~cmLocalUnixMakefileGenerator3(); diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx index 9e3185c..25b3f19 100644 --- a/Source/cmLocalVisualStudio10Generator.cxx +++ b/Source/cmLocalVisualStudio10Generator.cxx @@ -63,9 +63,8 @@ class cmVS10XMLParser : public cmXMLParser //---------------------------------------------------------------------------- cmLocalVisualStudio10Generator ::cmLocalVisualStudio10Generator(cmGlobalGenerator* gg, - cmLocalGenerator* parent, cmState::Snapshot snapshot): - cmLocalVisualStudio7Generator(gg, parent, snapshot) + cmLocalVisualStudio7Generator(gg, snapshot) { } diff --git a/Source/cmLocalVisualStudio10Generator.h b/Source/cmLocalVisualStudio10Generator.h index c588aaf..0f179fd 100644 --- a/Source/cmLocalVisualStudio10Generator.h +++ b/Source/cmLocalVisualStudio10Generator.h @@ -26,7 +26,6 @@ class cmLocalVisualStudio10Generator : public cmLocalVisualStudio7Generator public: ///! Set cache only and recurse to false by default. cmLocalVisualStudio10Generator(cmGlobalGenerator* gg, - cmLocalGenerator* parent, cmState::Snapshot snapshot); virtual ~cmLocalVisualStudio10Generator(); diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 3a44367..46e1987 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -25,9 +25,8 @@ cmLocalVisualStudio6Generator ::cmLocalVisualStudio6Generator(cmGlobalGenerator* gg, - cmLocalGenerator* parent, cmState::Snapshot snapshot): - cmLocalVisualStudioGenerator(gg, parent, snapshot) + cmLocalVisualStudioGenerator(gg, snapshot) { } diff --git a/Source/cmLocalVisualStudio6Generator.h b/Source/cmLocalVisualStudio6Generator.h index a44e61d..86b4906 100644 --- a/Source/cmLocalVisualStudio6Generator.h +++ b/Source/cmLocalVisualStudio6Generator.h @@ -30,7 +30,6 @@ class cmLocalVisualStudio6Generator : public cmLocalVisualStudioGenerator public: ///! Set cache only and recurse to false by default. cmLocalVisualStudio6Generator(cmGlobalGenerator* gg, - cmLocalGenerator* parent, cmState::Snapshot snapshot); virtual ~cmLocalVisualStudio6Generator(); diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 55ad852..eebed7e 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -54,9 +54,8 @@ static void cmConvertToWindowsSlash(std::string& s) //---------------------------------------------------------------------------- cmLocalVisualStudio7Generator ::cmLocalVisualStudio7Generator(cmGlobalGenerator* gg, - cmLocalGenerator* parent, cmState::Snapshot snapshot): - cmLocalVisualStudioGenerator(gg, parent, snapshot) + cmLocalVisualStudioGenerator(gg, snapshot) { this->Internal = new cmLocalVisualStudio7GeneratorInternals(this); } diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h index 43f3af9..42ae097 100644 --- a/Source/cmLocalVisualStudio7Generator.h +++ b/Source/cmLocalVisualStudio7Generator.h @@ -36,7 +36,6 @@ class cmLocalVisualStudio7Generator : public cmLocalVisualStudioGenerator public: ///! Set cache only and recurse to false by default. cmLocalVisualStudio7Generator(cmGlobalGenerator* gg, - cmLocalGenerator* parent, cmState::Snapshot snapshot); virtual ~cmLocalVisualStudio7Generator(); diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index 3588853..70f729f 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/Source/cmLocalVisualStudioGenerator.cxx @@ -20,9 +20,8 @@ //---------------------------------------------------------------------------- cmLocalVisualStudioGenerator ::cmLocalVisualStudioGenerator(cmGlobalGenerator* gg, - cmLocalGenerator* parent, cmState::Snapshot snapshot) - : cmLocalGenerator(gg, parent, snapshot) + : cmLocalGenerator(gg, snapshot) { } diff --git a/Source/cmLocalVisualStudioGenerator.h b/Source/cmLocalVisualStudioGenerator.h index d414651..32244c7 100644 --- a/Source/cmLocalVisualStudioGenerator.h +++ b/Source/cmLocalVisualStudioGenerator.h @@ -32,7 +32,6 @@ class cmLocalVisualStudioGenerator : public cmLocalGenerator { public: cmLocalVisualStudioGenerator(cmGlobalGenerator* gg, - cmLocalGenerator* parent, cmState::Snapshot snapshot); virtual ~cmLocalVisualStudioGenerator(); diff --git a/Source/cmLocalXCodeGenerator.cxx b/Source/cmLocalXCodeGenerator.cxx index 804dd7d..d6576f6 100644 --- a/Source/cmLocalXCodeGenerator.cxx +++ b/Source/cmLocalXCodeGenerator.cxx @@ -16,9 +16,8 @@ //---------------------------------------------------------------------------- cmLocalXCodeGenerator::cmLocalXCodeGenerator(cmGlobalGenerator* gg, - cmLocalGenerator* parent, cmState::Snapshot snapshot) - : cmLocalGenerator(gg, parent, snapshot) + : cmLocalGenerator(gg, snapshot) { // the global generator does this, so do not // put these flags into the language flags diff --git a/Source/cmLocalXCodeGenerator.h b/Source/cmLocalXCodeGenerator.h index 26fff9c..d96e78c 100644 --- a/Source/cmLocalXCodeGenerator.h +++ b/Source/cmLocalXCodeGenerator.h @@ -24,7 +24,7 @@ class cmLocalXCodeGenerator : public cmLocalGenerator { public: ///! Set cache only and recurse to false by default. - cmLocalXCodeGenerator(cmGlobalGenerator* gg, cmLocalGenerator* parent, + cmLocalXCodeGenerator(cmGlobalGenerator* gg, cmState::Snapshot snapshot); virtual ~cmLocalXCodeGenerator(); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 4a4663a..2ba12a4 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1755,7 +1755,7 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath, // create a new local generator and set its parent cmLocalGenerator *lg2 = this->GetGlobalGenerator() - ->MakeLocalGenerator(newSnapshot, this->LocalGenerator); + ->MakeLocalGenerator(newSnapshot); this->GetGlobalGenerator()->AddMakefile(lg2->GetMakefile()); this->GetGlobalGenerator()->AddLocalGenerator(lg2); ----------------------------------------------------------------------- Summary of changes: Source/CPack/cmCPackGenerator.cxx | 6 +- Source/CPack/cpack.cxx | 10 +-- Source/CTest/cmCTestLaunch.cxx | 5 +- Source/CTest/cmCTestScriptHandler.cxx | 45 +++++--------- Source/CTest/cmCTestTestHandler.cxx | 5 +- Source/cmCTest.cxx | 7 ++- Source/cmGlobalBorlandMakefileGenerator.cxx | 4 +- Source/cmGlobalBorlandMakefileGenerator.h | 3 +- Source/cmGlobalGenerator.cxx | 87 +++++++++++++-------------- Source/cmGlobalGenerator.h | 12 ++-- Source/cmGlobalGhsMultiGenerator.cxx | 5 +- Source/cmGlobalGhsMultiGenerator.h | 3 +- Source/cmGlobalNinjaGenerator.cxx | 5 +- Source/cmGlobalNinjaGenerator.h | 14 +---- Source/cmGlobalUnixMakefileGenerator3.cxx | 14 +++-- Source/cmGlobalUnixMakefileGenerator3.h | 4 +- Source/cmGlobalVisualStudio10Generator.cxx | 7 +-- Source/cmGlobalVisualStudio10Generator.h | 3 +- Source/cmGlobalVisualStudio6Generator.cxx | 5 +- Source/cmGlobalVisualStudio6Generator.h | 3 +- Source/cmGlobalVisualStudio7Generator.cxx | 7 +-- Source/cmGlobalVisualStudio7Generator.h | 3 +- Source/cmGlobalXCodeGenerator.cxx | 5 +- Source/cmGlobalXCodeGenerator.h | 3 +- Source/cmGraphVizWriter.cxx | 5 +- Source/cmLocalCommonGenerator.cxx | 5 +- Source/cmLocalCommonGenerator.h | 4 +- Source/cmLocalGenerator.cxx | 11 ++-- Source/cmLocalGenerator.h | 7 +-- Source/cmLocalGhsMultiGenerator.cxx | 5 +- Source/cmLocalGhsMultiGenerator.h | 3 +- Source/cmLocalNinjaGenerator.cxx | 5 +- Source/cmLocalNinjaGenerator.h | 3 +- Source/cmLocalUnixMakefileGenerator3.cxx | 5 +- Source/cmLocalUnixMakefileGenerator3.h | 4 +- Source/cmLocalVisualStudio10Generator.cxx | 6 +- Source/cmLocalVisualStudio10Generator.h | 4 +- Source/cmLocalVisualStudio6Generator.cxx | 6 +- Source/cmLocalVisualStudio6Generator.h | 4 +- Source/cmLocalVisualStudio7Generator.cxx | 6 +- Source/cmLocalVisualStudio7Generator.h | 4 +- Source/cmLocalVisualStudioGenerator.cxx | 6 +- Source/cmLocalVisualStudioGenerator.h | 4 +- Source/cmLocalXCodeGenerator.cxx | 5 +- Source/cmLocalXCodeGenerator.h | 4 +- Source/cmMakefile.cxx | 24 +++----- Source/cmMakefile.h | 6 +- Source/cmQtAutoGenerators.cxx | 5 +- Source/cmake.cxx | 20 +++--- Source/cmcmd.cxx | 5 +- 50 files changed, 184 insertions(+), 247 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Fri Aug 28 00:01:12 2015 From: kwrobot at kitware.com (Kitware Robot) Date: Fri, 28 Aug 2015 00:01:12 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-1009-g11d5088 Message-ID: <20150828040112.A0CF8B2B6D@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 11d5088a2f02994dc14c72170c73f7d60b0fba03 (commit) from 27e4b21dfa926a522bb32674b8836ebb79d51bc5 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=11d5088a2f02994dc14c72170c73f7d60b0fba03 commit 11d5088a2f02994dc14c72170c73f7d60b0fba03 Author: Kitware Robot AuthorDate: Fri Aug 28 00:01:10 2015 -0400 Commit: Kitware Robot CommitDate: Fri Aug 28 00:01:10 2015 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 1894b69..d1bce76 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150827) +set(CMake_VERSION_PATCH 20150828) #set(CMake_VERSION_RC 1) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From domen.vrankar at gmail.com Fri Aug 28 02:09:46 2015 From: domen.vrankar at gmail.com (Domen Vrankar) Date: Fri, 28 Aug 2015 02:09:46 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2586-ge1fcdb6 Message-ID: <20150828060946.7B65AB09F3@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via e1fcdb66be61bcc5d7c5ca9adc05860aec3b17cc (commit) via 674dc0b33566b433b6ac5751f965b7d0ff952e73 (commit) from 698baeca7519b75caa4958f187bc57e32da63aad (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e1fcdb66be61bcc5d7c5ca9adc05860aec3b17cc commit e1fcdb66be61bcc5d7c5ca9adc05860aec3b17cc Merge: 698baec 674dc0b Author: Domen Vrankar AuthorDate: Fri Aug 28 02:09:41 2015 -0400 Commit: CMake Topic Stage CommitDate: Fri Aug 28 02:09:41 2015 -0400 Merge topic 'cpack-config-generation-test' into next 674dc0b3 CPack generator independent tests http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=674dc0b33566b433b6ac5751f965b7d0ff952e73 commit 674dc0b33566b433b6ac5751f965b7d0ff952e73 Author: Roman Donchenko AuthorDate: Fri Aug 28 08:07:52 2015 +0200 Commit: Domen Vrankar CommitDate: Fri Aug 28 08:07:52 2015 +0200 CPack generator independent tests CPackConfig.cmake file generation from CMake test suite. Currently it contains only a simple test without special characters in variable value. Test is not part of RunCMake/CPack as those tests are expected to be run for a specified generator. diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index c274d8f..2955db2 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -239,6 +239,7 @@ add_RunCMake_test(CommandLine) add_RunCMake_test(CommandLineTar) add_RunCMake_test(install) +add_RunCMake_test(CPackConfig) add_RunCMake_test(CPackInstallProperties) add_RunCMake_test(ExternalProject) add_RunCMake_test(CTestCommandLine) diff --git a/Tests/RunCMake/CPackConfig/CMakeLists.txt b/Tests/RunCMake/CPackConfig/CMakeLists.txt new file mode 100644 index 0000000..9a9e7b4 --- /dev/null +++ b/Tests/RunCMake/CPackConfig/CMakeLists.txt @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 3.3) + +project(${RunCMake_TEST}) +include(${RunCMake_TEST}.cmake) + +include(CPack) diff --git a/Tests/RunCMake/CPackConfig/RunCMakeTest.cmake b/Tests/RunCMake/CPackConfig/RunCMakeTest.cmake new file mode 100644 index 0000000..6787eb8 --- /dev/null +++ b/Tests/RunCMake/CPackConfig/RunCMakeTest.cmake @@ -0,0 +1,3 @@ +include(RunCMake) + +run_cmake(Simple) diff --git a/Tests/RunCMake/CPackConfig/Simple-check.cmake b/Tests/RunCMake/CPackConfig/Simple-check.cmake new file mode 100644 index 0000000..6e0cf6f --- /dev/null +++ b/Tests/RunCMake/CPackConfig/Simple-check.cmake @@ -0,0 +1,3 @@ +include(${RunCMake_SOURCE_DIR}/check.cmake) + +test_variable(CPACK_FOO "bar baz;quux") diff --git a/Tests/RunCMake/CPackConfig/Simple.cmake b/Tests/RunCMake/CPackConfig/Simple.cmake new file mode 100644 index 0000000..c9f6541 --- /dev/null +++ b/Tests/RunCMake/CPackConfig/Simple.cmake @@ -0,0 +1 @@ +set(CPACK_FOO "bar baz;quux") diff --git a/Tests/RunCMake/CPackConfig/check.cmake b/Tests/RunCMake/CPackConfig/check.cmake new file mode 100644 index 0000000..2fc9f11 --- /dev/null +++ b/Tests/RunCMake/CPackConfig/check.cmake @@ -0,0 +1,7 @@ +function(test_variable NAME EXPECTED_VALUE) + if(NOT "${${NAME}}" STREQUAL "${EXPECTED_VALUE}") + message(FATAL_ERROR "${NAME}: variable mismatch; expected [${EXPECTED_VALUE}] actual [${${NAME}}]") + endif() +endfunction() + +include(${RunCMake_TEST_BINARY_DIR}/CPackConfig.cmake) ----------------------------------------------------------------------- Summary of changes: Tests/RunCMake/CMakeLists.txt | 1 + Tests/RunCMake/{CMP0064 => CPackConfig}/CMakeLists.txt | 5 ++++- Tests/RunCMake/CPackConfig/RunCMakeTest.cmake | 3 +++ Tests/RunCMake/CPackConfig/Simple-check.cmake | 3 +++ Tests/RunCMake/CPackConfig/Simple.cmake | 1 + Tests/RunCMake/CPackConfig/check.cmake | 7 +++++++ 6 files changed, 19 insertions(+), 1 deletion(-) copy Tests/RunCMake/{CMP0064 => CPackConfig}/CMakeLists.txt (61%) create mode 100644 Tests/RunCMake/CPackConfig/RunCMakeTest.cmake create mode 100644 Tests/RunCMake/CPackConfig/Simple-check.cmake create mode 100644 Tests/RunCMake/CPackConfig/Simple.cmake create mode 100644 Tests/RunCMake/CPackConfig/check.cmake hooks/post-receive -- CMake From brad.king at kitware.com Fri Aug 28 09:38:10 2015 From: brad.king at kitware.com (Brad King) Date: Fri, 28 Aug 2015 09:38:10 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2589-gac74eff Message-ID: <20150828133810.0459CB2AA7@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via ac74eff5bb5cb1827cb4636a0bdf9a9baab248ce (commit) via 90a22c3ac5d38a83d4d487030277db4021c1913a (commit) via 11d5088a2f02994dc14c72170c73f7d60b0fba03 (commit) from e1fcdb66be61bcc5d7c5ca9adc05860aec3b17cc (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ac74eff5bb5cb1827cb4636a0bdf9a9baab248ce commit ac74eff5bb5cb1827cb4636a0bdf9a9baab248ce Merge: e1fcdb6 90a22c3 Author: Brad King AuthorDate: Fri Aug 28 09:38:09 2015 -0400 Commit: CMake Topic Stage CommitDate: Fri Aug 28 09:38:09 2015 -0400 Merge topic 'FindJNI-mips' into next 90a22c3a FindJNI: Add mips64(el) mipsn32(el) support (#15714) 11d5088a CMake Nightly Date Stamp http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=90a22c3ac5d38a83d4d487030277db4021c1913a commit 90a22c3ac5d38a83d4d487030277db4021c1913a Author: Yunqiang Su AuthorDate: Fri Aug 28 09:37:06 2015 -0400 Commit: Brad King CommitDate: Fri Aug 28 09:37:22 2015 -0400 FindJNI: Add mips64(el) mipsn32(el) support (#15714) Submitted-by: Felix Geyer diff --git a/Modules/FindJNI.cmake b/Modules/FindJNI.cmake index 6958a2a..cbe21d7 100644 --- a/Modules/FindJNI.cmake +++ b/Modules/FindJNI.cmake @@ -57,7 +57,7 @@ macro(java_append_library_directories _var) elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^mips") # mips* machines are bi-endian mostly so processor does not tell # endianess of the underlying system. - set(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}" "mips" "mipsel" "mipseb") + set(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}" "mips" "mipsel" "mipseb" "mips64" "mips64el" "mipsn32" "mipsn32el") elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64le") set(_java_libarch "ppc64" "ppc64le") elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64") ----------------------------------------------------------------------- Summary of changes: Modules/FindJNI.cmake | 2 +- Source/CMakeVersion.cmake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Fri Aug 28 10:17:46 2015 From: brad.king at kitware.com (Brad King) Date: Fri, 28 Aug 2015 10:17:46 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2593-gb19023d Message-ID: <20150828141746.18E58B2556@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via b19023dd1d340cb6677beeec37e67746417e7569 (commit) via ab2524d63f651e6d96c770fb3571bddab4b86621 (commit) via dee84dc73d88d05b9ad66908780c3e7c6ddc67ef (commit) via b3372db588431f000b5fe3de980d6a2f27382eb1 (commit) from ac74eff5bb5cb1827cb4636a0bdf9a9baab248ce (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b19023dd1d340cb6677beeec37e67746417e7569 commit b19023dd1d340cb6677beeec37e67746417e7569 Merge: ac74eff ab2524d Author: Brad King AuthorDate: Fri Aug 28 10:17:44 2015 -0400 Commit: CMake Topic Stage CommitDate: Fri Aug 28 10:17:44 2015 -0400 Merge topic 'fix-ctest-xml-double-encoding' into next ab2524d6 CTest: Fix XML double-encoding cases dee84dc7 cmCTest{BZR,GIT,P4}: Remove unused cmXMLSafe includes b3372db5 cmExtra{Kate,SublimeText}Generator: Remove unused cmXMLSafe includes diff --cc Source/CTest/cmCTestGIT.cxx index 5b9208a,c32e876..bbb3b9d --- a/Source/CTest/cmCTestGIT.cxx +++ b/Source/CTest/cmCTestGIT.cxx @@@ -14,9 -14,9 +14,8 @@@ #include "cmCTest.h" #include "cmSystemTools.h" #include "cmAlgorithms.h" - #include "cmXMLSafe.h" #include -#include #include #include diff --cc Source/CTest/cmCTestP4.cxx index 5ce431a,ad8e8b3..5e0c54a --- a/Source/CTest/cmCTestP4.cxx +++ b/Source/CTest/cmCTestP4.cxx @@@ -13,9 -13,9 +13,8 @@@ #include "cmCTest.h" #include "cmSystemTools.h" - #include "cmXMLSafe.h" #include -#include #include #include http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ab2524d63f651e6d96c770fb3571bddab4b86621 commit ab2524d63f651e6d96c770fb3571bddab4b86621 Author: Daniel Pfeifer AuthorDate: Thu Jul 16 21:48:00 2015 +0200 Commit: Brad King CommitDate: Fri Aug 28 10:11:09 2015 -0400 CTest: Fix XML double-encoding cases Remove use of cmXMLSafe from CTest when generating content that is later handled by cmXMLWriter. This was broken by refactoring in the topic merged by commit v3.3.0-rc1~22 (Merge topic 'ctest-xml-refactor', 2015-05-28). diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index 8f26716..acf527a 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -80,8 +80,8 @@ public: int i = 0; for(; atts[i] != 0; i+=2) { - ostr << " " << cmXMLSafe(atts[i]) - << " - " << cmXMLSafe(atts[i+1]) << "\n"; + ostr << " " << atts[i] + << " - " << atts[i+1] << "\n"; } ostr << "\n"; this->Log += ostr.str(); @@ -856,7 +856,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckSanitizerOutput( defects++; ostr << "" << this->ResultStrings[idx] << " "; } - ostr << cmXMLSafe(*i) << std::endl; + ostr << *i << std::endl; } log = ostr.str(); if(defects) @@ -908,7 +908,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckPurifyOutput( results[failure] ++; defects ++; } - ostr << cmXMLSafe(*i) << std::endl; + ostr << *i << std::endl; } log = ostr.str(); @@ -1056,7 +1056,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput( defects ++; } totalOutputSize += lines[cc].size(); - ostr << cmXMLSafe(lines[cc]) << std::endl; + ostr << lines[cc] << std::endl; } else { @@ -1070,11 +1070,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput( nonValGrindOutput.begin(); i != nonValGrindOutput.end(); ++i) { totalOutputSize += lines[*i].size(); - cmCTestOptionalLog(this->CTest, DEBUG, "before xml safe " - << lines[*i] << std::endl, this->Quiet); - cmCTestOptionalLog(this->CTest, DEBUG, "after xml safe " - << cmXMLSafe(lines[*i]) << std::endl, this->Quiet); - ostr << cmXMLSafe(lines[*i]) << std::endl; + ostr << lines[*i] << std::endl; if(!unlimitedOutput && totalOutputSize > static_cast(this->CustomMaximumFailedTestOutputSize)) { diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 2af09cb..f93b87b 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -2070,7 +2070,7 @@ bool cmCTestTestHandler::CleanTestOutput(std::string& output, size_t length) } current = next; } - else // Bad byte will be handled by cmXMLSafe. + else // Bad byte will be handled by cmXMLWriter. { ++current; } diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index e3b7a2b..8fa19d2 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -22,7 +22,6 @@ #include #include "cmDynamicLoader.h" #include "cmGeneratedFileStream.h" -#include "cmXMLSafe.h" #include "cmVersionMacros.h" #include "cmCTestCommand.h" #include "cmCTestStartCommand.h" @@ -156,7 +155,7 @@ std::string cmCTest::CurrentTime() strftime(current_time, 1000, "%a %b %d %H:%M:%S %Z %Y", t); } cmCTestLog(this, DEBUG, " Current_Time: " << current_time << std::endl); - return cmXMLSafe(cmCTest::CleanString(current_time)).str(); + return cmCTest::CleanString(current_time); } //---------------------------------------------------------------------- @@ -1477,8 +1476,6 @@ std::string cmCTest::SafeBuildIdField(const std::string& value) cmSystemTools::ReplaceString(safevalue, replace, ""); } } - - safevalue = cmXMLSafe(safevalue).str(); } if (safevalue == "") http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=dee84dc73d88d05b9ad66908780c3e7c6ddc67ef commit dee84dc73d88d05b9ad66908780c3e7c6ddc67ef Author: Daniel Pfeifer AuthorDate: Thu Jul 16 21:47:29 2015 +0200 Commit: Brad King CommitDate: Fri Aug 28 10:11:08 2015 -0400 cmCTest{BZR,GIT,P4}: Remove unused cmXMLSafe includes diff --git a/Source/CTest/cmCTestBZR.cxx b/Source/CTest/cmCTestBZR.cxx index 3014a93..587b583 100644 --- a/Source/CTest/cmCTestBZR.cxx +++ b/Source/CTest/cmCTestBZR.cxx @@ -14,7 +14,6 @@ #include "cmCTest.h" #include "cmSystemTools.h" #include "cmXMLParser.h" -#include "cmXMLSafe.h" #include diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx index 6b84bab..c32e876 100644 --- a/Source/CTest/cmCTestGIT.cxx +++ b/Source/CTest/cmCTestGIT.cxx @@ -14,7 +14,6 @@ #include "cmCTest.h" #include "cmSystemTools.h" #include "cmAlgorithms.h" -#include "cmXMLSafe.h" #include #include diff --git a/Source/CTest/cmCTestP4.cxx b/Source/CTest/cmCTestP4.cxx index 31002a6..ad8e8b3 100644 --- a/Source/CTest/cmCTestP4.cxx +++ b/Source/CTest/cmCTestP4.cxx @@ -13,7 +13,6 @@ #include "cmCTest.h" #include "cmSystemTools.h" -#include "cmXMLSafe.h" #include #include http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b3372db588431f000b5fe3de980d6a2f27382eb1 commit b3372db588431f000b5fe3de980d6a2f27382eb1 Author: Daniel Pfeifer AuthorDate: Thu Jul 16 21:47:29 2015 +0200 Commit: Brad King CommitDate: Fri Aug 28 10:11:08 2015 -0400 cmExtra{Kate,SublimeText}Generator: Remove unused cmXMLSafe includes diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx index 578e7d3..f83b5cf 100644 --- a/Source/cmExtraKateGenerator.cxx +++ b/Source/cmExtraKateGenerator.cxx @@ -19,7 +19,6 @@ #include "cmGeneratedFileStream.h" #include "cmTarget.h" #include "cmSystemTools.h" -#include "cmXMLSafe.h" #include diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index 4e721d4..163a75b 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -21,7 +21,6 @@ #include "cmSourceFile.h" #include "cmSystemTools.h" #include "cmTarget.h" -#include "cmXMLSafe.h" #include ----------------------------------------------------------------------- Summary of changes: Source/CTest/cmCTestBZR.cxx | 1 - Source/CTest/cmCTestGIT.cxx | 1 - Source/CTest/cmCTestMemCheckHandler.cxx | 16 ++++++---------- Source/CTest/cmCTestP4.cxx | 1 - Source/CTest/cmCTestTestHandler.cxx | 2 +- Source/cmCTest.cxx | 5 +---- Source/cmExtraKateGenerator.cxx | 1 - Source/cmExtraSublimeTextGenerator.cxx | 1 - 8 files changed, 8 insertions(+), 20 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Fri Aug 28 11:03:26 2015 From: brad.king at kitware.com (Brad King) Date: Fri, 28 Aug 2015 11:03:26 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2595-g7507ca2 Message-ID: <20150828150326.B0906B2B2C@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 7507ca2302b7c34bf08c83cfe2c7cc1f6be0a57e (commit) via 371fe92e82ecadede532a211c1ec36f7039268d7 (commit) from b19023dd1d340cb6677beeec37e67746417e7569 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7507ca2302b7c34bf08c83cfe2c7cc1f6be0a57e commit 7507ca2302b7c34bf08c83cfe2c7cc1f6be0a57e Merge: b19023d 371fe92 Author: Brad King AuthorDate: Fri Aug 28 11:03:25 2015 -0400 Commit: CMake Topic Stage CommitDate: Fri Aug 28 11:03:25 2015 -0400 Merge topic 'makefile-color-when-needed' into next 371fe92e Makefile: Print color escapes only when necessary http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=371fe92e82ecadede532a211c1ec36f7039268d7 commit 371fe92e82ecadede532a211c1ec36f7039268d7 Author: Brad King AuthorDate: Thu Aug 27 16:41:34 2015 -0400 Commit: Brad King CommitDate: Fri Aug 28 10:27:42 2015 -0400 Makefile: Print color escapes only when necessary Teach cmSystemTools::MakefileColorEcho to use the color printing API only when we actually have a color to print. This avoids printing escape sequences that do not change the text attributes. Since commit v3.3.0-rc1~480^2~4 (Makefile: Fix output during parallel builds, 2015-02-05) we always use this code path to print progress and rule messages even when color is disabled (e.g. in a try_compile). It is important to avoid printing escapes when there is no color because on MSYS we have no isatty and so assume that vt100 escapes are supported, but we do not want to print them when capturing try_compile output. diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index e2adabe..b440a17 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -2331,7 +2331,7 @@ void cmSystemTools::MakefileColorEcho(int color, const char* message, assumeTTY = 0; } - if(enabled) + if(enabled && color != cmsysTerminal_Color_Normal) { // Print with color. Delay the newline until later so that // all color restore sequences appear before it. ----------------------------------------------------------------------- Summary of changes: Source/cmSystemTools.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From steveire at gmail.com Fri Aug 28 12:44:15 2015 From: steveire at gmail.com (Stephen Kelly) Date: Fri, 28 Aug 2015 12:44:15 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2597-ga741812 Message-ID: <20150828164415.C0EC2B2545@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via a741812b5189b0d0d61d7b1119410e8b0f722613 (commit) via 900816d1c3ede65e83e3de4253a5a560a3e4c994 (commit) from 7507ca2302b7c34bf08c83cfe2c7cc1f6be0a57e (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a741812b5189b0d0d61d7b1119410e8b0f722613 commit a741812b5189b0d0d61d7b1119410e8b0f722613 Merge: 7507ca2 900816d Author: Stephen Kelly AuthorDate: Fri Aug 28 12:44:14 2015 -0400 Commit: CMake Topic Stage CommitDate: Fri Aug 28 12:44:14 2015 -0400 Merge topic 'generate-time-generators' into next 900816d1 Revert topic. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=900816d1c3ede65e83e3de4253a5a560a3e4c994 commit 900816d1c3ede65e83e3de4253a5a560a3e4c994 Author: Stephen Kelly AuthorDate: Fri Aug 28 18:43:32 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 28 18:43:39 2015 +0200 Revert topic. diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 92a4b2b..bf4df60 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -716,10 +716,8 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( cm.AddCMakePaths(); cm.SetProgressCallback(cmCPackGeneratorProgress, this); cmGlobalGenerator gg(&cm); - cmsys::auto_ptr mf( - new cmMakefile(&gg, cm.GetCurrentSnapshot())); - cmsys::auto_ptr lg( - gg.CreateLocalGenerator(mf.get())); + cmsys::auto_ptr lg(gg.MakeLocalGenerator()); + cmMakefile *mf = lg->GetMakefile(); std::string realInstallDirectory = tempInstallDirectory; if ( !installSubDirectory.empty() && installSubDirectory != "/" ) { diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index cb9cbc4..c2fe763 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -202,10 +202,8 @@ int main (int argc, char const* const* argv) cminst.SetHomeOutputDirectory(""); cminst.GetState()->RemoveUnscriptableCommands(); cmGlobalGenerator cmgg(&cminst); - cmsys::auto_ptr globalMF( - new cmMakefile(&cmgg, cminst.GetCurrentSnapshot())); - cmsys::auto_ptr cmlg( - cmgg.CreateLocalGenerator(globalMF.get())); + cmsys::auto_ptr cmlg(cmgg.MakeLocalGenerator()); + cmMakefile* globalMF = cmlg->GetMakefile(); #if defined(__CYGWIN__) globalMF->AddDefinition("CMAKE_LEGACY_CYGWIN_WIN32", "0"); #endif @@ -359,8 +357,8 @@ int main (int argc, char const* const* argv) ++it ) { const char* gen = it->c_str(); - cmMakefile::ScopePushPop raii(globalMF.get()); - cmMakefile* mf = globalMF.get(); + cmMakefile::ScopePushPop raii(globalMF); + cmMakefile* mf = globalMF; cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "Specified generator: " << gen << std::endl); if ( parsed && !mf->GetDefinition("CPACK_PACKAGE_NAME") ) diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx index fb0cce6..0f588c5 100644 --- a/Source/CTest/cmCTestLaunch.cxx +++ b/Source/CTest/cmCTestLaunch.cxx @@ -738,9 +738,8 @@ void cmCTestLaunch::LoadConfig() cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); cmGlobalGenerator gg(&cm); - cmsys::auto_ptr mf(new cmMakefile(&gg, cm.GetCurrentSnapshot())); - cmsys::auto_ptr lg( - gg.CreateLocalGenerator(mf.get())); + cmsys::auto_ptr lg(gg.MakeLocalGenerator()); + cmMakefile* mf = lg->GetMakefile(); std::string fname = this->LogDir; fname += "CTestLaunchConfig.cmake"; if(cmSystemTools::FileExists(fname.c_str()) && diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 9154716..047bd98 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -125,25 +125,42 @@ void cmCTestScriptHandler::Initialize() // what time in seconds did this script start running this->ScriptStartTime = 0; - delete this->Makefile; this->Makefile = 0; - - delete this->LocalGenerator; + if (this->LocalGenerator) + { + delete this->LocalGenerator; + } this->LocalGenerator = 0; - - delete this->GlobalGenerator; + if (this->GlobalGenerator) + { + delete this->GlobalGenerator; + } this->GlobalGenerator = 0; - - delete this->CMake; + if (this->CMake) + { + delete this->CMake; + } } //---------------------------------------------------------------------- cmCTestScriptHandler::~cmCTestScriptHandler() { - delete this->Makefile; - delete this->LocalGenerator; - delete this->GlobalGenerator; - delete this->CMake; + // local generator owns the makefile + this->Makefile = 0; + if (this->LocalGenerator) + { + delete this->LocalGenerator; + } + this->LocalGenerator = 0; + if (this->GlobalGenerator) + { + delete this->GlobalGenerator; + } + this->GlobalGenerator = 0; + if (this->CMake) + { + delete this->CMake; + } } @@ -317,7 +334,6 @@ void cmCTestScriptHandler::CreateCMake() delete this->CMake; delete this->GlobalGenerator; delete this->LocalGenerator; - delete this->Makefile; } this->CMake = new cmake; this->CMake->SetHomeDirectory(""); @@ -325,10 +341,7 @@ void cmCTestScriptHandler::CreateCMake() this->CMake->AddCMakePaths(); this->GlobalGenerator = new cmGlobalGenerator(this->CMake); - cmState::Snapshot snapshot = this->CMake->GetCurrentSnapshot(); - this->Makefile = new cmMakefile(this->GlobalGenerator, snapshot); - this->LocalGenerator = - this->GlobalGenerator->CreateLocalGenerator(this->Makefile); + this->LocalGenerator = this->GlobalGenerator->MakeLocalGenerator(); this->Makefile = this->LocalGenerator->GetMakefile(); this->CMake->SetProgressCallback(ctestScriptProgressCallback, this->CTest); diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index a523f57..c8a0d27 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -1592,9 +1592,8 @@ void cmCTestTestHandler::GetListOfTests() cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); cmGlobalGenerator gg(&cm); - cmsys::auto_ptr mf(new cmMakefile(&gg, cm.GetCurrentSnapshot())); - cmsys::auto_ptr lg( - gg.CreateLocalGenerator(mf.get())); + cmsys::auto_ptr lg(gg.MakeLocalGenerator()); + cmMakefile *mf = lg->GetMakefile(); mf->AddDefinition("CTEST_CONFIGURATION_TYPE", this->CTest->GetConfigType().c_str()); diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index adefd1c..b976469 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -520,10 +520,9 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command) cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); cmGlobalGenerator gg(&cm); - cmsys::auto_ptr mf(new cmMakefile(&gg, cm.GetCurrentSnapshot())); - cmsys::auto_ptr lg(gg.CreateLocalGenerator(mf.get())); - if ( !this->ReadCustomConfigurationFileTree(this->BinaryDir.c_str(), - mf.get()) ) + cmsys::auto_ptr lg(gg.MakeLocalGenerator()); + cmMakefile *mf = lg->GetMakefile(); + if ( !this->ReadCustomConfigurationFileTree(this->BinaryDir.c_str(), mf) ) { cmCTestOptionalLog(this, DEBUG, "Cannot find custom configuration file tree" << std::endl, quiet); diff --git a/Source/cmGlobalBorlandMakefileGenerator.cxx b/Source/cmGlobalBorlandMakefileGenerator.cxx index 40e8d29..87665a0 100644 --- a/Source/cmGlobalBorlandMakefileGenerator.cxx +++ b/Source/cmGlobalBorlandMakefileGenerator.cxx @@ -44,10 +44,10 @@ void cmGlobalBorlandMakefileGenerator ///! Create a local generator appropriate to this Global Generator cmLocalGenerator *cmGlobalBorlandMakefileGenerator::CreateLocalGenerator( - cmMakefile *mf) + cmLocalGenerator* parent, cmState::Snapshot snapshot) { cmLocalUnixMakefileGenerator3* lg = - new cmLocalUnixMakefileGenerator3(this, mf); + new cmLocalUnixMakefileGenerator3(this, parent, snapshot); lg->SetMakefileVariableSize(32); lg->SetMakeCommandEscapeTargetTwice(true); lg->SetBorlandMakeCurlyHack(true); diff --git a/Source/cmGlobalBorlandMakefileGenerator.h b/Source/cmGlobalBorlandMakefileGenerator.h index b59c86d..2ec510d 100644 --- a/Source/cmGlobalBorlandMakefileGenerator.h +++ b/Source/cmGlobalBorlandMakefileGenerator.h @@ -36,7 +36,8 @@ public: static void GetDocumentation(cmDocumentationEntry& entry); ///! Create a local generator appropriate to this Global Generator - virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf); + virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent, + cmState::Snapshot snapshot); /** * Try to determine system information such as shared library diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index cb272f3..46c1ccc 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1127,38 +1127,23 @@ void cmGlobalGenerator::Configure() this->FirstTimeProgress = 0.0f; this->ClearGeneratorMembers(); - cmMakefile* dirMf = - new cmMakefile(this, this->GetCMakeInstance()->GetCurrentSnapshot()); - this->AddMakefile(dirMf); + // start with this directory + cmLocalGenerator *lg = this->MakeLocalGenerator(); + this->Makefiles.push_back(lg->GetMakefile()); + this->LocalGenerators.push_back(lg); // set the Start directories - dirMf->SetCurrentSourceDirectory + lg->GetMakefile()->SetCurrentSourceDirectory (this->CMakeInstance->GetHomeDirectory()); - dirMf->SetCurrentBinaryDirectory + lg->GetMakefile()->SetCurrentBinaryDirectory (this->CMakeInstance->GetHomeOutputDirectory()); this->BinaryDirectories.insert( this->CMakeInstance->GetHomeOutputDirectory()); // now do it - dirMf->Configure(); - dirMf->EnforceDirectoryLevelRules(); - - // Put a copy of each global target in every directory. - cmTargets globalTargets; - this->CreateDefaultGlobalTargets(&globalTargets); - - for (unsigned int i = 0; i < this->Makefiles.size(); ++i) - { - cmMakefile* mf = this->Makefiles[i]; - cmTargets* targets = &(mf->GetTargets()); - cmTargets::iterator tit; - for ( tit = globalTargets.begin(); tit != globalTargets.end(); ++ tit ) - { - (*targets)[tit->first] = tit->second; - (*targets)[tit->first].SetMakefile(mf); - } - } + lg->GetMakefile()->Configure(); + lg->GetMakefile()->EnforceDirectoryLevelRules(); // update the cache entry for the number of local generators, this is used // for progress @@ -1170,7 +1155,11 @@ void cmGlobalGenerator::Configure() // check for link libraries and include directories containing "NOTFOUND" // and for infinite loops - this->CheckTargetProperties(); + this->CheckLocalGenerators(); + + // at this point this->LocalGenerators has been filled, + // so create the map from project name to vector of local generators + this->FillProjectMap(); if ( this->CMakeInstance->GetWorkingMode() == cmake::NORMAL_MODE) { @@ -1197,23 +1186,29 @@ void cmGlobalGenerator::Configure() } this->CMakeInstance->UpdateProgress(msg.str().c_str(), -1); } -} -void cmGlobalGenerator::CreateLocalGenerators() -{ - cmDeleteAll(this->LocalGenerators); - this->LocalGenerators.clear(); - this->LocalGenerators.reserve(this->Makefiles.size()); - for (std::vector::const_iterator it = this->Makefiles.begin(); - it != this->Makefiles.end(); ++it) + unsigned int i; + + // Put a copy of each global target in every directory. + cmTargets globalTargets; + this->CreateDefaultGlobalTargets(&globalTargets); + + for (i = 0; i < this->Makefiles.size(); ++i) { - this->LocalGenerators.push_back(this->CreateLocalGenerator(*it)); + cmMakefile* mf = this->Makefiles[i]; + cmTargets* targets = &(mf->GetTargets()); + cmTargets::iterator tit; + for ( tit = globalTargets.begin(); tit != globalTargets.end(); ++ tit ) + { + (*targets)[tit->first] = tit->second; + (*targets)[tit->first].SetMakefile(mf); + } } + } void cmGlobalGenerator::CreateGenerationObjects(TargetTypes targetTypes) { - this->CreateLocalGenerators(); cmDeleteAll(this->GeneratorTargets); this->GeneratorTargets.clear(); this->CreateGeneratorTargets(targetTypes); @@ -1272,10 +1267,6 @@ bool cmGlobalGenerator::Compute() this->CreateGenerationObjects(); - // at this point this->LocalGenerators has been filled, - // so create the map from project name to vector of local generators - this->FillProjectMap(); - #ifdef CMAKE_BUILD_WITH_CMAKE // Iterate through all targets and set up automoc for those which have // the AUTOMOC, AUTOUIC or AUTORCC property set @@ -1609,7 +1600,6 @@ void cmGlobalGenerator::ClearGeneratorMembers() cmDeleteAll(this->BuildExportSets); this->BuildExportSets.clear(); - cmDeleteAll(this->Makefiles); this->Makefiles.clear(); cmDeleteAll(this->LocalGenerators); @@ -1644,7 +1634,7 @@ void cmGlobalGenerator::ComputeTargetObjectDirectory(cmGeneratorTarget*) const { } -void cmGlobalGenerator::CheckTargetProperties() +void cmGlobalGenerator::CheckLocalGenerators() { std::map notFoundMap; // std::set notFoundMap; @@ -1995,10 +1985,23 @@ void cmGlobalGenerator::EnableInstallTarget() this->InstallTargetEnabled = true; } +cmLocalGenerator * +cmGlobalGenerator::MakeLocalGenerator(cmState::Snapshot snapshot, + cmLocalGenerator *parent) +{ + if (!snapshot.IsValid()) + { + snapshot = this->CMakeInstance->GetCurrentSnapshot(); + } + + return this->CreateLocalGenerator(parent, snapshot); +} + cmLocalGenerator* -cmGlobalGenerator::CreateLocalGenerator(cmMakefile* mf) +cmGlobalGenerator::CreateLocalGenerator(cmLocalGenerator* parent, + cmState::Snapshot snapshot) { - return new cmLocalGenerator(this, mf); + return new cmLocalGenerator(this, parent, snapshot); } void cmGlobalGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator *gen, diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 4461831..21cbd44 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -56,8 +56,9 @@ public: cmGlobalGenerator(cmake* cm); virtual ~cmGlobalGenerator(); - virtual cmLocalGenerator* - CreateLocalGenerator(cmMakefile* mf); + cmLocalGenerator* MakeLocalGenerator( + cmState::Snapshot snapshot = cmState::Snapshot(), + cmLocalGenerator* parent = 0); ///! Get the name for this generator virtual std::string GetName() const { return "Generic"; } @@ -91,7 +92,6 @@ public: ImportedOnly }; - void CreateLocalGenerators(); void CreateGenerationObjects(TargetTypes targetTypes = AllTargets); /** @@ -395,7 +395,7 @@ protected: // Fill the ProjectMap, this must be called after LocalGenerators // has been populated. void FillProjectMap(); - void CheckTargetProperties(); + void CheckLocalGenerators(); bool IsExcluded(cmState::Snapshot const& root, cmState::Snapshot const& snp) const; bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen) const; @@ -441,6 +441,10 @@ protected: virtual bool UseFolderProperty(); private: + ///! Create a local generator appropriate to this Global Generator + virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent, + cmState::Snapshot snapshot); + cmMakefile* TryCompileOuterMakefile; // If you add a new map here, make sure it is copied // in EnableLanguagesFromGenerator diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx index 6dde1e3..f764418 100644 --- a/Source/cmGlobalGhsMultiGenerator.cxx +++ b/Source/cmGlobalGhsMultiGenerator.cxx @@ -33,9 +33,10 @@ cmGlobalGhsMultiGenerator::~cmGlobalGhsMultiGenerator() } cmLocalGenerator * -cmGlobalGhsMultiGenerator::CreateLocalGenerator(cmMakefile* mf) +cmGlobalGhsMultiGenerator::CreateLocalGenerator(cmLocalGenerator* parent, + cmState::Snapshot snapshot) { - return new cmLocalGhsMultiGenerator(this, mf); + return new cmLocalGhsMultiGenerator(this, parent, snapshot); } void cmGlobalGhsMultiGenerator::GetDocumentation(cmDocumentationEntry &entry) diff --git a/Source/cmGlobalGhsMultiGenerator.h b/Source/cmGlobalGhsMultiGenerator.h index 8f88d4f..f1a3ed7 100644 --- a/Source/cmGlobalGhsMultiGenerator.h +++ b/Source/cmGlobalGhsMultiGenerator.h @@ -31,7 +31,8 @@ public: { return new cmGlobalGeneratorSimpleFactory(); } ///! create the correct local generator - virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf); + virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent, + cmState::Snapshot snapshot); /// @return the name of this generator. static std::string GetActualName() { return "Green Hills MULTI"; } diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 120bb03..b92ad32 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -528,9 +528,10 @@ cmGlobalNinjaGenerator::cmGlobalNinjaGenerator(cmake* cm) // Virtual public methods. cmLocalGenerator* -cmGlobalNinjaGenerator::CreateLocalGenerator(cmMakefile* mf) +cmGlobalNinjaGenerator::CreateLocalGenerator(cmLocalGenerator* parent, + cmState::Snapshot snapshot) { - return new cmLocalNinjaGenerator(this, mf); + return new cmLocalNinjaGenerator(this, parent, snapshot); } void cmGlobalNinjaGenerator diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index d204a50..f103801 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -162,24 +162,33 @@ public: public: cmGlobalNinjaGenerator(cmake* cm); + /// Convenience method for creating an instance of this class. static cmGlobalGeneratorFactory* NewFactory() { return new cmGlobalGeneratorSimpleFactory(); } + /// Destructor. virtual ~cmGlobalNinjaGenerator() { } - virtual cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf); + /// Overloaded methods. @see cmGlobalGenerator::CreateLocalGenerator() + virtual cmLocalGenerator* CreateLocalGenerator(cmLocalGenerator* parent, + cmState::Snapshot snapshot); + /// Overloaded methods. @see cmGlobalGenerator::GetName(). virtual std::string GetName() const { return cmGlobalNinjaGenerator::GetActualName(); } + /// @return the name of this generator. static std::string GetActualName() { return "Ninja"; } + /// Overloaded methods. @see cmGlobalGenerator::GetDocumentation() static void GetDocumentation(cmDocumentationEntry& entry); + /// Overloaded methods. @see cmGlobalGenerator::EnableLanguage() virtual void EnableLanguage(std::vectorconst& languages, cmMakefile* mf, bool optional); + /// Overloaded methods. @see cmGlobalGenerator::GenerateBuildCommand() virtual void GenerateBuildCommand( std::vector& makeCommand, const std::string& makeProgram, @@ -298,8 +307,11 @@ public: protected: + /// Overloaded methods. @see cmGlobalGenerator::Generate() virtual void Generate(); + /// Overloaded methods. + /// @see cmGlobalGenerator::CheckALLOW_DUPLICATE_CUSTOM_TARGETS() virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const { return true; } diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index cf4fd69..605ece2 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -59,10 +59,11 @@ void cmGlobalUnixMakefileGenerator3 } ///! Create a local generator appropriate to this Global Generator -cmLocalGenerator* cmGlobalUnixMakefileGenerator3::CreateLocalGenerator( - cmMakefile* mf) +cmLocalGenerator * +cmGlobalUnixMakefileGenerator3::CreateLocalGenerator(cmLocalGenerator* parent, + cmState::Snapshot snapshot) { - return new cmLocalUnixMakefileGenerator3(this, mf); + return new cmLocalUnixMakefileGenerator3(this, parent, snapshot); } //---------------------------------------------------------------------------- @@ -577,20 +578,16 @@ void cmGlobalUnixMakefileGenerator3 makeOptions.begin(), makeOptions.end()); if (!targetName.empty()) { - cmMakefile* mf; cmLocalUnixMakefileGenerator3 *lg; if (!this->LocalGenerators.empty()) { lg = static_cast (this->LocalGenerators[0]); - mf = lg->GetMakefile(); } else { - cmState::Snapshot snapshot = this->CMakeInstance->GetCurrentSnapshot(); - mf = new cmMakefile(this, snapshot); lg = static_cast - (this->CreateLocalGenerator(mf)); + (this->MakeLocalGenerator()); // set the Start directories lg->GetMakefile()->SetCurrentSourceDirectory (this->CMakeInstance->GetHomeDirectory()); @@ -609,7 +606,6 @@ void cmGlobalUnixMakefileGenerator3 if (this->LocalGenerators.empty()) { delete lg; - delete mf; } } } diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index 5f39c79..c738c16 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -67,7 +67,9 @@ public: /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); - virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf); + ///! Create a local generator appropriate to this Global Generator3 + virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent, + cmState::Snapshot snapshot); /** * Try to determine system information such as shared library diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 44d632d..8ec4fd9 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -306,10 +306,11 @@ void cmGlobalVisualStudio10Generator::WriteSLNHeader(std::ostream& fout) } ///! Create a local generator appropriate to this Global Generator -cmLocalGenerator* cmGlobalVisualStudio10Generator::CreateLocalGenerator( - cmMakefile* mf) +cmLocalGenerator * +cmGlobalVisualStudio10Generator::CreateLocalGenerator(cmLocalGenerator* parent, + cmState::Snapshot snapshot) { - return new cmLocalVisualStudio10Generator(this, mf); + return new cmLocalVisualStudio10Generator(this, parent, snapshot); } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 8de7b09..3d34a3f 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -48,7 +48,8 @@ public: virtual bool Compute(); ///! create the correct local generator - virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf); + virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent, + cmState::Snapshot snapshot); /** * Try to determine system information such as shared library diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx index df49948..b7c897c 100644 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ b/Source/cmGlobalVisualStudio6Generator.cxx @@ -173,9 +173,10 @@ cmGlobalVisualStudio6Generator::GenerateBuildCommand( ///! Create a local generator appropriate to this Global Generator cmLocalGenerator * -cmGlobalVisualStudio6Generator::CreateLocalGenerator(cmMakefile* mf) +cmGlobalVisualStudio6Generator::CreateLocalGenerator(cmLocalGenerator* parent, + cmState::Snapshot snapshot) { - return new cmLocalVisualStudio6Generator(this, mf); + return new cmLocalVisualStudio6Generator(this, parent, snapshot); } diff --git a/Source/cmGlobalVisualStudio6Generator.h b/Source/cmGlobalVisualStudio6Generator.h index e9b24ea..420cb0b 100644 --- a/Source/cmGlobalVisualStudio6Generator.h +++ b/Source/cmGlobalVisualStudio6Generator.h @@ -39,7 +39,8 @@ public: static void GetDocumentation(cmDocumentationEntry& entry); ///! Create a local generator appropriate to this Global Generator - virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf); + virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent, + cmState::Snapshot snapshot); /** * Try to determine system information such as shared library diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 0175062..2660d23 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -279,11 +279,12 @@ void cmGlobalVisualStudio7Generator::GenerateBuildCommand( } ///! Create a local generator appropriate to this Global Generator -cmLocalGenerator *cmGlobalVisualStudio7Generator::CreateLocalGenerator( - cmMakefile* mf) +cmLocalGenerator * +cmGlobalVisualStudio7Generator::CreateLocalGenerator(cmLocalGenerator* parent, + cmState::Snapshot snapshot) { cmLocalVisualStudio7Generator *lg = - new cmLocalVisualStudio7Generator(this, mf); + new cmLocalVisualStudio7Generator(this, parent, snapshot); return lg; } diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 35575d1..931ac9c 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -43,7 +43,8 @@ public: std::string const& GetPlatformName() const; ///! Create a local generator appropriate to this Global Generator - virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf); + virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent, + cmState::Snapshot snapshot); virtual bool SetSystemName(std::string const& s, cmMakefile* mf); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 33babec..eb547bd 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -371,9 +371,10 @@ cmGlobalXCodeGenerator::GenerateBuildCommand( //---------------------------------------------------------------------------- ///! Create a local generator appropriate to this Global Generator cmLocalGenerator * -cmGlobalXCodeGenerator::CreateLocalGenerator(cmMakefile* mf) +cmGlobalXCodeGenerator::CreateLocalGenerator(cmLocalGenerator* parent, + cmState::Snapshot snapshot) { - return new cmLocalXCodeGenerator(this, mf); + return new cmLocalXCodeGenerator(this, parent, snapshot); } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index 102c036..ee8bf2c 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -41,7 +41,8 @@ public: static void GetDocumentation(cmDocumentationEntry& entry); ///! Create a local generator appropriate to this Global Generator - virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile *mf); + virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent, + cmState::Snapshot snapshot); /** * Try to determine system information such as shared library diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx index 2023697..fa29b4f 100644 --- a/Source/cmGraphVizWriter.cxx +++ b/Source/cmGraphVizWriter.cxx @@ -68,9 +68,8 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName, cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); cmGlobalGenerator ggi(&cm); - cmsys::auto_ptr mf( - new cmMakefile(&ggi, cm.GetCurrentSnapshot())); - cmsys::auto_ptr lg(ggi.CreateLocalGenerator(mf.get())); + cmsys::auto_ptr lg(ggi.MakeLocalGenerator()); + cmMakefile *mf = lg->GetMakefile(); const char* inFileName = settingsFileName; diff --git a/Source/cmLocalCommonGenerator.cxx b/Source/cmLocalCommonGenerator.cxx index 5a18e2f..4583446 100644 --- a/Source/cmLocalCommonGenerator.cxx +++ b/Source/cmLocalCommonGenerator.cxx @@ -14,8 +14,9 @@ #include "cmMakefile.h" cmLocalCommonGenerator::cmLocalCommonGenerator(cmGlobalGenerator* gg, - cmMakefile* mf): - cmLocalGenerator(gg, mf) + cmLocalGenerator* parent, + cmState::Snapshot snapshot): + cmLocalGenerator(gg, parent, snapshot) { } diff --git a/Source/cmLocalCommonGenerator.h b/Source/cmLocalCommonGenerator.h index 6b4b1cd..af94cda 100644 --- a/Source/cmLocalCommonGenerator.h +++ b/Source/cmLocalCommonGenerator.h @@ -22,7 +22,9 @@ class cmCommonTargetGenerator; class cmLocalCommonGenerator: public cmLocalGenerator { public: - cmLocalCommonGenerator(cmGlobalGenerator* gg, cmMakefile* mf); + cmLocalCommonGenerator(cmGlobalGenerator* gg, + cmLocalGenerator* parent, + cmState::Snapshot snapshot); ~cmLocalCommonGenerator(); std::string const& GetConfigName() { return this->ConfigName; } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 455b698..7ce4819 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -43,13 +43,15 @@ #endif cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg, - cmMakefile* makefile) - : cmOutputConverter(makefile->GetStateSnapshot()), - StateSnapshot(makefile->GetStateSnapshot()) + cmLocalGenerator* parent, + cmState::Snapshot snapshot) + : cmOutputConverter(snapshot), StateSnapshot(snapshot) { + assert(snapshot.IsValid()); this->GlobalGenerator = gg; + this->Parent = parent; - this->Makefile = makefile; + this->Makefile = new cmMakefile(this); this->EmitUniversalBinaryFlags = true; this->BackwardsCompatibility = 0; @@ -58,6 +60,7 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg, cmLocalGenerator::~cmLocalGenerator() { + delete this->Makefile; } void cmLocalGenerator::IssueMessage(cmake::MessageType t, diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 28b5ed1..915814b 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -36,7 +36,8 @@ class cmCustomCommandGenerator; class cmLocalGenerator : public cmOutputConverter { public: - cmLocalGenerator(cmGlobalGenerator* gg, cmMakefile* makefile); + cmLocalGenerator(cmGlobalGenerator* gg, cmLocalGenerator* parent, + cmState::Snapshot snapshot); virtual ~cmLocalGenerator(); /** @@ -85,6 +86,9 @@ public: cmState* GetState() const; cmState::Snapshot GetStateSnapshot() const; + ///! set/get the parent generator + cmLocalGenerator* GetParent() const {return this->Parent;} + void AddArchitectureFlags(std::string& flags, cmGeneratorTarget const* target, const std::string&lang, const std::string& config); @@ -339,6 +343,7 @@ protected: cmMakefile *Makefile; cmState::Snapshot StateSnapshot; cmGlobalGenerator *GlobalGenerator; + cmLocalGenerator* Parent; std::map UniqueObjectNamesMap; std::string::size_type ObjectPathMax; std::set ObjectMaxPathViolations; diff --git a/Source/cmLocalGhsMultiGenerator.cxx b/Source/cmLocalGhsMultiGenerator.cxx index bac989f..8e498dd 100644 --- a/Source/cmLocalGhsMultiGenerator.cxx +++ b/Source/cmLocalGhsMultiGenerator.cxx @@ -17,8 +17,9 @@ #include "cmGeneratedFileStream.h" cmLocalGhsMultiGenerator::cmLocalGhsMultiGenerator(cmGlobalGenerator* gg, - cmMakefile* mf) - : cmLocalGenerator(gg, mf) + cmLocalGenerator* parent, + cmState::Snapshot snapshot) + : cmLocalGenerator(gg, parent, snapshot) { } diff --git a/Source/cmLocalGhsMultiGenerator.h b/Source/cmLocalGhsMultiGenerator.h index b6a9a33..f52ef39 100644 --- a/Source/cmLocalGhsMultiGenerator.h +++ b/Source/cmLocalGhsMultiGenerator.h @@ -25,7 +25,8 @@ class cmGeneratedFileStream; class cmLocalGhsMultiGenerator : public cmLocalGenerator { public: - cmLocalGhsMultiGenerator(cmGlobalGenerator* gg, cmMakefile* mf); + cmLocalGhsMultiGenerator(cmGlobalGenerator* gg, cmLocalGenerator* parent, + cmState::Snapshot snapshot); virtual ~cmLocalGhsMultiGenerator(); diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 7525bf2..cfca418 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -23,8 +23,9 @@ #include cmLocalNinjaGenerator::cmLocalNinjaGenerator(cmGlobalGenerator* gg, - cmMakefile* mf) - : cmLocalCommonGenerator(gg, mf) + cmLocalGenerator* parent, + cmState::Snapshot snapshot) + : cmLocalCommonGenerator(gg, parent, snapshot) , HomeRelativeOutputPath("") { this->TargetImplib = "$TARGET_IMPLIB"; diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index 8d3d49c..d10be0c 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -31,7 +31,8 @@ class cmake; class cmLocalNinjaGenerator : public cmLocalCommonGenerator { public: - cmLocalNinjaGenerator(cmGlobalGenerator* gg, cmMakefile* mf); + cmLocalNinjaGenerator(cmGlobalGenerator* gg, cmLocalGenerator* parent, + cmState::Snapshot snapshot); virtual ~cmLocalNinjaGenerator(); diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index b131a63..589105e 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -80,8 +80,9 @@ static std::string cmSplitExtension(std::string const& in, std::string& base) //---------------------------------------------------------------------------- cmLocalUnixMakefileGenerator3:: -cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg, cmMakefile* mf) - : cmLocalCommonGenerator(gg, mf) +cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg, cmLocalGenerator* parent, + cmState::Snapshot snapshot) + : cmLocalCommonGenerator(gg, parent, snapshot) { this->MakefileVariableSize = 0; this->ColorMakefile = false; diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index 98f15e6..01ac01b 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -34,7 +34,9 @@ class cmSourceFile; class cmLocalUnixMakefileGenerator3 : public cmLocalCommonGenerator { public: - cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg, cmMakefile* mf); + cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg, + cmLocalGenerator* parent, + cmState::Snapshot snapshot); virtual ~cmLocalUnixMakefileGenerator3(); virtual void ComputeHomeRelativeOutputPath(); diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx index b043b00..9e3185c 100644 --- a/Source/cmLocalVisualStudio10Generator.cxx +++ b/Source/cmLocalVisualStudio10Generator.cxx @@ -62,8 +62,10 @@ class cmVS10XMLParser : public cmXMLParser //---------------------------------------------------------------------------- cmLocalVisualStudio10Generator -::cmLocalVisualStudio10Generator(cmGlobalGenerator* gg, cmMakefile* mf): - cmLocalVisualStudio7Generator(gg, mf) +::cmLocalVisualStudio10Generator(cmGlobalGenerator* gg, + cmLocalGenerator* parent, + cmState::Snapshot snapshot): + cmLocalVisualStudio7Generator(gg, parent, snapshot) { } diff --git a/Source/cmLocalVisualStudio10Generator.h b/Source/cmLocalVisualStudio10Generator.h index e187590..c588aaf 100644 --- a/Source/cmLocalVisualStudio10Generator.h +++ b/Source/cmLocalVisualStudio10Generator.h @@ -25,7 +25,9 @@ class cmLocalVisualStudio10Generator : public cmLocalVisualStudio7Generator { public: ///! Set cache only and recurse to false by default. - cmLocalVisualStudio10Generator(cmGlobalGenerator* gg, cmMakefile* mf); + cmLocalVisualStudio10Generator(cmGlobalGenerator* gg, + cmLocalGenerator* parent, + cmState::Snapshot snapshot); virtual ~cmLocalVisualStudio10Generator(); diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index cc94cd4..3a44367 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -24,8 +24,10 @@ #include cmLocalVisualStudio6Generator -::cmLocalVisualStudio6Generator(cmGlobalGenerator* gg, cmMakefile* mf): - cmLocalVisualStudioGenerator(gg, mf) +::cmLocalVisualStudio6Generator(cmGlobalGenerator* gg, + cmLocalGenerator* parent, + cmState::Snapshot snapshot): + cmLocalVisualStudioGenerator(gg, parent, snapshot) { } diff --git a/Source/cmLocalVisualStudio6Generator.h b/Source/cmLocalVisualStudio6Generator.h index 828d252..a44e61d 100644 --- a/Source/cmLocalVisualStudio6Generator.h +++ b/Source/cmLocalVisualStudio6Generator.h @@ -29,7 +29,9 @@ class cmLocalVisualStudio6Generator : public cmLocalVisualStudioGenerator { public: ///! Set cache only and recurse to false by default. - cmLocalVisualStudio6Generator(cmGlobalGenerator* gg, cmMakefile* mf); + cmLocalVisualStudio6Generator(cmGlobalGenerator* gg, + cmLocalGenerator* parent, + cmState::Snapshot snapshot); virtual ~cmLocalVisualStudio6Generator(); diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index cf67251..55ad852 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -53,8 +53,10 @@ static void cmConvertToWindowsSlash(std::string& s) //---------------------------------------------------------------------------- cmLocalVisualStudio7Generator -::cmLocalVisualStudio7Generator(cmGlobalGenerator* gg, cmMakefile* mf): - cmLocalVisualStudioGenerator(gg, mf) +::cmLocalVisualStudio7Generator(cmGlobalGenerator* gg, + cmLocalGenerator* parent, + cmState::Snapshot snapshot): + cmLocalVisualStudioGenerator(gg, parent, snapshot) { this->Internal = new cmLocalVisualStudio7GeneratorInternals(this); } diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h index bc05a06..43f3af9 100644 --- a/Source/cmLocalVisualStudio7Generator.h +++ b/Source/cmLocalVisualStudio7Generator.h @@ -35,7 +35,9 @@ class cmLocalVisualStudio7Generator : public cmLocalVisualStudioGenerator { public: ///! Set cache only and recurse to false by default. - cmLocalVisualStudio7Generator(cmGlobalGenerator* gg, cmMakefile* mf); + cmLocalVisualStudio7Generator(cmGlobalGenerator* gg, + cmLocalGenerator* parent, + cmState::Snapshot snapshot); virtual ~cmLocalVisualStudio7Generator(); diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index c0072de..3588853 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/Source/cmLocalVisualStudioGenerator.cxx @@ -19,8 +19,10 @@ //---------------------------------------------------------------------------- cmLocalVisualStudioGenerator -::cmLocalVisualStudioGenerator(cmGlobalGenerator* gg, cmMakefile* mf) - : cmLocalGenerator(gg, mf) +::cmLocalVisualStudioGenerator(cmGlobalGenerator* gg, + cmLocalGenerator* parent, + cmState::Snapshot snapshot) + : cmLocalGenerator(gg, parent, snapshot) { } diff --git a/Source/cmLocalVisualStudioGenerator.h b/Source/cmLocalVisualStudioGenerator.h index 071bfb3..d414651 100644 --- a/Source/cmLocalVisualStudioGenerator.h +++ b/Source/cmLocalVisualStudioGenerator.h @@ -31,7 +31,9 @@ class cmCustomCommandGenerator; class cmLocalVisualStudioGenerator : public cmLocalGenerator { public: - cmLocalVisualStudioGenerator(cmGlobalGenerator* gg, cmMakefile* mf); + cmLocalVisualStudioGenerator(cmGlobalGenerator* gg, + cmLocalGenerator* parent, + cmState::Snapshot snapshot); virtual ~cmLocalVisualStudioGenerator(); /** Construct a script from the given list of command lines. */ diff --git a/Source/cmLocalXCodeGenerator.cxx b/Source/cmLocalXCodeGenerator.cxx index b19112d..804dd7d 100644 --- a/Source/cmLocalXCodeGenerator.cxx +++ b/Source/cmLocalXCodeGenerator.cxx @@ -16,8 +16,9 @@ //---------------------------------------------------------------------------- cmLocalXCodeGenerator::cmLocalXCodeGenerator(cmGlobalGenerator* gg, - cmMakefile* mf) - : cmLocalGenerator(gg, mf) + cmLocalGenerator* parent, + cmState::Snapshot snapshot) + : cmLocalGenerator(gg, parent, snapshot) { // the global generator does this, so do not // put these flags into the language flags diff --git a/Source/cmLocalXCodeGenerator.h b/Source/cmLocalXCodeGenerator.h index 6d0926f..26fff9c 100644 --- a/Source/cmLocalXCodeGenerator.h +++ b/Source/cmLocalXCodeGenerator.h @@ -24,8 +24,8 @@ class cmLocalXCodeGenerator : public cmLocalGenerator { public: ///! Set cache only and recurse to false by default. - cmLocalXCodeGenerator(cmGlobalGenerator* gg, - cmMakefile* mf); + cmLocalXCodeGenerator(cmGlobalGenerator* gg, cmLocalGenerator* parent, + cmState::Snapshot snapshot); virtual ~cmLocalXCodeGenerator(); virtual std::string GetTargetDirectory(cmTarget const& target) const; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 6480667..4a4663a 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -16,6 +16,7 @@ #include "cmSourceFileLocation.h" #include "cmSystemTools.h" #include "cmGlobalGenerator.h" +#include "cmLocalGenerator.h" #include "cmCommands.h" #include "cmState.h" #include "cmOutputConverter.h" @@ -43,10 +44,9 @@ #include // default is not to be building executables -cmMakefile::cmMakefile(cmGlobalGenerator* globalGenerator, - cmState::Snapshot const& snapshot) - : GlobalGenerator(globalGenerator), - StateSnapshot(snapshot) +cmMakefile::cmMakefile(cmLocalGenerator* localGenerator) + : LocalGenerator(localGenerator), + StateSnapshot(localGenerator->GetStateSnapshot()) { this->IsSourceFileTryCompile = false; @@ -1753,8 +1753,13 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath, this->ContextStack.back()->Name, this->ContextStack.back()->Line); - cmMakefile* subMf = new cmMakefile(this->GlobalGenerator, newSnapshot); - this->GetGlobalGenerator()->AddMakefile(subMf); + // create a new local generator and set its parent + cmLocalGenerator *lg2 = this->GetGlobalGenerator() + ->MakeLocalGenerator(newSnapshot, this->LocalGenerator); + this->GetGlobalGenerator()->AddMakefile(lg2->GetMakefile()); + this->GetGlobalGenerator()->AddLocalGenerator(lg2); + + cmMakefile* subMf = lg2->GetMakefile(); // set the subdirs start dirs subMf->SetCurrentSourceDirectory(srcPath); @@ -2329,8 +2334,7 @@ void cmMakefile::ExpandVariablesCMP0019() l != this->Targets.end(); ++l) { cmTarget &t = l->second; - if (t.GetType() == cmTarget::INTERFACE_LIBRARY - || t.GetType() == cmTarget::GLOBAL_TARGET) + if (t.GetType() == cmTarget::INTERFACE_LIBRARY) { continue; } @@ -3740,12 +3744,12 @@ bool cmMakefile::GetIsSourceFileTryCompile() const cmake *cmMakefile::GetCMakeInstance() const { - return this->GlobalGenerator->GetCMakeInstance(); + return this->GetGlobalGenerator()->GetCMakeInstance(); } cmGlobalGenerator* cmMakefile::GetGlobalGenerator() const { - return this->GlobalGenerator; + return this->LocalGenerator->GetGlobalGenerator(); } #ifdef CMAKE_BUILD_WITH_CMAKE diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 3cf20a6..f3839aa 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -42,6 +42,7 @@ class cmFunctionBlocker; class cmCommand; class cmInstallGenerator; +class cmLocalGenerator; class cmMakeDepend; class cmSourceFile; class cmTest; @@ -70,8 +71,7 @@ public: /** * Construct an empty makefile. */ - cmMakefile(cmGlobalGenerator* globalGenerator, - const cmState::Snapshot& snapshot); + cmMakefile(cmLocalGenerator* localGenerator); /** * Destructor. @@ -856,7 +856,7 @@ protected: #endif std::vector FinalPassCommands; - cmGlobalGenerator* GlobalGenerator; + cmLocalGenerator* LocalGenerator; bool IsFunctionBlocked(const cmListFileFunction& lff, cmExecutionStatus &status); diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index becfeba..0a4b546 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -1217,9 +1217,7 @@ bool cmQtAutoGenerators::Run(const std::string& targetDirectory, cm.SetHomeDirectory(targetDirectory); cmGlobalGenerator gg(&cm); - cmState::Snapshot snapshot = cm.GetCurrentSnapshot(); - cmsys::auto_ptr mf(new cmMakefile(&gg, snapshot)); - cmsys::auto_ptr lg(gg.CreateLocalGenerator(mf.get())); + cmLocalGenerator* lg = gg.MakeLocalGenerator(); lg->GetMakefile()->SetCurrentBinaryDirectory(targetDirectory); lg->GetMakefile()->SetCurrentSourceDirectory(targetDirectory); gg.SetCurrentMakefile(lg->GetMakefile()); @@ -1236,6 +1234,7 @@ bool cmQtAutoGenerators::Run(const std::string& targetDirectory, this->WriteOldMocDefinitionsFile(targetDirectory); + delete lg; return success; } diff --git a/Source/cmake.cxx b/Source/cmake.cxx index f069481..1f5c4d4 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -429,9 +429,7 @@ void cmake::ReadListFile(const std::vector& args, std::string homeOutputDir = this->GetHomeOutputDirectory(); this->SetHomeDirectory(cmSystemTools::GetCurrentWorkingDirectory()); this->SetHomeOutputDirectory(cmSystemTools::GetCurrentWorkingDirectory()); - cmState::Snapshot snapshot = this->GetCurrentSnapshot(); - cmsys::auto_ptr mf(new cmMakefile(gg, snapshot)); - cmsys::auto_ptr lg(gg->CreateLocalGenerator(mf.get())); + cmsys::auto_ptr lg(gg->MakeLocalGenerator()); lg->GetMakefile()->SetCurrentBinaryDirectory (cmSystemTools::GetCurrentWorkingDirectory()); lg->GetMakefile()->SetCurrentSourceDirectory @@ -471,10 +469,9 @@ bool cmake::FindPackage(const std::vector& args) cmGlobalGenerator *gg = new cmGlobalGenerator(this); this->SetGlobalGenerator(gg); - cmState::Snapshot snapshot = this->GetCurrentSnapshot(); // read in the list file to fill the cache - cmsys::auto_ptr mf(new cmMakefile(gg, snapshot)); - cmsys::auto_ptr lg(gg->CreateLocalGenerator(mf.get())); + cmsys::auto_ptr lg(gg->MakeLocalGenerator()); + cmMakefile* mf = lg->GetMakefile(); mf->SetCurrentBinaryDirectory (cmSystemTools::GetCurrentWorkingDirectory()); mf->SetCurrentSourceDirectory @@ -2062,8 +2059,8 @@ int cmake::CheckBuildSystem() cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); cmGlobalGenerator gg(&cm); - cmsys::auto_ptr mf(new cmMakefile(&gg, cm.GetCurrentSnapshot())); - cmsys::auto_ptr lg(gg.CreateLocalGenerator(mf.get())); + cmsys::auto_ptr lg(gg.MakeLocalGenerator()); + cmMakefile* mf = lg->GetMakefile(); if(!mf->ReadListFile(this->CheckBuildSystemArgument.c_str()) || cmSystemTools::GetErrorOccuredFlag()) { @@ -2092,11 +2089,8 @@ int cmake::CheckBuildSystem() ggd(this->CreateGlobalGenerator(genName)); if(ggd.get()) { - cmsys::auto_ptr mfd(new cmMakefile(ggd.get(), - cm.GetCurrentSnapshot())); - cmsys::auto_ptr lgd( - ggd->CreateLocalGenerator(mfd.get())); - lgd->ClearDependencies(mfd.get(), verbose); + cmsys::auto_ptr lgd(ggd->MakeLocalGenerator()); + lgd->ClearDependencies(mf, verbose); } } diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index aa70aa0..7bee0ea 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -768,10 +768,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector& args) if(cmGlobalGenerator* ggd = cm.CreateGlobalGenerator(gen)) { cm.SetGlobalGenerator(ggd); - cmState::Snapshot snapshot = cm.GetCurrentSnapshot(); - cmsys::auto_ptr mf(new cmMakefile(ggd, snapshot)); - cmsys::auto_ptr lgd( - ggd->CreateLocalGenerator(mf.get())); + cmsys::auto_ptr lgd(ggd->MakeLocalGenerator()); lgd->GetMakefile()->SetCurrentSourceDirectory(startDir); lgd->GetMakefile()->SetCurrentBinaryDirectory(startOutDir); ----------------------------------------------------------------------- Summary of changes: Source/CPack/cmCPackGenerator.cxx | 6 +- Source/CPack/cpack.cxx | 10 ++- Source/CTest/cmCTestLaunch.cxx | 5 +- Source/CTest/cmCTestScriptHandler.cxx | 45 +++++++++----- Source/CTest/cmCTestTestHandler.cxx | 5 +- Source/cmCTest.cxx | 7 +-- Source/cmGlobalBorlandMakefileGenerator.cxx | 4 +- Source/cmGlobalBorlandMakefileGenerator.h | 3 +- Source/cmGlobalGenerator.cxx | 87 ++++++++++++++------------- Source/cmGlobalGenerator.h | 12 ++-- Source/cmGlobalGhsMultiGenerator.cxx | 5 +- Source/cmGlobalGhsMultiGenerator.h | 3 +- Source/cmGlobalNinjaGenerator.cxx | 5 +- Source/cmGlobalNinjaGenerator.h | 14 ++++- Source/cmGlobalUnixMakefileGenerator3.cxx | 14 ++--- Source/cmGlobalUnixMakefileGenerator3.h | 4 +- Source/cmGlobalVisualStudio10Generator.cxx | 7 ++- Source/cmGlobalVisualStudio10Generator.h | 3 +- Source/cmGlobalVisualStudio6Generator.cxx | 5 +- Source/cmGlobalVisualStudio6Generator.h | 3 +- Source/cmGlobalVisualStudio7Generator.cxx | 7 ++- Source/cmGlobalVisualStudio7Generator.h | 3 +- Source/cmGlobalXCodeGenerator.cxx | 5 +- Source/cmGlobalXCodeGenerator.h | 3 +- Source/cmGraphVizWriter.cxx | 5 +- Source/cmLocalCommonGenerator.cxx | 5 +- Source/cmLocalCommonGenerator.h | 4 +- Source/cmLocalGenerator.cxx | 11 ++-- Source/cmLocalGenerator.h | 7 ++- Source/cmLocalGhsMultiGenerator.cxx | 5 +- Source/cmLocalGhsMultiGenerator.h | 3 +- Source/cmLocalNinjaGenerator.cxx | 5 +- Source/cmLocalNinjaGenerator.h | 3 +- Source/cmLocalUnixMakefileGenerator3.cxx | 5 +- Source/cmLocalUnixMakefileGenerator3.h | 4 +- Source/cmLocalVisualStudio10Generator.cxx | 6 +- Source/cmLocalVisualStudio10Generator.h | 4 +- Source/cmLocalVisualStudio6Generator.cxx | 6 +- Source/cmLocalVisualStudio6Generator.h | 4 +- Source/cmLocalVisualStudio7Generator.cxx | 6 +- Source/cmLocalVisualStudio7Generator.h | 4 +- Source/cmLocalVisualStudioGenerator.cxx | 6 +- Source/cmLocalVisualStudioGenerator.h | 4 +- Source/cmLocalXCodeGenerator.cxx | 5 +- Source/cmLocalXCodeGenerator.h | 4 +- Source/cmMakefile.cxx | 24 +++++--- Source/cmMakefile.h | 6 +- Source/cmQtAutoGenerators.cxx | 5 +- Source/cmake.cxx | 20 +++--- Source/cmcmd.cxx | 5 +- 50 files changed, 247 insertions(+), 184 deletions(-) hooks/post-receive -- CMake From steveire at gmail.com Fri Aug 28 12:45:29 2015 From: steveire at gmail.com (Stephen Kelly) Date: Fri, 28 Aug 2015 12:45:29 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2611-g967ddfb Message-ID: <20150828164529.09629B26C2@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 967ddfb3100032f45a846c58f36073bb0e82926d (commit) via 2b9a25d7f723a9876e2979de8e6c06881e0312dc (commit) via 3e08b4df95208286d8891d76234f7910ff5c1d1c (commit) via 357bf469c7a6c6adad1f3269474989af9b203994 (commit) via ebf8d0a99ac6eb231180b3315b976bcc58baa9f3 (commit) via bd096d30e05fe66a0bf702fe7e366b0042ea14ae (commit) via ff8ac8ee6ab3ee686621445456a765fa33c1a873 (commit) via 0bd7279fd9608702b7790822c80f3c284de8e7e4 (commit) via 2f2d4da9dd031cdf9f8a0cadcbdffe38c2170353 (commit) via 7fdc9a8b5f63f645b5aedede4fd18e0c1d1c39c5 (commit) via 92041eec49ab4968b2d4f09e3bd71a3720d86036 (commit) via acb006229dbc531303538f4de1dc4d16d27369a5 (commit) via 83b8a927e5a992480e96b0be36ea0426a924c41f (commit) via 9b6a743b801dffa9f7ccab0c3e73fa8d22f3b8b9 (commit) from a741812b5189b0d0d61d7b1119410e8b0f722613 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=967ddfb3100032f45a846c58f36073bb0e82926d commit 967ddfb3100032f45a846c58f36073bb0e82926d Merge: a741812 2b9a25d Author: Stephen Kelly AuthorDate: Fri Aug 28 12:45:26 2015 -0400 Commit: CMake Topic Stage CommitDate: Fri Aug 28 12:45:26 2015 -0400 Merge topic 'generate-time-generators' into next 2b9a25d7 cmGlobalGenerator: Create global targets directly after Configure. 3e08b4df cmMakefile: Skip Global targets for CMP0019 evaluation. 357bf469 cmGlobalGenerator: Fill the project map at compute time. ebf8d0a9 cmGlobalGenerator: Rename method. bd096d30 cmGlobalGenerator: Avoid cmLocalGenerator until after Configure. ff8ac8ee cmLocalGenerator: Create from already-constructed cmMakefile. 0bd7279f Ninja: Remove some incorrect comments adding no value. 2f2d4da9 cmCTestScriptHandler: Simplify deletes. 7fdc9a8b QtAutogen: Use a smart pointer. 92041eec cmGlobalGenerator: Remove MakeLocalGenerator method. acb00622 cmGlobalGenerator: Require a snapshot to create a local generator. 83b8a927 cmMakefile: Remove cmLocalGenerator member. 9b6a743b cmLocalGenerator: Remove Parent pointer. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2b9a25d7f723a9876e2979de8e6c06881e0312dc commit 2b9a25d7f723a9876e2979de8e6c06881e0312dc Author: Stephen Kelly AuthorDate: Sun Aug 2 12:59:06 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 28 18:44:39 2015 +0200 cmGlobalGenerator: Create global targets directly after Configure. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 08ab163..b3f3cba 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1146,6 +1146,22 @@ void cmGlobalGenerator::Configure() dirMf->Configure(); dirMf->EnforceDirectoryLevelRules(); + // Put a copy of each global target in every directory. + cmTargets globalTargets; + this->CreateDefaultGlobalTargets(&globalTargets); + + for (unsigned int i = 0; i < this->Makefiles.size(); ++i) + { + cmMakefile* mf = this->Makefiles[i]; + cmTargets* targets = &(mf->GetTargets()); + cmTargets::iterator tit; + for ( tit = globalTargets.begin(); tit != globalTargets.end(); ++ tit ) + { + (*targets)[tit->first] = tit->second; + (*targets)[tit->first].SetMakefile(mf); + } + } + // update the cache entry for the number of local generators, this is used // for progress char num[100]; @@ -1183,25 +1199,6 @@ void cmGlobalGenerator::Configure() } this->CMakeInstance->UpdateProgress(msg.str().c_str(), -1); } - - unsigned int i; - - // Put a copy of each global target in every directory. - cmTargets globalTargets; - this->CreateDefaultGlobalTargets(&globalTargets); - - for (i = 0; i < this->Makefiles.size(); ++i) - { - cmMakefile* mf = this->Makefiles[i]; - cmTargets* targets = &(mf->GetTargets()); - cmTargets::iterator tit; - for ( tit = globalTargets.begin(); tit != globalTargets.end(); ++ tit ) - { - (*targets)[tit->first] = tit->second; - (*targets)[tit->first].SetMakefile(mf); - } - } - } void cmGlobalGenerator::CreateGenerationObjects(TargetTypes targetTypes) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3e08b4df95208286d8891d76234f7910ff5c1d1c commit 3e08b4df95208286d8891d76234f7910ff5c1d1c Author: Stephen Kelly AuthorDate: Sun Aug 2 13:25:53 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 28 18:44:39 2015 +0200 cmMakefile: Skip Global targets for CMP0019 evaluation. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 7893032..8a3d197 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2334,7 +2334,8 @@ void cmMakefile::ExpandVariablesCMP0019() l != this->Targets.end(); ++l) { cmTarget &t = l->second; - if (t.GetType() == cmTarget::INTERFACE_LIBRARY) + if (t.GetType() == cmTarget::INTERFACE_LIBRARY + || t.GetType() == cmTarget::GLOBAL_TARGET) { continue; } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=357bf469c7a6c6adad1f3269474989af9b203994 commit 357bf469c7a6c6adad1f3269474989af9b203994 Author: Stephen Kelly AuthorDate: Sun Aug 2 12:55:05 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 28 18:44:39 2015 +0200 cmGlobalGenerator: Fill the project map at compute time. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index e0e5af1..08ab163 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1158,10 +1158,6 @@ void cmGlobalGenerator::Configure() // and for infinite loops this->CheckTargetProperties(); - // at this point this->LocalGenerators has been filled, - // so create the map from project name to vector of local generators - this->FillProjectMap(); - if ( this->CMakeInstance->GetWorkingMode() == cmake::NORMAL_MODE) { std::ostringstream msg; @@ -1268,6 +1264,10 @@ bool cmGlobalGenerator::Compute() this->CreateGenerationObjects(); + // at this point this->LocalGenerators has been filled, + // so create the map from project name to vector of local generators + this->FillProjectMap(); + #ifdef CMAKE_BUILD_WITH_CMAKE // Iterate through all targets and set up automoc for those which have // the AUTOMOC, AUTOUIC or AUTORCC property set http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ebf8d0a99ac6eb231180b3315b976bcc58baa9f3 commit ebf8d0a99ac6eb231180b3315b976bcc58baa9f3 Author: Stephen Kelly AuthorDate: Sun Aug 2 12:44:07 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 28 18:44:39 2015 +0200 cmGlobalGenerator: Rename method. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index ac1c119..e0e5af1 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1156,7 +1156,7 @@ void cmGlobalGenerator::Configure() // check for link libraries and include directories containing "NOTFOUND" // and for infinite loops - this->CheckLocalGenerators(); + this->CheckTargetProperties(); // at this point this->LocalGenerators has been filled, // so create the map from project name to vector of local generators @@ -1636,7 +1636,7 @@ void cmGlobalGenerator::ComputeTargetObjectDirectory(cmGeneratorTarget*) const { } -void cmGlobalGenerator::CheckLocalGenerators() +void cmGlobalGenerator::CheckTargetProperties() { std::map notFoundMap; // std::set notFoundMap; diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index b113488..9fc2d45 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -394,7 +394,7 @@ protected: // Fill the ProjectMap, this must be called after LocalGenerators // has been populated. void FillProjectMap(); - void CheckLocalGenerators(); + void CheckTargetProperties(); bool IsExcluded(cmState::Snapshot const& root, cmState::Snapshot const& snp) const; bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen) const; http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bd096d30e05fe66a0bf702fe7e366b0042ea14ae commit bd096d30e05fe66a0bf702fe7e366b0042ea14ae Author: Stephen Kelly AuthorDate: Sun Aug 2 12:08:49 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 28 18:44:39 2015 +0200 cmGlobalGenerator: Avoid cmLocalGenerator until after Configure. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index d82c7f3..ac1c119 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1134,17 +1134,17 @@ void cmGlobalGenerator::Configure() this->LocalGenerators.push_back(lg); // set the Start directories - lg->GetMakefile()->SetCurrentSourceDirectory + dirMf->SetCurrentSourceDirectory (this->CMakeInstance->GetHomeDirectory()); - lg->GetMakefile()->SetCurrentBinaryDirectory + dirMf->SetCurrentBinaryDirectory (this->CMakeInstance->GetHomeOutputDirectory()); this->BinaryDirectories.insert( this->CMakeInstance->GetHomeOutputDirectory()); // now do it - lg->GetMakefile()->Configure(); - lg->GetMakefile()->EnforceDirectoryLevelRules(); + dirMf->Configure(); + dirMf->EnforceDirectoryLevelRules(); // update the cache entry for the number of local generators, this is used // for progress http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ff8ac8ee6ab3ee686621445456a765fa33c1a873 commit ff8ac8ee6ab3ee686621445456a765fa33c1a873 Author: Stephen Kelly AuthorDate: Sun Aug 2 11:41:51 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 28 18:44:39 2015 +0200 cmLocalGenerator: Create from already-constructed cmMakefile. Don't manage the lifetime of the cmMakefile with cmLocalGenerator. diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 8cbcd4e..92a4b2b 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -716,9 +716,10 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( cm.AddCMakePaths(); cm.SetProgressCallback(cmCPackGeneratorProgress, this); cmGlobalGenerator gg(&cm); + cmsys::auto_ptr mf( + new cmMakefile(&gg, cm.GetCurrentSnapshot())); cmsys::auto_ptr lg( - gg.CreateLocalGenerator(cm.GetCurrentSnapshot())); - cmMakefile *mf = lg->GetMakefile(); + gg.CreateLocalGenerator(mf.get())); std::string realInstallDirectory = tempInstallDirectory; if ( !installSubDirectory.empty() && installSubDirectory != "/" ) { diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index 96351f7..cb9cbc4 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -202,9 +202,10 @@ int main (int argc, char const* const* argv) cminst.SetHomeOutputDirectory(""); cminst.GetState()->RemoveUnscriptableCommands(); cmGlobalGenerator cmgg(&cminst); + cmsys::auto_ptr globalMF( + new cmMakefile(&cmgg, cminst.GetCurrentSnapshot())); cmsys::auto_ptr cmlg( - cmgg.CreateLocalGenerator(cminst.GetCurrentSnapshot())); - cmMakefile* globalMF = cmlg->GetMakefile(); + cmgg.CreateLocalGenerator(globalMF.get())); #if defined(__CYGWIN__) globalMF->AddDefinition("CMAKE_LEGACY_CYGWIN_WIN32", "0"); #endif @@ -358,8 +359,8 @@ int main (int argc, char const* const* argv) ++it ) { const char* gen = it->c_str(); - cmMakefile::ScopePushPop raii(globalMF); - cmMakefile* mf = globalMF; + cmMakefile::ScopePushPop raii(globalMF.get()); + cmMakefile* mf = globalMF.get(); cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "Specified generator: " << gen << std::endl); if ( parsed && !mf->GetDefinition("CPACK_PACKAGE_NAME") ) diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx index 7340d5c..fb0cce6 100644 --- a/Source/CTest/cmCTestLaunch.cxx +++ b/Source/CTest/cmCTestLaunch.cxx @@ -738,9 +738,9 @@ void cmCTestLaunch::LoadConfig() cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); cmGlobalGenerator gg(&cm); + cmsys::auto_ptr mf(new cmMakefile(&gg, cm.GetCurrentSnapshot())); cmsys::auto_ptr lg( - gg.CreateLocalGenerator(cm.GetCurrentSnapshot())); - cmMakefile* mf = lg->GetMakefile(); + gg.CreateLocalGenerator(mf.get())); std::string fname = this->LogDir; fname += "CTestLaunchConfig.cmake"; if(cmSystemTools::FileExists(fname.c_str()) && diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 4be5eb6..c1ba279 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -125,6 +125,7 @@ void cmCTestScriptHandler::Initialize() // what time in seconds did this script start running this->ScriptStartTime = 0; + delete this->Makefile; this->Makefile = 0; delete this->LocalGenerator; @@ -139,8 +140,7 @@ void cmCTestScriptHandler::Initialize() //---------------------------------------------------------------------- cmCTestScriptHandler::~cmCTestScriptHandler() { - // local generator owns the makefile - this->Makefile = 0; + delete this->Makefile; delete this->LocalGenerator; delete this->GlobalGenerator; delete this->CMake; @@ -317,6 +317,7 @@ void cmCTestScriptHandler::CreateCMake() delete this->CMake; delete this->GlobalGenerator; delete this->LocalGenerator; + delete this->Makefile; } this->CMake = new cmake; this->CMake->SetHomeDirectory(""); @@ -325,8 +326,9 @@ void cmCTestScriptHandler::CreateCMake() this->GlobalGenerator = new cmGlobalGenerator(this->CMake); cmState::Snapshot snapshot = this->CMake->GetCurrentSnapshot(); - this->LocalGenerator = this->GlobalGenerator->CreateLocalGenerator(snapshot); - this->Makefile = this->LocalGenerator->GetMakefile(); + this->Makefile = new cmMakefile(this->GlobalGenerator, snapshot); + this->LocalGenerator = + this->GlobalGenerator->CreateLocalGenerator(this->Makefile); this->CMake->SetProgressCallback(ctestScriptProgressCallback, this->CTest); diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 9e00193..a523f57 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -1592,9 +1592,9 @@ void cmCTestTestHandler::GetListOfTests() cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); cmGlobalGenerator gg(&cm); + cmsys::auto_ptr mf(new cmMakefile(&gg, cm.GetCurrentSnapshot())); cmsys::auto_ptr lg( - gg.CreateLocalGenerator(cm.GetCurrentSnapshot())); - cmMakefile *mf = lg->GetMakefile(); + gg.CreateLocalGenerator(mf.get())); mf->AddDefinition("CTEST_CONFIGURATION_TYPE", this->CTest->GetConfigType().c_str()); diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 1786c2c..adefd1c 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -520,10 +520,10 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command) cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); cmGlobalGenerator gg(&cm); - cmsys::auto_ptr lg( - gg.CreateLocalGenerator(cm.GetCurrentSnapshot())); - cmMakefile *mf = lg->GetMakefile(); - if ( !this->ReadCustomConfigurationFileTree(this->BinaryDir.c_str(), mf) ) + cmsys::auto_ptr mf(new cmMakefile(&gg, cm.GetCurrentSnapshot())); + cmsys::auto_ptr lg(gg.CreateLocalGenerator(mf.get())); + if ( !this->ReadCustomConfigurationFileTree(this->BinaryDir.c_str(), + mf.get()) ) { cmCTestOptionalLog(this, DEBUG, "Cannot find custom configuration file tree" << std::endl, quiet); diff --git a/Source/cmGlobalBorlandMakefileGenerator.cxx b/Source/cmGlobalBorlandMakefileGenerator.cxx index c31f952..40e8d29 100644 --- a/Source/cmGlobalBorlandMakefileGenerator.cxx +++ b/Source/cmGlobalBorlandMakefileGenerator.cxx @@ -44,10 +44,10 @@ void cmGlobalBorlandMakefileGenerator ///! Create a local generator appropriate to this Global Generator cmLocalGenerator *cmGlobalBorlandMakefileGenerator::CreateLocalGenerator( - cmState::Snapshot snapshot) + cmMakefile *mf) { cmLocalUnixMakefileGenerator3* lg = - new cmLocalUnixMakefileGenerator3(this, snapshot); + new cmLocalUnixMakefileGenerator3(this, mf); lg->SetMakefileVariableSize(32); lg->SetMakeCommandEscapeTargetTwice(true); lg->SetBorlandMakeCurlyHack(true); diff --git a/Source/cmGlobalBorlandMakefileGenerator.h b/Source/cmGlobalBorlandMakefileGenerator.h index 62e458f..b59c86d 100644 --- a/Source/cmGlobalBorlandMakefileGenerator.h +++ b/Source/cmGlobalBorlandMakefileGenerator.h @@ -36,7 +36,7 @@ public: static void GetDocumentation(cmDocumentationEntry& entry); ///! Create a local generator appropriate to this Global Generator - virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); + virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf); /** * Try to determine system information such as shared library diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index fba14e5..d82c7f3 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1127,10 +1127,10 @@ void cmGlobalGenerator::Configure() this->FirstTimeProgress = 0.0f; this->ClearGeneratorMembers(); - // start with this directory - cmLocalGenerator *lg = this->CreateLocalGenerator( - this->GetCMakeInstance()->GetCurrentSnapshot()); - this->Makefiles.push_back(lg->GetMakefile()); + cmMakefile* dirMf = + new cmMakefile(this, this->GetCMakeInstance()->GetCurrentSnapshot()); + this->Makefiles.push_back(dirMf); + cmLocalGenerator *lg = this->CreateLocalGenerator(dirMf); this->LocalGenerators.push_back(lg); // set the Start directories @@ -1601,6 +1601,7 @@ void cmGlobalGenerator::ClearGeneratorMembers() cmDeleteAll(this->BuildExportSets); this->BuildExportSets.clear(); + cmDeleteAll(this->Makefiles); this->Makefiles.clear(); cmDeleteAll(this->LocalGenerators); @@ -1987,9 +1988,9 @@ void cmGlobalGenerator::EnableInstallTarget() } cmLocalGenerator* -cmGlobalGenerator::CreateLocalGenerator(cmState::Snapshot snapshot) +cmGlobalGenerator::CreateLocalGenerator(cmMakefile* mf) { - return new cmLocalGenerator(this, snapshot); + return new cmLocalGenerator(this, mf); } void cmGlobalGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator *gen, diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 91c1aac..b113488 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -57,7 +57,7 @@ public: virtual ~cmGlobalGenerator(); virtual cmLocalGenerator* - CreateLocalGenerator(cmState::Snapshot snapshot = cmState::Snapshot()); + CreateLocalGenerator(cmMakefile* mf); ///! Get the name for this generator virtual std::string GetName() const { return "Generic"; } diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx index 29abb37..6dde1e3 100644 --- a/Source/cmGlobalGhsMultiGenerator.cxx +++ b/Source/cmGlobalGhsMultiGenerator.cxx @@ -33,9 +33,9 @@ cmGlobalGhsMultiGenerator::~cmGlobalGhsMultiGenerator() } cmLocalGenerator * -cmGlobalGhsMultiGenerator::CreateLocalGenerator(cmState::Snapshot snapshot) +cmGlobalGhsMultiGenerator::CreateLocalGenerator(cmMakefile* mf) { - return new cmLocalGhsMultiGenerator(this, snapshot); + return new cmLocalGhsMultiGenerator(this, mf); } void cmGlobalGhsMultiGenerator::GetDocumentation(cmDocumentationEntry &entry) diff --git a/Source/cmGlobalGhsMultiGenerator.h b/Source/cmGlobalGhsMultiGenerator.h index 873c20f..8f88d4f 100644 --- a/Source/cmGlobalGhsMultiGenerator.h +++ b/Source/cmGlobalGhsMultiGenerator.h @@ -31,7 +31,7 @@ public: { return new cmGlobalGeneratorSimpleFactory(); } ///! create the correct local generator - virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); + virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf); /// @return the name of this generator. static std::string GetActualName() { return "Green Hills MULTI"; } diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 72ef4d6..120bb03 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -528,9 +528,9 @@ cmGlobalNinjaGenerator::cmGlobalNinjaGenerator(cmake* cm) // Virtual public methods. cmLocalGenerator* -cmGlobalNinjaGenerator::CreateLocalGenerator(cmState::Snapshot snapshot) +cmGlobalNinjaGenerator::CreateLocalGenerator(cmMakefile* mf) { - return new cmLocalNinjaGenerator(this, snapshot); + return new cmLocalNinjaGenerator(this, mf); } void cmGlobalNinjaGenerator diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index ecc8928..d204a50 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -167,7 +167,7 @@ public: virtual ~cmGlobalNinjaGenerator() { } - virtual cmLocalGenerator* CreateLocalGenerator(cmState::Snapshot snapshot); + virtual cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf); virtual std::string GetName() const { return cmGlobalNinjaGenerator::GetActualName(); } diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 0d4ee15..cf4fd69 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -60,9 +60,9 @@ void cmGlobalUnixMakefileGenerator3 ///! Create a local generator appropriate to this Global Generator cmLocalGenerator* cmGlobalUnixMakefileGenerator3::CreateLocalGenerator( - cmState::Snapshot snapshot) + cmMakefile* mf) { - return new cmLocalUnixMakefileGenerator3(this, snapshot); + return new cmLocalUnixMakefileGenerator3(this, mf); } //---------------------------------------------------------------------------- @@ -577,17 +577,20 @@ void cmGlobalUnixMakefileGenerator3 makeOptions.begin(), makeOptions.end()); if (!targetName.empty()) { + cmMakefile* mf; cmLocalUnixMakefileGenerator3 *lg; if (!this->LocalGenerators.empty()) { lg = static_cast (this->LocalGenerators[0]); + mf = lg->GetMakefile(); } else { cmState::Snapshot snapshot = this->CMakeInstance->GetCurrentSnapshot(); + mf = new cmMakefile(this, snapshot); lg = static_cast - (this->CreateLocalGenerator(snapshot)); + (this->CreateLocalGenerator(mf)); // set the Start directories lg->GetMakefile()->SetCurrentSourceDirectory (this->CMakeInstance->GetHomeDirectory()); @@ -606,6 +609,7 @@ void cmGlobalUnixMakefileGenerator3 if (this->LocalGenerators.empty()) { delete lg; + delete mf; } } } diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index 3ea6bb2..5f39c79 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -67,8 +67,7 @@ public: /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); - ///! Create a local generator appropriate to this Global Generator3 - virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); + virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf); /** * Try to determine system information such as shared library diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index a36fed1..44d632d 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -307,9 +307,9 @@ void cmGlobalVisualStudio10Generator::WriteSLNHeader(std::ostream& fout) ///! Create a local generator appropriate to this Global Generator cmLocalGenerator* cmGlobalVisualStudio10Generator::CreateLocalGenerator( - cmState::Snapshot snapshot) + cmMakefile* mf) { - return new cmLocalVisualStudio10Generator(this, snapshot); + return new cmLocalVisualStudio10Generator(this, mf); } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index bbc22b9..8de7b09 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -48,7 +48,7 @@ public: virtual bool Compute(); ///! create the correct local generator - virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); + virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf); /** * Try to determine system information such as shared library diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx index 48c3d32..df49948 100644 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ b/Source/cmGlobalVisualStudio6Generator.cxx @@ -173,10 +173,9 @@ cmGlobalVisualStudio6Generator::GenerateBuildCommand( ///! Create a local generator appropriate to this Global Generator cmLocalGenerator * -cmGlobalVisualStudio6Generator::CreateLocalGenerator( - cmState::Snapshot snapshot) +cmGlobalVisualStudio6Generator::CreateLocalGenerator(cmMakefile* mf) { - return new cmLocalVisualStudio6Generator(this, snapshot); + return new cmLocalVisualStudio6Generator(this, mf); } diff --git a/Source/cmGlobalVisualStudio6Generator.h b/Source/cmGlobalVisualStudio6Generator.h index 0169be0..e9b24ea 100644 --- a/Source/cmGlobalVisualStudio6Generator.h +++ b/Source/cmGlobalVisualStudio6Generator.h @@ -39,7 +39,7 @@ public: static void GetDocumentation(cmDocumentationEntry& entry); ///! Create a local generator appropriate to this Global Generator - virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); + virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf); /** * Try to determine system information such as shared library diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index b8f6357..0175062 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -280,10 +280,10 @@ void cmGlobalVisualStudio7Generator::GenerateBuildCommand( ///! Create a local generator appropriate to this Global Generator cmLocalGenerator *cmGlobalVisualStudio7Generator::CreateLocalGenerator( - cmState::Snapshot snapshot) + cmMakefile* mf) { cmLocalVisualStudio7Generator *lg = - new cmLocalVisualStudio7Generator(this, snapshot); + new cmLocalVisualStudio7Generator(this, mf); return lg; } diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 5ada2c5..35575d1 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -43,7 +43,7 @@ public: std::string const& GetPlatformName() const; ///! Create a local generator appropriate to this Global Generator - virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); + virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf); virtual bool SetSystemName(std::string const& s, cmMakefile* mf); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index af3629d..33babec 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -371,9 +371,9 @@ cmGlobalXCodeGenerator::GenerateBuildCommand( //---------------------------------------------------------------------------- ///! Create a local generator appropriate to this Global Generator cmLocalGenerator * -cmGlobalXCodeGenerator::CreateLocalGenerator(cmState::Snapshot snapshot) +cmGlobalXCodeGenerator::CreateLocalGenerator(cmMakefile* mf) { - return new cmLocalXCodeGenerator(this, snapshot); + return new cmLocalXCodeGenerator(this, mf); } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index f93f62f..102c036 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -41,7 +41,7 @@ public: static void GetDocumentation(cmDocumentationEntry& entry); ///! Create a local generator appropriate to this Global Generator - virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); + virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile *mf); /** * Try to determine system information such as shared library diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx index 7da3085..2023697 100644 --- a/Source/cmGraphVizWriter.cxx +++ b/Source/cmGraphVizWriter.cxx @@ -68,9 +68,9 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName, cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); cmGlobalGenerator ggi(&cm); - cmsys::auto_ptr lg( - ggi.CreateLocalGenerator(cm.GetCurrentSnapshot())); - cmMakefile *mf = lg->GetMakefile(); + cmsys::auto_ptr mf( + new cmMakefile(&ggi, cm.GetCurrentSnapshot())); + cmsys::auto_ptr lg(ggi.CreateLocalGenerator(mf.get())); const char* inFileName = settingsFileName; diff --git a/Source/cmLocalCommonGenerator.cxx b/Source/cmLocalCommonGenerator.cxx index 58c707c..5a18e2f 100644 --- a/Source/cmLocalCommonGenerator.cxx +++ b/Source/cmLocalCommonGenerator.cxx @@ -14,8 +14,8 @@ #include "cmMakefile.h" cmLocalCommonGenerator::cmLocalCommonGenerator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot): - cmLocalGenerator(gg, snapshot) + cmMakefile* mf): + cmLocalGenerator(gg, mf) { } diff --git a/Source/cmLocalCommonGenerator.h b/Source/cmLocalCommonGenerator.h index b7caf0b..6b4b1cd 100644 --- a/Source/cmLocalCommonGenerator.h +++ b/Source/cmLocalCommonGenerator.h @@ -22,8 +22,7 @@ class cmCommonTargetGenerator; class cmLocalCommonGenerator: public cmLocalGenerator { public: - cmLocalCommonGenerator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot); + cmLocalCommonGenerator(cmGlobalGenerator* gg, cmMakefile* mf); ~cmLocalCommonGenerator(); std::string const& GetConfigName() { return this->ConfigName; } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 357a508..455b698 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -43,13 +43,13 @@ #endif cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot) - : cmOutputConverter(snapshot), StateSnapshot(snapshot) + cmMakefile* makefile) + : cmOutputConverter(makefile->GetStateSnapshot()), + StateSnapshot(makefile->GetStateSnapshot()) { - assert(snapshot.IsValid()); this->GlobalGenerator = gg; - this->Makefile = new cmMakefile(gg, snapshot); + this->Makefile = makefile; this->EmitUniversalBinaryFlags = true; this->BackwardsCompatibility = 0; @@ -58,7 +58,6 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg, cmLocalGenerator::~cmLocalGenerator() { - delete this->Makefile; } void cmLocalGenerator::IssueMessage(cmake::MessageType t, diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 4c0b1fe..28b5ed1 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -36,7 +36,7 @@ class cmCustomCommandGenerator; class cmLocalGenerator : public cmOutputConverter { public: - cmLocalGenerator(cmGlobalGenerator* gg, cmState::Snapshot snapshot); + cmLocalGenerator(cmGlobalGenerator* gg, cmMakefile* makefile); virtual ~cmLocalGenerator(); /** diff --git a/Source/cmLocalGhsMultiGenerator.cxx b/Source/cmLocalGhsMultiGenerator.cxx index 91dfeb4..bac989f 100644 --- a/Source/cmLocalGhsMultiGenerator.cxx +++ b/Source/cmLocalGhsMultiGenerator.cxx @@ -17,8 +17,8 @@ #include "cmGeneratedFileStream.h" cmLocalGhsMultiGenerator::cmLocalGhsMultiGenerator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot) - : cmLocalGenerator(gg, snapshot) + cmMakefile* mf) + : cmLocalGenerator(gg, mf) { } diff --git a/Source/cmLocalGhsMultiGenerator.h b/Source/cmLocalGhsMultiGenerator.h index 3309bfd..b6a9a33 100644 --- a/Source/cmLocalGhsMultiGenerator.h +++ b/Source/cmLocalGhsMultiGenerator.h @@ -25,8 +25,7 @@ class cmGeneratedFileStream; class cmLocalGhsMultiGenerator : public cmLocalGenerator { public: - cmLocalGhsMultiGenerator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot); + cmLocalGhsMultiGenerator(cmGlobalGenerator* gg, cmMakefile* mf); virtual ~cmLocalGhsMultiGenerator(); diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 62bf8b2..7525bf2 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -23,8 +23,8 @@ #include cmLocalNinjaGenerator::cmLocalNinjaGenerator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot) - : cmLocalCommonGenerator(gg, snapshot) + cmMakefile* mf) + : cmLocalCommonGenerator(gg, mf) , HomeRelativeOutputPath("") { this->TargetImplib = "$TARGET_IMPLIB"; diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index 4c158bc..8d3d49c 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -31,8 +31,7 @@ class cmake; class cmLocalNinjaGenerator : public cmLocalCommonGenerator { public: - cmLocalNinjaGenerator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot); + cmLocalNinjaGenerator(cmGlobalGenerator* gg, cmMakefile* mf); virtual ~cmLocalNinjaGenerator(); diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index d2b60d3..b131a63 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -80,9 +80,8 @@ static std::string cmSplitExtension(std::string const& in, std::string& base) //---------------------------------------------------------------------------- cmLocalUnixMakefileGenerator3:: -cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg, - cmState::Snapshot snapshot) - : cmLocalCommonGenerator(gg, snapshot) +cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg, cmMakefile* mf) + : cmLocalCommonGenerator(gg, mf) { this->MakefileVariableSize = 0; this->ColorMakefile = false; diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index 2b9af38..98f15e6 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -34,8 +34,7 @@ class cmSourceFile; class cmLocalUnixMakefileGenerator3 : public cmLocalCommonGenerator { public: - cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg, - cmState::Snapshot snapshot); + cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg, cmMakefile* mf); virtual ~cmLocalUnixMakefileGenerator3(); virtual void ComputeHomeRelativeOutputPath(); diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx index 25b3f19..b043b00 100644 --- a/Source/cmLocalVisualStudio10Generator.cxx +++ b/Source/cmLocalVisualStudio10Generator.cxx @@ -62,9 +62,8 @@ class cmVS10XMLParser : public cmXMLParser //---------------------------------------------------------------------------- cmLocalVisualStudio10Generator -::cmLocalVisualStudio10Generator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot): - cmLocalVisualStudio7Generator(gg, snapshot) +::cmLocalVisualStudio10Generator(cmGlobalGenerator* gg, cmMakefile* mf): + cmLocalVisualStudio7Generator(gg, mf) { } diff --git a/Source/cmLocalVisualStudio10Generator.h b/Source/cmLocalVisualStudio10Generator.h index 0f179fd..e187590 100644 --- a/Source/cmLocalVisualStudio10Generator.h +++ b/Source/cmLocalVisualStudio10Generator.h @@ -25,8 +25,7 @@ class cmLocalVisualStudio10Generator : public cmLocalVisualStudio7Generator { public: ///! Set cache only and recurse to false by default. - cmLocalVisualStudio10Generator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot); + cmLocalVisualStudio10Generator(cmGlobalGenerator* gg, cmMakefile* mf); virtual ~cmLocalVisualStudio10Generator(); diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 46e1987..cc94cd4 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -24,9 +24,8 @@ #include cmLocalVisualStudio6Generator -::cmLocalVisualStudio6Generator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot): - cmLocalVisualStudioGenerator(gg, snapshot) +::cmLocalVisualStudio6Generator(cmGlobalGenerator* gg, cmMakefile* mf): + cmLocalVisualStudioGenerator(gg, mf) { } diff --git a/Source/cmLocalVisualStudio6Generator.h b/Source/cmLocalVisualStudio6Generator.h index 86b4906..828d252 100644 --- a/Source/cmLocalVisualStudio6Generator.h +++ b/Source/cmLocalVisualStudio6Generator.h @@ -29,8 +29,7 @@ class cmLocalVisualStudio6Generator : public cmLocalVisualStudioGenerator { public: ///! Set cache only and recurse to false by default. - cmLocalVisualStudio6Generator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot); + cmLocalVisualStudio6Generator(cmGlobalGenerator* gg, cmMakefile* mf); virtual ~cmLocalVisualStudio6Generator(); diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index eebed7e..cf67251 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -53,9 +53,8 @@ static void cmConvertToWindowsSlash(std::string& s) //---------------------------------------------------------------------------- cmLocalVisualStudio7Generator -::cmLocalVisualStudio7Generator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot): - cmLocalVisualStudioGenerator(gg, snapshot) +::cmLocalVisualStudio7Generator(cmGlobalGenerator* gg, cmMakefile* mf): + cmLocalVisualStudioGenerator(gg, mf) { this->Internal = new cmLocalVisualStudio7GeneratorInternals(this); } diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h index 42ae097..bc05a06 100644 --- a/Source/cmLocalVisualStudio7Generator.h +++ b/Source/cmLocalVisualStudio7Generator.h @@ -35,8 +35,7 @@ class cmLocalVisualStudio7Generator : public cmLocalVisualStudioGenerator { public: ///! Set cache only and recurse to false by default. - cmLocalVisualStudio7Generator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot); + cmLocalVisualStudio7Generator(cmGlobalGenerator* gg, cmMakefile* mf); virtual ~cmLocalVisualStudio7Generator(); diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index 70f729f..c0072de 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/Source/cmLocalVisualStudioGenerator.cxx @@ -19,9 +19,8 @@ //---------------------------------------------------------------------------- cmLocalVisualStudioGenerator -::cmLocalVisualStudioGenerator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot) - : cmLocalGenerator(gg, snapshot) +::cmLocalVisualStudioGenerator(cmGlobalGenerator* gg, cmMakefile* mf) + : cmLocalGenerator(gg, mf) { } diff --git a/Source/cmLocalVisualStudioGenerator.h b/Source/cmLocalVisualStudioGenerator.h index 32244c7..071bfb3 100644 --- a/Source/cmLocalVisualStudioGenerator.h +++ b/Source/cmLocalVisualStudioGenerator.h @@ -31,8 +31,7 @@ class cmCustomCommandGenerator; class cmLocalVisualStudioGenerator : public cmLocalGenerator { public: - cmLocalVisualStudioGenerator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot); + cmLocalVisualStudioGenerator(cmGlobalGenerator* gg, cmMakefile* mf); virtual ~cmLocalVisualStudioGenerator(); /** Construct a script from the given list of command lines. */ diff --git a/Source/cmLocalXCodeGenerator.cxx b/Source/cmLocalXCodeGenerator.cxx index d6576f6..b19112d 100644 --- a/Source/cmLocalXCodeGenerator.cxx +++ b/Source/cmLocalXCodeGenerator.cxx @@ -16,8 +16,8 @@ //---------------------------------------------------------------------------- cmLocalXCodeGenerator::cmLocalXCodeGenerator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot) - : cmLocalGenerator(gg, snapshot) + cmMakefile* mf) + : cmLocalGenerator(gg, mf) { // the global generator does this, so do not // put these flags into the language flags diff --git a/Source/cmLocalXCodeGenerator.h b/Source/cmLocalXCodeGenerator.h index d96e78c..6d0926f 100644 --- a/Source/cmLocalXCodeGenerator.h +++ b/Source/cmLocalXCodeGenerator.h @@ -25,7 +25,7 @@ class cmLocalXCodeGenerator : public cmLocalGenerator public: ///! Set cache only and recurse to false by default. cmLocalXCodeGenerator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot); + cmMakefile* mf); virtual ~cmLocalXCodeGenerator(); virtual std::string GetTargetDirectory(cmTarget const& target) const; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 1df6213..7893032 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -16,7 +16,6 @@ #include "cmSourceFileLocation.h" #include "cmSystemTools.h" #include "cmGlobalGenerator.h" -#include "cmLocalGenerator.h" #include "cmCommands.h" #include "cmState.h" #include "cmOutputConverter.h" @@ -1754,14 +1753,14 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath, this->ContextStack.back()->Name, this->ContextStack.back()->Line); + cmMakefile* subMf = new cmMakefile(this->GlobalGenerator, newSnapshot); + this->GetGlobalGenerator()->AddMakefile(subMf); + // create a new local generator and set its parent cmLocalGenerator *lg2 = this->GetGlobalGenerator() - ->CreateLocalGenerator(newSnapshot); - this->GetGlobalGenerator()->AddMakefile(lg2->GetMakefile()); + ->CreateLocalGenerator(subMf); this->GetGlobalGenerator()->AddLocalGenerator(lg2); - cmMakefile* subMf = lg2->GetMakefile(); - // set the subdirs start dirs subMf->SetCurrentSourceDirectory(srcPath); subMf->SetCurrentBinaryDirectory(binPath); diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 9803c01..becfeba 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -1218,7 +1218,8 @@ bool cmQtAutoGenerators::Run(const std::string& targetDirectory, cmGlobalGenerator gg(&cm); cmState::Snapshot snapshot = cm.GetCurrentSnapshot(); - cmsys::auto_ptr lg(gg.CreateLocalGenerator(snapshot)); + cmsys::auto_ptr mf(new cmMakefile(&gg, snapshot)); + cmsys::auto_ptr lg(gg.CreateLocalGenerator(mf.get())); lg->GetMakefile()->SetCurrentBinaryDirectory(targetDirectory); lg->GetMakefile()->SetCurrentSourceDirectory(targetDirectory); gg.SetCurrentMakefile(lg->GetMakefile()); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index ebc38d8..f069481 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -430,7 +430,8 @@ void cmake::ReadListFile(const std::vector& args, this->SetHomeDirectory(cmSystemTools::GetCurrentWorkingDirectory()); this->SetHomeOutputDirectory(cmSystemTools::GetCurrentWorkingDirectory()); cmState::Snapshot snapshot = this->GetCurrentSnapshot(); - cmsys::auto_ptr lg(gg->CreateLocalGenerator(snapshot)); + cmsys::auto_ptr mf(new cmMakefile(gg, snapshot)); + cmsys::auto_ptr lg(gg->CreateLocalGenerator(mf.get())); lg->GetMakefile()->SetCurrentBinaryDirectory (cmSystemTools::GetCurrentWorkingDirectory()); lg->GetMakefile()->SetCurrentSourceDirectory @@ -472,8 +473,8 @@ bool cmake::FindPackage(const std::vector& args) cmState::Snapshot snapshot = this->GetCurrentSnapshot(); // read in the list file to fill the cache - cmsys::auto_ptr lg(gg->CreateLocalGenerator(snapshot)); - cmMakefile* mf = lg->GetMakefile(); + cmsys::auto_ptr mf(new cmMakefile(gg, snapshot)); + cmsys::auto_ptr lg(gg->CreateLocalGenerator(mf.get())); mf->SetCurrentBinaryDirectory (cmSystemTools::GetCurrentWorkingDirectory()); mf->SetCurrentSourceDirectory @@ -2061,9 +2062,8 @@ int cmake::CheckBuildSystem() cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); cmGlobalGenerator gg(&cm); - cmsys::auto_ptr lg( - gg.CreateLocalGenerator(cm.GetCurrentSnapshot())); - cmMakefile* mf = lg->GetMakefile(); + cmsys::auto_ptr mf(new cmMakefile(&gg, cm.GetCurrentSnapshot())); + cmsys::auto_ptr lg(gg.CreateLocalGenerator(mf.get())); if(!mf->ReadListFile(this->CheckBuildSystemArgument.c_str()) || cmSystemTools::GetErrorOccuredFlag()) { @@ -2092,9 +2092,11 @@ int cmake::CheckBuildSystem() ggd(this->CreateGlobalGenerator(genName)); if(ggd.get()) { + cmsys::auto_ptr mfd(new cmMakefile(ggd.get(), + cm.GetCurrentSnapshot())); cmsys::auto_ptr lgd( - ggd->CreateLocalGenerator(cm.GetCurrentSnapshot())); - lgd->ClearDependencies(mf, verbose); + ggd->CreateLocalGenerator(mfd.get())); + lgd->ClearDependencies(mfd.get(), verbose); } } diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index c788474..aa70aa0 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -769,8 +769,9 @@ int cmcmd::ExecuteCMakeCommand(std::vector& args) { cm.SetGlobalGenerator(ggd); cmState::Snapshot snapshot = cm.GetCurrentSnapshot(); + cmsys::auto_ptr mf(new cmMakefile(ggd, snapshot)); cmsys::auto_ptr lgd( - ggd->CreateLocalGenerator(snapshot)); + ggd->CreateLocalGenerator(mf.get())); lgd->GetMakefile()->SetCurrentSourceDirectory(startDir); lgd->GetMakefile()->SetCurrentBinaryDirectory(startOutDir); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0bd7279fd9608702b7790822c80f3c284de8e7e4 commit 0bd7279fd9608702b7790822c80f3c284de8e7e4 Author: Stephen Kelly AuthorDate: Thu Aug 27 22:13:34 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 28 18:44:39 2015 +0200 Ninja: Remove some incorrect comments adding no value. diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 418d6f7..ecc8928 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -162,32 +162,24 @@ public: public: cmGlobalNinjaGenerator(cmake* cm); - /// Convenience method for creating an instance of this class. static cmGlobalGeneratorFactory* NewFactory() { return new cmGlobalGeneratorSimpleFactory(); } - /// Destructor. virtual ~cmGlobalNinjaGenerator() { } - /// Overloaded methods. @see cmGlobalGenerator::CreateLocalGenerator() virtual cmLocalGenerator* CreateLocalGenerator(cmState::Snapshot snapshot); - /// Overloaded methods. @see cmGlobalGenerator::GetName(). virtual std::string GetName() const { return cmGlobalNinjaGenerator::GetActualName(); } - /// @return the name of this generator. static std::string GetActualName() { return "Ninja"; } - /// Overloaded methods. @see cmGlobalGenerator::GetDocumentation() static void GetDocumentation(cmDocumentationEntry& entry); - /// Overloaded methods. @see cmGlobalGenerator::EnableLanguage() virtual void EnableLanguage(std::vectorconst& languages, cmMakefile* mf, bool optional); - /// Overloaded methods. @see cmGlobalGenerator::GenerateBuildCommand() virtual void GenerateBuildCommand( std::vector& makeCommand, const std::string& makeProgram, @@ -306,11 +298,8 @@ public: protected: - /// Overloaded methods. @see cmGlobalGenerator::Generate() virtual void Generate(); - /// Overloaded methods. - /// @see cmGlobalGenerator::CheckALLOW_DUPLICATE_CUSTOM_TARGETS() virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const { return true; } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2f2d4da9dd031cdf9f8a0cadcbdffe38c2170353 commit 2f2d4da9dd031cdf9f8a0cadcbdffe38c2170353 Author: Stephen Kelly AuthorDate: Mon Aug 24 23:00:21 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 28 18:44:38 2015 +0200 cmCTestScriptHandler: Simplify deletes. Deleting a nullptr is fine. diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 8327f29..4be5eb6 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -126,20 +126,14 @@ void cmCTestScriptHandler::Initialize() this->ScriptStartTime = 0; this->Makefile = 0; - if (this->LocalGenerator) - { - delete this->LocalGenerator; - } + + delete this->LocalGenerator; this->LocalGenerator = 0; - if (this->GlobalGenerator) - { - delete this->GlobalGenerator; - } + + delete this->GlobalGenerator; this->GlobalGenerator = 0; - if (this->CMake) - { - delete this->CMake; - } + + delete this->CMake; } //---------------------------------------------------------------------- @@ -147,20 +141,9 @@ cmCTestScriptHandler::~cmCTestScriptHandler() { // local generator owns the makefile this->Makefile = 0; - if (this->LocalGenerator) - { - delete this->LocalGenerator; - } - this->LocalGenerator = 0; - if (this->GlobalGenerator) - { - delete this->GlobalGenerator; - } - this->GlobalGenerator = 0; - if (this->CMake) - { - delete this->CMake; - } + delete this->LocalGenerator; + delete this->GlobalGenerator; + delete this->CMake; } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7fdc9a8b5f63f645b5aedede4fd18e0c1d1c39c5 commit 7fdc9a8b5f63f645b5aedede4fd18e0c1d1c39c5 Author: Stephen Kelly AuthorDate: Sun Aug 2 11:41:48 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 28 18:44:38 2015 +0200 QtAutogen: Use a smart pointer. diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 9cb005c..9803c01 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -1218,7 +1218,7 @@ bool cmQtAutoGenerators::Run(const std::string& targetDirectory, cmGlobalGenerator gg(&cm); cmState::Snapshot snapshot = cm.GetCurrentSnapshot(); - cmLocalGenerator* lg = gg.CreateLocalGenerator(snapshot); + cmsys::auto_ptr lg(gg.CreateLocalGenerator(snapshot)); lg->GetMakefile()->SetCurrentBinaryDirectory(targetDirectory); lg->GetMakefile()->SetCurrentSourceDirectory(targetDirectory); gg.SetCurrentMakefile(lg->GetMakefile()); @@ -1235,7 +1235,6 @@ bool cmQtAutoGenerators::Run(const std::string& targetDirectory, this->WriteOldMocDefinitionsFile(targetDirectory); - delete lg; return success; } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=92041eec49ab4968b2d4f09e3bd71a3720d86036 commit 92041eec49ab4968b2d4f09e3bd71a3720d86036 Author: Stephen Kelly AuthorDate: Sun Aug 2 11:30:12 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 28 18:44:38 2015 +0200 cmGlobalGenerator: Remove MakeLocalGenerator method. Inline implementation to callers. diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 68509a5..8cbcd4e 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -717,7 +717,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( cm.SetProgressCallback(cmCPackGeneratorProgress, this); cmGlobalGenerator gg(&cm); cmsys::auto_ptr lg( - gg.MakeLocalGenerator(cm.GetCurrentSnapshot())); + gg.CreateLocalGenerator(cm.GetCurrentSnapshot())); cmMakefile *mf = lg->GetMakefile(); std::string realInstallDirectory = tempInstallDirectory; if ( !installSubDirectory.empty() && installSubDirectory != "/" ) diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index 0c53d1b..96351f7 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -203,7 +203,7 @@ int main (int argc, char const* const* argv) cminst.GetState()->RemoveUnscriptableCommands(); cmGlobalGenerator cmgg(&cminst); cmsys::auto_ptr cmlg( - cmgg.MakeLocalGenerator(cminst.GetCurrentSnapshot())); + cmgg.CreateLocalGenerator(cminst.GetCurrentSnapshot())); cmMakefile* globalMF = cmlg->GetMakefile(); #if defined(__CYGWIN__) globalMF->AddDefinition("CMAKE_LEGACY_CYGWIN_WIN32", "0"); diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx index d978568..7340d5c 100644 --- a/Source/CTest/cmCTestLaunch.cxx +++ b/Source/CTest/cmCTestLaunch.cxx @@ -739,7 +739,7 @@ void cmCTestLaunch::LoadConfig() cm.SetHomeOutputDirectory(""); cmGlobalGenerator gg(&cm); cmsys::auto_ptr lg( - gg.MakeLocalGenerator(cm.GetCurrentSnapshot())); + gg.CreateLocalGenerator(cm.GetCurrentSnapshot())); cmMakefile* mf = lg->GetMakefile(); std::string fname = this->LogDir; fname += "CTestLaunchConfig.cmake"; diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index c791302..8327f29 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -342,7 +342,7 @@ void cmCTestScriptHandler::CreateCMake() this->GlobalGenerator = new cmGlobalGenerator(this->CMake); cmState::Snapshot snapshot = this->CMake->GetCurrentSnapshot(); - this->LocalGenerator = this->GlobalGenerator->MakeLocalGenerator(snapshot); + this->LocalGenerator = this->GlobalGenerator->CreateLocalGenerator(snapshot); this->Makefile = this->LocalGenerator->GetMakefile(); this->CMake->SetProgressCallback(ctestScriptProgressCallback, this->CTest); diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 3262efd..9e00193 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -1593,7 +1593,7 @@ void cmCTestTestHandler::GetListOfTests() cm.SetHomeOutputDirectory(""); cmGlobalGenerator gg(&cm); cmsys::auto_ptr lg( - gg.MakeLocalGenerator(cm.GetCurrentSnapshot())); + gg.CreateLocalGenerator(cm.GetCurrentSnapshot())); cmMakefile *mf = lg->GetMakefile(); mf->AddDefinition("CTEST_CONFIGURATION_TYPE", this->CTest->GetConfigType().c_str()); diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index f020f9e..1786c2c 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -521,7 +521,7 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command) cm.SetHomeOutputDirectory(""); cmGlobalGenerator gg(&cm); cmsys::auto_ptr lg( - gg.MakeLocalGenerator(cm.GetCurrentSnapshot())); + gg.CreateLocalGenerator(cm.GetCurrentSnapshot())); cmMakefile *mf = lg->GetMakefile(); if ( !this->ReadCustomConfigurationFileTree(this->BinaryDir.c_str(), mf) ) { diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 251fa52..fba14e5 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1128,7 +1128,7 @@ void cmGlobalGenerator::Configure() this->ClearGeneratorMembers(); // start with this directory - cmLocalGenerator *lg = this->MakeLocalGenerator( + cmLocalGenerator *lg = this->CreateLocalGenerator( this->GetCMakeInstance()->GetCurrentSnapshot()); this->Makefiles.push_back(lg->GetMakefile()); this->LocalGenerators.push_back(lg); @@ -1986,12 +1986,6 @@ void cmGlobalGenerator::EnableInstallTarget() this->InstallTargetEnabled = true; } -cmLocalGenerator * -cmGlobalGenerator::MakeLocalGenerator(cmState::Snapshot snapshot) -{ - return this->CreateLocalGenerator(snapshot); -} - cmLocalGenerator* cmGlobalGenerator::CreateLocalGenerator(cmState::Snapshot snapshot) { diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 2e0f7b5..91c1aac 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -56,8 +56,8 @@ public: cmGlobalGenerator(cmake* cm); virtual ~cmGlobalGenerator(); - cmLocalGenerator* - MakeLocalGenerator(cmState::Snapshot snapshot = cmState::Snapshot()); + virtual cmLocalGenerator* + CreateLocalGenerator(cmState::Snapshot snapshot = cmState::Snapshot()); ///! Get the name for this generator virtual std::string GetName() const { return "Generic"; } @@ -440,9 +440,6 @@ protected: virtual bool UseFolderProperty(); private: - ///! Create a local generator appropriate to this Global Generator - virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); - cmMakefile* TryCompileOuterMakefile; // If you add a new map here, make sure it is copied // in EnableLanguagesFromGenerator diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index c396af4..0d4ee15 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -587,7 +587,7 @@ void cmGlobalUnixMakefileGenerator3 { cmState::Snapshot snapshot = this->CMakeInstance->GetCurrentSnapshot(); lg = static_cast - (this->MakeLocalGenerator(snapshot)); + (this->CreateLocalGenerator(snapshot)); // set the Start directories lg->GetMakefile()->SetCurrentSourceDirectory (this->CMakeInstance->GetHomeDirectory()); diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx index 797b198..7da3085 100644 --- a/Source/cmGraphVizWriter.cxx +++ b/Source/cmGraphVizWriter.cxx @@ -69,7 +69,7 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName, cm.SetHomeOutputDirectory(""); cmGlobalGenerator ggi(&cm); cmsys::auto_ptr lg( - ggi.MakeLocalGenerator(cm.GetCurrentSnapshot())); + ggi.CreateLocalGenerator(cm.GetCurrentSnapshot())); cmMakefile *mf = lg->GetMakefile(); const char* inFileName = settingsFileName; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 10ce0b3..1df6213 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1756,7 +1756,7 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath, // create a new local generator and set its parent cmLocalGenerator *lg2 = this->GetGlobalGenerator() - ->MakeLocalGenerator(newSnapshot); + ->CreateLocalGenerator(newSnapshot); this->GetGlobalGenerator()->AddMakefile(lg2->GetMakefile()); this->GetGlobalGenerator()->AddLocalGenerator(lg2); diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index c6c045a..9cb005c 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -1218,7 +1218,7 @@ bool cmQtAutoGenerators::Run(const std::string& targetDirectory, cmGlobalGenerator gg(&cm); cmState::Snapshot snapshot = cm.GetCurrentSnapshot(); - cmLocalGenerator* lg = gg.MakeLocalGenerator(snapshot); + cmLocalGenerator* lg = gg.CreateLocalGenerator(snapshot); lg->GetMakefile()->SetCurrentBinaryDirectory(targetDirectory); lg->GetMakefile()->SetCurrentSourceDirectory(targetDirectory); gg.SetCurrentMakefile(lg->GetMakefile()); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 29271b8..ebc38d8 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -430,7 +430,7 @@ void cmake::ReadListFile(const std::vector& args, this->SetHomeDirectory(cmSystemTools::GetCurrentWorkingDirectory()); this->SetHomeOutputDirectory(cmSystemTools::GetCurrentWorkingDirectory()); cmState::Snapshot snapshot = this->GetCurrentSnapshot(); - cmsys::auto_ptr lg(gg->MakeLocalGenerator(snapshot)); + cmsys::auto_ptr lg(gg->CreateLocalGenerator(snapshot)); lg->GetMakefile()->SetCurrentBinaryDirectory (cmSystemTools::GetCurrentWorkingDirectory()); lg->GetMakefile()->SetCurrentSourceDirectory @@ -472,7 +472,7 @@ bool cmake::FindPackage(const std::vector& args) cmState::Snapshot snapshot = this->GetCurrentSnapshot(); // read in the list file to fill the cache - cmsys::auto_ptr lg(gg->MakeLocalGenerator(snapshot)); + cmsys::auto_ptr lg(gg->CreateLocalGenerator(snapshot)); cmMakefile* mf = lg->GetMakefile(); mf->SetCurrentBinaryDirectory (cmSystemTools::GetCurrentWorkingDirectory()); @@ -2062,7 +2062,7 @@ int cmake::CheckBuildSystem() cm.SetHomeOutputDirectory(""); cmGlobalGenerator gg(&cm); cmsys::auto_ptr lg( - gg.MakeLocalGenerator(cm.GetCurrentSnapshot())); + gg.CreateLocalGenerator(cm.GetCurrentSnapshot())); cmMakefile* mf = lg->GetMakefile(); if(!mf->ReadListFile(this->CheckBuildSystemArgument.c_str()) || cmSystemTools::GetErrorOccuredFlag()) @@ -2093,7 +2093,7 @@ int cmake::CheckBuildSystem() if(ggd.get()) { cmsys::auto_ptr lgd( - ggd->MakeLocalGenerator(cm.GetCurrentSnapshot())); + ggd->CreateLocalGenerator(cm.GetCurrentSnapshot())); lgd->ClearDependencies(mf, verbose); } } diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 868dbe3..c788474 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -770,7 +770,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector& args) cm.SetGlobalGenerator(ggd); cmState::Snapshot snapshot = cm.GetCurrentSnapshot(); cmsys::auto_ptr lgd( - ggd->MakeLocalGenerator(snapshot)); + ggd->CreateLocalGenerator(snapshot)); lgd->GetMakefile()->SetCurrentSourceDirectory(startDir); lgd->GetMakefile()->SetCurrentBinaryDirectory(startOutDir); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=acb006229dbc531303538f4de1dc4d16d27369a5 commit acb006229dbc531303538f4de1dc4d16d27369a5 Author: Stephen Kelly AuthorDate: Sun May 31 01:43:31 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 28 18:44:38 2015 +0200 cmGlobalGenerator: Require a snapshot to create a local generator. diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index bf4df60..68509a5 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -716,7 +716,8 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( cm.AddCMakePaths(); cm.SetProgressCallback(cmCPackGeneratorProgress, this); cmGlobalGenerator gg(&cm); - cmsys::auto_ptr lg(gg.MakeLocalGenerator()); + cmsys::auto_ptr lg( + gg.MakeLocalGenerator(cm.GetCurrentSnapshot())); cmMakefile *mf = lg->GetMakefile(); std::string realInstallDirectory = tempInstallDirectory; if ( !installSubDirectory.empty() && installSubDirectory != "/" ) diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index c2fe763..0c53d1b 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -202,7 +202,8 @@ int main (int argc, char const* const* argv) cminst.SetHomeOutputDirectory(""); cminst.GetState()->RemoveUnscriptableCommands(); cmGlobalGenerator cmgg(&cminst); - cmsys::auto_ptr cmlg(cmgg.MakeLocalGenerator()); + cmsys::auto_ptr cmlg( + cmgg.MakeLocalGenerator(cminst.GetCurrentSnapshot())); cmMakefile* globalMF = cmlg->GetMakefile(); #if defined(__CYGWIN__) globalMF->AddDefinition("CMAKE_LEGACY_CYGWIN_WIN32", "0"); diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx index 0f588c5..d978568 100644 --- a/Source/CTest/cmCTestLaunch.cxx +++ b/Source/CTest/cmCTestLaunch.cxx @@ -738,7 +738,8 @@ void cmCTestLaunch::LoadConfig() cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); cmGlobalGenerator gg(&cm); - cmsys::auto_ptr lg(gg.MakeLocalGenerator()); + cmsys::auto_ptr lg( + gg.MakeLocalGenerator(cm.GetCurrentSnapshot())); cmMakefile* mf = lg->GetMakefile(); std::string fname = this->LogDir; fname += "CTestLaunchConfig.cmake"; diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 047bd98..c791302 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -341,7 +341,8 @@ void cmCTestScriptHandler::CreateCMake() this->CMake->AddCMakePaths(); this->GlobalGenerator = new cmGlobalGenerator(this->CMake); - this->LocalGenerator = this->GlobalGenerator->MakeLocalGenerator(); + cmState::Snapshot snapshot = this->CMake->GetCurrentSnapshot(); + this->LocalGenerator = this->GlobalGenerator->MakeLocalGenerator(snapshot); this->Makefile = this->LocalGenerator->GetMakefile(); this->CMake->SetProgressCallback(ctestScriptProgressCallback, this->CTest); diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index c8a0d27..3262efd 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -1592,7 +1592,8 @@ void cmCTestTestHandler::GetListOfTests() cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); cmGlobalGenerator gg(&cm); - cmsys::auto_ptr lg(gg.MakeLocalGenerator()); + cmsys::auto_ptr lg( + gg.MakeLocalGenerator(cm.GetCurrentSnapshot())); cmMakefile *mf = lg->GetMakefile(); mf->AddDefinition("CTEST_CONFIGURATION_TYPE", this->CTest->GetConfigType().c_str()); diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index b976469..f020f9e 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -520,7 +520,8 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command) cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); cmGlobalGenerator gg(&cm); - cmsys::auto_ptr lg(gg.MakeLocalGenerator()); + cmsys::auto_ptr lg( + gg.MakeLocalGenerator(cm.GetCurrentSnapshot())); cmMakefile *mf = lg->GetMakefile(); if ( !this->ReadCustomConfigurationFileTree(this->BinaryDir.c_str(), mf) ) { diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 01f50ed..251fa52 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1128,7 +1128,8 @@ void cmGlobalGenerator::Configure() this->ClearGeneratorMembers(); // start with this directory - cmLocalGenerator *lg = this->MakeLocalGenerator(); + cmLocalGenerator *lg = this->MakeLocalGenerator( + this->GetCMakeInstance()->GetCurrentSnapshot()); this->Makefiles.push_back(lg->GetMakefile()); this->LocalGenerators.push_back(lg); @@ -1988,11 +1989,6 @@ void cmGlobalGenerator::EnableInstallTarget() cmLocalGenerator * cmGlobalGenerator::MakeLocalGenerator(cmState::Snapshot snapshot) { - if (!snapshot.IsValid()) - { - snapshot = this->CMakeInstance->GetCurrentSnapshot(); - } - return this->CreateLocalGenerator(snapshot); } diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 0f491aa..c396af4 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -585,8 +585,9 @@ void cmGlobalUnixMakefileGenerator3 } else { + cmState::Snapshot snapshot = this->CMakeInstance->GetCurrentSnapshot(); lg = static_cast - (this->MakeLocalGenerator()); + (this->MakeLocalGenerator(snapshot)); // set the Start directories lg->GetMakefile()->SetCurrentSourceDirectory (this->CMakeInstance->GetHomeDirectory()); diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx index fa29b4f..797b198 100644 --- a/Source/cmGraphVizWriter.cxx +++ b/Source/cmGraphVizWriter.cxx @@ -68,7 +68,8 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName, cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); cmGlobalGenerator ggi(&cm); - cmsys::auto_ptr lg(ggi.MakeLocalGenerator()); + cmsys::auto_ptr lg( + ggi.MakeLocalGenerator(cm.GetCurrentSnapshot())); cmMakefile *mf = lg->GetMakefile(); const char* inFileName = settingsFileName; diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 0a4b546..c6c045a 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -1217,7 +1217,8 @@ bool cmQtAutoGenerators::Run(const std::string& targetDirectory, cm.SetHomeDirectory(targetDirectory); cmGlobalGenerator gg(&cm); - cmLocalGenerator* lg = gg.MakeLocalGenerator(); + cmState::Snapshot snapshot = cm.GetCurrentSnapshot(); + cmLocalGenerator* lg = gg.MakeLocalGenerator(snapshot); lg->GetMakefile()->SetCurrentBinaryDirectory(targetDirectory); lg->GetMakefile()->SetCurrentSourceDirectory(targetDirectory); gg.SetCurrentMakefile(lg->GetMakefile()); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 1f5c4d4..29271b8 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -429,7 +429,8 @@ void cmake::ReadListFile(const std::vector& args, std::string homeOutputDir = this->GetHomeOutputDirectory(); this->SetHomeDirectory(cmSystemTools::GetCurrentWorkingDirectory()); this->SetHomeOutputDirectory(cmSystemTools::GetCurrentWorkingDirectory()); - cmsys::auto_ptr lg(gg->MakeLocalGenerator()); + cmState::Snapshot snapshot = this->GetCurrentSnapshot(); + cmsys::auto_ptr lg(gg->MakeLocalGenerator(snapshot)); lg->GetMakefile()->SetCurrentBinaryDirectory (cmSystemTools::GetCurrentWorkingDirectory()); lg->GetMakefile()->SetCurrentSourceDirectory @@ -469,8 +470,9 @@ bool cmake::FindPackage(const std::vector& args) cmGlobalGenerator *gg = new cmGlobalGenerator(this); this->SetGlobalGenerator(gg); + cmState::Snapshot snapshot = this->GetCurrentSnapshot(); // read in the list file to fill the cache - cmsys::auto_ptr lg(gg->MakeLocalGenerator()); + cmsys::auto_ptr lg(gg->MakeLocalGenerator(snapshot)); cmMakefile* mf = lg->GetMakefile(); mf->SetCurrentBinaryDirectory (cmSystemTools::GetCurrentWorkingDirectory()); @@ -2059,7 +2061,8 @@ int cmake::CheckBuildSystem() cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); cmGlobalGenerator gg(&cm); - cmsys::auto_ptr lg(gg.MakeLocalGenerator()); + cmsys::auto_ptr lg( + gg.MakeLocalGenerator(cm.GetCurrentSnapshot())); cmMakefile* mf = lg->GetMakefile(); if(!mf->ReadListFile(this->CheckBuildSystemArgument.c_str()) || cmSystemTools::GetErrorOccuredFlag()) @@ -2089,7 +2092,8 @@ int cmake::CheckBuildSystem() ggd(this->CreateGlobalGenerator(genName)); if(ggd.get()) { - cmsys::auto_ptr lgd(ggd->MakeLocalGenerator()); + cmsys::auto_ptr lgd( + ggd->MakeLocalGenerator(cm.GetCurrentSnapshot())); lgd->ClearDependencies(mf, verbose); } } diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 7bee0ea..868dbe3 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -768,7 +768,9 @@ int cmcmd::ExecuteCMakeCommand(std::vector& args) if(cmGlobalGenerator* ggd = cm.CreateGlobalGenerator(gen)) { cm.SetGlobalGenerator(ggd); - cmsys::auto_ptr lgd(ggd->MakeLocalGenerator()); + cmState::Snapshot snapshot = cm.GetCurrentSnapshot(); + cmsys::auto_ptr lgd( + ggd->MakeLocalGenerator(snapshot)); lgd->GetMakefile()->SetCurrentSourceDirectory(startDir); lgd->GetMakefile()->SetCurrentBinaryDirectory(startOutDir); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=83b8a927e5a992480e96b0be36ea0426a924c41f commit 83b8a927e5a992480e96b0be36ea0426a924c41f Author: Stephen Kelly AuthorDate: Sun Aug 2 11:20:28 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 28 18:44:38 2015 +0200 cmMakefile: Remove cmLocalGenerator member. diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index aea14d5..357a508 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -49,7 +49,7 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg, assert(snapshot.IsValid()); this->GlobalGenerator = gg; - this->Makefile = new cmMakefile(this); + this->Makefile = new cmMakefile(gg, snapshot); this->EmitUniversalBinaryFlags = true; this->BackwardsCompatibility = 0; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 2ba12a4..10ce0b3 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -44,9 +44,10 @@ #include // default is not to be building executables -cmMakefile::cmMakefile(cmLocalGenerator* localGenerator) - : LocalGenerator(localGenerator), - StateSnapshot(localGenerator->GetStateSnapshot()) +cmMakefile::cmMakefile(cmGlobalGenerator* globalGenerator, + cmState::Snapshot const& snapshot) + : GlobalGenerator(globalGenerator), + StateSnapshot(snapshot) { this->IsSourceFileTryCompile = false; @@ -3744,12 +3745,12 @@ bool cmMakefile::GetIsSourceFileTryCompile() const cmake *cmMakefile::GetCMakeInstance() const { - return this->GetGlobalGenerator()->GetCMakeInstance(); + return this->GlobalGenerator->GetCMakeInstance(); } cmGlobalGenerator* cmMakefile::GetGlobalGenerator() const { - return this->LocalGenerator->GetGlobalGenerator(); + return this->GlobalGenerator; } #ifdef CMAKE_BUILD_WITH_CMAKE diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index f3839aa..3cf20a6 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -42,7 +42,6 @@ class cmFunctionBlocker; class cmCommand; class cmInstallGenerator; -class cmLocalGenerator; class cmMakeDepend; class cmSourceFile; class cmTest; @@ -71,7 +70,8 @@ public: /** * Construct an empty makefile. */ - cmMakefile(cmLocalGenerator* localGenerator); + cmMakefile(cmGlobalGenerator* globalGenerator, + const cmState::Snapshot& snapshot); /** * Destructor. @@ -856,7 +856,7 @@ protected: #endif std::vector FinalPassCommands; - cmLocalGenerator* LocalGenerator; + cmGlobalGenerator* GlobalGenerator; bool IsFunctionBlocked(const cmListFileFunction& lff, cmExecutionStatus &status); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9b6a743b801dffa9f7ccab0c3e73fa8d22f3b8b9 commit 9b6a743b801dffa9f7ccab0c3e73fa8d22f3b8b9 Author: Stephen Kelly AuthorDate: Sun Aug 2 11:08:49 2015 +0200 Commit: Stephen Kelly CommitDate: Fri Aug 28 18:44:38 2015 +0200 cmLocalGenerator: Remove Parent pointer. diff --git a/Source/cmGlobalBorlandMakefileGenerator.cxx b/Source/cmGlobalBorlandMakefileGenerator.cxx index 87665a0..c31f952 100644 --- a/Source/cmGlobalBorlandMakefileGenerator.cxx +++ b/Source/cmGlobalBorlandMakefileGenerator.cxx @@ -44,10 +44,10 @@ void cmGlobalBorlandMakefileGenerator ///! Create a local generator appropriate to this Global Generator cmLocalGenerator *cmGlobalBorlandMakefileGenerator::CreateLocalGenerator( - cmLocalGenerator* parent, cmState::Snapshot snapshot) + cmState::Snapshot snapshot) { cmLocalUnixMakefileGenerator3* lg = - new cmLocalUnixMakefileGenerator3(this, parent, snapshot); + new cmLocalUnixMakefileGenerator3(this, snapshot); lg->SetMakefileVariableSize(32); lg->SetMakeCommandEscapeTargetTwice(true); lg->SetBorlandMakeCurlyHack(true); diff --git a/Source/cmGlobalBorlandMakefileGenerator.h b/Source/cmGlobalBorlandMakefileGenerator.h index 2ec510d..62e458f 100644 --- a/Source/cmGlobalBorlandMakefileGenerator.h +++ b/Source/cmGlobalBorlandMakefileGenerator.h @@ -36,8 +36,7 @@ public: static void GetDocumentation(cmDocumentationEntry& entry); ///! Create a local generator appropriate to this Global Generator - virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent, - cmState::Snapshot snapshot); + virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); /** * Try to determine system information such as shared library diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 46c1ccc..01f50ed 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1986,22 +1986,20 @@ void cmGlobalGenerator::EnableInstallTarget() } cmLocalGenerator * -cmGlobalGenerator::MakeLocalGenerator(cmState::Snapshot snapshot, - cmLocalGenerator *parent) +cmGlobalGenerator::MakeLocalGenerator(cmState::Snapshot snapshot) { if (!snapshot.IsValid()) { snapshot = this->CMakeInstance->GetCurrentSnapshot(); } - return this->CreateLocalGenerator(parent, snapshot); + return this->CreateLocalGenerator(snapshot); } cmLocalGenerator* -cmGlobalGenerator::CreateLocalGenerator(cmLocalGenerator* parent, - cmState::Snapshot snapshot) +cmGlobalGenerator::CreateLocalGenerator(cmState::Snapshot snapshot) { - return new cmLocalGenerator(this, parent, snapshot); + return new cmLocalGenerator(this, snapshot); } void cmGlobalGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator *gen, diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 21cbd44..2e0f7b5 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -56,9 +56,8 @@ public: cmGlobalGenerator(cmake* cm); virtual ~cmGlobalGenerator(); - cmLocalGenerator* MakeLocalGenerator( - cmState::Snapshot snapshot = cmState::Snapshot(), - cmLocalGenerator* parent = 0); + cmLocalGenerator* + MakeLocalGenerator(cmState::Snapshot snapshot = cmState::Snapshot()); ///! Get the name for this generator virtual std::string GetName() const { return "Generic"; } @@ -442,8 +441,7 @@ protected: private: ///! Create a local generator appropriate to this Global Generator - virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent, - cmState::Snapshot snapshot); + virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); cmMakefile* TryCompileOuterMakefile; // If you add a new map here, make sure it is copied diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx index f764418..29abb37 100644 --- a/Source/cmGlobalGhsMultiGenerator.cxx +++ b/Source/cmGlobalGhsMultiGenerator.cxx @@ -33,10 +33,9 @@ cmGlobalGhsMultiGenerator::~cmGlobalGhsMultiGenerator() } cmLocalGenerator * -cmGlobalGhsMultiGenerator::CreateLocalGenerator(cmLocalGenerator* parent, - cmState::Snapshot snapshot) +cmGlobalGhsMultiGenerator::CreateLocalGenerator(cmState::Snapshot snapshot) { - return new cmLocalGhsMultiGenerator(this, parent, snapshot); + return new cmLocalGhsMultiGenerator(this, snapshot); } void cmGlobalGhsMultiGenerator::GetDocumentation(cmDocumentationEntry &entry) diff --git a/Source/cmGlobalGhsMultiGenerator.h b/Source/cmGlobalGhsMultiGenerator.h index f1a3ed7..873c20f 100644 --- a/Source/cmGlobalGhsMultiGenerator.h +++ b/Source/cmGlobalGhsMultiGenerator.h @@ -31,8 +31,7 @@ public: { return new cmGlobalGeneratorSimpleFactory(); } ///! create the correct local generator - virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent, - cmState::Snapshot snapshot); + virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); /// @return the name of this generator. static std::string GetActualName() { return "Green Hills MULTI"; } diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index b92ad32..72ef4d6 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -528,10 +528,9 @@ cmGlobalNinjaGenerator::cmGlobalNinjaGenerator(cmake* cm) // Virtual public methods. cmLocalGenerator* -cmGlobalNinjaGenerator::CreateLocalGenerator(cmLocalGenerator* parent, - cmState::Snapshot snapshot) +cmGlobalNinjaGenerator::CreateLocalGenerator(cmState::Snapshot snapshot) { - return new cmLocalNinjaGenerator(this, parent, snapshot); + return new cmLocalNinjaGenerator(this, snapshot); } void cmGlobalNinjaGenerator diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index f103801..418d6f7 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -170,8 +170,7 @@ public: virtual ~cmGlobalNinjaGenerator() { } /// Overloaded methods. @see cmGlobalGenerator::CreateLocalGenerator() - virtual cmLocalGenerator* CreateLocalGenerator(cmLocalGenerator* parent, - cmState::Snapshot snapshot); + virtual cmLocalGenerator* CreateLocalGenerator(cmState::Snapshot snapshot); /// Overloaded methods. @see cmGlobalGenerator::GetName(). virtual std::string GetName() const { diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 605ece2..0f491aa 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -59,11 +59,10 @@ void cmGlobalUnixMakefileGenerator3 } ///! Create a local generator appropriate to this Global Generator -cmLocalGenerator * -cmGlobalUnixMakefileGenerator3::CreateLocalGenerator(cmLocalGenerator* parent, - cmState::Snapshot snapshot) +cmLocalGenerator* cmGlobalUnixMakefileGenerator3::CreateLocalGenerator( + cmState::Snapshot snapshot) { - return new cmLocalUnixMakefileGenerator3(this, parent, snapshot); + return new cmLocalUnixMakefileGenerator3(this, snapshot); } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index c738c16..3ea6bb2 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -68,8 +68,7 @@ public: static void GetDocumentation(cmDocumentationEntry& entry); ///! Create a local generator appropriate to this Global Generator3 - virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent, - cmState::Snapshot snapshot); + virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); /** * Try to determine system information such as shared library diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 8ec4fd9..a36fed1 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -306,11 +306,10 @@ void cmGlobalVisualStudio10Generator::WriteSLNHeader(std::ostream& fout) } ///! Create a local generator appropriate to this Global Generator -cmLocalGenerator * -cmGlobalVisualStudio10Generator::CreateLocalGenerator(cmLocalGenerator* parent, - cmState::Snapshot snapshot) +cmLocalGenerator* cmGlobalVisualStudio10Generator::CreateLocalGenerator( + cmState::Snapshot snapshot) { - return new cmLocalVisualStudio10Generator(this, parent, snapshot); + return new cmLocalVisualStudio10Generator(this, snapshot); } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 3d34a3f..bbc22b9 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -48,8 +48,7 @@ public: virtual bool Compute(); ///! create the correct local generator - virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent, - cmState::Snapshot snapshot); + virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); /** * Try to determine system information such as shared library diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx index b7c897c..48c3d32 100644 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ b/Source/cmGlobalVisualStudio6Generator.cxx @@ -173,10 +173,10 @@ cmGlobalVisualStudio6Generator::GenerateBuildCommand( ///! Create a local generator appropriate to this Global Generator cmLocalGenerator * -cmGlobalVisualStudio6Generator::CreateLocalGenerator(cmLocalGenerator* parent, +cmGlobalVisualStudio6Generator::CreateLocalGenerator( cmState::Snapshot snapshot) { - return new cmLocalVisualStudio6Generator(this, parent, snapshot); + return new cmLocalVisualStudio6Generator(this, snapshot); } diff --git a/Source/cmGlobalVisualStudio6Generator.h b/Source/cmGlobalVisualStudio6Generator.h index 420cb0b..0169be0 100644 --- a/Source/cmGlobalVisualStudio6Generator.h +++ b/Source/cmGlobalVisualStudio6Generator.h @@ -39,8 +39,7 @@ public: static void GetDocumentation(cmDocumentationEntry& entry); ///! Create a local generator appropriate to this Global Generator - virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent, - cmState::Snapshot snapshot); + virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); /** * Try to determine system information such as shared library diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 2660d23..b8f6357 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -279,12 +279,11 @@ void cmGlobalVisualStudio7Generator::GenerateBuildCommand( } ///! Create a local generator appropriate to this Global Generator -cmLocalGenerator * -cmGlobalVisualStudio7Generator::CreateLocalGenerator(cmLocalGenerator* parent, - cmState::Snapshot snapshot) +cmLocalGenerator *cmGlobalVisualStudio7Generator::CreateLocalGenerator( + cmState::Snapshot snapshot) { cmLocalVisualStudio7Generator *lg = - new cmLocalVisualStudio7Generator(this, parent, snapshot); + new cmLocalVisualStudio7Generator(this, snapshot); return lg; } diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 931ac9c..5ada2c5 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -43,8 +43,7 @@ public: std::string const& GetPlatformName() const; ///! Create a local generator appropriate to this Global Generator - virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent, - cmState::Snapshot snapshot); + virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); virtual bool SetSystemName(std::string const& s, cmMakefile* mf); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index eb547bd..af3629d 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -371,10 +371,9 @@ cmGlobalXCodeGenerator::GenerateBuildCommand( //---------------------------------------------------------------------------- ///! Create a local generator appropriate to this Global Generator cmLocalGenerator * -cmGlobalXCodeGenerator::CreateLocalGenerator(cmLocalGenerator* parent, - cmState::Snapshot snapshot) +cmGlobalXCodeGenerator::CreateLocalGenerator(cmState::Snapshot snapshot) { - return new cmLocalXCodeGenerator(this, parent, snapshot); + return new cmLocalXCodeGenerator(this, snapshot); } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index ee8bf2c..f93f62f 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -41,8 +41,7 @@ public: static void GetDocumentation(cmDocumentationEntry& entry); ///! Create a local generator appropriate to this Global Generator - virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent, - cmState::Snapshot snapshot); + virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); /** * Try to determine system information such as shared library diff --git a/Source/cmLocalCommonGenerator.cxx b/Source/cmLocalCommonGenerator.cxx index 4583446..58c707c 100644 --- a/Source/cmLocalCommonGenerator.cxx +++ b/Source/cmLocalCommonGenerator.cxx @@ -14,9 +14,8 @@ #include "cmMakefile.h" cmLocalCommonGenerator::cmLocalCommonGenerator(cmGlobalGenerator* gg, - cmLocalGenerator* parent, cmState::Snapshot snapshot): - cmLocalGenerator(gg, parent, snapshot) + cmLocalGenerator(gg, snapshot) { } diff --git a/Source/cmLocalCommonGenerator.h b/Source/cmLocalCommonGenerator.h index af94cda..b7caf0b 100644 --- a/Source/cmLocalCommonGenerator.h +++ b/Source/cmLocalCommonGenerator.h @@ -23,7 +23,6 @@ class cmLocalCommonGenerator: public cmLocalGenerator { public: cmLocalCommonGenerator(cmGlobalGenerator* gg, - cmLocalGenerator* parent, cmState::Snapshot snapshot); ~cmLocalCommonGenerator(); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 7ce4819..aea14d5 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -43,13 +43,11 @@ #endif cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg, - cmLocalGenerator* parent, cmState::Snapshot snapshot) : cmOutputConverter(snapshot), StateSnapshot(snapshot) { assert(snapshot.IsValid()); this->GlobalGenerator = gg; - this->Parent = parent; this->Makefile = new cmMakefile(this); diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 915814b..4c0b1fe 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -36,8 +36,7 @@ class cmCustomCommandGenerator; class cmLocalGenerator : public cmOutputConverter { public: - cmLocalGenerator(cmGlobalGenerator* gg, cmLocalGenerator* parent, - cmState::Snapshot snapshot); + cmLocalGenerator(cmGlobalGenerator* gg, cmState::Snapshot snapshot); virtual ~cmLocalGenerator(); /** @@ -86,9 +85,6 @@ public: cmState* GetState() const; cmState::Snapshot GetStateSnapshot() const; - ///! set/get the parent generator - cmLocalGenerator* GetParent() const {return this->Parent;} - void AddArchitectureFlags(std::string& flags, cmGeneratorTarget const* target, const std::string&lang, const std::string& config); @@ -343,7 +339,6 @@ protected: cmMakefile *Makefile; cmState::Snapshot StateSnapshot; cmGlobalGenerator *GlobalGenerator; - cmLocalGenerator* Parent; std::map UniqueObjectNamesMap; std::string::size_type ObjectPathMax; std::set ObjectMaxPathViolations; diff --git a/Source/cmLocalGhsMultiGenerator.cxx b/Source/cmLocalGhsMultiGenerator.cxx index 8e498dd..91dfeb4 100644 --- a/Source/cmLocalGhsMultiGenerator.cxx +++ b/Source/cmLocalGhsMultiGenerator.cxx @@ -17,9 +17,8 @@ #include "cmGeneratedFileStream.h" cmLocalGhsMultiGenerator::cmLocalGhsMultiGenerator(cmGlobalGenerator* gg, - cmLocalGenerator* parent, cmState::Snapshot snapshot) - : cmLocalGenerator(gg, parent, snapshot) + : cmLocalGenerator(gg, snapshot) { } diff --git a/Source/cmLocalGhsMultiGenerator.h b/Source/cmLocalGhsMultiGenerator.h index f52ef39..3309bfd 100644 --- a/Source/cmLocalGhsMultiGenerator.h +++ b/Source/cmLocalGhsMultiGenerator.h @@ -25,7 +25,7 @@ class cmGeneratedFileStream; class cmLocalGhsMultiGenerator : public cmLocalGenerator { public: - cmLocalGhsMultiGenerator(cmGlobalGenerator* gg, cmLocalGenerator* parent, + cmLocalGhsMultiGenerator(cmGlobalGenerator* gg, cmState::Snapshot snapshot); virtual ~cmLocalGhsMultiGenerator(); diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index cfca418..62bf8b2 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -23,9 +23,8 @@ #include cmLocalNinjaGenerator::cmLocalNinjaGenerator(cmGlobalGenerator* gg, - cmLocalGenerator* parent, cmState::Snapshot snapshot) - : cmLocalCommonGenerator(gg, parent, snapshot) + : cmLocalCommonGenerator(gg, snapshot) , HomeRelativeOutputPath("") { this->TargetImplib = "$TARGET_IMPLIB"; diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index d10be0c..4c158bc 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -31,7 +31,7 @@ class cmake; class cmLocalNinjaGenerator : public cmLocalCommonGenerator { public: - cmLocalNinjaGenerator(cmGlobalGenerator* gg, cmLocalGenerator* parent, + cmLocalNinjaGenerator(cmGlobalGenerator* gg, cmState::Snapshot snapshot); virtual ~cmLocalNinjaGenerator(); diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 589105e..d2b60d3 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -80,9 +80,9 @@ static std::string cmSplitExtension(std::string const& in, std::string& base) //---------------------------------------------------------------------------- cmLocalUnixMakefileGenerator3:: -cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg, cmLocalGenerator* parent, +cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg, cmState::Snapshot snapshot) - : cmLocalCommonGenerator(gg, parent, snapshot) + : cmLocalCommonGenerator(gg, snapshot) { this->MakefileVariableSize = 0; this->ColorMakefile = false; diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index 01ac01b..2b9af38 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -35,7 +35,6 @@ class cmLocalUnixMakefileGenerator3 : public cmLocalCommonGenerator { public: cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg, - cmLocalGenerator* parent, cmState::Snapshot snapshot); virtual ~cmLocalUnixMakefileGenerator3(); diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx index 9e3185c..25b3f19 100644 --- a/Source/cmLocalVisualStudio10Generator.cxx +++ b/Source/cmLocalVisualStudio10Generator.cxx @@ -63,9 +63,8 @@ class cmVS10XMLParser : public cmXMLParser //---------------------------------------------------------------------------- cmLocalVisualStudio10Generator ::cmLocalVisualStudio10Generator(cmGlobalGenerator* gg, - cmLocalGenerator* parent, cmState::Snapshot snapshot): - cmLocalVisualStudio7Generator(gg, parent, snapshot) + cmLocalVisualStudio7Generator(gg, snapshot) { } diff --git a/Source/cmLocalVisualStudio10Generator.h b/Source/cmLocalVisualStudio10Generator.h index c588aaf..0f179fd 100644 --- a/Source/cmLocalVisualStudio10Generator.h +++ b/Source/cmLocalVisualStudio10Generator.h @@ -26,7 +26,6 @@ class cmLocalVisualStudio10Generator : public cmLocalVisualStudio7Generator public: ///! Set cache only and recurse to false by default. cmLocalVisualStudio10Generator(cmGlobalGenerator* gg, - cmLocalGenerator* parent, cmState::Snapshot snapshot); virtual ~cmLocalVisualStudio10Generator(); diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 3a44367..46e1987 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -25,9 +25,8 @@ cmLocalVisualStudio6Generator ::cmLocalVisualStudio6Generator(cmGlobalGenerator* gg, - cmLocalGenerator* parent, cmState::Snapshot snapshot): - cmLocalVisualStudioGenerator(gg, parent, snapshot) + cmLocalVisualStudioGenerator(gg, snapshot) { } diff --git a/Source/cmLocalVisualStudio6Generator.h b/Source/cmLocalVisualStudio6Generator.h index a44e61d..86b4906 100644 --- a/Source/cmLocalVisualStudio6Generator.h +++ b/Source/cmLocalVisualStudio6Generator.h @@ -30,7 +30,6 @@ class cmLocalVisualStudio6Generator : public cmLocalVisualStudioGenerator public: ///! Set cache only and recurse to false by default. cmLocalVisualStudio6Generator(cmGlobalGenerator* gg, - cmLocalGenerator* parent, cmState::Snapshot snapshot); virtual ~cmLocalVisualStudio6Generator(); diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 55ad852..eebed7e 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -54,9 +54,8 @@ static void cmConvertToWindowsSlash(std::string& s) //---------------------------------------------------------------------------- cmLocalVisualStudio7Generator ::cmLocalVisualStudio7Generator(cmGlobalGenerator* gg, - cmLocalGenerator* parent, cmState::Snapshot snapshot): - cmLocalVisualStudioGenerator(gg, parent, snapshot) + cmLocalVisualStudioGenerator(gg, snapshot) { this->Internal = new cmLocalVisualStudio7GeneratorInternals(this); } diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h index 43f3af9..42ae097 100644 --- a/Source/cmLocalVisualStudio7Generator.h +++ b/Source/cmLocalVisualStudio7Generator.h @@ -36,7 +36,6 @@ class cmLocalVisualStudio7Generator : public cmLocalVisualStudioGenerator public: ///! Set cache only and recurse to false by default. cmLocalVisualStudio7Generator(cmGlobalGenerator* gg, - cmLocalGenerator* parent, cmState::Snapshot snapshot); virtual ~cmLocalVisualStudio7Generator(); diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index 3588853..70f729f 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/Source/cmLocalVisualStudioGenerator.cxx @@ -20,9 +20,8 @@ //---------------------------------------------------------------------------- cmLocalVisualStudioGenerator ::cmLocalVisualStudioGenerator(cmGlobalGenerator* gg, - cmLocalGenerator* parent, cmState::Snapshot snapshot) - : cmLocalGenerator(gg, parent, snapshot) + : cmLocalGenerator(gg, snapshot) { } diff --git a/Source/cmLocalVisualStudioGenerator.h b/Source/cmLocalVisualStudioGenerator.h index d414651..32244c7 100644 --- a/Source/cmLocalVisualStudioGenerator.h +++ b/Source/cmLocalVisualStudioGenerator.h @@ -32,7 +32,6 @@ class cmLocalVisualStudioGenerator : public cmLocalGenerator { public: cmLocalVisualStudioGenerator(cmGlobalGenerator* gg, - cmLocalGenerator* parent, cmState::Snapshot snapshot); virtual ~cmLocalVisualStudioGenerator(); diff --git a/Source/cmLocalXCodeGenerator.cxx b/Source/cmLocalXCodeGenerator.cxx index 804dd7d..d6576f6 100644 --- a/Source/cmLocalXCodeGenerator.cxx +++ b/Source/cmLocalXCodeGenerator.cxx @@ -16,9 +16,8 @@ //---------------------------------------------------------------------------- cmLocalXCodeGenerator::cmLocalXCodeGenerator(cmGlobalGenerator* gg, - cmLocalGenerator* parent, cmState::Snapshot snapshot) - : cmLocalGenerator(gg, parent, snapshot) + : cmLocalGenerator(gg, snapshot) { // the global generator does this, so do not // put these flags into the language flags diff --git a/Source/cmLocalXCodeGenerator.h b/Source/cmLocalXCodeGenerator.h index 26fff9c..d96e78c 100644 --- a/Source/cmLocalXCodeGenerator.h +++ b/Source/cmLocalXCodeGenerator.h @@ -24,7 +24,7 @@ class cmLocalXCodeGenerator : public cmLocalGenerator { public: ///! Set cache only and recurse to false by default. - cmLocalXCodeGenerator(cmGlobalGenerator* gg, cmLocalGenerator* parent, + cmLocalXCodeGenerator(cmGlobalGenerator* gg, cmState::Snapshot snapshot); virtual ~cmLocalXCodeGenerator(); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 4a4663a..2ba12a4 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1755,7 +1755,7 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath, // create a new local generator and set its parent cmLocalGenerator *lg2 = this->GetGlobalGenerator() - ->MakeLocalGenerator(newSnapshot, this->LocalGenerator); + ->MakeLocalGenerator(newSnapshot); this->GetGlobalGenerator()->AddMakefile(lg2->GetMakefile()); this->GetGlobalGenerator()->AddLocalGenerator(lg2); ----------------------------------------------------------------------- Summary of changes: Source/CPack/cmCPackGenerator.cxx | 6 +- Source/CPack/cpack.cxx | 10 ++-- Source/CTest/cmCTestLaunch.cxx | 5 +- Source/CTest/cmCTestScriptHandler.cxx | 46 ++++++--------- Source/CTest/cmCTestTestHandler.cxx | 5 +- Source/cmCTest.cxx | 7 ++- Source/cmGlobalBorlandMakefileGenerator.cxx | 4 +- Source/cmGlobalBorlandMakefileGenerator.h | 3 +- Source/cmGlobalGenerator.cxx | 80 +++++++++++---------------- Source/cmGlobalGenerator.h | 11 +--- Source/cmGlobalGhsMultiGenerator.cxx | 5 +- Source/cmGlobalGhsMultiGenerator.h | 3 +- Source/cmGlobalNinjaGenerator.cxx | 5 +- Source/cmGlobalNinjaGenerator.h | 14 +---- Source/cmGlobalUnixMakefileGenerator3.cxx | 14 +++-- Source/cmGlobalUnixMakefileGenerator3.h | 4 +- Source/cmGlobalVisualStudio10Generator.cxx | 7 +-- Source/cmGlobalVisualStudio10Generator.h | 3 +- Source/cmGlobalVisualStudio6Generator.cxx | 5 +- Source/cmGlobalVisualStudio6Generator.h | 3 +- Source/cmGlobalVisualStudio7Generator.cxx | 7 +-- Source/cmGlobalVisualStudio7Generator.h | 3 +- Source/cmGlobalXCodeGenerator.cxx | 5 +- Source/cmGlobalXCodeGenerator.h | 3 +- Source/cmGraphVizWriter.cxx | 5 +- Source/cmLocalCommonGenerator.cxx | 5 +- Source/cmLocalCommonGenerator.h | 4 +- Source/cmLocalGenerator.cxx | 11 ++-- Source/cmLocalGenerator.h | 7 +-- Source/cmLocalGhsMultiGenerator.cxx | 5 +- Source/cmLocalGhsMultiGenerator.h | 3 +- Source/cmLocalNinjaGenerator.cxx | 5 +- Source/cmLocalNinjaGenerator.h | 3 +- Source/cmLocalUnixMakefileGenerator3.cxx | 5 +- Source/cmLocalUnixMakefileGenerator3.h | 4 +- Source/cmLocalVisualStudio10Generator.cxx | 6 +- Source/cmLocalVisualStudio10Generator.h | 4 +- Source/cmLocalVisualStudio6Generator.cxx | 6 +- Source/cmLocalVisualStudio6Generator.h | 4 +- Source/cmLocalVisualStudio7Generator.cxx | 6 +- Source/cmLocalVisualStudio7Generator.h | 4 +- Source/cmLocalVisualStudioGenerator.cxx | 6 +- Source/cmLocalVisualStudioGenerator.h | 4 +- Source/cmLocalXCodeGenerator.cxx | 5 +- Source/cmLocalXCodeGenerator.h | 4 +- Source/cmMakefile.cxx | 23 ++++---- Source/cmMakefile.h | 6 +- Source/cmQtAutoGenerators.cxx | 5 +- Source/cmake.cxx | 20 ++++--- Source/cmcmd.cxx | 5 +- 50 files changed, 176 insertions(+), 247 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Fri Aug 28 15:15:17 2015 From: brad.king at kitware.com (Brad King) Date: Fri, 28 Aug 2015 15:15:17 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2613-g9bbf909 Message-ID: <20150828191517.21D7FB25A5@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 9bbf90981849096ccabb54f8832756ba7f290a16 (commit) via d315f2bee2e1801032cc56e8e4f344725b29548e (commit) from 967ddfb3100032f45a846c58f36073bb0e82926d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9bbf90981849096ccabb54f8832756ba7f290a16 commit 9bbf90981849096ccabb54f8832756ba7f290a16 Merge: 967ddfb d315f2b Author: Brad King AuthorDate: Fri Aug 28 15:15:16 2015 -0400 Commit: CMake Topic Stage CommitDate: Fri Aug 28 15:15:16 2015 -0400 Merge topic 'makefile-color-when-needed' into next d315f2be Makefile: Print color escapes only when necessary http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d315f2bee2e1801032cc56e8e4f344725b29548e commit d315f2bee2e1801032cc56e8e4f344725b29548e Author: Brad King AuthorDate: Thu Aug 27 16:41:34 2015 -0400 Commit: Brad King CommitDate: Fri Aug 28 15:13:57 2015 -0400 Makefile: Print color escapes only when necessary Teach cmSystemTools::MakefileColorEcho to use the color printing API only when we actually have a color to print. This avoids printing escape sequences that do not change the text attributes. Since commit v3.3.0-rc1~480^2~4 (Makefile: Fix output during parallel builds, 2015-02-05) we always use this code path to print progress and rule messages even when color is disabled (e.g. in a try_compile). It is important to avoid printing escapes when there is no color because on MSYS we have no isatty and so assume that vt100 escapes are supported, but we do not want to print them when capturing try_compile output. If we capture the vt100 escapes in try_compile output, they contain unbalanced square brackets. This causes CMakeParseImplicitLinkInfo to fail to separate lines and extract infromation from the link line. diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index e2adabe..b440a17 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -2331,7 +2331,7 @@ void cmSystemTools::MakefileColorEcho(int color, const char* message, assumeTTY = 0; } - if(enabled) + if(enabled && color != cmsysTerminal_Color_Normal) { // Print with color. Delay the newline until later so that // all color restore sequences appear before it. ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From brad.king at kitware.com Fri Aug 28 15:17:07 2015 From: brad.king at kitware.com (Brad King) Date: Fri, 28 Aug 2015 15:17:07 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2615-g0ef3eae Message-ID: <20150828191707.D6EC1B247A@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 0ef3eae3a17803fcf0a4de7bf87f217da134663d (commit) via bfb9d34f8afe66c2ce344b36db48568fc88950c9 (commit) from 9bbf90981849096ccabb54f8832756ba7f290a16 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0ef3eae3a17803fcf0a4de7bf87f217da134663d commit 0ef3eae3a17803fcf0a4de7bf87f217da134663d Merge: 9bbf909 bfb9d34 Author: Brad King AuthorDate: Fri Aug 28 15:17:07 2015 -0400 Commit: CMake Topic Stage CommitDate: Fri Aug 28 15:17:07 2015 -0400 Merge topic 'makefile-color-when-needed' into next bfb9d34f Makefile: Print color escapes only when necessary http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bfb9d34f8afe66c2ce344b36db48568fc88950c9 commit bfb9d34f8afe66c2ce344b36db48568fc88950c9 Author: Brad King AuthorDate: Thu Aug 27 16:41:34 2015 -0400 Commit: Brad King CommitDate: Fri Aug 28 15:16:05 2015 -0400 Makefile: Print color escapes only when necessary Teach cmSystemTools::MakefileColorEcho to use the color printing API only when we actually have a color to print. This avoids printing escape sequences that do not change the text attributes. Since commit v3.3.0-rc1~480^2~4 (Makefile: Fix output during parallel builds, 2015-02-05) we always use this code path to print progress and rule messages even when color is disabled (e.g. in a try_compile). It is important to avoid printing escapes when there is no color because on MSYS we have no isatty and so assume that vt100 escapes are supported, but we do not want to print them when capturing try_compile output. If we capture the vt100 escapes in try_compile output, they contain unbalanced square brackets. This causes CMakeParseImplicitLinkInfo to fail to separate lines in a ;-list and therefore fail to extract information from the link line. Then mixed-language linking breaks. diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index e2adabe..b440a17 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -2331,7 +2331,7 @@ void cmSystemTools::MakefileColorEcho(int color, const char* message, assumeTTY = 0; } - if(enabled) + if(enabled && color != cmsysTerminal_Color_Normal) { // Print with color. Delay the newline until later so that // all color restore sequences appear before it. ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From kwrobot at kitware.com Sat Aug 29 00:01:05 2015 From: kwrobot at kitware.com (Kitware Robot) Date: Sat, 29 Aug 2015 00:01:05 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-1010-g746c9f8 Message-ID: <20150829040105.75C6BB2AF8@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 746c9f8882affae813f12e48c01332f251d86fbf (commit) from 11d5088a2f02994dc14c72170c73f7d60b0fba03 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=746c9f8882affae813f12e48c01332f251d86fbf commit 746c9f8882affae813f12e48c01332f251d86fbf Author: Kitware Robot AuthorDate: Sat Aug 29 00:01:03 2015 -0400 Commit: Kitware Robot CommitDate: Sat Aug 29 00:01:03 2015 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index d1bce76..8c14b50 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150828) +set(CMake_VERSION_PATCH 20150829) #set(CMake_VERSION_RC 1) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From steveire at gmail.com Sat Aug 29 03:39:59 2015 From: steveire at gmail.com (Stephen Kelly) Date: Sat, 29 Aug 2015 03:39:59 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2621-g9d22e55 Message-ID: <20150829073959.49A8EB1BB7@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 9d22e557598eea0ccae4442d6d43b58c724219ae (commit) via b3d2df0cb3733f8b4bebc970df89bed2724f321a (commit) via 3b5cf7d90a2ed5294f81d9e7b2748085a69e04fb (commit) via 0f5112eb9e189e9a5b8b946e41c825ddd6875d82 (commit) via ec56d244512ae87e4e3e1fcf01aa0ef80ead8763 (commit) via 1e5349a5a0162cf5f75639717d374e73358df7b2 (commit) from 0ef3eae3a17803fcf0a4de7bf87f217da134663d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9d22e557598eea0ccae4442d6d43b58c724219ae commit 9d22e557598eea0ccae4442d6d43b58c724219ae Merge: 0ef3eae b3d2df0 Author: Stephen Kelly AuthorDate: Sat Aug 29 03:39:57 2015 -0400 Commit: CMake Topic Stage CommitDate: Sat Aug 29 03:39:57 2015 -0400 Merge topic 'refactor-compute' into next b3d2df0c cmGlobalGenerator: Move path computation to Compute.: 3b5cf7d9 cmGlobalGenerator: Do more computation at compute time. 0f5112eb cmGeneratorTarget: Rename method to match operation. ec56d244 cmGlobalGenerator: Process evaluation files after target depends. 1e5349a5 cmGlobalGenerator: Access makefile from makefiles container. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b3d2df0cb3733f8b4bebc970df89bed2724f321a commit b3d2df0cb3733f8b4bebc970df89bed2724f321a Author: Stephen Kelly AuthorDate: Sat Aug 29 09:22:09 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 29 09:29:22 2015 +0200 cmGlobalGenerator: Move path computation to Compute.: diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index a440de2..2ccfc26 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1329,6 +1329,11 @@ bool cmGlobalGenerator::Compute() return false; } + for (i = 0; i < this->LocalGenerators.size(); ++i) + { + this->LocalGenerators[i]->ComputeHomeRelativeOutputPath(); + } + return true; } @@ -1340,13 +1345,8 @@ void cmGlobalGenerator::Generate() this->ProcessEvaluationFiles(); - for (i = 0; i < this->LocalGenerators.size(); ++i) - { - this->LocalGenerators[i]->ComputeHomeRelativeOutputPath(); - } - // Generate project files - for (i = 0; i < this->LocalGenerators.size(); ++i) + for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) { this->SetCurrentMakefile(this->LocalGenerators[i]->GetMakefile()); this->LocalGenerators[i]->Generate(); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3b5cf7d90a2ed5294f81d9e7b2748085a69e04fb commit 3b5cf7d90a2ed5294f81d9e7b2748085a69e04fb Author: Stephen Kelly AuthorDate: Sat Aug 29 09:21:32 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 29 09:29:21 2015 +0200 cmGlobalGenerator: Do more computation at compute time. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index a2885c0..a440de2 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1308,13 +1308,6 @@ bool cmGlobalGenerator::Compute() } } - return true; -} - -void cmGlobalGenerator::Generate() -{ - unsigned int i; - // Trace the dependencies, after that no custom commands should be added // because their dependencies might not be handled correctly for (i = 0; i < this->LocalGenerators.size(); ++i) @@ -1333,9 +1326,14 @@ void cmGlobalGenerator::Generate() // Compute the inter-target dependencies. if(!this->ComputeTargetDepends()) { - return; + return false; } + return true; +} + +void cmGlobalGenerator::Generate() +{ // Create a map from local generator to the complete set of targets // it builds by default. this->InitializeProgressMarks(); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0f5112eb9e189e9a5b8b946e41c825ddd6875d82 commit 0f5112eb9e189e9a5b8b946e41c825ddd6875d82 Author: Stephen Kelly AuthorDate: Tue Aug 25 08:25:12 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 29 09:28:06 2015 +0200 cmGeneratorTarget: Rename method to match operation. The manifest is computed, not generated, according to current language used in cmake method naming. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 4a1a7a2..09387b7 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -2554,7 +2554,7 @@ void cmGeneratorTarget::GetCompileDefinitions(std::vector &list, } //---------------------------------------------------------------------------- -void cmGeneratorTarget::GenerateTargetManifest( +void cmGeneratorTarget::ComputeTargetManifest( const std::string& config) const { if (this->Target->IsImported()) diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 2c8467f..06d9a1f 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -251,7 +251,7 @@ public: const std::string& config) const; /** Add the target output files to the global generator manifest. */ - void GenerateTargetManifest(const std::string& config) const; + void ComputeTargetManifest(const std::string& config) const; /** * Trace through the source files in this target and add al source files diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index e6cbce3..a2885c0 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1327,7 +1327,7 @@ void cmGlobalGenerator::Generate() // Compute the manifest of main targets generated. for (i = 0; i < this->LocalGenerators.size(); ++i) { - this->LocalGenerators[i]->GenerateTargetManifest(); + this->LocalGenerators[i]->ComputeTargetManifest(); } // Compute the inter-target dependencies. diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 7ce4819..f73e12f 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -450,7 +450,7 @@ void cmLocalGenerator::GenerateInstallRules() } //---------------------------------------------------------------------------- -void cmLocalGenerator::GenerateTargetManifest() +void cmLocalGenerator::ComputeTargetManifest() { // Collect the set of configuration types. std::vector configNames; @@ -478,7 +478,7 @@ void cmLocalGenerator::GenerateTargetManifest() ci != configNames.end(); ++ci) { const char* config = ci->c_str(); - target.GenerateTargetManifest(config); + target.ComputeTargetManifest(config); } } } diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 915814b..2f0971e 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -67,7 +67,7 @@ public: /** * Generate a manifest of target files that will be built. */ - void GenerateTargetManifest(); + void ComputeTargetManifest(); ///! Get the makefile for this generator cmMakefile *GetMakefile() { http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ec56d244512ae87e4e3e1fcf01aa0ef80ead8763 commit ec56d244512ae87e4e3e1fcf01aa0ef80ead8763 Author: Stephen Kelly AuthorDate: Sat Aug 29 09:18:01 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 29 09:18:01 2015 +0200 cmGlobalGenerator: Process evaluation files after target depends. No need to generate the files if computation aborts generation. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 97fa823..e6cbce3 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1330,8 +1330,6 @@ void cmGlobalGenerator::Generate() this->LocalGenerators[i]->GenerateTargetManifest(); } - this->ProcessEvaluationFiles(); - // Compute the inter-target dependencies. if(!this->ComputeTargetDepends()) { @@ -1342,6 +1340,8 @@ void cmGlobalGenerator::Generate() // it builds by default. this->InitializeProgressMarks(); + this->ProcessEvaluationFiles(); + for (i = 0; i < this->LocalGenerators.size(); ++i) { this->LocalGenerators[i]->ComputeHomeRelativeOutputPath(); http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1e5349a5a0162cf5f75639717d374e73358df7b2 commit 1e5349a5a0162cf5f75639717d374e73358df7b2 Author: Stephen Kelly AuthorDate: Tue Aug 25 08:21:22 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 29 09:15:37 2015 +0200 cmGlobalGenerator: Access makefile from makefiles container. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 46c1ccc..97fa823 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1669,8 +1669,7 @@ void cmGlobalGenerator::CheckLocalGenerators() text += "\n linked by target \""; text += l->second.GetName(); text += "\" in directory "; - text+=this->LocalGenerators[i]->GetMakefile() - ->GetCurrentSourceDirectory(); + text+=this->Makefiles[i]->GetCurrentSourceDirectory(); notFoundMap[varName] = text; } } ----------------------------------------------------------------------- Summary of changes: Source/cmGeneratorTarget.cxx | 2 +- Source/cmGeneratorTarget.h | 2 +- Source/cmGlobalGenerator.cxx | 33 +++++++++++++++------------------ Source/cmLocalGenerator.cxx | 4 ++-- Source/cmLocalGenerator.h | 2 +- 5 files changed, 20 insertions(+), 23 deletions(-) hooks/post-receive -- CMake From steveire at gmail.com Sat Aug 29 12:42:20 2015 From: steveire at gmail.com (Stephen Kelly) Date: Sat, 29 Aug 2015 12:42:20 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2623-gf07317c Message-ID: <20150829164220.0AA5EB2449@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via f07317cab18e849592c87e5c5839a40c10ca1ebb (commit) via e5359b73955e09a9269b7d4c49f95d08f9432b69 (commit) from 9d22e557598eea0ccae4442d6d43b58c724219ae (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f07317cab18e849592c87e5c5839a40c10ca1ebb commit f07317cab18e849592c87e5c5839a40c10ca1ebb Merge: 9d22e55 e5359b7 Author: Stephen Kelly AuthorDate: Sat Aug 29 12:42:19 2015 -0400 Commit: CMake Topic Stage CommitDate: Sat Aug 29 12:42:19 2015 -0400 Merge topic 'refactor-compute' into next e5359b73 Revert "cmGlobalGenerator: Move path computation to Compute.:" http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e5359b73955e09a9269b7d4c49f95d08f9432b69 commit e5359b73955e09a9269b7d4c49f95d08f9432b69 Author: Stephen Kelly AuthorDate: Sat Aug 29 18:41:57 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 29 18:41:57 2015 +0200 Revert "cmGlobalGenerator: Move path computation to Compute.:" This reverts commit b3d2df0cb3733f8b4bebc970df89bed2724f321a. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 2ccfc26..a440de2 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1329,11 +1329,6 @@ bool cmGlobalGenerator::Compute() return false; } - for (i = 0; i < this->LocalGenerators.size(); ++i) - { - this->LocalGenerators[i]->ComputeHomeRelativeOutputPath(); - } - return true; } @@ -1345,8 +1340,13 @@ void cmGlobalGenerator::Generate() this->ProcessEvaluationFiles(); + for (i = 0; i < this->LocalGenerators.size(); ++i) + { + this->LocalGenerators[i]->ComputeHomeRelativeOutputPath(); + } + // Generate project files - for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) + for (i = 0; i < this->LocalGenerators.size(); ++i) { this->SetCurrentMakefile(this->LocalGenerators[i]->GetMakefile()); this->LocalGenerators[i]->Generate(); ----------------------------------------------------------------------- Summary of changes: Source/cmGlobalGenerator.cxx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) hooks/post-receive -- CMake From steveire at gmail.com Sat Aug 29 12:55:41 2015 From: steveire at gmail.com (Stephen Kelly) Date: Sat, 29 Aug 2015 12:55:41 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2625-gb29ffb2 Message-ID: <20150829165541.A899CB2D15@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via b29ffb2a677590cafe21cc6e5dc2d14b00428108 (commit) via 379e4cc554992f78a636c2a70c0630863d6be4b9 (commit) from f07317cab18e849592c87e5c5839a40c10ca1ebb (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b29ffb2a677590cafe21cc6e5dc2d14b00428108 commit b29ffb2a677590cafe21cc6e5dc2d14b00428108 Merge: f07317c 379e4cc Author: Stephen Kelly AuthorDate: Sat Aug 29 12:55:40 2015 -0400 Commit: CMake Topic Stage CommitDate: Sat Aug 29 12:55:40 2015 -0400 Merge topic 'refactor-compute' into next 379e4cc5 fixup! cmGlobalGenerator: Do more computation at compute time. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=379e4cc554992f78a636c2a70c0630863d6be4b9 commit 379e4cc554992f78a636c2a70c0630863d6be4b9 Author: Stephen Kelly AuthorDate: Sat Aug 29 18:55:19 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 29 18:55:19 2015 +0200 fixup! cmGlobalGenerator: Do more computation at compute time. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index a440de2..e6bf5eb 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1334,6 +1334,8 @@ bool cmGlobalGenerator::Compute() void cmGlobalGenerator::Generate() { + unsigned int i; + // Create a map from local generator to the complete set of targets // it builds by default. this->InitializeProgressMarks(); ----------------------------------------------------------------------- Summary of changes: Source/cmGlobalGenerator.cxx | 2 ++ 1 file changed, 2 insertions(+) hooks/post-receive -- CMake From steveire at gmail.com Sat Aug 29 12:56:19 2015 From: steveire at gmail.com (Stephen Kelly) Date: Sat, 29 Aug 2015 12:56:19 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2627-gf90a297 Message-ID: <20150829165619.B17B8B2D2E@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via f90a2971aa49543f0d74a555abea1d0252205dc9 (commit) via 821468acc73560aabb6fa9904db511b5d992450e (commit) from b29ffb2a677590cafe21cc6e5dc2d14b00428108 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f90a2971aa49543f0d74a555abea1d0252205dc9 commit f90a2971aa49543f0d74a555abea1d0252205dc9 Merge: b29ffb2 821468a Author: Stephen Kelly AuthorDate: Sat Aug 29 12:56:19 2015 -0400 Commit: CMake Topic Stage CommitDate: Sat Aug 29 12:56:19 2015 -0400 Merge topic 'refactor-compute' into next 821468ac cmGlobalGenerator: Do more computation at compute time. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=821468acc73560aabb6fa9904db511b5d992450e commit 821468acc73560aabb6fa9904db511b5d992450e Author: Stephen Kelly AuthorDate: Sat Aug 29 09:21:32 2015 +0200 Commit: Stephen Kelly CommitDate: Sat Aug 29 18:55:54 2015 +0200 cmGlobalGenerator: Do more computation at compute time. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index a2885c0..e6bf5eb 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1308,13 +1308,6 @@ bool cmGlobalGenerator::Compute() } } - return true; -} - -void cmGlobalGenerator::Generate() -{ - unsigned int i; - // Trace the dependencies, after that no custom commands should be added // because their dependencies might not be handled correctly for (i = 0; i < this->LocalGenerators.size(); ++i) @@ -1333,9 +1326,16 @@ void cmGlobalGenerator::Generate() // Compute the inter-target dependencies. if(!this->ComputeTargetDepends()) { - return; + return false; } + return true; +} + +void cmGlobalGenerator::Generate() +{ + unsigned int i; + // Create a map from local generator to the complete set of targets // it builds by default. this->InitializeProgressMarks(); ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From kwrobot at kitware.com Sun Aug 30 00:01:04 2015 From: kwrobot at kitware.com (Kitware Robot) Date: Sun, 30 Aug 2015 00:01:04 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-1011-g2e4eb13 Message-ID: <20150830040104.B82C0B2F0A@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 2e4eb137b91f93c0fb48351a613790435a3fd63e (commit) from 746c9f8882affae813f12e48c01332f251d86fbf (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2e4eb137b91f93c0fb48351a613790435a3fd63e commit 2e4eb137b91f93c0fb48351a613790435a3fd63e Author: Kitware Robot AuthorDate: Sun Aug 30 00:01:03 2015 -0400 Commit: Kitware Robot CommitDate: Sun Aug 30 00:01:03 2015 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 8c14b50..c10ea22 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150829) +set(CMake_VERSION_PATCH 20150830) #set(CMake_VERSION_RC 1) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From steveire at gmail.com Sun Aug 30 05:39:36 2015 From: steveire at gmail.com (Stephen Kelly) Date: Sun, 30 Aug 2015 05:39:36 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2629-g0e79b98 Message-ID: <20150830093937.01B25B24E9@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 0e79b982a0066b31aa19fe942827d7967a51571f (commit) via 34a9e968aff1c1c27ec49776e1dd54c0e59478da (commit) from f90a2971aa49543f0d74a555abea1d0252205dc9 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0e79b982a0066b31aa19fe942827d7967a51571f commit 0e79b982a0066b31aa19fe942827d7967a51571f Merge: f90a297 34a9e96 Author: Stephen Kelly AuthorDate: Sun Aug 30 05:39:36 2015 -0400 Commit: CMake Topic Stage CommitDate: Sun Aug 30 05:39:36 2015 -0400 Merge topic 'refactor-compute' into next 34a9e968 Revert "cmGlobalGenerator: Do more computation at compute time." http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=34a9e968aff1c1c27ec49776e1dd54c0e59478da commit 34a9e968aff1c1c27ec49776e1dd54c0e59478da Author: Stephen Kelly AuthorDate: Sun Aug 30 11:39:09 2015 +0200 Commit: Stephen Kelly CommitDate: Sun Aug 30 11:39:09 2015 +0200 Revert "cmGlobalGenerator: Do more computation at compute time." This reverts commit 821468acc73560aabb6fa9904db511b5d992450e. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index e6bf5eb..a2885c0 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1308,6 +1308,13 @@ bool cmGlobalGenerator::Compute() } } + return true; +} + +void cmGlobalGenerator::Generate() +{ + unsigned int i; + // Trace the dependencies, after that no custom commands should be added // because their dependencies might not be handled correctly for (i = 0; i < this->LocalGenerators.size(); ++i) @@ -1326,16 +1333,9 @@ bool cmGlobalGenerator::Compute() // Compute the inter-target dependencies. if(!this->ComputeTargetDepends()) { - return false; + return; } - return true; -} - -void cmGlobalGenerator::Generate() -{ - unsigned int i; - // Create a map from local generator to the complete set of targets // it builds by default. this->InitializeProgressMarks(); ----------------------------------------------------------------------- Summary of changes: Source/cmGlobalGenerator.cxx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) hooks/post-receive -- CMake From steveire at gmail.com Sun Aug 30 05:40:02 2015 From: steveire at gmail.com (Stephen Kelly) Date: Sun, 30 Aug 2015 05:40:02 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2631-g772e192 Message-ID: <20150830094002.34A9CB25C9@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 772e19214951cd767510ff2a464e9ffb5b5e220c (commit) via 616d8f02d53b9a0c2ec5c85a6b1afc17081d1e2e (commit) from 0e79b982a0066b31aa19fe942827d7967a51571f (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=772e19214951cd767510ff2a464e9ffb5b5e220c commit 772e19214951cd767510ff2a464e9ffb5b5e220c Merge: 0e79b98 616d8f0 Author: Stephen Kelly AuthorDate: Sun Aug 30 05:40:01 2015 -0400 Commit: CMake Topic Stage CommitDate: Sun Aug 30 05:40:01 2015 -0400 Merge topic 'refactor-compute' into next 616d8f02 cmGeneratorTarget: Rename method to match operation. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=616d8f02d53b9a0c2ec5c85a6b1afc17081d1e2e commit 616d8f02d53b9a0c2ec5c85a6b1afc17081d1e2e Author: Stephen Kelly AuthorDate: Tue Aug 25 08:25:12 2015 +0200 Commit: Stephen Kelly CommitDate: Sun Aug 30 11:39:52 2015 +0200 cmGeneratorTarget: Rename method to match operation. The manifest is computed, not generated, according to current language used in cmake method naming. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 4a1a7a2..09387b7 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -2554,7 +2554,7 @@ void cmGeneratorTarget::GetCompileDefinitions(std::vector &list, } //---------------------------------------------------------------------------- -void cmGeneratorTarget::GenerateTargetManifest( +void cmGeneratorTarget::ComputeTargetManifest( const std::string& config) const { if (this->Target->IsImported()) diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 2c8467f..06d9a1f 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -251,7 +251,7 @@ public: const std::string& config) const; /** Add the target output files to the global generator manifest. */ - void GenerateTargetManifest(const std::string& config) const; + void ComputeTargetManifest(const std::string& config) const; /** * Trace through the source files in this target and add al source files diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index e6cbce3..a2885c0 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1327,7 +1327,7 @@ void cmGlobalGenerator::Generate() // Compute the manifest of main targets generated. for (i = 0; i < this->LocalGenerators.size(); ++i) { - this->LocalGenerators[i]->GenerateTargetManifest(); + this->LocalGenerators[i]->ComputeTargetManifest(); } // Compute the inter-target dependencies. diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 7ce4819..f73e12f 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -450,7 +450,7 @@ void cmLocalGenerator::GenerateInstallRules() } //---------------------------------------------------------------------------- -void cmLocalGenerator::GenerateTargetManifest() +void cmLocalGenerator::ComputeTargetManifest() { // Collect the set of configuration types. std::vector configNames; @@ -478,7 +478,7 @@ void cmLocalGenerator::GenerateTargetManifest() ci != configNames.end(); ++ci) { const char* config = ci->c_str(); - target.GenerateTargetManifest(config); + target.ComputeTargetManifest(config); } } } diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 915814b..2f0971e 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -67,7 +67,7 @@ public: /** * Generate a manifest of target files that will be built. */ - void GenerateTargetManifest(); + void ComputeTargetManifest(); ///! Get the makefile for this generator cmMakefile *GetMakefile() { ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From chuck.atkins at kitware.com Sun Aug 30 17:49:56 2015 From: chuck.atkins at kitware.com (Chuck Atkins) Date: Sun, 30 Aug 2015 17:49:56 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2635-g6a01363 Message-ID: <20150830214956.5A8CBB260E@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 6a01363837ba4aec29d788cdf89023a5470de460 (commit) via 77d483541c406847646ae1a355a4693e7b48e3e9 (commit) via 2e4eb137b91f93c0fb48351a613790435a3fd63e (commit) via 746c9f8882affae813f12e48c01332f251d86fbf (commit) from 772e19214951cd767510ff2a464e9ffb5b5e220c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6a01363837ba4aec29d788cdf89023a5470de460 commit 6a01363837ba4aec29d788cdf89023a5470de460 Merge: 772e192 77d4835 Author: Chuck Atkins AuthorDate: Sun Aug 30 17:49:55 2015 -0400 Commit: CMake Topic Stage CommitDate: Sun Aug 30 17:49:55 2015 -0400 Merge topic 'fix-link-search-start-logic' into next 77d48354 cmComputeLinkInformation: Fix bad logic for LINK_SEARCH_START_STATIC 2e4eb137 CMake Nightly Date Stamp 746c9f88 CMake Nightly Date Stamp http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=77d483541c406847646ae1a355a4693e7b48e3e9 commit 77d483541c406847646ae1a355a4693e7b48e3e9 Author: Chuck Atkins AuthorDate: Sun Aug 30 17:44:01 2015 -0400 Commit: Chuck Atkins CommitDate: Sun Aug 30 17:44:01 2015 -0400 cmComputeLinkInformation: Fix bad logic for LINK_SEARCH_START_STATIC In commit 675ef165, a but was introduced that always started the link line with -Wl,-Bstatic or -Wl,-Bdynamic by assuming no default link type. This commit fixes that by assuming the default start link type is shared. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 4b70e5e..686052c 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -863,7 +863,7 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo() const char* lss = this->Target->Target->GetProperty("LINK_SEARCH_START_STATIC"); this->StartLinkType = cmSystemTools::IsOn(lss)? LinkStatic : LinkShared; - this->CurrentLinkType = LinkUnknown; + this->CurrentLinkType = LinkShared; this->SetCurrentLinkType(this->StartLinkType); } ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- Source/cmComputeLinkInformation.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Mon Aug 31 00:01:05 2015 From: kwrobot at kitware.com (Kitware Robot) Date: Mon, 31 Aug 2015 00:01:05 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-1012-ga036a41 Message-ID: <20150831040105.99E77B275A@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via a036a4160597f83c13d2e513e2240e5a57b19a38 (commit) from 2e4eb137b91f93c0fb48351a613790435a3fd63e (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a036a4160597f83c13d2e513e2240e5a57b19a38 commit a036a4160597f83c13d2e513e2240e5a57b19a38 Author: Kitware Robot AuthorDate: Mon Aug 31 00:01:03 2015 -0400 Commit: Kitware Robot CommitDate: Mon Aug 31 00:01:03 2015 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index c10ea22..33ad704 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150830) +set(CMake_VERSION_PATCH 20150831) #set(CMake_VERSION_RC 1) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 31 09:48:27 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 31 Aug 2015 09:48:27 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-1014-g97db5c5 Message-ID: <20150831134827.C5BF1B31C6@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 97db5c567894c253173ab45c919925ce010ab05e (commit) via 3e2865b46744e543af3045331b31b94df2ebe1ad (commit) from a036a4160597f83c13d2e513e2240e5a57b19a38 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=97db5c567894c253173ab45c919925ce010ab05e commit 97db5c567894c253173ab45c919925ce010ab05e Merge: a036a41 3e2865b Author: Brad King AuthorDate: Mon Aug 31 09:48:26 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 31 09:48:26 2015 -0400 Merge topic 'GenerateExportHeader-cygwin-dllexport' 3e2865b4 GenerateExportHeader: Use dllexport/dllimport on Cygwin ----------------------------------------------------------------------- Summary of changes: Modules/GenerateExportHeader.cmake | 2 +- Tests/Module/GenerateExportHeader/CMakeLists.txt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 31 09:48:29 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 31 Aug 2015 09:48:29 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-1028-g352e8e9 Message-ID: <20150831134829.F107FB31CE@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 352e8e95b65e19cca10b4aec0c626787dfbb1ba1 (commit) via 2b9a25d7f723a9876e2979de8e6c06881e0312dc (commit) via 3e08b4df95208286d8891d76234f7910ff5c1d1c (commit) via 357bf469c7a6c6adad1f3269474989af9b203994 (commit) via ebf8d0a99ac6eb231180b3315b976bcc58baa9f3 (commit) via bd096d30e05fe66a0bf702fe7e366b0042ea14ae (commit) via ff8ac8ee6ab3ee686621445456a765fa33c1a873 (commit) via 0bd7279fd9608702b7790822c80f3c284de8e7e4 (commit) via 2f2d4da9dd031cdf9f8a0cadcbdffe38c2170353 (commit) via 7fdc9a8b5f63f645b5aedede4fd18e0c1d1c39c5 (commit) via 92041eec49ab4968b2d4f09e3bd71a3720d86036 (commit) via acb006229dbc531303538f4de1dc4d16d27369a5 (commit) via 83b8a927e5a992480e96b0be36ea0426a924c41f (commit) via 9b6a743b801dffa9f7ccab0c3e73fa8d22f3b8b9 (commit) from 97db5c567894c253173ab45c919925ce010ab05e (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=352e8e95b65e19cca10b4aec0c626787dfbb1ba1 commit 352e8e95b65e19cca10b4aec0c626787dfbb1ba1 Merge: 97db5c5 2b9a25d Author: Brad King AuthorDate: Mon Aug 31 09:48:28 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 31 09:48:28 2015 -0400 Merge topic 'generate-time-generators' 2b9a25d7 cmGlobalGenerator: Create global targets directly after Configure. 3e08b4df cmMakefile: Skip Global targets for CMP0019 evaluation. 357bf469 cmGlobalGenerator: Fill the project map at compute time. ebf8d0a9 cmGlobalGenerator: Rename method. bd096d30 cmGlobalGenerator: Avoid cmLocalGenerator until after Configure. ff8ac8ee cmLocalGenerator: Create from already-constructed cmMakefile. 0bd7279f Ninja: Remove some incorrect comments adding no value. 2f2d4da9 cmCTestScriptHandler: Simplify deletes. 7fdc9a8b QtAutogen: Use a smart pointer. 92041eec cmGlobalGenerator: Remove MakeLocalGenerator method. acb00622 cmGlobalGenerator: Require a snapshot to create a local generator. 83b8a927 cmMakefile: Remove cmLocalGenerator member. 9b6a743b cmLocalGenerator: Remove Parent pointer. ----------------------------------------------------------------------- Summary of changes: Source/CPack/cmCPackGenerator.cxx | 6 +- Source/CPack/cpack.cxx | 10 ++-- Source/CTest/cmCTestLaunch.cxx | 5 +- Source/CTest/cmCTestScriptHandler.cxx | 46 ++++++--------- Source/CTest/cmCTestTestHandler.cxx | 5 +- Source/cmCTest.cxx | 7 ++- Source/cmGlobalBorlandMakefileGenerator.cxx | 4 +- Source/cmGlobalBorlandMakefileGenerator.h | 3 +- Source/cmGlobalGenerator.cxx | 80 +++++++++++---------------- Source/cmGlobalGenerator.h | 11 +--- Source/cmGlobalGhsMultiGenerator.cxx | 5 +- Source/cmGlobalGhsMultiGenerator.h | 3 +- Source/cmGlobalNinjaGenerator.cxx | 5 +- Source/cmGlobalNinjaGenerator.h | 14 +---- Source/cmGlobalUnixMakefileGenerator3.cxx | 14 +++-- Source/cmGlobalUnixMakefileGenerator3.h | 4 +- Source/cmGlobalVisualStudio10Generator.cxx | 7 +-- Source/cmGlobalVisualStudio10Generator.h | 3 +- Source/cmGlobalVisualStudio6Generator.cxx | 5 +- Source/cmGlobalVisualStudio6Generator.h | 3 +- Source/cmGlobalVisualStudio7Generator.cxx | 7 +-- Source/cmGlobalVisualStudio7Generator.h | 3 +- Source/cmGlobalXCodeGenerator.cxx | 5 +- Source/cmGlobalXCodeGenerator.h | 3 +- Source/cmGraphVizWriter.cxx | 5 +- Source/cmLocalCommonGenerator.cxx | 5 +- Source/cmLocalCommonGenerator.h | 4 +- Source/cmLocalGenerator.cxx | 11 ++-- Source/cmLocalGenerator.h | 7 +-- Source/cmLocalGhsMultiGenerator.cxx | 5 +- Source/cmLocalGhsMultiGenerator.h | 3 +- Source/cmLocalNinjaGenerator.cxx | 5 +- Source/cmLocalNinjaGenerator.h | 3 +- Source/cmLocalUnixMakefileGenerator3.cxx | 5 +- Source/cmLocalUnixMakefileGenerator3.h | 4 +- Source/cmLocalVisualStudio10Generator.cxx | 6 +- Source/cmLocalVisualStudio10Generator.h | 4 +- Source/cmLocalVisualStudio6Generator.cxx | 6 +- Source/cmLocalVisualStudio6Generator.h | 4 +- Source/cmLocalVisualStudio7Generator.cxx | 6 +- Source/cmLocalVisualStudio7Generator.h | 4 +- Source/cmLocalVisualStudioGenerator.cxx | 6 +- Source/cmLocalVisualStudioGenerator.h | 4 +- Source/cmLocalXCodeGenerator.cxx | 5 +- Source/cmLocalXCodeGenerator.h | 4 +- Source/cmMakefile.cxx | 23 ++++---- Source/cmMakefile.h | 6 +- Source/cmQtAutoGenerators.cxx | 5 +- Source/cmake.cxx | 20 ++++--- Source/cmcmd.cxx | 5 +- 50 files changed, 176 insertions(+), 247 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 31 09:48:32 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 31 Aug 2015 09:48:32 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-1032-g9a6d7d2 Message-ID: <20150831134832.1C1B2B31CF@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 9a6d7d2e5484fb75aa3aea2ad5d981cf699bfd25 (commit) via 616d8f02d53b9a0c2ec5c85a6b1afc17081d1e2e (commit) via ec56d244512ae87e4e3e1fcf01aa0ef80ead8763 (commit) via 1e5349a5a0162cf5f75639717d374e73358df7b2 (commit) from 352e8e95b65e19cca10b4aec0c626787dfbb1ba1 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9a6d7d2e5484fb75aa3aea2ad5d981cf699bfd25 commit 9a6d7d2e5484fb75aa3aea2ad5d981cf699bfd25 Merge: 352e8e9 616d8f0 Author: Brad King AuthorDate: Mon Aug 31 09:48:30 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 31 09:48:30 2015 -0400 Merge topic 'refactor-compute' 616d8f02 cmGeneratorTarget: Rename method to match operation. ec56d244 cmGlobalGenerator: Process evaluation files after target depends. 1e5349a5 cmGlobalGenerator: Access makefile from makefiles container. ----------------------------------------------------------------------- Summary of changes: Source/cmGeneratorTarget.cxx | 2 +- Source/cmGeneratorTarget.h | 2 +- Source/cmGlobalGenerator.cxx | 9 ++++----- Source/cmLocalGenerator.cxx | 4 ++-- Source/cmLocalGenerator.h | 2 +- 5 files changed, 9 insertions(+), 10 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 31 09:48:34 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 31 Aug 2015 09:48:34 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-1034-g5f6718c Message-ID: <20150831134834.6D427B31D5@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 5f6718c003dce82a64b7fee6e3cd95ecfc11548b (commit) via 674dc0b33566b433b6ac5751f965b7d0ff952e73 (commit) from 9a6d7d2e5484fb75aa3aea2ad5d981cf699bfd25 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5f6718c003dce82a64b7fee6e3cd95ecfc11548b commit 5f6718c003dce82a64b7fee6e3cd95ecfc11548b Merge: 9a6d7d2 674dc0b Author: Brad King AuthorDate: Mon Aug 31 09:48:32 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 31 09:48:32 2015 -0400 Merge topic 'cpack-config-generation-test' 674dc0b3 CPack generator independent tests ----------------------------------------------------------------------- Summary of changes: Tests/RunCMake/CMakeLists.txt | 1 + Tests/RunCMake/{CMP0064 => CPackConfig}/CMakeLists.txt | 5 ++++- Tests/RunCMake/CPackConfig/RunCMakeTest.cmake | 3 +++ Tests/RunCMake/CPackConfig/Simple-check.cmake | 3 +++ Tests/RunCMake/CPackConfig/Simple.cmake | 1 + Tests/RunCMake/CPackConfig/check.cmake | 7 +++++++ 6 files changed, 19 insertions(+), 1 deletion(-) copy Tests/RunCMake/{CMP0064 => CPackConfig}/CMakeLists.txt (61%) create mode 100644 Tests/RunCMake/CPackConfig/RunCMakeTest.cmake create mode 100644 Tests/RunCMake/CPackConfig/Simple-check.cmake create mode 100644 Tests/RunCMake/CPackConfig/Simple.cmake create mode 100644 Tests/RunCMake/CPackConfig/check.cmake hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 31 09:48:36 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 31 Aug 2015 09:48:36 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-1036-gd01e3c3 Message-ID: <20150831134836.77208B31CA@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via d01e3c31c9027983663918d5cbcba2a61aeb2f9f (commit) via 90a22c3ac5d38a83d4d487030277db4021c1913a (commit) from 5f6718c003dce82a64b7fee6e3cd95ecfc11548b (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d01e3c31c9027983663918d5cbcba2a61aeb2f9f commit d01e3c31c9027983663918d5cbcba2a61aeb2f9f Merge: 5f6718c 90a22c3 Author: Brad King AuthorDate: Mon Aug 31 09:48:35 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 31 09:48:35 2015 -0400 Merge topic 'FindJNI-mips' 90a22c3a FindJNI: Add mips64(el) mipsn32(el) support (#15714) ----------------------------------------------------------------------- Summary of changes: Modules/FindJNI.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 31 09:48:38 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 31 Aug 2015 09:48:38 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-1040-ge18f6fe Message-ID: <20150831134838.D9D9DB31D4@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via e18f6fe276ea3ca576bb5f8fb910a6532280d900 (commit) via ab2524d63f651e6d96c770fb3571bddab4b86621 (commit) via dee84dc73d88d05b9ad66908780c3e7c6ddc67ef (commit) via b3372db588431f000b5fe3de980d6a2f27382eb1 (commit) from d01e3c31c9027983663918d5cbcba2a61aeb2f9f (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e18f6fe276ea3ca576bb5f8fb910a6532280d900 commit e18f6fe276ea3ca576bb5f8fb910a6532280d900 Merge: d01e3c3 ab2524d Author: Brad King AuthorDate: Mon Aug 31 09:48:37 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 31 09:48:37 2015 -0400 Merge topic 'fix-ctest-xml-double-encoding' ab2524d6 CTest: Fix XML double-encoding cases dee84dc7 cmCTest{BZR,GIT,P4}: Remove unused cmXMLSafe includes b3372db5 cmExtra{Kate,SublimeText}Generator: Remove unused cmXMLSafe includes diff --cc Source/CTest/cmCTestGIT.cxx index 5b9208a,c32e876..bbb3b9d --- a/Source/CTest/cmCTestGIT.cxx +++ b/Source/CTest/cmCTestGIT.cxx @@@ -14,9 -14,9 +14,8 @@@ #include "cmCTest.h" #include "cmSystemTools.h" #include "cmAlgorithms.h" - #include "cmXMLSafe.h" #include -#include #include #include diff --cc Source/CTest/cmCTestP4.cxx index 5ce431a,ad8e8b3..5e0c54a --- a/Source/CTest/cmCTestP4.cxx +++ b/Source/CTest/cmCTestP4.cxx @@@ -13,9 -13,9 +13,8 @@@ #include "cmCTest.h" #include "cmSystemTools.h" - #include "cmXMLSafe.h" #include -#include #include #include ----------------------------------------------------------------------- Summary of changes: Source/CTest/cmCTestBZR.cxx | 1 - Source/CTest/cmCTestGIT.cxx | 1 - Source/CTest/cmCTestMemCheckHandler.cxx | 16 ++++++---------- Source/CTest/cmCTestP4.cxx | 1 - Source/CTest/cmCTestTestHandler.cxx | 2 +- Source/cmCTest.cxx | 5 +---- Source/cmExtraKateGenerator.cxx | 1 - Source/cmExtraSublimeTextGenerator.cxx | 1 - 8 files changed, 8 insertions(+), 20 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 31 09:48:41 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 31 Aug 2015 09:48:41 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-1043-g08ae6ce Message-ID: <20150831134841.442B5B31D4@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 08ae6ced4d5bbdb536a79e561eed54b28ae56836 (commit) via ac0bb4333d13e633e26d107f288162d7d6a37b3a (commit) via 92b835ec9d17b190b13da93702f0eb416b665a48 (commit) from e18f6fe276ea3ca576bb5f8fb910a6532280d900 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=08ae6ced4d5bbdb536a79e561eed54b28ae56836 commit 08ae6ced4d5bbdb536a79e561eed54b28ae56836 Merge: e18f6fe ac0bb43 Author: Brad King AuthorDate: Mon Aug 31 09:48:39 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 31 09:48:39 2015 -0400 Merge topic 'vs-store-phone-cert-thumbs' ac0bb433 VS: Windows Store/Phone package cert thumbprint 92b835ec Simplify condition for using rpcrt4 library on Windows ----------------------------------------------------------------------- Summary of changes: CMakeLists.txt | 11 ---- CTestCustom.cmake.in | 1 + Source/CMakeLists.txt | 7 ++- Source/cmSystemTools.cxx | 88 ++++++++++++++++++++++++++++ Source/cmSystemTools.h | 3 + Source/cmVisualStudio10TargetGenerator.cxx | 16 ++++- 6 files changed, 111 insertions(+), 15 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 31 09:48:43 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 31 Aug 2015 09:48:43 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.3.1-1045-g51d7a7b Message-ID: <20150831134843.913E7B31CD@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 51d7a7bb3f03b3562c8ca82ddfefcc5185dc2455 (commit) via bfb9d34f8afe66c2ce344b36db48568fc88950c9 (commit) from 08ae6ced4d5bbdb536a79e561eed54b28ae56836 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=51d7a7bb3f03b3562c8ca82ddfefcc5185dc2455 commit 51d7a7bb3f03b3562c8ca82ddfefcc5185dc2455 Merge: 08ae6ce bfb9d34 Author: Brad King AuthorDate: Mon Aug 31 09:48:42 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 31 09:48:42 2015 -0400 Merge topic 'makefile-color-when-needed' bfb9d34f Makefile: Print color escapes only when necessary ----------------------------------------------------------------------- Summary of changes: Source/cmSystemTools.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 31 09:49:05 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 31 Aug 2015 09:49:05 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2645-g2af5650 Message-ID: <20150831134905.480FBB31C6@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 2af56500e8be3074ebb58060909d070b2557e17a (commit) via 51d7a7bb3f03b3562c8ca82ddfefcc5185dc2455 (commit) via 08ae6ced4d5bbdb536a79e561eed54b28ae56836 (commit) via e18f6fe276ea3ca576bb5f8fb910a6532280d900 (commit) via d01e3c31c9027983663918d5cbcba2a61aeb2f9f (commit) via 5f6718c003dce82a64b7fee6e3cd95ecfc11548b (commit) via 9a6d7d2e5484fb75aa3aea2ad5d981cf699bfd25 (commit) via 352e8e95b65e19cca10b4aec0c626787dfbb1ba1 (commit) via 97db5c567894c253173ab45c919925ce010ab05e (commit) via a036a4160597f83c13d2e513e2240e5a57b19a38 (commit) from 6a01363837ba4aec29d788cdf89023a5470de460 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2af56500e8be3074ebb58060909d070b2557e17a commit 2af56500e8be3074ebb58060909d070b2557e17a Merge: 6a01363 51d7a7b Author: Brad King AuthorDate: Mon Aug 31 09:48:54 2015 -0400 Commit: Brad King CommitDate: Mon Aug 31 09:48:54 2015 -0400 Merge branch 'master' into next ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 31 09:50:26 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 31 Aug 2015 09:50:26 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2647-gcb09b3a Message-ID: <20150831135026.1B431B3224@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via cb09b3a0ea2bacd67523ebd85af6890b674caea8 (commit) via 76fa8596997da889349b759990ea93dcd4c34c8f (commit) from 2af56500e8be3074ebb58060909d070b2557e17a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cb09b3a0ea2bacd67523ebd85af6890b674caea8 commit cb09b3a0ea2bacd67523ebd85af6890b674caea8 Merge: 2af5650 76fa859 Author: Brad King AuthorDate: Mon Aug 31 09:50:25 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 31 09:50:25 2015 -0400 Merge topic 'drop-cmsys-std-layer' into next 76fa8596 Tests: Remove use of include and kwsys_{ios,stl}:: http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=76fa8596997da889349b759990ea93dcd4c34c8f commit 76fa8596997da889349b759990ea93dcd4c34c8f Author: Brad King AuthorDate: Fri Aug 28 15:07:00 2015 -0400 Commit: Brad King CommitDate: Mon Aug 31 09:50:12 2015 -0400 Tests: Remove use of include and kwsys_{ios,stl}:: We no longer need this compatibility layer for the compilers we support. diff --git a/Tests/Plugin/src/example_exe.cxx b/Tests/Plugin/src/example_exe.cxx index 309302e..bc4b03e 100644 --- a/Tests/Plugin/src/example_exe.cxx +++ b/Tests/Plugin/src/example_exe.cxx @@ -3,15 +3,15 @@ #include #include -#include -#include +#include +#include #include // Implement the ABI used by plugins. extern "C" int example_exe_function() { - kwsys_ios::cout << "hello" << kwsys_ios::endl; + std::cout << "hello" << std::endl; return 123; } @@ -23,7 +23,7 @@ extern "C" int example_exe_function() int main() { - kwsys_stl::string libName = EXAMPLE_EXE_PLUGIN_DIR CONFIG_DIR "/"; + std::string libName = EXAMPLE_EXE_PLUGIN_DIR CONFIG_DIR "/"; libName += kwsys::DynamicLoader::LibPrefix(); libName += "example_mod_1"; libName += kwsys::DynamicLoader::LibExtension(); @@ -31,17 +31,17 @@ int main() kwsys::DynamicLoader::OpenLibrary(libName.c_str()); if(!handle) { - kwsys_ios::cerr << "Could not open plugin \"" - << libName << "\"!" << kwsys_ios::endl; + std::cerr << "Could not open plugin \"" + << libName << "\"!" << std::endl; return 1; } kwsys::DynamicLoader::SymbolPointer sym = kwsys::DynamicLoader::GetSymbolAddress(handle, "example_mod_1_function"); if(!sym) { - kwsys_ios::cerr + std::cerr << "Could not get plugin symbol \"example_mod_1_function\"!" - << kwsys_ios::endl; + << std::endl; return 1; } #ifdef __WATCOMC__ @@ -51,8 +51,8 @@ int main() #endif if(f(456) != (123+456)) { - kwsys_ios::cerr << "Incorrect return value from plugin!" - << kwsys_ios::endl; + std::cerr << "Incorrect return value from plugin!" + << std::endl; return 1; } kwsys::DynamicLoader::CloseLibrary(handle); ----------------------------------------------------------------------- Summary of changes: Tests/Plugin/src/example_exe.cxx | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 31 09:58:34 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 31 Aug 2015 09:58:34 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2650-gf83cd17 Message-ID: <20150831135834.211F4B336F@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via f83cd172f23d35bdf2552dfcc781914f7b46e968 (commit) via 49d293a795c42c0325aa677d6a7c0f55c647da91 (commit) via ca96be228345d93f51cb4edbd0428b709f529b84 (commit) from cb09b3a0ea2bacd67523ebd85af6890b674caea8 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f83cd172f23d35bdf2552dfcc781914f7b46e968 commit f83cd172f23d35bdf2552dfcc781914f7b46e968 Merge: cb09b3a 49d293a Author: Brad King AuthorDate: Mon Aug 31 09:58:33 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 31 09:58:33 2015 -0400 Merge topic 'update-kwsys' into next 49d293a7 Merge branch 'upstream-kwsys' into update-kwsys ca96be22 KWSys 2015-08-24 (cdaf522c) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=49d293a795c42c0325aa677d6a7c0f55c647da91 commit 49d293a795c42c0325aa677d6a7c0f55c647da91 Merge: 51d7a7b ca96be2 Author: Brad King AuthorDate: Mon Aug 31 09:55:01 2015 -0400 Commit: Brad King CommitDate: Mon Aug 31 09:55:01 2015 -0400 Merge branch 'upstream-kwsys' into update-kwsys http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ca96be228345d93f51cb4edbd0428b709f529b84 commit ca96be228345d93f51cb4edbd0428b709f529b84 Author: KWSys Robot AuthorDate: Mon Aug 24 22:44:47 2015 +0000 Commit: Brad King CommitDate: Mon Aug 31 09:54:42 2015 -0400 KWSys 2015-08-24 (cdaf522c) Extract upstream KWSys using the following shell commands. $ git archive --prefix=upstream-kwsys/ cdaf522c | tar x $ git shortlog --no-merges --abbrev=8 --format='%h %s' dad68c33..cdaf522c Brad King (2): c8e5d1b2 Pass C++ standard flags to SunPro in standalone build 91cb7820 Remove unused source file "CMakeEmptyInputFile.in" James Johnston (6): 0bca555e Process: Test running a process many times to discover resource leaks 52788bb8 SystemTools: Remove trailing whitespace. 8122214c cmake: Set CMAKE_LEGACY_CYGWIN_WIN32 to 0. 389d416b SystemTools: Clarify/simplify behavior of FileExists 8970cd56 SystemTools: Added new TestFileAccess function. cdaf522c SystemTools: Add honor_umask parameter to SetPermissions. Mattias Ellert (1): b9df3e48 Fix implementation of KWSYS_PROPERTIES_C diff --git a/CMakeEmptyInputFile.in b/CMakeEmptyInputFile.in deleted file mode 100644 index 40b7ea2..0000000 --- a/CMakeEmptyInputFile.in +++ /dev/null @@ -1 +0,0 @@ - at CMAKE_EMPTY_INPUT_FILE_CONTENT@ diff --git a/CMakeLists.txt b/CMakeLists.txt index 017d619..c1229ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,6 +91,7 @@ ENDIF() IF(POLICY CMP0056) CMAKE_POLICY(SET CMP0056 NEW) ENDIF() +SET(CMAKE_LEGACY_CYGWIN_WIN32 0) #----------------------------------------------------------------------------- # If a namespace is not specified, use "kwsys" and enable testing. @@ -311,6 +312,15 @@ IF(NOT CMAKE_COMPILER_IS_GNUCXX) ENDIF() ENDIF() ENDIF() +IF(KWSYS_STANDALONE) + IF(CMAKE_CXX_COMPILER_ID STREQUAL SunPro) + IF(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++03") + ELSE() + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -library=stlport4") + ENDIF() + ENDIF() +ENDIF() #----------------------------------------------------------------------------- # Configure Large File Support. @@ -1071,7 +1081,7 @@ IF(KWSYS_ENABLE_C AND KWSYS_C_SRCS) # Apply user-defined target properties to the library. IF(KWSYS_PROPERTIES_C) - SET_TARGET_PROPERTIES(${KWSYS_NAMESPACE} PROPERTIES + SET_TARGET_PROPERTIES(${KWSYS_NAMESPACE}_c PROPERTIES ${KWSYS_PROPERTIES_C} ) ENDIF() diff --git a/SystemTools.cxx b/SystemTools.cxx index 0714344..f12a06c 100644 --- a/SystemTools.cxx +++ b/SystemTools.cxx @@ -68,6 +68,10 @@ #include #include +#ifdef _MSC_VER +# define umask _umask // Note this is still umask on Borland +#endif + // support for realpath call #ifndef _WIN32 #include @@ -1233,13 +1237,11 @@ bool SystemTools::FileExists(const kwsys_stl::string& filename) //---------------------------------------------------------------------------- bool SystemTools::FileExists(const char* filename, bool isFile) { - if(SystemTools::FileExists(filename)) + if(!filename) { - // If isFile is set return not FileIsDirectory, - // so this will only be true if it is a file - return !isFile || !SystemTools::FileIsDirectory(filename); + return false; } - return false; + return SystemTools::FileExists(kwsys_stl::string(filename), isFile); } //---------------------------------------------------------------------------- @@ -1255,6 +1257,43 @@ bool SystemTools::FileExists(const kwsys_stl::string& filename, bool isFile) } //---------------------------------------------------------------------------- +bool SystemTools::TestFileAccess(const char* filename, + TestFilePermissions permissions) +{ + if(!filename) + { + return false; + } + return SystemTools::TestFileAccess(kwsys_stl::string(filename), + permissions); +} + +//---------------------------------------------------------------------------- +bool SystemTools::TestFileAccess(const kwsys_stl::string& filename, + TestFilePermissions permissions) +{ + if(filename.empty()) + { + return false; + } +#if defined(_WIN32) && !defined(__CYGWIN__) + // If execute set, change to read permission (all files on Windows + // are executable if they are readable). The CRT will always fail + // if you pass an execute bit. + if(permissions & TEST_FILE_EXECUTE) + { + permissions &= ~TEST_FILE_EXECUTE; + permissions |= TEST_FILE_READ; + } + return _waccess( + SystemTools::ConvertToWindowsExtendedPath(filename).c_str(), + permissions) == 0; +#else + return access(filename.c_str(), permissions) == 0; +#endif +} + +//---------------------------------------------------------------------------- #ifdef __CYGWIN__ bool SystemTools::PathCygwinToWin32(const char *path, char *win32_path) { @@ -4745,21 +4784,35 @@ bool SystemTools::GetPermissions(const kwsys_stl::string& file, mode_t& mode) return true; } -bool SystemTools::SetPermissions(const char* file, mode_t mode) +bool SystemTools::SetPermissions(const char* file, + mode_t mode, + bool honor_umask) { if ( !file ) { return false; } - return SystemTools::SetPermissions(kwsys_stl::string(file), mode); + return SystemTools::SetPermissions( + kwsys_stl::string(file), mode, honor_umask); } -bool SystemTools::SetPermissions(const kwsys_stl::string& file, mode_t mode) +bool SystemTools::SetPermissions(const kwsys_stl::string& file, + mode_t mode, + bool honor_umask) { - if ( !SystemTools::FileExists(file) ) + // TEMPORARY / TODO: After FileExists calls lstat() instead of + // access(), change this call to FileExists instead of + // TestFileAccess so that we don't follow symlinks. + if ( !SystemTools::TestFileAccess(file, TEST_FILE_OK) ) { return false; } + if (honor_umask) + { + mode_t currentMask = umask(0); + umask(currentMask); + mode &= ~currentMask; + } #ifdef _WIN32 if ( _wchmod(SystemTools::ConvertToWindowsExtendedPath(file).c_str(), mode) < 0 ) diff --git a/SystemTools.hxx.in b/SystemTools.hxx.in index 7899141..164c5e0 100644 --- a/SystemTools.hxx.in +++ b/SystemTools.hxx.in @@ -21,6 +21,9 @@ #include <@KWSYS_NAMESPACE@/String.hxx> #include +#if !defined(_WIN32) || defined(__CYGWIN__) +# include // For access permissions for use with access() +#endif // Required for va_list #include @@ -68,10 +71,28 @@ public: }; // This instance will show up in any translation unit that uses -// SystemTools. It will make sure SystemTools is initialized +// SystemTools. It will make sure SystemTools is initialized // before it is used and is the last static object destroyed. static SystemToolsManager SystemToolsManagerInstance; +// Flags for use with TestFileAccess. Use a typedef in case any operating +// system in the future needs a special type. These are flags that may be +// combined using the | operator. +typedef int TestFilePermissions; +#if defined(_WIN32) && !defined(__CYGWIN__) + // On Windows (VC and Borland), no system header defines these constants... + static const TestFilePermissions TEST_FILE_OK = 0; + static const TestFilePermissions TEST_FILE_READ = 4; + static const TestFilePermissions TEST_FILE_WRITE = 2; + static const TestFilePermissions TEST_FILE_EXECUTE = 1; +#else + // Standard POSIX constants + static const TestFilePermissions TEST_FILE_OK = F_OK; + static const TestFilePermissions TEST_FILE_READ = R_OK; + static const TestFilePermissions TEST_FILE_WRITE = W_OK; + static const TestFilePermissions TEST_FILE_EXECUTE = X_OK; +#endif + /** \class SystemTools * \brief A collection of useful platform-independent system functions. */ @@ -113,34 +134,34 @@ public: * all other are lowercased). */ static kwsys_stl::string Capitalized(const kwsys_stl::string&); - + /** * Return a 'capitalized words' string (i.e the first letter of each word * is uppercased all other are left untouched though). */ static kwsys_stl::string CapitalizedWords(const kwsys_stl::string&); - + /** * Return a 'uncapitalized words' string (i.e the first letter of each word * is lowercased all other are left untouched though). */ static kwsys_stl::string UnCapitalizedWords(const kwsys_stl::string&); - + /** * Return a lower case string */ static kwsys_stl::string LowerCase(const kwsys_stl::string&); - + /** * Return a lower case string */ static kwsys_stl::string UpperCase(const kwsys_stl::string&); - + /** * Count char in string */ static size_t CountChar(const char* str, char c); - + /** * Remove some characters from a string. * Return a pointer to the new resulting string (allocated with 'new') @@ -152,13 +173,13 @@ public: * Return a pointer to the new resulting string (allocated with 'new') */ static char* RemoveCharsButUpperHex(const char* str); - + /** * Replace some characters by another character in a string (in-place) * Return a pointer to string */ static char* ReplaceChars(char* str, const char *toreplace,char replacement); - + /** * Returns true if str1 starts (respectively ends) with str2 */ @@ -171,25 +192,25 @@ public: * Returns a pointer to the last occurence of str2 in str1 */ static const char* FindLastString(const char* str1, const char* str2); - + /** * Make a duplicate of the string similar to the strdup C function * but use new to create the 'new' string, so one can use * 'delete' to remove it. Returns 0 if the input is empty. */ static char* DuplicateString(const char* str); - + /** * Return the string cropped to a given length by removing chars in the * center of the string and replacing them with an ellipsis (...) */ static kwsys_stl::string CropString(const kwsys_stl::string&,size_t max_len); - + /** split a path by separator into an array of strings, default is /. If isPath is true then the string is treated like a path and if s starts with a / then the first element of the returned array will be /, so /foo/bar will be [/, foo, bar] - */ + */ static kwsys_stl::vector SplitString(const kwsys_stl::string& s, char separator = '/', bool isPath = false); /** @@ -197,7 +218,7 @@ public: */ static int Strucmp(const char *s1, const char *s2); - /** + /** * Convert a string in __DATE__ or __TIMESTAMP__ format into a time_t. * Return false on error, true on success */ @@ -210,11 +231,11 @@ public: */ static bool Split(const kwsys_stl::string& s, kwsys_stl::vector& l); static bool Split(const kwsys_stl::string& s, kwsys_stl::vector& l, char separator); - - /** + + /** * Return string with space added between capitalized words * (i.e. EatMyShorts becomes Eat My Shorts ) - * (note that IEatShorts becomes IEat Shorts) + * (note that IEatShorts becomes IEat Shorts) */ static kwsys_stl::string AddSpaceBetweenCapitalizedWords( const kwsys_stl::string&); @@ -290,9 +311,11 @@ public: /** * Return true if a file exists in the current directory. - * If isFile = true, then make sure the file is a file and + * If isFile = true, then make sure the file is a file and * not a directory. If isFile = false, then return true - * if it is a file or a directory. + * if it is a file or a directory. Note that the file will + * also be checked for read access. (Currently, this check + * for read access is only done on POSIX systems.) */ static bool FileExists(const char* filename, bool isFile); static bool FileExists(const kwsys_stl::string& filename, bool isFile); @@ -300,6 +323,21 @@ public: static bool FileExists(const kwsys_stl::string& filename); /** + * Test if a file exists and can be accessed with the requested + * permissions. Symbolic links are followed. Returns true if + * the access test was successful. + * + * On POSIX systems (including Cygwin), this maps to the access + * function. On Windows systems, all existing files are + * considered readable, and writable files are considered to + * have the read-only file attribute cleared. + */ + static bool TestFileAccess(const char* filename, + TestFilePermissions permissions); + static bool TestFileAccess(const kwsys_stl::string& filename, + TestFilePermissions permissions); + + /** * Converts Cygwin path to Win32 path. Uses dictionary container for * caching and calls to cygwin_conv_to_win32_path from Cygwin dll * for actual translation. Returns true on success, else false. @@ -317,7 +355,7 @@ public: Change the modification time or create a file */ static bool Touch(const kwsys_stl::string& filename, bool create); - + /** * Compare file modification times. * Return true for successful comparison and false for error. @@ -360,7 +398,7 @@ public: * to the running executable. If argv0 is not a full path, * then this will try to find the full path. If the path is not * found false is returned, if found true is returned. An error - * message of the attempted paths is stored in errorMsg. + * message of the attempted paths is stored in errorMsg. * exeName is the name of the executable. * buildDir is a possibly null path to the build directory. * installPrefix is a possibly null pointer to the install directory. @@ -384,7 +422,7 @@ public: static kwsys_stl::string CollapseFullPath(const kwsys_stl::string& in_relative, const kwsys_stl::string& in_base); - /** + /** * Get the real path for a given path, removing all symlinks. In * the event of an error (non-existent path, permissions issue, * etc.) the original path is returned if errorMessage pointer is @@ -469,31 +507,31 @@ public: */ static kwsys_stl::string GetFilenameLastExtension( const kwsys_stl::string& filename); - + /** * Return file name without extension of a full filename */ static kwsys_stl::string GetFilenameWithoutExtension( const kwsys_stl::string&); - + /** * Return file name without its last (shortest) extension */ static kwsys_stl::string GetFilenameWithoutLastExtension( const kwsys_stl::string&); - + /** * Return whether the path represents a full path (not relative) */ static bool FileIsFullPath(const kwsys_stl::string&); static bool FileIsFullPath(const char*); - + /** * For windows return the short path for the given path, * Unix just a pass through */ static bool GetShortPath(const kwsys_stl::string& path, kwsys_stl::string& result); - + /** * Read line from file. Make sure to get everything. Due to a buggy stream * library on the HP and another on Mac OS X, we need this very carefully @@ -501,7 +539,7 @@ public: * end-of-file was reached. If the has_newline argument is specified, it will * be true when the line read had a newline character. */ - static bool GetLineFromStream(kwsys_ios::istream& istr, + static bool GetLineFromStream(kwsys_ios::istream& istr, kwsys_stl::string& line, bool* has_newline=0, long sizeLimit=-1); @@ -529,7 +567,7 @@ public: /** * Make a new directory if it is not there. This function * can make a full path even if none of the directories existed - * prior to calling this function. + * prior to calling this function. */ static bool MakeDirectory(const char* path); static bool MakeDirectory(const kwsys_stl::string& path); @@ -572,12 +610,12 @@ public: */ static bool CopyADirectory(const kwsys_stl::string& source, const kwsys_stl::string& destination, bool always = true); - + /** * Remove a file */ static bool RemoveFile(const kwsys_stl::string& source); - + /** * Remove a directory */ @@ -593,7 +631,7 @@ public: */ static kwsys_stl::string FindFile( const kwsys_stl::string& name, - const kwsys_stl::vector& path = + const kwsys_stl::vector& path = kwsys_stl::vector(), bool no_system_path = false); @@ -602,7 +640,7 @@ public: */ static kwsys_stl::string FindDirectory( const kwsys_stl::string& name, - const kwsys_stl::vector& path = + const kwsys_stl::vector& path = kwsys_stl::vector(), bool no_system_path = false); @@ -631,17 +669,17 @@ public: static kwsys_stl::string FindLibrary( const kwsys_stl::string& name, const kwsys_stl::vector& path); - + /** * Return true if the file is a directory */ static bool FileIsDirectory(const kwsys_stl::string& name); - + /** * Return true if the file is a symlink */ static bool FileIsSymlink(const kwsys_stl::string& name); - + /** * Return true if the file has a given signature (first set of bytes) */ @@ -657,15 +695,15 @@ public: * The algorithm is simplistic, and should probably check for usual file * extensions, 'magic' signature, unicode, etc. */ - enum FileTypeEnum - { + enum FileTypeEnum + { FileTypeUnknown, FileTypeBinary, FileTypeText }; static SystemTools::FileTypeEnum DetectFileType( - const char* filename, - unsigned long length = 256, + const char* filename, + unsigned long length = 256, double percent_bin = 0.05); /** @@ -690,18 +728,18 @@ public: * 'filename_found' is assigned the fully qualified name/path of the file * if it is found (not touched otherwise). * If 'try_filename_dirs' is true, try to find the file using the - * components of its path, i.e. if we are looking for c:/foo/bar/bill.txt, + * components of its path, i.e. if we are looking for c:/foo/bar/bill.txt, * first look for bill.txt in 'dir', then in 'dir'/bar, then in 'dir'/foo/bar * etc. * Return true if the file was found, false otherwise. */ - static bool LocateFileInDir(const char *filename, - const char *dir, + static bool LocateFileInDir(const char *filename, + const char *dir, kwsys_stl::string& filename_found, int try_filename_dirs = 0); - /** compute the relative path from local to remote. local must - be a directory. remote can be a file or a directory. + /** compute the relative path from local to remote. local must + be a directory. remote can be a file or a directory. Both remote and local must be full paths. Basically, if you are in directory local and you want to access the file in remote what is the relative path to do that. For example: @@ -720,17 +758,27 @@ public: */ static long int CreationTime(const kwsys_stl::string& filename); + /** + * Visual C++ does not define mode_t (note that Borland does, however). + */ #if defined( _MSC_VER ) typedef unsigned short mode_t; #endif /** - * Get and set permissions of the file. + * Get and set permissions of the file. If honor_umask is set, the umask + * is queried and applied to the given permissions. Returns false if + * failure. + * + * WARNING: A non-thread-safe method is currently used to get the umask + * if a honor_umask parameter is set to true. */ static bool GetPermissions(const char* file, mode_t& mode); static bool GetPermissions(const kwsys_stl::string& file, mode_t& mode); - static bool SetPermissions(const char* file, mode_t mode); - static bool SetPermissions(const kwsys_stl::string& file, mode_t mode); + static bool SetPermissions( + const char* file, mode_t mode, bool honor_umask = false); + static bool SetPermissions( + const kwsys_stl::string& file, mode_t mode, bool honor_umask = false); /** ----------------------------------------------------------------- * Time Manipulation Routines @@ -891,11 +939,11 @@ public: * Return true if the string matches the format; false otherwise. */ static bool ParseURL( const kwsys_stl::string& URL, - kwsys_stl::string& protocol, - kwsys_stl::string& username, - kwsys_stl::string& password, - kwsys_stl::string& hostname, - kwsys_stl::string& dataport, + kwsys_stl::string& protocol, + kwsys_stl::string& username, + kwsys_stl::string& password, + kwsys_stl::string& hostname, + kwsys_stl::string& dataport, kwsys_stl::string& datapath ); private: @@ -936,7 +984,7 @@ private: */ static kwsys_stl::string FindName( const kwsys_stl::string& name, - const kwsys_stl::vector& path = + const kwsys_stl::vector& path = kwsys_stl::vector(), bool no_system_path = false); diff --git a/testProcess.c b/testProcess.c index d0e20c1..8fd3382 100644 --- a/testProcess.c +++ b/testProcess.c @@ -21,6 +21,7 @@ #endif #include +#include #include #include #include @@ -74,6 +75,16 @@ int runChild(const char* cmd[], int state, int exception, int value, static int test1(int argc, const char* argv[]) { + /* This is a very basic functional test of kwsysProcess. It is repeated + numerous times to verify that there are no resource leaks in kwsysProcess + that eventually lead to an error. Many versions of OS X will fail after + 256 leaked file handles, so 257 iterations seems to be a good test. On + the other hand, too many iterations will cause the test to time out - + especially if the test is instrumented with e.g. valgrind. + + If you have problems with this test timing out on your system, or want to + run more than 257 iterations, you can change the number of iterations by + setting the KWSYS_TEST_PROCESS_1_COUNT environment variable. */ (void)argc; (void)argv; fprintf(stdout, "Output on stdout from test returning 0.\n"); fprintf(stderr, "Output on stderr from test returning 0.\n"); @@ -557,6 +568,10 @@ int runChild(const char* cmd[], int state, int exception, int value, result = runChild2(kp, cmd, state, exception, value, share, output, delay, timeout, poll, disown, createNewGroup, interruptDelay); + if(result) + { + break; + } } kwsysProcess_Delete(kp); return result; @@ -660,13 +675,24 @@ int main(int argc, const char* argv[]) int delays[10] = {0, 0, 0, 0, 0, 1, 0, 0, 0, 0}; double timeouts[10] = {10, 10, 10, 30, 30, 10, -1, 10, 6, 4}; int polls[10] = {0, 0, 0, 0, 0, 0, 1, 0, 0, 0}; - int repeat[10] = {2, 1, 1, 1, 1, 1, 1, 1, 1, 1}; + int repeat[10] = {257, 1, 1, 1, 1, 1, 1, 1, 1, 1}; int createNewGroups[10] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 1}; unsigned int interruptDelays[10] = {0, 0, 0, 0, 0, 0, 0, 0, 3, 2}; int r; const char* cmd[4]; #ifdef _WIN32 char* argv0 = 0; +#endif + char* test1IterationsStr = getenv("KWSYS_TEST_PROCESS_1_COUNT"); + if(test1IterationsStr) + { + long int test1Iterations = strtol(test1IterationsStr, 0, 10); + if(test1Iterations > 10 && test1Iterations != LONG_MAX) + { + repeat[0] = (int)test1Iterations; + } + } +#ifdef _WIN32 if(n == 0 && (argv0 = strdup(argv[0]))) { /* Try converting to forward slashes to see if it works. */ diff --git a/testSystemTools.cxx b/testSystemTools.cxx index 7b5c025..bc9ca5e 100644 --- a/testSystemTools.cxx +++ b/testSystemTools.cxx @@ -30,6 +30,17 @@ #include #include /* strcmp */ +#if defined(_WIN32) && !defined(__CYGWIN__) +# include /* _umask (MSVC) / umask (Borland) */ +# ifdef _MSC_VER +# define umask _umask // Note this is still umask on Borland +# endif +#endif +#include /* umask (POSIX), _S_I* constants (Windows) */ +// Visual C++ does not define mode_t (note that Borland does, however). +#if defined( _MSC_VER ) +typedef unsigned short mode_t; +#endif //---------------------------------------------------------------------------- static const char* toUnixPaths[][2] = @@ -170,6 +181,135 @@ static bool CheckFileOperations() res = false; } + // Reset umask +#if defined(_WIN32) && !defined(__CYGWIN__) + // NOTE: Windows doesn't support toggling _S_IREAD. + mode_t fullMask = _S_IWRITE; +#else + // On a normal POSIX platform, we can toggle all permissions. + mode_t fullMask = S_IRWXU | S_IRWXG | S_IRWXO; +#endif + mode_t orig_umask = umask(fullMask); + + // Test file permissions without umask + mode_t origPerm, thisPerm; + if (!kwsys::SystemTools::GetPermissions(testNewFile, origPerm)) + { + kwsys_ios::cerr + << "Problem with GetPermissions (1) for: " + << testNewFile << kwsys_ios::endl; + res = false; + } + + if (!kwsys::SystemTools::SetPermissions(testNewFile, 0)) + { + kwsys_ios::cerr + << "Problem with SetPermissions (1) for: " + << testNewFile << kwsys_ios::endl; + res = false; + } + + if (!kwsys::SystemTools::GetPermissions(testNewFile, thisPerm)) + { + kwsys_ios::cerr + << "Problem with GetPermissions (2) for: " + << testNewFile << kwsys_ios::endl; + res = false; + } + + if ((thisPerm & fullMask) != 0) + { + kwsys_ios::cerr + << "SetPermissions failed to set permissions (1) for: " + << testNewFile << ": actual = " << thisPerm << "; expected = " + << 0 << kwsys_ios::endl; + res = false; + } + + // While we're at it, check proper TestFileAccess functionality. + if (kwsys::SystemTools::TestFileAccess(testNewFile, + kwsys::TEST_FILE_WRITE)) + { + kwsys_ios::cerr + << "TestFileAccess incorrectly indicated that this is a writable file:" + << testNewFile << kwsys_ios::endl; + res = false; + } + + if (!kwsys::SystemTools::TestFileAccess(testNewFile, + kwsys::TEST_FILE_OK)) + { + kwsys_ios::cerr + << "TestFileAccess incorrectly indicated that this file does not exist:" + << testNewFile << kwsys_ios::endl; + res = false; + } + + // Test restoring/setting full permissions. + if (!kwsys::SystemTools::SetPermissions(testNewFile, fullMask)) + { + kwsys_ios::cerr + << "Problem with SetPermissions (2) for: " + << testNewFile << kwsys_ios::endl; + res = false; + } + + if (!kwsys::SystemTools::GetPermissions(testNewFile, thisPerm)) + { + kwsys_ios::cerr + << "Problem with GetPermissions (3) for: " + << testNewFile << kwsys_ios::endl; + res = false; + } + + if ((thisPerm & fullMask) != fullMask) + { + kwsys_ios::cerr + << "SetPermissions failed to set permissions (2) for: " + << testNewFile << ": actual = " << thisPerm << "; expected = " + << fullMask << kwsys_ios::endl; + res = false; + } + + // Test setting file permissions while honoring umask + if (!kwsys::SystemTools::SetPermissions(testNewFile, fullMask, true)) + { + kwsys_ios::cerr + << "Problem with SetPermissions (3) for: " + << testNewFile << kwsys_ios::endl; + res = false; + } + + if (!kwsys::SystemTools::GetPermissions(testNewFile, thisPerm)) + { + kwsys_ios::cerr + << "Problem with GetPermissions (4) for: " + << testNewFile << kwsys_ios::endl; + res = false; + } + + if ((thisPerm & fullMask) != 0) + { + kwsys_ios::cerr + << "SetPermissions failed to honor umask for: " + << testNewFile << ": actual = " << thisPerm << "; expected = " + << 0 << kwsys_ios::endl; + res = false; + } + + // Restore umask + umask(orig_umask); + + // Restore file permissions + if (!kwsys::SystemTools::SetPermissions(testNewFile, origPerm)) + { + kwsys_ios::cerr + << "Problem with SetPermissions (4) for: " + << testNewFile << kwsys_ios::endl; + res = false; + } + + // Remove the test file if (!kwsys::SystemTools::RemoveFile(testNewFile)) { kwsys_ios::cerr @@ -271,48 +411,48 @@ static bool CheckStringOperations() kwsys_ios::cerr << "Problem with CapitalizedWords " << '"' << test << '"' << kwsys_ios::endl; - res = false; + res = false; } test = "Mary Had A Little Lamb."; - if (kwsys::SystemTools::UnCapitalizedWords(test) != + if (kwsys::SystemTools::UnCapitalizedWords(test) != "mary had a little lamb.") { kwsys_ios::cerr << "Problem with UnCapitalizedWords " << '"' << test << '"' << kwsys_ios::endl; - res = false; + res = false; } test = "MaryHadTheLittleLamb."; - if (kwsys::SystemTools::AddSpaceBetweenCapitalizedWords(test) != + if (kwsys::SystemTools::AddSpaceBetweenCapitalizedWords(test) != "Mary Had The Little Lamb.") { kwsys_ios::cerr << "Problem with AddSpaceBetweenCapitalizedWords " << '"' << test << '"' << kwsys_ios::endl; - res = false; + res = false; } - char * cres = + char * cres = kwsys::SystemTools::AppendStrings("Mary Had A"," Little Lamb."); if (strcmp(cres,"Mary Had A Little Lamb.")) { kwsys_ios::cerr << "Problem with AppendStrings " << "\"Mary Had A\" \" Little Lamb.\"" << kwsys_ios::endl; - res = false; + res = false; } delete [] cres; - cres = + cres = kwsys::SystemTools::AppendStrings("Mary Had"," A ","Little Lamb."); if (strcmp(cres,"Mary Had A Little Lamb.")) { kwsys_ios::cerr << "Problem with AppendStrings " << "\"Mary Had\" \" A \" \"Little Lamb.\"" << kwsys_ios::endl; - res = false; + res = false; } delete [] cres; @@ -321,28 +461,28 @@ static bool CheckStringOperations() kwsys_ios::cerr << "Problem with CountChar " << "\"Mary Had A Little Lamb.\"" << kwsys_ios::endl; - res = false; + res = false; } - cres = + cres = kwsys::SystemTools::RemoveChars("Mary Had A Little Lamb.","aeiou"); if (strcmp(cres,"Mry Hd A Lttl Lmb.")) { kwsys_ios::cerr << "Problem with RemoveChars " << "\"Mary Had A Little Lamb.\"" << kwsys_ios::endl; - res = false; + res = false; } delete [] cres; - cres = + cres = kwsys::SystemTools::RemoveCharsButUpperHex("Mary Had A Little Lamb."); if (strcmp(cres,"A")) { kwsys_ios::cerr << "Problem with RemoveCharsButUpperHex " << "\"Mary Had A Little Lamb.\"" << kwsys_ios::endl; - res = false; + res = false; } delete [] cres; @@ -354,7 +494,7 @@ static bool CheckStringOperations() kwsys_ios::cerr << "Problem with ReplaceChars " << "\"Mary Had A Little Lamb.\"" << kwsys_ios::endl; - res = false; + res = false; } delete [] cres2; @@ -364,7 +504,7 @@ static bool CheckStringOperations() kwsys_ios::cerr << "Problem with StringStartsWith " << "\"Mary Had A Little Lamb.\"" << kwsys_ios::endl; - res = false; + res = false; } if (!kwsys::SystemTools::StringEndsWith("Mary Had A Little Lamb.", @@ -373,7 +513,7 @@ static bool CheckStringOperations() kwsys_ios::cerr << "Problem with StringEndsWith " << "\"Mary Had A Little Lamb.\"" << kwsys_ios::endl; - res = false; + res = false; } cres = kwsys::SystemTools::DuplicateString("Mary Had A Little Lamb."); @@ -382,18 +522,18 @@ static bool CheckStringOperations() kwsys_ios::cerr << "Problem with DuplicateString " << "\"Mary Had A Little Lamb.\"" << kwsys_ios::endl; - res = false; + res = false; } delete [] cres; test = "Mary Had A Little Lamb."; - if (kwsys::SystemTools::CropString(test,13) != + if (kwsys::SystemTools::CropString(test,13) != "Mary ...Lamb.") { kwsys_ios::cerr << "Problem with CropString " << "\"Mary Had A Little Lamb.\"" << kwsys_ios::endl; - res = false; + res = false; } kwsys_stl::vector lines; @@ -515,36 +655,36 @@ static bool CheckStringOperations() #endif if (kwsys::SystemTools::ConvertToWindowsOutputPath - ("L://Local Mojo/Hex Power Pack/Iffy Voodoo") != + ("L://Local Mojo/Hex Power Pack/Iffy Voodoo") != "\"L:\\Local Mojo\\Hex Power Pack\\Iffy Voodoo\"") { kwsys_ios::cerr << "Problem with ConvertToWindowsOutputPath " << "\"L://Local Mojo/Hex Power Pack/Iffy Voodoo\"" << kwsys_ios::endl; - res = false; + res = false; } - + if (kwsys::SystemTools::ConvertToWindowsOutputPath - ("//grayson/Local Mojo/Hex Power Pack/Iffy Voodoo") != + ("//grayson/Local Mojo/Hex Power Pack/Iffy Voodoo") != "\"\\\\grayson\\Local Mojo\\Hex Power Pack\\Iffy Voodoo\"") { kwsys_ios::cerr << "Problem with ConvertToWindowsOutputPath " << "\"//grayson/Local Mojo/Hex Power Pack/Iffy Voodoo\"" << kwsys_ios::endl; - res = false; + res = false; } if (kwsys::SystemTools::ConvertToUnixOutputPath - ("//Local Mojo/Hex Power Pack/Iffy Voodoo") != + ("//Local Mojo/Hex Power Pack/Iffy Voodoo") != "//Local\\ Mojo/Hex\\ Power\\ Pack/Iffy\\ Voodoo") { kwsys_ios::cerr << "Problem with ConvertToUnixOutputPath " << "\"//Local Mojo/Hex Power Pack/Iffy Voodoo\"" << kwsys_ios::endl; - res = false; + res = false; } return res; @@ -672,7 +812,7 @@ int testSystemTools(int, char*[]) for (cc = 0; checkEscapeChars[cc][0]; cc ++ ) { - res &= CheckEscapeChars(checkEscapeChars[cc][0], checkEscapeChars[cc][1], + res &= CheckEscapeChars(checkEscapeChars[cc][0], checkEscapeChars[cc][1], *checkEscapeChars[cc][2], checkEscapeChars[cc][3]); } ----------------------------------------------------------------------- Summary of changes: Source/kwsys/CMakeEmptyInputFile.in | 1 - Source/kwsys/CMakeLists.txt | 12 ++- Source/kwsys/SystemTools.cxx | 71 +++++++++++-- Source/kwsys/SystemTools.hxx.in | 156 ++++++++++++++++++---------- Source/kwsys/testProcess.c | 28 ++++- Source/kwsys/testSystemTools.cxx | 196 ++++++++++++++++++++++++++++++----- 6 files changed, 370 insertions(+), 94 deletions(-) delete mode 100644 Source/kwsys/CMakeEmptyInputFile.in hooks/post-receive -- CMake From chuck.atkins at kitware.com Mon Aug 31 11:13:58 2015 From: chuck.atkins at kitware.com (Chuck Atkins) Date: Mon, 31 Aug 2015 11:13:58 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2652-g8a72b18 Message-ID: <20150831151358.3A66EB3194@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 8a72b18cb37592bd896d12570cbe82787b9cdc74 (commit) via 293e9f7a61810ac30789e5f34b416125f327d03a (commit) from f83cd172f23d35bdf2552dfcc781914f7b46e968 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8a72b18cb37592bd896d12570cbe82787b9cdc74 commit 8a72b18cb37592bd896d12570cbe82787b9cdc74 Merge: f83cd17 293e9f7 Author: Chuck Atkins AuthorDate: Mon Aug 31 11:13:57 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 31 11:13:57 2015 -0400 Merge topic 'fix-link-search-start-logic' into next 293e9f7a cmComputeLinkInformation: Revert changes from 675ef165 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=293e9f7a61810ac30789e5f34b416125f327d03a commit 293e9f7a61810ac30789e5f34b416125f327d03a Author: Chuck Atkins AuthorDate: Mon Aug 31 11:13:18 2015 -0400 Commit: Chuck Atkins CommitDate: Mon Aug 31 11:13:18 2015 -0400 cmComputeLinkInformation: Revert changes from 675ef165 diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 686052c..0269db9 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -522,10 +522,9 @@ bool cmComputeLinkInformation::Compute() // libraries are found. const char* lss = this->Target->Target->GetProperty("LINK_SEARCH_END_STATIC"); - if(lss) + if(cmSystemTools::IsOn(lss)) { - this->SetCurrentLinkType( - cmSystemTools::IsOn(lss) ? LinkStatic : LinkShared); + this->SetCurrentLinkType(LinkStatic); } else { @@ -863,8 +862,7 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo() const char* lss = this->Target->Target->GetProperty("LINK_SEARCH_START_STATIC"); this->StartLinkType = cmSystemTools::IsOn(lss)? LinkStatic : LinkShared; - this->CurrentLinkType = LinkShared; - this->SetCurrentLinkType(this->StartLinkType); + this->CurrentLinkType = this->StartLinkType); } //---------------------------------------------------------------------------- ----------------------------------------------------------------------- Summary of changes: Source/cmComputeLinkInformation.cxx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) hooks/post-receive -- CMake From chuck.atkins at kitware.com Mon Aug 31 11:20:38 2015 From: chuck.atkins at kitware.com (Chuck Atkins) Date: Mon, 31 Aug 2015 11:20:38 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2654-gcf3138b Message-ID: <20150831152038.2DB4CB344C@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via cf3138b2ec9150f33bf1fc9c5893a3b8135f8605 (commit) via 586a95d01184aa2300a3a32572c688cbf648106c (commit) from 8a72b18cb37592bd896d12570cbe82787b9cdc74 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cf3138b2ec9150f33bf1fc9c5893a3b8135f8605 commit cf3138b2ec9150f33bf1fc9c5893a3b8135f8605 Merge: 8a72b18 586a95d Author: Chuck Atkins AuthorDate: Mon Aug 31 11:20:37 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 31 11:20:37 2015 -0400 Merge topic 'fix-link-search-start-logic' into next 586a95d0 cmComputeLinkInformation: Fix bad logic for LINK_SEARCH_*STATIC http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=586a95d01184aa2300a3a32572c688cbf648106c commit 586a95d01184aa2300a3a32572c688cbf648106c Author: Chuck Atkins AuthorDate: Sun Aug 30 17:44:01 2015 -0400 Commit: Chuck Atkins CommitDate: Mon Aug 31 11:14:38 2015 -0400 cmComputeLinkInformation: Fix bad logic for LINK_SEARCH_*STATIC In commit 675ef165, a bug was introduced that treated the LINK_SEARCH_START_STATIC and LINK_SEARCH_END_STATIC as ternary properties instead of boolean. This reverts those changes back to the previous behavior in cmComputeLinkInformation. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 4b70e5e..0269db9 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -522,10 +522,9 @@ bool cmComputeLinkInformation::Compute() // libraries are found. const char* lss = this->Target->Target->GetProperty("LINK_SEARCH_END_STATIC"); - if(lss) + if(cmSystemTools::IsOn(lss)) { - this->SetCurrentLinkType( - cmSystemTools::IsOn(lss) ? LinkStatic : LinkShared); + this->SetCurrentLinkType(LinkStatic); } else { @@ -863,8 +862,7 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo() const char* lss = this->Target->Target->GetProperty("LINK_SEARCH_START_STATIC"); this->StartLinkType = cmSystemTools::IsOn(lss)? LinkStatic : LinkShared; - this->CurrentLinkType = LinkUnknown; - this->SetCurrentLinkType(this->StartLinkType); + this->CurrentLinkType = this->StartLinkType); } //---------------------------------------------------------------------------- ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From chuck.atkins at kitware.com Mon Aug 31 11:22:25 2015 From: chuck.atkins at kitware.com (Chuck Atkins) Date: Mon, 31 Aug 2015 11:22:25 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2656-g203306c Message-ID: <20150831152226.00DE7B35C7@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 203306cfc18d29686c6f6742d7960356c044438d (commit) via 9746b09d4eac6252e4edca12b204284367af8c93 (commit) from cf3138b2ec9150f33bf1fc9c5893a3b8135f8605 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=203306cfc18d29686c6f6742d7960356c044438d commit 203306cfc18d29686c6f6742d7960356c044438d Merge: cf3138b 9746b09 Author: Chuck Atkins AuthorDate: Mon Aug 31 11:22:25 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 31 11:22:25 2015 -0400 Merge topic 'fix-link-search-start-logic' into next 9746b09d cmComputeLinkInformation: Fix build error http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9746b09d4eac6252e4edca12b204284367af8c93 commit 9746b09d4eac6252e4edca12b204284367af8c93 Author: Chuck Atkins AuthorDate: Mon Aug 31 11:21:57 2015 -0400 Commit: Chuck Atkins CommitDate: Mon Aug 31 11:21:57 2015 -0400 cmComputeLinkInformation: Fix build error diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 0269db9..d35b566 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -862,7 +862,7 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo() const char* lss = this->Target->Target->GetProperty("LINK_SEARCH_START_STATIC"); this->StartLinkType = cmSystemTools::IsOn(lss)? LinkStatic : LinkShared; - this->CurrentLinkType = this->StartLinkType); + this->CurrentLinkType = this->StartLinkType; } //---------------------------------------------------------------------------- ----------------------------------------------------------------------- Summary of changes: Source/cmComputeLinkInformation.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From chuck.atkins at kitware.com Mon Aug 31 11:22:51 2015 From: chuck.atkins at kitware.com (Chuck Atkins) Date: Mon, 31 Aug 2015 11:22:51 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2658-g71dd6bf Message-ID: <20150831152251.75A10B368C@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 71dd6bfbbdcc4a91322ae233021c91d6899c2691 (commit) via f3eb5815cc507f0bd07db36c57dda10033db1436 (commit) from 203306cfc18d29686c6f6742d7960356c044438d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=71dd6bfbbdcc4a91322ae233021c91d6899c2691 commit 71dd6bfbbdcc4a91322ae233021c91d6899c2691 Merge: 203306c f3eb581 Author: Chuck Atkins AuthorDate: Mon Aug 31 11:22:50 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 31 11:22:50 2015 -0400 Merge topic 'fix-link-search-start-logic' into next f3eb5815 cmComputeLinkInformation: Fix bad logic for LINK_SEARCH_*STATIC http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f3eb5815cc507f0bd07db36c57dda10033db1436 commit f3eb5815cc507f0bd07db36c57dda10033db1436 Author: Chuck Atkins AuthorDate: Sun Aug 30 17:44:01 2015 -0400 Commit: Chuck Atkins CommitDate: Mon Aug 31 11:22:36 2015 -0400 cmComputeLinkInformation: Fix bad logic for LINK_SEARCH_*STATIC In commit 675ef165, a bug was introduced that treated the LINK_SEARCH_START_STATIC and LINK_SEARCH_END_STATIC as ternary properties instead of boolean. This reverts those changes back to the previous behavior in cmComputeLinkInformation. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 4b70e5e..d35b566 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -522,10 +522,9 @@ bool cmComputeLinkInformation::Compute() // libraries are found. const char* lss = this->Target->Target->GetProperty("LINK_SEARCH_END_STATIC"); - if(lss) + if(cmSystemTools::IsOn(lss)) { - this->SetCurrentLinkType( - cmSystemTools::IsOn(lss) ? LinkStatic : LinkShared); + this->SetCurrentLinkType(LinkStatic); } else { @@ -863,8 +862,7 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo() const char* lss = this->Target->Target->GetProperty("LINK_SEARCH_START_STATIC"); this->StartLinkType = cmSystemTools::IsOn(lss)? LinkStatic : LinkShared; - this->CurrentLinkType = LinkUnknown; - this->SetCurrentLinkType(this->StartLinkType); + this->CurrentLinkType = this->StartLinkType; } //---------------------------------------------------------------------------- ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 31 13:10:04 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 31 Aug 2015 13:10:04 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2660-g5ce9fe1 Message-ID: <20150831171004.7E7A6B2448@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 5ce9fe1efde6b17acdd0b3ae1dac0b65c0254893 (commit) via 9e21b01a4d4781cdcfb8990bdf72a11c83da3887 (commit) from 71dd6bfbbdcc4a91322ae233021c91d6899c2691 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5ce9fe1efde6b17acdd0b3ae1dac0b65c0254893 commit 5ce9fe1efde6b17acdd0b3ae1dac0b65c0254893 Merge: 71dd6bf 9e21b01 Author: Brad King AuthorDate: Mon Aug 31 13:10:03 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 31 13:10:03 2015 -0400 Merge topic 'add-link-search-static-properties-defaults' into next 9e21b01a Revert LINK_SEARCH_{START,END}_STATIC behavior change http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9e21b01a4d4781cdcfb8990bdf72a11c83da3887 commit 9e21b01a4d4781cdcfb8990bdf72a11c83da3887 Author: Brad King AuthorDate: Fri Aug 28 11:45:45 2015 -0400 Commit: Brad King CommitDate: Mon Aug 31 13:08:53 2015 -0400 Revert LINK_SEARCH_{START,END}_STATIC behavior change The changes to cmComputeLinkInformation.cxx in commit 675ef165 (Allow LINK_SEARCH_{START,END}_STATIC props to have default values, 2015-08-07) are unrelated to the feature added by that change and are incorrect. They lead to cases of extra -Bdynamic flags. Revert them. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 12dddd2..c16472e 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -522,10 +522,9 @@ bool cmComputeLinkInformation::Compute() // libraries are found. const char* lss = this->Target->Target->GetProperty("LINK_SEARCH_END_STATIC"); - if(lss) + if(cmSystemTools::IsOn(lss)) { - this->SetCurrentLinkType( - cmSystemTools::IsOn(lss) ? LinkStatic : LinkShared); + this->SetCurrentLinkType(LinkStatic); } else { @@ -863,8 +862,7 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo() const char* lss = this->Target->Target->GetProperty("LINK_SEARCH_START_STATIC"); this->StartLinkType = cmSystemTools::IsOn(lss)? LinkStatic : LinkShared; - this->CurrentLinkType = LinkUnknown; - this->SetCurrentLinkType(this->StartLinkType); + this->CurrentLinkType = this->StartLinkType; } //---------------------------------------------------------------------------- ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From zack.galbreath at kitware.com Mon Aug 31 14:58:29 2015 From: zack.galbreath at kitware.com (Zack Galbreath) Date: Mon, 31 Aug 2015 14:58:29 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2662-gb104667 Message-ID: <20150831185829.E4571B3766@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via b104667b9132bdc13fe42bde140378d579bfb3e6 (commit) via 8dc7f6c425ebdf1db8280e3b5f64a52729db64da (commit) from 5ce9fe1efde6b17acdd0b3ae1dac0b65c0254893 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b104667b9132bdc13fe42bde140378d579bfb3e6 commit b104667b9132bdc13fe42bde140378d579bfb3e6 Merge: 5ce9fe1 8dc7f6c Author: Zack Galbreath AuthorDate: Mon Aug 31 14:58:27 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 31 14:58:27 2015 -0400 Merge topic 'jacoco_find_files' into next 8dc7f6c4 Make Jacoco parser better at finding source files http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8dc7f6c425ebdf1db8280e3b5f64a52729db64da commit 8dc7f6c425ebdf1db8280e3b5f64a52729db64da Author: Zack Galbreath AuthorDate: Fri Aug 28 13:35:47 2015 -0400 Commit: Zack Galbreath CommitDate: Fri Aug 28 13:38:26 2015 -0400 Make Jacoco parser better at finding source files Instead of searching for source files in a couple hard-coded locations, we now search the source and binary directory for files matching both the name of the covered file and its package directory structure. diff --git a/Source/CTest/cmParseJacocoCoverage.cxx b/Source/CTest/cmParseJacocoCoverage.cxx index 31ad9fe..47e3b32 100644 --- a/Source/CTest/cmParseJacocoCoverage.cxx +++ b/Source/CTest/cmParseJacocoCoverage.cxx @@ -15,11 +15,9 @@ class cmParseJacocoCoverage::XMLParser: public cmXMLParser XMLParser(cmCTest* ctest, cmCTestCoverageHandlerContainer& cont) : CTest(ctest), Coverage(cont) { + this->FilePath = ""; + this->PackagePath = ""; this->PackageName = ""; - this->ModuleName = ""; - this->FileName = ""; - this->CurFileName = ""; - this->FilePaths.push_back(this->Coverage.SourceDir); } virtual ~XMLParser() @@ -38,58 +36,46 @@ class cmParseJacocoCoverage::XMLParser: public cmXMLParser if(name == "package") { this->PackageName = atts[1]; - std::string FilePath = this->Coverage.SourceDir + - "/" + this->ModuleName + "/src/main/java/" + - this->PackageName; - this->FilePaths.push_back(FilePath); - FilePath = this->Coverage.SourceDir + - "/src/main/java/" + this->PackageName; - this->FilePaths.push_back(FilePath); + this->PackagePath = ""; } else if(name == "sourcefile") { - this->FileName = atts[1]; - cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, - "Reading file: " << this->FileName << std::endl, - this->Coverage.Quiet); - for(size_t i=0;i < FilePaths.size();i++) - { - std::string finalpath = FilePaths[i] + "/" + this->FileName; - if(cmSystemTools::FileExists(finalpath.c_str())) - { - this->CurFileName = finalpath; - break; - } - } - cmsys::ifstream fin(this->CurFileName.c_str()); - if(this->CurFileName == "" || !fin ) + std::string fileName = atts[1]; + + if (this->PackagePath == "") { - this->CurFileName = this->Coverage.BinaryDir + "/" + - this->FileName; - fin.open(this->CurFileName.c_str()); - if (!fin) + if(!this->FindPackagePath(fileName)) { - cmCTestLog(this->CTest, ERROR_MESSAGE, - "Jacoco Coverage: Error opening " << this->CurFileName - << std::endl); - this->Coverage.Error++; + cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot find file: " + << this->PackageName << "/" << fileName << std::endl); + this->Coverage.Error++; + return; } } - std::string line; - FileLinesType& curFileLines = - this->Coverage.TotalCoverage[this->CurFileName]; - if(fin) - { - curFileLines.push_back(-1); - } - while(cmSystemTools::GetLineFromStream(fin, line)) + + cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + "Reading file: " << fileName << std::endl, + this->Coverage.Quiet); + + this->FilePath = this->PackagePath + "/" + fileName; + cmsys::ifstream fin(this->FilePath.c_str()); + if (!fin) { - curFileLines.push_back(-1); + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Jacoco Coverage: Error opening " << this->FilePath + << std::endl); + } + std::string line; + FileLinesType& curFileLines = + this->Coverage.TotalCoverage[this->FilePath]; + if(fin) + { + curFileLines.push_back(-1); + } + while(cmSystemTools::GetLineFromStream(fin, line)) + { + curFileLines.push_back(-1); } - } - else if(name == "report") - { - this->ModuleName=atts[1]; } else if(name == "line") { @@ -109,7 +95,7 @@ class cmParseJacocoCoverage::XMLParser: public cmXMLParser if (ci > -1 && nr > 0) { FileLinesType& curFileLines= - this->Coverage.TotalCoverage[this->CurFileName]; + this->Coverage.TotalCoverage[this->FilePath]; if(!curFileLines.empty()) { curFileLines[nr-1] = ci; @@ -121,12 +107,61 @@ class cmParseJacocoCoverage::XMLParser: public cmXMLParser } } + virtual bool FindPackagePath(const std::string fileName) + { + // Search for the source file in the source directory. + if (this->PackagePathFound(fileName, this->Coverage.SourceDir)) + { + return true; + } + + // If not found there, check the binary directory. + if (this->PackagePathFound(fileName, this->Coverage.BinaryDir)) + { + return true; + } + return false; + } + + virtual bool PackagePathFound(const std::string fileName, + const std::string baseDir) + { + // Search for the file in the baseDir and its subdirectories. + std::string packageGlob = baseDir; + packageGlob += "/"; + packageGlob += fileName; + cmsys::Glob gl; + gl.RecurseOn(); + gl.RecurseThroughSymlinksOn(); + gl.FindFiles(packageGlob); + std::vector const& files = gl.GetFiles(); + if (files.size() == 0) + { + return false; + } + + // Check if any of the locations found match our package. + for(std::vector::const_iterator fi = files.begin(); + fi != files.end(); ++fi) + { + std::string dir = cmsys::SystemTools::GetParentDirectory(*fi); + if (cmsys::SystemTools::StringEndsWith(dir, this->PackageName.c_str())) + { + cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + "Found package directory for " << fileName << + ": " << dir << std::endl, + this->Coverage.Quiet); + this->PackagePath = dir; + return true; + } + } + return false; + } + private: + std::string FilePath; + std::string PackagePath; std::string PackageName; - std::string FileName; - std::string ModuleName; - std::string CurFileName; - std::vector FilePaths; typedef cmCTestCoverageHandlerContainer::SingleFileCoverageVector FileLinesType; cmCTest* CTest; ----------------------------------------------------------------------- Summary of changes: Source/CTest/cmParseJacocoCoverage.cxx | 139 ++++++++++++++++++++------------ 1 file changed, 87 insertions(+), 52 deletions(-) hooks/post-receive -- CMake From gjasny at googlemail.com Mon Aug 31 15:06:56 2015 From: gjasny at googlemail.com (Gregor Jasny) Date: Mon, 31 Aug 2015 15:06:56 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2666-g70c864a Message-ID: <20150831190656.33A2EB363B@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 70c864ae8ffec43956e751a2ab600862b4fdac7d (commit) via ad262917d96aa4d6faeff3c9dfecf684cebbe123 (commit) via 48fe617e667d2e6b1e471cfb56346de51f984ba5 (commit) via d2c2319d6479d4319ef298f6178b00e953a9b179 (commit) from b104667b9132bdc13fe42bde140378d579bfb3e6 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=70c864ae8ffec43956e751a2ab600862b4fdac7d commit 70c864ae8ffec43956e751a2ab600862b4fdac7d Merge: b104667 ad26291 Author: Gregor Jasny AuthorDate: Mon Aug 31 15:06:54 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 31 15:06:54 2015 -0400 Merge topic 'fix-ios-install' into next ad262917 Xcode: Add unit test for iOS project install (#12506) 48fe617e Fix installation of iOS targets (#12506) d2c2319d Replace CMAKE_XCODE_EFFECTIVE_PLATFORMS with call to PlatformIsAppleIos http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ad262917d96aa4d6faeff3c9dfecf684cebbe123 commit ad262917d96aa4d6faeff3c9dfecf684cebbe123 Author: Gregor Jasny AuthorDate: Sat Aug 15 22:37:35 2015 +0200 Commit: Gregor Jasny CommitDate: Wed Aug 26 20:54:52 2015 +0200 Xcode: Add unit test for iOS project install (#12506) diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake index ef81739..382c990 100644 --- a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake @@ -11,6 +11,20 @@ endif() # Use a single build tree for a few tests without cleaning. if(NOT XCODE_VERSION VERSION_LESS 5) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeInstallIOS-build) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_BINARY_DIR}/ios_install") + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake(XcodeInstallIOS) + run_cmake_command(XcodeInstallIOS-install ${CMAKE_COMMAND} --build . --target install) + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) + unset(RunCMake_TEST_OPTIONS) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeBundlesOSX-build) set(RunCMake_TEST_NO_CLEAN 1) set(RunCMake_TEST_OPTIONS "-DTEST_IOS=OFF") diff --git a/Tests/RunCMake/XcodeProject/XcodeInstallIOS-install-stdout.txt b/Tests/RunCMake/XcodeProject/XcodeInstallIOS-install-stdout.txt new file mode 100644 index 0000000..f2478be --- /dev/null +++ b/Tests/RunCMake/XcodeProject/XcodeInstallIOS-install-stdout.txt @@ -0,0 +1,2 @@ +-- Install configuration: .* +-- Installing: .*/ios_install/lib/libfoo.a diff --git a/Tests/RunCMake/XcodeProject/XcodeInstallIOS.cmake b/Tests/RunCMake/XcodeProject/XcodeInstallIOS.cmake new file mode 100644 index 0000000..a797410 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/XcodeInstallIOS.cmake @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 2.8.5) + +project(XcodeInstallIOS) + +set(CMAKE_OSX_SYSROOT iphoneos) +set(XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") +set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO") + +set(CMAKE_OSX_ARCHITECTURES "armv7;i386") + +add_library(foo STATIC foo.cpp) +install(TARGETS foo ARCHIVE DESTINATION lib) diff --git a/Tests/RunCMake/XcodeProject/foo.cpp b/Tests/RunCMake/XcodeProject/foo.cpp new file mode 100644 index 0000000..2fb55ee --- /dev/null +++ b/Tests/RunCMake/XcodeProject/foo.cpp @@ -0,0 +1 @@ +void foo() { } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=48fe617e667d2e6b1e471cfb56346de51f984ba5 commit 48fe617e667d2e6b1e471cfb56346de51f984ba5 Author: Gregor Jasny AuthorDate: Thu Aug 13 13:03:02 2015 +0300 Commit: Gregor Jasny CommitDate: Tue Aug 25 21:53:51 2015 +0200 Fix installation of iOS targets (#12506) Since cmTarget::ComputeOutputDir results can be used in CMake code of script cmake_install.cmake and in Xcode internals, string ${EFFECTIVE_PLATFORM_NAME} should be used instead of $(EFFECTIVE_PLATFORM_NAME) because it works for both. Value of CMAKE_CFG_INTDIR can't be used in BUILD_TYPE argument of install command since it contains $(EFFECTIVE_PLATFORM_NAME) (e.g. equals to `Release-iphoneos`, `Debug-iphoneos`, etc.). diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 503c455..40f1fcf 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2427,7 +2427,17 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) if ( cmakeCfgIntDir && *cmakeCfgIntDir && cmakeCfgIntDir[0] != '.' ) { std::string cfgArg = "-DBUILD_TYPE="; - cfgArg += mf->GetDefinition("CMAKE_CFG_INTDIR"); + bool iosPlatform = mf->PlatformIsAppleIos(); + if(iosPlatform) + { + cfgArg += "$(CONFIGURATION)"; + singleLine.push_back(cfgArg); + cfgArg = "-DEFFECTIVE_PLATFORM_NAME=$(EFFECTIVE_PLATFORM_NAME)"; + } + else + { + cfgArg += mf->GetDefinition("CMAKE_CFG_INTDIR"); + } singleLine.push_back(cfgArg); } singleLine.push_back("-P"); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index da314a6..d6d509c 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3568,7 +3568,7 @@ bool cmTarget::ComputeOutputDir(const std::string& config, { bool iosPlatform = this->Makefile->PlatformIsAppleIos(); std::string suffix = - usesDefaultOutputDir && iosPlatform ? "$(EFFECTIVE_PLATFORM_NAME)" : ""; + usesDefaultOutputDir && iosPlatform ? "${EFFECTIVE_PLATFORM_NAME}" : ""; this->Makefile->GetGlobalGenerator()-> AppendDirectoryForConfig("/", conf, suffix, out); } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d2c2319d6479d4319ef298f6178b00e953a9b179 commit d2c2319d6479d4319ef298f6178b00e953a9b179 Author: Gregor Jasny AuthorDate: Thu Aug 20 22:29:49 2015 +0200 Commit: Gregor Jasny CommitDate: Tue Aug 25 21:53:51 2015 +0200 Replace CMAKE_XCODE_EFFECTIVE_PLATFORMS with call to PlatformIsAppleIos Currently the CMAKE_XCODE_EFFECTIVE_PLATFORMS property acts only as a kind of toggle switch to enable iOS project layout features. But instead of relying on this undocumented property, better detect the presence of an iOS SDK directly. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 49b3239..da314a6 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3566,10 +3566,9 @@ bool cmTarget::ComputeOutputDir(const std::string& config, // The generator may add the configuration's subdirectory. if(!conf.empty()) { - const char *platforms = this->Makefile->GetDefinition( - "CMAKE_XCODE_EFFECTIVE_PLATFORMS"); + bool iosPlatform = this->Makefile->PlatformIsAppleIos(); std::string suffix = - usesDefaultOutputDir && platforms ? "$(EFFECTIVE_PLATFORM_NAME)" : ""; + usesDefaultOutputDir && iosPlatform ? "$(EFFECTIVE_PLATFORM_NAME)" : ""; this->Makefile->GetGlobalGenerator()-> AppendDirectoryForConfig("/", conf, suffix, out); } diff --git a/Tests/RunCMake/XcodeProject/XcodeBundles.cmake b/Tests/RunCMake/XcodeProject/XcodeBundles.cmake index d5cb51f..2cbccfa 100644 --- a/Tests/RunCMake/XcodeProject/XcodeBundles.cmake +++ b/Tests/RunCMake/XcodeProject/XcodeBundles.cmake @@ -6,7 +6,6 @@ enable_language(C) if(TEST_IOS) set(CMAKE_OSX_SYSROOT iphoneos) set(CMAKE_OSX_ARCHITECTURES "armv7") - set(CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos;-iphonesimulator") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO") endif(TEST_IOS) diff --git a/Tests/iOSNavApp/CMakeLists.txt b/Tests/iOSNavApp/CMakeLists.txt index 12c3ada..1fc33e0 100644 --- a/Tests/iOSNavApp/CMakeLists.txt +++ b/Tests/iOSNavApp/CMakeLists.txt @@ -3,7 +3,6 @@ project(NavApp3) set(CMAKE_OSX_SYSROOT iphoneos4.3) set(CMAKE_OSX_ARCHITECTURES "armv6;armv7;i386") -set(CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos;-iphonesimulator") include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ----------------------------------------------------------------------- Summary of changes: Source/cmGlobalGenerator.cxx | 12 +++++++++++- Source/cmTarget.cxx | 5 ++--- Tests/RunCMake/XcodeProject/RunCMakeTest.cmake | 14 ++++++++++++++ Tests/RunCMake/XcodeProject/XcodeBundles.cmake | 1 - .../XcodeProject/XcodeInstallIOS-install-stdout.txt | 2 ++ Tests/RunCMake/XcodeProject/XcodeInstallIOS.cmake | 12 ++++++++++++ Tests/RunCMake/XcodeProject/foo.cpp | 1 + Tests/iOSNavApp/CMakeLists.txt | 1 - 8 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 Tests/RunCMake/XcodeProject/XcodeInstallIOS-install-stdout.txt create mode 100644 Tests/RunCMake/XcodeProject/XcodeInstallIOS.cmake create mode 100644 Tests/RunCMake/XcodeProject/foo.cpp hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 31 16:25:50 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 31 Aug 2015 16:25:50 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2668-g1bc2c6d Message-ID: <20150831202550.7223EB381D@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via 1bc2c6d2dadfbbedb7dee9a2d2f2baa830866d13 (commit) via f4b633a3612d290d6986bbfc56ff2d69807a134b (commit) from 70c864ae8ffec43956e751a2ab600862b4fdac7d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1bc2c6d2dadfbbedb7dee9a2d2f2baa830866d13 commit 1bc2c6d2dadfbbedb7dee9a2d2f2baa830866d13 Merge: 70c864a f4b633a Author: Brad King AuthorDate: Mon Aug 31 16:25:49 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 31 16:25:49 2015 -0400 Merge topic 'release-scripts-osx-doc-dir' into next f4b633a3 Utilities/Release: Install docs in unversioned dir on OS X (#15692) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f4b633a3612d290d6986bbfc56ff2d69807a134b commit f4b633a3612d290d6986bbfc56ff2d69807a134b Author: Brad King AuthorDate: Mon Aug 31 16:22:46 2015 -0400 Commit: Brad King CommitDate: Mon Aug 31 16:24:38 2015 -0400 Utilities/Release: Install docs in unversioned dir on OS X (#15692) The CMake.app directory will never overlap with another version of CMake so we do not need to have a version number on the documentation directory. Configure our release binaries on OS X to place the documentation in an unversioned directory under CMake.app so that one can always use a path like /Applications/CMake.app/Contents/doc/cmake/html/index.html to visit the documentation even after updating CMake. diff --git a/Utilities/Release/dashmacmini2_release.cmake b/Utilities/Release/dashmacmini2_release.cmake index 01f5b8b..2802e47 100644 --- a/Utilities/Release/dashmacmini2_release.cmake +++ b/Utilities/Release/dashmacmini2_release.cmake @@ -9,6 +9,7 @@ set(CPACK_BINARY_GENERATORS "DragNDrop TGZ TZ") set(CPACK_DMG_FORMAT "UDBZ") #build using bzip2 for smaller package size set(INITIAL_CACHE " CMAKE_BUILD_TYPE:STRING=Release +CMAKE_DOC_DIR:PATH=doc/cmake CMAKE_OSX_ARCHITECTURES:STRING=ppc;i386 CMAKE_USE_OPENSSL:BOOL=ON OPENSSL_CRYPTO_LIBRARY:FILEPATH=/Users/kitware/openssl-1.0.1g-install/lib/libcrypto.a diff --git a/Utilities/Release/dashmacmini5_release.cmake b/Utilities/Release/dashmacmini5_release.cmake index be1dfa9..0278f28 100644 --- a/Utilities/Release/dashmacmini5_release.cmake +++ b/Utilities/Release/dashmacmini5_release.cmake @@ -14,6 +14,7 @@ OPENSSL_CRYPTO_LIBRARY:FILEPATH=/Users/kitware/openssl-1.0.1g-install/lib/libcry OPENSSL_INCLUDE_DIR:PATH=/Users/kitware/openssl-1.0.1g-install/include OPENSSL_SSL_LIBRARY:FILEPATH=/Users/kitware/openssl-1.0.1g-install/lib/libssl.a CMAKE_BUILD_TYPE:STRING=Release +CMAKE_DOC_DIR:PATH=doc/cmake CMAKE_OSX_ARCHITECTURES:STRING=x86_64 CMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.6 CMAKE_SKIP_BOOTSTRAP_TEST:STRING=TRUE ----------------------------------------------------------------------- Summary of changes: Utilities/Release/dashmacmini2_release.cmake | 1 + Utilities/Release/dashmacmini5_release.cmake | 1 + 2 files changed, 2 insertions(+) hooks/post-receive -- CMake From brad.king at kitware.com Mon Aug 31 16:37:45 2015 From: brad.king at kitware.com (Brad King) Date: Mon, 31 Aug 2015 16:37:45 -0400 (EDT) Subject: [Cmake-commits] CMake branch, next, updated. v3.3.1-2670-gb53baca Message-ID: <20150831203745.1543BB3892@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, next has been updated via b53baca15b6531a1f4c68f8bdbd1bdf10bc1ec94 (commit) via e0cf77b3109e74cbc4c050e9907dacc9f0f40f70 (commit) from 1bc2c6d2dadfbbedb7dee9a2d2f2baa830866d13 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b53baca15b6531a1f4c68f8bdbd1bdf10bc1ec94 commit b53baca15b6531a1f4c68f8bdbd1bdf10bc1ec94 Merge: 1bc2c6d e0cf77b Author: Brad King AuthorDate: Mon Aug 31 16:37:44 2015 -0400 Commit: CMake Topic Stage CommitDate: Mon Aug 31 16:37:44 2015 -0400 Merge topic 'vs-store-phone-cert-thumbs' into next e0cf77b3 cmSystemTools: Use CreateFileW explicitly to pass wchar_t path http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e0cf77b3109e74cbc4c050e9907dacc9f0f40f70 commit e0cf77b3109e74cbc4c050e9907dacc9f0f40f70 Author: Brad King AuthorDate: Mon Aug 31 16:32:17 2015 -0400 Commit: Brad King CommitDate: Mon Aug 31 16:33:46 2015 -0400 cmSystemTools: Use CreateFileW explicitly to pass wchar_t path The call to CreateFile added by commit ac0bb433 (VS: Windows Store/Phone package cert thumbprint, 2015-08-21) passes a wide character path explicitly so we should call CreateFileW directly. Otherwise it does not build without -DUNICODE (e.g. in bootstrap on MSYS). diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 583e1d0..0cbe15c 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1025,13 +1025,14 @@ std::string cmSystemTools::ComputeCertificateThumbprint( HCERTSTORE certStore = NULL; PCCERT_CONTEXT certContext = NULL; - HANDLE certFile = CreateFile(cmsys::Encoding::ToWide(source.c_str()).c_str(), - GENERIC_READ, - FILE_SHARE_READ, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); + HANDLE certFile = + CreateFileW(cmsys::Encoding::ToWide(source.c_str()).c_str(), + GENERIC_READ, + FILE_SHARE_READ, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); if (certFile != INVALID_HANDLE_VALUE && certFile != NULL) { ----------------------------------------------------------------------- Summary of changes: Source/cmSystemTools.cxx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) hooks/post-receive -- CMake